diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a2b21501..3489d14a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ on: jobs: # This workflow contains a single job called "build" setup-sdk: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Cache sdk @@ -27,7 +27,8 @@ jobs: md2hlp/**/* orix-software/**/* oricutron/**/* - key: ${{ secrets.CACHE_ID }}-orix-sdk_ + bpm/**/* + key: ${{ secrets.CACHE_ID }}-orix-sdk - name: Checkout cc65 if: steps.cache-sdk.outputs.cache-hit != 'true' @@ -36,6 +37,13 @@ jobs: repository: cc65/cc65 path: cc65 + - name: Checkout bpm + #if: steps.cache-sdk.outputs.cache-hit != 'true' + uses: actions/checkout@v3 + with: + repository: orix-software/bpm + path: bpm + - name: Checkout orix-sdk if: steps.cache-sdk.outputs.cache-hit != 'true' uses: actions/checkout@v2 @@ -94,15 +102,17 @@ jobs: build: # The type of runner that the job will run on needs: setup-sdk - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 outputs: version: ${{ steps.job_vars.outputs.VERSION }} repo_name: ${{ steps.job_vars.outputs.REPO_NAME }} + bpm_found: ${{ steps.bpm_upload.outputs.BPM_FOUND }} steps: - uses: actions/checkout@v2 with: ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + submodules: recursive - name: Set job variables id: job_vars run: | @@ -118,12 +128,17 @@ jobs: md2hlp/**/* orix-software/**/* oricutron/**/* - key: ${{ secrets.CACHE_ID }}-orix-sdk_ + bpm/**/* + key: ${{ secrets.CACHE_ID }}-orix-sdk - name: Prepare environment for project run: | + mkdir ~/bin + cd bpm && pip install -r requirements.txt && cd .. + # cp bpm/src/bpm ~/bin + # chmod 755 ~/bin/bpm && export PATH=$PATH:~/bin ls -l && ls -l ../ - mv cc65 ../ && mv orix-software ../ && mv orix-sdk ../ && mv md2hlp ../ + mv cc65 ../ && mv orix-software ../ && mv orix-sdk ../ && mv md2hlp ../ && mv bpm ../ - name: Compile project run: CC65_HOME=${GITHUB_WORKSPACE}/../cc65 make @@ -136,10 +151,12 @@ jobs: git clone https://github.com/orix-software/docker-unit-test.git cd docker-unit-test && bash install.sh ${GITHUB_WORKSPACE} && cd .. cp build/usr/share/kernel/kernelsd.rom ${GITHUB_WORKSPACE}/oricutron/roms/kernel.rom - cat tests/unit_test/xopen.sub > ${GITHUB_WORKSPACE}/oricutron/sdcard/ETC/AUTOBOOT - cat tests/unit_test/xrm.sub >> ${GITHUB_WORKSPACE}/oricutron/sdcard/ETC/AUTOBOOT + cat tests/unit_test/xopen.sub > ${GITHUB_WORKSPACE}/oricutron/sdcard/ETC/AUTOBOOT + cat tests/unit_test/xrm.sub >> ${GITHUB_WORKSPACE}/oricutron/sdcard/ETC/AUTOBOOT + #cp mainarg ${GITHUB_WORKSPACE}/oricutron/sdcard/BIN + #cat mainarg >> ${GITHUB_WORKSPACE}/oricutron/sdcard/ETC/AUTOBOOT cd ${GITHUB_WORKSPACE}/oricutron - timeout --preserve-status 5 ./xvfb.sh || exit 0 + timeout --preserve-status 10 ./xvfb.sh || exit 0 - name: Check unit-test run: | @@ -147,7 +164,7 @@ jobs: bash tests/unit_test/verify.sh ${GITHUB_WORKSPACE}/oricutron/sdcard/ - name: Upload Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ steps.job_vars.outputs.REPO_NAME }} path: | @@ -159,11 +176,9 @@ jobs: mv ../cc65 . && mv ../orix-software . && mv ../orix-sdk . && mv ../md2hlp . ls -l - - upload: needs: build - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 defaults: run: shell: bash @@ -171,6 +186,7 @@ jobs: hash: ${{ secrets.HASH }} version: ${{ needs.build.outputs.version }} repo_name: ${{ needs.build.outputs.repo_name }} + BPM_FOUND: ${{ needs.build.outputs.bpm_found }} steps: - name: Get branch name diff --git a/Makefile b/Makefile index aeeae199..2af5b356 100644 --- a/Makefile +++ b/Makefile @@ -4,23 +4,26 @@ CFLAGS=-ttelestrat ASFLAGS=-ttelestrat LDFILES= -all : init kernel memmap -.PHONY : all +all : init kernel memmap unittest +.PHONY : prepare_tmp all + +prepare_tmp: + @mkdir -p tmp/ SOURCE=src/kernel.asm PROGRAM_NAME=kernel ifeq ($(CC65_HOME),) - CC = cl65 - AS = ca65 - LD = ld65 - AR = ar65 + CC = cl65 + AS = ca65 + LD = ld65 + AR = ar65 else - CC = $(CC65_HOME)/bin/cl65 - AS = $(CC65_HOME)/bin/ca65 - LD = $(CC65_HOME)/bin/ld65 - AR = $(CC65_HOME)/bin/ar65 + CC = $(CC65_HOME)/bin/cl65 + AS = $(CC65_HOME)/bin/ca65 + LD = $(CC65_HOME)/bin/ld65 + AR = $(CC65_HOME)/bin/ar65 endif PATH_PACKAGE_ROM=build/usr/share/$(PROGRAM_NAME)/ @@ -35,42 +38,90 @@ init: @mkdir -p build/usr/src/kernel/ kernel: $(SOURCE) + @mkdir -p tmp/ + @cd src/kernel8 && bpm update && cd .. @echo Rom are built in $(PATH_PACKAGE_ROM) - @echo Build kernelsd.rom for Twilighte board - @$(AS) --verbose -s -tnone --debug-info -o kernelsd.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > output.log - @$(LD) -C src/kernel.cfg kernelsd.ld65 -m kernelsd.map -DWITH_SDCARD_FOR_ROOT=1 -DWITH_TWILIGHTE_BOARD=1 -Ln kernelsd.sym > output.log + @echo "########################################################" + @echo "# Build kernelsd.rom for Twilighte board #" + @echo "########################################################" + @$(AS) --cpu 6502 -tnone src/functions/strings/xminma.asm -o tmp/xminma.o + @$(AS) --cpu 6502 -tnone src/functions/bank_mng/switch_to_kernel_extended.s -o tmp/switch_to_kernel_extended.o + @$(AS) --cpu 6502 -tnone src/functions/bank_mng/kernel_restore_banking_states.s -o tmp/kernel_restore_banking_states.o + @$(AS) --cpu 6502 -tnone src/functions/lib_mng/XBANK_ROUTINE.s -o tmp/xbank_routine.o + @$(AS) --cpu 6502 -tnone src/functions/network/init_network.s -o tmp/init_network.o + @$(AS) --cpu 6502 -tnone src/functions/bank_mng/search_free_bank.s -o tmp/search_free_bank.o + @$(AS) --cpu 6502 -tnone src/functions/bank_mng/kernel_free_bank.s -o tmp/kernel_free_bank.o + @$(AS) --cpu 6502 -tnone src/functions/bank_mng/kernel_free_bank_by_pid.s -o tmp/kernel_free_bank_by_pid.o + @$(AS) --cpu 6502 -tnone src/functions/network/close_sockets_by_pid.s -o tmp/close_sockets_by_pid.o + @$(AS) --cpu 6502 -tnone src/functions/network/xsocket.s -o tmp/xsocket.o + @$(AS) --cpu 6502 -tnone src/functions/network/xconnect.s -o tmp/xconnect.o + @$(AS) --cpu 6502 -tnone src/functions/network/xsend.s -o tmp/xsend.o + @$(AS) --cpu 6502 -tnone src/functions/network/xclose_socket.s -o tmp/xclose_socket.o + + @$(AR) r tmp/kernel.lib tmp/xminma.o + @$(AR) r tmp/kernel.lib tmp/switch_to_kernel_extended.o + @$(AR) r tmp/kernel.lib tmp/kernel_restore_banking_states.o + @$(AR) r tmp/kernel.lib tmp/xbank_routine.o + @$(AR) r tmp/kernel_bank8.lib tmp/init_network.o + @$(AR) r tmp/kernel_bank8.lib tmp/search_free_bank.o + @$(AR) r tmp/kernel_bank8.lib tmp/kernel_free_bank.o + @$(AR) r tmp/kernel_bank8.lib tmp/kernel_free_bank_by_pid.o + @$(AR) r tmp/kernel_bank8.lib tmp/xsocket.o + @$(AR) r tmp/kernel_bank8.lib tmp/xconnect.o + @$(AR) r tmp/kernel_bank8.lib tmp/xsend.o + @$(AR) r tmp/kernel_bank8.lib tmp/xclose_socket.o + @$(AR) r tmp/kernel_bank8.lib tmp/close_sockets_by_pid.o + + + @$(AS) --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 --verbose -s -ttelestrat src/kernel_main_memory.s -o tmp/kernel_main_memory.ld65 + @$(AS) --verbose -s -tnone --debug-info --cpu 6502 -tnone src/kernel8/src/kernel8.s -o tmp/kernel_bank8.ld65 $(ASFLAGS) > output.log + @$(AS) --verbose -s -tnone --debug-info -o kernel_bank0.ld65 -DWITH_SDCARD_FOR_ROOT=1 src/kernel_bank0.s $(ASFLAGS) > output.log + @$(AS) --verbose -s -tnone --debug-info -o kernelsd.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > output.log + + @$(AS) --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 --verbose -s -ttelestrat src/kernel_bank0.s -o tmp/kernel_bank0.ld65 --debug-info > memmap.md + @$(LD) -C cfg/rom.cfg tmp/kernel_bank8.ld65 tmp/kernel_bank0.ld65 tmp/kernel_main_memory.ld65 tmp/kernel_bank8.lib src/kernel8/orixlibs/ksocket/usr/share/ksocket/2025.1/ksocket.lib src/kernel8/orixlibs/ch395/usr/share/ch395/2024.4/ch395.lib -o kernel8.rom -Ln tmp/kernel8sd.sym -m tmp/memmap8.txt -vm + + @cp kernel.rom kernelsd.rom - @sed -re 's/al 00(.{4}) \.(.+)$$/\1 \2/' kernelsd.sym| sort > kernelsd2.sym > output.log + #@sed -re 's/al 00(.{4}) \.(.+)$$/\1 \2/' kernelsd.sym| sort > kernelsd2.sym > output.log @cp kernelsd.rom $(PATH_PACKAGE_ROM)/ - @cp kernelsd.sym $(PATH_PACKAGE_ROM)/ - @cp kernelsd.map $(PATH_PACKAGE_ROM)/ + #@cp kernelsd.sym $(PATH_PACKAGE_ROM)/ + #@cp kernelsd.map $(PATH_PACKAGE_ROM)/ - @echo Build kernelus.rom for Twilighte board + @echo "########################################################" + @echo "# Build kernelus.rom for Twilighte board #" + @echo "########################################################" + @$(AS) --verbose -s -tnone --debug-info -o kernel_bank0.ld65 -DWITH_TWILIGHTE_BOARD=1 src/kernel_bank0.s $(ASFLAGS) > output.log @echo "WITH_TWILIGHTE_BOARD">$(PATH_PACKAGE_ROM)/kernelus.lst @$(AS) --verbose -s -tnone --debug-info -o kernelus.ld65 $(SOURCE) $(ASFLAGS) > output.log - @$(LD) -C src/kernel.cfg kernelus.ld65 -m kernelus.map -DWITH_TWILIGHTE_BOARD=1 -Ln kernelus.sym > output.log + @$(LD) -C cfg/kernel.cfg tmp/kernelsd.ld65 tmp/kernel_bank0.ld65 tmp/kernel_main_memory.ld65 tmp/kernel.lib -m kernelus.map -DWITH_TWILIGHTE_BOARD=1 -Ln kernelus.sym > output.log @cp kernel.rom kernelus.rom @cp kernelus.rom $(PATH_PACKAGE_ROM)/ unittest: - $(CC) $(CFLAGS) tests/mkdir.c -o tmkdir - $(CC) $(CFLAGS) tests/fwrite.c -o tfwrite + @$(CC) $(CFLAGS) tests/mkdir.c -o tmp/tmkdir + @$(CC) $(CFLAGS) tests/fwrite.c -o tmp/tfwrite + @$(CC) $(CFLAGS) tests/unit_test/mainarg.s -I dependencies/orix-sdk/macros/ -o tmp/1000 --start-addr 2048 + @$(CC) $(CFLAGS) tests/unit_test/mainarg.s -I dependencies/orix-sdk/macros/ -o tmp/1256 --start-addr 2304 memmap: - @$(AS) --verbose -s -tnone --debug-info -o kernel-telestrat.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > memmap.md - @$(LD) -C src/kernel.cfg kernel-telestrat.ld65 -m kernel.map -o kernel-telestrat.ld65.rom -DWITH_ACIA=2 -DWITH_SDCARD_FOR_ROOT=1 -Ln kernel-telestrat.ca.sym - sh generate_memmap.sh + @echo "########################################################" + @echo "# Build memmap.md #" + @echo "########################################################" + @$(AS) --cpu 6502 -DMEMMAP_GENERATE=1 --verbose -s -ttelestrat src/kernel_main_memory.s -o tmp/kernel_main_memory.ld65 > memmap.md + #@$(LD) -C cfg/kernel.cfg tmp/kernelsd.ld65 tmp/kernel_bank0.ld65 tmp/kernel_main_memory.ld65 tmp/kernel.lib -m kernelus.map -o kernel-telestrat.ld65.rom -DWITH_ACIA=2 -DWITH_SDCARD_FOR_ROOT=1 -Ln kernel-telestrat.ca.sym + @sh generate_memmap.sh test: - cp Makefile build/usr/src/kernel/ - cp README.md build/usr/src/kernel/ - cp src/* build/usr/src/kernel/ -adpR - cp README.md build/usr/share/doc/$(PROGRAM_NAME)/ - ls -l $(HOMEDIR) - export ORIX_PATH=`pwd` - sh tools/builddocs.sh - cd build && tar -c * > ../$(PROGRAM_NAME).tar && cd .. - filepack $(PROGRAM_NAME).tar $(PROGRAM_NAME).pkg - gzip $(PROGRAM_NAME).tar - mv $(PROGRAM_NAME).tar.gz $(PROGRAM_NAME).tgz + @cp Makefile build/usr/src/kernel/ + @cp README.md build/usr/src/kernel/ + @cp src/* build/usr/src/kernel/ -adpR + @cp README.md build/usr/share/doc/$(PROGRAM_NAME)/ + @ls -l $(HOMEDIR) + @export ORIX_PATH=`pwd` + @sh tools/builddocs.sh + @cd build && tar -c * > ../$(PROGRAM_NAME).tar && cd .. + @filepack $(PROGRAM_NAME).tar $(PROGRAM_NAME).pkg + @gzip $(PROGRAM_NAME).tar + @mv $(PROGRAM_NAME).tar.gz $(PROGRAM_NAME).tgz diff --git a/README.md b/README.md index f12ba91c..519fbd5e 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,53 @@ here is the list of available "compile option" * Kernel tries to start binary set in his rom label 'str_binary_to_start' * it allocates a process struct (first malloc) * and register it in processlist + + +## generate .inc + +MEMORY { + #... + + KRNL1: file = "kernel.rom", start = $C000, size = $3FFF; + KRNL2: file = "kernel2.rom", start =$C000, size = $3FFF; + INCL: file="kernel2.inc", start=$0000, size = $FFFF; +} +SEGMENTS { + # ... + KERNEL: load = KRNL1, type = ro, define = yes, optional = yes; + EXTEND: load = KRNL2, type = ro, define = yes, optional = yes; + INCLUDE: load = INCL, optional = yes; +} + + + + +.feature org_per_seg +.pushseg + .segment "EXTEND" + .org $C000 ; + + + ; .segment "KERNEL" + ; .org $C000 + + +.popseg +Macro + + +.macro addsym symbole + .pushseg + .segment "INCLUDE" + .byte .sprintf("%s = $%x", .string(symbole), symbole) + .popseg +.endmacro + +Et enfin, pour ajouter un symbole dans le fichier .inc: + +.proc xvalue_routine + lda #$00 + .... +.endproc + +addsym xvalue_routine diff --git a/VERSION b/VERSION index 2cf03e51..103ea540 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2024.1 \ No newline at end of file +2025.1 \ No newline at end of file diff --git a/cfg/kernel.cfg b/cfg/kernel.cfg new file mode 100644 index 00000000..4d28d653 --- /dev/null +++ b/cfg/kernel.cfg @@ -0,0 +1,58 @@ +FEATURES { + STARTADDRESS: default = $1000; +} +SYMBOLS { + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STACKSTART__: type = weak, value = $8000; + __ZPSTART__: type = weak, value = $0080; +} +MEMORY { + ZP: file = "", define = yes, start = __ZPSTART__, size = $001F; + MAIN: file = %O, start = %S, size = __STACKSTART__ - __STACKSIZE__ - %S; + + BANK7: type = ro, start = $C000, size = $4000-16, file = "kernel.rom", fill = yes; + ORIXVEC7: start = $FFF0, size = 10 , file = "kernel.rom", fill = yes; + CPUVEC7: start = $FFFA, size = 6 , file = "kernel.rom", fill = yes; + INCL: file = "kernel_inc.inc", start=$0000, size = $FFFF; + + } +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + STARTUP: load = MAIN, type = ro, define = yes, optional = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = rw, define = yes, optional = yes; + RODATA: load = MAIN, type = rw, define = yes, optional = yes; + DATA: load = MAIN, type = rw, define = yes, optional = yes; + BSS: load = MAIN, type = bss, define = yes, optional = yes; + + SIGNATURE: load = MAIN, type = ro, define = yes, optional = yes; + INCLUDE: load = INCL, optional = yes; + # BANK8: load = BANK8, type = ro; + # ORIXVECT8: load = ORIXVEC8, type = ro, define = yes, optional = yes; + # CPUVECT8: load = CPUVEC8, type = ro, define = yes, optional = yes; + + BANK7: load = BANK7 , type = ro, define = yes; + ORIXVECT7: load = ORIXVEC7, type = ro, define = yes; + CPUVECT7: load = CPUVEC7, type = ro, define = yes; + + # BANK0: load = BANK0, type = ro; + # ORIXVECT0: load = ORIXVEC0, type = ro, define = yes, optional = yes; + # CPUVECT0: load = CPUVEC0, type = ro, define = yes, optional = yes; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} + diff --git a/cfg/kernel_bank8.cfg b/cfg/kernel_bank8.cfg new file mode 100644 index 00000000..579b6e2a --- /dev/null +++ b/cfg/kernel_bank8.cfg @@ -0,0 +1,82 @@ +FEATURES { + STARTADDRESS: default = $C000; +} +SYMBOLS { + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STACKSTART__: type = weak, value = $8000; + __ZPSTART__: type = weak, value = $0080; +} +MEMORY { + ZP: file = "", define = yes, start = __ZPSTART__, size = $001F; + MAIN: file = %O, start = %S, size = $10000 - %S - 16, fill = yes, fillval = $ff; + + BANK8: type = ro, start = $C000, size = $4000-16, file = "kernel8.rom", fill = yes; + ORIXVEC: start = $FFF0, size = 10 , file = "kernel8.rom", fill = yes; + CPUVEC: start = $FFFA, size = 6 , file = "kernel8.rom", fill = yes; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + STARTUP: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = rw; + RODATA: load = MAIN, type = rw; + DATA: load = MAIN, type = rw; + BSS: load = MAIN, type = bss, define = yes, optional = yes; + # BSS: load = MAIN, type = bss, define = yes; + SIGNATURE: load = MAIN, type = ro, define = yes, optional = yes; + ORIXVECT: load = ORIXVEC, type = ro, define = yes; + CPUVECT: load = CPUVEC, type = ro, define = yes; + BANK8: load = BANK8 , type = ro, define = yes; + +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} + +# FEATURES { +# STARTADDRESS: default = $C000; +# } +# SYMBOLS { +# # __STACKSIZE__: type = weak, value = $0800; # 2k stack +# # __STACKSTART__: type = weak, value = $8000; +# # __ZPSTART__: type = weak, value = $0080; +# } +# MEMORY { +# # ZP: file = "", define = yes, start = __ZPSTART__, size = $001F; +# MAIN: file = %O, start = %S, size = $4000; + +# # BANK8: type = ro, start = $C000, size = $4000-16, file = "kernel8.rom", fill = yes; + +# # CPUVEC8: start = $FFFA, size = 6 , file = "kernel8.rom", fill = yes; +# } +# SEGMENTS { +# # ZEROPAGE: load = ZP, type = zp; +# # STARTUP: load = MAIN, type = ro, define = yes, optional = yes; +# # LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; +# # ONCE: load = MAIN, type = ro, define = yes, optional = yes; +# CODE: load = MAIN, type = ro, define = yes, optional = yes; +# # RODATA: load = MAIN, type = ro, define = yes, optional = yes; +# # DATA: load = MAIN, type = ro, define = yes, optional = yes; +# # BSS: load = MAIN, type = bss, define = yes, optional = yes; + +# # SIGNATURE: load = MAIN, type = ro, define = yes, optional = yes; + +# # BANK8: load = BANK8, type = ro; +# # ORIXVECT8: load = ORIXVEC8, type = ro, define = yes, optional = yes; +# # CPUVECT8: load = CPUVEC8, type = ro, define = yes, optional = yes; + + +# } diff --git a/cfg/rom.cfg b/cfg/rom.cfg new file mode 100644 index 00000000..8d82f0be --- /dev/null +++ b/cfg/rom.cfg @@ -0,0 +1,29 @@ +FEATURES { + STARTADDRESS: default = $C000; +} + +SYMBOLS { + __ZPSTART__: type = weak, value = $0000; +} + +MEMORY { + ZP: file = "", define = yes, start = __ZPSTART__, size = $0100 - __ZPSTART__; + MAIN: file = %O, start = %S, size = $10000 - %S - 16, fill = yes, fillval = $ff; + ORIXVEC: start = $FFF0, size = 10; + CPUVEC: start = $FFFA, size = 6; +} + +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + ENTRY_TBL: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + DATA: load = MAIN, type = ro, optional = yes; + RODATA: load = MAIN, type = ro, optional = yes; + BSS: load = MAIN, type = ro, optional = yes; + # INSTRTBL: load = MAIN, type = ro, define = yes; + # INSTRTBL2: load = MAIN, type = ro, define = yes; + # INSTRJMP: load = MAIN, type = ro, define = yes; + SIGNATURE: load = MAIN, type = ro, define = yes, optional = yes; + ORIXVECT: load = ORIXVEC, type = ro, define = yes; + CPUVECT: load = CPUVEC, type = ro, define = yes; +} \ No newline at end of file diff --git a/dependencies/orix-sdk b/dependencies/orix-sdk index fe17aca6..a5640e25 160000 --- a/dependencies/orix-sdk +++ b/dependencies/orix-sdk @@ -1 +1 @@ -Subproject commit fe17aca694cc68fe05d0cfe9f6977e48da6250f3 +Subproject commit a5640e25fa03be5aaf2e81546eefc61fadf24d62 diff --git a/docs/ADDRESS_READ_BETWEEN_BANK.md b/docs/ADDRESS_READ_BETWEEN_BANK.md index 5914656c..0f31c7ee 100644 --- a/docs/ADDRESS_READ_BETWEEN_BANK.md +++ b/docs/ADDRESS_READ_BETWEEN_BANK.md @@ -1,2 +1 @@ # ADDRESS_READ_BETWEEN_BANK -* XWSTR0 diff --git a/docs/ADIODB_VECTOR.md b/docs/ADIODB_VECTOR.md index f36ee75b..4fe86ca8 100644 --- a/docs/ADIODB_VECTOR.md +++ b/docs/ADIODB_VECTOR.md @@ -1,5 +1 @@ # ADIODB_VECTOR -* XWR0 -* XWR0 -* XRD0 -* XRD0 diff --git a/docs/ADSCR.md b/docs/ADSCR.md index 03c64371..ca795a73 100644 --- a/docs/ADSCR.md +++ b/docs/ADSCR.md @@ -1,3 +1 @@ # ADSCR -* XWR0 -* XWR0 diff --git a/docs/ADSCRH.md b/docs/ADSCRH.md index 86aad815..942fa1f7 100644 --- a/docs/ADSCRH.md +++ b/docs/ADSCRH.md @@ -1,3 +1 @@ # ADSCRH -* XWR0 -* XWR0 diff --git a/docs/ADSCRL.md b/docs/ADSCRL.md index aa4acf24..73f37d4b 100644 --- a/docs/ADSCRL.md +++ b/docs/ADSCRL.md @@ -1,3 +1 @@ # ADSCRL -* XWR0 -* XWR0 diff --git a/docs/CURSCR.md b/docs/CURSCR.md index 70b0283b..ada25841 100644 --- a/docs/CURSCR.md +++ b/docs/CURSCR.md @@ -1,3 +1 @@ # CURSCR -* XWR0 -* XWR0 diff --git a/docs/FLGCUR.md b/docs/FLGCUR.md index 65721b3d..37d8b462 100644 --- a/docs/FLGCUR.md +++ b/docs/FLGCUR.md @@ -1,3 +1 @@ # FLGCUR -* XWR0 -* XWR0 diff --git a/docs/FLGCUR_STATE.md b/docs/FLGCUR_STATE.md index bb708158..c81a6d55 100644 --- a/docs/FLGCUR_STATE.md +++ b/docs/FLGCUR_STATE.md @@ -1,3 +1 @@ # FLGCUR_STATE -* XWR0 -* XWR0 diff --git a/docs/KBDKEY.md b/docs/KBDKEY.md index b76a88df..a39f4793 100644 --- a/docs/KBDKEY.md +++ b/docs/KBDKEY.md @@ -1,3 +1 @@ # KBDKEY -* XRD0 -* XRD0 diff --git a/docs/KBDSHT.md b/docs/KBDSHT.md index 2cdedca6..6600c050 100644 --- a/docs/KBDSHT.md +++ b/docs/KBDSHT.md @@ -1,3 +1 @@ # KBDSHT -* XRD0 -* XRD0 diff --git a/docs/KEYBOARD_COUNTER.md b/docs/KEYBOARD_COUNTER.md index b066d624..47628d86 100644 --- a/docs/KEYBOARD_COUNTER.md +++ b/docs/KEYBOARD_COUNTER.md @@ -1,3 +1 @@ # KEYBOARD_COUNTER -* XRD0 -* XRD0 diff --git a/docs/RES.md b/docs/RES.md index b3a6162e..df271125 100644 --- a/docs/RES.md +++ b/docs/RES.md @@ -1,26 +1 @@ # RES -* _create_file_pointer -* checking_fp_exists -* _set_to_value_seek_file -* kernel_create_process -* kernel_kill_process -* kernel_kill_process via XFREE_ROUTINE -* XDECAY -* XADRESS -* XDIVIS -* XREADBYTES_ROUTINE -* XPUTCWD_ROUTINE -* XWRITEBYTES_ROUTINE -* XFSEEK_ROUTINE -* XMKDIR_ROUTINE -* XRM_ROUTINE -* XOPENDIR -* XFILLM -* _XEXEC -* _XFORK -* _XFORK via kernel_create_process -* XMAINARGS_ROUTINE -* XGETARGV_ROUTINE -* kernel_try_to_find_command_in_bin_path -* XOPEN_ROUTINE -* XFREE_ROUTINE diff --git a/docs/RESB.md b/docs/RESB.md index ff316d2a..4d0408ac 100644 --- a/docs/RESB.md +++ b/docs/RESB.md @@ -1,20 +1 @@ # RESB -* checking_fp_exists -* kernel_create_process -* ZADCHA -* XDECAY -* XDIVIS -* XCLOSE_ROUTINE -* XGETCWD_ROUTINE -* XPUTCWD_ROUTINE -* XWRITEBYTES_ROUTINE -* XFSEEK_ROUTINE -* XOPENDIR -* compute_path_relative -* XFILLM -* _XEXEC -* _XFORK via kernel_create_process -* XGETARGV_ROUTINE -* getFileLength -* kernel_try_to_find_command_in_bin_path -* XOPEN_ROUTINE diff --git a/docs/RESC.md b/docs/RESC.md index ecd39671..3dec4e03 100644 --- a/docs/RESC.md +++ b/docs/RESC.md @@ -1,4 +1 @@ # RESC -* XOPENDIR -* compute_path_relative -* kernel_try_to_find_command_in_bin_path diff --git a/docs/RESD.md b/docs/RESD.md index b8517004..7935f88c 100644 --- a/docs/RESD.md +++ b/docs/RESD.md @@ -1,3 +1 @@ # RESD -* compute_path_relative -* kernel_try_to_find_command_in_bin_path diff --git a/docs/RESE.md b/docs/RESE.md index 0a6aa96e..21d2da98 100644 --- a/docs/RESE.md +++ b/docs/RESE.md @@ -1,3 +1 @@ # RESE -* compute_path_relative -* kernel_try_to_find_command_in_bin_path diff --git a/docs/RESF.md b/docs/RESF.md index 07747fd7..3d5fda33 100644 --- a/docs/RESF.md +++ b/docs/RESF.md @@ -1,3 +1 @@ # RESF -* compute_path_relative -* kernel_try_to_find_command_in_bin_path diff --git a/docs/RESG.md b/docs/RESG.md index 20efa94e..5d6a0a77 100644 --- a/docs/RESG.md +++ b/docs/RESG.md @@ -1,2 +1 @@ # RESG -* kernel_try_to_find_command_in_bin_path diff --git a/docs/RESH.md b/docs/RESH.md index b342aeee..b8e0c4c4 100644 --- a/docs/RESH.md +++ b/docs/RESH.md @@ -1,2 +1 @@ # RESH -* kernel_try_to_find_command_in_bin_path diff --git a/docs/SCRNB.md b/docs/SCRNB.md index af59abcf..11e62264 100644 --- a/docs/SCRNB.md +++ b/docs/SCRNB.md @@ -1,3 +1 @@ # SCRNB -* XWR0 -* XWR0 diff --git a/docs/TR0.md b/docs/TR0.md index 042918d4..7e1a8df3 100644 --- a/docs/TR0.md +++ b/docs/TR0.md @@ -1,9 +1 @@ # TR0 -* XBINDX -* XDIVIS -* XREADBYTES_ROUTINE -* XFSEEK_ROUTINE -* XOPENDIR -* _XEXEC -* _XFORK -* XMAINARGS_ROUTINE diff --git a/docs/TR1.md b/docs/TR1.md index 62c2e55b..32cc4fad 100644 --- a/docs/TR1.md +++ b/docs/TR1.md @@ -1,8 +1 @@ # TR1 -* XBINDX -* XDIVIS -|MODIFY:KERNEL_XOPEN_PTR1:XFSEEK_ROUTINE -* _XEXEC -* _XFORK -* XMAINARGS_ROUTINE -|MODIFY:KERNEL_XOPEN_PTR1:XOPEN_ROUTINE diff --git a/docs/TR2.md b/docs/TR2.md index bb21b5f4..383b5b18 100644 --- a/docs/TR2.md +++ b/docs/TR2.md @@ -1,3 +1 @@ # TR2 -* XBINDX -* XMAINARGS_ROUTINE diff --git a/docs/TR3.md b/docs/TR3.md index 616a3def..d77aeaac 100644 --- a/docs/TR3.md +++ b/docs/TR3.md @@ -1,3 +1 @@ # TR3 -* XBINDX -* XMAINARGS_ROUTINE diff --git a/docs/TR4.md b/docs/TR4.md index 9f102227..168f7b6d 100644 --- a/docs/TR4.md +++ b/docs/TR4.md @@ -1,7 +1 @@ # TR4 -* kernel_create_process -* XBINDX -* XDECIM -* XFSEEK_ROUTINE -* _XFORK via kernel_create_process -* XMAINARGS_ROUTINE diff --git a/docs/TR5.md b/docs/TR5.md index db030728..53692fc1 100644 --- a/docs/TR5.md +++ b/docs/TR5.md @@ -1,8 +1 @@ # TR5 -* checking_fp_exists -* kernel_create_process -* kernel_kill_process via XFREE_ROUTINE -* XBINDX -* XDECIM -* _XFORK via kernel_create_process -* XOPEN_ROUTINE diff --git a/docs/TR6.md b/docs/TR6.md index 65de9081..ec980260 100644 --- a/docs/TR6.md +++ b/docs/TR6.md @@ -1,3 +1 @@ # TR6 -* XDECIM -* XFSEEK_ROUTINE diff --git a/docs/TR7.md b/docs/TR7.md index abdeb0fb..1c56f1a5 100644 --- a/docs/TR7.md +++ b/docs/TR7.md @@ -1,7 +1 @@ # TR7 -* XCLOSE_ROUTINE -* XFSEEK_ROUTINE -* XMKDIR_ROUTINE -* XOPENDIR -* XOPEN_ROUTINE -* XMALLOC_ROUTINE diff --git a/docs/i_o_counter.md b/docs/i_o_counter.md index 7b152055..eac23a23 100644 --- a/docs/i_o_counter.md +++ b/docs/i_o_counter.md @@ -1,5 +1 @@ # i_o_counter -* XWR0 -* XWR0 -* XRD0 -* XRD0 diff --git a/docs/i_o_save.md b/docs/i_o_save.md index 8c6b1b86..fa56efce 100644 --- a/docs/i_o_save.md +++ b/docs/i_o_save.md @@ -1,4 +1 @@ # i_o_save -* XWR0 -* XWSTR0 -* XWR0 diff --git a/docs/memmap_ram.html b/docs/memmap_ram.html index 6cedd851..3241dd04 100644 --- a/docs/memmap_ram.html +++ b/docs/memmap_ram.html @@ -1,9 +1,9 @@ <!DOCTYPE html> - <html> - <head> - <meta charset="UTF-8"> - <title>Page 0</title> - <style> + <html> + <head> + <meta charset="UTF-8"> + <title>Memmap</title> + <style> /* From extension vscode.github */ /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. @@ -11,12 +11,14 @@ *--------------------------------------------------------------------------------------------*/ .vscode-dark img[src$=\#gh-light-mode-only], -.vscode-light img[src$=\#gh-dark-mode-only] { +.vscode-light img[src$=\#gh-dark-mode-only], +.vscode-high-contrast:not(.vscode-high-contrast-light) img[src$=\#gh-light-mode-only], +.vscode-high-contrast-light img[src$=\#gh-dark-mode-only] { display: none; } </style> - <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css"> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css"> <link href="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/markdown.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/highlight.css"> @@ -37,11 +39,108 @@ vertical-align: middle; pointer-events: none; } +</style> +<style> +:root { + --color-note: #0969da; + --color-tip: #1a7f37; + --color-warning: #9a6700; + --color-severe: #bc4c00; + --color-caution: #d1242f; + --color-important: #8250df; +} + +</style> +<style> +@media (prefers-color-scheme: dark) { + :root { + --color-note: #2f81f7; + --color-tip: #3fb950; + --color-warning: #d29922; + --color-severe: #db6d28; + --color-caution: #f85149; + --color-important: #a371f7; + } +} + +</style> +<style> +.markdown-alert { + padding: 0.5rem 1rem; + margin-bottom: 16px; + color: inherit; + border-left: .25em solid #888; +} + +.markdown-alert>:first-child { + margin-top: 0 +} + +.markdown-alert>:last-child { + margin-bottom: 0 +} + +.markdown-alert .markdown-alert-title { + display: flex; + font-weight: 500; + align-items: center; + line-height: 1 +} + +.markdown-alert .markdown-alert-title .octicon { + margin-right: 0.5rem; + display: inline-block; + overflow: visible !important; + vertical-align: text-bottom; + fill: currentColor; +} + +.markdown-alert.markdown-alert-note { + border-left-color: var(--color-note); +} + +.markdown-alert.markdown-alert-note .markdown-alert-title { + color: var(--color-note); +} + +.markdown-alert.markdown-alert-important { + border-left-color: var(--color-important); +} + +.markdown-alert.markdown-alert-important .markdown-alert-title { + color: var(--color-important); +} + +.markdown-alert.markdown-alert-warning { + border-left-color: var(--color-warning); +} + +.markdown-alert.markdown-alert-warning .markdown-alert-title { + color: var(--color-warning); +} + +.markdown-alert.markdown-alert-tip { + border-left-color: var(--color-tip); +} + +.markdown-alert.markdown-alert-tip .markdown-alert-title { + color: var(--color-tip); +} + +.markdown-alert.markdown-alert-caution { + border-left-color: var(--color-caution); +} + +.markdown-alert.markdown-alert-caution .markdown-alert-title { + color: var(--color-caution); +} + </style> - </head> - <body class="vscode-body vscode-light"> - <h1 id="page-0">Page 0</h1> + </head> + <body class="vscode-body vscode-light"> + <h1 id="memmap">Memmap</h1> +<h2 id="page-0">Page 0</h2> <table> <thead> <tr> @@ -277,18 +376,18 @@ <h1 id="page-0">Page 0</h1> <tr> <td style="text-align:left">RAM</td> <td style="text-align:left"><span style="color:green">FREE</span></td> -<td style="text-align:left">$2E-$31</td> +<td style="text-align:left">$2E-$14</td> <td style="text-align:left"></td> </tr> <tr> <td style="text-align:left">RAM</td> -<td style="text-align:left">ptr1</td> -<td style="text-align:left">$32-$33</td> +<td style="text-align:left">ADDRESS_READ_BETWEEN_BANK</td> +<td style="text-align:left">$15-$16</td> <td style="text-align:left">2</td> </tr> <tr> <td style="text-align:left">RAM</td> -<td style="text-align:left">tmp1</td> +<td style="text-align:left">BNKCIB_DOUBLON</td> <td style="text-align:left">$34-$34</td> <td style="text-align:left">1</td> </tr> @@ -312,7 +411,7 @@ <h1 id="page-0">Page 0</h1> </tr> <tr> <td style="text-align:left">RAM</td> -<td style="text-align:left">TIMEUD</td> +<td style="text-align:left">TIMEUD (used in cc65 clock function)</td> <td style="text-align:left">$44-$45</td> <td style="text-align:left">2</td> </tr> @@ -420,7 +519,7 @@ <h1 id="page-0">Page 0</h1> </tr> </tbody> </table> -<h1 id="page-2">Page 2</h1> +<h2 id="page-2">Page 2</h2> <table> <thead> <tr> @@ -488,8 +587,14 @@ <h1 id="page-2">Page 2</h1> <tr> <td style="text-align:left">RAM</td> <td style="text-align:left"><span style="color:green">FREE</span></td> -<td style="text-align:left">$0209-$020F</td> -<td style="text-align:left">6</td> +<td style="text-align:left">$0209-$020C</td> +<td style="text-align:left">4</td> +</tr> +<tr> +<td style="text-align:left">RAM</td> +<td style="text-align:left">FLGTEL</td> +<td style="text-align:left">$020D-$020D</td> +<td style="text-align:left">1</td> </tr> <tr> <td style="text-align:left">RAM</td> @@ -566,8 +671,8 @@ <h1 id="page-2">Page 2</h1> <tr> <td style="text-align:left">RAM</td> <td style="text-align:left">SCRY</td> -<td style="text-align:left">$0224-$0228</td> -<td style="text-align:left">1</td> +<td style="text-align:left">$0224-$0227</td> +<td style="text-align:left">4</td> </tr> <tr> <td style="text-align:left">RAM</td> @@ -644,8 +749,8 @@ <h1 id="page-2">Page 2</h1> <tr> <td style="text-align:left">RAM</td> <td style="text-align:left">SCRTXT</td> -<td style="text-align:left">$0256-$025C</td> -<td style="text-align:left">604</td> +<td style="text-align:left">$0256-$0260</td> +<td style="text-align:left">4</td> </tr> <tr> <td style="text-align:left">RAM</td> @@ -745,12 +850,18 @@ <h1 id="page-2">Page 2</h1> </tr> <tr> <td style="text-align:left">RAM</td> -<td style="text-align:left">kernel_malloc_free_chunk_size_low</td> +<td style="text-align:left">kernel_malloc_free_chunk_size</td> <td style="text-align:left">$02BA-$02C3</td> <td style="text-align:left">10</td> </tr> <tr> <td style="text-align:left">RAM</td> +<td style="text-align:left">kernel_xmalloc_call</td> +<td style="text-align:left">$02C4-$02EB</td> +<td style="text-align:left">39</td> +</tr> +<tr> +<td style="text-align:left">RAM</td> <td style="text-align:left">FLGRST</td> <td style="text-align:left">$02EE-$02EE</td> <td style="text-align:left">1</td> @@ -763,12 +874,6 @@ <h1 id="page-2">Page 2</h1> </tr> <tr> <td style="text-align:left">RAM</td> -<td style="text-align:left">kernel_xmalloc_call</td> -<td style="text-align:left">$02C4-$02EB</td> -<td style="text-align:left">39</td> -</tr> -<tr> -<td style="text-align:left">RAM</td> <td style="text-align:left"><span style="color:green">FREE</span></td> <td style="text-align:left">$02EC-$02ED</td> <td style="text-align:left">2</td> @@ -799,7 +904,7 @@ <h1 id="page-2">Page 2</h1> </tr> </tbody> </table> -<h1 id="page-3">Page 3</h1> +<h2 id="page-3">Page 3</h2> <table> <thead> <tr> @@ -818,7 +923,7 @@ <h1 id="page-3">Page 3</h1> </tr> </tbody> </table> -<h1 id="page-4">Page 4</h1> +<h2 id="page-4">Page 4</h2> <table> <thead> <tr> @@ -831,13 +936,13 @@ <h1 id="page-4">Page 4</h1> <tbody> <tr> <td style="text-align:left">RAM</td> -<td style="text-align:left">page4 overlay_access</td> -<td style="text-align:left">$0419-$0436</td> -<td style="text-align:left">54</td> +<td style="text-align:left">page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY</td> +<td style="text-align:left">$0411-$0414</td> +<td style="text-align:left">3</td> </tr> </tbody> </table> -<h1 id="page-56">Page 5&6</h1> +<h2 id="page-56">Page 5&6</h2> <table> <thead> <tr> @@ -850,7 +955,7 @@ <h1 id="page-56">Page 5&6</h1> <tbody> <tr> <td style="text-align:left">RAM</td> -<td style="text-align:left">BUFNOM</td> +<td style="text-align:left"><span style="color:green">FREE</span></td> <td style="text-align:left">$0517-$0525</td> <td style="text-align:left">14</td> </tr> @@ -879,76 +984,9 @@ <h1 id="page-56">Page 5&6</h1> <td style="text-align:left">163</td> </tr> </tbody> -</table> -<h1 id="kernel-bank-7">Kernel bank 7</h1> -<table> -<thead> -<tr> -<th style="text-align:left">Type</th> -<th style="text-align:left">Name</th> -<th style="text-align:left">Range</th> -<th style="text-align:left">Size</th> -</tr> -</thead> -<tbody> -<tr> -<td style="text-align:left">ROM</td> -<td style="text-align:left"><span style="color:green">FREE</span></td> -<td style="text-align:left">$feea-$fff0</td> -<td style="text-align:left">262</td> -</tr> -<tr> -<td style="text-align:left">#Bank 0</td> -<td style="text-align:left"></td> -<td style="text-align:left"></td> -<td style="text-align:left"></td> -</tr> -<tr> -<td style="text-align:left">Type</td> -<td style="text-align:left">Name</td> -<td style="text-align:left">Range</td> -<td style="text-align:left">Size</td> -</tr> -<tr> -<td style="text-align:left">--------</td> -<td style="text-align:left">----------------------------</td> -<td style="text-align:left">-------</td> -<td style="text-align:left">-----</td> -</tr> -<tr> -<td style="text-align:left">BANK0</td> -<td style="text-align:left">BUFBUF</td> -<td style="text-align:left">$c080-$c0b6</td> -<td style="text-align:left">54</td> -</tr> -<tr> -<td style="text-align:left">BANK0</td> -<td style="text-align:left">BUFROU</td> -<td style="text-align:left">$c500-$c54e</td> -<td style="text-align:left"></td> -</tr> -<tr> -<td style="text-align:left">BANK0</td> -<td style="text-align:left">TELEMON_KEYBOARD_BUFFER_BEGIN</td> -<td style="text-align:left">$c5c4-$c680</td> -<td style="text-align:left"></td> -</tr> -<tr> -<td style="text-align:left">BANK0</td> -<td style="text-align:left">XMALLOC (copy from kernel)</td> -<td style="text-align:left">$fb9c-$fc48</td> -<td style="text-align:left"></td> -</tr> -<tr> -<td style="text-align:left">BANK0</td> -<td style="text-align:left">X<span style="color:green">FREE</span> (copy from kernel)</td> -<td style="text-align:left">$fc48-$fecd</td> -<td style="text-align:left"></td> -</tr> -</tbody> </table> - <script async src="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.js"></script> - - </body> - </html> \ No newline at end of file + <script async src="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.js"></script> + + </body> + </html> \ No newline at end of file diff --git a/docs/memmap_ram.md b/docs/memmap_ram.md index e4ea2c0c..da96d42f 100644 --- a/docs/memmap_ram.md +++ b/docs/memmap_ram.md @@ -1,5 +1,7 @@ # Memmap + ## Page 0 + |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| |RAM|RES | $00-$01 | 2 | @@ -39,9 +41,9 @@ |RAM|SCRNB | $28-$29 | 2 | |RAM|ADKBD | $2A-$2B | 2 | |RAM|PTR_READ_DEST | $2C-$2D | 2 | -|RAM|<span style="color:green">FREE</span> | $2E-$31 | | -|RAM|ptr1 | $32-$33 | 2 | -|RAM|tmp1 | $34-$34 | 1 | +|RAM|<span style="color:green">FREE</span> | $2E-$14 | | +|RAM|ADDRESS_READ_BETWEEN_BANK | $15-$16 | 2 | +|RAM|BNKCIB_DOUBLON | $34-$34 | 1 | |RAM|<span style="color:green">FREE</span> | $35-$3F | | |RAM|ADCLK | $40-$41 | 2 | |RAM|TIMEUS | $42-$43 | 2 | @@ -75,7 +77,8 @@ |RAM|KERNEL_MALLOC_TYPE | $0206-$0206 | 1 | |RAM|KERNEL_SAVE_XEXEC_CURRENT_SET| $0207-$0207 | 1 | |RAM|KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM| $0208-$0209 | 1 | -|RAM|<span style="color:green">FREE</span> | $0209-$020F | 6 | +|RAM|<span style="color:green">FREE</span> | $020A-$020C | 3 | +|RAM|FLGTEL | $020D-$020D | 1 | |RAM|TIMED | $0210-$0210 | 1 | |RAM|TIMES | $0211-$0211 | 1 | |RAM|TIMEM | $0212-$0212 | 1 | @@ -134,8 +137,7 @@ ## Page 4 |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| -|RAM|page4 overlay_access | $0419-$0436 | 54 | -|RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0411 | 3 | +|RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0414 | 3 | ## Page 5&6 |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| @@ -144,15 +146,3 @@ |RAM|main kernel process struct | $0579-$058F | 22 | |RAM|BUFEDT | $0590-$05FE | 110 | |RAM|KERNEL_MEMORY_DRIVER | $05FE-$06A1 | 163 | -## Kernel bank 7 -| Type | Name | Range | Size | -| :-------- |:---------------------------- |:------- |:-----| -|ROM|<span style="color:green">FREE</span> |$feee-$fff0| 258 | -## Bank 0 -| Type | Name | Range | Size | -| -------- | ---------------------------- | ------- |-----| -|BANK0|BUFBUF | $c080-$c0b6 | 54 | -|BANK0|BUFROU | $c500-$c54e | | -|BANK0|TELEMON_KEYBOARD_BUFFER_BEGIN | $c5c4-$c680 | | -|BANK0|XMALLOC (copy from kernel) | $fba0-$fc4c | | -|BANK0|X<span style="color:green">FREE</span> (copy from kernel) | $fc4c-$fed1 | | diff --git a/docs/primitives/XGETCWD_ROUTINE.md b/docs/primitives/XGETCWD_ROUTINE.md index e64d8164..98f4ba3b 100644 --- a/docs/primitives/XGETCWD_ROUTINE.md +++ b/docs/primitives/XGETCWD_ROUTINE.md @@ -1,3 +1,2 @@ # XGETCWD_ROUTINE -* RESB diff --git a/docs/work_channel.md b/docs/work_channel.md index 98f04b62..56a130a1 100644 --- a/docs/work_channel.md +++ b/docs/work_channel.md @@ -1,6 +1 @@ # work_channel -* XWR0 -* XWSTR0 -* XRD0 -* XRD0 -* XOP0 diff --git a/memmap.md b/memmap.md index 85ec4182..2677a126 100644 --- a/memmap.md +++ b/memmap.md @@ -1,229 +1,35 @@ -KERNEL_MAX_PATH_LENGTH : 49 bytes +kernel_end_of_variables_before_BUFNOM : 503 +kernel_end_of_variables_before_BUFEDT : 58f +kernel_end_of_memory_for_kernel (malloc will start at this adress) : 6a1 +================================================================== +File memory +================================================================== +_KERNEL_FILE size (One fp struct) : $38 bytes +kernel_one_process_struct size (struct for one process) : $76 bytes +With all the parameter all process could use 494 bytes in memory, if it's allocated KERNEL_MAX_PROCESS (Max process in the system) : 4 KERNEL_MAX_FP_PER_PROCESS (Max file pointer per process): 2 KERNEL_USERZP_SAVE_LENGTH : 16 bytes KERNEL_LENGTH_MAX_CMDLINE : 37 kernel_process_struct size (struct init process) : $16 bytes -kernel_one_process_struct size (struct for one process) : $76 bytes -With all the parameter all process could use 494 bytes in memory, if it's allocated -================================================================== -Memory -================================================================== -KERNEL_MAX_NUMBER_OF_MALLOC (max malloc for all process) : 9 -kernel_malloc_struct size (malloc table) : $54 bytes -XMAINARGS_STRUCT size : $31 bytes -================================================================== -File memory -================================================================== -_KERNEL_FILE size (One fp struct) : $38 bytes -================================================================== -Resume -================================================================== -System will need almost 578 bytes in memory, if we reached KERNEL_MAX_PROCESS, KERNEL_MAX_NUMBER_OF_MALLOC and KERNEL_MALLOC_FREE_CHUNK_MAX allocated -kernel_end_of_variables_before_BUFNOM : 503 -kernel_end_of_variables_before_BUFEDT : 58f -kernel_end_of_memory_for_kernel (malloc will start at this adress) : 6a1 -int MALLOC_BUSY_SIZE_LOW=0x570; -int MALLOC_BUSY_SIZE_HIGH=0x567; -int MALLOC_BUSY_BEGIN_HIGH=0x539; -int MALLOC_BUSY_END_HIGH=0x54b; -int MALLOC_BUSY_BEGIN_LOW=0x542; -int MALLOC_BUSY_END_LOW=0x554; -int KERNEL_MAX_NUMBER_OF_MALLOC=0x9; -int MALLOC_FREE_SIZE_HIGH=0x2ba; -int MALLOC_FREE_SIZE_LOW=0x2bf; +int MALLOC_BUSY_SIZE_LOW = 0x570; +int MALLOC_BUSY_SIZE_HIGH = 0x567; +int MALLOC_BUSY_BEGIN_HIGH = 0x539; +int MALLOC_BUSY_END_HIGH = 0x54b; +int MALLOC_BUSY_BEGIN_LOW = 0x542; +int MALLOC_BUSY_END_LOW = 0x554; +int KERNEL_MAX_NUMBER_OF_MALLOC = 0x9; +int MALLOC_FREE_SIZE_HIGH =0x2ba; +int MALLOC_FREE_SIZE_LOW =0x2bf; int MALLOC_FREE_BEGIN_HIGH=0x52a; int MALLOC_FREE_BEGIN_LOW=0x525; int MALLOC_FREE_END_HIGH=0x534; int MALLOC_FREE_END_LOW=0x52f; int KERNEL_MALLOC_FREE_CHUNK_MAX=0x5; -|CALL:XCRLF:XWR0 -|CALL:XWR0:XCOSCR -|MODIFY:work_channel:XWR0 -|MODIFY:i_o_save:XWR0 -|MODIFY:i_o_counter:XWR0 -|MODIFY:ADIODB_VECTOR:XWR0 -|MODIFY:SCRNB:XWR0 -|MODIFY:ADSCR:XWR0 -|MODIFY:FLGCUR:XWR0 -|MODIFY:FLGCUR_STATE:XWR0 -|MODIFY:CURSCR:XWR0 -|MODIFY:ADSCRL:XWR0 -|MODIFY:ADSCRH:XWR0 -|MODIFY:FLGSCR:XWR0 -|MODIFY:i_o_save:XWSTR0 -|MODIFY:work_channel:XWSTR0 -|MODIFY:ADDRESS_READ_BETWEEN_BANK:XWSTR0 -|MODIFY:i_o_save:XWR0 -|MODIFY:i_o_counter:XWR0 -|MODIFY:ADIODB_VECTOR:XWR0 -|MODIFY:SCRNB:XWR0 -|MODIFY:ADSCR:XWR0 -|MODIFY:FLGCUR:XWR0 -|MODIFY:FLGCUR_STATE:XWR0 -|MODIFY:CURSCR:XWR0 -|MODIFY:ADSCRL:XWR0 -|MODIFY:ADSCRH:XWR0 -|MODIFY:FLGSCR:XWR0 -|MODIFY:work_channel:XRD0 -|MODIFY:i_o_counter:XRD0 -|MODIFY:ADDRESS_VECTOR_FOR_ADIOB:XRD0 -|MODIFY:ADIODB_VECTOR:XRD0 -|MODIFY:KEYBOARD_COUNTER:XRD0 -|MODIFY:KBDKEY:XRD0 -|MODIFY:KBDSHT:XRD0 -|MODIFY:$1B:XRDW0 -|MODIFY:work_channel:XRD0 -|MODIFY:i_o_counter:XRD0 -|MODIFY:ADDRESS_VECTOR_FOR_ADIOB:XRD0 -|MODIFY:ADIODB_VECTOR:XRD0 -|MODIFY:KEYBOARD_COUNTER:XRD0 -|MODIFY:KBDKEY:XRD0 -|MODIFY:KBDSHT:XRD0 -|MODIFY:IOTAB:XOP0 -|MODIFY:work_channel:XOP0 -|MODIFY:RES:_create_file_pointer -|MODIFY:KERNEL_ERRNO:_create_file_pointer -|CALL:XMALLOC:_create_file_pointer -|MODIFY:RES:checking_fp_exists -|MODIFY:RESB:checking_fp_exists -|MODIFY:TR5:checking_fp_exists -|MODIFY:RES:_set_to_value_seek_file -|MODIFY:RES:kernel_create_process -|MODIFY:RESB:kernel_create_process -|MODIFY:TR4:kernel_create_process -|MODIFY:TR5:kernel_create_process -|MODIFY:KERNEL_ERRNO:kernel_create_process -|MODIFY:KERNEL_MALLOC_TYPE:kernel_create_process -|MODIFY:KERNEL_XKERNEL_CREATE_PROCESS_TMP:kernel_create_process -|MODIFY:RES:kernel_kill_process -|MODIFY:TR5:kernel_kill_process via XFREE_ROUTINE -|MODIFY:RES:kernel_kill_process via XFREE_ROUTINE -|MODIFY:RESB:ZADCHA -|MODIFY:RES:XDECAY -|MODIFY:RESB:XDECAY -|MODIFY:TR0:XBINDX -|MODIFY:TR1:XBINDX -|MODIFY:TR2:XBINDX -|MODIFY:TR3:XBINDX -|MODIFY:TR4:XBINDX -|MODIFY:TR5:XBINDX -|CALL:XDECIM:XBINDX -|CALL:XDECIM:XWR0 -|MODIFY:TR4:XDECIM -|MODIFY:TR5:XDECIM -|MODIFY:TR6:XDECIM -|MODIFY:RES:XADRESS -|MODIFY:TR0:XDIVIS -|MODIFY:TR1:XDIVIS -|MODIFY:RES:XDIVIS -|MODIFY:RESB:XDIVIS -|MODIFY:RESB:XCLOSE_ROUTINE -|MODIFY:TR7:XCLOSE_ROUTINE -|MODIFY:PTR_READ_DEST:XREADBYTES_ROUTINE -|MODIFY:RES:XREADBYTES_ROUTINE -|MODIFY:TR0:XREADBYTES_ROUTINE -|MODIFY:RESB:XGETCWD_ROUTINE -|MODIFY:RES:XPUTCWD_ROUTINE -|MODIFY:RESB:XPUTCWD_ROUTINE -|MODIFY:PTR_READ_DEST:XWRITEBYTES_ROUTINE -|MODIFY:RES:XWRITEBYTES_ROUTINE -|MODIFY:RESB:XWRITEBYTES_ROUTINE -|MODIFY:TR0:XFSEEK_ROUTINE -|MODIFY:TR6:XFSEEK_ROUTINE -|MODIFY:TR7:XFSEEK_ROUTINE -|MODIFY:TR4:XFSEEK_ROUTINE -|MODIFY:RESB:XFSEEK_ROUTINE -|MODIFY:RES:XFSEEK_ROUTINE -|MODIFY:KERNEL_XOPEN_PTR1:XFSEEK_ROUTINE -|MODIFY:RES:XMKDIR_ROUTINE -|MODIFY:ptr1:XMKDIR_ROUTINE -|MODIFY:TR7:XMKDIR_ROUTINE -|MODIFY:RES:XRM_ROUTINE -CALL:_ch376_file_erase:XRM_ROUTINE -CALL:XCLOSE:XRM_ROUTINE -CALL:XOPEN:XRM_ROUTINE -|MODIFY:RES:XOPENDIR -|MODIFY:RESB:XOPENDIR -|MODIFY:RESC:XOPENDIR -|MODIFY:TR0:XOPENDIR -|MODIFY:TR7:XOPENDIR -|MODIFY:RESB:compute_path_relative -|MODIFY:RESC:compute_path_relative -|MODIFY:RESD:compute_path_relative -|MODIFY:RESE:compute_path_relative -|MODIFY:RESF:compute_path_relative -|MODIFY:DECTRV:XDECAL -|MODIFY:DECCIB:XDECAL -|MODIFY:DECFIN:XDECAL -|MODIFY:DECDEB:XDECAL -|MODIFY:RES:XFILLM -|MODIFY:RESB:XFILLM -|MODIFY:HRSPAT:XHIRES -|CALL:XTEXT:XCSSCR -|MODIFY:FLGTEL:XTEXT -|MODIFY:RES:_XEXEC -|MODIFY:TR0:_XEXEC -|MODIFY:TR1:_XEXEC -|MODIFY:BUFEDT:_XEXEC -|MODIFY:BNKOLD:_XEXEC -|MODIFY:BNK_TO_SWITCH:_XEXEC -|MODIFY:KERNEL_TMP_XEXEC:_XEXEC -|MODIFY:KERNEL_KERNEL_XEXEC_BNKOLD:_XEXEC -|MODIFY:HRS2:_XEXEC -|MODIFY:HRS3:_XEXEC -|MODIFY:VEXBNK:_XEXEC -|MODIFY:RESB:_XEXEC -|MODIFY:RES:_XFORK -|MODIFY:TR0:_XFORK -|MODIFY:TR1:_XFORK -|MODIFY:RES:_XFORK via kernel_create_process -|MODIFY:RESB:_XFORK via kernel_create_process -|MODIFY:TR4:_XFORK via kernel_create_process -|MODIFY:TR5:_XFORK via kernel_create_process -|MODIFY:TR0:XMAINARGS_ROUTINE -|MODIFY:TR1:XMAINARGS_ROUTINE -|MODIFY:TR2:XMAINARGS_ROUTINE -|MODIFY:TR3:XMAINARGS_ROUTINE -|MODIFY:TR4:XMAINARGS_ROUTINE -|MODIFY:RES:XMAINARGS_ROUTINE -|MODIFY:REB:XMAINARGS_ROUTINE -|MODIFY:KERNEL_ERRNO:XMAINARGS_ROUTINE -|MODIFY:RES:XGETARGV_ROUTINE -|MODIFY:RESB:XGETARGV_ROUTINE -|MODIFY:RESB:getFileLength -|MODIFY:ADHRS:XHRSCB -|MODIFY:ADHRS:XHRSCH -|MODIFY:HRSX40:XHRSCD -|MODIFY:HRSX6:XHRSCD -|MODIFY:HRSX40:XHRSCG -|MODIFY:HRSX6:XHRSCG -|MODIFY:RES:kernel_try_to_find_command_in_bin_path -|MODIFY:RESB:kernel_try_to_find_command_in_bin_path -|MODIFY:RESC:kernel_try_to_find_command_in_bin_path -|MODIFY:RESD:kernel_try_to_find_command_in_bin_path -|MODIFY:RESE:kernel_try_to_find_command_in_bin_path -|MODIFY:RESF:kernel_try_to_find_command_in_bin_path -|MODIFY:RESG:kernel_try_to_find_command_in_bin_path -|MODIFY:RESH:kernel_try_to_find_command_in_bin_path -|MODIFY:RESI:kernel_try_to_find_command_in_bin_path -|MODIFY:PTR_READ_DEST:kernel_try_to_find_command_in_bin_path -|MODIFY:RES:XOPEN_ROUTINE -|MODIFY:RESB:XOPEN_ROUTINE -|MODIFY:TR5:XOPEN_ROUTINE -|MODIFY:TR7:XOPEN_ROUTINE -|MODIFY:XOPEN_SAVE:XOPEN_ROUTINE -|MODIFY:XOPEN_FLAGS:XOPEN_ROUTINE -|MODIFY:XOPEN_RES_SAVE:XOPEN_ROUTINE -|MODIFY:XOPEN_SAVEA:XOPEN_ROUTINE -|MODIFY:KERNEL_ERRNO:XOPEN_ROUTINE -|MODIFY:KERNEL_XOPEN_PTR1:XOPEN_ROUTINE -|MODIFY:TR7:XMALLOC_ROUTINE -|MODIFY:KERNEL_ERRNO:XMALLOC_ROUTINE -|MODIFY:RES:XFREE_ROUTINE -|MODIFY:KERNEL_XFREE_TMP:XFREE_ROUTINE |#MEMMAP: Memmap +MEMMAP: |##MEMMAP: Page 0 +MEMMAP: |MEMMAP:Type | Name | Range | Size | |MEMMAP: :------- |:----------------------------- |:----------- |:-----| |MEMMAP:RAM|RES | $00-$01 | 2 | @@ -263,9 +69,9 @@ CALL:XOPEN:XRM_ROUTINE |MEMMAP:RAM|SCRNB | $28-$29 | 2 | |MEMMAP:RAM|ADKBD | $2A-$2B | 2 | |MEMMAP:RAM|PTR_READ_DEST | $2C-$2D | 2 | -|MEMMAP:RAM|FREE | $2E-$31 | | -|MEMMAP:RAM|ptr1 | $32-$33 | 2 | -|MEMMAP:RAM|tmp1 | $34-$34 | 1 | +|MEMMAP:RAM|FREE | $2E-$14 | | +|MEMMAP:RAM|ADDRESS_READ_BETWEEN_BANK | $15-$16 | 2 | +|MEMMAP:RAM|BNKCIB_DOUBLON | $34-$34 | 1 | |MEMMAP:RAM|FREE | $35-$3F | | |MEMMAP:RAM|ADCLK | $40-$41 | 2 | |MEMMAP:RAM|TIMEUS | $42-$43 | 2 | @@ -299,7 +105,8 @@ CALL:XOPEN:XRM_ROUTINE |MEMMAP:RAM|KERNEL_MALLOC_TYPE | $0206-$0206 | 1 | |MEMMAP:RAM|KERNEL_SAVE_XEXEC_CURRENT_SET| $0207-$0207 | 1 | |MEMMAP:RAM|KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM| $0208-$0209 | 1 | -|MEMMAP:RAM|FREE | $0209-$020F | 6 | +|MEMMAP:RAM|FREE | $0209-$020C | 4 | +|MEMMAP:RAM|FLGTEL | $020D-$020D | 1 | |MEMMAP:RAM|TIMED | $0210-$0210 | 1 | |MEMMAP:RAM|TIMES | $0211-$0211 | 1 | |MEMMAP:RAM|TIMEM | $0212-$0212 | 1 | @@ -358,8 +165,7 @@ CALL:XOPEN:XRM_ROUTINE |##MEMMAP: Page 4 |MEMMAP:Type | Name | Range | Size | |MEMMAP: :------- |:----------------------------- |:----------- |:-----| -|MEMMAP:RAM|page4 overlay_access | $0419-$0436 | 54 | -|MEMMAP:RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0411 | 3 | +|MEMMAP:RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0414 | 3 | |##MEMMAP: Page 5&6 |MEMMAP:Type | Name | Range | Size | |MEMMAP: :------- |:----------------------------- |:----------- |:-----| @@ -368,15 +174,3 @@ CALL:XOPEN:XRM_ROUTINE |MEMMAP:RAM|main kernel process struct | $0579-$058F | 22 | |MEMMAP:RAM|BUFEDT | $0590-$05FE | 110 | |MEMMAP:RAM|KERNEL_MEMORY_DRIVER | $05FE-$06A1 | 163 | -|##MEMMAP: Kernel bank 7 -|MEMMAP: Type | Name | Range | Size | -|MEMMAP: :-------- |:---------------------------- |:------- |:-----| -|MEMMAP:ROM|FREE |$feee-$fff0| 258 | -|##MEMMAP: Bank 0 -|MEMMAP: Type | Name | Range | Size | -|MEMMAP: -------- | ---------------------------- | ------- |-----| -|MEMMAP:BANK0|BUFBUF | $c080-$c0b6 | 54 | -|MEMMAP:BANK0|BUFROU | $c500-$c54e | | -|MEMMAP:BANK0|TELEMON_KEYBOARD_BUFFER_BEGIN | $c5c4-$c680 | | -|MEMMAP:BANK0|XMALLOC (copy from kernel) | $fba0-$fc4c | | -|MEMMAP:BANK0|XFREE (copy from kernel) | $fc4c-$fed1 | | diff --git a/run.bat b/run.bat deleted file mode 100644 index fd54a2b7..00000000 --- a/run.bat +++ /dev/null @@ -1,46 +0,0 @@ -@echo off - -rem SET ORICUTRON="..\..\..\..\oricutron-iss2-debug\" -SET ORICUTRON="D:\users\plifp\Onedrive\oric\oricutron_twilighte" - -rem set ORICUTRON="/d/Users/plifp/onedrive/oric/oricutron_twilighte" - - - -SET ORIGIN_PATH=%CD% - -SET ROM=kernel -rem -DWITH_SDCARD_FOR_ROOT=1 -%CC65%\ca65.exe --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 --verbose -s -ttelestrat --include-dir %CC65%\asminc\ src/%ROM%.asm -o %ROM%sd.ld65 --debug-info || goto :error -%CC65%\ld65.exe -tnone -DWITH_SDCARD_FOR_ROOT=1 %ROM%sd.ld65 -o %ROM%.rom -Ln kernelsd.sym -m memmap.txt -vm - - - - -%CC65%\ca65.exe --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 -DWITH_DEBUG=1 --verbose -s -ttelestrat --include-dir %CC65%\asminc\ src/kdebug.asm -o kdebugsd.ld65 --debug-info -%CC65%\ld65.exe -tnone -DWITH_SDCARD_FOR_ROOT=1 -DWITH_DEBUG=1 kdebugsd.ld65 -o kdebug.rom -Ln kdebugsd.sym -m memmap.txt -vm - -%CC65%\cl65.exe -ttelestrat tests/mkdir.c -o tmkdir -%CC65%\cl65.exe -ttelestrat tests/fwrite.c -o tfwrite -%CC65%\cl65.exe -ttelestrat -C tests/orix-sdk/cfg/telestrat_900.cfg tests/multiples_files_opened.c tests/multiples_files_fopen.s tests/exec.s -o multi - - -IF "%1"=="NORUN" GOTO End - -copy tmkdir %ORICUTRON%\sdcard\bin -copy tmkdir %ORICUTRON%\sdcard\bin -copy multi %ORICUTRON%\sdcard\bin\f -copy %ROM%.rom %ORICUTRON%\roms\ > NUL -rem copy kdebug.rom %ORICUTRON%\roms\ > NUL -copy bp.txt %ORICUTRON% -cd %ORICUTRON% - -oricutron -r :bp.txt - - -:End -cd %ORIGIN_PATH% -rem %OSDK%\bin\MemMap "%ORIGIN_PATH%\xa_labels_orix.txt" memmap.html O docs/telemon.css -exit /b -:error -echo Error de build diff --git a/run.sh b/run.sh index 1c8e249e..ffadf332 100644 --- a/run.sh +++ b/run.sh @@ -1,9 +1,92 @@ #! /bin/bash -ORICUTRON_PATH="/mnt/c/Users/plifp/OneDrive/oric/oricutron_wsl/oricutron" +#ORICUTRON_PATH="/mnt/c/Users/plifp/OneDrive/oric/oricutron_wsl/oricutron" + +#ORICUTRON_PATH="/mnt/c/Users/plifp/OneDrive/oric/oricutron_plugins/" +ORICUTRON_PATH="/mnt/c/Users/plifp/OneDrive/oric/projets/jedeoric/oricutron_assinie_plugins" CA65_INC=/usr/share/cc65/asminc/ # -DWITH_DEBUG=1 -ca65 --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 --verbose -s -ttelestrat src/kernel.asm -o tmp/kernelsd.ld65 --debug-info > memmap.md + +build_file() { + local file="$1" + local path="$2" + #echo Build $file + ca65 --cpu 6502 -tnone $path/$file.s -o tmp/$file.o + RET=$? + if [ $RET != 0 ] + then + echo Error + exit + fi +} + +ca65 --cpu 6502 -tnone src/functions/strings/xminma.asm -o tmp/xminma.o +ca65 --cpu 6502 -tnone src/functions/bank_mng/switch_to_kernel_extended.s -o tmp/switch_to_kernel_extended.o +ca65 --cpu 6502 -tnone src/functions/bank_mng/kernel_restore_banking_states.s -o tmp/kernel_restore_banking_states.o +ca65 --cpu 6502 -tnone src/functions/lib_mng/XBANK_ROUTINE.s -o tmp/xbank_routine.o +ca65 --cpu 6502 -tnone src/functions/network/init_network.s -o tmp/init_network.o +ca65 --cpu 6502 -tnone src/functions/network/xsocket.s -o tmp/xsocket.o +build_file "close_sockets_by_pid" "src/functions/network" +build_file "xconnect" "src/functions/network" +build_file "xsend" "src/functions/network" + +ca65 --cpu 6502 -tnone src/functions/network/xclose_socket.s -o tmp/xclose_socket.o + +RET=$? +if [ $RET != 0 ] +then +echo Error +exit +fi + +# Bank 8 +ca65 --cpu 6502 -tnone src/functions/bank_mng/search_free_bank.s -o tmp/search_free_bank.o +ca65 --cpu 6502 -tnone src/functions/bank_mng/kernel_free_bank.s -o tmp/kernel_free_bank.o +ca65 --cpu 6502 -tnone src/functions/bank_mng/kernel_free_bank_by_pid.s -o tmp/kernel_free_bank_by_pid.o + +ar65 r tmp/kernel.lib tmp/xminma.o +ar65 r tmp/kernel.lib tmp/switch_to_kernel_extended.o +ar65 r tmp/kernel.lib tmp/kernel_restore_banking_states.o +ar65 r tmp/kernel.lib tmp/xbank_routine.o + + +ar65 r tmp/kernel_bank8.lib tmp/init_network.o +ar65 r tmp/kernel_bank8.lib tmp/search_free_bank.o +ar65 r tmp/kernel_bank8.lib tmp/kernel_free_bank.o +ar65 r tmp/kernel_bank8.lib tmp/kernel_free_bank_by_pid.o +ar65 r tmp/kernel_bank8.lib tmp/xsocket.o +ar65 r tmp/kernel_bank8.lib tmp/xconnect.o +ar65 r tmp/kernel_bank8.lib tmp/xsend.o +ar65 r tmp/kernel_bank8.lib tmp/close_sockets_by_pid.o + + + +ca65 --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 --verbose -s -ttelestrat src/kernel_main_memory.s -o tmp/kernel_main_memory.ld65 +ca65 --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 --verbose -s -ttelestrat src/kernel.asm -o tmp/kernelsd.ld65 --debug-info > memmap.md + +RET=$? +if [ $RET != 0 ] +then + echo Error + exit +fi + +ca65 --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 --verbose -s -ttelestrat src/kernel_bank0.s -o tmp/kernel_bank0.ld65 --debug-info > memmap.md +ca65 --cpu 6502 -tnone src/kernel8/src/kernel8.s -o tmp/kernel_bank8.ld65 > memmap.md +RET=$? +if [ $RET != 0 ] +then + echo Error + exit +fi + + +#ld65 -tnone -DWITH_SDCARD_FOR_ROOT=1 tmp/kernelsd.ld65 tmp/kernel.lib -Ln tmp/kernelsd.sym -m tmp/memmap.txt -vm +echo "##########" +echo "# Bank 8 #" +echo "##########" +ld65 -C cfg/rom.cfg tmp/kernel_bank8.ld65 tmp/kernel_bank0.ld65 tmp/kernel_main_memory.ld65 tmp/kernel_bank8.lib src/kernel8/orixlibs/ksocket/usr/share/ksocket/2025.1/ksocket.lib src/kernel8/orixlibs/ch395/usr/share/ch395/2024.4/ch395.lib -o kernel8.rom -Ln tmp/kernel8sd.sym -m tmp/memmap8.txt -vm + RET=$? if [ $RET != 0 ] then @@ -11,21 +94,49 @@ echo Error exit fi -ld65 -C src/kernel.cfg -DWITH_SDCARD_FOR_ROOT=1 tmp/kernelsd.ld65 -Ln tmp/kernelsd.sym -m tmp/memmap.txt -vm +echo "##########" +echo "# Bank 7 #" +echo "##########" + +ld65 -C cfg/kernel.cfg -DWITH_SDCARD_FOR_ROOT=1 tmp/kernelsd.ld65 tmp/kernel_bank0.ld65 tmp/kernel_main_memory.ld65 tmp/kernel.lib -Ln tmp/kernelsd.sym -m tmp/memmap.txt -vm + #cl65 -ttelestrat -C tests/orix-sdk/cfg/telestrat_900.cfg tests/multiples_files_opened.c tests/multiples_files_fopen.s tests/exec.s -o multi #cl65 -ttelestrat -C tests/orix-sdk/cfg/telestrat_900.cfg tests/readdir.c tests/kernel_calls/readdir_extern.s -o b -ca65 --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 -DWITH_DEBUG=1 --verbose -s -ttelestrat src/kdebug.asm -o kdebugsd.ld65 --debug-info -ld65 -tnone -DWITH_SDCARD_FOR_ROOT=1 -DWITH_DEBUG=1 kdebugsd.ld65 -o kdebug.rom -Ln kdebugsd.sym -m memmap.txt -vm +#ca65 --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 -DWITH_DEBUG=1 --verbose -s -ttelestrat src/kdebug.asm -o kdebugsd.ld65 --debug-info +#ld65 -tnone -DWITH_SDCARD_FOR_ROOT=1 -DWITH_DEBUG=1 kdebugsd.ld65 -o kdebug.rom -Ln kdebugsd.sym -m memmap.txt -vm + + +# cl65 -ttelestrat tests/functions/bank_mng/search_free_bank.s -o tmp/1000 --start-addr 2048 +# cl65 -ttelestrat tests/functions/bank_mng/search_free_bank.s -o tmp/1256 --start-addr 2304 +# dependencies/orix-sdk/bin/relocbin.py3 -o tmp/sfbtest -2 tmp/1000 tmp/1256 +# cp tmp/sfbtest $ORICUTRON_PATH/sdcard/bin/ + +cl65 -ttelestrat tests/functions/network/netchk.s -o tmp/1000 --start-addr 2048 +cl65 -ttelestrat tests/functions/network/netchk.s -o tmp/1256 --start-addr 2304 +dependencies/orix-sdk/bin/relocbin.py3 -o tmp/netchk -2 tmp/1000 tmp/1256 +cp tmp/netchk $ORICUTRON_PATH/sdcard/bin/ cp kernel.rom $ORICUTRON_PATH/roms -# cp kdebug.rom $ORICUTRON_PATH/roms -cp tests/test_kernel $ORICUTRON_PATH/sdcard/bin/test +cp kernel8.rom $ORICUTRON_PATH/roms + +# # cp kdebug.rom $ORICUTRON_PATH/roms +# cp tests/test_kernel $ORICUTRON_PATH/sdcard/bin/test + #cp tests/kopened $ORICUTRON_PATH/sdcard/bin/ #cat tests/unit_test/xopen.sub > $ORICUTRON_PATH/sdcard/etc/AUTOBOOT -#cat tests/unit_test/xrm.sub >> $ORICUTRON_PATH/sdcard/etc/AUTOBOOT +cat tests/unit_test/start.sub > $ORICUTRON_PATH/sdcard/etc/AUTOBOOT + +# cp tests/unit_test/mainarg.sub $ORICUTRON_PATH/sdcard/bin/mainarg.sub + +# cl65 -ttelestrat tests/unit_test/mainarg.s -o 1000 --start-addr 2048 +# cl65 -ttelestrat tests/unit_test/mainarg.s -o 1256 --start-addr 2304 +# dependencies/orix-sdk/bin/relocbin.py3 -o mainarg -2 1000 1256 + + +#cp mainarg $ORICUTRON_PATH/sdcard/bin/mainarg cd $ORICUTRON_PATH ./oricutron diff --git a/src/functions/XWRx.asm b/src/functions/XWRx.asm index 54b6fe34..180b39f6 100644 --- a/src/functions/XWRx.asm +++ b/src/functions/XWRx.asm @@ -1,3 +1,5 @@ +.export XWR0_ROUTINE + XWR0_ROUTINE: .out .sprintf("|CALL:XWR0:XCOSCR") diff --git a/src/functions/bank_mng/kernel_free_bank.s b/src/functions/bank_mng/kernel_free_bank.s new file mode 100644 index 00000000..2ffdd5b3 --- /dev/null +++ b/src/functions/bank_mng/kernel_free_bank.s @@ -0,0 +1,43 @@ +.export kernel_free_bank + +.include "telestrat.inc" + +.include "../../include/kernel.inc" +.include "../../include/process.inc" +.include "../../include/memory.inc" +.include "../../include/files.inc" +;.include "../../kernel.inc" + +;.segment "BANK8" + +.import KERNEL_BANK_MANAGEMENT +.import kernel_process + +.proc kernel_free_bank + ;;@brief Free bank with id bank. PID is cleared in kernel bank + ;;@inputA Contains the id of the bank to free + ;;@modifyA + ;;@modifyX + ;;@modifyY + + ;;@returnsA + ;;@returnsX + ;;@returnsY + + stx TR2 ; Save + ldy TR2 + lda #$00 + ldx #$00 + MEMORY_PUT_VALUE_TO_BANK KERNEL_BANK_MANAGEMENT + + lda #kernel_bank_management_struct::KERNEL_BANK_PROCESS_ID + clc + adc TR2 + tay + + lda #$00 + ldx #$00 + MEMORY_PUT_VALUE_TO_BANK KERNEL_BANK_MANAGEMENT + + rts +.endproc diff --git a/src/functions/bank_mng/kernel_free_bank_by_pid.s b/src/functions/bank_mng/kernel_free_bank_by_pid.s new file mode 100644 index 00000000..2eda8ef3 --- /dev/null +++ b/src/functions/bank_mng/kernel_free_bank_by_pid.s @@ -0,0 +1,64 @@ +.export kernel_free_bank_by_pid + +.include "telestrat.inc" + +.include "../../include/kernel.inc" +.include "../../include/process.inc" +.include "../../include/memory.inc" +.include "../../include/files.inc" + +;.segment "BANK8" + +.import KERNEL_BANK_MANAGEMENT +.import kernel_process +.import kernel_free_bank + + + +.proc kernel_free_bank_by_pid + ;;@brief Free all bank with PID + ;;@inputA the pid + ;;@modifyA + ;;@modifyX + ;;@modifyY + ;;@modifyMEM_RES Tmp value + ;;@modifyMEM_RESB Tmp value + ;;@returnsA + ;;@returnsX + ;;@returnsY + sta TR0 ; Save pid to compare + + ldx #$00 ; ??? + + ldy #$00 ; First bank + sty TR1 + + lda #<KERNEL_BANK_MANAGEMENT + ldy #>KERNEL_BANK_MANAGEMENT + + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + +@check_next_bank: + ldy TR1 + + cpy #KERNEL_LAST_RAM_BANK + beq @oob ; Out Of Bank + + MEMORY_GET_VALUE_FROM_BANK ; A contains the value + + cmp TR0 + beq @found +@inc_next_bank: + inc TR1 + jmp @check_next_bank + +@found: + jsr kernel_free_bank + jmp @inc_next_bank + + rts +@oob: + lda #$00 ; Not found + rts +.endproc diff --git a/src/functions/bank_mng/kernel_restore_banking_states.s b/src/functions/bank_mng/kernel_restore_banking_states.s new file mode 100644 index 00000000..2ab3c3e8 --- /dev/null +++ b/src/functions/bank_mng/kernel_restore_banking_states.s @@ -0,0 +1,29 @@ +.export kernel_restore_banking_states +.export kernel_restore_banking_states_register + +.import KERNEL_SAVE_XEXEC_CURRENT_SET +.import KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM + +.import switch_to_kernel_extended + + +.segment "BANK7" + +.proc kernel_restore_banking_states + pla + jsr switch_to_kernel_extended + ; restore + jmp kernel_restore_banking_states_register +.endproc + + +.proc kernel_restore_banking_states_register + pha + lda KERNEL_SAVE_XEXEC_CURRENT_SET + sta $343 + lda KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM + sta $342 + pla + cli + rts +.endproc diff --git a/src/functions/bank_mng/search_free_bank.s b/src/functions/bank_mng/search_free_bank.s new file mode 100644 index 00000000..d648d0e5 --- /dev/null +++ b/src/functions/bank_mng/search_free_bank.s @@ -0,0 +1,99 @@ +.export search_free_bank + + +.include "telestrat.inc" + +.include "../../include/kernel.inc" +.include "../../include/process.inc" +.include "../../include/memory.inc" +.include "../../include/files.inc" +;.include "../../kernel.inc" + +;.segment "BANK8" + +.import KERNEL_BANK_MANAGEMENT +.import kernel_process + + +.proc search_free_bank + + ;;@brief Search free bank : Only manage RAM bank for instance + ;;@inputA the type of the bank + ;;@modifyA + ;;@modifyX + ;;@modifyY + ;;@modifyMEM_RES Tmp value + ;;@returnsA the id of the bank from 34 to 63 (Else A = 0 if out of bank) + ;;@returnsX the set + ;;@returnsY the id of the bank (from 1 to 4 depending of the set) + + ldx #$00 + + ldy #KERNEL_FIRST_FREE_RAM_BANK ; First bank + sty RES+1 + + lda #<KERNEL_BANK_MANAGEMENT + ldy #>KERNEL_BANK_MANAGEMENT + + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + +@not_found: + + ldy RES+1 + + cpy #(KERNEL_LAST_RAM_BANK+1) + beq @oob ; Out Of Bank + + MEMORY_GET_VALUE_FROM_BANK ; A contains the value + + cmp #$00 + beq @found + + inc RES+1 + bne @not_found + + +@found: + ; Set busy flag + lda #$01 ; Type + ldy RES+1 ; Offset + ldx #$00 ; BANK + + MEMORY_PUT_VALUE_TO_BANK KERNEL_BANK_MANAGEMENT + + lda RES+1 ; Offset + clc + adc #kernel_bank_management_struct::KERNEL_BANK_PROCESS_ID + tay + ; At this step, Y contains the offset of kernel_bank_management_struct::KERNEL_BANK_PROCESS_ID to store process id + lda kernel_process+kernel_process_struct::kernel_current_process + ldx #$00 ; BANK 0 to store process into KERNEL_BANK_MANAGEMENT and kernel_bank_management_struct::KERNEL_BANK_PROCESS_ID offset + + MEMORY_PUT_VALUE_TO_BANK KERNEL_BANK_MANAGEMENT + + ; A contains the id of the bank + + lda RES + 1 ; Load the id of the bank found + beq @bank0 + tay + lda set,y + tax + lda bank,y + tay + lda RES + 1 + + rts + +@bank0: + ; Impossible to have bank 0 + tax + rts + +@oob: + lda #$00 + rts + +.include "../xvars/set_bank_mapping_values.s" + +.endproc diff --git a/src/functions/bank_mng/switch_to_kernel_extended.s b/src/functions/bank_mng/switch_to_kernel_extended.s new file mode 100644 index 00000000..79b93254 --- /dev/null +++ b/src/functions/bank_mng/switch_to_kernel_extended.s @@ -0,0 +1,38 @@ +.include "telestrat.inc" + +.export switch_to_kernel_extended +.export switch_to_kernel_extended_fill_register + + +.import KERNEL_SAVE_XEXEC_CURRENT_SET +.import KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM + +.segment "BANK7" + +.proc switch_to_kernel_extended + jsr switch_to_kernel_extended_fill_register + jmp $40C +.endproc + +.proc switch_to_kernel_extended_fill_register + + pha + + lda $343 + sta KERNEL_SAVE_XEXEC_CURRENT_SET + + lda #$04 + sta BNKCIB + + lda $342 + sta KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM + and #%11011111 + sei + + sta $342 + + lda #$04 + sta $343 + pla + rts +.endproc \ No newline at end of file diff --git a/src/functions/charsets/charset.asm b/src/functions/charsets/charset.asm index ad4371a4..e2fb34b9 100644 --- a/src/functions/charsets/charset.asm +++ b/src/functions/charsets/charset.asm @@ -1,3 +1,5 @@ +.export charset_text + charset_text: ; ' ' .byte $00,$00,$00,$00,$00,$00,$00,$00 diff --git a/src/functions/files/compute_fp_struct.asm b/src/functions/files/compute_fp_struct.asm index 2b87fa1c..9a9eae27 100644 --- a/src/functions/files/compute_fp_struct.asm +++ b/src/functions/files/compute_fp_struct.asm @@ -1,3 +1,5 @@ +.export compute_fp_struct + .proc compute_fp_struct ; A contains the fd id diff --git a/src/functions/files/xmkdir.asm b/src/functions/files/xmkdir.asm index 3b390b05..08279a22 100644 --- a/src/functions/files/xmkdir.asm +++ b/src/functions/files/xmkdir.asm @@ -2,14 +2,14 @@ ; [IN] AY contains the pointer of the path ; FIXME .out .sprintf("|MODIFY:RES:XMKDIR_ROUTINE") - .out .sprintf("|MODIFY:ptr1:XMKDIR_ROUTINE") + .out .sprintf("|MODIFY:ADDRESS_READ_BETWEEN_BANK_DOUBLON:XMKDIR_ROUTINE") .out .sprintf("|MODIFY:TR7:XMKDIR_ROUTINE") - sta ptr1 - sty ptr1+1 + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 ; is it an absolute path ? ldy #$00 - lda (ptr1),y + lda (ADDRESS_READ_BETWEEN_BANK_DOUBLON),y cmp #"/" beq @isabsolute @@ -35,7 +35,7 @@ sta CH376_COMMAND ldy #$00 @mloop: - lda (ptr1),y + lda (ADDRESS_READ_BETWEEN_BANK_DOUBLON),y beq @mend cmp #"/" beq @launch_xopen @@ -78,9 +78,9 @@ @isabsolute: rts - lda ptr1 + lda ADDRESS_READ_BETWEEN_BANK_DOUBLON ldy #O_RDONLY - ldx ptr1+1 + ldx ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 jmp XOPEN_ROUTINE @@ -102,10 +102,11 @@ ldx #$00 @next_char: iny - lda (ptr1),y + lda (ADDRESS_READ_BETWEEN_BANK_DOUBLON),y beq @end cmp #"/" beq @create_dir + ; FIXME XMINMA cmp #"a" ; 'a' bcc @skip cmp #$7B ; 'z' diff --git a/src/functions/getargv.asm b/src/functions/getargv.asm index 2e93dfda..ea392963 100644 --- a/src/functions/getargv.asm +++ b/src/functions/getargv.asm @@ -10,6 +10,8 @@ .out .sprintf("|MODIFY:RES:XGETARGV_ROUTINE") .out .sprintf("|MODIFY:RESB:XGETARGV_ROUTINE") +.export XGETARGV_ROUTINE + .proc XGETARGV_ROUTINE ; lda RES diff --git a/src/functions/graphics/_xdrawr.asm b/src/functions/graphics/_xdrawr.asm index 7c2fed14..8d521a52 100644 --- a/src/functions/graphics/_xdrawr.asm +++ b/src/functions/graphics/_xdrawr.asm @@ -19,6 +19,7 @@ ; NOERROR +.export XDRAWR_ROUTINE .proc XDRAWR_ROUTINE lda HRSPAT ; sauve le pattern diff --git a/src/functions/graphics/_xeffhi.asm b/src/functions/graphics/_xeffhi.asm index 73719096..404a3f1b 100644 --- a/src/functions/graphics/_xeffhi.asm +++ b/src/functions/graphics/_xeffhi.asm @@ -1,3 +1,5 @@ +.export _xeffhi + .proc _xeffhi lda #<$A000 ldy #>$A000 diff --git a/src/functions/graphics/xbox.asm b/src/functions/graphics/xbox.asm index d39d3994..5c528f73 100644 --- a/src/functions/graphics/xbox.asm +++ b/src/functions/graphics/xbox.asm @@ -5,6 +5,9 @@ ; Pas très optimisé en temps tout cela, il aurait été plus simple de ; de tracer directement en relatif !!! ; Le rectangle est tracé comme ABOX avec les paramètres dans HRSx. + +.export XBOX_ROUTINE + .proc XBOX_ROUTINE clc ; C=0 lda HRSX ; on place les coordonées actuelles diff --git a/src/functions/graphics/xcircl.asm b/src/functions/graphics/xcircl.asm index c1bbe3bc..0f41a419 100644 --- a/src/functions/graphics/xcircl.asm +++ b/src/functions/graphics/xcircl.asm @@ -51,6 +51,8 @@ ; de la puissance de 2 > au rayon est infinie, idem si le rayon est 128. ; Il aurait suffit d'incrémenter le rayon avant le calcul... +.export XCIRCL_ROUTINE + .proc XCIRCL_ROUTINE lda HRSX ; on sauve HRSX pha diff --git a/src/functions/graphics/xcurse.asm b/src/functions/graphics/xcurse.asm index 77643356..542249a9 100644 --- a/src/functions/graphics/xcurse.asm +++ b/src/functions/graphics/xcurse.asm @@ -1,4 +1,6 @@ - ; ROUTINE CURSET +.export XCURSE_ROUTINE + +; ROUTINE CURSET .proc XCURSE_ROUTINE ldx HRS1 ; X=HRSX FIXME ldy HRS2 ; Y=HRSY FIXME diff --git a/src/functions/graphics/xdrawa.asm b/src/functions/graphics/xdrawa.asm index 1a72b222..7fa9b997 100644 --- a/src/functions/graphics/xdrawa.asm +++ b/src/functions/graphics/xdrawa.asm @@ -4,6 +4,8 @@ ; Action:on calcule dX et dY les deplacements dans HRS1 et HRS2 et on trace en ; relatif. En entr?e, comme ADRAW dans HRSx. +.export XDRAWA_ROUTINE + .proc XDRAWA_ROUTINE ldx HRS1 ; X=colonne ldy HRS2 ; Y=ligne du curseur diff --git a/src/functions/graphics/xdrawr.asm b/src/functions/graphics/xdrawr.asm index 123f2ccb..8dd92b30 100644 --- a/src/functions/graphics/xdrawr.asm +++ b/src/functions/graphics/xdrawr.asm @@ -19,6 +19,7 @@ ; NOERROR +.export XDRAWR_ROUTINE .proc XDRAWR_ROUTINE lda HRSPAT ; sauve le pattern diff --git a/src/functions/init_screen.asm b/src/functions/init_screen.asm index de08b29a..df9b96fe 100644 --- a/src/functions/init_screen.asm +++ b/src/functions/init_screen.asm @@ -11,6 +11,7 @@ bpl @loop ldy #$05 ; loop with $12 to fill text definitions and Hires + @L1: lda data_text_window,y ; data_to_define_2 sta SCRTXT,y ; thise fill also SCRHIR diff --git a/src/functions/lib_mng/XBANK_ROUTINE.s b/src/functions/lib_mng/XBANK_ROUTINE.s new file mode 100644 index 00000000..11fe1480 --- /dev/null +++ b/src/functions/lib_mng/XBANK_ROUTINE.s @@ -0,0 +1,27 @@ +.include "telestrat.inc" + +.export XBANK_ROUTINE + +.export XNETWORK_START_ROUTINE + +.import switch_to_kernel_extended +.import kernel_restore_banking_states + +.import KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM +.import KERNEL_SAVE_XEXEC_CURRENT_SET + +XNETWORK_START_ROUTINE := XBANK_ROUTINE + +.segment "BANK7" + +.proc XBANK_ROUTINE + pha + lda #<$C000 + sta VEXBNK+1 + + lda #>$C000 + sta VEXBNK+2 + ; !!!! pla is done in kernel_restore_banking_states + jmp kernel_restore_banking_states + +.endproc diff --git a/src/functions/mainargs.asm b/src/functions/mainargs.asm index 0b2f5bac..67f57e3a 100644 --- a/src/functions/mainargs.asm +++ b/src/functions/mainargs.asm @@ -28,18 +28,34 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte .proc XMAINARGS_ROUTINE + ;;@brief Build a mainargs array and returns in A and Y the ptr (malloc) + ;;@inputA Mode (0 or 1) + ;;@inputX High ptr curl struct + ;;@modifyMEM_RES + ;;@modifyMEM_RESB + ;;@modifyMEM_TR0 + ;;@modifyMEM_TR1 + ;;@modifyMEM_TR2 + ;;@modifyMEM_TR3 + ;;@modifyMEM_TR4 + ;;@modifyMEM_KERNEL_ERRNO + sta XMAINARGS_MODE + ; Get current process ldx kernel_process+kernel_process_struct::kernel_current_process + ; Get the struct og the process jsr kernel_get_struct_process_ptr sta RES sty RES+1 - lda RES + ; Compute cmdline offset + lda RES ; FIXME A is already populated clc adc #kernel_one_process_struct::cmdline ; 1 : number of args bcc @S7 inc RES+1 + @S7: sta RES @@ -73,6 +89,7 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte ; Mode 1 : Copy only ldy #$00 + @loop2: lda (RES),y beq @out2 @@ -104,6 +121,7 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte adc RESB bcc @S3 inc XMAINARGSV+1 + @S3: sta XMAINARGSV ; TR2 contains the first offset @@ -124,16 +142,28 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte beq @out cmp #' ' beq @new_arg - cmp #$22 ; Is it '"' ? + cmp #'"' ; Is it '"' ? bne @not_double_quote - lda XMAINARGS_DOUBLE_QUOTE + lda XMAINARGS_DOUBLE_QUOTE ; If equal two 0, it " is found here, let's beq @begin_double_quote - inc XMAINARGS_DOUBLE_QUOTE + ; End of double quote found, close param + bne @out @begin_double_quote: + inc XMAINARGS_DOUBLE_QUOTE + lda RES + clc + adc #$01 + bcc @no_inc + inc RES+1 + +@no_inc: + sta RES + jsr @init_param + jmp @loop @not_double_quote: ; store the string @@ -151,17 +181,34 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte ldx XMAINARGSC ; return ptr - lda RESB ; $7C9 + lda RESB ldy RESB+1 rts @new_arg: + ldx XMAINARGS_DOUBLE_QUOTE + beq @double_quote_not_opened + + ; At this step we found a space in a " sentence + ; A contains " " + sta (XMAINARGSV),y + jmp @no_new_arg + +@double_quote_not_opened: lda XMAINARGS_SPACEFOUND bne @no_new_arg lda #$01 sta XMAINARGS_SPACEFOUND + jsr @init_param + inc XMAINARGSC + +@no_new_arg: + iny + jmp @loop + +@init_param: lda #$00 sta (XMAINARGSV),y @@ -176,10 +223,5 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte txa tay - inc XMAINARGSC - -@no_new_arg: - iny - jmp @loop - + rts .endproc diff --git a/src/functions/math/xcos.asm b/src/functions/math/xcos.asm index aeef9bdd..253060e2 100644 --- a/src/functions/math/xcos.asm +++ b/src/functions/math/xcos.asm @@ -1,4 +1,5 @@ .export XCOS_ROUTINE + .proc XCOS_ROUTINE jsr LF8B1 lda #<CONST_PI_DIVIDED_BY_TWO @@ -6,6 +7,7 @@ jsr AY_add_acc1 jmp LF791 .endproc + LF8B1 jsr test_if_degree_mode beq LF8CC diff --git a/src/functions/math/xtan.asm b/src/functions/math/xtan.asm index 1bc543b2..9079d030 100644 --- a/src/functions/math/xtan.asm +++ b/src/functions/math/xtan.asm @@ -1,4 +1,5 @@ .export XTAN_ROUTINE + .proc XTAN_ROUTINE jsr LF8B1 jsr LF348 diff --git a/src/functions/memory/memory_driver.asm b/src/functions/memory/memory_driver.asm index 4faac144..8e03b5de 100644 --- a/src/functions/memory/memory_driver.asm +++ b/src/functions/memory/memory_driver.asm @@ -3,7 +3,8 @@ ; At the beginning of this routine, we already swapped into the a bank to check ; Bank and twilighte_banking_register are managed in the kernel and call this routines located in the main ram -kernel_memory_driver_to_copy: +kernel_memory_driver_to_copy + sei lda VIA2::PRA and KERNEL_TMP_XEXEC ; But select a bank in BNK_TO_SWITCH sta VIA2::PRA @@ -14,6 +15,7 @@ kernel_memory_driver_to_copy: lda $FFF7 ; The bank contains no any command in the current rom ($fff7=0) then skip beq exit_to_kernel_ENOENT + cli test_debug: lda $FFF5 ; List command @@ -78,6 +80,7 @@ exit_to_kernel: lda VIA2::PRA ora #%00000111 ; Return to telemon sta VIA2::PRA + cli rts read_command_from_bank_driver_command_found: diff --git a/src/functions/network/close_sockets_by_pid.s b/src/functions/network/close_sockets_by_pid.s new file mode 100644 index 00000000..6dc81888 --- /dev/null +++ b/src/functions/network/close_sockets_by_pid.s @@ -0,0 +1,77 @@ +.include "telestrat.inc" + +.export close_sockets_by_pid + +.import KERNEL_NETWORK_FLAG +.import KERNEL_NETWORK_SOCKET_LIST +.import KERNEL_NETWORK_SOURCE_PORT +.import KERNEL_NETWORK_SOCKET_PID +.import KERNEL_NETWORK_SOCKET_DOMAIN + +.import kernel_process + +.include "../../kernel8/orixlibs/ch395/usr/include/asm/ch395.inc" +.include "../../kernel8/orixlibs/ksocket/usr/include/asm/socket.inc" +.include "../../include/kernel.inc" +.include "../../include/process.inc" +.include "../../include/network.inc" +.include "../../include/memory.inc" + +.import ch395_close_socket_sn + +.proc close_sockets_by_pid + ;;@brief Close all sockets for current pid + ;;@modifyMEM_TR1 + + lda #$00 ; First socket + sta TR1 + +@restart: + lda #<KERNEL_NETWORK_SOCKET_PID ; D393 + ldy #>KERNEL_NETWORK_SOCKET_PID + + + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 + + ldx #$00 + ldy TR1 ; Offset of the socket + MEMORY_GET_VALUE_FROM_BANK ; A contains the value + + cmp kernel_process + kernel_process_struct::kernel_current_process + beq @close_socket + +@compute: + inc TR1 + lda TR1 + + cmp #NETWORK_MAX_SOCKET + beq @exit + bne @restart + +@close_socket: + lda TR1 ; Socket ID + + jsr ch395_close_socket_sn + + ; Set to 0 + ldy TR1 ; Get socket id (index) + lda #$00 ; clear + ldx #$00 ; BANK + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_LIST ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + + ; Set to 0n + ldy TR1 ; Get socket id (index) + lda #$00 ; Domain + ldx #$00 ; BANK + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_DOMAIN ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + + ; Clear PID + ldy TR1 ; Get socket id (index) + lda #$00 + ldx #$00 ; BANK + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_PID ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + jmp @compute +@exit: + rts +.endproc \ No newline at end of file diff --git a/src/functions/network/init_network.s b/src/functions/network/init_network.s new file mode 100644 index 00000000..d79121c2 --- /dev/null +++ b/src/functions/network/init_network.s @@ -0,0 +1,167 @@ +.include "telestrat.inc" + +.export init_network + +.import ch395_check_exist +.import ch395_set_fun_para +.import ch395_init +.import ch395_get_phy_status + +.import ch395_get_dhcp_status +.import ch395_dhcp_enable + +.import ch395_get_ip_inf + +.import KERNEL_NETWORK_FLAG +.import KERNEL_NETWORK_SOCKET_LIST +.import KERNEL_NETWORK_SOURCE_PORT + +.include "../../kernel8/orixlibs/ch395/usr/include/asm/ch395.inc" +.include "../../include/kernel.inc" +.include "../../include/process.inc" +.include "../../include/network.inc" +.include "../../include/memory.inc" + +.proc init_network + ; Returns KERNEL_NETWORK_FULLY_STARTED if network is started + + lda #<KERNEL_NETWORK_FLAG + ldy #>KERNEL_NETWORK_FLAG + + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + + ldx #$00 + ldy #$00 + MEMORY_GET_VALUE_FROM_BANK ; A contains the value + cmp #KERNEL_NETWORK_FULLY_STARTED + bne @check_all + rts + +@check_all: + cmp KERNEL_NETWORK_STATE_NOT_INITIALIZED + bne @ch395_found + + jsr ch395_check_exist + + cmp #$AA + beq @ch395_found + lda #KERNEL_NETWORK_STATE_CHIP_NOT_FOUND + rts + +@ch395_found: + ; FIXME SHould not be done here + lda #<KERNEL_NETWORK_FLAG + ldy #>KERNEL_NETWORK_FLAG + + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 + + ldx #$00 + ldy #$00 + MEMORY_GET_VALUE_FROM_BANK ; A contains the value + + cmp #KERNEL_NETWORK_STATE_NOT_INITIALIZED + beq @initialize + cmp #KERNEL_NETWORK_STATE_CHIP_INITIALIZED + beq @checking_cable + cmp #KERNEL_NETWORK_CABLE_DISCONNECTED + beq @checking_cable + cmp #KERNEL_NETWORK_CABLE_CONNECTED + beq @start_dhcp + cmp #KERNEL_NETWORK_STARTING_DHCP + beq @start_dhcp + rts + +@initialize: + jmp kernel_ch395_initialize + +@checking_cable: + ; Initialize socket list with 0 + lda #$07 + sta TR7 + +@loop: + ldy TR7 + lda #$00 + ldx #$00 + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_LIST + dec TR7 + bpl @loop + + + jsr ch395_get_phy_status + cmp #CH395_PHY_DISCONN + beq @cable_disconnected + + lda #KERNEL_NETWORK_CABLE_CONNECTED + ldx #$00 + ldy #$00 + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_FLAG + + lda #KERNEL_NETWORK_CABLE_CONNECTED + + rts + +@start_dhcp: + ; Check IP + lda #<RES + ldx #>RES + jsr ch395_get_ip_inf + + lda RES + cmp #$00 + beq @dhcp_not_started + + lda #KERNEL_NETWORK_FULLY_STARTED + ldx #$00 + ldy #$00 + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_FLAG + lda #KERNEL_NETWORK_FULLY_STARTED + rts + +@dhcp_not_started: + lda #CH395_DHCP_ENABLE_VAL + jsr ch395_dhcp_enable + lda #KERNEL_NETWORK_STARTING_DHCP + ldx #$00 + ldy #$00 + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_FLAG + lda #KERNEL_NETWORK_STARTING_DHCP + rts + +@cable_disconnected: + lda #KERNEL_NETWORK_CABLE_DISCONNECTED + ldx #$00 + ldy #$00 + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_FLAG + lda #KERNEL_NETWORK_CABLE_DISCONNECTED + rts + +kernel_ch395_initialize: + ; Set autoclose socket : + lda #CH395_FUN_PARA_FLAG_SOCKET_CLOSE + jsr ch395_set_fun_para + ; Starting stack and exit + jsr ch395_init + + lda #<KERNEL_FIRST_SOURCE_PORT_INIT + ldx #$00 + ldy #$00 + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOURCE_PORT + + lda #>KERNEL_FIRST_SOURCE_PORT_INIT + ldx #$00 + ldy #$01 + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOURCE_PORT + + lda #KERNEL_NETWORK_STATE_CHIP_INITIALIZED + ldx #$00 + ldy #$00 + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_FLAG + + lda #KERNEL_NETWORK_STATE_CHIP_INITIALIZED + + rts + +.endproc diff --git a/src/functions/network/xclose_socket.s b/src/functions/network/xclose_socket.s new file mode 100644 index 00000000..5e0d4eeb --- /dev/null +++ b/src/functions/network/xclose_socket.s @@ -0,0 +1,34 @@ +.include "../../kernel8/orixlibs/ch395/usr/include/asm/ch395.inc" +.include "../../kernel8/orixlibs/ksocket/usr/include/asm/socket.inc" + +.include "../../include/kernel.inc" +.include "../../include/process.inc" +.include "../../include/memory.inc" + +.include "telestrat.inc" + +.import KERNEL_NETWORK_SOCKET_LIST +.import KERNEL_NETWORK_SOCKET_DOMAIN + +.export XSOCKET_CLOSE_ROUTINE + +.import ch395_close_socket_sn + +.proc XSOCKET_CLOSE_ROUTINE + ; X contains the id of the socket + ; Remove socket id + sta TR0 + txa + tay ; Contains socket id + lda #$00 ; Type + ldx #$00 ; BANK + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_LIST ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + + + ; Flush buffers + lda TR0 ; Load socket id + jmp ch395_close_socket_sn + + +.endproc + diff --git a/src/functions/network/xconnect.s b/src/functions/network/xconnect.s new file mode 100644 index 00000000..0d8b2eb2 --- /dev/null +++ b/src/functions/network/xconnect.s @@ -0,0 +1,77 @@ +.include "../../kernel8/orixlibs/ch395/usr/include/asm/ch395.inc" +.include "../../kernel8/orixlibs/ksocket/usr/include/asm/socket.inc" + +.include "../../include/kernel.inc" +.include "../../include/process.inc" +.include "../../include/memory.inc" + +.include "telestrat.inc" + +.export xconnect + +.import kconnect + +.import KERNEL_NETWORK_SOURCE_PORT +.import KERNEL_NETWORK_SOCKET_LIST + +.proc xconnect + ;;@returnsA A = $FF if it's impossible to connect (SOCKET_ERROR) for instance or 0 if it's OK + socket := TR0 + ip := DECFIN + srcport := DECDEB ; Don't change it, DECDEB is used in kconnect + type := TR3 + + sty ip + stx ip + 1 + lda #<KERNEL_NETWORK_SOURCE_PORT + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + + lda #>KERNEL_NETWORK_SOURCE_PORT + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + + ldx #$00 + ldy #$00 + MEMORY_GET_VALUE_FROM_BANK ; A default source port + + sta srcport ; src port + ldx #$00 + stx srcport + 1 + + ; inc dst port for the future + tax + inx + txa + ldy #$00 + ldx #$00 ; BANK + + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOURCE_PORT ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + + lda #<KERNEL_NETWORK_SOCKET_LIST + ldy #>KERNEL_NETWORK_SOCKET_LIST + + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 + + ldx #$00 + ldy socket + MEMORY_GET_VALUE_FROM_BANK ; get Type + sta type + + + ;;@` lda #00 ; Port 80 + ;;@` sta RESB + ;;@` lda #80 ; Port + ;;@` sta RESB+1 + ;;@` lda #$00 ; Socket id + ;;@` lda mysocketid + ;;@` sta TR0 + ;;@ TR3 : + + ;;@` jsr kconnect + + ldy ip + ldx ip+1 + + jmp kconnect + +.endproc diff --git a/src/functions/network/xsend.s b/src/functions/network/xsend.s new file mode 100644 index 00000000..15a34564 --- /dev/null +++ b/src/functions/network/xsend.s @@ -0,0 +1,34 @@ +; .include "../../kernel8/orixlibs/ch395/usr/include/asm/ch395.inc" +; .include "../../kernel8/orixlibs/ksocket/usr/include/asm/socket.inc" + +; .include "../../include/kernel.inc" +; .include "../../include/process.inc" +; .include "../../include/memory.inc" + +.include "telestrat.inc" + + + + +.export XSEND_ROUTINE + +.import ksend + + +;.import socket_state +;.export socket_sour_port + + +.proc XSEND_ROUTINE + + ;;@brief Send data into socket + ;;@inputTR0 Socket id + ;;@inputY Low length + ;;@inputX High length + ;;@inputMEM_RES ptr + ;;@modifyMEM_TR1 ptr + ;;@returnsA Error type, 0 : success + ; jmp + + rts +.endproc diff --git a/src/functions/network/xsocket.s b/src/functions/network/xsocket.s new file mode 100644 index 00000000..ae1d5141 --- /dev/null +++ b/src/functions/network/xsocket.s @@ -0,0 +1,148 @@ +.include "../../kernel8/orixlibs/ch395/usr/include/asm/ch395.inc" +.include "../../kernel8/orixlibs/ksocket/usr/include/asm/socket.inc" + +.include "../../include/kernel.inc" +.include "../../include/process.inc" +.include "../../include/memory.inc" +.include "../../include/network.inc" + +.include "telestrat.inc" + +.import KERNEL_NETWORK_SOCKET_LIST +.import KERNEL_NETWORK_SOCKET_DOMAIN + +.import init_network + +.export XSOCKET_ROUTINE + +.import ch395_set_ipraw_pro_sn +.import ch395_set_proto_type_sn +.import ch395_get_socket_status_sn +.import ch395_close_socket_sn +.import kernel_process +.import KERNEL_NETWORK_SOCKET_PID +;.import socket_state +;.export socket_sour_port + + +.proc XSOCKET_ROUTINE + ;;@brief Open a socket + ;;@inputA protocol + ;;@inputX domain ex : AF_INET + ;;@inputY type ex : SOCK_STREAM + ;;@modifyMEM_RES + ;;@modifyMEM_TR6 + ;;@modifyMEM_TR5 + ;;@returnsX The socket id + ;;@returnsA if != -1 then it returns socket id. -1 is return if all socket are used, or network is not started or unavailable + + ; sock = socket(AF_INET, SOCK_STREAM, 0); + ;;@```ca65 + ;;@` ; or use Macro (socket.mac) SOCKET domain, type, protocol + ;;@` SOCKET AF_INET, SOCK_STREAM, 0 + ;;@` + ;;@``` + + ;;@```ca65 + ;;@` lda #$00 ; + ;;@` ldx #AF_INET ; domain + ;;@` ldy #SOCK_STREAM ; type + ;;@` brk XSOCKET + ;;@``` + + ; socket_state contains 0 if socket is not used, or contains type if used + + + socket := RES + 1 + type := TR6 + domain := TR5 + + stx domain ; domain + sty type ; Save type + + + ; Checking if network is started + jsr init_network + cmp #KERNEL_NETWORK_FULLY_STARTED + beq @continue +; Error, return INVALID + lda #INVALID_SOCKET + rts + +@continue: + ; Looking for available socket + lda #$00 + sta socket + +@search_free_socket: + ldx #$00 + + lda #<KERNEL_NETWORK_SOCKET_LIST + ldy #>KERNEL_NETWORK_SOCKET_LIST + + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 + ldy socket + MEMORY_GET_VALUE_FROM_BANK ; A contains the value + cmp #$00 + beq @socketfound + + inc socket + lda socket + cmp #NETWORK_MAX_SOCKET + bne @search_free_socket + +; Error, return INVALID + lda #INVALID_SOCKET + rts + +@socketfound: +; A contains the id of the socket + + + ; save TYPE (SOCK_STREAM etc) + ldy socket ; Get socket id (index) + lda type ; Type sock_stream + ldx #$00 ; BANK + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_LIST ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + + ; Store domain + ldy socket ; Get socket id (index) + lda domain ; Domain + ldx #$00 ; BANK + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_DOMAIN ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + + ; Store pid + ldy socket ; Get socket id (index) + lda kernel_process + kernel_process_struct::kernel_current_process + ldx #$00 ; BANK + + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_PID ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + + ; Setting CH395 + lda type + cmp #SOCK_RAW + beq @is_ip_raw + + + ; SOCK_STEAM or SOCK_DGRAM + lda socket ; socket + ldx type + + jsr ch395_set_proto_type_sn + jmp @exit_socket + +@is_ip_raw: + lda socket ; Get socket id + ldx #CH395_PROTO_TYPE_IP_RAW + jsr ch395_set_ipraw_pro_sn + +@exit_socket: + lda socket ; return the id of the socket + rts + +.endproc + + + + diff --git a/src/functions/process/kernel_get_struct_process_ptr.asm b/src/functions/process/kernel_get_struct_process_ptr.asm index 194582f4..aed2cede 100644 --- a/src/functions/process/kernel_get_struct_process_ptr.asm +++ b/src/functions/process/kernel_get_struct_process_ptr.asm @@ -1,3 +1,5 @@ +.export kernel_get_struct_process_ptr + .proc kernel_get_struct_process_ptr ; X contains the pid to get ; Returns in A and Y ptr diff --git a/src/functions/process/kernel_kill_process.asm b/src/functions/process/kernel_kill_process.asm index f2e25648..21c24753 100644 --- a/src/functions/process/kernel_kill_process.asm +++ b/src/functions/process/kernel_kill_process.asm @@ -26,6 +26,20 @@ jsr close_all_fp_from_current_process + ; Destroy socket attached to the process + + lda KERNEL_BANK_EXTENDED_AVAILABLE + cmp #128 + bne @do_not_destroy_socket + + + + lda #KERNEL_SOCKET_CLOSE_FROM_PID_NETWORK + jsr XNETWORK_START_ROUTINE + + +@do_not_destroy_socket: + ; destroy process memory chunks ; Try to find all malloc from this process @@ -47,16 +61,16 @@ lda (RES),y ; A contains the PPID ; X contains the current PID to kill here clear struct - sta kernel_process+kernel_process_struct::kernel_current_process + sta kernel_process + kernel_process_struct::kernel_current_process ; remove reference of process struct in the main struct lda #$00 - sta kernel_process+kernel_process_struct::kernel_one_process_struct_ptr_low,x - sta kernel_process+kernel_process_struct::kernel_one_process_struct_ptr_high,x + sta kernel_process + kernel_process_struct::kernel_one_process_struct_ptr_low,x + sta kernel_process + kernel_process_struct::kernel_one_process_struct_ptr_high,x ; remove pid from ps list - sta kernel_process+kernel_process_struct::kernel_pid_list,x ; Flush pidlist to 0 for the current index + sta kernel_process + kernel_process_struct::kernel_pid_list,x ; Flush pidlist to 0 for the current index lda RES ldy RES+1 diff --git a/src/functions/strings/xminma.asm b/src/functions/strings/xminma.asm index 9cd4ad64..8c4d59a5 100644 --- a/src/functions/strings/xminma.asm +++ b/src/functions/strings/xminma.asm @@ -1,9 +1,18 @@ +.export XMINMA_ROUTINE + +.segment "BANK7" + + + .proc XMINMA_ROUTINE - cmp #"a" ; 'a' + cmp #'a' ; 'a' bcc @skip cmp #$7B ; 'z' bcs @skip sbc #$1F + @skip: rts .endproc + +;addsym XMINMA_ROUTINE diff --git a/src/functions/text/xink.asm b/src/functions/text/xink.asm index ba0294b0..042ba569 100644 --- a/src/functions/text/xink.asm +++ b/src/functions/text/xink.asm @@ -1,3 +1,4 @@ +.export XINK_ROUTINE .proc XINK_ROUTINE sec diff --git a/src/functions/text/xpaper.asm b/src/functions/text/xpaper.asm index 7ec3860c..d9f3e97a 100644 --- a/src/functions/text/xpaper.asm +++ b/src/functions/text/xpaper.asm @@ -1,3 +1,4 @@ +.export XPAPER_ROUTINE .proc XPAPER_ROUTINE clc diff --git a/src/functions/text/xscrob_xscroh.asm b/src/functions/text/xscrob_xscroh.asm index a6c8bfbe..55f91f61 100644 --- a/src/functions/text/xscrob_xscroh.asm +++ b/src/functions/text/xscrob_xscroh.asm @@ -1,4 +1,6 @@ +.export XSCROH_ROUTINE + .proc XSCROH_ROUTINE ; SCROLLE UNE FENETRE VERS LE BAS ;Action:scrolle vers le bas de la ligne X à la ligne Y la fenêtre courante. diff --git a/src/functions/xvars/set_bank_mapping_values.s b/src/functions/xvars/set_bank_mapping_values.s new file mode 100644 index 00000000..0faafe30 --- /dev/null +++ b/src/functions/xvars/set_bank_mapping_values.s @@ -0,0 +1,43 @@ +set: + ; Rom + .byt 0 + .byte 0,0,0,0 ; 5 + .byte 4,4,4,4 ; 9 + .byte 1,1,1,1 ; 13 + .byte 5,5,5,5 ; 17 + .byte 2,2,2,2 ; 21 + .byte 6,6,6,6 ; 25 + .byte 3,3,3,3 ; 29 + .byte 7,7,7,7 ; 33 + + ; Ram + .byte 0,0,0,0 + .byte 1,1,1,1 + .byte 2,2,2,2 + .byte 3,3,3,3 + .byte 4,4,4,4 + .byte 5,5,5,5 + .byte 6,6,6,6 + .byte 7,7,7,7 + +bank: + .byt 0 + ; Rom + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + + ; Ram + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 diff --git a/src/functions/xvars/xvalues_wrapper.s b/src/functions/xvars/xvalues_wrapper.s new file mode 100644 index 00000000..fa8d16f4 --- /dev/null +++ b/src/functions/xvars/xvalues_wrapper.s @@ -0,0 +1,21 @@ +.export xvalues_wrapper + +.import xvalues_wrapper + +.proc xvalues_wrapper + pha + + lda $343 + sta KERNEL_BACKUP_SET + + lda #<$c006 + sta VEXBNK+1 + lda #>$c006 + sta VEXBNK+2 + lda #$01 + sta BNKCIB + + pla + jmp $40C + +.endproc diff --git "a/src/functions/xvars/xvalues\303\247for_link.s" "b/src/functions/xvars/xvalues\303\247for_link.s" new file mode 100644 index 00000000..4d784510 --- /dev/null +++ "b/src/functions/xvars/xvalues\303\247for_link.s" @@ -0,0 +1,567 @@ +.export XVALUES_ROUTINE + +; .include "telestrat.inc" + +; .include "../../include/kernel.inc" +; .include "../../include/process.inc" +; .include "../../include/memory.inc" +; .include "../../include/files.inc" + +; .include "../../kernel.inc" + +; .import XVARS_TABLE_HIGH +; .import XVARS_TABLE_LOW + +; .import XMALLOC_ROUTINE +; .import kernel_get_struct_process_ptr +; .import compute_fp_struct + + +.proc XVALUES_ROUTINE + cpx #KERNEL_XVALUES_FREE_MALLOC_TABLE + beq @malloc_table_copy ; Used by lsmem + + cpx #KERNEL_XVALUES_BUSY_MALLOC_TABLE + beq @malloc_table_busy_copy ; Used by lsmem + + cpx #KERNEL_XVALUES_GET_CURRENT_PROCESSNAME_FROM_PID + beq @XVARS_GET_PROCESS_NAME_PTR_CALL ; Used by lsmem + + cpx #KERNEL_XVALUES_PATH_FROM_FD + beq @xvars_get_fd_list_call ; Used by lsof + + cpx #KERNEL_XVALUES_GET_FTELL_FROM_FD ; $0A + beq @xvars_ftell_call ; Used by lsof + + cpx #KERNEL_XVALUES_GET_PROCESS_ID_LIST + beq @xvalues_get_process_id_list_call + + cpx #KERNEL_XVALUES_GET_PROCESS_NAME_WITH_PID + beq @xvalues_get_process_name_with_pid_call + + cpx #KERNEL_XVALUES_GET_OSNAME + beq @xvalues_get_osname + + cpx #KERNEL_XVALUES_GET_TIME + beq @xvalues_get_time + + cpx #KERNEL_XVALUES_GET_FREE_BANK ; $10 + beq @xvalues_get_free_ram_bank + + ; cpx #KERNEL_XVALUES_GET_FILESIZE ; $10 + ; beq @xvalues_get_filesize + + cpx #$00 + bne @check_who_am_i + + lda XVARS_TABLE_LOW,x + sta RES + + lda XVARS_TABLE_HIGH,x + sta RES+1 + + ldy #$00 + lda (RES),y + + rts + +@xvalues_get_process_name_with_pid_call: + jmp xvalues_get_process_name_with_pid + +@xvalues_get_process_id_list_call: + jmp xvalues_get_process_id_list + +@xvars_ftell_call: + jmp xvars_ftell + +@xvalues_get_free_ram_bank: + jmp xvalues_get_free_ram_bank_routine + +@malloc_table_copy: + lda #<(.sizeof(kernel_malloc_struct)+.sizeof(kernel_malloc_free_chunk_size_struct));+.sizeof(kernel_malloc_busy_begin_struct)+.sizeof(kernel_malloc_free_chunk_size_struct)) + ldy #>(.sizeof(kernel_malloc_struct)+.sizeof(kernel_malloc_free_chunk_size_struct));+.sizeof(kernel_malloc_busy_begin_struct)+.sizeof(kernel_malloc_free_chunk_size_struct)) + jsr XMALLOC_ROUTINE + + sta RES + sta RESB + + sty RES+1 + sty RESB+1 + + jsr XMALLOC_COPY_TABLE_FREE + + lda RESB + ldy RESB+1 + + rts + +@XVARS_GET_PROCESS_NAME_PTR_CALL: + jmp XVARS_GET_PROCESS_NAME_PTR + +@xvars_get_fd_list_call: + jmp xvars_get_fd_list + +@malloc_table_busy_copy: + lda #<(.sizeof(kernel_malloc_struct)+.sizeof(kernel_malloc_free_chunk_size_struct));+.sizeof(kernel_malloc_busy_begin_struct)+.sizeof(kernel_malloc_free_chunk_size_struct)) + ldy #>(.sizeof(kernel_malloc_struct)+.sizeof(kernel_malloc_free_chunk_size_struct));+.sizeof(kernel_malloc_busy_begin_struct)+.sizeof(kernel_malloc_free_chunk_size_struct)) + jsr XMALLOC_ROUTINE + + sta RES + sta RESB + + sty RES+1 + sty RESB+1 + + jsr XMALLOC_COPY_TABLE_BUSY2 + + lda RESB + ldy RESB+1 + + rts + + +@xvalues_get_osname: + lda #<$05 + ldy #>$05 + jsr XMALLOC_ROUTINE + sta RES + sty RES+1 + + ldy #$00 +@loop_osname: + lda osname,y + beq @eos_osname + sta (RES),y + iny + bne @loop_osname + +@eos_osname: + sta (RES),y + + lda RES + ldy RES+1 + + rts + +@xvalues_get_time: + ror FLGCLK + lda TIMES + ldy TIMEM + ldx TIMEH + rts + +@check_who_am_i: + cpx #$01 + bne @out + + lda #$00 + sta RES + + lda $342 + and #%00100000 + cmp #%00100000 + bne @rom + lda #32 + sta RES +@rom: + lda $343 + beq @do_not_compute + cmp #$04 + bne @not_set_4 + + lda #$00 + +@not_set_4: + tax + + lda #$00 +@L1: + clc + adc #$04 + dex + bne @L1 + +@do_not_compute: + clc + adc BNK_TO_SWITCH + clc + adc RES + + rts + +@out: + lda #$01 + rts + +.endproc + + + +.proc xvalues_get_free_ram_bank_routine + + ; Y contains if the type of bank + ; Y=0 RAM + ; Y=1 ROM + cpy #$01 ; Is rom ? + beq @not_managed + + + ; Aller lire + ; lda #<KERNEL_BANK_MANAGEMENT + ; sta ADDRESS_READ_BETWEEN_BANK + ; lda #>KERNEL_BANK_MANAGEMENT- + ; sta ADDRESS_READ_BETWEEN_BANK+1 + ; ldy #$00 + ; jsr $4AF + ; See code_adress_get + + + + ; Puis incrémenter + +; code_adress_4AF: +; lda VIA2::PRA +; and #%11111000 ; switch to RAM overlay +; ora BNK_TO_SWITCH ; but select a bank in BNK_TO_SWITCH +; sta VIA2::PRA +; lda (ADDRESS_READ_BETWEEN_BANK),y ; Read byt + + + ldx #$00 + lda BUSY_BANK_TABLE_RAM + +@search_available_bank: + clc + ror + bcc @found + + inx + cpx #$08 ; For instance, manage only 8 banks + beq @error + bne @search_available_bank + ; not found + +@found: + ; X contains the id of the bank + stx RES ; Save + + lda #01 ; 4 + +@continue: + asl + dex ; 0 + bne @continue + ora BUSY_BANK_TABLE_RAM + sta BUSY_BANK_TABLE_RAM + + lda RES + clc + adc #33 + sta RES + jsr get_registers_from_id_bank + ; A and X contains value + ; X contains set + ; A the bank + ; Y the id of the bank + + ldy RES + + rts + +@not_managed: +@error: + lda #$00 + tax + tay + rts +.endproc + +.proc get_registers_from_id_bank + cmp #$00 + beq @bank0 + tay + lda set,y + tax + lda bank,y + rts +@bank0: + ; Impossible to have bank 0 + tax + rts + +set: + ; Rom + .byt 0 + .byte 0,0,0,0 + .byte 4,4,4,4 + .byte 1,1,1,1 + .byte 5,5,5,5 + .byte 2,2,2,2 + .byte 6,6,6,6 + .byte 3,3,3,3 + .byte 7,7,7,7 + + ; Ram + .byte 0,0,0,0 + .byte 1,1,1,1 + .byte 2,2,2,2 + .byte 3,3,3,3 + .byte 4,4,4,4 + .byte 5,5,5,5 + .byte 6,6,6,6 + .byte 7,7,7,7 + +bank: + .byt 0 + ; Rom + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + + ; Ram + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + .byte 1,2,3,4 + +.endproc + +.proc xvalues_get_process_name_with_pid + ; y the pid + tya + tax + jsr kernel_get_struct_process_ptr + + + ; lda kernel_process+kernel_process_struct::kernel_one_process_struct_ptr_high,y + ; sta RES + + ; lda kernel_process+kernel_process_struct::kernel_one_process_struct_ptr_low,y + ; ldy RES + + rts +.endproc + +.proc xvalues_get_process_id_list + lda #<kernel_process+kernel_process_struct::kernel_pid_list + ldy #>kernel_process+kernel_process_struct::kernel_pid_list + rts +.endproc + +.proc xvars_ftell + ; A contains the fd + jsr compute_fp_struct + ; Return the current size + ; Set now seek position to 0 ("32 bits") + ldy #_KERNEL_FILE::f_seek_file + + lda (KERNEL_XOPEN_PTR1),y ; A + sta RESB + iny + lda (KERNEL_XOPEN_PTR1),y ; X + tax + iny + lda (KERNEL_XOPEN_PTR1),y ; Y + sta RESB+1 + + iny + lda (KERNEL_XOPEN_PTR1),y ; RES + sta RES + lda RESB + ldy RESB+1 + rts +.endproc + +; Arg = $09 +.proc xvars_get_fd_list + ; Y contains the fd to get + ; Returns : X the mode of the opened file$ + + tya + sec + sbc #KERNEL_FIRST_FD + asl + tax + + lda kernel_process+kernel_process_struct::fp_ptr,x + sta RES + lda kernel_process+kernel_process_struct::fp_ptr+1,x + beq @no_ptr + sta RES+1 + + ; Get the mode + ldy #_KERNEL_FILE::f_mode + lda (RES),y + tax + + lda #_KERNEL_FILE::f_path + clc + adc RES + bcc @S1 + inc RES+1 + +@S1: + ; A is valid path + ldy RES+1 + rts + +@no_ptr: + ldy #$00 + rts +.endproc + +.proc XMALLOC_COPY_TABLE_FREE + + lda #$00 + sta TR0 ; number of lines + + ldy #$01 ; Because we store the number of line + ldx #$00 + +@loop_copy_free_chunk_begin_low: + lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,x + beq @free_slot_not_used ; Begin low is equal to 0 ? Yes, it's empty + sta (RES),y + iny + + lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,x + sta (RES),y + iny + + lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_high,x + sta (RES),y + iny + + + lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_low,x + sta (RES),y + iny + + lda kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,x + sta (RES),y + iny + + + lda kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low,x + sta (RES),y + iny + + inc TR0 + +@free_slot_not_used: + inx + cpx #KERNEL_MALLOC_FREE_CHUNK_MAX + bne @loop_copy_free_chunk_begin_low + + ldy #$00 + lda TR0 + sta (RES),y + +; Store number of line at the first byte + + rts +.endproc + +.proc XMALLOC_COPY_TABLE_BUSY2 + + lda #$00 + sta TR0 ; number of lines + + ldy #$01 + ldx #$00 + +@loop_copy_busy_chunk_begin_low: + + lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x + beq @busy_slot_not_used ; Begin low is equal to 0 ? Yes, it's empty + + sta (RES),y + iny + + lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x + sta (RES),y + iny + + lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x + sta (RES),y + iny + + + lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x + sta (RES),y + iny + + lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x + sta (RES),y + iny + + lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x + sta (RES),y + iny + + inc TR0 + +@busy_slot_not_used: + inx + cpx #KERNEL_MAX_NUMBER_OF_MALLOC + bne @loop_copy_busy_chunk_begin_low + + ldy #$00 + lda TR0 + sta (RES),y + + rts +.endproc + +.proc XVARS_GET_PROCESS_NAME_PTR + ; Y contains the chunk + + lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_pid_list,y + cmp #$FF ; is init ? + beq @init + + tax + + jsr kernel_get_struct_process_ptr + rts + +@init: + lda #$00 ; Return null if it's init + ldy #$00 + rts +.endproc + +.proc XVARS_COPY_MALLOC_TABLE_COMPUTE_OFFSET_FREE_CHUNK + lda RES + clc + adc #KERNEL_MALLOC_FREE_CHUNK_MAX + bcc @S1 + inc RES+1 +@S1: + sta RES + rts +.endproc + +.proc XVARS_COPY_MALLOC_TABLE_COMPUTE_OFFSET_BUSY_CHUNK + lda RES + clc + adc #KERNEL_MAX_NUMBER_OF_MALLOC + bcc @S1 + inc RES+1 +@S1: + sta RES + rts +.endproc + + +osname: + .asciiz "Orix" diff --git a/src/functions/xvars/xvars.asm b/src/functions/xvars/xvars.asm index 35a186a9..9a28d55b 100644 --- a/src/functions/xvars/xvars.asm +++ b/src/functions/xvars/xvars.asm @@ -1,6 +1,11 @@ .include "include/xvars.inc" +.export XVARS_ROUTINE + +; .export XVARS_TABLE_LOW +; .export XVARS_TABLE_HIGH + .proc XVARS_ROUTINE lda XVARS_TABLE_LOW,x ldy XVARS_TABLE_HIGH,x @@ -8,6 +13,26 @@ rts .endproc + +; .export XVALUES_ROUTINE + +; .include "telestrat.inc" + +; .include "../../include/kernel.inc" +; .include "../../include/process.inc" +; .include "../../include/memory.inc" +; .include "../../include/files.inc" + +; .include "../../kernel.inc" + +; .import XVARS_TABLE_HIGH +; .import XVARS_TABLE_LOW + +; .import XMALLOC_ROUTINE +; .import kernel_get_struct_process_ptr +; .import compute_fp_struct + + .proc XVALUES_ROUTINE cpx #KERNEL_XVALUES_FREE_MALLOC_TABLE beq @malloc_table_copy ; Used by lsmem @@ -110,12 +135,10 @@ rts -; @xvalues_get_filesize: -; rts @xvalues_get_osname: - lda #<5 - ldy #>5 + lda #<$05 + ldy #>$05 jsr XMALLOC_ROUTINE sta RES sty RES+1 @@ -135,6 +158,7 @@ ldy RES+1 rts + @xvalues_get_time: ror FLGCLK lda TIMES @@ -187,6 +211,8 @@ .endproc + + .proc xvalues_get_free_ram_bank_routine ; Y contains if the type of bank @@ -195,6 +221,28 @@ cpy #$01 ; Is rom ? beq @not_managed + + ; Aller lire + ; lda #<KERNEL_BANK_MANAGEMENT + ; sta ADDRESS_READ_BETWEEN_BANK + ; lda #>KERNEL_BANK_MANAGEMENT- + ; sta ADDRESS_READ_BETWEEN_BANK+1 + ; ldy #$00 + ; jsr $4AF + ; See code_adress_get + + + + ; Puis incrémenter + +; code_adress_4AF: +; lda VIA2::PRA +; and #%11111000 ; switch to RAM overlay +; ora BNK_TO_SWITCH ; but select a bank in BNK_TO_SWITCH +; sta VIA2::PRA +; lda (ADDRESS_READ_BETWEEN_BANK),y ; Read byt + + ldx #$00 lda BUSY_BANK_TABLE_RAM @@ -257,49 +305,7 @@ tax rts -set: - ; Rom - .byt 0 - .byte 0,0,0,0 - .byte 4,4,4,4 - .byte 1,1,1,1 - .byte 5,5,5,5 - .byte 2,2,2,2 - .byte 6,6,6,6 - .byte 3,3,3,3 - .byte 7,7,7,7 - - ; Ram - .byte 0,0,0,0 - .byte 1,1,1,1 - .byte 2,2,2,2 - .byte 3,3,3,3 - .byte 4,4,4,4 - .byte 5,5,5,5 - .byte 6,6,6,6 - .byte 7,7,7,7 - -bank: - .byt 0 - ; Rom - .byte 1,2,3,4 - .byte 1,2,3,4 - .byte 1,2,3,4 - .byte 1,2,3,4 - .byte 1,2,3,4 - .byte 1,2,3,4 - .byte 1,2,3,4 - .byte 1,2,3,4 - - ; Ram - .byte 1,2,3,4 - .byte 1,2,3,4 - .byte 1,2,3,4 - .byte 1,2,3,4 - .byte 1,2,3,4 - .byte 1,2,3,4 - .byte 1,2,3,4 - .byte 1,2,3,4 +.include "set_bank_mapping_values.s" .endproc @@ -450,7 +456,6 @@ bank: @loop_copy_busy_chunk_begin_low: lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x - beq @busy_slot_not_used ; Begin low is equal to 0 ? Yes, it's empty sta (RES),y @@ -531,6 +536,11 @@ bank: rts .endproc + +; osname: +; .asciiz "Orix" + + XVARS_TABLE_VALUE_LOW: .byt <KERNEL_ERRNO diff --git a/src/include/files.inc b/src/include/files.inc index 20337c42..d232a98d 100644 --- a/src/include/files.inc +++ b/src/include/files.inc @@ -11,10 +11,6 @@ .endstruct -.out "==================================================================" -.out "File memory" -.out "==================================================================" -.out .sprintf("_KERNEL_FILE size (One fp struct) : $%X bytes", .sizeof(_KERNEL_FILE)) .struct _EXT_FILE f_flags .byte ; Fopen, closed etc diff --git a/src/include/kernel.inc b/src/include/kernel.inc index 847e66fe..77176884 100644 --- a/src/include/kernel.inc +++ b/src/include/kernel.inc @@ -1,10 +1,10 @@ .define XVARS_KERNEL_PROCESS 0 .define XVARS_KERNEL_MALLOC 1 -.define XVARS_KERNEL_CH376_MOUNT 2 -.define XVARS_KERNEL_CONF 3 -.define XVARS_KERNEL_ERRNO 4 -.define XVARS_KERNEL_BINARY_VERSION 6 ; used in untar version -.define XVARS_KERNEL_MAX_PROCESS 8 +.define XVARS_KERNEL_CH376_MOUNT 2 +.define XVARS_KERNEL_CONF 3 +.define XVARS_KERNEL_ERRNO 4 +.define XVARS_KERNEL_BINARY_VERSION 6 ; used in untar version +.define XVARS_KERNEL_MAX_PROCESS 8 .define KERNEL_XVARS_MAX_NUMBER_OF_MALLOC_AND_FREE_CHUNK $05 .define KERNEL_XVARS_CURRENT_VERSION_BINARY $06 .define KERNEL_XVARS_KERNEL_MAX_PROCESS $08 @@ -38,7 +38,8 @@ .define KERNEL_MAX_PATH_LENGTH 9*PATH_CURRENT_MAX_LEVEL+MAX_LENGTH_OF_FILES ; -.out .sprintf("KERNEL_MAX_PATH_LENGTH : %s bytes ", .string(KERNEL_MAX_PATH_LENGTH)) + + .define KERNEL_MAX_LENGTH_BUFEDT ORIX_MAX_PATH_LENGTH+9 @@ -53,23 +54,117 @@ ;.define KERNEL_PATH_CURRENT_MAX_LEVEL PATH_CURRENT_MAX_LEVEL ; 4 systems Buffers 6 for user (telemon historical) -.define KERNEL_NUMBER_BUFFER 4+6 +.define KERNEL_NUMBER_BUFFER 4 + 6 -TELEMON_KEYBOARD_BUFFER_BEGIN = $C5C4 -TELEMON_KEYBOARD_BUFFER_END = $C680 -TELEMON_ACIA_BUFFER_INPUT_BEGIN = $C680 -TELEMON_ACIA_BUFFER_INPUT_END = $C800 +KERNEL_FORK_PROCESS = 0 +KERNEL_NOFORK_PROCESS = 1 ; Performs an EXEC like unix/linux, it destroy memory from current process -TELEMON_ACIA_BUFFER_OUTPUT_BEGIN = $C800 -TELEMON_ACIA_BUFFER_OUTPUT_END = $CA00 -TELEMON_PRINTER_BUFFER_BEGIN = $CA00 -TELEMON_PRINTER_BUFFER_END = $D200 +ADDRESS_READ_BETWEEN_BANK_DOUBLON := $32 +BNKCIB_DOUBLON := $34 +RETURN_BANK_READ_BYTE_FROM_OVERLAY_RAM := $78 + +BASH_MAX_ARGS = 3 ; Number of possible args in the command line +BASH_MAX_BUFEDT_LENGTH = 110 +userzp := VARLNG +NEXT_STACK_BANK := $0418 +MOUSE_JOYSTICK_MANAGEMENT := $291 ; 12 bytes ? +i_o_counter := $1A ; 1 byte +i_o_save := $1B ; 3 bytes ? +TRANSITION_RS232 := $1E; 3 bytes +FILESYS_BANK := $20C +KEYBOARD_COUNTER := $02A6 ; 4 bytes +VIA_UNKNOWN := $028F ; seems tobe a backup of timer 2 bytes +ORIX_MEMORY_DRIVER_ADDRESS := $400 +SWITCH_TO_BANK_ID := $040C +;NEXT_STACK_BANK:=$418 +FIXME_PAGE0_0 := $25 +ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY:= $411 ; .dsb 3 + +KERNEL_XOPEN_PTR1 := $04 ; DECBIN + +work_channel := $19 ; 1 byte +KBD_UNKNOWN := $271 ;FIXME + +FUFTRV = $0100; working Buffer + +NULL = 0 +;BUFROU := $C500 ; Routines for buffers gestion + +SIZE_OF_STACK_BANK = 3 + +BNKOLD:=$40F + +ADDRESS_READ_BETWEEN_BANK := $15 +ADDRESS_VECTOR_FOR_ADIOB := $17 +BNK_TO_SWITCH := $410 + + +RES5 := $0A + +;RESC := DECDEB ; $04 +;RESD := DECFIN ; $06 +;RESE := DECCIB ; +;RESF := DECTRV ; +;RESG := ACCPS ; +;RESH := ACC1E + +;KERNEL_XOPEN_PTR1 := $04 ; DECBIN +KERNEL_XOPEN_PTR2 := $06 ; DECFIN + +KERNEL_XWRITE_XCLOSE_XFSEEK_XFREAD_SAVE_Y := $51 ; DECBIN +KERNEL_XWRITE_XCLOSE_XFSEEK_XFREAD_SAVE_X := $52 ; DECBIN + +KERNEL_XFSEEK_SAVE_RES := $06; DECBIN +KERNEL_XFSEEK_SAVE_RESB := $4D ; DECBIN +;KERNEL_XOPEN_PTR2 := $06 ; DECFIN + + +KERNEL_CREATE_PROCESS_PTR1 := ACC1E ; $60 & $61 +XOPEN_RES := $4D ; Also HRS1 2 bytes +XOPEN_RESB := $4F ; Also HRS2 2 bytes +XOPEN_RES_SAVE := $51 ; Also HRS3 2 bytes +XOPEN_RESB_SAVE := $53 ; Also HRS4 2 bytes +XOPEN_SAVEY := $55 ; Also HRS4 2 bytes +XOPEN_SAVEA := $56 ; Also HRS4 2 bytes +XOPEN_FLAGS := $57 ; also HRSFB 1 byte +TELEMON_UNKNWON_LABEL_62 := $62 +TELEMON_UNKNWON_LABEL_70 := $70 +TELEMON_UNKNWON_LABEL_71 := $71 +TELEMON_UNKNWON_LABEL_72 := $72 +TELEMON_UNKNWON_LABEL_7F := $7F +TELEMON_UNKNWON_LABEL_86 := $86 +FLPOLP := $85 +FLPO0 := $87 + +.macro addsym symbole + .out .sprintf("%s = $%x", .string(symbole), symbole) +.endmacro -;HISTORY_BUFFER_BEGIN = TELEMON_PRINTER_BUFFER_END+1 -;HISTORY_BUFFER_END = TELEMON_PRINTER_BUFFER_END+200 -KERNEL_CONF_BEGIN := $D201 -KERNEL_CONF_END := $D210 +.ifdef DISPLAY_INFO + .out .sprintf("KERNEL_MAX_PATH_LENGTH : %s bytes ", .string(KERNEL_MAX_PATH_LENGTH)) +.endif + + +.define KERNEL_SIZE_IOTAB $04 + +XMALLOC_ROUTINE_TO_RAM_OVERLAY = 39 +ADIODB_LENGTH = $08 + + +.macro STZ_ABS arg ; Define macro ldax + lda #$00 + sta arg +.endmacro + +.macro STZ_ABS_X arg ; Define macro ldax + lda #$00 + sta arg,x +.endmacro + +.macro INCA + clc + adc #$01 +.endmacro + -KERNEL_FORK_PROCESS = 0 -KERNEL_NOFORK_PROCESS = 1 ; Performs an EXEC like unix/linux, it destroy memory from current process diff --git a/src/include/libs/ch376_verify.s b/src/include/libs/ch376_verify.s index f46a040f..971cf7ac 100644 --- a/src/include/libs/ch376_verify.s +++ b/src/include/libs/ch376_verify.s @@ -3,12 +3,11 @@ cmp #CH376_DETECTED beq @detected - - ; let's start reset jsr _ch376_reset_all lda #$01 ; error rts + @detected: jsr _ch376_set_usb_mode_kernel diff --git a/src/include/memory.inc b/src/include/memory.inc index 0b7a34c0..5ac8327e 100644 --- a/src/include/memory.inc +++ b/src/include/memory.inc @@ -3,8 +3,19 @@ .define KERNEL_MALLOC_FREE_CHUNK_MAX 5 .define KERNEL_MALLOC_MAX_MEM_ADRESS $B3FF ; We can't do malloc greater than this offset +.define KERNEL_FIRST_FREE_RAM_BANK 34 +.define KERNEL_LAST_RAM_BANK 64 + +.define KERNEL_RAM_BANK_APPLICATION_TYPE $01 ; The bank won't be destroyed when the process stops (example : bank) + + ; If struct is changed see xvars. +.define KERNEL_ALLOCATE_BANK $01 +.define KERNEL_FREE_BANK $02 +.define KERNEL_FREE_BANK_BY_PID $03 +.define KERNEL_STUB_1_BANK $04 ; Offset used for start network + .struct kernel_malloc_struct kernel_malloc_free_chunk_begin_low .res KERNEL_MALLOC_FREE_CHUNK_MAX kernel_malloc_free_chunk_begin_high .res KERNEL_MALLOC_FREE_CHUNK_MAX @@ -52,20 +63,14 @@ .endstruct .struct kernel_malloc_free_chunk - kernel_malloc_free_chunk_begin_low .res KERNEL_MALLOC_FREE_CHUNK_MAX - kernel_malloc_free_chunk_begin_high .res KERNEL_MALLOC_FREE_CHUNK_MAX - kernel_malloc_free_chunk_end_low .res KERNEL_MALLOC_FREE_CHUNK_MAX - kernel_malloc_free_chunk_end_high .res KERNEL_MALLOC_FREE_CHUNK_MAX - kernel_malloc_free_chunk_size_high .res KERNEL_MALLOC_FREE_CHUNK_MAX - kernel_malloc_free_chunk_size_low .res KERNEL_MALLOC_FREE_CHUNK_MAX + kernel_malloc_free_chunk_begin_low .res KERNEL_MALLOC_FREE_CHUNK_MAX + kernel_malloc_free_chunk_begin_high .res KERNEL_MALLOC_FREE_CHUNK_MAX + kernel_malloc_free_chunk_end_low .res KERNEL_MALLOC_FREE_CHUNK_MAX + kernel_malloc_free_chunk_end_high .res KERNEL_MALLOC_FREE_CHUNK_MAX + kernel_malloc_free_chunk_size_high .res KERNEL_MALLOC_FREE_CHUNK_MAX + kernel_malloc_free_chunk_size_low .res KERNEL_MALLOC_FREE_CHUNK_MAX .endstruct -.out "==================================================================" -.out "Memory" -.out "==================================================================" -.out .sprintf("KERNEL_MAX_NUMBER_OF_MALLOC (max malloc for all process) : %s", .string(KERNEL_MAX_NUMBER_OF_MALLOC)) -.out .sprintf("kernel_malloc_struct size (malloc table) : $%X bytes", .sizeof(kernel_malloc_struct)) - .if .sizeof(kernel_malloc_struct) > 255 .error "kernel_malloc_struct size is greater than 255. It's impossible because code does not handle a struct greater than 255" .endif @@ -75,4 +80,53 @@ argv_value_ptr .res KERNEL_LENGTH_MAX_CMDLINE+KERNEL_MAX_ARGS_COMMAND_LINE ; add 0 to string .endstruct +.ifdef DISPLAY_INFO +.out "==================================================================" +.out "Memory" +.out "==================================================================" +.out .sprintf("KERNEL_MAX_NUMBER_OF_MALLOC (max malloc for all process) : %s", .string(KERNEL_MAX_NUMBER_OF_MALLOC)) +.out .sprintf("kernel_malloc_struct size (malloc table) : $%X bytes", .sizeof(kernel_malloc_struct)) .out .sprintf("XMAINARGS_STRUCT size : $%X bytes", .sizeof(XMAINARGS_STRUCT)) +.endif + +.struct kernel_bank_management_struct + KERNEL_BANK_STATES .res 64 + KERNEL_BANK_PROCESS_ID .res 64 +.endstruct + +.macro MEMORY_PUT_VALUE_TO_BANK address + ; Put a value into ank + ; X the id of the bank where the value will be written + ; A the value to write + ; Y the offset from address + ; Modify RES + + sta RES + stx BNKCIB_DOUBLON + ldx #$01 ; Write + lda #<address + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + lda #>address + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + jsr $04C7 +.endmacro + + +.macro MEMORY_GET_VALUE_FROM_BANK + ; X the id of the bank + ; A and Y are the address + ; stx BNK_TO_SWITCH + ; sta ADDRESS_READ_BETWEEN_BANK + ; sty ADDRESS_READ_BETWEEN_BANK+1 + ; ldx #$ + ; ldy #$00 + ; jsr $04AF + stx BNKCIB_DOUBLON ; Bank + + lda $321 + sta RETURN_BANK_READ_BYTE_FROM_OVERLAY_RAM + + ldx #$00 ; Read + jsr $04C7 + +.endmacro diff --git a/src/include/network.inc b/src/include/network.inc new file mode 100644 index 00000000..3c24d865 --- /dev/null +++ b/src/include/network.inc @@ -0,0 +1,25 @@ +.define KERNEL_STUB1_NETWORK $01 +.define KERNEL_STUB2_NETWORK $02 +.define KERNEL_STUB3_NETWORK $03 +.define KERNEL_START_NETWORK $04 + +.define KERNEL_SOCKET_NETWORK $05 +.define KERNEL_BIND_NETWORK $06 +.define KERNEL_CONNECT_NETWORK $07 +.define KERNEL_RECV_NETWORK $08 +.define KERNEL_SEND_NETWORK $09 +.define KERNEL_SOCKET_CLOSE_NETWORK $0A +.define KERNEL_SOCKET_CLOSE_FROM_PID_NETWORK $0B + + +.define KERNEL_NETWORK_STATE_NOT_INITIALIZED $00 +.define KERNEL_NETWORK_STATE_CHIP_INITIALIZED $01 +.define KERNEL_NETWORK_CABLE_DISCONNECTED $02 +.define KERNEL_NETWORK_CABLE_CONNECTED $03 +.define KERNEL_NETWORK_FULLY_STARTED $04 +.define KERNEL_NETWORK_STARTING_DHCP $05 + +.define KERNEL_NETWORK_STATE_CHIP_NOT_FOUND $FF + +; When network stack is initialized, this value will be the first source port for an openning socket +.define KERNEL_FIRST_SOURCE_PORT_INIT 140 \ No newline at end of file diff --git a/src/include/orix.inc b/src/include/orix.inc new file mode 100644 index 00000000..e69de29b diff --git a/src/include/process.inc b/src/include/process.inc index f8d49fdd..fc6ad895 100644 --- a/src/include/process.inc +++ b/src/include/process.inc @@ -41,12 +41,6 @@ ;kernel_max_process_value .res 1 .endstruct -.out .sprintf("KERNEL_MAX_PROCESS (Max process in the system) : %s", .string(KERNEL_MAX_PROCESS)) -.out .sprintf("KERNEL_MAX_FP_PER_PROCESS (Max file pointer per process): %s", .string(KERNEL_MAX_FP_PER_PROCESS)) -.out .sprintf("KERNEL_USERZP_SAVE_LENGTH : %s bytes", .string(KERNEL_USERZP_SAVE_LENGTH)) -.out .sprintf("KERNEL_LENGTH_MAX_CMDLINE : %s", .string(KERNEL_LENGTH_MAX_CMDLINE)) - -.out .sprintf("kernel_process_struct size (struct init process) : $%X bytes", .sizeof(kernel_process_struct)) .if .sizeof(kernel_process_struct) > 255 .error "kernel_process_struct size is greater than 255. It's impossible because code does not handle a struct greater than 255" @@ -73,10 +67,10 @@ .endif .endstruct -.out .sprintf("kernel_one_process_struct size (struct for one process) : $%X bytes", .sizeof(kernel_one_process_struct)) + .if .sizeof(kernel_one_process_struct) > 255 .error "kernel_one_process_struct size is greater than 255. It's impossible because code does not handle a struct greater than 255" .endif -.out .sprintf("With all the parameter all process could use %s bytes in memory, if it's allocated", .string(.sizeof(kernel_one_process_struct)*KERNEL_MAX_PROCESS+.sizeof(kernel_process_struct))) + diff --git a/src/include/xvars.inc b/src/include/xvars.inc index 735719dc..64e37f7f 100644 --- a/src/include/xvars.inc +++ b/src/include/xvars.inc @@ -1,5 +1,8 @@ .define WHO_AM_IAM $01 .define MALLOC_TABLE_COPY $02 +.define KERNEL_BANK_NETWORK $01 +.define KERNEL_BANK_UNDEFINED $FF + diff --git a/src/kernel.asm b/src/kernel.asm index a496504f..71c7bb42 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -1,26 +1,6 @@ -.FEATURE labels_without_colons, pc_assignment, loose_char_term, c_comments +.FEATURE labels_without_colons, pc_assignment, loose_char_term, org_per_seg -.macro STZ_ABS arg ; Define macro ldax - lda #$00 - sta arg -.endmacro - -.macro STZ_ABS_X arg ; Define macro ldax - lda #$00 - sta arg,x -.endmacro - -.macro INCA - clc - adc #$01 -.endmacro - -.define VERSION "2024.1" - -XMALLOC_ROUTINE_TO_RAM_OVERLAY = 39 - -ADIODB_LENGTH = $08 -.define KERNEL_SIZE_IOTAB $04 +.define VERSION "2025.1" .include "telestrat.inc" ; from cc65 .include "fcntl.inc" ; from cc65 @@ -28,15 +8,81 @@ ADIODB_LENGTH = $08 .include "errno.inc" ; from cc65 .include "cpu.mac" ; from cc65 .include "signal.inc" ; from cc65 + .include "libs/ch376-lib/include/ch376.inc" .include "include/kernel.inc" .include "include/process.inc" -;.include "include/process_bss.inc" +.include "include/network.inc" .include "include/memory.inc" .include "include/files.inc" .include "include/ori2.inc" .include "versions/versions.inc" + + +.export code_adress_419 +.export VEXBNK +.export code_adress_436 + + +.import XMINMA_ROUTINE + +; Network +.import XNETWORK_START_ROUTINE + +; Import from bank0 +.import TELEMON_KEYBOARD_BUFFER_END +.import TELEMON_KEYBOARD_BUFFER_BEGIN +.import BUFROU +.import KERNEL_CONF_BEGIN +.import KERNEL_BANK_MANAGEMENT + +; Import main memory +.import KERNEL_ERRNO +.import KERNEL_CH376_MOUNT +.import KERNEL_XFREE_TMP +.import KERNEL_XKERNEL_CREATE_PROCESS_TMP +.import KERNEL_TMP_XEXEC +.import KERNEL_KERNEL_XEXEC_BNKOLD +.import KERNEL_MALLOC_TYPE +.import KERNEL_SAVE_XEXEC_CURRENT_SET +.import KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM +.import KERNEL_END_PROCESS_VARIABLES +.import SCRFX_KERNEL +.import IOTAB +.import KERNEL_ADIOB +.import kernel_malloc_free_chunk_size +.import kernel_xmalloc_call +.import KERNEL_ADIOB_END +.import READ_BYTE_FROM_OVERLAY_RAM +.import FIXME_DUNNO +.import STACK_BANK +;.import BUFNOM +.import kernel_malloc +.import KERNEL_DRIVER_MEMORY +.import kernel_process +.import BUSY_BANK_TABLE_RAM +.import kernel_end_of_memory_for_kernel + +.import KERNEL_NETWORK_FLAG + +.import XBANK_ROUTINE + +.import KERNEL_BANK_EXTENDED_AVAILABLE + +.import switch_to_kernel_extended_fill_register +.import kernel_restore_banking_states +.import kernel_restore_banking_states_register +; .import RESC +; .import RESD +; .import RESE +; .import RESF +; .import RESG +; .import RESH +; .import RESI +; .import RESCONCAT + + .out "==================================================================" .out "Resume" .out "==================================================================" @@ -47,9 +93,10 @@ ADIODB_LENGTH = $08 .endif .include "orix.mac" -.include "kernel.inc" +;.include "kernel.inc" .include "build.inc" +;.import KERNEL_BANK_MANAGEMENT ; Used for HRS, but we use it also for XOPEN primitive, there is no probability to have graphics could opens HRS values (For instance) .org $04 @@ -66,48 +113,12 @@ RESG: .res 2 .org $60 ; ACC1E RESH: - .res 2 ; ACC1M+1 $62 + .res 2 ; ACC1M + 1 $62 RESI: - .res 2 ; $ACC1M+3 $64 + .res 2 ; $ACC1M + 3 $64 RESCONCAT: - .res 2 ; ACC1S+1 $66 - -RES5 := $0A - -;RESC := DECDEB ; $04 -;RESD := DECFIN ; $06 -;RESE := DECCIB ; -;RESF := DECTRV ; -;RESG := ACCPS ; -;RESH := ACC1E - -KERNEL_XOPEN_PTR1 := $04 ; DECBIN -KERNEL_XOPEN_PTR2 := $06 ; DECFIN - -KERNEL_XWRITE_XCLOSE_XFSEEK_XFREAD_SAVE_Y := $51 ; DECBIN -KERNEL_XWRITE_XCLOSE_XFSEEK_XFREAD_SAVE_X := $52 ; DECBIN - -KERNEL_XFSEEK_SAVE_RES := $06; DECBIN -KERNEL_XFSEEK_SAVE_RESB := $4D ; DECBIN -;KERNEL_XOPEN_PTR2 := $06 ; DECFIN - - -KERNEL_CREATE_PROCESS_PTR1 := ACC1E ; $60 & $61 -XOPEN_RES := $4D ; Also HRS1 2 bytes -XOPEN_RESB := $4F ; Also HRS2 2 bytes -XOPEN_RES_SAVE := $51 ; Also HRS3 2 bytes -XOPEN_RESB_SAVE := $53 ; Also HRS4 2 bytes -XOPEN_SAVEY := $55 ; Also HRS4 2 bytes -XOPEN_SAVEA := $56 ; Also HRS4 2 bytes -XOPEN_FLAGS := $57 ; also HRSFB 1 byte -TELEMON_UNKNWON_LABEL_62 := $62 -TELEMON_UNKNWON_LABEL_70 := $70 -TELEMON_UNKNWON_LABEL_71 := $71 -TELEMON_UNKNWON_LABEL_72 := $72 -TELEMON_UNKNWON_LABEL_7F := $7F -TELEMON_UNKNWON_LABEL_86 := $86 -FLPOLP := $85 -FLPO0 := $87 + .res 2 ; ACC1S + 1 $66 + ; PARSE_VECTOR:=$FFF1 @@ -117,22 +128,14 @@ FLPO0 := $87 ; 3- Launch mount on the device but don't test the result, because we don't care at this step : it's a quick hack to mount quickly mass storage gadget -.segment "BANK8" -; .bss -.res 100 - -.segment "BANK0" -; .bss -.res 100 - .segment "BANK7" - .org $C000 start_rom: .proc _main sei + cld ldx #$FF txs ; init stack @@ -149,6 +152,7 @@ start_rom: stz $500,x inx bne @nloopc02 + stz KERNEL_BANK_EXTENDED_AVAILABLE .p02 .else inx @@ -163,9 +167,9 @@ start_rom: sta $500,x inx bne @nloop + sta KERNEL_BANK_EXTENDED_AVAILABLE .endif - ; Trying to mount .ifdef WITH_SDCARD_FOR_ROOT @@ -176,13 +180,16 @@ start_rom: sta KERNEL_CH376_MOUNT + + ;jsr init_network + ; BUSY_BANK_TABLE_RAM is used to know if a ram bank is empty or not lda #$03 ; bank 33 and 34 are reserved (loader/network) sta BUSY_BANK_TABLE_RAM ; Set BUSY BANK_table lda #$00 - sta BUSY_BANK_TABLE_RAM+1 ; Set BUSY BANK_table - sta BUSY_BANK_TABLE_RAM+2 ; Set BUSY BANK_table + sta BUSY_BANK_TABLE_RAM + 1 ; Set BUSY BANK_table + sta BUSY_BANK_TABLE_RAM + 2 ; Set BUSY BANK_table @usb_controler_not_detected: @@ -196,34 +203,12 @@ start_rom: lda #$07 ; Kernel bank sta RETURN_BANK_READ_BYTE_FROM_OVERLAY_RAM -.ifdef WITH_DEBUG_BOARD - lda #'M' - sta $bb80+13 - .endif - jsr init_screens - -.ifdef WITH_DEBUG_BOARD - lda #'N' - sta $bb80+14 -.endif - - jsr XLOADCHARSET_ROUTINE - -.ifdef WITH_DEBUG_BOARD - lda #'O' - sta $bb80+15 -.endif - jsr XALLKB_ROUTINE -.ifdef WITH_DEBUG_BOARD - lda #'P' - sta $bb80+16 -.endif - ldx #$00 + @myloop: lda page2_xmalloc_call,x @@ -233,27 +218,11 @@ start_rom: bne @myloop - .ifdef WITH_DEBUG_BOARD - lda #'Q' - sta $bb80+17 - .endif - jsr init_via - - .ifdef WITH_DEBUG_BOARD - lda #'R' - sta $bb80+18 - .endif - jsr init_printer - .ifdef WITH_DEBUG_BOARD - lda #'S' - sta $bb80+19 - .endif - - ldx #(KERNEL_SIZE_IOTAB-1) + @loop: lsr IOTAB,x ; init channels (0 to 3) dex @@ -262,7 +231,7 @@ start_rom: lda IRQVECTOR ; testing if IRQVECTOR low byte is $4C ? cmp #$4C bne @L1 ; non equal to $4C - lda KBDCOL+5 + lda KBDCOL + 5 and #$20 bne @L1 @L1: @@ -278,7 +247,6 @@ next1: set_todefine6: - ldx #$00 loading_vectors_telemon: @@ -294,21 +262,17 @@ loading_vectors_telemon: sta $0700,x ; used to copy in Overlay RAM ... see loop40 label lda ramoverlay_xmalloc,x sta $0800,x ; used to copy in Overlay RAM ... see loop40 label - lda ramoverlay_xmalloc+256,x + lda ramoverlay_xmalloc + 256,x sta $0900,x ; used to copy in Overlay RAM ... see loop40 label lda ramoverlay_xfree,x sta $2000,x ; used to copy in Overlay RAM ... see loop40 label - lda ramoverlay_xfree+256,x + lda ramoverlay_xfree + 256,x sta $2100,x ; used to copy in Overlay RAM ... see loop40 label - lda ramoverlay_xfree+256+256,x + lda ramoverlay_xfree + 256 + 256,x sta $2200,x ; used to copy in Overlay RAM ... see loop40 label inx ; loop until 256 bytes are filled bne @loop - .ifdef WITH_DEBUG_BOARD - lda #'T' - sta $bb80+20 - .endif ; Just fill ram with BUFROU jsr $0600 @@ -320,23 +284,13 @@ loading_vectors_telemon: inx ; loop until 256 bytes are filled bne @loop2 - .ifdef WITH_DEBUG_BOARD - lda #'U' - sta $bb80+21 - .endif set_buffers: ; this code sets buffers - ldx #$00 ; Start from 0 + ;ldx #$00 ; Start from 0 jsr XDEFBU_ROUTINE - - .ifdef WITH_DEBUG_BOARD - lda #'A' - sta $bb80 - .endif - skip: ldx #$0B ; copy to $2F4 12 bytes @@ -346,50 +300,23 @@ skip: dex bpl @loop - .ifdef WITH_DEBUG_BOARD - lda #'B' - sta $bb80+1 - .endif - jsr init_keyboard - .ifdef WITH_DEBUG_BOARD - lda #'C' - sta $bb80+2 - .endif - next5: - - lda KBDCOL+4 ; + lda KBDCOL + 4 ; and #$90 beq @skip lda FLGTEL ora #$40 sta FLGTEL -@skip: - -.ifdef WITH_DEBUG_BOARD - lda #'D' - sta $bb80+3 -.endif +@skip: lda #XKBD ; Setup keyboard on channel 0 BRK_TELEMON XOP0 - .ifdef WITH_DEBUG_BOARD - lda #'E' - sta $bb80+4 - .endif - lda #$82 ; Setup screen ! on channel 0 BRK_TELEMON XOP0 - .ifdef WITH_DEBUG_BOARD - lda #'F' - sta $bb80+5 - .endif - - BRK_TELEMON XRECLK ; Don't know this vector bit FLGRST ; COLD RESET ? @@ -402,38 +329,35 @@ next5: ; it's similar to lda #10 brk xwr0 lda #13 brk XWR0 RETURN_LINE - PRINT str_KOROM - telemon_hot_reset: - don_t_display_telemon_signature: lda #<str_tofix ldy #>str_tofix BRK_TELEMON XWSTR0 - ;JSR $0600 ; CORRECTME - - .ifdef WITH_DEBUG_BOARD - lda #'V' - sta $bb80+22 - .endif - don_t_display_signature: jsr routine_to_define_19 - .ifdef WITH_DEBUG_BOARD - lda #'W' - sta $bb80+23 - .endif + lda #64 + sta RES + 1 -display_cursor: + ; Initialize banks states to Empty +@L1: + lda #$00 ; value to store + ldx #$00 ; BANK + ldy #$00 ; Offset to write + MEMORY_PUT_VALUE_TO_BANK KERNEL_BANK_MANAGEMENT + dec RES + 1 + bne @L1 + ; Displays cursor ldx #$00 - BRK_KERNEL XCSSCR ; display cursors -; initialize + BRK_KERNEL XCSSCR + + ; initialize ; Init PID tables and structs @@ -452,34 +376,34 @@ display_cursor: lda #$FF ; Init ; Set process foreground - sta kernel_process+kernel_process_struct::kernel_current_process + sta kernel_process + kernel_process_struct::kernel_current_process ; register init process lda #$01 - sta kernel_process+kernel_process_struct::kernel_pid_list ; COMMENT TO HAVE WORKING MAX PROCESS + sta kernel_process + kernel_process_struct::kernel_pid_list ; COMMENT TO HAVE WORKING MAX PROCESS init_process_init_cwd_in_struct: ldx #$00 @L1: lda str_name_process_kernel,x beq @S1 - sta kernel_process+kernel_process_struct::kernel_cwd_str,x + sta kernel_process + kernel_process_struct::kernel_cwd_str,x inx bne @L1 @S1: - sta kernel_process+kernel_process_struct::kernel_cwd_str,x + sta kernel_process + kernel_process_struct::kernel_cwd_str,x lda #KERNEL_ERRNO_OK sta KERNEL_ERRNO ; init FD lda #$FF - sta kernel_process+kernel_process_struct::kernel_fd_opened ; Store the current fd opened is FF + sta kernel_process + kernel_process_struct::kernel_fd_opened ; Store the current fd opened is FF ; A=00 at this step ldx #$00 txa @init_fp: - sta kernel_process+kernel_process_struct::kernel_fd,x + sta kernel_process + kernel_process_struct::kernel_fd,x inx cpx #KERNEL_MAX_FP bne @init_fp @@ -492,32 +416,32 @@ init_process_init_cwd_in_struct: ldx #$00 lda #$00 ; First byte available when Orix Kernel has started @L3: - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,x ; not useful + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,x ; not useful - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_low,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_high,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_low,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_high,x inx cpx #KERNEL_MALLOC_FREE_CHUNK_MAX bne @L3 lda #<kernel_end_of_memory_for_kernel ; First byte available when Orix Kernel has started - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_low + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_low lda #>kernel_end_of_memory_for_kernel - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high lda #<KERNEL_MALLOC_MAX_MEM_ADRESS ; Get the max memory adress (in oric.h) - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_low + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_low lda #>KERNEL_MALLOC_MAX_MEM_ADRESS - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_high + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_high - lda #<(KERNEL_MALLOC_MAX_MEM_ADRESS-kernel_end_of_memory_for_kernel) ; Get the size (free) - sta kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low + lda #<(KERNEL_MALLOC_MAX_MEM_ADRESS - kernel_end_of_memory_for_kernel) ; Get the size (free) + sta kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low lda #>(KERNEL_MALLOC_MAX_MEM_ADRESS-kernel_end_of_memory_for_kernel) - sta kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high + sta kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high @@ -533,16 +457,59 @@ init_malloc_busy_table: ; lda #$FF ; ; UNCOMMENT MAX_PROCESS lda #$00 @loop: - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_pid_list,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_pid_list,x dex bpl @loop + ; Checking of extended ROM is here + ;KERNEL_BANK_AVAILABLE + + + lda #KERNEL_NETWORK_STATE_NOT_INITIALIZED + ldy #$00 + ldx #$00 + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_FLAG + + + jsr switch_to_kernel_extended_fill_register + + lda #<($FFF0 + 1) ; Offset magic token + ldy #>($FFF0 + 1) + + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 + + ldx #$04 + ldy #$00 + + + MEMORY_GET_VALUE_FROM_BANK ; A contains the value + cmp #'x' ; Magic token for bank 8 + bne @not_extended_bank_found + lda #128 + sta KERNEL_BANK_EXTENDED_AVAILABLE + + ; **************************************************************************** + ; * Start init for network chip * + ; **************************************************************************** + ; Set stage for kernel init + + lda #KERNEL_START_NETWORK + jsr XNETWORK_START_ROUTINE + +@not_extended_bank_found: + jsr kernel_restore_banking_states_register + cli + + +@not_extended_bank: .ifdef WITH_SYSTEMD_AT_BOOT_TIME launch_systemd: lda #<str_binary_systemd sta RES lda #>str_binary_systemd - sta RES+1 + sta RES + 1 + ; kernel_end_of_memory_for_kernel is used it will start XEXEC, but it will be erased after the system stat but we don't care because XEXEC starts ldy #$00 @L1: @@ -561,17 +528,12 @@ launch_systemd: jsr _XEXEC ; start shell .endif - .ifdef WITH_DEBUG_BOARD - lda #'X' - sta $bb80+24 - .endif - launch_command: jsr XCRLF_ROUTINE lda #<str_binary_to_start sta RES lda #>str_binary_to_start - sta RES+1 + sta RES + 1 ; kernel_end_of_memory_for_kernel is used it will start XEXEC, but it will be erased after the system stat but we don't care because XEXEC starts ldy #$00 @@ -648,10 +610,6 @@ init_via: rts loading_code_to_page_6: - .ifdef WITH_DEBUG_BOARD - lda #'Y' - sta $bb80+25 - .endif ; At this step we will copy into ram overlay lda VIA2::PRA ; 3 bytes ; switch to overlay ram ? @@ -668,26 +626,26 @@ loading_code_to_page_6: lda $0800,x sta ramoverlay_xmalloc,x ; used to copy in Overlay RAM ... see loop40 label lda $0900,x - sta ramoverlay_xmalloc+256,x ; used to copy in Overlay RAM ... see loop40 label + sta ramoverlay_xmalloc + 256,x ; used to copy in Overlay RAM ... see loop40 label lda $2000,x sta ramoverlay_xfree,x ; used to copy in Overlay RAM ... see loop40 label lda $2100,x - sta ramoverlay_xfree+256,x ; used to copy in Overlay RAM ... see loop40 label + sta ramoverlay_xfree + 256,x ; used to copy in Overlay RAM ... see loop40 label lda $2200,x - sta ramoverlay_xfree+256+256,x ; used to copy in Overlay RAM ... see loop40 label + sta ramoverlay_xfree + 256 + 256,x ; used to copy in Overlay RAM ... see loop40 label inx bne @loop ; copy 256 bytes to BUFROU in OVERLAY RAM ; Becare full, each time shell is executed it launch it + ; lda #ORIX_FIRST_FREE_RAM_BANK + ; sta KERNEL_BANK_MANAGEMENT + end_proc_init_rams: - .ifdef WITH_DEBUG_BOARD - lda #'Z' - sta $bb80+26 - .endif + lda VIA2::PRA ; 3 bytes ; switch to overlay ram ? ora #%00000111 ; Bank 7 @@ -739,17 +697,17 @@ str_tofix: XDEFBU_ROUTINE: - stx RESB ; store the id of the buffer to set + ;stx RESB ; store the id of the buffer to set lda #<TELEMON_KEYBOARD_BUFFER_BEGIN sta RES lda #>TELEMON_KEYBOARD_BUFFER_BEGIN ; Get high adress of the buffer - sta RES+1 + sta RES + 1 lda #<TELEMON_KEYBOARD_BUFFER_END ldy #>TELEMON_KEYBOARD_BUFFER_END - ldx RESB + ldx #$00 XINIBU_ROUTINE: bit XLISBU_ROUTINE @@ -764,7 +722,7 @@ XTSTBU_ROUTINE: skip2003: sec - jmp ORIX_MEMORY_DRIVER_ADDRESS+9 + jmp ORIX_MEMORY_DRIVER_ADDRESS + 9 XLISBU_ROUTINE: bit XLISBU_ROUTINE @@ -774,7 +732,7 @@ XECRBU_ROUTINE: bit loading_vectors_page_4 skipme2002: clc - jmp ORIX_MEMORY_DRIVER_ADDRESS+9 + jmp ORIX_MEMORY_DRIVER_ADDRESS + 9 ;********************************************************************************* ; CODE INSERTED IN PAGE 4 @@ -883,6 +841,7 @@ code_adress_47E: ; brk gestion ora #$07 sta VIA2::PRA jmp brk_management + code_adress_493: lda VIA2::PRA and #$F8 @@ -902,7 +861,7 @@ code_adress_4A1: ; this routine read a value in a bank ; -code_adress_4AF: +code_adress_4AF: ; $04AF lda VIA2::PRA and #%11111000 ; switch to RAM overlay ora BNK_TO_SWITCH ; but select a bank in BNK_TO_SWITCH @@ -917,19 +876,22 @@ code_adress_4AF: ; Stack used to switch from any bank ; let this res !!! ;.res 1 ; Let this res because, it's FIXME_DUNNO var here -code_adress_get: -; used in bank command in Oric +code_adress_4C7: +;code_adress_get: +; used in bank command in shell rom + Used in bank 8 (kernel) lda VIA2::PRA and #%11111000 ; switch to RAM overlay ; switch to RAM overlay - ora tmp1 ; but select a bank in $410 + ora BNKCIB_DOUBLON ; FIXME ; but select a bank in $410 sta VIA2::PRA cpx #$00 beq @read lda RES - sta (ptr1),y + sta (ADDRESS_READ_BETWEEN_BANK_DOUBLON),y + @read: - lda (ptr1),y ; Read byte + lda (ADDRESS_READ_BETWEEN_BANK_DOUBLON),y ; Read byte + @exit: pha lda RETURN_BANK_READ_BYTE_FROM_OVERLAY_RAM @@ -950,8 +912,8 @@ data_to_define_4: tay beq LC61E - lda BUFBUF+8,x ; $c088 - ora BUFBUF+9,x + lda BUFBUF + 8,x ; $c088 + ora BUFBUF + 9,x beq @skip clc rts @@ -960,13 +922,13 @@ data_to_define_4: rts LC5FE: sta RESB - sty RESB+1 + sty RESB + 1 sec sbc RES sta BUFBUF+$0A,x tya - sbc RES+1 + sbc RES + 1 sta BUFBUF+$0B,x txa adc #$03 @@ -983,14 +945,14 @@ LC5FE: LC61E: lda #$00 ; see page 4 of "Manuel Developpeur Telestrat" - sta BUFBUF+8,x ; get length low - sta BUFBUF+9,x ; get length high - lda BUFBUF+2,x - sta BUFBUF+4,x - sta BUFBUF+6,x - lda BUFBUF+3,x - sta BUFBUF+5,x - sta BUFBUF+7,x + sta BUFBUF + 8,x ; get length low + sta BUFBUF + 9,x ; get length high + lda BUFBUF + 2,x + sta BUFBUF + 4,x + sta BUFBUF + 6,x + lda BUFBUF + 3,x + sta BUFBUF + 5,x + sta BUFBUF + 7,x rts end_BUFROU: @@ -999,19 +961,19 @@ LC639: bvs LC661 jsr $C507 ; FIXME bcs LC660 - lda BUFBUF+6,x - ldy BUFBUF+7,x + lda BUFBUF + 6,x + ldy BUFBUF + 7,x jsr $C5A6 ; FIXME - sta BUFBUF+6,x + sta BUFBUF + 6,x tya - sta BUFBUF+7,x - lda BUFBUF+8,x + sta BUFBUF + 7,x + lda BUFBUF + 8,x bne @skip - dec BUFBUF+9,x + dec BUFBUF + 9,x @skip: - dec BUFBUF+8,x + dec BUFBUF + 8,x ; 65C02 FIXME .IFPC02 .pc02 @@ -1027,20 +989,20 @@ LC660: LC661: pha - lda BUFBUF+8,x + lda BUFBUF + 8,x cmp BUFBUF+$0A,x - lda BUFBUF+9,x + lda BUFBUF + 9,x sbc BUFBUF+$0B,x bcs LC68F - lda BUFBUF+4,x - ldy BUFBUF+5,x + lda BUFBUF + 4,x + ldy BUFBUF + 5,x jsr $C5A6 ; FIXME - sta BUFBUF+4,x + sta BUFBUF + 4,x tya - sta BUFBUF+5,x - inc BUFBUF+8,x + sta BUFBUF + 5,x + inc BUFBUF + 8,x bne LC688 - inc BUFBUF+9,x + inc BUFBUF + 9,x LC688: ; 65C02 FIXME : use sta (XX) ldy #$00 @@ -1058,23 +1020,23 @@ LC691: bcc LC697 iny LC697: - cmp BUFBUF+2,x + cmp BUFBUF + 2,x sta IRQSVP routine_to_define_16: tya - sbc BUFBUF+3,x + sbc BUFBUF + 3,x bcc @S1 lda BUFBUF,x - ldy BUFBUF+1,x + ldy BUFBUF + 1,x sta IRQSVP @S1: sty FIXME_PAGE0_0 ; FIXME lda IRQSVP rts - +;.include "functions/xvars/xvalues.s" .include "functions/xcrlf.asm" .include "functions/XWRx.asm" .include "functions/XWSTRx.asm" @@ -1104,18 +1066,18 @@ routine_to_define_16: send_command_A: sty ADDRESS_VECTOR_FOR_ADIOB - sty ADDRESS_VECTOR_FOR_ADIOB+1 + sty ADDRESS_VECTOR_FOR_ADIOB + 1 pha txa asl tax lda KERNEL_ADIOB,x - sta ADIODB_VECTOR+1 - lda KERNEL_ADIOB+1,x - sta ADIODB_VECTOR+2 + sta ADIODB_VECTOR + 1 + lda KERNEL_ADIOB + 1,x + sta ADIODB_VECTOR + 2 pla lsr ADDRESS_VECTOR_FOR_ADIOB - bit ADDRESS_VECTOR_FOR_ADIOB+1 + bit ADDRESS_VECTOR_FOR_ADIOB + 1 jmp ADIODB_VECTOR ; These bytes are set in ADIOB (page 2) @@ -1136,8 +1098,8 @@ brk_management: ; management of BRK $XX ; on the stack we have ; SP = P register - ; SP-1 = PC+2 adress of brk sent - ; SP-2 = PC+1 + ; SP-1 = PC + 2 adress of brk sent + ; SP-2 = PC + 1 .IFPC02 .pc02 phx @@ -1152,21 +1114,21 @@ brk_management: and #%00010000 ; test B flag B flag means an that we reach a brk commands beq next200 ; is it a break ? tsx ; yes we get Stack pointer - pla ; we pull pointer program +2 + pla ; we pull pointer program + 2 bne @skip - dec BUFTRV+2,x ; CORRECTME + dec BUFTRV + 2,x ; CORRECTME @skip: reset115_labels: sec sbc #$01 pha sta ADDRESS_READ_BETWEEN_BANK - lda BUFTRV+2,x - sta ADDRESS_READ_BETWEEN_BANK+1 - lda BNKOLD - sta BNK_TO_SWITCH - ldy #$00 + lda BUFTRV + 2,x + sta ADDRESS_READ_BETWEEN_BANK + 1 + lda BNKOLD ; On regarde la ROM appelante + sta BNK_TO_SWITCH ; On stocke pour cette banque pour pouvoir aller lire $XX après le brk + ldy #$00 ; On prend la 1ère valeur jsr ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY asl tax @@ -1179,11 +1141,11 @@ reset115_labels: ; then kill process :) @continue_vector: - lda vectors_telemon+1,x ; fetch vector of brk + lda vectors_telemon + 1,x ; fetch vector of brk ldy vectors_telemon,x bcc @skip - lda vectors_telemon_second_table+1,x ; Second table because X >127 + lda vectors_telemon_second_table + 1,x ; Second table because X >127 ldy vectors_telemon_second_table,x ; @@ -1233,7 +1195,7 @@ timeud_next: lda TIMEUD bne @skip - dec TIMEUD+1 + dec TIMEUD + 1 @skip: skipme12: dec TIMEUD @@ -1253,7 +1215,7 @@ skipme12: inc TIMES lda TIMEUS bne @L1 - dec TIMEUS+1 + dec TIMEUS + 1 @L1: dec TIMEUS lda TIMES @@ -1289,13 +1251,13 @@ manage_irq_T1_and_T2: and #$20 beq LC9b9 lda VIA_UNKNOWN - ldy VIA_UNKNOWN+1 + ldy VIA_UNKNOWN + 1 sta VIA::T2 - sty VIA::T2+1 + sty VIA::T2 + 1 routine_todefine_1: lda #$FF - sta VIA::T2+1 + sta VIA::T2 + 1 jmp LC8B9 LC9b9: @@ -1323,13 +1285,13 @@ next110: bit KBDFLG_KEY bpl @S3 lda #$14 - sta KEYBOARD_COUNTER+1 + sta KEYBOARD_COUNTER + 1 bne @L5 @S3: - lda KEYBOARD_COUNTER+2 - bit KEYBOARD_COUNTER+1 + lda KEYBOARD_COUNTER + 2 + bit KEYBOARD_COUNTER + 1 bmi @skip - dec KEYBOARD_COUNTER+1 + dec KEYBOARD_COUNTER + 1 @L5: lda #$01 @skip: @@ -1363,29 +1325,29 @@ XDIVIDE_INTEGER32_BY_1024_ROUTINE: ; RESB and RES contains the result of the division ; BUG : does manage 24 bits integer lsr RESB - ror RES+1 + ror RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES rts @@ -1427,9 +1389,11 @@ telemon_display_clock_chars: ; table des vecteurs du brk vectors_telemon: ;0 + + .byt <XOP0_ROUTINE,>XOP0_ROUTINE ; $00 - .byt <$00,>$00 ; $1 - .byt <$00,>$00 ; 2 + .byt <XBANK_ROUTINE,>XBANK_ROUTINE; $1 + .byt $00,$00 ; 2 .byt <$00,>$00 .byt $00,$00 ; 4 Was XCL in telemon @@ -1485,14 +1449,14 @@ vectors_telemon: .byt <XOPEN_ROUTINE,>XOPEN_ROUTINE ; $30 .byt <$00,>$00 ; .byt $00,$00 ; Old XEDTIN $32 - .byt <XECRPR_ROUTINE,>XECRPR_ROUTINE ; XECRPR $33 - .byt <XCOSCR_ROUTINE,>XCOSCR_ROUTINE ; XCOSCR $34 - .byt <XCSSCR_ROUTINE,>XCSSCR_ROUTINE ; $35 XCSSCR - .byt <XSCRSE_ROUTINE,>XSCRSE_ROUTINE ; $36 - .byt <XSCROH_ROUTINE,>XSCROH_ROUTINE ; $37 - .byt <XSCROB_ROUTINE,>XSCROB_ROUTINE ; $38 XSCROB - .byt <XSCRNE_ROUTINE,>XSCRNE_ROUTINE ; $39 - .byt <XCLOSE_ROUTINE,>XCLOSE_ROUTINE ; $3a + .byt <XECRPR_ROUTINE, >XECRPR_ROUTINE ; XECRPR $33 + .byt <XCOSCR_ROUTINE, >XCOSCR_ROUTINE ; XCOSCR $34 + .byt <XCSSCR_ROUTINE, >XCSSCR_ROUTINE ; $35 XCSSCR + .byt <XSCRSE_ROUTINE, >XSCRSE_ROUTINE ; $36 + .byt <XSCROH_ROUTINE, >XSCROH_ROUTINE ; $37 + .byt <XSCROB_ROUTINE, >XSCROB_ROUTINE ; $38 XSCROB + .byt <XSCRNE_ROUTINE, >XSCRNE_ROUTINE ; $39 + .byt <XCLOSE_ROUTINE, >XCLOSE_ROUTINE ; $3a .byt <XWRITEBYTES_ROUTINE,>XWRITEBYTES_ROUTINE ; nothing $3b .byt <_xreclk,>_xreclk ; $3c .byt <_xclcl,>_xclcl ; $3d @@ -1571,14 +1535,14 @@ vectors_telemon_second_table: .byt <XADNXT_ROUTINE,>XADNXT_ROUTINE .byt <XINTEG_ROUTINE,>XINTEG_ROUTINE .byt $00,$00 - .byt <XHRSCG_ROUTINE,>XHRSCG_ROUTINE - .byt <XHRSCD_ROUTINE,>XHRSCD_ROUTINE - .byt <XHRSCB_ROUTINE,>XHRSCB_ROUTINE - .byt <XHRSCH_ROUTINE,>XHRSCH_ROUTINE - .byt <XHRSSE_ROUTINE,>XHRSSE_ROUTINE - .byt <XDRAWA_ROUTINE,>XDRAWA_ROUTINE - .byt <XDRAWR_ROUTINE,>XDRAWR_ROUTINE - .byt <XCIRCL_ROUTINE,>XCIRCL_ROUTINE + .byt <XHRSCG_ROUTINE, >XHRSCG_ROUTINE + .byt <XHRSCD_ROUTINE, >XHRSCD_ROUTINE + .byt <XHRSCB_ROUTINE, >XHRSCB_ROUTINE + .byt <XHRSCH_ROUTINE, >XHRSCH_ROUTINE + .byt <XHRSSE_ROUTINE, >XHRSSE_ROUTINE + .byt <XDRAWA_ROUTINE, >XDRAWA_ROUTINE + .byt <XDRAWR_ROUTINE, >XDRAWR_ROUTINE + .byt <XCIRCL_ROUTINE, >XCIRCL_ROUTINE .byt <XCURSE_ROUTINE,>XCURSE_ROUTINE .byt <XCURMO_ROUTINE,>XCURMO_ROUTINE .byt <XPAPER_ROUTINE,>XPAPER_ROUTINE @@ -1628,9 +1592,9 @@ display_x_choice: jsr put_cursor_in_61_x inx lda ACC2M - ldy ACC2M+1 + ldy ACC2M + 1 sta ADDRESS_READ_BETWEEN_BANK - sty ADDRESS_READ_BETWEEN_BANK+1 + sty ADDRESS_READ_BETWEEN_BANK + 1 ldy #$00 Lcd0c: dex @@ -1638,17 +1602,17 @@ Lcd0c: Lcd0f: iny bne @skip - inc ADDRESS_READ_BETWEEN_BANK+1 + inc ADDRESS_READ_BETWEEN_BANK + 1 @skip: jsr ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY bne Lcd0f iny bne Lcd0c - inc ADDRESS_READ_BETWEEN_BANK+1 + inc ADDRESS_READ_BETWEEN_BANK + 1 bne Lcd0c Lcd20: - ldx ADDRESS_READ_BETWEEN_BANK+1 + ldx ADDRESS_READ_BETWEEN_BANK + 1 clc tya adc ADDRESS_READ_BETWEEN_BANK @@ -1656,7 +1620,7 @@ Lcd20: inx @skip: sta RESB - stx RESB+1 + stx RESB + 1 lda #$20 sta DEFAFF pla @@ -1669,7 +1633,7 @@ Lcd20: lda #$20 jsr XWR0_ROUTINE lda RESB - ldy RESB+1 + ldy RESB + 1 jsr XWSTR0_ROUTINE ldy #$01 jsr ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY @@ -1698,10 +1662,13 @@ put_cursor_in_61_x: data_for_decimal_conversion: const_10_decimal_low .byt $0A ; 19 + const_100_decimal_low .byt $64 ; 100 + const_1000_decimal_low ; $3e8=1000 .byt $E8 + const_10000_decimal_low ; $3e8=1000 .byt $10 const_10_decimal_high @@ -1774,10 +1741,7 @@ XCHECK_VERIFY_USBDRIVE_READY_ROUTINE: .include "functions/process/kernel_get_struct_process_ptr.asm" - -.include "functions/strings/xminma.asm" - - +;.include "functions/strings/xminma.asm" .include "functions/xdecal.asm" .include "functions/sound/xepsg.asm" @@ -1800,7 +1764,7 @@ XCHECK_VERIFY_USBDRIVE_READY_ROUTINE: .proc _trim ; This routine modify RES -; Each time a space is found, RES is modified (+1 to the pointer) until it reached 0 +; Each time a space is found, RES is modified ( + 1 to the pointer) until it reached 0 ldy #$00 @L1: lda (RES),y @@ -1814,7 +1778,7 @@ XCHECK_VERIFY_USBDRIVE_READY_ROUTINE: @trim: inc RES bne @next - inc RES+1 + inc RES + 1 @next: jmp @L1 .endproc @@ -1909,7 +1873,7 @@ XKBDAS_ROUTINE: bcc @loop @skip: - lda KBDCOL+4 + lda KBDCOL + 4 tax and #$90 beq @skip2 @@ -1939,6 +1903,7 @@ XKBDAS_ROUTINE: lda (ADKBD),y bit FLGKBD bpl @skip5 + ; XMINMA FIXME cmp #$61 bcc @skip5 cmp #$7B @@ -1950,7 +1915,7 @@ XKBDAS_ROUTINE: txa and #$04 beq next68 - and KBDCOL+7 + and KBDCOL + 7 beq @skip6 lda #$80 sta KBDCTC @@ -2076,7 +2041,7 @@ next22: ldy #$08 @L1: - lda SCRTRA+5,y + lda SCRTRA + 5,y bne out1 cpy #$06 @@ -2094,7 +2059,7 @@ out1: manage_I_O_keyboard: bmi skip2005 lda #$01 - sta KEYBOARD_COUNTER+2 + sta KEYBOARD_COUNTER + 2 sta KEYBOARD_COUNTER php sei @@ -2121,6 +2086,7 @@ skip2005: lda #$40 sta VIA::IER rts + @skip3: lda VIA::ACR ora #$40 @@ -2129,7 +2095,7 @@ skip2005: lda #$a8 ldy #$61 sta VIA::T1 - sty VIA::T1+1 + sty VIA::T1 + 1 lda #$c0 sta VIA::IER @@ -2145,20 +2111,20 @@ data_to_define_KBDCOL: init_keyboard: lda #$FF sta VIA::DDRA - sta KEYBOARD_COUNTER+1 + sta KEYBOARD_COUNTER + 1 lda #$F7 sta VIA::DDRB lda #$01 sta KBDVRL - sta KBDVRL+1 - sta KEYBOARD_COUNTER+2 + sta KBDVRL + 1 + sta KEYBOARD_COUNTER + 2 sta KEYBOARD_COUNTER lda #$0E sta KBDVRR lda #<table_chars_qwerty ldy #>table_chars_qwerty sta ADKBD - sty ADKBD+1 ; FIXME + sty ADKBD + 1 ; FIXME lsr KBDFLG_KEY lda #$C0 sta FLGKBD @@ -2174,12 +2140,12 @@ XSONPS_ROUTINE: sec php sei - lda ADDRESS_READ_BETWEEN_BANK+1 + lda ADDRESS_READ_BETWEEN_BANK + 1 pha lda ADDRESS_READ_BETWEEN_BANK pha stx ADDRESS_READ_BETWEEN_BANK - sty ADDRESS_READ_BETWEEN_BANK+1 + sty ADDRESS_READ_BETWEEN_BANK + 1 php ldy #$00 @L1: @@ -2205,7 +2171,7 @@ XSONPS_ROUTINE: pla sta ADDRESS_READ_BETWEEN_BANK pla - sta ADDRESS_READ_BETWEEN_BANK+1 + sta ADDRESS_READ_BETWEEN_BANK + 1 plp rts @@ -2263,7 +2229,7 @@ output_window0: pla ; on lit la donnée < Ldbb5: - sta SCRNB+1 ; store the char to display + sta SCRNB + 1 ; store the char to display pha ; Save A txa ; save X pha ; @@ -2274,9 +2240,9 @@ Ldbb5: lda ADSCRL ; get address of the window sta ADSCR lda ADSCRH - sta ADSCR+1 + sta ADSCR + 1 - lda SCRNB+1 + lda SCRNB + 1 cmp #" " ; is it greater than space ? bcs Ldc4c ; yes let's displays it. Ldbce: ; $d27e @@ -2285,14 +2251,14 @@ Ldbce: ; $d27e pha jsr XCOSCR_ROUTINE ; switch off cursor - lda #>(LDC2B-1) ; FIXME ? + lda #>(LDC2B - 1) ; FIXME ? pha - lda #<(LDC2B-1) ; FIXME ? + lda #<(LDC2B - 1) ; FIXME ? pha - lda SCRNB+1 + lda SCRNB + 1 asl ; MULT2 in order to get vector tay - lda TABLE_OF_SHORTCUT_KEYBOARD+1,y + lda TABLE_OF_SHORTCUT_KEYBOARD + 1,y pha lda TABLE_OF_SHORTCUT_KEYBOARD,y pha @@ -2342,7 +2308,7 @@ LDC2B: sta CURSCR ; and save it lda ADSCR ; get current addr (low) sta ADSCRL ; save it - lda ADSCR+1 + lda ADSCR + 1 sta ADSCRH pla sta FLGSCR @@ -2360,22 +2326,22 @@ Ldc4c: lda FLGSCR and #%00001100 bne Ldc9a - lda SCRNB+1 + lda SCRNB + 1 bpl Ldc5d - cmp #$A0 ; Is it higher than 128+32 + cmp #$A0 ; Is it higher than 128 + 32 bcs Ldc5d ; is it a normal code ? ; yes don't display and #$7F ; yes let's write code Ldc5d: - sta SCRNB+1 + sta SCRNB + 1 jsr display_char lda #$09 - sta SCRNB+1 + sta SCRNB + 1 skip_code: jmp Ldbce LDC69: - sta SCRNB+1 + sta SCRNB + 1 display_char: ldy #$80 @@ -2387,7 +2353,7 @@ display_char: @skip: tya - ora SCRNB+1 + ora SCRNB + 1 sta CURSCR ldy SCRX sta (ADSCR),y @@ -2396,7 +2362,7 @@ display_char: Ldc9a: and #$08 beq @S1 - lda SCRNB+1 + lda SCRNB + 1 bmi LDC46 cmp #$40 bcc LDC46 @@ -2418,7 +2384,7 @@ Ldc9a: lsr ; doit-on envoyer Y ou X ? bcs @S2 ; X ------------------------------------------------ - lda SCRNB+1 ; on lit Y I + lda SCRNB + 1 ; on lit Y I and #$3F ; on vire b4 (protocole US) I sta SCRY ; et on fixe Y I jsr LDE07 ; on ajuste l'adresse dans la fenêtre I @@ -2430,7 +2396,7 @@ Ldc9a: pha ; I jmp LDC2B ; et on sort I @S2: - lda SCRNB+1 ; on lit X <---------------------------------------- + lda SCRNB + 1 ; on lit X <---------------------------------------- and #$3F ; on vire b4 sta SCRX ; dans SCRX pla @@ -2508,12 +2474,15 @@ LDD14: cmp SCRDX ; interdite ? I bcs @S1 ; non I jmp CTRL_M_START ; I oui,on en sort I + @S1: rts ; <--- I + @S2: - dec SCRDX ; on autorise colonne 0 et 1 <---------------------- + dec SCRDX ; on autorise colonne 0 et 1 <---------------------- dec SCRDX rts + LDD43: dec SCRX ; on ramène le curseur un cran à gauche <---------- rts ; I @@ -2524,7 +2493,7 @@ LDD43: CTRL_H_START: lda SCRX ; est-on déja au début de la fenêtre ? I cmp SCRDX ; I - bne LDD43 ; non, on ramène à gauche -------------------------- + bne LDD43 ; non, on ramène à gauche -------------------------- lda SCRFX ; oui, on se place à la fin de la fenètre sta SCRX @@ -2539,10 +2508,12 @@ CTRL_K_START: ldy SCRFY ; fin de la fentre X I tax ; I jsr XSCROB_ROUTINE ; on scrolle l'écran vers le bas ligne X à Y I + CTRL_M_START: lda SCRDX ; on place début de la fenêtre dans X I sta SCRX ; I rts ; I + LDD6E: dec SCRY ; on remontre le curseur <-------------------------- jmp LDE07 ; et on ajuste ADSCR @@ -2561,13 +2532,13 @@ CTRL_X_START: LDD7D: lda SCRFX ; et la dernière colonne de la fenetre - sta SCRNB+1 ; dans $29 + sta SCRNB + 1 ; dans $29 lda #$20 ; on envoie un espace @loop: sta (ADSCR),y iny ; jusqu'à la fin de la ligne - cpy SCRNB+1 + cpy SCRNB + 1 bcc @loop sta (ADSCR),y ; et à la dernière position aussi rts ; (INC $29 avant la boucle aurait été mieux !) @@ -2596,6 +2567,7 @@ CTRL_J_START: tax ; I jsr XSCROH_ROUTINE ; on scrolle la fenetre I jmp CTRL_M_START ; on revient en debut de ligne I + @skip: inc SCRY ; on incremente la ligne <-------------------------I jmp LDE07 ; et on ajuste ADSCR @@ -2653,11 +2625,12 @@ CTRL_HOME_START: sta SCRX ; dans SCRX lda SCRDY ; la première ligne dans sta SCRY ; SCRY + LDE07: lda SCRY ; et on calcule l'adresse jsr LDE12 ; de la ligne sta ADSCR ; dans ADSCR - sty ADSCR+1 ; + sty ADSCR + 1 ; rts ; CALCULE L'ADRESSE DE LA LIGNE A @@ -2754,8 +2727,8 @@ XSCRSE_ROUTINE ; init window ROUTINE_TO_DEFINE_7: clc php - sta ADDRESS_READ_BETWEEN_BANK ; CORRECTME - sty ADDRESS_READ_BETWEEN_BANK+1 ; CORRECTME + sta ADDRESS_READ_BETWEEN_BANK ; CORRECTME + sty ADDRESS_READ_BETWEEN_BANK + 1 ; CORRECTME txa clc adc #$18 @@ -2835,24 +2808,6 @@ next15: and #$1F rts -; Le19f: -; clc -; php -; stx VABKP1 -; ldx #$00 -; jsr XECRBU_ROUTINE -; lda #$08 -; plp -; bcs Le1af -; lda #$20 -; Le1af: -; ldx #$00 -; jsr XECRBU_ROUTINE -; ldx VABKP1 -; rts -; Le1b7: -; sec -; rts XHCHRS_ROUTINE: rts @@ -2875,17 +2830,21 @@ test_if_prompt_is_on_beginning_of_the_line: bne @skip tya cmp SCRDX + @skip: rts + Le2f9: ldy SCRDX lda (RES),y cmp #$7F rts + LE301: ldx SCRNB lda SCRY sta ACC1M + Le2ed: lda ACC1M jsr LDE12 @@ -2898,10 +2857,12 @@ Le2ed: beq @S2 dec ACC1M bcs Le2ed + @S1: clc iny sty ACC1E + @S2: rts @@ -2979,6 +2940,7 @@ Le390: cmp #$20 bcs Le398 ora #$80 + Le398: ldx MENX bit ACC1EX @@ -3019,11 +2981,12 @@ display_bufedt_content: lda #$00 ; FIXME 65c02 sta MENX lda ADSCR - ldy ADSCR+1 + ldy ADSCR + 1 sta RES - sty RES+1 + sty RES + 1 ldx SCRNB ldy SCRX + Le3e3: ldx MENX @@ -3042,6 +3005,7 @@ Le3e3: bit FLGTEL ; Minitel ? bvc Le405 jsr LE656 + Le405: tya iny @@ -3052,6 +3016,7 @@ Le405: ldy #$00 jsr XADRES_ROUTINE ldy SCRDX + Le418: inc MENX bne Le3e3 @@ -3073,7 +3038,6 @@ Le45a: Le479: rts - manage_code_control: cmp #$08 bne Le5d5 @@ -3152,10 +3116,10 @@ Le624: Le62a: lda #$1F ; on envoie un US jsr Le648 - tya ; on envoie Y+64 + tya ; on envoie Y + 64 ora #$40 jsr Le648 - txa ; et X+64 + txa ; et X + 64 ora #$40 jsr Ldbb5 .ifdef WITH_MINITEL @@ -3211,11 +3175,11 @@ data_for_hires_display XHRSSE_ROUTINE: clc ; C=0 - bit HRS5+1 ; on fait tourner HRS5+1 sur lui-même + bit HRS5 + 1 ; on fait tourner HRS5 + 1 sur lui-même bpl @skip ; afin de conserver le pattern sec @skip: - rol HRS5+1 + rol HRS5 + 1 bcc Le7c0 ; si b7 de $56 ? 0, on saute <-------------------- LE79C: ldy HRSX40 ; sinon on prend X/6 I @@ -3251,7 +3215,7 @@ Le7c0: ; PLACE LE CURSEUR EN X,Y ;Action:calcule l'adresse du curseur en calculant la position de la ligne par -; $A000+40*Y, la colonne dans X/6 et la position dans l'octet par X mod 6. +; $A000 + 40*Y, la colonne dans X/6 et la position dans l'octet par X mod 6. ; Suite à une erreur dans la table des vecteur TELEMON, cette routine n'est ; pas appelée (alors qu'elle devrait l'être) par BRK XHRSSE... ; En sortie, HSRX,Y,X40,X6 et ADHRS sont ajust?s en fonction de X et Y. @@ -3267,11 +3231,11 @@ hires_put_coordinate: clc tya adc #$A0 ; et on ajoute $A000, écran HIRES - sta ADHRS+1 ; dans ADHRS + sta ADHRS + 1 ; dans ADHRS stx RES ; on met la colonne dans RES lda #$06 ; A=6 - ldy #$00 ; et Y=0 (dans RES+1) - sty RES+1 ; AY=6 et RES=colonne + ldy #$00 ; et Y=0 (dans RES + 1) + sty RES + 1 ; AY=6 et RES=colonne jsr XDIVIS_ROUTINE ; on divise la colonne par 6 lda RES ; on sauve colonne/6 dans HSRX40 sta HRSX40 ; @@ -3288,7 +3252,7 @@ hires_put_coordinate: ; CALCUL LA TANGENTE (*256) D'UN TRAIT Le921: - stx RES+1 ; dX (ou dY)*256 dans RES+1 + stx RES + 1 ; dX (ou dY)*256 dans RES + 1 ldy #$00 ; dY (ou dX) dans AY FIXME 65C02 sty RES jsr XDIVIS_ROUTINE ; calcul dX*256/dY (ou dY/dX) @@ -3390,7 +3354,7 @@ LE9A7: lda #$00 ; <----------------------------------------------+-- FIXME 65C02 ldx #$A0 ; I sta RES ; RES=$A000 , adresse HIRES I - stx RES+1 ; I + stx RES + 1 ; I ldx #$C8 ; X=200 pour 200 lignes I lda #$00 ; A=0 pour colonne de début = colonne 0 I LE9B3: @@ -3406,7 +3370,7 @@ LE9B8: adc #$28 ;I (donc une ligne) sta RES ;I bcc @S1 ; I - inc RES+1 ; I + inc RES + 1 ; I @S1: pla ; I on sort le code dex ; I on compte X lignes @@ -3418,9 +3382,9 @@ LE9B8: ; XFILL_ROUTINE: lda ADHRS - ldy ADHRS+1 + ldy ADHRS + 1 sta RES - sty RES+1 + sty RES + 1 @loop2: ldx HRS2 ldy HRSX40 @@ -3441,18 +3405,18 @@ Lea92: XSCHAR_ROUTINE: sta HRS3 - sty HRS3+1 + sty HRS3 + 1 stx HRS2 lda #$40 sta HRSFB ldy #$00 @L1: - sty HRS2+1 + sty HRS2 + 1 cpy HRS2 bcs Lea92 lda (HRS3),y jsr LEAB5 - ldy HRS2+1 + ldy HRS2 + 1 iny bne @L1 @@ -3666,7 +3630,7 @@ LEFC2: bmi mantisse_A tay lda ACC1EX - lsr RES+1,x + lsr RES + 1,x jsr LF0FC next802: @@ -3685,13 +3649,13 @@ LEFFA: sbc $04,x ; FIXME sta MENX ; FIXME lda $0003,y ; FIXME - sbc RESB+1,x + sbc RESB + 1,x sta MENDFY lda $0002,y ; FIXME sbc RESB,x sta TELEMON_UNKNWON_LABEL_62 ; FIXME lda $0001,y ; FIXME - sbc RES+1,x + sbc RES + 1,x sta ACC1M LF01D: bcs Lf022 @@ -3733,13 +3697,13 @@ Lf049: adc TELEMON_UNKNWON_LABEL_7F sta ACC1EX lda MENX - adc ACC2M+3 + adc ACC2M + 3 sta MENX lda MENDFY - adc ACC2M+2 + adc ACC2M + 2 sta MENDFY lda TELEMON_UNKNWON_LABEL_62 - adc ACC2M+1 + adc ACC2M + 1 sta TELEMON_UNKNWON_LABEL_62 lda ACC1M @@ -3822,14 +3786,14 @@ justify__to_the_right_with_A_and_X: LF0D1: ldy DECDEB,x sty ACC1EX - ldy RESB+1,x + ldy RESB + 1,x sty $04,x ldy RESB,x - sty RESB+1,x - ldy RES+1,x + sty RESB + 1,x + ldy RES + 1,x sty RESB,x ldy ACC1J - sty RES+1,x + sty RES + 1,x LF0E5: adc #$08 bmi LF0D1 @@ -3839,15 +3803,15 @@ LF0E5: lda ACC1EX bcs LF106 LF0F2: - asl RES+1,x + asl RES + 1,x bcc LF0F8 - inc RES+1,x + inc RES + 1,x LF0F8: - ror RES+1,x - ror RES+1,x + ror RES + 1,x + ror RES + 1,x LF0FC: ror RESB,x - ror RESB+1,x + ror RESB + 1,x ror DECDEB,x ror iny @@ -3930,13 +3894,13 @@ LF1C1: bcc LF1DD clc lda TELEMON_UNKNWON_LABEL_72 - adc ACC2M+3 + adc ACC2M + 3 sta TELEMON_UNKNWON_LABEL_72 lda TELEMON_UNKNWON_LABEL_71 - adc ACC2M+2 + adc ACC2M + 2 sta TELEMON_UNKNWON_LABEL_71 lda TELEMON_UNKNWON_LABEL_70 - adc ACC2M+1 + adc ACC2M + 1 sta TELEMON_UNKNWON_LABEL_70 lda ACC3 adc ACC2M @@ -3959,19 +3923,19 @@ LF1EC: sty FLTR1 ldy #$04 lda (FLTR0),y - sta ADMEN+3 ; $6C + sta ADMEN + 3 ; $6C dey lda (FLTR0),y - sta ADMEN+2 ; $6B + sta ADMEN + 2 ; $6B dey lda (FLTR0),y - sta ADMEN+1 ; $6a + sta ADMEN + 1 ; $6a dey lda (FLTR0),y - sta ADMEN+4 + sta ADMEN + 4 eor ACC1S - sta ADMEN+5; $6E - lda ADMEN+4 ; $6d + sta ADMEN + 5; $6E + lda ADMEN + 4 ; $6d ora #$80 sta ADMEN ; $69 dey @@ -4076,13 +4040,13 @@ LF2A4: ldy ACC2M cpy ACC1M bne LF2BA - ldy ACC2M+1 + ldy ACC2M + 1 cpy TELEMON_UNKNWON_LABEL_62 ; FIXME bne LF2BA - ldy ACC2M+2 + ldy ACC2M + 2 cpy MENDFY bne LF2BA - ldy ACC2M+3 + ldy ACC2M + 3 cpy MENX LF2BA: @@ -4106,9 +4070,9 @@ LF2CA: bcs LF2DB LF2CD: - asl ACC2M+3 - rol ACC2M+2 - rol ACC2M+1 + asl ACC2M + 3 + rol ACC2M + 2 + rol ACC2M + 1 rol ACC2M bcs LF2BA bmi LF2A4 @@ -4116,15 +4080,15 @@ LF2CD: LF2DB: tay - lda ACC2M+3 + lda ACC2M + 3 sbc MENX - sta ACC2M+3 - lda ACC2M+2 + sta ACC2M + 3 + lda ACC2M + 2 sbc MENDFY - sta ACC2M+2 - lda ACC2M+1 + sta ACC2M + 2 + lda ACC2M + 1 sbc TELEMON_UNKNWON_LABEL_62 ; FIXME - sta ACC2M+1 + sta ACC2M + 1 lda ACC2M sbc ACC1M sta ACC2M @@ -4505,13 +4469,13 @@ LF532: clc LF533: lda MENX - adc const_negative_100_000_000+3,y + adc const_negative_100_000_000 + 3,y sta MENX lda MENDFY - adc const_negative_100_000_000+2,y + adc const_negative_100_000_000 + 2,y sta MENDFY lda TELEMON_UNKNWON_LABEL_62 - adc const_negative_100_000_000+1,y + adc const_negative_100_000_000 + 1,y sta TELEMON_UNKNWON_LABEL_62 lda ACC1M adc const_negative_100_000_000,y @@ -4833,12 +4797,12 @@ LF915: ;;;;;;;;;;;;;;; XDECA1_ROUTINE: sta RES - sty RES+1 + sty RES + 1 tsx stx FLSVS lda #$00 sta RESB - sta RESB+1 + sta RESB + 1 sta ACC1EX ldx #$05 @L1: @@ -4858,7 +4822,7 @@ XDECA1_ROUTINE: bne LF953 .byte $2C LF94C: - stx RESB+1 + stx RESB + 1 LF94E: jsr LF9FC LF951: @@ -4939,14 +4903,16 @@ LF9C0: dec FLDT1 bne LF9C0 LF9C7: - lda RESB+1 + lda RESB + 1 bmi LF9E1 bpl LF9E4 + LF9CD: pha bit FLDT2 bpl LF9D4 inc ACC4M + LF9D4: jsr Lf242 pla @@ -4957,6 +4923,7 @@ LF9D4: LF9E1: jsr XNA1_ROUTINE + LF9E4: ldx #$00 jmp XAA1_ROUTINE @@ -4971,8 +4938,10 @@ LF9E9: sta ACCPS ldx ACC1E jmp XA1PA2_ROUTINE + LF9FC: inc RESB + LF9FE: ldy RESB lda (RES),y @@ -5014,7 +4983,7 @@ XGOKBD_ROUTINE: .endif ldy #$00 sty RES - sta RES+1 + sta RES + 1 tya @loop: @@ -5026,15 +4995,15 @@ XGOKBD_ROUTINE: cmp #$40 bne @loop - lda RES+1 + lda RES + 1 sbc #$03 sta TR0 sbc #$04 - sta RES+1 + sta RES + 1 lda #<charset_text ldy #>charset_text sta RESB - sty RESB+1 + sty RESB + 1 ldy #$00 loop70: @@ -5043,7 +5012,7 @@ loop70: tax inc RESB bne @L1 - inc RESB+1 + inc RESB + 1 @L1: jsr routine_to_define_23 @@ -5071,8 +5040,8 @@ routine_to_define_23: sta (RES),y iny bne @skip - inc RES+1 - lda RES+1 + inc RES + 1 + lda RES + 1 cmp TR0 bne @skip pla @@ -5098,7 +5067,7 @@ next81: sta (RES),y iny bne @skip - inc RES+1 + inc RES + 1 @skip: pla @@ -5138,7 +5107,7 @@ Lfef9: sec ror RES sta ADDRESS_READ_BETWEEN_BANK - sty ADDRESS_READ_BETWEEN_BANK+1 + sty ADDRESS_READ_BETWEEN_BANK + 1 Lff00: ldy #$00 @@ -5148,7 +5117,7 @@ Lff00: inc ADDRESS_READ_BETWEEN_BANK bne @loop - inc ADDRESS_READ_BETWEEN_BANK+1 + inc ADDRESS_READ_BETWEEN_BANK + 1 @loop: jsr read_a_code_in_15_and_y sta (RESB),y @@ -5161,10 +5130,12 @@ Lff00: adc ADDRESS_READ_BETWEEN_BANK sta ADDRESS_READ_BETWEEN_BANK bcc Lff00 - inc ADDRESS_READ_BETWEEN_BANK+1 + inc ADDRESS_READ_BETWEEN_BANK + 1 bcs Lff00 + Lff26: rts + read_a_code_in_15_and_y: bit RES bpl @skip @@ -5217,7 +5188,7 @@ copy_ramoverlay_end: .error "XMALLOC can't be copied into RAMOVERLAY" .endif -.if ramoverlay_xfree_end-ramoverlay_xfree> 512+256 +.if ramoverlay_xfree_end-ramoverlay_xfree> 512 + 256 .error "XFREE can't be copied into RAMOVERLAY" .endif @@ -5267,8 +5238,9 @@ signature: .byt $00 free_bytes: ; 26 bytes - .res $FFF0-* - .org $FFF0 + +.segment "ORIXVECT7" + .byt $01 ; Kernel type .res 7 @@ -5276,8 +5248,11 @@ free_bytes: ; 26 bytes .byt <signature .byt >signature +; .segment "CPUVECT" + END_ROM: ; fffa +.segment "CPUVECT7" NMI: .byt <start_rom,>start_rom ; fffc @@ -5287,4 +5262,4 @@ RESET: BRK_IRQ: .byt <IRQVECTOR,>IRQVECTOR ; Displays map -.include "memmap.asm" +;.include "memmap.asm" diff --git a/src/kernel.inc b/src/kernel.inc deleted file mode 100644 index 77376dde..00000000 --- a/src/kernel.inc +++ /dev/null @@ -1,186 +0,0 @@ -BASH_MAX_ARGS = 3 ; Number of possible args in the command line -BASH_MAX_BUFEDT_LENGTH = 110 -userzp := VARLNG -RETURN_BANK_READ_BYTE_FROM_OVERLAY_RAM := $78 -NEXT_STACK_BANK := $0418 -MOUSE_JOYSTICK_MANAGEMENT := $291 ; 12 bytes ? -i_o_counter := $1A ; 1 byte -i_o_save := $1B ; 3 bytes ? -TRANSITION_RS232 := $1E; 3 bytes -FILESYS_BANK := $20C -KEYBOARD_COUNTER := $02A6 ; 4 bytes -VIA_UNKNOWN := $028F ; seems tobe a backup of timer 2 bytes -ORIX_MEMORY_DRIVER_ADDRESS := $400 -SWITCH_TO_BANK_ID := $040C -;NEXT_STACK_BANK:=$418 -FIXME_PAGE0_0 :=$25 -ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY:=$411 ; .dsb 3 - -work_channel :=$19 ; 1 byte -KBD_UNKNOWN :=$271 ;FIXME - -FUFTRV =$0100; working Buffer - -NULL = 0 -BUFROU := $C500 ; Routines for buffers gestion - -SIZE_OF_STACK_BANK = 3 - -BNKOLD:=$40F - -ADDRESS_READ_BETWEEN_BANK:=$15 -ADDRESS_VECTOR_FOR_ADIOB:=$17 -BNK_TO_SWITCH:=$410 - -tmp1:=$34 -ptr1:=$32 - -.bss -.org $200 -KERNEL_ERRNO: - .res 1 -KERNEL_CH376_MOUNT: - .res 1 -KERNEL_XFREE_TMP: - .res 1 -KERNEL_XKERNEL_CREATE_PROCESS_TMP: - .res 1 -KERNEL_TMP_XEXEC: - .res 1 -KERNEL_KERNEL_XEXEC_BNKOLD: - .res 1 -KERNEL_MALLOC_TYPE: - .res 1 -KERNEL_SAVE_XEXEC_CURRENT_SET: - .res 1 -KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM: - .res 1 -;KERNEL -KERNEL_END_PROCESS_VARIABLES: -.if KERNEL_END_PROCESS_VARIABLES > FLGTEL - .error "Error KERNEL_END_PROCESS_VARIABLES overlap FLGTEL" -.endif - -.org SCRX+1 -BUSY_BANK_TABLE_RAM: - .res 3 - -.org SCRDX - ; SCRDX - .res 1 -SCRFX_KERNEL: - .res 1 - -.org $282 -; Was VDTPIL - - -.org $2AE -IOTAB: - .res 4 ; KERNEL_SIZE_IOTAB -KERNEL_ADIOB: - .res 8 -kernel_malloc_free_chunk_size: - .tag kernel_malloc_free_chunk_size_struct -kernel_xmalloc_call: - .res 40 ; XMALLOC_ROUTINE_TO_RAM_OVERLAY -KERNEL_ADIOB_END: -.if KERNEL_ADIOB_END > VNMI - .error "Error malloc table overlap VNMI" -.endif - -.bss -.org $4C7 - -.res 1 ;Was before FIXME_DUNNO, it could remove when READ_BYTE_FROM_OVERLAY_RAM will be aligned correctly with kernel load - -READ_BYTE_FROM_OVERLAY_RAM: -; this contains a routine length : 20 bytew -.res 20 -.org $4FF -FIXME_DUNNO: - .res 1 - -.bss -.org $500 -STACK_BANK: - .res SIZE_OF_STACK_BANK - -kernel_end_of_variables_before_BUFNOM: - -.if kernel_end_of_variables_before_BUFNOM > BUFNOM - .error "Error BUFNOM is written by kernel variables try to move some variables in kernel.inc after BUFNOM or BUFEDT" -.endif - -.out .sprintf("kernel_end_of_variables_before_BUFNOM : %x", kernel_end_of_variables_before_BUFNOM) - -.bss -.org BUFNOM - .res 14 -BUFNOM_END: - -kernel_malloc: - .tag kernel_malloc_struct -;kernel_malloc_pid_list: -; .tag kernel_malloc_pid_struct - -;kernel_malloc_pid: - ; .tag kernel_malloc_pid_struct -kernel_malloc_end: -kernel_process: - .tag kernel_process_struct - -kernel_process_end: -kernel_end_of_variables_before_BUFEDT: -.out .sprintf("kernel_end_of_variables_before_BUFEDT : %x", kernel_end_of_variables_before_BUFEDT) -.if kernel_end_of_variables_before_BUFEDT > BUFEDT - .error "Error BUFEDT is written by kernel variables try to move some variables in kernel.inc after $590" -.endif - -.bss -.org BUFEDT - -.ifdef WITH_DEBUG -;.org BUFNOM -kernel_debug: - .tag kernel_debug_struct - .out .sprintf("Size of kernel_debug_struct $%x ", .sizeof(kernel_debug_struct)) -.else -.res 110 -.endif - -BUFEDT_END: - -KERNEL_DRIVER_MEMORY: - .res 163 -KERNEL_DRIVER_MEMORY_END: - -kernel_end_of_memory_for_kernel: - -.out .sprintf("kernel_end_of_memory_for_kernel (malloc will start at this adress) : %x", kernel_end_of_memory_for_kernel) - -kernel_end_of_variables_after_BUFEDT: -.if kernel_end_of_variables_after_BUFEDT > $7FF - .error "Error start of execution program for binary ($800) is written by kernel variables try to move some variables in kernel.inc before $800" -.endif - -.out .sprintf("int MALLOC_BUSY_SIZE_LOW=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_low) -.out .sprintf("int MALLOC_BUSY_SIZE_HIGH=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_high) -.out .sprintf("int MALLOC_BUSY_BEGIN_HIGH=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high) -.out .sprintf("int MALLOC_BUSY_END_HIGH=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_high) -.out .sprintf("int MALLOC_BUSY_BEGIN_LOW=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low) -.out .sprintf("int MALLOC_BUSY_END_LOW=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_low) -.out .sprintf("int KERNEL_MAX_NUMBER_OF_MALLOC=0x%x;",KERNEL_MAX_NUMBER_OF_MALLOC) - - -.out .sprintf("int MALLOC_FREE_SIZE_HIGH=0x%x;",kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high) -.out .sprintf("int MALLOC_FREE_SIZE_LOW=0x%x;",kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low) - -.out .sprintf("int MALLOC_FREE_BEGIN_HIGH=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high) -.out .sprintf("int MALLOC_FREE_BEGIN_LOW=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_low) - -.out .sprintf("int MALLOC_FREE_END_HIGH=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_high) -.out .sprintf("int MALLOC_FREE_END_LOW=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_low) - -.out .sprintf("int KERNEL_MALLOC_FREE_CHUNK_MAX=0x%x;",KERNEL_MALLOC_FREE_CHUNK_MAX) - diff --git a/src/kernel8/.gitignore b/src/kernel8/.gitignore new file mode 100644 index 00000000..320ea541 --- /dev/null +++ b/src/kernel8/.gitignore @@ -0,0 +1,2 @@ +bpmtmp/ +build diff --git a/src/kernel8/VERSION b/src/kernel8/VERSION new file mode 100644 index 00000000..53bb8b10 --- /dev/null +++ b/src/kernel8/VERSION @@ -0,0 +1 @@ +2024.4 \ No newline at end of file diff --git a/src/kernel8/bpm.tml b/src/kernel8/bpm.tml new file mode 100644 index 00000000..8646b857 --- /dev/null +++ b/src/kernel8/bpm.tml @@ -0,0 +1,26 @@ +[package] +name = "kernel8" +version = "2024.4" +authors = [ "nobody@nobody.fr",] +license = "MIT OR Apache-2.0" +edition = "2018" +cpu = "6502" +readme = "" +repository = "" +documentation = "" +description = "" +homepage = "" +buildfolder = "build" +packagetype = "tgz" +codetype = "rom" +templatecode = "" +pathsrc = "src" +oricutron_replace_autoboot_run = "True" +asm_bin_tpl_version = "alpha" +asm_rom_tpl_version = "alpha" +orixsdk_version = "2023.3.0" +orix_minimal_kernel_version = "2024.1" + +[dependencies] +ch395 = "2024.4" +ksocket = "2025.1" diff --git a/src/kernel8/orixlibs/ch395/etc/bpm/ch395/2024.4/bpm.tml b/src/kernel8/orixlibs/ch395/etc/bpm/ch395/2024.4/bpm.tml new file mode 100644 index 00000000..f4123cfd --- /dev/null +++ b/src/kernel8/orixlibs/ch395/etc/bpm/ch395/2024.4/bpm.tml @@ -0,0 +1,10 @@ +[package] +name = "ch395" +version = "2024.4" +authors = [ "nobody@nobody.fr",] +license = "MIT OR Apache-2.0" +edition = "2018" +cpu = "6502" +codetype = "lib" + +[dependencies] diff --git a/src/kernel8/orixlibs/ch395/etc/bpm/ch395/2024.4/bpm.tpl b/src/kernel8/orixlibs/ch395/etc/bpm/ch395/2024.4/bpm.tpl new file mode 100644 index 00000000..f4123cfd --- /dev/null +++ b/src/kernel8/orixlibs/ch395/etc/bpm/ch395/2024.4/bpm.tpl @@ -0,0 +1,10 @@ +[package] +name = "ch395" +version = "2024.4" +authors = [ "nobody@nobody.fr",] +license = "MIT OR Apache-2.0" +edition = "2018" +cpu = "6502" +codetype = "lib" + +[dependencies] diff --git a/src/kernel8/orixlibs/ch395/usr/include/asm/ch395.inc b/src/kernel8/orixlibs/ch395/usr/include/asm/ch395.inc new file mode 100644 index 00000000..06115414 --- /dev/null +++ b/src/kernel8/orixlibs/ch395/usr/include/asm/ch395.inc @@ -0,0 +1,160 @@ +; supports up to 8 sockets +; 10/100M +; PPPOE,IP,DHCP, ARP,ICMP,IGMP,UDP,TCP +; 24K ram +; 4KEEPROM +; 8 GPIO + +CH395_DETECTED = $AA + +CH395_COMMAND_PORT := $381 +CH395_DATA_PORT := $380 + +CH395_GET_IC_VER = $01 +CH395_SET_BAUDRATE = $02 +CH395_ENTER_SLEEP = $03 +CH395_RESET_ALL = $05 ; 50ms +CH395_CHECK_EXIST = $06 +CH395_SET_PHY = $20 +CH395_GET_GLOB_INT_STATUS_ALL = $19 +CH395_SET_MAC_ADDR = $21 ; 6 ? +CH395_SET_IP_ADDR = $22 ; 4 +CH395_SET_GWIP_ADDR = $23 ; 4 +CH395_SET_MASK_ADDR = $24 ; 4 +CH395_SET_MAC_FILT = $25 +CH395_GET_PHY_STATUS = $26 +CH395_INIT = $27 +CH395_GET_UNREACH_IPPORT = $28 +CH395_GET_GLOB_INT_STATUS = $29 +CH395_SET_RETRAN_COUNT = $2A +CH395_SET_RETRAN_PERIOD = $2B +CH395_GET_CMD_STATUS = $2C +CH395_GET_REMOT_IPP_SN = $2D +CH395_CLEAR_RECV_BUF_SN = $2E +CH395_GET_SOCKET_STATUS_SN = $2F +CH395_GET_INT_STATUS_SN = $30 +CH395_SET_IP_ADDR_SN = $31 +CH395_SET_DES_PORT_SN = $32 +CH395_SET_SOUR_PORT_SN = $33 +CH395_SET_PROTO_TYPE_SN = $34 +CH395_OPEN_SOCKET_SN = $35 +CH395_TCP_LISTEN_SN = $36 +CH395_TCP_CONNECT_SN = $37 +CH395_TCP_DISNCONNECT_SN = $38 +CH395_WRITE_SEND_BUF_SN = $39 +CH395_GET_RECV_LEN_SN = $3B +CH395_READ_RECV_BUF_SN = $3C +CH395_CLOSE_SOCKET_SN = $3D +CH395_SET_IPRAW_PRO_SN = $3E +CH395_PING_ENABLE = $3F +CH395_GET_MAC_ADDR = $40 +CH395_DHCP_ENABLE = $41 +CH395_GET_DHCP_STATUS = $42 +CH395_GET_IP_INF = $43 +CH395_PPPOE_SET_USER_NAME = $44 +CH395_PPPOE_SET_PASSWORD = $45 +CH395_PPPOE_ENABLE = $46 +CH395_GET_PPPOE_STATUS = $47 +CH395_SET_TCP_MSS = $50 +CH395_SET_TTL = $51 +CH395_SET_RECV_BUF = $52 +CH395_SET_SEND_BUF = $53 +CH395_SET_FUN_PARA = $55 +CH395_SET_KEEP_LIVE_IDLE = $56 +CH395_SET_KEEP_LIVE_INTVL = $57 +CH395_SET_KEEP_LIVE_CNT = $58 +CH395_SET_KEEP_LIVE_SN = $59 +CH395_EEPROM_ERASE = $E9 +CH395_EEPROM_WRITE = $EA +CH395_EEPROM_READ = $EB +CH395_READ_GPIO_REG = $EC +CH395_WRITE_GPIO_REG = $ED + +; Status + +CH395_ERR_SUCCESS = $00 ; Success +CH395_ERR_BUSY = $10 ; Occupé, indiquant que la commande est en cours d'exécution +CH395_ERR_MEM = $11 ; Erreur de gestion de la mémoire +CH395_ERR_BUF = $12 ; Erreur de tampon +CH395_ERR_TIMEOUT = $13 ; Timeout +CH395_ERR_RTE = $14 ; Erreur de routage +CH395_ERR_ABRT = $15 ; Abandon de la connexion +CH395_ERR_RST = $16 ; Connexion réinitialisée +CH395_ERR_CLSD = $17 ; Connexion fermée +CH395_ERR_CONN = $18 ; Pas de connexion +CH395_ERR_VAL = $19 ; Mauvaise valeur +CH395_ERR_ARG = $1A ; Erreur de paramètre +CH395_ERR_USE = $1B ; Déjà utilisé +CH395_ERR_IF = $1C ; Erreur MAC +CH395_ERR_ISCONN = $1D ; Connecté +CH395_ERR_OPEN = $20 ; Ouvert + +CH395_DHCP_ENABLE_VAL = $01 +CH395_DHCP_DISABLE_VAL = $00 + +CH395_DHCP_STATUS_ENABLED = $00 +CH395_DHCP_STATUS_DISABLED = $01 + +CH395_NUMBER_MAX_SOCKET = $08 + +CH395_SOCKET0 = 0 +CH395_SOCKET1 = 1 +CH395_SOCKET2 = 2 +CH395_SOCKET3 = 3 +CH395_SOCKET4 = 4 +CH395_SOCKET5 = 5 +CH395_SOCKET6 = 6 +CH395_SOCKET7 = 7 + +CH395_PROTO_TYPE_TCP = $03 +CH395_PROTO_TYPE_UDP = $02 +CH395_PROTO_TYPE_MAC_RAW = $01 +CH395_PROTO_TYPE_IP_RAW = $00 + +CH395_SINT_STAT_TIM_OUT = $40 +CH395_SINT_STAT_DISCONNECT = $10 +CH395_SINT_STAT_CONNECT = $08 +CH395_SINT_STAT_RECV = $04 +CH395_SINT_STAT_SEND_OK = $02 +CH395_SINT_STAT_SENBUF_FREE = $01 + +CH395_PHY_DISCONN = $01 +CH395_PHY_10M_FLL = $02 +CH395_PHY_10M_HALF = $04 +CH395_PHY_100M_FLL = $08 +CH395_PHY_100M_HALF = $10 + +CH395_SOCKET_CLOSED = $00 +CH395_SOCKET_OPEN = $05 + +CH395_TCP_CLOSED = $00 +CH395_TCP_LISTEN = $01 +CH395_TCP_SYN_SENT = $02 +CH395_TCP_SYN_REVD = $03 +CH395_TCP_ESTABLISHED = $04 +CH395_TCP_FIN_WAIT_1 = $05 +CH395_TCP_FIN_WAIT_2 = $06 +CH395_TCP_CLOSE_WAIT = $07 +CH395_TCP_CLOSING = $08 +CH395_TCP_LAST_ACK = $09 +CH395_TCP_TIME_WAIT = $0A + +CH395_GINT_STAT_DHCP = $08 +CH395_GINT_STAT_PHY_CHANGE = $04 +CH395_GINT_STAT_IP_CONFLI = $02 +CH395_GINT_STAT_UNREACH = $01 + +CH395_FUN_PARA_FLAG_TCP_SERVER = $02 +CH395_FUN_PARA_FLAG_LOW_PWR = $04 +CH395_FUN_PARA_FLAG_SOCKET_CLOSE = $08 +CH395_FUN_PARA_FLAG_DISABLE_SEND_OK = $10 + +CH395_GINT_STAT_SOCK0 = 16 +CH395_GINT_STAT_SOCK1 = 32 +CH395_GINT_STAT_SOCK2 = 64 +CH395_GINT_STAT_SOCK3 = 128 + +CH395_GINT_STAT_SOCK4 = 1 +CH395_GINT_STAT_SOCK5 = 2 +CH395_GINT_STAT_SOCK6 = 3 +CH395_GINT_STAT_SOCK7 = 4 \ No newline at end of file diff --git a/src/kernel8/orixlibs/ch395/usr/include/ch395.h b/src/kernel8/orixlibs/ch395/usr/include/ch395.h new file mode 100644 index 00000000..8404344b --- /dev/null +++ b/src/kernel8/orixlibs/ch395/usr/include/ch395.h @@ -0,0 +1,121 @@ +//typedef ch395ipaddress byte[4]; +//typedef ch395macaddress byte[6]; + +unsigned char ch395_get_ic_ver(); +void ch395_reset_all(); +unsigned char ch395_check_exist(); +void ch395_init(); +unsigned char ch395_get_cmd_status(); +void ch395_get_mac_adress(unsigned char macaddress[]); +void ch395_set_mac_adress(unsigned char macaddress[]); +void ch395_get_ip_inf(unsigned char ip_infos[]); + +void ch395_set_ipraw_pro_sn(unsigned char ID_SOCKET); + +void ch395_dhcp_enable(unsigned char mode); +unsigned char ch395_get_dhcp_status(); +void ch395_retran_period(unsigned int period); +void ch395_set_retran_count(unsigned char period); + +void ch395_set_ip_addr(unsigned char fix); + +void ch395_set_ip_addr_sn(unsigned char ip_addr[], unsigned char ID_SOCKET); +void ch395_set_proto_type_sn(unsigned char proto,unsigned char ID_SOCKET); +void ch395_set_des_port_sn(unsigned int port,unsigned char ID_SOCKET); +void ch395_set_sour_port_sn(unsigned int port,unsigned char ID_SOCKET); +void ch395_open_socket_sn(unsigned char ID_SOCKET); +void ch395_tcp_connect_sn(unsigned char ID_SOCKET); +void ch395_tcp_listen_sn(unsigned char ID_SOCKET); +unsigned int ch395_get_recv_len_sn(unsigned char ID_SOCKET); + +void ch395_write_send_buf_sn(unsigned char *buffer, unsigned int length,unsigned char ID_SOCKET); +void ch395_read_recv_buf_sn(unsigned char *buffer, unsigned int length,unsigned char ID_SOCKET); + +void ch395_close_socket_sn(unsigned char ID_SOCKET); +unsigned char ch395_get_int_status_sn(unsigned char ID_SOCKET); +unsigned char ch395_get_socket_status_sn(unsigned char ID_SOCKET); // return 2 bytes +unsigned char ch395_get_phy_status(); +void ch395_get_remot_ipp_sn(unsigned char *ptr, unsigned char socket); + +unsigned char ch395_get_glob_int_status(); +void ch395_clear_recv_buf_sn(unsigned char socket); +void ch395_set_fun_para(unsigned char flag); +void ch395_tcp_disconnect_sn(unsigned char ID_SOCKET); +void ch395_set_ttl(unsigned char ID_SOCKET, unsigned char ttl_value); + +#define CH395_DETECTED 0xaa + +//void ch395_set_gwip_addr(ch395ipaddress gatewayipadress); + +#define CH395_ERR_SUCCESS 0x00 /* Success*/ +#define CH395_ERR_BUSY 0x10 /* Occupé, indiquant que la commande est en cours d'exécution */ +#define CH395_ERR_MEM 0x11 /* Erreur de gestion de la mémoire */ +#define CH395_ERR_BUF 0x12 /* Erreur de tampon */ +#define CH395_ERR_TIMEOUT 0x13 /* Timeout */ +#define CH395_ERR_RTE 0x14 /* Erreur de routage */ +#define CH395_ERR_ABRT 0x15 /* Abandon de la connexion */ +#define CH395_ERR_RST 0x16 /* Connexion réinitialisée */ +#define CH395_ERR_CLSD 0x17 /* Connexion fermée */ +#define CH395_ERR_CONN 0x18 /* Pas de connexion */ +#define CH395_ERR_VAL 0x19 /* Mauvaise valeur */ +#define CH395_ERR_ARG 0x1A /* Erreur de paramètre */ +#define CH395_ERR_USE 0x1B /* Déjà utilisé */ +#define CH395_ERR_IF 0x1C /* Erreur MAC */ +#define CH395_ERR_ISCONN 0x1D /* Connecté*/ +#define CH395_ERR_OPEN 0x20 /* Ouvert */ + +#define CH395_DHCP_ENABLE_VAL 0x01 +#define CH395_DHCP_DISABLE_VAL 0x00 + +#define CH395_DHCP_STATUS_ENABLED 0x00 +#define CH395_DHCP_STATUS_DISABLED 0x01 + +#define CH395_SOCKET0 0 +#define CH395_SOCKET1 1 +#define CH395_SOCKET2 2 +#define CH395_SOCKET3 3 +#define CH395_SOCKET4 4 +#define CH395_SOCKET5 5 +#define CH395_SOCKET6 6 +#define CH395_SOCKET7 7 + +#define CH395_PROTO_TYPE_TCP 0x03 +#define CH395_PROTO_TYPE_UDP 0x02 +#define CH395_PROTO_TYPE_MAC_RAW 0x01 +#define CH395_PROTO_TYPE_IP_RAW 0x00 + +#define CH395_SINT_STAT_TIM_OUT 0x40 +#define CH395_SINT_STAT_DISCONNECT 0x10 + +#define CH395_SINT_STAT_CONNECT 0x08 +#define CH395_SINT_STAT_RECV 0x04 +#define CH395_SINT_STAT_SEND_OK 0x02 +#define CH395_SINT_STAT_SENBUF_FREE 0x01 + +#define CH395_PHY_DISCONN 0x01 +#define CH395_PHY_10M_FLL 0x02 +#define CH395_PHY_10M_HALF 0x04 +#define CH395_PHY_100M_FLL 0x08 +#define CH395_PHY_100M_HALF 0x10 + +#define CH395_SOCKET_CLOSED 0x00 +#define CH395_SOCKET_OPEN 0x05 + +#define CH395_TCP_CLOSED 0x00 // Shutdown +#define CH395_TCP_LISTEN 0x01 +#define CH395_TCP_SYN_SENT 0x02 +#define CH395_TCP_SYN_REVD 0x03 +#define CH395_TCP_ESTABLISHED 0x04 +#define CH395_TCP_FIN_WAIT_1 0x05 +#define CH395_TCP_FIN_WAIT_2 0x06 +#define CH395_TCP_CLOSE_WAIT 0x07 +#define CH395_TCP_CLOSING 0x08 +#define CH395_TCP_LAST_ACK 0x09 +#define CH395_TCP_TIME_WAIT 0x0A + +#define CH395_FUN_PARA_FLAG_TCP_SERVER 0x02 +#define CH395_FUN_PARA_FLAG_LOW_PWR 0x04 +#define CH395_FUN_PARA_FLAG_SOCKET_CLOSE 0x08 +#define CH395_FUN_PARA_FLAG_DISABLE_SEND_OK 0x10 + +#define CH395_GINT_STAT_DHCP 0x08 diff --git a/src/kernel8/orixlibs/ch395/usr/share/ch395/2024.4/README.md b/src/kernel8/orixlibs/ch395/usr/share/ch395/2024.4/README.md new file mode 100644 index 00000000..993f9170 --- /dev/null +++ b/src/kernel8/orixlibs/ch395/usr/share/ch395/2024.4/README.md @@ -0,0 +1,20 @@ +# ch395-lib + +## Documentation + +https://orix-software.github.io/ch395lib/api/ + +## Repository + +## Dependencies + +ca65 syntax + +If you set a mac address maybe will refuse to attribute a mac address + +## Informations complémentaires sur le chip + +* Même quand le cable est déconnecté, il est possible de lire le buffer quand on a déjà récupéré de la data. +* Quand le cable est débranché, l'ip est persistante dans la stack. En revanche, les serveurs DNS fournis par le dhcp smeblent être eux resettés quand le cable est débranché. +* Quand on teste le cable, il est toujours déconnecté après l'initialisation de la stack. Il faut faire une boucle avec des compteurs sur le get_phy_status pour vraiment détecter si oui on non le cable est débranché +* Il ne faut pas fermer une socket quand la connexion TCP est toujours en established. Il faut attendre le disconnect TCP (et bien tcp, et non pas le statut de la socket en SUCCESS) avant d'envoyer l'ordre de stop de la socket diff --git a/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2024.4/bpm.tml b/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2024.4/bpm.tml new file mode 100644 index 00000000..261295ac --- /dev/null +++ b/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2024.4/bpm.tml @@ -0,0 +1,21 @@ +[package] +name = "ksocket" +version = "2024.4" +authors = [ "nobody@nobody.fr",] +license = "MIT OR Apache-2.0" +edition = "2018" +cpu = "6502" +readme = "" +repository = "" +documentation = "" +description = "Socket for Orix kernel" +homepage = "" +buildfolder = "build" +packagetype = "tgz" +codetype = "lib" +oricutron_replace_autoboot_run = "True" +templatecode = "" + +[dependencies] +inet = "2024.4" +ch395 = "2024.4" diff --git a/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2024.4/bpm.tpl b/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2024.4/bpm.tpl new file mode 100644 index 00000000..261295ac --- /dev/null +++ b/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2024.4/bpm.tpl @@ -0,0 +1,21 @@ +[package] +name = "ksocket" +version = "2024.4" +authors = [ "nobody@nobody.fr",] +license = "MIT OR Apache-2.0" +edition = "2018" +cpu = "6502" +readme = "" +repository = "" +documentation = "" +description = "Socket for Orix kernel" +homepage = "" +buildfolder = "build" +packagetype = "tgz" +codetype = "lib" +oricutron_replace_autoboot_run = "True" +templatecode = "" + +[dependencies] +inet = "2024.4" +ch395 = "2024.4" diff --git a/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2025.1/bpm.tml b/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2025.1/bpm.tml new file mode 100644 index 00000000..ea64ec58 --- /dev/null +++ b/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2025.1/bpm.tml @@ -0,0 +1,21 @@ +[package] +name = "ksocket" +version = "2025.1" +authors = [ "nobody@nobody.fr",] +license = "MIT OR Apache-2.0" +edition = "2018" +cpu = "6502" +readme = "" +repository = "" +documentation = "" +description = "Socket for Orix kernel" +homepage = "" +buildfolder = "build" +packagetype = "tgz" +codetype = "lib" +oricutron_replace_autoboot_run = "True" +templatecode = "" + +[dependencies] +inet = "2024.4" +ch395 = "2024.4" diff --git a/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2025.1/bpm.tpl b/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2025.1/bpm.tpl new file mode 100644 index 00000000..ea64ec58 --- /dev/null +++ b/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2025.1/bpm.tpl @@ -0,0 +1,21 @@ +[package] +name = "ksocket" +version = "2025.1" +authors = [ "nobody@nobody.fr",] +license = "MIT OR Apache-2.0" +edition = "2018" +cpu = "6502" +readme = "" +repository = "" +documentation = "" +description = "Socket for Orix kernel" +homepage = "" +buildfolder = "build" +packagetype = "tgz" +codetype = "lib" +oricutron_replace_autoboot_run = "True" +templatecode = "" + +[dependencies] +inet = "2024.4" +ch395 = "2024.4" diff --git a/src/kernel8/orixlibs/ksocket/etc/bpm/socket/2024.4/bpm.tml b/src/kernel8/orixlibs/ksocket/etc/bpm/socket/2024.4/bpm.tml new file mode 100644 index 00000000..5fd221f8 --- /dev/null +++ b/src/kernel8/orixlibs/ksocket/etc/bpm/socket/2024.4/bpm.tml @@ -0,0 +1,21 @@ +[package] +name = "socket" +version = "2024.4" +authors = [ "nobody@nobody.fr",] +license = "MIT OR Apache-2.0" +edition = "2018" +cpu = "6502" +readme = "" +repository = "" +documentation = "" +description = "" +homepage = "" +buildfolder = "build" +packagetype = "tgz" +codetype = "lib" +oricutron_replace_autoboot_run = "True" +templatecode = "" + +[dependencies] +inet = "2024.4" +ch395 = "2024.4" diff --git a/src/kernel8/orixlibs/ksocket/etc/bpm/socket/2024.4/bpm.tpl b/src/kernel8/orixlibs/ksocket/etc/bpm/socket/2024.4/bpm.tpl new file mode 100644 index 00000000..5fd221f8 --- /dev/null +++ b/src/kernel8/orixlibs/ksocket/etc/bpm/socket/2024.4/bpm.tpl @@ -0,0 +1,21 @@ +[package] +name = "socket" +version = "2024.4" +authors = [ "nobody@nobody.fr",] +license = "MIT OR Apache-2.0" +edition = "2018" +cpu = "6502" +readme = "" +repository = "" +documentation = "" +description = "" +homepage = "" +buildfolder = "build" +packagetype = "tgz" +codetype = "lib" +oricutron_replace_autoboot_run = "True" +templatecode = "" + +[dependencies] +inet = "2024.4" +ch395 = "2024.4" diff --git a/src/kernel8/orixlibs/ksocket/usr/include/asm/socket.inc b/src/kernel8/orixlibs/ksocket/usr/include/asm/socket.inc new file mode 100644 index 00000000..f9c6987e --- /dev/null +++ b/src/kernel8/orixlibs/ksocket/usr/include/asm/socket.inc @@ -0,0 +1,43 @@ + +SOCK_STREAM = CH395_PROTO_TYPE_TCP ; stream (connection) socket +SOCK_DGRAM = CH395_PROTO_TYPE_UDP ; datagram (conn.less) socket +SOCK_RAW = CH395_PROTO_TYPE_IP_RAW + +INVALID_SOCKET = 255 +SOCKET_ERROR = 255 + +; https://www.cisco.com/c/en/us/td/docs/ios/sw_upgrades/interlink/r2_0/unpremsg/mucsock.html + +NETWORK_MAX_SOCKET = 4 +AF_UNIX = 1 ; /* Unix domain sockets*/ +AF_INET = 2 ; + +EPROTOTYPE = 41 ; Protocol wrong type +ESOCKTNOSUPPORT = 44 ; Socket type not supported +EPFNOSUPPORT = 46 ; Protocol family not supported +EAFNOSUPPORT = 47 ; Address family not supported +EADDRINUSE = 48 ; Address already in use +ENETDOWN = 50 ; Network is down +ENETUNREACH = 51 ; Network is unreachable +ECONNRESET = 54 ; Connection reset by peer +EISCONN = 56 ; Socket is already connected +ENOTCONN = 57 ; Socket is not connected +ETIMEDOUT = 60 ; Connection timed out +ECONNREFUSED = 61 ; Connection refused +EHOSTUNREACH = 65 ; No route to host + +;ENOPROTOOPT= 42 ; Protocol not available +;EPROTONOSUPPORT =43 ;Protocol not supported +;EOPNOTSUPP 45 Operation not supported +;EADDRNOTAVAIL 49 Can't assign requested address +;ENETRESET 52 Network dropped connection +;ECONNABORTED 53 Software caused connection +;ENOBUFS 55 No buffer space available +;ESHUTDOWN 58 Can't send after shutdown +;ETOOMANYREFS 59 Too many references + +.struct sockaddr_in + sin_family .byte ; e.g. AF_INET + sin_port .word ; e.g. htons(3490) + sin_addr .res 4 ;long sin_addr +.endstruct diff --git a/src/kernel8/orixlibs/ksocket/usr/include/asm/socket.mac b/src/kernel8/orixlibs/ksocket/usr/include/asm/socket.mac new file mode 100644 index 00000000..76311459 --- /dev/null +++ b/src/kernel8/orixlibs/ksocket/usr/include/asm/socket.mac @@ -0,0 +1,65 @@ +; int socket(int domain, int type, int protocol); + +; Exemple +; SOCKET sock = SOCKET AF_INET, SOCK_STREAM, 0 + +.macro SOCKET domain, type, protocol + lda #$00 + ldx #domain + ldy #type + jsr socket +.endmacro + +.macro BIND socket_id, src_port + lda current_socket + ldx #>src_port + ldy #<src_port + jsr bind +.endmacro + +.macro SENDTO socket, buf, len + lda #<len + sta RES + lda #>len + sta RES+1 + + lda #<buf + ldy #>buf + jsr send +.endmacro + +.macro RECVFROM socket, buffer, len + ldx socket + lda #<buffer + ldy #>buffer + jsr recv +.endmacro + +.macro SOCKETCLOSE socket_id + ldx socket_id + jsr socket_close +.endmacro + +.macro ACCEPT socket_id +; Loop until socket is connected +@wait_connection: + lda socket_id ; socket 0 + jsr ch395_get_int_status_sn + + and #CH395_SINT_STAT_CONNECT + cmp #CH395_SINT_STAT_CONNECT ; Success + bne @wait_connection +.endmacro + +.macro socket_connect socket, src_port, dest_port, ip_dest + + ;;@brief Perform connect to socket + ;;@inputY Socket id + ;;@inputY Low ip dest + ;;@inputX High ip dest + ; FIXME + + + jmp connect +.endmacro + diff --git a/src/kernel8/orixlibs/ksocket/usr/include/socket.h b/src/kernel8/orixlibs/ksocket/usr/include/socket.h new file mode 100644 index 00000000..96a2a52b --- /dev/null +++ b/src/kernel8/orixlibs/ksocket/usr/include/socket.h @@ -0,0 +1,38 @@ +#define AF_UNSPEC 0 +#define AF_UNIX 1 /* Unix domain sockets */ +#define AF_INET 2 /* Internet IP Protocol */ + +/* Socket types. */ +#define SOCK_STREAM 3 /* stream (connection) socket */ +#define SOCK_DGRAM 2 /* datagram (conn.less) socket */ +#define SOCK_RAW 1 /* raw socket */ +#define SOCK_RDM 4 /* reliably-delivered message */ +#define SOCK_SEQPACKET 5 /* sequential packet socket */ +#define SOCK_PACKET 10 /* linux specific way of */ + +struct sockaddr_in { + unsigned char sin_family; // e.g. AF_INET + unsigned int sin_port; // e.g. htons(3490) + unsigned long sin_addr; // see struct in_addr, below +}; + +struct sockaddr { + unsigned char sa_family; /* Address family */ + char sa_data[]; /* Socket address */ +}; + +/* Create a new socket of type TYPE in domain DOMAIN, using + protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically. + Returns a file descriptor for the new socket, or -1 for errors. */ +unsigned char socket (unsigned char domain, unsigned char type, unsigned char protocol); +unsigned char bind(int socket, const struct sockaddr_in* addr, unsigned int addrlen); +unsigned char listen(unsigned char socket, unsigned char backlog); +unsigned char accept(int socket, struct sockaddr_in* addr, unsigned int addrlen); + + +unsigned int recv(unsigned char s, void *buf, unsigned int len, unsigned char flags); +unsigned int send(unsigned char sockfd, const void buf[], unsigned int len, unsigned char flags); + +unsigned int socket_close(unsigned char sockfd); + +int connect(unsigned int sockfd, const struct sockaddr *addr, unsigned int addrlen); diff --git a/src/kernel8/orixlibs/ksocket/usr/share/ksocket/2024.4/README.md b/src/kernel8/orixlibs/ksocket/usr/share/ksocket/2024.4/README.md new file mode 100644 index 00000000..62621ec0 --- /dev/null +++ b/src/kernel8/orixlibs/ksocket/usr/share/ksocket/2024.4/README.md @@ -0,0 +1,13 @@ +# kSocket lib for orix kernel only + +## Documentation + +## Repository + +## Dependencies + +## behavior + +Each calls to connect will allocate source port from 170 to 170 + $FF. Each time a connect is performed, source port = source port ++ + +Because when we connect to same host, we are trying to connect to same source port from Orix and the remote computer won't accept a connexion from a source port when connection is still closing. diff --git a/src/kernel8/orixlibs/ksocket/usr/share/ksocket/2025.1/README.md b/src/kernel8/orixlibs/ksocket/usr/share/ksocket/2025.1/README.md new file mode 100644 index 00000000..62621ec0 --- /dev/null +++ b/src/kernel8/orixlibs/ksocket/usr/share/ksocket/2025.1/README.md @@ -0,0 +1,13 @@ +# kSocket lib for orix kernel only + +## Documentation + +## Repository + +## Dependencies + +## behavior + +Each calls to connect will allocate source port from 170 to 170 + $FF. Each time a connect is performed, source port = source port ++ + +Because when we connect to same host, we are trying to connect to same source port from Orix and the remote computer won't accept a connexion from a source port when connection is still closing. diff --git a/src/kernel8/orixlibs/ksocket/usr/share/socket/2024.4/README.md b/src/kernel8/orixlibs/ksocket/usr/share/socket/2024.4/README.md new file mode 100644 index 00000000..8952ba50 --- /dev/null +++ b/src/kernel8/orixlibs/ksocket/usr/share/socket/2024.4/README.md @@ -0,0 +1,14 @@ +# Socket lib + +## Documentation + +## Repository + +## Dependencies + +## behavior + +Each calls to connect will allocate source port from 170 to 170 + $FF. Each time a connect is performed, source port = source port ++ + +Because when we connect to same host, we are trying to connect to same source port from Orix and the remote computer won't accept a connexion from a source port when connection is still closing. + diff --git a/src/kernel8/src/kernel8.s b/src/kernel8/src/kernel8.s new file mode 100644 index 00000000..6b635bc3 --- /dev/null +++ b/src/kernel8/src/kernel8.s @@ -0,0 +1,137 @@ + +;.FEATURE labels_without_colons, pc_assignment, loose_char_term, c_comments, org_per_seg +.FEATURE org_per_seg + +.include "telestrat.inc" +.include "../../rom_cmd.s" + +.include "../../include/kernel.inc" +.include "../../include/process.inc" +.include "../../include/network.inc" +.include "../../include/memory.inc" +.include "../../include/files.inc" +.include "../../include/ori2.inc" +.include "../../versions/versions.inc" + + +.import KERNEL_BANK_MANAGEMENT +.import search_free_bank +.import kernel_free_bank +.import kernel_free_bank_by_pid +.import init_network +.import XSOCKET_ROUTINE + +.import kbind +.import krecv +.import ksend +.import ksocket_close +.import xconnect +.import XSOCKET_CLOSE_ROUTINE +.import close_sockets_by_pid + + ; .segment "BANK8" + .org $C000 +start_rom: + jmp XBANK + +XBANK: + cmp #KERNEL_ALLOCATE_BANK + beq @allocate_bank + + cmp #KERNEL_FREE_BANK + beq @free_bank + + cmp #KERNEL_FREE_BANK_BY_PID + beq @kernel_free_bank_by_pid + + cmp #KERNEL_START_NETWORK + beq @kernel_init_network + + cmp #KERNEL_SOCKET_NETWORK + beq @kernel_socket_network + + cmp #KERNEL_BIND_NETWORK + beq @kernel_bind_network + + cmp #KERNEL_CONNECT_NETWORK + beq @kernel_connect_network + + cmp #KERNEL_RECV_NETWORK + beq @kernel_recv_network + + cmp #KERNEL_SEND_NETWORK + beq @kernel_send_network + + cmp #KERNEL_SOCKET_CLOSE_NETWORK + beq @kernel_socket_close_network + + cmp #KERNEL_SOCKET_CLOSE_FROM_PID_NETWORK + beq @kernel_sockets_close_by_pid_network + + rts + +@allocate_bank: + jmp search_free_bank + +@free_bank: + jmp kernel_free_bank + +@kernel_free_bank_by_pid: + jmp kernel_free_bank_by_pid + +@kernel_init_network: + jmp init_network + +@kernel_socket_network: + jmp XSOCKET_ROUTINE + +@kernel_bind_network: + jmp kbind + +@kernel_connect_network: + jmp xconnect + +@kernel_send_network: + jmp ksend + +@kernel_recv_network: + jmp krecv + +@kernel_socket_close_network: + jmp XSOCKET_CLOSE_ROUTINE + +@kernel_sockets_close_by_pid_network: + jmp close_sockets_by_pid + + + + +signature: + .asciiz "Kernel Extended v2025.X" + +.segment "ORIXVECT" + .byt $01 ; Kernel type + +; This token is used to detect if Kernel Extended rom is here (used in bank 7) +kernel_extended_magic_token: + .byt 'x' + + .res 6 + + .byt <signature + .byt >signature + +; .segment "CPUVECT" + +END_ROM: +; fffa +.segment "CPUVECT" +NMI: + .byt <start_rom,>start_rom +; fffc +RESET: + .byt <start_rom,>start_rom +; fffe +BRK_IRQ: + .byt <IRQVECTOR,>IRQVECTOR +; Displays map \ No newline at end of file diff --git a/src/kernel_bank0.s b/src/kernel_bank0.s new file mode 100644 index 00000000..df85fc00 --- /dev/null +++ b/src/kernel_bank0.s @@ -0,0 +1,80 @@ +.export BUFROU +.export KERNEL_CONF_BEGIN +.export TELEMON_KEYBOARD_BUFFER_END +.export TELEMON_KEYBOARD_BUFFER_BEGIN + +.export KERNEL_BANK_MANAGEMENT + +; Network +.export KERNEL_NETWORK_FLAG + +.export KERNEL_NETWORK_SOCKET_LIST +.export KERNEL_NETWORK_SOCKET_DOMAIN +.export KERNEL_NETWORK_SOURCE_PORT +.export KERNEL_NETWORK_SOCKET_PID + + +.include "telestrat.inc" + +.include "include/kernel.inc" +.include "include/process.inc" + +.include "include/memory.inc" +.include "include/files.inc" +.include "include/ori2.inc" +.include "versions/versions.inc" + +ORIX_NUMBER_OF_BANK = 64 + + +.org $c080 +.bss +BUFBUF_ORIX: + +.org $C500 +BUFROU: + +.org $C5C4 +TELEMON_KEYBOARD_BUFFER_BEGIN: + +.org $C680 +TELEMON_KEYBOARD_BUFFER_END: + +.org $C680 + TELEMON_ACIA_BUFFER_INPUT_BEGIN: + +.org $C800 + TELEMON_ACIA_BUFFER_INPUT_END: + +.org $C800 + TELEMON_ACIA_BUFFER_OUTPUT_BEGIN: + +.org $CA00 + TELEMON_ACIA_BUFFER_OUTPUT_END: + +.org $CA00 + TELEMON_PRINTER_BUFFER_BEGIN: + +.org $D200 + TELEMON_PRINTER_BUFFER_END: + +.org $D201 +KERNEL_CONF_BEGIN: + +.org $D210 +KERNEL_CONF_END: + +.org $D300 +; Store the state of each bank +KERNEL_BANK_MANAGEMENT: + .tag kernel_bank_management_struct +KERNEL_NETWORK_FLAG: + .byt 0 ; Set for flag, it contains the state of the network +KERNEL_NETWORK_SOCKET_LIST: + .res 8 +KERNEL_NETWORK_SOCKET_DOMAIN: + .res 8 +KERNEL_NETWORK_SOURCE_PORT: ; To increment source port socket + .res 2 +KERNEL_NETWORK_SOCKET_PID: + .res 8 diff --git a/src/kernel_main_memory.s b/src/kernel_main_memory.s new file mode 100644 index 00000000..d9592081 --- /dev/null +++ b/src/kernel_main_memory.s @@ -0,0 +1,454 @@ +.include "telestrat.inc" +.include "include/kernel.inc" +.include "include/process.inc" +.include "include/memory.inc" +.include "include/network.inc" +.include "include/files.inc" +.include "include/ori2.inc" +.include "versions/versions.inc" + + +.export KERNEL_ERRNO +.export KERNEL_CH376_MOUNT +.export KERNEL_XFREE_TMP +.export KERNEL_XKERNEL_CREATE_PROCESS_TMP +.export KERNEL_TMP_XEXEC +.export KERNEL_KERNEL_XEXEC_BNKOLD +.export KERNEL_MALLOC_TYPE +.export KERNEL_SAVE_XEXEC_CURRENT_SET +.export KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM +.export KERNEL_END_PROCESS_VARIABLES +.export SCRFX_KERNEL +.export IOTAB +.export KERNEL_ADIOB +.export kernel_malloc_free_chunk_size +.export kernel_xmalloc_call +.export KERNEL_ADIOB_END +.export READ_BYTE_FROM_OVERLAY_RAM +.export FIXME_DUNNO +.export STACK_BANK +;.export BUFNOM +.export kernel_malloc +.export KERNEL_DRIVER_MEMORY +.export kernel_process +.export BUSY_BANK_TABLE_RAM +.export kernel_end_of_memory_for_kernel +.export KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM +.export RESC +.export RESD +.export RESE +.export RESF +.export RESG +.export RESH +.export RESI +.export RESCONCAT + + +.export KERNEL_BANK_EXTENDED_AVAILABLE + +.import code_adress_419 +.import code_adress_436 + +.bss +.org $04 +RESC: ; is also DECDEB + .res 2 +RESD: ; is also DECFIN + .res 2 +RESE: ; is also DECCIB + .res 2 +RESF: ; is also DECTRV + .res 2 +.org $59 ; RS232T := $59 & RS232C := $5A +RESG: + .res 2 +.org $60 ; ACC1E +RESH: + .res 2 ; ACC1M+1 $62 +RESI: + .res 2 ; $ACC1M+3 $64 +RESCONCAT: + .res 2 ; ACC1S+1 $66 + + +.bss + .org $200 +KERNEL_ERRNO: + .res 1 +KERNEL_CH376_MOUNT: + .res 1 +KERNEL_XFREE_TMP: + .res 1 +KERNEL_XKERNEL_CREATE_PROCESS_TMP: + .res 1 +KERNEL_TMP_XEXEC: + .res 1 +KERNEL_KERNEL_XEXEC_BNKOLD: + .res 1 +KERNEL_MALLOC_TYPE: + .res 1 +KERNEL_SAVE_XEXEC_CURRENT_SET: + .res 1 +KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM: + .res 1 +; KERNEL_BANK_AVAILABLE is used to know if a bank is available or not (example : Kernel extended) +KERNEL_BANK_EXTENDED_AVAILABLE: + .res 1 + +KERNEL_FREE1_MEMORY: +KERNEL_END_PROCESS_VARIABLES: +.if KERNEL_END_PROCESS_VARIABLES > FLGTEL + .error "Error KERNEL_END_PROCESS_VARIABLES overlap FLGTEL" +.endif + +.org SCRX + 1 +BUSY_BANK_TABLE_RAM: + .res 3 + +.org SCRDX + ; SCRDX + .res 1 +SCRFX_KERNEL: + .res 1 + +.org $282 +; Was VDTPIL + + +.org $2AE +IOTAB: + .res 4 ; KERNEL_SIZE_IOTAB +KERNEL_ADIOB: + .res 8 +kernel_malloc_free_chunk_size: + .tag kernel_malloc_free_chunk_size_struct +kernel_xmalloc_call: + .res 40 ; XMALLOC_ROUTINE_TO_RAM_OVERLAY +KERNEL_ADIOB_END: +.if KERNEL_ADIOB_END > VNMI + .error "Error malloc table overlap VNMI" +.endif + +.bss +.org $4C7 + +.res 1 ;Was before FIXME_DUNNO, it could remove when READ_BYTE_FROM_OVERLAY_RAM will be aligned correctly with kernel load + +READ_BYTE_FROM_OVERLAY_RAM: +; this contains a routine length : 20 bytew +.res 20 +.org $4FF +FIXME_DUNNO: + .res 1 + +.bss +.org $500 +STACK_BANK: + .res SIZE_OF_STACK_BANK + +kernel_end_of_variables_before_BUFNOM: + +.if kernel_end_of_variables_before_BUFNOM > BUFNOM + .error "Error BUFNOM is written by kernel variables try to move some variables in kernel.inc after BUFNOM or BUFEDT" +.endif + +.out .sprintf("kernel_end_of_variables_before_BUFNOM : %x", kernel_end_of_variables_before_BUFNOM) + +.bss +.org BUFNOM + .res 14 +BUFNOM_END: + +kernel_malloc: + .tag kernel_malloc_struct + +kernel_malloc_end: +kernel_process: + .tag kernel_process_struct + +kernel_process_end: +kernel_end_of_variables_before_BUFEDT: +.out .sprintf("kernel_end_of_variables_before_BUFEDT : %x", kernel_end_of_variables_before_BUFEDT) +.if kernel_end_of_variables_before_BUFEDT > BUFEDT + .error "Error BUFEDT is written by kernel variables try to move some variables in kernel.inc after $590" +.endif + +.bss +.org BUFEDT + +.ifdef WITH_DEBUG +kernel_debug: + .tag kernel_debug_struct + .out .sprintf("Size of kernel_debug_struct $%x ", .sizeof(kernel_debug_struct)) +.else +.res 110 +.endif + +BUFEDT_END: + +KERNEL_DRIVER_MEMORY: + .res 163 + +KERNEL_DRIVER_MEMORY_END: + +kernel_end_of_memory_for_kernel: + +.out .sprintf("kernel_end_of_memory_for_kernel (malloc will start at this adress) : %x", kernel_end_of_memory_for_kernel) + +kernel_end_of_variables_after_BUFEDT: +.if kernel_end_of_variables_after_BUFEDT > $7FF + .error "Error start of execution program for binary ($800) is written by kernel variables try to move some variables in kernel.inc before $800" +.endif + + +.ifdef MEMMAP_GENERATE + + + + +.out "==================================================================" +.out "File memory" +.out "==================================================================" +.out .sprintf("_KERNEL_FILE size (One fp struct) : $%X bytes", .sizeof(_KERNEL_FILE)) + +.out .sprintf("kernel_one_process_struct size (struct for one process) : $%X bytes", .sizeof(kernel_one_process_struct)) +.out .sprintf("With all the parameter all process could use %s bytes in memory, if it's allocated", .string(.sizeof(kernel_one_process_struct)*KERNEL_MAX_PROCESS+.sizeof(kernel_process_struct))) + +.out .sprintf("KERNEL_MAX_PROCESS (Max process in the system) : %s", .string(KERNEL_MAX_PROCESS)) +.out .sprintf("KERNEL_MAX_FP_PER_PROCESS (Max file pointer per process): %s", .string(KERNEL_MAX_FP_PER_PROCESS)) +.out .sprintf("KERNEL_USERZP_SAVE_LENGTH : %s bytes", .string(KERNEL_USERZP_SAVE_LENGTH)) +.out .sprintf("KERNEL_LENGTH_MAX_CMDLINE : %s", .string(KERNEL_LENGTH_MAX_CMDLINE)) + +.out .sprintf("kernel_process_struct size (struct init process) : $%X bytes", .sizeof(kernel_process_struct)) + + + +.out .sprintf("int MALLOC_BUSY_SIZE_LOW = 0x%x;", kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low) +.out .sprintf("int MALLOC_BUSY_SIZE_HIGH = 0x%x;", kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high) +.out .sprintf("int MALLOC_BUSY_BEGIN_HIGH = 0x%x;", kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high) +.out .sprintf("int MALLOC_BUSY_END_HIGH = 0x%x;", kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_high) +.out .sprintf("int MALLOC_BUSY_BEGIN_LOW = 0x%x;", kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low) +.out .sprintf("int MALLOC_BUSY_END_LOW = 0x%x;", kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_low) +.out .sprintf("int KERNEL_MAX_NUMBER_OF_MALLOC = 0x%x;", KERNEL_MAX_NUMBER_OF_MALLOC) + + + +.out .sprintf("int MALLOC_FREE_SIZE_HIGH =0x%x;",kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high) +.out .sprintf("int MALLOC_FREE_SIZE_LOW =0x%x;",kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low) + +.out .sprintf("int MALLOC_FREE_BEGIN_HIGH=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high) +.out .sprintf("int MALLOC_FREE_BEGIN_LOW=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_low) + +.out .sprintf("int MALLOC_FREE_END_HIGH=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_high) +.out .sprintf("int MALLOC_FREE_END_LOW=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_low) + +.out .sprintf("int KERNEL_MALLOC_FREE_CHUNK_MAX=0x%x;",KERNEL_MALLOC_FREE_CHUNK_MAX) + + + +.out .sprintf("|#MEMMAP: Memmap") +; \n +.out .sprintf("MEMMAP:") +.out .sprintf("|##MEMMAP: Page 0") +; \nr +.out .sprintf("MEMMAP:") +.out "|MEMMAP:Type | Name | Range | Size |" +.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" +.out .sprintf("|MEMMAP:RAM|RES | $%02X-$%02X | 2 |", RES, RES+1) +.out .sprintf("|MEMMAP:RAM|RESB | $%02X-$%02X | 2 |", RESB, RESB + 1) +.out .sprintf("|MEMMAP:RAM|RESC | $%02X-$%02X | 2 |", RESC, RESC + 1) +.out .sprintf("|MEMMAP:RAM|RESD | $%02X-$%02X | 2 |", RESD, RESD + 1) +.out .sprintf("|MEMMAP:RAM|RESE | $%02X-$%02X | 2 |", RESE, RESE + 1) +.out .sprintf("|MEMMAP:RAM|RESF | $%02X-$%02X | 2 |", RESF, RESF + 1) +.out .sprintf("|MEMMAP:RAM|RESG | $%02X-$%02X | 2 |", RESG, RESG + 1) +.out .sprintf("|MEMMAP:RAM|RESH | $%02X-$%02X | 2 |", RESH, RESH + 1) +.out .sprintf("|MEMMAP:RAM|RESI | $%02X-$%02X | 2 |", RESI, RESI + 1) +.out .sprintf("|MEMMAP:RAM|RESCONCAT | $%02X-$%02X | 2 |", RESCONCAT, RESCONCAT + 1) +.out .sprintf("|MEMMAP:RAM|TR0 | $%02X-$%02X | 1 |", TR0, TR0) +.out .sprintf("|MEMMAP:RAM|TR1 | $%02X-$%02X | 1 |", TR1 ,TR1) +.out .sprintf("|MEMMAP:RAM|TR2 | $%02X-$%02X | 1 |", TR2, TR2) +.out .sprintf("|MEMMAP:RAM|TR3 | $%02X-$%02X | 1 |", TR3, TR3) +.out .sprintf("|MEMMAP:RAM|TR4 | $%02X-$%02X | 1 |", TR4, TR4) +.out .sprintf("|MEMMAP:RAM|TR5 | $%02X-$%02X | 1 |", TR5, TR5) +.out .sprintf("|MEMMAP:RAM|TR6 | $%02X-$%02X | 1 |", TR6, TR6) +.out .sprintf("|MEMMAP:RAM|TR7 | $%02X-$%02X | 1 |", TR7, TR7) +.out .sprintf("|MEMMAP:RAM|DEFAFF | $%02X-$%02X | 1 |", DEFAFF, DEFAFF) +.out .sprintf("|MEMMAP:RAM|FREE | $15-$16 | 2 |") +.out .sprintf("|MEMMAP:RAM|ADDRESS_VECTOR_FOR_ADIOB | $%02X-$%02X | 2 |", ADDRESS_VECTOR_FOR_ADIOB, ADDRESS_VECTOR_FOR_ADIOB + 1) +.out .sprintf("|MEMMAP:RAM|work_channel | $%02X-$%02X | 1 |", work_channel, work_channel) +.out .sprintf("|MEMMAP:RAM|i_o_counter | $%02X-$%02X | 2 |", i_o_counter, i_o_counter + 1) +.out .sprintf("|MEMMAP:RAM|FREE | $1C-$1C | 1 |") +.out .sprintf("|MEMMAP:RAM|GS | $1D-$1D | 1 |") +.out .sprintf("|MEMMAP:RAM|FREE | $1E-$1E | 1 |") +.out .sprintf("|MEMMAP:RAM|TOFIX | $1F-$1F | 1 |") +.out .sprintf("|MEMMAP:RAM|TOFIX | $20-$20 | 1 |") +.out .sprintf("|MEMMAP:RAM|IRQSVA | $%02X-$%02X | 1 |", IRQSVA, IRQSVA) +.out .sprintf("|MEMMAP:RAM|IRQSVX | $%02X-$%02X | 1 |", IRQSVX, IRQSVX) +.out .sprintf("|MEMMAP:RAM|IRQSVY | $%02X-$%02X | 1 |", IRQSVY, IRQSVY) +.out .sprintf("|MEMMAP:RAM|IRQSVP | $%02X-$%02X | 1 |", IRQSVP, IRQSVP) +.out .sprintf("|MEMMAP:RAM|FIXME_PAGE0_0 | $%02X-$%02X | 1 |", FIXME_PAGE0_0, FIXME_PAGE0_0) +.out .sprintf("|MEMMAP:RAM|ADSCR | $%02X-$%02X | 2 |", ADSCR,ADSCR + 1) +.out .sprintf("|MEMMAP:RAM|SCRNB | $%02X-$%02X | 2 |", SCRNB,SCRNB + 1) +.out .sprintf("|MEMMAP:RAM|ADKBD | $%02X-$%02X | 2 |", ADKBD,ADKBD + 1) +.out .sprintf("|MEMMAP:RAM|PTR_READ_DEST | $%02X-$%02X | 2 |", PTR_READ_DEST, PTR_READ_DEST + 1) +.out .sprintf("|MEMMAP:RAM|FREE | $%02X-$%02X | |", PTR_READ_DEST + 2, ADDRESS_READ_BETWEEN_BANK - 1) +.out .sprintf("|MEMMAP:RAM|ADDRESS_READ_BETWEEN_BANK | $%02X-$%02X | 2 |", ADDRESS_READ_BETWEEN_BANK, ADDRESS_READ_BETWEEN_BANK + 1) +.out .sprintf("|MEMMAP:RAM|BNKCIB_DOUBLON | $%02X-$%02X | 1 |", BNKCIB_DOUBLON, BNKCIB_DOUBLON) +.out .sprintf("|MEMMAP:RAM|FREE | $%02X-$%02X | |", BNKCIB_DOUBLON + 1, ADCLK -1) +.out .sprintf("|MEMMAP:RAM|ADCLK | $%02X-$%02X | 2 |", ADCLK, ADCLK + 1) +.out .sprintf("|MEMMAP:RAM|TIMEUS | $%02X-$%02X | 2 |", TIMEUS, TIMEUS + 1) +.out .sprintf("|MEMMAP:RAM|TIMEUD (used in cc65 clock function)| $%02X-$%02X | 2 |", TIMEUD, TIMEUD + 1) +.out .sprintf("|MEMMAP:RAM|HRSX | $%02X-$%02X | 1 |", HRSX, HRSX) +.out .sprintf("|MEMMAP:RAM|HRSY | $%02X-$%02X | 1 |", HRSY, HRSY) +.out .sprintf("|MEMMAP:RAM|FREE | $48-$48 | 1 |") +.out .sprintf("|MEMMAP:RAM|HRSX40 | $%02X-$%02X | 1 |", HRSX40, HRSX40) +.out .sprintf("|MEMMAP:RAM|HRSX6 | $%02X-$%02X | 1 |", HRSX6, HRSX6) +.out .sprintf("|MEMMAP:RAM|ADHRS | $%02X-$%02X | 2 |", ADHRS, ADHRS + 1) +.out .sprintf("|MEMMAP:RAM|HRS1 | $%02X-$%02X | 2 |", HRS1, HRS1 + 1) +.out .sprintf("|MEMMAP:RAM|HRS2 | $%02X-$%02X | 2 |", HRS2, HRS2 + 1) +.out .sprintf("|MEMMAP:RAM|HRS3 | $%02X-$%02X | 2 |", HRS3, HRS3 + 1) +.out .sprintf("|MEMMAP:RAM|HRS4 | $%02X-$%02X | 2 |", HRS4, HRS4 + 1) +.out .sprintf("|MEMMAP:RAM|HRS5 | $%02X-$%02X | 2 |", HRS5, HRS5 + 1) +.out .sprintf("|MEMMAP:RAM|HRSFB | $%02X-$%02X | 1 |", HRSFB, HRSFB) +.out .sprintf("|MEMMAP:RAM|VABPK1 | $%02X-$%02X | 1 |", VABKP1, VABKP1) +.out .sprintf("|MEMMAP:RAM|FREE | $59-$5A | 2 |") +.out .sprintf("|MEMMAP:RAM|INDRS | $%02X-$%02X | 1 |", INDRS, INDRS) +.out .sprintf("|MEMMAP:RAM|FREE | $5C-$5F | 2 |") + + +.out .sprintf("|MEMMAP:RAM|FREE | $%02X-$FF | %d |",VARLNG, $FF - VARLNG) + + + +.out .sprintf("|##MEMMAP: Page 2") +.out "|MEMMAP:Type | Name | Range | Size |" +.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" +.out .sprintf("|MEMMAP:RAM|KERNEL_ERRNO | $%04X-$%04X | 1 |", KERNEL_ERRNO, KERNEL_ERRNO) +.out .sprintf("|MEMMAP:RAM|KERNEL_CH376_MOUNT | $%04X-$%04X | 1 |", KERNEL_CH376_MOUNT, KERNEL_CH376_MOUNT) +.out .sprintf("|MEMMAP:RAM|KERNEL_XFREE_TMP | $%04X-$%04X | 1 |", KERNEL_XFREE_TMP, KERNEL_XFREE_TMP) + +.out .sprintf("|MEMMAP:RAM|KERNEL_XKERNEL_CREATE_PROCESS_TMP| $%04X-$%04X | 1 |", KERNEL_XKERNEL_CREATE_PROCESS_TMP, KERNEL_XKERNEL_CREATE_PROCESS_TMP) + +.out .sprintf("|MEMMAP:RAM|KERNEL_TMP_XEXEC | $%04X-$%04X | 1 |", KERNEL_TMP_XEXEC, KERNEL_TMP_XEXEC) +.out .sprintf("|MEMMAP:RAM|KERNEL_KERNEL_XEXEC_BNKOLD | $%04X-$%04X | 1 |", KERNEL_KERNEL_XEXEC_BNKOLD, KERNEL_KERNEL_XEXEC_BNKOLD) + +.out .sprintf("|MEMMAP:RAM|KERNEL_MALLOC_TYPE | $%04X-$%04X | 1 |", KERNEL_MALLOC_TYPE, KERNEL_MALLOC_TYPE) +.out .sprintf("|MEMMAP:RAM|KERNEL_SAVE_XEXEC_CURRENT_SET| $%04X-$%04X | 1 |", KERNEL_SAVE_XEXEC_CURRENT_SET, KERNEL_SAVE_XEXEC_CURRENT_SET) +.out .sprintf("|MEMMAP:RAM|KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM| $%04X-$%04X | 1 |", KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM, KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM+1) + +.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", KERNEL_FREE1_MEMORY, FLGTEL - 1, FLGTEL - KERNEL_FREE1_MEMORY) + +; KOROM and KORAM are not used + +.out .sprintf("|MEMMAP:RAM|FLGTEL | $%04X-$%04X | 1 |", FLGTEL, FLGTEL ) +.out .sprintf("|MEMMAP:RAM|TIMED | $%04X-$%04X | 1 |", TIMED, TIMED ) +.out .sprintf("|MEMMAP:RAM|TIMES | $%04X-$%04X | 1 |", TIMES, TIMES) +.out .sprintf("|MEMMAP:RAM|TIMEM | $%04X-$%04X | 1 |", TIMEM , TIMEM) +.out .sprintf("|MEMMAP:RAM|TIMEH | $%04X-$%04X | 1 |", TIMEH, TIMEH) + +.out .sprintf("|MEMMAP:RAM|FLGCLK | $%04X-$%04X | 1 |", FLGCLK, FLGCLK) +.out .sprintf("|MEMMAP:RAM|FLGCLK_FLAG | $%04X-$%04X | 1 |", FLGCLK_FLAG, FLGCLK_FLAG) + +.out .sprintf("|MEMMAP:RAM|FLGCUR | $%04X-$%04X | 1 |", FLGCUR, FLGCUR) +.out .sprintf("|MEMMAP:RAM|FLGCUR_STATE | $%04X-$%04X | 1 |", FLGCUR_STATE, FLGCUR_STATE) + +.out .sprintf("|MEMMAP:RAM|ADSCRL | $%04X-$%04X | 4 |", ADSCRL,ADSCRL+3) +.out .sprintf("|MEMMAP:RAM|ADSCRH | $%04X-$%04X | 4 |", ADSCRH,ADSCRH+3) + +.out .sprintf("|MEMMAP:RAM|SCRX | $%04X-$%04X | 1 |", SCRX, SCRX) + +.out .sprintf("|MEMMAP:RAM|BUSY_BANK_TABLE_RAM | $%04X-$%04X | %d |", BUSY_BANK_TABLE_RAM, BUSY_BANK_TABLE_RAM+3, 3) + +.out .sprintf("|MEMMAP:RAM|SCRY | $%04X-$%04X | 4 |", SCRY, SCRY+3) + +.out .sprintf("|MEMMAP:RAM|SCRDX | $%04X-$%04X | 1 |", SCRDX, SCRDX) +.out .sprintf("|MEMMAP:RAM|SCRFX | $%04X-$%04X | 1 |", SCRFX, SCRFX) + +.out .sprintf("|MEMMAP:RAM|SCRFY | $%04X-$%04X | 1 |", SCRFY, SCRFY) +.out .sprintf("|MEMMAP:RAM|SCRDY | $%04X-$%04X | 1 |", SCRDY, SCRDY) + +.out .sprintf("|MEMMAP:RAM|SCRBAL | $%04X-$%04X | 1 |", SCRBAL, SCRBAL) + +.out .sprintf("|MEMMAP:RAM|SCRBAH | $%04X-$%04X | 1 |", SCRBAH, SCRBAH) + + +.out .sprintf("|MEMMAP:RAM|SCRCT | $%04X-$%04X | 1 |", SCRCT, SCRCT) +.out .sprintf("|MEMMAP:RAM|SCRCF | $%04X-$%04X | 1 |", SCRCF, SCRCF) + + +.out .sprintf("|MEMMAP:RAM|FIXME | $%04X-$%04X | %d |", SCRCF+4,ADSCRH+4,KBDCOL-ADSCRH+4) + +.out .sprintf("|MEMMAP:RAM|FLGSCR | $%04X-$%04X | 4 |", FLGSCR,FLGSCR+4) ; $248 +.out .sprintf("|MEMMAP:RAM|CURSCR | $%04X-$%04X | 1 |", CURSCR,CURSCR+1) ; $248 + +.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", CURSCR+1,SCRTXT,SCRTXT-CURSCR+1) ; $248 + +.out .sprintf("|MEMMAP:RAM|SCRTXT | $%04X-$%04X | 4 |", SCRTXT,SCRHIR+4) ; $248 +.out .sprintf("|MEMMAP:RAM|SCRHIR (not used) | $%04X-$%04X | %d |", SCRHIR,SCRHIR+4,4) ; $248 + +.out .sprintf("|MEMMAP:RAM|SCRTRA | $%04X-$%04X | %d |", SCRTRA,SCRTRA+4,6) ; $248 + +.out .sprintf("|MEMMAP:RAM|KBDCOL | $%04X-$%04X | %d |", KBDCOL,KBDCOL+8,8) +.out .sprintf("|MEMMAP:RAM|KBDFLG_KEY | $%04X-$%04X | %d |", KBDFLG_KEY, KBDFLG_KEY+2,2) + +.out .sprintf("|MEMMAP:RAM|KBDVRR | $%04X-$%04X | %d |", KBDVRR, KBDVRR + 1,1) +.out .sprintf("|MEMMAP:RAM|KBDVRL | $%04X-$%04X | %d |", KBDVRL, KBDVRL + 2,2) +.out .sprintf("|MEMMAP:RAM|FLGKBD | $%04X-$%04X | %d |", FLGKBD, FLGKBD + 1,1) + +.out .sprintf("|MEMMAP:RAM|KBDFCT | $%04X-$%04X | %d |", KBDFCT, KBDFCT + 1,1) + +.out .sprintf("|MEMMAP:RAM|KBDSHT | $%04X-$%04X | %d |", KBDSHT, KBDSHT + 1,1) + +.out .sprintf("|MEMMAP:RAM|KBDKEY | $%04X-$%04X | %d |", KBDKEY, KBDKEY + 5,1) + +.out .sprintf("|MEMMAP:RAM|KBDCTC | $%04X-$%04X | 2 |", KBDCTC, KBDCTC+1) + +.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", KBDCTC + 1, KEYBOARD_COUNTER - 1,KEYBOARD_COUNTER - KBDCTC) + +.out .sprintf("|MEMMAP:RAM|KEYBOARD_COUNTER | $%04X-$%04X | %d |", KEYBOARD_COUNTER, KEYBOARD_COUNTER+3,3) +.out .sprintf("|MEMMAP:RAM|HRSPAT | $%04X-$%04X | %d |", HRSPAT, HRSPAT,1) + +.out .sprintf("|MEMMAP:RAM|IOTAB | $%04X-$%04X | X |", IOTAB, IOTAB + KERNEL_SIZE_IOTAB - 1) +.out .sprintf("|MEMMAP:RAM|KERNEL_ADIOB | $%04X-$%04X | %d |", KERNEL_ADIOB, KERNEL_ADIOB+ADIODB_LENGTH-1,KERNEL_ADIOB+ADIODB_LENGTH-KERNEL_ADIOB) + +.out .sprintf("|MEMMAP:RAM|kernel_malloc_free_chunk_size | $%04X-$%04X | %d |", kernel_malloc_free_chunk_size, kernel_malloc_free_chunk_size + .sizeof(kernel_malloc_free_chunk_size_struct)-1,.sizeof(kernel_malloc_free_chunk_size_struct)) + +.out .sprintf("|MEMMAP:RAM|kernel_xmalloc_call | $%04X-$%04X | %d |", kernel_xmalloc_call, kernel_xmalloc_call + XMALLOC_ROUTINE_TO_RAM_OVERLAY,kernel_xmalloc_call+XMALLOC_ROUTINE_TO_RAM_OVERLAY-kernel_xmalloc_call) + +.out .sprintf("|MEMMAP:RAM|FLGRST | $%04X-$%04X | %d |", FLGRST, FLGRST,1) +.out .sprintf("|MEMMAP:RAM|CSRND | $%04X-$%04X | %d |", CSRND, CSRND,1) + + +.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", KERNEL_ADIOB_END, FLGRST-1, FLGRST-KERNEL_ADIOB_END) + +.out .sprintf("|MEMMAP:RAM|VNMI | $%04X-$%04X | 3 |", VNMI, VNMI+3) + +.out .sprintf("|MEMMAP:RAM|ADIODB_VECTOR | $%04X-$%04X | %d |", ADIODB_VECTOR, ADIODB_VECTOR+3,3) + +.out .sprintf("|MEMMAP:RAM|IRQVECTOR | $%04X-$%04X | %d |", IRQVECTOR, IRQVECTOR + 3,3) + +.out .sprintf("|MEMMAP:RAM|VAPLIC | $%04X-$%04X | %d |", VAPLIC, VAPLIC + 3,3) + +.out .sprintf("|##MEMMAP: Page 3") +.out "|MEMMAP:Type | Name | Range | Size |" +.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" +.out .sprintf("|MEMMAP:IO |VIA1 | $0300-$030F | |") + +.out .sprintf("|##MEMMAP: Page 4") +.out "|MEMMAP:Type | Name | Range | Size |" +.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" +.out .sprintf("|MEMMAP:RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $%04X-$%04X | 3 |", ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY,ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY+3) +;.out .sprintf("|MEMMAP:RAM|page4 overlay_access | $%04X-$%04X | %d |", $400 + code_adress_419 - code_adress_400, $400 + code_adress_436 - code_adress_400, code_adress_436 - code_adress_400) + +.out .sprintf("|##MEMMAP: Page 5&6") +.out "|MEMMAP:Type | Name | Range | Size |" +.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" +.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", BUFNOM, BUFNOM_END, BUFNOM_END - BUFNOM) +.out .sprintf("|MEMMAP:RAM|Malloc table | $%04X-$%04X | %d |", kernel_malloc, kernel_malloc_end,kernel_malloc_end-kernel_malloc) +.out .sprintf("|MEMMAP:RAM|main kernel process struct | $%04X-$%04X | %d |", kernel_process, kernel_process_end,kernel_process_end-kernel_process) + +.out .sprintf("|MEMMAP:RAM|BUFEDT | $%04X-$%04X | %d |", BUFEDT, BUFEDT_END,BUFEDT_END-BUFEDT) +.out .sprintf("|MEMMAP:RAM|KERNEL_MEMORY_DRIVER | $%04X-$%04X | %d |", KERNEL_DRIVER_MEMORY, KERNEL_DRIVER_MEMORY_END, KERNEL_DRIVER_MEMORY_END - KERNEL_DRIVER_MEMORY) + + +.endif diff --git a/src/memmap.asm b/src/memmap.asm index 8ba5c085..8b137891 100644 --- a/src/memmap.asm +++ b/src/memmap.asm @@ -1,220 +1 @@ -.out .sprintf("|#MEMMAP: Memmap") -.out .sprintf("|##MEMMAP: Page 0") -.out "|MEMMAP:Type | Name | Range | Size |" -.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" -.out .sprintf("|MEMMAP:RAM|RES | $%02X-$%02X | 2 |", RES,RES+1) -.out .sprintf("|MEMMAP:RAM|RESB | $%02X-$%02X | 2 |", RESB,RESB+1) -.out .sprintf("|MEMMAP:RAM|RESC | $%02X-$%02X | 2 |", RESC,RESC+1) -.out .sprintf("|MEMMAP:RAM|RESD | $%02X-$%02X | 2 |", RESD,RESD+1) -.out .sprintf("|MEMMAP:RAM|RESE | $%02X-$%02X | 2 |", RESE,RESE+1) -.out .sprintf("|MEMMAP:RAM|RESF | $%02X-$%02X | 2 |", RESF,RESF+1) -.out .sprintf("|MEMMAP:RAM|RESG | $%02X-$%02X | 2 |", RESG,RESG+1) -.out .sprintf("|MEMMAP:RAM|RESH | $%02X-$%02X | 2 |", RESH,RESH+1) -.out .sprintf("|MEMMAP:RAM|RESI | $%02X-$%02X | 2 |", RESI,RESI+1) -.out .sprintf("|MEMMAP:RAM|RESCONCAT | $%02X-$%02X | 2 |", RESCONCAT,RESCONCAT+1) -.out .sprintf("|MEMMAP:RAM|TR0 | $%02X-$%02X | 1 |", TR0,TR0) -.out .sprintf("|MEMMAP:RAM|TR1 | $%02X-$%02X | 1 |", TR1,TR1) -.out .sprintf("|MEMMAP:RAM|TR2 | $%02X-$%02X | 1 |", TR2,TR2) -.out .sprintf("|MEMMAP:RAM|TR3 | $%02X-$%02X | 1 |", TR3,TR3) -.out .sprintf("|MEMMAP:RAM|TR4 | $%02X-$%02X | 1 |", TR4,TR4) -.out .sprintf("|MEMMAP:RAM|TR5 | $%02X-$%02X | 1 |", TR5,TR5) -.out .sprintf("|MEMMAP:RAM|TR6 | $%02X-$%02X | 1 |", TR6,TR6) -.out .sprintf("|MEMMAP:RAM|TR7 | $%02X-$%02X | 1 |", TR7,TR7) -.out .sprintf("|MEMMAP:RAM|DEFAFF | $%02X-$%02X | 1 |",DEFAFF,DEFAFF) -.out .sprintf("|MEMMAP:RAM|FREE | $15-$16 | 2 |") -.out .sprintf("|MEMMAP:RAM|ADDRESS_VECTOR_FOR_ADIOB | $%02X-$%02X | 2 |",ADDRESS_VECTOR_FOR_ADIOB,ADDRESS_VECTOR_FOR_ADIOB+1) -.out .sprintf("|MEMMAP:RAM|work_channel | $%02X-$%02X | 1 |",work_channel,work_channel) -.out .sprintf("|MEMMAP:RAM|i_o_counter | $%02X-$%02X | 2 |",i_o_counter,i_o_counter+1) -.out .sprintf("|MEMMAP:RAM|FREE | $1C-$1C | 1 |") -.out .sprintf("|MEMMAP:RAM|GS | $1D-$1D | 1 |") -.out .sprintf("|MEMMAP:RAM|FREE | $1E-$1E | 1 |") -.out .sprintf("|MEMMAP:RAM|TOFIX | $1F-$1F | 1 |") -.out .sprintf("|MEMMAP:RAM|TOFIX | $20-$20 | 1 |") -.out .sprintf("|MEMMAP:RAM|IRQSVA | $%02X-$%02X | 1 |", IRQSVA,IRQSVA) -.out .sprintf("|MEMMAP:RAM|IRQSVX | $%02X-$%02X | 1 |", IRQSVX,IRQSVX) -.out .sprintf("|MEMMAP:RAM|IRQSVY | $%02X-$%02X | 1 |", IRQSVY,IRQSVY) -.out .sprintf("|MEMMAP:RAM|IRQSVP | $%02X-$%02X | 1 |", IRQSVP,IRQSVP) -.out .sprintf("|MEMMAP:RAM|FIXME_PAGE0_0 | $%02X-$%02X | 1 |",FIXME_PAGE0_0,FIXME_PAGE0_0) -.out .sprintf("|MEMMAP:RAM|ADSCR | $%02X-$%02X | 2 |", ADSCR,ADSCR+1) -.out .sprintf("|MEMMAP:RAM|SCRNB | $%02X-$%02X | 2 |", SCRNB,SCRNB+1) -.out .sprintf("|MEMMAP:RAM|ADKBD | $%02X-$%02X | 2 |", ADKBD,ADKBD+1) -.out .sprintf("|MEMMAP:RAM|PTR_READ_DEST | $%02X-$%02X | 2 |", PTR_READ_DEST,PTR_READ_DEST+1) -.out .sprintf("|MEMMAP:RAM|FREE | $%02X-$%02X | |", PTR_READ_DEST+2,ptr1-1) -.out .sprintf("|MEMMAP:RAM|ptr1 | $%02X-$%02X | 2 |", ptr1,ptr1+1) -.out .sprintf("|MEMMAP:RAM|tmp1 | $%02X-$%02X | 1 |", tmp1,tmp1) -.out .sprintf("|MEMMAP:RAM|FREE | $%02X-$%02X | |", tmp1+1,ADCLK-1) -.out .sprintf("|MEMMAP:RAM|ADCLK | $%02X-$%02X | 2 |", ADCLK,ADCLK+1) -.out .sprintf("|MEMMAP:RAM|TIMEUS | $%02X-$%02X | 2 |", TIMEUS,TIMEUS+1) -.out .sprintf("|MEMMAP:RAM|TIMEUD (used in cc65 clock function)| $%02X-$%02X | 2 |", TIMEUD,TIMEUD+1) -.out .sprintf("|MEMMAP:RAM|HRSX | $%02X-$%02X | 1 |", HRSX,HRSX) -.out .sprintf("|MEMMAP:RAM|HRSY | $%02X-$%02X | 1 |", HRSY,HRSY) -.out .sprintf("|MEMMAP:RAM|FREE | $48-$48 | 1 |") -.out .sprintf("|MEMMAP:RAM|HRSX40 | $%02X-$%02X | 1 |", HRSX40,HRSX40) -.out .sprintf("|MEMMAP:RAM|HRSX6 | $%02X-$%02X | 1 |", HRSX6,HRSX6) -.out .sprintf("|MEMMAP:RAM|ADHRS | $%02X-$%02X | 2 |", ADHRS,ADHRS+1) -.out .sprintf("|MEMMAP:RAM|HRS1 | $%02X-$%02X | 2 |", HRS1,HRS1+1) -.out .sprintf("|MEMMAP:RAM|HRS2 | $%02X-$%02X | 2 |", HRS2,HRS2+1) -.out .sprintf("|MEMMAP:RAM|HRS3 | $%02X-$%02X | 2 |", HRS3,HRS3+1) -.out .sprintf("|MEMMAP:RAM|HRS4 | $%02X-$%02X | 2 |", HRS4,HRS4+1) -.out .sprintf("|MEMMAP:RAM|HRS5 | $%02X-$%02X | 2 |", HRS5,HRS5+1) -.out .sprintf("|MEMMAP:RAM|HRSFB | $%02X-$%02X | 1 |", HRSFB,HRSFB) -.out .sprintf("|MEMMAP:RAM|VABPK1 | $%02X-$%02X | 1 |", VABKP1,VABKP1) -.out .sprintf("|MEMMAP:RAM|FREE | $59-$5A | 2 |") -.out .sprintf("|MEMMAP:RAM|INDRS | $%02X-$%02X | 1 |", INDRS,INDRS) -.out .sprintf("|MEMMAP:RAM|FREE | $5C-$5F | 2 |") - - -.out .sprintf("|MEMMAP:RAM|FREE | $%02X-$FF | %d |",VARLNG,$FF-VARLNG) - -; Used by A : FLGSCR, FLGKBD, CURSCR, SCRX, SCRY, KBDCTC, KBDSHT, KBDFCT -; used in cc65 : SCRX, SCRY, ADSCR, SCRDY - -.out .sprintf("|##MEMMAP: Page 2") -.out "|MEMMAP:Type | Name | Range | Size |" -.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" -.out .sprintf("|MEMMAP:RAM|KERNEL_ERRNO | $%04X-$%04X | 1 |", KERNEL_ERRNO, KERNEL_ERRNO) -.out .sprintf("|MEMMAP:RAM|KERNEL_CH376_MOUNT | $%04X-$%04X | 1 |", KERNEL_CH376_MOUNT, KERNEL_CH376_MOUNT) -.out .sprintf("|MEMMAP:RAM|KERNEL_XFREE_TMP | $%04X-$%04X | 1 |", KERNEL_XFREE_TMP, KERNEL_XFREE_TMP) - -.out .sprintf("|MEMMAP:RAM|KERNEL_XKERNEL_CREATE_PROCESS_TMP| $%04X-$%04X | 1 |", KERNEL_XKERNEL_CREATE_PROCESS_TMP, KERNEL_XKERNEL_CREATE_PROCESS_TMP) - -.out .sprintf("|MEMMAP:RAM|KERNEL_TMP_XEXEC | $%04X-$%04X | 1 |", KERNEL_TMP_XEXEC, KERNEL_TMP_XEXEC) -.out .sprintf("|MEMMAP:RAM|KERNEL_KERNEL_XEXEC_BNKOLD | $%04X-$%04X | 1 |", KERNEL_KERNEL_XEXEC_BNKOLD, KERNEL_KERNEL_XEXEC_BNKOLD) - -.out .sprintf("|MEMMAP:RAM|KERNEL_MALLOC_TYPE | $%04X-$%04X | 1 |", KERNEL_MALLOC_TYPE, KERNEL_MALLOC_TYPE) -.out .sprintf("|MEMMAP:RAM|KERNEL_SAVE_XEXEC_CURRENT_SET| $%04X-$%04X | 1 |", KERNEL_SAVE_XEXEC_CURRENT_SET, KERNEL_SAVE_XEXEC_CURRENT_SET) -.out .sprintf("|MEMMAP:RAM|KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM| $%04X-$%04X | 1 |", KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM, KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM+1) - -.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", $209, KORAM,KORAM-$209) - - -;.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | 2 |", KOROM, KORAM) -;.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | 2 |", KOROM, KORAM) - -.out .sprintf("|MEMMAP:RAM|TIMED | $%04X-$%04X | 1 |", TIMED, TIMED ) -.out .sprintf("|MEMMAP:RAM|TIMES | $%04X-$%04X | 1 |", TIMES, TIMES) -.out .sprintf("|MEMMAP:RAM|TIMEM | $%04X-$%04X | 1 |", TIMEM , TIMEM) -.out .sprintf("|MEMMAP:RAM|TIMEH | $%04X-$%04X | 1 |", TIMEH, TIMEH) - -.out .sprintf("|MEMMAP:RAM|FLGCLK | $%04X-$%04X | 1 |", FLGCLK, FLGCLK) -.out .sprintf("|MEMMAP:RAM|FLGCLK_FLAG | $%04X-$%04X | 1 |", FLGCLK_FLAG, FLGCLK_FLAG) - -.out .sprintf("|MEMMAP:RAM|FLGCUR | $%04X-$%04X | 1 |", FLGCUR, FLGCUR) -.out .sprintf("|MEMMAP:RAM|FLGCUR_STATE | $%04X-$%04X | 1 |", FLGCUR_STATE, FLGCUR_STATE) - -.out .sprintf("|MEMMAP:RAM|ADSCRL | $%04X-$%04X | 4 |", ADSCRL,ADSCRL+3) -.out .sprintf("|MEMMAP:RAM|ADSCRH | $%04X-$%04X | 4 |", ADSCRH,ADSCRH+3) - -.out .sprintf("|MEMMAP:RAM|SCRX | $%04X-$%04X | 1 |", SCRX, SCRX) - -.out .sprintf("|MEMMAP:RAM|BUSY_BANK_TABLE_RAM | $%04X-$%04X | %d |", BUSY_BANK_TABLE_RAM, BUSY_BANK_TABLE_RAM+3, 3) - -.out .sprintf("|MEMMAP:RAM|SCRY | $%04X-$%04X | 4 |", SCRY, SCRY+3) - -.out .sprintf("|MEMMAP:RAM|SCRDX | $%04X-$%04X | 1 |", SCRDX, SCRDX) -.out .sprintf("|MEMMAP:RAM|SCRFX | $%04X-$%04X | 1 |", SCRFX, SCRFX) - -.out .sprintf("|MEMMAP:RAM|SCRFY | $%04X-$%04X | 1 |", SCRFY, SCRFY) -.out .sprintf("|MEMMAP:RAM|SCRDY | $%04X-$%04X | 1 |", SCRDY, SCRDY) - -.out .sprintf("|MEMMAP:RAM|SCRBAL | $%04X-$%04X | 1 |", SCRBAL, SCRBAL) - -.out .sprintf("|MEMMAP:RAM|SCRBAH | $%04X-$%04X | 1 |", SCRBAH, SCRBAH) - - -.out .sprintf("|MEMMAP:RAM|SCRCT | $%04X-$%04X | 1 |", SCRCT, SCRCT) -.out .sprintf("|MEMMAP:RAM|SCRCF | $%04X-$%04X | 1 |", SCRCF, SCRCF) - - -.out .sprintf("|MEMMAP:RAM|FIXME | $%04X-$%04X | %d |", SCRCF+4,ADSCRH+4,KBDCOL-ADSCRH+4) - -.out .sprintf("|MEMMAP:RAM|FLGSCR | $%04X-$%04X | 4 |", FLGSCR,FLGSCR+4) ; $248 -.out .sprintf("|MEMMAP:RAM|CURSCR | $%04X-$%04X | 1 |", CURSCR,CURSCR+1) ; $248 - -.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", CURSCR+1,SCRTXT,SCRTXT-CURSCR+1) ; $248 - -.out .sprintf("|MEMMAP:RAM|SCRTXT | $%04X-$%04X | 4 |", SCRTXT,SCRHIR+4) ; $248 -.out .sprintf("|MEMMAP:RAM|SCRHIR (not used) | $%04X-$%04X | %d |", SCRHIR,SCRHIR+4,4) ; $248 - -.out .sprintf("|MEMMAP:RAM|SCRTRA | $%04X-$%04X | %d |", SCRTRA,SCRTRA+4,6) ; $248 - -.out .sprintf("|MEMMAP:RAM|KBDCOL | $%04X-$%04X | %d |", KBDCOL,KBDCOL+8,8) -.out .sprintf("|MEMMAP:RAM|KBDFLG_KEY | $%04X-$%04X | %d |", KBDFLG_KEY,KBDFLG_KEY+2,2) - -.out .sprintf("|MEMMAP:RAM|KBDVRR | $%04X-$%04X | %d |", KBDVRR,KBDVRR+1,1) -.out .sprintf("|MEMMAP:RAM|KBDVRL | $%04X-$%04X | %d |", KBDVRL,KBDVRL+2,2) -.out .sprintf("|MEMMAP:RAM|FLGKBD | $%04X-$%04X | %d |", FLGKBD,FLGKBD+1,1) - -.out .sprintf("|MEMMAP:RAM|KBDFCT | $%04X-$%04X | %d |", KBDFCT,KBDFCT+1,1) - -.out .sprintf("|MEMMAP:RAM|KBDSHT | $%04X-$%04X | %d |", KBDSHT,KBDSHT+1,1) - -.out .sprintf("|MEMMAP:RAM|KBDKEY | $%04X-$%04X | %d |", KBDKEY ,KBDKEY+5,1) - -.out .sprintf("|MEMMAP:RAM|KBDCTC | $%04X-$%04X | 2 |", KBDCTC,KBDCTC+1) - -.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", KBDCTC+1,KEYBOARD_COUNTER-1,KEYBOARD_COUNTER-KBDCTC) - -.out .sprintf("|MEMMAP:RAM|KEYBOARD_COUNTER | $%04X-$%04X | %d |", KEYBOARD_COUNTER, KEYBOARD_COUNTER+3,3) -.out .sprintf("|MEMMAP:RAM|HRSPAT | $%04X-$%04X | %d |", HRSPAT,HRSPAT,1) - -.out .sprintf("|MEMMAP:RAM|IOTAB | $%04X-$%04X | X |", IOTAB, IOTAB+KERNEL_SIZE_IOTAB-1) -.out .sprintf("|MEMMAP:RAM|KERNEL_ADIOB | $%04X-$%04X | %d |", KERNEL_ADIOB,KERNEL_ADIOB+ADIODB_LENGTH-1,KERNEL_ADIOB+ADIODB_LENGTH-KERNEL_ADIOB) - -.out .sprintf("|MEMMAP:RAM|kernel_malloc_free_chunk_size | $%04X-$%04X | %d |", kernel_malloc_free_chunk_size,kernel_malloc_free_chunk_size+.sizeof(kernel_malloc_free_chunk_size_struct)-1,.sizeof(kernel_malloc_free_chunk_size_struct)) - -.out .sprintf("|MEMMAP:RAM|kernel_xmalloc_call | $%04X-$%04X | %d |", kernel_xmalloc_call,kernel_xmalloc_call+XMALLOC_ROUTINE_TO_RAM_OVERLAY,kernel_xmalloc_call+XMALLOC_ROUTINE_TO_RAM_OVERLAY-kernel_xmalloc_call) - -.out .sprintf("|MEMMAP:RAM|FLGRST | $%04X-$%04X | %d |", FLGRST,FLGRST,1) -.out .sprintf("|MEMMAP:RAM|CSRND | $%04X-$%04X | %d |", CSRND,CSRND,1) - - -.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", KERNEL_ADIOB_END,FLGRST-1,FLGRST-KERNEL_ADIOB_END) - -.out .sprintf("|MEMMAP:RAM|VNMI | $%04X-$%04X | 3 |", VNMI,VNMI+3) - -.out .sprintf("|MEMMAP:RAM|ADIODB_VECTOR | $%04X-$%04X | %d |", ADIODB_VECTOR,ADIODB_VECTOR+3,3) - -.out .sprintf("|MEMMAP:RAM|IRQVECTOR | $%04X-$%04X | %d |", IRQVECTOR,IRQVECTOR+3,3) - -.out .sprintf("|MEMMAP:RAM|VAPLIC | $%04X-$%04X | %d |", VAPLIC,VAPLIC+3,3) - -.out .sprintf("|##MEMMAP: Page 3") -.out "|MEMMAP:Type | Name | Range | Size |" -.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" -.out .sprintf("|MEMMAP:IO |VIA1 | $0300-$030F | |") - -.out .sprintf("|##MEMMAP: Page 4") -.out "|MEMMAP:Type | Name | Range | Size |" -.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" -.out .sprintf("|MEMMAP:RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $%04X-$%04X | 3 |", ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY,ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY+3) -.out .sprintf("|MEMMAP:RAM|page4 overlay_access | $%04X-$%04X | %d |", $400+code_adress_419-code_adress_400,$400+code_adress_436-code_adress_400,code_adress_436-code_adress_400) - -.out .sprintf("|##MEMMAP: Page 5&6") -.out "|MEMMAP:Type | Name | Range | Size |" -.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" -.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", BUFNOM, BUFNOM_END,BUFNOM_END-BUFNOM) -.out .sprintf("|MEMMAP:RAM|Malloc table | $%04X-$%04X | %d |", kernel_malloc,kernel_malloc_end,kernel_malloc_end-kernel_malloc) -.out .sprintf("|MEMMAP:RAM|main kernel process struct | $%04X-$%04X | %d |", kernel_process,kernel_process_end,kernel_process_end-kernel_process) - -.out .sprintf("|MEMMAP:RAM|BUFEDT | $%04X-$%04X | %d |", BUFEDT, BUFEDT_END,BUFEDT_END-BUFEDT) -.out .sprintf("|MEMMAP:RAM|KERNEL_MEMORY_DRIVER | $%04X-$%04X | %d |", KERNEL_DRIVER_MEMORY,KERNEL_DRIVER_MEMORY_END,KERNEL_DRIVER_MEMORY_END-KERNEL_DRIVER_MEMORY) - - -.out .sprintf("|##MEMMAP: Kernel bank 7") -.out "|MEMMAP: Type | Name | Range | Size |" -.out "|MEMMAP: :-------- |:---------------------------- |:------- |:-----|" - -.out .sprintf("|MEMMAP:ROM|FREE |$%x-$fff0| %d |", free_bytes,$fff0-free_bytes) - -.out .sprintf("|##MEMMAP: Bank 0") -.out "|MEMMAP: Type | Name | Range | Size |" -.out "|MEMMAP: -------- | ---------------------------- | ------- |-----|" -.out .sprintf("|MEMMAP:BANK0|BUFBUF | $%x-$%x | %d |", BUFBUF,BUFBUF+12*KERNEL_NUMBER_BUFFER,BUFBUF+12*KERNEL_NUMBER_BUFFER-BUFBUF) -.out .sprintf("|MEMMAP:BANK0|BUFROU | $%x-$%x | |", BUFROU,BUFROU+(end_BUFROU-data_to_define_4)) -.out .sprintf("|MEMMAP:BANK0|TELEMON_KEYBOARD_BUFFER_BEGIN | $%x-$%x | |", TELEMON_KEYBOARD_BUFFER_BEGIN,TELEMON_KEYBOARD_BUFFER_END) -.out .sprintf("|MEMMAP:BANK0|XMALLOC (copy from kernel) | $%x-$%x | |", ramoverlay_xmalloc,ramoverlay_xmalloc_end ) -.out .sprintf("|MEMMAP:BANK0|XFREE (copy from kernel) | $%x-$%x | |", ramoverlay_xfree,ramoverlay_xfree_end ) - - diff --git a/src/rom_cmd.s b/src/rom_cmd.s new file mode 100644 index 00000000..20d58805 --- /dev/null +++ b/src/rom_cmd.s @@ -0,0 +1,182 @@ +;---------------------------------------------------------------------- +; Number of commands +;---------------------------------------------------------------------- +.scope SDK_ROM + command_nb .set 0 + vectors_set .set 0 +.endscope + +;---------------------------------------------------------------------- +; +; usage: +; add_command "command_name"[, command_address] +; +; note: +; command_address defaults to command_name +; Ex: add_command "test" will use label test for command_address +; +; Add command_name to the rom +;---------------------------------------------------------------------- +.macro add_command command_name, address + + verbose 2, .sprintf("*** Add command: %s", command_name) + + .assert SDK_ROM::vectors_set = 0, ldwarning, .sprintf("Command '%s' defined after set_orix_vectors", command_name) + + .pushseg + + .segment "INSTRTBL" + .ident(.sprintf("%s_name",command_name)) := * + .asciiz command_name + + .segment "INSTRTBL2" + .word .ident(.sprintf("%s_name",command_name)) + + .if .not .xmatch({address}, NOOP) + .segment "INSTRJMP" + + .if .not .blank({address}) + .addr address + .else + .word .ident(command_name) + .endif + .endif + + SDK_ROM::command_nb .set SDK_ROM::command_nb+1 + + .popseg +.endmacro + + +;---------------------------------------------------------------------- +; +; usage: +; command "command_name" +; +; note: +; Open command scope, don't forget to use endcommand to close +; the scope +; +; Add command_name to the rom +;---------------------------------------------------------------------- +.macro command command_name + + verbose 2, .sprintf("*** Add command: %s", command_name) + + .assert SDK_ROM::vectors_set = 0, ldwarning, .sprintf("Command '%s' defined after set_orix_vectors", command_name) + + .pushseg + + .segment "INSTRTBL" + .ident(.sprintf("%s_name",command_name)) := * + .asciiz command_name + + .segment "INSTRTBL2" + .word .ident(.sprintf("%s_name",command_name)) + + .segment "INSTRJMP" + .word .ident(command_name) + + + SDK_ROM::command_nb .set SDK_ROM::command_nb+1 + + .popseg + + .proc .ident(command_name) +.endmacro + + +;---------------------------------------------------------------------- +; +; usage: +; endcommand +; +; Close command scope +;---------------------------------------------------------------------- +.macro endcommand + .endproc +.endmacro + + +;---------------------------------------------------------------------- +; +; usage: +; set_orix_vectors rom_type, parse_vector, signature +; +; note: +; signature: may be "string" or label +; if signature is a "string", this macro create new label rom_signaure +; +; Set orix rom vectors +;---------------------------------------------------------------------- +.macro set_orix_vectors rom_type, parse_vector, signature + .local _signature + + .pushseg + + ;.import __INSTRJMP_LOAD__ + ;.import __INSTRTBL_LOAD__ + + .if .match(signature,"") + .segment "SIGNATURE" + .import __SIGNATURE_LOAD__ + + ; A voir si dans ce cas on doit définir le label "rom_signature" ou non + ; .ident(.sprintf("rom_signature")) := * + + _signature := __SIGNATURE_LOAD__ + .asciiz signature + .else + _signature := signature + .endif + + .segment "ORIXVECT" + .byte rom_type + .addr parse_vector + .addr parse_vector + .addr parse_vector + .byte SDK_ROM::command_nb + .word _signature + + .popseg + + SDK_ROM::vectors_set .set 1 + + verbose 1, .sprintf("*** Bank name: %s", signature) + verbose 1, .sprintf("*** Commands : %d", SDK_ROM::command_nb) + + ;.assert SDK_ROM::command_nb > 0, warning, "No command defined" + +.endmacro + + +;---------------------------------------------------------------------- +; +; usage: +; set_cpu_vectors nmi, reset, irq +; +; Set 6502 vectors +;---------------------------------------------------------------------- +.macro set_cpu_vectors nmi, reset, irq + .pushseg + + .segment "CPUVECT" + .addr nmi + .addr reset + .addr irq + + .popseg +.endmacro + +; ---------------------------------------------------------------------------- +; verbose level, string +; ---------------------------------------------------------------------------- +; Affiche un message si level <= VERBOSE_LEVEL +; ---------------------------------------------------------------------------- +.macro verbose level, string + .ifdef VERBOSE_LEVEL + .if level <= ::VERBOSE_LEVEL + .out string + .endif + .endif +.endmacro diff --git a/src/versions/versions.inc b/src/versions/versions.inc index 851348ad..e64d12e4 100644 --- a/src/versions/versions.inc +++ b/src/versions/versions.inc @@ -5,5 +5,6 @@ .define KERNEL_VERSION_2023_2 $04 .define KERNEL_VERSION_2023_3 $05 .define KERNEL_VERSION_2024_1 $06 +.define KERNEL_VERSION_2025_1 $07 -.define CURRENT_VERSION_BINARY KERNEL_VERSION_2024_1 +.define CURRENT_VERSION_BINARY KERNEL_VERSION_2025_1 diff --git a/tests/functions/bank_mng/search_free_bank.s b/tests/functions/bank_mng/search_free_bank.s new file mode 100644 index 00000000..a2d85934 --- /dev/null +++ b/tests/functions/bank_mng/search_free_bank.s @@ -0,0 +1,192 @@ +; Code to test XMAINARGS + +.include "telestrat.inc" +.include "../../../dependencies/orix-sdk/macros/SDK_mainargs.mac" +.include "../../../dependencies/orix-sdk/macros/SDK_print.mac" +.include "../../../dependencies/orix-sdk/macros/SDK_conio.mac" + +.segment "STARTUP" +.segment "INIT" +.segment "ONCE" + +.segment "CODE" + +_main: + +.define KERNEL_RAM_BANK_APPLICATION_TYPE $01 +.define KERNEL_ALLOCATE_BANK $01 +.define KERNEL_FREE_BANK $02 + +userzp := $80 + +tmp1 := userzp +tmp2 := userzp + 1 +tmp3 := userzp + 2 + +start_adress: + ; argv := userzp ; 2 bytes + ; argc := userzp + 2 ; 1 byte + + print str_bank_id_given + lda #KERNEL_ALLOCATE_BANK ; Mode + ldx #KERNEL_RAM_BANK_APPLICATION_TYPE ; X the type of bank + BRK_TELEMON $01 ; GET free bank + sta tmp1 + stx tmp2 + sty tmp3 + + ldy #00 + print_int ,2, 2 + print str_set + lda tmp2 ; Load set + ldy #00 + print_int ,2, 2 + print str_bank + lda tmp3 ; Load bank + ldy #00 + print_int ,2, 2 + crlf + + ; Free + print str_free_id + lda tmp1 + print_int ,2, 2 + lda #KERNEL_FREE_BANK ; Mode + ldx tmp1 ; X the type of bank + BRK_TELEMON $01 ; GET free bank + crlf + ; + + print str_bank_id_given + lda #KERNEL_ALLOCATE_BANK ; Mode + ldx #KERNEL_RAM_BANK_APPLICATION_TYPE ; X the type of bank + BRK_TELEMON $01 ; GET free bank + sta tmp1 + stx tmp2 ; Set + sty tmp3 + + ldy #00 + print_int ,2, 2 + print str_set + lda tmp2 ; Load set + ldy #00 + print_int ,2, 2 + print str_bank + lda tmp3 ; Load bank + ldy #00 + print_int ,2, 2 + crlf + + print str_bank_id_given + lda #KERNEL_ALLOCATE_BANK ; Mode + ldx #KERNEL_RAM_BANK_APPLICATION_TYPE ; X the type of bank + BRK_TELEMON $01 ; GET free bank + sta tmp1 + stx tmp2 + sty tmp3 + + ldy #00 + print_int ,2, 2 + print str_set + lda tmp2 ; Load set + ldy #00 + print_int ,2, 2 + print str_bank + lda tmp3 ; Load bank + ldy #00 + print_int ,2, 2 + crlf + + print str_bank_id_given + lda #KERNEL_ALLOCATE_BANK ; Mode + ldx #KERNEL_RAM_BANK_APPLICATION_TYPE ; X the type of bank + BRK_TELEMON $01 ; GET free bank + sta tmp1 + stx tmp2 + sty tmp3 + + ldy #00 + print_int ,2, 2 + print str_set + lda tmp2 ; Load set + ldy #00 + print_int ,2, 2 + print str_bank + lda tmp3 ; Load bank + ldy #00 + print_int ,2, 2 + crlf + + ;initmainargs argv, argc, 0 + rts + + ; appel de la lib curl + + ; brk XEXECLIB, #curl_exec, id_bank + + ; Macro : + + ; XEXECLIB #curl_exec, bank. + ; Ce qui donnerait : + ; pha + ; lda bank + ; sta bank_lib ; Offset + ; lda func + ; sta func_id ; Offset + ; pla + ; brk_kernel xexec lib + + ; Initialisation d'une banque pour charger une lib curl: + + ; lda #KERNEL_ALLOCATE_BANK ; Mode + ; ldx #KERNEL_RAM_BANK_LIB_TYPE ; X the type of bank + ; BRK_TELEMON $01 ; GET free bank + + ; lda #KERNEL_LOAD_LIB + ; ldx #<libcurl_so + ; ldy #>libcurl_so + ; BRK_TELEMON $01 + ; ; Relocation de la lib + ; referencement de la lib + + ; rts + ;libcurl_so: + ; .asciiz "/lib/2024.1/libcurl.so" + ; + + + +; lda argc +; cmp #$03 +; bne @no_arg + +; getmainarg #1, (argv) +; BRK_TELEMON XWSTR0 +; crlf + +; getmainarg #2, (argv) +; BRK_TELEMON XWSTR0 +; crlf + +; rts + +; @no_arg: +; print str_there_not_two_arg +; lda #$01 +; ldy #$00 +; rts + +str_there_not_two_arg: + .asciiz "There is not 2 arg" + +str_bank_id_given: + .asciiz "Allocate bank id : " + +str_free_id: + .asciiz "Free bank id : " + +str_set: + .asciiz " Set :" + +str_bank: + .asciiz " bank :" \ No newline at end of file diff --git a/tests/functions/network/netchk.s b/tests/functions/network/netchk.s new file mode 100644 index 00000000..6f94647b --- /dev/null +++ b/tests/functions/network/netchk.s @@ -0,0 +1,475 @@ +; Code to test XMAINARGS + +.include "telestrat.inc" +.include "../../../src/kernel8/orixlibs/ch395/usr/include/asm/ch395.inc" +.include "../../../src/kernel8/orixlibs/ksocket/usr/include/asm/socket.inc" + +.include "../../../dependencies/orix-sdk/macros/SDK_mainargs.mac" +.include "../../../dependencies/orix-sdk/macros/SDK_print.mac" +.include "../../../dependencies/orix-sdk/macros/SDK_conio.mac" +.include "../../../dependencies/orix-sdk/macros/SDK_memory.mac" + +.include "errno.inc" + +.segment "STARTUP" +.segment "INIT" +.segment "ONCE" + +.segment "CODE" + +.define KERNEL_START_NETWORK $04 + +_main: + +.define KERNEL_NETWORK_STATE_NOT_INITIALIZED $00 +.define KERNEL_NETWORK_STATE_CHIP_INITIALIZED $01 +.define KERNEL_NETWORK_CABLE_DISCONNECTED $02 +.define KERNEL_NETWORK_CABLE_CONNECTED $03 +.define KERNEL_NETWORK_FULLY_STARTED $04 +.define KERNEL_NETWORK_STARTING_DHCP $05 + +.define KERNEL_SOCKET_NETWORK $05 +.define KERNEL_BIND_NETWORK $06 +.define KERNEL_CONNECT_NETWORK $07 +.define KERNEL_RECV_NETWORK $08 +.define KERNEL_SEND_NETWORK $09 +.define KERNEL_SOCKET_CLOSE_NETWORK $0A + +.define KERNEL_NETWORK_STATE_CHIP_NOT_FOUND $FF + + +; Exemple +; SOCKET sock = SOCKET AF_INET, SOCK_STREAM, 0 + +.macro SOCKET domain, type, protocol + lda #$00 + ldx #domain + ldy #type + + lda #KERNEL_SOCKET_NETWORK + BRK_TELEMON $01 +.endmacro + + + +userzp := $80 + +tmp1 := userzp +tmp2 := userzp + 1 +tmp3 := userzp + 2 +retry := userzp + 3 +socket := userzp + 4 +ptr_recv := userzp + 5 + + +start_adress: + + malloc #4096 + cmp #$00 + beq @not_oom + cpy #$00 + bne @not_oom + print str_oom + crlf + rts +@not_oom: + sta ptr_recv + sty ptr_recv+1 + + lda #$FF + sta retry + + + ; argv := userzp ; 2 bytes + ; argc := userzp + 2 ; 1 byte +@start: + dec retry + beq @end + + ; print str_bank_id_given + lda #KERNEL_START_NETWORK ; Mode + BRK_TELEMON $01 ; Get network state + cmp #KERNEL_NETWORK_CABLE_DISCONNECTED + beq @disconnected + cmp #KERNEL_NETWORK_CABLE_CONNECTED + beq @connected + cmp #KERNEL_NETWORK_FULLY_STARTED + beq @fully_started + cmp #KERNEL_NETWORK_STARTING_DHCP + beq @dhcp_starting + cmp #KERNEL_NETWORK_FULLY_STARTED + beq @dhcp_started + cmp #KERNEL_NETWORK_STATE_CHIP_NOT_FOUND + beq @network_chip_not_found + +@end: + pha + print str_not_known_network_status + pla + + ldy #00 ; 0 because the number is 12 (from A) + print_int ,2, 2 ; an arg is skipped because the number is from register + crlf + rts + + + +@fully_started: + print str_fully_started + crlf + jmp @socket + +@disconnected: + print str_cable_disconnected + crlf + rts + +@connected: + print str_cable_connected + crlf + jmp @waiting + +@dhcp_starting: + print str_starting_dhcp + crlf + jmp @waiting + +@dhcp_started: + print str_started_dhcp + crlf + rts + +@waiting: + print str_waiting + crlf + jmp @start + +@network_chip_not_found: + print str_network_chip_not_found + rts + +@socket: + +@loop_socket: + print str_socket + + +; .macro SOCKET domain, type, protocol +; lda #$00 +; ldx #domain +; ldy #type + +; lda #KERNEL_SOCKET_NETWORK +; BRK_TELEMON $01 +; .endmacro + + SOCKET AF_INET, SOCK_STREAM, 0 + cmp #INVALID_SOCKET + beq @INVALID_SOCKET_STR + sta socket + clc + adc #'0' + BRK_TELEMON XWR0 + crlf + + lda #00 ; Port 80 + sta RESB + lda #80 ; Port + sta RESB+1 + lda #$00 ; Socket id + lda socket + sta TR0 + ldy #<ip + ldx #>ip + lda #KERNEL_CONNECT_NETWORK ; Connect + BRK_TELEMON $01 + cmp #SOCKET_ERROR + beq @socket_error + + ;;@brief Send data into socket + ;;@inputTR0 Socket id + ;;@inputY Low length + ;;@inputX High length + ;;@inputMEM_RES ptr + ;;@modifyMEM_TR1 ptr + ;;@returnsA Error type, 0 : success + lda socket + sta TR0 + ; Set length + lda #<str_http + sta RES + lda #>str_http + sta RES + 1 + ldy #18 + ldx #$00 + + lda #KERNEL_SEND_NETWORK ; Connect + BRK_TELEMON $01 + cmp #$00 + beq @send_success + print str_send_error + crlf + + ;socket_connect 202, (curl_dest_port), (curl_ip_dest) + jmp @loop_socket + +@send_success: + print str_send_success + + + ; Recv + + ;;@inputTR0 Socket id + ;;@inputY Low ptr to store the buffer + ;;@inputX High ptr to store the buffer + lda socket + sta TR0 + + + ldy ptr_recv + ldx ptr_recv+1 + lda #KERNEL_RECV_NETWORK + BRK_TELEMON $01 + cmp #EOK + bne @not_received + beq @received + + crlf + jmp @loop_socket + +@socket_error: + print str_socket_error + crlf + jmp @loop_socket + +@INVALID_SOCKET_STR: + print str_invalid_socket + rts + +@not_received: + print str_not_received + crlf + jmp @loop_socket + +@received: + print str_received + crlf + jmp @loop_socket + +str_network_chip_not_found: + .byte $81,"Network chip not found",0 + +str_not_known_network_status: + .byte $81,"Unknown network status !",0 + +str_cannot_open_socket: + .byte 1,"Cannot open socket !",0 + +str_not_received: + .byte $81,"Received Error!",0 + +str_received: + .byte $81,"Received!",0 + +str_oom: + .byte $81,"OOM!",0 + +str_send_success: + .byte 2,"Send success !",0 + +str_send_error: + .byte $81,"Send Error!",0 + +str_http: + .byte "GET /index.htm", $0D, $0A, $0D, $0A + +str_socket_error: + .byte $81, "Socket open error",0 + +ip: + .byte 192,168,1,77 + +str_invalid_socket: + .byte $81,"Invalid socket",0 + +str_socket: + .asciiz "Socket : " + +str_waiting: + .asciiz "Waiting ..." + +str_started_dhcp: + .asciiz "Started dhcp !!" + +str_starting_dhcp: + .asciiz "Starting dhcp" + +str_fully_started: + .asciiz "Fully Started" + +str_cable_disconnected: + .asciiz "Cable disconnected" + +str_cable_connected: + .asciiz "Cable connected" + + + ; sta tmp1 + ; stx tmp2 + ; sty tmp3 + + ; ldy #00 + ; print_int ,2, 2 + ; print str_set + ; lda tmp2 ; Load set + ; ldy #00 + ; print_int ,2, 2 + ; print str_bank + ; lda tmp3 ; Load bank + ; ldy #00 + ; print_int ,2, 2 + ; crlf + + ; ; Free + ; print str_free_id + ; lda tmp1 + ; print_int ,2, 2 + ; lda #KERNEL_FREE_BANK ; Mode + ; ldx tmp1 ; X the type of bank + ; BRK_TELEMON $01 ; GET free bank + ; crlf + ; ; + + ; print str_bank_id_given + ; lda #KERNEL_ALLOCATE_BANK ; Mode + ; ldx #KERNEL_RAM_BANK_APPLICATION_TYPE ; X the type of bank + ; BRK_TELEMON $01 ; GET free bank + ; sta tmp1 + ; stx tmp2 ; Set + ; sty tmp3 + + ; ldy #00 + ; print_int ,2, 2 + ; print str_set + ; lda tmp2 ; Load set + ; ldy #00 + ; print_int ,2, 2 + ; print str_bank + ; lda tmp3 ; Load bank + ; ldy #00 + ; print_int ,2, 2 + ; crlf + + ; print str_bank_id_given + ; lda #KERNEL_ALLOCATE_BANK ; Mode + ; ldx #KERNEL_RAM_BANK_APPLICATION_TYPE ; X the type of bank + ; BRK_TELEMON $01 ; GET free bank + ; sta tmp1 + ; stx tmp2 + ; sty tmp3 + + ; ldy #00 + ; print_int ,2, 2 + ; print str_set + ; lda tmp2 ; Load set + ; ldy #00 + ; print_int ,2, 2 + ; print str_bank + ; lda tmp3 ; Load bank + ; ldy #00 + ; print_int ,2, 2 + ; crlf + + ; print str_bank_id_given + ; lda #KERNEL_ALLOCATE_BANK ; Mode + ; ldx #KERNEL_RAM_BANK_APPLICATION_TYPE ; X the type of bank + ; BRK_TELEMON $01 ; GET free bank + ; sta tmp1 + ; stx tmp2 + ; sty tmp3 + + ; ldy #00 + ; print_int ,2, 2 + ; print str_set + ; lda tmp2 ; Load set + ; ldy #00 + ; print_int ,2, 2 + ; print str_bank + ; lda tmp3 ; Load bank + ; ldy #00 + ; print_int ,2, 2 + ; crlf + + ;initmainargs argv, argc, 0 + rts + + ; appel de la lib curl + + ; brk XEXECLIB, #curl_exec, id_bank + + ; Macro : + + ; XEXECLIB #curl_exec, bank. + ; Ce qui donnerait : + ; pha + ; lda bank + ; sta bank_lib ; Offset + ; lda func + ; sta func_id ; Offset + ; pla + ; brk_kernel xexec lib + + ; Initialisation d'une banque pour charger une lib curl: + + ; lda #KERNEL_ALLOCATE_BANK ; Mode + ; ldx #KERNEL_RAM_BANK_LIB_TYPE ; X the type of bank + ; BRK_TELEMON $01 ; GET free bank + + ; lda #KERNEL_LOAD_LIB + ; ldx #<libcurl_so + ; ldy #>libcurl_so + ; BRK_TELEMON $01 + ; ; Relocation de la lib + ; referencement de la lib + + ; rts + ;libcurl_so: + ; .asciiz "/lib/2024.1/libcurl.so" + ; + + + +; lda argc +; cmp #$03 +; bne @no_arg + +; getmainarg #1, (argv) +; BRK_TELEMON XWSTR0 +; crlf + +; getmainarg #2, (argv) +; BRK_TELEMON XWSTR0 +; crlf + +; rts + +; @no_arg: +; print str_there_not_two_arg +; lda #$01 +; ldy #$00 +; rts + +str_there_not_two_arg: + .asciiz "There is not 2 arg" + +str_bank_id_given: + .asciiz "Allocate bank id : " + +str_free_id: + .asciiz "Free bank id : " + +str_set: + .asciiz " Set :" + +str_bank: + .asciiz " bank :" \ No newline at end of file diff --git a/tests/unit_test/mainarg.s b/tests/unit_test/mainarg.s new file mode 100644 index 00000000..09f8fa58 --- /dev/null +++ b/tests/unit_test/mainarg.s @@ -0,0 +1,58 @@ +; Code to test XMAINARGS + +.include "telestrat.inc" +.include "../../dependencies/orix-sdk/macros/SDK_mainargs.mac" +.include "../../dependencies/orix-sdk/macros/SDK_print.mac" +.include "../../dependencies/orix-sdk/macros/SDK_conio.mac" + +.segment "STARTUP" +.segment "INIT" +.segment "ONCE" + +.segment "CODE" +_main: + +userzp := $80 + +start_adress: + argv := userzp ; 2 bytes + argc := userzp + 2 ; 1 byte + + initmainargs argv, argc, 0 + +nop + lda argc + cmp #$03 + bne @no_arg +nop +nop + +nop + +nop + getmainarg #1, (argv) + BRK_TELEMON XWSTR0 + crlf +nop +nop + +nop + +nop + getmainarg #2, (argv) + BRK_TELEMON XWSTR0 + crlf + + rts +nop +@no_arg: + print str_there_not_two_arg + lda #$01 + ldy #$00 + rts + +str_there_not_two_arg: + .asciiz "There is not 2 arg" + + + lda #$41 \ No newline at end of file diff --git a/tests/unit_test/mainarg.sub b/tests/unit_test/mainarg.sub new file mode 100644 index 00000000..f14fd4d0 --- /dev/null +++ b/tests/unit_test/mainarg.sub @@ -0,0 +1,4 @@ +#!/bin/submit +echo Mainarg test +mainarg ici "part1 part2" +#on error echo error diff --git a/tests/unit_test/start.sub b/tests/unit_test/start.sub new file mode 100644 index 00000000..0ba8a614 --- /dev/null +++ b/tests/unit_test/start.sub @@ -0,0 +1,6 @@ +#!/bin/submit + +echo Salut + +chain /bin/mainarg.sub 1 2 + diff --git a/tests/xexec.asm b/tests/xexec.asm index 58ef65b1..5f3d1350 100644 --- a/tests/xexec.asm +++ b/tests/xexec.asm @@ -17,6 +17,5 @@ __MAIN_START__: ;save_return: ; .res 1 str: - .asciiz "lsmem" + .asciiz "lsmem" __MAIN_LAST__: - \ No newline at end of file