lunaix-os.git
22 months agoSupport to multi-threading and pthread interface (POSIX.1-2008) (#23)
Lunaixsky [Mon, 5 Feb 2024 17:20:02 +0000 (17:20 +0000)]
Support to multi-threading and pthread interface (POSIX.1-2008) (#23)

This patch brings a functional multi-threading support to Lunaix kernel
together with essential syscalls to support POSIX's pthread interfacing.

About the threading model in Lunaix
Like the Linux kernel, the threading feature is built upon the existing
multi-processing infrastructure. However, unlike Linux which uses a more
lazy yet clever approach to implement threads as a specialized process,
Lunaix implements threading that perfectly reflects its orthodox definition.
Which requires a from-scratch and massive refactoring of the existing process
model. Doing this allows us to make things clearer and pursue a true
lightweightness of what threads are supposed to be.

Kernel thread and preemptive kernel
As a natural result of our implementation, we have implemented the concept
of kernel threads, which are subsidiaries of a special process (pid=0) that runs
under kernel mode. Treating the kernel as a dedicated process rather than a
process parasite, enables us to implement an advanced feature of a preemptive
kernel. Unlike in Linux, where the kernel is preemptive anywhere; Things were
different in Lunaix, where only functions called directly from the kernel thread can
be preemptive, which allows us to perform more fine-grand control. This reduces
the effort of refactoring and eases the writing of new kernel code, for which the
non-preemptive assumption can be kept.

Spawning and forking
This patch introduces a set of tools for performing remote virtual memory space
transaction, allow the kernel to inject data into another address space. And will
be used as infrastructure for kernel-level support on the `posix-spawn`
interface, which creates a process from scratch rather than fork from another,
allows us to skip duplicating the process's VM space and reduce overhead.

LunaDBG
LunaDBG has been refactored for modularization and arch-agnostic. New set of
commands are being added:

        mm: a sophisticated tool for examining page table mapping and performing
            physical memory profiling (detailed usage see up-coming documentation)
     sched: tools for examining the scheduler context, listing all threads and
            processes

--------------
All changes included in this patch:

* * Signal mechanism refactor

   The sigctx of proc_info is changed to a pointer reference as well as the
   sigact array is now in favour of storing references. Therefore we can keep
   the overall proc_info and sigctx size small thus to avoid internal fragmentation
   of allocating large cake piece.

   Some refactoring also done on signal related method/struct to improve
   overall readability

* Temporary removal of x87 state from context switching until a space-efficient
  workaround emerged

* Add check on kernel originated seg-fault and halt the kernel (for debugging).
  As by assumption kernel mapping will always present (at least for now, as
  page swapping and stagging is not implemented in Lunaix yet).

* Re-group the fork related functions to a dedicated fork.c file

* Fix a incorrect checking on privilege level of interrupt context when
  printing tracing

* * Make proc_mm as a pointer reference to further reduce the single allocation size
  as well as making things more flexible

* Remove the need of pid when allocating the physicall memory. Due the complexity and
  the dynamics in the ownership of physical page, there is no point to do such checking
  and tracking.

* Add some short-cut for accessing some commonly used proc_mm field, to avoid nasty
  chain of cascading '->' for sake of readbility.

* * Introducing struct thread to represent a light-weighted schedulable element.

  The `struct thread` abstract the execution context out of the process, while the
  latter now composed only descriptors to program resources (e.g., file, memory
  installed signal handlers). This made possible of duplicating concurrent
  execution flow while impose a rather less kernel overhead (e.g., cost to context
  switch, old-fashioned fork()-assisted concurrency).

  Such change to process model require vast amount of refactoring to almost every
  subsystem involving direct use of process. As well as introducing additional
  tools to create the initial process. This commit only contains a perliminary
  refactoring works, some parts require additional work-around is commented out and
  marked with `FIXME`

* Other refactoring and cleaning has been done to improve the semantics of certain
  pieces of code.

* * Process and thread spawning. Allow to reduce the system overhead
  introduced by invoking fork to create process. However, creating
  a process housed executable image is not implemented as it require
  remote injection of user stack for which is still under consideration

* Introducing kernel process and kernel threads. Prior to the threading
  patch, the dummy process is a terrible minick of kernel process
  and used as merely a fallback when no schdulable process can be found.
  This makes it rather useless and a waste of kernel object pool space.
  The introducing of thread and new scheduler deisgn promote Lunaix
  to a full functioning kernel thread, it's preemptiveness enable the
  opportunity to integrating advanced, periodical, event driven kernel
  task (such as memory region coalescing, lightweight irq handler)

* Some minor refactorings are also performed to make things more clean

* Update the virtual memory layout to reflect the current development

* * Fix the issue of transfer context being inject into wrong address
  as the page offset was some-how not considered

* Fix the refactoring and various compile time error

* Adjust the lunadbg to work with latest threading refactoring.

* Also fix the issue that lunadbg's llist iterator had made false
  assumption on the offset of embeded llist_header.

* Rename spawn_thread -> create_thread. And introduce spawn_kthread
  to spawn a kernel thread within kernel process.

* Fix the issue in vmm_lookupat that ignore the present bit when
  doing pte probing

* Leaves some holes for later investigations

* * Make threading feature works properly

* Fixed left-over issues as well as new issues found:

    1. incorrect checking on thread state in 'can_schedule', causing
       scheduler unable to select suitable thread even though there
       exists one

    2. double free struct v_file when destorying process. Which caused
       by a missing vfs_ref_file in elf32_openat

    3. destory_thread removed wrong thread from global thread list

    4. thread-local kernel and user thread don't get released when
       destorying thread

    5. lunad should spawn a new process for user space initd rather than
       kexec on current kernel process

    6. guarding the end of thread entry function with 'thread_exit'
       to prevent run-over into abyss.

    7. fix tracing.c prints wrong context entring-leaving order

    8. zero fill the first pde when duplicating the vm space to avoid
       garbage interfering the vmm

* * Allow each process to store their executable arguments

* Refactor the lunadbg toolset (done: process, thread and scheduler)

* * Fix can_schedule() should check against thread's state rather than process state

* Remove the hack of using ebp in 'syscall_hndlr', thus to prevent it for
  interferencing the stack-walker

* Find tune the output of tracer when incountering unknown symbol

* (LunaDBG) Add implementation for examing sigctx

* * Add related syscall to manipulate threads

* Factorise the access of frame pointer and return address to abi.h

* Shrink the default pre-thread user stack size to 256K, to account
  the shortage on 32-bit virtual address space.

* Add check to kernel preemptible function context

* Add different test cases to exercise various pthread_* api

* * (My Little Pthread Test) Fix the all sorts of issues found in current threading model implementation
  with a set of simple pthread tests.

* Add more sanity checks on tracing and pfault handler, to avoid them spamming the output stream when
  the failure is severe enough to cause infinite nesting (e.g., when vm mapping of kernel stack get
  messed up)

* Add guardian page at the end of thread-local kernel and user stack to detect stack overflow

* Remove an unwanted interrupt enablement in ps2kbd.c (which behaviour is undefined in the booting
  stage)

* Temporary fix issues with vmr dump py utils (need to adapt the new design sooner or later)

* Specify a cpu model for QEMU, which make things more detrerministic

* * Change the mmap flag for creating thread-local user stack to non-FIXED.
  As a previous experiment shows that during high concurrency situtaion,
  the calculation of ustack location for new thread will be affected and
  had risk of smashing existing thread's ustack causing undefined bevhaiour
  when return from kernel (as the stack address is implied from
  proc_info::threads_count) for which reason it should treated as
  hint to mem_map rather than a hard requirement.

* Re-implement the VMR allocation alogirthm that will takes the vicinity of
  the hinted address as high priority search area, rather than dumbly start
  from beginning.

* Remove the undesired pmm_free_page from __dup_kernel_stack. As we
  now skipped the first 4MiB when duplicating the page table. Thus the
  ref counters for these physical page are already 1 after fork. This
  has been identify the root cause of a randomly appearing segfault
  during memory intensive task such as test_pthread, as these falsely
  released physical page will get repurposed. However, this also lead
  to a question in Lunaix's memory utilisation, as the next-free strategy
  is unlikely to visit the previously allocated page when plenty of free
  space ahead. More efforts should be taken into investigating memory
  performance.

* Added more assertion and checks to enhance the robustness and ease
  the debugging experience.

* Adjust some output format and refactor the test_pthread code.

* * (lunadbg) `mm` command for probing page table and physical memory profiling

* Add missing syscall-table doc

* Add more test cases related to pthread

* * (LunaDBG) decouple the pte related operation as arch-dependent feature

* (LunaDBG) adjust the output format

* * (LunaDBG) Refactor VMR dump

* * Adjust the thread id generation to avoid duplication ratio

* Capped the thread limit per process

* (LunaDBG) Fix the issue with display of percentage in pmem profiling

22 months ago2-setup_gdt.md (#22)
FFreestanding [Mon, 22 Jan 2024 14:00:43 +0000 (22:00 +0800)]
2-setup_gdt.md (#22)

22 months ago1-hello_kernel_world.md (#21)
FFreestanding [Fri, 19 Jan 2024 19:07:30 +0000 (03:07 +0800)]
1-hello_kernel_world.md (#21)

* Add files via upload

0-教程介绍和环境搭建

* update README.md and create a tuturial dir

* docs/tutorial/1-hello_kernel_world.md

* Update 1-hello_kernel_world.md

* update 1-hello_kernel_world.md

---------

Co-authored-by: ffreestanding <achillesweb@qq.com>
23 months agofix: corner cases when printing large content through term interface
Minep [Mon, 11 Dec 2023 19:43:48 +0000 (19:43 +0000)]
fix: corner cases when printing large content through term interface
refactor: make usr/ compilation more clean
refactor: clean up unused header files
refactor: renamed things

23 months agoMerge branch 'master' of github.com:Minep/lunaix-os
Minep [Mon, 11 Dec 2023 01:00:23 +0000 (01:00 +0000)]
Merge branch 'master' of github.com:Minep/lunaix-os

23 months agofeat: capability list to enable greater flexibility of devices
Minep [Mon, 11 Dec 2023 00:56:18 +0000 (00:56 +0000)]
feat: capability list to enable greater flexibility of devices
feat: implement termios interface in LunaClib
fix: strange behaviour refered as double mounting and double-mkdir
fix: a mis-used of fpos parameter in some device file read/write invocation
fix: some bugs in user program
chore: edit readme

23 months ago教程介绍和环境搭建 (#19)
FFreestanding [Sun, 10 Dec 2023 15:18:58 +0000 (23:18 +0800)]
教程介绍和环境搭建 (#19)

* Add files via upload

0-教程介绍和环境搭建

* update README.md and create a tuturial dir

---------

Co-authored-by: ffreestanding <achillesweb@qq.com>
23 months agofeat: owloysius - dynamic init function invocator
Minep [Sun, 10 Dec 2023 13:50:32 +0000 (13:50 +0000)]
feat: owloysius - dynamic init function invocator
refactor: add a generic base struct to devices
  this allow us to specialize different kinds of device,
  sparating devfs tree node and real device, to save the overhead
feat: add device aliasing (i.e. hard link in devfs)
feat: add new gdb command to dump system log
feat: make default system console configurable through `console=<dev>` boot command line
fix: trying to delete mount point when unmounted.
fix: ensure frame-point always included regardless optimization level
chore: edit readme
d

23 months agofeat: a better boot command line parser
Minep [Sat, 9 Dec 2023 20:56:32 +0000 (20:56 +0000)]
feat: a better boot command line parser
fix: bugs in term interfacing

23 months agorefactor: add a async read/write variant to device ops, with allow async io to be...
Minep [Fri, 8 Dec 2023 20:30:53 +0000 (20:30 +0000)]
refactor: add a async read/write variant to device ops, with allow async io to be used.
refactor: decouple the gcc version requirement.
refactor: add implementation to arch-aware division, this allows removal of libgcc
fix: couple bugs in builtin user shell

updated readme

2 years agofeat: nearly complete POSIX.1-2008 compliant terminal interface implementation
Minep [Sun, 26 Nov 2023 23:17:42 +0000 (23:17 +0000)]
feat: nearly complete POSIX.1-2008 compliant terminal interface implementation
fix: a corner case in cake allocator
fix: remove a double free and add checks to cake allocator for that
fix: enforcing the termination condition of stackwalker
fix: signal delivery to process group
chore: tweak the clang-formatter config
chore: clean-up and refactors

2 years agofeat: IO polling for file descriptor
Minep [Sat, 18 Nov 2023 18:47:07 +0000 (18:47 +0000)]
feat: IO polling for file descriptor
refactor: remove the need of a separate property to track mmaped file length
  we just bring in an entire page-length of content that contains what
  we care and ignore all that garbage comes with it.
fix: sync the dirty pages in file-maped mem region upon unmapping.
chore: update readme
chore: remove objdump -S of entire kernel.

2 years agofeat: lunadbg GDB plugin to ease kernel debugging process.
Minep [Sun, 5 Nov 2023 17:28:58 +0000 (17:28 +0000)]
feat: lunadbg GDB plugin to ease kernel debugging process.
fix: rewrite mem_unmap for correctness and robustness
fix: offset in divisor cause system timer running a bit slow than expected.
fix: preventing gcc to put everything into a single loadable section when compiling user-space program
fix: nullptr risk when printing kernel stack trace

2 years agorefactor: make pci device driver loading passive, pci bus scanner will not load them...
Minep [Sat, 4 Nov 2023 19:27:18 +0000 (19:27 +0000)]
refactor: make pci device driver loading passive, pci bus scanner will not load them automatically,
          this allow greater flexibility and decouple the pci bus scanning and the driver init dependency.
refactor: move acpi as a loadable device
refactor: remove the nonsense "len" parameter from {read|write}_page file ops
refactor: decouple the ahci main driver from the pci interfacing
refacror: move the mounting of some kernel fs to user space.
refactor: rename the device loading stage to make more sense.
chores: some house-keeping stuff

2 years agofeat: kprintf now goes into dedicated pseudo-dev rather than flooding the framebuffer
Minep [Fri, 3 Nov 2023 19:33:53 +0000 (19:33 +0000)]
feat: kprintf now goes into dedicated pseudo-dev rather than flooding the framebuffer
refactor: a better kprintf buffer design that can carry more information and simplify interface signature
chores: some housekeeping stuff

2 years agofeat: support user-spcae pci rescan
Minep [Thu, 26 Oct 2023 11:29:58 +0000 (12:29 +0100)]
feat: support user-spcae pci rescan
refactor: allow lazy driver binding for pci devices

2 years agofeat: gfxm: a layer provides user space access to low level interfacing of graphic...
Minep [Tue, 24 Oct 2023 14:15:59 +0000 (15:15 +0100)]
feat: gfxm: a layer provides user space access to low level interfacing of graphic adapter
chore: clear things up

2 years agofeat: standard vga support (mode switching, framebuffer remapping)
Minep [Sat, 21 Oct 2023 21:40:52 +0000 (22:40 +0100)]
feat: standard vga support (mode switching, framebuffer remapping)
feat: better tty/term abstraction
feat: mask on pci device id to allow driver do fussy device matching
refactor: the variant field of device id is now to be the instance number
chore: clean up and re-formatting

2 years agofeat: fstat now handle symbolic link
Minep [Thu, 7 Sep 2023 19:55:56 +0000 (20:55 +0100)]
feat: fstat now handle symbolic link
refactor: file type mask rework
fix: device definition should be reflected on the abstract device struct

2 years agoregression: test serial port r/w.
Minep [Tue, 5 Sep 2023 23:50:17 +0000 (00:50 +0100)]
regression: test serial port r/w.
fix: uart register bitmap
fix: refine context switch trace message
feat: add a dedicated program to host all test routines

2 years agofeat: serial device interfacing
Minep [Sun, 3 Sep 2023 23:38:06 +0000 (00:38 +0100)]
feat: serial device interfacing
feat: devzero
feat: simple cat implementation
fix: add default name for nameless device
chore: general clean up

2 years agofeat: device subsystem rework
Minep [Mon, 28 Aug 2023 21:47:39 +0000 (22:47 +0100)]
feat: device subsystem rework
      + dynamic device driver registration and discovery
      + centeralise the device managements
refactor: syslog

2 years agofeat: better rtc framework which aims to remove single rtc restrictions.
Minep [Fri, 25 Aug 2023 22:17:18 +0000 (23:17 +0100)]
feat: better rtc framework which aims to remove single rtc restrictions.
feat: user mode api for timer/rtc through fs mapping.
feat: interrupt handlers now have the option to accept customized payload.
refactor: creare a new device class of pseudo device, hope that it will clear things
refactor: move ps2 keyboard driver out of kernel code base.
fix: pcache is now abandon the use of valloc api, as the access is unaligned when allocating page size buffer.
fix: pcached write/read should use direct file i/o and must not failed with ENOMEM when buffer allocation failed.
chore: group the device file ops for better clarity

2 years agorefactor: use a more decent physical memory map
Minep [Thu, 24 Aug 2023 12:46:14 +0000 (13:46 +0100)]
refactor: use a more decent physical memory map
fix: pde's perm overrides pte's when pte has lower access level.
feat: template generator now with infinite horizon when inferencing the memory region's base and size

2 years agohotfix: a better hinting on non-returning spin function
Minep [Wed, 23 Aug 2023 16:56:09 +0000 (17:56 +0100)]
hotfix: a better hinting on non-returning spin function
fix: make sometimes can't find 'python' if it's alias does not exported to makefile's shell

2 years agoadd lunaix dynamic linker as submodule
Minep [Wed, 23 Aug 2023 16:32:15 +0000 (17:32 +0100)]
add lunaix dynamic linker as submodule
fix: elf32 should load the PT_LOAD segments only
fix: vmap does not respect the passed mapping attribute flags
fix: mmap does not take account of flen
fix: makefile does not recompiled on changed source file.
fix: incorrect modulo operation on PG_SIZE
fix: unwanted infinite loop elimination reported in #16

2 years agoupdate readme for more up-to-date information
Minep [Sun, 20 Aug 2023 19:59:09 +0000 (20:59 +0100)]
update readme for more up-to-date information
chore: housekeeping stuff

2 years agofeat: kernel stack tracing
Minep [Sun, 20 Aug 2023 16:14:13 +0000 (17:14 +0100)]
feat: kernel stack tracing
refactor: move cpu.h to arch specific

2 years agofix: corrected time conversion on alarm/sleep syscall
Minep [Sun, 20 Aug 2023 00:27:12 +0000 (01:27 +0100)]
fix: corrected time conversion on alarm/sleep syscall
fix: makefile does not respond to source file change
feat: makefile respond to header change
chore: add description on arch-specific code
chore: clean up

2 years agorefactor: one more step towards arch-agnostic design
Minep [Sat, 19 Aug 2023 22:54:30 +0000 (23:54 +0100)]
refactor: one more step towards arch-agnostic design
feat: linker generated array to free up the need of those nasty explicit invocation init_* functions

2 years agorefactor: striped more arch-related code from the kernel code base
Minep [Sat, 12 Aug 2023 16:37:14 +0000 (17:37 +0100)]
refactor: striped more arch-related code from the kernel code base
feat: memory map generation from description file

2 years agorefactor: organize all arch related files together.
Minep [Thu, 10 Aug 2023 18:46:04 +0000 (19:46 +0100)]
refactor: organize all arch related files together.
refactor: better code templating

2 years agorefactor: decouple i386 specific instruction invocation
Minep [Tue, 25 Jul 2023 18:24:03 +0000 (19:24 +0100)]
refactor: decouple i386 specific instruction invocation
refactor: re-organize the directory structure

2 years agofix: corner case for x87 context restore on execve
Minep [Sun, 23 Jul 2023 17:45:53 +0000 (18:45 +0100)]
fix: corner case for x87 context restore on execve
chore: clean up unused fields

2 years agorefactor: Optimize the signal context overhead
Minep [Sun, 23 Jul 2023 13:35:18 +0000 (14:35 +0100)]
refactor: Optimize the signal context overhead
refactor: remove kernel memory overhead for saving x87 context by saving it into user stack

2 years agorefactor: Optimize the context switch overhead
Minep [Sun, 23 Jul 2023 10:39:16 +0000 (11:39 +0100)]
refactor: Optimize the context switch overhead

2 years agofix: argv, envp passing
Minep [Sat, 22 Jul 2023 22:17:28 +0000 (23:17 +0100)]
fix: argv, envp passing
chore: take care of some warnings

2 years agoedit readme
Minep [Fri, 21 Jul 2023 18:28:03 +0000 (19:28 +0100)]
edit readme

2 years agorefactor: full rewrite of signal feature
Minep [Fri, 21 Jul 2023 18:19:01 +0000 (19:19 +0100)]
refactor: full rewrite of signal feature
refactor: scheduler logic
refactor: (hhk) initial page mapper.
fix: remove debugging user access to kernel page
feat: make signal.h more posix compliant

2 years agorefactor: rewrite kernel's make script
Minep [Thu, 20 Jul 2023 21:07:37 +0000 (22:07 +0100)]
refactor: rewrite kernel's make script
fix: change linking script to match rewrited kernel makefile
fix: some recent exposed issues.

2 years agorefactor: restructure the user space stuff.
Minep [Mon, 17 Jul 2023 17:17:20 +0000 (18:17 +0100)]
refactor: restructure the user space stuff.
refactor: better isolation between kernel and user header file
refactor: rebuild user space make system

2 years agochore: fix almost *ALL* warnings.
Minep [Sun, 16 Jul 2023 23:05:34 +0000 (00:05 +0100)]
chore: fix almost *ALL* warnings.

2 years agorefactor: decouple the executable file implementations with execve functionality.
Minep [Sun, 16 Jul 2023 17:20:16 +0000 (18:20 +0100)]
refactor: decouple the executable file implementations with execve functionality.

2 years agoedit readme
Minep [Mon, 10 Jul 2023 20:53:58 +0000 (21:53 +0100)]
edit readme

2 years agorefactor: elf parsing utility and exec related
Minep [Mon, 10 Jul 2023 20:37:38 +0000 (21:37 +0100)]
refactor: elf parsing utility and exec related
refactor: ISA abstraction setup

2 years agofeat: refine symbolic link support.
Minep [Sun, 25 Jun 2023 15:47:55 +0000 (16:47 +0100)]
feat: refine symbolic link support.

2 years agofeat: dynamic boot medium probing and mounting
Minep [Sun, 18 Jun 2023 20:27:23 +0000 (21:27 +0100)]
feat: dynamic boot medium probing and mounting
fix: null pointer exception in usr/sh
fix: parameter passing by uwrapper

2 years agofeat: shell and signal demo as loadable user executable
Minep [Sun, 18 Jun 2023 18:08:07 +0000 (19:08 +0100)]
feat: shell and signal demo as loadable user executable
fix: incorrect offset when mmap segments
refactor: streamline loading of memory-mapped file
other minor refactorings

2 years agoMerge branch 'master' into prog-loader
Minep [Wed, 14 Jun 2023 21:34:07 +0000 (22:34 +0100)]
Merge branch 'master' into prog-loader

2 years agofix: the correct way to detect ahci LBA48 support
Minep [Wed, 14 Jun 2023 21:29:22 +0000 (22:29 +0100)]
fix: the correct way to detect ahci LBA48 support

2 years agofix: promote to gcc-12.2.0 (close #15)
Minep [Sat, 10 Jun 2023 20:08:17 +0000 (21:08 +0100)]
fix: promote to gcc-12.2.0 (close #15)

2 years agoupdate readme
Minep [Wed, 22 Feb 2023 19:05:55 +0000 (19:05 +0000)]
update readme

2 years agoMerge branch 'master' into prog-loader
Minep [Tue, 17 Jan 2023 10:30:13 +0000 (10:30 +0000)]
Merge branch 'master' into prog-loader

2 years agoMerge branch 'master' of github.com:Minep/lunaix-os
Minep [Tue, 17 Jan 2023 10:26:31 +0000 (10:26 +0000)]
Merge branch 'master' of github.com:Minep/lunaix-os

2 years agofix: sleeper issue #13
Minep [Tue, 17 Jan 2023 10:21:03 +0000 (10:21 +0000)]
fix: sleeper issue #13

2 years agofeat: brk and sbrk (mmap based)
Minep [Fri, 6 Jan 2023 00:47:54 +0000 (00:47 +0000)]
feat: brk and sbrk (mmap based)
feat: environ access
refactor: status code user space port

2 years agoupdate readmes
Minep [Wed, 4 Jan 2023 22:28:36 +0000 (22:28 +0000)]
update readmes
upload ELF related specification

2 years agofeat: closedir(2)
Minep [Wed, 4 Jan 2023 16:35:48 +0000 (16:35 +0000)]
feat: closedir(2)
regression: execve
fix: wrong signature for printf
fix: sys_readdir context misuse
fix: page fault handler: offset calculation for memory-mapped file
fix: (merged) interrupt reworks in favour of execve.
fix: mmap: gap fitting

2 years agoMerge branch 'interrupt-rework' into prog-loader
Minep [Wed, 4 Jan 2023 16:12:56 +0000 (16:12 +0000)]
Merge branch 'interrupt-rework' into prog-loader

2 years agofix: previous interrupt context lost after a nested interrupt
Minep [Wed, 4 Jan 2023 16:06:20 +0000 (16:06 +0000)]
fix: previous interrupt context lost after a nested interrupt
fix: disable function inlining optimization as it could potentially cause BUGS!

2 years agorefactor: cut off some bloats in intr_ctx
Minep [Wed, 4 Jan 2023 02:15:56 +0000 (02:15 +0000)]
refactor: cut off some bloats in intr_ctx

2 years agofeat: provide some libc routines only for testing
Minep [Mon, 2 Jan 2023 16:47:37 +0000 (16:47 +0000)]
feat: provide some libc routines only for testing
feat: ls
feat: readdir(3) for wrapping sys_readdir(2)
chore: clean ups

2 years agoregression: elf loading
Minep [Mon, 2 Jan 2023 14:25:22 +0000 (14:25 +0000)]
regression: elf loading

2 years agofeat: wrapper function for bootstraping user program
Minep [Sun, 1 Jan 2023 01:44:46 +0000 (01:44 +0000)]
feat: wrapper function for bootstraping user program
feat: user runtime library for writing user space program
wip: initd
refactor: separate user space code from kernel code (syscall and some inits)
refactor: rewrite makefile to make it more flexible and modular

2 years agofeat: heap support and re-worked
Minep [Sat, 31 Dec 2022 21:57:49 +0000 (21:57 +0000)]
feat: heap support and re-worked
refactor: re-worked user program bootstraping
refactor: mm_region interfacings
refactor: remove kalloc, as no longer needed.
regression: mmap, munmap

2 years agofeat: basic elf32 loader (only LOAD segment is supported)
Minep [Sat, 31 Dec 2022 01:26:10 +0000 (01:26 +0000)]
feat: basic elf32 loader (only LOAD segment is supported)
feat: execve(2)
feat: MAP_FIXED, MAP_FIXED_NOREPLACE
refactor: mem_map: improved arguments passing
refactor: mm_region: custom page init policy and managed region_release()
refactor: use mem_map to create user stack
chore: update READMEs

2 years agofeat: msync(2)
Minep [Thu, 29 Dec 2022 20:53:39 +0000 (20:53 +0000)]
feat: msync(2)
fix: sync mappings when destorying process
fix: regression on mmap(2)
refactor: rename PD_REFERENCE to VMS_SELF
refactor: rename PD_MOUNT_1 to VMS_MOUNT_1

2 years agorefactor: separate syscall interfaces from kernel space, into posix compliant structure.
Minep [Thu, 29 Dec 2022 01:03:17 +0000 (01:03 +0000)]
refactor: separate syscall interfaces from kernel space, into posix compliant structure.

2 years agoregression: mmap for fd
Minep [Wed, 28 Dec 2022 23:19:19 +0000 (23:19 +0000)]
regression: mmap for fd
fix: replace %ebp register to %esi for passing 5-th arg when switching to syscall dispatcher.
feat: support for anonymous mapping
refactor: mm_region interfaces
refactor: page fault handler clean up.
refactor: resolve cyclic dependencies between mm.h and fs.h
refactor: rename readdir to sys_readdir to distinguish readdir(3)
wip refactor: separating syscall definitions to userspace.

2 years agoMerge pull request #10 from jackwang0108/master
Lunaixsky [Sun, 11 Dec 2022 14:52:19 +0000 (14:52 +0000)]
Merge pull request #10 from jackwang0108/master

Add all-build tool

2 years agoadd all-build tool. Add qemu support, add configure option support
JackWang [Fri, 9 Dec 2022 15:48:56 +0000 (09:48 -0600)]
add all-build tool. Add qemu support, add configure option support

2 years agoMerge pull request #8 from Catrol-s-Forks/master
Lunaixsky [Thu, 8 Dec 2022 13:27:59 +0000 (13:27 +0000)]
Merge pull request #8 from Catrol-s-Forks/master

Update README.md for link

2 years agoUpdate README_en.md
常青园晚 [Thu, 8 Dec 2022 11:53:54 +0000 (19:53 +0800)]
Update README_en.md

3 years agoUpdate README.md
常青园晚 [Wed, 7 Dec 2022 05:52:50 +0000 (13:52 +0800)]
Update README.md

3 years agoMerge branch 'master' into prog-loader
Minep [Mon, 5 Dec 2022 20:25:20 +0000 (20:25 +0000)]
Merge branch 'master' into prog-loader

3 years agorefactor: vfs_open: start opening iff there is a empty fd slot available.
Minep [Mon, 5 Dec 2022 20:23:52 +0000 (20:23 +0000)]
refactor: vfs_open: start opening iff there is a empty fd slot available.

3 years agofeat: (vm) memory mapping support: mmap/munmap
Minep [Sun, 20 Nov 2022 22:28:38 +0000 (22:28 +0000)]
feat: (vm) memory mapping support: mmap/munmap
fix: (vm_region) ensure the ordering of regions.
fix: (hal/rnd) correct the clobbered register name.

3 years agofeat: (device) dev_null and dev_rand support
Minep [Sun, 20 Nov 2022 15:04:28 +0000 (15:04 +0000)]
feat: (device) dev_null and dev_rand support
feat: versioning stuff

3 years agofeat: (iso9660) finishing up unmount
Minep [Sun, 13 Nov 2022 23:42:08 +0000 (23:42 +0000)]
feat: (iso9660) finishing up unmount
fix: (vfs) no need to do sync when inode getting evicted

3 years agorefactor: replace all stdint::uint32_t into short and more manageable u32_t
Minep [Sun, 13 Nov 2022 22:20:45 +0000 (22:20 +0000)]
refactor: replace all stdint::uint32_t into short and more manageable u32_t

3 years agofeat: (iso9660) rock ridge extension
Minep [Sun, 13 Nov 2022 00:08:59 +0000 (00:08 +0000)]
feat: (iso9660) rock ridge extension
fix: (pcache) over-reading the page cache

3 years agoupdate readme
Minep [Sat, 12 Nov 2022 20:07:19 +0000 (20:07 +0000)]
update readme
add materials related to ISO9660 file system

3 years agofeat: (vfs) write_page and read_page file operations
Minep [Fri, 11 Nov 2022 23:45:51 +0000 (23:45 +0000)]
feat: (vfs) write_page and read_page file operations
fix: (iso9660) infinite loop when scanning iso9660 volume descriptors
chore: clean up

3 years agofeat: (iso9660) implement file read (for both interleaved and non-interleaved mode)
Minep [Fri, 11 Nov 2022 21:45:16 +0000 (21:45 +0000)]
feat: (iso9660) implement file read (for both interleaved and non-interleaved mode)
fix: (blkio) race condition between blkio_commit and pwait
fix: regression
chore: clean up

3 years agofeat: (iso9660) directory read support
Minep [Fri, 11 Nov 2022 19:50:54 +0000 (19:50 +0000)]
feat: (iso9660) directory read support
feat: (syslog) syslog syscall for kernel-level logging in userspace
feat: (blkio) block io feature in sector level granularity
refactor: (vfs) simplify some interfaces
refactor: (vfs) verbose logging on mount
refactor: (lunaix) rename proc.h to lunaix.h
fix: regression
chore: code clean up and add verbose logging message

3 years agofix: (blkio) enforce disk io buffer size alignment (to block size)
Minep [Thu, 10 Nov 2022 22:15:09 +0000 (22:15 +0000)]
fix: (blkio) enforce disk io buffer size alignment (to block size)
fix: (blkio) handle buffer smaller than block size
fix: (ahci) handle the hba interrupt as per spec
refactor: (vecbuf) a more compact interface

3 years agofeat: (ahci) support multiple AHCI controller
Minep [Thu, 10 Nov 2022 18:33:40 +0000 (18:33 +0000)]
feat: (ahci) support multiple AHCI controller
feat: (pci) pci device driver auto-binding
refactor: (isrm) change the interrupt vector type to int
fix: (waitq) mitigation of possible race condition in pwait
fix: (sched) expand stack size of dummy process for allowance in the using of kprintf
refactor: (kinit) reserve the higher half space as earlier as possible.

3 years agorefactor: more compact log message
Minep [Thu, 10 Nov 2022 13:52:47 +0000 (13:52 +0000)]
refactor: more compact log message

3 years agofix: add dummy process to keep scheduler busy
Minep [Thu, 10 Nov 2022 12:53:53 +0000 (12:53 +0000)]
fix: add dummy process to keep scheduler busy
refactor: reduce boot stack size
fix: regression

3 years agofeat: block partition support
Minep [Thu, 10 Nov 2022 02:04:20 +0000 (02:04 +0000)]
feat: block partition support
feat: GUID Partition Table parsing
fix: regression

3 years agofix: memory leakage in file descriptor allocation
Minep [Wed, 9 Nov 2022 21:42:11 +0000 (21:42 +0000)]
fix: memory leakage in file descriptor allocation

3 years agofix: use wait queue for blocking process
Minep [Wed, 9 Nov 2022 18:44:24 +0000 (18:44 +0000)]
fix: use wait queue for blocking process
test: regression on the async io feature.
refactor: centeralize process state changing.

3 years agofeat: asynchronized SATA IO
Minep [Wed, 9 Nov 2022 00:35:48 +0000 (00:35 +0000)]
feat: asynchronized SATA IO
feat: vectorized buffer for flexibility
refactor: block device subsystem.

3 years agoMerge branch 'iso-9660' into block-io
Minep [Sun, 6 Nov 2022 13:41:22 +0000 (13:41 +0000)]
Merge branch 'iso-9660' into block-io

3 years agofix: ensure inlining
Minep [Sun, 23 Oct 2022 11:49:15 +0000 (12:49 +0100)]
fix: ensure inlining
prerequisites check before compiling
add some housekeeping stuff

3 years agoMerge branch 'master' into iso-9660
Minep [Sun, 23 Oct 2022 01:34:09 +0000 (02:34 +0100)]
Merge branch 'master' into iso-9660

3 years agofix: temporary disable the cse optimizations that cause kernel misbehave.
Minep [Sun, 23 Oct 2022 01:16:07 +0000 (02:16 +0100)]
fix: temporary disable the cse optimizations that cause kernel misbehave.

3 years agofix: bugs related to O2 optimization
Minep [Sun, 23 Oct 2022 00:23:11 +0000 (01:23 +0100)]
fix: bugs related to O2 optimization
fix: change default optimization level to O1 as temp workaround.

3 years agorefactor: isrm to centeralize interrupt/irq resources management.
Minep [Sat, 22 Oct 2022 00:13:59 +0000 (01:13 +0100)]
refactor: isrm to centeralize interrupt/irq resources management.

3 years agolaying out the iso9660 structure definitions
Minep [Fri, 21 Oct 2022 21:52:08 +0000 (22:52 +0100)]
laying out the iso9660 structure definitions
fix: switch the order of hash mangling, as it gives higher empirical collision rarity.
refactor: own primitive type shadowing, will be good for future portability.