mirror of
https://github.com/RGBCube/serenity
synced 2025-07-04 18:17:36 +00:00
Kernel: Implement OffsetDiskDevice to prepare for partition support
This implements a passthrough disk driver that translates the read/write block addresses by a fixed offset. This could form the basis of MBR partition support if we were to parse the MBR table at boot and create that OffsetDiskDevice dynamically, rather than seeking to a fixed offset. This also introduces a dependency in the form of grub. You'll need to have 32-bit grub binaries installed to build the project now. As a bonus, divorcing Serenity from qemu's kernel loading means we can now *technically* boot on real hardware. It just... doesn't get very far yet. If you write the `_disk_image` file to an IDE hard drive and boot it in a machine that supports all the basic PC hardware, it *will* start loading the kernel.
This commit is contained in:
parent
5e1c7cb32c
commit
6f43f81fb4
8 changed files with 220 additions and 66 deletions
|
@ -6,6 +6,7 @@
|
|||
#include "Process.h"
|
||||
#include "PIC.h"
|
||||
#include <Kernel/Devices/IDEDiskDevice.h>
|
||||
#include <Kernel/Devices/OffsetDiskDevice.h>
|
||||
#include "KSyms.h"
|
||||
#include <Kernel/Devices/NullDevice.h>
|
||||
#include <Kernel/Devices/ZeroDevice.h>
|
||||
|
@ -57,6 +58,11 @@ VFS* vfs;
|
|||
}
|
||||
#endif
|
||||
|
||||
// TODO: delete this magic number. this block offset corresponds to a
|
||||
// partition that starts at 32k into an MBR disk. this value is also specified
|
||||
// in sync.sh, but should ideally be read from the MBR header at startup.
|
||||
#define PARTITION_OFFSET 62
|
||||
|
||||
[[noreturn]] static void init_stage2()
|
||||
{
|
||||
Syscall::initialize();
|
||||
|
@ -66,7 +72,8 @@ VFS* vfs;
|
|||
auto dev_random = make<RandomDevice>();
|
||||
auto dev_ptmx = make<PTYMultiplexer>();
|
||||
auto dev_hd0 = IDEDiskDevice::create();
|
||||
auto e2fs = Ext2FS::create(dev_hd0.copy_ref());
|
||||
auto dev_hd0p1 = OffsetDiskDevice::create(dev_hd0.copy_ref(), PARTITION_OFFSET);
|
||||
auto e2fs = Ext2FS::create(dev_hd0p1.copy_ref());
|
||||
e2fs->initialize();
|
||||
|
||||
vfs->mount_root(e2fs.copy_ref());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue