Compare commits

..
Author SHA1 Message Date
t3hn3rd 91cd005361 feat: integrate Wasuro WASM runtime into Asuro build chain
continuous-integration/drone/push Build is failing
- Add compile_wasuro.sh to sparse-clone Wasuro src/wasm from gitea
  (develop branch) with caching to skip redundant pulls
- Update compile.sh to include wasuro build step in pipeline
- Update compile_sources.sh to dynamically discover -Fu paths via
  find across src/ and wasuro/ directories
- Extend system.pas with FPC 3.2.2 compilerprocs required by Wasuro:
  - 64-bit signed/unsigned div and mod (fpc_div_int64, fpc_mod_int64,
    fpc_div_qword, fpc_mod_qword) with correct i386 parameter mapping
  - 64-bit multiply (fpc_mul_int64) via three 32-bit MUL instructions
  - Float-to-integer intrinsics (Trunc, Round) using x87 FPU
  - Memory allocation compilerprocs (fpc_getmem, fpc_freemem)
    delegating to kernel kalloc/kfree
  - Exception handling stubs (reraise, raiseexception, catches, doneexception)
  - setjmp/longjmp for exception address stack
  - Fix sInt64 type alias (was longint/32-bit, now int64/64-bit)
  - Add serial debug helpers (COM1 $3F8) for bare-metal tracing
- Wire up Wasuro in kernel.pas: init WASM VM, set I/O callback to
  syslog, and run all 1103 Wasuro tests (0 failures)
- Update .gitignore to exclude wasuro/ cache directory
2026-03-03 23:20:02 +00:00
t3hn3rd 99fd5507ca Merge branch 'feature/vtop-fix' into feature/process-management
continuous-integration/drone/push Build is passing
2026-03-03 19:11:47 +00:00
t3hn3rd 035d489c4f feature: preemptive process management - implementation progress
continuous-integration/drone/push Build is passing
Implement a preemptive multitasking system for the Asuro kernel.

Context Switching & Scheduling:
- Custom IRQ0 ISR (contextswitcher.pas) with PUSHAD/POPAD ESP-swap
- Round-robin scheduler with priority-based quantum
- Process table using DList of PProcessContext pointers
- Idle process (PID 0) replaces kernel HLT loop

Process Lifecycle:
- create/kill/terminate/sendMessage API (processmanager.pas)
- Process states: Created, Running, Ready, Suspended, Awaiting,
  Finished, Error
- Parent-child tracking (ParentID, smChildExited notification on reap)
- proc_yield, proc_sleep_ms, proc_await, proc_suspend, proc_exit

Resource Binding & Cleanup:
- Per-process resource list
  (bindResource/unbindResource/unbindAllResources)
- TCP sockets auto-bound to owning process (OwnerPID on TTCPSocket)
- socket_cleanup + auto-unbind in DestroySocket

VTerminal Refactor:
- Multi-instance design (heap-allocated TVTermState per terminal)
- Foreground process with incremental stdout/stderr drain via LVGL timer
- Ctrl+C kills foreground process (killForeground)
- Per-terminal CWD, dir stack, FS builtins (CD/LS/PUSHD/POPD)
- Background job support (& suffix, JOBS/FG commands)
- Command history (Up/Down arrow)

Command Consolidation:
- 14 commands extracted from 9 units into centralized progmanager.pas
- Command procedures exported in host unit interfaces
- E1000/TRACER/stdio builtins kept in-place (conditional/circular)

New Units:
- src/include/proctypes.pas — process type definitions
- src/processmanager.pas — core process manager
- src/prog/ping.pas — standalone ICMP ping process
- src/prog/testcmd.pas — test command (proc_sleep_ms demo)
- src/testprocs.pas — process subsystem smoke tests

Misc:
- ICMP callbacks gain userData parameter for concurrency-safe ping
- CLI/STI guards on kalloc/kfree (lmemorymanager.pas)
- LV_KEY_CTRLC constant + Ctrl+C interception in LVGL keyboard hook
- Window owner PID tracking (windows.pas)
- ISR_32 gate override support (isrmanager.pas)
2026-03-03 19:02:21 +00:00
t3hn3rd 5e9d0004d7 feature: implement TCP (RFC 793) protocol driver
continuous-integration/drone/push Build is passing
Add full TCP/IP stack implementation at L4 alongside UDP and ICMP.

