Commit Graph

91 Commits

Author SHA1 Message Date
Ashwin Naren
b8ad29b4b1 update .gitignore 2025-12-17 20:07:53 -08:00
Matthew Leach
9db6162414 formatting 2025-12-17 20:04:31 -08:00
Matthew Leach
0a32eeaaa0 scripts: create /tmp
Create /tmp and modify the kernel command line to mount tmpfs on /tmp.
2025-12-17 20:04:31 -08:00
Matthew Leach
5511e28b72 syscalls: implement ftruncate 2025-12-17 20:04:31 -08:00
Matthew Leach
8bc271c266 fs: open: pass create mode parameter
Pass the `mode` parameter to the open VFS call, specifying the
permissions of the file when O_CREAT is specified.
2025-12-17 20:04:31 -08:00
Matthew Leach
236dd3aa84 fs: reg: implement write
For some reason, `write` is just a copy of the `read` code. Fix that by
implementing `write`.
2025-12-17 20:04:31 -08:00
Matthew Leach
bebee6d8f5 libkernel: address: ensure to_pfn can only be called on PA
calculating a PFN from a VA makes no sense since it could be mapped to
any address. Therefore, ensure that it can *only* be called on PAs.
2025-12-17 20:04:31 -08:00
Matthew Leach
264d603044 drivers: fs: tmpfs: new
Add tmpfs driver and register with the kernel driver's FS subsystem.
2025-12-17 20:04:31 -08:00
Matthew Leach
a867493fa7 page_alloc: make test fixture public
Having the ability to use the `FrameAlloctor`, simulating via the heap
is a very useful pattern when testing libkernel code. Make the test
fixture public for other modules to use.
2025-12-17 20:04:31 -08:00
Matthew Leach
54f2d683b8 libkernel: move ClaimedPage into libkernel crate
By moving `ClaimedPage` into libkernel we can utilise it in
arch-agonstic ode.
2025-12-17 20:04:31 -08:00
Matthew Leach
c1bea5ecbb tmpfs: new
Add basic directory inode implementation and tmpfs filesystem
implementation.
2025-12-17 20:04:31 -08:00
Matthew Leach
ba7848fc8b libkernel: CpuOps: add 'static trait bound
The CpuOps trait should never hold a reference to any other object. In
fact, it should be a singleton object which is constructed at kernel
boot and live for the entire lifetime of the system. Therefore, it's
safe to add the `'static` trait bound.
2025-12-17 20:04:31 -08:00
Ashwin Naren
5c8793675d Initialize buffer as 1s to ensure it's written to. 2025-12-16 04:51:57 +00:00
Ashwin Naren
ebd459039e test read syscall 2025-12-16 04:51:57 +00:00
Ashwin Naren
bc9676b696 Add stopped state 2025-12-15 16:49:04 -08:00
Ashwin Naren
f1d2d007bb handle stop and continue 2025-12-15 16:49:04 -08:00
Ashwin Naren
f63ad250f4 implement restarting 2025-12-15 21:22:53 +00:00
Matthew Leach
b8edd4af68 fat32: downcase 8.3 filenames
Using mtools to prepare the initrd image results in an image that
exclusively uses 8.3 filenames; as per the spec, the 8.3 filenames are
stored uppercase. However, on most UNIX systems, people are used to
dealing with down-case names; therefore convert the strings to
lower-case before passing back to the user.
2025-12-14 06:38:42 +00:00
Matthew Leach
4cd9fab80b scripts: deps: usertest: new
Add a script to build the userspace test program and include it in the
initramfs.
2025-12-13 19:21:22 -08:00
Matthew Leach
e2a9306037 build-deps: busybox: don't popd too many times
Fix the busybox deps script's dir stack underflow.
2025-12-13 19:21:22 -08:00
Ashwin Naren
a4e9cf9fd9 formatting 2025-12-11 20:09:47 +00:00
Ashwin Naren
6d967332b7 remove old todo 2025-12-11 20:09:47 +00:00
Ashwin Naren
76f7707e00 test writing 2025-12-11 20:09:47 +00:00
Ashwin Naren
b05c606a2a testing 2025-12-11 20:09:47 +00:00
Ashwin Naren
e2534ffd9c Implement /dev/zero 2025-12-10 14:37:59 -08:00
Ashwin Naren
71f025b437 Implement /dev/null (#48) 2025-12-09 08:40:27 -08:00
Matthew Leach
511a0db41e arch: arm64: parse cmdline from chosen node
The kernel command line is passed via the FDT's chosen node. Use that,
rather than hard-coding it into the kernel.

Fixes: #20
2025-12-07 16:41:45 +00:00
Matthew Leach
abd5ef39c2 create-image: use mtools to populate image
Use the `mtools` set of utilities to populate the image without the need
to run mount the image (requring sudo).
2025-12-07 16:41:35 +00:00
Matthew Leach
76624b8be0 scripts/deps/bash: fix build for later gcc
'bool' has become a reserved keyword in c23.  If gcc is modern enough
that this is the default standard, it results in an error.  Default to
c99 for the host compiler to fix the problem.

Patch suggested by: @dec-mcgraw

Fixes: #43
2025-12-07 16:41:35 +00:00
Matthew Leach
afaae627cf scripts/deps/bash: use release tar
Rather than closing the entire git repo, use the offical tar.gz release
from GNU.
2025-12-07 16:41:35 +00:00
Matthew Leach
dec7348015 rust-toolchain.toml: add rust-analyzer
Add rust analyzer to project rust deps.
2025-12-07 16:41:35 +00:00
Brian R.
8101e6278f Update README.md
I was having a hard time figuring out what this meant when I was going through the instructions the first time, and I believe that this would help clarify things for people who got stuck like I did. I also corrected the name for "Any OS" to clarify this is for X86-64 Linux OSes, because of the command I provided in the README.
2025-12-07 16:40:54 +00:00
Ashwin Naren
661f368334 implement sys_kill 2025-12-01 19:55:41 +00:00
NerdNextDoor
0904a1994c Introduce experimental macOS build support
Tested on my M4 MacBook Air, builds fine.
2025-11-30 21:15:30 +00:00
Matthew Leach
910203e0c2 syscalls: mprotect: implement
Implement the `mprotect` syscall. Including a bunch of tests for
ensuring proper VMA functionality regarding splitting and merging via
`mprotect`.
2025-11-30 20:13:36 +00:00
Matthew Leach
baf98c452f libkernel: vmarea: shrink_to: implement
Implement a `shrink_to` function for a VMA. This shrinks the VMA's
region to the specified region, while recalculating file offsets and
size if the VMA is file-backed.
2025-11-30 20:13:36 +00:00
Matthew Leach
3e3a9ad0c5 libkernel: region: add punch_hole
Add a function for calculating the set difference when punching one
region out of another.
2025-11-30 20:13:36 +00:00
Matthew Leach
1b95049159 libkernel: memory: VMArea: page align on from_pheader
Page align any non-aligned program headers, fixing up the file offset
and filesz accordingly.
2025-11-30 20:13:36 +00:00
Herman Polloni
41814dddbe Fix bash build on aarch64 host 2025-11-30 10:19:14 +00:00
Matthew Leach
8038a6c4e2 syscalls: sys_getrand: implement
Implement sys_getrand
2025-11-28 21:24:37 +00:00
Ashwin Naren
5f2c2491b8 implement fair scheduler 2025-11-28 21:06:07 +00:00
Bjorn Beishline
6d3af6a95d Update syscall doc with newly implemented methods 2025-11-28 20:46:45 +00:00
Bjorn Beishline
911a85e4ef Implement sys_set_robust_list and sys_gettid 2025-11-28 20:46:45 +00:00
Matthew Leach
fb405282cc syscalls: rseq: return ENOSYS
Return ENOSYS for sys_rseq
2025-11-28 20:09:05 +00:00
Matthew Leach
1741b036bb syscalls: getrlimit: return error
Return error for the moment for `sys_getrlimit`.
2025-11-28 20:09:05 +00:00
Matthew Leach
1ed714e47b libkernel: memory: region: remove breaking assert in expand
The `expand` function adds bytes size into the region; the check `size
>= self.size` isn't needed since this is an expanding function, not a
resizing one. To emphasise that, rename the function to `expand_by`.

Also include a bunch of unit tests to ensure that expansion by regions
with differing sizes works correctly.
2025-11-28 20:09:05 +00:00
Matthew Leach
6e988c3639 syscall: socket: return with error
Return with an error when calling socket()
2025-11-28 20:09:05 +00:00
Matthew Leach
6a029c340a syscall: gettimeofday: impement
Provide a dummy implementation of sys_gettimeofday
2025-11-28 20:09:05 +00:00
Matthew Leach
5f42f74c5c process: exec: add AT_PH aux vectors
libc uses the program headers to find the TLS pheader. Therefore, we
need to push these values into the aux vector when creating the
userspace mappings for the process.
2025-11-28 20:09:05 +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