Commit graph

431 commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen
ae423eaeef Added open(2).
Please note that mount points and file systems do not exist yet.
2011-11-19 00:57:17 +01:00
Jonas 'Sortie' Termansen
15329187b9 Unrefing a device that has never been ref'd will also destroy it. 2011-11-17 23:14:45 +01:00
Jonas 'Sortie' Termansen
708643d0f2 Fixed bug in dup(2). 2011-11-17 23:03:14 +01:00
Jonas 'Sortie' Termansen
dd349a150a Merge branch 'master' of gitorious.org:sortix/sortix
Conflicts:
	libmaxsi/c/hsrc/unistd.h
	libmaxsi/io.cpp
	sortix/io.cpp
	sortix/syscallnum.h
2011-11-17 22:28:20 +01:00
Jonas 'Sortie' Termansen
05196f49b2 Added dup(2). 2011-11-17 20:34:04 +01:00
Jonas 'Sortie' Termansen
e8cd27c353 Added close(2) and fixed bugs in pipe(2) and others. 2011-11-17 10:22:43 +01:00
Jonas 'Sortie' Termansen
a7de7b4905 Added pipe(2), write(2), and read(2). 2011-11-16 21:21:38 +01:00
Jonas 'Sortie' Termansen
ae599b6d67 Argv now works in main. 2011-11-09 23:18:26 +01:00
Jonas 'Sortie' Termansen
9ba01ad3b2 Oh my god, did I include thread.cpp into kernel.cpp!? 2011-11-07 14:36:35 +01:00
Jonas 'Sortie' Termansen
024f1581ea Added the wait() and waitpid() system call. 2011-11-07 00:59:48 +01:00
Jonas 'Sortie' Termansen
851ee78903 Added some support for blocking system calls in the kernel. 2011-11-07 00:48:20 +01:00
Jonas 'Sortie' Termansen
cfd7648ca9 Added the _exit() system call.
exit() will not call _exit() yet, we need support for wait() in the shell.
2011-11-05 20:19:36 +01:00
Jonas 'Sortie' Termansen
09b1252821 Added an AsIs() function to the Syscall namespace. 2011-11-05 20:03:17 +01:00
Jonas 'Sortie' Termansen
196e958336 Added a CPU::ShutDown() function. 2011-11-05 19:13:16 +01:00
Jonas 'Sortie' Termansen
884ce30c07 The scheduler now keeps track of the initial process. 2011-11-05 18:49:30 +01:00
Jonas 'Sortie' Termansen
f9e10ab265 Added an API for user-space to list the initrd, and 'ls' does so now. 2011-11-03 18:26:43 +01:00
Jonas 'Sortie' Termansen
329c8cc468 Merge gitorious.org:sortix/sortix 2011-11-02 20:37:04 +01:00
Jonas 'Sortie' Termansen
0fdfa570cc Removed obsolete IKeystrokable. 2011-11-02 19:43:48 +01:00
Jonas 'Sortie' Termansen
52a228861e cr2 isn't pushed by pushal. 2011-11-02 19:27:46 +01:00
Jonas 'Sortie' Termansen
e110594ab2 Processes are listed in a global array sorted after pid. 2011-11-02 17:51:01 +01:00
Jonas 'Sortie' Termansen
2db3c902fb Fixed missing breaks in switch in vgaterminal.cpp. 2011-11-02 11:39:02 +01:00
Jonas 'Sortie' Termansen
2afe9d1fd6 Implemented the fork() system call and what it needed to work properly.
This commit got completely out of control.

Added the fork(), getpid(), getppid(), sleep(), usleep() system calls, and
aliases in the Maxsi:: namespace.

Fixed a bug where zero-byte allocation would fail.

Worked on the DescriptorTable class which now works and can fork.

Got rid of some massive print-registers statements and replaced them with
the portable InterruptRegisters::LogRegisters() function.

Removed the SysExecuteOld function and replaced it with Process::Execute().

Rewrote the boot sequence in kernel.cpp such that it now loads the system
idle process 'idle' as PID 0, and the initization process 'init' as PID 1.

Rewrote the SIGINT hack.