Core Protocol Engine:
- TCP types in nettypes.pas (header, TCB, state enum, error codes,
  callbacks, OOO entry, socket structures)
- 3-way handshake (active & passive OPEN)
- Reliable data transfer with ACK and sequence number tracking
- Graceful close (FIN_WAIT, CLOSE_WAIT, LAST_ACK, TIME_WAIT)
- RST send/receive handling
- Retransmission with exponential backoff (max 5 attempts)
- Pseudo-header based checksum (RFC 793)

Server Support:
- LISTEN → SYN_RECEIVED → ESTABLISHED passive open path
- Listen backlog enforcement (configurable per-socket)
- accept() to retrieve established child connections

Robustness & Hardening:
- Delayed ACK timer (~200ms)
- Nagle's algorithm (buffer small sends while unACKed data pending)
- Jacobson/Karels RTT estimation with adaptive RTO
- Congestion control (slow start / congestion avoidance)
- Zero-window probing with exponential backoff
- MSS option negotiation in SYN/SYN-ACK (Kind=2, Len=4)
- Keep-alive (30s idle, 10s interval, 5 probes)
- Out-of-order segment reassembly (4-slot buffer)

Terminal & Testing:
- tcpconnect: active open + send "Hello, World!"
- tcplisten: passive open with syslog output
- tcphttp: HTTP/1.0 GET client

Also add push_trace() instrumentation to net, eth2, arp, ipv4,
icmp, udp, and dhcp entry points for call tracing, and register
tcp in net.init.
2026-03-03 10:55:50 +00:00
232 changed files with 8681 additions and 34452 deletions

No files matched your search

