Commit Graph

32 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen 5e7605fad2 Implement threading primitives that truly sleep.
The idle thread is now actually run when the system is idle because it
truly goes idle. The idle thread is made power efficient by using the hlt
instruction rather than a busy loop.

The new futex(2) system call is used to implement fast user-space mutexes,
condition variables, and semaphores. The same backend and design is used as
kutexes for truly sleeping kernel mutexes and condition variables.

The new exit_thread(2) flag EXIT_THREAD_FUTEX_WAKE wakes a futex.

Sleeping on clocks in the kernel now uses timers for true sleep.

The interrupt worker thread now truly sleeps when idle.

Kernel threads are now named.

This is a compatible ABI change.
2021-06-23 22:10:47 +02:00
Jonas 'Sortie' Termansen 1f659c49c6 Fix multiboot header not coming first in the executable.
The default linker script places .text.unlikely prior to .text.
2018-12-08 22:34:49 +01:00
Pedro Falcato c0a44e72a6
Clear the direction flag upon entry to the kernel. 2017-06-12 21:26:26 +01:00
Pedro Falcato 205a3e7156
Remove not_rsp and not_esp. 2016-10-30 12:03:47 +00:00
Jonas 'Sortie' Termansen 8f81f990f8 Fix undefined stack register after switch into long mode.
Thanks to dminuoso for pointing out the issue.
2016-07-29 15:20:05 +02:00
Jonas 'Sortie' Termansen 9b98679885 Clean up errno. 2016-05-15 22:43:29 +02:00
Jonas 'Sortie' Termansen 9f77beaea6 Fix floating point registers of new threads. 2016-03-26 23:29:09 +01:00
Jonas 'Sortie' Termansen 2b72262b4f Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.

All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.

All imported code from other projects is compatible with this license.

All GPL licensed code from other projects had previously been removed.

Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-05 22:21:50 +01:00
Jonas 'Sortie' Termansen 2e3d7c45af Add paging no-execute and write protection support.
Enable the NX bit on x86_64 and set if not PROT_EXEC and enable the write
protection mode (CR0.WP) that disables the default behavior where the kernel
is able to write to read-only memory. Fix kernel broken assumptions it can
access read-only memory and take care to never set PROT_KWRITE on user-space
pages unless PROT_WRITE is also set, otherwise user-space will be able to
write to read-only memory.

This achieves X^W in the whole system except for the core kernel itself as
it is currently don't know the purpose of pages when identity mapping the
first 4 MiB.
2016-01-25 17:39:57 +01:00
Jonas 'Sortie' Termansen dad5c57f33 Allow bootloader bitmap framebuffer modesetting. 2016-01-08 19:56:11 +01:00
Jonas 'Sortie' Termansen 3e068bc88f Fix x86 Alignment Check and Security Exception handlers.
The processor pushes an error code when delivering these exception.

Discovered by Alexandros Alexandrou.
2016-01-07 19:17:04 +01:00
Jonas 'Sortie' Termansen 12b5044bc7 Fix signal delivery during context switch. 2015-10-09 16:17:52 +02:00
Jonas 'Sortie' Termansen 0fc3d70716 Clear registers after system calls. 2015-08-26 16:29:18 +02:00
Jonas 'Sortie' Termansen 218875eb79 Initialize paging before KernelInit. 2015-08-21 21:25:00 +02:00
Jonas 'Sortie' Termansen a422c394b8 Initialize the GDT in the bootstrap assembly. 2015-08-21 21:25:00 +02:00
Jonas 'Sortie' Termansen 524a028a4f Forward compatibility with future rename of _start to __start. 2014-12-28 20:18:58 +01:00
Jonas 'Sortie' Termansen ba1e0882ec Initialize system call table at compile time. 2014-12-03 14:19:49 +01:00
Jonas 'Sortie' Termansen 35708fa900 Retire calltrace support in favor of the kernel debugger. 2014-12-01 21:38:06 +01:00
Jonas 'Sortie' Termansen 749d123331 Maintain counts of physical frames used for particular purposes. 2014-11-26 22:27:04 +01:00
Jonas 'Sortie' Termansen 25e07a9083 Refactor kernel interrupt and thread register support. 2014-11-18 20:33:21 +01:00
Jonas 'Sortie' Termansen 7b3e2fa229 Clean up kernel thread creation code. 2014-11-18 18:10:22 +01:00
Jonas 'Sortie' Termansen 30cd318c17 Implement signals.
Note: This is an incompatible ABI change.
2014-07-22 13:25:39 +02:00
Jonas 'Sortie' Termansen 1f72c1637c Maintain fsbase and gsbase as per-thread registers.
Note: This is an incompatible ABI change.
2014-05-29 17:07:42 +02:00
Jonas 'Sortie' Termansen 0c48dfca96 Fix 4 KiB memory leak on x86_64 for each process. 2014-05-16 14:48:27 +02:00
Jonas 'Sortie' Termansen e941ff0430 Rename useresp to esp and userrsp to rsp. 2014-03-17 19:22:13 +01:00
Jonas 'Sortie' Termansen a133a7717e Refactor i386 and x86_64 interrupt support. 2014-03-17 19:22:13 +01:00
Jonas 'Sortie' Termansen cacd010066 Update kernel/{x64/x64,x86/x86}.cpp to current coding conventions. 2014-03-01 14:37:41 +01:00
Jonas 'Sortie' Termansen fcb8ae3af3 Update kernel/{x64,x86}/thread.cpp to current coding conventions. 2014-03-01 14:37:41 +01:00
Jonas 'Sortie' Termansen ccb0f368a3 Update kernel/{x64,x86}/process.cpp to current coding conventions. 2014-03-01 14:37:41 +01:00
Jonas 'Sortie' Termansen a099f82890 Update kernel memory management to current coding conventions. 2014-03-01 14:37:40 +01:00
Jonas 'Sortie' Termansen 6788f0096e Preprocess assembly files with the C preprocessor. 2014-03-01 14:37:40 +01:00
Jonas 'Sortie' Termansen 98a87fa1e5 Rename Sortix kernel directory to kernel. 2014-03-01 14:37:39 +01:00