Commit Graph

242 Commits

Author SHA1 Message Date
Ashwin Naren
d2d1ba2cbf async unit testing 2026-02-19 09:56:59 -08:00
Ashwin Naren
a7e8f07686 unit testing 2026-02-18 22:23:40 -08:00
Ashwin Naren
6e0d5ef43a implement clock_settime 2026-02-15 22:05:10 -08:00
Matthew Leach
ba0ff25b20 Merge pull request #203 from arihant2math/statfs
Implement `sys_statfs` and `sys_fstatfs`
2026-02-15 20:05:13 +00:00
Ashwin Naren
6aebef2168 enable clippy lints for libkernel 2026-02-13 10:24:13 -08:00
Ashwin Naren
6d0a4370fb fix efault in settimeofday 2026-02-11 09:47:44 -08:00
Ashwin Naren
3d33578533 Merge pull request #187 from arihant2math/cap-raise
prctl: implement `AmbientCapOp::Raise`
2026-02-09 23:24:52 -08:00
Matthew Leach
141fbf8a1b Merge pull request #202 from hexagonal-sun/slab-alloc-stress-test 2026-02-10 07:21:18 +00:00
Ashwin Naren
5408932bb9 fix fstatfs 2026-02-09 16:59:35 -08:00
Ashwin Naren
f1c0cba3b8 statfs 2026-02-09 16:59:15 -08:00
Ashwin Naren
2855ef7a51 Merge pull request #201 from arihant2math/hostname
Store hostname and allow for updates via `sys_sethostname`
2026-02-09 16:48:10 -08:00
Ashwin Naren
e65d51e48a address review 2026-02-09 16:40:53 -08:00
Ashwin Naren
eb84a1ec6d Merge pull request #198 from arihant2math/more-fnctl 2026-02-09 13:59:40 -08:00
Ashwin Naren
8281ea798f Merge pull request #197 from arihant2math/sysfs 2026-02-09 13:59:28 -08:00
Matthew Leach
9f21618058 libkernel: memory: slab: heap: new
Add a new module which implements the high-level heap logic (implements
`GlobalAlloc`) for the slab allocator.

