Commit Graph

2759 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen deee5e4335 Added a partial implementation of remove(3), since rmdir(2) is missing. 2011-12-30 01:11:33 +01:00
Jonas 'Sortie' Termansen 5d16b5c61e Added getchar(3) and putchar(3). 2011-12-30 01:06:27 +01:00
Jonas 'Sortie' Termansen 66999ff94a Added putc(3) and getc(3). 2011-12-30 01:03:24 +01:00
Jonas 'Sortie' Termansen d39d4222b5 Added fputc(3) and fgetc(3). 2011-12-30 00:55:59 +01:00
Jonas 'Sortie' Termansen 76800553da Clarified comment about typedef struct _FILE FILE. 2011-12-30 00:42:36 +01:00
Jonas 'Sortie' Termansen 064b69d2b6 Added fseeko(3) and ftello(3). 2011-12-30 00:36:39 +01:00
Jonas 'Sortie' Termansen 912b2f78f0 Implemented the fdio backend of fseek(3) and ftell(3). 2011-12-26 23:15:52 +01:00
Jonas 'Sortie' Termansen 648b324385 Added lseek(2). 2011-12-26 23:12:12 +01:00
Jonas 'Sortie' Termansen d6d404f3f0 Added a simple pager program while we wait for less(1) to be ported. 2011-12-26 17:23:40 +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 2b3b4ed62a error(3) and perror(3) now writes to stderr. 2011-12-24 04:39:16 +01:00
Jonas 'Sortie' Termansen fdbd4ca90d Implemented large parts of the stdio(3), including fprintf.
Made FILE an interface to various backends. This allows application writers
to override the standard FILE API functions with their own backends. This
is highly unportable - it'd be nice if a real standard existed for this.
glibc already does something like this internally, but AFAIK you can't hook
into it.

Added fdopen(3), fopen(3), fregister(3), funregister(3), fread(3),
fwrite(3), fseek(3), clearerr(3), ferror(3), feof(3), rewind(3), ftell(3),
fflush(3), fclose(3), fileno(3), fnewline(3), fcloseall(3), memset(3),
stdio(3), vfprintf(3), fprintf(3), and vprintf(3).

Added a file-descriptor backend to the FILE API.

fd's {0, 1, 2} are now initialized as stdin, stdout, and stderr when the
standard library initializes.

fcloseall(3) is now called on exit(3).

decl/intn_t_.h now @include(size_t.h) instead of declaring it itself.

Added <stdint.h>.

The following programs now flush stdout: cat(1), clear(1), editor(1),
init(1), mxsh(1).

printf(3) is now hooked up against vprintf(3), while Maxsi::PrintF
remains using the system call, for now.
2011-12-24 04:28:34 +01:00
Jonas 'Sortie' Termansen 4841d83ff8 Added calloc(3). 2011-12-24 04:05:38 +01:00
Jonas 'Sortie' Termansen b5fe020b7a Fixed bad variable name in uptime(1), it's usecs not msecs. 2011-12-23 19:53:47 +01:00
Jonas 'Sortie' Termansen ee125f01e2 Made the memstat program a little more 64-bit friendly.
I think.
2011-12-23 16:54:34 +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
Steve Dougherty 567786d26b Added calc, an integer-based reverse polish notation calculator. 2011-12-17 11:40:16 +01:00
Jonas 'Sortie' Termansen 203f2a2bb1 Better default octal detection in strtol(3). 2011-12-16 22:24:29 +01:00
Jonas 'Sortie' Termansen 73bcafc004 strtol(3) now returns 0 if the string was + or -. 2011-12-16 21:44:32 +01:00
Jonas 'Sortie' Termansen f1a49dbad3 Hex numbers now work properly in strtol(3). 2011-12-16 21:15:26 +01:00
Jonas 'Sortie' Termansen ae6696ed7a Added -fno-exceptions to the cross compiler flags. 2011-12-16 18:46:56 +01:00
Jonas 'Sortie' Termansen da2bfac34f Fixed bug in strtol*. 2011-12-16 18:28:22 +01:00
Jonas 'Sortie' Termansen bf6a4c1861 Added strto{u,}{l,}l(3). 2011-12-16 16:49:27 +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 fecaf6b43f System calls in libmaxsi now use the constants from syscallnum.h. 2011-12-09 12:41:06 +01:00
Jonas 'Sortie' Termansen 8be3624ca3 Added auto-completion to snake for debugging purposes. 2011-12-06 14:18:15 +01:00
Jonas 'Sortie' Termansen fefeb92e89 Begun development of Sortix 0.6. 2011-12-06 01:28:23 +01:00
Jonas 'Sortie' Termansen 9b3efeed5a Updated version number to 0.5. 2011-12-05 23:22:27 +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 0bb91ee161 printf(3) now supports signed integers and ptrdiff_t. 2011-12-05 13:59:26 +01:00
Jonas 'Sortie' Termansen a9609502ed Removed references to mksound from mxmpp. 2011-12-04 21:33:23 +01:00
Jonas 'Sortie' Termansen 889646d033 Removed excess space. 2011-12-04 21:31:53 +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 597e700618 Removed outdated comment about sleep(2) and signals. 2011-12-04 21:08:26 +01:00
Jonas 'Sortie' Termansen 5bc05c4e0e Moved around comments in heap.cpp. 2011-12-04 20:59:42 +01:00
Jonas 'Sortie' Termansen fcc6147c5c Prevent the kernel from calling system calls. 2011-12-04 20:56:29 +01:00
Jonas 'Sortie' Termansen 60d23eac19 printf now understands %l and %j. 2011-12-04 20:53:43 +01:00
Jonas 'Sortie' Termansen 84b93044c8 Sortix now defaults to build the same arch as the host machine. 2011-12-04 20:21:36 +01:00
Jonas 'Sortie' Termansen de70b1804d Rewrote the x86 64-bit division stubs, which now actually work. 2011-12-04 19:02:35 +01:00