| Age | Commit message (Collapse) | Author |
|
inode in memory.
Added a jump instruction in front of the multiboot header so that the
kernel may be run as a binary image. The jump instruction will skip over
the multiboot header to the beginning of the kernel's startup procedure
in kboot.
Moved the call to initialize the timer to earlier in the boot sequence.
This is to allow for some drivers that may require it's functionality
during the startup to function properly.
Added functionality for the 'fast-gate' to the enable_a20 subroutine.
Now, if the keyboard controller method fails when enabling the gate, an
attempt is made to enable the A20 gate using the PS/2's fast-gate
interface. If this also fails, the kernel will panic.
Implemented TTY output for the console. The console is now TTY device 0
(the default for new userspace programs).
|
|
|
|
to make management/maintenance easier.
Defined the structures super_block and m_inode in kernel/fs.h for super
blocks and inodes respectively.
Added the new header file sys/stat.h which contains basic definitions
for inode types and permissions. These definitions will be required by
any functions handling m_inode structures.
Moved the sys_read and sys_write system calls to the filesystem's main
source file at kernel/fs/fs.c.
Added the file kernel/fs/mount.c which will contain the super-blocks
table as well as the function mount_root() which will attempt to mount
the root filesystem during boot. Eventually, this file will be expanded
to include a general-purpose mount function to mount any filesystem as
well as the system call handler for sys_mount.
Seperated block I/O functions into their own subsystem under
kernel/fs/block.c which currently supports two functions; block_read()
and block_write() to read and write blocks from block devices.
Currently, no device can be specified since the primary ATA master drive
is the only possible target. This will change in the future however.
Modified the hard disk driver's read and write functions to use
filesystem blocks rather than sectors as the units of transfer. This is
intended to keep the block I/O subsystem simple by ensuring a uniform
transfer unit is used across all block devices and drivers.
The hard disk driver is no longer initialized during the main boot
procedure. Instead, a call is made to the new function fs_init() which
will setup filesystem tables and structures, call hd_init() to
initialize the disk and finally, attempt to load the super-block for the
root filesystem.
The hard disk driver now stores the disk's size and sanity checks
addresses and sizes in read and write calls against this value.
|
|
SSIZE_MAX which is needed to limit the number of bytes read() will
transfer.
Laid the foundation for a TTY subsystem. This works by taking the
previously used buffer and r/w pointers concept and implements it as a
'tty_queue' struct. The struct 'tty_struct' is used to represent a TTY
device. This struct currently contains three elements; a read queue for
data flowing from the device to the user, a write queue for data flowing
from the user to the device and a function pointer to an init function.
The latter element will reduce complexity by allowing the TTY subsystem
to initialize each TTY device driver (when it's ready), rather than each
driver having to be initialized during bootup. Each TTY device is
implemented as a pointer to a tty_struct. The structures are defined
separately by each driver as well as tracked and maintained by pointers
in the table 'ttys' in tty.c.
Modified the RS232 serial driver to make use of the new TTY subsystem
for transferring data to the user. Currently, write calls are still
handled manually through the rsputs() function though this will change
in future.
Modified the read() system call to direct read calls to the TTY
subsystem which will further direct the call to the appropriate TTY
device driver.
The serial driver's interrupt routine now uses the wake_up() function to
wake processes blocking for serial data. This is to ensure the scheduler
is notified of the wakeup. This function is the preferred method for
waking processes since accessing the task state field directly may not
be possible in the future and is discouraged. The reason for this is
that the scheduler's behaviour may change to require being notified of
task wakeup events in the future.
|
|
the IDT. This function takes the same parameters as register_isr() which
creates interrupt gate entries in the IDT.
The register_isr() function now sets the gate type to 0x0E regardless of
what was already in the descriptor. This is to break reliance on the IDT
already being initialized to a known state as well as avoiding conflicts
with the new register_trap() function.
Added declaration for the 'ticks' variable in kernel/sched.h so that
it's value may be used throughout the kernel.
Changed the system call gate to a trap gate. This means that interrupts
will not be disabled prior to entry into the system call handler. This
will allow hardware functions such as the timer to operate continuously
even if the user makes a system call.
Added checks to the timer interrupt handler. These checks prevent the
scheduler from being called if the interrupt occurred during kernel mode
execution. The idea here, is that the timer interrupt handler only
services the hardware (increments the tick count and sends an EOI to the
PIC's) if a system call was already running in the kernel. The system
call handler has also been expanded to check if the timer fired prior to
returning to userspace. If the timer did fire, the syscall handler will
invoke the scheduler (as the timer handler would have), so that it can
decide if it's time to switch tasks.
|
|
Implemented a basic serial interface using COM0 which can be accessed
with the system call sys_puts as well as the library functions rsputs()
and rsprintf().
Renamed puts() in con.c to con_puts() and made the function static to
avoid interference with the library function puts().
|
|
prior to return. This meant that switching to the same task did not
abort properly as the incorrect return address was popped off the stack.
Fixed a bug where the task register was not initialized before the
scheduler. This meant that on the first task switch, the CPU would dump
it's current state to a random address (0 most likely), potentially
corrupting important data. This has been corrected by introducing a
'garbage TSS' (and associated descriptor in the GDT) which is selected
before the scheduler is initialized as a safe place for the data to be
written.
Modified the scheduler so that it now waits indefinitely until a task
becomes ready to run. This fixes the possible bug where the scheduler
won't re-schedule the currently running task if it is the only task on
the system.
Add signal handling capabilities to the kernel. The bulk of this is
present in the subroutine check_signals() defined in traps.s. This
function is called on every timer tick and system call prior to
userspace return. The subroutine operates by pushing fake state
information onto the kernel's stack, then using it to return to
userspace. Prior to this, the subroutine pushes the return address
0xFFFFE000 onto the user's stack. This address corresponds to the
unmapped page located between the top of the user's stack (lower) and
the kernel's stack page (upper). When the user's signal handler tries to
return, it will cause a page fault that will be used as a notification
mechanism to inform the kernel that the signal handler is done. The
kernel will then switch to the originally pushed state information and
use it to return the task to the original execution state. Due to it's
nature, check_signals() must only be called prior to exiting the kernel
since it may not return.
Added the header file 'signal.h' which defines (most) of the POSIX
signals as well as the prototype for the signal() function.
Added the 'signal' element to the task structure. This field is a bitmap
of all currently pending signals.
Added the 'sig_handlers' element to the task structure. This is an array
of all user-defined signal handlers. Currently, a value of 0 indicates
the default handler should be used whilst any other value is considered
to be the address of a userspace signal handler. The ability to ignore a
signal is not yet present but will be added sometime soon.
Added the sys_signal system call to register a signal.
Added the stub function sighandler_default() to sched.c which handles
all signals not caught by the user.
|
|
rather than in kmain() as some subsystems may now require early console
I/O.
Added 16-bit read/write I/O functions to asm/io.h. These functions are
inw() and outw() respectively.
Added the file kernel/fs.h which will contain definitions relating to
filesystem functions.
Defined the type off_t as a signed 32-bit value in sys/types.h. This
type will be required for filesystem functionality.
Added the directory 'kernel/fs' to the project's source tree. The
kernel's makefile has been updated accordingly. This directory will
contain any source files relating to filesystem functionality (both
assembly and C files).
Added the file 'fs/hd.c' to the kernel's source tree. This file
currently contains three main functions (which are defined in
kernel/hd.h). These functions are as follows; hd_init() to enumerate and
initialize the hard disks, hd_read() to read sectors from the disk and
hd_write() to write sectors to the disk. Currently, all transfers are
done in ATA PIO mode using polling, however this will change in future.
The function hd_init() is called during the kernel's boot sequence in
kboot().
Added the file hd.img to the project's root directory. This is a 20MB
raw image file that will be used by Qemu as a 20MB hard disk. The main
makefile has been updated to tell Qemu to use this file on launch.
|
|
each structure has a TSS inside, as well as several descriptor entries
in the GDT pointing to each task's TSS. Task switching is performed in
hardware by means of far jumping to the new task's TSS descriptor in the
GDT. Task states are saved manually by copying the saved state from the
interrupt handler's stack, back into the task's TSS.
Added the function save_state() to sched.c which can be called from
assembly to copy the state information of the suspended task from the
current stack, to it's respective task structure. NOTE: this assumes
that the pointer cstate has been set ahead of time to point to the state
information on the stack, and that the pointer ctask has not yet been
modified.
Added the function reschedule() which is currently called from the
timer's tick handler. Currently, this function merely alternates between
the two tasks created in sched_init(), but in future, will be expanded
to decided independently which task will run next.
The function userspace_init() was renamed to the more appropriate
sched_init().
Moved most of the code from the original userspace_init() to the new
function create_proc() which sets up a virtual address space and state
information, copies the specified binary into the new address space,
then returns a pointer to the newly created tasks entry in the task
table.
Defined the type pid_t in unistd.h as a 16-bit unsigned integer.
Added two new debugging system calls for checking which task is
currently active. The getpid() system calls returns the caller's PID
whilst the getpdir() call returns the physical location of the caller's
page directory (the value of CR3). The getpdir() call can be used as a
fallback to determine which task is *actually* running if the
information in ctask or the getpid() call is faulty.
Added two new subroutines; set_tss() and clear_tss() (whose prototypes
are defined in asm/system.h) for managing the task-state descriptor
entries in the GDT. set_tss() initializes a TSS descriptor and sets it's
base pointer to the supplied TSS pointer whilst clear_tss() simply marks
a TSS descriptor as 'not present' without clearing it.
|
|
is produced. This may change later.
Added the new directory 'lib' to the source tree which build lib.a, an
archive containing common library routines for both the kernel and
userspace code to use.
Added the file string.c to the lib directory (as well as the appropriate
headers in /include) which provides some basic functions from the
standard C string library.
Added a physical memory manager which is now located in memory.c. This
memory manager tracks free pages from 1MB-8MB with a simple table and
allocates memory in blocks of 4KB pages. Multiple pages can be allocated
in which they are returned as a linked list.
Added a 'page window' in memory.c which allows the temporary mapping of
a single page at a time into the current address space.
Moved all paging routines that were previously located in page.s over to
memory.c where they have been re-implemented as a mixture of C and
inline assembly.
Moved the primative userspace routines from usrspace.s over to the new
sched.c. The only remaining routine, usrcall is now located in asm.s as
'switch_to' which takes two arguments, pointers to the task structure
and task state structure of the new task which is being switched to.
Pages for userspace are now allocated dynamically. The user binary is
loaded in at 1GB upwards. The user stack is located at the end of the
4GB address space with the lower 1GB being reserved for the kernel.
Updated the link.ld file for the userspace binary to include the new
starting address 0x40000000 (1GB).
Renamed the symbols for the user binary blob to make them shorter.
|
|
assembly function register_isr making it usable within the C portions of
the source.
Added a new file panic.s with the function panic that will print a panic
message, disable interrupts and halt the system.
Created the skeleton framework for paging in the new file page.s. The
new function paging_init (called in kboot) will setup a simple page
directory with two tables covering all addresses 0-8MB. It will also
mark pages from 0-1MB as 'supervisor-only' to protect the kernel. NOTE:
The function paging_init must be called before initialising the IDT as
it does not disable interrupts!
Modified the page fault handler to print the offending linear address
along with the supplied error code. Following that, the handler will
initiate a kernel panic. This function (along with panic) assumes
console I/O to be operational.
Modified the userspace test code to deliberately intiate a page fault by
accessing an unmapped page.
|
|
32-255. A separate routine in the new file traps.s initializes the first
32 entries with addresses pointing to exception handlers within said
file.
Modified the register_isr function to now accept a descriptor privilege
level which it will assign to the modified IDT entry.
Added a task state segment and corresponding entry to the GDT. The TSS
will store the kernel's stack pointer and stack segment when switching
to userspace. NOTE: The stack pointer MUST be saved manually before
switching to userspace!
Added the framework for a system call interface at interrupt vector 0x80
(128).
|
|
time_t.
Moved the kernel's loading point down to address 0 in
conventional memory and updated linker scripts accordingly.
Began to experiment with loading a binary blob into extended memory
(0x100000), switching to userspace mode, and executing it.
|
|
counter.
|
|
|