libdriver: make partition code use a contiguous buffer
This commit is contained in:
parent
1b2c01db1b
commit
eeab8e0680
@ -170,8 +170,6 @@
|
|||||||
#define ATAPI_IDENTIFY 0xA1 /* identify drive */
|
#define ATAPI_IDENTIFY 0xA1 /* identify drive */
|
||||||
#define SCSI_READ10 0x28 /* read from disk */
|
#define SCSI_READ10 0x28 /* read from disk */
|
||||||
#define SCSI_SENSE 0x03 /* sense request */
|
#define SCSI_SENSE 0x03 /* sense request */
|
||||||
|
|
||||||
#define CD_SECTOR_SIZE 2048 /* sector size of a CD-ROM */
|
|
||||||
#endif /* ATAPI */
|
#endif /* ATAPI */
|
||||||
|
|
||||||
/* Interrupt request lines. */
|
/* Interrupt request lines. */
|
||||||
|
@ -83,6 +83,8 @@ _PROTOTYPE( int nop_ioctl, (struct driver *dp, message *m_ptr) );
|
|||||||
#define SECTOR_SHIFT 9 /* for division */
|
#define SECTOR_SHIFT 9 /* for division */
|
||||||
#define SECTOR_MASK 511 /* and remainder */
|
#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. */
|
/* Size of the DMA buffer buffer in bytes. */
|
||||||
#define USE_EXTRA_DMA_BUF 0 /* usually not needed */
|
#define USE_EXTRA_DMA_BUF 0 /* usually not needed */
|
||||||
#define DMA_BUF_SIZE (DMA_SECTORS * SECTOR_SIZE)
|
#define DMA_BUF_SIZE (DMA_SECTORS * SECTOR_SIZE)
|
||||||
|
@ -434,9 +434,14 @@ PUBLIC void driver_init_buffer(void)
|
|||||||
* be used to read partition tables and such. Its absolute address is
|
* be used to read partition tables and such. Its absolute address is
|
||||||
* 'tmp_phys', the normal address is 'tmp_buf'.
|
* 'tmp_phys', the normal address is 'tmp_buf'.
|
||||||
*/
|
*/
|
||||||
|
vir_bytes size;
|
||||||
|
|
||||||
if(!(tmp_buf = alloc_contig(2*DMA_BUF_SIZE, AC_ALIGN4K, &tmp_phys)))
|
if (tmp_buf == NULL) {
|
||||||
panic("can't allocate tmp_buf: %d", DMA_BUF_SIZE);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
|
@ -17,10 +17,6 @@ FORWARD _PROTOTYPE( int get_part_table, (struct driver *dp, int device,
|
|||||||
unsigned long offset, struct part_entry *table));
|
unsigned long offset, struct part_entry *table));
|
||||||
FORWARD _PROTOTYPE( void sort, (struct part_entry *table) );
|
FORWARD _PROTOTYPE( void sort, (struct part_entry *table) );
|
||||||
|
|
||||||
#ifndef CD_SECTOR_SIZE
|
|
||||||
#define CD_SECTOR_SIZE 2048
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*============================================================================*
|
/*============================================================================*
|
||||||
* partition *
|
* partition *
|
||||||
*============================================================================*/
|
*============================================================================*/
|
||||||
@ -158,10 +154,11 @@ struct part_entry *table; /* four entries */
|
|||||||
*/
|
*/
|
||||||
iovec_t iovec1;
|
iovec_t iovec1;
|
||||||
u64_t position;
|
u64_t position;
|
||||||
static unsigned char partbuf[CD_SECTOR_SIZE];
|
|
||||||
|
driver_init_buffer();
|
||||||
|
|
||||||
position = mul64u(offset, SECTOR_SIZE);
|
position = mul64u(offset, SECTOR_SIZE);
|
||||||
iovec1.iov_addr = (vir_bytes) partbuf;
|
iovec1.iov_addr = (vir_bytes) tmp_buf;
|
||||||
iovec1.iov_size = CD_SECTOR_SIZE;
|
iovec1.iov_size = CD_SECTOR_SIZE;
|
||||||
if ((*dp->dr_prepare)(device) != NULL) {
|
if ((*dp->dr_prepare)(device) != NULL) {
|
||||||
(void) (*dp->dr_transfer)(SELF, DEV_GATHER_S, position, &iovec1, 1);
|
(void) (*dp->dr_transfer)(SELF, DEV_GATHER_S, position, &iovec1, 1);
|
||||||
@ -169,11 +166,11 @@ struct part_entry *table; /* four entries */
|
|||||||
if (iovec1.iov_size != 0) {
|
if (iovec1.iov_size != 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (partbuf[510] != 0x55 || partbuf[511] != 0xAA) {
|
if (tmp_buf[510] != 0x55 || tmp_buf[511] != 0xAA) {
|
||||||
/* Invalid partition table. */
|
/* Invalid partition table. */
|
||||||
return 0;
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ void *alloc_contig(size_t len, int flags, phys_bytes *phys)
|
|||||||
if(flags & AC_ALIGN64K)
|
if(flags & AC_ALIGN64K)
|
||||||
mmapflags |= MAP_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
|
* to be page-aligned, and we can tell VM it has to be
|
||||||
* pre-allocated and contiguous.
|
* pre-allocated and contiguous.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user