Also implement a multi-threaded stress test of the heap ensuring
concurrent allocation is unique (doesn't corrupt other allocs) and all
memory is free'd back to the `FrameAllocator` when all caches are
purged.
2026-02-09 07:00:13 +00:00
Ashwin Naren
ef10631dc4 Merge pull request #195 from hexagonal-sun/slab-allocator
slab allocator
2026-02-08 16:51:29 -08:00
Ashwin Naren
c07dd2140c implement hostname properly 2026-02-08 00:39:55 -08:00
Ashwin Naren
75afc15bc7 fix typo 2026-02-07 18:26:28 -08:00
Ashwin Naren
479926f767 stub cgroup fs 2026-02-07 18:25:30 -08:00
Ashwin Naren
e9bcc1b10d implement fcntl F_SETFL 2026-02-07 13:53:34 -08:00
Ashwin Naren
157c29104f formatting 2026-02-07 00:31:23 -08:00
Ashwin Naren
ab93101a9f implement STATX_MNT_ID for sys_statx 2026-02-07 00:31:23 -08:00
Ashwin Naren
8046d746dd implement more of sys_power 2026-02-07 00:31:23 -08:00
Matthew Leach
1906f1be5e arch: arm64: memory: heap: new
Add a new heap module which integrates the per-cpu cache and
`SlabAllocator` into a usable `GlobalAlloc` for the kernel.
2026-02-07 08:26:35 +00:00
Matthew Leach
0f0febdad0 arch: arm64: exceptions: use SP_EL0 as scratch reg
When detecting stack overflow in the kernel exception handler, use
`SP_EL0`, rather than `TPIDR_EL1` as the scratch register.  This allows
us to use the `TPIDR_EL1` register as a CPU-banked register for other
purposes.

Use of `SP_EL0` is safe here since the stack overflow check occurs
during kernel exceptions and SP_EL0 will be restored by the user-space
context restore logic, overriding the clobber.
2026-02-07 08:26:35 +00:00
Matthew Leach
1bdaaef14a libkernel: memory: slab: allocator: new
Add a new slab allocator implementation. The `SlabAllocator` manages
lists of slabs for each size class.
2026-02-07 08:26:35 +00:00
Matthew Leach
c0ecac05f3 libkernel: memory: PageAllocGetter: return ref to allocator
Rather than returning a reference to the `OnceCell` wrapping the
allocator, return a static reference to the allocator itself. This
allows flexibility for how the allocator is wrapped.
2026-02-07 08:26:35 +00:00
Matthew Leach
972f023edc libkernel: memory: reorganise allocators
Create a new submodule within `memory`, `allocators` which contains all
memory allocators. Also split out the `Frame` struct from the `pg_alloc`
module, allowing it to be used by other modules.
2026-02-07 08:26:35 +00:00
Ashwin Naren
c394e18231 tmp 2026-02-07 00:20:37 -08:00
Matthew Leach
fc873a9b67 arm64: mem: AddresSpace: impl Drop
Implement the Drop trait on `Arm64ProcessAddressSpace` freeing up all
pages which have been used by this address space.
2026-01-30 19:39:59 -08:00
Ashwin Naren
62709be4d6 cmdline inode 2026-01-30 19:36:42 -08:00
Ashwin Naren
04ac1e8783 implement sys_waitid 2026-01-30 08:31:26 -08:00
Ashwin Naren
ba7c517685 prctl: implement AmbientCapOp::Raise 2026-01-29 14:30:24 -08:00
Matthew Leach
64469bb79c Merge pull request #185 from hexagonal-sun/hardware-smp-fixes 2026-01-28 09:14:25 +00:00
Matthew Leach
462de189b0 arm64: boot: secondaries: ensure WFI doesn't trap
The WFI insn is set not to trap on the primary core. Ensure it's also
set on the secondary cores too.
2026-01-28 08:00:01 +00:00
Matthew Leach
ba53418382 arm64: secondary: ensure boot_ctx is flushed to RAM
When the secondary boots and derefes the boot_ctx pointer passed in as a
parameter, it reads NULL, causing the secondary to end up stuck in an
exception loop. The data is sat in the primary core's cache and hasn't
been flushed to RAM. Since the secondary starts without the MMU (and
caches) enabled, the CCI doesn't kick in and we read stale data.

Manually flush the boot_ctx data to RAM before waking up the secondary.
2026-01-28 08:00:01 +00:00
Matthew Leach
d92945379a arm64: memory: flush_to_ram: new
Create a new function which takes a pointer to an object `T` and ensures
that the data is flushed from the caches to the point of
coherency (RAM).
2026-01-28 08:00:01 +00:00
Ashwin Naren
17b347cdc4 naming changes 2026-01-27 00:31:47 -08:00
Ashwin Naren
04f015848b percpu refactor 2026-01-27 00:31:47 -08:00
Ashwin Naren
7c7776ba7b working top
implements enough of procfs for `top` to run
2026-01-27 00:31:47 -08:00
Matthew Leach
87fe041ba0 procfs: implement /proc/<PID>/maps
Implement the `maps` file which shows a process's VMA entries. Example
output:

```
[root@moss-machine /]# cat /proc/1/maps
500000000000-500000117000 r-xp 0000000000                    /bin/bash
50000012b000-500000130000 r--p 000011b000                    /bin/bash
500000130000-50000013e000 rw-p 0000120000                    /bin/bash
700000000000-70000002b000 r-xp 0000000000                    /lib/ld-linux-aarch64.so.1
70000003e000-700000040000 r--p 000002e000                    /lib/ld-linux-aarch64.so.1
700000040000-700000042000 rw-p 0000030000                    /lib/ld-linux-aarch64.so.1
7fffff510000-7fffff585000 r-xp 0000000000                    /usr/lib/libncursesw.so.6
7fffff585000-7fffff59b000 ---p 0000075000                    /usr/lib/libncursesw.so.6
7fffff59b000-7fffff5a0000 r--p 000007b000                    /usr/lib/libncursesw.so.6
7fffff5a0000-7fffff5a1000 rw-p 0000080000                    /usr/lib/libncursesw.so.6
7fffff5b0000-7fffff760000 r-xp 0000000000                    /usr/lib/libc.so.6
7fffff760000-7fffff76d000 ---p 00001b0000                    /usr/lib/libc.so.6
7fffff76d000-7fffff770000 r--p 00001bd000                    /usr/lib/libc.so.6
7fffff770000-7fffff772000 rw-p 00001c0000                    /usr/lib/libc.so.6
7fffff772000-7fffff779000 rw-p 0000000000
7fffff780000-7fffff7d9000 r-xp 0000000000                    /usr/lib/libreadline.so.8
7fffff7d9000-7fffff7ed000 ---p 0000059000                    /usr/lib/libreadline.so.8
7fffff7ed000-7fffff7f0000 r--p 000005d000                    /usr/lib/libreadline.so.8
7fffff7f0000-7fffff7f6000 rw-p 0000060000                    /usr/lib/libreadline.so.8
7fffff7f6000-7fffff7fb000 rw-p 0000000000
7fffff800000-800000063000 rw-p 0000000000                    [stack]
```
2026-01-27 06:10:43 +00:00
Ashwin Naren
d386b8ba36 post rebase fixes 2026-01-25 10:50:02 -08:00
Ashwin Naren
d8c77ebca7 procfs bugfixes 2026-01-25 10:50:02 -08:00
Ashwin Naren
d7ad7b76dc fix clocks not actually updating within time slice 2026-01-25 10:50:02 -08:00
Ashwin Naren
2d34ebcef9 procfs refactor 2026-01-25 10:50:02 -08:00
Ashwin Naren
c5a0976a73 track stime and utime
Tracks stime and utime for processes and tasks. Reports the times through procfs and `sys_clock_gettime`.
2026-01-25 10:50:02 -08:00
Ashwin Naren
bed6b65db0 fix clockid enum 2026-01-25 10:50:02 -08:00
Matthew Leach
3aca7b2122 devfs: set attr id the same as the inode id
Ensure that the ID of the attr contains the ID of the devfs inode,
instead of the default value.
2026-01-25 10:29:43 -08:00
Matthew Leach
4c94f6e3d4 pipe: add PipeInode for fstat
Add a PipeInode struct which allows `fstat` for an FD which is backed by
a pipe.
2026-01-25 10:29:43 -08:00
Matthew Leach
4a3477182a clock_nanosleep: fix arguments to syscall
The `sys_clock_nanosleep` implementation was missing a `flags` parameter
in the second position.  This meant that `rqtp` was interpreted as
`rmtp`, and when interrupted, `rmtp` would write to a garbage address
causing an `EFAULT`.

Fix the argument ordering.
2026-01-25 10:28:40 -08:00