Selaa lähdekoodia

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... :)
pull/85/head
Virgil Dupras 4 vuotta sitten
vanhempi
commit
cdd0b64570
13 muutettua tiedostoa jossa 30 lisäystä ja 27 poistoa
  1. +15
    -2
      apps/README.md
  2. +1
    -1
      apps/at28w/glue.asm
  3. +1
    -1
      apps/basic/glue.asm
  4. +1
    -2
      apps/ed/glue.asm
  5. +1
    -2
      apps/memt/glue.asm
  6. +1
    -1
      apps/sdct/glue.asm
  7. +1
    -2
      apps/zasm/glue.asm
  8. +2
    -3
      recipes/rc2014/zasm/user.h
  9. +4
    -4
      recipes/sms/romasm/Makefile
  10. +1
    -4
      recipes/sms/romasm/user.h
  11. +0
    -2
      tools/emul/cfsin/hello.asm
  12. +1
    -2
      tools/emul/shell/user.h
  13. +1
    -1
      tools/emul/zasm/user.h

+ 15
- 2
apps/README.md Näytä tiedosto

@@ -10,8 +10,16 @@ you will typically not want to do that.

## Userspace convention

We execute a userspace application by calling the address it's loaded into. This
means: a userspace application is expected to return.
We execute a userspace application by calling the address it's loaded into.

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
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
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.

+ 1
- 1
apps/at28w/glue.asm Näytä tiedosto

@@ -16,9 +16,9 @@

.inc "user.h"
.inc "err.h"
.org USER_CODE
.equ AT28W_RAMSTART USER_RAMSTART

jp at28wMain

.inc "at28w/main.asm"
USER_RAMSTART:

+ 1
- 1
apps/basic/glue.asm Näytä tiedosto

@@ -7,7 +7,6 @@
.inc "user.h"

.inc "err.h"
.org USER_CODE

jp basStart

@@ -16,3 +15,4 @@
.inc "lib/parse.asm"
.equ BAS_RAMSTART USER_RAMSTART
.inc "basic/main.asm"
USER_RAMSTART:

+ 1
- 2
apps/ed/glue.asm Näytä tiedosto

@@ -26,8 +26,6 @@
; ******

.inc "err.h"
.org USER_CODE

jp edMain

.inc "core.asm"
@@ -41,3 +39,4 @@
.inc "ed/cmd.asm"
.equ ED_RAMSTART CMD_RAMEND
.inc "ed/main.asm"
USER_RAMSTART:

+ 1
- 2
apps/memt/glue.asm Näytä tiedosto

@@ -13,8 +13,7 @@
; *** Includes ***

.inc "user.h"
.org USER_CODE

jp memtMain

.inc "memt/main.asm"
USER_RAMSTART:

+ 1
- 1
apps/sdct/glue.asm Näytä tiedosto

@@ -19,9 +19,9 @@
; *** Includes ***

.inc "user.h"
.org USER_CODE
.equ SDCT_RAMSTART USER_RAMSTART

jp sdctMain

.inc "sdct/main.asm"
USER_RAMSTART:

+ 1
- 2
apps/zasm/glue.asm Näytä tiedosto

@@ -64,8 +64,6 @@

.inc "err.h"
.inc "ascii.h"
.org USER_CODE

jp zasmMain

.inc "core.asm"
@@ -87,3 +85,4 @@ jp zasmMain
.inc "zasm/symbol.asm"
.equ ZASM_RAMSTART SYM_RAMEND
.inc "zasm/main.asm"
USER_RAMSTART:

+ 2
- 3
recipes/rc2014/zasm/user.h Näytä tiedosto

@@ -1,6 +1,5 @@
.equ USER_CODE 0x8700
.equ USER_RAMSTART USER_CODE+0x1900
.equ FS_HANDLE_SIZE 6
.org 0x8700
.equ FS_HANDLE_SIZE 8
.equ BLOCKDEV_SIZE 8

; *** JUMP TABLE ***


+ 4
- 4
recipes/sms/romasm/Makefile Näytä tiedosto

@@ -5,13 +5,13 @@ APPS = ../../../apps
.PHONY: all clean
all: os.sms

# -o value synced with offset in glue.asm
ed.bin: $(APPS)/ed/glue.asm
echo ".equ USER_CODE ED_CODE" | cat user-tmpl.h - > user.h
$(ZASM) $(KERNEL) $(APPS) user.h < $< > $@
$(ZASM) -o 19 $(KERNEL) $(APPS) user.h < $< > $@

# -o value synced with offset in glue.asm
zasm.bin: $(APPS)/zasm/glue.asm
echo ".equ USER_CODE ZASM_CODE" | cat user-tmpl.h - > user.h
$(ZASM) $(KERNEL) $(APPS) user.h < $< > $@
$(ZASM) -o 1d $(KERNEL) $(APPS) user.h < $< > $@

os.sms: glue.asm ed.bin zasm.bin
$(ZASM) $(KERNEL) ed.bin zasm.bin < $< > $@


recipes/sms/romasm/user-tmpl.h → recipes/sms/romasm/user.h Näytä tiedosto

@@ -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 FS_HANDLE_SIZE 6
.equ FS_HANDLE_SIZE 8
.equ BLOCKDEV_SIZE 8
; Make ed fit in SMS's memory
.equ ED_BUF_MAXLINES 0x100

+ 0
- 2
tools/emul/cfsin/hello.asm Näytä tiedosto

@@ -1,6 +1,4 @@
.inc "user.h"
.org USER_CODE

ld hl, sAwesome
call printstr
xor a ; success


+ 1
- 2
tools/emul/shell/user.h Näytä tiedosto

@@ -1,5 +1,4 @@
.equ USER_CODE 0x4200
.equ USER_RAMSTART USER_CODE+0x1800
.org 0x4200 ; in sync with USERCODE in shell/shell_.asm
.equ FS_HANDLE_SIZE 8
.equ BLOCKDEV_SIZE 8



+ 1
- 1
tools/emul/zasm/user.h Näytä tiedosto

@@ -1,4 +1,4 @@
.equ USER_CODE 0x4800
.org 0x4800 ; in sync with USER_CODE in glue.asm
.equ USER_RAMSTART 0x6000
.equ FS_HANDLE_SIZE 8
.equ BLOCKDEV_SIZE 8


Loading…
Peruuta
Tallenna