From 52e915c8383b6f7e20f186b1242db18f12cc0f22 Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 4 Jun 2024 21:51:16 +0200 Subject: [PATCH 01/49] fix/mainargs with " --- .github/workflows/main.yml | 8 +++-- Makefile | 51 +++++++++++++------------- VERSION | 2 +- dependencies/orix-sdk | 2 +- docs/memmap_ram.md | 2 +- memmap.md | 8 ++--- run.sh | 15 ++++++-- src/functions/init_screen.asm | 1 + src/functions/mainargs.asm | 64 +++++++++++++++++++++++++++------ src/include/libs/ch376_verify.s | 3 +- src/kernel.asm | 2 +- tests/unit_test/mainarg.s | 59 ++++++++++++++++++++++++++++++ tests/unit_test/mainarg.sub | 4 +++ tests/unit_test/start.sub | 6 ++++ tests/xexec.asm | 3 +- 15 files changed, 176 insertions(+), 54 deletions(-) create mode 100644 tests/unit_test/mainarg.s create mode 100644 tests/unit_test/mainarg.sub create mode 100644 tests/unit_test/start.sub diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a2b21501..e7ba6f93 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -136,10 +136,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: | diff --git a/Makefile b/Makefile index aeeae199..30c7eccc 100644 --- a/Makefile +++ b/Makefile @@ -12,15 +12,15 @@ 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)/ @@ -37,8 +37,8 @@ init: kernel: $(SOURCE) @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 + @$(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 @cp kernel.rom kernelsd.rom @sed -re 's/al 00(.{4}) \.(.+)$$/\1 \2/' kernelsd.sym| sort > kernelsd2.sym > output.log @cp kernelsd.rom $(PATH_PACKAGE_ROM)/ @@ -48,29 +48,30 @@ kernel: $(SOURCE) @echo Build kernelus.rom for Twilighte board @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 src/kernel.cfg kernelus.ld65 -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 tmkdir + @$(CC) $(CFLAGS) tests/fwrite.c -o tfwrite + @$(CC) $(CFLAGS) tests/unit_test/mainarg.s -o mainarg 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 + @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/VERSION b/VERSION index 2cf03e51..80e1c8d5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2024.1 \ No newline at end of file +2024.3 \ 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/memmap_ram.md b/docs/memmap_ram.md index e4ea2c0c..0bbcadf4 100644 --- a/docs/memmap_ram.md +++ b/docs/memmap_ram.md @@ -134,8 +134,8 @@ ## Page 4 |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| +|RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0414 | 3 | |RAM|page4 overlay_access | $0419-$0436 | 54 | -|RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0411 | 3 | ## Page 5&6 |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| diff --git a/memmap.md b/memmap.md index 85ec4182..e90d88ca 100644 --- a/memmap.md +++ b/memmap.md @@ -358,8 +358,8 @@ CALL:XOPEN:XRM_ROUTINE |##MEMMAP: Page 4 |MEMMAP:Type | Name | Range | Size | |MEMMAP: :------- |:----------------------------- |:----------- |:-----| +|MEMMAP:RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0414 | 3 | |MEMMAP:RAM|page4 overlay_access | $0419-$0436 | 54 | -|MEMMAP:RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0411 | 3 | |##MEMMAP: Page 5&6 |MEMMAP:Type | Name | Range | Size | |MEMMAP: :------- |:----------------------------- |:----------- |:-----| @@ -371,12 +371,12 @@ CALL:XOPEN:XRM_ROUTINE |##MEMMAP: Kernel bank 7 |MEMMAP: Type | Name | Range | Size | |MEMMAP: :-------- |:---------------------------- |:------- |:-----| -|MEMMAP:ROM|FREE |$feee-$fff0| 258 | +|MEMMAP:ROM|FREE |$ff0e-$fff0| 226 | |##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 | | +|MEMMAP:BANK0|XMALLOC (copy from kernel) | $fbc0-$fc6c | | +|MEMMAP:BANK0|XFREE (copy from kernel) | $fc6c-$fef1 | | diff --git a/run.sh b/run.sh index 1c8e249e..b5436f6f 100644 --- a/run.sh +++ b/run.sh @@ -15,8 +15,8 @@ ld65 -C src/kernel.cfg -DWITH_SDCARD_FOR_ROOT=1 tmp/kernelsd.ld65 -Ln tmp/kerne #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 cp kernel.rom $ORICUTRON_PATH/roms # cp kdebug.rom $ORICUTRON_PATH/roms @@ -25,7 +25,16 @@ 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/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/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/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/kernel.asm b/src/kernel.asm index a496504f..0cb8f9f6 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -15,7 +15,7 @@ adc #$01 .endmacro -.define VERSION "2024.1" +.define VERSION "2024.3" XMALLOC_ROUTINE_TO_RAM_OVERLAY = 39 diff --git a/tests/unit_test/mainarg.s b/tests/unit_test/mainarg.s new file mode 100644 index 00000000..32275210 --- /dev/null +++ b/tests/unit_test/mainarg.s @@ -0,0 +1,59 @@ +; 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 From 8876031c61ebe34e2a74d8939be62b1f1b3c16b4 Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 4 Jun 2024 22:03:48 +0200 Subject: [PATCH 02/49] add unittest step --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 30c7eccc..6d1143fd 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CFLAGS=-ttelestrat ASFLAGS=-ttelestrat LDFILES= -all : init kernel memmap +all : init kernel memmap unittest .PHONY : all SOURCE=src/kernel.asm From d8b42ab67540fd93a0cf481735caf9c6e5d3b52e Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 4 Jun 2024 22:09:26 +0200 Subject: [PATCH 03/49] test --- Makefile | 3 ++- tests/unit_test/mainarg.s | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6d1143fd..66a302ca 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,8 @@ kernel: $(SOURCE) unittest: @$(CC) $(CFLAGS) tests/mkdir.c -o tmkdir @$(CC) $(CFLAGS) tests/fwrite.c -o tfwrite - @$(CC) $(CFLAGS) tests/unit_test/mainarg.s -o mainarg + @$(CC) $(CFLAGS) tests/unit_test/mainarg.s -I -o 1000 --start-addr 2048 + @$(CC) $(CFLAGS) tests/unit_test/mainarg.s -I dependencies/orix-sdk/macros/ -o 1256 --start-addr 2304 memmap: @$(AS) --verbose -s -tnone --debug-info -o kernel-telestrat.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > memmap.md diff --git a/tests/unit_test/mainarg.s b/tests/unit_test/mainarg.s index 32275210..09f8fa58 100644 --- a/tests/unit_test/mainarg.s +++ b/tests/unit_test/mainarg.s @@ -20,7 +20,6 @@ start_adress: initmainargs argv, argc, 0 - nop lda argc cmp #$03 From 8e42b27b2a41b85f11e74939c89d9b16b68a7b6a Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 4 Jun 2024 22:11:22 +0200 Subject: [PATCH 04/49] test --- run.sh | 6 +++--- tests/unit_test/mainarg.s | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/run.sh b/run.sh index b5436f6f..052c22e4 100644 --- a/run.sh +++ b/run.sh @@ -29,9 +29,9 @@ 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 +# 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 diff --git a/tests/unit_test/mainarg.s b/tests/unit_test/mainarg.s index 09f8fa58..84104c5e 100644 --- a/tests/unit_test/mainarg.s +++ b/tests/unit_test/mainarg.s @@ -1,9 +1,9 @@ ; 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" +.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" From d162fdbf67b95d6c3a79ec734cf5c8e1c35cd011 Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 4 Jun 2024 22:17:12 +0200 Subject: [PATCH 05/49] fix recursive --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e7ba6f93..999dad5b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -103,6 +103,7 @@ jobs: - uses: actions/checkout@v2 with: ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + submodules: recursive - name: Set job variables id: job_vars run: | From 7054fbe914ecdee161cec611a5d9293d6086d8b0 Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 4 Jun 2024 22:18:30 +0200 Subject: [PATCH 06/49] fix --- Makefile | 2 +- tests/unit_test/mainarg.s | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 66a302ca..4c9247dd 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ kernel: $(SOURCE) unittest: @$(CC) $(CFLAGS) tests/mkdir.c -o tmkdir @$(CC) $(CFLAGS) tests/fwrite.c -o tfwrite - @$(CC) $(CFLAGS) tests/unit_test/mainarg.s -I -o 1000 --start-addr 2048 + @$(CC) $(CFLAGS) tests/unit_test/mainarg.s -I dependencies/orix-sdk/macros/ -o 1000 --start-addr 2048 @$(CC) $(CFLAGS) tests/unit_test/mainarg.s -I dependencies/orix-sdk/macros/ -o 1256 --start-addr 2304 memmap: diff --git a/tests/unit_test/mainarg.s b/tests/unit_test/mainarg.s index 84104c5e..09f8fa58 100644 --- a/tests/unit_test/mainarg.s +++ b/tests/unit_test/mainarg.s @@ -1,9 +1,9 @@ ; 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" +.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" From 7f00be55e1c2d8a0c73e47bbaa0e8cd270a4dc8c Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 4 Jun 2024 22:23:21 +0200 Subject: [PATCH 07/49] test --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 999dad5b..8b105696 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -139,8 +139,8 @@ jobs: 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 - cp mainarg ${GITHUB_WORKSPACE}/oricutron/sdcard/BIN - cat mainarg >> ${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 10 ./xvfb.sh || exit 0 From 87d8e238b8e2b5baf7daad2d7d927ffb34026506 Mon Sep 17 00:00:00 2001 From: jede Date: Mon, 13 Jan 2025 22:10:47 +0100 Subject: [PATCH 08/49] prepare 2025.1 --- Makefile | 42 +- README.md | 50 ++ VERSION | 2 +- cfg/kernel.cfg | 58 ++ cfg/kernel_bank8.cfg | 82 +++ cfg/rom.cfg | 29 + run.bat | 46 -- run.sh | 92 ++- src/functions/XWRx.asm | 2 + src/functions/bank_mng/kernel_free_bank.s | 43 ++ .../bank_mng/kernel_free_bank_by_pid.s | 64 ++ .../bank_mng/kernel_restore_banking_states.s | 24 + src/functions/bank_mng/search_free_bank.s | 99 +++ .../bank_mng/switch_to_kernel_extended.s | 34 ++ src/functions/charsets/charset.asm | 2 + src/functions/files/compute_fp_struct.asm | 2 + src/functions/files/xmkdir.asm | 17 +- src/functions/getargv.asm | 2 + src/functions/graphics/_xdrawr.asm | 1 + src/functions/graphics/_xeffhi.asm | 2 + src/functions/graphics/xbox.asm | 3 + src/functions/graphics/xcircl.asm | 2 + src/functions/graphics/xcurse.asm | 4 +- src/functions/graphics/xdrawa.asm | 2 + src/functions/graphics/xdrawr.asm | 1 + src/functions/lib_mng/XBANK_ROUTINE.s | 27 + src/functions/math/xcos.asm | 2 + src/functions/math/xtan.asm | 1 + src/functions/memory/memory_driver.asm | 5 +- src/functions/network/init_network.s | 160 +++++ src/functions/network/xclose_socket.s | 34 ++ src/functions/network/xconnect.s | 75 +++ src/functions/network/xsend.s | 34 ++ src/functions/network/xsocket.s | 132 ++++ .../process/kernel_get_struct_process_ptr.asm | 2 + src/functions/strings/xminma.asm | 11 +- src/functions/text/xink.asm | 1 + src/functions/text/xpaper.asm | 1 + src/functions/text/xscrob_xscroh.asm | 2 + src/functions/xvars/set_bank_mapping_values.s | 43 ++ src/functions/xvars/xvalues_wrapper.s | 21 + .../xvars/xvalues\303\247for_link.s" | 567 ++++++++++++++++++ src/functions/xvars/xvars.asm | 106 ++-- src/include/files.inc | 4 - src/include/kernel.inc | 137 ++++- src/include/memory.inc | 79 ++- src/include/network.inc | 27 + src/include/orix.inc | 0 src/include/process.inc | 10 +- src/include/xvars.inc | 3 + src/kernel.asm | 358 +++++------ src/kernel.inc | 186 ------ src/kernel8/.gitignore | 2 + src/kernel8/VERSION | 1 + src/kernel8/bpm.tml | 26 + .../ch395/etc/bpm/ch395/2024.4/bpm.tml | 10 + .../ch395/etc/bpm/ch395/2024.4/bpm.tpl | 10 + .../orixlibs/ch395/usr/include/asm/ch395.inc | 160 +++++ .../orixlibs/ch395/usr/include/ch395.h | 121 ++++ .../ch395/usr/share/ch395/2024.4/README.md | 20 + .../ksocket/etc/bpm/ksocket/2024.4/bpm.tml | 21 + .../ksocket/etc/bpm/ksocket/2024.4/bpm.tpl | 21 + .../ksocket/etc/bpm/ksocket/2025.1/bpm.tml | 21 + .../ksocket/etc/bpm/ksocket/2025.1/bpm.tpl | 21 + .../ksocket/etc/bpm/socket/2024.4/bpm.tml | 21 + .../ksocket/etc/bpm/socket/2024.4/bpm.tpl | 21 + .../ksocket/usr/include/asm/socket.inc | 43 ++ .../ksocket/usr/include/asm/socket.mac | 65 ++ .../orixlibs/ksocket/usr/include/socket.h | 38 ++ .../usr/share/ksocket/2024.4/README.md | 13 + .../usr/share/ksocket/2025.1/README.md | 13 + .../ksocket/usr/share/socket/2024.4/README.md | 14 + src/kernel8/src/kernel8.s | 128 ++++ src/kernel_bank0.s | 76 +++ src/kernel_main_memory.s | 158 +++++ src/memmap.asm | 49 +- src/versions/versions.inc | 3 +- tests/functions/bank_mng/search_free_bank.s | 192 ++++++ tests/functions/network/netchk.s | 475 +++++++++++++++ 79 files changed, 3914 insertions(+), 562 deletions(-) create mode 100644 cfg/kernel.cfg create mode 100644 cfg/kernel_bank8.cfg create mode 100644 cfg/rom.cfg delete mode 100644 run.bat create mode 100644 src/functions/bank_mng/kernel_free_bank.s create mode 100644 src/functions/bank_mng/kernel_free_bank_by_pid.s create mode 100644 src/functions/bank_mng/kernel_restore_banking_states.s create mode 100644 src/functions/bank_mng/search_free_bank.s create mode 100644 src/functions/bank_mng/switch_to_kernel_extended.s create mode 100644 src/functions/lib_mng/XBANK_ROUTINE.s create mode 100644 src/functions/network/init_network.s create mode 100644 src/functions/network/xclose_socket.s create mode 100644 src/functions/network/xconnect.s create mode 100644 src/functions/network/xsend.s create mode 100644 src/functions/network/xsocket.s create mode 100644 src/functions/xvars/set_bank_mapping_values.s create mode 100644 src/functions/xvars/xvalues_wrapper.s create mode 100644 "src/functions/xvars/xvalues\303\247for_link.s" create mode 100644 src/include/network.inc create mode 100644 src/include/orix.inc delete mode 100644 src/kernel.inc create mode 100644 src/kernel8/.gitignore create mode 100644 src/kernel8/VERSION create mode 100644 src/kernel8/bpm.tml create mode 100644 src/kernel8/orixlibs/ch395/etc/bpm/ch395/2024.4/bpm.tml create mode 100644 src/kernel8/orixlibs/ch395/etc/bpm/ch395/2024.4/bpm.tpl create mode 100644 src/kernel8/orixlibs/ch395/usr/include/asm/ch395.inc create mode 100644 src/kernel8/orixlibs/ch395/usr/include/ch395.h create mode 100644 src/kernel8/orixlibs/ch395/usr/share/ch395/2024.4/README.md create mode 100644 src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2024.4/bpm.tml create mode 100644 src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2024.4/bpm.tpl create mode 100644 src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2025.1/bpm.tml create mode 100644 src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2025.1/bpm.tpl create mode 100644 src/kernel8/orixlibs/ksocket/etc/bpm/socket/2024.4/bpm.tml create mode 100644 src/kernel8/orixlibs/ksocket/etc/bpm/socket/2024.4/bpm.tpl create mode 100644 src/kernel8/orixlibs/ksocket/usr/include/asm/socket.inc create mode 100644 src/kernel8/orixlibs/ksocket/usr/include/asm/socket.mac create mode 100644 src/kernel8/orixlibs/ksocket/usr/include/socket.h create mode 100644 src/kernel8/orixlibs/ksocket/usr/share/ksocket/2024.4/README.md create mode 100644 src/kernel8/orixlibs/ksocket/usr/share/ksocket/2025.1/README.md create mode 100644 src/kernel8/orixlibs/ksocket/usr/share/socket/2024.4/README.md create mode 100644 src/kernel8/src/kernel8.s create mode 100644 src/kernel_bank0.s create mode 100644 src/kernel_main_memory.s create mode 100644 tests/functions/bank_mng/search_free_bank.s create mode 100644 tests/functions/network/netchk.s diff --git a/Makefile b/Makefile index 4c9247dd..deb06352 100644 --- a/Makefile +++ b/Makefile @@ -37,18 +37,44 @@ init: kernel: $(SOURCE) @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 + @$(AS) --cpu 6502 -tnone src/functions/strings/xminma.asm -o tmp/xminma.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 + @$(AR) r tmp/kernel.lib tmp/xminma.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 + + @$(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)/ @@ -60,7 +86,7 @@ unittest: 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 + @$(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: 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 80e1c8d5..103ea540 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2024.3 \ 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/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 052c22e4..fb1a11be 100644 --- a/run.sh +++ b/run.sh @@ -1,9 +1,21 @@ #! /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 +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 +ca65 --cpu 6502 -tnone src/functions/network/xconnect.s -o tmp/xconnect.o +ca65 --cpu 6502 -tnone src/functions/network/xsend.s -o tmp/xsend.o +ca65 --cpu 6502 -tnone src/functions/network/xclose_socket.s -o tmp/xclose_socket.o + RET=$? if [ $RET != 0 ] then @@ -11,30 +23,94 @@ 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 +# 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/xclose_socket.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 +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 +echo Error +exit +fi + +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 + +# 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/start.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 +# 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 +#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 + + 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..056f9920 --- /dev/null +++ b/src/functions/bank_mng/kernel_restore_banking_states.s @@ -0,0 +1,24 @@ +.export kernel_restore_banking_states + +.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 + 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 + + 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..934c182a --- /dev/null +++ b/src/functions/bank_mng/switch_to_kernel_extended.s @@ -0,0 +1,34 @@ +.include "telestrat.inc" + +.export switch_to_kernel_extended + +.import KERNEL_SAVE_XEXEC_CURRENT_SET +.import KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM + +.segment "BANK7" + +.proc switch_to_kernel_extended + + 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 + jmp $40C + + +.endproc 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/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/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 #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 + bne @ch395_found + + jsr ch395_check_exist + + cmp #$AA + beq @ch395_found + lda #KERNEL_NETWORK_STATE_CHIP_NOT_FOUND + rts + +@ch395_found: + lda #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 + 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 #$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..b8edba55 --- /dev/null +++ b/src/functions/network/xconnect.s @@ -0,0 +1,75 @@ +.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 + 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+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 + + 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..dce4079a --- /dev/null +++ b/src/functions/network/xsocket.s @@ -0,0 +1,132 @@ +.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_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 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 + + ; 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 + + ; Looking for available socket + lda #$00 + sta socket + +@search_free_socket: + ldx #$00 + + lda #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 + 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 + + ; 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/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+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 + 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+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 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,54 @@ 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+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..154e5723 --- /dev/null +++ b/src/include/network.inc @@ -0,0 +1,27 @@ +.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_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 0cb8f9f6..9dcb1263 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -1,26 +1,23 @@ -.FEATURE labels_without_colons, pc_assignment, loose_char_term, c_comments +.FEATURE labels_without_colons, pc_assignment, loose_char_term, c_comments, 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 +.define VERSION "2025.1" -.macro INCA - clc - adc #$01 -.endmacro +.export VEXBNK +;.export KERNEL_SAVE_XEXEC_CURRENT_SET -.define VERSION "2024.3" -XMALLOC_ROUTINE_TO_RAM_OVERLAY = 39 +.import XMINMA_ROUTINE -ADIODB_LENGTH = $08 -.define KERNEL_SIZE_IOTAB $04 +; 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 .include "telestrat.inc" ; from cc65 .include "fcntl.inc" ; from cc65 @@ -28,15 +25,49 @@ 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" +.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 + + + .out "==================================================================" .out "Resume" .out "==================================================================" @@ -47,9 +78,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 @@ -72,42 +104,6 @@ RESI: 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 ; PARSE_VECTOR:=$FFF1 @@ -117,22 +113,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 @@ -176,6 +164,9 @@ 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) @@ -196,34 +187,20 @@ 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 +210,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 @@ -278,7 +239,6 @@ next1: set_todefine6: - ldx #$00 loading_vectors_telemon: @@ -305,10 +265,6 @@ loading_vectors_telemon: 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,15 +276,11 @@ 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 @@ -346,50 +298,30 @@ 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: +next5: lda KBDCOL+4 ; and #$90 beq @skip lda FLGTEL ora #$40 sta FLGTEL + @skip: -.ifdef WITH_DEBUG_BOARD - lda #'D' - sta $bb80+3 -.endif + 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 +334,39 @@ 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 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 -display_cursor: + lda #64 + sta RES+1 + + ; 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 @@ -537,12 +470,27 @@ init_malloc_busy_table: dex bpl @loop + ; **************************************************************************** + ; * Start init for network chip * + ; **************************************************************************** + ; Set stage for kernel init + + lda #KERNEL_NETWORK_STATE_NOT_INITIALIZED + ldy #$00 + ldx #$00 + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_FLAG + + + lda #KERNEL_START_NETWORK + jsr XNETWORK_START_ROUTINE + .ifdef WITH_SYSTEMD_AT_BOOT_TIME launch_systemd: lda #str_binary_systemd 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: @@ -648,10 +596,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 ? @@ -681,13 +625,13 @@ loading_code_to_page_6: 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,7 +683,7 @@ 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_END - ldx RESB + ldx #$00 XINIBU_ROUTINE: bit XLISBU_ROUTINE @@ -883,6 +827,7 @@ code_adress_47E: ; brk gestion ora #$07 sta VIA2::PRA jmp brk_management + code_adress_493: lda VIA2::PRA and #$F8 @@ -902,7 +847,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 +862,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 @@ -1074,7 +1022,7 @@ routine_to_define_16: lda IRQSVP rts - +;.include "functions/xvars/xvalues.s" .include "functions/xcrlf.asm" .include "functions/XWRx.asm" .include "functions/XWSTRx.asm" @@ -1152,7 +1100,7 @@ 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 @@ -1164,9 +1112,9 @@ reset115_labels: sta ADDRESS_READ_BETWEEN_BANK lda BUFTRV+2,x sta ADDRESS_READ_BETWEEN_BANK+1 - lda BNKOLD - sta BNK_TO_SWITCH - ldy #$00 + 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 @@ -1427,9 +1375,11 @@ telemon_display_clock_chars: ; table des vecteurs du brk vectors_telemon: ;0 + + .byt XOP0_ROUTINE ; $00 - .byt <$00,>$00 ; $1 - .byt <$00,>$00 ; 2 + .byt XBANK_ROUTINE; $1 + .byt $00,$00 ; 2 .byt <$00,>$00 .byt $00,$00 ; 4 Was XCL in telemon @@ -1774,10 +1724,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" @@ -1939,6 +1886,7 @@ XKBDAS_ROUTINE: lda (ADKBD),y bit FLGKBD bpl @skip5 + ; XMINMA FIXME cmp #$61 bcc @skip5 cmp #$7B @@ -2508,12 +2456,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 +2475,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 +2490,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 @@ -2653,11 +2606,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 +2708,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 +2789,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 +2811,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 +2838,12 @@ Le2ed: beq @S2 dec ACC1M bcs Le2ed + @S1: clc iny sty ACC1E + @S2: rts @@ -2979,6 +2921,7 @@ Le390: cmp #$20 bcs Le398 ora #$80 + Le398: ldx MENX bit ACC1EX @@ -3024,6 +2967,7 @@ display_bufedt_content: sty RES+1 ldx SCRNB ldy SCRX + Le3e3: ldx MENX @@ -3042,6 +2986,7 @@ Le3e3: bit FLGTEL ; Minitel ? bvc Le405 jsr LE656 + Le405: tya iny @@ -3052,6 +2997,7 @@ Le405: ldy #$00 jsr XADRES_ROUTINE ldy SCRDX + Le418: inc MENX bne Le3e3 @@ -3073,7 +3019,6 @@ Le45a: Le479: rts - manage_code_control: cmp #$08 bne Le5d5 @@ -4942,11 +4887,13 @@ LF9C7: lda RESB+1 bmi LF9E1 bpl LF9E4 + LF9CD: pha bit FLDT2 bpl LF9D4 inc ACC4M + LF9D4: jsr Lf242 pla @@ -4957,6 +4904,7 @@ LF9D4: LF9E1: jsr XNA1_ROUTINE + LF9E4: ldx #$00 jmp XAA1_ROUTINE @@ -4971,8 +4919,10 @@ LF9E9: sta ACCPS ldx ACC1E jmp XA1PA2_ROUTINE + LF9FC: inc RESB + LF9FE: ldy RESB lda (RES),y @@ -5163,8 +5113,10 @@ Lff00: bcc Lff00 inc ADDRESS_READ_BETWEEN_BANK+1 bcs Lff00 + Lff26: rts + read_a_code_in_15_and_y: bit RES bpl @skip @@ -5267,8 +5219,9 @@ signature: .byt $00 free_bytes: ; 26 bytes - .res $FFF0-* - .org $FFF0 + +.segment "ORIXVECT7" + .byt $01 ; Kernel type .res 7 @@ -5276,8 +5229,11 @@ free_bytes: ; 26 bytes .byt signature +; .segment "CPUVECT" + END_ROM: ; fffa +.segment "CPUVECT7" NMI: .byt start_rom ; fffc @@ -5287,4 +5243,4 @@ RESET: BRK_IRQ: .byt 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 #len + sta RES+1 + + lda #buf + jsr send +.endmacro + +.macro RECVFROM socket, buffer, len + ldx socket + lda #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..ae9b00b4 --- /dev/null +++ b/src/kernel8/src/kernel8.s @@ -0,0 +1,128 @@ + +;.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 + + ; .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 + + 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 + +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 + +; .segment "CPUVECT" + +END_ROM: +; fffa +.segment "CPUVECT" +NMI: + .byt start_rom +; fffc +RESET: + .byt start_rom +; fffe +BRK_IRQ: + .byt 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..7fd43f33 --- /dev/null +++ b/src/kernel_bank0.s @@ -0,0 +1,76 @@ +.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 + +.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: + .res 2 \ No newline at end of file diff --git a/src/kernel_main_memory.s b/src/kernel_main_memory.s new file mode 100644 index 00000000..1ed71083 --- /dev/null +++ b/src/kernel_main_memory.s @@ -0,0 +1,158 @@ +.include "telestrat.inc" +.include "include/kernel.inc" +.include "include/process.inc" +.include "include/memory.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 + + +.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_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 + + diff --git a/src/memmap.asm b/src/memmap.asm index 8ba5c085..677d771c 100644 --- a/src/memmap.asm +++ b/src/memmap.asm @@ -1,3 +1,38 @@ + +.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") .out .sprintf("|##MEMMAP: Page 0") .out "|MEMMAP:Type | Name | Range | Size |" @@ -39,10 +74,10 @@ .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|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) @@ -210,9 +245,9 @@ .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|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/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 + ; 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 + 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 + 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 + ; 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 From 823b3f615fc736b916d9d29d7c9dd34578df6f90 Mon Sep 17 00:00:00 2001 From: jede Date: Mon, 13 Jan 2025 22:37:54 +0100 Subject: [PATCH 09/49] test --- .github/workflows/main.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8b105696..be169548 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -150,7 +150,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: | @@ -162,8 +162,6 @@ jobs: mv ../cc65 . && mv ../orix-software . && mv ../orix-sdk . && mv ../md2hlp . ls -l - - upload: needs: build runs-on: ubuntu-22.04 From 24959fbfa32b407695f7622267764b8a64f61ae2 Mon Sep 17 00:00:00 2001 From: jede Date: Mon, 13 Jan 2025 23:40:07 +0100 Subject: [PATCH 10/49] update --- Makefile | 23 ++- docs/ADDRESS_READ_BETWEEN_BANK.md | 1 - docs/ADIODB_VECTOR.md | 4 - docs/ADSCR.md | 2 - docs/ADSCRH.md | 2 - docs/ADSCRL.md | 2 - docs/CURSCR.md | 2 - docs/FLGCUR.md | 2 - docs/FLGCUR_STATE.md | 2 - docs/KBDKEY.md | 2 - docs/KBDSHT.md | 2 - docs/KEYBOARD_COUNTER.md | 2 - docs/RES.md | 25 --- docs/RESB.md | 19 -- docs/RESC.md | 3 - docs/RESD.md | 2 - docs/RESE.md | 2 - docs/RESF.md | 2 - docs/RESG.md | 1 - docs/RESH.md | 1 - docs/SCRNB.md | 2 - docs/TR0.md | 8 - docs/TR1.md | 7 - docs/TR2.md | 2 - docs/TR3.md | 2 - docs/TR4.md | 6 - docs/TR5.md | 7 - docs/TR6.md | 2 - docs/TR7.md | 6 - docs/i_o_counter.md | 4 - docs/i_o_save.md | 3 - docs/memmap_ram.html | 252 +++++++++++++----------- docs/memmap_ram.md | 24 +-- docs/primitives/XGETCWD_ROUTINE.md | 1 - docs/work_channel.md | 5 - memmap.md | 256 +++---------------------- src/kernel.asm | 64 +++---- src/kernel_main_memory.s | 298 ++++++++++++++++++++++++++++- 38 files changed, 519 insertions(+), 531 deletions(-) diff --git a/Makefile b/Makefile index deb06352..d0326037 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,6 @@ kernel: $(SOURCE) @$(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 @$(AR) r tmp/kernel.lib tmp/xminma.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 @@ -55,13 +54,16 @@ kernel: $(SOURCE) @$(AR) r tmp/kernel_bank8.lib tmp/xsend.o @$(AR) r tmp/kernel_bank8.lib tmp/xclose_socket.o - @$(AS) --verbose -s -tnone --debug-info --cpu 6502 -tnone src/kernel8/src/kernel8.s -o tmp/kernel_bank8.ld65 $(ASFLAGS) > output.log + + @$(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) --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 @cp kernelsd.rom $(PATH_PACKAGE_ROM)/ @@ -79,14 +81,17 @@ kernel: $(SOURCE) @cp kernelus.rom $(PATH_PACKAGE_ROM)/ unittest: - @$(CC) $(CFLAGS) tests/mkdir.c -o tmkdir - @$(CC) $(CFLAGS) tests/fwrite.c -o tfwrite - @$(CC) $(CFLAGS) tests/unit_test/mainarg.s -I dependencies/orix-sdk/macros/ -o 1000 --start-addr 2048 - @$(CC) $(CFLAGS) tests/unit_test/mainarg.s -I dependencies/orix-sdk/macros/ -o 1256 --start-addr 2304 + @$(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 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 + @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: 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 @@ - - - - Page 0 - - + @@ -37,11 +39,108 @@ vertical-align: middle; pointer-events: none; } + + + + - - -

Page 0

+ + +

Memmap

+

Page 0

@@ -277,18 +376,18 @@

Page 0

- + - - + + - + @@ -312,7 +411,7 @@

Page 0

- + @@ -420,7 +519,7 @@

Page 0

RAM FREE$2E-$31$2E-$14
RAMptr1$32-$33ADDRESS_READ_BETWEEN_BANK$15-$16 2
RAMtmp1BNKCIB_DOUBLON $34-$34 1
RAMTIMEUDTIMEUD (used in cc65 clock function) $44-$45 2
-

Page 2

+

Page 2

@@ -488,8 +587,14 @@

Page 2

- - + + + + + + + + @@ -566,8 +671,8 @@

Page 2

- - + + @@ -644,8 +749,8 @@

Page 2

- - + + @@ -745,12 +850,18 @@

Page 2

- + + + + + + + @@ -763,12 +874,6 @@

Page 2

- - - - - - @@ -799,7 +904,7 @@

Page 2

RAM FREE$0209-$020F6$0209-$020C4
RAMFLGTEL$020D-$020D1
RAM
RAM SCRY$0224-$02281$0224-$02274
RAM
RAM SCRTXT$0256-$025C604$0256-$02604
RAM
RAMkernel_malloc_free_chunk_size_lowkernel_malloc_free_chunk_size $02BA-$02C3 10
RAMkernel_xmalloc_call$02C4-$02EB39
RAM FLGRST $02EE-$02EE 1
RAMkernel_xmalloc_call$02C4-$02EB39
RAM FREE $02EC-$02ED 2
-

Page 3

+

Page 3

@@ -818,7 +923,7 @@

Page 3

-

Page 4

+

Page 4

@@ -831,13 +936,13 @@

Page 4

- - - + + +
RAMpage4 overlay_access$0419-$043654page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY$0411-$04143
-

Page 5&6

+

Page 5&6

@@ -850,7 +955,7 @@

Page 5&6

- + @@ -879,76 +984,9 @@

Page 5&6

-
RAMBUFNOMFREE $0517-$0525 14
163
-

Kernel bank 7

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TypeNameRangeSize
ROMFREE$feea-$fff0262
#Bank 0
TypeNameRangeSize
------------------------------------------------
BANK0BUFBUF$c080-$c0b654
BANK0BUFROU$c500-$c54e
BANK0TELEMON_KEYBOARD_BUFFER_BEGIN$c5c4-$c680
BANK0XMALLOC (copy from kernel)$fb9c-$fc48
BANK0XFREE (copy from kernel)$fc48-$fecd
- - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/docs/memmap_ram.md b/docs/memmap_ram.md index 0bbcadf4..ed12361d 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|FREE | $2E-$31 | | -|RAM|ptr1 | $32-$33 | 2 | -|RAM|tmp1 | $34-$34 | 1 | +|RAM|FREE | $2E-$14 | | +|RAM|ADDRESS_READ_BETWEEN_BANK | $15-$16 | 2 | +|RAM|BNKCIB_DOUBLON | $34-$34 | 1 | |RAM|FREE | $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|FREE | $0209-$020F | 6 | +|RAM|FREE | $0209-$020C | 4 | +|RAM|FLGTEL | $020D-$020D | 1 | |RAM|TIMED | $0210-$0210 | 1 | |RAM|TIMES | $0211-$0211 | 1 | |RAM|TIMEM | $0212-$0212 | 1 | @@ -135,7 +138,6 @@ |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| |RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0414 | 3 | -|RAM|page4 overlay_access | $0419-$0436 | 54 | ## 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|FREE |$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|XFREE (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 e90d88ca..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 | @@ -359,7 +166,6 @@ CALL:XOPEN:XRM_ROUTINE |MEMMAP:Type | Name | Range | Size | |MEMMAP: :------- |:----------------------------- |:----------- |:-----| |MEMMAP:RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0414 | 3 | -|MEMMAP:RAM|page4 overlay_access | $0419-$0436 | 54 | |##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 |$ff0e-$fff0| 226 | -|##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) | $fbc0-$fc6c | | -|MEMMAP:BANK0|XFREE (copy from kernel) | $fc6c-$fef1 | | diff --git a/src/kernel.asm b/src/kernel.asm index 9dcb1263..01e4af76 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -1,24 +1,7 @@ -.FEATURE labels_without_colons, pc_assignment, loose_char_term, c_comments, org_per_seg - +.FEATURE labels_without_colons, pc_assignment, loose_char_term, org_per_seg .define VERSION "2025.1" -.export VEXBNK -;.export KERNEL_SAVE_XEXEC_CURRENT_SET - - -.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 - .include "telestrat.inc" ; from cc65 .include "fcntl.inc" ; from cc65 .include "stdio.inc" ; from cc65 @@ -35,6 +18,26 @@ .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 @@ -61,12 +64,20 @@ .import BUSY_BANK_TABLE_RAM .import kernel_end_of_memory_for_kernel - .import KERNEL_NETWORK_FLAG .import XBANK_ROUTINE +; .import RESC +; .import RESD +; .import RESE +; .import RESF +; .import RESG +; .import RESH +; .import RESI +; .import RESCONCAT + .out "==================================================================" .out "Resume" @@ -137,6 +148,7 @@ start_rom: stz $500,x inx bne @nloopc02 + stz KERNEL_BANK_AVAILABLE .p02 .else inx @@ -151,9 +163,9 @@ start_rom: sta $500,x inx bne @nloop + sta KERNEL_BANK_AVAILABLE .endif - ; Trying to mount .ifdef WITH_SDCARD_FOR_ROOT @@ -188,17 +200,9 @@ start_rom: sta RETURN_BANK_READ_BYTE_FROM_OVERLAY_RAM jsr init_screens - - - jsr XLOADCHARSET_ROUTINE - - - jsr XALLKB_ROUTINE - - ldx #$00 @myloop: @@ -343,13 +347,9 @@ don_t_display_telemon_signature: ldy #>str_tofix BRK_TELEMON XWSTR0 - - don_t_display_signature: jsr routine_to_define_19 - - lda #64 sta RES+1 diff --git a/src/kernel_main_memory.s b/src/kernel_main_memory.s index 1ed71083..22617558 100644 --- a/src/kernel_main_memory.s +++ b/src/kernel_main_memory.s @@ -2,6 +2,11 @@ .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 @@ -29,6 +34,39 @@ .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 + + +.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 @@ -51,13 +89,17 @@ KERNEL_SAVE_XEXEC_CURRENT_SET: .res 1 KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM: .res 1 -;KERNEL +; KERNEL_BANK_AVAILABLE is used to know if a bank is available or not (example : Kernel extended) +KERNEL_BANK_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 +.org SCRX + 1 BUSY_BANK_TABLE_RAM: .res 3 @@ -144,6 +186,7 @@ BUFEDT_END: KERNEL_DRIVER_MEMORY: .res 163 + KERNEL_DRIVER_MEMORY_END: kernel_end_of_memory_for_kernel: @@ -156,3 +199,254 @@ kernel_end_of_variables_after_BUFEDT: .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 From 23b7cfa482154e1dec222b4c6523b54fc4e8848a Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 14 Jan 2025 23:00:33 +0100 Subject: [PATCH 11/49] test --- Makefile | 5 +- docs/memmap_ram.md | 2 +- src/kernel.asm | 1 + src/memmap.asm | 254 --------------------------------------------- 4 files changed, 6 insertions(+), 256 deletions(-) diff --git a/Makefile b/Makefile index d0326037..b962ea53 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,10 @@ ASFLAGS=-ttelestrat LDFILES= all : init kernel memmap unittest -.PHONY : all +.PHONY : prepare_tmp all + +prepare_tmp: + @mkdir -p tmp/ SOURCE=src/kernel.asm diff --git a/docs/memmap_ram.md b/docs/memmap_ram.md index ed12361d..da96d42f 100644 --- a/docs/memmap_ram.md +++ b/docs/memmap_ram.md @@ -77,7 +77,7 @@ |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|FREE | $0209-$020C | 4 | +|RAM|FREE | $020A-$020C | 3 | |RAM|FLGTEL | $020D-$020D | 1 | |RAM|TIMED | $0210-$0210 | 1 | |RAM|TIMES | $0211-$0211 | 1 | diff --git a/src/kernel.asm b/src/kernel.asm index 01e4af76..60a78a00 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -68,6 +68,7 @@ .import XBANK_ROUTINE +.import KERNEL_BANK_AVAILABLE ; .import RESC ; .import RESD diff --git a/src/memmap.asm b/src/memmap.asm index 677d771c..8b137891 100644 --- a/src/memmap.asm +++ b/src/memmap.asm @@ -1,255 +1 @@ -.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") -.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,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) - -; 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 ) - - - From 13eae42a1dfb8fb7df684fd3e4e4a836a0cc04e9 Mon Sep 17 00:00:00 2001 From: jede Date: Sun, 19 Jan 2025 20:37:11 +0100 Subject: [PATCH 12/49] fix/update --- Makefile | 2 + run.sh | 25 +++++- .../bank_mng/kernel_restore_banking_states.s | 9 ++- .../bank_mng/switch_to_kernel_extended.s | 14 ++-- src/functions/network/close_sockets_by_pid.s | 74 +++++++++++++++++ src/functions/network/init_network.s | 2 +- src/functions/network/xconnect.s | 4 +- src/functions/network/xsocket.s | 20 +++-- src/functions/process/kernel_kill_process.asm | 20 ++++- src/include/network.inc | 8 +- src/kernel.asm | 80 +++++++++++-------- src/kernel8/src/kernel8.s | 10 +++ src/kernel_bank0.s | 8 +- src/kernel_main_memory.s | 4 +- 14 files changed, 214 insertions(+), 66 deletions(-) create mode 100644 src/functions/network/close_sockets_by_pid.s diff --git a/Makefile b/Makefile index b962ea53..93d70c82 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,7 @@ kernel: $(SOURCE) @$(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 @$(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 @@ -56,6 +57,7 @@ kernel: $(SOURCE) @$(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 diff --git a/run.sh b/run.sh index fb1a11be..83499520 100644 --- a/run.sh +++ b/run.sh @@ -12,6 +12,15 @@ ca65 --cpu 6502 -tnone src/functions/bank_mng/kernel_restore_banking_states.s -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 +ca65 --cpu 6502 -tnone src/functions/network/close_sockets_by_pid.s -o tmp/close_sockets_by_pid.o + +RET=$? +if [ $RET != 0 ] +then + echo Error + exit +fi + ca65 --cpu 6502 -tnone src/functions/network/xconnect.s -o tmp/xconnect.o ca65 --cpu 6502 -tnone src/functions/network/xsend.s -o tmp/xsend.o ca65 --cpu 6502 -tnone src/functions/network/xclose_socket.s -o tmp/xclose_socket.o @@ -41,20 +50,30 @@ 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/xclose_socket.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 + 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 #" diff --git a/src/functions/bank_mng/kernel_restore_banking_states.s b/src/functions/bank_mng/kernel_restore_banking_states.s index 056f9920..2ab3c3e8 100644 --- a/src/functions/bank_mng/kernel_restore_banking_states.s +++ b/src/functions/bank_mng/kernel_restore_banking_states.s @@ -1,16 +1,23 @@ .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 @@ -20,5 +27,3 @@ cli rts .endproc - - diff --git a/src/functions/bank_mng/switch_to_kernel_extended.s b/src/functions/bank_mng/switch_to_kernel_extended.s index 934c182a..79b93254 100644 --- a/src/functions/bank_mng/switch_to_kernel_extended.s +++ b/src/functions/bank_mng/switch_to_kernel_extended.s @@ -1,6 +1,8 @@ .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 @@ -8,6 +10,11 @@ .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 @@ -20,7 +27,6 @@ lda $342 sta KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM and #%11011111 - sei sta $342 @@ -28,7 +34,5 @@ lda #$04 sta $343 pla - jmp $40C - - -.endproc + rts +.endproc \ No newline at end of file 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..fc31a648 --- /dev/null +++ b/src/functions/network/close_sockets_by_pid.s @@ -0,0 +1,74 @@ +.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 "../../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 + + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + + ldx TR1 + ldy #$00 + 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 #$08 + 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 index 661d0f99..936580c8 100644 --- a/src/functions/network/init_network.s +++ b/src/functions/network/init_network.s @@ -48,7 +48,7 @@ ldy #>KERNEL_NETWORK_FLAG sta ADDRESS_READ_BETWEEN_BANK_DOUBLON - sty ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 ldx #$00 ldy #$00 diff --git a/src/functions/network/xconnect.s b/src/functions/network/xconnect.s index b8edba55..e069b68f 100644 --- a/src/functions/network/xconnect.s +++ b/src/functions/network/xconnect.s @@ -21,7 +21,7 @@ type := TR3 sty ip - stx ip+1 + stx ip + 1 lda #KERNEL_NETWORK_SOCKET_LIST sta ADDRESS_READ_BETWEEN_BANK_DOUBLON - sty ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 ldx #$00 ldy socket diff --git a/src/functions/network/xsocket.s b/src/functions/network/xsocket.s index dce4079a..739e6d28 100644 --- a/src/functions/network/xsocket.s +++ b/src/functions/network/xsocket.s @@ -17,7 +17,8 @@ .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 @@ -68,7 +69,7 @@ ldy #>KERNEL_NETWORK_SOCKET_LIST sta ADDRESS_READ_BETWEEN_BANK_DOUBLON - sty ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 ldy socket MEMORY_GET_VALUE_FROM_BANK ; A contains the value cmp #$00 @@ -85,26 +86,29 @@ rts @socketfound: -; ; A contains the id of the socket +; A contains the id of the socket ; save TYPE (SOCK_STREAM etc) ldy socket ; Get socket id (index) - lda type ; Type - ldx #$00 ; BANK - + 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 diff --git a/src/functions/process/kernel_kill_process.asm b/src/functions/process/kernel_kill_process.asm index f2e25648..4bb44f7d 100644 --- a/src/functions/process/kernel_kill_process.asm +++ b/src/functions/process/kernel_kill_process.asm @@ -26,6 +26,18 @@ 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 +59,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/include/network.inc b/src/include/network.inc index 154e5723..3c24d865 100644 --- a/src/include/network.inc +++ b/src/include/network.inc @@ -7,11 +7,9 @@ .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_SEND_NETWORK $09 +.define KERNEL_SOCKET_CLOSE_NETWORK $0A +.define KERNEL_SOCKET_CLOSE_FROM_PID_NETWORK $0B .define KERNEL_NETWORK_STATE_NOT_INITIALIZED $00 diff --git a/src/kernel.asm b/src/kernel.asm index 60a78a00..837dc8ac 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -64,12 +64,15 @@ .import BUSY_BANK_TABLE_RAM .import kernel_end_of_memory_for_kernel -.import KERNEL_NETWORK_FLAG +.import KERNEL_NETWORK_FLAG -.import XBANK_ROUTINE +.import XBANK_ROUTINE -.import KERNEL_BANK_AVAILABLE +.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 @@ -149,7 +152,7 @@ start_rom: stz $500,x inx bne @nloopc02 - stz KERNEL_BANK_AVAILABLE + stz KERNEL_BANK_EXTENDED_AVAILABLE .p02 .else inx @@ -164,7 +167,7 @@ start_rom: sta $500,x inx bne @nloop - sta KERNEL_BANK_AVAILABLE + sta KERNEL_BANK_EXTENDED_AVAILABLE .endif ; Trying to mount @@ -288,12 +291,6 @@ set_buffers: ;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 @@ -303,12 +300,8 @@ skip: dex bpl @loop - - jsr init_keyboard - - next5: lda KBDCOL+4 ; and #$90 @@ -318,9 +311,6 @@ next5: sta FLGTEL @skip: - - - lda #XKBD ; Setup keyboard on channel 0 BRK_TELEMON XOP0 @@ -386,7 +376,7 @@ don_t_display_signature: 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 @@ -471,10 +461,9 @@ init_malloc_busy_table: dex bpl @loop - ; **************************************************************************** - ; * Start init for network chip * - ; **************************************************************************** - ; Set stage for kernel init + ; Checking of extended ROM is here + ;KERNEL_BANK_AVAILABLE + lda #KERNEL_NETWORK_STATE_NOT_INITIALIZED ldy #$00 @@ -482,9 +471,39 @@ init_malloc_busy_table: 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_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 @@ -689,7 +703,7 @@ XDEFBU_ROUTINE: lda #TELEMON_KEYBOARD_BUFFER_BEGIN ; Get high adress of the buffer - sta RES+1 + sta RES + 1 lda #TELEMON_KEYBOARD_BUFFER_END @@ -909,13 +923,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 @@ -1016,7 +1030,7 @@ routine_to_define_16: 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 diff --git a/src/kernel8/src/kernel8.s b/src/kernel8/src/kernel8.s index ae9b00b4..d76bf10d 100644 --- a/src/kernel8/src/kernel8.s +++ b/src/kernel8/src/kernel8.s @@ -27,6 +27,7 @@ .import ksocket_close .import xconnect .import XSOCKET_CLOSE_ROUTINE +.import close_sockets_by_pid ; .segment "BANK8" .org $C000 @@ -65,6 +66,9 @@ XBANK: 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: @@ -97,6 +101,12 @@ XBANK: @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" diff --git a/src/kernel_bank0.s b/src/kernel_bank0.s index 7fd43f33..df85fc00 100644 --- a/src/kernel_bank0.s +++ b/src/kernel_bank0.s @@ -11,6 +11,8 @@ .export KERNEL_NETWORK_SOCKET_LIST .export KERNEL_NETWORK_SOCKET_DOMAIN .export KERNEL_NETWORK_SOURCE_PORT +.export KERNEL_NETWORK_SOCKET_PID + .include "telestrat.inc" @@ -72,5 +74,7 @@ KERNEL_NETWORK_SOCKET_LIST: .res 8 KERNEL_NETWORK_SOCKET_DOMAIN: .res 8 -KERNEL_NETWORK_SOURCE_PORT: - .res 2 \ No newline at end of file +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 index 22617558..d9592081 100644 --- a/src/kernel_main_memory.s +++ b/src/kernel_main_memory.s @@ -44,6 +44,8 @@ .export RESCONCAT +.export KERNEL_BANK_EXTENDED_AVAILABLE + .import code_adress_419 .import code_adress_436 @@ -90,7 +92,7 @@ KERNEL_SAVE_XEXEC_CURRENT_SET: 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_AVAILABLE: +KERNEL_BANK_EXTENDED_AVAILABLE: .res 1 KERNEL_FREE1_MEMORY: From cf8308e76af74197c3e45db817f93b8545bc9a1e Mon Sep 17 00:00:00 2001 From: jede Date: Sun, 19 Jan 2025 22:37:33 +0100 Subject: [PATCH 13/49] fix test --- Makefile | 5 +++- run.sh | 27 ++++++++++++------- src/functions/network/close_sockets_by_pid.s | 15 ++++++----- src/functions/network/init_network.s | 7 +++++ src/functions/network/xsocket.s | 16 +++++++++-- src/functions/process/kernel_kill_process.asm | 2 ++ src/include/memory.inc | 1 - src/kernel.asm | 10 +++---- src/kernel8/src/kernel8.s | 1 - 9 files changed, 58 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 93d70c82..91353f16 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,11 @@ init: @mkdir -p build/usr/src/kernel/ kernel: $(SOURCE) + @mkdir -p tmp/ @echo Rom are built in $(PATH_PACKAGE_ROM) - @echo Build kernelsd.rom for Twilighte board + @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/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 diff --git a/run.sh b/run.sh index 83499520..ffadf332 100644 --- a/run.sh +++ b/run.sh @@ -6,23 +6,30 @@ ORICUTRON_PATH="/mnt/c/Users/plifp/OneDrive/oric/projets/jedeoric/oricutron_assi CA65_INC=/usr/share/cc65/asminc/ # -DWITH_DEBUG=1 + +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 -ca65 --cpu 6502 -tnone src/functions/network/close_sockets_by_pid.s -o tmp/close_sockets_by_pid.o - -RET=$? -if [ $RET != 0 ] -then - echo Error - exit -fi +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/xconnect.s -o tmp/xconnect.o -ca65 --cpu 6502 -tnone src/functions/network/xsend.s -o tmp/xsend.o ca65 --cpu 6502 -tnone src/functions/network/xclose_socket.s -o tmp/xclose_socket.o RET=$? diff --git a/src/functions/network/close_sockets_by_pid.s b/src/functions/network/close_sockets_by_pid.s index fc31a648..6dc81888 100644 --- a/src/functions/network/close_sockets_by_pid.s +++ b/src/functions/network/close_sockets_by_pid.s @@ -11,6 +11,7 @@ .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" @@ -26,14 +27,15 @@ sta TR1 @restart: - lda #KERNEL_NETWORK_SOCKET_PID + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON - sty ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 - ldx TR1 - ldy #$00 + 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 @@ -42,13 +44,14 @@ @compute: inc TR1 lda TR1 - cmp #$08 + + cmp #NETWORK_MAX_SOCKET beq @exit bne @restart - @close_socket: lda TR1 ; Socket ID + jsr ch395_close_socket_sn ; Set to 0 diff --git a/src/functions/network/init_network.s b/src/functions/network/init_network.s index 936580c8..d79121c2 100644 --- a/src/functions/network/init_network.s +++ b/src/functions/network/init_network.s @@ -23,6 +23,7 @@ .include "../../include/memory.inc" .proc init_network + ; Returns KERNEL_NETWORK_FULLY_STARTED if network is started lda #KERNEL_NETWORK_FLAG @@ -33,6 +34,11 @@ 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 @@ -44,6 +50,7 @@ rts @ch395_found: + ; FIXME SHould not be done here lda #KERNEL_NETWORK_FLAG diff --git a/src/functions/network/xsocket.s b/src/functions/network/xsocket.s index 739e6d28..ae1d5141 100644 --- a/src/functions/network/xsocket.s +++ b/src/functions/network/xsocket.s @@ -4,12 +4,14 @@ .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 @@ -32,7 +34,7 @@ ;;@modifyMEM_TR6 ;;@modifyMEM_TR5 ;;@returnsX The socket id - ;;@returnsA if != -1 then it returns socket id. -1 is return if all socket are used + ;;@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 @@ -58,6 +60,16 @@ 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 @@ -81,7 +93,6 @@ bne @search_free_socket ; Error, return INVALID - lda #INVALID_SOCKET rts @@ -105,6 +116,7 @@ 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 diff --git a/src/functions/process/kernel_kill_process.asm b/src/functions/process/kernel_kill_process.asm index 4bb44f7d..21c24753 100644 --- a/src/functions/process/kernel_kill_process.asm +++ b/src/functions/process/kernel_kill_process.asm @@ -32,6 +32,8 @@ cmp #128 bne @do_not_destroy_socket + + lda #KERNEL_SOCKET_CLOSE_FROM_PID_NETWORK jsr XNETWORK_START_ROUTINE diff --git a/src/include/memory.inc b/src/include/memory.inc index 9b9b8084..5ac8327e 100644 --- a/src/include/memory.inc +++ b/src/include/memory.inc @@ -94,7 +94,6 @@ 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 diff --git a/src/kernel.asm b/src/kernel.asm index 837dc8ac..612d4323 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -188,8 +188,8 @@ start_rom: 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: @@ -342,7 +342,7 @@ don_t_display_signature: jsr routine_to_define_19 lda #64 - sta RES+1 + sta RES + 1 ; Initialize banks states to Empty @L1: @@ -350,7 +350,7 @@ don_t_display_signature: ldx #$00 ; BANK ldy #$00 ; Offset to write MEMORY_PUT_VALUE_TO_BANK KERNEL_BANK_MANAGEMENT - dec RES+1 + dec RES + 1 bne @L1 ; Displays cursor @@ -477,7 +477,7 @@ init_malloc_busy_table: ldy #>($FFF0+1) sta ADDRESS_READ_BETWEEN_BANK_DOUBLON - sty ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 ldx #$04 ldy #$00 diff --git a/src/kernel8/src/kernel8.s b/src/kernel8/src/kernel8.s index d76bf10d..6b635bc3 100644 --- a/src/kernel8/src/kernel8.s +++ b/src/kernel8/src/kernel8.s @@ -35,7 +35,6 @@ start_rom: jmp XBANK XBANK: - cmp #KERNEL_ALLOCATE_BANK beq @allocate_bank From 1b040da97c43bd340d650004d65466d8703637b9 Mon Sep 17 00:00:00 2001 From: jede Date: Sun, 19 Jan 2025 23:13:09 +0100 Subject: [PATCH 14/49] fix --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 91353f16..190c0746 100644 --- a/Makefile +++ b/Makefile @@ -44,10 +44,19 @@ kernel: $(SOURCE) @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 From 6dbb66459d4acc5e464b7773be6d538d661d03ea Mon Sep 17 00:00:00 2001 From: jede Date: Sun, 19 Jan 2025 23:19:53 +0100 Subject: [PATCH 15/49] fix --- src/rom_cmd.s | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 src/rom_cmd.s 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 From 431d3346e8e4e5ae793f4dd09ad36c926dfde9cd Mon Sep 17 00:00:00 2001 From: jede Date: Mon, 20 Jan 2025 22:21:48 +0100 Subject: [PATCH 16/49] update --- .github/workflows/main.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index be169548..0c6a82aa 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,10 +102,11 @@ 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 @@ -123,8 +132,12 @@ jobs: - 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 @@ -164,7 +177,7 @@ jobs: upload: needs: build - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 defaults: run: shell: bash @@ -172,6 +185,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 From 94f30e9b16c8f9c2cee6856e9a521bec41719a26 Mon Sep 17 00:00:00 2001 From: jede Date: Mon, 20 Jan 2025 22:30:10 +0100 Subject: [PATCH 17/49] fix --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 190c0746..2af5b356 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,7 @@ init: kernel: $(SOURCE) @mkdir -p tmp/ + @cd src/kernel8 && bpm update && cd .. @echo Rom are built in $(PATH_PACKAGE_ROM) @echo "########################################################" @echo "# Build kernelsd.rom for Twilighte board #" From 99bf267070d0cf5d13ba9726d095f3a306a1b9f5 Mon Sep 17 00:00:00 2001 From: jede Date: Mon, 20 Jan 2025 22:50:07 +0100 Subject: [PATCH 18/49] fix --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0c6a82aa..3489d14a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -128,7 +128,8 @@ jobs: md2hlp/**/* orix-software/**/* oricutron/**/* - key: ${{ secrets.CACHE_ID }}-orix-sdk_ + bpm/**/* + key: ${{ secrets.CACHE_ID }}-orix-sdk - name: Prepare environment for project run: | From 757bc5ff92044af366d6fe8fd86fe61a89d7d167 Mon Sep 17 00:00:00 2001 From: jede Date: Sat, 25 Jan 2025 21:59:56 +0100 Subject: [PATCH 19/49] fix/bugs --- src/functions/network/xconnect.s | 2 + src/kernel.asm | 446 ++++++++++++++++--------------- 2 files changed, 227 insertions(+), 221 deletions(-) diff --git a/src/functions/network/xconnect.s b/src/functions/network/xconnect.s index e069b68f..0d8b2eb2 100644 --- a/src/functions/network/xconnect.s +++ b/src/functions/network/xconnect.s @@ -15,6 +15,7 @@ .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 @@ -72,4 +73,5 @@ ldx ip+1 jmp kconnect + .endproc diff --git a/src/kernel.asm b/src/kernel.asm index 612d4323..71c7bb42 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -113,11 +113,11 @@ 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 + .res 2 ; ACC1S + 1 $66 ; PARSE_VECTOR:=$FFF1 @@ -231,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: @@ -262,13 +262,13 @@ 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 @@ -303,7 +303,7 @@ skip: jsr init_keyboard next5: - lda KBDCOL+4 ; + lda KBDCOL + 4 ; and #$90 beq @skip lda FLGTEL @@ -379,31 +379,31 @@ don_t_display_signature: 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 @@ -416,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 - 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 - 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 @@ -457,7 +457,7 @@ 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 @@ -473,8 +473,8 @@ init_malloc_busy_table: jsr switch_to_kernel_extended_fill_register - lda #<($FFF0+1) ; Offset magic token - ldy #>($FFF0+1) + lda #<($FFF0 + 1) ; Offset magic token + ldy #>($FFF0 + 1) sta ADDRESS_READ_BETWEEN_BANK_DOUBLON sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 @@ -497,7 +497,6 @@ init_malloc_busy_table: lda #KERNEL_START_NETWORK jsr XNETWORK_START_ROUTINE - @not_extended_bank_found: jsr kernel_restore_banking_states_register cli @@ -509,7 +508,7 @@ launch_systemd: 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 @@ -627,14 +626,14 @@ 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 @@ -723,7 +722,7 @@ XTSTBU_ROUTINE: skip2003: sec - jmp ORIX_MEMORY_DRIVER_ADDRESS+9 + jmp ORIX_MEMORY_DRIVER_ADDRESS + 9 XLISBU_ROUTINE: bit XLISBU_ROUTINE @@ -733,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 @@ -913,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 @@ -946,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: @@ -962,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 @@ -990,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 @@ -1021,13 +1020,13 @@ 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 @@ -1067,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) @@ -1099,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 @@ -1118,15 +1117,15 @@ brk_management: 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 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 @@ -1142,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 ; @@ -1196,7 +1195,7 @@ timeud_next: lda TIMEUD bne @skip - dec TIMEUD+1 + dec TIMEUD + 1 @skip: skipme12: dec TIMEUD @@ -1216,7 +1215,7 @@ skipme12: inc TIMES lda TIMEUS bne @L1 - dec TIMEUS+1 + dec TIMEUS + 1 @L1: dec TIMEUS lda TIMES @@ -1252,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: @@ -1286,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: @@ -1326,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 @@ -1450,14 +1449,14 @@ vectors_telemon: .byt XOPEN_ROUTINE ; $30 .byt <$00,>$00 ; .byt $00,$00 ; Old XEDTIN $32 - .byt XECRPR_ROUTINE ; XECRPR $33 - .byt XCOSCR_ROUTINE ; XCOSCR $34 - .byt XCSSCR_ROUTINE ; $35 XCSSCR - .byt XSCRSE_ROUTINE ; $36 - .byt XSCROH_ROUTINE ; $37 - .byt XSCROB_ROUTINE ; $38 XSCROB - .byt XSCRNE_ROUTINE ; $39 - .byt XCLOSE_ROUTINE ; $3a + .byt XECRPR_ROUTINE ; XECRPR $33 + .byt XCOSCR_ROUTINE ; XCOSCR $34 + .byt XCSSCR_ROUTINE ; $35 XCSSCR + .byt XSCRSE_ROUTINE ; $36 + .byt XSCROH_ROUTINE ; $37 + .byt XSCROB_ROUTINE ; $38 XSCROB + .byt XSCRNE_ROUTINE ; $39 + .byt XCLOSE_ROUTINE ; $3a .byt XWRITEBYTES_ROUTINE ; nothing $3b .byt <_xreclk,>_xreclk ; $3c .byt <_xclcl,>_xclcl ; $3d @@ -1536,14 +1535,14 @@ vectors_telemon_second_table: .byt XADNXT_ROUTINE .byt XINTEG_ROUTINE .byt $00,$00 - .byt XHRSCG_ROUTINE - .byt XHRSCD_ROUTINE - .byt XHRSCB_ROUTINE - .byt XHRSCH_ROUTINE - .byt XHRSSE_ROUTINE - .byt XDRAWA_ROUTINE - .byt XDRAWR_ROUTINE - .byt XCIRCL_ROUTINE + .byt XHRSCG_ROUTINE + .byt XHRSCD_ROUTINE + .byt XHRSCB_ROUTINE + .byt XHRSCH_ROUTINE + .byt XHRSSE_ROUTINE + .byt XDRAWA_ROUTINE + .byt XDRAWR_ROUTINE + .byt XCIRCL_ROUTINE .byt XCURSE_ROUTINE .byt XCURMO_ROUTINE .byt XPAPER_ROUTINE @@ -1593,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 @@ -1603,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 @@ -1621,7 +1620,7 @@ Lcd20: inx @skip: sta RESB - stx RESB+1 + stx RESB + 1 lda #$20 sta DEFAFF pla @@ -1634,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 @@ -1663,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 @@ -1762,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 @@ -1776,7 +1778,7 @@ XCHECK_VERIFY_USBDRIVE_READY_ROUTINE: @trim: inc RES bne @next - inc RES+1 + inc RES + 1 @next: jmp @L1 .endproc @@ -1871,7 +1873,7 @@ XKBDAS_ROUTINE: bcc @loop @skip: - lda KBDCOL+4 + lda KBDCOL + 4 tax and #$90 beq @skip2 @@ -1913,7 +1915,7 @@ XKBDAS_ROUTINE: txa and #$04 beq next68 - and KBDCOL+7 + and KBDCOL + 7 beq @skip6 lda #$80 sta KBDCTC @@ -2039,7 +2041,7 @@ next22: ldy #$08 @L1: - lda SCRTRA+5,y + lda SCRTRA + 5,y bne out1 cpy #$06 @@ -2057,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 @@ -2084,6 +2086,7 @@ skip2005: lda #$40 sta VIA::IER rts + @skip3: lda VIA::ACR ora #$40 @@ -2092,7 +2095,7 @@ skip2005: lda #$a8 ldy #$61 sta VIA::T1 - sty VIA::T1+1 + sty VIA::T1 + 1 lda #$c0 sta VIA::IER @@ -2108,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 sta ADKBD - sty ADKBD+1 ; FIXME + sty ADKBD + 1 ; FIXME lsr KBDFLG_KEY lda #$C0 sta FLGKBD @@ -2137,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: @@ -2168,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 @@ -2226,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 ; @@ -2237,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 @@ -2248,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 @@ -2305,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 @@ -2323,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 @@ -2350,7 +2353,7 @@ display_char: @skip: tya - ora SCRNB+1 + ora SCRNB + 1 sta CURSCR ldy SCRX sta (ADSCR),y @@ -2359,7 +2362,7 @@ display_char: Ldc9a: and #$08 beq @S1 - lda SCRNB+1 + lda SCRNB + 1 bmi LDC46 cmp #$40 bcc LDC46 @@ -2381,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 @@ -2393,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 @@ -2529,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 !) @@ -2564,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 @@ -2977,9 +2981,9 @@ 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 @@ -3112,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 @@ -3171,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 @@ -3211,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. @@ -3227,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 ; @@ -3248,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) @@ -3350,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: @@ -3366,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 @@ -3378,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 @@ -3401,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 @@ -3626,7 +3630,7 @@ LEFC2: bmi mantisse_A tay lda ACC1EX - lsr RES+1,x + lsr RES + 1,x jsr LF0FC next802: @@ -3645,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 @@ -3693,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 @@ -3782,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 @@ -3799,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 @@ -3890,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 @@ -3919,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 @@ -4036,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: @@ -4066,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 @@ -4076,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 @@ -4465,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 @@ -4793,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: @@ -4818,7 +4822,7 @@ XDECA1_ROUTINE: bne LF953 .byte $2C LF94C: - stx RESB+1 + stx RESB + 1 LF94E: jsr LF9FC LF951: @@ -4899,7 +4903,7 @@ LF9C0: dec FLDT1 bne LF9C0 LF9C7: - lda RESB+1 + lda RESB + 1 bmi LF9E1 bpl LF9E4 @@ -4979,7 +4983,7 @@ XGOKBD_ROUTINE: .endif ldy #$00 sty RES - sta RES+1 + sta RES + 1 tya @loop: @@ -4991,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 sta RESB - sty RESB+1 + sty RESB + 1 ldy #$00 loop70: @@ -5008,7 +5012,7 @@ loop70: tax inc RESB bne @L1 - inc RESB+1 + inc RESB + 1 @L1: jsr routine_to_define_23 @@ -5036,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 @@ -5063,7 +5067,7 @@ next81: sta (RES),y iny bne @skip - inc RES+1 + inc RES + 1 @skip: pla @@ -5103,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 @@ -5113,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 @@ -5126,7 +5130,7 @@ 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: @@ -5184,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 From bbb6d5e63a4a56eec76857e831bc891364cf9335 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 29 Jan 2025 22:53:09 +0100 Subject: [PATCH 20/49] fix get_inf for network --- Makefile | 4 ++-- buildr64.sh | 6 ++++-- run.sh | 3 ++- src/functions/lib_mng/XBANK_ROUTINE.s | 2 ++ src/functions/network/init_network.s | 10 +++++++-- src/kernel.asm | 2 ++ src/kernel8/bpm.tml | 1 + src/libs/ch376-lib/src/ch376.s | 2 +- tests/functions/network/netchk.s | 30 +++++++++++++++++---------- 9 files changed, 41 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 2af5b356..ea222170 100644 --- a/Makefile +++ b/Makefile @@ -93,8 +93,8 @@ kernel: $(SOURCE) @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 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 + @$(AS) --verbose -s -tnone --debug-info -o kernelus.ld65 $(SOURCE) $(ASFLAGS) > 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)/ diff --git a/buildr64.sh b/buildr64.sh index 48f28de1..a84e51fe 100644 --- a/buildr64.sh +++ b/buildr64.sh @@ -1,11 +1,13 @@ #! /bin/bash #make -NAME_TO_BUILD=k2023-2.r64 +NAME_TO_BUILD=k2025-1.r64 + +make cp ../../shell/develop/shell.rom $NAME_TO_BUILD cat basicus2.rom >> $NAME_TO_BUILD cat kernelus.rom >> $NAME_TO_BUILD -cat ../../empty-rom/empty-rom.rom >> $NAME_TO_BUILD +cat kernel8.rom >> $NAME_TO_BUILD cp $NAME_TO_BUILD /mnt/s/devus.r64 # NAME_TO_BUILD2=k2023-1.r64 diff --git a/run.sh b/run.sh index ffadf332..64597984 100644 --- a/run.sh +++ b/run.sh @@ -85,7 +85,7 @@ fi 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 +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/kch395/usr/share/kch395/2025.1/kch395.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 ] @@ -112,6 +112,7 @@ ld65 -C cfg/kernel.cfg -DWITH_SDCARD_FOR_ROOT=1 tmp/kernelsd.ld65 tmp/kernel_ba # dependencies/orix-sdk/bin/relocbin.py3 -o tmp/sfbtest -2 tmp/1000 tmp/1256 # cp tmp/sfbtest $ORICUTRON_PATH/sdcard/bin/ +echo Build autoboot 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 diff --git a/src/functions/lib_mng/XBANK_ROUTINE.s b/src/functions/lib_mng/XBANK_ROUTINE.s index 11fe1480..0c805f03 100644 --- a/src/functions/lib_mng/XBANK_ROUTINE.s +++ b/src/functions/lib_mng/XBANK_ROUTINE.s @@ -15,6 +15,8 @@ XNETWORK_START_ROUTINE := XBANK_ROUTINE .segment "BANK7" .proc XBANK_ROUTINE + + pha lda #<$C000 sta VEXBNK+1 diff --git a/src/functions/network/init_network.s b/src/functions/network/init_network.s index d79121c2..9e6214fd 100644 --- a/src/functions/network/init_network.s +++ b/src/functions/network/init_network.s @@ -11,6 +11,7 @@ .import ch395_dhcp_enable .import ch395_get_ip_inf +.import kch395_get_ip_inf .import KERNEL_NETWORK_FLAG .import KERNEL_NETWORK_SOCKET_LIST @@ -63,14 +64,19 @@ 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: @@ -107,8 +113,8 @@ ; Check IP lda #RES - jsr ch395_get_ip_inf - + ;jsr ch395_get_ip_inf + jsr kch395_get_ip_inf lda RES cmp #$00 beq @dhcp_not_started diff --git a/src/kernel.asm b/src/kernel.asm index 71c7bb42..defb807d 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -176,6 +176,7 @@ start_rom: lda #CH376_SET_USB_MODE_CODE_SDCARD .else lda #CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY + .out "Building usb device kernel" .endif sta KERNEL_CH376_MOUNT @@ -494,6 +495,7 @@ init_malloc_busy_table: ; **************************************************************************** ; Set stage for kernel init + lda #KERNEL_START_NETWORK jsr XNETWORK_START_ROUTINE diff --git a/src/kernel8/bpm.tml b/src/kernel8/bpm.tml index 8646b857..7faf64b7 100644 --- a/src/kernel8/bpm.tml +++ b/src/kernel8/bpm.tml @@ -24,3 +24,4 @@ orix_minimal_kernel_version = "2024.1" [dependencies] ch395 = "2024.4" ksocket = "2025.1" +kch395 = "2025.1" diff --git a/src/libs/ch376-lib/src/ch376.s b/src/libs/ch376-lib/src/ch376.s index 7539d5a9..b87161b0 100644 --- a/src/libs/ch376-lib/src/ch376.s +++ b/src/libs/ch376-lib/src/ch376.s @@ -143,7 +143,7 @@ loop: .warning "Build for sdcard by default" lda #CH376_SET_USB_MODE_CODE_SDCARD .else - .warning "Build by usb key" + .warning "[Default] Build for usb key" lda #CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY .endif lda KERNEL_CH376_MOUNT diff --git a/tests/functions/network/netchk.s b/tests/functions/network/netchk.s index 6f94647b..9254dd13 100644 --- a/tests/functions/network/netchk.s +++ b/tests/functions/network/netchk.s @@ -63,7 +63,6 @@ ptr_recv := userzp + 5 start_adress: - malloc #4096 cmp #$00 beq @not_oom @@ -72,6 +71,7 @@ start_adress: print str_oom crlf rts + @not_oom: sta ptr_recv sty ptr_recv+1 @@ -85,7 +85,7 @@ start_adress: @start: dec retry beq @end - + nop ; print str_bank_id_given lda #KERNEL_START_NETWORK ; Mode BRK_TELEMON $01 ; Get network state @@ -112,12 +112,13 @@ start_adress: crlf rts - +nop @fully_started: + crlf print str_fully_started crlf - jmp @socket + rts @disconnected: print str_cable_disconnected @@ -127,12 +128,12 @@ start_adress: @connected: print str_cable_connected crlf - jmp @waiting + print str_starting_dhcp + jmp @start @dhcp_starting: - print str_starting_dhcp - crlf - jmp @waiting + print #'.' + jmp @start @dhcp_started: print str_started_dhcp @@ -151,6 +152,12 @@ start_adress: @socket: @loop_socket: + ;lda ip ; 12 + ;ldy #00 ; 0 because the number is 12 (from A) + ;print_int ,2, 2 ; an arg is skipped because the number is from register + ; lda #' ' +; BRK_TELEMON XWR0 + nop print str_socket @@ -202,7 +209,7 @@ start_adress: sta RES + 1 ldy #18 ldx #$00 - + nop lda #KERNEL_SEND_NETWORK ; Connect BRK_TELEMON $01 cmp #$00 @@ -287,6 +294,7 @@ str_socket_error: .byte $81, "Socket open error",0 ip: + ;.byte 213,186,33,19 .byte 192,168,1,77 str_invalid_socket: @@ -299,7 +307,7 @@ str_waiting: .asciiz "Waiting ..." str_started_dhcp: - .asciiz "Started dhcp !!" + .asciiz "Dhcp Started !" str_starting_dhcp: .asciiz "Starting dhcp" @@ -312,7 +320,7 @@ str_cable_disconnected: str_cable_connected: .asciiz "Cable connected" - +nop ; sta tmp1 ; stx tmp2 From 782ccf1516141b754db2a7258c5dc77e432dad38 Mon Sep 17 00:00:00 2001 From: jede Date: Sat, 26 Apr 2025 23:37:42 +0200 Subject: [PATCH 21/49] feature/version --- Makefile | 4 +- README.md | 75 +---- VERSION | 2 +- memmap.html | 320 +++++++++++++++++++ memmap.md | 2 +- run.sh | 14 +- src/functions/hard_copy.s | 8 +- src/functions/mainargs.asm | 14 +- src/functions/network/close_sockets_by_pid.s | 2 +- src/functions/network/xclose_socket.s | 14 +- src/functions/xadress.asm | 4 +- src/functions/xbindx.asm | 4 +- src/functions/xdecal.asm | 36 +-- src/functions/xdecay.asm | 20 +- src/functions/xdivis.asm | 10 +- src/functions/xfillm.asm | 4 +- src/functions/xhexa.asm | 2 + src/functions/xhrscb.asm | 4 +- src/kernel.asm | 3 +- 19 files changed, 419 insertions(+), 123 deletions(-) create mode 100644 memmap.html diff --git a/Makefile b/Makefile index ea222170..9999de7e 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,8 @@ all : init kernel memmap unittest prepare_tmp: @mkdir -p tmp/ +KCH395_LIB_VERSION=2025.1 + SOURCE=src/kernel.asm PROGRAM_NAME=kernel @@ -79,7 +81,7 @@ kernel: $(SOURCE) @$(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 + @$(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/kch395/usr/share/kch395/$(KCH395_LIB_VERSION)/kch395.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 diff --git a/README.md b/README.md index 519fbd5e..dd37b494 100644 --- a/README.md +++ b/README.md @@ -4,86 +4,41 @@ ## Introduction -Orix is designed to work with ORICHD (telestrat) and Twilighte card (atmos). See : http://orix.oric.org +Orix is designed to work with ORICHD (telestrat) and Twilighte board (atmos). See : http://orix.oric.org -Some code is done by Fabrice Broche (60%) and Jede (40%). Anyway, all minitel and FDC routines had been removed +Some code is done by Fabrice Broche (50%) and Jede (50%). Anyway, all minitel and FDC routines had been removed Assembler : ca65 CPU : 6502 & 65C02 (but 65C02 not tested) +# How to compile + +Bank 8 (extended) is managed with bpm tool + +make + +Or for local development + +sh run.sh + ## How to use it ? This kernel is a set of primitives to displays string, open/close/write files ... You need at least "shell" bank to use this kernel -## Build option +## Documentation + +[Kernel Primitives Documentation](https://orix-software.github.io/developer_manual/kernel/primitives/) ### Root file on sdcard Pass to ca65 command line : -DWITH_SDCARD_FOR_ROOT=1 or else it will reads en usb key -here is the list of available "compile option" - -* CPU_65C02 -* WITH_MULTITASKING -* WITH_ACIA -* WITH_DEBUG : In that case, somes primitives send their debug to printer with a help of kdebug ROM. -* WITH_TWILIGHTE_BOARD - ## How does it starts * 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 103ea540..89c24c57 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2025.1 \ No newline at end of file +2025.2 \ No newline at end of file diff --git a/memmap.html b/memmap.html new file mode 100644 index 00000000..08c2c9dd --- /dev/null +++ b/memmap.html @@ -0,0 +1,320 @@ + + + + + + + + + + + + + + + + + + +

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 +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; +|#MEMMAP: Memmap +MEMMAP: +|##MEMMAP: Page 0 +MEMMAP: +|MEMMAP:Type | Name | Range | Size | +|MEMMAP: :------- |:----------------------------- |:----------- |:-----| +|MEMMAP:RAM|RES | $00-$01 | 2 | +|MEMMAP:RAM|RESB | $02-$03 | 2 | +|MEMMAP:RAM|RESC | $04-$05 | 2 | +|MEMMAP:RAM|RESD | $06-$07 | 2 | +|MEMMAP:RAM|RESE | $08-$09 | 2 | +|MEMMAP:RAM|RESF | $0A-$0B | 2 | +|MEMMAP:RAM|RESG | $59-$5A | 2 | +|MEMMAP:RAM|RESH | $60-$61 | 2 | +|MEMMAP:RAM|RESI | $62-$63 | 2 | +|MEMMAP:RAM|RESCONCAT | $64-$65 | 2 | +|MEMMAP:RAM|TR0 | $0C-$0C | 1 | +|MEMMAP:RAM|TR1 | $0D-$0D | 1 | +|MEMMAP:RAM|TR2 | $0E-$0E | 1 | +|MEMMAP:RAM|TR3 | $0F-$0F | 1 | +|MEMMAP:RAM|TR4 | $10-$10 | 1 | +|MEMMAP:RAM|TR5 | $11-$11 | 1 | +|MEMMAP:RAM|TR6 | $12-$12 | 1 | +|MEMMAP:RAM|TR7 | $13-$13 | 1 | +|MEMMAP:RAM|DEFAFF | $14-$14 | 1 | +|MEMMAP:RAM|FREE | $15-$16 | 2 | +|MEMMAP:RAM|ADDRESS_VECTOR_FOR_ADIOB | $17-$18 | 2 | +|MEMMAP:RAM|work_channel | $19-$19 | 1 | +|MEMMAP:RAM|i_o_counter | $1A-$1B | 2 | +|MEMMAP:RAM|FREE | $1C-$1C | 1 | +|MEMMAP:RAM|GS | $1D-$1D | 1 | +|MEMMAP:RAM|FREE | $1E-$1E | 1 | +|MEMMAP:RAM|TOFIX | $1F-$1F | 1 | +|MEMMAP:RAM|TOFIX | $20-$20 | 1 | +|MEMMAP:RAM|IRQSVA | $21-$21 | 1 | +|MEMMAP:RAM|IRQSVX | $22-$22 | 1 | +|MEMMAP:RAM|IRQSVY | $23-$23 | 1 | +|MEMMAP:RAM|IRQSVP | $24-$24 | 1 | +|MEMMAP:RAM|FIXME_PAGE0_0 | $25-$25 | 1 | +|MEMMAP:RAM|ADSCR | $26-$27 | 2 | +|MEMMAP:RAM|SCRNB | $28-$29 | 2 | +|MEMMAP:RAM|ADKBD | $2A-$2B | 2 | +|MEMMAP:RAM|PTR_READ_DEST | $2C-$2D | 2 | +|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 | +|MEMMAP:RAM|TIMEUD (used in cc65 clock function)| $44-$45 | 2 | +|MEMMAP:RAM|HRSX | $46-$46 | 1 | +|MEMMAP:RAM|HRSY | $47-$47 | 1 | +|MEMMAP:RAM|FREE | $48-$48 | 1 | +|MEMMAP:RAM|HRSX40 | $49-$49 | 1 | +|MEMMAP:RAM|HRSX6 | $4A-$4A | 1 | +|MEMMAP:RAM|ADHRS | $4B-$4C | 2 | +|MEMMAP:RAM|HRS1 | $4D-$4E | 2 | +|MEMMAP:RAM|HRS2 | $4F-$50 | 2 | +|MEMMAP:RAM|HRS3 | $51-$52 | 2 | +|MEMMAP:RAM|HRS4 | $53-$54 | 2 | +|MEMMAP:RAM|HRS5 | $55-$56 | 2 | +|MEMMAP:RAM|HRSFB | $57-$57 | 1 | +|MEMMAP:RAM|VABPK1 | $58-$58 | 1 | +|MEMMAP:RAM|FREE | $59-$5A | 2 | +|MEMMAP:RAM|INDRS | $5B-$5B | 1 | +|MEMMAP:RAM|FREE | $5C-$5F | 2 | +|MEMMAP:RAM|FREE | $8C-$FF | 115 | +|##MEMMAP: Page 2 +|MEMMAP:Type | Name | Range | Size | +|MEMMAP: :------- |:----------------------------- |:----------- |:-----| +|MEMMAP:RAM|KERNEL_ERRNO | $0200-$0200 | 1 | +|MEMMAP:RAM|KERNEL_CH376_MOUNT | $0201-$0201 | 1 | +|MEMMAP:RAM|KERNEL_XFREE_TMP | $0202-$0202 | 1 | +|MEMMAP:RAM|KERNEL_XKERNEL_CREATE_PROCESS_TMP| $0203-$0203 | 1 | +|MEMMAP:RAM|KERNEL_TMP_XEXEC | $0204-$0204 | 1 | +|MEMMAP:RAM|KERNEL_KERNEL_XEXEC_BNKOLD | $0205-$0205 | 1 | +|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-$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 | +|MEMMAP:RAM|TIMEH | $0213-$0213 | 1 | +|MEMMAP:RAM|FLGCLK | $0214-$0214 | 1 | +|MEMMAP:RAM|FLGCLK_FLAG | $0215-$0215 | 1 | +|MEMMAP:RAM|FLGCUR | $0216-$0216 | 1 | +|MEMMAP:RAM|FLGCUR_STATE | $0217-$0217 | 1 | +|MEMMAP:RAM|ADSCRL | $0218-$021B | 4 | +|MEMMAP:RAM|ADSCRH | $021C-$021F | 4 | +|MEMMAP:RAM|SCRX | $0220-$0220 | 1 | +|MEMMAP:RAM|BUSY_BANK_TABLE_RAM | $0221-$0224 | 3 | +|MEMMAP:RAM|SCRY | $0224-$0227 | 4 | +|MEMMAP:RAM|SCRDX | $0228-$0228 | 1 | +|MEMMAP:RAM|SCRFX | $022C-$022C | 1 | +|MEMMAP:RAM|SCRFY | $0234-$0234 | 1 | +|MEMMAP:RAM|SCRDY | $0230-$0230 | 1 | +|MEMMAP:RAM|SCRBAL | $0238-$0238 | 1 | +|MEMMAP:RAM|SCRBAH | $023C-$023C | 1 | +|MEMMAP:RAM|SCRCT | $0240-$0240 | 1 | +|MEMMAP:RAM|SCRCF | $0244-$0244 | 1 | +|MEMMAP:RAM|FIXME | $0248-$0220 | 80 | +|MEMMAP:RAM|FLGSCR | $0248-$024C | 4 | +|MEMMAP:RAM|CURSCR | $024C-$024D | 1 | +|MEMMAP:RAM|FREE | $024D-$0256 | 11 | +|MEMMAP:RAM|SCRTXT | $0256-$0260 | 4 | +|MEMMAP:RAM|SCRHIR (not used) | $025C-$0260 | 4 | +|MEMMAP:RAM|SCRTRA | $0262-$0266 | 6 | +|MEMMAP:RAM|KBDCOL | $0268-$0270 | 8 | +|MEMMAP:RAM|KBDFLG_KEY | $0270-$0272 | 2 | +|MEMMAP:RAM|KBDVRR | $0272-$0273 | 1 | +|MEMMAP:RAM|KBDVRL | $0273-$0275 | 2 | +|MEMMAP:RAM|FLGKBD | $0275-$0276 | 1 | +|MEMMAP:RAM|KBDFCT | $0276-$0277 | 1 | +|MEMMAP:RAM|KBDSHT | $0278-$0279 | 1 | +|MEMMAP:RAM|KBDKEY | $0279-$027E | 1 | +|MEMMAP:RAM|KBDCTC | $027E-$027F | 2 | +|MEMMAP:RAM|FREE | $027F-$02A5 | 40 | +|MEMMAP:RAM|KEYBOARD_COUNTER | $02A6-$02A9 | 3 | +|MEMMAP:RAM|HRSPAT | $02AA-$02AA | 1 | +|MEMMAP:RAM|IOTAB | $02AE-$02B1 | X | +|MEMMAP:RAM|KERNEL_ADIOB | $02B2-$02B9 | 8 | +|MEMMAP:RAM|kernel_malloc_free_chunk_size | $02BA-$02C3 | 10 | +|MEMMAP:RAM|kernel_xmalloc_call | $02C4-$02EB | 39 | +|MEMMAP:RAM|FLGRST | $02EE-$02EE | 1 | +|MEMMAP:RAM|CSRND | $02EF-$02EF | 1 | +|MEMMAP:RAM|FREE | $02EC-$02ED | 2 | +|MEMMAP:RAM|VNMI | $02F4-$02F7 | 3 | +|MEMMAP:RAM|ADIODB_VECTOR | $02F7-$02FA | 3 | +|MEMMAP:RAM|IRQVECTOR | $02FA-$02FD | 3 | +|MEMMAP:RAM|VAPLIC | $02FD-$0300 | 3 | +|##MEMMAP: Page 3 +|MEMMAP:Type | Name | Range | Size | +|MEMMAP: :------- |:----------------------------- |:----------- |:-----| +|MEMMAP:IO |VIA1 | $0300-$030F | | +|##MEMMAP: Page 4 +|MEMMAP:Type | Name | Range | Size | +|MEMMAP: :------- |:----------------------------- |:----------- |:-----| +|MEMMAP:RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0414 | 3 | +|##MEMMAP: Page 5&6 +|MEMMAP:Type | Name | Range | Size | +|MEMMAP: :------- |:----------------------------- |:----------- |:-----| +|MEMMAP:RAM|FREE | $0517-$0525 | 14 | +|MEMMAP:RAM|Malloc table | $0525-$0579 | 84 | +|MEMMAP:RAM|main kernel process struct | $0579-$058F | 22 | +|MEMMAP:RAM|BUFEDT | $0590-$05FE | 110 | +|MEMMAP:RAM|KERNEL_MEMORY_DRIVER | $05FE-$06A1 | 163 |

+ + + + + \ No newline at end of file diff --git a/memmap.md b/memmap.md index 2677a126..649d21e2 100644 --- a/memmap.md +++ b/memmap.md @@ -105,7 +105,7 @@ MEMMAP: |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-$020C | 4 | +|MEMMAP:RAM|FREE | $020A-$020C | 3 | |MEMMAP:RAM|FLGTEL | $020D-$020D | 1 | |MEMMAP:RAM|TIMED | $0210-$0210 | 1 | |MEMMAP:RAM|TIMES | $0211-$0211 | 1 | diff --git a/run.sh b/run.sh index 64597984..046fb165 100644 --- a/run.sh +++ b/run.sh @@ -58,6 +58,7 @@ 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 +ar65 r tmp/kernel_bank8.lib tmp/xclose_socket.o @@ -80,11 +81,10 @@ then 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 "##########" +echo "#####################" +echo "# Generating 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/kch395/usr/share/kch395/2025.1/kch395.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=$? @@ -94,9 +94,9 @@ echo Error exit fi -echo "##########" -echo "# Bank 7 #" -echo "##########" +echo "#####################" +echo "# Generating 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 diff --git a/src/functions/hard_copy.s b/src/functions/hard_copy.s index 372a7654..4c278941 100644 --- a/src/functions/hard_copy.s +++ b/src/functions/hard_copy.s @@ -5,6 +5,7 @@ LE25E: dex bne LE25E stx TR0 + LE269: ldx #$06 LE26B: @@ -12,6 +13,7 @@ LE26B: LE276: lda #$05 sta TR2 + LE27A: lda TR0 asl @@ -26,6 +28,7 @@ LE27A: lda #$08 sta TR4 ldy TR1 + LE290: lda (TR5),Y tax @@ -34,12 +37,15 @@ LE290: txa and #$80 tax + LE29B: txa bpl LE2A0 eor #$3F + LE2A0: ldx TR2 + LE2A2: lsr dex @@ -53,6 +59,6 @@ LE2A2: inc TR6 LE2B1: -LE2D0! +LE2D0: rts diff --git a/src/functions/mainargs.asm b/src/functions/mainargs.asm index 67f57e3a..d5e59d84 100644 --- a/src/functions/mainargs.asm +++ b/src/functions/mainargs.asm @@ -47,14 +47,14 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte ; Get the struct og the process jsr kernel_get_struct_process_ptr sta RES - sty RES+1 + sty RES + 1 ; 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 + inc RES + 1 @S7: sta RES @@ -81,7 +81,7 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte @continue: ; Save malloc sta RESB - sty RESB+1 + sty RESB + 1 lda XMAINARGS_MODE beq @parse @@ -114,13 +114,13 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte sta (RESB),y lda RESB+1 - sta XMAINARGSV+1 + sta XMAINARGSV + 1 lda #XMAINARGS_STRUCT::argv_value_ptr clc adc RESB bcc @S3 - inc XMAINARGSV+1 + inc XMAINARGSV + 1 @S3: sta XMAINARGSV ; TR2 contains the first offset @@ -158,7 +158,7 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte clc adc #$01 bcc @no_inc - inc RES+1 + inc RES + 1 @no_inc: sta RES @@ -182,7 +182,7 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte ldx XMAINARGSC ; return ptr lda RESB - ldy RESB+1 + ldy RESB + 1 rts @new_arg: diff --git a/src/functions/network/close_sockets_by_pid.s b/src/functions/network/close_sockets_by_pid.s index 6dc81888..b1aaf2a9 100644 --- a/src/functions/network/close_sockets_by_pid.s +++ b/src/functions/network/close_sockets_by_pid.s @@ -50,8 +50,8 @@ bne @restart @close_socket: - lda TR1 ; Socket ID + lda TR1 ; Socket ID jsr ch395_close_socket_sn ; Set to 0 diff --git a/src/functions/network/xclose_socket.s b/src/functions/network/xclose_socket.s index 5e0d4eeb..6264fb47 100644 --- a/src/functions/network/xclose_socket.s +++ b/src/functions/network/xclose_socket.s @@ -7,8 +7,11 @@ .include "telestrat.inc" + + .import KERNEL_NETWORK_SOCKET_LIST .import KERNEL_NETWORK_SOCKET_DOMAIN +.import KERNEL_NETWORK_SOCKET_PID .export XSOCKET_CLOSE_ROUTINE @@ -17,14 +20,21 @@ .proc XSOCKET_CLOSE_ROUTINE ; X contains the id of the socket ; Remove socket id - sta TR0 + txa + sta TR0 + tay ; Contains socket id - lda #$00 ; Type + 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 + ldy TR0 ; Contains socket id + lda #$00 ; Type + ldx #$00 ; BANK + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_PID ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + ; Flush buffers lda TR0 ; Load socket id jmp ch395_close_socket_sn diff --git a/src/functions/xadress.asm b/src/functions/xadress.asm index 555fa830..65aa4a2c 100644 --- a/src/functions/xadress.asm +++ b/src/functions/xadress.asm @@ -6,8 +6,8 @@ sta RES pha tya - adc RES+1 - sta RES+1 + adc RES + 1 + sta RES + 1 tay pla rts diff --git a/src/functions/xbindx.asm b/src/functions/xbindx.asm index b156f57c..577825d0 100644 --- a/src/functions/xbindx.asm +++ b/src/functions/xbindx.asm @@ -35,11 +35,11 @@ lda TR0 beq @L2 sta TR3 - bne @L3+1 + bne @L3 + 1 @L2: ldy TR3 - bne @L3+1 + bne @L3 + 1 lda DEFAFF @L3: .byt $2C diff --git a/src/functions/xdecal.asm b/src/functions/xdecal.asm index f9e7523a..e017e477 100644 --- a/src/functions/xdecal.asm +++ b/src/functions/xdecal.asm @@ -22,16 +22,16 @@ lda DECFIN sbc DECDEB tay - lda DECFIN+1 - sbc DECDEB+1 + lda DECFIN + 1 + sbc DECDEB + 1 tax bcc Lcdb9 - stx DECTRV+1 + stx DECTRV + 1 lda DECCIB cmp DECDEB - lda DECCIB+1 - sbc DECDEB+1 + lda DECCIB + 1 + sbc DECDEB + 1 bcs Lcdbf tya eor #$FF @@ -40,7 +40,7 @@ sta DECTRV bcc @S1 dex - inc DECFIN+1 + inc DECFIN + 1 @S1: sec lda DECCIB @@ -48,20 +48,20 @@ sta DECCIB bcs @S3 - dec DECCIB+1 + dec DECCIB + 1 @S3: clc - lda DECFIN+1 - sbc DECTRV+1 - sta DECFIN+1 + lda DECFIN + 1 + sbc DECTRV + 1 + sta DECFIN + 1 inx @L2: lda (DECFIN),y sta (DECCIB),y iny bne @L2 - inc DECFIN+1 - inc DECCIB+1 + inc DECFIN + 1 + inc DECCIB + 1 dex bne @L2 Lcdb8: @@ -76,12 +76,12 @@ Lcdb9: Lcdbf: txa clc - adc DECDEB+1 - sta DECDEB+1 + adc DECDEB + 1 + sta DECDEB + 1 txa clc - adc DECCIB+1 - sta DECCIB+1 + adc DECCIB + 1 + sta DECCIB + 1 inx @L1: dey @@ -89,8 +89,8 @@ Lcdbf: sta (DECCIB),y tya bne @L1 - dec DECDEB+1 - dec DECCIB+1 + dec DECDEB + 1 + dec DECCIB + 1 dex bne @L1 beq Lcdb8 diff --git a/src/functions/xdecay.asm b/src/functions/xdecay.asm index db870a5c..ea26ed14 100644 --- a/src/functions/xdecay.asm +++ b/src/functions/xdecay.asm @@ -13,10 +13,10 @@ .out .sprintf("|MODIFY:RESB:XDECAY") sta RES ; on sauve l'adresse du nombre - sty RES+1 ; dans RES + sty RES + 1 ; dans RES ldy #$00 ; et on met RESB ? 0 sty RESB - sty RESB+1 + sty RESB + 1 loop: lda (RES),Y ; on lit le code <------------------------------ cmp #$30 ; inférieur à 0 ? I @@ -26,23 +26,23 @@ loop: and #$0F ; on isole le chiffre I I pha ; dans la pile I I asl RESB ; RESB*2 I I - rol RESB+1 ; I I + rol RESB + 1 ; I I lda RESB ; AX=RESB*2 I I - ldx RESB+1 ; I I + ldx RESB + 1 ; I I asl RESB ; *4 I I - rol RESB+1 ; I I + rol RESB + 1 ; I I asl RESB ; *8 I I - rol RESB+1 ; I I + rol RESB + 1 ; I I adc RESB ; +RESB*2 I I sta RESB ; I I txa ; I I - adc RESB+1 ; I I - sta RESB+1 ; = RESB*10 I I + adc RESB + 1 ; I I + sta RESB + 1 ; = RESB*10 I I pla ; plus chiffre lu I I adc RESB ; I I sta RESB ; I I bcc @S1 ; I I - inc RESB+1 ; I I + inc RESB + 1 ; I I @S1: iny ; on ajoute un chiffre lu I I bne loop ; et on recommence ---------------------------- I @@ -50,6 +50,6 @@ loop: tya ; nombre de chiffres lus <-------------------------- tax ; dans X lda RESB ; nombre dans AY et RESB - ldy RESB+1 ; + ldy RESB + 1 ; rts .endproc diff --git a/src/functions/xdivis.asm b/src/functions/xdivis.asm index 9fb8912d..82ba9a08 100644 --- a/src/functions/xdivis.asm +++ b/src/functions/xdivis.asm @@ -6,24 +6,24 @@ sty TR1 ldx #$00 stx RESB - stx RESB+1 + stx RESB + 1 ldx #$10 @loop: asl RES - rol RES+1 + rol RES + 1 rol RESB - rol RESB+1 + rol RESB + 1 sec lda RESB sbc TR0 tay - lda RESB+1 + lda RESB + 1 sbc TR1 bcc @skip sty RESB - sta RESB+1 + sta RESB + 1 inc RES @skip: diff --git a/src/functions/xfillm.asm b/src/functions/xfillm.asm index 840af7c1..883c0221 100644 --- a/src/functions/xfillm.asm +++ b/src/functions/xfillm.asm @@ -7,7 +7,7 @@ sbc RES tay txa - sbc RES+1 + sbc RES + 1 tax sty RESB pla @@ -35,7 +35,7 @@ loop: sta (RES),y iny bne @L1 - inc RES+1 + inc RES + 1 dex bne @L1 diff --git a/src/functions/xhexa.asm b/src/functions/xhexa.asm index b3e3d358..cbde1777 100644 --- a/src/functions/xhexa.asm +++ b/src/functions/xhexa.asm @@ -8,11 +8,13 @@ lsr lsr lsr + Lce60: ora #$30 cmp #$3A bcc @skip adc #$06 + @skip: rts diff --git a/src/functions/xhrscb.asm b/src/functions/xhrscb.asm index 6964c238..885aa83f 100644 --- a/src/functions/xhrscb.asm +++ b/src/functions/xhrscb.asm @@ -10,13 +10,13 @@ ; avant le deplacement, de vous de gerer cela. ; DEPLACE LE CURSEUR HIRES VERS LE BAS - .out .sprintf("|MODIFY:ADHRS:XHRSCB") + .out .sprintf("|MODIFY:ADHRS:XHRSCB") clc ; on ajoute 40 lda ADHRS ; à ADHRS adc #$28 sta ADHRS bcc skip - inc ADHRS+1 + inc ADHRS + 1 skip: rts diff --git a/src/kernel.asm b/src/kernel.asm index defb807d..c29fe727 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -1,6 +1,6 @@ .FEATURE labels_without_colons, pc_assignment, loose_char_term, org_per_seg -.define VERSION "2025.1" +.define VERSION "2025.2" .include "telestrat.inc" ; from cc65 .include "fcntl.inc" ; from cc65 @@ -1059,6 +1059,7 @@ routine_to_define_16: .include "functions/xdecay.asm" .include "functions/xinteg.asm" .include "functions/exe/ori2.asm" +.include "functions/exe/relocate_ORI2.asm" .include "common/strcpy_RESI.asm" From 24ac58255f4f95b7672fa38b5685afd949e5c145 Mon Sep 17 00:00:00 2001 From: jede Date: Sat, 26 Apr 2025 23:56:19 +0200 Subject: [PATCH 22/49] fix/cache_github_action --- src/functions/XOP.asm | 2 +- src/functions/XWRx.asm | 4 +- src/functions/XWSTRx.asm | 10 +- src/functions/bank_mng/search_free_bank.s | 14 +- src/functions/exe/ori2.asm | 163 +++--------------- src/functions/exe/relocate_ORI2.asm | 127 ++++++++++++++ src/functions/lib_mng/XBANK_ROUTINE.s | 8 +- src/functions/memory/memory_driver.asm | 10 +- src/functions/memory/xfree.asm | 79 ++++----- src/functions/network/close_sockets_by_pid.s | 3 + src/functions/network/init_network.s | 8 +- src/functions/network/xclose_socket.s | 1 + src/functions/network/xconnect.s | 7 +- src/functions/network/xsend.s | 3 - src/functions/network/xsocket.s | 1 + .../process/kernel_exec_from_storage.asm | 48 +++--- src/functions/process/kernel_kill_process.asm | 5 +- src/functions/xhrscd.asm | 4 +- src/functions/xhrscg.asm | 4 +- src/functions/xhrsch.asm | 4 +- src/functions/xloadcharset.asm | 10 +- src/functions/xmul40.asm | 16 +- src/functions/xmult.asm | 14 +- src/functions/zadcha.asm | 14 +- src/kernel8/.gitignore | 1 + src/kernel8/bpm.tml | 2 + .../ch395/usr/share/ch395/2024.4/README.md | 1 + src/kernel8/src/kernel8.s | 2 - 28 files changed, 298 insertions(+), 267 deletions(-) create mode 100644 src/functions/exe/relocate_ORI2.asm diff --git a/src/functions/XOP.asm b/src/functions/XOP.asm index 400e1054..67dcf415 100644 --- a/src/functions/XOP.asm +++ b/src/functions/XOP.asm @@ -24,7 +24,7 @@ XOP0_ROUTINE: rts skip129: - ldy #(KERNEL_SIZE_IOTAB-1) + ldy #(KERNEL_SIZE_IOTAB - 1) @loop: cmp IOTAB,y diff --git a/src/functions/XWRx.asm b/src/functions/XWRx.asm index 180b39f6..49a46edc 100644 --- a/src/functions/XWRx.asm +++ b/src/functions/XWRx.asm @@ -39,8 +39,8 @@ XWSTR0_re_enter_from_XDECAL: tax ; lda KERNEL_ADIOB,x ; GET vectors sta ADIODB_VECTOR+1 - lda KERNEL_ADIOB+1,x - sta ADIODB_VECTOR+2 ; + lda KERNEL_ADIOB + 1,x + sta ADIODB_VECTOR + 2 ; lda i_o_save ; Get Byte to write @loop: bit @loop diff --git a/src/functions/XWSTRx.asm b/src/functions/XWSTRx.asm index f896958f..54883973 100644 --- a/src/functions/XWSTRx.asm +++ b/src/functions/XWSTRx.asm @@ -19,21 +19,21 @@ .out .sprintf("|MODIFY:FLGSCR:XWR0") ; IOTAB ldx #$00 - stx i_o_save+1 + stx i_o_save + 1 sta ADDRESS_READ_BETWEEN_BANK - sty ADDRESS_READ_BETWEEN_BANK+1 + sty ADDRESS_READ_BETWEEN_BANK + 1 @loop: - lda i_o_save+1 + lda i_o_save + 1 sta work_channel ldy #$00 jsr ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY beq Lc7a7 - jsr XWSTR0_re_enter_from_XDECAL + jsr XWSTR0_re_enter_from_XDECAL inc ADDRESS_READ_BETWEEN_BANK bne @loop - inc ADDRESS_READ_BETWEEN_BANK+1 + inc ADDRESS_READ_BETWEEN_BANK + 1 bne @loop .endproc diff --git a/src/functions/bank_mng/search_free_bank.s b/src/functions/bank_mng/search_free_bank.s index d648d0e5..72b0fcb8 100644 --- a/src/functions/bank_mng/search_free_bank.s +++ b/src/functions/bank_mng/search_free_bank.s @@ -30,19 +30,19 @@ ldx #$00 ldy #KERNEL_FIRST_FREE_RAM_BANK ; First bank - sty RES+1 + sty RES + 1 lda #KERNEL_BANK_MANAGEMENT sta ADDRESS_READ_BETWEEN_BANK_DOUBLON - sty ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 @not_found: - ldy RES+1 + ldy RES + 1 - cpy #(KERNEL_LAST_RAM_BANK+1) + cpy #(KERNEL_LAST_RAM_BANK + 1) beq @oob ; Out Of Bank MEMORY_GET_VALUE_FROM_BANK ; A contains the value @@ -50,19 +50,19 @@ cmp #$00 beq @found - inc RES+1 + inc RES + 1 bne @not_found @found: ; Set busy flag lda #$01 ; Type - ldy RES+1 ; Offset + ldy RES + 1 ; Offset ldx #$00 ; BANK MEMORY_PUT_VALUE_TO_BANK KERNEL_BANK_MANAGEMENT - lda RES+1 ; Offset + lda RES + 1 ; Offset clc adc #kernel_bank_management_struct::KERNEL_BANK_PROCESS_ID tay diff --git a/src/functions/exe/ori2.asm b/src/functions/exe/ori2.asm index 1df010cd..3f9c4f1d 100644 --- a/src/functions/exe/ori2.asm +++ b/src/functions/exe/ori2.asm @@ -13,13 +13,20 @@ ; 04-05 : 00 00 ; 06 : Inchangé .proc compute_all_offset_ORI2 + .out .sprintf("|MODIFY:KERNEL_CREATE_PROCESS_PTR1:compute_all_offset_ORI2") + .out .sprintf("|MODIFY:RESD:compute_all_offset_ORI2") + .out .sprintf("|MODIFY:RESE:compute_all_offset_ORI2") + .out .sprintf("|MODIFY:PTR_READ_DEST:compute_all_offset_ORI2") + + + ; RESD contains header ; Set the adress in the kernel struct - ldx kernel_process+kernel_process_struct::kernel_current_process - lda kernel_process+kernel_process_struct::kernel_one_process_struct_ptr_low,x + ldx kernel_process + kernel_process_struct::kernel_current_process + lda kernel_process + kernel_process_struct::kernel_one_process_struct_ptr_low,x sta KERNEL_CREATE_PROCESS_PTR1 - lda kernel_process+kernel_process_struct::kernel_one_process_struct_ptr_high,x - sta KERNEL_CREATE_PROCESS_PTR1+1 + lda kernel_process + kernel_process_struct::kernel_one_process_struct_ptr_high,x + sta KERNEL_CREATE_PROCESS_PTR1 + 1 ; Get execution address low @@ -44,9 +51,9 @@ sta RESE - ldy #kernel_one_process_struct::kernel_process_addr+1 + ldy #kernel_one_process_struct::kernel_process_addr + 1 - ldx RESD+1 + ldx RESD + 1 inx txa clc @@ -54,14 +61,14 @@ sta (KERNEL_CREATE_PROCESS_PTR1),y - ldy RESD+1 ; the ptr of the address allocated + ldy RESD + 1 ; the ptr of the address allocated iny - sty ORI2_PROGRAM_ADRESS+1 ; addr $62: $0B - sty ORI2_MAP_ADRESS+1 ; Prepare adresse map but does not compute yet ; $0B - sty RESE+1 ; Set address execution ; 0B - sty PTR_READ_DEST+1 ; Set address to load the next part of the program - sty ORI2_PROGRAM_ADRESS+1 + sty ORI2_PROGRAM_ADRESS + 1 ; addr $62: $0B + sty ORI2_MAP_ADRESS + 1 ; Prepare adresse map but does not compute yet ; $0B + sty RESE + 1 ; Set address execution ; 0B + sty PTR_READ_DEST + 1 ; Set address to load the next part of the program + sty ORI2_PROGRAM_ADRESS + 1 ; .IFPC02 @@ -70,7 +77,7 @@ stz ORI2_MAP_ADRESS stz RESE ; Set address execution stz PTR_READ_DEST - stz ORI2_PAGE_LOAD ; Set to 0 for instance before compute + stz ORI2_PAGE_LOAD ; Set to 0 for instance before compute .p02 .else lda #$00 @@ -83,7 +90,7 @@ ldy #15 ; High start adress - lda RESD+1 ; Align + lda RESD + 1 ; Align clc adc #$01 cmp (RESD),y @@ -101,145 +108,25 @@ ldy #$08 lda (RESD),y - sta ORI2_LENGTH_MAP+1 + sta ORI2_LENGTH_MAP + 1 ldy #12 lda (RESD),y clc adc ORI2_MAP_ADRESS bcc @S2 - inc ORI2_MAP_ADRESS+1 + inc ORI2_MAP_ADRESS + 1 @S2: sta ORI2_MAP_ADRESS ldy #13 lda (RESD),y ; fixme 65c02 clc - adc ORI2_MAP_ADRESS+1 - sta ORI2_MAP_ADRESS+1 + adc ORI2_MAP_ADRESS + 1 + sta ORI2_MAP_ADRESS + 1 rts .endproc -.proc relocate_ORI2 - - ; On suppose que A = page de chargement du programme (chargé en début de page) - ; On suppose également que z02-z05 ont été mis à jour par l'appelant (adresse et longueur de la bitmap) - lda ORI2_PAGE_LOAD ; offset à appliquer - beq rel_end - - ; Length map $47 - ldy #$00 ; Au cas ou on parte directement vers "reste" - lda ORI2_LENGTH_MAP+1 - - beq reste - -boucle: - lda (ORI2_MAP_ADRESS),y ; On prend un octet de la MAP - beq skip8 ; 0 -> On saute directement 8 octets du programme - - tax ; Sauvegarde ACC - tya ; Sauvegarde Y - pha - - ldy #$07 ; 8 Bits - txa ; Restaure ACC -reloc: - lsr a - bcc next - - tax ; Sauvegarde ACC - clc ; On ajuste l'adresse - lda (ORI2_PROGRAM_ADRESS),y - adc ORI2_PAGE_LOAD - sta (ORI2_PROGRAM_ADRESS),y - txa ; Restaure ACC -next: - dey - bpl reloc - pla ; Restaure Y - tay - ; - ; On saute 8 octets - ; -skip8: - clc ; On saute 8 octets du programme - lda ORI2_PROGRAM_ADRESS - adc #$08 - sta ORI2_PROGRAM_ADRESS - bcc *+4 - inc ORI2_PROGRAM_ADRESS+1 -suite: -; $1248 don't relocate -; $1268 - - - iny - bne *+6 - inc ORI2_MAP_ADRESS+1 ; Page suivante dans la MAP - dec ORI2_LENGTH_MAP+1 - bne boucle - - ; - ; On a traité toutes les pages entières - ; On traite les octets restants - ; - ; On arrive ici avec Y=0 - ; -reste: - lda ORI2_LENGTH_MAP - beq rel_end - -boucle2: - lda (ORI2_MAP_ADRESS),y ; On prend un octet de la MAP - beq skip82 ; 0 -> On saute directement 8 octets du programme - - tax ; Sauvegarde ACC - tya ; Sauvegarde Y - pha - - - ldy #$07 ; 8 Bits - txa ; Restaure ACC -reloc2: - lsr a - bcc next2 - - tax ; Sauvegarde ACC - clc ; On ajuste l'adresse - lda (ORI2_PROGRAM_ADRESS),y - adc ORI2_PAGE_LOAD - sta (ORI2_PROGRAM_ADRESS),y - txa ; Restaure ACC -next2: - dey - bpl reloc2 - pla ; Restaure Y - tay - ; - ; On saute 8 octets - ; -skip82: - clc ; On saute 8 octets du programme - lda ORI2_PROGRAM_ADRESS - adc #$08 - sta ORI2_PROGRAM_ADRESS - bcc *+4 - inc ORI2_PROGRAM_ADRESS+1 - -suite2: - iny - - dec ORI2_LENGTH_MAP - bne boucle2 - -rel_end: - inc ORI2_PAGE_LOAD ; On remet la page de chargement à sa valeur initiale - - - rts ; Pour utilisation éventuelle par une autre routine -.endproc - - diff --git a/src/functions/exe/relocate_ORI2.asm b/src/functions/exe/relocate_ORI2.asm new file mode 100644 index 00000000..639b7315 --- /dev/null +++ b/src/functions/exe/relocate_ORI2.asm @@ -0,0 +1,127 @@ +.export relocate_ORI2 + +; .import ORI2_PAGE_LOAD +; .import ORI2_LENGTH_MAP +; .import ORI2_MAP_ADRESS +; .import ORI2_PROGRAM_ADRESS + +.proc relocate_ORI2 + ; Relocalise le programme en fonction de la MAP et de la page de chargement + ; On suppose que A = page de chargement du programme (chargé en début de page) + ; On suppose également que z02-z05 ont été mis à jour par l'appelant (adresse et longueur de la bitmap) + lda ORI2_PAGE_LOAD ; offset à appliquer + beq rel_end + + ; Length map $47 + ldy #$00 ; Au cas ou on parte directement vers "reste" + lda ORI2_LENGTH_MAP + 1 + + beq reste + +boucle: + lda (ORI2_MAP_ADRESS),y ; On prend un octet de la MAP + beq skip8 ; 0 -> On saute directement 8 octets du programme + + tax ; Sauvegarde ACC + tya ; Sauvegarde Y + pha + + ldy #$07 ; 8 Bits + txa ; Restaure ACC + +reloc: + lsr a + bcc next + + tax ; Sauvegarde ACC + clc ; On ajuste l'adresse + lda (ORI2_PROGRAM_ADRESS),y + adc ORI2_PAGE_LOAD + sta (ORI2_PROGRAM_ADRESS),y + txa ; Restaure ACC + +next: + dey + bpl reloc + pla ; Restaure Y + tay + ; + ; On saute 8 octets + ; +skip8: + clc ; On saute 8 octets du programme + lda ORI2_PROGRAM_ADRESS + adc #$08 + sta ORI2_PROGRAM_ADRESS + bcc *+4 + inc ORI2_PROGRAM_ADRESS + 1 +suite: +; $1248 don't relocate +; $1268 + + + iny + bne *+6 + inc ORI2_MAP_ADRESS + 1 ; Page suivante dans la MAP + dec ORI2_LENGTH_MAP + 1 + bne boucle + + ; + ; On a traité toutes les pages entières + ; On traite les octets restants + ; + ; On arrive ici avec Y=0 + ; +reste: + lda ORI2_LENGTH_MAP + beq rel_end + +boucle2: + lda (ORI2_MAP_ADRESS),y ; On prend un octet de la MAP + beq skip82 ; 0 -> On saute directement 8 octets du programme + + tax ; Sauvegarde ACC + tya ; Sauvegarde Y + pha + + + ldy #$07 ; 8 Bits + txa ; Restaure ACC +reloc2: + lsr a + bcc next2 + + tax ; Sauvegarde ACC + clc ; On ajuste l'adresse + lda (ORI2_PROGRAM_ADRESS),y + adc ORI2_PAGE_LOAD + sta (ORI2_PROGRAM_ADRESS),y + txa ; Restaure ACC +next2: + dey + bpl reloc2 + pla ; Restaure Y + tay + ; + ; On saute 8 octets + ; +skip82: + clc ; On saute 8 octets du programme + lda ORI2_PROGRAM_ADRESS + adc #$08 + sta ORI2_PROGRAM_ADRESS + bcc *+4 + inc ORI2_PROGRAM_ADRESS + 1 + +suite2: + iny + + dec ORI2_LENGTH_MAP + bne boucle2 + +rel_end: + inc ORI2_PAGE_LOAD ; On remet la page de chargement à sa valeur initiale + + + rts ; Pour utilisation éventuelle par une autre routine +.endproc diff --git a/src/functions/lib_mng/XBANK_ROUTINE.s b/src/functions/lib_mng/XBANK_ROUTINE.s index 0c805f03..7eec0fda 100644 --- a/src/functions/lib_mng/XBANK_ROUTINE.s +++ b/src/functions/lib_mng/XBANK_ROUTINE.s @@ -16,13 +16,17 @@ XNETWORK_START_ROUTINE := XBANK_ROUTINE .proc XBANK_ROUTINE + .out .sprintf("|MODIFY:VEXBNK:XBANK_ROUTINE") + + ;;@brief XBANK_ROUTINE is a wrapper to switch to Kernel bank 8 (extended mode) and call the function in bank 8. + ;;@modifyMEM_VEXBNK pha lda #<$C000 - sta VEXBNK+1 + sta VEXBNK + 1 lda #>$C000 - sta VEXBNK+2 + sta VEXBNK + 2 ; !!!! pla is done in kernel_restore_banking_states jmp kernel_restore_banking_states diff --git a/src/functions/memory/memory_driver.asm b/src/functions/memory/memory_driver.asm index 8e03b5de..5eca57a8 100644 --- a/src/functions/memory/memory_driver.asm +++ b/src/functions/memory/memory_driver.asm @@ -26,8 +26,10 @@ test_debug: sta RESB+1 ; d15E ldx #$00 + read_command_from_bank_driver_mloop: ldy #$00 + read_command_from_bank_driver_next_char: lda (RES),y ; RES contains the ptr of the string typed by the user when XEXEC is launched cmp (RESB),y ; Same character? RESB contains the ptr of the command in the rom @@ -65,7 +67,7 @@ command_not_found_no_inc: clc adc RESB bcc read_command_from_bank_driver_do_not_inc - inc RESB+1 + inc RESB + 1 read_command_from_bank_driver_do_not_inc: sta RESB @@ -88,19 +90,19 @@ read_command_from_bank_driver_command_found: lda $FFF3 sta RES lda $FFF4 - sta RES+1 + sta RES + 1 txa asl tay lda (RES),y read_command_from_bank_driver_patch1: - sta VEXBNK+1 ; Will store in read_command_from_bank_driver_to_patch + sta VEXBNK + 1 ; Will store in read_command_from_bank_driver_to_patch iny lda (RES),y read_command_from_bank_driver_patch2: - sta VEXBNK+2 ; Will store in read_command_from_bank_driver_to_patch + sta VEXBNK + 2 ; Will store in read_command_from_bank_driver_to_patch lda #$07 ; Return to telemon jsr $46A diff --git a/src/functions/memory/xfree.asm b/src/functions/memory/xfree.asm index 10840b92..ce8c1bba 100644 --- a/src/functions/memory/xfree.asm +++ b/src/functions/memory/xfree.asm @@ -4,12 +4,13 @@ .proc XFREE_ROUTINE ; A & Y + ;@brief free memory routine .out .sprintf("|MODIFY:RES:XFREE_ROUTINE") + .out .sprintf("|MODIFY:HRS1:XFREE_ROUTINE") .out .sprintf("|MODIFY:KERNEL_XFREE_TMP:XFREE_ROUTINE") sta KERNEL_XFREE_TMP ; Save A (low) - sty HRS1 .ifdef WITH_DEBUG @@ -39,10 +40,10 @@ @search_busy_chunk: lda KERNEL_XFREE_TMP - cmp kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x ; Looking if low is available. + cmp kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x ; Looking if low is available. bne @next_chunk tya - cmp kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x + cmp kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x beq @busy_chunk_found @next_chunk: @@ -80,7 +81,7 @@ ; Erase pid reference ; FR : On set 0 dans la table de malloc (dans la liste des pid de malloc) pour dire que le chunk "busy" est libre - STZ_ABS_X kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_pid_list + STZ_ABS_X kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_pid_list jsr xfree_find_free_chunk cmp #$00 @@ -91,7 +92,7 @@ ; Looking for Free chunk available ldy #$01 @find_a_free_chunk: - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y beq @free_chunk_is_available iny cpy #KERNEL_MALLOC_FREE_CHUNK_MAX @@ -154,9 +155,9 @@ out: @try_another_free_chunk: ; On regarde si le chunk libre à sa valeur high de début à 0, si oui, alors on ne peut pas recoller avec ce chunk ; Parce qu'il n'est pas setté - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y ; $FC $B4 + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y ; $FC $B4 beq @next_free_chunk - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,y ; $FC $B4 + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,y ; $FC $B4 ; FIXME 65C02, use 'dec A' sec @@ -165,15 +166,15 @@ out: inc RES ; X contains the index of the busy chunk found @skip_inc_high: - cmp kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x ; kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_low + cmp kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x ; kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_low bne @next_free_chunk @compare_high: - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y clc adc RES - cmp kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x + cmp kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x beq @merge_with_free_table @next_free_chunk: @@ -192,44 +193,44 @@ out: ; add in the free malloc table ; On prend l'offset de début de chunk busy, ce qui est le début du chunk free - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,y + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,y - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y ; update size - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x clc - adc kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low,y ; $572 + adc kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low,y ; $572 bcc @do_not_inc pha - lda kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y ; It should be better here but inc does not manage inc $xx,y $56B + lda kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y ; It should be better here but inc does not manage inc $xx,y $56B clc adc #$01 - sta kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y + sta kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y pla @do_not_inc: - sta kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low,y + sta kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low,y - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x clc - adc kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y - sta kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y + adc kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y + sta kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y lda #$00 - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x rts .endproc @@ -239,23 +240,23 @@ out: ; X contient l'index du chunk busy qu'on va recopier dans libre ; On arrive ici parce qu'on n'a pas pu recoller avec un chunk déjà existant, donc on le popule - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,y + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,y - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_low,y + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_low,y - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_high,y + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_high,y - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x - sta kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low,y + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x + sta kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low,y - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x - sta kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x + sta kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y jsr xfree_clear_busy_chunk @@ -281,7 +282,7 @@ out: STZ_ABS RES ; FR : on essaie de trouver un chunk libre ldy #$02 - cpy #(KERNEL_MALLOC_FREE_CHUNK_MAX-1) + cpy #(KERNEL_MALLOC_FREE_CHUNK_MAX - 1) bcc @try_another_free_chunk rts diff --git a/src/functions/network/close_sockets_by_pid.s b/src/functions/network/close_sockets_by_pid.s index b1aaf2a9..c85cacfe 100644 --- a/src/functions/network/close_sockets_by_pid.s +++ b/src/functions/network/close_sockets_by_pid.s @@ -17,6 +17,9 @@ .include "../../include/network.inc" .include "../../include/memory.inc" +.out .sprintf("|MODIFY:TR1:close_sockets_by_pid") +.out .sprintf("|MODIFY:ADDRESS_READ_BETWEEN_BANK_DOUBLON:close_sockets_by_pid") + .import ch395_close_socket_sn .proc close_sockets_by_pid diff --git a/src/functions/network/init_network.s b/src/functions/network/init_network.s index 9e6214fd..936708f7 100644 --- a/src/functions/network/init_network.s +++ b/src/functions/network/init_network.s @@ -110,11 +110,11 @@ rts @start_dhcp: + ; Check IP - lda #RES - ;jsr ch395_get_ip_inf - jsr kch395_get_ip_inf + + jsr kch395_get_ip_inf ; Fill RES to RES + 20 + lda RES cmp #$00 beq @dhcp_not_started diff --git a/src/functions/network/xclose_socket.s b/src/functions/network/xclose_socket.s index 6264fb47..efe2f530 100644 --- a/src/functions/network/xclose_socket.s +++ b/src/functions/network/xclose_socket.s @@ -20,6 +20,7 @@ .proc XSOCKET_CLOSE_ROUTINE ; X contains the id of the socket ; Remove socket id + .out .sprintf("|MODIFY:TR0:XSOCKET_CLOSE_ROUTINE") txa sta TR0 diff --git a/src/functions/network/xconnect.s b/src/functions/network/xconnect.s index 0d8b2eb2..f8d6c9ea 100644 --- a/src/functions/network/xconnect.s +++ b/src/functions/network/xconnect.s @@ -15,6 +15,11 @@ .import KERNEL_NETWORK_SOCKET_LIST .proc xconnect + .out .sprintf("|MODIFY:TR0:xconnect") + .out .sprintf("|MODIFY:DECFIN:xconnect") + .out .sprintf("|MODIFY:DECDEB:xconnect") + .out .sprintf("|MODIFY:TR3:xconnect") + ;;@returnsA A = $FF if it's impossible to connect (SOCKET_ERROR) for instance or 0 if it's OK socket := TR0 ip := DECFIN @@ -70,7 +75,7 @@ ;;@` jsr kconnect ldy ip - ldx ip+1 + ldx ip + 1 jmp kconnect diff --git a/src/functions/network/xsend.s b/src/functions/network/xsend.s index 15a34564..39be74eb 100644 --- a/src/functions/network/xsend.s +++ b/src/functions/network/xsend.s @@ -7,9 +7,6 @@ .include "telestrat.inc" - - - .export XSEND_ROUTINE .import ksend diff --git a/src/functions/network/xsocket.s b/src/functions/network/xsocket.s index ae1d5141..d988467d 100644 --- a/src/functions/network/xsocket.s +++ b/src/functions/network/xsocket.s @@ -94,6 +94,7 @@ ; Error, return INVALID lda #INVALID_SOCKET + rts @socketfound: diff --git a/src/functions/process/kernel_exec_from_storage.asm b/src/functions/process/kernel_exec_from_storage.asm index cb412993..31d90c75 100644 --- a/src/functions/process/kernel_exec_from_storage.asm +++ b/src/functions/process/kernel_exec_from_storage.asm @@ -252,11 +252,12 @@ open_binary_and_exec: lda RESD sta (KERNEL_CREATE_PROCESS_PTR1),y ; $741 iny - lda RESD+1 + lda RESD + 1 sta (KERNEL_CREATE_PROCESS_PTR1),y ; Read 20 bytes in the header + ; A is the number of byte to read (20 for 20 bytes in the header) lda #20 ldy #$00 ldx RESF ; FP @@ -293,8 +294,8 @@ open_binary_and_exec: lda RESD sta RESI - lda RESD+1 - sta RESI+1 + lda RESD + 1 + sta RESI + 1 jmp shebang_management @@ -351,7 +352,7 @@ open_binary_and_exec: ldx kernel_process+kernel_process_struct::kernel_current_process jsr kernel_get_struct_process_ptr sta KERNEL_CREATE_PROCESS_PTR1 - sty KERNEL_CREATE_PROCESS_PTR1+1 + sty KERNEL_CREATE_PROCESS_PTR1 + 1 ldy #kernel_one_process_struct::kernel_process_addr lda (KERNEL_CREATE_PROCESS_PTR1),y @@ -385,13 +386,13 @@ open_binary_and_exec: ldy #19 lda (RESD),y ; fixme 65c02 - sta RESE+1 + sta RESE + 1 ; Checking if RESD is equal or below than the loading address ldy #15 lda (RESD),y ; Does high byte for malloc ptr is $08 - cmp RESD+1 ; greater than the loading adress $7f + cmp RESD + 1 ; greater than the loading adress $7f bcc @error ; Yes error, can't not start bcs @start_to_read ; it's equal @@ -417,21 +418,21 @@ open_binary_and_exec: sta RESD iny lda (KERNEL_CREATE_PROCESS_PTR1),y - sta RESD+1 + sta RESD + 1 ; free the length of the binary lda RESD - ldy RESD+1 + ldy RESD + 1 jsr XFREE_ROUTINE ldy #EOK pla ; get return code - ldx HRS2+1 + ldx HRS2 + 1 rts @error: ; free the length of the binary lda RESD - ldy RESD+1 + ldy RESD + 1 jsr XFREE_ROUTINE jsr process_kill_and_exit @@ -441,19 +442,19 @@ open_binary_and_exec: @clean_before_execute: ; save RES lda RES - ldy RES+1 + ldy RES + 1 sta RESG - sty RESG+1 + sty RESG + 1 ; send cmdline ptr lda RESF - ldy RESF+1 + ldy RESF + 1 jsr XCLOSE_ROUTINE lda RESG - ldy RESG+1 + ldy RESG + 1 rts @execute: @@ -507,7 +508,7 @@ str_root_bin: ; $94D sta RESE ; RESE contains the malloc /bin/path - sty RESE+1 + sty RESE + 1 rts .endproc @@ -533,7 +534,7 @@ str_root_bin: clc adc RESD bcc @advance_ptr_resd - inc RESD+1 + inc RESD + 1 @advance_ptr_resd: sta RESD @@ -578,7 +579,7 @@ str_root_bin: ; RESD Free here (and RESI) ; On désalloue RESI qui est juste le ptr RESD après malloc, avec cette opération on libère ces 2 offsets lda RESI - ldy RESI+1 ; $842 + ldy RESI + 1 ; $842 jsr XFREE_ROUTINE ; Nous allons donc changer la ligne de commande pour écrire submit + le processname @@ -589,13 +590,14 @@ str_root_bin: jsr kernel_get_struct_process_ptr sta KERNEL_CREATE_PROCESS_PTR1 - sty KERNEL_CREATE_PROCESS_PTR1+1 + sty KERNEL_CREATE_PROCESS_PTR1 + 1 lda KERNEL_CREATE_PROCESS_PTR1 clc adc #kernel_one_process_struct::cmdline bcc @S7 - inc KERNEL_CREATE_PROCESS_PTR1+1 + inc KERNEL_CREATE_PROCESS_PTR1 + 1 + @S7: sta KERNEL_CREATE_PROCESS_PTR1 @@ -610,7 +612,7 @@ str_root_bin: lda KERNEL_CREATE_PROCESS_PTR1 sta RESCONCAT - lda KERNEL_CREATE_PROCESS_PTR1+1 + lda KERNEL_CREATE_PROCESS_PTR1 + 1 sta RESCONCAT+1 lda RESE @@ -629,7 +631,7 @@ str_root_bin: clc adc RESCONCAT bcc @S100 - inc RESCONCAT+1 + inc RESCONCAT + 1 @S100: sta RESCONCAT @@ -646,7 +648,7 @@ str_root_bin: clc adc RESCONCAT bcc @S10000 - inc RESCONCAT+1 + inc RESCONCAT + 1 @S10000: sta RESCONCAT @@ -702,7 +704,7 @@ str_bin: .proc kernel_concat_from_RESB_to_RESCONCAT sta RESB - sty RESB+1 + sty RESB + 1 ldy #$00 diff --git a/src/functions/process/kernel_kill_process.asm b/src/functions/process/kernel_kill_process.asm index 21c24753..ba735e2c 100644 --- a/src/functions/process/kernel_kill_process.asm +++ b/src/functions/process/kernel_kill_process.asm @@ -33,7 +33,6 @@ bne @do_not_destroy_socket - lda #KERNEL_SOCKET_CLOSE_FROM_PID_NETWORK jsr XNETWORK_START_ROUTINE @@ -133,7 +132,7 @@ .endproc .proc erase_all_chunk_from_current_process - ; A contains the process id + ; A contains the process id sta KERNEL_XKERNEL_CREATE_PROCESS_TMP ; Try to find all malloc from this process @@ -141,7 +140,6 @@ @L2: lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_pid_list,x - beq @skip ; is it 0 ? Yes it's a free chunk cmp KERNEL_XKERNEL_CREATE_PROCESS_TMP @@ -152,6 +150,7 @@ cpx #KERNEL_MAX_NUMBER_OF_MALLOC bne @L2 beq @all_chunk_are_free + @erase_chunk: txa pha diff --git a/src/functions/xhrscd.asm b/src/functions/xhrscd.asm index d554b7d1..549b2670 100644 --- a/src/functions/xhrscd.asm +++ b/src/functions/xhrscd.asm @@ -1,7 +1,7 @@ ; DEPLACE LE CURSEUR VERS LA DROITE (hires) .proc XHRSCD_ROUTINE - .out .sprintf("|MODIFY:HRSX40:XHRSCD") - .out .sprintf("|MODIFY:HRSX6:XHRSCD") + .out .sprintf("|MODIFY:HRSX40:XHRSCD") + .out .sprintf("|MODIFY:HRSX6:XHRSCD") ldx HRSX6 ; on déplace d'un pixel inx diff --git a/src/functions/xhrscg.asm b/src/functions/xhrscg.asm index 449885fe..f6bf8393 100644 --- a/src/functions/xhrscg.asm +++ b/src/functions/xhrscg.asm @@ -2,8 +2,8 @@ ; DEPLACE LE CURSEUR VERS LA GAUCHE (hires) .proc XHRSCG_ROUTINE - .out .sprintf("|MODIFY:HRSX40:XHRSCG") - .out .sprintf("|MODIFY:HRSX6:XHRSCG") + .out .sprintf("|MODIFY:HRSX40:XHRSCG") + .out .sprintf("|MODIFY:HRSX6:XHRSCG") ldx HRSX6 dex ; on déplace à gauche bpl @skip ; si on sort diff --git a/src/functions/xhrsch.asm b/src/functions/xhrsch.asm index b5c3a9a7..6adea63b 100644 --- a/src/functions/xhrsch.asm +++ b/src/functions/xhrsch.asm @@ -1,5 +1,5 @@ .proc XHRSCH_ROUTINE - .out .sprintf("|MODIFY:ADHRS:XHRSCH") + .out .sprintf("|MODIFY:ADHRS:XHRSCH") ; DEPLACE LE CURSEUR HIRES VERS LE HAUT sec ; on soustrait 40 @@ -7,7 +7,7 @@ sbc #$28 sta ADHRS bcs @skip - dec ADHRS+1 + dec ADHRS + 1 @skip: rts diff --git a/src/functions/xloadcharset.asm b/src/functions/xloadcharset.asm index b48d12fd..98a2f8f9 100644 --- a/src/functions/xloadcharset.asm +++ b/src/functions/xloadcharset.asm @@ -3,12 +3,12 @@ @loop: lda charset_text,x - sta $B400+8*32,x + sta $B400 + 8*32,x - lda charset_text+256,x - sta $B500+8*32,x - lda charset_text+512,x - sta $B600+8*32,x + lda charset_text + 256,x + sta $B500 + 8*32,x + lda charset_text + 512,x + sta $B600 + 8*32,x inx bne @loop rts diff --git a/src/functions/xmul40.asm b/src/functions/xmul40.asm index 91323285..cd49f000 100644 --- a/src/functions/xmul40.asm +++ b/src/functions/xmul40.asm @@ -1,24 +1,24 @@ ldy #$00 sta RES - sty RES+1 + sty RES + 1 asl - rol RES+1 + rol RES + 1 asl - rol RES+1 + rol RES + 1 adc RES bcc @skip - inc RES+1 + inc RES + 1 @skip: asl - rol RES+1 + rol RES + 1 asl - rol RES+1 + rol RES + 1 asl - rol RES+1 + rol RES + 1 sta RES - ldy RES+1 + ldy RES + 1 rts diff --git a/src/functions/xmult.asm b/src/functions/xmult.asm index 61929900..a419cbed 100644 --- a/src/functions/xmult.asm +++ b/src/functions/xmult.asm @@ -1,16 +1,16 @@ sta TR4 - sty TR4+1 + sty TR4 + 1 ldx #$00 stx TR0 stx TR1 stx $0E stx $0F stx RESB - stx RESB+1 + stx RESB + 1 ldx #$10 LCEAB: - lsr TR4+1 + lsr TR4 + 1 ror TR4 bcc LCECA clc @@ -19,7 +19,7 @@ LCEAB: adc TR0 sta TR0 - lda RES+1 + lda RES + 1 adc TR1 sta TR1 @@ -27,14 +27,14 @@ LCEAB: adc $0F sta $0F - lda RESB+1 + lda RESB + 1 adc $0F sta $0F LCECA: asl RES - rol RES+1 + rol RES + 1 rol RESB - rol RESB+1 + rol RESB + 1 lda TR4 ora $11 diff --git a/src/functions/zadcha.asm b/src/functions/zadcha.asm index 9c766a25..1aa11e30 100644 --- a/src/functions/zadcha.asm +++ b/src/functions/zadcha.asm @@ -1,20 +1,20 @@ .proc ZADCHA_ROUTINE - .out .sprintf("|MODIFY:RESB:ZADCHA") + .out .sprintf("|MODIFY:RESB:ZADCHA") ldx #$13 - stx RESB+1 + stx RESB + 1 asl - rol RESB+1 + rol RESB + 1 asl - rol RESB+1 + rol RESB + 1 asl - rol RESB+1 + rol RESB + 1 sta RESB bit FLGTEL bmi @skip - lda RESB+1 + lda RESB + 1 adc #$1C - sta RESB+1 + sta RESB + 1 @skip: rts diff --git a/src/kernel8/.gitignore b/src/kernel8/.gitignore index 320ea541..dd9173e8 100644 --- a/src/kernel8/.gitignore +++ b/src/kernel8/.gitignore @@ -1,2 +1,3 @@ bpmtmp/ build +src/kernel8/orixlibs/ diff --git a/src/kernel8/bpm.tml b/src/kernel8/bpm.tml index 7faf64b7..10f58fdb 100644 --- a/src/kernel8/bpm.tml +++ b/src/kernel8/bpm.tml @@ -25,3 +25,5 @@ orix_minimal_kernel_version = "2024.1" ch395 = "2024.4" ksocket = "2025.1" kch395 = "2025.1" + +[srcfolders] 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 index 993f9170..bb2a407e 100644 --- a/src/kernel8/orixlibs/ch395/usr/share/ch395/2024.4/README.md +++ b/src/kernel8/orixlibs/ch395/usr/share/ch395/2024.4/README.md @@ -18,3 +18,4 @@ If you set a mac address maybe will refuse to attribute a mac address * 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 +* Si le cable est branché, mais le ch395 n'est pas initialisé, jamais le cable apparaitra branché sur le ch395 diff --git a/src/kernel8/src/kernel8.s b/src/kernel8/src/kernel8.s index 6b635bc3..feccd2d1 100644 --- a/src/kernel8/src/kernel8.s +++ b/src/kernel8/src/kernel8.s @@ -104,8 +104,6 @@ XBANK: jmp close_sockets_by_pid - - signature: .asciiz "Kernel Extended v2025.X" From c52bb21e030f6e0db5a6f2e1ee6f87db0415a559 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 23 Jul 2025 23:13:56 +0200 Subject: [PATCH 23/49] fix xfseek --- .github/workflows/main.yml | 10 +- Makefile | 84 +++++-- README.md | 24 +- run.sh | 213 +++++++++--------- src/functions/XOP.asm | 18 +- src/functions/bank_mng/kernel_free_bank.s | 6 +- src/functions/bank_mng/search_free_bank.s | 2 +- src/functions/exe/ori2.asm | 3 + src/functions/exe/relocate_ORI2.asm | 1 + .../files/_set_to_value_seek_file.asm | 4 +- src/functions/files/checking_fp_exists.asm | 14 +- src/functions/files/compute_fp_struct.asm | 6 +- src/functions/files/xfseek.asm | 99 ++++++-- src/functions/memory/xmalloc.asm | 68 +++--- .../process/kernel_exec_from_storage.asm | 30 +-- src/kernel.asm | 4 +- tests/file_operations/file_operations.sub | 15 ++ tests/file_operations/fseek_test.c | 33 ++- tests/{ => file_operations}/fwrite.c | 2 +- tests/{ => file_operations}/readdir.c | 0 tests/{ => file_operations}/xmkdir.asm | 0 tests/{ => file_operations}/xrm.asm | 0 22 files changed, 389 insertions(+), 247 deletions(-) create mode 100644 tests/file_operations/file_operations.sub rename tests/{ => file_operations}/fwrite.c (94%) rename tests/{ => file_operations}/readdir.c (100%) rename tests/{ => file_operations}/xmkdir.asm (100%) rename tests/{ => file_operations}/xrm.asm (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3489d14a..ff3d4223 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Cache sdk id: cache-sdk - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | cc65/**/* @@ -120,7 +120,7 @@ jobs: echo "::set-output name=REPO_NAME::${GITHUB_REPOSITORY##*/}" - name: Install sdk - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | cc65/**/* @@ -150,11 +150,7 @@ jobs: run: | 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 - #cp mainarg ${GITHUB_WORKSPACE}/oricutron/sdcard/BIN - #cat mainarg >> ${GITHUB_WORKSPACE}/oricutron/sdcard/ETC/AUTOBOOT + make prepare-unit-test cd ${GITHUB_WORKSPACE}/oricutron timeout --preserve-status 10 ./xvfb.sh || exit 0 diff --git a/Makefile b/Makefile index 9999de7e..c392d295 100644 --- a/Makefile +++ b/Makefile @@ -4,25 +4,31 @@ CFLAGS=-ttelestrat ASFLAGS=-ttelestrat LDFILES= -all : init kernel memmap unittest +all : init kernel memmap .PHONY : prepare_tmp all prepare_tmp: @mkdir -p tmp/ KCH395_LIB_VERSION=2025.1 - SOURCE=src/kernel.asm - PROGRAM_NAME=kernel +ifeq ($(strip $(GITHUB_WORKSPACE)),) + WORKSPACE = $(ORICUTRON_PATH) +else + WORKSPACE = $(GITHUB_WORKSPACE)/oricutron/ +endif + ifeq ($(CC65_HOME),) - CC = cl65 + CL = cl65 + CC = cc65 AS = ca65 LD = ld65 AR = ar65 else - CC = $(CC65_HOME)/bin/cl65 + CL = $(CC65_HOME)/bin/cl65 + CC = $(CC65_HOME)/bin/cc65 AS = $(CC65_HOME)/bin/ca65 LD = $(CC65_HOME)/bin/ld65 AR = $(CC65_HOME)/bin/ar65 @@ -41,7 +47,7 @@ init: kernel: $(SOURCE) @mkdir -p tmp/ - @cd src/kernel8 && bpm update && cd .. + @cd src/kernel8 && bpm update && cd .. @echo Rom are built in $(PATH_PACKAGE_ROM) @echo "########################################################" @echo "# Build kernelsd.rom for Twilighte board #" @@ -77,18 +83,19 @@ kernel: $(SOURCE) @$(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) --verbose -s -tnone --debug-info -o tmp/kernel_bank0.ld65 -DWITH_SDCARD_FOR_ROOT=1 src/kernel_bank0.s $(ASFLAGS) > output.log + @$(AS) --verbose -s -tnone --debug-info -o tmp/kernelsd.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > output.log + @$(LD) -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 + @cp kernel.rom kernelsd.rom @$(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/kch395/usr/share/kch395/$(KCH395_LIB_VERSION)/kch395.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 "########################################################" @echo "# Build kernelus.rom for Twilighte board #" @@ -96,22 +103,59 @@ kernel: $(SOURCE) @$(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 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 + + + +compile_cc65: + @echo "########################################################" + @echo "# Compile C file with cc65 #" + @echo "########################################################" + @echo "FILE_TO_COMPILE: $(FILE_TO_COMPILE) FINAL_BIN: $(FINAL_BIN) " + @$(CC) $(CFLAGS) $(FILE_TO_COMPILE) -o tmp/$(FINAL_BIN)_1000.s + @$(CC) $(CFLAGS) $(FILE_TO_COMPILE) -o tmp/$(FINAL_BIN)_2304.s + + @$(AS) $(CFLAGS) tmp/$(FINAL_BIN)_1000.s -o tmp/$(FINAL_BIN)_1000.o + @$(AS) $(CFLAGS) tmp/$(FINAL_BIN)_2304.s -o tmp/$(FINAL_BIN)_2304.o + + @$(LD) $(CFLAGS) tmp/$(FINAL_BIN)_1000.o -o tmp/$(FINAL_BIN)_1000 --start-addr 2048 telestrat.lib + @$(LD) $(CFLAGS) tmp/$(FINAL_BIN)_2304.o -o tmp/$(FINAL_BIN)_2304 --start-addr 2304 telestrat.lib + @dependencies/orix-sdk/bin/relocbin.py3 -o tmp/$(FINAL_BIN) -2 tmp/$(FINAL_BIN)_1000 tmp/$(FINAL_BIN)_2304 + +prepare-unit-test: + @cp build/usr/share/kernel/kernelsd.rom ${WORKSPACE}/roms/kernel.rom + @cat tests/unit_test/xopen.sub > ${WORKSPACE}/sdcard/ETC/AUTOBOOT + @cat tests/file_operations/file_operations.sub >> ${WORKSPACE}/sdcard/ETC/AUTOBOOT + @cat tests/unit_test/xrm.sub >> ${WORKSPACE}/sdcard/ETC/AUTOBOOT + @cat tests/unit_test/tail.sub >> ${WORKSPACE}/sdcard/ETC/AUTOBOOT + @cp tmp/tfseek ${WORKSPACE}/sdcard/BIN + cat ${WORKSPACE}/sdcard/ETC/AUTOBOOT + +launch-unit-test: build-unit-test prepare-unit-test execute-oricutron + @echo "########################################################" + @echo "# Launch unit test #" + @echo "########################################################" + +execute-oricutron: + @cp kernelsd.rom ${WORKSPACE}/roms/kernel.rom + @cp kernel8.rom ${WORKSPACE}/roms/ + @cd ${WORKSPACE} && ./oricutron + +memmap: @cp kernel.rom kernelus.rom @cp kernelus.rom $(PATH_PACKAGE_ROM)/ -unittest: - @$(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 +build-unit-test: + @$(MAKE) compile_cc65 FILE_TO_COMPILE="tests/file_operations/fseek_test.c" FINAL_BIN="tfseek" + @#$(CL) $(CFLAGS) tests/file_operations/mkdir.c -o tmp/tmkdir + @$(CL) $(CFLAGS) tests/file_operations/fwrite.c -o tmp/tfwrite + @$(CL) $(CFLAGS) tests/unit_test/mainarg.s -I dependencies/orix-sdk/macros/ -o tmp/1000 --start-addr 2048 + @$(CL) $(CFLAGS) tests/unit_test/mainarg.s -I dependencies/orix-sdk/macros/ -o tmp/1256 --start-addr 2304 -memmap: @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 + @#@$(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: diff --git a/README.md b/README.md index dd37b494..7722d5f3 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,10 @@ [![build](https://github.com/orix-software/kernel/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/orix-software/kernel/actions/workflows/main.yml) -# Orix +# Orix Kernel ## Introduction -Orix is designed to work with ORICHD (telestrat) and Twilighte board (atmos). See : http://orix.oric.org - -Some code is done by Fabrice Broche (50%) and Jede (50%). Anyway, all minitel and FDC routines had been removed +It's the Orix kernel (in bank 7 and 8) in order to start on twilighte board Assembler : ca65 CPU : 6502 & 65C02 (but 65C02 not tested) @@ -31,10 +29,15 @@ You need at least "shell" bank to use this kernel [Kernel Primitives Documentation](https://orix-software.github.io/developer_manual/kernel/primitives/) -### Root file on sdcard +### Root filesystem :sdcard Pass to ca65 command line : -DWITH_SDCARD_FOR_ROOT=1 -or else it will reads en usb key +or else it will reads in* usb key + +### Root filesystem : usbdrive + +Remove -DWITH_SDCARD_FOR_ROOT=1 on ca65 command line +or else it will reads in sdcard ## How does it starts @@ -42,3 +45,12 @@ or else it will reads en usb key * it allocates a process struct (first malloc) * and register it in processlist +## Launch unit test (local) + +1) Set ORICUTRON_PATH in your shell eg : + +ORICUTRON_PATH=/bin/ +export ORICUTRON_PATH + +2) make launch-unit-test + diff --git a/run.sh b/run.sh index 046fb165..b9ed6813 100644 --- a/run.sh +++ b/run.sh @@ -2,115 +2,118 @@ #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" +#ORICUTRON_PATH="/mnt/c/Users/plifp/OneDrive/oric/projets/jedeoric/oricutron_assinie_plugins" +ORICUTRON_PATH="/mnt/c/Users/plifp/OneDrive/oric/oricutron_plugins/" CA65_INC=/usr/share/cc65/asminc/ # -DWITH_DEBUG=1 -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 -ar65 r tmp/kernel_bank8.lib tmp/xclose_socket.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 "# Generating 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/kch395/usr/share/kch395/2025.1/kch395.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 -echo Error -exit -fi - -echo "#####################" -echo "# Generating 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 - - -# 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/ +# 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 +# ar65 r tmp/kernel_bank8.lib tmp/xclose_socket.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 "# Generating 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/kch395/usr/share/kch395/2025.1/kch395.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 +# echo Error +# exit +# fi + +# echo "#####################" +# echo "# Generating 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 + + +# # 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/ + +make unittest echo Build autoboot cl65 -ttelestrat tests/functions/network/netchk.s -o tmp/1000 --start-addr 2048 diff --git a/src/functions/XOP.asm b/src/functions/XOP.asm index 67dcf415..a73e9df9 100644 --- a/src/functions/XOP.asm +++ b/src/functions/XOP.asm @@ -1,5 +1,5 @@ ; A contains channel -XOP0_ROUTINE: +.proc XOP0_ROUTINE .out .sprintf("|MODIFY:IOTAB:XOP0") .out .sprintf("|MODIFY:work_channel:XOP0") @@ -7,23 +7,23 @@ XOP0_ROUTINE: pha -@loop: +@L1: pla cmp IOTAB,x ; Already open with the same IO ? - beq @skip2 ; Yes exit + beq @S1 ; Yes exit ldy IOTAB,x - bpl skip129 + bpl @skip129 inx pha txa and #$03 - bne @loop + bne @L1 pla - @skip2: +@S1: rts -skip129: +@skip129: ldy #(KERNEL_SIZE_IOTAB - 1) @loop: @@ -42,7 +42,9 @@ skip129: ldx work_channel pla - @skip2: + +@skip2: sta IOTAB,x clc rts +.endproc diff --git a/src/functions/bank_mng/kernel_free_bank.s b/src/functions/bank_mng/kernel_free_bank.s index 2ffdd5b3..0ff1eddd 100644 --- a/src/functions/bank_mng/kernel_free_bank.s +++ b/src/functions/bank_mng/kernel_free_bank.s @@ -15,7 +15,7 @@ .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 + ;;@inputX Contains the id of the bank to free ;;@modifyA ;;@modifyX ;;@modifyY @@ -24,7 +24,7 @@ ;;@returnsX ;;@returnsY - stx TR2 ; Save + stx TR2 ; Save bank to free in TR2 ldy TR2 lda #$00 ldx #$00 @@ -39,5 +39,7 @@ ldx #$00 MEMORY_PUT_VALUE_TO_BANK KERNEL_BANK_MANAGEMENT + lda #$00 ; Success since kernel 2025.3 + rts .endproc diff --git a/src/functions/bank_mng/search_free_bank.s b/src/functions/bank_mng/search_free_bank.s index 72b0fcb8..852f153b 100644 --- a/src/functions/bank_mng/search_free_bank.s +++ b/src/functions/bank_mng/search_free_bank.s @@ -67,7 +67,7 @@ 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 + 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 diff --git a/src/functions/exe/ori2.asm b/src/functions/exe/ori2.asm index 3f9c4f1d..7fc06ef7 100644 --- a/src/functions/exe/ori2.asm +++ b/src/functions/exe/ori2.asm @@ -29,6 +29,7 @@ sta KERNEL_CREATE_PROCESS_PTR1 + 1 + ; Get execution address low ldy #18 clc @@ -44,6 +45,8 @@ lda (RESD),y sta RESE ; Use RESE as temp value + ; FIXME ICI + ldy #19 ; Get execution address high lda (RESD),y sec diff --git a/src/functions/exe/relocate_ORI2.asm b/src/functions/exe/relocate_ORI2.asm index 639b7315..a890a9da 100644 --- a/src/functions/exe/relocate_ORI2.asm +++ b/src/functions/exe/relocate_ORI2.asm @@ -6,6 +6,7 @@ ; .import ORI2_PROGRAM_ADRESS .proc relocate_ORI2 + ;jmp relocate_ORI2 ; Relocalise le programme en fonction de la MAP et de la page de chargement ; On suppose que A = page de chargement du programme (chargé en début de page) ; On suppose également que z02-z05 ont été mis à jour par l'appelant (adresse et longueur de la bitmap) diff --git a/src/functions/files/_set_to_value_seek_file.asm b/src/functions/files/_set_to_value_seek_file.asm index c17138d4..4ab86b10 100644 --- a/src/functions/files/_set_to_value_seek_file.asm +++ b/src/functions/files/_set_to_value_seek_file.asm @@ -4,11 +4,11 @@ ; KERNEL_XOPEN_PTR1 must be set to the fd struct .out .sprintf("|MODIFY:RES:_set_to_value_seek_file") - sty RES+1 + sty RES + 1 ldy #_KERNEL_FILE::f_seek_file sta (KERNEL_XOPEN_PTR1),y iny - lda RES+1 ; Y value + lda RES + 1 ; Y value sta (KERNEL_XOPEN_PTR1),y iny txa diff --git a/src/functions/files/checking_fp_exists.asm b/src/functions/files/checking_fp_exists.asm index aa9b5f62..2b55126b 100644 --- a/src/functions/files/checking_fp_exists.asm +++ b/src/functions/files/checking_fp_exists.asm @@ -2,8 +2,6 @@ ; X fp to find ; Save A & X - - .out .sprintf("|MODIFY:RES:checking_fp_exists") .out .sprintf("|MODIFY:RESB:checking_fp_exists") .out .sprintf("|MODIFY:TR5:checking_fp_exists") @@ -57,7 +55,7 @@ jsr send_0_to_ch376_and_open - ldy #_KERNEL_FILE::f_path+1 ; Skip first '/' + ldy #_KERNEL_FILE::f_path + 1 ; Skip first '/' @set_filename: lda #CH376_SET_FILE_NAME ;$2F @@ -76,16 +74,6 @@ ldy TR5 jmp @set_filename -; lda (KERNEL_XOPEN_PTR1),y - -; beq @send_end_out -; cmp #'/' -; beq @send -; jsr XMINMA_ROUTINE -; sta CH376_DATA -; iny -; bne @loop_next_byte -; ; Here we should not reach this part except if there is an overflow @doesnot_exists: diff --git a/src/functions/files/compute_fp_struct.asm b/src/functions/files/compute_fp_struct.asm index 9a9eae27..a50fbf59 100644 --- a/src/functions/files/compute_fp_struct.asm +++ b/src/functions/files/compute_fp_struct.asm @@ -7,10 +7,10 @@ sbc #KERNEL_FIRST_FD asl tax - lda kernel_process+kernel_process_struct::fp_ptr,x + lda kernel_process + kernel_process_struct::fp_ptr,x sta KERNEL_XOPEN_PTR1 inx - lda kernel_process+kernel_process_struct::fp_ptr,x - sta KERNEL_XOPEN_PTR1+1 + lda kernel_process + kernel_process_struct::fp_ptr,x + sta KERNEL_XOPEN_PTR1 + 1 rts .endproc diff --git a/src/functions/files/xfseek.asm b/src/functions/files/xfseek.asm index 62d3be7d..0b499a1c 100644 --- a/src/functions/files/xfseek.asm +++ b/src/functions/files/xfseek.asm @@ -1,8 +1,20 @@ .proc XFSEEK_ROUTINE -; [IN] X whence -; [IN] AY position 0 to 15 -; [IN] RESB position 0 to 31 -; [IN] RES fd + ;;@brief perform a seek on a file + ;;@description This function performs a seek operation on a file, adjusting the file pointer based on the specified whence and offset. + ;;@inputA low position 0 to 15 bits + ;;@inputX whence + ;;@inputY high position 0 to 15 bits + ;;@inputMEM_RESB RESB position 0 to 31 (2 bytes) + ;;@inputMEM_RES fd + ;;@modifyMEM_RES5 (2 bytes) + ;;@modifyMEM_TR0 + ;;@modifyMEM_TR4 + ;;@modifyMEM_TR7 + ;;@returnsA EOK if successful, EBADF if the file descriptor is invalid, or EINVAL if the whence is invalid, Return A=$FF if something is wrong when seek has performed + ;;@returnsA position 0 to 7 (1 byte) + ;;@returnsA position 8 to 15 (1 byte) + ;;@returnsMEM_RES position 16 to 31 (2 bytes) + .out .sprintf("|MODIFY:TR0:XFSEEK_ROUTINE") .out .sprintf("|MODIFY:TR6:XFSEEK_ROUTINE") .out .sprintf("|MODIFY:TR7:XFSEEK_ROUTINE") @@ -17,14 +29,14 @@ sta TR0 ; 09 lda RES sta KERNEL_XFSEEK_SAVE_RES - lda RES+1 + lda RES + 1 sta KERNEL_XFSEEK_SAVE_RES+1 lda RESB sta RES5 - lda RESB+1 - sta RES5+1 + lda RESB + 1 + sta RES5 + 1 sty TR7 ; save Y $02 stx TR4 @@ -34,7 +46,13 @@ jsr checking_fp_exists bcc @continue_xfseek - lda #EBADF + ; lda #EBADF + + lda #$FF + tax + sta RES + sta RES + 1 + rts @continue_xfseek: @@ -43,13 +61,13 @@ lda KERNEL_XFSEEK_SAVE_RES sta RES - lda KERNEL_XFSEEK_SAVE_RES+1 - sta RES+1 + lda KERNEL_XFSEEK_SAVE_RES + 1 + sta RES + 1 lda KERNEL_XFSEEK_SAVE_RESB sta RESB - lda KERNEL_XFSEEK_SAVE_RESB+1 - sta RESB+1 + lda KERNEL_XFSEEK_SAVE_RESB + 1 + sta RESB + 1 cpx #SEEK_CUR beq @move @@ -57,9 +75,16 @@ beq @go_end cpx #SEEK_SET beq @go_beginning - lda #EINVAL ; Return error + ;lda #EINVAL ; Return error + + lda #$FF + tax + sta RES + sta RES + 1 + rts +; SEEK_END : Seek from the end of the file @go_end: lda CH376_DATA ldx CH376_DATA @@ -79,26 +104,31 @@ jsr compute_fp_struct - jsr getFileLength ; return A,X,Y RES : 4 bytes values + jsr getFileLength ; return A, X, Y RES : 4 bytes values ; Send A X Y RES (from getFileLength) jsr _set_to_value_seek_file - lda #EOK ; Return ok + jsr returns_position + rts @error_bad_seek: + ; lda #$FF ; EBADSEEK + + lda #$FF + tax + sta RES + sta RES + 1 - lda #$FF ; EBADSEEK rts +; SEEK_CUR : Seek from the current position @move: ; A : TR0 ; Y : TR7 ; 16 to 31 : RES5 (2 bytes) - - lda KERNEL_XFSEEK_SAVE_RES jsr compute_fp_struct @@ -117,7 +147,6 @@ sta (KERNEL_XOPEN_PTR1),y sta TR7 - iny lda (KERNEL_XOPEN_PTR1),y adc RES5 @@ -126,7 +155,7 @@ iny lda (KERNEL_XOPEN_PTR1),y - adc RES5+1 + adc RES5 + 1 sta (KERNEL_XOPEN_PTR1),y sta RESB @@ -137,9 +166,11 @@ cmp #$14 bne @error_bad_seek - lda #EOK ; Return ok + jsr returns_position + rts +; SEEK_SET : Seek from the beginning of the file @go_beginning: ;sta TR6 ; Seek from the beginning of the file @@ -152,7 +183,7 @@ bne @error_bad_seek ; And seek with offset now - lda RES5+1 + lda RES5 + 1 sta RESB ldy TR7 ; Get Y @@ -192,6 +223,28 @@ adc RES5+1 sta (KERNEL_XOPEN_PTR1),y - lda #EOK ; Return ok + jsr returns_position + rts + +returns_position: + ldy #_KERNEL_FILE::f_seek_file + 3 + + ; Get the position of the file pointer + ;; Store it in RES for from 16 to 31 bits + lda (KERNEL_XOPEN_PTR1),y + sta RES + dey + ; Store it in AX for from 0 to 15 bits + lda (KERNEL_XOPEN_PTR1),y + sta RES + 1 + dey + lda (KERNEL_XOPEN_PTR1),y + tax + dey + lda (KERNEL_XOPEN_PTR1),y + + rts + + .endproc diff --git a/src/functions/memory/xmalloc.asm b/src/functions/memory/xmalloc.asm index c1dea421..d0a29d51 100644 --- a/src/functions/memory/xmalloc.asm +++ b/src/functions/memory/xmalloc.asm @@ -57,7 +57,7 @@ jsr kdebug_restore .endif - cpy kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high ; Does High value of the number of the malloc is greater than the free memory ? + cpy kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high ; Does High value of the number of the malloc is greater than the free memory ? bcc @allocate @exit_null: ; If yes, then we have no memory left, return NULL @@ -78,7 +78,7 @@ @looking_for_busy_chunck_available: ; Try to find a place to set the pid value - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_pid_list,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_pid_list,x ;cmp #$FF ; UNCOMMENT MAX_PROCESS beq @found inx @@ -90,64 +90,64 @@ lda TR7 ; get low byte of size (store the size) ; Store the size in the busy table - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x tya ; Get high byte of the size and store - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x ; store the length (low) + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x ; store the length (low) - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_low - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_low + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x ; Compute the end of the busy address clc - adc kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x + adc kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x bcc @skip2 - inc kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x + inc kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x @skip2: - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_low ; update of the next chunk available + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_low ; update of the next chunk available - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x clc - adc kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x + adc kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x ; FIXME for 32 bits mode in the future - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high ; update now the memory available in the chunk memory free ; - lda kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low ; $566 $BE $45 $30 + lda kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low ; $566 $BE $45 $30 sec - sbc kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x ; X=3 X=4 $24 $EB + sbc kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x ; X=3 X=4 $24 $EB bcs @skip3 - dec kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high ; $561 + dec kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high ; $561 @skip3: - sta kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low ; $45 $24 + sta kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low ; $45 $24 - lda kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high ; $561 $84 $84 + lda kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high ; $561 $84 $84 sec - sbc kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x ; $557 X=3 + sbc kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x ; $557 X=3 ; FIXME 32 bits - sta kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high ; $84 ; $84 + sta kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high ; $84 ; $84 ; Ok now inc the next free memory offset - inc kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_low + inc kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_low bne @skip4 - inc kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high + inc kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high @skip4: - lda kernel_process+kernel_process_struct::kernel_current_process + lda kernel_process + kernel_process_struct::kernel_current_process @store: - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_pid_list,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_pid_list,x ; Restore type @@ -159,17 +159,17 @@ .ifdef WITH_DEBUG jsr kdebug_save - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x - ldy kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x + ldy kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x - ldx #3 + ldx #$03 jsr xdebug_print_with_ay jsr kdebug_restore .endif - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x - ldy kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x + ldy kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x rts .endproc diff --git a/src/functions/process/kernel_exec_from_storage.asm b/src/functions/process/kernel_exec_from_storage.asm index 31d90c75..4e42eec8 100644 --- a/src/functions/process/kernel_exec_from_storage.asm +++ b/src/functions/process/kernel_exec_from_storage.asm @@ -111,7 +111,7 @@ clc adc RESC bcc @S20 - inc RESC+1 + inc RESC + 1 @S20: sta RESC @@ -229,24 +229,26 @@ open_binary_and_exec: @not_null2: + ; $0A05 ; RESD contains pointer to header and the length is equal to the file to load sta RESD - sty RESD+1 ; $842 + sty RESD + 1 ; $842 $3B23 sta PTR_READ_DEST - sty PTR_READ_DEST+1 + sty PTR_READ_DEST + 1 ; Save in order to compute nb_bytes_read sta RESC - sty RESC+1 + sty RESC + 1 ; save RESD - ldx kernel_process+kernel_process_struct::kernel_current_process + ; Get current process + ldx kernel_process + kernel_process_struct::kernel_current_process jsr kernel_get_struct_process_ptr sta KERNEL_CREATE_PROCESS_PTR1 - sty KERNEL_CREATE_PROCESS_PTR1+1 + sty KERNEL_CREATE_PROCESS_PTR1 + 1 ldy #kernel_one_process_struct::kernel_process_addr lda RESD @@ -331,11 +333,11 @@ open_binary_and_exec: rts @free: lda RESD - ldy RESD+1 + ldy RESD + 1 jsr XFREE_ROUTINE lda RESF - ldy RESF+1 + ldy RESF + 1 jsr XCLOSE_ROUTINE jmp @kill_and_exit @@ -349,20 +351,21 @@ open_binary_and_exec: ; Now get the execution address - ldx kernel_process+kernel_process_struct::kernel_current_process + ldx kernel_process + kernel_process_struct::kernel_current_process jsr kernel_get_struct_process_ptr sta KERNEL_CREATE_PROCESS_PTR1 sty KERNEL_CREATE_PROCESS_PTR1 + 1 ldy #kernel_one_process_struct::kernel_process_addr + ; $3AB1 + lda (KERNEL_CREATE_PROCESS_PTR1),y + ; Ici c'est transformé en $1F sta RESE iny lda (KERNEL_CREATE_PROCESS_PTR1),y - sta RESE+1 + sta RESE + 1 ; - - jmp @run ; Format 1 : static adress @@ -379,7 +382,6 @@ open_binary_and_exec: sta PTR_READ_DEST ; init RES to start code - ldy #18 lda (RESD),y ; fixme 65c02 sta RESE @@ -410,7 +412,7 @@ open_binary_and_exec: jsr @execute - stx HRS2+1 + stx HRS2 + 1 pha ; Save return code $91e ldy #kernel_one_process_struct::kernel_process_addr diff --git a/src/kernel.asm b/src/kernel.asm index c29fe727..0ba34619 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -1,6 +1,6 @@ .FEATURE labels_without_colons, pc_assignment, loose_char_term, org_per_seg -.define VERSION "2025.2" +.define VERSION "2025.X" .include "telestrat.inc" ; from cc65 .include "fcntl.inc" ; from cc65 @@ -18,8 +18,6 @@ .include "include/ori2.inc" .include "versions/versions.inc" - - .export code_adress_419 .export VEXBNK .export code_adress_436 diff --git a/tests/file_operations/file_operations.sub b/tests/file_operations/file_operations.sub new file mode 100644 index 00000000..fdcee16b --- /dev/null +++ b/tests/file_operations/file_operations.sub @@ -0,0 +1,15 @@ +#! /bin/submit +touch tfseek.sta + +echo ^[TTest FSEEK (.c), seek (asm), ftell (.c)^[Tand ftell (asm) + +tfseek +echo "err = $errorlevel" +if errorlevel=0 goto fseeknext + +:fseekerr +echo " ^[ANOK" +goto egeneral + +:fseeknext +echo Fseek ok ^[B [OK] diff --git a/tests/file_operations/fseek_test.c b/tests/file_operations/fseek_test.c index 4e4a1650..643575a6 100644 --- a/tests/file_operations/fseek_test.c +++ b/tests/file_operations/fseek_test.c @@ -1,14 +1,37 @@ #include +#include +#include -main() { +int main() { FILE *fp; + unsigned int result; + long position; - fp=fopen("/bin/file","r") - if (fp==null) { + //return 1; + // Open a file for reading + fp = fopen("/bin/file", "r"); + if (fp == NULL) { printf("Error opened"); - exit(); + exit(1); } - fseek(fp,10,SEEK_SET); + result = fseek(fp, 10, SEEK_SET); + if (result != 0) { + fclose(fp); + printf("fseek failed \n"); + return 1; // error fseek + } + else { + printf("fseek succeeded\n"); + position = ftell(fp); + printf("Position fseek : %ld\n", position); + if (position != 10) { + printf("return value for ftell is wrong\n"); + fclose(fp); + return 2; // Exit with error code + } + } + fclose(fp); + return 0; // Exit with success code } diff --git a/tests/fwrite.c b/tests/file_operations/fwrite.c similarity index 94% rename from tests/fwrite.c rename to tests/file_operations/fwrite.c index e43b4ead..d00f8d69 100644 --- a/tests/fwrite.c +++ b/tests/file_operations/fwrite.c @@ -1,7 +1,7 @@ #include #include -main () { +int main () { unsigned char buf[]={'a','b','c','d'}; FILE *fp; unsigned int nb; diff --git a/tests/readdir.c b/tests/file_operations/readdir.c similarity index 100% rename from tests/readdir.c rename to tests/file_operations/readdir.c diff --git a/tests/xmkdir.asm b/tests/file_operations/xmkdir.asm similarity index 100% rename from tests/xmkdir.asm rename to tests/file_operations/xmkdir.asm diff --git a/tests/xrm.asm b/tests/file_operations/xrm.asm similarity index 100% rename from tests/xrm.asm rename to tests/file_operations/xrm.asm From 2b5fa4c9592db2b0ead946740948d5610694042c Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 23 Jul 2025 23:19:24 +0200 Subject: [PATCH 24/49] fix missing for action --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ff3d4223..8b71a26d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -80,7 +80,7 @@ jobs: - name: Prepare environment for oricutron if: steps.cache-sdk.outputs.cache-hit != 'true' run: | - sudo apt-get install -y xvfb libgtk-3-0 libgtk-3-dev libsdl1.2debian libsdl1.2-dev + sudo apt-get install --fix-missing -y xvfb libgtk-3-0 libgtk-3-dev libsdl1.2debian libsdl1.2-dev git clone https://github.com/pete-gordon/oricutron.git cd oricutron && make && pwd && cd .. && ls -l && echo ${GITHUB_WORKSPACE} echo Timeout oricutron : $secret.TMOUT_ORICUTRON From 74cb9e1b8784bc9aab980604031c49932a4387b3 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 23 Jul 2025 23:23:29 +0200 Subject: [PATCH 25/49] fix update github action --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8b71a26d..8e5c9263 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -80,6 +80,7 @@ jobs: - name: Prepare environment for oricutron if: steps.cache-sdk.outputs.cache-hit != 'true' run: | + sudo apt-get update sudo apt-get install --fix-missing -y xvfb libgtk-3-0 libgtk-3-dev libsdl1.2debian libsdl1.2-dev git clone https://github.com/pete-gordon/oricutron.git cd oricutron && make && pwd && cd .. && ls -l && echo ${GITHUB_WORKSPACE} From 0afda3cb3da036d5349a71e2be2e2862f18522db Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 23 Jul 2025 23:30:44 +0200 Subject: [PATCH 26/49] test bpm --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8e5c9263..47db7a63 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -139,6 +139,8 @@ jobs: # cp bpm/src/bpm ~/bin # chmod 755 ~/bin/bpm && export PATH=$PATH:~/bin ls -l && ls -l ../ + echo ls ~/bin + ls -l ~/bin mv cc65 ../ && mv orix-software ../ && mv orix-sdk ../ && mv md2hlp ../ && mv bpm ../ - name: Compile project From 7d3f5682b53ff7d819139ebf09e9cb4694bc3674 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 23 Jul 2025 23:31:21 +0200 Subject: [PATCH 27/49] fix test --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 47db7a63..ef811193 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -141,6 +141,9 @@ jobs: ls -l && ls -l ../ echo ls ~/bin ls -l ~/bin + echo $PATH + PATH=$PATH:~/bin + echo $PATH mv cc65 ../ && mv orix-software ../ && mv orix-sdk ../ && mv md2hlp ../ && mv bpm ../ - name: Compile project From 3ce8609e075e5f4222b83507d27f94c89f22d7e2 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 23 Jul 2025 23:48:00 +0200 Subject: [PATCH 28/49] fix bpm --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ef811193..3ba0f844 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -136,14 +136,14 @@ jobs: run: | mkdir ~/bin cd bpm && pip install -r requirements.txt && cd .. - # cp bpm/src/bpm ~/bin - # chmod 755 ~/bin/bpm && export PATH=$PATH:~/bin + cp bpm/src/bpm ~/bin + chmod 755 ~/bin/bpm && export PATH=$PATH:~/bin ls -l && ls -l ../ echo ls ~/bin ls -l ~/bin echo $PATH - PATH=$PATH:~/bin - echo $PATH + #PATH=$PATH:~/bin + #echo $PATH mv cc65 ../ && mv orix-software ../ && mv orix-sdk ../ && mv md2hlp ../ && mv bpm ../ - name: Compile project From b259a98e553271d9c1a8f45f0b24c8d102c02bdb Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 23 Jul 2025 23:58:31 +0200 Subject: [PATCH 29/49] test --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3ba0f844..fd153d21 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -136,6 +136,7 @@ jobs: run: | mkdir ~/bin cd bpm && pip install -r requirements.txt && cd .. + echo cp bpm/src/bpm ~/bin cp bpm/src/bpm ~/bin chmod 755 ~/bin/bpm && export PATH=$PATH:~/bin ls -l && ls -l ../ @@ -147,7 +148,9 @@ jobs: mv cc65 ../ && mv orix-software ../ && mv orix-sdk ../ && mv md2hlp ../ && mv bpm ../ - name: Compile project - run: CC65_HOME=${GITHUB_WORKSPACE}/../cc65 make + run: | + PATH=$PATH:~/bin + CC65_HOME=${GITHUB_WORKSPACE}/../cc65 make - name: List build directory content run: ls -lR build From 66bfb827cfd04e39c719436091c3decb57c1cbbc Mon Sep 17 00:00:00 2001 From: jede Date: Thu, 24 Jul 2025 00:03:29 +0200 Subject: [PATCH 30/49] fix --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd153d21..4ce2737f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -150,6 +150,8 @@ jobs: - name: Compile project run: | PATH=$PATH:~/bin + bpm --force-update + bpm update CC65_HOME=${GITHUB_WORKSPACE}/../cc65 make - name: List build directory content From 7494a7ddac3d8e60b0fa1e709369259b8bcbee9d Mon Sep 17 00:00:00 2001 From: jede Date: Mon, 28 Jul 2025 00:05:49 +0200 Subject: [PATCH 31/49] fix/bpm command --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ce2737f..5a547e4d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -150,7 +150,7 @@ jobs: - name: Compile project run: | PATH=$PATH:~/bin - bpm --force-update + bpm --force-update --replace-for-new-project bpm update CC65_HOME=${GITHUB_WORKSPACE}/../cc65 make From e6630ee952daa1fc8e19566406d007d9bb58b039 Mon Sep 17 00:00:00 2001 From: jede Date: Mon, 28 Jul 2025 00:17:16 +0200 Subject: [PATCH 32/49] fix --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5a547e4d..ead5d98e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -151,7 +151,7 @@ jobs: run: | PATH=$PATH:~/bin bpm --force-update --replace-for-new-project - bpm update + cd src/kernel8 && bpm update cd ../../ CC65_HOME=${GITHUB_WORKSPACE}/../cc65 make - name: List build directory content From 896ebf97e9c71ffffbe6ba2c0e1117474084299f Mon Sep 17 00:00:00 2001 From: jede Date: Mon, 28 Jul 2025 23:56:31 +0200 Subject: [PATCH 33/49] fix --- .gitignore | 1 + .../ch395/etc/bpm/ch395/2024.4/bpm.tml | 10 -- .../ch395/etc/bpm/ch395/2024.4/bpm.tpl | 10 -- .../orixlibs/ch395/usr/include/asm/ch395.inc | 160 ------------------ .../orixlibs/ch395/usr/include/ch395.h | 121 ------------- .../ch395/usr/share/ch395/2024.4/README.md | 21 --- .../ksocket/etc/bpm/ksocket/2024.4/bpm.tml | 21 --- .../ksocket/etc/bpm/ksocket/2024.4/bpm.tpl | 21 --- .../ksocket/etc/bpm/ksocket/2025.1/bpm.tml | 21 --- .../ksocket/etc/bpm/ksocket/2025.1/bpm.tpl | 21 --- .../ksocket/etc/bpm/socket/2024.4/bpm.tml | 21 --- .../ksocket/etc/bpm/socket/2024.4/bpm.tpl | 21 --- .../ksocket/usr/include/asm/socket.inc | 43 ----- .../ksocket/usr/include/asm/socket.mac | 65 ------- .../orixlibs/ksocket/usr/include/socket.h | 38 ----- .../usr/share/ksocket/2024.4/README.md | 13 -- .../usr/share/ksocket/2025.1/README.md | 13 -- .../ksocket/usr/share/socket/2024.4/README.md | 14 -- tests/unit_test/start.sub | 6 +- tests/unit_test/tail.sub | 2 + tests/unit_test/xopen.sub | 5 - 21 files changed, 7 insertions(+), 641 deletions(-) delete mode 100644 src/kernel8/orixlibs/ch395/etc/bpm/ch395/2024.4/bpm.tml delete mode 100644 src/kernel8/orixlibs/ch395/etc/bpm/ch395/2024.4/bpm.tpl delete mode 100644 src/kernel8/orixlibs/ch395/usr/include/asm/ch395.inc delete mode 100644 src/kernel8/orixlibs/ch395/usr/include/ch395.h delete mode 100644 src/kernel8/orixlibs/ch395/usr/share/ch395/2024.4/README.md delete mode 100644 src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2024.4/bpm.tml delete mode 100644 src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2024.4/bpm.tpl delete mode 100644 src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2025.1/bpm.tml delete mode 100644 src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2025.1/bpm.tpl delete mode 100644 src/kernel8/orixlibs/ksocket/etc/bpm/socket/2024.4/bpm.tml delete mode 100644 src/kernel8/orixlibs/ksocket/etc/bpm/socket/2024.4/bpm.tpl delete mode 100644 src/kernel8/orixlibs/ksocket/usr/include/asm/socket.inc delete mode 100644 src/kernel8/orixlibs/ksocket/usr/include/asm/socket.mac delete mode 100644 src/kernel8/orixlibs/ksocket/usr/include/socket.h delete mode 100644 src/kernel8/orixlibs/ksocket/usr/share/ksocket/2024.4/README.md delete mode 100644 src/kernel8/orixlibs/ksocket/usr/share/ksocket/2025.1/README.md delete mode 100644 src/kernel8/orixlibs/ksocket/usr/share/socket/2024.4/README.md create mode 100644 tests/unit_test/tail.sub diff --git a/.gitignore b/.gitignore index f9e3f544..c60fd7bf 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ tmp/ *.log build.inc *.bin +src/kernel8/orixlibs/* 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 deleted file mode 100644 index f4123cfd..00000000 --- a/src/kernel8/orixlibs/ch395/etc/bpm/ch395/2024.4/bpm.tml +++ /dev/null @@ -1,10 +0,0 @@ -[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 deleted file mode 100644 index f4123cfd..00000000 --- a/src/kernel8/orixlibs/ch395/etc/bpm/ch395/2024.4/bpm.tpl +++ /dev/null @@ -1,10 +0,0 @@ -[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 deleted file mode 100644 index 06115414..00000000 --- a/src/kernel8/orixlibs/ch395/usr/include/asm/ch395.inc +++ /dev/null @@ -1,160 +0,0 @@ -; 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 deleted file mode 100644 index 8404344b..00000000 --- a/src/kernel8/orixlibs/ch395/usr/include/ch395.h +++ /dev/null @@ -1,121 +0,0 @@ -//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 deleted file mode 100644 index bb2a407e..00000000 --- a/src/kernel8/orixlibs/ch395/usr/share/ch395/2024.4/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# 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 -* Si le cable est branché, mais le ch395 n'est pas initialisé, jamais le cable apparaitra branché sur le ch395 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 deleted file mode 100644 index 261295ac..00000000 --- a/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2024.4/bpm.tml +++ /dev/null @@ -1,21 +0,0 @@ -[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 deleted file mode 100644 index 261295ac..00000000 --- a/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2024.4/bpm.tpl +++ /dev/null @@ -1,21 +0,0 @@ -[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 deleted file mode 100644 index ea64ec58..00000000 --- a/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2025.1/bpm.tml +++ /dev/null @@ -1,21 +0,0 @@ -[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 deleted file mode 100644 index ea64ec58..00000000 --- a/src/kernel8/orixlibs/ksocket/etc/bpm/ksocket/2025.1/bpm.tpl +++ /dev/null @@ -1,21 +0,0 @@ -[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 deleted file mode 100644 index 5fd221f8..00000000 --- a/src/kernel8/orixlibs/ksocket/etc/bpm/socket/2024.4/bpm.tml +++ /dev/null @@ -1,21 +0,0 @@ -[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 deleted file mode 100644 index 5fd221f8..00000000 --- a/src/kernel8/orixlibs/ksocket/etc/bpm/socket/2024.4/bpm.tpl +++ /dev/null @@ -1,21 +0,0 @@ -[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 deleted file mode 100644 index f9c6987e..00000000 --- a/src/kernel8/orixlibs/ksocket/usr/include/asm/socket.inc +++ /dev/null @@ -1,43 +0,0 @@ - -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 deleted file mode 100644 index 76311459..00000000 --- a/src/kernel8/orixlibs/ksocket/usr/include/asm/socket.mac +++ /dev/null @@ -1,65 +0,0 @@ -; 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 #len - sta RES+1 - - lda #buf - jsr send -.endmacro - -.macro RECVFROM socket, buffer, len - ldx socket - lda #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 deleted file mode 100644 index 96a2a52b..00000000 --- a/src/kernel8/orixlibs/ksocket/usr/include/socket.h +++ /dev/null @@ -1,38 +0,0 @@ -#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 deleted file mode 100644 index 62621ec0..00000000 --- a/src/kernel8/orixlibs/ksocket/usr/share/ksocket/2024.4/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# 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 deleted file mode 100644 index 62621ec0..00000000 --- a/src/kernel8/orixlibs/ksocket/usr/share/ksocket/2025.1/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# 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 deleted file mode 100644 index 8952ba50..00000000 --- a/src/kernel8/orixlibs/ksocket/usr/share/socket/2024.4/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# 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/tests/unit_test/start.sub b/tests/unit_test/start.sub index 0ba8a614..8f70d0ce 100644 --- a/tests/unit_test/start.sub +++ b/tests/unit_test/start.sub @@ -1,6 +1,8 @@ #!/bin/submit +echo start -echo Salut +netchk -chain /bin/mainarg.sub 1 2 + +#exit diff --git a/tests/unit_test/tail.sub b/tests/unit_test/tail.sub new file mode 100644 index 00000000..53ec45f2 --- /dev/null +++ b/tests/unit_test/tail.sub @@ -0,0 +1,2 @@ +:egeneral +exit \ No newline at end of file diff --git a/tests/unit_test/xopen.sub b/tests/unit_test/xopen.sub index 2131c0ef..dfa80815 100644 --- a/tests/unit_test/xopen.sub +++ b/tests/unit_test/xopen.sub @@ -13,8 +13,3 @@ echo -n O_RDONLY & O_WRONLY|O_CREAT cp started starcop if exist /starcop echo ^[B [OK] - - - - - From 2eb28f4e9c3fa7c883a1dcb92478ebab555000d9 Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 29 Jul 2025 23:56:07 +0200 Subject: [PATCH 34/49] fix typo --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ead5d98e..57e26958 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -151,7 +151,7 @@ jobs: run: | PATH=$PATH:~/bin bpm --force-update --replace-for-new-project - cd src/kernel8 && bpm update cd ../../ + cd src/kernel8 && bpm update && cd ../../ CC65_HOME=${GITHUB_WORKSPACE}/../cc65 make - name: List build directory content From f96d85dbbc8051ae9fd04ff99fdf40ea254be1ea Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 30 Jul 2025 00:17:05 +0200 Subject: [PATCH 35/49] fix --- Makefile | 15 ++++++++++----- README.md | 7 +++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c392d295..1b605000 100644 --- a/Makefile +++ b/Makefile @@ -82,9 +82,14 @@ kernel: $(SOURCE) @$(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 tmp/kernel_bank0.ld65 -DWITH_SDCARD_FOR_ROOT=1 src/kernel_bank0.s $(ASFLAGS) > output.log - @$(AS) --verbose -s -tnone --debug-info -o tmp/kernelsd.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > output.log + + echo ici + @$(AS) --verbose -s --debug-info --cpu 6502 src/kernel8/src/kernel8.s -o tmp/kernel_bank8.ld65 $(ASFLAGS) > output.log + echo ici2 + @$(AS) --verbose -s --debug-info -o tmp/kernel_bank0.ld65 -DWITH_SDCARD_FOR_ROOT=1 src/kernel_bank0.s $(ASFLAGS) > output.log + @$(AS) --verbose -s --debug-info -o tmp/kernelsd.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > output.log + + echo ici3 @$(LD) -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 @cp kernel.rom kernelsd.rom @@ -100,9 +105,9 @@ kernel: $(SOURCE) @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 + @$(AS) --verbose -s --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 + @$(AS) --verbose -s --debug-info -o kernelus.ld65 $(SOURCE) $(ASFLAGS) > output.log diff --git a/README.md b/README.md index 7722d5f3..40e72649 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,10 @@ export ORICUTRON_PATH 2) make launch-unit-test + +## Test github action + +An docker image in tests/Dockerfile is available to test some stuff into Dockerenvironnement (in order to simulate github action behavior) + +docker build --no-cache -t kernelorix . + From ef04cd5755144ead7e2bd48ec0d7edc03a1e040d Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 30 Jul 2025 00:21:41 +0200 Subject: [PATCH 36/49] fix --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 1b605000..2c5af561 100644 --- a/Makefile +++ b/Makefile @@ -109,8 +109,6 @@ kernel: $(SOURCE) @echo "WITH_TWILIGHTE_BOARD">$(PATH_PACKAGE_ROM)/kernelus.lst @$(AS) --verbose -s --debug-info -o kernelus.ld65 $(SOURCE) $(ASFLAGS) > output.log - - compile_cc65: @echo "########################################################" @echo "# Compile C file with cc65 #" From 4ed3876bfa59568c456ae54898f6d51700a045b1 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 30 Jul 2025 00:25:51 +0200 Subject: [PATCH 37/49] fix/test --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 57e26958..63deada3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -161,6 +161,7 @@ jobs: run: | git clone https://github.com/orix-software/docker-unit-test.git cd docker-unit-test && bash install.sh ${GITHUB_WORKSPACE} && cd .. + make build-unit-test make prepare-unit-test cd ${GITHUB_WORKSPACE}/oricutron timeout --preserve-status 10 ./xvfb.sh || exit 0 From 4f620701030a41dfe4d87de73e52c50d5868b89b Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 30 Jul 2025 00:34:52 +0200 Subject: [PATCH 38/49] fix test --- Makefile | 12 ++++-------- tests/docker/Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ tests/unit_test/xrm.sub | 3 ++- 3 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 tests/docker/Dockerfile diff --git a/Makefile b/Makefile index 2c5af561..af64c4d1 100644 --- a/Makefile +++ b/Makefile @@ -79,17 +79,10 @@ kernel: $(SOURCE) @$(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 - - echo ici @$(AS) --verbose -s --debug-info --cpu 6502 src/kernel8/src/kernel8.s -o tmp/kernel_bank8.ld65 $(ASFLAGS) > output.log - echo ici2 @$(AS) --verbose -s --debug-info -o tmp/kernel_bank0.ld65 -DWITH_SDCARD_FOR_ROOT=1 src/kernel_bank0.s $(ASFLAGS) > output.log @$(AS) --verbose -s --debug-info -o tmp/kernelsd.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > output.log - - echo ici3 @$(LD) -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 @cp kernel.rom kernelsd.rom @@ -113,8 +106,11 @@ compile_cc65: @echo "########################################################" @echo "# Compile C file with cc65 #" @echo "########################################################" - @echo "FILE_TO_COMPILE: $(FILE_TO_COMPILE) FINAL_BIN: $(FINAL_BIN) " + @echo "FILE_TO_COMPILE: $(FILE_TO_COMPILE) FINAL_BIN: $(FINAL_BIN)" + @mkdir tmp/ + @echo Build $(FILE_TO_COMPILE) to tmp/$(FINAL_BIN)_1000.s @$(CC) $(CFLAGS) $(FILE_TO_COMPILE) -o tmp/$(FINAL_BIN)_1000.s + @echo Build $(FILE_TO_COMPILE) to tmp/$(FINAL_BIN)_2304.s @$(CC) $(CFLAGS) $(FILE_TO_COMPILE) -o tmp/$(FINAL_BIN)_2304.s @$(AS) $(CFLAGS) tmp/$(FINAL_BIN)_1000.s -o tmp/$(FINAL_BIN)_1000.o diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile new file mode 100644 index 00000000..b470e18d --- /dev/null +++ b/tests/docker/Dockerfile @@ -0,0 +1,37 @@ +# Utilise une image de base, par exemple Ubuntu +FROM ubuntu:latest + +# Installe Git +RUN apt-get update && apt-get install -y git pip python3 python3.12-venv + +# Clone un dépôt Git +#COPY ../../ /kernel +RUN git clone https://github.com/orix-software/kernel.git -b develop + +# Définit le répertoire de travail +WORKDIR /kernel + +RUN git clone https://github.com/orix-software/bpm + +RUN python3 -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" +#RUN python3 -m venv mon_env +#RUN source mon_env/bin/activate +RUN ls -l + +RUN cd bpm && pip install -r requirements.txt && cd .. +RUN mkdir ~/bin +RUN cp bpm/src/bpm ~/bin +RUN chmod 755 ~/bin/bpm +ENV PATH=$PATH:~/bin +# RUN echo $PATH +RUN echo "#!/bin/bash\nbpm --force-update --replace-for-new-project" > initscript.sh +#RUN echo "cd src/kernel8 && bpm update cd ../../" >> initscript.sh +# Commande par défaut à exécuter lorsque le conteneur démarre + +# Rendez le script exécutable +RUN chmod +x initscript.sh +# Exécutez le script au démarrage du conteneur +#ENTRYPOINT ["/kernel/initscript.sh"] + +CMD ["echo", "Le dépôt Git a été clonné avec succès."] \ No newline at end of file diff --git a/tests/unit_test/xrm.sub b/tests/unit_test/xrm.sub index 82cb8750..1e9207ec 100644 --- a/tests/unit_test/xrm.sub +++ b/tests/unit_test/xrm.sub @@ -9,4 +9,5 @@ exit :error_rm echo ^[A il y a un dysfonctionnement avec rm, le fichier n'a pas été supprimé -exit +goto egeneral + From b2bfefc8962b1b6631c2fa35ef942a9b2231864b Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 30 Jul 2025 00:40:45 +0200 Subject: [PATCH 39/49] fix debug --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index af64c4d1..75cc966f 100644 --- a/Makefile +++ b/Makefile @@ -107,7 +107,6 @@ compile_cc65: @echo "# Compile C file with cc65 #" @echo "########################################################" @echo "FILE_TO_COMPILE: $(FILE_TO_COMPILE) FINAL_BIN: $(FINAL_BIN)" - @mkdir tmp/ @echo Build $(FILE_TO_COMPILE) to tmp/$(FINAL_BIN)_1000.s @$(CC) $(CFLAGS) $(FILE_TO_COMPILE) -o tmp/$(FINAL_BIN)_1000.s @echo Build $(FILE_TO_COMPILE) to tmp/$(FINAL_BIN)_2304.s From 14b5b1ae454e1a23e8de58bab4721e33addaedf1 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 30 Jul 2025 00:46:37 +0200 Subject: [PATCH 40/49] fix/test --- .github/workflows/main.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 63deada3..2eb24d1b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -136,15 +136,8 @@ jobs: run: | mkdir ~/bin cd bpm && pip install -r requirements.txt && cd .. - echo cp bpm/src/bpm ~/bin cp bpm/src/bpm ~/bin chmod 755 ~/bin/bpm && export PATH=$PATH:~/bin - ls -l && ls -l ../ - echo ls ~/bin - ls -l ~/bin - echo $PATH - #PATH=$PATH:~/bin - #echo $PATH mv cc65 ../ && mv orix-software ../ && mv orix-sdk ../ && mv md2hlp ../ && mv bpm ../ - name: Compile project @@ -161,6 +154,7 @@ jobs: run: | git clone https://github.com/orix-software/docker-unit-test.git cd docker-unit-test && bash install.sh ${GITHUB_WORKSPACE} && cd .. + CC65_HOME=${GITHUB_WORKSPACE}/../cc65 make build-unit-test make prepare-unit-test cd ${GITHUB_WORKSPACE}/oricutron From 48f76ee03e82ad3cad098242b8ceebd3af4b98d0 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 30 Jul 2025 00:46:48 +0200 Subject: [PATCH 41/49] fix --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2eb24d1b..fc45650b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -154,7 +154,7 @@ jobs: run: | git clone https://github.com/orix-software/docker-unit-test.git cd docker-unit-test && bash install.sh ${GITHUB_WORKSPACE} && cd .. - CC65_HOME=${GITHUB_WORKSPACE}/../cc65 + CC65_HOME=${GITHUB_WORKSPACE}/../cc65 make build-unit-test make prepare-unit-test cd ${GITHUB_WORKSPACE}/oricutron From fe6ab4fe2096d2bf311c48d3ac29761735e6d663 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 30 Jul 2025 22:40:36 +0200 Subject: [PATCH 42/49] test --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fc45650b..cd6f3767 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -154,9 +154,8 @@ jobs: run: | git clone https://github.com/orix-software/docker-unit-test.git cd docker-unit-test && bash install.sh ${GITHUB_WORKSPACE} && cd .. - CC65_HOME=${GITHUB_WORKSPACE}/../cc65 - make build-unit-test - make prepare-unit-test + CC65_HOME=${GITHUB_WORKSPACE}/../cc65 make build-unit-test + CC65_HOME=${GITHUB_WORKSPACE}/../cc65 make prepare-unit-test cd ${GITHUB_WORKSPACE}/oricutron timeout --preserve-status 10 ./xvfb.sh || exit 0 From c181643301d7b0a397c1c611f179094bb54c6969 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 30 Jul 2025 22:47:58 +0200 Subject: [PATCH 43/49] fix --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 75cc966f..4c1f1cb0 100644 --- a/Makefile +++ b/Makefile @@ -117,6 +117,7 @@ compile_cc65: @$(LD) $(CFLAGS) tmp/$(FINAL_BIN)_1000.o -o tmp/$(FINAL_BIN)_1000 --start-addr 2048 telestrat.lib @$(LD) $(CFLAGS) tmp/$(FINAL_BIN)_2304.o -o tmp/$(FINAL_BIN)_2304 --start-addr 2304 telestrat.lib + @chmod +x dependencies/orix-sdk/bin/relocbin.py3 @dependencies/orix-sdk/bin/relocbin.py3 -o tmp/$(FINAL_BIN) -2 tmp/$(FINAL_BIN)_1000 tmp/$(FINAL_BIN)_2304 prepare-unit-test: From e0edf67db77372e76f64b654a66f53ac0a7372e6 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 30 Jul 2025 22:51:17 +0200 Subject: [PATCH 44/49] fix artifact --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cd6f3767..f75f93fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -206,7 +206,7 @@ jobs: # On pourrait faire l'extraction directement à la racine si VERSION est dans l'artifact - name: Download Artifact id: download - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: ${{ needs.build.outputs.repo_name }} path: artifact From b947d4ed02391f8b91d63e14b4164447f04173c4 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 30 Jul 2025 22:54:24 +0200 Subject: [PATCH 45/49] fix --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f75f93fe..c239e9d2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -206,7 +206,7 @@ jobs: # On pourrait faire l'extraction directement à la racine si VERSION est dans l'artifact - name: Download Artifact id: download - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ${{ needs.build.outputs.repo_name }} path: artifact From f68c6c0cf838f297a61d5c129fe2770163fad203 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 30 Jul 2025 23:41:42 +0200 Subject: [PATCH 46/49] fix/kernel --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4c1f1cb0..e6b51c2b 100644 --- a/Makefile +++ b/Makefile @@ -86,9 +86,10 @@ kernel: $(SOURCE) @$(LD) -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 @cp kernel.rom kernelsd.rom + @echo Build kernel bank 8 @$(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/kch395/usr/share/kch395/$(KCH395_LIB_VERSION)/kch395.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 kernel8.rom $(PATH_PACKAGE_ROM)/ @#@sed -re 's/al 00(.{4}) \.(.+)$$/\1 \2/' kernelsd.sym| sort > kernelsd2.sym > output.log @cp kernelsd.rom $(PATH_PACKAGE_ROM)/ From 17708c444e2628d30224d2c945b14b9051c28302 Mon Sep 17 00:00:00 2001 From: jede Date: Fri, 7 Nov 2025 23:38:59 +0100 Subject: [PATCH 47/49] fix bug when we close a second file --- Makefile | 24 +- run.sh | 2 +- .../bank_mng/switch_to_kernel_extended.s | 9 +- src/functions/charsets/charset.asm | 1 + src/functions/clock/_xreclk.asm | 1 + src/functions/clock/_xwrclk.asm | 2 +- src/functions/files/XOPEN.asm | 4 +- src/functions/files/_create_file_pointer.asm | 6 +- .../files/_set_to_add_value_seek_file.asm | 4 +- src/functions/files/_update_fp_position.asm | 11 +- src/functions/files/compute_path_relative.asm | 18 +- .../files/restore_position_into_file.asm | 4 +- src/functions/files/xclose.asm | 36 +- src/functions/files/xfseek.asm | 24 +- src/functions/files/xgetcwd.asm | 7 +- src/functions/files/xmkdir.asm | 114 +++---- src/functions/files/xread.asm | 9 +- src/functions/math/xlog.asm | 8 + src/functions/memory/xfree.asm | 24 +- src/functions/memory/xmalloc.asm | 91 ++++- src/functions/xdebug.asm | 47 +-- src/functions/xloadcharset.asm | 8 + src/headerorixcfg.bin | Bin 80 -> 0 bytes src/include/memory.inc | 2 + src/kernel.asm | 311 ++++++++++-------- src/kernel8/README.md | 20 ++ src/kernel8/src/kernel8.s | 18 +- src/kernel_main_memory.s | 1 + src/versions/versions.inc | 4 +- 29 files changed, 510 insertions(+), 300 deletions(-) create mode 100644 src/functions/math/xlog.asm delete mode 100644 src/headerorixcfg.bin create mode 100644 src/kernel8/README.md diff --git a/Makefile b/Makefile index e6b51c2b..295de0ac 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,9 @@ CFLAGS=-ttelestrat ASFLAGS=-ttelestrat LDFILES= +FILES_KERNEL7="tmp/xminma.o" + + all : init kernel memmap .PHONY : prepare_tmp all @@ -48,6 +51,10 @@ init: kernel: $(SOURCE) @mkdir -p tmp/ @cd src/kernel8 && bpm update && cd .. + + #echo "Building xdebug.lib" + #@$(AS) --cpu 6502 -tnone src/functions/xdebug.asm -o tmp/xdebug.o + @echo Rom are built in $(PATH_PACKAGE_ROM) @echo "########################################################" @echo "# Build kernelsd.rom for Twilighte board #" @@ -64,12 +71,24 @@ kernel: $(SOURCE) @$(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/xloadcharset.asm -o tmp/xloadcharset.o + @$(AS) --cpu 6502 -tnone src/functions/charsets/charset.asm -o tmp/charset.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.lib tmp/charset.o +# @$(AR) r tmp/kernel.lib tmp/xloadcharset.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 @@ -79,11 +98,14 @@ kernel: $(SOURCE) @$(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 +# @$(AR) r tmp/kernel_bank8.lib tmp/charset.o +# @$(AR) r tmp/kernel_bank8.lib tmp/xloadcharset.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 --debug-info --cpu 6502 src/kernel8/src/kernel8.s -o tmp/kernel_bank8.ld65 $(ASFLAGS) > output.log @$(AS) --verbose -s --debug-info -o tmp/kernel_bank0.ld65 -DWITH_SDCARD_FOR_ROOT=1 src/kernel_bank0.s $(ASFLAGS) > output.log @$(AS) --verbose -s --debug-info -o tmp/kernelsd.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > output.log - @$(LD) -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 + @$(LD) -C cfg/kernel.cfg -DWITH_SDCARD_FOR_ROOT=1 tmp/kernelsd.ld65 tmp/kernel_bank0.ld65 tmp/kernel_main_memory.ld65 tmp/kernel.lib tmp/charset.o tmp/xloadcharset.o -Ln tmp/kernelsd.sym -m tmp/memmap.txt -vm || exit 1 @cp kernel.rom kernelsd.rom @echo Build kernel bank 8 diff --git a/run.sh b/run.sh index b9ed6813..5c0b9365 100644 --- a/run.sh +++ b/run.sh @@ -113,7 +113,7 @@ CA65_INC=/usr/share/cc65/asminc/ # # dependencies/orix-sdk/bin/relocbin.py3 -o tmp/sfbtest -2 tmp/1000 tmp/1256 # # cp tmp/sfbtest $ORICUTRON_PATH/sdcard/bin/ -make unittest +make echo Build autoboot cl65 -ttelestrat tests/functions/network/netchk.s -o tmp/1000 --start-addr 2048 diff --git a/src/functions/bank_mng/switch_to_kernel_extended.s b/src/functions/bank_mng/switch_to_kernel_extended.s index 79b93254..f8d614dd 100644 --- a/src/functions/bank_mng/switch_to_kernel_extended.s +++ b/src/functions/bank_mng/switch_to_kernel_extended.s @@ -1,7 +1,7 @@ .include "telestrat.inc" .export switch_to_kernel_extended -.export switch_to_kernel_extended_fill_register +.export switch_to_kernel_extended_fill_register_bank8 .import KERNEL_SAVE_XEXEC_CURRENT_SET @@ -10,14 +10,13 @@ .segment "BANK7" .proc switch_to_kernel_extended - jsr switch_to_kernel_extended_fill_register + jsr switch_to_kernel_extended_fill_register_bank8 jmp $40C .endproc -.proc switch_to_kernel_extended_fill_register - +.proc switch_to_kernel_extended_fill_register_bank8 + ; Switch to bank 8 (extended mode) pha - lda $343 sta KERNEL_SAVE_XEXEC_CURRENT_SET diff --git a/src/functions/charsets/charset.asm b/src/functions/charsets/charset.asm index e2fb34b9..a3d7ee72 100644 --- a/src/functions/charsets/charset.asm +++ b/src/functions/charsets/charset.asm @@ -1,5 +1,6 @@ .export charset_text +.segment "BANK7" charset_text: ; ' ' .byte $00,$00,$00,$00,$00,$00,$00,$00 diff --git a/src/functions/clock/_xreclk.asm b/src/functions/clock/_xreclk.asm index 7342c603..dce1dc71 100644 --- a/src/functions/clock/_xreclk.asm +++ b/src/functions/clock/_xreclk.asm @@ -1,6 +1,7 @@ .proc _xreclk lda #$00 ldx #$04 + @loop: sta TIMED,x dex diff --git a/src/functions/clock/_xwrclk.asm b/src/functions/clock/_xwrclk.asm index 4e65f153..3a7730ac 100644 --- a/src/functions/clock/_xwrclk.asm +++ b/src/functions/clock/_xwrclk.asm @@ -2,7 +2,7 @@ php sei sta ADCLK - sty ADCLK+1 + sty ADCLK + 1 sec ror FLGCLK plp diff --git a/src/functions/files/XOPEN.asm b/src/functions/files/XOPEN.asm index 4ecd4ea6..2baefc46 100644 --- a/src/functions/files/XOPEN.asm +++ b/src/functions/files/XOPEN.asm @@ -60,7 +60,7 @@ stx RES+1 ; Save ptr sta XOPEN_RES_SAVE - stx XOPEN_RES_SAVE+1 + stx XOPEN_RES_SAVE + 1 ; save flag sty XOPEN_FLAGS @@ -77,7 +77,7 @@ @open_new_file: .ifdef WITH_DEBUG2 jsr kdebug_save - ldy XOPEN_RES_SAVE+1 + ldy XOPEN_RES_SAVE + 1 ldx #XDEBUG_XOPEN_ENTER jsr xdebug_print_with_ay_string jsr kdebug_restore diff --git a/src/functions/files/_create_file_pointer.asm b/src/functions/files/_create_file_pointer.asm index a1a6fcda..14df442d 100644 --- a/src/functions/files/_create_file_pointer.asm +++ b/src/functions/files/_create_file_pointer.asm @@ -14,7 +14,7 @@ .out .sprintf("|CALL:XMALLOC:_create_file_pointer") sta RES - sty RES+1 + sty RES + 1 .ifdef WITH_DEBUG2 jsr kdebug_save @@ -42,10 +42,10 @@ @not_null_2: sta KERNEL_XOPEN_PTR1 ; save ptr - sty KERNEL_XOPEN_PTR1+1 + sty KERNEL_XOPEN_PTR1 + 1 sta KERNEL_XOPEN_PTR2 ; save ptr - sty KERNEL_XOPEN_PTR2+1 + sty KERNEL_XOPEN_PTR2 + 1 ldy #_KERNEL_FILE::f_flags ; get Offset diff --git a/src/functions/files/_set_to_add_value_seek_file.asm b/src/functions/files/_set_to_add_value_seek_file.asm index f3234755..4447f64d 100644 --- a/src/functions/files/_set_to_add_value_seek_file.asm +++ b/src/functions/files/_set_to_add_value_seek_file.asm @@ -7,13 +7,13 @@ lda RES sta (KERNEL_XOPEN_PTR1),y iny - lda RES+1 + lda RES + 1 sta (KERNEL_XOPEN_PTR1),y iny lda RESB sta (KERNEL_XOPEN_PTR1),y iny - lda RESB+1 + lda RESB + 1 sta (KERNEL_XOPEN_PTR1),y rts .endproc diff --git a/src/functions/files/_update_fp_position.asm b/src/functions/files/_update_fp_position.asm index 8f829b41..388277b8 100644 --- a/src/functions/files/_update_fp_position.asm +++ b/src/functions/files/_update_fp_position.asm @@ -5,8 +5,8 @@ lda PTR_READ_DEST sbc RES tay - lda PTR_READ_DEST+1 - sbc RES+1 + lda PTR_READ_DEST + 1 + sbc RES + 1 tax tya @@ -16,7 +16,7 @@ ; Save length sta XOPEN_RES - stx XOPEN_RES+1 + stx XOPEN_RES + 1 ; compute fp lda KERNEL_XWRITE_XCLOSE_XFSEEK_XFREAD_SAVE_X @@ -42,11 +42,10 @@ jsr inc_byte_superior bcc @no_inc_byte2 - @no_inc_byte2: ldy #(_KERNEL_FILE::f_seek_file+1) lda (KERNEL_XOPEN_PTR1),y - adc XOPEN_RES+1 + adc XOPEN_RES + 1 sta (KERNEL_XOPEN_PTR1),y ; update byte 2 of the file position bcc @no_inc_byte3 @@ -59,7 +58,7 @@ @no_inc_byte3: lda XOPEN_RES - ldx XOPEN_RES+1 + ldx XOPEN_RES + 1 rts inc_byte_superior: diff --git a/src/functions/files/compute_path_relative.asm b/src/functions/files/compute_path_relative.asm index eb8ec249..55e08e8d 100644 --- a/src/functions/files/compute_path_relative.asm +++ b/src/functions/files/compute_path_relative.asm @@ -9,7 +9,7 @@ .out .sprintf("|MODIFY:RESF:compute_path_relative") sta RESE - sty RESE+1 + sty RESE + 1 ; Checking if ./ ldy #$01 ; We are looking if it's ./ @@ -90,13 +90,13 @@ ldx kernel_process+kernel_process_struct::kernel_current_process jsr kernel_get_struct_process_ptr sta RESD - sty RESD+1 + sty RESD + 1 lda #kernel_one_process_struct::cmdline clc adc RESD bcc @S1 - inc RESD+1 + inc RESD + 1 @S1: sta RESD @@ -118,15 +118,15 @@ sty RESF ; Backup position for cmdline ldy #$02 - sty RESF+1 ; backup position for string to copy + sty RESF + 1 ; backup position for string to copy @copy: - ldy RESF+1 + ldy RESF + 1 lda (RESE),y beq @out2 - inc RESF+1 + inc RESF + 1 ldy RESF cpy #KERNEL_LENGTH_MAX_CMDLINE beq @out2 @@ -159,7 +159,7 @@ @malloc_ok: ; Now copy sta RESF - sty RESF+1 + sty RESF + 1 ldy #$00 @@ -181,7 +181,7 @@ sta RESH ; Malloc is done lda RESF - ldy RESF+1 + ldy RESF + 1 ; A contains the compute rts @@ -193,6 +193,6 @@ ; Store cwd ptr into RESC sta RESC - sty RESC+1 + sty RESC + 1 rts .endproc diff --git a/src/functions/files/restore_position_into_file.asm b/src/functions/files/restore_position_into_file.asm index 66e874b0..2b4984e9 100644 --- a/src/functions/files/restore_position_into_file.asm +++ b/src/functions/files/restore_position_into_file.asm @@ -6,7 +6,7 @@ sta RES iny lda (KERNEL_XOPEN_PTR1),y - sta RES+1 + sta RES + 1 iny lda (KERNEL_XOPEN_PTR1),y tax @@ -15,7 +15,7 @@ sta RESB lda RES - ldy RES+1 + ldy RES + 1 jmp _ch376_seek_file32 diff --git a/src/functions/files/xclose.asm b/src/functions/files/xclose.asm index ad65ad3d..09b4a34a 100644 --- a/src/functions/files/xclose.asm +++ b/src/functions/files/xclose.asm @@ -1,12 +1,14 @@ .export XCLOSE_ROUTINE .proc XCLOSE_ROUTINE + ; $d046 + ; jmp XCLOSE_ROUTINE ; A contains FD ; Calls XFREE .out .sprintf("|MODIFY:RESB:XCLOSE_ROUTINE") .out .sprintf("|MODIFY:TR7:XCLOSE_ROUTINE") sta RESB - sty RESB+1 ; save fp + sty RESB + 1 ; save fp .ifdef WITH_DEBUG pha @@ -29,7 +31,7 @@ bcs @exit tax - lda kernel_process+kernel_process_struct::kernel_fd,x ; A contient l'id du process, X contient l'id du FD retranché de 3 + lda kernel_process + kernel_process_struct::kernel_fd,x ; A contient l'id du process, X contient l'id du FD retranché de 3 bne @found_fp_slot .ifdef WITH_DEBUG @@ -53,30 +55,34 @@ .endif txa ; Transfert fd 'id slot' - asl ; Multiply + asl ; Multiply * 2 tax ; remove fp from main struct .IFPC02 .pc02 - stz kernel_process+kernel_process_struct::fp_ptr,x + stz kernel_process + kernel_process_struct::fp_ptr,x inx - stz kernel_process+kernel_process_struct::fp_ptr,x + stz kernel_process + kernel_process_struct::fp_ptr,x .p02 .else lda #$00 - sta kernel_process+kernel_process_struct::fp_ptr,x + sta kernel_process + kernel_process_struct::fp_ptr,x inx - sta kernel_process+kernel_process_struct::fp_ptr,x + sta kernel_process + kernel_process_struct::fp_ptr,x .endif ; store pointer in process struct - ldx kernel_process+kernel_process_struct::kernel_current_process ; Get current process + ldx kernel_process + kernel_process_struct::kernel_current_process ; Get current process jsr kernel_get_struct_process_ptr - sta RESB - sty RESB+1 + sta RESB ; $741 + sty RESB + 1 - ldy #kernel_one_process_struct::fp_ptr + lda TR7 + asl + clc + adc #kernel_one_process_struct::fp_ptr + tay @try_to_find_a_free_fp_for_current_process: lda (RESB),y @@ -88,8 +94,10 @@ tay pla ; $7D5 + jsr XFREE_ROUTINE + ; Clear fp in current process ldy #kernel_one_process_struct::fp_ptr lda #$00 sta (RESB),y @@ -101,14 +109,14 @@ .IFPC02 .pc02 - stz kernel_process+kernel_process_struct::kernel_fd,x + stz kernel_process + kernel_process_struct::kernel_fd,x .p02 .else lda #$00 - sta kernel_process+kernel_process_struct::kernel_fd,x + sta kernel_process + kernel_process_struct::kernel_fd,x .endif - cpx kernel_process+kernel_process_struct::kernel_fd_opened ; does the fd sent is the current file opened ? if no, it's already close, then don't close it from ch376 + cpx kernel_process + kernel_process_struct::kernel_fd_opened ; does the fd sent is the current file opened ? if no, it's already close, then don't close it from ch376 beq close_in_ch376 rts diff --git a/src/functions/files/xfseek.asm b/src/functions/files/xfseek.asm index 0b499a1c..691245ce 100644 --- a/src/functions/files/xfseek.asm +++ b/src/functions/files/xfseek.asm @@ -77,6 +77,7 @@ beq @go_beginning ;lda #EINVAL ; Return error +@returns_minus_1: lda #$FF tax sta RES @@ -109,19 +110,13 @@ ; Send A X Y RES (from getFileLength) jsr _set_to_value_seek_file - jsr returns_position + jmp returns_position - rts @error_bad_seek: ; lda #$FF ; EBADSEEK + jmp @returns_minus_1 - lda #$FF - tax - sta RES - sta RES + 1 - - rts ; SEEK_CUR : Seek from the current position @move: @@ -166,9 +161,8 @@ cmp #$14 bne @error_bad_seek - jsr returns_position + jmp returns_position - rts ; SEEK_SET : Seek from the beginning of the file @go_beginning: @@ -223,9 +217,7 @@ adc RES5+1 sta (KERNEL_XOPEN_PTR1),y - jsr returns_position - - rts + ; Don't RTS here , we execute returns position returns_position: ldy #_KERNEL_FILE::f_seek_file + 3 @@ -233,17 +225,19 @@ returns_position: ; Get the position of the file pointer ;; Store it in RES for from 16 to 31 bits lda (KERNEL_XOPEN_PTR1),y - sta RES + sta RES + 1 dey ; Store it in AX for from 0 to 15 bits lda (KERNEL_XOPEN_PTR1),y - sta RES + 1 + sta RES dey lda (KERNEL_XOPEN_PTR1),y tax dey lda (KERNEL_XOPEN_PTR1),y + ; FIXME REMOVE ME !!!!! + ldy #EOK rts diff --git a/src/functions/files/xgetcwd.asm b/src/functions/files/xgetcwd.asm index 828f7a19..a5fe0a58 100644 --- a/src/functions/files/xgetcwd.asm +++ b/src/functions/files/xgetcwd.asm @@ -10,18 +10,17 @@ jsr kernel_get_struct_process_ptr sta RESB - sty RESB+1 - + sty RESB + 1 lda #kernel_one_process_struct::cwd_str clc adc RESB bcc @S1 - inc RESB+1 + inc RESB + 1 @S1: ; A contains the compute - ldy RESB+1 + ldy RESB + 1 rts .endproc diff --git a/src/functions/files/xmkdir.asm b/src/functions/files/xmkdir.asm index 08279a22..cd5cc55a 100644 --- a/src/functions/files/xmkdir.asm +++ b/src/functions/files/xmkdir.asm @@ -29,8 +29,8 @@ lda KERNEL_ERRNO rts -@skip2: +@skip2: lda #CH376_SET_FILE_NAME sta CH376_COMMAND ldy #$00 @@ -78,60 +78,60 @@ @isabsolute: rts - lda ADDRESS_READ_BETWEEN_BANK_DOUBLON - ldy #O_RDONLY - ldx ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 - - jmp XOPEN_ROUTINE - - lda #CH376_SET_FILE_NAME ;$2f - sta CH376_COMMAND - lda #"/" - sta CH376_DATA - - STZ_ABS CH376_DATA - - jsr _ch376_file_open - - lda #CH376_SET_FILE_NAME ;$2f - sta CH376_COMMAND - - ldy #$00 ; skip / - -@next_folder: - ldx #$00 -@next_char: - iny - lda (ADDRESS_READ_BETWEEN_BANK_DOUBLON),y - beq @end - cmp #"/" - beq @create_dir - ; FIXME XMINMA - cmp #"a" ; 'a' - bcc @skip - cmp #$7B ; 'z' - bcs @skip - sbc #$1F -@skip: - sta CH376_DATA - - - inx - bne @next_char -@end: - ; Create last folder - ; Store 0 - sta CH376_DATA - - jsr _ch376_dir_create - jmp _ch376_file_close - lda #$00 - rts - -@create_dir: - sta CH376_DATA - sty TR7 ; Save Y - jsr _ch376_dir_create - ldy TR7 - jmp @next_folder ; FIXME 65c02 + ; lda ADDRESS_READ_BETWEEN_BANK_DOUBLON + ; ldy #O_RDONLY + ; ldx ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + + ; jmp XOPEN_ROUTINE + + ; lda #CH376_SET_FILE_NAME ;$2f + ; sta CH376_COMMAND + ; lda #"/" + ; sta CH376_DATA + + ; STZ_ABS CH376_DATA + + ; jsr _ch376_file_open + + ; lda #CH376_SET_FILE_NAME ;$2f + ; sta CH376_COMMAND + + ; ldy #$00 ; skip / + +; @next_folder: +; ldx #$00 +; @next_char: +; iny +; lda (ADDRESS_READ_BETWEEN_BANK_DOUBLON),y +; beq @end +; cmp #"/" +; beq @create_dir +; ; FIXME XMINMA +; cmp #"a" ; 'a' +; bcc @skip +; cmp #$7B ; 'z' +; bcs @skip +; sbc #$1F +; @skip: +; sta CH376_DATA + + +; inx +; bne @next_char +; @end: +; ; Create last folder +; ; Store 0 +; sta CH376_DATA + +; jsr _ch376_dir_create +; jmp _ch376_file_close +; lda #$00 +; rts + +; @create_dir: +; sta CH376_DATA +; sty TR7 ; Save Y +; jsr _ch376_dir_create +; ldy TR7 +; jmp @next_folder ; FIXME 65c02 .endproc diff --git a/src/functions/files/xread.asm b/src/functions/files/xread.asm index 1b6befdf..23b54072 100644 --- a/src/functions/files/xread.asm +++ b/src/functions/files/xread.asm @@ -7,7 +7,7 @@ ; [IN] PTR_READ_DEST must be set because it's the ptr_dest ; [IN] X contains the fd id -; Modify : RES, PTR_READ_DEST, TR0 + ; Modify : RES, PTR_READ_DEST, TR0 @@ -19,12 +19,14 @@ ; Save PTR_READ_DEST to compute bytes + + pha lda PTR_READ_DEST sta RES ; lda PTR_READ_DEST+1 - sta RES+1 + sta RES + 1 ; Checking if fp exists jsr checking_fp_exists @@ -36,6 +38,7 @@ rts @continue_xfread: + pla jsr _ch376_set_bytes_read @@ -96,7 +99,7 @@ clc ; adc PTR_READ_DEST bcc @next - inc PTR_READ_DEST+1 + inc PTR_READ_DEST + 1 @next: sta PTR_READ_DEST diff --git a/src/functions/math/xlog.asm b/src/functions/math/xlog.asm new file mode 100644 index 00000000..9a0af72e --- /dev/null +++ b/src/functions/math/xlog.asm @@ -0,0 +1,8 @@ +.include "telestrat.inc" + +.export XLOG_ROUTINE + +.import XA1A2_ROUTINE +.import XAYA1_ROUTINE +.import XA2DA1_ROUTINE + diff --git a/src/functions/memory/xfree.asm b/src/functions/memory/xfree.asm index ce8c1bba..002ab550 100644 --- a/src/functions/memory/xfree.asm +++ b/src/functions/memory/xfree.asm @@ -2,6 +2,10 @@ ; DBF1 ; 6c6 b3ff ac3c +.import kdebug_save +.import xdebug_lsmem +.import kdebug_restore + .proc XFREE_ROUTINE ; A & Y ;@brief free memory routine @@ -13,7 +17,9 @@ sta KERNEL_XFREE_TMP ; Save A (low) sty HRS1 -.ifdef WITH_DEBUG +;.define WITH_DEBUG_FREE + +.ifdef WITH_DEBUG_TOTO jsr kdebug_save lda KERNEL_XFREE_TMP @@ -91,6 +97,7 @@ ; Looking for Free chunk available ldy #$01 + @find_a_free_chunk: lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y beq @free_chunk_is_available @@ -135,7 +142,7 @@ out: ; trying to merge with main chunk @exit: -.ifdef WITH_DEBUG +.ifdef WITH_DEBUG_FREE jsr kdebug_save jsr xdebug_lsmem jsr kdebug_restore @@ -240,22 +247,22 @@ out: ; X contient l'index du chunk busy qu'on va recopier dans libre ; On arrive ici parce qu'on n'a pas pu recoller avec un chunk déjà existant, donc on le popule - lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x ; 0 sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,y - lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x ; 4 sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y - lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x ; C4 sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_low,y - lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x ; 72 sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_high,y - lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x ; 00 sta kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low,y - lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x ; 00 sta kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y jsr xfree_clear_busy_chunk @@ -552,6 +559,7 @@ out: str_can_not_find_any_free_chunk_available: .asciiz "Free chunk slot error" + str_kernel_panic: .byte $0D .byte "KPANIC!" diff --git a/src/functions/memory/xmalloc.asm b/src/functions/memory/xmalloc.asm index d0a29d51..47c76269 100644 --- a/src/functions/memory/xmalloc.asm +++ b/src/functions/memory/xmalloc.asm @@ -2,6 +2,19 @@ .proc XMALLOC_ROUTINE + ;;@brief Perform a malloc in the kernel memory space (48K). Return NULL if no memory available + ;;@inputA contains the low byte of the length to allocate + ;;@inputX contains the high nbyte of the length to allocate + ;;@modifyMEM_TR6 + ;;@modifyMEM_TR7 + ;;@```asm + ;;@` lda #<5 + ;;@` ldy #>5 + ;;@` BRK_TELEMON XMALLOC + ;;@` rts + ;;@``` + + ; $fb64 .out .sprintf("|MODIFY:TR7:XMALLOC_ROUTINE") @@ -56,11 +69,12 @@ @O1: jsr kdebug_restore .endif - - cpy kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high ; Does High value of the number of the malloc is greater than the free memory ? + ; Does High value of the number of the malloc is greater than the free memory ? + cpy kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high bcc @allocate -@exit_null: ; If yes, then we have no memory left, return NULL + ; If yes, then we have no memory left, return NULL +@exit_null: ; we don't fix #ENOMEM, because null is returned already means OOM by default lda #ENOMEM sta KERNEL_ERRNO @@ -73,6 +87,7 @@ @allocate: ; found first available busy table sta TR7 ; Save A (low value of the malloc), Y is not saved because we don't modify it + sty TR6 ; Save Y (high value of the malloc) ldx #$00 @@ -87,16 +102,77 @@ bne @looking_for_busy_chunck_available @found: + ; X contains the PID position to keep PID of the current malloc + ; TR6 contains the high byte of the size to allocate + ; TR7 contains the low byte of the size to allocate + ; Trying to look if we have free slot available which is not used + ldy #$01 + +@looking_for_free_chunk_available: + + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y ; Check if begin high is busy, if it's zero, this slot is not used + beq @is_greater ; Not used we check nest free chunk + + lda kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y ; + cmp TR6 ; High + bcc @is_greater ; if freater than size (high byte), we can not use this chunk + ; Check low now + lda kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low,y ; + cmp TR7 ; Low + bcc @is_greater ; if greater or equal than size (low byte), + ; we can use this chunk, here we go, change it to busy chunk + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x + + lda kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x + + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,y + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x + + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x + + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_low,y + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x + + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_high,y + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x + ; Free slot now + lda #$00 + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y + jmp @return_pointer + + ; lda kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high,y + ; sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x + + ; lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,y + ; sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x + + ; lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,y + ; sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x + + ; lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_low,y + ; sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x + + ; lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_high,y + + +@is_greater: + iny + cpy #KERNEL_MALLOC_FREE_CHUNK_MAX + bne @looking_for_free_chunk_available + + +@malloc_from_first_free_chunk_main_memory: lda TR7 ; get low byte of size (store the size) ; Store the size in the busy table sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x - - tya ; Get high byte of the size and store + lda TR6 + ; tya ; Get high byte of the size and store sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x ; store the length (low) lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high - sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x @@ -104,7 +180,6 @@ sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x - ; Compute the end of the busy address clc adc kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x @@ -144,6 +219,7 @@ bne @skip4 inc kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_high + @skip4: lda kernel_process + kernel_process_struct::kernel_current_process @store: @@ -168,6 +244,7 @@ jsr kdebug_restore .endif +@return_pointer: lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x ldy kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x rts diff --git a/src/functions/xdebug.asm b/src/functions/xdebug.asm index d5eae270..13ae3033 100644 --- a/src/functions/xdebug.asm +++ b/src/functions/xdebug.asm @@ -1,11 +1,22 @@ +.export kdebug_save +.export xdebug_lsmem +.export kdebug_restore + +.include "../include/kernel.inc" +.include "../include/debug.inc" +.include "telestrat.inc" + +.import STACK_BANK +.import FIXME_DUNNO + .proc xdebug_print_with_a rts pha lda #<$c006 - sta VEXBNK+1 + sta VEXBNK + 1 lda #>$c006 - sta VEXBNK+2 + sta VEXBNK + 2 lda #$01 sta BNKCIB @@ -22,9 +33,9 @@ lda #$00 sta $343 lda #<$c009 - sta VEXBNK+1 + sta VEXBNK + 1 lda #>$c009 - sta VEXBNK+2 + sta VEXBNK + 2 lda #$01 sta BNKCIB pla @@ -59,8 +70,6 @@ sta VEXBNK+2 lda #$01 sta BNKCIB - - jmp $40C .endproc @@ -157,9 +166,9 @@ hex_table: jsr xdebug_save lda #'#' jsr xdebug_send_printer - lda kernel_debug+kernel_debug_struct::RY + lda kernel_debug + kernel_debug_struct::RY jsr xdebug_binhex - lda kernel_debug+kernel_debug_struct::RA + lda kernel_debug + kernel_debug_struct::RA jsr xdebug_binhex lda #' ' jsr xdebug_send_printer @@ -293,21 +302,19 @@ str_enter_free: .endproc .proc kdebug_save - - - sta kernel_debug+kernel_debug_struct::RA - stx kernel_debug+kernel_debug_struct::RX - sty kernel_debug+kernel_debug_struct::RY + sta kernel_debug + kernel_debug_struct::RA + stx kernel_debug + kernel_debug_struct::RX + sty kernel_debug + kernel_debug_struct::RY lda BNKCIB - sta kernel_debug+kernel_debug_struct::BNKCIB - lda VEXBNK+1 - sta kernel_debug+kernel_debug_struct::VEXBNK - lda VEXBNK+2 - sta kernel_debug+kernel_debug_struct::VEXBNK+1 + sta kernel_debug + kernel_debug_struct::BNKCIB + lda VEXBNK + 1 + sta kernel_debug + kernel_debug_struct::VEXBNK + lda VEXBNK + 2 + sta kernel_debug + kernel_debug_struct::VEXBNK + 1 lda BNKOLD - sta kernel_debug+kernel_debug_struct::BNKOLD + sta kernel_debug + kernel_debug_struct::BNKOLD lda FIXME_DUNNO - sta kernel_debug+kernel_debug_struct::FIXME_DUNNO + sta kernel_debug + kernel_debug_struct::FIXME_DUNNO ldx NEXT_STACK_BANK stx kernel_debug+kernel_debug_struct::NEXT_STACK_BANK diff --git a/src/functions/xloadcharset.asm b/src/functions/xloadcharset.asm index 98a2f8f9..77818524 100644 --- a/src/functions/xloadcharset.asm +++ b/src/functions/xloadcharset.asm @@ -1,4 +1,12 @@ + +.import charset_text + +.export XLOADCHARSET_ROUTINE + +.segment "BANK7" + .proc XLOADCHARSET_ROUTINE + ldx #$00 @loop: diff --git a/src/headerorixcfg.bin b/src/headerorixcfg.bin deleted file mode 100644 index 017c56fb14352b7209d37ba026fa203f6b872e4e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 80 UcmeZv4f1pK33d%(WS|NF0L#w;uK)l5 diff --git a/src/include/memory.inc b/src/include/memory.inc index 5ac8327e..a7a903db 100644 --- a/src/include/memory.inc +++ b/src/include/memory.inc @@ -8,6 +8,8 @@ .define KERNEL_RAM_BANK_APPLICATION_TYPE $01 ; The bank won't be destroyed when the process stops (example : bank) +.define KERNEL_LOAD_QWERTY_CHARSET $0C ; New function in bank 8 to load qwerty charset Called with XBANK + ; If struct is changed see xvars. diff --git a/src/kernel.asm b/src/kernel.asm index 0ba34619..e450e1fa 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -1,4 +1,4 @@ -.FEATURE labels_without_colons, pc_assignment, loose_char_term, org_per_seg +.FEATURE labels_without_colons, pc_assignment, loose_char_term, org_per_seg .define VERSION "2025.X" @@ -18,6 +18,8 @@ .include "include/ori2.inc" .include "versions/versions.inc" +.import charset_text +.import XLOADCHARSET_ROUTINE .export code_adress_419 .export VEXBNK .export code_adress_436 @@ -68,9 +70,10 @@ .import KERNEL_BANK_EXTENDED_AVAILABLE -.import switch_to_kernel_extended_fill_register +.import switch_to_kernel_extended_fill_register_bank8 .import kernel_restore_banking_states -.import kernel_restore_banking_states_register +.import kernel_restore_banking_states_register +;.import XLOADCHARSET_ROUTINE ; .import RESC ; .import RESD ; .import RESE @@ -203,6 +206,13 @@ start_rom: sta RETURN_BANK_READ_BYTE_FROM_OVERLAY_RAM jsr init_screens + +; @me: +; jmp @me + + ; lda #KERNEL_LOAD_QWERTY_CHARSET + ; jsr XBANK_ROUTINE + jsr XLOADCHARSET_ROUTINE jsr XALLKB_ROUTINE @@ -470,7 +480,7 @@ init_malloc_busy_table: MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_FLAG - jsr switch_to_kernel_extended_fill_register + jsr switch_to_kernel_extended_fill_register_bank8 lda #<($FFF0 + 1) ; Offset magic token ldy #>($FFF0 + 1) @@ -3411,6 +3421,7 @@ XSCHAR_ROUTINE: lda #$40 sta HRSFB ldy #$00 + @L1: sty HRS2 + 1 cpy HRS2 @@ -3441,14 +3452,18 @@ LEAB5: cmp #$08 bne Leacf lda #$00 + Leacf: tay + Lead0: jsr hires_put_coordinate + Lead3: pla jsr ZADCHA_ROUTINE ldy #$00 + Lead9: sty RES lda HRSX40 @@ -3457,16 +3472,19 @@ Lead9: pha lda (RESB),y asl + Leae4: asl beq Leaf3 pha bpl Leaed jsr LE79C + Leaed: jsr XHRSCD_ROUTINE pla bne Leae4 + Leaf3: jsr XHRSCB_ROUTINE pla @@ -3533,6 +3551,7 @@ LECB9: jsr LECB4 bcs LECB9 rts + Lecbf: sec .byt $24 @@ -3576,6 +3595,7 @@ add_0_5_A_ACC1: lda #const_zero_dot_half jmp AY_add_acc1 ; AY+acc1 + Lef97: rts @@ -3599,6 +3619,7 @@ XA1PA2_ROUTINE: ACC2_ADD_ACC1: bne @L1 jmp XA2A1_ROUTINE + @L1: tsx stx FLSVS @@ -3606,6 +3627,7 @@ ACC2_ADD_ACC1: stx TELEMON_UNKNWON_LABEL_7F ldx #$68 lda ACC2E + LEFC2: tay beq Lef97 @@ -3626,14 +3648,15 @@ LEFC2: @next801: ldy #$00 sty ACC1EX + @L2: cmp #$F9 bmi mantisse_A tay lda ACC1EX lsr RES + 1,x - jsr LF0FC + next802: bit ACCPS bpl Lf049 @@ -3641,6 +3664,7 @@ next802: cpx #$68 beq LEFFA ldy #$68 + LEFFA: sec eor #$FF @@ -3658,17 +3682,18 @@ LEFFA: lda $0001,y ; FIXME sbc RES + 1,x sta ACC1M + LF01D: bcs Lf022 - jsr Lf090 + Lf022: ldy #$00 tya clc + LF026: ldx ACC1M - bne LF074 ldx TELEMON_UNKNWON_LABEL_62 ; FIXME stx ACC1M @@ -3687,14 +3712,16 @@ LF026: adc #$08 cmp #$28 bne LF026 + Lf042: lda #$00 ; FIXME 65C02 sta ACC1E + LF046: sta ACC1S rts -Lf049: +Lf049: adc TELEMON_UNKNWON_LABEL_7F sta ACC1EX lda MENX @@ -3711,6 +3738,7 @@ Lf049: adc ACC2M sta ACC1M jmp Lf081 + Ld068: adc #$01 asl ACC1EX @@ -3718,6 +3746,7 @@ Ld068: rol MENDFY rol TELEMON_UNKNWON_LABEL_62 rol ACC1M + LF074: bpl Ld068 @@ -3728,23 +3757,26 @@ LF074: eor #$FF adc #$01 sta ACC1E + Lf081: bcc Lf08f + LF083: inc ACC1E - beq LF0C7 ror ACC1M ror TELEMON_UNKNWON_LABEL_62 ror MENDFY ror MENX + Lf08f: rts -Lf090: +Lf090: lda ACC1S eor #$FF sta ACC1S + LF096: lda ACC1M eor #$FF @@ -3763,6 +3795,7 @@ LF096: sta ACC1EX inc ACC1EX bne LF0C6 + LF0B8: inc MENX bne LF0C6 @@ -3771,11 +3804,13 @@ LF0B8: inc TELEMON_UNKNWON_LABEL_62 bne LF0C6 inc ACC1M + LF0C6: rts LF0C7: lda #$01 + LF0C9: sta FLERR ldx FLSVS @@ -3784,6 +3819,7 @@ LF0C9: justify__to_the_right_with_A_and_X: ldx #$6E + LF0D1: ldy DECDEB,x sty ACC1EX @@ -3795,6 +3831,7 @@ LF0D1: sty RESB,x ldy ACC1J sty RES + 1,x + LF0E5: adc #$08 bmi LF0D1 @@ -3803,13 +3840,16 @@ LF0E5: tay lda ACC1EX bcs LF106 + LF0F2: asl RES + 1,x bcc LF0F8 inc RES + 1,x + LF0F8: ror RES + 1,x ror RES + 1,x + LF0FC: ror RESB,x ror RESB + 1,x @@ -3817,16 +3857,17 @@ LF0FC: ror iny bne LF0F2 + LF106: clc rts - const_negative_zero_dot_five: .byt $80,$80,$00,$00,$00 ; -0.5 LF140: rts + LF141: lda #$02 jmp LF0C9 @@ -3859,11 +3900,13 @@ LF184: jsr LF1EC beq LF140 bne LF190 + XA1MA2_ROUTINE: beq LF140 tsx stx FLSVS + LF190: jsr LF217 lda #$00 @@ -3992,6 +4035,7 @@ Lf242 beq Lf23c Lf258: rts + ten_in_floating_point: .byt $84,$20,$00,$00,$00 ; Ten in floating point Lf25e: @@ -4006,7 +4050,11 @@ LF267 jsr XAYA1_ROUTINE jmp XA2DA1_ROUTINE -XLOG_ROUTINE: +.export XA1A2_ROUTINE +.export XAYA1_ROUTINE +.export XA2DA1_ROUTINE + +.proc XLOG_ROUTINE ;tsx stx FLSVS jsr LF149 @@ -4019,11 +4067,14 @@ display_divide_per_0: lda #$03 sta FLERR ; FLERR rts +.endproc + + Lf287: jsr LF1EC XA2DA1_ROUTINE: - beq display_divide_per_0 + beq XLOG_ROUTINE::display_divide_per_0 tsx stx FLSVS jsr XAA1_ROUTINE @@ -4141,6 +4192,7 @@ XAYA1_ROUTINE: sta ACC1E sty ACC1EX rts + LF348: ldx #$73 .byt $2C @@ -4963,120 +5015,117 @@ LFA10: .include "functions/charsets/charset_qwerty.asm" -.ifdef WITH_CHARSET_AZERTY -.include "functions/charsets/charset_azerty.asm" -.endif - -.include "functions/charsets/charset.asm" -.include "functions/xloadcharset.asm" - -codes_for_calc_alternates: - .byt $00,$38,$07,$3F - -XGOKBD_ROUTINE: - lda #$B9 ; index of alternate chars -.ifdef WITH_TWILIGHTE_BOARD -.else - bit FLGTEL - bpl @L1 - lda #$9D ; FILL CHARSET ? -@L1: -.endif - ldy #$00 - sty RES - sta RES + 1 - tya - -@loop: - pha - jsr put_an_alternate_char_in_memory - pla - clc - adc #$01 - cmp #$40 - bne @loop - - lda RES + 1 - sbc #$03 - sta TR0 - sbc #$04 - sta RES + 1 - lda #charset_text - sta RESB - sty RESB + 1 - ldy #$00 - -loop70: - ldx #$00 - lda (RESB,x) - tax - inc RESB - bne @L1 - inc RESB + 1 -@L1: - jsr routine_to_define_23 - - txa - and #$C0 - beq loop70 - cmp #$C0 - beq @S1 - cmp #$40 - beq next76 - jsr routine_to_define_23 - - .byt $2c -@S1: - ldx #$00 - -next76: - jsr routine_to_define_23 - bne loop70 - - -routine_to_define_23: - txa - and #$3F - sta (RES),y - iny - bne @skip - inc RES + 1 - lda RES + 1 - cmp TR0 - bne @skip - pla - pla -@skip: - rts - -put_an_alternate_char_in_memory: - ldx #$03 - stx RESB -next81: - pha - and #$03 - tax - lda codes_for_calc_alternates,x - sta (RES),y - iny - sta (RES),y - iny - ldx RESB - cpx #$02 - beq @skip - sta (RES),y - iny - bne @skip - inc RES + 1 - -@skip: - pla - lsr - lsr - dec RESB - bne next81 - rts +;.include "functions/charsets/charset.asm" +;.include "functions/xloadcharset.asm" + +; codes_for_calc_alternates: +; .byt $00,$38,$07,$3F + +; XGOKBD_ROUTINE: + +; lda #$B9 ; index of alternate chars +; .ifdef WITH_TWILIGHTE_BOARD +; .else +; bit FLGTEL +; bpl @L1 +; lda #$9D ; FILL CHARSET ? +; @L1: +; .endif +; ldy #$00 +; sty RES +; sta RES + 1 +; tya + +; @loop: +; pha +; jsr put_an_alternate_char_in_memory +; pla +; clc +; adc #$01 +; cmp #$40 +; bne @loop + +; lda RES + 1 +; sbc #$03 +; sta TR0 +; sbc #$04 +; sta RES + 1 +; lda #charset_text +; sta RESB +; sty RESB + 1 +; ldy #$00 + +; loop70: +; ldx #$00 +; lda (RESB,x) +; tax +; inc RESB +; bne @L1 +; inc RESB + 1 +; @L1: +; jsr routine_to_define_23 + +; txa +; and #$C0 +; beq loop70 +; cmp #$C0 +; beq @S1 +; cmp #$40 +; beq next76 +; jsr routine_to_define_23 + +; .byt $2c +; @S1: +; ldx #$00 + +; next76: +; jsr routine_to_define_23 +; bne loop70 + + +; routine_to_define_23: +; txa +; and #$3F +; sta (RES),y +; iny +; bne @skip +; inc RES + 1 +; lda RES + 1 +; cmp TR0 +; bne @skip +; pla +; pla +; @skip: +; rts + +; put_an_alternate_char_in_memory: +; ldx #$03 +; stx RESB +; next81: +; pha +; and #$03 +; tax +; lda codes_for_calc_alternates,x +; sta (RES),y +; iny +; sta (RES),y +; iny +; ldx RESB +; cpx #$02 +; beq @skip +; sta (RES),y +; iny +; bne @skip +; inc RES + 1 + +; @skip: +; pla +; lsr +; lsr +; dec RESB +; bne next81 +; rts move_chars_text_to_hires: ldy #$05 @@ -5193,15 +5242,7 @@ copy_ramoverlay_end: .error "XFREE can't be copied into RAMOVERLAY" .endif -.ifdef WITH_SDCARD_FOR_ROOT - KERN_SDCARD_FOR_ROOT_CONFIG=2 -.else - KERN_SDCARD_FOR_ROOT_CONFIG=0 -.endif -; Byte for compile options -kernel_compile_option: - .byt KERN_SDCARD_FOR_ROOT_CONFIG diff --git a/src/kernel8/README.md b/src/kernel8/README.md new file mode 100644 index 00000000..523719e4 --- /dev/null +++ b/src/kernel8/README.md @@ -0,0 +1,20 @@ +# How to add a new routine into bank8 + +* A is checked to switch to the function + +1) Declare id function in .inc KERNEL_LOAD_QWERTY_CHARSET (ex : src/include/memory.inc), the id must be greater than the previous id +2) Build your function, and store it in a folder and declare in the source file function .segment "BANK8" + +3) Add it in Makefile for example : @$(AS) --cpu 6502 -tnone src/functions/xloadcharset.asm -o tmp/xloadcharset.o +4) Add the check in src/kernel8.s : + +Ex : + cmp #KERNEL_LOAD_QWERTY_CHARSET ; $0C + beq @load_qwerty_charset_routine + +5) add in Makefile .o in kernel_bank8.lib @$(AR) r tmp/kernel_bank8.lib xloadcharset.o + +6) in kernel.asm, call it : + + lda #KERNEL_LOAD_QWERTY_CHARSET + jsr XBANK_routine diff --git a/src/kernel8/src/kernel8.s b/src/kernel8/src/kernel8.s index feccd2d1..929d4382 100644 --- a/src/kernel8/src/kernel8.s +++ b/src/kernel8/src/kernel8.s @@ -1,5 +1,7 @@ -;.FEATURE labels_without_colons, pc_assignment, loose_char_term, c_comments, org_per_seg +; See README.md for more details for bank 8 + + .FEATURE org_per_seg .include "telestrat.inc" @@ -14,6 +16,7 @@ .include "../../versions/versions.inc" +;.import XLOADCHARSET_ROUTINE .import KERNEL_BANK_MANAGEMENT .import search_free_bank .import kernel_free_bank @@ -30,7 +33,8 @@ .import close_sockets_by_pid ; .segment "BANK8" - .org $C000 + .org $C000 + start_rom: jmp XBANK @@ -65,9 +69,13 @@ XBANK: cmp #KERNEL_SOCKET_CLOSE_NETWORK beq @kernel_socket_close_network - cmp #KERNEL_SOCKET_CLOSE_FROM_PID_NETWORK + cmp #KERNEL_SOCKET_CLOSE_FROM_PID_NETWORK ; $0B beq @kernel_sockets_close_by_pid_network + cmp #KERNEL_LOAD_QWERTY_CHARSET ; $0C + + beq @load_qwerty_charset_routine + rts @allocate_bank: @@ -103,6 +111,10 @@ XBANK: @kernel_sockets_close_by_pid_network: jmp close_sockets_by_pid +@load_qwerty_charset_routine: + ; jmp XLOADCHARSET_ROUTINE + + signature: .asciiz "Kernel Extended v2025.X" diff --git a/src/kernel_main_memory.s b/src/kernel_main_memory.s index d9592081..0a39c2a0 100644 --- a/src/kernel_main_memory.s +++ b/src/kernel_main_memory.s @@ -161,6 +161,7 @@ BUFNOM_END: kernel_malloc: .tag kernel_malloc_struct +.out .sprintf("kernel_malloc_struct : 0x%x", kernel_malloc) kernel_malloc_end: kernel_process: diff --git a/src/versions/versions.inc b/src/versions/versions.inc index e64d12e4..3c25fa55 100644 --- a/src/versions/versions.inc +++ b/src/versions/versions.inc @@ -5,6 +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 KERNEL_VERSION_2025_3 $07 -.define CURRENT_VERSION_BINARY KERNEL_VERSION_2025_1 +.define CURRENT_VERSION_BINARY KERNEL_VERSION_2025_3 From 9dabbec7974ef87286b0060ae9f5c81316648bd1 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 12 Nov 2025 23:32:13 +0100 Subject: [PATCH 48/49] fix bug when 2 files are opened and the second is closed and opened : overflow in fp ptr of the process --- src/functions/files/xclose.asm | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/functions/files/xclose.asm b/src/functions/files/xclose.asm index 09b4a34a..86d12c04 100644 --- a/src/functions/files/xclose.asm +++ b/src/functions/files/xclose.asm @@ -10,12 +10,7 @@ sta RESB sty RESB + 1 ; save fp -.ifdef WITH_DEBUG - pha - ldx #XDEBUG_FCLOSE_ENTER - jsr xdebug_print_with_a - pla -.endif + ; Try to found FP ; kernel_process+kernel_process_struct::kernel_fd contient un tableau où la position 0 est le FD 3 (car on commence à 3 avec stin- 0 , stdout, stderr) @@ -34,25 +29,13 @@ lda kernel_process + kernel_process_struct::kernel_fd,x ; A contient l'id du process, X contient l'id du FD retranché de 3 bne @found_fp_slot -.ifdef WITH_DEBUG - jsr kdebug_save - txa - ldx #XDEBUG_XCLOSE_FD_NOT_FOUND - jsr xdebug_print_with_a - jsr kdebug_restore -.endif + @exit: rts @found_fp_slot: ; Process should be called here -.ifdef WITH_DEBUG - pha - lda RESB - ldx #XDEBUG_XCLOSE_FD_FOUND - jsr xdebug_print - pla -.endif + txa ; Transfert fd 'id slot' asl ; Multiply * 2 @@ -98,7 +81,11 @@ jsr XFREE_ROUTINE ; Clear fp in current process - ldy #kernel_one_process_struct::fp_ptr + lda TR7 + asl + clc + adc #kernel_one_process_struct::fp_ptr + tay lda #$00 sta (RESB),y iny From a9ceb8d3c88849a5a32e30596f512758a5bfcaaf Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 12 Nov 2025 23:32:51 +0100 Subject: [PATCH 49/49] fix bug when overflow of the fp ptr occurs --- src/functions/files/XOPEN.asm | 86 ++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/src/functions/files/XOPEN.asm b/src/functions/files/XOPEN.asm index 2baefc46..4eb76329 100644 --- a/src/functions/files/XOPEN.asm +++ b/src/functions/files/XOPEN.asm @@ -1,9 +1,11 @@ .proc XOPEN_ROUTINE +; $ed31 .out .sprintf("|MODIFY:RES:XOPEN_ROUTINE") .out .sprintf("|MODIFY:RESB:XOPEN_ROUTINE") .out .sprintf("|MODIFY:TR5:XOPEN_ROUTINE") -.out .sprintf("|MODIFY:TR7:XOPEN_ROUTINE") +.out .sprintf("|MODIFY:TR6:XOPEN_ROUTINE (used by XMALLOC)") +.out .sprintf("|MODIFY:TR7:XOPEN_ROUTINE (used by XMALLOC)") .out .sprintf("|MODIFY:XOPEN_SAVE:XOPEN_ROUTINE") .out .sprintf("|MODIFY:XOPEN_FLAGS:XOPEN_ROUTINE") .out .sprintf("|MODIFY:XOPEN_RES_SAVE:XOPEN_ROUTINE") @@ -57,7 +59,7 @@ ; O_CREAT | Yes | open and return FD sta RES - stx RES+1 + stx RES + 1 ; Save ptr sta XOPEN_RES_SAVE stx XOPEN_RES_SAVE + 1 @@ -67,7 +69,7 @@ ; ; Close current file if we already open a file - lda kernel_process+kernel_process_struct::kernel_fd_opened ; if there is already a file open on ch376 if value <> $FF, if it's equal to $ff, there is no file opened + lda kernel_process + kernel_process_struct::kernel_fd_opened ; if there is already a file open on ch376 if value <> $FF, if it's equal to $ff, there is no file opened cmp #$FF bne @open_new_file @@ -75,13 +77,6 @@ jsr _ch376_file_close @open_new_file: -.ifdef WITH_DEBUG2 - jsr kdebug_save - ldy XOPEN_RES_SAVE + 1 - ldx #XDEBUG_XOPEN_ENTER - jsr xdebug_print_with_ay_string - jsr kdebug_restore -.endif lda #EOK sta KERNEL_ERRNO @@ -97,9 +92,8 @@ ldx #$FF txa rts -@L1: - +@L1: ldy #$00 lda (RES),y ; @@ -126,8 +120,9 @@ rts @not_null_2: + sta KERNEL_XOPEN_PTR1 - sty KERNEL_XOPEN_PTR1+1 + sty KERNEL_XOPEN_PTR1 + 1 ; now concat ; reach the end of string in the pointer ldy #_KERNEL_FILE::f_path @@ -135,7 +130,7 @@ lda (KERNEL_XOPEN_PTR1),y beq @end_of_string_found iny - cpy #KERNEL_MAX_PATH_LENGTH+_KERNEL_FILE::f_path + cpy #KERNEL_MAX_PATH_LENGTH + _KERNEL_FILE::f_path bne @L3 ; at this step, we cannot detect the end of string : BOF, return null @@ -143,7 +138,7 @@ @end_of_string_found: ; This solution avoid to compute pointer and to create another zp address - cpy #_KERNEL_FILE::f_path+$01 ; is it slash "/",0 ? + cpy #_KERNEL_FILE::f_path + $01 ; is it slash "/",0 ? beq @don_t_add_slash ; yes ; it's a relative path and we are still in a folder (except /) ; add slash then @@ -172,7 +167,7 @@ ; Be careful BOF can occurs if iny sty RES - cpy #KERNEL_MAX_PATH_LENGTH+_KERNEL_FILE::f_path + cpy #KERNEL_MAX_PATH_LENGTH + _KERNEL_FILE::f_path bne @L4 ; Bof return NULL @@ -189,7 +184,7 @@ ; Pass arg to createfile_pointer lda RES - ldy RES+1 + ldy RES + 1 ; and XOPEN_FLAGS too at this step jsr _create_file_pointer @@ -203,7 +198,7 @@ @not_null_1: sta KERNEL_XOPEN_PTR1 - sty KERNEL_XOPEN_PTR1+1 + sty KERNEL_XOPEN_PTR1 + 1 @open_from_device: ; Reset flag to say that end of string is reached @@ -218,7 +213,7 @@ jsr send_0_to_ch376_and_open - ldy #_KERNEL_FILE::f_path+1 ; skip / + ldy #_KERNEL_FILE::f_path + 1 ; skip / @next_filename: lda #CH376_SET_FILE_NAME ;$2F @@ -256,7 +251,7 @@ iny lda (KERNEL_XOPEN_PTR1),y bne @next_filename - cpy #_KERNEL_FILE::f_path+1 + cpy #_KERNEL_FILE::f_path + 1 beq @open_and_register_fp bne @next_filename @@ -282,9 +277,15 @@ beq @exit_open_with_null ; yes, return NULL + ; save KERNEL_XOPEN_PTR1 (modifued by open_full_filename) + lda KERNEL_XOPEN_PTR1 + sta TR6 + lda KERNEL_XOPEN_PTR1 + 1 + sta TR7 + ; Le fichier n'a pas été trouvé, ; On va vérifier qu'on avait un fichier ouvert avant - lda kernel_process+kernel_process_struct::kernel_fd_opened ; if there is already a file open on ch376 if value <> $FF, if it's equal to $ff, there is no file opened + lda kernel_process + kernel_process_struct::kernel_fd_opened ; if there is already a file open on ch376 if value <> $FF, if it's equal to $ff, there is no file opened cmp #$FF beq @exit_open_with_null @@ -293,18 +294,14 @@ jsr open_full_filename @exit_open_with_null: - lda KERNEL_XOPEN_PTR1 - ldy KERNEL_XOPEN_PTR1+1 + + lda TR6 ; KERNEL_XOPEN_PTR1 restored + ldy TR7 ; KERNEL_XOPEN_PTR1 restored jsr XFREE_ROUTINE ; No such file_or_directy lda #ENOENT sta KERNEL_ERRNO -.ifdef WITH_DEBUG2 - ldx #XDEBUG_XOPEN_FILE_NOT_FOUND - lda #$FF - jsr xdebug_print_with_a -.endif lda #$FF tax @@ -319,16 +316,16 @@ @open_and_register_fp: ; Register fp in process struct ; store pointer in process struct - ldx kernel_process+kernel_process_struct::kernel_current_process ; Get current process + ldx kernel_process + kernel_process_struct::kernel_current_process ; Get current process jsr kernel_get_struct_process_ptr sta RES - sty RES+1 + sty RES + 1 ; Fill the address of the fp ; Manage only 1 FP for instance FIXME bug ldx #$00 - ldy #(kernel_one_process_struct::fp_ptr+1) - + ldy #(kernel_one_process_struct::fp_ptr + 1) +; $ee53 @try_to_find_a_free_fp_for_current_process: lda (RES),y ; Load high beq @fp_is_not_busy ; If it's equal to $00, it means that it's empty because it's impossible to have a fp registered in zp @@ -339,14 +336,15 @@ inx cpx #KERNEL_MAX_FP_PER_PROCESS bne @try_to_find_a_free_fp_for_current_process + ; At this step, we did not have any free fp for the current process lda #KERNEL_ERRNO_REACH_MAX_FP_FOR_A_PROCESS sta KERNEL_ERRNO - beq @exit_open_with_null + jmp @exit_open_with_null ; @fp_is_not_busy: - lda KERNEL_XOPEN_PTR1+1 + lda KERNEL_XOPEN_PTR1 + 1 sta (RES),y dey lda KERNEL_XOPEN_PTR1 @@ -357,7 +355,7 @@ ldx #$00 @init_fp: - lda kernel_process+kernel_process_struct::kernel_fd,x + lda kernel_process + kernel_process_struct::kernel_fd,x beq @found_fp_slot inx cpx #KERNEL_MAX_FP @@ -365,7 +363,7 @@ ; No available fd lda KERNEL_XOPEN_PTR1 - ldy KERNEL_XOPEN_PTR1+1 + ldy KERNEL_XOPEN_PTR1 + 1 jsr XFREE_ROUTINE lda #EMFILE @@ -377,21 +375,25 @@ ; not found @found_fp_slot: - lda kernel_process+kernel_process_struct::kernel_current_process ; Get the current process - sta kernel_process+kernel_process_struct::kernel_fd,x ; and store in fd slot the id of the process + lda kernel_process + kernel_process_struct::kernel_current_process ; Get the current process + sta kernel_process + kernel_process_struct::kernel_fd,x ; and store in fd slot the id of the process txa pha ; save Id of the fd asl tax ; Store fp in main process + + + lda KERNEL_XOPEN_PTR1 - sta kernel_process+kernel_process_struct::fp_ptr,x + sta kernel_process + kernel_process_struct::fp_ptr,x inx - lda KERNEL_XOPEN_PTR1+1 - sta kernel_process+kernel_process_struct::fp_ptr,x + lda KERNEL_XOPEN_PTR1 + 1 + sta kernel_process + kernel_process_struct::fp_ptr,x pla ; restore Id of the fd - sta kernel_process+kernel_process_struct::kernel_fd_opened ; Define that it's the new current fd + sta kernel_process + kernel_process_struct::kernel_fd_opened ; Define that it's the new current fd + clc adc #KERNEL_FIRST_FD