mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-23 22:36:48 +03:00
Fix issue with int 13h DAP potentially not fitting within a single real mode segment; load stage 2 at 0x8000 and disable LTO as it is broken for some unknown reasons now
This commit is contained in:
parent
d192bb9101
commit
ed5d049c72
@ -2,9 +2,9 @@ CC = i386-elf-gcc
|
||||
LD = i386-elf-gcc
|
||||
OBJCOPY = i386-elf-objcopy
|
||||
|
||||
CFLAGS = -flto -Os -pipe -Wall -Wextra
|
||||
CFLAGS = -Os -pipe -Wall -Wextra
|
||||
|
||||
INTERNAL_CFLAGS = \
|
||||
INTERNAL_CFLAGS = \
|
||||
-std=gnu11 \
|
||||
-ffreestanding \
|
||||
-fno-stack-protector \
|
||||
@ -20,13 +20,14 @@ INTERNAL_CFLAGS = \
|
||||
-MMD \
|
||||
-I.
|
||||
|
||||
LDFLAGS = -flto -Os
|
||||
LDFLAGS = -Os
|
||||
|
||||
INTERNAL_LDFLAGS = \
|
||||
-lgcc \
|
||||
-static-libgcc \
|
||||
-nostdlib \
|
||||
-no-pie \
|
||||
-z max-page-size=0x1000 \
|
||||
-static \
|
||||
-Tlinker.ld
|
||||
|
||||
|
@ -24,4 +24,8 @@ SECTIONS
|
||||
*(.bss*)
|
||||
bss_end = .;
|
||||
}
|
||||
|
||||
/DISCARD/ : {
|
||||
*(*)
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
__attribute__((noreturn))
|
||||
void entry(uint8_t *compressed_stage2, size_t stage2_size, uint8_t boot_drive) {
|
||||
// The decompressor should decompress compressed_stage2 to address 0x4000.
|
||||
uint8_t *dest = (uint8_t *)0x4000;
|
||||
// The decompressor should decompress compressed_stage2 to address 0x8000.
|
||||
uint8_t *dest = (uint8_t *)0x8000;
|
||||
|
||||
tinf_gzip_uncompress(dest, compressed_stage2, stage2_size);
|
||||
|
||||
|
BIN
limine.bin
BIN
limine.bin
Binary file not shown.
@ -2,9 +2,9 @@ CC = i386-elf-gcc
|
||||
LD = i386-elf-gcc
|
||||
OBJCOPY = i386-elf-objcopy
|
||||
|
||||
CFLAGS = -flto -Os -pipe -Wall -Wextra
|
||||
CFLAGS = -Os -pipe -Wall -Wextra
|
||||
|
||||
INTERNAL_CFLAGS = \
|
||||
INTERNAL_CFLAGS = \
|
||||
-std=gnu11 \
|
||||
-fplan9-extensions \
|
||||
-ffreestanding \
|
||||
@ -22,13 +22,14 @@ INTERNAL_CFLAGS = \
|
||||
-I. \
|
||||
-I..
|
||||
|
||||
LDFLAGS = -flto -Os
|
||||
LDFLAGS = -Os
|
||||
|
||||
INTERNAL_LDFLAGS = \
|
||||
-lgcc \
|
||||
-static-libgcc \
|
||||
-nostdlib \
|
||||
-no-pie \
|
||||
-z max-page-size=0x1000 \
|
||||
-static \
|
||||
-Tlinker.ld
|
||||
|
||||
|
@ -17,35 +17,44 @@
|
||||
static uint8_t *cache = NULL;
|
||||
static uint64_t cached_block = CACHE_INVALID;
|
||||
|
||||
static struct {
|
||||
struct dap {
|
||||
uint16_t size;
|
||||
uint16_t count;
|
||||
uint16_t offset;
|
||||
uint16_t segment;
|
||||
uint64_t lba;
|
||||
} dap = { 16, BLOCK_SIZE_IN_SECTORS, 0, 0, 0 };
|
||||
};
|
||||
|
||||
static struct dap *dap = NULL;
|
||||
|
||||
static int cache_block(int drive, uint64_t block) {
|
||||
if (block == cached_block)
|
||||
return 0;
|
||||
|
||||
if (!dap) {
|
||||
dap = conv_mem_alloc(sizeof(struct dap));
|
||||
dap->size = 16;
|
||||
dap->count = BLOCK_SIZE_IN_SECTORS;
|
||||
}
|
||||
|
||||
if (!cache)
|
||||
cache = conv_mem_alloc_aligned(BLOCK_SIZE, 16);
|
||||
|
||||
dap.segment = rm_seg(cache);
|
||||
dap.offset = rm_off(cache);
|
||||
dap.lba = block * BLOCK_SIZE_IN_SECTORS;
|
||||
dap->segment = rm_seg(cache);
|
||||
dap->offset = rm_off(cache);
|
||||
dap->lba = block * BLOCK_SIZE_IN_SECTORS;
|
||||
|
||||
struct rm_regs r = {0};
|
||||
r.eax = 0x4200;
|
||||
r.edx = drive;
|
||||
r.esi = (uint32_t)&dap;
|
||||
r.esi = (uint32_t)rm_off(dap);
|
||||
r.ds = rm_seg(dap);
|
||||
|
||||
rm_int(0x13, &r, &r);
|
||||
|
||||
if (r.eflags & EFLAGS_CF) {
|
||||
int ah = (r.eax >> 8) & 0xff;
|
||||
panic("Disk error %x. Drive %x, LBA %x.\n", ah, drive, dap.lba);
|
||||
panic("Disk error %x. Drive %x, LBA %x.\n", ah, drive, dap->lba);
|
||||
cached_block = CACHE_INVALID;
|
||||
return ah;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ ENTRY(_start)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x4000;
|
||||
. = 0x8000;
|
||||
|
||||
.text : {
|
||||
KEEP(*(.entry*))
|
||||
@ -25,4 +25,8 @@ SECTIONS
|
||||
*(.bss*)
|
||||
bss_end = .;
|
||||
}
|
||||
|
||||
/DISCARD/ : {
|
||||
*(*)
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ void *conv_mem_alloc_aligned(size_t count, size_t alignment) {
|
||||
uint16_t limit;
|
||||
uint32_t ptr;
|
||||
} __attribute__((packed)) gdtr;
|
||||
asm volatile ("sgdt %0" :: "m"(gdtr));
|
||||
asm volatile ("sgdt %0" :: "m"(gdtr) : "memory");
|
||||
bump_allocator_limit = gdtr.ptr;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
TIMEOUT=3
|
||||
|
||||
THEME_BLACK=33000000
|
||||
THEME_BLACK=50000000
|
||||
THEME_RED=aa0000
|
||||
THEME_GREEN=00aaff
|
||||
THEME_BROWN=aa5500
|
||||
@ -9,7 +9,7 @@ THEME_MAGENTA=aa00aa
|
||||
THEME_CYAN=9076DE
|
||||
THEME_GREY=aaaaaa
|
||||
THEME_WHITE=ffffff
|
||||
THEME_MARGIN=16
|
||||
THEME_MARGIN=64
|
||||
|
||||
BACKGROUND_PARTITION=0
|
||||
BACKGROUND_PATH=bg.bmp
|
||||
|
Loading…
Reference in New Issue
Block a user