diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a2b2150..e7ba6f9 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 aeeae19..30c7ecc 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 2cf03e5..80e1c8d 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 fe17aca..a5640e2 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 e4ea2c0..0bbcadf 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 85ec418..e90d88c 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 1c8e249..b5436f6 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 de08b29..df9b96f 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 0b2f5ba..67f57e3 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 f46a040..971cf7a 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 a496504..0cb8f9f 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 0000000..3227521 --- /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 0000000..f14fd4d --- /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 0000000..0ba8a61 --- /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 58ef65b..5f3d135 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