mirror of
https://github.com/drasko/codezero.git
synced 2026-02-22 23:03:14 +01:00
Lots of cosmetic changes to the thread library.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include <utcb.h>
|
||||
|
||||
/* Static variable definitions */
|
||||
static unsigned long utcb_end_max_addr;
|
||||
static unsigned long lib_utcb_end_addr;
|
||||
|
||||
/* Function definitions */
|
||||
unsigned long get_utcb_addr(void)
|
||||
@@ -24,7 +24,7 @@ unsigned long get_utcb_addr(void)
|
||||
utcb_addr = utcb_new_slot(udesc_ptr);
|
||||
}
|
||||
|
||||
if (utcb_addr >= utcb_end_max_addr)
|
||||
if (utcb_addr >= lib_utcb_end_addr)
|
||||
return 0;
|
||||
|
||||
return utcb_addr;
|
||||
@@ -47,57 +47,56 @@ static int set_utcb_addr(void)
|
||||
|
||||
if ((err = l4_exchange_registers(&exregs, ids.tid)) < 0) {
|
||||
printf("libl4thread: l4_exchange_registers failed with "
|
||||
"(%d)!\n", err);
|
||||
"(%d).\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_utcb_params(unsigned long utcb_start_addr,
|
||||
unsigned long utcb_end_addr)
|
||||
int set_utcb_params(unsigned long utcb_start, unsigned long utcb_end)
|
||||
{
|
||||
int err;
|
||||
|
||||
/* Ensure that arguments are valid. */
|
||||
if (IS_UTCB_SETUP()) {
|
||||
printf("libl4thread: You have already called: %s. Simply, "
|
||||
"this will have no effect!\n", __FUNCTION__);
|
||||
printf("libl4thread: You have already called: %s.\n",
|
||||
__FUNCTION__);
|
||||
return -EPERM;
|
||||
}
|
||||
if (!utcb_start_addr || !utcb_end_addr) {
|
||||
printf("libl4thread: utcb address range cannot contain "
|
||||
"0x00000000 as a start and/or end address(es)!\n");
|
||||
if (!utcb_start || !utcb_end) {
|
||||
printf("libl4thread: Utcb address range cannot contain "
|
||||
"0x0 as a start and/or end address(es).\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
/* Check if the start address is aligned on UTCB_SIZE. */
|
||||
if (utcb_start_addr & !UTCB_SIZE) {
|
||||
printf("libl4thread: utcb start address must be aligned "
|
||||
"on UTCB_SIZE(0x%x)\n", UTCB_SIZE);
|
||||
if (utcb_start & !UTCB_SIZE) {
|
||||
printf("libl4thread: Utcb start address must be aligned "
|
||||
"on UTCB_SIZE(0x%x).\n", UTCB_SIZE);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* The range must be a valid one. */
|
||||
if (utcb_start_addr >= utcb_end_addr) {
|
||||
printf("libl4thread: utcb end address must be bigger "
|
||||
"than utcb start address!\n");
|
||||
if (utcb_start >= utcb_end) {
|
||||
printf("libl4thread: Utcb end address must be bigger "
|
||||
"than utcb start address.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
/*
|
||||
* This check guarantees two things:
|
||||
* 1. The range must be multiple of UTCB_SIZE, at least one item.
|
||||
* 2. utcb_end_addr is aligned on UTCB_SIZE
|
||||
* 2. utcb_end is aligned on UTCB_SIZE
|
||||
*/
|
||||
if ((utcb_end_addr - utcb_start_addr) % UTCB_SIZE) {
|
||||
printf("libl4thread: the given range size must be multiple "
|
||||
"of the utcb size(%d)!\n", UTCB_SIZE);
|
||||
if ((utcb_end - utcb_start) % UTCB_SIZE) {
|
||||
printf("libl4thread: The given range size must be multiple "
|
||||
"of the utcb size(%d).\n", UTCB_SIZE);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* Arguments passed the validity tests. */
|
||||
|
||||
/* Init utcb virtual address pool */
|
||||
utcb_pool_init(utcb_start_addr, utcb_end_addr);
|
||||
utcb_pool_init(utcb_start, utcb_end);
|
||||
|
||||
utcb_end_max_addr = utcb_end_addr;
|
||||
lib_utcb_end_addr = utcb_end;
|
||||
|
||||
/* The very first thread's utcb address is assigned. */
|
||||
if ((err = set_utcb_addr()) < 0)
|
||||
|
||||
Reference in New Issue
Block a user