reading path tables now, need to make kheap sooner or later
This commit is contained in:
@@ -7,18 +7,21 @@
|
||||
|
||||
uint8_t sector_buf[2048];
|
||||
void read_iso(ide_device_t* dev) {
|
||||
kprintf("Reading ISO Filesystem from CDROM Disk\n");
|
||||
|
||||
ide_read_blks(dev, 16, 1, sector_buf);
|
||||
if (sector_buf[0] != 1) {
|
||||
kprintf("Couldn't find PVD\n");
|
||||
int success = ide_read_blks(dev, 16, 1, sector_buf);
|
||||
if (!success) {
|
||||
kprintf("Failed to read PVD\n");
|
||||
return;
|
||||
}
|
||||
|
||||
iso_pvd_t pvd = *(iso_pvd_t*)sector_buf;
|
||||
if (sector_buf[0] != 1) {
|
||||
kprintf("Couldn't find PVD in sector 0x10\n");
|
||||
return;
|
||||
}
|
||||
|
||||
iso_pvd_t* pvd = (iso_pvd_t*)sector_buf;
|
||||
|
||||
char pvd_identifier[6];
|
||||
memcpy(pvd.header.identifier, pvd_identifier, 5);
|
||||
memcpy(pvd->header.identifier, pvd_identifier, 5);
|
||||
pvd_identifier[5] = 0;
|
||||
|
||||
if (strcmp(pvd_identifier, "CD001") > 0) {
|
||||
@@ -26,15 +29,32 @@ void read_iso(ide_device_t* dev) {
|
||||
return;
|
||||
}
|
||||
|
||||
char system_identifier[33];
|
||||
memcpy(&pvd.sys_ident[0], system_identifier, 32);
|
||||
system_identifier[32] = 0;
|
||||
if (strlen(system_identifier) > 0) {
|
||||
kprintf("System Identifier: %s\n", system_identifier);
|
||||
}
|
||||
|
||||
char volume_identifier[33];
|
||||
memcpy(&pvd.volume_ident[0], volume_identifier, 32);
|
||||
volume_identifier[32] = 0;
|
||||
kprintf("Volume Identifier: %s\n", volume_identifier);
|
||||
memset((uint8_t*)volume_identifier, 0, 33);
|
||||
memcpy(&pvd->volume_ident[0], volume_identifier, 32);
|
||||
|
||||
kprintf("Reading ISO Filesystem from CDROM Disk %s\n", volume_identifier);
|
||||
|
||||
uint32_t lba_path_table = pvd->path_table_l_loc;
|
||||
uint32_t path_table_sz = pvd->path_table_sz_le;
|
||||
uint32_t sectors = path_table_sz / 2048;
|
||||
if (sectors % 2048 > 0) {
|
||||
sectors++;
|
||||
}
|
||||
|
||||
uint8_t path_table_sec[2048 * sectors];
|
||||
memset(path_table_sec, 0, 2048);
|
||||
success = ide_read_blks(dev, lba_path_table, 1, path_table_sec);
|
||||
if (!success) {
|
||||
kprintf("could not read path table at lba 0x%x\n", lba_path_table);
|
||||
return;
|
||||
}
|
||||
|
||||
kprintf("iterating path table\n");
|
||||
iso_path_table_entry_t* path = (iso_path_table_entry_t*)path_table_sec;
|
||||
while ((uint32_t)path - (uint32_t)path_table_sec < 2048) {
|
||||
size_t entry_sz = sizeof(iso_path_table_entry_t) + (path->dir_ident_len - 1);
|
||||
if (path->dir_ident_len % 2 > 0) entry_sz++;
|
||||
path = (iso_path_table_entry_t*)((uint32_t)path + entry_sz);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,10 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t version;
|
||||
} vd_header_t;
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
|
||||
} iso_dec_datetime_t;
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
vd_header_t header;
|
||||
uint8_t unused;
|
||||
@@ -26,8 +30,36 @@ typedef struct __attribute__((packed)) {
|
||||
uint16_t logical_blk_sz_be;
|
||||
uint32_t path_table_sz_le;
|
||||
uint32_t path_table_sz_be;
|
||||
uint32_t path_table_l_loc;
|
||||
uint32_t opt_path_table_l_loc;
|
||||
uint32_t path_table_m_loc;
|
||||
uint32_t opt_path_table_m_loc;
|
||||
uint8_t root_dir_entry[34];
|
||||
uint8_t vol_set_ident_strd[128];
|
||||
uint8_t publisher_ident_stra[128];
|
||||
uint8_t data_prep_ident_stra[128];
|
||||
uint8_t app_ident_stra[128];
|
||||
uint8_t copyright_ident_strd[37];
|
||||
uint8_t abs_file_ident_strd[37];
|
||||
uint8_t bib_file_ident_strd[37];
|
||||
iso_dec_datetime_t vol_creation_datetime;
|
||||
iso_dec_datetime_t vol_modif_datetime;
|
||||
iso_dec_datetime_t vol_expr_datetime;
|
||||
iso_dec_datetime_t vol_effective_datetime;
|
||||
uint8_t file_struct_version;
|
||||
uint8_t unused_3;
|
||||
uint8_t app_reserved[512];
|
||||
uint8_t reserved[653];
|
||||
} iso_pvd_t;
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint8_t dir_ident_len;
|
||||
uint8_t ext_attrib_len;
|
||||
uint32_t location;
|
||||
uint16_t parent_idx;
|
||||
uint8_t dir_ident_start;
|
||||
} iso_path_table_entry_t;
|
||||
|
||||
void read_iso(ide_device_t* dev);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user