mkdir -p out
echo 'fs0:main' >out/startup.nsh
-main: main.asm impl.asm bootstrap.asm sys.f os/linux.asm
- OS_INCLUDE=os/linux.asm fasm $< $@
-
.PHONY: clean
clean:
rm -rf out OVMF_CODE.fd OVMF_VARS.fd
-;; vim: syntax=fasm
-
-;; At compile-time we load the module given by the environment variable
-;; OS_INCLUDE. All of the following these procedures should preserve the value
-;; of RSI and RSP. They may use other registers as they like.
-;;
-;; The module should provide the following:
-;;
-;; os_code_section
-;; Macro to start the text segment.
-;;
-;; os_data_section
-;; Macro to start the data segment.
+;; The UEFI module defines the following functions. Each of these functions
+;; preserve the value of RSI and RSP. They may use other registers as they like.
;;
;; os_initialize
;; Called at initialization.
;;
;; os_terminate
;; Shut down the system, returning the error code given in RAX.
-include '%OS_INCLUDE%'
+include 'os/uefi.asm'
;; The code in this macro is placed at the end of each Forth word. When we are
;; executing a definition, this code is what causes execution to resume at the
.start:
}
+section '.text' code readable executable
+
include "impl.asm" ; Misc. subroutines
include "bootstrap.asm" ; Forth words encoded in Assembly
-os_code_section
-
main:
cld ; Clear direction flag so LODSQ does the right thing.
mov rbp, return_stack_top ; Initialize return stack
dq LIT, input_buffer_length
dq EXIT
-os_data_section
+section '.data' readable writable
;; The LATEST variable holds a pointer to the word that was last added to the
;; dictionary. This pointer is updated as new words are added, and its value is
+++ /dev/null
-format ELF64 executable
-entry main
-
-macro os_code_section {
- segment readable executable
-}
-
-macro os_data_section {
- segment readable writable
-}
-
-os_code_section
-
-os_initialize:
- ret
-
-os_print_string:
- push rsi
- mov rax, 1
- mov rdi, 1
- mov rsi, rcx
- syscall
- pop rsi
- ret
-
-os_read_char:
- push rsi
- mov rax, 0
- mov rdi, 0
- mov rsi, .buffer
- mov rdx, 1
- syscall
- pop rsi
- movzx rax, byte [.buffer]
- ret
-
-os_terminate:
- mov rdi, rax
- mov rax, $3C
- syscall
-
-os_data_section
-
-os_read_char.buffer db ?
-