2020-09-06 04:35:32 +03:00
|
|
|
#include <lib/asm.h>
|
|
|
|
|
|
|
|
ASM_BASIC(
|
|
|
|
".section .entry\n\t"
|
|
|
|
|
|
|
|
"cld\n\t"
|
|
|
|
|
|
|
|
// Zero out .bss
|
|
|
|
"xor al, al\n\t"
|
|
|
|
"mov edi, OFFSET bss_begin\n\t"
|
|
|
|
"mov ecx, OFFSET bss_end\n\t"
|
|
|
|
"sub ecx, OFFSET bss_begin\n\t"
|
|
|
|
"rep stosb\n\t"
|
|
|
|
|
|
|
|
"mov ebx, OFFSET main\n\t"
|
|
|
|
"jmp ebx\n\t"
|
|
|
|
);
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <gzip/tinf.h>
|
|
|
|
|
|
|
|
__attribute__((noreturn))
|
|
|
|
void main(uint8_t *compressed_stage2, size_t stage2_size, uint8_t boot_drive) {
|
2020-09-06 06:15:55 +03:00
|
|
|
// The decompressor should decompress compressed_stage2 to address 0x4000.
|
|
|
|
volatile uint8_t *dest = (volatile uint8_t *)0x4000;
|
2020-09-06 04:35:32 +03:00
|
|
|
|
|
|
|
tinf_gzip_uncompress(dest, compressed_stage2, stage2_size);
|
|
|
|
|
|
|
|
__attribute__((noreturn))
|
|
|
|
void (*stage2)(uint8_t boot_drive) = (void *)dest;
|
|
|
|
|
|
|
|
stage2(boot_drive);
|
|
|
|
}
|