mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
Add Limine.CFG auto-generate ability to LimineMHDIns.
This commit is contained in:
parent
42234bdef1
commit
2590420586
1 changed files with 55 additions and 4 deletions
|
@ -11,15 +11,64 @@ class CLimineStage2Header
|
|||
U8 binary_limine_hdd_bin_data[0];
|
||||
#endif
|
||||
|
||||
Bool LimineCFGMake(U8 drv_let)
|
||||
{
|
||||
U8 *filename_cfg = MStrPrint("%C:/Boot/Limine.CFG", drv_let);
|
||||
CDoc *doc = DocNew(filename_cfg);
|
||||
CDrive *drive;
|
||||
CBlkDev *bd;
|
||||
I64 i;
|
||||
U8 *filename_sys, *filename_elf, *filename_zxe, *st;
|
||||
// Limine interface settings
|
||||
DocPrint(doc,
|
||||
"TIMEOUT=2\n"
|
||||
"INTERFACE_RESOLUTION=1024x768\n\n");
|
||||
|
||||
for (i = 0, drive = blkdev.drvs; i < DRIVES_NUM; i++, drive++)
|
||||
{
|
||||
if (drive->drive_signature == DRIVE_SIGNATURE_VAL)
|
||||
{
|
||||
bd = drive->bd;
|
||||
drv_let = Drive2Letter(drive);
|
||||
|
||||
if (DriveIsWritable(drv_let) && drive->fs_type == FSt_FAT32)
|
||||
{
|
||||
filename_sys = MStrPrint("%C:/Boot/Limine.SYS", drv_let);
|
||||
filename_elf = MStrPrint("%C:/Boot/ZealBooter.ELF", drv_let);
|
||||
filename_zxe = MStrPrint("%C:/Boot/Kernel.ZXE", drv_let);
|
||||
if (FileFind(filename_sys) && FileFind(filename_elf) && FileFind(filename_zxe))
|
||||
{
|
||||
st = MStrPrint(":ZealOS %C:/\n"
|
||||
"PROTOCOL=limine\n"
|
||||
"RESOLUTION=1024x768\n"
|
||||
"KERNEL_PATH=boot://%d/Boot/ZealBooter.ELF\n"
|
||||
"MODULE_PATH=boot://%d/Boot/Kernel.ZXE\n"
|
||||
"\n", drv_let, drive->prt_num + 1, drive->prt_num + 1);
|
||||
|
||||
DocPrint(doc, st);
|
||||
|
||||
}
|
||||
else
|
||||
"\n%C:/ drive is missing Limine bootloader files.\n", drv_let;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DocWrite(doc);
|
||||
DocDel(doc);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool LimineMHDIns(U8 drv_let)
|
||||
{
|
||||
U8 *limine = binary_limine_hdd_bin_data;
|
||||
U16 limine_size = sizeof(binary_limine_hdd_bin_data);
|
||||
CLimineStage2Header *limine_stage2 = limine + 0x1A4;
|
||||
U16 limine_stage2_size = limine_size - BLK_SIZE;
|
||||
U16 limine_stage2_size_aligned = limine_stage2_size + ((BLK_SIZE * 2) - limine_stage2_size % (BLK_SIZE * 2));
|
||||
CBlkDev *bd = Letter2BlkDev(drv_let);
|
||||
CMasterBoot old_mbr, *new_mbr = limine;
|
||||
U16 limine_stage2_size = limine_size - BLK_SIZE;
|
||||
U16 limine_stage2_size_aligned = limine_stage2_size + ((BLK_SIZE * 2) - limine_stage2_size % (BLK_SIZE * 2));
|
||||
CBlkDev *bd = Letter2BlkDev(drv_let);
|
||||
CMasterBoot old_mbr, *new_mbr = limine;
|
||||
|
||||
if (limine_size == 0)
|
||||
{
|
||||
|
@ -41,6 +90,8 @@ Bool LimineMHDIns(U8 drv_let)
|
|||
|
||||
BlkDevUnlock(bd);
|
||||
|
||||
LimineCFGMake(drv_let);
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue