Commit Graph

441 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen 950610e1eb Added a kernel worker thread for use when the kernel goes multithreaded. 2012-08-04 18:35:23 +02:00
Jonas 'Sortie' Termansen ee73aa7783 Added a library of functions to simulate atomic operations on memory. 2012-08-04 18:35:23 +02:00
Jonas 'Sortie' Termansen dafe1c499d Thread secured pipe class. 2012-08-04 18:35:23 +02:00
Jonas 'Sortie' Termansen 66d7234ab1 Thread secured logterminal class and implemented VEOF. 2012-08-04 18:35:23 +02:00
Jonas 'Sortie' Termansen bf07674d7a Thread secured the keyboard driver. 2012-08-04 18:35:23 +02:00
Jonas 'Sortie' Termansen af015491db sortix/io.cpp is now ready for new system call semantics. 2012-08-04 18:35:23 +02:00
Jonas 'Sortie' Termansen 4810ccae39 Added warning in case the laws of logic changes. 2012-08-04 18:35:23 +02:00
Jonas 'Sortie' Termansen 2e3843ffce Fixed incorrect x86-family protection flags. 2012-08-04 18:35:23 +02:00
Jonas 'Sortie' Termansen 49ad293d1d Thread secured the physical page allocator. 2012-08-04 18:35:23 +02:00
Jonas 'Sortie' Termansen 459a1b2b3f Thread secured initfs. 2012-08-04 18:35:23 +02:00
Jonas 'Sortie' Termansen f00c8b3d63 Thread secured the kernel device class. 2012-08-04 18:35:23 +02:00
Jonas 'Sortie' Termansen 38349da082 Thread secured the COM driver. 2012-08-04 18:35:22 +02:00
Jonas 'Sortie' Termansen f3f33e22e7 Thread secured ATA driver. 2012-08-04 18:35:22 +02:00
Jonas 'Sortie' Termansen eb4f179330 Added DEBUG_KERNEL option to kernel makefile. 2012-08-04 18:35:22 +02:00
Jonas 'Sortie' Termansen 199fec6674 Hack: ReadParamString supports "STOP" because of stdarg bug. 2012-08-04 18:35:22 +02:00
Jonas 'Sortie' Termansen 14d709c136 Added support for gcc 4.7.1. 2012-08-04 18:33:47 +02:00
Jonas 'Sortie' Termansen 78300931ba Workarounds for older gcc releases such that endian.h works. 2012-08-02 16:24:51 +02:00
Jonas 'Sortie' Termansen 86f8662a4e The VGA font is now available as /dev/vga. 2012-08-01 13:07:47 +02:00
Jonas 'Sortie' Termansen f3532081aa Added a filesystem utility class for providing a fixed buffer. 2012-08-01 13:07:31 +02:00
Jonas 'Sortie' Termansen 8dc5955f5e Wrote a driver for the Bochs VBE Extensions (BGA). 2012-07-30 19:03:48 +02:00
Jonas 'Sortie' Termansen cb5a242dfc Added a text buffer that works with graphical linear frame buffers. 2012-07-30 19:02:05 +02:00
Jonas 'Sortie' Termansen 78f0c6c094 The video framework is now exposed as /dev/video.
This provides easy user-space access to the framebuffer.
2012-07-30 19:00:24 +02:00
Jonas 'Sortie' Termansen 1ce55af846 Created framework for video drivers.
This supports dynamic loading and unloading of graphics drivers, mode
switching and detection and flexible kernel access to the framebuffer.
2012-07-30 19:00:24 +02:00
Jonas 'Sortie' Termansen d27a2bdcbf Better detection of panicing while panicing. 2012-07-30 18:59:13 +02:00
Jonas 'Sortie' Termansen 1041823d42 Fixed VGA text buffer rendering non-ascii text incorrectly. 2012-07-30 18:56:47 +02:00
Jonas 'Sortie' Termansen 3b0f165c4f Fixed bad declaration of MapPAT in x86-family/memorymanagement.h. 2012-07-30 18:56:02 +02:00
Jonas 'Sortie' Termansen 19b5451f3b Refactored the PCI code to become a library of utility functions. 2012-07-29 23:45:54 +02:00
Jonas 'Sortie' Termansen 5f6ca5e729 Added a kernel endian.h header for easy conversion. 2012-07-29 23:45:54 +02:00
Jonas 'Sortie' Termansen f390418515 Preallocated kernel address space for video memory. 2012-07-24 20:08:51 +02:00
Jonas 'Sortie' Termansen 494636b8eb Added some filesystem utility classes. 2012-07-24 19:56:33 +02:00
Jonas 'Sortie' Termansen 143120d160 Added tcgetwinsize(2) for determining terminal resolution.
Unfortunately this area is not standardized by POSIX. Linux uses an ioctl
which is not that bad, but I'd like to have a designated function. I'm not
sure if this facility is powerful enough and whether it should be improved.
Also note that I use a struct winsize as on Linux, but I use size_ts instead
for the heck of it. Perhaps I should use another name for the struct.
2012-07-24 18:43:34 +02:00
Jonas 'Sortie' Termansen f5c4b64aff The console can now be rendered to any text buffer.
The console renderer now renders to a text buffer, which can be implemented
on any device, whether it's the VGA text buffer or a bitmap graphics device
with font rendering. This replaces the older code that could only render to
a VGA framebuffer and where the input parsing was tightly coupled with the
device rendering phase.
2012-07-24 14:48:14 +02:00
Jonas 'Sortie' Termansen 8c5ab54c9b Updated refcount.cpp to a newer coding convention. 2012-07-23 00:05:31 +02:00
Jonas 'Sortie' Termansen 3907e14cb8 Updated vgaterminal.cpp to newer coding conventions. 2012-07-23 00:05:31 +02:00
Jonas 'Sortie' Termansen d75a7145ef Updated vga code to newer coding conventions. 2012-07-23 00:05:31 +02:00
Jonas 'Sortie' Termansen b2814db927 Added support for getting a copy of the VGA Font.
This will be useful for providing a text-mode like environment (console)
after having switched to graphical mode where the system needs a font.
2012-07-22 15:51:38 +02:00
Jonas 'Sortie' Termansen 476ba278da Improved VGA scroll performance using memcpy(3). 2012-07-17 16:23:00 +02:00
Jonas 'Sortie' Termansen ebc0b064c3 Added a function to get the current address space pointer. 2012-07-06 17:18:07 +02:00
Jonas 'Sortie' Termansen d59c0cb3ed getpagesize(2) now call Sortix::Page::Size(). 2012-07-06 17:18:07 +02:00
Jonas 'Sortie' Termansen 22990b77b8 Refactored the internal kernel memory management API.
It is now permission-oriented, not just user/kernel oriented.

Added <sys/mman.h> with nice PROT_{READ,WRITE,EXEC,FORK} constants.
2012-07-06 17:18:07 +02:00
Jonas 'Sortie' Termansen ec5fa92761 Programmers can now redirect what the errno macro refers to. 2012-07-06 17:18:06 +02:00
Jonas 'Sortie' Termansen e7baf6a4b0 Updated the kthread compatibility layer with signal support. 2012-07-06 17:17:45 +02:00
Jonas 'Sortie' Termansen c39473157a Implemented a new initrd format with better inode support.
This enables useful features such as directories, CRC32 checksums, and other
useful features. The initrdfs in the kernel is now hooked up against the new
API, although the kernel's current limited FS support is a problem for now.
To work around that, directories are not supported at runtime, although the
internal API understands them wonderfully. This will be fixed when the
kernel gets a real VFS.
2012-07-02 17:40:52 +02:00
Jonas 'Sortie' Termansen 2046482e77 Added support for MSRs, PAT and MTRRs.
This provides control over the caching of memory, which makes write-combined
IO possible. Graphics drivers can use this to transfer data at a much higher
rate to the video memory.

The implementation is a bit hacky but it'll do for now. It provides enough
support for the experimental VBE driver to work on the real computers I
tested it on, even if the BIOS uses screwed up default MTRRs.

The virtual memory layer now automatically uses the PAT feature if available
but in a backwards compatible manner and otherwise just tries to approximate
PAT features if they are asked for.
2012-07-01 00:55:36 +02:00
Jonas 'Sortie' Termansen b650c9a8f0 Added a O_ACCMODE flag for GNU compatibility. 2012-05-28 22:52:11 +02:00
Jonas 'Sortie' Termansen 00869bcdc1 The PIC can now be deprogrammed and reprogrammed. 2012-05-26 14:00:24 +02:00
Jonas 'Sortie' Termansen bd489eb73a Forward compatbility with the kthread branch. 2012-05-04 13:13:44 +02:00
Jonas 'Sortie' Termansen 92c5533820 Improved the implementation of the exec* functions. 2012-04-30 21:10:02 +02:00
Jonas 'Sortie' Termansen 93abeda32e Fixed buffer overflow in devfs.cpp. 2012-04-14 22:03:55 +02:00
Jonas 'Sortie' Termansen 3b63a70191 Added Interrupt::SetEnabled(bool). 2012-04-13 17:42:21 +02:00
Jonas 'Sortie' Termansen f59b53ddce Ported x64 interrupt assembly to the GNU assembler. 2012-04-13 17:34:17 +02:00
Jonas 'Sortie' Termansen 8cbf9ff8f0 Added Interrupt::IsEnabled(). 2012-04-11 15:46:32 +02:00
Jonas 'Sortie' Termansen 36ff6c7f96 seek(2) now correctly rejects a bad whence value. 2012-04-10 13:20:33 +02:00
Jonas 'Sortie' Termansen 6367a2352e Added sforkr(2) that controls the child registers as well.
sfork(2) now calls sforkr(2) with the current registers.

This will prove useful in creating threads, where user-space now can fully
control what state the child will start in. This is unlike the Linux clone
system call that accepts a pointer to the child stack; this is more powerful
and somehow simpler. Note that this will create a rather raw thread; no
thread initization has been done by the standard thread API (when it is
implemented), so this feature shouldn't be used by programmers unless they
know what they are doing.

fork(2) now calls sfork(2) directly. Also removed fork(2) and sfork(2) from
the kernel as they are done using sforkr(2) now. So technically they aren't
system calls right now, but that could always change.
2012-04-05 23:00:47 +02:00
Jonas 'Sortie' Termansen 6f36ecf0b3 execve(2) now pushes envp to the new stack and sets up registers.
This fully implements environmental variables over exec.
2012-04-04 01:49:14 +02:00
Jonas 'Sortie' Termansen 05b29ce25a Renamed rfork(2) to sfork(2) to avoid compatibility issues.
sfork is much like rfork except sharing is default for everything.

Eventually, I'll make a rfork(3) wrapper function around sfork(2) to
provide compatibility to BSD programs.

I don't like Linux clone(2): that's some messy function.
2012-04-04 00:29:25 +02:00
Jonas 'Sortie' Termansen 95a088fec5 Added a dummy implementation rfork(2) equal to fork(2).
Note that in my implementation, you share per default, unless you ask.
2012-04-02 16:30:13 +02:00
Jonas 'Sortie' Termansen b3b1f6af66 Make sure that the right bits.h file is always included. 2012-03-27 16:36:55 +02:00
Jonas 'Sortie' Termansen 554b2e44cc Added a Page::IsAligned inline function. 2012-03-26 16:46:26 +02:00
Jonas 'Sortie' Termansen c62eb09cdc Added stubs for pread(2) and pwrite(2).
These are not implemented yet because the current kernel design is bad.

However, I need the stubs for other code.
2012-03-24 15:23:07 +01:00
Jonas 'Sortie' Termansen 1ba4417b19 Removed dead ancient code. 2012-03-22 01:04:27 +01:00
Jonas 'Sortie' Termansen db79994e64 Refactored all the sortix headers into a include directory.
Also got rid of trailing white space. That corrupted .git/.

Big ass-commit because of recovered .git directory.
2012-03-22 00:52:29 +01:00
Jonas 'Sortie' Termansen ea11c20689 Added a way for discover refcount of Refcounted classes. 2012-03-21 16:20:41 +01:00
Jonas 'Sortie' Termansen 0f099c65ca The virtual memory fork code can now handle ENOMEM conditions.
(forkbombs now don't panic the system!)
2012-03-19 02:39:11 +01:00
Jonas 'Sortie' Termansen c9ab4fa6b4 The sortix vga terminal now can delete tabs and newlines properly.
A nice little vga attribute array takes care of remembering what indexes
actually contains a character.
2012-03-18 18:06:13 +01:00
Jonas 'Sortie' Termansen 14a9149f17 Added detection for an obscure bug to let users know I know about it. 2012-03-18 17:36:31 +01:00
Jonas 'Sortie' Termansen d564603460 Fixed kernel stack overflow and premature EOF in the unix pipe code.
This usually caused the system to lock up when much data was transferred
over pipes, for instance: $ cd /bin ; cat cat | cat
2012-03-18 16:14:26 +01:00
Jonas 'Sortie' Termansen c7c0fc603a Fixed initial kernel stack being wrong size. 2012-03-17 20:17:12 +01:00
Jonas 'Sortie' Termansen 969c0e8048 Cleaned up sortix/kernel.cpp and it now uses the new coding style.
All kernel.cpp code related to jssortix was removed as it is not supported
any longer.
2012-03-17 20:11:37 +01:00
Jonas 'Sortie' Termansen 4f3e22140c Fixed x64 memory leaks upon process termination. 2012-03-17 18:14:57 +01:00
Jonas 'Sortie' Termansen 0364ce6f55 Added a new COM Port driver.
Any detected COM ports available as /dev/comN.

It currently utilizes AGAIN to do polling in user-space. This prevents it
from locking up the whole system and makes it respond to the SIGINT hack.

There is also a more reliable and faster polling-blocking mode, but it locks
up the entire system.

The main interrupt mode is broken, perhaps by a bug in VirtualBox.
2012-03-17 15:48:42 +01:00
Jonas 'Sortie' Termansen 1ff0321400 Added a stub for Syscall::Yield() which is used by broken code.
The whole system call interface is currently stupid.
2012-03-17 15:14:42 +01:00
Jonas 'Sortie' Termansen 798b421d16 Refactored devfs so new devices can easily be added. 2012-03-17 15:11:35 +01:00
Jonas 'Sortie' Termansen 5ec4e33196 Removed the last reference to the old kernel HTTP server. 2012-03-16 16:56:16 +01:00
Jonas 'Sortie' Termansen 2cdeb575f8 Renamed EACCESS to EACCES.
Stupid POSIX.
2012-03-12 01:43:00 +01:00
Jonas 'Sortie' Termansen 5b916b5f63 Added F_SETFL and F_GETFL to fcntl(2).
This is a bit of a hacky implementation.
2012-03-11 20:29:00 +01:00
Jonas 'Sortie' Termansen 868ed43e05 Removed sortix/mxfs.
It's unbelievable that this piece of dead code survived 8 months of
development on git. It doesn't even work, despit the comment that it
does.
2012-03-11 18:07:01 +01:00
Jonas 'Sortie' Termansen f01d7951c1 stat(2) now supports directories.
A bit hackily, though.
2012-03-11 17:56:20 +01:00
Jonas 'Sortie' Termansen 6e536ba8f9 Fixed error codes in sortix/fs/devfs. 2012-03-11 17:55:52 +01:00
Jonas 'Sortie' Termansen 245e8bf0e3 Fixed error codes in sortix/fs/initfs. 2012-03-11 17:55:23 +01:00
Jonas 'Sortie' Termansen f45cf8327a Forgot to enable the /bin /dev hack in sortix/fs/ramfs.cpp. 2012-03-11 17:30:13 +01:00
Jonas 'Sortie' Termansen cadac5ce2a Moved the /bin and /dev hack into the kernel.
This makes ls seem less hacky.
2012-03-11 17:25:32 +01:00
Jonas 'Sortie' Termansen 8a9a0c58ea Added kernelinfo(2), which reads a kernel information string.
Currently it lets you query the name of the kernel, its version, and the
build timestamp of the kernelinfo.cpp file.
2012-03-07 18:04:59 +01:00
Jonas 'Sortie' Termansen 6bcb3d7384 Added stat(2) and fstat(2) in the kernel.
It's a bit hacky, but it works.

lstat(2) currently redirects to stat(2).
2012-03-06 13:10:59 +01:00
Jonas 'Sortie' Termansen 4b2c22d480 Added access(2). 2012-03-05 15:46:23 +01:00
Jonas 'Sortie' Termansen d3c4df72b1 Added st_{a,c,m}time to struct stat. 2012-03-04 22:25:47 +01:00
Jonas 'Sortie' Termansen aa72efdb2c Added <sortix/timeval.h> to the list of public headers. 2012-03-04 22:18:53 +01:00
Jonas 'Sortie' Termansen c0a02248da Added <sys/time.h>, struct timeval and gettimeofday(3) stub. 2012-03-04 22:05:52 +01:00
Jonas 'Sortie' Termansen 5e75f5c428 Added fcntl(3) with FD_GET and FD_SET. 2012-03-04 21:36:40 +01:00
Jonas 'Sortie' Termansen 75b14aa821 Refactored the descriptor table and added FD_CLOEXEC and FD_CLOFORK.
open(2) now also respects O_CLOEXEC and O_CLOFORK.
2012-03-04 21:06:49 +01:00
Jonas 'Sortie' Termansen 777fc04682 Added <time.h>, clock_t, and a stub for clock(3). 2012-03-04 18:38:23 +01:00
Jonas 'Sortie' Termansen ac7e55ffbd Added st_dev to struct stat. 2012-03-04 16:48:24 +01:00
Jonas 'Sortie' Termansen db7781c54a Install <sortix/*.h> headers in sysroot. 2012-03-04 16:04:12 +01:00
Jonas 'Sortie' Termansen 0ed0082070 Added execv(3) and execve(3).
Removed the older libmaxsi system call.
2012-03-02 15:00:11 +01:00
Jonas 'Sortie' Termansen 93a9ee334d Removed a debug ifdef that isn't used. 2012-03-02 14:25:48 +01:00
Jonas 'Sortie' Termansen cfbbf67247 make CALLTRACE=1 to enable printing primitive calltraces upon panic.
This won't work with optimizations turned fully on.

Added protection against double panics.
2012-03-02 14:08:25 +01:00
Jonas 'Sortie' Termansen 6dd0e586ff Added protection against bad addrspace vars and bad Page::Put() calls.
This will offer protection against the bug fixed in the previous commit.
2012-03-02 13:51:03 +01:00
Jonas 'Sortie' Termansen 5e5991ce19 Fixed x86 addrspace destroy code calling Page::Put with garbage. 2012-03-02 13:45:33 +01:00
Jonas 'Sortie' Termansen a7c38cb997 Improved bad currentdir variable panic message. 2012-03-02 00:09:08 +01:00
Jonas 'Sortie' Termansen 9c193777a9 Pipes now return 0 (EOF) if no data and no fds can write. 2012-03-01 14:31:12 +01:00
Jonas 'Sortie' Termansen b4f47f0f79 Split descriptor_tables.cpp into a gdt.cpp and idt.cpp.
This was about time, since descriptor_tables was a really bad name!
2012-03-01 00:15:28 +01:00
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
Jonas 'Sortie' Termansen 2c728fc1f1 VGA now sort-of works under serial-connections. 2011-12-05 21:44:14 +01:00
Jonas 'Sortie' Termansen 9e5b9e3767 Hacks to make the JSVM serial driver work better. 2011-12-05 21:14:50 +01:00
Jonas 'Sortie' Termansen cdb873271d Increased hard-coded maximum JSVM initrd size to 2 MiB 512 KiB. 2011-12-05 19:43:27 +01:00
Jonas 'Sortie' Termansen 7e55f325fc Don't check the initrd on JSVM. 2011-12-05 19:36:15 +01:00
Jonas 'Sortie' Termansen 854d9b171a uptime(2) now reports usecs instead of msecs. 2011-12-04 21:27:21 +01:00
Jonas 'Sortie' Termansen 3b8bf9419d Removed obsolete functions to read from the initrd.
Use the initrd filesystem instead.
2011-12-04 15:38:02 +01:00
Jonas 'Sortie' Termansen b0859c6d92 usleep'ing for 0 usecs simply causes a context-switch. 2011-12-02 22:37:17 +01:00
Jonas 'Sortie' Termansen f8129a17b2 Changed the build system for 64-bit quite a bit.
The kernel is now compiled 100% as 64-bit code and converted to ELF32.
2011-12-01 23:06:34 +01:00
Jonas 'Sortie' Termansen 8e8bb15a1b Improved corruption panic message in initrd.cpp 2011-12-01 23:03:00 +01:00
Jonas 'Sortie' Termansen b0884584a1 Added a very simple checksum field to the init ramdisk.
This uncovers a bug where the bootloader may corrupt the initrd on x64.

This is probably related to our kernel64 hack..
2011-12-01 21:44:11 +01:00
Jonas 'Sortie' Termansen 2faafd3f99 Stack is now aligned in 64-bit Sortix threads. 2011-12-01 21:43:35 +01:00
Jonas 'Sortie' Termansen 7304c8f528 Fixed uninitialized memory bug in the keyboard driver.
This often prevented the letter 'c' from working in x64.
2011-12-01 17:30:14 +01:00
Jonas 'Sortie' Termansen 6562da4092 waitpid(2) now returns ECHILD on error. 2011-12-01 14:54:19 +01:00
Jonas 'Sortie' Termansen cf53e4a020 Fixed 64-bit resumed system calls. 2011-12-01 14:29:49 +01:00
Jonas 'Sortie' Termansen c0c20860ed Lots of improvements to 64-bit Sortix.
Fixed 64-bit-ness bug in BSR() and BSF().
Added 64-bit system call stubs in libmaxsi.
Added a Elf64 program loader.
Fixed uninitialized memory bug in the scheduler.
x64/boot.s now takes care of user-space memory permissions.
Fixed bug in x64/syscall.s

That's right. The system now boots in 64-bit mode.

It is horribly unstable, though.
2011-12-01 10:45:44 +01:00
Jonas 'Sortie' Termansen f460c4abec Added support for 64-bit interrupts. 2011-11-30 23:30:14 +01:00
Jonas 'Sortie' Termansen f0ec4ffacc Forgot to push %rbp in x64/syscall.s 2011-11-29 11:45:00 +01:00
Jonas 'Sortie' Termansen 0b1c2a77c9 x64 now compiles again and runs on real hardware.
A nasty bug was fixed that caused triple faults on systems with > 1 GiB RAM.
2011-11-29 01:31:54 +01:00
Jonas 'Sortie' Termansen 8c146f14c0 Added uptime(1). 2011-11-28 16:29:53 +01:00
Jonas 'Sortie' Termansen f232a054d3 Added O=-ON and PANIC_SHORT=1 variables to the makefile. 2011-11-28 15:25:00 +01:00
Jonas 'Sortie' Termansen cd936886e6 Writing to /dev/vga hides the cursor until a write to /dev/tty. 2011-11-27 12:03:33 +01:00
Jonas 'Sortie' Termansen 4f3a7230b0 Destroying the addressspace after exit prevents leak of at least 16 KiB. 2011-11-27 12:02:34 +01:00
Jonas 'Sortie' Termansen 06909c6df9 Fixed panic when executing non-existent file. 2011-11-27 00:20:23 +01:00
Jonas 'Sortie' Termansen bd1b1fe3bc Added isatty(2), which is used by editor. 2011-11-26 21:00:40 +01:00
Jonas 'Sortie' Termansen 3f50a335bb devfs now correctly manages sizes of files.
This fixes a regression caused by the RAM fix a few commits ago.
2011-11-26 21:00:37 +01:00
Jonas 'Sortie' Termansen ce9787a439 Greatly reduced RAM usage in ramfs. 2011-11-26 20:25:25 +01:00
Jonas 'Sortie' Termansen 9152443816 Added memstat, a program for displaying memory usage. 2011-11-26 20:14:57 +01:00
Jonas 'Sortie' Termansen b6a0fd0374 Removed deprecated VGA API and moved it to /dev/vga. 2011-11-25 13:38:31 +01:00
Jonas 'Sortie' Termansen 724305f3a7 Merge commit '7a233f2938f4e28d61504853e2f6daf4904aab33'
Conflicts:
	sortix/fs/ramfs.cpp
2011-11-24 15:38:45 +01:00
Jonas 'Sortie' Termansen e72d086a8f Disallow / in filenames in ramfs. 2011-11-23 17:51:18 +01:00
Jonas 'Sortie' Termansen 5bf22b2c4a ramfs doesn't allow opening files as directories. 2011-11-23 14:14:59 +01:00
Jonas 'Sortie' Termansen 2b032b0414 Initial signal support. Please squash improvements into this commit. 2011-11-23 00:19:09 +01:00
Jonas 'Sortie' Termansen 46c0cc6a12 -1 is no longer an allowed system call.
This treats a nasty bug where forking and exiting before the child
causes the kernel to panic, because the syscall -1 is run, which
just contains a trash value that happened to be 0.

The cause is still unknown. Might be the scheduler.

This won't help me sleep at night.
2011-11-22 22:08:34 +01:00
Jonas 'Sortie' Termansen b15763b2de Fixed descriptors not being reset by SysExit.
Indirectly, this fixes the snake; snake; panic bug.
2011-11-22 19:12:04 +01:00
Jonas 'Sortie' Termansen e234e0a2d4 execve(2) now sets errno=EACCESS on non-buffer files. 2011-11-22 18:21:01 +01:00
Jonas 'Sortie' Termansen 9deb183786 The ELF loader now uses errno. 2011-11-22 18:06:40 +01:00
Jonas 'Sortie' Termansen 1b56d01f17 Improved error codes in devfs. 2011-11-22 17:56:58 +01:00
Jonas 'Sortie' Termansen 9f35df813e Implemented errno(3), added support in both kernel and utils. 2011-11-22 17:26:47 +01:00
Jonas 'Sortie' Termansen 8678ad6444 / is no longer a valid filename under ramfs. 2011-11-22 15:33:47 +01:00
Jonas 'Sortie' Termansen 2c3fb60d52 execve(2) now works relative to current dir. 2011-11-22 15:27:58 +01:00
Jonas 'Sortie' Termansen e8fb8d885b execve(2) can now load programs from the filesystem.
Previously it was restricted to only the ramdisk.
2011-11-22 14:02:33 +01:00
Jonas 'Sortie' Termansen 324a9a1a22 Fixed bug in initfs causing panics. 2011-11-22 12:44:23 +01:00
Jonas 'Sortie' Termansen 55240fb3f5 Added devfs, with files /tty and /null and mounted it at /dev. 2011-11-21 21:49:13 +01:00
Jonas 'Sortie' Termansen 91a97a2667 Mount-points are now handled properly within the kernel. 2011-11-21 19:39:13 +01:00
Jonas 'Sortie' Termansen 8b2b52b9f6 Added unlink(2) and rm(1). 2011-11-21 19:01:56 +01:00
Jonas 'Sortie' Termansen d4590cefa1 Added chdir(2), getcwd(2), which mxsh and ls now uses. 2011-11-21 12:19:57 +01:00
Jonas 'Sortie' Termansen eb035d6a4a Fixed tripple-fault when creating a new frame, after the current was gc'd.
We'll need to get rid of that awful VGA sometime soon.
2011-11-21 00:27:10 +01:00
Jonas 'Sortie' Termansen 313079483a Missing files from the previous two commits. Ooops! 2011-11-21 00:19:55 +01:00
Jonas 'Sortie' Termansen 0b90ab534f ramfs now supports O_TRUNC. 2011-11-21 00:12:20 +01:00