Fix up documentation
This commit is contained in:
parent
a71bebe92e
commit
631603cab3
@ -34,7 +34,7 @@ DEFINE_SLAB(BufCacheEntry, &cacheEntrySlab);
|
||||
/**
|
||||
* BufCache_Init --
|
||||
*
|
||||
* Initialize the system buffer cache.
|
||||
* Initialize the system buffer cache.
|
||||
*/
|
||||
void
|
||||
BufCache_Init()
|
||||
@ -83,14 +83,15 @@ BufCache_Init()
|
||||
/**
|
||||
* BufCacheLookup --
|
||||
*
|
||||
* Looks up a buffer cache entry that can be used by BufCache_Alloc or
|
||||
* BufCache_Read to allocate the underlying buffer.
|
||||
* Looks up a buffer cache entry that can be used by BufCache_Alloc or
|
||||
* BufCache_Read to allocate the underlying buffer.
|
||||
*
|
||||
* @param [in] disk Disk object
|
||||
* @param [in] diskOffset Block offset within the disk
|
||||
* @param [out] entry If successful, this contains the buffer cache entry.
|
||||
* @retval 0 if successful
|
||||
* @return ENOENT if not present.
|
||||
* @param [in] disk Disk object
|
||||
* @param [in] diskOffset Block offset within the disk
|
||||
* @param [out] entry If successful, this contains the buffer cache entry.
|
||||
*
|
||||
* @retval 0 if successful
|
||||
* @return ENOENT if not present.
|
||||
*/
|
||||
static int
|
||||
BufCacheLookup(Disk *disk, uint64_t diskOffset, BufCacheEntry **entry)
|
||||
@ -118,14 +119,15 @@ BufCacheLookup(Disk *disk, uint64_t diskOffset, BufCacheEntry **entry)
|
||||
/**
|
||||
* BufCacheAlloc --
|
||||
*
|
||||
* Allocates a buffer cache entry that can be used by BufCache_Alloc or
|
||||
* BufCache_Read to allocate the underlying buffer..
|
||||
* Allocates a buffer cache entry that can be used by BufCache_Alloc or
|
||||
* BufCache_Read to allocate the underlying buffer..
|
||||
*
|
||||
* @param [in] disk Disk object
|
||||
* @param [in] diskOffset Block offset within the disk
|
||||
* @param [out] entry If successful, this contains the buffer cache entry.
|
||||
* @retval 0 if successful.
|
||||
* @return ENOMEM if there's no buffer cache entries free.
|
||||
* @param [in] disk Disk object
|
||||
* @param [in] diskOffset Block offset within the disk
|
||||
* @param [out] entry If successful, this contains the buffer cache entry.
|
||||
*
|
||||
* @retval 0 if successful.
|
||||
* @return ENOMEM if there's no buffer cache entries free.
|
||||
*/
|
||||
static int
|
||||
BufCacheAlloc(Disk *disk, uint64_t diskOffset, BufCacheEntry **entry)
|
||||
@ -163,13 +165,14 @@ BufCacheAlloc(Disk *disk, uint64_t diskOffset, BufCacheEntry **entry)
|
||||
/**
|
||||
* BufCache_Alloc --
|
||||
*
|
||||
* Allocate a buffer cache entry to allow writing new data to disk.
|
||||
* Allocate a buffer cache entry to allow writing new data to disk.
|
||||
*
|
||||
* @param [in] disk Disk object
|
||||
* @param [in] diskOffset Block offset within the disk
|
||||
* @param [out] entry If successful, this contains the buffer cache entry.
|
||||
* @retval 0 if successful
|
||||
* @return Otherwise returns an error code.
|
||||
* @param [in] disk Disk object
|
||||
* @param [in] diskOffset Block offset within the disk
|
||||
* @param [out] entry If successful, this contains the buffer cache entry.
|
||||
*
|
||||
* @retval 0 if successful
|
||||
* @return Otherwise returns an error code.
|
||||
*/
|
||||
int
|
||||
BufCache_Alloc(Disk *disk, uint64_t diskOffset, BufCacheEntry **entry)
|
||||
@ -193,10 +196,10 @@ BufCache_Alloc(Disk *disk, uint64_t diskOffset, BufCacheEntry **entry)
|
||||
/**
|
||||
* BufCache_Release --
|
||||
*
|
||||
* Release a buffer cache entry. If no other references are held the
|
||||
* buffer cache entry is placed on the LRU list.
|
||||
* Release a buffer cache entry. If no other references are held the
|
||||
* buffer cache entry is placed on the LRU list.
|
||||
*
|
||||
* @param [in] entry Buffer cache entry.
|
||||
* @param [in] entry Buffer cache entry.
|
||||
*/
|
||||
void
|
||||
BufCache_Release(BufCacheEntry *entry)
|
||||
@ -214,13 +217,13 @@ BufCache_Release(BufCacheEntry *entry)
|
||||
/**
|
||||
* BufCache_Read --
|
||||
*
|
||||
* Read block from disk into the buffer cache.
|
||||
* Read block from disk into the buffer cache.
|
||||
*
|
||||
* @param [in] disk Disk object
|
||||
* @param [in] diskOffset Block offset within the disk
|
||||
* @param [out] entry If successful, this contains the buffer cache entry.
|
||||
* @retval 0 if successful
|
||||
* @return Otherwise returns an error code.
|
||||
* @param [in] disk Disk object
|
||||
* @param [in] diskOffset Block offset within the disk
|
||||
* @param [out] entry If successful, this contains the buffer cache entry.
|
||||
* @retval 0 if successful
|
||||
* @return Otherwise returns an error code.
|
||||
*/
|
||||
int
|
||||
BufCache_Read(Disk *disk, uint64_t diskOffset, BufCacheEntry **entry)
|
||||
@ -261,10 +264,10 @@ BufCache_Read(Disk *disk, uint64_t diskOffset, BufCacheEntry **entry)
|
||||
/**
|
||||
* BufCache_Write --
|
||||
*
|
||||
* Write a buffer cache entry to disk.
|
||||
* Write a buffer cache entry to disk.
|
||||
*
|
||||
* @retval 0 if successful
|
||||
* @return Otherwise an error code is returned.
|
||||
* @retval 0 if successful
|
||||
* @return Otherwise an error code is returned.
|
||||
*/
|
||||
int
|
||||
BufCache_Write(BufCacheEntry *entry)
|
||||
|
@ -17,16 +17,18 @@ extern int copystr_unsafe(void *to_addr, void *from_addr, uintptr_t len);
|
||||
|
||||
/**
|
||||
* Copy_In --
|
||||
* Safely copy memory from userspace. Prevents userspace pointers from
|
||||
* reading kernel memory.
|
||||
*
|
||||
* @param [in] fromuser User address to copy from.
|
||||
* @param [in] tokernel Kernel address to copy to.
|
||||
* @param [in] len Length of the data to copy.
|
||||
* @retval EFAULT if the address is invalid or causes a fault.
|
||||
* Safely copy memory from userspace. Prevents userspace pointers from
|
||||
* reading kernel memory.
|
||||
*
|
||||
* Side effects:
|
||||
* Kernel page fault may have occurred.
|
||||
* Kernel page fault may have occurred.
|
||||
*
|
||||
* @param [in] fromuser User address to copy from.
|
||||
* @param [in] tokernel Kernel address to copy to.
|
||||
* @param [in] len Length of the data to copy.
|
||||
*
|
||||
* @retval EFAULT if the address is invalid or causes a fault.
|
||||
*/
|
||||
int
|
||||
Copy_In(uintptr_t fromuser, void *tokernel, uintptr_t len)
|
||||
@ -51,16 +53,18 @@ Copy_In(uintptr_t fromuser, void *tokernel, uintptr_t len)
|
||||
|
||||
/**
|
||||
* Copy_Out --
|
||||
* Safely copy memory to userspace. Prevents userspace pointers from
|
||||
* writing kernel memory.
|
||||
*
|
||||
* @param [in] fromkernel Kernel address to copy from.
|
||||
* @param [in] touser User address to copy to.
|
||||
* @param [in] len Length of the data to copy.
|
||||
* @retval EFAULT if the address is invalid or causes a fault.
|
||||
* Safely copy memory to userspace. Prevents userspace pointers from
|
||||
* writing kernel memory.
|
||||
*
|
||||
* Side effects:
|
||||
* Kernel page fault may have occurred.
|
||||
* Kernel page fault may have occurred.
|
||||
*
|
||||
* @param [in] fromkernel Kernel address to copy from.
|
||||
* @param [in] touser User address to copy to.
|
||||
* @param [in] len Length of the data to copy.
|
||||
*
|
||||
* @retval EFAULT if the address is invalid or causes a fault.
|
||||
*/
|
||||
int
|
||||
Copy_Out(void *fromkernel, uintptr_t touser, uintptr_t len)
|
||||
@ -86,16 +90,17 @@ Copy_Out(void *fromkernel, uintptr_t touser, uintptr_t len)
|
||||
/**
|
||||
* Copy_StrIn --
|
||||
*
|
||||
* Safely copy a string from userspace. Prevents userspace pointers from
|
||||
* reading kernel memory.
|
||||
*
|
||||
* @param [in] fromuser User address to copy from.
|
||||
* @param [in] tokernel Kernel address to copy to.
|
||||
* @param [in] len Maximum string length.
|
||||
* @retval EFAULT if the address is invalid or causes a fault.
|
||||
* Safely copy a string from userspace. Prevents userspace pointers from
|
||||
* reading kernel memory.
|
||||
*
|
||||
* Side effects:
|
||||
* Kernel page fault may have occurred.
|
||||
* Kernel page fault may have occurred.
|
||||
*
|
||||
* @param [in] fromuser User address to copy from.
|
||||
* @param [in] tokernel Kernel address to copy to.
|
||||
* @param [in] len Maximum string length.
|
||||
*
|
||||
* @retval EFAULT if the address is invalid or causes a fault.
|
||||
*/
|
||||
int
|
||||
Copy_StrIn(uintptr_t fromuser, void *tokernel, uintptr_t len)
|
||||
@ -120,16 +125,18 @@ Copy_StrIn(uintptr_t fromuser, void *tokernel, uintptr_t len)
|
||||
|
||||
/**
|
||||
* Copy_StrOut --
|
||||
* Safely copy a string to userspace. Prevents userspace pointers from
|
||||
* writing kernel memory.
|
||||
*
|
||||
* @param [in] fromkernel Kernel address to copy from.
|
||||
* @param [in] touser User address to copy to.
|
||||
* @param [in] len Maximum string length.
|
||||
* @retval EFAULT if the address is invalid or causes a fault.
|
||||
* Safely copy a string to userspace. Prevents userspace pointers from
|
||||
* writing kernel memory.
|
||||
*
|
||||
* Side effects:
|
||||
* Kernel page fault may have occurred.
|
||||
* Kernel page fault may have occurred.
|
||||
*
|
||||
* @param [in] fromkernel Kernel address to copy from.
|
||||
* @param [in] touser User address to copy to.
|
||||
* @param [in] len Maximum string length.
|
||||
*
|
||||
* @retval EFAULT if the address is invalid or causes a fault.
|
||||
*/
|
||||
int
|
||||
Copy_StrOut(void *fromkernel, uintptr_t touser, uintptr_t len)
|
||||
|
@ -40,7 +40,7 @@ CV_Destroy(CV *cv)
|
||||
/**
|
||||
* CV_Wait --
|
||||
*
|
||||
* Wait to be woken up on a condition.
|
||||
* Wait to be woken up on a condition.
|
||||
*/
|
||||
void
|
||||
CV_Wait(CV *cv, Mutex *mtx)
|
||||
@ -59,7 +59,7 @@ CV_Wait(CV *cv, Mutex *mtx)
|
||||
/**
|
||||
* CV_Signal --
|
||||
*
|
||||
* Wake a single thread waiting on the condition.
|
||||
* Wake a single thread waiting on the condition.
|
||||
*/
|
||||
void
|
||||
CV_Signal(CV *cv)
|
||||
@ -72,7 +72,7 @@ CV_Signal(CV *cv)
|
||||
/**
|
||||
* CV_WakeAll --
|
||||
*
|
||||
* Wake all threads waiting on the condition.
|
||||
* Wake all threads waiting on the condition.
|
||||
*/
|
||||
void
|
||||
CV_WakeAll(CV *cv)
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2023 Ali Mashtizadeh
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2023 Ali Mashtizadeh
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -21,10 +25,10 @@
|
||||
|
||||
extern Handle *Console_OpenHandle();
|
||||
|
||||
/*
|
||||
/**
|
||||
* Loader_CheckHeader --
|
||||
*
|
||||
* Check that the program has a valid ELF header.
|
||||
* Check that the program has a valid ELF header.
|
||||
*/
|
||||
bool
|
||||
Loader_CheckHeader(const Elf64_Ehdr *ehdr)
|
||||
@ -46,12 +50,12 @@ Loader_CheckHeader(const Elf64_Ehdr *ehdr)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* LoaderLoadSegment --
|
||||
*
|
||||
* Loads a single segment into the target address space. This function
|
||||
* loads a single page at a time because it has to lookup the address
|
||||
* mappings through the page tables.
|
||||
* Loads a single segment into the target address space. This function loads a
|
||||
* single page at a time because it has to lookup the address mappings through
|
||||
* the page tables.
|
||||
*/
|
||||
static void
|
||||
LoaderLoadSegment(AS *as, VNode *vn, uintptr_t vaddr,
|
||||
@ -84,11 +88,11 @@ LoaderLoadSegment(AS *as, VNode *vn, uintptr_t vaddr,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* LoaderZeroSegment --
|
||||
*
|
||||
* Zeroes a segment of memory in the target address space. This is done
|
||||
* one page a time while translating the virtual address to physical.
|
||||
* Zeroes a segment of memory in the target address space. This is done one
|
||||
* page a time while translating the virtual address to physical.
|
||||
*/
|
||||
static void
|
||||
LoaderZeroSegment(AS *as, uintptr_t vaddr, uintptr_t len)
|
||||
@ -118,10 +122,10 @@ LoaderZeroSegment(AS *as, uintptr_t vaddr, uintptr_t len)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Loader_Load --
|
||||
*
|
||||
* Load the ELF binary into the process belonging to the thread.
|
||||
* Load the ELF binary into the process belonging to the thread.
|
||||
*/
|
||||
bool
|
||||
Loader_Load(Thread *thr, VNode *vn, void *buf, uint64_t len)
|
||||
@ -184,12 +188,12 @@ Loader_Load(Thread *thr, VNode *vn, void *buf, uint64_t len)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Loader_LoadInit --
|
||||
*
|
||||
* The init process is created from the execution kernel thread that
|
||||
* initializes the system. This function initializes the thread and
|
||||
* process state then loads the init binary.
|
||||
* The init process is created from the execution kernel thread that
|
||||
* initializes the system. This function initializes the thread and process
|
||||
* state then loads the init binary.
|
||||
*/
|
||||
void
|
||||
Loader_LoadInit()
|
||||
|
@ -46,7 +46,7 @@ Mutex_Destroy(Mutex *mtx)
|
||||
/**
|
||||
* Mutex_Lock --
|
||||
*
|
||||
* Acquires the mutex.
|
||||
* Acquires the mutex.
|
||||
*/
|
||||
void
|
||||
Mutex_Lock(Mutex *mtx)
|
||||
@ -74,8 +74,8 @@ Mutex_Lock(Mutex *mtx)
|
||||
/**
|
||||
* Mutex_TryLock --
|
||||
*
|
||||
* Attempts to acquire the user mutex. Returns EBUSY if the lock is
|
||||
* already taken, otherwise 0 on success.
|
||||
* Attempts to acquire the user mutex. Returns EBUSY if the lock is already
|
||||
* taken, otherwise 0 on success.
|
||||
*/
|
||||
int
|
||||
Mutex_TryLock(Mutex *mtx)
|
||||
@ -95,7 +95,7 @@ Mutex_TryLock(Mutex *mtx)
|
||||
/**
|
||||
* Mutex_Unlock --
|
||||
*
|
||||
* Releases the user mutex.
|
||||
* Releases the user mutex.
|
||||
*/
|
||||
void
|
||||
Mutex_Unlock(Mutex *mtx)
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2023 Ali Mashtizadeh
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
@ -63,9 +63,9 @@ PAlloc_Init()
|
||||
/**
|
||||
* PAlloc_LateInit --
|
||||
*
|
||||
* The late init call is made after the page tables are initialized using
|
||||
* a small boot memory region (2nd 16MBs). This is where initialize the
|
||||
* XMem region that represents the PageInfo array, and map memory into it.
|
||||
* The late init call is made after the page tables are initialized using a
|
||||
* small boot memory region (2nd 16MBs). This is where initialize the XMem
|
||||
* region that represents the PageInfo array, and map memory into it.
|
||||
*/
|
||||
void
|
||||
PAlloc_LateInit()
|
||||
@ -86,7 +86,7 @@ PAlloc_LateInit()
|
||||
/**
|
||||
* PAlloc_AddRegion --
|
||||
*
|
||||
* Add a physical memory region to the page allocator.
|
||||
* Add a physical memory region to the page allocator.
|
||||
*/
|
||||
void
|
||||
PAlloc_AddRegion(uintptr_t start, uintptr_t len)
|
||||
@ -166,7 +166,7 @@ PAlloc_AddRegion(uintptr_t start, uintptr_t len)
|
||||
/**
|
||||
* PAllocGetInfo --
|
||||
*
|
||||
* Lookup the PageInfo structure for a given physical address.
|
||||
* Lookup the PageInfo structure for a given physical address.
|
||||
*/
|
||||
static inline PageInfo *
|
||||
PAllocGetInfo(void *pg)
|
||||
@ -178,11 +178,11 @@ PAllocGetInfo(void *pg)
|
||||
/**
|
||||
* PAlloc_AllocPage --
|
||||
*
|
||||
* Allocate a physical page and return the page's address in the Kernel's
|
||||
* ident mapped memory region.
|
||||
* Allocate a physical page and return the page's address in the Kernel's ident
|
||||
* mapped memory region.
|
||||
*
|
||||
* @retval NULL if no memory is available.
|
||||
* @return Newly allocated physical page.
|
||||
* @retval NULL if no memory is available.
|
||||
* @return Newly allocated physical page.
|
||||
*/
|
||||
void *
|
||||
PAlloc_AllocPage()
|
||||
@ -215,7 +215,7 @@ PAlloc_AllocPage()
|
||||
/**
|
||||
* PAllocFreePage --
|
||||
*
|
||||
* Free a page.
|
||||
* Free a page.
|
||||
*/
|
||||
static void
|
||||
PAllocFreePage(void *region)
|
||||
@ -242,7 +242,7 @@ PAllocFreePage(void *region)
|
||||
/**
|
||||
* PAlloc_Retain --
|
||||
*
|
||||
* Increment the reference count for a physical page.
|
||||
* Increment the reference count for a physical page.
|
||||
*/
|
||||
void
|
||||
PAlloc_Retain(void *pg)
|
||||
@ -258,8 +258,8 @@ PAlloc_Retain(void *pg)
|
||||
/**
|
||||
* PAlloc_Release --
|
||||
*
|
||||
* Deccrement the reference count for a physical page. If the reference
|
||||
* count is zero the page will be freed.
|
||||
* Deccrement the reference count for a physical page. If the reference count
|
||||
* is zero the page will be freed.
|
||||
*/
|
||||
void
|
||||
PAlloc_Release(void *pg)
|
||||
|
@ -39,11 +39,12 @@ Slab processSlab;
|
||||
/**
|
||||
* Process_Create --
|
||||
*
|
||||
* Create a process.
|
||||
* Create a process.
|
||||
*
|
||||
* @param [in] parent Parent process.
|
||||
* @param [in] title Process title.
|
||||
* @return The newly created process.
|
||||
* @param [in] parent Parent process.
|
||||
* @param [in] title Process title.
|
||||
*
|
||||
* @return The newly created process.
|
||||
*/
|
||||
Process *
|
||||
Process_Create(Process *parent, const char *title)
|
||||
@ -103,10 +104,10 @@ Process_Create(Process *parent, const char *title)
|
||||
/**
|
||||
* Process_Destroy --
|
||||
*
|
||||
* Destroy a process. This should not be called direct, but rather by
|
||||
* Process_Release.
|
||||
* Destroy a process. This should not be called direct, but rather by
|
||||
* Process_Release.
|
||||
*
|
||||
* @param [in] proc Process to destroy.
|
||||
* @param [in] proc Process to destroy.
|
||||
*/
|
||||
static void
|
||||
Process_Destroy(Process *proc)
|
||||
@ -133,11 +134,12 @@ Process_Destroy(Process *proc)
|
||||
/**
|
||||
* Process_Lookup --
|
||||
*
|
||||
* Lookup a process by PID and increment its reference count.
|
||||
* @param [in] pid Process ID to search for.
|
||||
* Lookup a process by PID and increment its reference count.
|
||||
*
|
||||
* @retval NULL No such process.
|
||||
* @return Process that corresponds to the pid.
|
||||
* @param [in] pid Process ID to search for.
|
||||
*
|
||||
* @retval NULL No such process.
|
||||
* @return Process that corresponds to the pid.
|
||||
*/
|
||||
Process *
|
||||
Process_Lookup(uint64_t pid)
|
||||
@ -161,9 +163,9 @@ Process_Lookup(uint64_t pid)
|
||||
/**
|
||||
* Process_Retain --
|
||||
*
|
||||
* Increment the reference count for a given process.
|
||||
* Increment the reference count for a given process.
|
||||
*
|
||||
* @param proc Process to retain a reference to.
|
||||
* @param proc Process to retain a reference to.
|
||||
*/
|
||||
void
|
||||
Process_Retain(Process *proc)
|
||||
@ -175,9 +177,9 @@ Process_Retain(Process *proc)
|
||||
/**
|
||||
* Process_Release --
|
||||
*
|
||||
* Decrement the reference count for a given process.
|
||||
* Decrement the reference count for a given process.
|
||||
*
|
||||
* @param proc Process to release a reference of.
|
||||
* @param proc Process to release a reference of.
|
||||
*/
|
||||
void
|
||||
Process_Release(Process *proc)
|
||||
@ -191,14 +193,14 @@ Process_Release(Process *proc)
|
||||
/**
|
||||
* Process_Wait --
|
||||
*
|
||||
* Wait for a process to exit and then cleanup it's references. If the
|
||||
* pid == 0, we wait for any process, otherwise we wait for a specific
|
||||
* process.
|
||||
* Wait for a process to exit and then cleanup it's references. If the pid ==
|
||||
* 0, we wait for any process, otherwise we wait for a specific process.
|
||||
*
|
||||
* @param [in] proc Parent process.
|
||||
* @param [in] pid Optionally specify the pid of the process to wait on.
|
||||
* @retval ENOENT Process ID doesn't exist.
|
||||
* @return Exit status of the process that exited or crashed.
|
||||
* @param [in] proc Parent process.
|
||||
* @param [in] pid Optionally specify the pid of the process to wait on.
|
||||
*
|
||||
* @retval ENOENT Process ID doesn't exist.
|
||||
* @return Exit status of the process that exited or crashed.
|
||||
*/
|
||||
uint64_t
|
||||
Process_Wait(Process *proc, uint64_t pid)
|
||||
|
@ -47,10 +47,10 @@ Thread *curProc[MAX_CPUS];
|
||||
/**
|
||||
* Sched_Current() --
|
||||
*
|
||||
* Get the currently executing thread. This function retains a reference
|
||||
* count and you must release the reference by calling Thread_Release.
|
||||
* Get the currently executing thread. This function retains a reference count
|
||||
* and you must release the reference by calling Thread_Release.
|
||||
*
|
||||
* @return Returns the current thread.
|
||||
* @return Returns the current thread.
|
||||
*/
|
||||
Thread *
|
||||
Sched_Current()
|
||||
@ -68,10 +68,10 @@ Sched_Current()
|
||||
/**
|
||||
* Sched_SetRunnable --
|
||||
*
|
||||
* Set the thread to the runnable state and move it from the wait queue if
|
||||
* necessary to the runnable queue.
|
||||
* Set the thread to the runnable state and move it from the wait queue if
|
||||
* necessary to the runnable queue.
|
||||
*
|
||||
* @param [in] thr Thread to be set as runnable.
|
||||
* @param [in] thr Thread to be set as runnable.
|
||||
*/
|
||||
void
|
||||
Sched_SetRunnable(Thread *thr)
|
||||
@ -95,10 +95,10 @@ Sched_SetRunnable(Thread *thr)
|
||||
/**
|
||||
* Sched_SetWaiting --
|
||||
*
|
||||
* Set the thread to the waiting state and move it to the wait queue. The
|
||||
* thread should be currently running.
|
||||
* Set the thread to the waiting state and move it to the wait queue. The
|
||||
* thread should be currently running.
|
||||
*
|
||||
* @param [in] thr Thread to be set as waiting.
|
||||
* @param [in] thr Thread to be set as waiting.
|
||||
*/
|
||||
void
|
||||
Sched_SetWaiting(Thread *thr)
|
||||
@ -117,11 +117,10 @@ Sched_SetWaiting(Thread *thr)
|
||||
/**
|
||||
* Sched_SetZombie --
|
||||
*
|
||||
* Set the thread to the zombie state and move it to the parent
|
||||
* processes's zombie process queue. The thread should be currently
|
||||
* running.
|
||||
* Set the thread to the zombie state and move it to the parent processes's
|
||||
* zombie process queue. The thread should be currently running.
|
||||
*
|
||||
* @param [in] thr Thread to be set as zombie.
|
||||
* @param [in] thr Thread to be set as zombie.
|
||||
*/
|
||||
void
|
||||
Sched_SetZombie(Thread *thr)
|
||||
@ -165,13 +164,12 @@ Sched_SetZombie(Thread *thr)
|
||||
/**
|
||||
* Sched_Switch --
|
||||
*
|
||||
* Switch between threads. During the creation of kernel threads (and by
|
||||
* proxy user threads) we may not return through this code path and thus
|
||||
* the kernel thread initialization function must release the scheduler
|
||||
* lock.
|
||||
* Switch between threads. During the creation of kernel threads (and by proxy
|
||||
* user threads) we may not return through this code path and thus the kernel
|
||||
* thread initialization function must release the scheduler lock.
|
||||
*
|
||||
* @param [in] oldthr Current thread we are switching from.
|
||||
* @param [in] newthr Thread to switch to.
|
||||
* @param [in] oldthr Current thread we are switching from.
|
||||
* @param [in] newthr Thread to switch to.
|
||||
*/
|
||||
static void
|
||||
Sched_Switch(Thread *oldthr, Thread *newthr)
|
||||
@ -185,7 +183,7 @@ Sched_Switch(Thread *oldthr, Thread *newthr)
|
||||
/**
|
||||
* Sched_Scheduler --
|
||||
*
|
||||
* Run our round robin scheduler to find the process and switch to it.
|
||||
* Run our round robin scheduler to find the process and switch to it.
|
||||
*/
|
||||
void
|
||||
Sched_Scheduler()
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2023 Ali Mashtizadeh
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -68,8 +68,8 @@ Spinlock_Destroy(Spinlock *lock)
|
||||
/**
|
||||
* Spinlock_Lock --
|
||||
*
|
||||
* Spin until we acquire the spinlock. This will also disable interrupts
|
||||
* to prevent deadlocking with interrupt handlers.
|
||||
* Spin until we acquire the spinlock. This will also disable interrupts to
|
||||
* prevent deadlocking with interrupt handlers.
|
||||
*/
|
||||
void
|
||||
Spinlock_Lock(Spinlock *lock) __NO_LOCK_ANALYSIS
|
||||
@ -103,7 +103,7 @@ Spinlock_Lock(Spinlock *lock) __NO_LOCK_ANALYSIS
|
||||
/**
|
||||
* Spinlock_Unlock --
|
||||
*
|
||||
* Release the spinlock. This will re-enable interrupts.
|
||||
* Release the spinlock. This will re-enable interrupts.
|
||||
*/
|
||||
void
|
||||
Spinlock_Unlock(Spinlock *lock) __NO_LOCK_ANALYSIS
|
||||
|
@ -218,11 +218,12 @@ Thread_Destroy(Thread *thr)
|
||||
/**
|
||||
* Thread_Lookup --
|
||||
*
|
||||
* Lookup a thread by TID and increment its reference count.
|
||||
* Lookup a thread by TID and increment its reference count.
|
||||
*
|
||||
* @param [in] proc Process within which to find a specific thread.
|
||||
* @param [in] tid Thread ID of the thread to find.
|
||||
* @retval NULL if the thread isn't found.
|
||||
* @param [in] proc Process within which to find a specific thread.
|
||||
* @param [in] tid Thread ID of the thread to find.
|
||||
*
|
||||
* @retval NULL if the thread isn't found.
|
||||
*/
|
||||
Thread *
|
||||
Thread_Lookup(Process *proc, uint64_t tid)
|
||||
@ -246,7 +247,7 @@ Thread_Lookup(Process *proc, uint64_t tid)
|
||||
/**
|
||||
* Thread_Retain --
|
||||
*
|
||||
* Increment the reference count for a given thread.
|
||||
* Increment the reference count for a given thread.
|
||||
*/
|
||||
void
|
||||
Thread_Retain(Thread *thr)
|
||||
@ -258,7 +259,7 @@ Thread_Retain(Thread *thr)
|
||||
/**
|
||||
* Thread_Release --
|
||||
*
|
||||
* Decrement the reference count for a given thread.
|
||||
* Decrement the reference count for a given thread.
|
||||
*/
|
||||
void
|
||||
Thread_Release(Thread *thr)
|
||||
@ -272,7 +273,7 @@ Thread_Release(Thread *thr)
|
||||
/**
|
||||
* Thread_Wait --
|
||||
*
|
||||
* Wait for any thread (tid == TID_ANY) or a specific thread.
|
||||
* Wait for any thread (tid == TID_ANY) or a specific thread.
|
||||
*/
|
||||
uint64_t
|
||||
Thread_Wait(Thread *thr, uint64_t tid)
|
||||
|
@ -30,7 +30,7 @@ DEFINE_SLAB(VNode, &vnodeSlab);
|
||||
/**
|
||||
* VFS_MountRoot --
|
||||
*
|
||||
* Mount the root file system from a specific disk.
|
||||
* Mount the root file system from a specific disk.
|
||||
*/
|
||||
int
|
||||
VFS_MountRoot(Disk *rootDisk)
|
||||
@ -56,9 +56,8 @@ VFS_MountRoot(Disk *rootDisk)
|
||||
/**
|
||||
* VFS_Lookup --
|
||||
*
|
||||
* Lookup a VNode by a path. This function recursively searches the
|
||||
* directory heirarchy until the given path is found otherwise returns
|
||||
* NULL if not found.
|
||||
* Lookup a VNode by a path. This function recursively searches the directory
|
||||
* heirarchy until the given path is found otherwise returns NULL if not found.
|
||||
*/
|
||||
VNode *
|
||||
VFS_Lookup(const char *path)
|
||||
@ -118,8 +117,8 @@ VFS_Lookup(const char *path)
|
||||
/**
|
||||
* VFS_Stat --
|
||||
*
|
||||
* Return the struct stat that contains the file and directory information
|
||||
* for a given VNode.
|
||||
* Return the struct stat that contains the file and directory information for
|
||||
* a given VNode.
|
||||
*/
|
||||
int
|
||||
VFS_Stat(const char *path, struct stat *sb)
|
||||
@ -138,10 +137,11 @@ VFS_Stat(const char *path, struct stat *sb)
|
||||
/**
|
||||
* VFS_Open --
|
||||
*
|
||||
* Open a vnode for reading and writing.
|
||||
* Open a vnode for reading and writing.
|
||||
*
|
||||
* @param [in] fn VNode to open.
|
||||
* @return Return status
|
||||
* @param [in] fn VNode to open.
|
||||
*
|
||||
* @return Return status
|
||||
*/
|
||||
int
|
||||
VFS_Open(VNode *fn)
|
||||
@ -152,10 +152,11 @@ VFS_Open(VNode *fn)
|
||||
/**
|
||||
* VFS_Close --
|
||||
*
|
||||
* Close a vnode.
|
||||
* Close a vnode.
|
||||
*
|
||||
* @param [in] fn VNode to close.
|
||||
* @return Return status
|
||||
* @param [in] fn VNode to close.
|
||||
*
|
||||
* @return Return status
|
||||
*/
|
||||
int
|
||||
VFS_Close(VNode *fn)
|
||||
@ -166,13 +167,14 @@ VFS_Close(VNode *fn)
|
||||
/**
|
||||
* VFS_Read --
|
||||
*
|
||||
* Read from a vnode.
|
||||
* Read from a vnode.
|
||||
*
|
||||
* @param [in] fn VNode to read from.
|
||||
* @param [in] buf Buffer to write the data to.
|
||||
* @param [in] off File offset in bytes.
|
||||
* @param [in] len Length to read in bytes.
|
||||
* @return Return status
|
||||
* @param [in] fn VNode to read from.
|
||||
* @param [in] buf Buffer to write the data to.
|
||||
* @param [in] off File offset in bytes.
|
||||
* @param [in] len Length to read in bytes.
|
||||
*
|
||||
* @return Return status
|
||||
*/
|
||||
int
|
||||
VFS_Read(VNode *fn, void *buf, uint64_t off, uint64_t len)
|
||||
@ -183,13 +185,14 @@ VFS_Read(VNode *fn, void *buf, uint64_t off, uint64_t len)
|
||||
/**
|
||||
* VFS_Write --
|
||||
*
|
||||
* Write from a vnode.
|
||||
* Write from a vnode.
|
||||
*
|
||||
* @param [in] fn VNode to write to.
|
||||
* @param [in] buf Buffer to read the data from.
|
||||
* @param [in] off File offset in bytes.
|
||||
* @param [in] len Length to read in bytes.
|
||||
* @return Return status
|
||||
* @param [in] fn VNode to write to.
|
||||
* @param [in] buf Buffer to read the data from.
|
||||
* @param [in] off File offset in bytes.
|
||||
* @param [in] len Length to read in bytes.
|
||||
*
|
||||
* @return Return status
|
||||
*/
|
||||
int
|
||||
VFS_Write(VNode *fn, void *buf, uint64_t off, uint64_t len)
|
||||
@ -200,13 +203,14 @@ VFS_Write(VNode *fn, void *buf, uint64_t off, uint64_t len)
|
||||
/**
|
||||
* VFS_ReadDir --
|
||||
*
|
||||
* Read a directory entry from a vnode.
|
||||
* Read a directory entry from a vnode.
|
||||
*
|
||||
* @param [in] fn VNode to read from.
|
||||
* @param [in] buf Buffer to write the data to.
|
||||
* @param [in] off Directory offset in bytes.
|
||||
* @param [in] len Length to read in bytes.
|
||||
* @return Return status
|
||||
* @param [in] fn VNode to read from.
|
||||
* @param [in] buf Buffer to write the data to.
|
||||
* @param [in] off Directory offset in bytes.
|
||||
* @param [in] len Length to read in bytes.
|
||||
*
|
||||
* @return Return status
|
||||
*/
|
||||
int
|
||||
VFS_ReadDir(VNode *fn, void *buf, uint64_t len, uint64_t *off)
|
||||
|
Loading…
Reference in New Issue
Block a user