Commit Graph

23 Commits

Author SHA1 Message Date
Matthew Leach
aaac9ffd2c sched: eliminate CUR_TASK_PTR
Replace `CUR_TASK_PTR` with `ProcessCtx`. This allows differentiation
between functions that access process context (take in `ProcessCtx` as a
parameter) and those that don't.

When creating a new class of scheduleable tasks (softirqs, kthreads),
this ensure that those functions cannot call context-sensitive
functions.
2026-03-19 20:58:15 +00:00
Matthew Leach
70ce893daf rand: add EntropySource
Add an `EntropySource` trait which allows the `EntropyPool` to pull
entropy from various sources.
2026-03-07 07:33:18 +00:00
Matthew Leach
65517c6641 Add BLAKE2s entropy pool with per-CPU ChaCha20 CSPRNG
Replace the single `SmallRng` with a proper two-layer RNG architecture:

- Global BLAKE2s-256 entropy pool that accumulates entropy and gates
  seed extraction behind a 256-bit threshold.
- Per-CPU ChaCha20Rng instances that are lazily seeded from the pool on
  first use and periodically reseed every 1 MB by XOR-ing a fresh BLAKE2
  extract with 32 bytes of their own output.

The /dev/random chardev uses fill_random_bytes directly instead of
routing through the syscall layer.
2026-03-07 07:33:15 +00:00
Ashwin Naren
b28d2baa7f bump dependencies and use workspace dependencies when possible 2026-02-26 23:14:31 -08:00
Ashwin Naren
9f5311e788 post-rebase fixes 2026-02-20 14:31:19 -08:00
Ashwin Naren
c6ba98decf initial macro system 2026-02-20 14:27:39 -08:00
Andrew Mackenzie
b142fb74ec Merge pull request #227 from andrewdavidmackenzie/master
Rework uname to avoid hardcoded datetime and add unit tests

Restructure `uname` so that:
- there is an internal function that does the main logic and can be tested by unit tests
- Generate an env var in build.rs that is the actual build datetime timestamp
- Avoid hardcoded date in the version string
- Use the timestamp in the building of `uname` response, so the data is the actual build time
- add a simple unit test for the sysname field
- add more complex test for the version field that checks the date formatting (not exhaustively)

NOTE: The build timestamp can be used by any other function, syscall or part of the code if required.
2026-02-20 14:23:59 -08:00
Matthew Leach
2ee681ef02 Merge pull request #223 from arihant2math/unit-testing 2026-02-20 04:52:31 +00:00
Ashwin Naren
37def9264e implement copy_file_range 2026-02-19 12:51:20 -08:00
Ashwin Naren
d2d1ba2cbf async unit testing 2026-02-19 09:56:59 -08:00
Ashwin Naren
e65d51e48a address review 2026-02-09 16:40:53 -08:00
Ashwin Naren
c07dd2140c implement hostname properly 2026-02-08 00:39:55 -08:00
Ashwin Naren
157c29104f formatting 2026-02-07 00:31:23 -08:00
Ashwin Naren
8046d746dd implement more of sys_power 2026-02-07 00:31:23 -08:00
Ashwin Naren
aa5a9c7b79 fix typos 2026-01-23 01:26:04 -08:00
Matthew Leach
35efecad76 process: split Task into Task (shared) and OwnedTask (local)
This commit refactors the core process representation to decouple
"Identity/Resources" from "Execution/Scheduling". Previously, a
monolithic `Task` struct wrapped in `Arc<SpinLock<>>` caused lock
contention during hot scheduling paths and conflated shared state with
CPU-local state.

The `Task` struct has been split into:

1. `Task` (Shared): Holds process-wide resources (VM, FileTable,
Credentials). Managed via `Arc` and internal fine-grained locking.

2. `OwnedTask` (Private): Holds execution state (Context, v_runtime,
signal mask). Strictly owned by a specific CPU (via the Scheduler) and
accessed lock-free.

Key changes:

* Scheduler:
  chedState` now owns tasks via `Box<OwnedTask>`.
  - Transitions between `run_queue` and `running_task` involve strictly
    moving ownership of the Box, ensuring pointer stability.
  - The EEVDF comparison logic now explicitly handles comparisons
    between the queued candidates and the currently running task (which is
    not in the queue).

* Current Task Access:
  - `current()` now returns a `CurrentTaskGuard` which:
    1. Disables preemption (preventing context switches while holding
       the reference).
    2. Performs a runtime borrow check (panic on double-mutable borrow).
    3. Dereferences a cached Per-CPU raw pointer for O(1) access.
2026-01-01 22:54:43 +00:00
ootinnyoo
fe4f3103dc implement linux-like process capabilities 2025-12-29 13:53:02 -08:00
Ashwin Naren
35a6caa541 Implement sys_sysinfo (#71) 2025-12-20 15:42:08 -08:00
Ashwin Naren
f63ad250f4 implement restarting 2025-12-15 21:22:53 +00:00
Matthew Leach
8038a6c4e2 syscalls: sys_getrand: implement
Implement sys_getrand
2025-11-28 21:24:37 +00:00
Matthew Leach
28980c6725 uname: fudge the version of the kernel for libc
libc bringup checks the version of the kernel and it appears as though
it's not happy with `0.1.0`:

```
FATAL: kernel too old
```

For now, fudge the version to keep libc happy.
2025-11-28 20:09:05 +00:00
Ashwin Naren
de76e243a2 properly shutdown system 2025-11-28 20:02:12 +00:00
Matthew Leach
ca6fdd0da5 Initial Commit
Initial commit of arm64 bring-up code, kernel core (libkernel) and build
infrastructure.
2025-11-16 20:15:01 +00:00