Processes now maintain a family-tree structure and keep track of their
threads. PIDs are now allocated using a simple hack. Virtual memory
per-process can now be allocated using a simple hack. Processes can now be
forked. Fixed the Process::Execute function such that it now resets the
stack pointer to where the stack actually is - not just a magic value.
Removed the old and ugly Process::_endcodesection hack.

Rewrote the scheduler into a much cleaner and faster version. Debug code is
now moved to designated functions. The noop kernel-thread has been replaced
by a simple user-space infinite-loop program 'idle'.

The Thread class has been seperated from the Scheduler except in Scheduler-
related code. Thread::{Save,Load}Registers has been improved and has been
moved to $(CPU)/thread.cpp. Threads can now be forked. A new CreateThread
function creates threads properly and portably.

Added a MicrosecondsSinceBoot() function.

Fixed a crucial bug in MemoryManagement::Fork().

Added an 'idle' user-space program that is a noop infinite loop, which is
used by the scheduler when there is nothing to do.

Rewrote the 'init' program such that it now forks off a shell, instead of
becoming the shell.

Added the $$ (current PID) and $PPID (parent PPID) variables to the shell.
2011-11-01 01:00:20 +01:00
Jonas 'Sortie' Termansen
c705bf39ff Ported kernel to new syscall API and started cleaning up the old one. 2011-10-27 00:20:28 +02:00
Jonas 'Sortie' Termansen
011e6eca95 Added the string for the SIMD Floating-Point exception. 2011-10-26 02:25:27 +02:00
Jonas 'Sortie' Termansen
4e8c2dfc33 Better mm comments. 2011-10-22 15:17:58 +02:00
Jonas 'Sortie' Termansen
b0df5186e6 Fixed two very nasty bugs in the x86 memory management code.
1) The PML2 was not initialized to zeroes, thus leaving some bits behind that
caused the fork code to go crazy, forking the unforkable, and mapping addresses
that never, ever, should have been mapped, leaving behind a trail of page faults
and general protection faults on some computers, while other computers worked
because the uninitalized memory just wasn't uninitialized enough. Yep, this was
a schrödinbug!

2) Fixed a time bomb. The kernel heap was accidentally put such that whenever a
few megabytes were allocated, it would begin overwriting the physical page stack
causing unthinkable events to unfold and would probably be even more obscure to
debug than 1).

Oh, and some string errors fixed and removed RunApplication from kernel.cpp,
funny thing that even linked in the first place. Guess, the optimizer actually
did work for once. :)
2011-10-20 03:52:08 +02:00
Jonas 'Sortie' Termansen
5082e6523c Updated git version to 0.5dev. 2011-10-10 20:14:37 +02:00
Jonas 'Sortie' Termansen
1b7dc2d817 Fixes to memory management that helps me sleep at night. 2011-10-10 17:22:03 +02:00
Jonas 'Sortie' Termansen
c16bdd2604 Added a friendly warning that X64 cannot boot fully when booting X64. 2011-10-10 01:16:36 +02:00
Jonas 'Sortie' Termansen
4579384312 Ported the GDT and TSS to x64. 2011-10-10 01:16:36 +02:00
Jonas 'Sortie' Termansen
a1cf7e9dbc Removed unneeded and unused old memory management assembly. 2011-10-10 01:14:14 +02:00
Jonas 'Sortie' Termansen
66192d1e86 Rewrote memory management again and added support for x64 and forking. 2011-10-10 01:02:57 +02:00
Jonas 'Sortie' Termansen
f1848b9932 Added comments to x64/boot.s. 2011-09-21 21:08:43 +02:00
Jonas 'Sortie' Termansen
4bc2841ef0 Restored the partial support for x64. 2011-09-08 21:09:14 +02:00
Jonas 'Sortie' Termansen
cc61176e5b Restored support for JSSortix using very ugly hacks. :( 2011-09-08 11:10:41 +02:00
Jonas 'Sortie' Termansen
3859e1f566 Refactored interrupt system and got rid of old not-mine code. 2011-09-07 18:45:07 +02:00
Jonas 'Sortie' Termansen
4e05eb33d8 Ignore the ramdisk in sortix/. 2011-09-07 17:50:11 +02:00
Jonas 'Sortie' Termansen
1a2446fca6 Added a friendly message on panic, and SIGSEGV no longer panics. 2011-09-07 17:48:01 +02:00
Jonas 'Sortie' Termansen
c157e65352 Removed lots of deprecated suff! 2011-09-06 19:51:47 +02:00
Jonas 'Sortie' Termansen
6ae297d088 Ugly hacks to restore support for Sortix on real hardware. 2011-08-28 16:59:07 +02:00
Jonas 'Sortie' Termansen
2c18d43359 Added the programs ls and help. 2011-08-28 12:38:01 +02:00
Jonas 'Sortie' Termansen
34e9ca277d Added a shell, a few programs, and added support for SIGINT. 2011-08-28 12:38:01 +02:00
Jonas 'Sortie' Termansen
2f9d08a800 Added a process execute API. 2011-08-28 12:38:01 +02:00
Jonas 'Sortie' Termansen
011addf46c The initrd now uses the mkinitrd format and the kernel now loads it. 2011-08-28 12:38:01 +02:00
Jonas 'Sortie' Termansen
d9c0c8d0cd Added a driver to parse the Sortix init ramdisk. 2011-08-27 20:08:33 +02:00
Jonas 'Sortie' Termansen
fa7834b5d6 Added a mkinitrd program that creates initrds for Sortix. 2011-08-27 16:57:03 +02:00
Jonas 'Sortie' Termansen
5c86cb4abd Processes now remember the memory segments it has loaded. 2011-08-27 16:46:00 +02:00
Jonas 'Sortie' Termansen
1fd4e6b63e Minor change in keyboard.cpp. 2011-08-23 21:02:15 +02:00
Jonas 'Sortie' Termansen
8d86dc6f6a Changing the sound frequency no longer prints to the terminal. 2011-08-23 21:02:15 +02:00
Jonas 'Sortie' Termansen
cd78c42c78 VGA Cursor code is now in vga.cpp. 2011-08-23 21:02:15 +02:00
Jonas 'Sortie' Termansen
013c5b5e71 Processes in the initrd are now made from ELF files. 2011-08-23 21:02:00 +02:00
Jonas 'Sortie' Termansen
4898343e2f The ELF loader now uses program headers and not section headers. 2011-08-23 18:16:44 +02:00
Jonas 'Sortie' Termansen
b705bf27a1 Fixed bug in MapRange{User,Kernel}. 2011-08-23 18:16:44 +02:00
Jonas 'Sortie' Termansen
9db2c88aca Sortix can now load ELF executables into addresses spaces. 2011-08-23 00:42:56 +02:00
Jonas 'Sortie' Termansen
e5eaf3eeb5 Added the MapRange virtual memory functions. 2011-08-23 00:33:57 +02:00
Jonas 'Sortie' Termansen
b80195dc19 Implemented the new physical page allocator API. 2011-08-22 21:12:55 +02:00
Jonas 'Sortie' Termansen
d392045559 Extended and documented the memory management API.
Physical paging have been extended with Page::Insert() and Page::GetStats()
which allows the physical paging system to add new pages to the physical page
allocator, and still keep the "free/used pages" count accurate, and providing
this information to the kernel (and user-space at some point).

The virtual memory API has been extended with RemapKernel(), RemapUser(),
MapRangeKernel(), UnmapRangeKernel(), MapRangeUser(), and UnmapRangeUser().
This huge number of related functions have been created in the hope that it
hides the internal complexity of portable virtual memory management and avoid
bugs. It is crucial that the correct group of functions are used when solving
a problem and that they are not mixed in a manner not documented.

I probably overdocumented the code - hopefully it should help avoiding making
stupid or bothersome code.

Another problem is that code calling Page::Get() often should call something
like Page::AlwaysGetPageEvenIfYouHaveToSwap(). I'd be swell to have a function
that always gets a page under heavily-swapping conditions. Possibly Page::Get()
could become that?
2011-08-22 21:05:10 +02:00
Jonas 'Sortie' Termansen
4c1cb806ba Added a sound api. 2011-08-22 00:25:28 +02:00
Jonas 'Sortie' Termansen
47c44caa8d Fixed move-cursor-left bug in vgaterminal. 2011-08-21 12:52:56 +02:00
Jonas 'Sortie' Termansen
9ee93082c5 Hello is now a hello world sample ANSI text editor. 2011-08-21 12:52:56 +02:00
Jonas 'Sortie' Termansen
4db550c13b Added libmaxsi keyboard API, allowing user-space to use the keyboard. 2011-08-21 12:52:56 +02:00
Jonas 'Sortie' Termansen
ed2b3cb5c9 Prevented user-space from issueing non-user-space interrupts. 2011-08-12 21:00:15 +02:00
Jonas 'Sortie' Termansen
ec8c0c533b Removed accidentally included infinite debug loop in kernel.cpp. 2011-08-12 20:13:31 +02:00
Jonas 'Sortie' Termansen
a2f70f358c Added linebreaks after maxsi logo. 2011-08-12 20:09:40 +02:00
Jonas 'Sortie' Termansen
9995354f95 Moved CPU code shared by x86 and x64 into x86-family. 2011-08-12 17:33:18 +02:00
Jonas 'Sortie' Termansen
4728809c00 The serial terminal now clears the screen using ANSI when initialized. 2011-08-12 17:29:45 +02:00
Jonas 'Sortie' Termansen
64d191a882 x86 now has a driver for rebooting. 2011-08-12 15:13:18 +02:00
Jonas 'Sortie' Termansen
15ce53919c Added VGA API allowing userspace to easily access 0xB8000. 2011-08-11 22:03:13 +02:00
Jonas 'Sortie' Termansen
1026354e98 Sortix now uses the Device class.
This class is very WIP and is just experimental.
2011-08-08 15:20:08 +02:00
Jonas 'Sortie' Termansen
e95eb60d31 Provide a virtual address where pages can be temporarily mapped. 2011-08-08 15:20:02 +02:00
Jonas 'Sortie' Termansen
6ae7ddbcb3 Descriptors are now public members in processes. 2011-08-08 15:20:02 +02:00
Jonas 'Sortie' Termansen
412d3e78b2 AlignDown and AlignUp aligns an address on a page boundary. 2011-08-08 15:20:02 +02:00
Jonas 'Sortie' Termansen
e78443d92a Processes now keep track of where their code section ends.
This is very hacky, but allows us to allocate address space.
2011-08-08 15:19:49 +02:00
Jonas 'Sortie' Termansen
db34033d40 Removed unneeded #includes from sortix/memorymanagement.cpp. 2011-08-07 20:14:26 +02:00
Jonas 'Sortie' Termansen
07b409c1a0 Added a wrapper class for handling file descriptors. 2011-08-07 19:47:43 +02:00
Jonas 'Sortie' Termansen
294e5d72dd All of the initrd is now loaded. 2011-08-07 01:30:47 +02:00
Jonas 'Sortie' Termansen
794630a802 Adding proper .gitignore files. 2011-08-07 01:22:36 +02:00
Jonas 'Sortie' Termansen
185c6d4b6f Processes (and thus threads) now belong to an address space.
Changing theads now automatically switches the adress space.
2011-08-07 01:17:53 +02:00
Jonas 'Sortie' Termansen
90ebfe7f0a Improvements to the address space switching function.
It now only switches when needed and returns the old addr space.
2011-08-07 01:16:53 +02:00
Jonas 'Sortie' Termansen
66c058fba1 Refactored virtual memory management, making it less buggy.
uintptr_t is now replaced with addr_t when referring to physical memory
addresses in Sortix. Many bugs in the previous memory management code have been
fixed. The new interface is less flexible - but should prove more solid as the
nasty internals have been hidden away. The current interface design should also
make the code more 64-bit ready/friendly. And so on.
2011-08-07 00:18:41 +02:00
Jonas 'Sortie' Termansen
9b79673dcb Initial version of Sortix. 2011-08-05 14:25:00 +02:00