#define ATAPI_IDENTIFY 0xA1 /* identify drive */
#define SCSI_READ10 0x28 /* read from disk */
#define SCSI_SENSE 0x03 /* sense request */
-
-#define CD_SECTOR_SIZE 2048 /* sector size of a CD-ROM */
#endif /* ATAPI */
/* Interrupt request lines. */
#define SECTOR_SHIFT 9 /* for division */
#define SECTOR_MASK 511 /* and remainder */
+#define CD_SECTOR_SIZE 2048 /* sector size of a CD-ROM in bytes */
+
/* Size of the DMA buffer buffer in bytes. */
#define USE_EXTRA_DMA_BUF 0 /* usually not needed */
#define DMA_BUF_SIZE (DMA_SECTORS * SECTOR_SIZE)
* be used to read partition tables and such. Its absolute address is
* 'tmp_phys', the normal address is 'tmp_buf'.
*/
+ vir_bytes size;
- if(!(tmp_buf = alloc_contig(2*DMA_BUF_SIZE, AC_ALIGN4K, &tmp_phys)))
- panic("can't allocate tmp_buf: %d", DMA_BUF_SIZE);
+ if (tmp_buf == NULL) {
+ size = MAX(2*DMA_BUF_SIZE, CD_SECTOR_SIZE);
+
+ if(!(tmp_buf = alloc_contig(size, AC_ALIGN4K, &tmp_phys)))
+ panic("can't allocate tmp_buf: %lu", size);
+ }
}
/*===========================================================================*
unsigned long offset, struct part_entry *table));
FORWARD _PROTOTYPE( void sort, (struct part_entry *table) );
-#ifndef CD_SECTOR_SIZE
-#define CD_SECTOR_SIZE 2048
-#endif
-
/*============================================================================*
* partition *
*============================================================================*/
*/
iovec_t iovec1;
u64_t position;
- static unsigned char partbuf[CD_SECTOR_SIZE];
+
+ driver_init_buffer();
position = mul64u(offset, SECTOR_SIZE);
- iovec1.iov_addr = (vir_bytes) partbuf;
+ iovec1.iov_addr = (vir_bytes) tmp_buf;
iovec1.iov_size = CD_SECTOR_SIZE;
if ((*dp->dr_prepare)(device) != NULL) {
(void) (*dp->dr_transfer)(SELF, DEV_GATHER_S, position, &iovec1, 1);
if (iovec1.iov_size != 0) {
return 0;
}
- if (partbuf[510] != 0x55 || partbuf[511] != 0xAA) {
+ if (tmp_buf[510] != 0x55 || tmp_buf[511] != 0xAA) {
/* Invalid partition table. */
return 0;
}
- memcpy(table, (partbuf + PART_TABLE_OFF), NR_PARTITIONS * sizeof(table[0]));
+ memcpy(table, (tmp_buf + PART_TABLE_OFF), NR_PARTITIONS * sizeof(table[0]));
return 1;
}
if(flags & AC_ALIGN64K)
mmapflags |= MAP_ALIGN64K;
- /* First try to get memory with mmap. This is gauranteed
+ /* First try to get memory with mmap. This is guaranteed
* to be page-aligned, and we can tell VM it has to be
* pre-allocated and contiguous.
*/