diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a2b21501..c239e9d2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,12 +14,12 @@ 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 id: cache-sdk - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | cc65/**/* @@ -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 @@ -72,7 +80,8 @@ 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 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} echo Timeout oricutron : $secret.TMOUT_ORICUTRON @@ -94,15 +103,17 @@ jobs: build: # The type of runner that the job will run on needs: setup-sdk - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 outputs: version: ${{ steps.job_vars.outputs.VERSION }} repo_name: ${{ steps.job_vars.outputs.REPO_NAME }} + bpm_found: ${{ steps.bpm_upload.outputs.BPM_FOUND }} steps: - uses: actions/checkout@v2 with: ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + submodules: recursive - name: Set job variables id: job_vars run: | @@ -110,7 +121,7 @@ jobs: echo "::set-output name=REPO_NAME::${GITHUB_REPOSITORY##*/}" - name: Install sdk - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | cc65/**/* @@ -118,15 +129,23 @@ jobs: md2hlp/**/* orix-software/**/* oricutron/**/* - key: ${{ secrets.CACHE_ID }}-orix-sdk_ + bpm/**/* + key: ${{ secrets.CACHE_ID }}-orix-sdk - name: Prepare environment for project run: | - ls -l && ls -l ../ - mv cc65 ../ && mv orix-software ../ && mv orix-sdk ../ && mv md2hlp ../ + mkdir ~/bin + cd bpm && pip install -r requirements.txt && cd .. + cp bpm/src/bpm ~/bin + chmod 755 ~/bin/bpm && export PATH=$PATH:~/bin + 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 + bpm --force-update --replace-for-new-project + cd src/kernel8 && bpm update && cd ../../ + CC65_HOME=${GITHUB_WORKSPACE}/../cc65 make - name: List build directory content run: ls -lR build @@ -135,11 +154,10 @@ 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 + 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 5 ./xvfb.sh || exit 0 + timeout --preserve-status 10 ./xvfb.sh || exit 0 - name: Check unit-test run: | @@ -147,7 +165,7 @@ jobs: bash tests/unit_test/verify.sh ${GITHUB_WORKSPACE}/oricutron/sdcard/ - name: Upload Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ steps.job_vars.outputs.REPO_NAME }} path: | @@ -159,11 +177,9 @@ jobs: mv ../cc65 . && mv ../orix-software . && mv ../orix-sdk . && mv ../md2hlp . ls -l - - upload: needs: build - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 defaults: run: shell: bash @@ -171,6 +187,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 @@ -189,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@v4 with: name: ${{ needs.build.outputs.repo_name }} path: artifact 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/Makefile b/Makefile index aeeae199..68889aa3 100644 --- a/Makefile +++ b/Makefile @@ -4,23 +4,37 @@ CFLAGS=-ttelestrat ASFLAGS=-ttelestrat LDFILES= +FILES_KERNEL7="tmp/xminma.o" + + all : init kernel memmap -.PHONY : all +.PHONY : prepare_tmp all -SOURCE=src/kernel.asm +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 - AS = ca65 - LD = ld65 - AR = ar65 + CL = cl65 + CC = cc65 + 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 + 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 endif PATH_PACKAGE_ROM=build/usr/share/$(PROGRAM_NAME)/ @@ -34,43 +48,143 @@ init: @mkdir -p build/usr/include/kernel/ @mkdir -p build/usr/src/kernel/ + 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 Build kernelsd.rom for Twilighte board - @$(AS) --verbose -s -tnone --debug-info -o kernelsd.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > output.log - @$(LD) -C src/kernel.cfg kernelsd.ld65 -m kernelsd.map -DWITH_SDCARD_FOR_ROOT=1 -DWITH_TWILIGHTE_BOARD=1 -Ln kernelsd.sym > output.log + @echo "########################################################" + @echo "# Build kernelsd.rom for Twilighte board #" + @echo "########################################################" + @$(AS) --cpu 6502 -tnone src/functions/strings/xminma.asm -o tmp/xminma.o + @$(AS) --cpu 6502 -tnone src/functions/bank_mng/switch_to_kernel_extended.s -o tmp/switch_to_kernel_extended.o + @$(AS) --cpu 6502 -tnone src/functions/bank_mng/kernel_restore_banking_states.s -o tmp/kernel_restore_banking_states.o + @$(AS) --cpu 6502 -tnone src/functions/lib_mng/XBANK_ROUTINE.s -o tmp/xbank_routine.o + @$(AS) --cpu 6502 -tnone src/functions/network/init_network.s -o tmp/init_network.o + @$(AS) --cpu 6502 -tnone src/functions/bank_mng/search_free_bank.s -o tmp/search_free_bank.o + @$(AS) --cpu 6502 -tnone src/functions/bank_mng/kernel_free_bank.s -o tmp/kernel_free_bank.o + @$(AS) --cpu 6502 -tnone src/functions/bank_mng/kernel_free_bank_by_pid.s -o tmp/kernel_free_bank_by_pid.o + @$(AS) --cpu 6502 -tnone src/functions/network/close_sockets_by_pid.s -o tmp/close_sockets_by_pid.o + @$(AS) --cpu 6502 -tnone src/functions/network/xsocket.s -o tmp/xsocket.o + @$(AS) --cpu 6502 -tnone src/functions/network/xconnect.s -o tmp/xconnect.o + @$(AS) --cpu 6502 -tnone src/functions/network/xsend.s -o tmp/xsend.o + @$(AS) --cpu 6502 -tnone src/functions/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 + @$(AR) r tmp/kernel_bank8.lib tmp/kernel_free_bank_by_pid.o + @$(AR) r tmp/kernel_bank8.lib tmp/xsocket.o + @$(AR) r tmp/kernel_bank8.lib tmp/xconnect.o + @$(AR) r tmp/kernel_bank8.lib tmp/xsend.o + @$(AR) r tmp/kernel_bank8.lib tmp/xclose_socket.o + @$(AR) r tmp/kernel_bank8.lib tmp/close_sockets_by_pid.o + @$(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 || exit 1 @cp kernel.rom kernelsd.rom - @sed -re 's/al 00(.{4}) \.(.+)$$/\1 \2/' kernelsd.sym| sort > kernelsd2.sym > output.log + + @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 || exit 1 + @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)/ - @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 --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 + @$(AS) --verbose -s --debug-info -o kernelus.ld65 $(SOURCE) $(ASFLAGS) > output.log + +compile_cc65: + @echo "########################################################" + @echo "# Compile C file with cc65 #" + @echo "########################################################" + @echo "FILE_TO_COMPILE: $(FILE_TO_COMPILE) FINAL_BIN: $(FINAL_BIN)" + @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 + @$(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 + @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: + @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 tmkdir - $(CC) $(CFLAGS) tests/fwrite.c -o tfwrite +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: - @$(AS) --verbose -s -tnone --debug-info -o kernel-telestrat.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > memmap.md - @$(LD) -C src/kernel.cfg kernel-telestrat.ld65 -m kernel.map -o kernel-telestrat.ld65.rom -DWITH_ACIA=2 -DWITH_SDCARD_FOR_ROOT=1 -Ln kernel-telestrat.ca.sym - sh generate_memmap.sh + @echo "########################################################" + @echo "# Build memmap.md #" + @echo "########################################################" + @$(AS) --cpu 6502 -DMEMMAP_GENERATE=1 --verbose -s -ttelestrat src/kernel_main_memory.s -o tmp/kernel_main_memory.ld65 > memmap.md + @#@$(LD) -C cfg/kernel.cfg tmp/kernelsd.ld65 tmp/kernel_bank0.ld65 tmp/kernel_main_memory.ld65 tmp/kernel.lib -m kernelus.map -o kernel-telestrat.ld65.rom -DWITH_ACIA=2 -DWITH_SDCARD_FOR_ROOT=1 -Ln kernel-telestrat.ca.sym + @sh generate_memmap.sh test: - cp Makefile build/usr/src/kernel/ - cp README.md build/usr/src/kernel/ - cp src/* build/usr/src/kernel/ -adpR - cp README.md build/usr/share/doc/$(PROGRAM_NAME)/ - ls -l $(HOMEDIR) - export ORIX_PATH=`pwd` - sh tools/builddocs.sh - cd build && tar -c * > ../$(PROGRAM_NAME).tar && cd .. - filepack $(PROGRAM_NAME).tar $(PROGRAM_NAME).pkg - gzip $(PROGRAM_NAME).tar - mv $(PROGRAM_NAME).tar.gz $(PROGRAM_NAME).tgz + @cp Makefile build/usr/src/kernel/ + @cp README.md build/usr/src/kernel/ + @cp src/* build/usr/src/kernel/ -adpR + @cp README.md build/usr/share/doc/$(PROGRAM_NAME)/ + @ls -l $(HOMEDIR) + @export ORIX_PATH=`pwd` + @sh tools/builddocs.sh + @cd build && tar -c * > ../$(PROGRAM_NAME).tar && cd .. + @filepack $(PROGRAM_NAME).tar $(PROGRAM_NAME).pkg + @gzip $(PROGRAM_NAME).tar + @mv $(PROGRAM_NAME).tar.gz $(PROGRAM_NAME).tgz diff --git a/README.md b/README.md index f12ba91c..40e72649 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,63 @@ [![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 card (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 +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) +# 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 -### Root file on sdcard +[Kernel Primitives Documentation](https://orix-software.github.io/developer_manual/kernel/primitives/) + +### 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 -here is the list of available "compile option" +### Root filesystem : usbdrive -* 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 +Remove -DWITH_SDCARD_FOR_ROOT=1 on ca65 command line +or else it will reads in sdcard ## 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 + +## Launch unit test (local) + +1) Set ORICUTRON_PATH in your shell eg : + +ORICUTRON_PATH=/bin/ +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 . + diff --git a/VERSION b/VERSION index 2cf03e51..89c24c57 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2024.1 \ No newline at end of file +2025.2 \ No newline at end of file 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/cfg/kernel.cfg b/cfg/kernel.cfg new file mode 100644 index 00000000..4d28d653 --- /dev/null +++ b/cfg/kernel.cfg @@ -0,0 +1,58 @@ +FEATURES { + STARTADDRESS: default = $1000; +} +SYMBOLS { + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STACKSTART__: type = weak, value = $8000; + __ZPSTART__: type = weak, value = $0080; +} +MEMORY { + ZP: file = "", define = yes, start = __ZPSTART__, size = $001F; + MAIN: file = %O, start = %S, size = __STACKSTART__ - __STACKSIZE__ - %S; + + BANK7: type = ro, start = $C000, size = $4000-16, file = "kernel.rom", fill = yes; + ORIXVEC7: start = $FFF0, size = 10 , file = "kernel.rom", fill = yes; + CPUVEC7: start = $FFFA, size = 6 , file = "kernel.rom", fill = yes; + INCL: file = "kernel_inc.inc", start=$0000, size = $FFFF; + + } +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + STARTUP: load = MAIN, type = ro, define = yes, optional = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = rw, define = yes, optional = yes; + RODATA: load = MAIN, type = rw, define = yes, optional = yes; + DATA: load = MAIN, type = rw, define = yes, optional = yes; + BSS: load = MAIN, type = bss, define = yes, optional = yes; + + SIGNATURE: load = MAIN, type = ro, define = yes, optional = yes; + INCLUDE: load = INCL, optional = yes; + # BANK8: load = BANK8, type = ro; + # ORIXVECT8: load = ORIXVEC8, type = ro, define = yes, optional = yes; + # CPUVECT8: load = CPUVEC8, type = ro, define = yes, optional = yes; + + BANK7: load = BANK7 , type = ro, define = yes; + ORIXVECT7: load = ORIXVEC7, type = ro, define = yes; + CPUVECT7: load = CPUVEC7, type = ro, define = yes; + + # BANK0: load = BANK0, type = ro; + # ORIXVECT0: load = ORIXVEC0, type = ro, define = yes, optional = yes; + # CPUVECT0: load = CPUVEC0, type = ro, define = yes, optional = yes; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} + diff --git a/cfg/kernel_bank8.cfg b/cfg/kernel_bank8.cfg new file mode 100644 index 00000000..579b6e2a --- /dev/null +++ b/cfg/kernel_bank8.cfg @@ -0,0 +1,82 @@ +FEATURES { + STARTADDRESS: default = $C000; +} +SYMBOLS { + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STACKSTART__: type = weak, value = $8000; + __ZPSTART__: type = weak, value = $0080; +} +MEMORY { + ZP: file = "", define = yes, start = __ZPSTART__, size = $001F; + MAIN: file = %O, start = %S, size = $10000 - %S - 16, fill = yes, fillval = $ff; + + BANK8: type = ro, start = $C000, size = $4000-16, file = "kernel8.rom", fill = yes; + ORIXVEC: start = $FFF0, size = 10 , file = "kernel8.rom", fill = yes; + CPUVEC: start = $FFFA, size = 6 , file = "kernel8.rom", fill = yes; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + STARTUP: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = rw; + RODATA: load = MAIN, type = rw; + DATA: load = MAIN, type = rw; + BSS: load = MAIN, type = bss, define = yes, optional = yes; + # BSS: load = MAIN, type = bss, define = yes; + SIGNATURE: load = MAIN, type = ro, define = yes, optional = yes; + ORIXVECT: load = ORIXVEC, type = ro, define = yes; + CPUVECT: load = CPUVEC, type = ro, define = yes; + BANK8: load = BANK8 , type = ro, define = yes; + +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} + +# FEATURES { +# STARTADDRESS: default = $C000; +# } +# SYMBOLS { +# # __STACKSIZE__: type = weak, value = $0800; # 2k stack +# # __STACKSTART__: type = weak, value = $8000; +# # __ZPSTART__: type = weak, value = $0080; +# } +# MEMORY { +# # ZP: file = "", define = yes, start = __ZPSTART__, size = $001F; +# MAIN: file = %O, start = %S, size = $4000; + +# # BANK8: type = ro, start = $C000, size = $4000-16, file = "kernel8.rom", fill = yes; + +# # CPUVEC8: start = $FFFA, size = 6 , file = "kernel8.rom", fill = yes; +# } +# SEGMENTS { +# # ZEROPAGE: load = ZP, type = zp; +# # STARTUP: load = MAIN, type = ro, define = yes, optional = yes; +# # LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; +# # ONCE: load = MAIN, type = ro, define = yes, optional = yes; +# CODE: load = MAIN, type = ro, define = yes, optional = yes; +# # RODATA: load = MAIN, type = ro, define = yes, optional = yes; +# # DATA: load = MAIN, type = ro, define = yes, optional = yes; +# # BSS: load = MAIN, type = bss, define = yes, optional = yes; + +# # SIGNATURE: load = MAIN, type = ro, define = yes, optional = yes; + +# # BANK8: load = BANK8, type = ro; +# # ORIXVECT8: load = ORIXVEC8, type = ro, define = yes, optional = yes; +# # CPUVECT8: load = CPUVEC8, type = ro, define = yes, optional = yes; + + +# } diff --git a/cfg/rom.cfg b/cfg/rom.cfg new file mode 100644 index 00000000..8d82f0be --- /dev/null +++ b/cfg/rom.cfg @@ -0,0 +1,29 @@ +FEATURES { + STARTADDRESS: default = $C000; +} + +SYMBOLS { + __ZPSTART__: type = weak, value = $0000; +} + +MEMORY { + ZP: file = "", define = yes, start = __ZPSTART__, size = $0100 - __ZPSTART__; + MAIN: file = %O, start = %S, size = $10000 - %S - 16, fill = yes, fillval = $ff; + ORIXVEC: start = $FFF0, size = 10; + CPUVEC: start = $FFFA, size = 6; +} + +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + ENTRY_TBL: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + DATA: load = MAIN, type = ro, optional = yes; + RODATA: load = MAIN, type = ro, optional = yes; + BSS: load = MAIN, type = ro, optional = yes; + # INSTRTBL: load = MAIN, type = ro, define = yes; + # INSTRTBL2: load = MAIN, type = ro, define = yes; + # INSTRJMP: load = MAIN, type = ro, define = yes; + SIGNATURE: load = MAIN, type = ro, define = yes, optional = yes; + ORIXVECT: load = ORIXVEC, type = ro, define = yes; + CPUVECT: load = CPUVEC, type = ro, define = yes; +} \ No newline at end of file diff --git a/dependencies/orix-sdk b/dependencies/orix-sdk index fe17aca6..a5640e25 160000 --- a/dependencies/orix-sdk +++ b/dependencies/orix-sdk @@ -1 +1 @@ -Subproject commit fe17aca694cc68fe05d0cfe9f6977e48da6250f3 +Subproject commit a5640e25fa03be5aaf2e81546eefc61fadf24d62 diff --git a/docs/ADDRESS_READ_BETWEEN_BANK.md b/docs/ADDRESS_READ_BETWEEN_BANK.md index 5914656c..0f31c7ee 100644 --- a/docs/ADDRESS_READ_BETWEEN_BANK.md +++ b/docs/ADDRESS_READ_BETWEEN_BANK.md @@ -1,2 +1 @@ # ADDRESS_READ_BETWEEN_BANK -* XWSTR0 diff --git a/docs/ADIODB_VECTOR.md b/docs/ADIODB_VECTOR.md index f36ee75b..4fe86ca8 100644 --- a/docs/ADIODB_VECTOR.md +++ b/docs/ADIODB_VECTOR.md @@ -1,5 +1 @@ # ADIODB_VECTOR -* XWR0 -* XWR0 -* XRD0 -* XRD0 diff --git a/docs/ADSCR.md b/docs/ADSCR.md index 03c64371..ca795a73 100644 --- a/docs/ADSCR.md +++ b/docs/ADSCR.md @@ -1,3 +1 @@ # ADSCR -* XWR0 -* XWR0 diff --git a/docs/ADSCRH.md b/docs/ADSCRH.md index 86aad815..942fa1f7 100644 --- a/docs/ADSCRH.md +++ b/docs/ADSCRH.md @@ -1,3 +1 @@ # ADSCRH -* XWR0 -* XWR0 diff --git a/docs/ADSCRL.md b/docs/ADSCRL.md index aa4acf24..73f37d4b 100644 --- a/docs/ADSCRL.md +++ b/docs/ADSCRL.md @@ -1,3 +1 @@ # ADSCRL -* XWR0 -* XWR0 diff --git a/docs/CURSCR.md b/docs/CURSCR.md index 70b0283b..ada25841 100644 --- a/docs/CURSCR.md +++ b/docs/CURSCR.md @@ -1,3 +1 @@ # CURSCR -* XWR0 -* XWR0 diff --git a/docs/FLGCUR.md b/docs/FLGCUR.md index 65721b3d..37d8b462 100644 --- a/docs/FLGCUR.md +++ b/docs/FLGCUR.md @@ -1,3 +1 @@ # FLGCUR -* XWR0 -* XWR0 diff --git a/docs/FLGCUR_STATE.md b/docs/FLGCUR_STATE.md index bb708158..c81a6d55 100644 --- a/docs/FLGCUR_STATE.md +++ b/docs/FLGCUR_STATE.md @@ -1,3 +1 @@ # FLGCUR_STATE -* XWR0 -* XWR0 diff --git a/docs/KBDKEY.md b/docs/KBDKEY.md index b76a88df..a39f4793 100644 --- a/docs/KBDKEY.md +++ b/docs/KBDKEY.md @@ -1,3 +1 @@ # KBDKEY -* XRD0 -* XRD0 diff --git a/docs/KBDSHT.md b/docs/KBDSHT.md index 2cdedca6..6600c050 100644 --- a/docs/KBDSHT.md +++ b/docs/KBDSHT.md @@ -1,3 +1 @@ # KBDSHT -* XRD0 -* XRD0 diff --git a/docs/KEYBOARD_COUNTER.md b/docs/KEYBOARD_COUNTER.md index b066d624..47628d86 100644 --- a/docs/KEYBOARD_COUNTER.md +++ b/docs/KEYBOARD_COUNTER.md @@ -1,3 +1 @@ # KEYBOARD_COUNTER -* XRD0 -* XRD0 diff --git a/docs/RES.md b/docs/RES.md index b3a6162e..df271125 100644 --- a/docs/RES.md +++ b/docs/RES.md @@ -1,26 +1 @@ # RES -* _create_file_pointer -* checking_fp_exists -* _set_to_value_seek_file -* kernel_create_process -* kernel_kill_process -* kernel_kill_process via XFREE_ROUTINE -* XDECAY -* XADRESS -* XDIVIS -* XREADBYTES_ROUTINE -* XPUTCWD_ROUTINE -* XWRITEBYTES_ROUTINE -* XFSEEK_ROUTINE -* XMKDIR_ROUTINE -* XRM_ROUTINE -* XOPENDIR -* XFILLM -* _XEXEC -* _XFORK -* _XFORK via kernel_create_process -* XMAINARGS_ROUTINE -* XGETARGV_ROUTINE -* kernel_try_to_find_command_in_bin_path -* XOPEN_ROUTINE -* XFREE_ROUTINE diff --git a/docs/RESB.md b/docs/RESB.md index ff316d2a..4d0408ac 100644 --- a/docs/RESB.md +++ b/docs/RESB.md @@ -1,20 +1 @@ # RESB -* checking_fp_exists -* kernel_create_process -* ZADCHA -* XDECAY -* XDIVIS -* XCLOSE_ROUTINE -* XGETCWD_ROUTINE -* XPUTCWD_ROUTINE -* XWRITEBYTES_ROUTINE -* XFSEEK_ROUTINE -* XOPENDIR -* compute_path_relative -* XFILLM -* _XEXEC -* _XFORK via kernel_create_process -* XGETARGV_ROUTINE -* getFileLength -* kernel_try_to_find_command_in_bin_path -* XOPEN_ROUTINE diff --git a/docs/RESC.md b/docs/RESC.md index ecd39671..3dec4e03 100644 --- a/docs/RESC.md +++ b/docs/RESC.md @@ -1,4 +1 @@ # RESC -* XOPENDIR -* compute_path_relative -* kernel_try_to_find_command_in_bin_path diff --git a/docs/RESD.md b/docs/RESD.md index b8517004..7935f88c 100644 --- a/docs/RESD.md +++ b/docs/RESD.md @@ -1,3 +1 @@ # RESD -* compute_path_relative -* kernel_try_to_find_command_in_bin_path diff --git a/docs/RESE.md b/docs/RESE.md index 0a6aa96e..21d2da98 100644 --- a/docs/RESE.md +++ b/docs/RESE.md @@ -1,3 +1 @@ # RESE -* compute_path_relative -* kernel_try_to_find_command_in_bin_path diff --git a/docs/RESF.md b/docs/RESF.md index 07747fd7..3d5fda33 100644 --- a/docs/RESF.md +++ b/docs/RESF.md @@ -1,3 +1 @@ # RESF -* compute_path_relative -* kernel_try_to_find_command_in_bin_path diff --git a/docs/RESG.md b/docs/RESG.md index 20efa94e..5d6a0a77 100644 --- a/docs/RESG.md +++ b/docs/RESG.md @@ -1,2 +1 @@ # RESG -* kernel_try_to_find_command_in_bin_path diff --git a/docs/RESH.md b/docs/RESH.md index b342aeee..b8e0c4c4 100644 --- a/docs/RESH.md +++ b/docs/RESH.md @@ -1,2 +1 @@ # RESH -* kernel_try_to_find_command_in_bin_path diff --git a/docs/SCRNB.md b/docs/SCRNB.md index af59abcf..11e62264 100644 --- a/docs/SCRNB.md +++ b/docs/SCRNB.md @@ -1,3 +1 @@ # SCRNB -* XWR0 -* XWR0 diff --git a/docs/TR0.md b/docs/TR0.md index 042918d4..7e1a8df3 100644 --- a/docs/TR0.md +++ b/docs/TR0.md @@ -1,9 +1 @@ # TR0 -* XBINDX -* XDIVIS -* XREADBYTES_ROUTINE -* XFSEEK_ROUTINE -* XOPENDIR -* _XEXEC -* _XFORK -* XMAINARGS_ROUTINE diff --git a/docs/TR1.md b/docs/TR1.md index 62c2e55b..32cc4fad 100644 --- a/docs/TR1.md +++ b/docs/TR1.md @@ -1,8 +1 @@ # TR1 -* XBINDX -* XDIVIS -|MODIFY:KERNEL_XOPEN_PTR1:XFSEEK_ROUTINE -* _XEXEC -* _XFORK -* XMAINARGS_ROUTINE -|MODIFY:KERNEL_XOPEN_PTR1:XOPEN_ROUTINE diff --git a/docs/TR2.md b/docs/TR2.md index bb21b5f4..383b5b18 100644 --- a/docs/TR2.md +++ b/docs/TR2.md @@ -1,3 +1 @@ # TR2 -* XBINDX -* XMAINARGS_ROUTINE diff --git a/docs/TR3.md b/docs/TR3.md index 616a3def..d77aeaac 100644 --- a/docs/TR3.md +++ b/docs/TR3.md @@ -1,3 +1 @@ # TR3 -* XBINDX -* XMAINARGS_ROUTINE diff --git a/docs/TR4.md b/docs/TR4.md index 9f102227..168f7b6d 100644 --- a/docs/TR4.md +++ b/docs/TR4.md @@ -1,7 +1 @@ # TR4 -* kernel_create_process -* XBINDX -* XDECIM -* XFSEEK_ROUTINE -* _XFORK via kernel_create_process -* XMAINARGS_ROUTINE diff --git a/docs/TR5.md b/docs/TR5.md index db030728..53692fc1 100644 --- a/docs/TR5.md +++ b/docs/TR5.md @@ -1,8 +1 @@ # TR5 -* checking_fp_exists -* kernel_create_process -* kernel_kill_process via XFREE_ROUTINE -* XBINDX -* XDECIM -* _XFORK via kernel_create_process -* XOPEN_ROUTINE diff --git a/docs/TR6.md b/docs/TR6.md index 65de9081..ec980260 100644 --- a/docs/TR6.md +++ b/docs/TR6.md @@ -1,3 +1 @@ # TR6 -* XDECIM -* XFSEEK_ROUTINE diff --git a/docs/TR7.md b/docs/TR7.md index abdeb0fb..1c56f1a5 100644 --- a/docs/TR7.md +++ b/docs/TR7.md @@ -1,7 +1 @@ # TR7 -* XCLOSE_ROUTINE -* XFSEEK_ROUTINE -* XMKDIR_ROUTINE -* XOPENDIR -* XOPEN_ROUTINE -* XMALLOC_ROUTINE diff --git a/docs/i_o_counter.md b/docs/i_o_counter.md index 7b152055..eac23a23 100644 --- a/docs/i_o_counter.md +++ b/docs/i_o_counter.md @@ -1,5 +1 @@ # i_o_counter -* XWR0 -* XWR0 -* XRD0 -* XRD0 diff --git a/docs/i_o_save.md b/docs/i_o_save.md index 8c6b1b86..fa56efce 100644 --- a/docs/i_o_save.md +++ b/docs/i_o_save.md @@ -1,4 +1 @@ # i_o_save -* XWR0 -* XWSTR0 -* XWR0 diff --git a/docs/memmap_ram.html b/docs/memmap_ram.html index 6cedd851..3241dd04 100644 --- a/docs/memmap_ram.html +++ b/docs/memmap_ram.html @@ -1,9 +1,9 @@ - - - - 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 e4ea2c0c..da96d42f 100644 --- a/docs/memmap_ram.md +++ b/docs/memmap_ram.md @@ -1,5 +1,7 @@ # Memmap + ## Page 0 + |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| |RAM|RES | $00-$01 | 2 | @@ -39,9 +41,9 @@ |RAM|SCRNB | $28-$29 | 2 | |RAM|ADKBD | $2A-$2B | 2 | |RAM|PTR_READ_DEST | $2C-$2D | 2 | -|RAM|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 | $020A-$020C | 3 | +|RAM|FLGTEL | $020D-$020D | 1 | |RAM|TIMED | $0210-$0210 | 1 | |RAM|TIMES | $0211-$0211 | 1 | |RAM|TIMEM | $0212-$0212 | 1 | @@ -134,8 +137,7 @@ ## Page 4 |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| -|RAM|page4 overlay_access | $0419-$0436 | 54 | -|RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0411 | 3 | +|RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0414 | 3 | ## Page 5&6 |Type | Name | Range | Size | | :------- |:----------------------------- |:----------- |:-----| @@ -144,15 +146,3 @@ |RAM|main kernel process struct | $0579-$058F | 22 | |RAM|BUFEDT | $0590-$05FE | 110 | |RAM|KERNEL_MEMORY_DRIVER | $05FE-$06A1 | 163 | -## Kernel bank 7 -| Type | Name | Range | Size | -| :-------- |:---------------------------- |:------- |:-----| -|ROM|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.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 85ec4182..e69de29b 100644 --- a/memmap.md +++ b/memmap.md @@ -1,382 +0,0 @@ -KERNEL_MAX_PATH_LENGTH : 49 bytes -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_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: Page 0 -|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-$31 | | -|MEMMAP:RAM|ptr1 | $32-$33 | 2 | -|MEMMAP:RAM|tmp1 | $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-$020F | 6 | -|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 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: :------- |:----------------------------- |:----------- |:-----| -|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: Type | Name | Range | Size | -|MEMMAP: :-------- |:---------------------------- |:------- |:-----| -|MEMMAP:ROM|FREE |$feee-$fff0| 258 | -|##MEMMAP: Bank 0 -|MEMMAP: Type | Name | Range | Size | -|MEMMAP: -------- | ---------------------------- | ------- |-----| -|MEMMAP:BANK0|BUFBUF | $c080-$c0b6 | 54 | -|MEMMAP:BANK0|BUFROU | $c500-$c54e | | -|MEMMAP:BANK0|TELEMON_KEYBOARD_BUFFER_BEGIN | $c5c4-$c680 | | -|MEMMAP:BANK0|XMALLOC (copy from kernel) | $fba0-$fc4c | | -|MEMMAP:BANK0|XFREE (copy from kernel) | $fc4c-$fed1 | | diff --git a/run.bat b/run.bat deleted file mode 100644 index fd54a2b7..00000000 --- a/run.bat +++ /dev/null @@ -1,46 +0,0 @@ -@echo off - -rem SET ORICUTRON="..\..\..\..\oricutron-iss2-debug\" -SET ORICUTRON="D:\users\plifp\Onedrive\oric\oricutron_twilighte" - -rem set ORICUTRON="/d/Users/plifp/onedrive/oric/oricutron_twilighte" - - - -SET ORIGIN_PATH=%CD% - -SET ROM=kernel -rem -DWITH_SDCARD_FOR_ROOT=1 -%CC65%\ca65.exe --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 --verbose -s -ttelestrat --include-dir %CC65%\asminc\ src/%ROM%.asm -o %ROM%sd.ld65 --debug-info || goto :error -%CC65%\ld65.exe -tnone -DWITH_SDCARD_FOR_ROOT=1 %ROM%sd.ld65 -o %ROM%.rom -Ln kernelsd.sym -m memmap.txt -vm - - - - -%CC65%\ca65.exe --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 -DWITH_DEBUG=1 --verbose -s -ttelestrat --include-dir %CC65%\asminc\ src/kdebug.asm -o kdebugsd.ld65 --debug-info -%CC65%\ld65.exe -tnone -DWITH_SDCARD_FOR_ROOT=1 -DWITH_DEBUG=1 kdebugsd.ld65 -o kdebug.rom -Ln kdebugsd.sym -m memmap.txt -vm - -%CC65%\cl65.exe -ttelestrat tests/mkdir.c -o tmkdir -%CC65%\cl65.exe -ttelestrat tests/fwrite.c -o tfwrite -%CC65%\cl65.exe -ttelestrat -C tests/orix-sdk/cfg/telestrat_900.cfg tests/multiples_files_opened.c tests/multiples_files_fopen.s tests/exec.s -o multi - - -IF "%1"=="NORUN" GOTO End - -copy tmkdir %ORICUTRON%\sdcard\bin -copy tmkdir %ORICUTRON%\sdcard\bin -copy multi %ORICUTRON%\sdcard\bin\f -copy %ROM%.rom %ORICUTRON%\roms\ > NUL -rem copy kdebug.rom %ORICUTRON%\roms\ > NUL -copy bp.txt %ORICUTRON% -cd %ORICUTRON% - -oricutron -r :bp.txt - - -:End -cd %ORIGIN_PATH% -rem %OSDK%\bin\MemMap "%ORIGIN_PATH%\xa_labels_orix.txt" memmap.html O docs/telemon.css -exit /b -:error -echo Error de build diff --git a/run.sh b/run.sh index 1c8e249e..40d13840 100644 --- a/run.sh +++ b/run.sh @@ -1,31 +1,146 @@ #! /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" +ORICUTRON_PATH="/mnt/c/Users/plifp/OneDrive/oric/oricutron_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 -RET=$? -if [ $RET != 0 ] -then -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 -#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 +# 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 -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 +# 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 + +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 +cp tmp/netchk $ORICUTRON_PATH/sdcard/bin/ cp kernel.rom $ORICUTRON_PATH/roms -# cp kdebug.rom $ORICUTRON_PATH/roms -cp tests/test_kernel $ORICUTRON_PATH/sdcard/bin/test +cp kernel8.rom $ORICUTRON_PATH/roms + +# # cp kdebug.rom $ORICUTRON_PATH/roms +# cp tests/test_kernel $ORICUTRON_PATH/sdcard/bin/test + #cp tests/kopened $ORICUTRON_PATH/sdcard/bin/ #cat tests/unit_test/xopen.sub > $ORICUTRON_PATH/sdcard/etc/AUTOBOOT -#cat tests/unit_test/xrm.sub >> $ORICUTRON_PATH/sdcard/etc/AUTOBOOT +#cat tests/unit_test/start.sub > $ORICUTRON_PATH/sdcard/etc/AUTOBOOT + +# cp tests/unit_test/mainarg.sub $ORICUTRON_PATH/sdcard/bin/mainarg.sub + +# cl65 -ttelestrat tests/unit_test/mainarg.s -o 1000 --start-addr 2048 +# cl65 -ttelestrat tests/unit_test/mainarg.s -o 1256 --start-addr 2304 +# dependencies/orix-sdk/bin/relocbin.py3 -o mainarg -2 1000 1256 + + +#cp mainarg $ORICUTRON_PATH/sdcard/bin/mainarg cd $ORICUTRON_PATH ./oricutron diff --git a/src/functions/XOP.asm b/src/functions/XOP.asm index 400e1054..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,24 +7,24 @@ 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: - ldy #(KERNEL_SIZE_IOTAB-1) +@skip129: + ldy #(KERNEL_SIZE_IOTAB - 1) @loop: cmp IOTAB,y @@ -42,7 +42,9 @@ skip129: ldx work_channel pla - @skip2: + +@skip2: sta IOTAB,x clc rts +.endproc diff --git a/src/functions/XWRx.asm b/src/functions/XWRx.asm index 54b6fe34..49a46edc 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") @@ -37,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/_manage_keyboard.asm b/src/functions/_manage_keyboard.asm index 249ee48d..ea2f7894 100644 --- a/src/functions/_manage_keyboard.asm +++ b/src/functions/_manage_keyboard.asm @@ -18,7 +18,7 @@ lda KBDVRR jmp @S5 @S2: - dec KBDVRL+1 + dec KBDVRL + 1 bne @S6 jsr XKBDAS_ROUTINE jmp @S4 @@ -27,7 +27,7 @@ @S4: lda KBDVRL @S5: - sta KBDVRL+1 + sta KBDVRL + 1 @S6: rts .endproc 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..0ff1eddd --- /dev/null +++ b/src/functions/bank_mng/kernel_free_bank.s @@ -0,0 +1,45 @@ +.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 + ;;@inputX Contains the id of the bank to free + ;;@modifyA + ;;@modifyX + ;;@modifyY + + ;;@returnsA + ;;@returnsX + ;;@returnsY + + stx TR2 ; Save bank to free in TR2 + 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 + + lda #$00 ; Success since kernel 2025.3 + + 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..2ab3c3e8 --- /dev/null +++ b/src/functions/bank_mng/kernel_restore_banking_states.s @@ -0,0 +1,29 @@ +.export kernel_restore_banking_states +.export kernel_restore_banking_states_register + +.import KERNEL_SAVE_XEXEC_CURRENT_SET +.import KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM + +.import switch_to_kernel_extended + + +.segment "BANK7" + +.proc kernel_restore_banking_states + pla + jsr switch_to_kernel_extended + ; restore + jmp kernel_restore_banking_states_register +.endproc + + +.proc kernel_restore_banking_states_register + pha + lda KERNEL_SAVE_XEXEC_CURRENT_SET + sta $343 + lda KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM + sta $342 + pla + cli + rts +.endproc diff --git a/src/functions/bank_mng/search_free_bank.s b/src/functions/bank_mng/search_free_bank.s new file mode 100644 index 00000000..852f153b --- /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..f8d614dd --- /dev/null +++ b/src/functions/bank_mng/switch_to_kernel_extended.s @@ -0,0 +1,37 @@ +.include "telestrat.inc" + +.export switch_to_kernel_extended +.export switch_to_kernel_extended_fill_register_bank8 + + +.import KERNEL_SAVE_XEXEC_CURRENT_SET +.import KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM + +.segment "BANK7" + +.proc switch_to_kernel_extended + jsr switch_to_kernel_extended_fill_register_bank8 + jmp $40C +.endproc + +.proc switch_to_kernel_extended_fill_register_bank8 + ; Switch to bank 8 (extended mode) + pha + lda $343 + sta KERNEL_SAVE_XEXEC_CURRENT_SET + + lda #$04 + sta BNKCIB + + lda $342 + sta KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM + and #%11011111 + sei + + sta $342 + + lda #$04 + sta $343 + pla + rts +.endproc \ No newline at end of file diff --git a/src/functions/charsets/charset.asm b/src/functions/charsets/charset.asm index ad4371a4..f6a9e943 100644 --- a/src/functions/charsets/charset.asm +++ b/src/functions/charsets/charset.asm @@ -1,3 +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/exe/ori2.asm b/src/functions/exe/ori2.asm index 1df010cd..3bde5d35 100644 --- a/src/functions/exe/ori2.asm +++ b/src/functions/exe/ori2.asm @@ -13,13 +13,21 @@ ; 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 @@ -37,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 @@ -44,24 +54,25 @@ 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 adc RESE 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 +81,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 +94,7 @@ ldy #15 ; High start adress - lda RESD+1 ; Align + lda RESD + 1 ; Align clc adc #$01 cmp (RESD),y @@ -101,145 +112,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..a890a9da --- /dev/null +++ b/src/functions/exe/relocate_ORI2.asm @@ -0,0 +1,128 @@ +.export relocate_ORI2 + +; .import ORI2_PAGE_LOAD +; .import ORI2_LENGTH_MAP +; .import ORI2_MAP_ADRESS +; .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) + 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/files/XOPEN.asm b/src/functions/files/XOPEN.asm index 4ecd4ea6..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,17 +59,17 @@ ; 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 + stx XOPEN_RES_SAVE + 1 ; save flag sty XOPEN_FLAGS ; ; 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 diff --git a/src/functions/files/_create_file_pointer.asm b/src/functions/files/_create_file_pointer.asm index a1a6fcda..a55d63a7 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 @@ -64,7 +64,7 @@ clc adc KERNEL_XOPEN_PTR2 bcc @S1 - inc KERNEL_XOPEN_PTR2+1 + inc KERNEL_XOPEN_PTR2 + 1 @S1: sta KERNEL_XOPEN_PTR2 @@ -87,7 +87,7 @@ ; return fp or null lda KERNEL_XOPEN_PTR1 ; $7c3 - ldy KERNEL_XOPEN_PTR1+1 + ldy KERNEL_XOPEN_PTR1 + 1 rts .endproc 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/_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/_update_fp_position.asm b/src/functions/files/_update_fp_position.asm index 8f829b41..46d8c36e 100644 --- a/src/functions/files/_update_fp_position.asm +++ b/src/functions/files/_update_fp_position.asm @@ -1,12 +1,12 @@ .proc _update_fp_position - + ; Modify HRS1 sec 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 @@ -30,23 +30,22 @@ sta (KERNEL_XOPEN_PTR1),y ; update byte 1 of the file position bcc @no_inc_byte2 - ldy #(_KERNEL_FILE::f_seek_file+1) + ldy #(_KERNEL_FILE::f_seek_file + 1) jsr inc_byte_superior ; byte 2 bcc @no_inc_byte2 - ldy #(_KERNEL_FILE::f_seek_file+2) + ldy #(_KERNEL_FILE::f_seek_file + 2) jsr inc_byte_superior bcc @no_inc_byte2 - ldy #(_KERNEL_FILE::f_seek_file+3) + ldy #(_KERNEL_FILE::f_seek_file + 3) jsr inc_byte_superior bcc @no_inc_byte2 - @no_inc_byte2: - ldy #(_KERNEL_FILE::f_seek_file+1) + 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,8 @@ @no_inc_byte3: lda XOPEN_RES - ldx XOPEN_RES+1 + ldx XOPEN_RES + 1 + rts inc_byte_superior: diff --git a/src/functions/files/checking_fp_exists.asm b/src/functions/files/checking_fp_exists.asm index aa9b5f62..eae61bfe 100644 --- a/src/functions/files/checking_fp_exists.asm +++ b/src/functions/files/checking_fp_exists.asm @@ -2,16 +2,15 @@ ; 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") + .out .sprintf("|MODIFY:HRS3:checking_fp_exists") sty KERNEL_XWRITE_XCLOSE_XFSEEK_XFREAD_SAVE_Y txa ; X contains the fp - sta KERNEL_XWRITE_XCLOSE_XFSEEK_XFREAD_SAVE_X ; save fp id + sta KERNEL_XWRITE_XCLOSE_XFSEEK_XFREAD_SAVE_X ; save fp id $52 is HRS3+1 ; Compute fd index in main fp struct sec sbc #KERNEL_FIRST_FD @@ -19,20 +18,20 @@ bcs @doesnot_exists ; Yes error ; When orix boots, kernel_fd_opened is equal to $FF, if the fd passed into arg is the same than kernel_fd_opened it means that we don't need to close and store - cmp kernel_process+kernel_process_struct::kernel_fd_opened + cmp kernel_process + kernel_process_struct::kernel_fd_opened beq @do_not_seek - ldx kernel_process+kernel_process_struct::kernel_fd_opened + ldx kernel_process + kernel_process_struct::kernel_fd_opened cpx #$FF ; First file opened when orix boots ? bne @store_and_seek - sta kernel_process+kernel_process_struct::kernel_fd_opened + sta kernel_process + kernel_process_struct::kernel_fd_opened jmp @do_not_seek @store_and_seek: ; store the new fd to open - sta kernel_process+kernel_process_struct::kernel_fd_opened + sta kernel_process + kernel_process_struct::kernel_fd_opened ; At this step we can store the seek of the file ; close current file @@ -40,7 +39,7 @@ sta KERNEL_XFSEEK_SAVE_RESB lda RES+1 - sta KERNEL_XFSEEK_SAVE_RESB+1 + sta KERNEL_XFSEEK_SAVE_RESB + 1 jsr _ch376_file_close @@ -57,7 +56,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 +75,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 2b87fa1c..a50fbf59 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 @@ -5,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/compute_path_relative.asm b/src/functions/files/compute_path_relative.asm index eb8ec249..d3d99d0e 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 ./ @@ -18,6 +18,7 @@ beq @it_s_dot_slash cmp #'.' beq @it_s_dot_dot_slash + @error_relative: ldx #$01 ; Error rts @@ -90,13 +91,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 +119,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 +160,7 @@ @malloc_ok: ; Now copy sta RESF - sty RESF+1 + sty RESF + 1 ldy #$00 @@ -181,7 +182,7 @@ sta RESH ; Malloc is done lda RESF - ldy RESF+1 + ldy RESF + 1 ; A contains the compute rts @@ -193,6 +194,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..86d12c04 100644 --- a/src/functions/files/xclose.asm +++ b/src/functions/files/xclose.asm @@ -1,19 +1,16 @@ .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 - 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) @@ -29,54 +26,46 @@ 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 - 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 + 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,9 +77,15 @@ tay pla ; $7D5 + jsr XFREE_ROUTINE - ldy #kernel_one_process_struct::fp_ptr + ; Clear fp in current process + lda TR7 + asl + clc + adc #kernel_one_process_struct::fp_ptr + tay lda #$00 sta (RESB),y iny @@ -101,14 +96,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 62d3be7d..98e79951 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) $0A & $0B + ;;@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 - sta KERNEL_XFSEEK_SAVE_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,17 @@ beq @go_end cpx #SEEK_SET beq @go_beginning - lda #EINVAL ; Return error + ;lda #EINVAL ; Return error + +@returns_minus_1: + 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 +105,25 @@ 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 - rts + jmp returns_position + @error_bad_seek: + ; lda #$FF ; EBADSEEK + jmp @returns_minus_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 +142,6 @@ sta (KERNEL_XOPEN_PTR1),y sta TR7 - iny lda (KERNEL_XOPEN_PTR1),y adc RES5 @@ -126,7 +150,7 @@ iny lda (KERNEL_XOPEN_PTR1),y - adc RES5+1 + adc RES5 + 1 sta (KERNEL_XOPEN_PTR1),y sta RESB @@ -137,9 +161,10 @@ cmp #$14 bne @error_bad_seek - lda #EOK ; Return ok - rts + jmp returns_position + +; SEEK_SET : Seek from the beginning of the file @go_beginning: ;sta TR6 ; Seek from the beginning of the file @@ -152,7 +177,7 @@ bne @error_bad_seek ; And seek with offset now - lda RES5+1 + lda RES5 + 1 sta RESB ldy TR7 ; Get Y @@ -192,6 +217,28 @@ adc RES5+1 sta (KERNEL_XOPEN_PTR1),y - lda #EOK ; Return ok + ; Don't RTS here , we execute returns position + +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 + 1 + dey + ; Store it in AX for from 0 to 15 bits + lda (KERNEL_XOPEN_PTR1),y + sta RES + dey + lda (KERNEL_XOPEN_PTR1),y + tax + dey + lda (KERNEL_XOPEN_PTR1),y + ; FIXME REMOVE ME !!!!! + ldy #EOK + ; lda #EOK rts + + .endproc 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 3b390b05..cd5cc55a 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 @@ -29,13 +29,13 @@ lda KERNEL_ERRNO rts -@skip2: +@skip2: lda #CH376_SET_FILE_NAME sta CH376_COMMAND ldy #$00 @mloop: - lda (ptr1),y + lda (ADDRESS_READ_BETWEEN_BANK_DOUBLON),y beq @mend cmp #"/" beq @launch_xopen @@ -78,59 +78,60 @@ @isabsolute: rts - lda ptr1 - ldy #O_RDONLY - ldx ptr1+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 (ptr1),y - beq @end - cmp #"/" - beq @create_dir - 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/xopendir.asm b/src/functions/files/xopendir.asm index 4d1ca312..d62a1e20 100644 --- a/src/functions/files/xopendir.asm +++ b/src/functions/files/xopendir.asm @@ -19,7 +19,7 @@ CH376_DIR_INFO_READ = $37 ; A&Y ptr of str ; Do do : check if it's a DIR sta RES - sty RES+1 + sty RES + 1 ; Add /* at the end ldy #$00 @@ -97,8 +97,8 @@ CH376_DIR_INFO_READ = $37 sta RES sty RES+1 ; FD - lda #<(.sizeof(_READDIR_STRUCT)*READDIR_MAX_LINE) - ldy #>(.sizeof(_READDIR_STRUCT)*READDIR_MAX_LINE) + lda #<(.sizeof(_READDIR_STRUCT) * READDIR_MAX_LINE) + ldy #>(.sizeof(_READDIR_STRUCT) * READDIR_MAX_LINE) jsr XMALLOC_ROUTINE cmp #$00 bne @continue @@ -201,7 +201,7 @@ display_catalog: pla @not_space: - cmp #'Z'+1 ; + cmp #'Z' + 1 ; bcs @skip cmp #'A' @@ -291,7 +291,7 @@ display_catalog: clc adc #.sizeof(_READDIR_STRUCT) bcc @do_not_inc - inc RESC+1 + inc RESC + 1 @do_not_inc: sta RESC diff --git a/src/functions/files/xputcwd.asm b/src/functions/files/xputcwd.asm index 06a78f8c..61eb2dc7 100644 --- a/src/functions/files/xputcwd.asm +++ b/src/functions/files/xputcwd.asm @@ -7,7 +7,7 @@ .out .sprintf("|MODIFY:RESB:XPUTCWD_ROUTINE") sta RES - sty RES+1 + sty RES + 1 ; let's trim jsr _trim @@ -56,7 +56,7 @@ clc adc RESB bcc @S4 - inc RESB+1 + inc RESB + 1 @S4: sta RESB @@ -76,7 +76,7 @@ @compute: - ldx kernel_process+kernel_process_struct::kernel_current_process + ldx kernel_process + kernel_process_struct::kernel_current_process jsr kernel_get_struct_process_ptr @@ -90,7 +90,7 @@ clc adc RESB bcc @S1 - inc RESB+1 + inc RESB + 1 @S1: sta RESB rts diff --git a/src/functions/files/xread.asm b/src/functions/files/xread.asm index 1b6befdf..fa2cb7bd 100644 --- a/src/functions/files/xread.asm +++ b/src/functions/files/xread.asm @@ -3,13 +3,16 @@ .out .sprintf("|MODIFY:PTR_READ_DEST:XREADBYTES_ROUTINE") .out .sprintf("|MODIFY:RES:XREADBYTES_ROUTINE") .out .sprintf("|MODIFY:TR0:XREADBYTES_ROUTINE") + .out .sprintf("|MODIFY:HRS1:XREADBYTES_ROUTINE") + .out .sprintf("|MODIFY:HRS3:XREADBYTES_ROUTINE") + ; [IN] AY contains the length to read ; [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 + +; Modify : RES, PTR_READ_DEST, TR0, HRS1 (update_fp_postion.asm with XOPEN_RES) ; [OUT] PTR_READ_DEST updated ; Compute with update_position @@ -23,11 +26,11 @@ lda PTR_READ_DEST sta RES ; - lda PTR_READ_DEST+1 - sta RES+1 + lda PTR_READ_DEST + 1 + sta RES + 1 ; Checking if fp exists - jsr checking_fp_exists + jsr checking_fp_exists ; Uses HRS3 + 1 bcc @continue_xfread pla ; Error return 0 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/files/xrm.asm b/src/functions/files/xrm.asm index 97b9193c..e4d9c0e7 100644 --- a/src/functions/files/xrm.asm +++ b/src/functions/files/xrm.asm @@ -18,12 +18,12 @@ @continue: ; save fp sta RES - stx RES+1 + stx RES + 1 jsr _ch376_file_erase lda RES - ldy RES+1 + ldy RES + 1 jsr XCLOSE_ROUTINE lda #$00 rts diff --git a/src/functions/files/xwrite.asm b/src/functions/files/xwrite.asm index b5e2c585..9b954a68 100644 --- a/src/functions/files/xwrite.asm +++ b/src/functions/files/xwrite.asm @@ -15,8 +15,8 @@ lda PTR_READ_DEST sta RES - lda PTR_READ_DEST+1 - sta RES+1 + lda PTR_READ_DEST + 1 + sta RES + 1 ; Checking if fp exists jsr checking_fp_exists @@ -81,7 +81,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/getargv.asm b/src/functions/getargv.asm index 2e93dfda..52870afa 100644 --- a/src/functions/getargv.asm +++ b/src/functions/getargv.asm @@ -10,11 +10,13 @@ .out .sprintf("|MODIFY:RES:XGETARGV_ROUTINE") .out .sprintf("|MODIFY:RESB:XGETARGV_ROUTINE") +.export XGETARGV_ROUTINE + .proc XGETARGV_ROUTINE ; lda RES - sty RES+1 - sty RESB+1 + sty RES + 1 + sty RESB + 1 sta RES txa @@ -24,9 +26,9 @@ clc adc RES bcc @S1 - inc RESB+1 + inc RESB + 1 @S1: - ldy RESB+1 + ldy RESB + 1 ; A & Y return ptr of the param rts 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/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/init_screen.asm b/src/functions/init_screen.asm index de08b29a..df9b96fe 100644 --- a/src/functions/init_screen.asm +++ b/src/functions/init_screen.asm @@ -11,6 +11,7 @@ bpl @loop ldy #$05 ; loop with $12 to fill text definitions and Hires + @L1: lda data_text_window,y ; data_to_define_2 sta SCRTXT,y ; thise fill also SCRHIR diff --git a/src/functions/lib_mng/XBANK_ROUTINE.s b/src/functions/lib_mng/XBANK_ROUTINE.s new file mode 100644 index 00000000..7eec0fda --- /dev/null +++ b/src/functions/lib_mng/XBANK_ROUTINE.s @@ -0,0 +1,33 @@ +.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 + + .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 + + lda #>$C000 + sta VEXBNK + 2 + ; !!!! pla is done in kernel_restore_banking_states + jmp kernel_restore_banking_states + +.endproc diff --git a/src/functions/mainargs.asm b/src/functions/mainargs.asm index 0b2f5bac..ac2539a1 100644 --- a/src/functions/mainargs.asm +++ b/src/functions/mainargs.asm @@ -28,23 +28,38 @@ 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 - ldx kernel_process+kernel_process_struct::kernel_current_process + ; 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 + 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 + inc RES + 1 + @S7: sta RES - lda #KERNEL_XMAINARG_MALLOC_TYPE - sta KERNEL_MALLOC_TYPE + lda #<.sizeof(XMAINARGS_STRUCT) ldy #>.sizeof(XMAINARGS_STRUCT) @@ -65,7 +80,7 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte @continue: ; Save malloc sta RESB - sty RESB+1 + sty RESB + 1 lda XMAINARGS_MODE beq @parse @@ -73,6 +88,7 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte ; Mode 1 : Copy only ldy #$00 + @loop2: lda (RES),y beq @out2 @@ -84,7 +100,7 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte sta (RESB),y lda RESB - ldy RESB+1 + ldy RESB + 1 rts @@ -97,13 +113,14 @@ 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 @@ -124,16 +141,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 +180,34 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte ldx XMAINARGSC ; return ptr - lda RESB ; $7C9 - ldy RESB+1 + 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 +222,5 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte txa tay - inc XMAINARGSC - -@no_new_arg: - iny - jmp @loop - + rts .endproc diff --git a/src/functions/math/xcos.asm b/src/functions/math/xcos.asm index aeef9bdd..253060e2 100644 --- a/src/functions/math/xcos.asm +++ b/src/functions/math/xcos.asm @@ -1,4 +1,5 @@ .export XCOS_ROUTINE + .proc XCOS_ROUTINE jsr LF8B1 lda #5 + ;;@` BRK_TELEMON XMALLOC + ;;@` rts + ;;@``` + + ; $fb64 .out .sprintf("|MODIFY:TR7:XMALLOC_ROUTINE") @@ -15,52 +28,12 @@ ; Verify if there is enough memory ; -.ifdef WITH_DEBUG - jsr kdebug_save - - ldx #XDEBUG_XMALLOC_ENTER_AY - - jsr xdebug_print_with_ay - - ldx #XDEBUG_TYPE - jsr xdebug_print - - - lda KERNEL_MALLOC_TYPE - cmp #KERNEL_PROCESS_STRUCT_MALLOC_TYPE - bne @O2 - ldx #XDEBUG_TYPE_PROCESSSTRUCT - jsr xdebug_print - jmp @O1 -@O2: - cmp #KERNEL_UNKNOWN_MALLOC_TYPE - bne @O4 - ldx #XDEBUG_UNKNOWN - jsr xdebug_print - - jmp @O1 -@O4: - cmp #KERNEL_XMAINARG_MALLOC_TYPE - bne @O3 - ldx #XDEBUG_TYPE_MAINARGS - jsr xdebug_print - jmp @O1 -@O3: - cmp #KERNEL_FP_MALLOC_TYPE - bne @O5 - ldx #XDEBUG_TYPE_FPSTRUCT - jsr xdebug_print - jmp @O1 -@O5: - ; others -@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,12 +46,13 @@ @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 @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 @@ -87,89 +61,135 @@ 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 - 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 +@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 - 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_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_high + ; 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 - 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_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_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_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 + 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 + + 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 +@return_pointer: @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 - - ; Restore type + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_pid_list,x - lda #KERNEL_UNKNOWN_MALLOC_TYPE - sta KERNEL_MALLOC_TYPE ; Debug -.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 - - ldx #3 - - 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/memory/xrealloc.asm b/src/functions/memory/xrealloc.asm new file mode 100644 index 00000000..5b34118b --- /dev/null +++ b/src/functions/memory/xrealloc.asm @@ -0,0 +1,97 @@ +.export XREALLOC_ROUTINE +;.import search_busy_chunk_with_address + +.proc XREALLOC_ROUTINE ; ; $02 + ;;@brief Perform a realloc in the kernel memory space (48K). Return NULL if no memory available or if the pointer is invalid + ;;@inputA contains the new size to allocate low (1 byte) + ;;@inputY contains the new size to allocate high (1 byte) + ;;@inputX reserved for future use, should be set to 0 by caller + ;;@inputMEM_RES contains the pointer to reallocate (2 bytes) + ;;@modifyMEM_RESB + ;;@modifyMEM_HRS2 + ;;@modifyMEM_HRS1 + + + sta HRS2 ; save size + sty HRS2 + 1 ; save size + + ; lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_begin_low,y + ;lda kernel_malloc + kernel_malloc_struct::kernel_malloc_free_chunk_end_low,y + ;kernel_malloc_free_chunk_begin_low + + ; A and Y contains the pointer to the memory to reallocate, and X contains the new size of the memory to allocate + ; We need to check if the pointer is valid, if not, we just call XMALLOC + ; If the pointer is valid, we need to check if the new size is greater than the old size, if not, we can just return the same pointer, if it's greater, we need to allocate new memory and copy the old memory to the new one, then free the old memory and return the new pointer + ; Check if pointer is valid + jsr XMALLOC_ROUTINE ; Does not use RES or RESB, so it does not affect kernel_create_process routine and kernel_try_to_find_command_in_bin_path, it returns NULL in A and Y if no memory available, or the pointer to the allocated memory in A and Y if successful + ; If the pointer is NULL, it means that the pointer is invalid, we just call XMALLOC + cmp #NULL + bne @continue_realloc + cpy #NULL + bne @continue_realloc + ; The pointer is invalid + ; Impossible to realloc, we return NULL +@exit_null: + rts + +@continue_realloc: + ; Let's copy to new memory the content of the old memory, then free the old memory and return the new pointer + ; New ptr + sta RESB ; Save A (low value of the new size), Y is not saved because we don't modify it + sty RESB + 1 ; Save Y (high value of the new size) + + ; Save old ptr + lda RES + sta HRS2 + + lda RES + 1 + sta HRS2 + 1 + + jsr search_busy_chunk_with_address + cmp #NULL + ; Y will be equal to NULL if we did not found the busy chunk (from search_busy_chunk_with_address), it means that the pointer is invalid + beq @exit_null + + ; Now get size of the old memory to reallocate + + stx HRS1 + 1 ; Save position of the busy chunk found in search_busy_chunk_with_address, because we will need it to free the old memory after copying + + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high,x + beq @copy_low + ;sta HRS1 + + inx + + ldy #$00 + +@restart_copy: + lda (RES),y + sta (RESB),y ; Copy content of the old memory to the new one + iny + bne @copy + inc RES + 1 + inc RESB + 1 + dex + bne @restart_copy + +@copy_low: + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x + sta HRS1 + beq @nop + +@copy: + lda (RES),y + sta (RESB),y ; Copy content of the old memory to the new one + iny + cpy HRS1 + bne @copy + + ; Free old memory +@nop: + lda HRS2 + ldy HRS2 + 1 + jmp XFREE_ROUTINE + +.endproc + + 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..c85cacfe --- /dev/null +++ b/src/functions/network/close_sockets_by_pid.s @@ -0,0 +1,80 @@ +.include "telestrat.inc" + +.export close_sockets_by_pid + +.import KERNEL_NETWORK_FLAG +.import KERNEL_NETWORK_SOCKET_LIST +.import KERNEL_NETWORK_SOURCE_PORT +.import KERNEL_NETWORK_SOCKET_PID +.import KERNEL_NETWORK_SOCKET_DOMAIN + +.import kernel_process + +.include "../../kernel8/orixlibs/ch395/usr/include/asm/ch395.inc" +.include "../../kernel8/orixlibs/ksocket/usr/include/asm/socket.inc" +.include "../../include/kernel.inc" +.include "../../include/process.inc" +.include "../../include/network.inc" +.include "../../include/memory.inc" + +.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 + ;;@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 #$00 + ldy TR1 ; Offset of the socket + MEMORY_GET_VALUE_FROM_BANK ; A contains the value + + cmp kernel_process + kernel_process_struct::kernel_current_process + beq @close_socket + +@compute: + inc TR1 + lda TR1 + + cmp #NETWORK_MAX_SOCKET + beq @exit + bne @restart + +@close_socket: + + lda TR1 ; Socket ID + jsr ch395_close_socket_sn + + ; Set to 0 + ldy TR1 ; Get socket id (index) + lda #$00 ; clear + ldx #$00 ; BANK + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_LIST ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + + ; Set to 0n + ldy TR1 ; Get socket id (index) + lda #$00 ; Domain + ldx #$00 ; BANK + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_DOMAIN ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + + ; Clear PID + ldy TR1 ; Get socket id (index) + lda #$00 + ldx #$00 ; BANK + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_PID ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + jmp @compute +@exit: + rts +.endproc \ No newline at end of file diff --git a/src/functions/network/init_network.s b/src/functions/network/init_network.s new file mode 100644 index 00000000..936708f7 --- /dev/null +++ b/src/functions/network/init_network.s @@ -0,0 +1,173 @@ +.include "telestrat.inc" + +.export init_network + +.import ch395_check_exist +.import ch395_set_fun_para +.import ch395_init +.import ch395_get_phy_status + +.import ch395_get_dhcp_status +.import ch395_dhcp_enable + +.import ch395_get_ip_inf +.import kch395_get_ip_inf + +.import KERNEL_NETWORK_FLAG +.import KERNEL_NETWORK_SOCKET_LIST +.import KERNEL_NETWORK_SOURCE_PORT + +.include "../../kernel8/orixlibs/ch395/usr/include/asm/ch395.inc" +.include "../../include/kernel.inc" +.include "../../include/process.inc" +.include "../../include/network.inc" +.include "../../include/memory.inc" + +.proc init_network + ; Returns KERNEL_NETWORK_FULLY_STARTED if network is started + + lda #KERNEL_NETWORK_FLAG + + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + + ldx #$00 + ldy #$00 + MEMORY_GET_VALUE_FROM_BANK ; A contains the value + cmp #KERNEL_NETWORK_FULLY_STARTED + bne @check_all + rts + +@check_all: + cmp KERNEL_NETWORK_STATE_NOT_INITIALIZED + bne @ch395_found + + jsr ch395_check_exist + + cmp #$AA + beq @ch395_found + lda #KERNEL_NETWORK_STATE_CHIP_NOT_FOUND + rts + +@ch395_found: + ; FIXME SHould not be done here + lda #KERNEL_NETWORK_FLAG + + 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 + + jsr kch395_get_ip_inf ; Fill RES to RES + 20 + + 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..efe2f530 --- /dev/null +++ b/src/functions/network/xclose_socket.s @@ -0,0 +1,45 @@ +.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 +.import KERNEL_NETWORK_SOCKET_PID + +.export XSOCKET_CLOSE_ROUTINE + +.import ch395_close_socket_sn + +.proc XSOCKET_CLOSE_ROUTINE + ; X contains the id of the socket + ; Remove socket id + .out .sprintf("|MODIFY:TR0:XSOCKET_CLOSE_ROUTINE") + + txa + sta TR0 + + 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 + + + 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 + + +.endproc + diff --git a/src/functions/network/xconnect.s b/src/functions/network/xconnect.s new file mode 100644 index 00000000..f8d6c9ea --- /dev/null +++ b/src/functions/network/xconnect.s @@ -0,0 +1,82 @@ +.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 + .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 + 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..39be74eb --- /dev/null +++ b/src/functions/network/xsend.s @@ -0,0 +1,31 @@ +; .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..d988467d --- /dev/null +++ b/src/functions/network/xsocket.s @@ -0,0 +1,149 @@ +.include "../../kernel8/orixlibs/ch395/usr/include/asm/ch395.inc" +.include "../../kernel8/orixlibs/ksocket/usr/include/asm/socket.inc" + +.include "../../include/kernel.inc" +.include "../../include/process.inc" +.include "../../include/memory.inc" +.include "../../include/network.inc" + +.include "telestrat.inc" + +.import KERNEL_NETWORK_SOCKET_LIST +.import KERNEL_NETWORK_SOCKET_DOMAIN + +.import init_network + +.export XSOCKET_ROUTINE + +.import ch395_set_ipraw_pro_sn +.import ch395_set_proto_type_sn +.import ch395_get_socket_status_sn +.import ch395_close_socket_sn +.import kernel_process +.import KERNEL_NETWORK_SOCKET_PID +;.import socket_state +;.export socket_sour_port + + +.proc XSOCKET_ROUTINE + ;;@brief Open a socket + ;;@inputA protocol + ;;@inputX domain ex : AF_INET + ;;@inputY type ex : SOCK_STREAM + ;;@modifyMEM_RES + ;;@modifyMEM_TR6 + ;;@modifyMEM_TR5 + ;;@returnsX The socket id + ;;@returnsA if != -1 then it returns socket id. -1 is return if all socket are used, or network is not started or unavailable + + ; sock = socket(AF_INET, SOCK_STREAM, 0); + ;;@```ca65 + ;;@` ; or use Macro (socket.mac) SOCKET domain, type, protocol + ;;@` SOCKET AF_INET, SOCK_STREAM, 0 + ;;@` + ;;@``` + + ;;@```ca65 + ;;@` lda #$00 ; + ;;@` ldx #AF_INET ; domain + ;;@` ldy #SOCK_STREAM ; type + ;;@` brk XSOCKET + ;;@``` + + ; socket_state contains 0 if socket is not used, or contains type if used + + + socket := RES + 1 + type := TR6 + domain := TR5 + + stx domain ; domain + sty type ; Save type + + + ; Checking if network is started + jsr init_network + cmp #KERNEL_NETWORK_FULLY_STARTED + beq @continue +; Error, return INVALID + lda #INVALID_SOCKET + rts + +@continue: + ; Looking for available socket + lda #$00 + sta socket + +@search_free_socket: + ldx #$00 + + lda #KERNEL_NETWORK_SOCKET_LIST + + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 + ldy socket + MEMORY_GET_VALUE_FROM_BANK ; A contains the value + cmp #$00 + beq @socketfound + + inc socket + lda socket + cmp #NETWORK_MAX_SOCKET + bne @search_free_socket + +; Error, return INVALID + lda #INVALID_SOCKET + + rts + +@socketfound: +; A contains the id of the socket + + + ; save TYPE (SOCK_STREAM etc) + ldy socket ; Get socket id (index) + lda type ; Type sock_stream + ldx #$00 ; BANK + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_LIST ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + + ; Store domain + ldy socket ; Get socket id (index) + lda domain ; Domain + ldx #$00 ; BANK + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_DOMAIN ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + + ; Store pid + ldy socket ; Get socket id (index) + lda kernel_process + kernel_process_struct::kernel_current_process + ldx #$00 ; BANK + + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_SOCKET_PID ; ADDRESS_READ_BETWEEN_BANK_DOUBLON is already set previously : FIXME + + ; Setting CH395 + lda type + cmp #SOCK_RAW + beq @is_ip_raw + + + ; SOCK_STEAM or SOCK_DGRAM + lda socket ; socket + ldx type + + jsr ch395_set_proto_type_sn + jmp @exit_socket + +@is_ip_raw: + lda socket ; Get socket id + ldx #CH395_PROTO_TYPE_IP_RAW + jsr ch395_set_ipraw_pro_sn + +@exit_socket: + lda socket ; return the id of the socket + rts + +.endproc + + + + diff --git a/src/functions/process/kernel_create_process.asm b/src/functions/process/kernel_create_process.asm index 0f0257a9..ecd6f40e 100644 --- a/src/functions/process/kernel_create_process.asm +++ b/src/functions/process/kernel_create_process.asm @@ -25,22 +25,16 @@ sta RESB sta TR4 - sty RESB+1 + sty RESB + 1 sty TR5 - -.ifdef WITH_DEBUG - ldx #XDEBUG_CREATE_PROCESS_PRINT - ; jsr xdebug_print -.endif - ; Try to find the next PID available ; Get first pid ldx #$00 ; Because the first is init ( @L3: - lda kernel_process+kernel_process_struct::kernel_pid_list,x + lda kernel_process + kernel_process_struct::kernel_pid_list,x beq @found inx cpx #KERNEL_MAX_PROCESS @@ -61,7 +55,7 @@ stx KERNEL_XKERNEL_CREATE_PROCESS_TMP lda #$01 - sta kernel_process+kernel_process_struct::kernel_pid_list,x + sta kernel_process + kernel_process_struct::kernel_pid_list,x ; Malloc process for init process lda #KERNEL_PROCESS_STRUCT_MALLOC_TYPE @@ -78,8 +72,7 @@ cpy #NULL bne @S2 ; erreur OOM - lda #KERNEL_UNKNOWN_MALLOC_TYPE - sta KERNEL_MALLOC_TYPE + ldy #ENOMEM rts @@ -87,11 +80,10 @@ @S2: ; now register ptr adress of process ldx KERNEL_XKERNEL_CREATE_PROCESS_TMP - - sta kernel_process+kernel_process_struct::kernel_one_process_struct_ptr_low,x + sta kernel_process + kernel_process_struct::kernel_one_process_struct_ptr_low,x sta RES tya - sta kernel_process+kernel_process_struct::kernel_one_process_struct_ptr_high,x + sta kernel_process + kernel_process_struct::kernel_one_process_struct_ptr_high,x sty RES+1 ; prepare to copy 'process' string @@ -102,7 +94,7 @@ ldy #kernel_one_process_struct::ppid - lda kernel_process+kernel_process_struct::kernel_current_process ; $57A + lda kernel_process + kernel_process_struct::kernel_current_process ; $57A sta (RES),y ; $6AE @register_processname: @@ -164,7 +156,7 @@ save_command_line: @L5: sta (RES),y iny - cpy #(kernel_one_process_struct::fp_ptr+KERNEL_MAX_FP_PER_PROCESS*2) + cpy #(kernel_one_process_struct::fp_ptr+KERNEL_MAX_FP_PER_PROCESS * 2 ) bne @L5 ; Set to "/" cwd of init process @@ -174,10 +166,10 @@ save_command_line: cpx #$01 ; First process after init (should be sh) ; COMMENT TO HAVE WORKING MAX PROCESS beq @initialize_to_slash - 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 + sty KERNEL_CREATE_PROCESS_PTR1 + 1 ; Copy cwd from ppid @@ -208,7 +200,8 @@ save_command_line: @skip: ; Set pid number in the struct ldx KERNEL_XKERNEL_CREATE_PROCESS_TMP - stx kernel_process+kernel_process_struct::kernel_current_process + + stx kernel_process + kernel_process_struct::kernel_current_process ldy #EOK rts diff --git a/src/functions/process/kernel_exec_from_storage.asm b/src/functions/process/kernel_exec_from_storage.asm index cb412993..2f7fecc3 100644 --- a/src/functions/process/kernel_exec_from_storage.asm +++ b/src/functions/process/kernel_exec_from_storage.asm @@ -13,6 +13,7 @@ .out .sprintf("|MODIFY:PTR_READ_DEST:kernel_try_to_find_command_in_bin_path") + ; A & Y contains the command ; here we found no command, let's go trying to find it in /bin ; Malloc @@ -111,7 +112,7 @@ clc adc RESC bcc @S20 - inc RESC+1 + inc RESC + 1 @S20: sta RESC @@ -218,7 +219,7 @@ open_binary_and_exec: @out_not_found: lda RESF - ldy RESF+1 + ldy RESF + 1 jsr XCLOSE_ROUTINE @@ -229,34 +230,37 @@ 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 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 +297,8 @@ open_binary_and_exec: lda RESD sta RESI - lda RESD+1 - sta RESI+1 + lda RESD + 1 + sta RESI + 1 jmp shebang_management @@ -328,13 +332,14 @@ open_binary_and_exec: ldy #ENOEXEC sty KERNEL_ERRNO 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 @@ -348,20 +353,22 @@ 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 + 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 @@ -378,20 +385,19 @@ open_binary_and_exec: sta PTR_READ_DEST ; init RES to start code - ldy #18 lda (RESD),y ; fixme 65c02 sta RESE 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 @@ -405,11 +411,14 @@ open_binary_and_exec: jsr @read_program @run: + + + jsr @clean_before_execute jsr @execute - stx HRS2+1 + stx HRS2 + 1 pha ; Save return code $91e ldy #kernel_one_process_struct::kernel_process_addr @@ -417,21 +426,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,25 +450,29 @@ 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: + jmp (RESE) ; jmp : it means that if program launched do an rts, it returns to interpreter @read_program: + + + lda #$FF ; read all the binary ldy #$FF ldx RESF ; FP @@ -507,7 +520,7 @@ str_root_bin: ; $94D sta RESE ; RESE contains the malloc /bin/path - sty RESE+1 + sty RESE + 1 rts .endproc @@ -533,7 +546,7 @@ str_root_bin: clc adc RESD bcc @advance_ptr_resd - inc RESD+1 + inc RESD + 1 @advance_ptr_resd: sta RESD @@ -578,7 +591,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 +602,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 +624,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 +643,7 @@ str_root_bin: clc adc RESCONCAT bcc @S100 - inc RESCONCAT+1 + inc RESCONCAT + 1 @S100: sta RESCONCAT @@ -646,7 +660,7 @@ str_root_bin: clc adc RESCONCAT bcc @S10000 - inc RESCONCAT+1 + inc RESCONCAT + 1 @S10000: sta RESCONCAT @@ -702,7 +716,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_get_struct_process_ptr.asm b/src/functions/process/kernel_get_struct_process_ptr.asm index 194582f4..4ebd4779 100644 --- a/src/functions/process/kernel_get_struct_process_ptr.asm +++ b/src/functions/process/kernel_get_struct_process_ptr.asm @@ -1,8 +1,10 @@ +.export kernel_get_struct_process_ptr + .proc kernel_get_struct_process_ptr ; X contains the pid to get ; Returns in A and Y ptr - lda kernel_process+kernel_process_struct::kernel_one_process_struct_ptr_low,x - ldy kernel_process+kernel_process_struct::kernel_one_process_struct_ptr_high,x + lda kernel_process + kernel_process_struct::kernel_one_process_struct_ptr_low,x + ldy kernel_process + kernel_process_struct::kernel_one_process_struct_ptr_high,x rts .endproc diff --git a/src/functions/process/kernel_kill_process.asm b/src/functions/process/kernel_kill_process.asm index f2e25648..266ddbd9 100644 --- a/src/functions/process/kernel_kill_process.asm +++ b/src/functions/process/kernel_kill_process.asm @@ -26,6 +26,19 @@ 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 +60,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 @@ -66,7 +79,7 @@ ; restore zp of the PPID - ldx kernel_process+kernel_process_struct::kernel_current_process ; $57D + ldx kernel_process + kernel_process_struct::kernel_current_process ; $57D jsr kernel_get_struct_process_ptr sta RES sty RES+1 @@ -98,7 +111,7 @@ ldx #$00 @init_fp: - cmp kernel_process+kernel_process_struct::kernel_fd,x + cmp kernel_process + kernel_process_struct::kernel_fd,x bne @next txa @@ -119,15 +132,14 @@ .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 ldx #$00 @L2: - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_pid_list,x - + 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 @@ -138,12 +150,13 @@ cpx #KERNEL_MAX_NUMBER_OF_MALLOC bne @L2 beq @all_chunk_are_free + @erase_chunk: txa pha - 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 jsr XFREE_ROUTINE diff --git a/src/functions/process/xexec.asm b/src/functions/process/xexec.asm index 2c9acc3c..704f2b66 100644 --- a/src/functions/process/xexec.asm +++ b/src/functions/process/xexec.asm @@ -150,7 +150,7 @@ out1: skip_sta_hrs2: - lda kernel_process+kernel_process_struct::kernel_current_process + lda kernel_process + kernel_process_struct::kernel_current_process cmp #$01 ; Dans le cas d'exec, il y a 2 kill qui se font FIXME bug beq @no_kill jsr kernel_kill_process diff --git a/src/functions/process/xfork.asm b/src/functions/process/xfork.asm index 0564073c..8d44a6ee 100644 --- a/src/functions/process/xfork.asm +++ b/src/functions/process/xfork.asm @@ -36,10 +36,10 @@ ; At this step we replace the process ; Let's free all memory from this process - ldx kernel_process+kernel_process_struct::kernel_current_process + ldx kernel_process + kernel_process_struct::kernel_current_process jsr kernel_get_struct_process_ptr - sty KERNEL_CREATE_PROCESS_PTR1+1 + sty KERNEL_CREATE_PROCESS_PTR1 + 1 sta KERNEL_CREATE_PROCESS_PTR1 clc @@ -57,7 +57,7 @@ beq @S8 sta (KERNEL_CREATE_PROCESS_PTR1),y iny - cpy #(KERNEL_LENGTH_MAX_CMDLINE-1) + cpy #(KERNEL_LENGTH_MAX_CMDLINE - 1) bne @L10 lda #$00 ; Store 0 @@ -68,7 +68,7 @@ rts @perform_fork: - ldx kernel_process+kernel_process_struct::kernel_current_process + ldx kernel_process + kernel_process_struct::kernel_current_process cpx #$FF ; is it init ? beq @skip_save_zp ; For instance, we don't save init zp because all are reserved @@ -91,8 +91,7 @@ lda TR0 ldy TR1 - jsr kernel_create_process ; returns null if we reached max process or KERNEL_ERRNO is filled too + jmp kernel_create_process ; returns null if we reached max process or KERNEL_ERRNO is filled too - rts .endproc diff --git a/src/functions/strings/xminma.asm b/src/functions/strings/xminma.asm index 9cd4ad64..74c52b8a 100644 --- a/src/functions/strings/xminma.asm +++ b/src/functions/strings/xminma.asm @@ -1,9 +1,16 @@ +.export XMINMA_ROUTINE + +.segment "BANK7" + .proc XMINMA_ROUTINE - cmp #"a" ; 'a' - bcc @skip - cmp #$7B ; 'z' - bcs @skip - sbc #$1F + 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..3a778386 100644 --- a/src/functions/text/xink.asm +++ b/src/functions/text/xink.asm @@ -1,3 +1,4 @@ +.export XINK_ROUTINE .proc XINK_ROUTINE sec @@ -51,7 +52,7 @@ 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 @S5: @@ -67,7 +68,7 @@ adc #$28 ;I (donc une ligne) sta RES ;I bcc @S6 ; I - inc RES+1 ; I + inc RES + 1 ; I @S6: pla ; I on sort le code dex ; I on compte X lignes 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_scroh.asm b/src/functions/text/xscrob_scroh.asm index 5ee34ae4..9751dcb1 100644 --- a/src/functions/text/xscrob_scroh.asm +++ b/src/functions/text/xscrob_scroh.asm @@ -4,7 +4,7 @@ XSCROH_ROUTINE: ;Action:scrolle vers le bas de la ligne X à la ligne Y la fenêtre courante. lda #$00 ; on prend $0028, soit 40 FIXME 65c02 - sta DECFIN+1 + sta DECFIN + 1 lda #$28 bne LDE62 ; inconditionnel @@ -14,7 +14,7 @@ XSCROH_ROUTINE: XSCROB_ROUTINE: lda #$FF ; on prend $FFD8, soit -40 en complement a 2 - sta DECFIN+1 + sta DECFIN + 1 lda #$D8 LDE62: sta DECFIN ; $06-07 contiennent le déplacement @@ -36,13 +36,13 @@ LDE62: iny @skip2: sta DECCIB ; est dans $08-09 - sty DECCIB+1 + sty DECCIB + 1 clc ; on ajoute le deplacement adc DECFIN sta DECDEB tya - adc DECFIN+1 - sta DECDEB+1 ; dans $04-05 + adc DECFIN + 1 + sta DECDEB + 1 ; dans $04-05 pla ; on sort le nombre de lignes sta RES ; dans RES beq LDEC4 ; si nul on fait n'importe quoi ! on devrait sortir! @@ -51,9 +51,9 @@ LDE62: ldx SCRNB ; I lda SCRFX ; la largeur de la fenètre I sbc SCRDX ; I - sta RES+1 ; dans RES+1 I + sta RES + 1 ; dans RES+1 I LDE9D: - ldy RES+1 + ldy RES + 1 LDE9F: ; I lda (DECDEB),y ; on transfère une ligne I sta (DECCIB),y ; I @@ -63,20 +63,20 @@ LDE9F: ; I lda DECDEB ; on ajoute le déplacement I adc DECFIN ; à l'adresse de base I sta DECDEB ; I - lda DECDEB+1 ; I - adc DECFIN+1 ; I - sta DECDEB+1 ; I + lda DECDEB + 1 ; I + adc DECFIN + 1 ; I + sta DECDEB + 1 ; I clc ; I lda DECCIB ; et à l'adresse d'arrivée I adc DECFIN ; I sta DECCIB ; I - lda DECCIB+1 ; I - adc DECFIN+1 ; I - sta DECCIB+1 ; I + lda DECCIB + 1 ; I + adc DECFIN + 1 ; I + sta DECCIB + 1 ; I dec RES ; on décompte une ligne de faite I bne LDE9D ; et on fait toutes les lignes I LDEC4 - ldy RES+1 ; on remplit la dernière ligne I + ldy RES + 1 ; on remplit la dernière ligne I lda #$20 ; I @L1: sta (DECCIB),Y ; avec de espaces I diff --git a/src/functions/text/xscrob_xscroh.asm b/src/functions/text/xscrob_xscroh.asm index a6c8bfbe..02d6f62d 100644 --- a/src/functions/text/xscrob_xscroh.asm +++ b/src/functions/text/xscrob_xscroh.asm @@ -1,10 +1,12 @@ +.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. lda #$00 ; on prend $0028, soit 40 - sta DECFIN+1 + sta DECFIN + 1 lda #$28 bne scroll_XSCROB_ROUTINE ; inconditionnel .endproc @@ -14,7 +16,7 @@ XSCROB_ROUTINE: lda #$FF ; on prend $FFD8, soit -40 en complément à 2 - sta DECFIN+1 + sta DECFIN + 1 lda #$D8 scroll_XSCROB_ROUTINE: sta DECFIN ; $06-07 contiennent le déplacement @@ -36,13 +38,13 @@ scroll_XSCROB_ROUTINE: iny @skip2: sta DECCIB ; est dans $08-09 - sty DECCIB+1 + sty DECCIB + 1 clc ; on ajoute le déplacement adc DECFIN sta DECDEB tya - adc DECFIN+1 - sta DECDEB+1 ; dans $04-05 + adc DECFIN + 1 + sta DECDEB + 1 ; dans $04-05 pla ; on sort le nombre de lignes sta RES ; dans RES beq LDEC4 ; si nul on fait n'importe quoi ! on devrait sortir! @@ -63,20 +65,20 @@ LDE9D: lda DECDEB ; on ajoute le déplacement I adc DECFIN ; à l'adresse de base I sta DECDEB ; I - lda DECDEB+1 ; I - adc DECFIN+1 ; I - sta DECDEB+1 ; I + lda DECDEB + 1 ; I + adc DECFIN + 1 ; I + sta DECDEB + 1 ; I clc ; I lda DECCIB ; et à l'adresse d'arrivée I adc DECFIN ; I sta DECCIB ; I - lda DECCIB+1 ; I - adc DECFIN+1 ; I - sta DECCIB+1 ; I + lda DECCIB + 1 ; I + adc DECFIN + 1 ; I + sta DECCIB + 1 ; I dec RES ; on décompte une ligne de faite I bne LDE9D ; et on fait toutes les lignes I LDEC4: - ldy RES+1 ; on remplit la dernière ligne I + ldy RES + 1 ; on remplit la dernière ligne I lda #$20 ; I @L1: sta (DECCIB),y ; avec de espaces I 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/xdebug.asm b/src/functions/xdebug.asm index d5eae270..91f339d8 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 @@ -167,18 +176,6 @@ hex_table: rts .endproc -.proc xdebug_enter_XFREE_new_freechunk - rts - jsr xdebug_save - lda #str_enter_free - sta RES - sty RES+1 - jmp xdebug_enter - -str_enter_free: - .byte $0D,"[XFREE] new free chunk",0 -.endproc .proc xdebug_end rts @@ -293,21 +290,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/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/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..fda83d3a 100644 --- a/src/functions/xloadcharset.asm +++ b/src/functions/xloadcharset.asm @@ -1,14 +1,22 @@ + +.import charset_text + +.export XLOADCHARSET_ROUTINE + +;.segment "BANK7" + .proc XLOADCHARSET_ROUTINE + ldx #$00 @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/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..23ecef80 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 @@ -9,7 +14,7 @@ .endproc .proc XVALUES_ROUTINE - cpx #KERNEL_XVALUES_FREE_MALLOC_TABLE + cpx #KERNEL_XVALUES_FREE_MALLOC_TABLE ; $02 beq @malloc_table_copy ; Used by lsmem cpx #KERNEL_XVALUES_BUSY_MALLOC_TABLE @@ -76,8 +81,8 @@ sta RES sta RESB - sty RES+1 - sty RESB+1 + sty RES + 1 + sty RESB + 1 jsr XMALLOC_COPY_TABLE_FREE @@ -93,34 +98,32 @@ 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)) + 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 + sty RES + 1 + sty RESB + 1 jsr XMALLOC_COPY_TABLE_BUSY2 lda RESB - ldy RESB+1 + ldy RESB + 1 rts -; @xvalues_get_filesize: -; rts - @xvalues_get_osname: - lda #<5 - ldy #>5 + lda #<$05 + ldy #>$05 jsr XMALLOC_ROUTINE sta RES - sty RES+1 + sty RES + 1 ldy #$00 + @loop_osname: lda osname,y beq @eos_osname @@ -135,6 +138,7 @@ ldy RES+1 rts + @xvalues_get_time: ror FLGCLK lda TIMES @@ -155,6 +159,7 @@ bne @rom lda #32 sta RES + @rom: lda $343 beq @do_not_compute @@ -187,6 +192,7 @@ .endproc + .proc xvalues_get_free_ram_bank_routine ; Y contains if the type of bank @@ -195,6 +201,8 @@ cpy #$01 ; Is rom ? beq @not_managed + + ldx #$00 lda BUSY_BANK_TABLE_RAM @@ -245,61 +253,19 @@ .endproc .proc get_registers_from_id_bank - cmp #$00 - beq @bank0 - tay - lda set,y - tax - lda bank,y - rts + 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 + ; Impossible to have bank 0 + tax + rts + +.include "set_bank_mapping_values.s" .endproc @@ -345,7 +311,7 @@ bank: lda (KERNEL_XOPEN_PTR1),y ; RES sta RES lda RESB - ldy RESB+1 + ldy RESB + 1 rts .endproc @@ -362,7 +328,7 @@ bank: lda kernel_process+kernel_process_struct::fp_ptr,x sta RES - lda kernel_process+kernel_process_struct::fp_ptr+1,x + lda kernel_process+kernel_process_struct::fp_ptr + 1,x beq @no_ptr sta RES+1 @@ -396,30 +362,30 @@ bank: ldx #$00 @loop_copy_free_chunk_begin_low: - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high,x + 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 + 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 + 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 + 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 + 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 + lda kernel_malloc_free_chunk_size + kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low,x sta (RES),y iny @@ -449,31 +415,30 @@ bank: @loop_copy_busy_chunk_begin_low: - 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 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 + 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 + 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 + 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 + 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 + lda kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low,x sta (RES),y iny @@ -494,14 +459,14 @@ bank: .proc XVARS_GET_PROCESS_NAME_PTR ; Y contains the chunk - lda kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_pid_list,y + 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 + jmp kernel_get_struct_process_ptr + @init: lda #$00 ; Return null if it's init @@ -514,7 +479,7 @@ bank: clc adc #KERNEL_MALLOC_FREE_CHUNK_MAX bcc @S1 - inc RES+1 + inc RES + 1 @S1: sta RES rts @@ -525,12 +490,18 @@ bank: clc adc #KERNEL_MAX_NUMBER_OF_MALLOC bcc @S1 - inc RES+1 + inc RES + 1 + @S1: sta RES 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 +82,53 @@ argv_value_ptr .res KERNEL_LENGTH_MAX_CMDLINE+KERNEL_MAX_ARGS_COMMAND_LINE ; add 0 to string .endstruct +.ifdef DISPLAY_INFO +.out "==================================================================" +.out "Memory" +.out "==================================================================" +.out .sprintf("KERNEL_MAX_NUMBER_OF_MALLOC (max malloc for all process) : %s", .string(KERNEL_MAX_NUMBER_OF_MALLOC)) +.out .sprintf("kernel_malloc_struct size (malloc table) : $%X bytes", .sizeof(kernel_malloc_struct)) .out .sprintf("XMAINARGS_STRUCT size : $%X bytes", .sizeof(XMAINARGS_STRUCT)) +.endif + +.struct kernel_bank_management_struct + KERNEL_BANK_STATES .res 64 + KERNEL_BANK_PROCESS_ID .res 64 +.endstruct + +.macro MEMORY_PUT_VALUE_TO_BANK address + ; Put a value into ank + ; X the id of the bank where the value will be written + ; A the value to write + ; Y the offset from address + ; Modify RES + + sta RES + stx BNKCIB_DOUBLON + ldx #$01 ; Write + lda #
address + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON+1 + jsr $04C7 +.endmacro + + +.macro MEMORY_GET_VALUE_FROM_BANK + ; X the id of the bank + ; A and Y are the address + ; stx BNK_TO_SWITCH + ; sta ADDRESS_READ_BETWEEN_BANK + ; sty ADDRESS_READ_BETWEEN_BANK+1 + ; ldx #$ + ; ldy #$00 + ; jsr $04AF + stx BNKCIB_DOUBLON ; Bank + + lda $321 + sta RETURN_BANK_READ_BYTE_FROM_OVERLAY_RAM + + ldx #$00 ; Read + jsr $04C7 + +.endmacro diff --git a/src/include/network.inc b/src/include/network.inc new file mode 100644 index 00000000..3c24d865 --- /dev/null +++ b/src/include/network.inc @@ -0,0 +1,25 @@ +.define KERNEL_STUB1_NETWORK $01 +.define KERNEL_STUB2_NETWORK $02 +.define KERNEL_STUB3_NETWORK $03 +.define KERNEL_START_NETWORK $04 + +.define KERNEL_SOCKET_NETWORK $05 +.define KERNEL_BIND_NETWORK $06 +.define KERNEL_CONNECT_NETWORK $07 +.define KERNEL_RECV_NETWORK $08 +.define KERNEL_SEND_NETWORK $09 +.define KERNEL_SOCKET_CLOSE_NETWORK $0A +.define KERNEL_SOCKET_CLOSE_FROM_PID_NETWORK $0B + + +.define KERNEL_NETWORK_STATE_NOT_INITIALIZED $00 +.define KERNEL_NETWORK_STATE_CHIP_INITIALIZED $01 +.define KERNEL_NETWORK_CABLE_DISCONNECTED $02 +.define KERNEL_NETWORK_CABLE_CONNECTED $03 +.define KERNEL_NETWORK_FULLY_STARTED $04 +.define KERNEL_NETWORK_STARTING_DHCP $05 + +.define KERNEL_NETWORK_STATE_CHIP_NOT_FOUND $FF + +; When network stack is initialized, this value will be the first source port for an openning socket +.define KERNEL_FIRST_SOURCE_PORT_INIT 140 \ No newline at end of file diff --git a/src/include/orix.inc b/src/include/orix.inc new file mode 100644 index 00000000..e69de29b diff --git a/src/include/process.inc b/src/include/process.inc index f8d49fdd..d7de71f4 100644 --- a/src/include/process.inc +++ b/src/include/process.inc @@ -28,11 +28,11 @@ ; don't move kernel_pid_list in an other line because it breaks ps and lsmem kernel_pid_list .res KERNEL_MAX_PROCESS ; list of PID when the byte is equal to 0, it means that this is free, it store the index kernel_current_process .res 1 ; id of the current pid (French, contient l'index et non pas la valeur, l'index sur la table kernel_pid_list) - kernel_one_process_struct_ptr_low .res KERNEL_MAX_PROCESS + kernel_one_process_struct_ptr_low .res KERNEL_MAX_PROCESS ; Ptr of the proccess kernel_one_process_struct_ptr_high .res KERNEL_MAX_PROCESS ;kernel_init_string .res .strlen("init")+1 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 + fp_ptr .res KERNEL_MAX_FP_PER_PROCESS * 2 ; contains struct of fp ptr, fp for init for instance, only shell could be in it ; kernel_fd contains ... 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 @@ -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" @@ -54,10 +48,10 @@ ; This struct is used with a malloc. Each proces has this struct, and the pointer of this struct is in kernel_process_struct struct .struct kernel_one_process_struct - process_name .res KERNEL_MAX_LENGTH_COMMAND+1 ; don't move it in the struct, because code handle process_name when it's at the first position. If it moves, the code will generate bugs + process_name .res KERNEL_MAX_LENGTH_COMMAND + 1 ; don't move it in the struct, because code handle process_name when it's at the first position. If it moves, the code will generate bugs cwd_str .res KERNEL_MAX_PATH_LENGTH ; child_pid .res KERNEL_NUMBER_OF_CHILD_PER_PROCESS - fp_ptr .res KERNEL_MAX_FP_PER_PROCESS*2 + fp_ptr .res KERNEL_MAX_FP_PER_PROCESS * 2 zp_save_userzp .res KERNEL_USERZP_SAVE_LENGTH cmdline .res KERNEL_LENGTH_MAX_CMDLINE ppid .res 1 @@ -73,10 +67,10 @@ .endif .endstruct -.out .sprintf("kernel_one_process_struct size (struct for one process) : $%X bytes", .sizeof(kernel_one_process_struct)) + .if .sizeof(kernel_one_process_struct) > 255 .error "kernel_one_process_struct size is greater than 255. It's impossible because code does not handle a struct greater than 255" .endif -.out .sprintf("With all the parameter all process could use %s bytes in memory, if it's allocated", .string(.sizeof(kernel_one_process_struct)*KERNEL_MAX_PROCESS+.sizeof(kernel_process_struct))) + diff --git a/src/include/xvars.inc b/src/include/xvars.inc index 735719dc..64e37f7f 100644 --- a/src/include/xvars.inc +++ b/src/include/xvars.inc @@ -1,5 +1,8 @@ .define WHO_AM_IAM $01 .define MALLOC_TABLE_COPY $02 +.define KERNEL_BANK_NETWORK $01 +.define KERNEL_BANK_UNDEFINED $FF + diff --git a/src/kernel.asm b/src/kernel.asm index a496504f..3f32070d 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -1,26 +1,6 @@ -.FEATURE labels_without_colons, pc_assignment, loose_char_term, c_comments +.FEATURE labels_without_colons, pc_assignment, loose_char_term, org_per_seg -.macro STZ_ABS arg ; Define macro ldax - lda #$00 - sta arg -.endmacro - -.macro STZ_ABS_X arg ; Define macro ldax - lda #$00 - sta arg,x -.endmacro - -.macro INCA - clc - adc #$01 -.endmacro - -.define VERSION "2024.1" - -XMALLOC_ROUTINE_TO_RAM_OVERLAY = 39 - -ADIODB_LENGTH = $08 -.define KERNEL_SIZE_IOTAB $04 +.define VERSION "2025.X" .include "telestrat.inc" ; from cc65 .include "fcntl.inc" ; from cc65 @@ -28,15 +8,82 @@ 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 charset_text +.import XLOADCHARSET_ROUTINE +.export code_adress_419 +.export VEXBNK +.export code_adress_436 + + +.import XMINMA_ROUTINE + +; Network +.import XNETWORK_START_ROUTINE + +; Import from bank0 +.import TELEMON_KEYBOARD_BUFFER_END +.import TELEMON_KEYBOARD_BUFFER_BEGIN +.import BUFROU +.import KERNEL_CONF_BEGIN +.import KERNEL_BANK_MANAGEMENT + +; Import main memory +.import KERNEL_ERRNO +.import KERNEL_CH376_MOUNT +.import KERNEL_XFREE_TMP +.import KERNEL_XKERNEL_CREATE_PROCESS_TMP +.import KERNEL_TMP_XEXEC +.import KERNEL_KERNEL_XEXEC_BNKOLD +.import KERNEL_MALLOC_TYPE +.import KERNEL_SAVE_XEXEC_CURRENT_SET +.import KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM +.import KERNEL_END_PROCESS_VARIABLES +.import SCRFX_KERNEL +.import IOTAB +.import KERNEL_ADIOB +.import kernel_malloc_free_chunk_size +.import kernel_xmalloc_call +.import KERNEL_ADIOB_END +.import READ_BYTE_FROM_OVERLAY_RAM +.import FIXME_DUNNO +.import STACK_BANK +;.import BUFNOM +.import kernel_malloc +.import KERNEL_DRIVER_MEMORY +.import kernel_process +.import BUSY_BANK_TABLE_RAM +.import kernel_end_of_memory_for_kernel + +.import KERNEL_NETWORK_FLAG + +.import XBANK_ROUTINE + +.import KERNEL_BANK_EXTENDED_AVAILABLE + +.import switch_to_kernel_extended_fill_register_bank8 +.import kernel_restore_banking_states +.import kernel_restore_banking_states_register +;.import XLOADCHARSET_ROUTINE +; .import RESC +; .import RESD +; .import RESE +; .import RESF +; .import RESG +; .import RESH +; .import RESI +; .import RESCONCAT + + .out "==================================================================" .out "Resume" .out "==================================================================" @@ -47,9 +94,10 @@ ADIODB_LENGTH = $08 .endif .include "orix.mac" -.include "kernel.inc" +;.include "kernel.inc" .include "build.inc" +;.import KERNEL_BANK_MANAGEMENT ; Used for HRS, but we use it also for XOPEN primitive, there is no probability to have graphics could opens HRS values (For instance) .org $04 @@ -66,48 +114,12 @@ RESG: .res 2 .org $60 ; ACC1E RESH: - .res 2 ; ACC1M+1 $62 + .res 2 ; ACC1M + 1 $62 RESI: - .res 2 ; $ACC1M+3 $64 + .res 2 ; $ACC1M + 3 $64 RESCONCAT: - .res 2 ; ACC1S+1 $66 - -RES5 := $0A - -;RESC := DECDEB ; $04 -;RESD := DECFIN ; $06 -;RESE := DECCIB ; -;RESF := DECTRV ; -;RESG := ACCPS ; -;RESH := ACC1E - -KERNEL_XOPEN_PTR1 := $04 ; DECBIN -KERNEL_XOPEN_PTR2 := $06 ; DECFIN - -KERNEL_XWRITE_XCLOSE_XFSEEK_XFREAD_SAVE_Y := $51 ; DECBIN -KERNEL_XWRITE_XCLOSE_XFSEEK_XFREAD_SAVE_X := $52 ; DECBIN - -KERNEL_XFSEEK_SAVE_RES := $06; DECBIN -KERNEL_XFSEEK_SAVE_RESB := $4D ; DECBIN -;KERNEL_XOPEN_PTR2 := $06 ; DECFIN - - -KERNEL_CREATE_PROCESS_PTR1 := ACC1E ; $60 & $61 -XOPEN_RES := $4D ; Also HRS1 2 bytes -XOPEN_RESB := $4F ; Also HRS2 2 bytes -XOPEN_RES_SAVE := $51 ; Also HRS3 2 bytes -XOPEN_RESB_SAVE := $53 ; Also HRS4 2 bytes -XOPEN_SAVEY := $55 ; Also HRS4 2 bytes -XOPEN_SAVEA := $56 ; Also HRS4 2 bytes -XOPEN_FLAGS := $57 ; also HRSFB 1 byte -TELEMON_UNKNWON_LABEL_62 := $62 -TELEMON_UNKNWON_LABEL_70 := $70 -TELEMON_UNKNWON_LABEL_71 := $71 -TELEMON_UNKNWON_LABEL_72 := $72 -TELEMON_UNKNWON_LABEL_7F := $7F -TELEMON_UNKNWON_LABEL_86 := $86 -FLPOLP := $85 -FLPO0 := $87 + .res 2 ; ACC1S + 1 $66 + ; PARSE_VECTOR:=$FFF1 @@ -117,22 +129,14 @@ FLPO0 := $87 ; 3- Launch mount on the device but don't test the result, because we don't care at this step : it's a quick hack to mount quickly mass storage gadget -.segment "BANK8" -; .bss -.res 100 - -.segment "BANK0" -; .bss -.res 100 - .segment "BANK7" - .org $C000 start_rom: .proc _main sei + cld ldx #$FF txs ; init stack @@ -149,6 +153,7 @@ start_rom: stz $500,x inx bne @nloopc02 + stz KERNEL_BANK_EXTENDED_AVAILABLE .p02 .else inx @@ -163,26 +168,30 @@ start_rom: sta $500,x inx bne @nloop + sta KERNEL_BANK_EXTENDED_AVAILABLE .endif - ; Trying to mount .ifdef WITH_SDCARD_FOR_ROOT 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 + + ;jsr init_network + ; BUSY_BANK_TABLE_RAM is used to know if a ram bank is empty or not lda #$03 ; bank 33 and 34 are reserved (loader/network) sta BUSY_BANK_TABLE_RAM ; Set BUSY BANK_table lda #$00 - sta BUSY_BANK_TABLE_RAM+1 ; Set BUSY BANK_table - sta BUSY_BANK_TABLE_RAM+2 ; Set BUSY BANK_table + sta BUSY_BANK_TABLE_RAM + 1 ; Set BUSY BANK_table + sta BUSY_BANK_TABLE_RAM + 2 ; Set BUSY BANK_table @usb_controler_not_detected: @@ -196,34 +205,12 @@ start_rom: lda #$07 ; Kernel bank sta RETURN_BANK_READ_BYTE_FROM_OVERLAY_RAM -.ifdef WITH_DEBUG_BOARD - lda #'M' - sta $bb80+13 - .endif - jsr init_screens -.ifdef WITH_DEBUG_BOARD - lda #'N' - sta $bb80+14 -.endif - jsr XLOADCHARSET_ROUTINE - -.ifdef WITH_DEBUG_BOARD - lda #'O' - sta $bb80+15 -.endif - - jsr XALLKB_ROUTINE - -.ifdef WITH_DEBUG_BOARD - lda #'P' - sta $bb80+16 -.endif - ldx #$00 + @myloop: lda page2_xmalloc_call,x @@ -233,27 +220,11 @@ start_rom: bne @myloop - .ifdef WITH_DEBUG_BOARD - lda #'Q' - sta $bb80+17 - .endif - jsr init_via - - .ifdef WITH_DEBUG_BOARD - lda #'R' - sta $bb80+18 - .endif - jsr init_printer - .ifdef WITH_DEBUG_BOARD - lda #'S' - sta $bb80+19 - .endif - - ldx #(KERNEL_SIZE_IOTAB-1) + @loop: lsr IOTAB,x ; init channels (0 to 3) dex @@ -262,7 +233,7 @@ start_rom: lda IRQVECTOR ; testing if IRQVECTOR low byte is $4C ? cmp #$4C bne @L1 ; non equal to $4C - lda KBDCOL+5 + lda KBDCOL + 5 and #$20 bne @L1 @L1: @@ -278,7 +249,6 @@ next1: set_todefine6: - ldx #$00 loading_vectors_telemon: @@ -294,21 +264,17 @@ loading_vectors_telemon: sta $0700,x ; used to copy in Overlay RAM ... see loop40 label lda ramoverlay_xmalloc,x sta $0800,x ; used to copy in Overlay RAM ... see loop40 label - lda ramoverlay_xmalloc+256,x + lda ramoverlay_xmalloc + 256,x sta $0900,x ; used to copy in Overlay RAM ... see loop40 label lda ramoverlay_xfree,x sta $2000,x ; used to copy in Overlay RAM ... see loop40 label - lda ramoverlay_xfree+256,x + lda ramoverlay_xfree + 256,x sta $2100,x ; used to copy in Overlay RAM ... see loop40 label - lda ramoverlay_xfree+256+256,x + lda ramoverlay_xfree + 256 + 256,x sta $2200,x ; used to copy in Overlay RAM ... see loop40 label inx ; loop until 256 bytes are filled bne @loop - .ifdef WITH_DEBUG_BOARD - lda #'T' - sta $bb80+20 - .endif ; Just fill ram with BUFROU jsr $0600 @@ -320,23 +286,13 @@ loading_vectors_telemon: inx ; loop until 256 bytes are filled bne @loop2 - .ifdef WITH_DEBUG_BOARD - lda #'U' - sta $bb80+21 - .endif set_buffers: ; this code sets buffers - ldx #$00 ; Start from 0 + ;ldx #$00 ; Start from 0 jsr XDEFBU_ROUTINE - - .ifdef WITH_DEBUG_BOARD - lda #'A' - sta $bb80 - .endif - skip: ldx #$0B ; copy to $2F4 12 bytes @@ -346,50 +302,23 @@ skip: dex bpl @loop - .ifdef WITH_DEBUG_BOARD - lda #'B' - sta $bb80+1 - .endif - jsr init_keyboard - .ifdef WITH_DEBUG_BOARD - lda #'C' - sta $bb80+2 - .endif - next5: - - lda KBDCOL+4 ; + lda KBDCOL + 4 ; and #$90 beq @skip lda FLGTEL ora #$40 sta FLGTEL -@skip: - -.ifdef WITH_DEBUG_BOARD - lda #'D' - sta $bb80+3 -.endif +@skip: lda #XKBD ; Setup keyboard on channel 0 BRK_TELEMON XOP0 - .ifdef WITH_DEBUG_BOARD - lda #'E' - sta $bb80+4 - .endif - lda #$82 ; Setup screen ! on channel 0 BRK_TELEMON XOP0 - .ifdef WITH_DEBUG_BOARD - lda #'F' - sta $bb80+5 - .endif - - BRK_TELEMON XRECLK ; Don't know this vector bit FLGRST ; COLD RESET ? @@ -402,38 +331,46 @@ next5: ; it's similar to lda #10 brk xwr0 lda #13 brk XWR0 RETURN_LINE - PRINT str_KOROM - telemon_hot_reset: +; @me: +; jmp @me + + ; @me: + ; jmp @me + lda #KERNEL_LOAD_QWERTY_CHARSET + jsr XBANK_ROUTINE + + ;jsr XLOADCHARSET_ROUTINE + jsr XALLKB_ROUTINE 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 + lda #64 + sta RES + 1 -display_cursor: + ; Initialize banks states to Empty +@L1: + lda #$00 ; value to store + ldx #$00 ; BANK + ldy #$00 ; Offset to write + MEMORY_PUT_VALUE_TO_BANK KERNEL_BANK_MANAGEMENT + dec RES + 1 + bne @L1 + ; Displays cursor ldx #$00 - BRK_KERNEL XCSSCR ; display cursors -; initialize + BRK_KERNEL XCSSCR + + ; initialize ; Init PID tables and structs @@ -452,34 +389,34 @@ display_cursor: lda #$FF ; Init ; Set process foreground - sta kernel_process+kernel_process_struct::kernel_current_process + sta kernel_process + kernel_process_struct::kernel_current_process ; register init process lda #$01 - sta kernel_process+kernel_process_struct::kernel_pid_list ; COMMENT TO HAVE WORKING MAX PROCESS + sta kernel_process + kernel_process_struct::kernel_pid_list ; COMMENT TO HAVE WORKING MAX PROCESS init_process_init_cwd_in_struct: ldx #$00 @L1: lda str_name_process_kernel,x beq @S1 - sta kernel_process+kernel_process_struct::kernel_cwd_str,x + sta kernel_process + kernel_process_struct::kernel_cwd_str,x inx bne @L1 @S1: - sta kernel_process+kernel_process_struct::kernel_cwd_str,x + sta kernel_process + kernel_process_struct::kernel_cwd_str,x lda #KERNEL_ERRNO_OK sta KERNEL_ERRNO ; init FD lda #$FF - sta kernel_process+kernel_process_struct::kernel_fd_opened ; Store the current fd opened is FF + sta kernel_process + kernel_process_struct::kernel_fd_opened ; Store the current fd opened is FF ; A=00 at this step ldx #$00 txa @init_fp: - sta kernel_process+kernel_process_struct::kernel_fd,x + sta kernel_process + kernel_process_struct::kernel_fd,x inx cpx #KERNEL_MAX_FP bne @init_fp @@ -492,32 +429,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 @@ -533,16 +470,60 @@ init_malloc_busy_table: ; lda #$FF ; ; UNCOMMENT MAX_PROCESS lda #$00 @loop: - sta kernel_malloc+kernel_malloc_struct::kernel_malloc_busy_pid_list,x + sta kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_pid_list,x dex bpl @loop + ; Checking of extended ROM is here + ;KERNEL_BANK_AVAILABLE + + + lda #KERNEL_NETWORK_STATE_NOT_INITIALIZED + ldy #$00 + ldx #$00 + MEMORY_PUT_VALUE_TO_BANK KERNEL_NETWORK_FLAG + + + jsr switch_to_kernel_extended_fill_register_bank8 + + lda #<($FFF0 + 1) ; Offset magic token + ldy #>($FFF0 + 1) + + sta ADDRESS_READ_BETWEEN_BANK_DOUBLON + sty ADDRESS_READ_BETWEEN_BANK_DOUBLON + 1 + + ldx #$04 + ldy #$00 + + + MEMORY_GET_VALUE_FROM_BANK ; A contains the value + cmp #'x' ; Magic token for bank 8 + bne @not_extended_bank_found + lda #128 + sta KERNEL_BANK_EXTENDED_AVAILABLE + + ; **************************************************************************** + ; * Start init for network chip * + ; **************************************************************************** + ; Set stage for kernel init + + + lda #KERNEL_START_NETWORK + jsr XNETWORK_START_ROUTINE + +@not_extended_bank_found: + jsr kernel_restore_banking_states_register + cli + + +@not_extended_bank: .ifdef WITH_SYSTEMD_AT_BOOT_TIME launch_systemd: lda #str_binary_systemd - sta RES+1 + sta RES + 1 + ; kernel_end_of_memory_for_kernel is used it will start XEXEC, but it will be erased after the system stat but we don't care because XEXEC starts ldy #$00 @L1: @@ -561,17 +542,12 @@ launch_systemd: jsr _XEXEC ; start shell .endif - .ifdef WITH_DEBUG_BOARD - lda #'X' - sta $bb80+24 - .endif - launch_command: jsr XCRLF_ROUTINE lda #str_binary_to_start - sta RES+1 + sta RES + 1 ; kernel_end_of_memory_for_kernel is used it will start XEXEC, but it will be erased after the system stat but we don't care because XEXEC starts ldy #$00 @@ -648,10 +624,6 @@ init_via: rts loading_code_to_page_6: - .ifdef WITH_DEBUG_BOARD - lda #'Y' - sta $bb80+25 - .endif ; At this step we will copy into ram overlay lda VIA2::PRA ; 3 bytes ; switch to overlay ram ? @@ -668,26 +640,26 @@ loading_code_to_page_6: lda $0800,x sta ramoverlay_xmalloc,x ; used to copy in Overlay RAM ... see loop40 label lda $0900,x - sta ramoverlay_xmalloc+256,x ; used to copy in Overlay RAM ... see loop40 label + sta ramoverlay_xmalloc + 256,x ; used to copy in Overlay RAM ... see loop40 label lda $2000,x sta ramoverlay_xfree,x ; used to copy in Overlay RAM ... see loop40 label lda $2100,x - sta ramoverlay_xfree+256,x ; used to copy in Overlay RAM ... see loop40 label + sta ramoverlay_xfree + 256,x ; used to copy in Overlay RAM ... see loop40 label lda $2200,x - sta ramoverlay_xfree+256+256,x ; used to copy in Overlay RAM ... see loop40 label + sta ramoverlay_xfree + 256 + 256,x ; used to copy in Overlay RAM ... see loop40 label inx bne @loop ; copy 256 bytes to BUFROU in OVERLAY RAM ; Becare full, each time shell is executed it launch it + ; lda #ORIX_FIRST_FREE_RAM_BANK + ; sta KERNEL_BANK_MANAGEMENT + end_proc_init_rams: - .ifdef WITH_DEBUG_BOARD - lda #'Z' - sta $bb80+26 - .endif + lda VIA2::PRA ; 3 bytes ; switch to overlay ram ? ora #%00000111 ; Bank 7 @@ -739,17 +711,17 @@ str_tofix: XDEFBU_ROUTINE: - stx RESB ; store the id of the buffer to set + ;stx RESB ; store the id of the buffer to set lda #TELEMON_KEYBOARD_BUFFER_BEGIN ; Get high adress of the buffer - sta RES+1 + sta RES + 1 lda #TELEMON_KEYBOARD_BUFFER_END - ldx RESB + ldx #$00 XINIBU_ROUTINE: bit XLISBU_ROUTINE @@ -764,7 +736,7 @@ XTSTBU_ROUTINE: skip2003: sec - jmp ORIX_MEMORY_DRIVER_ADDRESS+9 + jmp ORIX_MEMORY_DRIVER_ADDRESS + 9 XLISBU_ROUTINE: bit XLISBU_ROUTINE @@ -774,7 +746,7 @@ XECRBU_ROUTINE: bit loading_vectors_page_4 skipme2002: clc - jmp ORIX_MEMORY_DRIVER_ADDRESS+9 + jmp ORIX_MEMORY_DRIVER_ADDRESS + 9 ;********************************************************************************* ; CODE INSERTED IN PAGE 4 @@ -883,6 +855,7 @@ code_adress_47E: ; brk gestion ora #$07 sta VIA2::PRA jmp brk_management + code_adress_493: lda VIA2::PRA and #$F8 @@ -902,7 +875,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 +890,22 @@ code_adress_4AF: ; Stack used to switch from any bank ; let this res !!! ;.res 1 ; Let this res because, it's FIXME_DUNNO var here -code_adress_get: -; used in bank command in Oric +code_adress_4C7: +;code_adress_get: +; used in bank command in shell rom + Used in bank 8 (kernel) lda VIA2::PRA and #%11111000 ; switch to RAM overlay ; switch to RAM overlay - ora tmp1 ; but select a bank in $410 + ora BNKCIB_DOUBLON ; FIXME ; but select a bank in $410 sta VIA2::PRA cpx #$00 beq @read lda RES - sta (ptr1),y + sta (ADDRESS_READ_BETWEEN_BANK_DOUBLON),y + @read: - lda (ptr1),y ; Read byte + lda (ADDRESS_READ_BETWEEN_BANK_DOUBLON),y ; Read byte + @exit: pha lda RETURN_BANK_READ_BYTE_FROM_OVERLAY_RAM @@ -950,8 +926,8 @@ data_to_define_4: tay beq LC61E - lda BUFBUF+8,x ; $c088 - ora BUFBUF+9,x + lda BUFBUF + 8,x ; $c088 + ora BUFBUF + 9,x beq @skip clc rts @@ -960,13 +936,13 @@ data_to_define_4: rts LC5FE: sta RESB - sty RESB+1 + sty RESB + 1 sec sbc RES sta BUFBUF+$0A,x tya - sbc RES+1 + sbc RES + 1 sta BUFBUF+$0B,x txa adc #$03 @@ -983,14 +959,14 @@ LC5FE: LC61E: lda #$00 ; see page 4 of "Manuel Developpeur Telestrat" - sta BUFBUF+8,x ; get length low - sta BUFBUF+9,x ; get length high - lda BUFBUF+2,x - sta BUFBUF+4,x - sta BUFBUF+6,x - lda BUFBUF+3,x - sta BUFBUF+5,x - sta BUFBUF+7,x + sta BUFBUF + 8,x ; get length low + sta BUFBUF + 9,x ; get length high + lda BUFBUF + 2,x + sta BUFBUF + 4,x + sta BUFBUF + 6,x + lda BUFBUF + 3,x + sta BUFBUF + 5,x + sta BUFBUF + 7,x rts end_BUFROU: @@ -999,19 +975,19 @@ LC639: bvs LC661 jsr $C507 ; FIXME bcs LC660 - lda BUFBUF+6,x - ldy BUFBUF+7,x + lda BUFBUF + 6,x + ldy BUFBUF + 7,x jsr $C5A6 ; FIXME - sta BUFBUF+6,x + sta BUFBUF + 6,x tya - sta BUFBUF+7,x - lda BUFBUF+8,x + sta BUFBUF + 7,x + lda BUFBUF + 8,x bne @skip - dec BUFBUF+9,x + dec BUFBUF + 9,x @skip: - dec BUFBUF+8,x + dec BUFBUF + 8,x ; 65C02 FIXME .IFPC02 .pc02 @@ -1027,20 +1003,20 @@ LC660: LC661: pha - lda BUFBUF+8,x + lda BUFBUF + 8,x cmp BUFBUF+$0A,x - lda BUFBUF+9,x + lda BUFBUF + 9,x sbc BUFBUF+$0B,x bcs LC68F - lda BUFBUF+4,x - ldy BUFBUF+5,x + lda BUFBUF + 4,x + ldy BUFBUF + 5,x jsr $C5A6 ; FIXME - sta BUFBUF+4,x + sta BUFBUF + 4,x tya - sta BUFBUF+5,x - inc BUFBUF+8,x + sta BUFBUF + 5,x + inc BUFBUF + 8,x bne LC688 - inc BUFBUF+9,x + inc BUFBUF + 9,x LC688: ; 65C02 FIXME : use sta (XX) ldy #$00 @@ -1058,23 +1034,23 @@ LC691: bcc LC697 iny LC697: - cmp BUFBUF+2,x + cmp BUFBUF + 2,x sta IRQSVP routine_to_define_16: tya - sbc BUFBUF+3,x + sbc BUFBUF + 3,x bcc @S1 lda BUFBUF,x - ldy BUFBUF+1,x + ldy BUFBUF + 1,x sta IRQSVP @S1: sty FIXME_PAGE0_0 ; FIXME lda IRQSVP rts - +;.include "functions/xvars/xvalues.s" .include "functions/xcrlf.asm" .include "functions/XWRx.asm" .include "functions/XWSTRx.asm" @@ -1095,6 +1071,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" @@ -1104,18 +1081,18 @@ routine_to_define_16: send_command_A: sty ADDRESS_VECTOR_FOR_ADIOB - sty ADDRESS_VECTOR_FOR_ADIOB+1 + sty ADDRESS_VECTOR_FOR_ADIOB + 1 pha txa asl tax lda KERNEL_ADIOB,x - sta ADIODB_VECTOR+1 - lda KERNEL_ADIOB+1,x - sta ADIODB_VECTOR+2 + sta ADIODB_VECTOR + 1 + lda KERNEL_ADIOB + 1,x + sta ADIODB_VECTOR + 2 pla lsr ADDRESS_VECTOR_FOR_ADIOB - bit ADDRESS_VECTOR_FOR_ADIOB+1 + bit ADDRESS_VECTOR_FOR_ADIOB + 1 jmp ADIODB_VECTOR ; These bytes are set in ADIOB (page 2) @@ -1136,8 +1113,8 @@ brk_management: ; management of BRK $XX ; on the stack we have ; SP = P register - ; SP-1 = PC+2 adress of brk sent - ; SP-2 = PC+1 + ; SP-1 = PC + 2 adress of brk sent + ; SP-2 = PC + 1 .IFPC02 .pc02 phx @@ -1152,21 +1129,21 @@ brk_management: and #%00010000 ; test B flag B flag means an that we reach a brk commands beq next200 ; is it a break ? tsx ; yes we get Stack pointer - pla ; we pull pointer program +2 + pla ; we pull pointer program + 2 bne @skip - dec BUFTRV+2,x ; CORRECTME + dec BUFTRV + 2,x ; CORRECTME @skip: reset115_labels: sec sbc #$01 pha sta ADDRESS_READ_BETWEEN_BANK - lda BUFTRV+2,x - sta ADDRESS_READ_BETWEEN_BANK+1 - lda BNKOLD - sta BNK_TO_SWITCH - ldy #$00 + lda BUFTRV + 2,x + sta ADDRESS_READ_BETWEEN_BANK + 1 + lda BNKOLD ; On regarde la ROM appelante + sta BNK_TO_SWITCH ; On stocke pour cette banque pour pouvoir aller lire $XX après le brk + ldy #$00 ; On prend la 1ère valeur jsr ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY asl tax @@ -1179,11 +1156,11 @@ reset115_labels: ; then kill process :) @continue_vector: - lda vectors_telemon+1,x ; fetch vector of brk + lda vectors_telemon + 1,x ; fetch vector of brk ldy vectors_telemon,x bcc @skip - lda vectors_telemon_second_table+1,x ; Second table because X >127 + lda vectors_telemon_second_table + 1,x ; Second table because X >127 ldy vectors_telemon_second_table,x ; @@ -1233,7 +1210,7 @@ timeud_next: lda TIMEUD bne @skip - dec TIMEUD+1 + dec TIMEUD + 1 @skip: skipme12: dec TIMEUD @@ -1253,7 +1230,7 @@ skipme12: inc TIMES lda TIMEUS bne @L1 - dec TIMEUS+1 + dec TIMEUS + 1 @L1: dec TIMEUS lda TIMES @@ -1289,13 +1266,13 @@ manage_irq_T1_and_T2: and #$20 beq LC9b9 lda VIA_UNKNOWN - ldy VIA_UNKNOWN+1 + ldy VIA_UNKNOWN + 1 sta VIA::T2 - sty VIA::T2+1 + sty VIA::T2 + 1 routine_todefine_1: lda #$FF - sta VIA::T2+1 + sta VIA::T2 + 1 jmp LC8B9 LC9b9: @@ -1323,13 +1300,13 @@ next110: bit KBDFLG_KEY bpl @S3 lda #$14 - sta KEYBOARD_COUNTER+1 + sta KEYBOARD_COUNTER + 1 bne @L5 @S3: - lda KEYBOARD_COUNTER+2 - bit KEYBOARD_COUNTER+1 + lda KEYBOARD_COUNTER + 2 + bit KEYBOARD_COUNTER + 1 bmi @skip - dec KEYBOARD_COUNTER+1 + dec KEYBOARD_COUNTER + 1 @L5: lda #$01 @skip: @@ -1363,29 +1340,29 @@ XDIVIDE_INTEGER32_BY_1024_ROUTINE: ; RESB and RES contains the result of the division ; BUG : does manage 24 bits integer lsr RESB - ror RES+1 + ror RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES - lsr RES+1 + lsr RES + 1 ror RES rts @@ -1427,9 +1404,9 @@ 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 XOP0_ROUTINE ; $00 + .byt XBANK_ROUTINE ; $01 + .byt XREALLOC_ROUTINE ; $02 .byt <$00,>$00 .byt $00,$00 ; 4 Was XCL in telemon @@ -1485,14 +1462,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 @@ -1571,14 +1548,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 @@ -1628,9 +1605,9 @@ display_x_choice: jsr put_cursor_in_61_x inx lda ACC2M - ldy ACC2M+1 + ldy ACC2M + 1 sta ADDRESS_READ_BETWEEN_BANK - sty ADDRESS_READ_BETWEEN_BANK+1 + sty ADDRESS_READ_BETWEEN_BANK + 1 ldy #$00 Lcd0c: dex @@ -1638,17 +1615,17 @@ Lcd0c: Lcd0f: iny bne @skip - inc ADDRESS_READ_BETWEEN_BANK+1 + inc ADDRESS_READ_BETWEEN_BANK + 1 @skip: jsr ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY bne Lcd0f iny bne Lcd0c - inc ADDRESS_READ_BETWEEN_BANK+1 + inc ADDRESS_READ_BETWEEN_BANK + 1 bne Lcd0c Lcd20: - ldx ADDRESS_READ_BETWEEN_BANK+1 + ldx ADDRESS_READ_BETWEEN_BANK + 1 clc tya adc ADDRESS_READ_BETWEEN_BANK @@ -1656,7 +1633,7 @@ Lcd20: inx @skip: sta RESB - stx RESB+1 + stx RESB + 1 lda #$20 sta DEFAFF pla @@ -1669,7 +1646,7 @@ Lcd20: lda #$20 jsr XWR0_ROUTINE lda RESB - ldy RESB+1 + ldy RESB + 1 jsr XWSTR0_ROUTINE ldy #$01 jsr ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY @@ -1698,10 +1675,13 @@ put_cursor_in_61_x: data_for_decimal_conversion: const_10_decimal_low .byt $0A ; 19 + const_100_decimal_low .byt $64 ; 100 + const_1000_decimal_low ; $3e8=1000 .byt $E8 + const_10000_decimal_low ; $3e8=1000 .byt $10 const_10_decimal_high @@ -1774,10 +1754,7 @@ XCHECK_VERIFY_USBDRIVE_READY_ROUTINE: .include "functions/process/kernel_get_struct_process_ptr.asm" - -.include "functions/strings/xminma.asm" - - +;.include "functions/strings/xminma.asm" .include "functions/xdecal.asm" .include "functions/sound/xepsg.asm" @@ -1800,7 +1777,7 @@ XCHECK_VERIFY_USBDRIVE_READY_ROUTINE: .proc _trim ; This routine modify RES -; Each time a space is found, RES is modified (+1 to the pointer) until it reached 0 +; Each time a space is found, RES is modified ( + 1 to the pointer) until it reached 0 ldy #$00 @L1: lda (RES),y @@ -1814,7 +1791,7 @@ XCHECK_VERIFY_USBDRIVE_READY_ROUTINE: @trim: inc RES bne @next - inc RES+1 + inc RES + 1 @next: jmp @L1 .endproc @@ -1909,7 +1886,7 @@ XKBDAS_ROUTINE: bcc @loop @skip: - lda KBDCOL+4 + lda KBDCOL + 4 tax and #$90 beq @skip2 @@ -1939,6 +1916,7 @@ XKBDAS_ROUTINE: lda (ADKBD),y bit FLGKBD bpl @skip5 + ; XMINMA FIXME cmp #$61 bcc @skip5 cmp #$7B @@ -1950,7 +1928,7 @@ XKBDAS_ROUTINE: txa and #$04 beq next68 - and KBDCOL+7 + and KBDCOL + 7 beq @skip6 lda #$80 sta KBDCTC @@ -1983,6 +1961,7 @@ Ld882: lda FLGKBD eor #$20 bcs @S12 + @S10: cmp #$1B bne @S13 @@ -1992,11 +1971,14 @@ Ld882: pla lda #$00 pha + @S11: lda FLGKBD eor #$80 + @S12: sta FLGKBD + @S13: pla ldx #$00 @@ -2076,7 +2058,7 @@ next22: ldy #$08 @L1: - lda SCRTRA+5,y + lda SCRTRA + 5,y bne out1 cpy #$06 @@ -2094,7 +2076,7 @@ out1: manage_I_O_keyboard: bmi skip2005 lda #$01 - sta KEYBOARD_COUNTER+2 + sta KEYBOARD_COUNTER + 2 sta KEYBOARD_COUNTER php sei @@ -2121,6 +2103,7 @@ skip2005: lda #$40 sta VIA::IER rts + @skip3: lda VIA::ACR ora #$40 @@ -2129,7 +2112,7 @@ skip2005: lda #$a8 ldy #$61 sta VIA::T1 - sty VIA::T1+1 + sty VIA::T1 + 1 lda #$c0 sta VIA::IER @@ -2145,20 +2128,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 @@ -2174,12 +2157,12 @@ XSONPS_ROUTINE: sec php sei - lda ADDRESS_READ_BETWEEN_BANK+1 + lda ADDRESS_READ_BETWEEN_BANK + 1 pha lda ADDRESS_READ_BETWEEN_BANK pha stx ADDRESS_READ_BETWEEN_BANK - sty ADDRESS_READ_BETWEEN_BANK+1 + sty ADDRESS_READ_BETWEEN_BANK + 1 php ldy #$00 @L1: @@ -2205,7 +2188,7 @@ XSONPS_ROUTINE: pla sta ADDRESS_READ_BETWEEN_BANK pla - sta ADDRESS_READ_BETWEEN_BANK+1 + sta ADDRESS_READ_BETWEEN_BANK + 1 plp rts @@ -2263,7 +2246,7 @@ output_window0: pla ; on lit la donnée < Ldbb5: - sta SCRNB+1 ; store the char to display + sta SCRNB + 1 ; store the char to display pha ; Save A txa ; save X pha ; @@ -2274,9 +2257,9 @@ Ldbb5: lda ADSCRL ; get address of the window sta ADSCR lda ADSCRH - sta ADSCR+1 + sta ADSCR + 1 - lda SCRNB+1 + lda SCRNB + 1 cmp #" " ; is it greater than space ? bcs Ldc4c ; yes let's displays it. Ldbce: ; $d27e @@ -2285,14 +2268,14 @@ Ldbce: ; $d27e pha jsr XCOSCR_ROUTINE ; switch off cursor - lda #>(LDC2B-1) ; FIXME ? + lda #>(LDC2B - 1) ; FIXME ? pha - lda #<(LDC2B-1) ; FIXME ? + lda #<(LDC2B - 1) ; FIXME ? pha - lda SCRNB+1 + lda SCRNB + 1 asl ; MULT2 in order to get vector tay - lda TABLE_OF_SHORTCUT_KEYBOARD+1,y + lda TABLE_OF_SHORTCUT_KEYBOARD + 1,y pha lda TABLE_OF_SHORTCUT_KEYBOARD,y pha @@ -2342,7 +2325,7 @@ LDC2B: sta CURSCR ; and save it lda ADSCR ; get current addr (low) sta ADSCRL ; save it - lda ADSCR+1 + lda ADSCR + 1 sta ADSCRH pla sta FLGSCR @@ -2360,22 +2343,22 @@ Ldc4c: lda FLGSCR and #%00001100 bne Ldc9a - lda SCRNB+1 + lda SCRNB + 1 bpl Ldc5d - cmp #$A0 ; Is it higher than 128+32 + cmp #$A0 ; Is it higher than 128 + 32 bcs Ldc5d ; is it a normal code ? ; yes don't display and #$7F ; yes let's write code Ldc5d: - sta SCRNB+1 + sta SCRNB + 1 jsr display_char lda #$09 - sta SCRNB+1 + sta SCRNB + 1 skip_code: jmp Ldbce LDC69: - sta SCRNB+1 + sta SCRNB + 1 display_char: ldy #$80 @@ -2387,7 +2370,7 @@ display_char: @skip: tya - ora SCRNB+1 + ora SCRNB + 1 sta CURSCR ldy SCRX sta (ADSCR),y @@ -2396,7 +2379,7 @@ display_char: Ldc9a: and #$08 beq @S1 - lda SCRNB+1 + lda SCRNB + 1 bmi LDC46 cmp #$40 bcc LDC46 @@ -2418,7 +2401,7 @@ Ldc9a: lsr ; doit-on envoyer Y ou X ? bcs @S2 ; X ------------------------------------------------ - lda SCRNB+1 ; on lit Y I + lda SCRNB + 1 ; on lit Y I and #$3F ; on vire b4 (protocole US) I sta SCRY ; et on fixe Y I jsr LDE07 ; on ajuste l'adresse dans la fenêtre I @@ -2430,7 +2413,7 @@ Ldc9a: pha ; I jmp LDC2B ; et on sort I @S2: - lda SCRNB+1 ; on lit X <---------------------------------------- + lda SCRNB + 1 ; on lit X <---------------------------------------- and #$3F ; on vire b4 sta SCRX ; dans SCRX pla @@ -2508,12 +2491,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 +2510,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 +2525,12 @@ CTRL_K_START: ldy SCRFY ; fin de la fentre X I tax ; I jsr XSCROB_ROUTINE ; on scrolle l'écran vers le bas ligne X à Y I + CTRL_M_START: lda SCRDX ; on place début de la fenêtre dans X I sta SCRX ; I rts ; I + LDD6E: dec SCRY ; on remontre le curseur <-------------------------- jmp LDE07 ; et on ajuste ADSCR @@ -2561,13 +2549,13 @@ CTRL_X_START: LDD7D: lda SCRFX ; et la dernière colonne de la fenetre - sta SCRNB+1 ; dans $29 + sta SCRNB + 1 ; dans $29 lda #$20 ; on envoie un espace @loop: sta (ADSCR),y iny ; jusqu'à la fin de la ligne - cpy SCRNB+1 + cpy SCRNB + 1 bcc @loop sta (ADSCR),y ; et à la dernière position aussi rts ; (INC $29 avant la boucle aurait été mieux !) @@ -2596,6 +2584,7 @@ CTRL_J_START: tax ; I jsr XSCROH_ROUTINE ; on scrolle la fenetre I jmp CTRL_M_START ; on revient en debut de ligne I + @skip: inc SCRY ; on incremente la ligne <-------------------------I jmp LDE07 ; et on ajuste ADSCR @@ -2653,11 +2642,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 +2744,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 +2825,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 +2847,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 +2874,12 @@ Le2ed: beq @S2 dec ACC1M bcs Le2ed + @S1: clc iny sty ACC1E + @S2: rts @@ -2979,6 +2957,7 @@ Le390: cmp #$20 bcs Le398 ora #$80 + Le398: ldx MENX bit ACC1EX @@ -3019,11 +2998,12 @@ display_bufedt_content: lda #$00 ; FIXME 65c02 sta MENX lda ADSCR - ldy ADSCR+1 + ldy ADSCR + 1 sta RES - sty RES+1 + sty RES + 1 ldx SCRNB ldy SCRX + Le3e3: ldx MENX @@ -3042,6 +3022,7 @@ Le3e3: bit FLGTEL ; Minitel ? bvc Le405 jsr LE656 + Le405: tya iny @@ -3052,6 +3033,7 @@ Le405: ldy #$00 jsr XADRES_ROUTINE ldy SCRDX + Le418: inc MENX bne Le3e3 @@ -3073,7 +3055,6 @@ Le45a: Le479: rts - manage_code_control: cmp #$08 bne Le5d5 @@ -3152,10 +3133,10 @@ Le624: Le62a: lda #$1F ; on envoie un US jsr Le648 - tya ; on envoie Y+64 + tya ; on envoie Y + 64 ora #$40 jsr Le648 - txa ; et X+64 + txa ; et X + 64 ora #$40 jsr Ldbb5 .ifdef WITH_MINITEL @@ -3211,11 +3192,11 @@ data_for_hires_display XHRSSE_ROUTINE: clc ; C=0 - bit HRS5+1 ; on fait tourner HRS5+1 sur lui-même + bit HRS5 + 1 ; on fait tourner HRS5 + 1 sur lui-même bpl @skip ; afin de conserver le pattern sec @skip: - rol HRS5+1 + rol HRS5 + 1 bcc Le7c0 ; si b7 de $56 ? 0, on saute <-------------------- LE79C: ldy HRSX40 ; sinon on prend X/6 I @@ -3251,7 +3232,7 @@ Le7c0: ; PLACE LE CURSEUR EN X,Y ;Action:calcule l'adresse du curseur en calculant la position de la ligne par -; $A000+40*Y, la colonne dans X/6 et la position dans l'octet par X mod 6. +; $A000 + 40*Y, la colonne dans X/6 et la position dans l'octet par X mod 6. ; Suite à une erreur dans la table des vecteur TELEMON, cette routine n'est ; pas appelée (alors qu'elle devrait l'être) par BRK XHRSSE... ; En sortie, HSRX,Y,X40,X6 et ADHRS sont ajust?s en fonction de X et Y. @@ -3267,11 +3248,11 @@ hires_put_coordinate: clc tya adc #$A0 ; et on ajoute $A000, écran HIRES - sta ADHRS+1 ; dans ADHRS + sta ADHRS + 1 ; dans ADHRS stx RES ; on met la colonne dans RES lda #$06 ; A=6 - ldy #$00 ; et Y=0 (dans RES+1) - sty RES+1 ; AY=6 et RES=colonne + ldy #$00 ; et Y=0 (dans RES + 1) + sty RES + 1 ; AY=6 et RES=colonne jsr XDIVIS_ROUTINE ; on divise la colonne par 6 lda RES ; on sauve colonne/6 dans HSRX40 sta HRSX40 ; @@ -3288,7 +3269,7 @@ hires_put_coordinate: ; CALCUL LA TANGENTE (*256) D'UN TRAIT Le921: - stx RES+1 ; dX (ou dY)*256 dans RES+1 + stx RES + 1 ; dX (ou dY)*256 dans RES + 1 ldy #$00 ; dY (ou dX) dans AY FIXME 65C02 sty RES jsr XDIVIS_ROUTINE ; calcul dX*256/dY (ou dY/dX) @@ -3390,7 +3371,7 @@ LE9A7: lda #$00 ; <----------------------------------------------+-- FIXME 65C02 ldx #$A0 ; I sta RES ; RES=$A000 , adresse HIRES I - stx RES+1 ; I + stx RES + 1 ; I ldx #$C8 ; X=200 pour 200 lignes I lda #$00 ; A=0 pour colonne de début = colonne 0 I LE9B3: @@ -3406,7 +3387,7 @@ LE9B8: adc #$28 ;I (donc une ligne) sta RES ;I bcc @S1 ; I - inc RES+1 ; I + inc RES + 1 ; I @S1: pla ; I on sort le code dex ; I on compte X lignes @@ -3418,9 +3399,9 @@ LE9B8: ; XFILL_ROUTINE: lda ADHRS - ldy ADHRS+1 + ldy ADHRS + 1 sta RES - sty RES+1 + sty RES + 1 @loop2: ldx HRS2 ldy HRSX40 @@ -3441,18 +3422,19 @@ 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 @@ -3476,14 +3458,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 @@ -3492,16 +3478,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 @@ -3568,6 +3557,7 @@ LECB9: jsr LECB4 bcs LECB9 rts + Lecbf: sec .byt $24 @@ -3611,6 +3601,7 @@ add_0_5_A_ACC1: lda #const_zero_dot_half jmp AY_add_acc1 ; AY+acc1 + Lef97: rts @@ -3634,6 +3625,7 @@ XA1PA2_ROUTINE: ACC2_ADD_ACC1: bne @L1 jmp XA2A1_ROUTINE + @L1: tsx stx FLSVS @@ -3641,6 +3633,7 @@ ACC2_ADD_ACC1: stx TELEMON_UNKNWON_LABEL_7F ldx #$68 lda ACC2E + LEFC2: tay beq Lef97 @@ -3661,14 +3654,15 @@ LEFC2: @next801: ldy #$00 sty ACC1EX + @L2: cmp #$F9 bmi mantisse_A tay lda ACC1EX - lsr RES+1,x - + lsr RES + 1,x jsr LF0FC + next802: bit ACCPS bpl Lf049 @@ -3676,6 +3670,7 @@ next802: cpx #$68 beq LEFFA ldy #$68 + LEFFA: sec eor #$FF @@ -3685,25 +3680,26 @@ 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 - jsr Lf090 + Lf022: ldy #$00 tya clc + LF026: ldx ACC1M - bne LF074 ldx TELEMON_UNKNWON_LABEL_62 ; FIXME stx ACC1M @@ -3722,30 +3718,33 @@ 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 - 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 adc ACC2M sta ACC1M jmp Lf081 + Ld068: adc #$01 asl ACC1EX @@ -3753,6 +3752,7 @@ Ld068: rol MENDFY rol TELEMON_UNKNWON_LABEL_62 rol ACC1M + LF074: bpl Ld068 @@ -3763,23 +3763,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 @@ -3798,6 +3801,7 @@ LF096: sta ACC1EX inc ACC1EX bne LF0C6 + LF0B8: inc MENX bne LF0C6 @@ -3806,11 +3810,13 @@ LF0B8: inc TELEMON_UNKNWON_LABEL_62 bne LF0C6 inc ACC1M + LF0C6: rts LF0C7: lda #$01 + LF0C9: sta FLERR ldx FLSVS @@ -3819,17 +3825,19 @@ LF0C9: justify__to_the_right_with_A_and_X: ldx #$6E + 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 @@ -3838,30 +3846,34 @@ LF0E5: tay 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 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 @@ -3894,11 +3906,13 @@ LF184: jsr LF1EC beq LF140 bne LF190 + XA1MA2_ROUTINE: beq LF140 tsx stx FLSVS + LF190: jsr LF217 lda #$00 @@ -3930,13 +3944,13 @@ LF1C1: bcc LF1DD clc lda TELEMON_UNKNWON_LABEL_72 - adc ACC2M+3 + adc ACC2M + 3 sta TELEMON_UNKNWON_LABEL_72 lda TELEMON_UNKNWON_LABEL_71 - adc ACC2M+2 + adc ACC2M + 2 sta TELEMON_UNKNWON_LABEL_71 lda TELEMON_UNKNWON_LABEL_70 - adc ACC2M+1 + adc ACC2M + 1 sta TELEMON_UNKNWON_LABEL_70 lda ACC3 adc ACC2M @@ -3959,19 +3973,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 @@ -4027,6 +4041,7 @@ Lf242 beq Lf23c Lf258: rts + ten_in_floating_point: .byt $84,$20,$00,$00,$00 ; Ten in floating point Lf25e: @@ -4041,7 +4056,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 @@ -4054,11 +4073,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 @@ -4076,13 +4098,13 @@ LF2A4: ldy ACC2M cpy ACC1M bne LF2BA - ldy ACC2M+1 + ldy ACC2M + 1 cpy TELEMON_UNKNWON_LABEL_62 ; FIXME bne LF2BA - ldy ACC2M+2 + ldy ACC2M + 2 cpy MENDFY bne LF2BA - ldy ACC2M+3 + ldy ACC2M + 3 cpy MENX LF2BA: @@ -4106,9 +4128,9 @@ LF2CA: bcs LF2DB LF2CD: - asl ACC2M+3 - rol ACC2M+2 - rol ACC2M+1 + asl ACC2M + 3 + rol ACC2M + 2 + rol ACC2M + 1 rol ACC2M bcs LF2BA bmi LF2A4 @@ -4116,15 +4138,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 @@ -4176,6 +4198,7 @@ XAYA1_ROUTINE: sta ACC1E sty ACC1EX rts + LF348: ldx #$73 .byt $2C @@ -4505,13 +4528,13 @@ LF532: clc LF533: lda MENX - adc const_negative_100_000_000+3,y + adc const_negative_100_000_000 + 3,y sta MENX lda MENDFY - adc const_negative_100_000_000+2,y + adc const_negative_100_000_000 + 2,y sta MENDFY lda TELEMON_UNKNWON_LABEL_62 - adc const_negative_100_000_000+1,y + adc const_negative_100_000_000 + 1,y sta TELEMON_UNKNWON_LABEL_62 lda ACC1M adc const_negative_100_000_000,y @@ -4833,12 +4856,12 @@ LF915: ;;;;;;;;;;;;;;; XDECA1_ROUTINE: sta RES - sty RES+1 + sty RES + 1 tsx stx FLSVS lda #$00 sta RESB - sta RESB+1 + sta RESB + 1 sta ACC1EX ldx #$05 @L1: @@ -4858,7 +4881,7 @@ XDECA1_ROUTINE: bne LF953 .byte $2C LF94C: - stx RESB+1 + stx RESB + 1 LF94E: jsr LF9FC LF951: @@ -4939,14 +4962,16 @@ LF9C0: dec FLDT1 bne LF9C0 LF9C7: - lda RESB+1 + lda RESB + 1 bmi LF9E1 bpl LF9E4 + LF9CD: pha bit FLDT2 bpl LF9D4 inc ACC4M + LF9D4: jsr Lf242 pla @@ -4957,6 +4982,7 @@ LF9D4: LF9E1: jsr XNA1_ROUTINE + LF9E4: ldx #$00 jmp XAA1_ROUTINE @@ -4971,8 +4997,10 @@ LF9E9: sta ACCPS ldx ACC1E jmp XA1PA2_ROUTINE + LF9FC: inc RESB + LF9FE: ldy RESB lda (RES),y @@ -4993,120 +5021,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 +;.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 -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 +; 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 -@skip: - pla - lsr - lsr - dec RESB - bne next81 - 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 @@ -5138,7 +5163,7 @@ Lfef9: sec ror RES sta ADDRESS_READ_BETWEEN_BANK - sty ADDRESS_READ_BETWEEN_BANK+1 + sty ADDRESS_READ_BETWEEN_BANK + 1 Lff00: ldy #$00 @@ -5148,7 +5173,7 @@ Lff00: inc ADDRESS_READ_BETWEEN_BANK bne @loop - inc ADDRESS_READ_BETWEEN_BANK+1 + inc ADDRESS_READ_BETWEEN_BANK + 1 @loop: jsr read_a_code_in_15_and_y sta (RESB),y @@ -5161,10 +5186,12 @@ Lff00: adc ADDRESS_READ_BETWEEN_BANK sta ADDRESS_READ_BETWEEN_BANK bcc Lff00 - inc ADDRESS_READ_BETWEEN_BANK+1 + inc ADDRESS_READ_BETWEEN_BANK + 1 bcs Lff00 + Lff26: rts + read_a_code_in_15_and_y: bit RES bpl @skip @@ -5210,6 +5237,9 @@ ramoverlay_xfree: .include "functions/memory/xfree.asm" ramoverlay_xfree_end: copy_ramoverlay_end: +.include "functions/memory/xrealloc.asm" + + ; end of COPY_OVERLAY8RAM @@ -5217,19 +5247,11 @@ 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 -.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 @@ -5267,8 +5289,11 @@ signature: .byt $00 free_bytes: ; 26 bytes - .res $FFF0-* - .org $FFF0 + +.out .sprintf("BANK7 number of free bytes : %x", free_bytes) + +.segment "ORIXVECT7" + .byt $01 ; Kernel type .res 7 @@ -5276,8 +5301,11 @@ free_bytes: ; 26 bytes .byt signature +; .segment "CPUVECT" + END_ROM: ; fffa +.segment "CPUVECT7" NMI: .byt start_rom ; fffc @@ -5287,4 +5315,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..dd9173e8 --- /dev/null +++ b/src/kernel8/.gitignore @@ -0,0 +1,3 @@ +bpmtmp/ +build +src/kernel8/orixlibs/ 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/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..90d7a2f3 --- /dev/null +++ b/src/kernel8/bpm.tml @@ -0,0 +1,32 @@ +[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" +enable_publish = "True" +enable_build = "True" +lib = "True" +rom_compatible = "False" +web_doc_command = "mkdocs build" +mike_management = "False" + +[dependencies] + +[srcfolders] diff --git a/src/kernel8/src/kernel8.s b/src/kernel8/src/kernel8.s new file mode 100644 index 00000000..e296f6d2 --- /dev/null +++ b/src/kernel8/src/kernel8.s @@ -0,0 +1,147 @@ + +; See README.md for more details for bank 8 + + +.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 XLOADCHARSET_ROUTINE +.import KERNEL_BANK_MANAGEMENT +.import search_free_bank +.import kernel_free_bank +.import kernel_free_bank_by_pid +.import init_network +.import XSOCKET_ROUTINE + +.import kbind +.import krecv +.import ksend +.import ksocket_close +.import xconnect +.import XSOCKET_CLOSE_ROUTINE +.import close_sockets_by_pid + + ; .segment "BANK8" + .org $C000 + +start_rom: + jmp XBANK + +XBANK: + + cmp #KERNEL_ALLOCATE_BANK + beq @allocate_bank + + cmp #KERNEL_FREE_BANK + beq @free_bank + + cmp #KERNEL_FREE_BANK_BY_PID + beq @kernel_free_bank_by_pid + + cmp #KERNEL_START_NETWORK + beq @kernel_init_network + + cmp #KERNEL_SOCKET_NETWORK + beq @kernel_socket_network + + cmp #KERNEL_BIND_NETWORK + beq @kernel_bind_network + + cmp #KERNEL_CONNECT_NETWORK + beq @kernel_connect_network + + cmp #KERNEL_RECV_NETWORK + beq @kernel_recv_network + + cmp #KERNEL_SEND_NETWORK + beq @kernel_send_network + + cmp #KERNEL_SOCKET_CLOSE_NETWORK + beq @kernel_socket_close_network + + cmp #KERNEL_SOCKET_CLOSE_FROM_PID_NETWORK ; $0B + beq @kernel_sockets_close_by_pid_network + + cmp #KERNEL_LOAD_QWERTY_CHARSET ; $0C + beq @load_qwerty_charset_routine + + rts + +@allocate_bank: + jmp search_free_bank + +@free_bank: + jmp kernel_free_bank + +@kernel_free_bank_by_pid: + jmp kernel_free_bank_by_pid + +@kernel_init_network: + jmp init_network + +@kernel_socket_network: + jmp XSOCKET_ROUTINE + +@kernel_bind_network: + jmp kbind + +@kernel_connect_network: + jmp xconnect + +@kernel_send_network: + jmp ksend + +@kernel_recv_network: + jmp krecv + +@kernel_socket_close_network: + jmp XSOCKET_CLOSE_ROUTINE + +@kernel_sockets_close_by_pid_network: + jmp close_sockets_by_pid + +@load_qwerty_charset_routine: + jmp XLOADCHARSET_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..df85fc00 --- /dev/null +++ b/src/kernel_bank0.s @@ -0,0 +1,80 @@ +.export BUFROU +.export KERNEL_CONF_BEGIN +.export TELEMON_KEYBOARD_BUFFER_END +.export TELEMON_KEYBOARD_BUFFER_BEGIN + +.export KERNEL_BANK_MANAGEMENT + +; Network +.export KERNEL_NETWORK_FLAG + +.export KERNEL_NETWORK_SOCKET_LIST +.export KERNEL_NETWORK_SOCKET_DOMAIN +.export KERNEL_NETWORK_SOURCE_PORT +.export KERNEL_NETWORK_SOCKET_PID + + +.include "telestrat.inc" + +.include "include/kernel.inc" +.include "include/process.inc" + +.include "include/memory.inc" +.include "include/files.inc" +.include "include/ori2.inc" +.include "versions/versions.inc" + +ORIX_NUMBER_OF_BANK = 64 + + +.org $c080 +.bss +BUFBUF_ORIX: + +.org $C500 +BUFROU: + +.org $C5C4 +TELEMON_KEYBOARD_BUFFER_BEGIN: + +.org $C680 +TELEMON_KEYBOARD_BUFFER_END: + +.org $C680 + TELEMON_ACIA_BUFFER_INPUT_BEGIN: + +.org $C800 + TELEMON_ACIA_BUFFER_INPUT_END: + +.org $C800 + TELEMON_ACIA_BUFFER_OUTPUT_BEGIN: + +.org $CA00 + TELEMON_ACIA_BUFFER_OUTPUT_END: + +.org $CA00 + TELEMON_PRINTER_BUFFER_BEGIN: + +.org $D200 + TELEMON_PRINTER_BUFFER_END: + +.org $D201 +KERNEL_CONF_BEGIN: + +.org $D210 +KERNEL_CONF_END: + +.org $D300 +; Store the state of each bank +KERNEL_BANK_MANAGEMENT: + .tag kernel_bank_management_struct +KERNEL_NETWORK_FLAG: + .byt 0 ; Set for flag, it contains the state of the network +KERNEL_NETWORK_SOCKET_LIST: + .res 8 +KERNEL_NETWORK_SOCKET_DOMAIN: + .res 8 +KERNEL_NETWORK_SOURCE_PORT: ; To increment source port socket + .res 2 +KERNEL_NETWORK_SOCKET_PID: + .res 8 diff --git a/src/kernel_main_memory.s b/src/kernel_main_memory.s new file mode 100644 index 00000000..9e37b677 --- /dev/null +++ b/src/kernel_main_memory.s @@ -0,0 +1,456 @@ +.include "telestrat.inc" +.include "include/kernel.inc" +.include "include/process.inc" +.include "include/memory.inc" +.include "include/network.inc" +.include "include/files.inc" +.include "include/ori2.inc" +.include "versions/versions.inc" + + +.export KERNEL_ERRNO +.export KERNEL_CH376_MOUNT +.export KERNEL_XFREE_TMP +.export KERNEL_XKERNEL_CREATE_PROCESS_TMP +.export KERNEL_TMP_XEXEC +.export KERNEL_KERNEL_XEXEC_BNKOLD +.export KERNEL_MALLOC_TYPE +.export KERNEL_SAVE_XEXEC_CURRENT_SET +.export KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM +.export KERNEL_END_PROCESS_VARIABLES +.export SCRFX_KERNEL +.export IOTAB +.export KERNEL_ADIOB +.export kernel_malloc_free_chunk_size +.export kernel_xmalloc_call +.export KERNEL_ADIOB_END +.export READ_BYTE_FROM_OVERLAY_RAM +.export FIXME_DUNNO +.export STACK_BANK +;.export BUFNOM +.export kernel_malloc +.export KERNEL_DRIVER_MEMORY +.export kernel_process +.export BUSY_BANK_TABLE_RAM +.export kernel_end_of_memory_for_kernel +.export KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM +.export RESC +.export RESD +.export RESE +.export RESF +.export RESG +.export RESH +.export RESI +.export RESCONCAT + + +.export KERNEL_BANK_EXTENDED_AVAILABLE + +.import code_adress_419 +.import code_adress_436 + +.bss +.org $04 +RESC: ; is also DECDEB + .res 2 +RESD: ; is also DECFIN + .res 2 +RESE: ; is also DECCIB + .res 2 +RESF: ; is also DECTRV + .res 2 +.org $59 ; RS232T := $59 & RS232C := $5A +RESG: + .res 2 +.org $60 ; ACC1E +RESH: + .res 2 ; ACC1M+1 $62 +RESI: + .res 2 ; $ACC1M+3 $64 +RESCONCAT: + .res 2 ; ACC1S+1 $66 + + +.bss + .org $200 +KERNEL_ERRNO: + .res 1 +KERNEL_CH376_MOUNT: + .res 1 +KERNEL_XFREE_TMP: + .res 1 +KERNEL_XKERNEL_CREATE_PROCESS_TMP: + .res 1 +KERNEL_TMP_XEXEC: + .res 1 +KERNEL_KERNEL_XEXEC_BNKOLD: + .res 1 +KERNEL_MALLOC_TYPE: + .res 1 +KERNEL_SAVE_XEXEC_CURRENT_SET: + .res 1 +KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM: + .res 1 +; KERNEL_BANK_AVAILABLE is used to know if a bank is available or not (example : Kernel extended) +KERNEL_BANK_EXTENDED_AVAILABLE: + .res 1 + +KERNEL_FREE1_MEMORY: +KERNEL_END_PROCESS_VARIABLES: +.if KERNEL_END_PROCESS_VARIABLES > FLGTEL + .error "Error KERNEL_END_PROCESS_VARIABLES overlap FLGTEL" +.endif + +.org SCRX + 1 +BUSY_BANK_TABLE_RAM: + .res 3 + +.org SCRDX + ; SCRDX + .res 1 + +SCRFX_KERNEL: + .res 1 + +.org $282 +; Was VDTPIL + + +.org $2AE +IOTAB: + .res 4 ; KERNEL_SIZE_IOTAB +KERNEL_ADIOB: + .res 8 +kernel_malloc_free_chunk_size: + .tag kernel_malloc_free_chunk_size_struct +kernel_xmalloc_call: + .res 40 ; XMALLOC_ROUTINE_TO_RAM_OVERLAY +KERNEL_ADIOB_END: +.if KERNEL_ADIOB_END > VNMI + .error "Error malloc table overlap VNMI" +.endif + +.bss +.org $4C7 + +.res 1 ;Was before FIXME_DUNNO, it could remove when READ_BYTE_FROM_OVERLAY_RAM will be aligned correctly with kernel load + +READ_BYTE_FROM_OVERLAY_RAM: +; this contains a routine length : 20 bytew +.res 20 +.org $4FF +FIXME_DUNNO: + .res 1 + +.bss +.org $500 +STACK_BANK: + .res SIZE_OF_STACK_BANK + +kernel_end_of_variables_before_BUFNOM: + +.if kernel_end_of_variables_before_BUFNOM > BUFNOM + .error "Error BUFNOM is written by kernel variables try to move some variables in kernel.inc after BUFNOM or BUFEDT" +.endif + +.out .sprintf("kernel_end_of_variables_before_BUFNOM : %x", kernel_end_of_variables_before_BUFNOM) + +.bss +.org BUFNOM + .res 14 +BUFNOM_END: + +kernel_malloc: + .tag kernel_malloc_struct + .out .sprintf("kernel_malloc_struct : 0x%x", kernel_malloc) + +kernel_malloc_end: +kernel_process: + .tag kernel_process_struct + +kernel_process_end: +kernel_end_of_variables_before_BUFEDT: +.out .sprintf("kernel_end_of_variables_before_BUFEDT : %x", kernel_end_of_variables_before_BUFEDT) +.if kernel_end_of_variables_before_BUFEDT > BUFEDT + .error "Error BUFEDT is written by kernel variables try to move some variables in kernel.inc after $590" +.endif + +.bss +.org BUFEDT + +.ifdef WITH_DEBUG +kernel_debug: + .tag kernel_debug_struct + .out .sprintf("Size of kernel_debug_struct $%x ", .sizeof(kernel_debug_struct)) +.else +.res 110 +.endif + +BUFEDT_END: + +KERNEL_DRIVER_MEMORY: + .res 163 + +KERNEL_DRIVER_MEMORY_END: + +kernel_end_of_memory_for_kernel: + +.out .sprintf("kernel_end_of_memory_for_kernel (malloc will start at this adress) : %x", kernel_end_of_memory_for_kernel) + +kernel_end_of_variables_after_BUFEDT: +.if kernel_end_of_variables_after_BUFEDT > $7FF + .error "Error start of execution program for binary ($800) is written by kernel variables try to move some variables in kernel.inc before $800" +.endif + + +.ifdef MEMMAP_GENERATE + + + + +.out "==================================================================" +.out "File memory" +.out "==================================================================" +.out .sprintf("_KERNEL_FILE size (One fp struct) : $%X bytes", .sizeof(_KERNEL_FILE)) + +.out .sprintf("kernel_one_process_struct size (struct for one process) : $%X bytes", .sizeof(kernel_one_process_struct)) +.out .sprintf("With all the parameter all process could use %s bytes in memory, if it's allocated", .string(.sizeof(kernel_one_process_struct)*KERNEL_MAX_PROCESS+.sizeof(kernel_process_struct))) + +.out .sprintf("KERNEL_MAX_PROCESS (Max process in the system) : %s", .string(KERNEL_MAX_PROCESS)) +.out .sprintf("KERNEL_MAX_FP_PER_PROCESS (Max file pointer per process): %s", .string(KERNEL_MAX_FP_PER_PROCESS)) +.out .sprintf("KERNEL_USERZP_SAVE_LENGTH : %s bytes", .string(KERNEL_USERZP_SAVE_LENGTH)) +.out .sprintf("KERNEL_LENGTH_MAX_CMDLINE : %s", .string(KERNEL_LENGTH_MAX_CMDLINE)) + +.out .sprintf("kernel_process_struct size (struct init process) : $%X bytes", .sizeof(kernel_process_struct)) + + + +.out .sprintf("int MALLOC_BUSY_SIZE_LOW = 0x%x;", kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_low) +.out .sprintf("int MALLOC_BUSY_SIZE_HIGH = 0x%x;", kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_size_high) +.out .sprintf("int MALLOC_BUSY_BEGIN_HIGH = 0x%x;", kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_high) +.out .sprintf("int MALLOC_BUSY_END_HIGH = 0x%x;", kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_high) +.out .sprintf("int MALLOC_BUSY_BEGIN_LOW = 0x%x;", kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_begin_low) +.out .sprintf("int MALLOC_BUSY_END_LOW = 0x%x;", kernel_malloc + kernel_malloc_struct::kernel_malloc_busy_chunk_end_low) +.out .sprintf("int KERNEL_MAX_NUMBER_OF_MALLOC = 0x%x;", KERNEL_MAX_NUMBER_OF_MALLOC) + + + +.out .sprintf("int MALLOC_FREE_SIZE_HIGH =0x%x;",kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_high) +.out .sprintf("int MALLOC_FREE_SIZE_LOW =0x%x;",kernel_malloc_free_chunk_size+kernel_malloc_free_chunk_size_struct::kernel_malloc_free_chunk_size_low) + +.out .sprintf("int MALLOC_FREE_BEGIN_HIGH=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_high) +.out .sprintf("int MALLOC_FREE_BEGIN_LOW=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_begin_low) + +.out .sprintf("int MALLOC_FREE_END_HIGH=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_high) +.out .sprintf("int MALLOC_FREE_END_LOW=0x%x;",kernel_malloc+kernel_malloc_struct::kernel_malloc_free_chunk_end_low) + +.out .sprintf("int KERNEL_MALLOC_FREE_CHUNK_MAX=0x%x;",KERNEL_MALLOC_FREE_CHUNK_MAX) + + + +.out .sprintf("|#MEMMAP: Memmap") +; \n +.out .sprintf("MEMMAP:") +.out .sprintf("|##MEMMAP: Page 0") +; \nr +.out .sprintf("MEMMAP:") +.out "|MEMMAP:Type | Name | Range | Size |" +.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" +.out .sprintf("|MEMMAP:RAM|RES | $%02X-$%02X | 2 |", RES, RES+1) +.out .sprintf("|MEMMAP:RAM|RESB | $%02X-$%02X | 2 |", RESB, RESB + 1) +.out .sprintf("|MEMMAP:RAM|RESC | $%02X-$%02X | 2 |", RESC, RESC + 1) +.out .sprintf("|MEMMAP:RAM|RESD | $%02X-$%02X | 2 |", RESD, RESD + 1) +.out .sprintf("|MEMMAP:RAM|RESE | $%02X-$%02X | 2 |", RESE, RESE + 1) +.out .sprintf("|MEMMAP:RAM|RESF | $%02X-$%02X | 2 |", RESF, RESF + 1) +.out .sprintf("|MEMMAP:RAM|RESG | $%02X-$%02X | 2 |", RESG, RESG + 1) +.out .sprintf("|MEMMAP:RAM|RESH | $%02X-$%02X | 2 |", RESH, RESH + 1) +.out .sprintf("|MEMMAP:RAM|RESI | $%02X-$%02X | 2 |", RESI, RESI + 1) +.out .sprintf("|MEMMAP:RAM|RESCONCAT | $%02X-$%02X | 2 |", RESCONCAT, RESCONCAT + 1) +.out .sprintf("|MEMMAP:RAM|TR0 | $%02X-$%02X | 1 |", TR0, TR0) +.out .sprintf("|MEMMAP:RAM|TR1 | $%02X-$%02X | 1 |", TR1 ,TR1) +.out .sprintf("|MEMMAP:RAM|TR2 | $%02X-$%02X | 1 |", TR2, TR2) +.out .sprintf("|MEMMAP:RAM|TR3 | $%02X-$%02X | 1 |", TR3, TR3) +.out .sprintf("|MEMMAP:RAM|TR4 | $%02X-$%02X | 1 |", TR4, TR4) +.out .sprintf("|MEMMAP:RAM|TR5 | $%02X-$%02X | 1 |", TR5, TR5) +.out .sprintf("|MEMMAP:RAM|TR6 | $%02X-$%02X | 1 |", TR6, TR6) +.out .sprintf("|MEMMAP:RAM|TR7 | $%02X-$%02X | 1 |", TR7, TR7) +.out .sprintf("|MEMMAP:RAM|DEFAFF | $%02X-$%02X | 1 |", DEFAFF, DEFAFF) +.out .sprintf("|MEMMAP:RAM|FREE | $15-$16 | 2 |") +.out .sprintf("|MEMMAP:RAM|ADDRESS_VECTOR_FOR_ADIOB | $%02X-$%02X | 2 |", ADDRESS_VECTOR_FOR_ADIOB, ADDRESS_VECTOR_FOR_ADIOB + 1) +.out .sprintf("|MEMMAP:RAM|work_channel | $%02X-$%02X | 1 |", work_channel, work_channel) +.out .sprintf("|MEMMAP:RAM|i_o_counter | $%02X-$%02X | 2 |", i_o_counter, i_o_counter + 1) +.out .sprintf("|MEMMAP:RAM|FREE | $1C-$1C | 1 |") +.out .sprintf("|MEMMAP:RAM|GS | $1D-$1D | 1 |") +.out .sprintf("|MEMMAP:RAM|FREE | $1E-$1E | 1 |") +.out .sprintf("|MEMMAP:RAM|TOFIX | $1F-$1F | 1 |") +.out .sprintf("|MEMMAP:RAM|TOFIX | $20-$20 | 1 |") +.out .sprintf("|MEMMAP:RAM|IRQSVA | $%02X-$%02X | 1 |", IRQSVA, IRQSVA) +.out .sprintf("|MEMMAP:RAM|IRQSVX | $%02X-$%02X | 1 |", IRQSVX, IRQSVX) +.out .sprintf("|MEMMAP:RAM|IRQSVY | $%02X-$%02X | 1 |", IRQSVY, IRQSVY) +.out .sprintf("|MEMMAP:RAM|IRQSVP | $%02X-$%02X | 1 |", IRQSVP, IRQSVP) +.out .sprintf("|MEMMAP:RAM|FIXME_PAGE0_0 | $%02X-$%02X | 1 |", FIXME_PAGE0_0, FIXME_PAGE0_0) +.out .sprintf("|MEMMAP:RAM|ADSCR | $%02X-$%02X | 2 |", ADSCR,ADSCR + 1) +.out .sprintf("|MEMMAP:RAM|SCRNB | $%02X-$%02X | 2 |", SCRNB,SCRNB + 1) +.out .sprintf("|MEMMAP:RAM|ADKBD | $%02X-$%02X | 2 |", ADKBD,ADKBD + 1) +.out .sprintf("|MEMMAP:RAM|PTR_READ_DEST | $%02X-$%02X | 2 |", PTR_READ_DEST, PTR_READ_DEST + 1) +.out .sprintf("|MEMMAP:RAM|FREE | $%02X-$%02X | |", PTR_READ_DEST + 2, ADDRESS_READ_BETWEEN_BANK - 1) +.out .sprintf("|MEMMAP:RAM|ADDRESS_READ_BETWEEN_BANK | $%02X-$%02X | 2 |", ADDRESS_READ_BETWEEN_BANK, ADDRESS_READ_BETWEEN_BANK + 1) +.out .sprintf("|MEMMAP:RAM|BNKCIB_DOUBLON | $%02X-$%02X | 1 |", BNKCIB_DOUBLON, BNKCIB_DOUBLON) +.out .sprintf("|MEMMAP:RAM|FREE | $%02X-$%02X | |", BNKCIB_DOUBLON + 1, ADCLK -1) +.out .sprintf("|MEMMAP:RAM|ADCLK | $%02X-$%02X | 2 |", ADCLK, ADCLK + 1) +.out .sprintf("|MEMMAP:RAM|TIMEUS | $%02X-$%02X | 2 |", TIMEUS, TIMEUS + 1) +.out .sprintf("|MEMMAP:RAM|TIMEUD (used in cc65 clock function)| $%02X-$%02X | 2 |", TIMEUD, TIMEUD + 1) +.out .sprintf("|MEMMAP:RAM|HRSX | $%02X-$%02X | 1 |", HRSX, HRSX) +.out .sprintf("|MEMMAP:RAM|HRSY | $%02X-$%02X | 1 |", HRSY, HRSY) +.out .sprintf("|MEMMAP:RAM|FREE | $48-$48 | 1 |") +.out .sprintf("|MEMMAP:RAM|HRSX40 | $%02X-$%02X | 1 |", HRSX40, HRSX40) +.out .sprintf("|MEMMAP:RAM|HRSX6 | $%02X-$%02X | 1 |", HRSX6, HRSX6) +.out .sprintf("|MEMMAP:RAM|ADHRS | $%02X-$%02X | 2 |", ADHRS, ADHRS + 1) +.out .sprintf("|MEMMAP:RAM|HRS1 | $%02X-$%02X | 2 |", HRS1, HRS1 + 1) +.out .sprintf("|MEMMAP:RAM|HRS2 | $%02X-$%02X | 2 |", HRS2, HRS2 + 1) +.out .sprintf("|MEMMAP:RAM|HRS3 | $%02X-$%02X | 2 |", HRS3, HRS3 + 1) +.out .sprintf("|MEMMAP:RAM|HRS4 | $%02X-$%02X | 2 |", HRS4, HRS4 + 1) +.out .sprintf("|MEMMAP:RAM|HRS5 | $%02X-$%02X | 2 |", HRS5, HRS5 + 1) +.out .sprintf("|MEMMAP:RAM|HRSFB | $%02X-$%02X | 1 |", HRSFB, HRSFB) +.out .sprintf("|MEMMAP:RAM|VABPK1 | $%02X-$%02X | 1 |", VABKP1, VABKP1) +.out .sprintf("|MEMMAP:RAM|FREE | $59-$5A | 2 |") +.out .sprintf("|MEMMAP:RAM|INDRS | $%02X-$%02X | 1 |", INDRS, INDRS) +.out .sprintf("|MEMMAP:RAM|FREE | $5C-$5F | 2 |") + + +.out .sprintf("|MEMMAP:RAM|FREE | $%02X-$FF | %d |",VARLNG, $FF - VARLNG) + + + +.out .sprintf("|##MEMMAP: Page 2") +.out "|MEMMAP:Type | Name | Range | Size |" +.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" +.out .sprintf("|MEMMAP:RAM|KERNEL_ERRNO | $%04X-$%04X | 1 |", KERNEL_ERRNO, KERNEL_ERRNO) +.out .sprintf("|MEMMAP:RAM|KERNEL_CH376_MOUNT | $%04X-$%04X | 1 |", KERNEL_CH376_MOUNT, KERNEL_CH376_MOUNT) +.out .sprintf("|MEMMAP:RAM|KERNEL_XFREE_TMP | $%04X-$%04X | 1 |", KERNEL_XFREE_TMP, KERNEL_XFREE_TMP) + +.out .sprintf("|MEMMAP:RAM|KERNEL_XKERNEL_CREATE_PROCESS_TMP| $%04X-$%04X | 1 |", KERNEL_XKERNEL_CREATE_PROCESS_TMP, KERNEL_XKERNEL_CREATE_PROCESS_TMP) + +.out .sprintf("|MEMMAP:RAM|KERNEL_TMP_XEXEC | $%04X-$%04X | 1 |", KERNEL_TMP_XEXEC, KERNEL_TMP_XEXEC) +.out .sprintf("|MEMMAP:RAM|KERNEL_KERNEL_XEXEC_BNKOLD | $%04X-$%04X | 1 |", KERNEL_KERNEL_XEXEC_BNKOLD, KERNEL_KERNEL_XEXEC_BNKOLD) + +.out .sprintf("|MEMMAP:RAM|KERNEL_MALLOC_TYPE | $%04X-$%04X | 1 |", KERNEL_MALLOC_TYPE, KERNEL_MALLOC_TYPE) +.out .sprintf("|MEMMAP:RAM|KERNEL_SAVE_XEXEC_CURRENT_SET| $%04X-$%04X | 1 |", KERNEL_SAVE_XEXEC_CURRENT_SET, KERNEL_SAVE_XEXEC_CURRENT_SET) +.out .sprintf("|MEMMAP:RAM|KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM| $%04X-$%04X | 1 |", KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM, KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM+1) + +.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", KERNEL_FREE1_MEMORY, FLGTEL - 1, FLGTEL - KERNEL_FREE1_MEMORY) + +; KOROM and KORAM are not used + +.out .sprintf("|MEMMAP:RAM|FLGTEL | $%04X-$%04X | 1 |", FLGTEL, FLGTEL ) +.out .sprintf("|MEMMAP:RAM|TIMED | $%04X-$%04X | 1 |", TIMED, TIMED ) +.out .sprintf("|MEMMAP:RAM|TIMES | $%04X-$%04X | 1 |", TIMES, TIMES) +.out .sprintf("|MEMMAP:RAM|TIMEM | $%04X-$%04X | 1 |", TIMEM , TIMEM) +.out .sprintf("|MEMMAP:RAM|TIMEH | $%04X-$%04X | 1 |", TIMEH, TIMEH) + +.out .sprintf("|MEMMAP:RAM|FLGCLK | $%04X-$%04X | 1 |", FLGCLK, FLGCLK) +.out .sprintf("|MEMMAP:RAM|FLGCLK_FLAG | $%04X-$%04X | 1 |", FLGCLK_FLAG, FLGCLK_FLAG) + +.out .sprintf("|MEMMAP:RAM|FLGCUR | $%04X-$%04X | 1 |", FLGCUR, FLGCUR) +.out .sprintf("|MEMMAP:RAM|FLGCUR_STATE | $%04X-$%04X | 1 |", FLGCUR_STATE, FLGCUR_STATE) + +.out .sprintf("|MEMMAP:RAM|ADSCRL | $%04X-$%04X | 4 |", ADSCRL,ADSCRL+3) +.out .sprintf("|MEMMAP:RAM|ADSCRH | $%04X-$%04X | 4 |", ADSCRH,ADSCRH+3) + +.out .sprintf("|MEMMAP:RAM|SCRX | $%04X-$%04X | 1 |", SCRX, SCRX) + +.out .sprintf("|MEMMAP:RAM|BUSY_BANK_TABLE_RAM | $%04X-$%04X | %d |", BUSY_BANK_TABLE_RAM, BUSY_BANK_TABLE_RAM+3, 3) + +.out .sprintf("|MEMMAP:RAM|SCRY | $%04X-$%04X | 4 |", SCRY, SCRY+3) + +.out .sprintf("|MEMMAP:RAM|SCRDX | $%04X-$%04X | 1 |", SCRDX, SCRDX) +.out .sprintf("|MEMMAP:RAM|SCRFX | $%04X-$%04X | 1 |", SCRFX, SCRFX) + +.out .sprintf("|MEMMAP:RAM|SCRFY | $%04X-$%04X | 1 |", SCRFY, SCRFY) +.out .sprintf("|MEMMAP:RAM|SCRDY | $%04X-$%04X | 1 |", SCRDY, SCRDY) + +.out .sprintf("|MEMMAP:RAM|SCRBAL | $%04X-$%04X | 1 |", SCRBAL, SCRBAL) + +.out .sprintf("|MEMMAP:RAM|SCRBAH | $%04X-$%04X | 1 |", SCRBAH, SCRBAH) + + +.out .sprintf("|MEMMAP:RAM|SCRCT | $%04X-$%04X | 1 |", SCRCT, SCRCT) +.out .sprintf("|MEMMAP:RAM|SCRCF | $%04X-$%04X | 1 |", SCRCF, SCRCF) + + +.out .sprintf("|MEMMAP:RAM|FIXME | $%04X-$%04X | %d |", SCRCF+4,ADSCRH+4,KBDCOL-ADSCRH+4) + +.out .sprintf("|MEMMAP:RAM|FLGSCR | $%04X-$%04X | 4 |", FLGSCR,FLGSCR+4) ; $248 +.out .sprintf("|MEMMAP:RAM|CURSCR | $%04X-$%04X | 1 |", CURSCR,CURSCR+1) ; $248 + +.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", CURSCR+1,SCRTXT,SCRTXT-CURSCR+1) ; $248 + +.out .sprintf("|MEMMAP:RAM|SCRTXT | $%04X-$%04X | 4 |", SCRTXT,SCRHIR+4) ; $248 +.out .sprintf("|MEMMAP:RAM|SCRHIR (not used) | $%04X-$%04X | %d |", SCRHIR,SCRHIR+4,4) ; $248 + +.out .sprintf("|MEMMAP:RAM|SCRTRA | $%04X-$%04X | %d |", SCRTRA,SCRTRA+4,6) ; $248 + +.out .sprintf("|MEMMAP:RAM|KBDCOL | $%04X-$%04X | %d |", KBDCOL,KBDCOL+8,8) +.out .sprintf("|MEMMAP:RAM|KBDFLG_KEY | $%04X-$%04X | %d |", KBDFLG_KEY, KBDFLG_KEY+2,2) + +.out .sprintf("|MEMMAP:RAM|KBDVRR | $%04X-$%04X | %d |", KBDVRR, KBDVRR + 1,1) +.out .sprintf("|MEMMAP:RAM|KBDVRL | $%04X-$%04X | %d |", KBDVRL, KBDVRL + 2,2) +.out .sprintf("|MEMMAP:RAM|FLGKBD | $%04X-$%04X | %d |", FLGKBD, FLGKBD + 1,1) + +.out .sprintf("|MEMMAP:RAM|KBDFCT | $%04X-$%04X | %d |", KBDFCT, KBDFCT + 1,1) + +.out .sprintf("|MEMMAP:RAM|KBDSHT | $%04X-$%04X | %d |", KBDSHT, KBDSHT + 1,1) + +.out .sprintf("|MEMMAP:RAM|KBDKEY | $%04X-$%04X | %d |", KBDKEY, KBDKEY + 5,1) + +.out .sprintf("|MEMMAP:RAM|KBDCTC | $%04X-$%04X | 2 |", KBDCTC, KBDCTC+1) + +.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", KBDCTC + 1, KEYBOARD_COUNTER - 1,KEYBOARD_COUNTER - KBDCTC) + +.out .sprintf("|MEMMAP:RAM|KEYBOARD_COUNTER | $%04X-$%04X | %d |", KEYBOARD_COUNTER, KEYBOARD_COUNTER+3,3) +.out .sprintf("|MEMMAP:RAM|HRSPAT | $%04X-$%04X | %d |", HRSPAT, HRSPAT,1) + +.out .sprintf("|MEMMAP:RAM|IOTAB | $%04X-$%04X | X |", IOTAB, IOTAB + KERNEL_SIZE_IOTAB - 1) +.out .sprintf("|MEMMAP:RAM|KERNEL_ADIOB | $%04X-$%04X | %d |", KERNEL_ADIOB, KERNEL_ADIOB+ADIODB_LENGTH-1,KERNEL_ADIOB+ADIODB_LENGTH-KERNEL_ADIOB) + +.out .sprintf("|MEMMAP:RAM|kernel_malloc_free_chunk_size | $%04X-$%04X | %d |", kernel_malloc_free_chunk_size, kernel_malloc_free_chunk_size + .sizeof(kernel_malloc_free_chunk_size_struct)-1,.sizeof(kernel_malloc_free_chunk_size_struct)) + +.out .sprintf("|MEMMAP:RAM|kernel_xmalloc_call | $%04X-$%04X | %d |", kernel_xmalloc_call, kernel_xmalloc_call + XMALLOC_ROUTINE_TO_RAM_OVERLAY,kernel_xmalloc_call+XMALLOC_ROUTINE_TO_RAM_OVERLAY-kernel_xmalloc_call) + +.out .sprintf("|MEMMAP:RAM|FLGRST | $%04X-$%04X | %d |", FLGRST, FLGRST,1) +.out .sprintf("|MEMMAP:RAM|CSRND | $%04X-$%04X | %d |", CSRND, CSRND,1) + + +.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", KERNEL_ADIOB_END, FLGRST-1, FLGRST-KERNEL_ADIOB_END) + +.out .sprintf("|MEMMAP:RAM|VNMI | $%04X-$%04X | 3 |", VNMI, VNMI+3) + +.out .sprintf("|MEMMAP:RAM|ADIODB_VECTOR | $%04X-$%04X | %d |", ADIODB_VECTOR, ADIODB_VECTOR+3,3) + +.out .sprintf("|MEMMAP:RAM|IRQVECTOR | $%04X-$%04X | %d |", IRQVECTOR, IRQVECTOR + 3,3) + +.out .sprintf("|MEMMAP:RAM|VAPLIC | $%04X-$%04X | %d |", VAPLIC, VAPLIC + 3,3) + +.out .sprintf("|##MEMMAP: Page 3") +.out "|MEMMAP:Type | Name | Range | Size |" +.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" +.out .sprintf("|MEMMAP:IO |VIA1 | $0300-$030F | |") + +.out .sprintf("|##MEMMAP: Page 4") +.out "|MEMMAP:Type | Name | Range | Size |" +.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" +.out .sprintf("|MEMMAP:RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $%04X-$%04X | 3 |", ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY,ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY+3) +;.out .sprintf("|MEMMAP:RAM|page4 overlay_access | $%04X-$%04X | %d |", $400 + code_adress_419 - code_adress_400, $400 + code_adress_436 - code_adress_400, code_adress_436 - code_adress_400) + +.out .sprintf("|##MEMMAP: Page 5&6") +.out "|MEMMAP:Type | Name | Range | Size |" +.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" +.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", BUFNOM, BUFNOM_END, BUFNOM_END - BUFNOM) +.out .sprintf("|MEMMAP:RAM|Malloc table | $%04X-$%04X | %d |", kernel_malloc, kernel_malloc_end,kernel_malloc_end-kernel_malloc) +.out .sprintf("|MEMMAP:RAM|main kernel process struct | $%04X-$%04X | %d |", kernel_process, kernel_process_end,kernel_process_end-kernel_process) + +.out .sprintf("|MEMMAP:RAM|BUFEDT | $%04X-$%04X | %d |", BUFEDT, BUFEDT_END,BUFEDT_END-BUFEDT) +.out .sprintf("|MEMMAP:RAM|KERNEL_MEMORY_DRIVER | $%04X-$%04X | %d |", KERNEL_DRIVER_MEMORY, KERNEL_DRIVER_MEMORY_END, KERNEL_DRIVER_MEMORY_END - KERNEL_DRIVER_MEMORY) + + +.endif diff --git a/src/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/src/memmap.asm b/src/memmap.asm index 8ba5c085..8b137891 100644 --- a/src/memmap.asm +++ b/src/memmap.asm @@ -1,220 +1 @@ -.out .sprintf("|#MEMMAP: Memmap") -.out .sprintf("|##MEMMAP: Page 0") -.out "|MEMMAP:Type | Name | Range | Size |" -.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" -.out .sprintf("|MEMMAP:RAM|RES | $%02X-$%02X | 2 |", RES,RES+1) -.out .sprintf("|MEMMAP:RAM|RESB | $%02X-$%02X | 2 |", RESB,RESB+1) -.out .sprintf("|MEMMAP:RAM|RESC | $%02X-$%02X | 2 |", RESC,RESC+1) -.out .sprintf("|MEMMAP:RAM|RESD | $%02X-$%02X | 2 |", RESD,RESD+1) -.out .sprintf("|MEMMAP:RAM|RESE | $%02X-$%02X | 2 |", RESE,RESE+1) -.out .sprintf("|MEMMAP:RAM|RESF | $%02X-$%02X | 2 |", RESF,RESF+1) -.out .sprintf("|MEMMAP:RAM|RESG | $%02X-$%02X | 2 |", RESG,RESG+1) -.out .sprintf("|MEMMAP:RAM|RESH | $%02X-$%02X | 2 |", RESH,RESH+1) -.out .sprintf("|MEMMAP:RAM|RESI | $%02X-$%02X | 2 |", RESI,RESI+1) -.out .sprintf("|MEMMAP:RAM|RESCONCAT | $%02X-$%02X | 2 |", RESCONCAT,RESCONCAT+1) -.out .sprintf("|MEMMAP:RAM|TR0 | $%02X-$%02X | 1 |", TR0,TR0) -.out .sprintf("|MEMMAP:RAM|TR1 | $%02X-$%02X | 1 |", TR1,TR1) -.out .sprintf("|MEMMAP:RAM|TR2 | $%02X-$%02X | 1 |", TR2,TR2) -.out .sprintf("|MEMMAP:RAM|TR3 | $%02X-$%02X | 1 |", TR3,TR3) -.out .sprintf("|MEMMAP:RAM|TR4 | $%02X-$%02X | 1 |", TR4,TR4) -.out .sprintf("|MEMMAP:RAM|TR5 | $%02X-$%02X | 1 |", TR5,TR5) -.out .sprintf("|MEMMAP:RAM|TR6 | $%02X-$%02X | 1 |", TR6,TR6) -.out .sprintf("|MEMMAP:RAM|TR7 | $%02X-$%02X | 1 |", TR7,TR7) -.out .sprintf("|MEMMAP:RAM|DEFAFF | $%02X-$%02X | 1 |",DEFAFF,DEFAFF) -.out .sprintf("|MEMMAP:RAM|FREE | $15-$16 | 2 |") -.out .sprintf("|MEMMAP:RAM|ADDRESS_VECTOR_FOR_ADIOB | $%02X-$%02X | 2 |",ADDRESS_VECTOR_FOR_ADIOB,ADDRESS_VECTOR_FOR_ADIOB+1) -.out .sprintf("|MEMMAP:RAM|work_channel | $%02X-$%02X | 1 |",work_channel,work_channel) -.out .sprintf("|MEMMAP:RAM|i_o_counter | $%02X-$%02X | 2 |",i_o_counter,i_o_counter+1) -.out .sprintf("|MEMMAP:RAM|FREE | $1C-$1C | 1 |") -.out .sprintf("|MEMMAP:RAM|GS | $1D-$1D | 1 |") -.out .sprintf("|MEMMAP:RAM|FREE | $1E-$1E | 1 |") -.out .sprintf("|MEMMAP:RAM|TOFIX | $1F-$1F | 1 |") -.out .sprintf("|MEMMAP:RAM|TOFIX | $20-$20 | 1 |") -.out .sprintf("|MEMMAP:RAM|IRQSVA | $%02X-$%02X | 1 |", IRQSVA,IRQSVA) -.out .sprintf("|MEMMAP:RAM|IRQSVX | $%02X-$%02X | 1 |", IRQSVX,IRQSVX) -.out .sprintf("|MEMMAP:RAM|IRQSVY | $%02X-$%02X | 1 |", IRQSVY,IRQSVY) -.out .sprintf("|MEMMAP:RAM|IRQSVP | $%02X-$%02X | 1 |", IRQSVP,IRQSVP) -.out .sprintf("|MEMMAP:RAM|FIXME_PAGE0_0 | $%02X-$%02X | 1 |",FIXME_PAGE0_0,FIXME_PAGE0_0) -.out .sprintf("|MEMMAP:RAM|ADSCR | $%02X-$%02X | 2 |", ADSCR,ADSCR+1) -.out .sprintf("|MEMMAP:RAM|SCRNB | $%02X-$%02X | 2 |", SCRNB,SCRNB+1) -.out .sprintf("|MEMMAP:RAM|ADKBD | $%02X-$%02X | 2 |", ADKBD,ADKBD+1) -.out .sprintf("|MEMMAP:RAM|PTR_READ_DEST | $%02X-$%02X | 2 |", PTR_READ_DEST,PTR_READ_DEST+1) -.out .sprintf("|MEMMAP:RAM|FREE | $%02X-$%02X | |", PTR_READ_DEST+2,ptr1-1) -.out .sprintf("|MEMMAP:RAM|ptr1 | $%02X-$%02X | 2 |", ptr1,ptr1+1) -.out .sprintf("|MEMMAP:RAM|tmp1 | $%02X-$%02X | 1 |", tmp1,tmp1) -.out .sprintf("|MEMMAP:RAM|FREE | $%02X-$%02X | |", tmp1+1,ADCLK-1) -.out .sprintf("|MEMMAP:RAM|ADCLK | $%02X-$%02X | 2 |", ADCLK,ADCLK+1) -.out .sprintf("|MEMMAP:RAM|TIMEUS | $%02X-$%02X | 2 |", TIMEUS,TIMEUS+1) -.out .sprintf("|MEMMAP:RAM|TIMEUD (used in cc65 clock function)| $%02X-$%02X | 2 |", TIMEUD,TIMEUD+1) -.out .sprintf("|MEMMAP:RAM|HRSX | $%02X-$%02X | 1 |", HRSX,HRSX) -.out .sprintf("|MEMMAP:RAM|HRSY | $%02X-$%02X | 1 |", HRSY,HRSY) -.out .sprintf("|MEMMAP:RAM|FREE | $48-$48 | 1 |") -.out .sprintf("|MEMMAP:RAM|HRSX40 | $%02X-$%02X | 1 |", HRSX40,HRSX40) -.out .sprintf("|MEMMAP:RAM|HRSX6 | $%02X-$%02X | 1 |", HRSX6,HRSX6) -.out .sprintf("|MEMMAP:RAM|ADHRS | $%02X-$%02X | 2 |", ADHRS,ADHRS+1) -.out .sprintf("|MEMMAP:RAM|HRS1 | $%02X-$%02X | 2 |", HRS1,HRS1+1) -.out .sprintf("|MEMMAP:RAM|HRS2 | $%02X-$%02X | 2 |", HRS2,HRS2+1) -.out .sprintf("|MEMMAP:RAM|HRS3 | $%02X-$%02X | 2 |", HRS3,HRS3+1) -.out .sprintf("|MEMMAP:RAM|HRS4 | $%02X-$%02X | 2 |", HRS4,HRS4+1) -.out .sprintf("|MEMMAP:RAM|HRS5 | $%02X-$%02X | 2 |", HRS5,HRS5+1) -.out .sprintf("|MEMMAP:RAM|HRSFB | $%02X-$%02X | 1 |", HRSFB,HRSFB) -.out .sprintf("|MEMMAP:RAM|VABPK1 | $%02X-$%02X | 1 |", VABKP1,VABKP1) -.out .sprintf("|MEMMAP:RAM|FREE | $59-$5A | 2 |") -.out .sprintf("|MEMMAP:RAM|INDRS | $%02X-$%02X | 1 |", INDRS,INDRS) -.out .sprintf("|MEMMAP:RAM|FREE | $5C-$5F | 2 |") - - -.out .sprintf("|MEMMAP:RAM|FREE | $%02X-$FF | %d |",VARLNG,$FF-VARLNG) - -; Used by A : FLGSCR, FLGKBD, CURSCR, SCRX, SCRY, KBDCTC, KBDSHT, KBDFCT -; used in cc65 : SCRX, SCRY, ADSCR, SCRDY - -.out .sprintf("|##MEMMAP: Page 2") -.out "|MEMMAP:Type | Name | Range | Size |" -.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" -.out .sprintf("|MEMMAP:RAM|KERNEL_ERRNO | $%04X-$%04X | 1 |", KERNEL_ERRNO, KERNEL_ERRNO) -.out .sprintf("|MEMMAP:RAM|KERNEL_CH376_MOUNT | $%04X-$%04X | 1 |", KERNEL_CH376_MOUNT, KERNEL_CH376_MOUNT) -.out .sprintf("|MEMMAP:RAM|KERNEL_XFREE_TMP | $%04X-$%04X | 1 |", KERNEL_XFREE_TMP, KERNEL_XFREE_TMP) - -.out .sprintf("|MEMMAP:RAM|KERNEL_XKERNEL_CREATE_PROCESS_TMP| $%04X-$%04X | 1 |", KERNEL_XKERNEL_CREATE_PROCESS_TMP, KERNEL_XKERNEL_CREATE_PROCESS_TMP) - -.out .sprintf("|MEMMAP:RAM|KERNEL_TMP_XEXEC | $%04X-$%04X | 1 |", KERNEL_TMP_XEXEC, KERNEL_TMP_XEXEC) -.out .sprintf("|MEMMAP:RAM|KERNEL_KERNEL_XEXEC_BNKOLD | $%04X-$%04X | 1 |", KERNEL_KERNEL_XEXEC_BNKOLD, KERNEL_KERNEL_XEXEC_BNKOLD) - -.out .sprintf("|MEMMAP:RAM|KERNEL_MALLOC_TYPE | $%04X-$%04X | 1 |", KERNEL_MALLOC_TYPE, KERNEL_MALLOC_TYPE) -.out .sprintf("|MEMMAP:RAM|KERNEL_SAVE_XEXEC_CURRENT_SET| $%04X-$%04X | 1 |", KERNEL_SAVE_XEXEC_CURRENT_SET, KERNEL_SAVE_XEXEC_CURRENT_SET) -.out .sprintf("|MEMMAP:RAM|KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM| $%04X-$%04X | 1 |", KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM, KERNEL_SAVE_XEXEC_CURRENT_ROM_RAM+1) - -.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", $209, KORAM,KORAM-$209) - - -;.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | 2 |", KOROM, KORAM) -;.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | 2 |", KOROM, KORAM) - -.out .sprintf("|MEMMAP:RAM|TIMED | $%04X-$%04X | 1 |", TIMED, TIMED ) -.out .sprintf("|MEMMAP:RAM|TIMES | $%04X-$%04X | 1 |", TIMES, TIMES) -.out .sprintf("|MEMMAP:RAM|TIMEM | $%04X-$%04X | 1 |", TIMEM , TIMEM) -.out .sprintf("|MEMMAP:RAM|TIMEH | $%04X-$%04X | 1 |", TIMEH, TIMEH) - -.out .sprintf("|MEMMAP:RAM|FLGCLK | $%04X-$%04X | 1 |", FLGCLK, FLGCLK) -.out .sprintf("|MEMMAP:RAM|FLGCLK_FLAG | $%04X-$%04X | 1 |", FLGCLK_FLAG, FLGCLK_FLAG) - -.out .sprintf("|MEMMAP:RAM|FLGCUR | $%04X-$%04X | 1 |", FLGCUR, FLGCUR) -.out .sprintf("|MEMMAP:RAM|FLGCUR_STATE | $%04X-$%04X | 1 |", FLGCUR_STATE, FLGCUR_STATE) - -.out .sprintf("|MEMMAP:RAM|ADSCRL | $%04X-$%04X | 4 |", ADSCRL,ADSCRL+3) -.out .sprintf("|MEMMAP:RAM|ADSCRH | $%04X-$%04X | 4 |", ADSCRH,ADSCRH+3) - -.out .sprintf("|MEMMAP:RAM|SCRX | $%04X-$%04X | 1 |", SCRX, SCRX) - -.out .sprintf("|MEMMAP:RAM|BUSY_BANK_TABLE_RAM | $%04X-$%04X | %d |", BUSY_BANK_TABLE_RAM, BUSY_BANK_TABLE_RAM+3, 3) - -.out .sprintf("|MEMMAP:RAM|SCRY | $%04X-$%04X | 4 |", SCRY, SCRY+3) - -.out .sprintf("|MEMMAP:RAM|SCRDX | $%04X-$%04X | 1 |", SCRDX, SCRDX) -.out .sprintf("|MEMMAP:RAM|SCRFX | $%04X-$%04X | 1 |", SCRFX, SCRFX) - -.out .sprintf("|MEMMAP:RAM|SCRFY | $%04X-$%04X | 1 |", SCRFY, SCRFY) -.out .sprintf("|MEMMAP:RAM|SCRDY | $%04X-$%04X | 1 |", SCRDY, SCRDY) - -.out .sprintf("|MEMMAP:RAM|SCRBAL | $%04X-$%04X | 1 |", SCRBAL, SCRBAL) - -.out .sprintf("|MEMMAP:RAM|SCRBAH | $%04X-$%04X | 1 |", SCRBAH, SCRBAH) - - -.out .sprintf("|MEMMAP:RAM|SCRCT | $%04X-$%04X | 1 |", SCRCT, SCRCT) -.out .sprintf("|MEMMAP:RAM|SCRCF | $%04X-$%04X | 1 |", SCRCF, SCRCF) - - -.out .sprintf("|MEMMAP:RAM|FIXME | $%04X-$%04X | %d |", SCRCF+4,ADSCRH+4,KBDCOL-ADSCRH+4) - -.out .sprintf("|MEMMAP:RAM|FLGSCR | $%04X-$%04X | 4 |", FLGSCR,FLGSCR+4) ; $248 -.out .sprintf("|MEMMAP:RAM|CURSCR | $%04X-$%04X | 1 |", CURSCR,CURSCR+1) ; $248 - -.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", CURSCR+1,SCRTXT,SCRTXT-CURSCR+1) ; $248 - -.out .sprintf("|MEMMAP:RAM|SCRTXT | $%04X-$%04X | 4 |", SCRTXT,SCRHIR+4) ; $248 -.out .sprintf("|MEMMAP:RAM|SCRHIR (not used) | $%04X-$%04X | %d |", SCRHIR,SCRHIR+4,4) ; $248 - -.out .sprintf("|MEMMAP:RAM|SCRTRA | $%04X-$%04X | %d |", SCRTRA,SCRTRA+4,6) ; $248 - -.out .sprintf("|MEMMAP:RAM|KBDCOL | $%04X-$%04X | %d |", KBDCOL,KBDCOL+8,8) -.out .sprintf("|MEMMAP:RAM|KBDFLG_KEY | $%04X-$%04X | %d |", KBDFLG_KEY,KBDFLG_KEY+2,2) - -.out .sprintf("|MEMMAP:RAM|KBDVRR | $%04X-$%04X | %d |", KBDVRR,KBDVRR+1,1) -.out .sprintf("|MEMMAP:RAM|KBDVRL | $%04X-$%04X | %d |", KBDVRL,KBDVRL+2,2) -.out .sprintf("|MEMMAP:RAM|FLGKBD | $%04X-$%04X | %d |", FLGKBD,FLGKBD+1,1) - -.out .sprintf("|MEMMAP:RAM|KBDFCT | $%04X-$%04X | %d |", KBDFCT,KBDFCT+1,1) - -.out .sprintf("|MEMMAP:RAM|KBDSHT | $%04X-$%04X | %d |", KBDSHT,KBDSHT+1,1) - -.out .sprintf("|MEMMAP:RAM|KBDKEY | $%04X-$%04X | %d |", KBDKEY ,KBDKEY+5,1) - -.out .sprintf("|MEMMAP:RAM|KBDCTC | $%04X-$%04X | 2 |", KBDCTC,KBDCTC+1) - -.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", KBDCTC+1,KEYBOARD_COUNTER-1,KEYBOARD_COUNTER-KBDCTC) - -.out .sprintf("|MEMMAP:RAM|KEYBOARD_COUNTER | $%04X-$%04X | %d |", KEYBOARD_COUNTER, KEYBOARD_COUNTER+3,3) -.out .sprintf("|MEMMAP:RAM|HRSPAT | $%04X-$%04X | %d |", HRSPAT,HRSPAT,1) - -.out .sprintf("|MEMMAP:RAM|IOTAB | $%04X-$%04X | X |", IOTAB, IOTAB+KERNEL_SIZE_IOTAB-1) -.out .sprintf("|MEMMAP:RAM|KERNEL_ADIOB | $%04X-$%04X | %d |", KERNEL_ADIOB,KERNEL_ADIOB+ADIODB_LENGTH-1,KERNEL_ADIOB+ADIODB_LENGTH-KERNEL_ADIOB) - -.out .sprintf("|MEMMAP:RAM|kernel_malloc_free_chunk_size | $%04X-$%04X | %d |", kernel_malloc_free_chunk_size,kernel_malloc_free_chunk_size+.sizeof(kernel_malloc_free_chunk_size_struct)-1,.sizeof(kernel_malloc_free_chunk_size_struct)) - -.out .sprintf("|MEMMAP:RAM|kernel_xmalloc_call | $%04X-$%04X | %d |", kernel_xmalloc_call,kernel_xmalloc_call+XMALLOC_ROUTINE_TO_RAM_OVERLAY,kernel_xmalloc_call+XMALLOC_ROUTINE_TO_RAM_OVERLAY-kernel_xmalloc_call) - -.out .sprintf("|MEMMAP:RAM|FLGRST | $%04X-$%04X | %d |", FLGRST,FLGRST,1) -.out .sprintf("|MEMMAP:RAM|CSRND | $%04X-$%04X | %d |", CSRND,CSRND,1) - - -.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", KERNEL_ADIOB_END,FLGRST-1,FLGRST-KERNEL_ADIOB_END) - -.out .sprintf("|MEMMAP:RAM|VNMI | $%04X-$%04X | 3 |", VNMI,VNMI+3) - -.out .sprintf("|MEMMAP:RAM|ADIODB_VECTOR | $%04X-$%04X | %d |", ADIODB_VECTOR,ADIODB_VECTOR+3,3) - -.out .sprintf("|MEMMAP:RAM|IRQVECTOR | $%04X-$%04X | %d |", IRQVECTOR,IRQVECTOR+3,3) - -.out .sprintf("|MEMMAP:RAM|VAPLIC | $%04X-$%04X | %d |", VAPLIC,VAPLIC+3,3) - -.out .sprintf("|##MEMMAP: Page 3") -.out "|MEMMAP:Type | Name | Range | Size |" -.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" -.out .sprintf("|MEMMAP:IO |VIA1 | $0300-$030F | |") - -.out .sprintf("|##MEMMAP: Page 4") -.out "|MEMMAP:Type | Name | Range | Size |" -.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" -.out .sprintf("|MEMMAP:RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $%04X-$%04X | 3 |", ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY,ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY+3) -.out .sprintf("|MEMMAP:RAM|page4 overlay_access | $%04X-$%04X | %d |", $400+code_adress_419-code_adress_400,$400+code_adress_436-code_adress_400,code_adress_436-code_adress_400) - -.out .sprintf("|##MEMMAP: Page 5&6") -.out "|MEMMAP:Type | Name | Range | Size |" -.out "|MEMMAP: :------- |:----------------------------- |:----------- |:-----|" -.out .sprintf("|MEMMAP:RAM|FREE | $%04X-$%04X | %d |", BUFNOM, BUFNOM_END,BUFNOM_END-BUFNOM) -.out .sprintf("|MEMMAP:RAM|Malloc table | $%04X-$%04X | %d |", kernel_malloc,kernel_malloc_end,kernel_malloc_end-kernel_malloc) -.out .sprintf("|MEMMAP:RAM|main kernel process struct | $%04X-$%04X | %d |", kernel_process,kernel_process_end,kernel_process_end-kernel_process) - -.out .sprintf("|MEMMAP:RAM|BUFEDT | $%04X-$%04X | %d |", BUFEDT, BUFEDT_END,BUFEDT_END-BUFEDT) -.out .sprintf("|MEMMAP:RAM|KERNEL_MEMORY_DRIVER | $%04X-$%04X | %d |", KERNEL_DRIVER_MEMORY,KERNEL_DRIVER_MEMORY_END,KERNEL_DRIVER_MEMORY_END-KERNEL_DRIVER_MEMORY) - - -.out .sprintf("|##MEMMAP: Kernel bank 7") -.out "|MEMMAP: Type | Name | Range | Size |" -.out "|MEMMAP: :-------- |:---------------------------- |:------- |:-----|" - -.out .sprintf("|MEMMAP:ROM|FREE |$%x-$fff0| %d |", free_bytes,$fff0-free_bytes) - -.out .sprintf("|##MEMMAP: Bank 0") -.out "|MEMMAP: Type | Name | Range | Size |" -.out "|MEMMAP: -------- | ---------------------------- | ------- |-----|" -.out .sprintf("|MEMMAP:BANK0|BUFBUF | $%x-$%x | %d |", BUFBUF,BUFBUF+12*KERNEL_NUMBER_BUFFER,BUFBUF+12*KERNEL_NUMBER_BUFFER-BUFBUF) -.out .sprintf("|MEMMAP:BANK0|BUFROU | $%x-$%x | |", BUFROU,BUFROU+(end_BUFROU-data_to_define_4)) -.out .sprintf("|MEMMAP:BANK0|TELEMON_KEYBOARD_BUFFER_BEGIN | $%x-$%x | |", TELEMON_KEYBOARD_BUFFER_BEGIN,TELEMON_KEYBOARD_BUFFER_END) -.out .sprintf("|MEMMAP:BANK0|XMALLOC (copy from kernel) | $%x-$%x | |", ramoverlay_xmalloc,ramoverlay_xmalloc_end ) -.out .sprintf("|MEMMAP:BANK0|XFREE (copy from kernel) | $%x-$%x | |", ramoverlay_xfree,ramoverlay_xfree_end ) - - diff --git a/src/rom_cmd.s b/src/rom_cmd.s new file mode 100644 index 00000000..20d58805 --- /dev/null +++ b/src/rom_cmd.s @@ -0,0 +1,182 @@ +;---------------------------------------------------------------------- +; Number of commands +;---------------------------------------------------------------------- +.scope SDK_ROM + command_nb .set 0 + vectors_set .set 0 +.endscope + +;---------------------------------------------------------------------- +; +; usage: +; add_command "command_name"[, command_address] +; +; note: +; command_address defaults to command_name +; Ex: add_command "test" will use label test for command_address +; +; Add command_name to the rom +;---------------------------------------------------------------------- +.macro add_command command_name, address + + verbose 2, .sprintf("*** Add command: %s", command_name) + + .assert SDK_ROM::vectors_set = 0, ldwarning, .sprintf("Command '%s' defined after set_orix_vectors", command_name) + + .pushseg + + .segment "INSTRTBL" + .ident(.sprintf("%s_name",command_name)) := * + .asciiz command_name + + .segment "INSTRTBL2" + .word .ident(.sprintf("%s_name",command_name)) + + .if .not .xmatch({address}, NOOP) + .segment "INSTRJMP" + + .if .not .blank({address}) + .addr address + .else + .word .ident(command_name) + .endif + .endif + + SDK_ROM::command_nb .set SDK_ROM::command_nb+1 + + .popseg +.endmacro + + +;---------------------------------------------------------------------- +; +; usage: +; command "command_name" +; +; note: +; Open command scope, don't forget to use endcommand to close +; the scope +; +; Add command_name to the rom +;---------------------------------------------------------------------- +.macro command command_name + + verbose 2, .sprintf("*** Add command: %s", command_name) + + .assert SDK_ROM::vectors_set = 0, ldwarning, .sprintf("Command '%s' defined after set_orix_vectors", command_name) + + .pushseg + + .segment "INSTRTBL" + .ident(.sprintf("%s_name",command_name)) := * + .asciiz command_name + + .segment "INSTRTBL2" + .word .ident(.sprintf("%s_name",command_name)) + + .segment "INSTRJMP" + .word .ident(command_name) + + + SDK_ROM::command_nb .set SDK_ROM::command_nb+1 + + .popseg + + .proc .ident(command_name) +.endmacro + + +;---------------------------------------------------------------------- +; +; usage: +; endcommand +; +; Close command scope +;---------------------------------------------------------------------- +.macro endcommand + .endproc +.endmacro + + +;---------------------------------------------------------------------- +; +; usage: +; set_orix_vectors rom_type, parse_vector, signature +; +; note: +; signature: may be "string" or label +; if signature is a "string", this macro create new label rom_signaure +; +; Set orix rom vectors +;---------------------------------------------------------------------- +.macro set_orix_vectors rom_type, parse_vector, signature + .local _signature + + .pushseg + + ;.import __INSTRJMP_LOAD__ + ;.import __INSTRTBL_LOAD__ + + .if .match(signature,"") + .segment "SIGNATURE" + .import __SIGNATURE_LOAD__ + + ; A voir si dans ce cas on doit définir le label "rom_signature" ou non + ; .ident(.sprintf("rom_signature")) := * + + _signature := __SIGNATURE_LOAD__ + .asciiz signature + .else + _signature := signature + .endif + + .segment "ORIXVECT" + .byte rom_type + .addr parse_vector + .addr parse_vector + .addr parse_vector + .byte SDK_ROM::command_nb + .word _signature + + .popseg + + SDK_ROM::vectors_set .set 1 + + verbose 1, .sprintf("*** Bank name: %s", signature) + verbose 1, .sprintf("*** Commands : %d", SDK_ROM::command_nb) + + ;.assert SDK_ROM::command_nb > 0, warning, "No command defined" + +.endmacro + + +;---------------------------------------------------------------------- +; +; usage: +; set_cpu_vectors nmi, reset, irq +; +; Set 6502 vectors +;---------------------------------------------------------------------- +.macro set_cpu_vectors nmi, reset, irq + .pushseg + + .segment "CPUVECT" + .addr nmi + .addr reset + .addr irq + + .popseg +.endmacro + +; ---------------------------------------------------------------------------- +; verbose level, string +; ---------------------------------------------------------------------------- +; Affiche un message si level <= VERBOSE_LEVEL +; ---------------------------------------------------------------------------- +.macro verbose level, string + .ifdef VERBOSE_LEVEL + .if level <= ::VERBOSE_LEVEL + .out string + .endif + .endif +.endmacro diff --git a/src/versions/versions.inc b/src/versions/versions.inc index 851348ad..3c25fa55 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_3 $07 -.define CURRENT_VERSION_BINARY KERNEL_VERSION_2024_1 +.define CURRENT_VERSION_BINARY KERNEL_VERSION_2025_3 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/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 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..9254dd13 --- /dev/null +++ b/tests/functions/network/netchk.s @@ -0,0 +1,483 @@ +; 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 + nop + ; 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 + +nop + +@fully_started: + crlf + print str_fully_started + crlf + rts + +@disconnected: + print str_cable_disconnected + crlf + rts + +@connected: + print str_cable_connected + crlf + print str_starting_dhcp + jmp @start + +@dhcp_starting: + print #'.' + jmp @start + +@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: + ;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 + + +; .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 + nop + 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 213,186,33,19 + .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 "Dhcp Started !" + +str_starting_dhcp: + .asciiz "Starting dhcp" + +str_fully_started: + .asciiz "Fully Started" + +str_cable_disconnected: + .asciiz "Cable disconnected" + +str_cable_connected: + .asciiz "Cable connected" +nop + + ; 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/unit_test/mainarg.s b/tests/unit_test/mainarg.s new file mode 100644 index 00000000..09f8fa58 --- /dev/null +++ b/tests/unit_test/mainarg.s @@ -0,0 +1,58 @@ +; Code to test XMAINARGS + +.include "telestrat.inc" +.include "../../dependencies/orix-sdk/macros/SDK_mainargs.mac" +.include "../../dependencies/orix-sdk/macros/SDK_print.mac" +.include "../../dependencies/orix-sdk/macros/SDK_conio.mac" + +.segment "STARTUP" +.segment "INIT" +.segment "ONCE" + +.segment "CODE" +_main: + +userzp := $80 + +start_adress: + argv := userzp ; 2 bytes + argc := userzp + 2 ; 1 byte + + initmainargs argv, argc, 0 + +nop + lda argc + cmp #$03 + bne @no_arg +nop +nop + +nop + +nop + getmainarg #1, (argv) + BRK_TELEMON XWSTR0 + crlf +nop +nop + +nop + +nop + getmainarg #2, (argv) + BRK_TELEMON XWSTR0 + crlf + + rts +nop +@no_arg: + print str_there_not_two_arg + lda #$01 + ldy #$00 + rts + +str_there_not_two_arg: + .asciiz "There is not 2 arg" + + + lda #$41 \ No newline at end of file diff --git a/tests/unit_test/mainarg.sub b/tests/unit_test/mainarg.sub new file mode 100644 index 00000000..f14fd4d0 --- /dev/null +++ b/tests/unit_test/mainarg.sub @@ -0,0 +1,4 @@ +#!/bin/submit +echo Mainarg test +mainarg ici "part1 part2" +#on error echo error diff --git a/tests/unit_test/start.sub b/tests/unit_test/start.sub new file mode 100644 index 00000000..8f70d0ce --- /dev/null +++ b/tests/unit_test/start.sub @@ -0,0 +1,8 @@ +#!/bin/submit +echo start + +netchk + + +#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] - - - - - 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 + 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