97 if (interruptTable[interrupt])
98 status = interruptTable[interrupt](interrupt, error, t);
129 asm volatile(
"clts");
139 asm volatile(
"frstor %0" : :
"m" (t->
fpu) );
143 asm volatile(
"fninit");
159 asm volatile(
"clts");
204 uint32_t syscall = t->
task.
eax;
242 RELEASE_USER_MEMORY(&k);
251 struct thread *old_t, *__old_t;
285 if (ACCESS_USER_MEMORY(&k2, &old_p, (
void *)t->
task.
ecx, t->
task.
edx,
true))
292 RELEASE_USER_MEMORY(&k);
294 RELEASE_USER_MEMORY(&k2);
303 if (ACCESS_USER_MEMORY(&k2, &old_p, (
void *)t->
task.
esi, t->
task.
edi,
true))
311 RELEASE_USER_MEMORY(&k);
313 RELEASE_USER_MEMORY(&k2);
341 memset(task, 0,
sizeof(*task));
368 task->
iomap =
sizeof(*task);
507 if (obj1 || obj2) t->
task.
eax = (obj1 == obj2);
519 if (obj) __objectShutdown(obj, t->
task.
ecx);
544 if (obj) __objectSignal(obj, t->
task.
ecx);
552 if (ACCESS_USER_MEMORY(&k, p, (
void *)t->
task.
ecx, t->
task.
edx,
false))
555 RELEASE_USER_MEMORY(&k);
564 if (ACCESS_USER_MEMORY(&k, p, (
void *)t->
task.
ecx, t->
task.
edx,
true))
567 RELEASE_USER_MEMORY(&k);
589 if (ACCESS_USER_MEMORY(&k, p, (
void *)t->
task.
ebx, t->
task.
ecx,
true))
592 RELEASE_USER_MEMORY(&k);
598 if (ACCESS_USER_MEMORY_STRUCT(&k, p, (
void *)t->
task.
ebx, t->
task.
ecx,
sizeof(uint16_t),
true))
601 RELEASE_USER_MEMORY(&k);
649 if (ACCESS_USER_MEMORY(&k, p, (
void *)t->
task.
ecx, t->
task.
edx,
true))
664 if (ACCESS_USER_MEMORY(&k, p, (
void *)t->
task.
ecx, t->
task.
edx,
true))
730 if (interruptTable[interrupt])
733 interruptTable[interrupt] = callback;
744 interruptTable[interrupt] = NULL;
bool interruptReserve(uint32_t interrupt, interrupt_callback callback)
Request an interrupt.
void consoleWriteRawLen(const uint16_t *data, size_t count)
Write raw data with a fixed size to the console.
void pagingReleaseProcessPageTable(struct process *p)
Releases the page directory and page table of a specific process.
uint32_t consoleGetSize()
Returns the packed size of the console.
bool handleSet(struct handleTable *table, uint32_t handle, struct object *object)
Associates a handle (index) with a kernel object.
struct thread * threadCreate(struct process *p, struct thread *original, void *eip)
Creates a new kernel thread object.
struct object * handleGet(struct handleTable *table, uint32_t handle)
Returns the kernel object associated to a handle.
#define USERMODE_KERNELSTACK_LIMIT
#define USERMODE_IDT_ADDRESS
struct directory * fileSystemIsValidDirectory(struct object *obj)
Checks if a given object is of the type directory and casts it if possible.
struct process * processCreate(struct process *original)
Creates a new kernel process object.
uint32_t interrupt_0x0E(uint32_t interrupt, uint32_t error, struct thread *t)
struct openedDirectory * directoryOpen(struct directory *directory)
Creates a new kernel openedDirectory object.
struct openedFile * fileOpen(struct file *file)
Creates a new kernel openedFile object.
void pagingAllocProcessPageTable(struct process *p)
Allocates the page directory and page table for a specific process.
struct file * fileSystemIsValidFile(struct object *obj)
Checks if a given object is of the type file and casts it if possible.
void * memset(void *ptr, int value, size_t num)
Fills a memory region with some specific byte value.
void * user_programArgumentsBase
#define INTERRUPT_UNHANDLED
#define objectShutdown(p, a)
uint32_t consoleGetHardwareCursor()
Get packed position of the hardware cursor.
#define USERMODE_GDT_ADDRESS
struct pagingEntry * pageDirectory
void * pagingAllocatePhysMem(struct process *p, uint32_t length, bool rw, bool user)
Allocates several pages of physical memory in a process.
bool pagingTryReleaseUserMem(struct process *p, void *addr, uint32_t length)
Releases several pages of physical memory of a process.
#define DEFAULT_STACK_SIZE
void * user_ring3StackBase
struct thread * lastFPUthread
uint32_t processInfo(struct processInfo *info, uint32_t count)
Fills out the processInfo structure with information about each individual process.
uint32_t user_environmentVariablesLength
struct semaphore * semaphoreCreate(uint32_t value)
Creates a new kernel semaphore object.
struct pipe * pipeCreate()
Creates a new kernel pipe object.
struct event * eventCreate(bool wakeupAll)
Creates a new kernel event object.
#define USERMODE_KERNELSTACK_ADDRESS
struct GDTEntry * codeRing3
void * pagingTryAllocatePhysMem(struct process *p, uint32_t length, bool rw, bool user)
Tries to allocates several pages of physical memory in a process.
void * user_threadLocalBase
void consoleSetColor(uint8_t color)
Set the text and background color of the console.
struct GDTEntry * dataRing0
bool elfLoadBinary(struct process *p, void *addr, uint32_t length)
Loads an ELF executable stored in the memory into a process.
uint32_t user_threadLocalLength
#define INTERRUPT_EXIT_PROCESS
struct directory * fileSystemSearchDirectory(struct directory *directory, char *path, uint32_t pathLength, bool create)
Opens or creates a directory.
uint32_t(* interrupt_callback)(uint32_t interrupt, uint32_t error, struct thread *t)
void * user_environmentVariablesBase
struct pagingEntry * pageTables[PAGETABLE_COUNT]
struct linkedList threads
uint32_t user_programArgumentsLength
uint32_t gdtGetEntryOffset(struct GDTEntry *entry, uint32_t ring)
Determines the offset of a GDT entry.
void consoleClear()
Clear the screen contents.
uint8_t consoleGetColor()
Get current color.
void * memcpy(void *destination, const void *source, size_t num)
Copies a block of memory from source to destination.
void consoleSetHardwareCursor(uint8_t x, uint8_t y)
Set the position of the hardware cursor.
uint32_t interrupt_0x80(UNUSED uint32_t interrupt, UNUSED uint32_t error, struct thread *t)
Interrupt which handles Syscalls.
struct GDTEntry * dataRing3
struct timer * timerCreate(bool wakeupAll)
Creates a new kernel timer object.
uint32_t interrupt_0x07(UNUSED uint32_t interrupt, UNUSED uint32_t error, struct thread *t)
Coprocessor / FPU not available handler.
uint32_t pagingGetPhysMem(struct process *p, void *addr)
Returns the physical page index for a virtual address.
bool handleRelease(struct handleTable *table, uint32_t handle)
Releases the object associated with a handle.
uint32_t consoleGetCursorPos()
Get packed position of the text cursor.
void consoleWriteStringLen(const char *str, size_t len)
Write a string with a fixed size to the console.
uint32_t interrupt_0x10(UNUSED uint32_t interrupt, UNUSED uint32_t error, struct thread *t)
struct handleTable handles
#define INTERRUPT_CONTINUE_EXECUTION
bool consoleSetCursorPos(uint8_t x, uint8_t y)
Set the position of the text cursor.
uint32_t dispatchInterrupt(uint32_t interrupt, uint32_t error, struct thread *t)
Handle an incoming interrupt.
void consoleSetFlags(uint32_t flags)
Set console flags.
#define LL_FOR_EACH_SAFE(element, next_element, list, type, field)
Allows to iterate a linkedList similar to a for-loop (safe when deleting elements).
#define INTERRUPT_EXIT_THREAD
uint32_t handleAllocate(struct handleTable *table, struct object *object)
Allocates a handle (index) for a specific kernel object.
void interruptFree(uint32_t interrupt)
Free a previously requested interrupt.
uint32_t threadWait(struct thread *t, struct object *obj, uint32_t mode)
Makes a kernel thread object wait for some waitable object.
struct file * fileSystemSearchFile(struct directory *directory, char *path, uint32_t pathLength, bool create)
Opens or creates a file.
#define USERMODE_TASK_ADDRESS
uint64_t timerGetTimestamp()
Returns the current kernel timestamp.
void * pagingMapRemoteMemory(struct process *dst_p, struct process *src_p, void *dst_addr, void *src_addr, uint32_t length, bool rw, bool user)
Maps some virtual memory from one process to another one.
uint32_t user_ring3StackLength
#define USERMODE_INTJMP_ADDRESS
uint32_t consoleGetFlags()
Get console flags.