From d3803fe6572e6a38747b083d18a9797f90ebb6f1 Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 21 Nov 2023 22:12:06 +0100 Subject: [PATCH] cleaning --- VERSION | 2 +- docs/memmap_ram.md | 27 ++-- memmap.md | 24 +-- run.sh | 2 + src/functions/files/XOPEN.asm | 16 -- src/functions/files/xclose.asm | 19 +-- src/functions/files/xread.asm | 7 +- src/functions/graphics/xabox.asm | 47 +++--- src/functions/graphics/xdrawa.asm | 2 +- src/functions/mainargs.asm | 3 +- .../process/kernel_create_process.asm | 4 + src/functions/process/xfork.asm | 2 + src/include/files.inc | 1 - src/include/kernel.inc | 5 +- src/include/keyboard.inc | 1 - src/include/memory.inc | 20 +-- src/include/process.inc | 2 +- src/kdebug.asm | 139 ++++++++---------- src/kernel.asm | 10 +- src/libs/ch376-lib/src/ch376.s | 66 ++++----- src/memmap.asm | 23 ++- src/versions/versions.inc | 3 +- 22 files changed, 190 insertions(+), 235 deletions(-) diff --git a/VERSION b/VERSION index f607a17..f416694 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2023.3 \ No newline at end of file +2023.4 \ No newline at end of file diff --git a/docs/memmap_ram.md b/docs/memmap_ram.md index a4e893d..373ad8d 100644 --- a/docs/memmap_ram.md +++ b/docs/memmap_ram.md @@ -1,4 +1,5 @@ -# Page 0 +# Memmap +## Page 0 |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| |RAM|RES | $00-$01 | 2 | @@ -44,7 +45,7 @@ |RAM|FREE | $35-$3F | | |RAM|ADCLK | $40-$41 | 2 | |RAM|TIMEUS | $42-$43 | 2 | -|RAM|TIMEUD | $44-$45 | 2 | +|RAM|TIMEUD (used in cc65 clock function)| $44-$45 | 2 | |RAM|HRSX | $46-$46 | 1 | |RAM|HRSY | $47-$47 | 1 | |RAM|FREE | $48-$48 | 1 | @@ -62,7 +63,7 @@ |RAM|INDRS | $5B-$5B | 1 | |RAM|FREE | $5C-$5F | 2 | |RAM|FREE | $8C-$FF | 115 | -# Page 2 +## Page 2 |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| |RAM|KERNEL_ERRNO | $0200-$0200 | 1 | @@ -87,7 +88,7 @@ |RAM|ADSCRH | $021C-$021F | 4 | |RAM|SCRX | $0220-$0220 | 1 | |RAM|BUSY_BANK_TABLE_RAM | $0221-$0224 | 3 | -|RAM|SCRY | $0224-$0228 | 1 | +|RAM|SCRY | $0224-$0227 | 4 | |RAM|SCRDX | $0228-$0228 | 1 | |RAM|SCRFX | $022C-$022C | 1 | |RAM|SCRFY | $0234-$0234 | 1 | @@ -100,7 +101,7 @@ |RAM|FLGSCR | $0248-$024C | 4 | |RAM|CURSCR | $024C-$024D | 1 | |RAM|FREE | $024D-$0256 | 11 | -|RAM|SCRTXT | $0256-$025C | 604 | +|RAM|SCRTXT | $0256-$0260 | 4 | |RAM|SCRHIR (not used) | $025C-$0260 | 4 | |RAM|SCRTRA | $0262-$0266 | 6 | |RAM|KBDCOL | $0268-$0270 | 8 | @@ -117,36 +118,36 @@ |RAM|HRSPAT | $02AA-$02AA | 1 | |RAM|IOTAB | $02AE-$02B1 | X | |RAM|KERNEL_ADIOB | $02B2-$02B9 | 8 | -|RAM|kernel_malloc_free_chunk_size_low | $02BA-$02C3 | 10 | +|RAM|kernel_malloc_free_chunk_size | $02BA-$02C3 | 10 | +|RAM|kernel_xmalloc_call | $02C4-$02EB | 39 | |RAM|FLGRST | $02EE-$02EE | 1 | |RAM|CSRND | $02EF-$02EF | 1 | -|RAM|kernel_xmalloc_call | $02C4-$02EB | 39 | |RAM|FREE | $02EC-$02ED | 2 | |RAM|VNMI | $02F4-$02F7 | 3 | |RAM|ADIODB_VECTOR | $02F7-$02FA | 3 | |RAM|IRQVECTOR | $02FA-$02FD | 3 | |RAM|VAPLIC | $02FD-$0300 | 3 | -# Page 3 +## Page 3 |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| |IO |VIA1 | $0300-$030F | | -# Page 4 +## Page 4 |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| |RAM|page4 overlay_access | $0419-$0436 | 54 | -# Page 5&6 +## Page 5&6 |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| -|RAM|BUFNOM | $0517-$0525 | 14 | +|RAM|FREE | $0517-$0525 | 14 | |RAM|Malloc table | $0525-$0579 | 84 | |RAM|main kernel process struct | $0579-$058F | 22 | |RAM|BUFEDT | $0590-$05FE | 110 | |RAM|KERNEL_MEMORY_DRIVER | $05FE-$06A1 | 163 | -# Kernel bank 7 +## Kernel bank 7 | Type | Name | Range | Size | | :-------- |:---------------------------- |:------- |:-----| |ROM|FREE |$feea-$fff0| 262 | -#Bank 0 +##Bank 0 | Type | Name | Range | Size | | -------- | ---------------------------- | ------- |-----| |BANK0|BUFBUF | $c080-$c0b6 | 54 | diff --git a/memmap.md b/memmap.md index 318de19..8331381 100644 --- a/memmap.md +++ b/memmap.md @@ -67,6 +67,7 @@ int KERNEL_MALLOC_FREE_CHUNK_MAX=0x5; |MODIFY:RESB:XWRITEBYTES_ROUTINE |MODIFY:TR0:XFSEEK_ROUTINE |MODIFY:TR7:XFSEEK_ROUTINE +|MODIFY:TR7:XFSEEK_ROUTINE |MODIFY:TR4:XFSEEK_ROUTINE |MODIFY:RESB:XFSEEK_ROUTINE |MODIFY:RES:XFSEEK_ROUTINE @@ -140,7 +141,8 @@ CALL:XOPEN:XRM_ROUTINE |MODIFY:KERNEL_ERRNO:XMALLOC_ROUTINE |MODIFY:RES:XFREE_ROUTINE |MODIFY:KERNEL_XFREE_TMP:XFREE_ROUTINE -|#MEMMAP: Page 0 +|#MEMMAP: Memmap +|##MEMMAP: Page 0 |MEMMAP:Type | Name | Range | Size | |MEMMAP: :------- |:----------------------------- |:----------- |:-----| |MEMMAP:RAM|RES | $00-$01 | 2 | @@ -204,7 +206,7 @@ CALL:XOPEN:XRM_ROUTINE |MEMMAP:RAM|INDRS | $5B-$5B | 1 | |MEMMAP:RAM|FREE | $5C-$5F | 2 | |MEMMAP:RAM|FREE | $8C-$FF | 115 | -|#MEMMAP: Page 2 +|##MEMMAP: Page 2 |MEMMAP:Type | Name | Range | Size | |MEMMAP: :------- |:----------------------------- |:----------- |:-----| |MEMMAP:RAM|KERNEL_ERRNO | $0200-$0200 | 1 | @@ -268,31 +270,31 @@ CALL:XOPEN:XRM_ROUTINE |MEMMAP:RAM|ADIODB_VECTOR | $02F7-$02FA | 3 | |MEMMAP:RAM|IRQVECTOR | $02FA-$02FD | 3 | |MEMMAP:RAM|VAPLIC | $02FD-$0300 | 3 | -|#MEMMAP: Page 3 +|##MEMMAP: Page 3 |MEMMAP:Type | Name | Range | Size | |MEMMAP: :------- |:----------------------------- |:----------- |:-----| |MEMMAP:IO |VIA1 | $0300-$030F | | -|#MEMMAP: Page 4 +|##MEMMAP: Page 4 |MEMMAP:Type | Name | Range | Size | |MEMMAP: :------- |:----------------------------- |:----------- |:-----| |MEMMAP:RAM|page4 overlay_access | $0419-$0436 | 54 | -|#MEMMAP: Page 5&6 +|##MEMMAP: Page 5&6 |MEMMAP:Type | Name | Range | Size | |MEMMAP: :------- |:----------------------------- |:----------- |:-----| -|MEMMAP:RAM|BUFNOM | $0517-$0525 | 14 | +|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 | -|#MEMMAP: Kernel bank 7 +|##MEMMAP: Kernel bank 7 |MEMMAP: Type | Name | Range | Size | |MEMMAP: :-------- |:---------------------------- |:------- |:-----| -|MEMMAP:ROM|FREE |$feea-$fff0| 262 | -|#MEMMAP:Bank 0 +|MEMMAP:ROM|FREE |$fee8-$fff0| 264 | +|##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) | $fb9c-$fc48 | | -|MEMMAP:BANK0|XFREE (copy from kernel) | $fc48-$fecd | | +|MEMMAP:BANK0|XMALLOC (copy from kernel) | $fb9a-$fc46 | | +|MEMMAP:BANK0|XFREE (copy from kernel) | $fc46-$fecb | | diff --git a/run.sh b/run.sh index 4ef0e0b..babd272 100644 --- a/run.sh +++ b/run.sh @@ -24,6 +24,8 @@ cp tests/test_kernel $ORICUTRON_PATH/sdcard/bin/test cp tests/kopened $ORICUTRON_PATH/sdcard/bin/ +cp autoboot $ORICUTRON_PATH/sdcard/etc/ + cd $ORICUTRON_PATH ./oricutron #-r :bp.txt diff --git a/src/functions/files/XOPEN.asm b/src/functions/files/XOPEN.asm index 1de9e5e..637598b 100644 --- a/src/functions/files/XOPEN.asm +++ b/src/functions/files/XOPEN.asm @@ -11,8 +11,6 @@ .out .sprintf("|MODIFY:KERNEL_XOPEN_PTR1:XOPEN_ROUTINE") - - ; INPUT ; this routine use : ; RES, A X Y, XOPEN_SAVE XOPEN_FLAGS, XOPEN_RES_SAVE, XOPEN_SAVEA @@ -288,13 +286,9 @@ @file_not_found: ; Checking if filesys is found - ; jmp @exit_open_with_null - lda FILESYS_BANK beq @filesys_bank_not_found - - @filesys_bank_not_found: ; When we have file not found, do we have O_CREATE flag ? lda XOPEN_FLAGS @@ -308,15 +302,12 @@ cmp #O_WRONLY beq @exit_open_with_null ; yes, return NULL - lda XOPEN_FLAGS ; Get flags and #O_RDONLY cmp #O_RDONLY bne @could_be_created - @exit_open_with_null: - lda KERNEL_XOPEN_PTR1 ldy KERNEL_XOPEN_PTR1+1 jsr XFREE_ROUTINE @@ -350,16 +341,10 @@ and #O_WRONLY cmp #O_WRONLY beq @write_only - ; not write - ;bne @open_and_register_fp - @write_only: @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 @@ -431,7 +416,6 @@ ; 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 ; stx TR7 ; save FD id diff --git a/src/functions/files/xclose.asm b/src/functions/files/xclose.asm index 5e6895a..ad65ad3 100644 --- a/src/functions/files/xclose.asm +++ b/src/functions/files/xclose.asm @@ -1,7 +1,7 @@ .export XCLOSE_ROUTINE .proc XCLOSE_ROUTINE - ; A & Y contains fd + ; A contains FD ; Calls XFREE .out .sprintf("|MODIFY:RESB:XCLOSE_ROUTINE") .out .sprintf("|MODIFY:TR7:XCLOSE_ROUTINE") @@ -16,30 +16,22 @@ .endif ; Try to found FP - ;ldx #$00 ; 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) ; kernel_process+kernel_process_struct::kernel_fd,x contient 0 si le FD n'est pas connu ; si c'est différent de 0, alors cela contient le process concerné - - ; $580 sec sbc #KERNEL_FIRST_FD - sta TR7 - ; Cheking if we tries to close a fp greater than the max allowed - + ; Checking if we tries to close a fp greater than the max allowed cmp #KERNEL_MAX_FP bcs @exit - - tax - lda kernel_process+kernel_process_struct::kernel_fd,x ; + 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 @@ -60,8 +52,8 @@ pla .endif - txa - asl + txa ; Transfert fd 'id slot' + asl ; Multiply tax ; remove fp from main struct @@ -85,6 +77,7 @@ sty RESB+1 ldy #kernel_one_process_struct::fp_ptr + @try_to_find_a_free_fp_for_current_process: lda (RESB),y diff --git a/src/functions/files/xread.asm b/src/functions/files/xread.asm index 0498b23..fb90996 100644 --- a/src/functions/files/xread.asm +++ b/src/functions/files/xread.asm @@ -12,10 +12,9 @@ ; Modify : RES, PTR_READ_DEST, TR0 ; [OUT] PTR_READ_DEST updated - - -; [OUT] A could contains 0 or the CH376 state -; [OUT] Y contains the last size of bytes +; Compute with update_position +; [OUT] A contains the last size of bytes (low) +; [OUT] X contains the last size of bytes (high) ;jmp XREADBYTES_ROUTINE diff --git a/src/functions/graphics/xabox.asm b/src/functions/graphics/xabox.asm index fde763f..898116e 100644 --- a/src/functions/graphics/xabox.asm +++ b/src/functions/graphics/xabox.asm @@ -1,6 +1,7 @@ ; TRACE UN RECTANGLE ABSOLU + ;Principe:Par un procédé très astucieux, on va tracer les 4 traits (en absolu) ; joignant les 4 points. Voila bien la seule astuce inutile ! Il aurait ; été 100 (pourquoi pas 1000 !?) fois plus simple, puisque le rectangle @@ -11,40 +12,42 @@ ; Notez également l'utilisation de l'absolu,X plutot que du page 0,X en ; $E850... tss tss ! + + XABOX_ROUTINE: - ldy #$06 ; on place les 4 paramètres (poids faible seulement) + ldy #$06 ; On place les 4 paramètres (poids faible seulement) ldx #$03 LE830 - lda HRS1,Y ; de HRSx - sta DECFIN,X ; dans $06-7-8-9 + lda HRS1,y ; de HRSx + sta DECFIN,x ; dans $06-7-8-9 dey dey dex bpl LE830 LE83A: - ldx #$03 ; on va tracer 4 traits + ldx #$03 ; on va tracer 4 traits LE83C: stx DECDEB+1 ; dans $05 <---------------------------------------- - lda table_for_rect,X ; on lit le code coordonn?es I - sta DECDEB ; dans $04 I - ldx #$06 ; on va extraire 8 bits I + lda table_for_rect,x ; on lit le code coordonn?es I + sta DECDEB ; dans $04 I + ldx #$06 ; on va extraire 8 bits I LE845: - lda #$00 ; A=0 <---------------------------------------- I - sta HRS1+1,X ; poids fort HRSx ? 0 et positif I I - lsr DECDEB ; on sort 2 bits I I - rol ; dans A I I - lsr DECDEB ; I I - rol ; I I - tay ; et Y I I - lda $0006,Y ; on lit la coordonnée correspondante I I - sta HRS1,X ; et on stocke dans HRSx I I - dex ; I I - dex ; I I - bpl LE845 ; on fait les 4 coordonnées ADRAW ------------- I + lda #$00 ; A=0 <---------------------------------------- I + sta HRS1+1,c ; poids fort HRSx ? 0 et positif I I + lsr DECDEB ; on sort 2 bits I I + rol ; dans A I I + lsr DECDEB ; I I + rol ; I I + tay ; et Y I I + lda $0006,y ; on lit la coordonnée correspondante I I + sta HRS1,x ; et on stocke dans HRSx I I + dex ; I I + dex ; I I + bpl LE845 ; on fait les 4 coordonnées ADRAW ------------- I jsr XDRAWA_ROUTINE ; on trace le trait en absolu I - ldx DECDEB+1 ; I - dex ; I - bpl LE83C ; et on fait 4 traits ------------------------------ + ldx DECDEB+1 ; I + dex ; I + bpl LE83C ; et on fait 4 traits ------------------------------ rts table_for_rect: .byt $26,$67,$73,$32 diff --git a/src/functions/graphics/xdrawa.asm b/src/functions/graphics/xdrawa.asm index be57553..75fdee3 100644 --- a/src/functions/graphics/xdrawa.asm +++ b/src/functions/graphics/xdrawa.asm @@ -1,7 +1,7 @@ ; TRACE DE TRAIT EN ABSOLU -; Action:on calcule dX et dY les d?placements dans HRS1 et HRS2 et on trace en +; Action:on calcule dX et dY les deplacements dans HRS1 et HRS2 et on trace en ; relatif. En entr?e, comme ADRAW dans HRSx. .proc XDRAWA_ROUTINE diff --git a/src/functions/mainargs.asm b/src/functions/mainargs.asm index 587ab64..0b2f5ba 100644 --- a/src/functions/mainargs.asm +++ b/src/functions/mainargs.asm @@ -19,9 +19,8 @@ ; Register Modify : A,X,Y ; Memory modify : RES,RESB,TR0,TR1,TR2,TR3,TR4 - XMAINARGSC := TR0 ; 1 byte -XMAINARGSV := TR1 ; 2 byte +XMAINARGSV := TR1 ; 2 bytes XMAINARGS_SPACEFOUND := TR3 ; 1 byte XMAINARGS_MODE := TR4 ; 1 byte XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte diff --git a/src/functions/process/kernel_create_process.asm b/src/functions/process/kernel_create_process.asm index 4932cc2..0f0257a 100644 --- a/src/functions/process/kernel_create_process.asm +++ b/src/functions/process/kernel_create_process.asm @@ -143,6 +143,7 @@ save_command_line: ; Now TR4 & TR5 are set the the beginning of cmdline ldy #$00 + @L10: lda (RESB),y beq @S8 @@ -152,12 +153,14 @@ save_command_line: bne @L10 ldy #EINVAL rts + @S8: sta (TR4),y ; Init fp to $00 ldy #kernel_one_process_struct::fp_ptr lda #$00 + @L5: sta (RES),y iny @@ -186,6 +189,7 @@ save_command_line: sta (RES),y ; Store / at the first car iny bne @loop + @out: lda #$00 sta (RES),y ; Store 0 for the last string diff --git a/src/functions/process/xfork.asm b/src/functions/process/xfork.asm index 27bcef8..79efd3c 100644 --- a/src/functions/process/xfork.asm +++ b/src/functions/process/xfork.asm @@ -50,12 +50,14 @@ adc #kernel_one_process_struct::cmdline bcc @S7 inc KERNEL_CREATE_PROCESS_PTR1+1 + @S7: sta KERNEL_CREATE_PROCESS_PTR1 ; Shebang management ; Copy new cmdline with #! ldy #$00 + @L10: lda (TR0),y ; Get the command launched (full command) beq @S8 diff --git a/src/include/files.inc b/src/include/files.inc index 2e953ef..20337c4 100644 --- a/src/include/files.inc +++ b/src/include/files.inc @@ -65,5 +65,4 @@ garbage .res 19 .endstruct - .define KERNEL_FIRST_FD 3 diff --git a/src/include/kernel.inc b/src/include/kernel.inc index 858fbae..f2ec6b6 100644 --- a/src/include/kernel.inc +++ b/src/include/kernel.inc @@ -51,8 +51,6 @@ ; You can increase this number but when this number is increased, there is more memory consumed for many features ;.define KERNEL_PATH_CURRENT_MAX_LEVEL PATH_CURRENT_MAX_LEVEL - - ; 4 systems Buffers 6 for user (telemon historical) .define KERNEL_NUMBER_BUFFER 4+6 @@ -72,6 +70,5 @@ TELEMON_PRINTER_BUFFER_END = $D200 KERNEL_CONF_BEGIN := $D201 KERNEL_CONF_END := $D210 - KERNEL_FORK_PROCESS = 0 -KERNEL_NOFORK_PROCESS = 1 ; Performs an EXEC like unix/linux, it destroy memory from current process \ No newline at end of file +KERNEL_NOFORK_PROCESS = 1 ; Performs an EXEC like unix/linux, it destroy memory from current process diff --git a/src/include/keyboard.inc b/src/include/keyboard.inc index 7bd0749..be64c1b 100644 --- a/src/include/keyboard.inc +++ b/src/include/keyboard.inc @@ -10,4 +10,3 @@ KEY_UP = 11 KEY_RETURN = $0D KEY_ESC = $1B KEY_DEL = $7F - diff --git a/src/include/memory.inc b/src/include/memory.inc index 71e6b77..0b7a34c 100644 --- a/src/include/memory.inc +++ b/src/include/memory.inc @@ -47,18 +47,17 @@ .endstruct .struct kernel_malloc_busy_begin_struct - kernel_malloc_busy_chunk_begin_high .res KERNEL_MAX_NUMBER_OF_MALLOC + kernel_malloc_busy_chunk_begin_high .res KERNEL_MAX_NUMBER_OF_MALLOC ;kernel_malloc_busy_chunk_begin_low .res KERNEL_MAX_NUMBER_OF_MALLOC .endstruct - .struct kernel_malloc_free_chunk -kernel_malloc_free_chunk_begin_low .res KERNEL_MALLOC_FREE_CHUNK_MAX -kernel_malloc_free_chunk_begin_high .res KERNEL_MALLOC_FREE_CHUNK_MAX -kernel_malloc_free_chunk_end_low .res KERNEL_MALLOC_FREE_CHUNK_MAX -kernel_malloc_free_chunk_end_high .res KERNEL_MALLOC_FREE_CHUNK_MAX -kernel_malloc_free_chunk_size_high .res KERNEL_MALLOC_FREE_CHUNK_MAX -kernel_malloc_free_chunk_size_low .res KERNEL_MALLOC_FREE_CHUNK_MAX + kernel_malloc_free_chunk_begin_low .res KERNEL_MALLOC_FREE_CHUNK_MAX + kernel_malloc_free_chunk_begin_high .res KERNEL_MALLOC_FREE_CHUNK_MAX + kernel_malloc_free_chunk_end_low .res KERNEL_MALLOC_FREE_CHUNK_MAX + kernel_malloc_free_chunk_end_high .res KERNEL_MALLOC_FREE_CHUNK_MAX + kernel_malloc_free_chunk_size_high .res KERNEL_MALLOC_FREE_CHUNK_MAX + kernel_malloc_free_chunk_size_low .res KERNEL_MALLOC_FREE_CHUNK_MAX .endstruct .out "==================================================================" @@ -76,9 +75,4 @@ kernel_malloc_free_chunk_size_low .res KERNEL_MALLOC_FREE_CHUNK_MAX argv_value_ptr .res KERNEL_LENGTH_MAX_CMDLINE+KERNEL_MAX_ARGS_COMMAND_LINE ; add 0 to string .endstruct - .out .sprintf("XMAINARGS_STRUCT size : $%X bytes", .sizeof(XMAINARGS_STRUCT)) - - - - diff --git a/src/include/process.inc b/src/include/process.inc index a2a3298..f881819 100644 --- a/src/include/process.inc +++ b/src/include/process.inc @@ -34,7 +34,7 @@ kernel_cwd_str .res .strlen("/")+1 fp_ptr .res KERNEL_MAX_FP_PER_PROCESS*2 ; fp for init for instance, only shell could be in it ; kernel_fd contains ... - kernel_fd .res KERNEL_MAX_FP + kernel_fd .res KERNEL_MAX_FP ; Va contenir l'id du process qui possède ce FD kernel_fd_opened .res 1 ; the id of the current fd opened ;kernel_process_addr .res KERNEL_MAX_PROCESS*2 ;kernel_next_fd .res 1 diff --git a/src/kdebug.asm b/src/kdebug.asm index b7e0b82..414c422 100644 --- a/src/kdebug.asm +++ b/src/kdebug.asm @@ -9,7 +9,6 @@ .include "include/debug.inc" .include "kernel.inc" - .org $c000 .code @@ -34,25 +33,24 @@ table_low_ay: table_high_ay: .byte >str_unknown - .byte >str_xfree_enter + .byte >str_xfree_enter .byte >str_xmalloc_enter .byte >str_xmalloc_return_address - -str_unknown: +str_unknown: .asciiz "Unknown" -table_low_noparam: +table_low_noparam: .byte str_create_process .byte >str_xfree_enter .byte >str_xfree_garbage_collector_in - .byte >str_xfree_garbage_collector_out + .byte >str_xfree_garbage_collector_out .byte >str_found_chunk - .byte >str_fseek + .byte >str_fseek .byte >str_fclose - .byte >str_unknown + .byte >str_unknown .byte >str_xopen_allocate_fp .byte >str_fclose_not_found .byte >str_fclose_found @@ -80,7 +78,7 @@ table_high_noparam: .byte >str_fork_starting .byte >str_unknown .byte >str_type - .byte >str_mainargs + .byte >str_mainargs .byte >str_process_struct .byte >str_type_fp @@ -92,13 +90,13 @@ table_high_ay_string: .byte >str_xexec_enter .byte >str_xopen_enter -table_str_low: +table_str_low: .byte str_fd_id .byte >str_max_fd_reached .byte >str_fclose_enter @@ -111,9 +109,7 @@ str_xmalloc_enter: .byte $0D,"[XMALLOC] Query size :",0 str_xmalloc_return_address: - .byte $0D,"[XMALLOC] Return address :",0 - - + .byte $0D,"[XMALLOC] Return address :",0 str_max_fd_reached: .byte $0D,"[XOPEN] Free FP pointer, return $FFFF in AX, because KERNEL_MAX_FP reached :",0 @@ -121,7 +117,6 @@ str_max_fd_reached: str_max_xopen_file_not_found: .byte $0D,"[XOPEN] File not found",0 - str_process_struct: .asciiz "PROCESS_STRUCT(Kernel)" @@ -142,31 +137,31 @@ str_found_chunk: str_fclose_enter: .byte $0D - .byte "[XCLOSE] Enter with FD id : ",0 + .byte "[XCLOSE] Enter with FD id : ",0 str_fclose_not_found: .byte $0D - .byte "[XCLOSE] FD id not found [ERROR] ",0 + .byte "[XCLOSE] FD id not found [ERROR] ",0 str_fclose_found: .byte $0D - .byte "[XCLOSE] FD found [OK] ",0 + .byte "[XCLOSE] FD found [OK] ",0 str_fclose: .byte $0D - .byte "[XCLOSE] ",0 + .byte "[XCLOSE] ",0 str_fseek: .byte $0D - .byte "[FSEEK] ",0 + .byte "[FSEEK] ",0 str_fork: .byte $0D - .byte "[XFORK] Trying to find binary on device ...",0 + .byte "[XFORK] Trying to find binary on device ...",0 str_fork_starting: .byte $0D - .byte "[XFORK] Starting process",0 + .byte "[XFORK] Starting process",0 str_create_process: .byte $0D,"[CREATE PROCESS] Create process struct ...",0 @@ -175,17 +170,18 @@ str_xfree_enter: .byte $0D .byte "[XFREE] AY enter : ",0 -str_xfree_garbage_collector_in: +str_xfree_garbage_collector_in: .byte $0D,"[GARBAGE COLLECTOR IN]",0 -str_xfree_garbage_collector_out: + +str_xfree_garbage_collector_out: .byte $0D,"[GARBAGE COLLECTOR OUT]",0 str_mainargs: .byte "MAINARGS(Kernel)",0 + str_type_fp: .byte "FP(Kernel)",0 - .proc print_routine_noparam ; X contains id of the string rts @@ -198,7 +194,6 @@ str_type_fp: rts .endproc - .proc print_msg_and_string_ay ; X contains id of the string @@ -244,11 +239,11 @@ str_type_fp: rts .endproc -.proc print_msg_and_a - +.proc print_msg_and_a + ; X contains id of the string pha - + lda table_str_low,x sta ACC2M lda table_str_high,x @@ -277,32 +272,32 @@ str_type_fp: beq @init clc adc #'0' - jsr xdebug_send_printer -@end: + jsr xdebug_send_printer +@end: lda #')' - jsr xdebug_send_printer + jsr xdebug_send_printer rts @init: lda #'0' - jsr xdebug_send_printer + jsr xdebug_send_printer jmp @end pid: .asciiz "(pid:" -.endproc +.endproc .proc display_lsmem_state tya pha - lda #str_lsmem sta ACC2M+1 jsr xdebug_send_string_to_printer - + ldx #$00 + @loop: lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,x beq @next_chunk @@ -322,7 +317,7 @@ pid: jsr xdebug_binhex lda #':' - jsr xdebug_send_printer + jsr xdebug_send_printer lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_high,x jsr xdebug_binhex lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_low,x @@ -355,27 +350,27 @@ pid: lda #'#' jsr xdebug_send_printer - + lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high,x jsr xdebug_binhex lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low,x jsr xdebug_binhex lda #':' - jsr xdebug_send_printer + jsr xdebug_send_printer lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_high,x jsr xdebug_binhex lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_end_low,x - jsr xdebug_binhex + jsr xdebug_binhex lda #' ' jsr xdebug_send_printer lda #'#' - jsr xdebug_send_printer + jsr xdebug_send_printer lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x jsr xdebug_binhex lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x jsr xdebug_binhex - ; lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_pid_list,x + ; lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_pid_list,x lda #$0D jsr xdebug_send_printer @next_chunk2: @@ -387,28 +382,29 @@ pid: pla tay rts + str_lsmem: - .byte $0D,"[lsmem state]",$0D,$00 + .byte $0D,"[lsmem state]",$0D,$00 + str_free: .byte "Free:",$00 + str_busy: .byte "Busy:",$00 .endproc - .proc xdebug_send_a_to_printer pha lda #'#' jsr xdebug_send_printer pla - + jsr xdebug_binhex lda #' ' jsr xdebug_send_printer - rts + rts .endproc - .proc xdebug_send_ay_to_printer pha lda #'#' @@ -416,15 +412,13 @@ str_busy: tya jsr xdebug_binhex pla - + jsr xdebug_binhex lda #' ' jsr xdebug_send_printer - rts + rts .endproc - - .proc xdebug_load lda kernel_debug+kernel_debug_struct::RES @@ -439,10 +433,7 @@ str_busy: lda kernel_debug+kernel_debug_struct::RESB+1 sta RESB+1 - - - - lda kernel_debug+kernel_debug_struct::RA + lda kernel_debug+kernel_debug_struct::RA ldy kernel_debug+kernel_debug_struct::RY ldx kernel_debug+kernel_debug_struct::RX rts @@ -457,16 +448,16 @@ str_line: lsr ;MSN lsr lsr - tay + tay jsr r0000010 ;save ASCII pla ;recover byte - and #%00001111 + and #%00001111 tay r0000010: lda hex_table,y - + jsr xdebug_send_printer rts ;done hex_table: @@ -476,17 +467,17 @@ hex_table: 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 - + 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 - + ; update size - + 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 bcc @do_not_inc - inc kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high + inc kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high @do_not_inc: sta kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low @@ -499,7 +490,7 @@ hex_table: .proc xdebug_send_string_to_printer ldy #$00 -@L1: +@L1: lda (ACC2M),y beq @out jsr xdebug_send_printer @@ -509,13 +500,9 @@ hex_table: rts .endproc - - - - .proc xdebug_send_printer - sta VIA::PRA + sta VIA::PRA lda VIA::PRB and #$EF @@ -536,13 +523,13 @@ command1_str: commands_text: .addr command1_str + commands_address: .addr _command1 + commands_version: .ASCIIZ "0.0.1" - - ; ---------------------------------------------------------------------------- ; Copyrights address @@ -553,8 +540,8 @@ parse_vector: .byt $00,$00 ; fff3 adress_commands: - .addr commands_address -; fff5 + .addr commands_address +; fff5 list_commands: .addr command1_str ; $fff7 @@ -565,7 +552,7 @@ signature_address: ; ---------------------------------------------------------------------------- ; Version + ROM Type -ROMDEF: +ROMDEF: .addr rom_start ; ---------------------------------------------------------------------------- diff --git a/src/kernel.asm b/src/kernel.asm index 37082de..7b05f82 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -15,9 +15,9 @@ adc #$01 .endmacro -.define VERSION "2023.3" +.define VERSION "2023.4" -XMALLOC_ROUTINE_TO_RAM_OVERLAY=39 +XMALLOC_ROUTINE_TO_RAM_OVERLAY = 39 ADIODB_LENGTH = $08 .define KERNEL_SIZE_IOTAB $04 @@ -31,7 +31,7 @@ ADIODB_LENGTH = $08 .include "libs/ch376-lib/include/ch376.inc" .include "include/kernel.inc" .include "include/process.inc" -.include "include/process_bss.inc" +;.include "include/process_bss.inc" .include "include/memory.inc" .include "include/files.inc" .include "include/ori2.inc" @@ -176,7 +176,6 @@ start_rom: @usb_controler_not_detected: - ; Mapping FILESYS lda #$00 sta FILESYS_BANK @@ -891,7 +890,6 @@ code_adress_4A1: pla rts - ; this routine read a value in a bank ; code_adress_4AF: @@ -1885,11 +1883,13 @@ XKBDAS_ROUTINE: asl tay lda KBD_UNKNOWN ; + @loop: LSR bcs @skip iny bcc @loop + @skip: lda KBDCOL+4 tax diff --git a/src/libs/ch376-lib/src/ch376.s b/src/libs/ch376-lib/src/ch376.s index f6d70da..7539d5a 100644 --- a/src/libs/ch376-lib/src/ch376.s +++ b/src/libs/ch376-lib/src/ch376.s @@ -2,7 +2,6 @@ lda #CH376_CMD_FILE_CREATE sta CH376_COMMAND jmp _ch376_wait_response - .endproc .proc _ch376_dir_create @@ -22,7 +21,7 @@ lda CH376_DATA sta TR2 lda CH376_DATA - sta TR3 + sta TR3 rts .endproc @@ -30,22 +29,21 @@ lda #CH376_DISK_CAPACITY sta CH376_COMMAND jsr _ch376_wait_response - + lda CH376_RD_USB_DATA0 sta CH376_COMMAND - + lda CH376_DATA ; total sector0 sta TR0 ; $5F - + lda CH376_DATA ; total sector1 sta TR1 ; $ED - + lda CH376_DATA ; total sector2 sta TR2 ; $92 - + lda CH376_DATA ; total sector3 - sta TR3 ; $d8 - + sta TR3 ; $d8 rts .endproc @@ -62,8 +60,8 @@ lda #$01 sta CH376_DATA jmp _ch376_wait_response -.endproc - +.endproc + ; [IN] AYX + RES : the 32 bits values .proc _ch376_seek_file @@ -73,7 +71,7 @@ sty CH376_DATA stx CH376_DATA - + lda RES sta CH376_DATA @@ -81,7 +79,6 @@ rts .endproc - .proc _ch376_file_open lda #CH376_FILE_OPEN sta CH376_COMMAND @@ -102,11 +99,11 @@ sta TR2 lda CH376_DATA sta TR3 - rts + rts .endproc - + .proc _ch376_reset_all - lda #CH376_RESET_ALL ; 5 + lda #CH376_RESET_ALL ; 5 sta CH376_COMMAND ; waiting ldy #$00 @@ -118,16 +115,16 @@ loop: iny bne loop rts -.endproc - +.endproc + .proc _ch376_check_exist - lda #CH376_CHECK_EXIST ; + lda #CH376_CHECK_EXIST ; sta CH376_COMMAND lda #$55 sta CH376_DATA lda CH376_DATA rts -.endproc +.endproc .proc _ch376_ic_get_ver lda #CH376_GET_IC_VER @@ -137,45 +134,44 @@ loop: clc adc #$30 ; return ascii version rts -.endproc - +.endproc + .proc _ch376_set_usb_mode lda #CH376_SET_USB_MODE ; $15 sta CH376_COMMAND .ifdef WITH_SDCARD_FOR_ROOT .warning "Build for sdcard by default" lda #CH376_SET_USB_MODE_CODE_SDCARD -.else +.else .warning "Build by usb key" lda #CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY -.endif +.endif lda KERNEL_CH376_MOUNT - sta CH376_DATA + sta CH376_DATA rts -.endproc +.endproc _ch376_set_bytes_read: ; A and Y contains number of bytes to read ldx #CH376_BYTE_READ .byt $2C ; jump 2 bytes with the hack bit $xxxx -_ch376_set_bytes_write: +_ch376_set_bytes_write: ldx #CH376_BYTE_WRITE stx CH376_COMMAND sta CH376_DATA sty CH376_DATA .IFPC02 -.pc02 +.pc02 ;stz CH376_DATA ;stz CH376_DATA -.p02 +.p02 .else ;lda #$00 ;sta CH376_DATA ;sta CH376_DATA -.endif +.endif jmp _ch376_wait_response - .proc _ch376_disk_mount lda #CH376_DISK_MOUNT sta CH376_COMMAND @@ -200,7 +196,7 @@ loop3: dey bne loop3 ; error is here - lda #$01 + lda #$01 rts no_error: lda #CH376_GET_STATUS @@ -208,8 +204,6 @@ no_error: lda CH376_DATA rts -.endproc -; -;str_usbdrive_controller_not_found: -; .byte "Usb drive controller not found !",$0D,$0A,0 +.endproc + diff --git a/src/memmap.asm b/src/memmap.asm index b2766c5..cd6cad4 100644 --- a/src/memmap.asm +++ b/src/memmap.asm @@ -1,5 +1,5 @@ - -.out .sprintf("|#MEMMAP: Page 0") +.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) @@ -69,7 +69,7 @@ ; Used by A : FLGSCR, FLGKBD, CURSCR, SCRX, SCRY, KBDCTC, KBDSHT, KBDFCT ; used in cc65 : SCRX, SCRY, ADSCR, SCRDY -.out .sprintf("|#MEMMAP: Page 2") +.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) @@ -179,25 +179,20 @@ .out .sprintf("|MEMMAP:RAM|VAPLIC | $%04X-$%04X | %d |", VAPLIC,VAPLIC+3,3) - - - - - -.out .sprintf("|#MEMMAP: Page 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 .sprintf("|##MEMMAP: Page 4") .out "|MEMMAP:Type | Name | Range | Size |" .out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" .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 .sprintf("|##MEMMAP: Page 5&6") .out "|MEMMAP:Type | Name | Range | Size |" .out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" -.out .sprintf("|MEMMAP:RAM|BUFNOM | $%04X-$%04X | %d |", BUFNOM, BUFNOM_END,BUFNOM_END-BUFNOM) +.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) @@ -205,13 +200,13 @@ .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 .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 .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) diff --git a/src/versions/versions.inc b/src/versions/versions.inc index c8ff0ed..1058d1e 100644 --- a/src/versions/versions.inc +++ b/src/versions/versions.inc @@ -4,5 +4,6 @@ .define KERNEL_VERSION_2023_1 $03 .define KERNEL_VERSION_2023_2 $04 .define KERNEL_VERSION_2023_3 $05 +.define KERNEL_VERSION_2023_4 $06 -.define CURRENT_VERSION_BINARY KERNEL_VERSION_2023_3 +.define CURRENT_VERSION_BINARY KERNEL_VERSION_2023_4