bios_hello_world_c

This commit is contained in:
Ciro Santilli
2018-12-02 21:01:24 +00:00
parent a2ca298afe
commit 8f4d2cf8a3
5 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
TODO not working.
A single stage educational minimal C BIOS hello world example for: https://stackoverflow.com/questions/22054578/how-to-run-a-program-without-an-operating-system/32483545#32483545

7
bios_hello_world_c/build.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -eux
as -ggdb3 -o entry.o entry.S
gcc -c -ggdb3 -nostartfiles -nostdlib -o main.o main.c
ld -o main.elf -T linker.ld entry.o main.o
ld --oformat binary -o main.img -T linker.ld entry.o main.o
qemu-system-x86_64 -hda main.img

View File

@@ -0,0 +1,6 @@
.text
.global mystart
mystart:
mov %rsp, __stack_top
call main
jmp .

View File

@@ -0,0 +1,17 @@
ENTRY(mystart)
SECTIONS
{
.text : {
entry.o(.text)
*(.text)
*(.rodata)
*(.data)
/**(.eh_frame)*/
. = 0x1FE;
SHORT(0xAA55)
}
/* Reserve 16 MiB of stack. */
__stack_bottom = .;
. = . + 0x1000000;
__stack_top = .;
}

View File

@@ -0,0 +1,3 @@
void main(void) {
while (1);
}