27 static const char table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
29 for (
size_t i = 0; i < len;)
31 uint32_t octetA = i < len ? src[i++] : 0;
32 uint32_t octetB = i < len ? src[i++] : 0;
33 uint32_t octetC = i < len ? src[i++] : 0;
35 uint32_t n = (octetA << 16) | (octetB << 8) | octetC;
36 *dest++ = table[(n >> 18) & 0x3F];
37 *dest++ = table[(n >> 12) & 0x3F];
38 *dest++ = table[(n >> 6) & 0x3F];
39 *dest++ = table[n & 0x3F];
51 uint8_t bytes[((size - 1) / 4) * 3];
159 if (mapEntry ==
NULL)
#define assert(expression)
EFI_PHYSICAL_ADDRESS buffer
#define SYSCALL_DEFINE(num, returnType,...)
Macro to define a syscall.
uint64_t rand_gen(void *buffer, uint64_t size)
Fills a buffer with random bytes.
file_t * file_table_get(file_table_t *table, fd_t fd)
Get a file from its file descriptor.
fd_t file_table_open(file_table_t *table, file_t *file)
Allocate a new file descriptor for a file.
file_t * key_claim(const char *key)
Claims a shared file using the provided key.
uint64_t key_share(char *key, uint64_t size, file_t *file, clock_t timeout)
Generates a key that can be used to retrieve the file within the specified timeout.
clock_t clock_uptime(void)
Retrieve the time in nanoseconds since boot.
static thread_t * thread_current(void)
Retrieves the currently running thread.
uint64_t thread_copy_from_user_string(thread_t *thread, char *dest, const char *userSrc, uint64_t size)
Safely copy a string from user space.
uint64_t thread_copy_to_user(thread_t *thread, void *userDest, const void *src, uint64_t length)
Safely copy data to user space.
#define LOCK_CREATE()
Create a lock initializer.
#define LOCK_SCOPE(lock)
Acquires a lock for the reminder of the current scope.
void timer_set(clock_t now, clock_t deadline)
Schedule a one-shot timer interrupt on the current CPU.
void map_entry_init(map_entry_t *entry)
Initialize a map entry.
uint64_t map_insert(map_t *map, const map_key_t *key, map_entry_t *value)
Insert a key-value pair into the map.
map_entry_t * map_get_and_remove(map_t *map, const map_key_t *key)
Get and remove a key-value pair from the map.
void map_remove(map_t *map, map_entry_t *entry)
Remove a entry from the map.
map_entry_t * map_get(map_t *map, const map_key_t *key)
Get a value from the map by key.
static map_key_t map_key_string(const char *str)
Create a map key from a string.
#define MAP_CREATE()
Create a map initializer.
#define UNREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define REF(ptr)
Increment reference count.
#define UNREF(ptr)
Decrement reference count.
#define ENOENT
No such file or directory.
#define EINVAL
Invalid argument.
#define errno
Error number variable.
#define UNUSED(x)
Mark a variable as unused.
#define KEY_MAX
Maximum size of a key generated by share().
#define LIST_FOR_EACH(elem, list, member)
Iterates over a list.
static void list_remove(list_entry_t *entry)
Removes a list entry from its current list.
static void list_push_back(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the list.
static void list_prepend(list_entry_t *head, list_entry_t *entry)
Prepends an entry to the list.
#define LIST_CREATE(name)
Creates a list initializer.
#define LIST_FOR_EACH_SAFE(elem, temp, list, member)
Safely iterates over a list, allowing for element removal during iteration.
static bool list_is_empty(list_t *list)
Checks if a list is empty.
static void list_entry_init(list_entry_t *entry)
Initializes a list entry.
clock_t uptime(void)
System call for retreving the time since boot.
#define NULL
Pointer error value.
#define ERR
Integer error value.
#define CONTAINER_OF(ptr, type, member)
Container of macro.
__UINT64_TYPE__ fd_t
File descriptor type.
#define CLOCKS_DEADLINE(timeout, uptime)
Safely calculate deadline from timeout.
__UINT64_TYPE__ clock_t
A nanosecond time.
static uint64_t key_generate(char *buffer, uint64_t size)
static void key_base64_encode(const uint8_t *src, size_t len, char *dest)
static void key_timer_handler(interrupt_frame_t *frame, cpu_t *self)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
_PUBLIC void * memcpy(void *_RESTRICT s1, const void *_RESTRICT s2, size_t n)
A simple ticket lock implementation.
Thread of execution structure.
process_t * process
The parent process that the thread executes within.