From: Jonas Hvid Date: Fri, 9 Oct 2020 21:12:36 +0000 (+0200) Subject: Revert support for Linux backend X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=c6c2c1941a030ebda811db613262d317e6041137;p=rrq%2Fjonasforth.git Revert support for Linux backend Now that we're implementing UEFI-related words directly in Forth, it doesn't make much sense to provide an alternative Linux backend. That was a dead end. --- diff --git a/.gitignore b/.gitignore index cef3077..5557c76 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ /out -/main /OVMF_CODE.fd /OVMF_VARS.fd diff --git a/Makefile b/Makefile index 4b8184f..058cbf5 100644 --- a/Makefile +++ b/Makefile @@ -22,9 +22,6 @@ out/startup.nsh: 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 diff --git a/impl.asm b/impl.asm index 67d11b5..6267b3e 100644 --- a/impl.asm +++ b/impl.asm @@ -1,4 +1,4 @@ -os_code_section +section '.text' code readable executable macro printlen msg, len { push rsi @@ -184,7 +184,7 @@ parse_number: mov rax, 100 call os_terminate -os_data_section +section '.data' readable writable find.search_length dq ? find.search_buffer dq ? diff --git a/main.asm b/main.asm index e510410..5f63d84 100644 --- a/main.asm +++ b/main.asm @@ -1,16 +1,5 @@ -;; 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. @@ -25,7 +14,7 @@ ;; ;; 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 @@ -84,11 +73,11 @@ macro forth_asm label, name, immediate { .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 @@ -678,7 +667,7 @@ forth INPUT_LENGTH, 'INPUT-LENGTH' 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 diff --git a/os/linux.asm b/os/linux.asm deleted file mode 100644 index 2ea3d16..0000000 --- a/os/linux.asm +++ /dev/null @@ -1,45 +0,0 @@ -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 ? - diff --git a/os/uefi.asm b/os/uefi.asm index 10c7627..16fc85d 100644 --- a/os/uefi.asm +++ b/os/uefi.asm @@ -58,14 +58,6 @@ struct EFI_INPUT_KEY ;; }}} -macro os_code_section { - section '.text' code readable executable -} - -macro os_data_section { - section '.data' readable writable -} - section '.text' code executable readable os_initialize: