diff --git a/src/userland/mbr/compile_flags.txt b/src/userland/mbr/compile_flags.txt new file mode 100644 index 0000000..f084bb0 --- /dev/null +++ b/src/userland/mbr/compile_flags.txt @@ -0,0 +1,6 @@ +clang +-Iinclude +-I../../include +-fms-extensions +-Wno-microsoft-anon-tag +-Wno-incompatible-library-redeclaration diff --git a/src/userland/mbr/compile_flags.txt b/src/userland/mbr/compile_flags.txt new file mode 100644 index 0000000..f084bb0 --- /dev/null +++ b/src/userland/mbr/compile_flags.txt @@ -0,0 +1,6 @@ +clang +-Iinclude +-I../../include +-fms-extensions +-Wno-microsoft-anon-tag +-Wno-incompatible-library-redeclaration diff --git a/src/userland/mbr/include/mbr.h b/src/userland/mbr/include/mbr.h new file mode 100644 index 0000000..720624f --- /dev/null +++ b/src/userland/mbr/include/mbr.h @@ -0,0 +1,26 @@ +#ifndef MBR_H +#define MBR_H + +#include + +typedef struct { + uint8_t active; + uint8_t startCHS[3]; + uint8_t type; + uint8_t endCHS[3]; + uint32_t lbaStart; + uint32_t sectorCount; +} PartitionTableEntry; + +typedef struct { + PartitionTableEntry entries[4]; + uint8_t signature[2]; +} ClassicMBR; + +typedef struct { + uint32_t id; + uint32_t serviceId, deviceId, readFunktion, writeFunktion; + ClassicMBR *mbr; +} MbrDevice; + +#endif \ No newline at end of file diff --git a/src/userland/mbr/compile_flags.txt b/src/userland/mbr/compile_flags.txt new file mode 100644 index 0000000..f084bb0 --- /dev/null +++ b/src/userland/mbr/compile_flags.txt @@ -0,0 +1,6 @@ +clang +-Iinclude +-I../../include +-fms-extensions +-Wno-microsoft-anon-tag +-Wno-incompatible-library-redeclaration diff --git a/src/userland/mbr/include/mbr.h b/src/userland/mbr/include/mbr.h new file mode 100644 index 0000000..720624f --- /dev/null +++ b/src/userland/mbr/include/mbr.h @@ -0,0 +1,26 @@ +#ifndef MBR_H +#define MBR_H + +#include + +typedef struct { + uint8_t active; + uint8_t startCHS[3]; + uint8_t type; + uint8_t endCHS[3]; + uint32_t lbaStart; + uint32_t sectorCount; +} PartitionTableEntry; + +typedef struct { + PartitionTableEntry entries[4]; + uint8_t signature[2]; +} ClassicMBR; + +typedef struct { + uint32_t id; + uint32_t serviceId, deviceId, readFunktion, writeFunktion; + ClassicMBR *mbr; +} MbrDevice; + +#endif \ No newline at end of file diff --git a/src/userland/mbr/main.c b/src/userland/mbr/main.c new file mode 100644 index 0000000..7ae4f5e --- /dev/null +++ b/src/userland/mbr/main.c @@ -0,0 +1,23 @@ +#include +#include + +ListElement *devices = NULL; + +void registerDevice(uint32_t deviceId, uint32_t reserved, uint32_t serviceName, uint32_t serviceId) { + MbrDevice *device = malloc(sizeof(MbrDevice)); + device->serviceId = serviceId; + device->deviceId = deviceId; + device->readFunktion = getFunction(serviceId, "mbr_read"); + device->writeFunktion = getFunction(serviceId, "mbr_write"); + listAdd(&devices, device); + + void *firstSector = PTR(request(device->serviceId, device->readFunktion, device->deviceId | 512 << 16, 0)); + void *dataHere = requestMemory(1, NULL, firstSector); + device->mbr = malloc(sizeof(ClassicMBR)); + memcpy(dataHere + 446, device->mbr, sizeof(ClassicMBR)); + printf("MBR signature: 0x%x%x\n", device->mbr->signature[0], device->mbr->signature[1]); +} + +int32_t main() { + createFunction("register", (void *)registerDevice); +} \ No newline at end of file