Modify userspace .org and RAMSTART expectations
Instead of expecting a `USER_CODE` symbol to be set, we expect `.org` to be set in all userspace glue code. This gives us more flexibility with regards to how we manage that. Moreover, instead of making `USER_RAMSTART` mandatory, we make it default to the end of the binary, which is adequate in a majority of cases. Will be useful for my upcoming mega-commit... :)
This commit is contained in:
parent
d74b85f146
commit
cdd0b64570
@ -10,8 +10,16 @@ you will typically not want to do that.
|
|||||||
|
|
||||||
## Userspace convention
|
## Userspace convention
|
||||||
|
|
||||||
We execute a userspace application by calling the address it's loaded into. This
|
We execute a userspace application by calling the address it's loaded into.
|
||||||
means: a userspace application is expected to return.
|
|
||||||
|
This means that userspace applications must be assembled with a proper `.org`,
|
||||||
|
otherwise labels in its code will be wrong.
|
||||||
|
|
||||||
|
The `.org`, it is not specified by glue code of the apps themselves. It is
|
||||||
|
expected to be set either in the `user.h` file to through `zasm` 3rd argument.
|
||||||
|
|
||||||
|
That a userspace is called also means that an application, when finished
|
||||||
|
running, is expected to return with a regular `ret` and a clean stack.
|
||||||
|
|
||||||
Whatever calls the userspace app (usually, it will be the shell), should set
|
Whatever calls the userspace app (usually, it will be the shell), should set
|
||||||
HL to a pointer to unparsed arguments in string form, null terminated.
|
HL to a pointer to unparsed arguments in string form, null terminated.
|
||||||
@ -25,3 +33,8 @@ because otherwise, it will break the kernel.
|
|||||||
|
|
||||||
Apps in Collapse OS are design to be ROM-compatible, that is, they don't write
|
Apps in Collapse OS are design to be ROM-compatible, that is, they don't write
|
||||||
to addresses that are part of the code's address space.
|
to addresses that are part of the code's address space.
|
||||||
|
|
||||||
|
By default, apps set their RAM to begin at the end of the binary because in
|
||||||
|
most cases, these apps will be ran from RAM. If they're ran from ROM, make sure
|
||||||
|
to set `USER_RAMSTART` properly in your `user.h` to ensure that the RAM is
|
||||||
|
placed properly.
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
.inc "user.h"
|
.inc "user.h"
|
||||||
.inc "err.h"
|
.inc "err.h"
|
||||||
.org USER_CODE
|
|
||||||
.equ AT28W_RAMSTART USER_RAMSTART
|
.equ AT28W_RAMSTART USER_RAMSTART
|
||||||
|
|
||||||
jp at28wMain
|
jp at28wMain
|
||||||
|
|
||||||
.inc "at28w/main.asm"
|
.inc "at28w/main.asm"
|
||||||
|
USER_RAMSTART:
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
.inc "user.h"
|
.inc "user.h"
|
||||||
|
|
||||||
.inc "err.h"
|
.inc "err.h"
|
||||||
.org USER_CODE
|
|
||||||
|
|
||||||
jp basStart
|
jp basStart
|
||||||
|
|
||||||
@ -16,3 +15,4 @@
|
|||||||
.inc "lib/parse.asm"
|
.inc "lib/parse.asm"
|
||||||
.equ BAS_RAMSTART USER_RAMSTART
|
.equ BAS_RAMSTART USER_RAMSTART
|
||||||
.inc "basic/main.asm"
|
.inc "basic/main.asm"
|
||||||
|
USER_RAMSTART:
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
; ******
|
; ******
|
||||||
|
|
||||||
.inc "err.h"
|
.inc "err.h"
|
||||||
.org USER_CODE
|
|
||||||
|
|
||||||
jp edMain
|
jp edMain
|
||||||
|
|
||||||
.inc "core.asm"
|
.inc "core.asm"
|
||||||
@ -41,3 +39,4 @@
|
|||||||
.inc "ed/cmd.asm"
|
.inc "ed/cmd.asm"
|
||||||
.equ ED_RAMSTART CMD_RAMEND
|
.equ ED_RAMSTART CMD_RAMEND
|
||||||
.inc "ed/main.asm"
|
.inc "ed/main.asm"
|
||||||
|
USER_RAMSTART:
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
; *** Includes ***
|
; *** Includes ***
|
||||||
|
|
||||||
.inc "user.h"
|
.inc "user.h"
|
||||||
.org USER_CODE
|
|
||||||
|
|
||||||
jp memtMain
|
jp memtMain
|
||||||
|
|
||||||
.inc "memt/main.asm"
|
.inc "memt/main.asm"
|
||||||
|
USER_RAMSTART:
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
; *** Includes ***
|
; *** Includes ***
|
||||||
|
|
||||||
.inc "user.h"
|
.inc "user.h"
|
||||||
.org USER_CODE
|
|
||||||
.equ SDCT_RAMSTART USER_RAMSTART
|
.equ SDCT_RAMSTART USER_RAMSTART
|
||||||
|
|
||||||
jp sdctMain
|
jp sdctMain
|
||||||
|
|
||||||
.inc "sdct/main.asm"
|
.inc "sdct/main.asm"
|
||||||
|
USER_RAMSTART:
|
||||||
|
@ -64,8 +64,6 @@
|
|||||||
|
|
||||||
.inc "err.h"
|
.inc "err.h"
|
||||||
.inc "ascii.h"
|
.inc "ascii.h"
|
||||||
.org USER_CODE
|
|
||||||
|
|
||||||
jp zasmMain
|
jp zasmMain
|
||||||
|
|
||||||
.inc "core.asm"
|
.inc "core.asm"
|
||||||
@ -87,3 +85,4 @@ jp zasmMain
|
|||||||
.inc "zasm/symbol.asm"
|
.inc "zasm/symbol.asm"
|
||||||
.equ ZASM_RAMSTART SYM_RAMEND
|
.equ ZASM_RAMSTART SYM_RAMEND
|
||||||
.inc "zasm/main.asm"
|
.inc "zasm/main.asm"
|
||||||
|
USER_RAMSTART:
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
.equ USER_CODE 0x8700
|
.org 0x8700
|
||||||
.equ USER_RAMSTART USER_CODE+0x1900
|
.equ FS_HANDLE_SIZE 8
|
||||||
.equ FS_HANDLE_SIZE 6
|
|
||||||
.equ BLOCKDEV_SIZE 8
|
.equ BLOCKDEV_SIZE 8
|
||||||
|
|
||||||
; *** JUMP TABLE ***
|
; *** JUMP TABLE ***
|
||||||
|
@ -5,13 +5,13 @@ APPS = ../../../apps
|
|||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
all: os.sms
|
all: os.sms
|
||||||
|
|
||||||
|
# -o value synced with offset in glue.asm
|
||||||
ed.bin: $(APPS)/ed/glue.asm
|
ed.bin: $(APPS)/ed/glue.asm
|
||||||
echo ".equ USER_CODE ED_CODE" | cat user-tmpl.h - > user.h
|
$(ZASM) -o 19 $(KERNEL) $(APPS) user.h < $< > $@
|
||||||
$(ZASM) $(KERNEL) $(APPS) user.h < $< > $@
|
|
||||||
|
|
||||||
|
# -o value synced with offset in glue.asm
|
||||||
zasm.bin: $(APPS)/zasm/glue.asm
|
zasm.bin: $(APPS)/zasm/glue.asm
|
||||||
echo ".equ USER_CODE ZASM_CODE" | cat user-tmpl.h - > user.h
|
$(ZASM) -o 1d $(KERNEL) $(APPS) user.h < $< > $@
|
||||||
$(ZASM) $(KERNEL) $(APPS) user.h < $< > $@
|
|
||||||
|
|
||||||
os.sms: glue.asm ed.bin zasm.bin
|
os.sms: glue.asm ed.bin zasm.bin
|
||||||
$(ZASM) $(KERNEL) ed.bin zasm.bin < $< > $@
|
$(ZASM) $(KERNEL) ed.bin zasm.bin < $< > $@
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
; USER_CODE is filled in on-the-fly with either ED_CODE or ZASM_CODE
|
|
||||||
.equ ED_CODE 0x1900
|
|
||||||
.equ ZASM_CODE 0x1d00
|
|
||||||
.equ USER_RAMSTART 0xc200
|
.equ USER_RAMSTART 0xc200
|
||||||
.equ FS_HANDLE_SIZE 6
|
.equ FS_HANDLE_SIZE 8
|
||||||
.equ BLOCKDEV_SIZE 8
|
.equ BLOCKDEV_SIZE 8
|
||||||
; Make ed fit in SMS's memory
|
; Make ed fit in SMS's memory
|
||||||
.equ ED_BUF_MAXLINES 0x100
|
.equ ED_BUF_MAXLINES 0x100
|
@ -1,6 +1,4 @@
|
|||||||
.inc "user.h"
|
.inc "user.h"
|
||||||
.org USER_CODE
|
|
||||||
|
|
||||||
ld hl, sAwesome
|
ld hl, sAwesome
|
||||||
call printstr
|
call printstr
|
||||||
xor a ; success
|
xor a ; success
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
.equ USER_CODE 0x4200
|
.org 0x4200 ; in sync with USERCODE in shell/shell_.asm
|
||||||
.equ USER_RAMSTART USER_CODE+0x1800
|
|
||||||
.equ FS_HANDLE_SIZE 8
|
.equ FS_HANDLE_SIZE 8
|
||||||
.equ BLOCKDEV_SIZE 8
|
.equ BLOCKDEV_SIZE 8
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.equ USER_CODE 0x4800
|
.org 0x4800 ; in sync with USER_CODE in glue.asm
|
||||||
.equ USER_RAMSTART 0x6000
|
.equ USER_RAMSTART 0x6000
|
||||||
.equ FS_HANDLE_SIZE 8
|
.equ FS_HANDLE_SIZE 8
|
||||||
.equ BLOCKDEV_SIZE 8
|
.equ BLOCKDEV_SIZE 8
|
||||||
|
Loading…
Reference in New Issue
Block a user