Commit Graph

190 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen 5162a12d03 Further cleanup and refactoring of the interrupt code. 2012-02-29 23:03:40 +01:00
Jonas 'Sortie' Termansen 0e48b23429 Refactored the interrupt code to make it cleaner and more flexible.
Added support for hooking directly into an interrupt with your own
interrupt handler.
2012-02-29 15:40:30 +01:00
Jonas 'Sortie' Termansen 7ebed6dd6a sortix/io.cpp now uses <sortix/seek.h>. 2012-02-24 22:02:01 +01:00
Jonas 'Sortie' Termansen cbdf54fcdd Moved SEEK_SET, SEEK_CUR, and SEEK_SET to <sortix/seek.h>. 2012-02-24 17:34:50 +01:00
Jonas 'Sortie' Termansen 5de83df6ec Unified constants from sortix/filesystem.h and <fcntl.h> in <sortix/fcntl.h>. 2012-02-23 13:15:40 +01:00
Jonas 'Sortie' Termansen 03273d0076 Added stubs for stat(2), and fstat(2). 2012-02-22 00:30:34 +01:00
Jonas 'Sortie' Termansen edd806fc74 Added a Refcounted class, useful for refcounted objects. 2012-02-21 20:12:52 +01:00
Jonas 'Sortie' Termansen 74dab2cbca Cleaned up the Sortix makefile. 2012-02-13 13:16:43 +01:00
Jonas 'Sortie' Termansen fec176fa15 Refactored the libmaxsi/ directory.
C and C++ files are now kept together and so are the mxmpp declarations.

Header files are now stored in include/ and mxmpp'd into preproc/.

All other code now -I ../libmaxsi/preproc.

