Basic idea's are created for the storage solution
- Added boot device info parsing to the kernel - Added a pointer in the kernel to our pre-kernel BootInfo structure - Created a layout for the FAT driver - Created a layout for the virtual filesystem - Separated IDE driver from the basic atapio driver. This will ensure we are not using one or the other - The create_harddrive shell script will now actually build a harddrive image of the kernel - The virtual filesystem initializes and creates a filesystem structure for every FAT16 partition in the master boot record
This commit is contained in:
43
kernel/storage/partitiontables/mbr/MasterBootRecord.h
Normal file
43
kernel/storage/partitiontables/mbr/MasterBootRecord.h
Normal file
@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include <stdint-gcc.h>
|
||||
#include "PartitionTableEntry.h"
|
||||
#include "../../../memory/KernelHeap.h"
|
||||
#include "../../ata pio/ATAPIO.h"
|
||||
|
||||
struct MBR {
|
||||
uint8_t code [440];
|
||||
uint32_t uniqueID;
|
||||
uint16_t Reserved;
|
||||
struct PartitionTableEntry TableEntries[4];
|
||||
uint16_t ValidBootsector;
|
||||
}__attribute__((packed));
|
||||
|
||||
|
||||
inline MBR* GetPartitions(bool DEBUG = false){
|
||||
const int C = 0;
|
||||
const int H = 0;
|
||||
const int HPC = 16;
|
||||
const int SPT = 63;
|
||||
|
||||
int S =1;
|
||||
uint32_t LBA = (C*HPC+H) * SPT + (S-1);
|
||||
|
||||
MBR* mbr =(MBR*) malloc(sizeof (MBR));
|
||||
|
||||
ATAPIO::Read(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER, LBA, (uint16_t*)mbr);
|
||||
|
||||
|
||||
printf("MBR (In Memory) Address 0x%x, Size = %d\n", mbr, sizeof (MBR));
|
||||
if(DEBUG){
|
||||
printf("BootSector: 0x%x\n", mbr->ValidBootsector );
|
||||
for( int i = 0 ; i < 4 ; i ++){
|
||||
PartitionTableEntry PT = mbr->TableEntries[i];
|
||||
|
||||
printf("Partition %d [ %d sectors, PartitionType: 0x%x, 0x%x, \nLBA Start: 0x%x ]\n" ,
|
||||
i, PT.Number_sectors_inPartition, PT.PartitionType, mbr->uniqueID, PT.LBA_partition_start );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return mbr;
|
||||
}
|
11
kernel/storage/partitiontables/mbr/PartitionTableEntry.h
Normal file
11
kernel/storage/partitiontables/mbr/PartitionTableEntry.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
struct PartitionTableEntry{
|
||||
uint8_t driveAttribute;
|
||||
uint8_t CHS_start_address [3];
|
||||
uint8_t PartitionType;
|
||||
uint8_t CHS_lastSector_Address[3];
|
||||
uint32_t LBA_partition_start;
|
||||
uint32_t Number_sectors_inPartition;
|
||||
}__attribute__((packed));
|
Reference in New Issue
Block a user