bios_hello_world_c
This commit is contained in:
3
bios_hello_world_c/README.adoc
Normal file
3
bios_hello_world_c/README.adoc
Normal 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
7
bios_hello_world_c/build.sh
Executable 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
|
||||
6
bios_hello_world_c/entry.S
Normal file
6
bios_hello_world_c/entry.S
Normal file
@@ -0,0 +1,6 @@
|
||||
.text
|
||||
.global mystart
|
||||
mystart:
|
||||
mov %rsp, __stack_top
|
||||
call main
|
||||
jmp .
|
||||
17
bios_hello_world_c/linker.ld
Normal file
17
bios_hello_world_c/linker.ld
Normal 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 = .;
|
||||
}
|
||||
3
bios_hello_world_c/main.c
Normal file
3
bios_hello_world_c/main.c
Normal file
@@ -0,0 +1,3 @@
|
||||
void main(void) {
|
||||
while (1);
|
||||
}
|
||||
Reference in New Issue
Block a user