we can reaad CDROMS

This commit is contained in:
2026-06-24 13:30:23 -05:00
parent ae4b6863bf
commit 68dbdbb2c8
7 changed files with 133 additions and 57 deletions

40
kernel/drivers/iso/iso.c Normal file
View File

@@ -0,0 +1,40 @@
#include "iso.h"
#include "drivers/ide/ide.h"
#include "lib/print.h"
#include "lib/memory.h"
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");
return;
}
iso_pvd_t pvd = *(iso_pvd_t*)sector_buf;
char pvd_identifier[6];
memcpy(pvd.header.identifier, pvd_identifier, 5);
pvd_identifier[5] = 0;
if (strcmp(pvd_identifier, "CD001") > 0) {
kprintf("Invalid PVD identifier\n");
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);
}

33
kernel/drivers/iso/iso.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef KISO_H
#define KISO_H
#include "drivers/ide/ide.h"
typedef struct __attribute__((packed)) {
uint8_t type;
char identifier[5];
uint8_t version;
} vd_header_t;
typedef struct __attribute__((packed)) {
vd_header_t header;
uint8_t unused;
uint8_t sys_ident[32];
uint8_t volume_ident[32];
uint8_t unused_1[8];
uint32_t volume_space_sz_le;
uint32_t volume_space_sz_be;
uint8_t unused_2[32];
uint16_t vol_set_sz_le;
uint16_t vol_set_sz_be;
uint16_t vol_seq_num_le;
uint16_t vol_seq_num_be;
uint16_t logical_blk_sz_le;
uint16_t logical_blk_sz_be;
uint32_t path_table_sz_le;
uint32_t path_table_sz_be;
} iso_pvd_t;
void read_iso(ide_device_t* dev);
#endif