Play with sections.

parent 71eb19c6
......@@ -46,8 +46,10 @@ build/diskfs.img: build/diskfs.list
./create_diskfs.py < $< > $@
# Asmg kernel
build/full-asmg.asm: lib/mb_header.asm lib/kernel.asm lib/no_io.asm lib/shutdown.asm lib/initrd.asm lib/library.asm lib/setjmp.asm asmg/asmg.asm asmg/kernel-asmg.asm lib/top.asm
cat $^ | grep -v "^ *section " > $@
build/full-asmg.asm: lib/mb_header.asm lib/kernel.asm lib/io.asm lib/shutdown.asm lib/initrd.asm lib/library.asm lib/setjmp.asm asmg/asmg.asm asmg/kernel-asmg.asm lib/top.asm
#cat $^ | grep -v "^ *section " > $@
cat $^ | sed -e 's|section .bss|section .data|' > $@
#cat $^ > $@
build/initrd-asmg.list: asmg/*.g
ls $^ | sed -e 's|\(.*\)/\([^/]*\)|\2 \1/\2|g' > $@
......
......@@ -18,6 +18,8 @@
WRITE_LABEL_BUF_LEN equ 128
STACK_VARS_LEN equ 1024
section .data
TEMP_VAR:
db '__temp'
db 0
......@@ -53,6 +55,8 @@ str_const:
db 'const'
db 0
section .bss
label_num:
resd 1
......@@ -92,6 +96,7 @@ read_ptr_begin:
read_ptr_end:
resd 1
section .text
gen_label:
;; Increment by 1 gen_label and return its original value
......
......@@ -15,10 +15,11 @@
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
section .data
str_platform_g_compile:
db 'platform_g_compile'
db 0
str_platform_setjmp:
db 'platform_setjmp'
db 0
......@@ -50,6 +51,7 @@ str_entry:
db 'entry'
db 0
section .text
;; void platform_g_compile(char *filename)
platform_g_compile:
......
......@@ -19,12 +19,18 @@
TERM_COL_NUM equ 80
TERM_BASE_ADDR equ 0xb8000
%ifdef DEBUG
section .bss
term_row:
resd 1
term_col:
resd 1
section .text
;; Fill the VGA framebuffer with spaces char, with color light grey
;; on black
;; Destroys: EAX
......@@ -194,3 +200,13 @@ stdout_setup:
call term_setup
call serial_setup
ret
%else
write_console:
ret
stdout_setup:
ret
%endif
......@@ -22,9 +22,13 @@
FILE_RECORD_SIZE equ 16
FILE_RECORD_SIZE_LOG equ 4
section .bss
heap_ptr:
resd 1
section .data
%ifdef DEBUG
str_exit:
db 'The execution has finished, bye bye...'
......@@ -34,6 +38,7 @@ str_exit:
str_panic:
db 'PANIC!'
str_newline:
db NEWLINE
str_empty:
db 0
......@@ -53,6 +58,18 @@ str_done:
db 0
%endif
str_platform_panic:
db 'platform_panic'
db 0
str_platform_allocate:
db 'platform_allocate'
db 0
str_platform_get_symbol:
db 'platform_get_symbol'
db 0
section .text
entry:
;; Make it double sure that we do not have interrupts around
cli
......@@ -61,6 +78,15 @@ entry:
mov esp, temp_stack_top
and esp, 0xfffffff0
;; Initialize the BSS
;; mov ecx, begin_bss
;; xor eax, eax
;; entry_bss_loop:
;; mov [ecx], al
;; inc ecx
;; cmp ecx, end_bss
;; jne entry_bss_loop
;; Find the end of the ar initrd
mov ecx, str_empty
call walk_initrd
......@@ -112,7 +138,6 @@ entry:
platform_panic:
panic:
cpuid
jmp shutdown
%ifdef DEBUG
;; Write an exit string
......@@ -158,16 +183,6 @@ allocate:
ret
str_platform_panic:
db 'platform_panic'
db 0
str_platform_allocate:
db 'platform_allocate'
db 0
str_platform_get_symbol:
db 'platform_get_symbol'
db 0
;; Initialize the symbols table with the "kernel API"
init_kernel_api:
mov edx, 0
......
......@@ -74,15 +74,6 @@ current_loc:
stage:
resd 1
section .data
str_symbol_already_defined:
db 'Symbol already defined: '
db 0
str_newline:
db NEWLINE
db 0
section .text
;; Input number in AL
......
......@@ -23,9 +23,13 @@
MBFLAGS equ 0x10003
MBCHECKSUM equ 0x100000000 - MBMAGIC - MBFLAGS
jmp entry
section .text
;; Manually jump to after_header, to avoid depending on instruction encoding length
db 0xeb, after_header - 2, 0x00, 0x00
align 4
dd begin_bss
dd end_bss
MBBEGIN equ $
......@@ -40,4 +44,11 @@
dd 0x0
dd 0x100000
after_header:
jmp entry
temp_stack_top:
section .bss
begin_bss:
;; This file is part of asmc, a bootstrapping OS with minimal seed
;; Copyright (C) 2018-2019 Giovanni Mascellani <gio@debian.org>
;; https://gitlab.com/giomasce/asmc
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
write_console:
ret
stdout_setup:
ret
......@@ -15,4 +15,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
section .bss
end_bss:
initrd:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment