t3hn3rd
fc080027b2
Merge branch 'feature/memory-allocation-optimization' into feature/process-management
...
# Conflicts:
# src/kernel.pas
# src/lmemorymanager.pas
# src/progmanager.pas
2026-03-04 11:36:17 +00:00
t3hn3rd
8b4335768b
refactor(memory): complete PMM/VMM/LMM rewrite - bitmap allocators, bug fixes, hardening
...
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
PMM Rewrite:
- Replace ~8KB record array with compact bitmaps
(PhysPresent/PhysAlloc/PhysScanned, 128B each)
- Add PhysOwner[0..1023] for per-block ownership tracking
- new_block: O(1) amortised via NextFreeHint + dword-level BSF scan,
returns 0 as OOM sentinel
- free_block: O(1) direct bit clear with double-free detection
- alloc_block: validates PhysPresent and PhysAlloc bits before allocation
- Add pmm_free_blocks/pmm_total_blocks stats functions
VMM Correctness Fixes:
- Fix free_page block extraction (Address SHR 10, was using
raw Address field)
- Fix invlpg operand (use virtual address, was passing PDE index)
- Clear PDE entry on free_page before returning block to PMM
- Remove map_page double-write (delegate to map_page_ex only)
- Add OOM propagation (new_page returns false if PMM returns 0)
- Fix missing pop_trace in new_page error path
LMM Rewrite:
- Replace per-entry record array with bitmap allocator
(93% vs 43% page efficiency)
- Layout: Header(24B) + Bitmap(64512B) + Padding + Data at 0x10000
- SIZE_PREFIX=16 for 16-byte aligned returns (SSE MOVAPS requirement)
- Next-fit bitmap scan with roving hint (NextFree) and dword-level
fast skip
- Large alloc sentinel (LARGE_ALLOC_MAGIC=$FFFFFFFE) so kfree detects
klalloc'd memory
- Implement klfree (was previously a no-op - pages could never
be returned)
- Implement try_release_page (return fully-free heap pages to VMM/PMM)
- Fix interrupt safety: stack-balanced pushfd/cli/pop +
restore_if (sti only)
Fixes Bad TSS caused by popfd restoring dangerous EFLAGS bits (NT, IOPL)
- Zero memory via rep stosd instead of byte-by-byte loop
Hardening:
- kalloc OOM now triggers BSOD instead of returning nil
(90% of callers don't check)
- Double-free detection in kfree (verify bitmap bits set before clearing)
- Guard bytes ({$IFDEF DEBUG_LMM}): $DEADBEEF sentinel for buffer overrun detection
- kpalloc: bounds check (block >= 1024 -> GPF) + syslog MMIO mapping audit log
Observability:
- Add MEMINFO command as src/prog/meminfo.pas (moved from inline kernel.pas)
- Displays multiboot memory, PMM block stats, LMM heap stats
- Register via progmanager.pas following standard prog pattern
Files changed:
- src/pmemorymanager.pas
- src/vmemorymanager.pas
- src/lmemorymanager.pas
- src/kernel.pas
- src/progmanager.pas
- src/prog/meminfo.pas
2026-03-04 10:36:09 +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
cb7144f282
USB Stack & HID Refactor
...
- New units: usbtypes, usbcore, usbhub, UHCI, OHCI, usb_keyboard,
usb_mouse
- usbtypes: shared USB descriptors, constants, HC abstraction,
aligned alloc, unit tests
- usb_keyboard: USB HID boot keyboard driver with HID-to-ASCII
translation, polling, unit tests
- usb_mouse: USB HID boot mouse driver with delta/scroll/button
processing, polling, unit tests
HID Layer Restructure:
- keyboard.pas: stripped to abstract API (hook + reportKeyEvent),
no PS/2 dependency
- mouse.pas: absorbed mousestate.pas, now owns
position/buttons/scroll/hooks directly
- mousestate.pas: deleted (merged into mouse.pas)
- New ps2_keyboard.pas: PS/2 scan code translation,
calls keyboard.reportKeyEvent
- New ps2_mouse.pas: PS/2 packet handling, calls
mouse.setMousePos/fireMouseEvent
LVGL Integration:
- lvgl.pas: updated to use mouse.pas directly (was mousestate),
improved keyboard input handling with proper key held/release tracking
- vterminal.pas: removed serial debug logging, dropped serial dependency
Kernel:
- kernel.pas: added USB units, USB polling in main loop, unit test
calls, ps2_keyboard/ps2_mouse init
2026-03-01 21:23:33 +00:00
t3hn3rd
f752be48ce
refactor/feature/fix: Major refactor of codebase
...
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
refactor(stdio): replace console/terminal command system with buffer-based stdio
- Introduced stdio.pas as the unified command I/O layer.
- All 31 command procedures across 15 files now receive stdin_buf,
stdout_buf, and stderr_buf (POutBuf) instead of a single outbuf.
- vterminal.pas creates all three buffers per command invocation and
displays both stdout and stderr.
- Deleted console.pas, terminal.pas, and 9 obsolete windowing programs
(shell, splash, edit, memview, themer, netlog, vmlog, vmstate, udpcat).
- Migrated all registerCommand calls to stdio, rewrote vterminal
processCommand to use stdio.findCommand, and added proper error
routing to stderr for invalid params, bad paths, and system errors.
refactor(syslog): replace console logging with serial-backed syslog
- Introduced syslog.pas for kernel-level logging over serial/dev.
- Migrated all boot logging in kernel.pas from console.outputln/
writestringln to syslog.logln/writestringln.
- Converted 19 fault handlers, hashmap, lists, scheduler, tracer, net,
udp, and all driver init paths to use syslog.
- Rewrote BSOD in util.pas (50+ calls) from console to syslog.
- Removed CONSOLE_SLOW_REDRAW, TRGB565, TRGB565Pair, and HWND
from system.pas.
fix(keyboard): add ring buffer and proper press/release cycling for LVGL input
- Replaced the single last_key/key_pressed slot in lvgl.pas with a
16-entry ring buffer (kb_buf, kb_head, kb_tail) to prevent ISR
overwrites when typing fast.
- Added a kb_pending_release flag so each keystroke gets a
full PRESSED->RELEASED cycle before the next key is consumed —
LVGL requires this pairing and was silently dropping intermediate
keys when receiving consecutive PRESSED events without
intervening releases.
feat(vterminal): use Hack monospace font for terminal output
- Added Hack Regular 14px (hack_14.c) as a custom LVGL font.
- Removed the .static_bitmap field from the generated font file
(not present in LVGL 9.2 lv_font_t struct).
- Declared the hack_14 external symbol in lvgl.pas and switched
vterminal's text label from lv_font_montserrat_14 to hack_14
for proper monospace terminal rendering.
2026-03-01 02:06:31 +00:00
t3hn3rd
98a14bc7dc
More work towards LVGL implementation
continuous-integration/drone/push Build is failing
2026-02-27 22:43:02 +00:00
t3hn3rd
64b3c9a7ba
Apache License
...
Added the apache license to all source files, accounting for authors. Also added a license.md containing the apache license + contributors.md listing all contributors.
2021-06-22 21:31:17 +01:00
kieron
6b6129b769
Added VFS
...
git-svn-id: https://spexeah.com:8443/svn/Asuro@1318 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2020-07-18 21:00:31 +00:00
aaron
d4234225d1
Started rewrite of storage system.
...
git-svn-id: https://spexeah.com:8443/svn/Asuro@1299 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2020-07-17 22:30:36 +00:00
kieron
a7ee8c6d34
Hashmap added.
...
git-svn-id: https://spexeah.com:8443/svn/Asuro@1235 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2020-07-15 23:03:32 +00:00
kieron
7a48111bf3
git-svn-id: https://spexeah.com:8443/svn/Asuro@1035 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2020-07-12 17:02:35 +00:00
kieron
fbc59a1617
DHCP Works now.
...
git-svn-id: https://spexeah.com:8443/svn/Asuro@1034 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2020-07-12 17:02:14 +00:00
goose
8b3d59918d
Addition of base64 module and prog
...
git-svn-id: https://spexeah.com:8443/svn/Asuro@975 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2020-07-11 18:51:52 +00:00
kieron
739898068b
md5 complete + md5sum added as a prog.
...
git-svn-id: https://spexeah.com:8443/svn/Asuro@971 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2020-07-11 00:44:05 +00:00
kieron
5d26e199aa
git-svn-id: https://spexeah.com:8443/svn/Asuro@918 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2020-07-09 21:06:52 +00:00
kieron
b60870984b
git-svn-id: https://spexeah.com:8443/svn/Asuro@874 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2020-07-08 22:02:42 +00:00
aaron
f0e013db2e
git-svn-id: https://spexeah.com:8443/svn/Asuro@762 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2019-01-25 15:32:18 +00:00
kieron
db58264fa6
Comments now conform to PasDoc specifications.
...
git-svn-id: https://spexeah.com:8443/svn/Asuro@749 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-10-12 20:49:03 +00:00
kieron
877ef01b80
git-svn-id: https://spexeah.com:8443/svn/Asuro@748 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-09-29 14:32:04 +00:00
kieron
0c939b8b31
git-svn-id: https://spexeah.com:8443/svn/Asuro@747 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-09-29 12:50:40 +00:00
kieron
8066634367
git-svn-id: https://spexeah.com:8443/svn/Asuro@746 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-22 03:33:51 +00:00
kieron
17f41d9794
git-svn-id: https://spexeah.com:8443/svn/Asuro@744 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-13 19:43:43 +00:00
kieron
beb04a225a
git-svn-id: https://spexeah.com:8443/svn/Asuro@733 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-13 10:35:04 +00:00
kieron
7e293e683b
git-svn-id: https://spexeah.com:8443/svn/Asuro@731 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-12 20:25:42 +00:00
kieron
fabe8bd6eb
git-svn-id: https://spexeah.com:8443/svn/Asuro@677 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-10 07:39:07 +00:00
kieron
1615e6781a
git-svn-id: https://spexeah.com:8443/svn/Asuro@670 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-07 21:47:59 +00:00
kieron
b9d6225cb8
git-svn-id: https://spexeah.com:8443/svn/Asuro@668 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-06 05:58:03 +00:00
kieron
fee4e4d759
git-svn-id: https://spexeah.com:8443/svn/Asuro@667 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-05 23:39:12 +00:00
kieron
cac366e78c
git-svn-id: https://spexeah.com:8443/svn/Asuro@664 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-05 21:04:48 +00:00
kieron
e5321d8b46
git-svn-id: https://spexeah.com:8443/svn/Asuro@663 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-05 19:57:37 +00:00
kieron
80ffb9a60b
git-svn-id: https://spexeah.com:8443/svn/Asuro@658 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-04 00:10:05 +00:00
kieron
0406efe0ec
git-svn-id: https://spexeah.com:8443/svn/Asuro@657 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-04 00:08:21 +00:00
kieron
6ae51ac70d
git-svn-id: https://spexeah.com:8443/svn/Asuro@654 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-03 23:16:37 +00:00
kieron
a5bae52f09
git-svn-id: https://spexeah.com:8443/svn/Asuro@653 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-03 01:45:14 +00:00
kieron
b42c7641e6
git-svn-id: https://spexeah.com:8443/svn/Asuro@651 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-02 17:17:58 +00:00
kieron
191f0a8159
git-svn-id: https://spexeah.com:8443/svn/Asuro@650 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-01 21:31:07 +00:00
kieron
9915c45e00
git-svn-id: https://spexeah.com:8443/svn/Asuro@649 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-01 20:45:42 +00:00
kieron
de17203bf7
git-svn-id: https://spexeah.com:8443/svn/Asuro@648 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-01 20:40:43 +00:00
kieron
7197be24e8
git-svn-id: https://spexeah.com:8443/svn/Asuro@647 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-01 20:20:34 +00:00
kieron
96025771fe
git-svn-id: https://spexeah.com:8443/svn/Asuro@646 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-01 20:14:38 +00:00
kieron
4cf64375f8
git-svn-id: https://spexeah.com:8443/svn/Asuro@644 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-01 19:14:26 +00:00
kieron
e8508fb22f
git-svn-id: https://spexeah.com:8443/svn/Asuro@643 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-01 18:35:40 +00:00
kieron
6d8717a7fc
git-svn-id: https://spexeah.com:8443/svn/Asuro@642 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-01 17:34:47 +00:00
kieron
ecf09646ec
git-svn-id: https://spexeah.com:8443/svn/Asuro@625 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-05-01 01:35:45 +00:00
kieron
d709244a3a
git-svn-id: https://spexeah.com:8443/svn/Asuro@611 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-04-30 19:06:43 +00:00
kieron
f1d3dabe14
git-svn-id: https://spexeah.com:8443/svn/Asuro@610 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
2018-04-30 17:22:09 +00:00