]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
feat: gettimeofday + mprotect syscalls + Newlib libgloss port
authorTulio A M Mendes <[email protected]>
Sat, 14 Mar 2026 00:18:08 +0000 (21:18 -0300)
committerTulio A M Mendes <[email protected]>
Sat, 14 Mar 2026 00:18:08 +0000 (21:18 -0300)
commita179eafc59ea3b15b5c7f951db769f42f1c71492
treed0f77cf6bc74473582d03ff2518b1d3e8790363d
parent207554a71c31ecaf04924d2872d8037b643fa7f1
feat: gettimeofday + mprotect syscalls + Newlib libgloss port

Kernel:
- Add SYSCALL_GETTIMEOFDAY (127): returns RTC epoch seconds + TSC-derived
  microseconds via struct timeval. Timezone arg ignored per POSIX.
- Add SYSCALL_MPROTECT (128): changes page protection on heap, mmap, and
  stack regions. Converts POSIX PROT_READ/WRITE/EXEC to VMM flags and
  calls vmm_protect_range(). Validates ownership before modifying PTEs.

ulibc:
- Add gettimeofday() wrapper in sys/time.h + time.c
- Add mprotect() wrapper in sys/mman.h + mman.c
- Add SYS_GETTIMEOFDAY/SYS_MPROTECT to ulibc syscall.h

Newlib port (newlib/):
- newlib/libgloss/adros/crt0.S: C runtime startup for AdrOS, calls
  __libc_init_array/__libc_fini_array for Newlib/C++ ctor/dtor support
- newlib/libgloss/adros/syscalls.c: all 21 Newlib-required OS stubs
  (_exit, _read, _write, _open, _close, _lseek, _fstat, _stat, _isatty,
  _kill, _getpid, _sbrk, _link, _unlink, _fork, _execve, _wait, _times,
  _gettimeofday, _rename, _mkdir) implemented via INT 0x80
- newlib/libgloss/adros/Makefile: builds crt0.o + libadros.a
- newlib/README.md: build instructions for full Newlib cross-compilation
- newlib/patches/README.md: documents config.sub, configure.host, and
  libgloss/configure.in changes needed in Newlib source tree

All 21 Newlib libgloss stubs are now implemented. To build Newlib:
  1. Copy libgloss/adros/ into Newlib source tree
  2. Add i686-*-adros* target to configure files
  3. Build with: ../configure --target=i686-adros && make
12 files changed:
include/syscall.h
newlib/README.md [new file with mode: 0644]
newlib/libgloss/adros/Makefile [new file with mode: 0644]
newlib/libgloss/adros/crt0.S [new file with mode: 0644]
newlib/libgloss/adros/syscalls.c [new file with mode: 0644]
newlib/patches/README.md [new file with mode: 0644]
src/kernel/syscall.c
user/ulibc/include/sys/mman.h
user/ulibc/include/sys/time.h
user/ulibc/include/syscall.h
user/ulibc/src/mman.c
user/ulibc/src/time.c