+2 -2
View File
@@ -22,8 +22,8 @@ steps:
commands: commands:
- git fetch --tags - git fetch --tags
- find . -type f -print0 | xargs -0 dos2unix - find . -type f -print0 | xargs -0 dos2unix
- chmod +x /drone/src/toolchain/*.sh - chmod +x /drone/src/*.sh
- /drone/src/toolchain/compile.sh - /drone/src/compile.sh
- name: upload-iso-artifact - name: upload-iso-artifact
image: alpine/git image: alpine/git
-2
View File
@@ -14,8 +14,6 @@ localenv.json
/lvgl/ /lvgl/
dockerout.txt dockerout.txt
AGENTS.md AGENTS.md
lessons_learnt.md
*.log *.log
/doc/*.md /doc/*.md
wasuro wasuro
src/core/core.version.pas
+2 -1
View File
@@ -14,9 +14,10 @@ RUN curl -sL https://sourceforge.net/projects/freepascal/files/Linux/$FPC_VERSIO
pushd fpc-$FPC_VERSION.i386-linux && ./install.sh && popd && \ pushd fpc-$FPC_VERSION.i386-linux && ./install.sh && popd && \
rm -rf fpc-$FPC_VERSION.i386-linux rm -rf fpc-$FPC_VERSION.i386-linux
COPY compile.sh /compile.sh
ADD https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver /usr/bin/semver ADD https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver /usr/bin/semver
RUN chmod +x /usr/bin/semver RUN chmod +x /usr/bin/semver
WORKDIR /code WORKDIR /code
RUN find . -type f -print0 | xargs -0 dos2unix RUN find . -type f -print0 | xargs -0 dos2unix
ENTRYPOINT ["/bin/bash", "-c"] ENTRYPOINT ["/bin/bash", "-c"]
CMD ["find toolchain -name '*.sh' -exec dos2unix {} + 2>/dev/null; find toolchain -name '*.sh' -exec chmod +x {} +; bash toolchain/compile.sh"] CMD ["/compile.sh"]
-75
View File
@@ -1,75 +0,0 @@
{ Compatibility shim: wasuro references the old unit name 'lmemorymanager'.
Since wasuro/ cannot be modified, this unit re-exports the public API of
memory.heap so that 'uses lmemorymanager' continues to compile. }
unit lmemorymanager;
interface
uses
memory.heap;
const
ALLOC_UNIT = memory.heap.ALLOC_UNIT;
DATA_OFFSET = memory.heap.DATA_OFFSET;
PAGE_SIZE_LMM = memory.heap.PAGE_SIZE_LMM;
TOTAL_UNITS = memory.heap.TOTAL_UNITS;
BITMAP_DWORDS = memory.heap.BITMAP_DWORDS;
SIZE_PREFIX = memory.heap.SIZE_PREFIX;
LARGE_ALLOC_MAGIC = memory.heap.LARGE_ALLOC_MAGIC;
type
PHeapPageHeader = memory.heap.PHeapPageHeader;
THeapPageHeader = memory.heap.THeapPageHeader;
procedure init;
function kalloc(size : uint32) : void;
function klalloc(size : uint32) : void;
procedure klfree(address : uint32);
function kpalloc(address : uint32) : void;
procedure kfree(area : void);
function lmm_total_free : uint32;
function lmm_page_count : uint32;
implementation
procedure init;
begin
memory.heap.init;
end;
function kalloc(size : uint32) : void; inline;
begin
kalloc := memory.heap.kalloc(size);
end;
function klalloc(size : uint32) : void; inline;
begin
klalloc := memory.heap.klalloc(size);
end;
procedure klfree(address : uint32); inline;
begin
memory.heap.klfree(address);
end;
function kpalloc(address : uint32) : void; inline;
begin
kpalloc := memory.heap.kpalloc(address);
end;
procedure kfree(area : void); inline;
begin
memory.heap.kfree(area);
end;
function lmm_total_free : uint32; inline;
begin
lmm_total_free := memory.heap.lmm_total_free;
end;
function lmm_page_count : uint32; inline;
begin
lmm_page_count := memory.heap.lmm_page_count;
end;
end.
-7
View File
@@ -1,7 +0,0 @@
unit types;
interface
implementation
end.
+3 -5
View File
@@ -20,8 +20,6 @@ runOrFail() {
fi fi
} }
TOOLCHAIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
declare -a run_steps=( declare -a run_steps=(
"compile_stub.sh" "Failed to compile stub!" "compile_stub.sh" "Failed to compile stub!"
"compile_vergen.sh" "Versions failed to compile" "compile_vergen.sh" "Versions failed to compile"
@@ -36,7 +34,7 @@ for ((i=0; i<${#run_steps[@]}; i+=2))
do do
if [ "$ERRCOUNT" -eq "0" ] if [ "$ERRCOUNT" -eq "0" ]
then then
script="${TOOLCHAIN_DIR}/${run_steps[$i]}" script=$(pwd)/"${run_steps[$i]}"
message="${run_steps[$i+1]}" message="${run_steps[$i+1]}"
runOrFail "$script" "$message" runOrFail "$script" "$message"
fi fi
@@ -45,9 +43,9 @@ done
#Call generate final artifacts based on failure or success of the above. #Call generate final artifacts based on failure or success of the above.
if [ "$ERRCOUNT" -ne "0" ] if [ "$ERRCOUNT" -ne "0" ]
then then
. "${TOOLCHAIN_DIR}/compile_finish.sh" "failed" . ./compile_finish.sh "failed"
else else
. "${TOOLCHAIN_DIR}/compile_finish.sh" "success" . ./compile_finish.sh "success"
fi fi
cd .. cd ..
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -19,4 +19,4 @@ echo " "
LIBGCC=$(gcc -m32 -print-libgcc-file-name) LIBGCC=$(gcc -m32 -print-libgcc-file-name)
echo "libgcc: ${LIBGCC}" echo "libgcc: ${LIBGCC}"
ld -m elf_i386 -s --gc-sections -Ttoolchain/linker.script -o bin/kernel.bin $objstring --start-group lib/liblvgl.a ${LIBGCC} --end-group ld -m elf_i386 -s --gc-sections -Tlinker.script -o bin/kernel.bin $objstring --start-group lib/liblvgl.a ${LIBGCC} --end-group
+7 -21
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# compile_lvgl.sh — Download LVGL v9.2 source and compile into lib/liblvgl.a # compile_lvgl.sh — Download LVGL v9.2 source and compile into lib/liblvgl.a
# Clone & compile in /tmp (fast container-local fs). # Clone & compile in /tmp (fast container-local fs).
# Cache liblvgl.a on host mount (/code/lvgl/) to skip rebuild. # Copy source + objects to /lvgl (host mount) for debugging.
set -e set -e
LVGL_VERSION="v9.2.2" LVGL_VERSION="v9.2.2"
@@ -10,7 +10,6 @@ LVGL_DIR="/tmp/lvgl"
OBJ_DIR="/tmp/lvgl_obj" OBJ_DIR="/tmp/lvgl_obj"
CONF_DIR="$(pwd)/lvglh" CONF_DIR="$(pwd)/lvglh"
OUT_DIR="$(pwd)/lib" OUT_DIR="$(pwd)/lib"
CACHE_DIR="/code/lvgl"
CC="gcc" CC="gcc"
CFLAGS="-m32 -march=i686 -ffreestanding \ CFLAGS="-m32 -march=i686 -ffreestanding \
@@ -27,17 +26,6 @@ echo " "
echo "Compiling LVGL..." echo "Compiling LVGL..."
echo " " echo " "
# If cached liblvgl.a exists on host mount, just copy it and skip everything
if [ -f "${CACHE_DIR}/liblvgl.a" ]; then
echo "Found cached liblvgl.a in ${CACHE_DIR}, copying to ${OUT_DIR}..."
cp "${CACHE_DIR}/liblvgl.a" "${OUT_DIR}/liblvgl.a"
echo "(Delete lvgl/liblvgl.a to force a full rebuild.)"
echo " "
echo "LVGL compilation complete (cached)."
echo " "
exit 0
fi
# Clone LVGL into /tmp (container-local) # Clone LVGL into /tmp (container-local)
rm -rf "$LVGL_DIR" rm -rf "$LVGL_DIR"
echo "Downloading LVGL ${LVGL_VERSION}..." echo "Downloading LVGL ${LVGL_VERSION}..."
@@ -117,14 +105,12 @@ else
echo "No custom LVGL files in lvglh/." echo "No custom LVGL files in lvglh/."
fi fi
# Cache liblvgl.a and source to host mount for next build # Copy source + objects to /lvgl host mount for debugging
echo "Caching LVGL to host mount..." echo "Copying LVGL source and objects to host mount..."
mkdir -p "$CACHE_DIR" mkdir /code/lvgl 2>/dev/null || true
rm -rf ${CACHE_DIR}/* ${CACHE_DIR}/.[!.]* ${CACHE_DIR}/..?* 2>/dev/null || true rm -rf /code/lvgl/* /code/lvgl/.[!.]* /code/lvgl/..?* 2>/dev/null || true
cp "${OUT_DIR}/liblvgl.a" "${CACHE_DIR}/liblvgl.a" cp -a "$LVGL_DIR/src" /code/lvgl/src
cp -a "$LVGL_DIR/src" "${CACHE_DIR}/src" cp -a "$OBJ_DIR" /code/lvgl/obj
cp -a "$LVGL_DIR"/*.h "${CACHE_DIR}/" 2>/dev/null || true
cp -a "$OBJ_DIR" "${CACHE_DIR}/obj"
echo "Done." echo "Done."
echo " " echo " "
File renamed without changes.
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
echo " "
echo "======================="
echo " "
echo "Compiling FPC Sources..."
echo " "
# Build -Fu flags for all directories under src/ and wasuro/
FU_PATHS=""
for dir in $(find src wasuro -type d 2>/dev/null); do
FU_PATHS="$FU_PATHS -Fu$dir"
done
fpc -Aelf -gw -g -gl -n -v0ew -O3 -OpPENTIUM3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ $FU_PATHS src/kernel.pas
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
echo " "
echo "======================="
echo " "
echo "Compiling Stub..."
echo " "
nasm -f elf src/stub/stub.asm -o lib/stub.o
File renamed without changes.
@@ -1,15 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TOOLCHAIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo " " echo " "
echo "=======================" echo "======================="
echo " " echo " "
echo "Generating Versioning Info..." echo "Generating Versioning Info..."
echo " " echo " "
chmod +x "${TOOLCHAIN_DIR}/compile_checksum.sh" chmod +x ./compile_checksum.sh
"${TOOLCHAIN_DIR}/compile_checksum.sh" ./compile_checksum.sh
outfile="src/core/core.version.pas" outfile="src/include/asuro.pas"
file="toolchain/version" file="version"
{ {
# this script requires semver tool # this script requires semver tool
wget -q https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver -O bin/semver && chmod +x bin/semver wget -q https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver -O bin/semver && chmod +x bin/semver
@@ -23,7 +22,7 @@ sub=$(semver get patch $tagref)
version=$(semver get release $tagref) version=$(semver get release $tagref)
release=$(semver get prerel $tagref) release=$(semver get prerel $tagref)
build=$(semver get build $tagref) build=$(semver get build $tagref)
linecount=$("${TOOLCHAIN_DIR}/loc.sh" | awk '{print $1}') linecount=$(./loc.sh | awk '{print $1}')
sourcecount=$(find src -type f | wc -l) sourcecount=$(find src -type f | wc -l)
drivercount=$(find src/driver -type f | wc -l) drivercount=$(find src/driver -type f | wc -l)
fpcversion=$(fpc -h | grep -m 1 version | awk '{print $5}') fpcversion=$(fpc -h | grep -m 1 version | awk '{print $5}')
@@ -35,7 +34,7 @@ checksum=$(md5sum checksums.md5 | awk '{print $1}')
[[ -n "$release" ]] && version="$version-$release" [[ -n "$release" ]] && version="$version-$release"
cat > $outfile <<EOF cat > $outfile <<EOF
unit core.version; unit asuro;
interface interface
@@ -1,13 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# compile_wasuro.sh — Pull Wasuro WASM runtime source into wasuro/ # compile_wasuro.sh — Pull Wasuro WASM runtime source into /wasuro
# Clones the repo (sparse, src/wasm only) and copies the Pascal sources # Clones the repo (sparse, src/wasm only) and copies the Pascal sources
# into $PWD/wasuro so the FPC build can reference them via -Fu. # into /code/wasuro so the FPC build can reference them via -Fu.
set -e set -e
WASURO_REPO="https://gitea.spexeah.com/Spexeah/Wasuro.git" WASURO_REPO="https://gitea.spexeah.com/Spexeah/Wasuro.git"
WASURO_BRANCH="develop" WASURO_BRANCH="develop"
WASURO_TMP="/tmp/wasuro" WASURO_TMP="/tmp/wasuro"
WASURO_OUT="$(pwd)/wasuro" WASURO_OUT="/code/wasuro"
echo " " echo " "
echo "=======================" echo "======================="
@@ -28,7 +28,7 @@ git clone --depth 1 --branch "${WASURO_BRANCH}" --filter=blob:none --sparse \
"${WASURO_REPO}" "${WASURO_TMP}" 2>&1 "${WASURO_REPO}" "${WASURO_TMP}" 2>&1
cd "$WASURO_TMP" cd "$WASURO_TMP"
git sparse-checkout set src/wasm 2>&1 git sparse-checkout set src/wasm 2>&1
cd - cd /code
echo "Copying src/wasm to ${WASURO_OUT}..." echo "Copying src/wasm to ${WASURO_OUT}..."
rm -rf "$WASURO_OUT" rm -rf "$WASURO_OUT"
-32
View File
@@ -1,32 +0,0 @@
#Flat filesystem
A super simple filesystem for asuro. Folders are emulated in filenames.
Starts with disk info sector, sector 0 of volume
---
#### disk info
jmp2boot : ubit24;
OEMName : array[0..7] of char;
version : uint16 // numerical version of filesystem
sectorCount : uint16;
fileCount : uint16
signature : uint32 = 0x0B00B1E5
the Rest of the sector is reserved
---
Starting from sector 1 is the file table. Table size is determined by entry size (64) * fileCount
---
####File entry
name : array[0..59] of char //file name max 60 chars
fileStart : 16bit // start sector of data
fileSize : 16bit // data size in sectors
---
-648
View File
File diff suppressed because it is too large. Load diff
Loaded 20 of 232 files, more files were not shown because too many files have changed in this diff. Show more