And other stuff to make this happen, including refactoring Makefile.
2012-02-12 13:20:53 +01:00
Jonas 'Sortie' Termansen 4e29f2b907 Fixed spelling error in sortix/*/bits.h. 2012-02-11 21:20:49 +01:00
Jonas 'Sortie' Termansen ead53567a1 Made the compile process a little less verbose. 2012-02-11 19:06:00 +01:00
Jonas 'Sortie' Termansen ed68db03fb Replaced SORTIX_EXTENSIONS macro with _SORTIX_SOURCE macro.
<features.h> declares _SORTIX_SOURCE if no conflicting macros are
declared, such as _GNU_SOURCE.

Fixed g++ automatically declaring _GNU_SOURCE, but Sortix isn't GNU.

Replaced SORTIX_UNIMPLEMENTED macro with __SORTIX_SHOW_UNIMPLEMENTED.
2012-02-11 18:51:55 +01:00
Jonas 'Sortie' Termansen 028867ab9d Removed the unused and deprecated old <libmaxsi/sortix-keyboard.h> API.
This has been entirely replaced by stdin and <sys/termmode.h>.
2012-02-10 13:46:26 +01:00
Jonas 'Sortie' Termansen c4264d9c2a Ported the user-space programs to use stdin for keyboard access.
The old keyboard API is hereby deprecated and unused.
2012-02-10 13:46:26 +01:00
Jonas 'Sortie' Termansen fa9c7007b4 Implemented a terminal that reads from keyboard and writes to kernel log.
This terminal will provide the keyboard data in a couple modes as /dev/tty.
2012-02-10 13:28:28 +01:00
Jonas 'Sortie' Termansen 4ba906a157 Added a class for handling terminal linebuffering. 2012-02-10 13:28:28 +01:00
Jonas 'Sortie' Termansen 133fb9871c Fixed buggy and broken KBKEY_ENCODE and KBKEY_DECODE macros. 2012-02-10 13:28:28 +01:00
Jonas 'Sortie' Termansen 5fde8e13ed Blocking systemcalls now return EBLOCKING instead of EWOULDBLOCK.
EWOULDBLOCK is now used when it wanted to block, but didn't.
2012-02-10 13:28:28 +01:00
Jonas 'Sortie' Termansen 9bcfdad174 Added protection against running terminated threads.
A bool is set when a thread is terminated, which may help detect it.

A cached version of the thread's pid is also kept around.

And lastly, the thread is unsubscribed from events upon destruction.
2012-02-10 13:27:11 +01:00
Jonas 'Sortie' Termansen f6f0d24b5c Added TERMMODE_NONBLOCK.
This allows user-space to query whether data is available.
2012-01-22 18:38:46 +01:00
Jonas 'Sortie' Termansen ecc3114f2a Refactored the system to use the new Terminal interface.
This will allow development of a better terminal providing stdin.

Added new system calls settermmode(2) and gettermmode(2) declared in
<sys/termmode.h>. They allow querying and changing the current mode of
terminals (enabling raw keyboard data, signal handling, line buffering,
UTF-8 encoding stdin, and more). However, all that is unsupported by the
current terminal device driver.

Added KBKEY_ENCODE and KBKEY_DECODE macros to <sys/keycodes.h> which allows
encoding the kbkey format in UTF-32 characters.
2012-01-22 16:48:57 +01:00
Jonas 'Sortie' Termansen ead0e1523f Refactored the kernel keyboard API, but kept system calls compatible.
Caps lock now works as caps lock, not as shift lock.

This new design will allow implementing a working tty, such that stdin is
the only way to access the keyboard, instead of the current hacky way of
using a special system call to read from the keyboard.

Added a new system header file <sys/keycodes.h> defining the constants for
every key on the keyboard. This will be used in future APIs.

The main change is to split the keyboard driver into a class that reads
from the keyboard, while another class handles the translation into
printable characters (if possible). This allows a terminal driver based
on logical key presses and printable characters, instead of a terminal
driver based only on unicode-ish codes.
2012-01-22 15:53:50 +01:00
Jonas 'Sortie' Termansen 16dd39e467 Added a nice Log::PrintData function to the kernel.
This allows writing binary data to the kernel log.
2012-01-22 02:12:52 +01:00
Jonas 'Sortie' Termansen 1f3f85b609 Added a simple utf8 encoder in the kernel. 2012-01-22 00:56:58 +01:00
Jonas 'Sortie' Termansen 83aeec2514 Multiple threads can now wait on the same pipe. 2012-01-18 17:19:08 +01:00
Jonas 'Sortie' Termansen ba2cb5103a Made Device::IsType 'const', because it is. 2012-01-18 01:11:17 +01:00
Jonas 'Sortie' Termansen 35fc0f6dfe Removed the old unused interrupt 177. 2012-01-15 19:00:05 +01:00
Jonas 'Sortie' Termansen 93fb66ff90 Refactored Interrupt handlers to provide a user pointer. 2012-01-15 18:32:42 +01:00
Jonas 'Sortie' Termansen c8c34d3cdd readdirents(2) now properly reports ERANGE. 2012-01-15 00:43:13 +01:00
Jonas 'Sortie' Termansen f476a82498 Fixed idention error in ramfs. 2012-01-14 23:19:31 +01:00
Jonas 'Sortie' Termansen c94f6b64c3 readdirents(2) now returns ERANGE if insufficient storage space
was provided, but that the needed size could be copied to d_namelen.
2012-01-14 23:06:18 +01:00
Jonas 'Sortie' Termansen 8ef439b328 Fixed NULL-pointer in SysReadDirEnts. 2012-01-14 22:57:17 +01:00
Jonas 'Sortie' Termansen 56084556bb Added stubs for truncate(2) and ftruncate(3). 2012-01-14 16:37:21 +01:00
Jonas 'Sortie' Termansen 0519af33ee Added stubs for rmdir(2) and mkdir(2). 2012-01-14 16:25:28 +01:00
Jonas 'Sortie' Termansen ad200ffa91 Added getpagesize(2) with the new return type size_t.
This function is non-standard  and size_t is better than int here.
2012-01-08 14:58:57 +01:00
Jonas 'Sortie' Termansen d3ad36b181 Made detected ATA devices available as /dev/ataN block devices. 2012-01-08 14:21:36 +01:00
Jonas 'Sortie' Termansen a3a2226bb5 Implemented a simple ATA PIO Mode driver that can read and write.
Read operations are enabled by default, but you must set DISKWRITE=1 in
makeflags before write operations are permitted. This protects against
accidentally corrupting the existing filesystems on the system.
2012-01-08 14:20:39 +01:00
Jonas 'Sortie' Termansen 4e0f57f4d7 DevFileWrapper now understands and respects O_TRUNC. 2012-01-08 14:15:51 +01:00
Jonas 'Sortie' Termansen 648b324385 Added lseek(2). 2011-12-26 23:12:12 +01:00
Jonas 'Sortie' Termansen 36b01eb2d3 Fixed the horrible 'nofoo' bug!
When compiled with gcc 4.6.1, 32-bit Sortix would triple fault during
early boot: When the TLB is being flushed, somehow a garbage value had
sneaked into Sortix::Memory::currentdir, and a non-page aligned (and
garbage) page directory is loaded. (Triple fault, here we come!)

However, adding a volatile addr_t foo after the currentdir variable
actually caused the system to boot correctly - the garbage was written
into that variable instead. To debug the problem, I set the foo value
to 0: as long as !foo (hence the name nofoo) everything was alright.

After closer examination I found that the initrd open code wrote to a
pointer supplied by kernel.cpp. The element pointed to was on the
stack. Worse, its address was the same as currentdir (now foo).

Indeed, the stack had gone into the kernel's data segment!

Turns out that this gcc configuration stores variables in the data
segment in the reverse order they are defined in, whereas previous
compilers did the opposite. The hack used to set up the stack during
early boot relied on this (now obviously incorrect) fact.

In effect, the stack was initialized to the end of the stack, not
the start of it: completely ignoring all the nice stack space
allocated in kernel.cpp.

I did not see that one coming.
2011-12-25 03:41:59 +01:00
Jonas 'Sortie' Termansen 7bc1fa259e Made Sortix compatible with gcc 4.6.1.
This commit fixes some instances of uninitialized memory.

In addition, the bootstrap tables for x64 are moved around a bit,
in this awful game of placing stuff where it won't collide with grub.
2011-12-25 00:10:56 +01:00
Jonas 'Sortie' Termansen ffe3cc49f2 Now counting memory usage in a more solid manner. 2011-12-23 16:45:07 +01:00
Jonas 'Sortie' Termansen ba9b715c59 Added a global variable at the end of the kernel to detect its size.
This lets the kernel use any memory not directly used by it or the
init ramdisk. Although, now we test whether the kernel fits into
the identitymapped area. It can't really grow down there, unless it
wants to collide with user-space. Instead, modules and the like
(when they are invented), should be put in the upper memory. Or in
their own user-space process, yay, microkernel!
2011-12-23 13:09:09 +01:00
Jonas 'Sortie' Termansen 0515111314 The initial ramdisk is now mapped onto a special location.
This fixes issues where it did not fit into the first few MiB,
or that GRUB loaded it someplace weird.

The kernel heap is now also protected against growing into the
ramdisk and the kernel stack.
2011-12-22 14:13:18 +01:00
Jonas 'Sortie' Termansen a623b1b07e Fixed registering memstat(2) multiple times. 2011-12-22 12:59:48 +01:00
Jonas 'Sortie' Termansen c8c08e7b90 Moved the make-color-red code into DoWelcome in kernel.cpp. 2011-12-22 12:56:29 +01:00
Jonas 'Sortie' Termansen 0f5864602f Fixed bad filename written in elf.cpp. 2011-12-16 15:35:45 +01:00
Jonas 'Sortie' Termansen 7cd28f097c Program loader now sets the correct program segment type. 2011-12-16 15:33:12 +01:00
Jonas 'Sortie' Termansen acf1eebc98 Added user-space memory allocation. 2011-12-16 13:24:49 +01:00
Jonas 'Sortie' Termansen aae0ed3092 The cursor is disabled when displaying the VGA under JSVM. 2011-12-05 22:13:51 +01:00