Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1767 → Rev 1780

/kernel/trunk/generic/src/synch/rwlock.c
101,7 → 101,7
*
* @return See comment for waitq_sleep_timeout().
*/
int _rwlock_write_lock_timeout(rwlock_t *rwl, __u32 usec, int flags)
int _rwlock_write_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags)
{
ipl_t ipl;
int rc;
155,7 → 155,7
*
* @return See comment for waitq_sleep_timeout().
*/
int _rwlock_read_lock_timeout(rwlock_t *rwl, __u32 usec, int flags)
int _rwlock_read_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags)
{
int rc;
ipl_t ipl;
/kernel/trunk/generic/src/synch/mutex.c
64,7 → 64,7
*
* @return See comment for waitq_sleep_timeout().
*/
int _mutex_lock_timeout(mutex_t *mtx, __u32 usec, int flags)
int _mutex_lock_timeout(mutex_t *mtx, uint32_t usec, int flags)
{
return _semaphore_down_timeout(&mtx->sem, usec, flags);
}
/kernel/trunk/generic/src/synch/spinlock.c
108,7 → 108,7
#endif
if (i++ > DEADLOCK_THRESHOLD) {
printf("cpu%d: looping on spinlock %.*p:%s, caller=%.*p",
CPU->id, sizeof(__address) * 2, sl, sl->name, sizeof(__address) * 2, CALLER);
CPU->id, sizeof(uintptr_t) * 2, sl, sl->name, sizeof(uintptr_t) * 2, CALLER);
symbol = get_symtab_entry(CALLER);
if (symbol)
printf("(%s)", symbol);
/kernel/trunk/generic/src/synch/semaphore.c
78,7 → 78,7
*
* @return See comment for waitq_sleep_timeout().
*/
int _semaphore_down_timeout(semaphore_t *s, __u32 usec, int flags)
int _semaphore_down_timeout(semaphore_t *s, uint32_t usec, int flags)
{
return waitq_sleep_timeout(&s->wq, usec, flags);
}
/kernel/trunk/generic/src/synch/waitq.c
214,7 → 214,7
* @li ESYNCH_OK_BLOCKED means that the sleep succeeded; the full sleep was
* attempted.
*/
int waitq_sleep_timeout(waitq_t *wq, __u32 usec, int flags)
int waitq_sleep_timeout(waitq_t *wq, uint32_t usec, int flags)
{
ipl_t ipl;
int rc;
297,7 → 297,7
*
* @return See waitq_sleep_timeout().
*/
int waitq_sleep_timeout_unsafe(waitq_t *wq, __u32 usec, int flags)
int waitq_sleep_timeout_unsafe(waitq_t *wq, uint32_t usec, int flags)
{
/* checks whether to go to sleep at all */
if (wq->missed_wakeups) {
351,7 → 351,7
return ESYNCH_TIMEOUT;
}
THREAD->timeout_pending = true;
timeout_register(&THREAD->sleep_timeout, (__u64) usec, waitq_timeouted_sleep, THREAD);
timeout_register(&THREAD->sleep_timeout, (uint64_t) usec, waitq_timeouted_sleep, THREAD);
}
 
list_append(&THREAD->wq_link, &wq->head);
/kernel/trunk/generic/src/synch/futex.c
58,9 → 58,9
 
static void futex_initialize(futex_t *futex);
 
static futex_t *futex_find(__address paddr);
static index_t futex_ht_hash(__native *key);
static bool futex_ht_compare(__native *key, count_t keys, link_t *item);
static futex_t *futex_find(uintptr_t paddr);
static index_t futex_ht_hash(unative_t *key);
static bool futex_ht_compare(unative_t *key, count_t keys, link_t *item);
static void futex_ht_remove_callback(link_t *item);
 
/**
108,10 → 108,10
* @return One of ESYNCH_TIMEOUT, ESYNCH_OK_ATOMIC and ESYNCH_OK_BLOCKED. See synch.h.
* If there is no physical mapping for uaddr ENOENT is returned.
*/
__native sys_futex_sleep_timeout(__address uaddr, __u32 usec, int flags)
unative_t sys_futex_sleep_timeout(uintptr_t uaddr, uint32_t usec, int flags)
{
futex_t *futex;
__address paddr;
uintptr_t paddr;
pte_t *t;
ipl_t ipl;
125,7 → 125,7
if (!t || !PTE_VALID(t) || !PTE_PRESENT(t)) {
page_table_unlock(AS, true);
interrupts_restore(ipl);
return (__native) ENOENT;
return (unative_t) ENOENT;
}
paddr = PTE_GET_FRAME(t) + (uaddr - ALIGN_DOWN(uaddr, PAGE_SIZE));
page_table_unlock(AS, true);
134,7 → 134,7
 
futex = futex_find(paddr);
return (__native) waitq_sleep_timeout(&futex->wq, usec, flags | SYNCH_FLAGS_INTERRUPTIBLE);
return (unative_t) waitq_sleep_timeout(&futex->wq, usec, flags | SYNCH_FLAGS_INTERRUPTIBLE);
}
 
/** Wakeup one thread waiting in futex wait queue.
143,10 → 143,10
*
* @return ENOENT if there is no physical mapping for uaddr.
*/
__native sys_futex_wakeup(__address uaddr)
unative_t sys_futex_wakeup(uintptr_t uaddr)
{
futex_t *futex;
__address paddr;
uintptr_t paddr;
pte_t *t;
ipl_t ipl;
160,7 → 160,7
if (!t || !PTE_VALID(t) || !PTE_PRESENT(t)) {
page_table_unlock(AS, true);
interrupts_restore(ipl);
return (__native) ENOENT;
return (unative_t) ENOENT;
}
paddr = PTE_GET_FRAME(t) + (uaddr - ALIGN_DOWN(uaddr, PAGE_SIZE));
page_table_unlock(AS, true);
182,7 → 182,7
*
* @return Address of the kernel futex structure.
*/
futex_t *futex_find(__address paddr)
futex_t *futex_find(uintptr_t paddr)
{
link_t *item;
futex_t *futex;
275,7 → 275,7
*
* @return Index into futex hash table.
*/
index_t futex_ht_hash(__native *key)
index_t futex_ht_hash(unative_t *key)
{
return *key & (FUTEX_HT_SIZE-1);
}
286,7 → 286,7
*
* @return True if the item matches the key. False otherwise.
*/
bool futex_ht_compare(__native *key, count_t keys, link_t *item)
bool futex_ht_compare(unative_t *key, count_t keys, link_t *item)
{
futex_t *futex;
 
323,7 → 323,7
node = list_get_instance(cur, btree_node_t, leaf_link);
for (i = 0; i < node->keys; i++) {
futex_t *ftx;
__address paddr = node->key[i];
uintptr_t paddr = node->key[i];
ftx = (futex_t *) node->value[i];
if (--ftx->refcount == 0)
/kernel/trunk/generic/src/synch/condvar.c
87,7 → 87,7
*
* @return See comment for waitq_sleep_timeout().
*/
int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, __u32 usec, int flags)
int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec, int flags)
{
int rc;
ipl_t ipl;
/kernel/trunk/generic/src/main/main.c
101,7 → 101,7
* the linker or the low level assembler code with
* appropriate sizes and addresses.
*/
__address hardcoded_load_address = 0; /**< Virtual address of where the kernel is loaded. */
uintptr_t hardcoded_load_address = 0; /**< Virtual address of where the kernel is loaded. */
size_t hardcoded_ktext_size = 0; /**< Size of the kernel code in bytes. */
size_t hardcoded_kdata_size = 0; /**< Size of the kernel data in bytes. */
 
132,7 → 132,7
*/
void main_bsp(void)
{
__address stackaddr;
uintptr_t stackaddr;
 
config.cpu_count = 1;
config.cpu_active = 1;
202,7 → 202,7
arch_post_mm_init();
 
version_print();
printf("%.*p: hardcoded_ktext_size=%zdK, hardcoded_kdata_size=%zdK\n", sizeof(__address) * 2, config.base, hardcoded_ktext_size >> 10, hardcoded_kdata_size >> 10);
printf("%.*p: hardcoded_ktext_size=%zdK, hardcoded_kdata_size=%zdK\n", sizeof(uintptr_t) * 2, config.base, hardcoded_ktext_size >> 10, hardcoded_kdata_size >> 10);
 
arch_pre_smp_init();
smp_init();
223,7 → 223,7
klog_init();
for (i = 0; i < init.cnt; i++)
printf("init[%zd].addr=%.*p, init[%zd].size=%zd\n", i, sizeof(__address) * 2, init.tasks[i].addr, i, init.tasks[i].size);
printf("init[%zd].addr=%.*p, init[%zd].size=%zd\n", i, sizeof(uintptr_t) * 2, init.tasks[i].addr, i, init.tasks[i].size);
ipc_init();
 
297,7 → 297,7
* collide with another CPU coming up. To prevent this, we
* switch to this cpu's private stack prior to waking kmp up.
*/
context_set(&CPU->saved_context, FADDR(main_ap_separated_stack), (__address) CPU->stack, CPU_STACK_SIZE);
context_set(&CPU->saved_context, FADDR(main_ap_separated_stack), (uintptr_t) CPU->stack, CPU_STACK_SIZE);
context_restore(&CPU->saved_context);
/* not reached */
}
/kernel/trunk/generic/src/debug/symtab.c
50,15 → 50,15
*
* @return Pointer to respective symbol string on success, NULL otherwise.
*/
char * get_symtab_entry(__native addr)
char * get_symtab_entry(unative_t addr)
{
count_t i;
 
for (i=1;symbol_table[i].address_le;++i) {
if (addr < __u64_le2host(symbol_table[i].address_le))
if (addr < uint64_t_le2host(symbol_table[i].address_le))
break;
}
if (addr >= __u64_le2host(symbol_table[i-1].address_le))
if (addr >= uint64_t_le2host(symbol_table[i-1].address_le))
return symbol_table[i-1].symbol_name;
return NULL;
}
108,10 → 108,10
* @param name Name of the symbol
* @return 0 - Not found, -1 - Duplicate symbol, other - address of symbol
*/
__address get_symbol_addr(const char *name)
uintptr_t get_symbol_addr(const char *name)
{
count_t found = 0;
__address addr = NULL;
uintptr_t addr = NULL;
char *hint;
int i;
 
118,13 → 118,13
i = 0;
while ((hint=symtab_search_one(name, &i))) {
if (!strlen(hint)) {
addr = __u64_le2host(symbol_table[i].address_le);
addr = uint64_t_le2host(symbol_table[i].address_le);
found++;
}
i++;
}
if (found > 1)
return ((__address) -1);
return ((uintptr_t) -1);
return addr;
}
 
132,15 → 132,15
void symtab_print_search(const char *name)
{
int i;
__address addr;
uintptr_t addr;
char *realname;
 
 
i = 0;
while (symtab_search_one(name, &i)) {
addr = __u64_le2host(symbol_table[i].address_le);
addr = uint64_t_le2host(symbol_table[i].address_le);
realname = symbol_table[i].symbol_name;
printf("%.*p: %s\n", sizeof(__address) * 2, addr, realname);
printf("%.*p: %s\n", sizeof(uintptr_t) * 2, addr, realname);
i++;
}
}
/kernel/trunk/generic/src/cpu/cpu.c
68,10 → 68,10
panic("malloc/cpus");
 
/* initialize everything */
memsetb((__address) cpus, sizeof(cpu_t) * config.cpu_count, 0);
memsetb((uintptr_t) cpus, sizeof(cpu_t) * config.cpu_count, 0);
 
for (i=0; i < config.cpu_count; i++) {
cpus[i].stack = (__u8 *) frame_alloc(STACK_FRAMES, FRAME_KA | FRAME_ATOMIC);
cpus[i].stack = (uint8_t *) frame_alloc(STACK_FRAMES, FRAME_KA | FRAME_ATOMIC);
cpus[i].id = i;
/kernel/trunk/generic/src/sysinfo/sysinfo.c
167,7 → 167,7
return NULL;
}
 
void sysinfo_set_item_val(const char *name, sysinfo_item_t **root, __native val)
void sysinfo_set_item_val(const char *name, sysinfo_item_t **root, unative_t val)
{
if (root == NULL)
root = &_root;
222,7 → 222,7
while (root != NULL) {
int i;
__native val = 0;
unative_t val = 0;
char *vtype = NULL;
278,7 → 278,7
return ret;
}
 
__native sys_sysinfo_valid(__native ptr, __native len)
unative_t sys_sysinfo_valid(unative_t ptr, unative_t len)
{
char *str;
sysinfo_rettype_t ret = {0, 0};
292,7 → 292,7
return ret.valid;
}
 
__native sys_sysinfo_value(__native ptr, __native len)
unative_t sys_sysinfo_value(unative_t ptr, unative_t len)
{
char *str;
sysinfo_rettype_t ret = {0, 0};
/kernel/trunk/generic/src/interrupt/interrupt.c
109,11 → 109,11
spinlock_lock(&exctbl_lock);
printf("Exc Description Handler\n");
for (i=0; i < IVT_ITEMS; i++) {
symbol = get_symtab_entry((__native)exc_table[i].f);
symbol = get_symtab_entry((unative_t)exc_table[i].f);
if (!symbol)
symbol = "not found";
printf("%d %s %.*p(%s)\n", i + IVT_FIRST, exc_table[i].name,
sizeof(__address) * 2, exc_table[i].f,symbol);
sizeof(uintptr_t) * 2, exc_table[i].f,symbol);
if (!((i+1) % 20)) {
printf("Press any key to continue.");
spinlock_unlock(&exctbl_lock);
/kernel/trunk/generic/src/time/delay.c
49,7 → 49,7
*
* @param usec Number of microseconds to sleep.
*/
void delay(__u32 usec)
void delay(uint32_t usec)
{
ipl_t ipl;
/kernel/trunk/generic/src/time/timeout.c
103,12 → 103,12
* @param arg Timeout handler argument.
*
*/
void timeout_register(timeout_t *t, __u64 time, timeout_handler_t f, void *arg)
void timeout_register(timeout_t *t, uint64_t time, timeout_handler_t f, void *arg)
{
timeout_t *hlp = NULL;
link_t *l, *m;
ipl_t ipl;
__u64 sum;
uint64_t sum;
 
ipl = interrupts_disable();
spinlock_lock(&CPU->timeoutlock);
/kernel/trunk/generic/src/time/clock.c
57,15 → 57,15
 
/* Pointers to public variables with time */
struct ptime {
__native seconds1;
__native useconds;
__native seconds2;
unative_t seconds1;
unative_t useconds;
unative_t seconds2;
};
struct ptime *public_time;
/* Variable holding fragment of second, so that we would update
* seconds correctly
*/
static __native secfrag = 0;
static unative_t secfrag = 0;
 
/** Initialize realtime clock counter
*
90,7 → 90,7
public_time->seconds2 = 0;
public_time->useconds = 0;
 
sysinfo_set_item_val("clock.faddr", NULL, (__native)faddr);
sysinfo_set_item_val("clock.faddr", NULL, (unative_t)faddr);
}
 
 
165,7 → 165,7
*/
 
if (THREAD) {
__u64 ticks;
uint64_t ticks;
spinlock_lock(&CPU->lock);
CPU->needs_relink += 1 + missed_clock_ticks;
/kernel/trunk/generic/src/ddi/ddi.c
62,7 → 62,7
* ENOENT if there is no task matching the specified ID and ENOMEM if
* there was a problem in creating address space area.
*/
static int ddi_physmem_map(__address pf, __address vp, count_t pages, int flags)
static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, count_t pages, int flags)
{
ipl_t ipl;
cap_t caps;
110,7 → 110,7
* @return 0 on success, EPERM if the caller lacks capabilities to use this syscall,
* ENOENT if there is no task matching the specified ID.
*/
static int ddi_iospace_enable(task_id_t id, __address ioaddr, size_t size)
static int ddi_iospace_enable(task_id_t id, uintptr_t ioaddr, size_t size)
{
ipl_t ipl;
cap_t caps;
158,11 → 158,11
*
* @return 0 on success, otherwise it returns error code found in errno.h
*/
__native sys_physmem_map(__native phys_base, __native virt_base, __native pages,
__native flags)
unative_t sys_physmem_map(unative_t phys_base, unative_t virt_base, unative_t pages,
unative_t flags)
{
return (__native) ddi_physmem_map(ALIGN_DOWN((__address) phys_base, FRAME_SIZE),
ALIGN_DOWN((__address) virt_base, PAGE_SIZE), (count_t) pages,
return (unative_t) ddi_physmem_map(ALIGN_DOWN((uintptr_t) phys_base, FRAME_SIZE),
ALIGN_DOWN((uintptr_t) virt_base, PAGE_SIZE), (count_t) pages,
(int) flags);
}
 
172,7 → 172,7
*
* @return 0 on success, otherwise it returns error code found in errno.h
*/
__native sys_iospace_enable(ddi_ioarg_t *uspace_io_arg)
unative_t sys_iospace_enable(ddi_ioarg_t *uspace_io_arg)
{
ddi_ioarg_t arg;
int rc;
179,9 → 179,9
rc = copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t));
if (rc != 0)
return (__native) rc;
return (unative_t) rc;
return (__native) ddi_iospace_enable((task_id_t) arg.task_id, (__address) arg.ioaddr, (size_t) arg.size);
return (unative_t) ddi_iospace_enable((task_id_t) arg.task_id, (uintptr_t) arg.ioaddr, (size_t) arg.size);
}
 
/** Disable or enable preemption.
192,7 → 192,7
*
* @return Zero on success or EPERM if callers capabilities are not sufficient.
*/
__native sys_preempt_control(int enable)
unative_t sys_preempt_control(int enable)
{
if (! cap_get(TASK) & CAP_PREEMPT_CONTROL)
return EPERM;
/kernel/trunk/generic/src/printf/printf_core.c
88,9 → 88,9
* @param str Pointer to valid string.
* @return string length without trailing zero.
*/
static __native strlen(const char *str)
static unative_t strlen(const char *str)
{
__native counter = 0;
unative_t counter = 0;
 
while (str[counter] != 0) {
counter++;
146,7 → 146,7
* @param flags
* @return number of printed characters, negative value on fail
*/
static int print_char(char c, int width, __u64 flags, struct printf_spec *ps)
static int print_char(char c, int width, uint64_t flags, struct printf_spec *ps)
{
int counter = 0;
176,7 → 176,7
* @return number of printed characters or negative value on fail
*/
static int print_string(char *s, int width, int precision, __u64 flags, struct printf_spec *ps)
static int print_string(char *s, int width, int precision, uint64_t flags, struct printf_spec *ps)
{
int counter = 0;
size_t size;
236,7 → 236,7
* @return number of written characters or EOF
*
*/
static int print_number(__u64 num, int width, int precision, int base , __u64 flags, struct printf_spec *ps)
static int print_number(uint64_t num, int width, int precision, int base , uint64_t flags, struct printf_spec *ps)
{
char *digits = digits_small;
char d[PRINT_NUMBER_BUFFER_SIZE]; /* this is good enough even for base == 2, prefix and sign */
427,7 → 427,7
* - "" Signed or usigned int (default value).@n
* - "l" Signed or usigned long int.@n
* - "ll" Signed or usigned long long int.@n
* - "z" __native (non-standard extension).@n
* - "z" unative_t (non-standard extension).@n
*
*
* CONVERSION:@n
466,10 → 466,10
char c;
qualifier_t qualifier; /* type of argument */
int base; /**< base in which will be parameter (numbers only) printed */
__u64 number; /**< argument value */
uint64_t number; /**< argument value */
size_t size; /**< byte size of integer parameter */
int width, precision;
__u64 flags;
uint64_t flags;
counter = 0;
562,7 → 562,7
qualifier = PrintfQualifierLongLong;
}
break;
case 'z': /* __native */
case 'z': /* unative_t */
qualifier = PrintfQualifierNative;
break;
default:
644,31 → 644,31
switch (qualifier) {
case PrintfQualifierByte:
size = sizeof(unsigned char);
number = (__u64)va_arg(ap, unsigned int);
number = (uint64_t)va_arg(ap, unsigned int);
break;
case PrintfQualifierShort:
size = sizeof(unsigned short);
number = (__u64)va_arg(ap, unsigned int);
number = (uint64_t)va_arg(ap, unsigned int);
break;
case PrintfQualifierInt:
size = sizeof(unsigned int);
number = (__u64)va_arg(ap, unsigned int);
number = (uint64_t)va_arg(ap, unsigned int);
break;
case PrintfQualifierLong:
size = sizeof(unsigned long);
number = (__u64)va_arg(ap, unsigned long);
number = (uint64_t)va_arg(ap, unsigned long);
break;
case PrintfQualifierLongLong:
size = sizeof(unsigned long long);
number = (__u64)va_arg(ap, unsigned long long);
number = (uint64_t)va_arg(ap, unsigned long long);
break;
case PrintfQualifierPointer:
size = sizeof(void *);
number = (__u64)(unsigned long)va_arg(ap, void *);
number = (uint64_t)(unsigned long)va_arg(ap, void *);
break;
case PrintfQualifierNative:
size = sizeof(__native);
number = (__u64)va_arg(ap, __native);
size = sizeof(unative_t);
number = (uint64_t)va_arg(ap, unative_t);
break;
default: /* Unknown qualifier */
counter = -counter;
679,8 → 679,8
if (number & (0x1 << (size*8 - 1))) {
flags |= __PRINTF_FLAG_NEGATIVE;
if (size == sizeof(__u64)) {
number = -((__s64)number);
if (size == sizeof(uint64_t)) {
number = -((int64_t)number);
} else {
number = ~number;
number &= (~((0xFFFFFFFFFFFFFFFFll) << (size * 8)));
703,7 → 703,7
}
if (i > j) {
if ((retval = printf_putnchars(&fmt[j], (__native)(i - j), ps)) < 0) { /* error */
if ((retval = printf_putnchars(&fmt[j], (unative_t)(i - j), ps)) < 0) { /* error */
counter = -counter;
goto out;
/kernel/trunk/generic/src/console/console.c
76,9 → 76,9
*
* @return Character read.
*/
__u8 _getc(chardev_t *chardev)
uint8_t _getc(chardev_t *chardev)
{
__u8 ch;
uint8_t ch;
ipl_t ipl;
 
if (atomic_get(&haltstate)) {
150,9 → 150,9
}
 
/** Get character from device & echo it to screen */
__u8 getc(chardev_t *chardev)
uint8_t getc(chardev_t *chardev)
{
__u8 ch;
uint8_t ch;
 
ch = _getc(chardev);
putchar(ch);
/kernel/trunk/generic/src/console/cmd.c
479,13 → 479,13
/** Call function with zero parameters */
int cmd_call0(cmd_arg_t *argv)
{
__address symaddr;
uintptr_t symaddr;
char *symbol;
__native (*f)(void);
unative_t (*f)(void);
#ifdef ia64
struct {
__native f;
__native gp;
unative_t f;
unative_t gp;
}fptr;
#endif
 
492,18 → 492,18
symaddr = get_symbol_addr(argv->buffer);
if (!symaddr)
printf("Symbol %s not found.\n", argv->buffer);
else if (symaddr == (__address) -1) {
else if (symaddr == (uintptr_t) -1) {
symtab_print_search(argv->buffer);
printf("Duplicate symbol, be more specific.\n");
} else {
symbol = get_symtab_entry(symaddr);
printf("Calling f(): %.*p: %s\n", sizeof(__address) * 2, symaddr, symbol);
printf("Calling f(): %.*p: %s\n", sizeof(uintptr_t) * 2, symaddr, symbol);
#ifdef ia64
fptr.f = symaddr;
fptr.gp = ((__native *)cmd_call2)[1];
f = (__native (*)(void)) &fptr;
fptr.gp = ((unative_t *)cmd_call2)[1];
f = (unative_t (*)(void)) &fptr;
#else
f = (__native (*)(void)) symaddr;
f = (unative_t (*)(void)) symaddr;
#endif
printf("Result: %#zx\n", f());
}
514,14 → 514,14
/** Call function with one parameter */
int cmd_call1(cmd_arg_t *argv)
{
__address symaddr;
uintptr_t symaddr;
char *symbol;
__native (*f)(__native,...);
__native arg1 = argv[1].intval;
unative_t (*f)(unative_t,...);
unative_t arg1 = argv[1].intval;
#ifdef ia64
struct {
__native f;
__native gp;
unative_t f;
unative_t gp;
}fptr;
#endif
 
528,19 → 528,19
symaddr = get_symbol_addr(argv->buffer);
if (!symaddr)
printf("Symbol %s not found.\n", argv->buffer);
else if (symaddr == (__address) -1) {
else if (symaddr == (uintptr_t) -1) {
symtab_print_search(argv->buffer);
printf("Duplicate symbol, be more specific.\n");
} else {
symbol = get_symtab_entry(symaddr);
 
printf("Calling f(%#zx): %.*p: %s\n", arg1, sizeof(__address) * 2, symaddr, symbol);
printf("Calling f(%#zx): %.*p: %s\n", arg1, sizeof(uintptr_t) * 2, symaddr, symbol);
#ifdef ia64
fptr.f = symaddr;
fptr.gp = ((__native *)cmd_call2)[1];
f = (__native (*)(__native,...)) &fptr;
fptr.gp = ((unative_t *)cmd_call2)[1];
f = (unative_t (*)(unative_t,...)) &fptr;
#else
f = (__native (*)(__native,...)) symaddr;
f = (unative_t (*)(unative_t,...)) symaddr;
#endif
printf("Result: %#zx\n", f(arg1));
}
551,15 → 551,15
/** Call function with two parameters */
int cmd_call2(cmd_arg_t *argv)
{
__address symaddr;
uintptr_t symaddr;
char *symbol;
__native (*f)(__native,__native,...);
__native arg1 = argv[1].intval;
__native arg2 = argv[2].intval;
unative_t (*f)(unative_t,unative_t,...);
unative_t arg1 = argv[1].intval;
unative_t arg2 = argv[2].intval;
#ifdef ia64
struct {
__native f;
__native gp;
unative_t f;
unative_t gp;
}fptr;
#endif
 
566,19 → 566,19
symaddr = get_symbol_addr(argv->buffer);
if (!symaddr)
printf("Symbol %s not found.\n", argv->buffer);
else if (symaddr == (__address) -1) {
else if (symaddr == (uintptr_t) -1) {
symtab_print_search(argv->buffer);
printf("Duplicate symbol, be more specific.\n");
} else {
symbol = get_symtab_entry(symaddr);
printf("Calling f(0x%zx,0x%zx): %.*p: %s\n",
arg1, arg2, sizeof(__address) * 2, symaddr, symbol);
arg1, arg2, sizeof(uintptr_t) * 2, symaddr, symbol);
#ifdef ia64
fptr.f = symaddr;
fptr.gp = ((__native *)cmd_call2)[1];
f = (__native (*)(__native,__native,...)) &fptr;
fptr.gp = ((unative_t *)cmd_call2)[1];
f = (unative_t (*)(unative_t,unative_t,...)) &fptr;
#else
f = (__native (*)(__native,__native,...)) symaddr;
f = (unative_t (*)(unative_t,unative_t,...)) symaddr;
#endif
printf("Result: %#zx\n", f(arg1, arg2));
}
589,16 → 589,16
/** Call function with three parameters */
int cmd_call3(cmd_arg_t *argv)
{
__address symaddr;
uintptr_t symaddr;
char *symbol;
__native (*f)(__native,__native,__native,...);
__native arg1 = argv[1].intval;
__native arg2 = argv[2].intval;
__native arg3 = argv[3].intval;
unative_t (*f)(unative_t,unative_t,unative_t,...);
unative_t arg1 = argv[1].intval;
unative_t arg2 = argv[2].intval;
unative_t arg3 = argv[3].intval;
#ifdef ia64
struct {
__native f;
__native gp;
unative_t f;
unative_t gp;
}fptr;
#endif
 
605,19 → 605,19
symaddr = get_symbol_addr(argv->buffer);
if (!symaddr)
printf("Symbol %s not found.\n", argv->buffer);
else if (symaddr == (__address) -1) {
else if (symaddr == (uintptr_t) -1) {
symtab_print_search(argv->buffer);
printf("Duplicate symbol, be more specific.\n");
} else {
symbol = get_symtab_entry(symaddr);
printf("Calling f(0x%zx,0x%zx, 0x%zx): %.*p: %s\n",
arg1, arg2, arg3, sizeof(__address) * 2, symaddr, symbol);
arg1, arg2, arg3, sizeof(uintptr_t) * 2, symaddr, symbol);
#ifdef ia64
fptr.f = symaddr;
fptr.gp = ((__native *)cmd_call2)[1];
f = (__native (*)(__native,__native,__native,...)) &fptr;
fptr.gp = ((unative_t *)cmd_call2)[1];
f = (unative_t (*)(unative_t,unative_t,unative_t,...)) &fptr;
#else
f = (__native (*)(__native,__native,__native,...)) symaddr;
f = (unative_t (*)(unative_t,unative_t,unative_t,...)) symaddr;
#endif
printf("Result: %#zx\n", f(arg1, arg2, arg3));
}
659,28 → 659,28
/** Write 4 byte value to address */
int cmd_set4(cmd_arg_t *argv)
{
__u32 *addr ;
__u32 arg1 = argv[1].intval;
uint32_t *addr ;
uint32_t arg1 = argv[1].intval;
bool pointer = false;
 
if (((char *)argv->buffer)[0] == '*') {
addr = (__u32 *) get_symbol_addr(argv->buffer+1);
addr = (uint32_t *) get_symbol_addr(argv->buffer+1);
pointer = true;
} else if (((char *)argv->buffer)[0] >= '0' &&
((char *)argv->buffer)[0] <= '9')
addr = (__u32 *)atoi((char *)argv->buffer);
addr = (uint32_t *)atoi((char *)argv->buffer);
else
addr = (__u32 *)get_symbol_addr(argv->buffer);
addr = (uint32_t *)get_symbol_addr(argv->buffer);
 
if (!addr)
printf("Symbol %s not found.\n", argv->buffer);
else if (addr == (__u32 *) -1) {
else if (addr == (uint32_t *) -1) {
symtab_print_search(argv->buffer);
printf("Duplicate symbol, be more specific.\n");
} else {
if (pointer)
addr = (__u32 *)(*(__native *)addr);
printf("Writing 0x%x -> %.*p\n", arg1, sizeof(__address) * 2, addr);
addr = (uint32_t *)(*(unative_t *)addr);
printf("Writing 0x%x -> %.*p\n", arg1, sizeof(uintptr_t) * 2, addr);
*addr = arg1;
}
/kernel/trunk/generic/src/console/chardev.c
59,7 → 59,7
* @param chardev Character device.
* @param ch Character being pushed.
*/
void chardev_push_character(chardev_t *chardev, __u8 ch)
void chardev_push_character(chardev_t *chardev, uint8_t ch)
{
spinlock_lock(&chardev->lock);
chardev->counter++;
/kernel/trunk/generic/src/console/klog.c
63,7 → 63,7
panic("Cannot allocate page for klog");
klog = (char *)PA2KA(faddr);
sysinfo_set_item_val("klog.faddr", NULL, (__native)faddr);
sysinfo_set_item_val("klog.faddr", NULL, (unative_t)faddr);
sysinfo_set_item_val("klog.pages", NULL, 1 << KLOG_ORDER);
 
klogsize = PAGE_SIZE << KLOG_ORDER;
/kernel/trunk/generic/src/console/kconsole.c
431,10 → 431,10
}
}
 
static int parse_int_arg(char *text, size_t len, __native *result)
static int parse_int_arg(char *text, size_t len, unative_t *result)
{
char symname[MAX_SYMBOL_NAME];
__address symaddr;
uintptr_t symaddr;
bool isaddr = false;
bool isptr = false;
453,21 → 453,21
printf("Symbol %s not found.\n",symname);
return -1;
}
if (symaddr == (__address) -1) {
if (symaddr == (uintptr_t) -1) {
printf("Duplicate symbol %s.\n",symname);
symtab_print_search(symname);
return -1;
}
if (isaddr)
*result = (__native)symaddr;
*result = (unative_t)symaddr;
else if (isptr)
*result = **((__native **)symaddr);
*result = **((unative_t **)symaddr);
else
*result = *((__native *)symaddr);
*result = *((unative_t *)symaddr);
} else { /* It's a number - convert it */
*result = atoi(text);
if (isptr)
*result = *((__native *)*result);
*result = *((unative_t *)*result);
}
 
return 0;
554,7 → 554,7
strncpy(buf, (const char *) &cmdline[start+1],
min((end-start), cmd->argv[i].len));
buf[min((end - start), cmd->argv[i].len - 1)] = '\0';
cmd->argv[i].intval = (__native) buf;
cmd->argv[i].intval = (unative_t) buf;
cmd->argv[i].vartype = ARG_TYPE_STRING;
} else if (!parse_int_arg(cmdline+start, end-start+1,
&cmd->argv[i].intval))
/kernel/trunk/generic/src/proc/scheduler.c
349,7 → 349,7
* scheduler_separated_stack().
*/
context_save(&CPU->saved_context);
context_set(&CPU->saved_context, FADDR(scheduler_separated_stack), (__address) CPU->stack, CPU_STACK_SIZE);
context_set(&CPU->saved_context, FADDR(scheduler_separated_stack), (uintptr_t) CPU->stack, CPU_STACK_SIZE);
context_restore(&CPU->saved_context);
/* not reached */
}
/kernel/trunk/generic/src/proc/task.c
240,13 → 240,13
*
* @return 0 on success or an error code from @ref errno.h.
*/
__native sys_task_get_id(task_id_t *uspace_task_id)
unative_t sys_task_get_id(task_id_t *uspace_task_id)
{
/*
* No need to acquire lock on TASK because taskid
* remains constant for the lifespan of the task.
*/
return (__native) copy_to_uspace(uspace_task_id, &TASK->taskid, sizeof(TASK->taskid));
return (unative_t) copy_to_uspace(uspace_task_id, &TASK->taskid, sizeof(TASK->taskid));
}
 
/** Find task structure corresponding to task ID.
/kernel/trunk/generic/src/proc/thread.c
90,7 → 90,7
btree_t threads_btree;
 
SPINLOCK_INITIALIZE(tidlock);
__u32 last_tid = 0;
uint32_t last_tid = 0;
 
static slab_cache_t *thread_slab;
#ifdef ARCH_HAS_FPU
254,7 → 254,7
spinlock_unlock(&t->lock);
 
spinlock_lock(&threads_lock);
btree_remove(&threads_btree, (btree_key_t) ((__address ) t), NULL);
btree_remove(&threads_btree, (btree_key_t) ((uintptr_t ) t), NULL);
spinlock_unlock(&threads_lock);
 
/*
299,7 → 299,7
thread_create_arch(t);
/* Not needed, but good for debugging */
memsetb((__address)t->kstack, THREAD_STACK_SIZE * 1<<STACK_FRAMES, 0);
memsetb((uintptr_t)t->kstack, THREAD_STACK_SIZE * 1<<STACK_FRAMES, 0);
ipl = interrupts_disable();
spinlock_lock(&tidlock);
308,7 → 308,7
interrupts_restore(ipl);
context_save(&t->saved_context);
context_set(&t->saved_context, FADDR(cushion), (__address) t->kstack, THREAD_STACK_SIZE);
context_set(&t->saved_context, FADDR(cushion), (uintptr_t) t->kstack, THREAD_STACK_SIZE);
the_initialize((the_t *) t->kstack);
368,7 → 368,7
* Register this thread in the system-wide list.
*/
spinlock_lock(&threads_lock);
btree_insert(&threads_btree, (btree_key_t) ((__address) t), (void *) t, NULL);
btree_insert(&threads_btree, (btree_key_t) ((uintptr_t) t), (void *) t, NULL);
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
411,7 → 411,7
* @param sec Number of seconds to sleep.
*
*/
void thread_sleep(__u32 sec)
void thread_sleep(uint32_t sec)
{
thread_usleep(sec*1000000);
}
424,7 → 424,7
*
* @return An error code from errno.h or an error code from synch.h.
*/
int thread_join_timeout(thread_t *t, __u32 usec, int flags)
int thread_join_timeout(thread_t *t, uint32_t usec, int flags)
{
ipl_t ipl;
int rc;
484,7 → 484,7
* @param usec Number of microseconds to sleep.
*
*/
void thread_usleep(__u32 usec)
void thread_usleep(uint32_t usec)
{
waitq_t wq;
564,46 → 564,46
{
btree_node_t *leaf;
return btree_search(&threads_btree, (btree_key_t) ((__address) t), &leaf) != NULL;
return btree_search(&threads_btree, (btree_key_t) ((uintptr_t) t), &leaf) != NULL;
}
 
/** Process syscall to create new thread.
*
*/
__native sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name)
unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name)
{
thread_t *t;
char namebuf[THREAD_NAME_BUFLEN];
uspace_arg_t *kernel_uarg;
__u32 tid;
uint32_t tid;
int rc;
 
rc = copy_from_uspace(namebuf, uspace_name, THREAD_NAME_BUFLEN);
if (rc != 0)
return (__native) rc;
return (unative_t) rc;
 
kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);
rc = copy_from_uspace(kernel_uarg, uspace_uarg, sizeof(uspace_arg_t));
if (rc != 0) {
free(kernel_uarg);
return (__native) rc;
return (unative_t) rc;
}
 
if ((t = thread_create(uinit, kernel_uarg, TASK, 0, namebuf))) {
tid = t->tid;
thread_ready(t);
return (__native) tid;
return (unative_t) tid;
} else {
free(kernel_uarg);
}
 
return (__native) ENOMEM;
return (unative_t) ENOMEM;
}
 
/** Process syscall to terminate thread.
*
*/
__native sys_thread_exit(int uspace_status)
unative_t sys_thread_exit(int uspace_status)
{
thread_exit();
/* Unreachable */
/kernel/trunk/generic/src/lib/elf.c
96,7 → 96,7
 
/* Walk through all segment headers and process them. */
for (i = 0; i < header->e_phnum; i++) {
rc = segment_header(&((elf_segment_header_t *)(((__u8 *) header) + header->e_phoff))[i], header, as);
rc = segment_header(&((elf_segment_header_t *)(((uint8_t *) header) + header->e_phoff))[i], header, as);
if (rc != EE_OK)
return rc;
}
103,7 → 103,7
 
/* Inspect all section headers and proccess them. */
for (i = 0; i < header->e_shnum; i++) {
rc = section_header(&((elf_section_header_t *)(((__u8 *) header) + header->e_shoff))[i], header, as);
rc = section_header(&((elf_section_header_t *)(((uint8_t *) header) + header->e_shoff))[i], header, as);
if (rc != EE_OK)
return rc;
}
/kernel/trunk/generic/src/lib/memstr.c
61,17 → 61,17
{
int i, j;
if (ALIGN_UP((__address) src, sizeof(__native)) != (__address) src ||
ALIGN_UP((__address) dst, sizeof(__native)) != (__address) dst) {
if (ALIGN_UP((uintptr_t) src, sizeof(unative_t)) != (uintptr_t) src ||
ALIGN_UP((uintptr_t) dst, sizeof(unative_t)) != (uintptr_t) dst) {
for (i = 0; i < cnt; i++)
((__u8 *) dst)[i] = ((__u8 *) src)[i];
((uint8_t *) dst)[i] = ((uint8_t *) src)[i];
} else {
for (i = 0; i < cnt/sizeof(__native); i++)
((__native *) dst)[i] = ((__native *) src)[i];
for (i = 0; i < cnt/sizeof(unative_t); i++)
((unative_t *) dst)[i] = ((unative_t *) src)[i];
for (j = 0; j < cnt%sizeof(__native); j++)
((__u8 *)(((__native *) dst) + i))[j] = ((__u8 *)(((__native *) src) + i))[j];
for (j = 0; j < cnt%sizeof(unative_t); j++)
((uint8_t *)(((unative_t *) dst) + i))[j] = ((uint8_t *)(((unative_t *) src) + i))[j];
}
return (char *)src;
87,10 → 87,10
* @param x Value to fill.
*
*/
void _memsetb(__address dst, size_t cnt, __u8 x)
void _memsetb(uintptr_t dst, size_t cnt, uint8_t x)
{
int i;
__u8 *p = (__u8 *) dst;
uint8_t *p = (uint8_t *) dst;
for(i=0; i<cnt; i++)
p[i] = x;
106,10 → 106,10
* @param x Value to fill.
*
*/
void _memsetw(__address dst, size_t cnt, __u16 x)
void _memsetw(uintptr_t dst, size_t cnt, uint16_t x)
{
int i;
__u16 *p = (__u16 *) dst;
uint16_t *p = (uint16_t *) dst;
for(i=0; i<cnt; i++)
p[i] = x;
/kernel/trunk/generic/src/lib/sort.c
63,8 → 63,8
*/
void qsort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b))
{
__u8 buf_tmp[EBUFSIZE];
__u8 buf_pivot[EBUFSIZE];
uint8_t buf_tmp[EBUFSIZE];
uint8_t buf_pivot[EBUFSIZE];
void * tmp = buf_tmp;
void * pivot = buf_pivot;
 
132,7 → 132,7
*/
void bubblesort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b))
{
__u8 buf_slot[EBUFSIZE];
uint8_t buf_slot[EBUFSIZE];
void * slot = buf_slot;
if (e_size > EBUFSIZE) {
184,19 → 184,19
return (* (int *) a > * (int*)b) ? 1 : (*(int *)a < * (int *)b) ? -1 : 0;
}
 
int __u8_cmp(void * a, void * b)
int uint8_t_cmp(void * a, void * b)
{
return (* (__u8 *) a > * (__u8 *)b) ? 1 : (*(__u8 *)a < * (__u8 *)b) ? -1 : 0;
return (* (uint8_t *) a > * (uint8_t *)b) ? 1 : (*(uint8_t *)a < * (uint8_t *)b) ? -1 : 0;
}
 
int __u16_cmp(void * a, void * b)
int uint16_t_cmp(void * a, void * b)
{
return (* (__u16 *) a > * (__u16 *)b) ? 1 : (*(__u16 *)a < * (__u16 *)b) ? -1 : 0;
return (* (uint16_t *) a > * (uint16_t *)b) ? 1 : (*(uint16_t *)a < * (uint16_t *)b) ? -1 : 0;
}
 
int __u32_cmp(void * a, void * b)
int uint32_t_cmp(void * a, void * b)
{
return (* (__u32 *) a > * (__u32 *)b) ? 1 : (*(__u32 *)a < * (__u32 *)b) ? -1 : 0;
return (* (uint32_t *) a > * (uint32_t *)b) ? 1 : (*(uint32_t *)a < * (uint32_t *)b) ? -1 : 0;
}
 
/** @}
/kernel/trunk/generic/src/lib/func.c
148,7 → 148,7
dest[i-1] = '\0';
}
 
/** Convert ascii representation to __native
/** Convert ascii representation to unative_t
*
* Supports 0x for hexa & 0 for octal notation.
* Does not check for overflows, does not support negative numbers
156,10 → 156,10
* @param text Textual representation of number
* @return Converted number or 0 if no valid number ofund
*/
__native atoi(const char *text)
unative_t atoi(const char *text)
{
int base = 10;
__native result = 0;
unative_t result = 0;
 
if (text[0] == '0' && text[1] == 'x') {
base = 16;
/kernel/trunk/generic/src/security/cap.c
94,7 → 94,7
*
* @return Zero on success or an error code from @ref errno.h.
*/
__native sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps)
unative_t sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps)
{
sysarg64_t taskid_arg;
task_t *t;
102,11 → 102,11
int rc;
if (!(cap_get(TASK) & CAP_CAP))
return (__native) EPERM;
return (unative_t) EPERM;
rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t));
if (rc != 0)
return (__native) rc;
return (unative_t) rc;
ipl = interrupts_disable();
spinlock_lock(&tasks_lock);
114,7 → 114,7
if (!t) {
spinlock_unlock(&tasks_lock);
interrupts_restore(ipl);
return (__native) ENOENT;
return (unative_t) ENOENT;
}
spinlock_lock(&t->lock);
139,7 → 139,7
*
* @return Zero on success or an error code from @ref errno.h.
*/
__native sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps)
unative_t sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps)
{
sysarg64_t taskid_arg;
task_t *t;
148,7 → 148,7
rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t));
if (rc != 0)
return (__native) rc;
return (unative_t) rc;
 
ipl = interrupts_disable();
spinlock_lock(&tasks_lock);
156,7 → 156,7
if (!t) {
spinlock_unlock(&tasks_lock);
interrupts_restore(ipl);
return (__native) ENOENT;
return (unative_t) ENOENT;
}
 
/*
167,7 → 167,7
if (!(cap_get(TASK) & CAP_CAP) || !(t == TASK)) {
spinlock_unlock(&tasks_lock);
interrupts_restore(ipl);
return (__native) EPERM;
return (unative_t) EPERM;
}
spinlock_lock(&t->lock);
/kernel/trunk/generic/src/adt/hash_table.c
64,7 → 64,7
if (!h->entry) {
panic("cannot allocate memory for hash table\n");
}
memsetb((__address) h->entry, m * sizeof(link_t), 0);
memsetb((uintptr_t) h->entry, m * sizeof(link_t), 0);
for (i = 0; i < m; i++)
list_initialize(&h->entry[i]);
80,7 → 80,7
* @param key Array of all keys necessary to compute hash index.
* @param item Item to be inserted into the hash table.
*/
void hash_table_insert(hash_table_t *h, __native key[], link_t *item)
void hash_table_insert(hash_table_t *h, unative_t key[], link_t *item)
{
index_t chain;
 
100,7 → 100,7
*
* @return Matching item on success, NULL if there is no such item.
*/
link_t *hash_table_find(hash_table_t *h, __native key[])
link_t *hash_table_find(hash_table_t *h, unative_t key[])
{
link_t *cur;
index_t chain;
130,7 → 130,7
* @param key Array of keys that will be compared against items of the hash table.
* @param keys Number of keys in the key array.
*/
void hash_table_remove(hash_table_t *h, __native key[], count_t keys)
void hash_table_remove(hash_table_t *h, unative_t key[], count_t keys)
{
index_t chain;
link_t *cur;
/kernel/trunk/generic/src/adt/bitmap.c
55,7 → 55,7
* @param map Address of the memory used to hold the map.
* @param bits Number of bits stored in bitmap.
*/
void bitmap_initialize(bitmap_t *bitmap, __u8 *map, count_t bits)
void bitmap_initialize(bitmap_t *bitmap, uint8_t *map, count_t bits)
{
bitmap->map = map;
bitmap->bits = bits;
/kernel/trunk/generic/src/mm/slab.c
549,7 → 549,7
 
cache->mag_cache = malloc(sizeof(slab_mag_cache_t)*config.cpu_count,0);
for (i=0; i < config.cpu_count; i++) {
memsetb((__address)&cache->mag_cache[i],
memsetb((uintptr_t)&cache->mag_cache[i],
sizeof(cache->mag_cache[i]), 0);
spinlock_initialize(&cache->mag_cache[i].lock,
"slab_maglock_cpu");
569,11 → 569,11
int pages;
ipl_t ipl;
 
memsetb((__address)cache, sizeof(*cache), 0);
memsetb((uintptr_t)cache, sizeof(*cache), 0);
cache->name = name;
 
if (align < sizeof(__native))
align = sizeof(__native);
if (align < sizeof(unative_t))
align = sizeof(unative_t);
size = ALIGN_UP(size, align);
cache->size = size;
820,7 → 820,7
_slab_cache_create(&mag_cache,
"slab_magazine",
sizeof(slab_magazine_t)+SLAB_MAG_SIZE*sizeof(void*),
sizeof(__address),
sizeof(uintptr_t),
NULL, NULL,
SLAB_CACHE_NOMAGAZINE | SLAB_CACHE_SLINSIDE);
/* Initialize slab_cache cache */
827,7 → 827,7
_slab_cache_create(&slab_cache_cache,
"slab_cache",
sizeof(slab_cache_cache),
sizeof(__address),
sizeof(uintptr_t),
NULL, NULL,
SLAB_CACHE_NOMAGAZINE | SLAB_CACHE_SLINSIDE);
/* Initialize external slab cache */
/kernel/trunk/generic/src/mm/tlb.c
78,7 → 78,7
* @param page Virtual page address, if required by type.
* @param count Number of pages, if required by type.
*/
void tlb_shootdown_start(tlb_invalidate_type_t type, asid_t asid, __address page, count_t count)
void tlb_shootdown_start(tlb_invalidate_type_t type, asid_t asid, uintptr_t page, count_t count)
{
int i;
 
141,7 → 141,7
{
tlb_invalidate_type_t type;
asid_t asid;
__address page;
uintptr_t page;
count_t count;
int i;
/kernel/trunk/generic/src/mm/backend_anon.c
51,8 → 51,8
#include <align.h>
#include <arch.h>
 
static int anon_page_fault(as_area_t *area, __address addr, pf_access_t access);
static void anon_frame_free(as_area_t *area, __address page, __address frame);
static int anon_page_fault(as_area_t *area, uintptr_t addr, pf_access_t access);
static void anon_frame_free(as_area_t *area, uintptr_t page, uintptr_t frame);
static void anon_share(as_area_t *area);
 
mem_backend_t anon_backend = {
71,9 → 71,9
*
* @return AS_PF_FAULT on failure (i.e. page fault) or AS_PF_OK on success (i.e. serviced).
*/
int anon_page_fault(as_area_t *area, __address addr, pf_access_t access)
int anon_page_fault(as_area_t *area, uintptr_t addr, pf_access_t access)
{
__address frame;
uintptr_t frame;
 
if (!as_area_check_access(area, access))
return AS_PF_FAULT;
88,7 → 88,7
* mapping, a new frame is allocated and the mapping is created.
*/
mutex_lock(&area->sh_info->lock);
frame = (__address) btree_search(&area->sh_info->pagemap,
frame = (uintptr_t) btree_search(&area->sh_info->pagemap,
ALIGN_DOWN(addr, PAGE_SIZE) - area->base, &leaf);
if (!frame) {
bool allocate = true;
105,7 → 105,7
}
}
if (allocate) {
frame = (__address) frame_alloc(ONE_FRAME, 0);
frame = (uintptr_t) frame_alloc(ONE_FRAME, 0);
memsetb(PA2KA(frame), FRAME_SIZE, 0);
/*
132,7 → 132,7
* do not forget to distinguish between
* the different causes
*/
frame = (__address)frame_alloc(ONE_FRAME, 0);
frame = (uintptr_t)frame_alloc(ONE_FRAME, 0);
memsetb(PA2KA(frame), FRAME_SIZE, 0);
}
156,7 → 156,7
* @param page Ignored.
* @param frame Frame to be released.
*/
void anon_frame_free(as_area_t *area, __address page, __address frame)
void anon_frame_free(as_area_t *area, uintptr_t page, uintptr_t frame)
{
frame_free(frame);
}
184,7 → 184,7
node = list_get_instance(cur, btree_node_t, leaf_link);
for (i = 0; i < node->keys; i++) {
__address base = node->key[i];
uintptr_t base = node->key[i];
count_t count = (count_t) node->value[i];
int j;
/kernel/trunk/generic/src/mm/as.c
97,8 → 97,8
as_t *AS_KERNEL = NULL;
 
static int area_flags_to_page_flags(int aflags);
static as_area_t *find_area_and_lock(as_t *as, __address va);
static bool check_area_conflicts(as_t *as, __address va, size_t size, as_area_t *avoid_area);
static as_area_t *find_area_and_lock(as_t *as, uintptr_t va);
static bool check_area_conflicts(as_t *as, uintptr_t va, size_t size, as_area_t *avoid_area);
static void sh_info_remove_reference(share_info_t *sh_info);
 
/** Initialize address space subsystem. */
199,7 → 199,7
*
* @return Address space area on success or NULL on failure.
*/
as_area_t *as_area_create(as_t *as, int flags, size_t size, __address base, int attrs,
as_area_t *as_area_create(as_t *as, int flags, size_t size, uintptr_t base, int attrs,
mem_backend_t *backend, mem_backend_data_t *backend_data)
{
ipl_t ipl;
238,7 → 238,7
if (backend_data)
a->backend_data = *backend_data;
else
memsetb((__address) &a->backend_data, sizeof(a->backend_data), 0);
memsetb((uintptr_t) &a->backend_data, sizeof(a->backend_data), 0);
 
btree_create(&a->used_space);
259,7 → 259,7
*
* @return Zero on success or a value from @ref errno.h otherwise.
*/
int as_area_resize(as_t *as, __address address, size_t size, int flags)
int as_area_resize(as_t *as, uintptr_t address, size_t size, int flags)
{
as_area_t *area;
ipl_t ipl;
312,7 → 312,7
if (pages < area->pages) {
bool cond;
__address start_free = area->base + pages*PAGE_SIZE;
uintptr_t start_free = area->base + pages*PAGE_SIZE;
 
/*
* Shrinking the area.
337,7 → 337,7
ASSERT(!list_empty(&area->used_space.leaf_head));
node = list_get_instance(area->used_space.leaf_head.prev, btree_node_t, leaf_link);
if ((cond = (bool) node->keys)) {
__address b = node->key[node->keys - 1];
uintptr_t b = node->key[node->keys - 1];
count_t c = (count_t) node->value[node->keys - 1];
int i = 0;
418,10 → 418,10
*
* @return Zero on success or a value from @ref errno.h on failure.
*/
int as_area_destroy(as_t *as, __address address)
int as_area_destroy(as_t *as, uintptr_t address)
{
as_area_t *area;
__address base;
uintptr_t base;
link_t *cur;
ipl_t ipl;
 
451,7 → 451,7
node = list_get_instance(cur, btree_node_t, leaf_link);
for (i = 0; i < node->keys; i++) {
__address b = node->key[i];
uintptr_t b = node->key[i];
count_t j;
pte_t *pte;
518,8 → 518,8
* address space area. ENOTSUP is returned if an attempt
* to share non-anonymous address space area is detected.
*/
int as_area_share(as_t *src_as, __address src_base, size_t acc_size,
as_t *dst_as, __address dst_base, int dst_flags_mask)
int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size,
as_t *dst_as, uintptr_t dst_base, int dst_flags_mask)
{
ipl_t ipl;
int src_flags;
665,7 → 665,7
* @return AS_PF_FAULT on page fault, AS_PF_OK on success or AS_PF_DEFER if the
* fault was caused by copy_to_uspace() or copy_from_uspace().
*/
int as_page_fault(__address page, pf_access_t access, istate_t *istate)
int as_page_fault(uintptr_t page, pf_access_t access, istate_t *istate)
{
pte_t *pte;
as_area_t *area;
744,10 → 744,10
page_fault:
if (THREAD->in_copy_from_uspace) {
THREAD->in_copy_from_uspace = false;
istate_set_retaddr(istate, (__address) &memcpy_from_uspace_failover_address);
istate_set_retaddr(istate, (uintptr_t) &memcpy_from_uspace_failover_address);
} else if (THREAD->in_copy_to_uspace) {
THREAD->in_copy_to_uspace = false;
istate_set_retaddr(istate, (__address) &memcpy_to_uspace_failover_address);
istate_set_retaddr(istate, (uintptr_t) &memcpy_to_uspace_failover_address);
} else {
return AS_PF_FAULT;
}
942,7 → 942,7
*
* @return Locked address space area containing va on success or NULL on failure.
*/
as_area_t *find_area_and_lock(as_t *as, __address va)
as_area_t *find_area_and_lock(as_t *as, uintptr_t va)
{
as_area_t *a;
btree_node_t *leaf, *lnode;
998,7 → 998,7
*
* @return True if there is no conflict, false otherwise.
*/
bool check_area_conflicts(as_t *as, __address va, size_t size, as_area_t *avoid_area)
bool check_area_conflicts(as_t *as, uintptr_t va, size_t size, as_area_t *avoid_area)
{
as_area_t *a;
btree_node_t *leaf, *node;
1071,7 → 1071,7
}
 
/** Return size of the address space area with given base. */
size_t as_get_size(__address base)
size_t as_get_size(uintptr_t base)
{
ipl_t ipl;
as_area_t *src_area;
1099,7 → 1099,7
*
* @return 0 on failure and 1 on success.
*/
int used_space_insert(as_area_t *a, __address page, count_t count)
int used_space_insert(as_area_t *a, uintptr_t page, count_t count)
{
btree_node_t *leaf, *node;
count_t pages;
1123,7 → 1123,7
 
node = btree_leaf_node_left_neighbour(&a->used_space, leaf);
if (node) {
__address left_pg = node->key[node->keys - 1], right_pg = leaf->key[0];
uintptr_t left_pg = node->key[node->keys - 1], right_pg = leaf->key[0];
count_t left_cnt = (count_t) node->value[node->keys - 1], right_cnt = (count_t) leaf->value[0];
/*
1166,7 → 1166,7
return 1;
}
} else if (page < leaf->key[0]) {
__address right_pg = leaf->key[0];
uintptr_t right_pg = leaf->key[0];
count_t right_cnt = (count_t) leaf->value[0];
/*
1197,7 → 1197,7
 
node = btree_leaf_node_right_neighbour(&a->used_space, leaf);
if (node) {
__address left_pg = leaf->key[leaf->keys - 1], right_pg = node->key[0];
uintptr_t left_pg = leaf->key[leaf->keys - 1], right_pg = node->key[0];
count_t left_cnt = (count_t) leaf->value[leaf->keys - 1], right_cnt = (count_t) node->value[0];
/*
1240,7 → 1240,7
return 1;
}
} else if (page >= leaf->key[leaf->keys - 1]) {
__address left_pg = leaf->key[leaf->keys - 1];
uintptr_t left_pg = leaf->key[leaf->keys - 1];
count_t left_cnt = (count_t) leaf->value[leaf->keys - 1];
/*
1272,7 → 1272,7
*/
for (i = 1; i < leaf->keys; i++) {
if (page < leaf->key[i]) {
__address left_pg = leaf->key[i - 1], right_pg = leaf->key[i];
uintptr_t left_pg = leaf->key[i - 1], right_pg = leaf->key[i];
count_t left_cnt = (count_t) leaf->value[i - 1], right_cnt = (count_t) leaf->value[i];
 
/*
1326,7 → 1326,7
*
* @return 0 on failure and 1 on success.
*/
int used_space_remove(as_area_t *a, __address page, count_t count)
int used_space_remove(as_area_t *a, uintptr_t page, count_t count)
{
btree_node_t *leaf, *node;
count_t pages;
1363,7 → 1363,7
 
node = btree_leaf_node_left_neighbour(&a->used_space, leaf);
if (node && page < leaf->key[0]) {
__address left_pg = node->key[node->keys - 1];
uintptr_t left_pg = node->key[node->keys - 1];
count_t left_cnt = (count_t) node->value[node->keys - 1];
 
if (overlaps(left_pg, left_cnt*PAGE_SIZE, page, count*PAGE_SIZE)) {
1396,7 → 1396,7
}
if (page > leaf->key[leaf->keys - 1]) {
__address left_pg = leaf->key[leaf->keys - 1];
uintptr_t left_pg = leaf->key[leaf->keys - 1];
count_t left_cnt = (count_t) leaf->value[leaf->keys - 1];
 
if (overlaps(left_pg, left_cnt*PAGE_SIZE, page, count*PAGE_SIZE)) {
1432,7 → 1432,7
*/
for (i = 1; i < leaf->keys - 1; i++) {
if (page < leaf->key[i]) {
__address left_pg = leaf->key[i - 1];
uintptr_t left_pg = leaf->key[i - 1];
count_t left_cnt = (count_t) leaf->value[i - 1];
 
/*
1496,7 → 1496,7
node = list_get_instance(cur, btree_node_t, leaf_link);
for (i = 0; i < node->keys; i++)
frame_free((__address) node->value[i]);
frame_free((uintptr_t) node->value[i]);
}
}
1513,24 → 1513,24
*/
 
/** Wrapper for as_area_create(). */
__native sys_as_area_create(__address address, size_t size, int flags)
unative_t sys_as_area_create(uintptr_t address, size_t size, int flags)
{
if (as_area_create(AS, flags | AS_AREA_CACHEABLE, size, address, AS_AREA_ATTR_NONE, &anon_backend, NULL))
return (__native) address;
return (unative_t) address;
else
return (__native) -1;
return (unative_t) -1;
}
 
/** Wrapper for as_area_resize. */
__native sys_as_area_resize(__address address, size_t size, int flags)
unative_t sys_as_area_resize(uintptr_t address, size_t size, int flags)
{
return (__native) as_area_resize(AS, address, size, 0);
return (unative_t) as_area_resize(AS, address, size, 0);
}
 
/** Wrapper for as_area_destroy. */
__native sys_as_area_destroy(__address address)
unative_t sys_as_area_destroy(uintptr_t address)
{
return (__native) as_area_destroy(AS, address);
return (unative_t) as_area_destroy(AS, address);
}
 
/** @}
/kernel/trunk/generic/src/mm/buddy.c
66,7 → 66,7
* @return New buddy system.
*/
void buddy_system_create(buddy_system_t *b,
__u8 max_order,
uint8_t max_order,
buddy_system_operations_t *op,
void *data)
{
101,8 → 101,8
*
* @return True if block can be allocated
*/
bool buddy_system_can_alloc(buddy_system_t *b, __u8 i) {
__u8 k;
bool buddy_system_can_alloc(buddy_system_t *b, uint8_t i) {
uint8_t k;
/*
* If requested block is greater then maximal block
130,7 → 130,7
link_t *buddy_system_alloc_block(buddy_system_t *b, link_t *block)
{
link_t *left,*right, *tmp;
__u8 order;
uint8_t order;
 
left = b->op->find_block(b, block, BUDDY_SYSTEM_INNER_BLOCK);
ASSERT(left);
167,7 → 167,7
*
* @return Block of data represented by link_t.
*/
link_t *buddy_system_alloc(buddy_system_t *b, __u8 i)
link_t *buddy_system_alloc(buddy_system_t *b, uint8_t i)
{
link_t *res, *hlp;
 
230,7 → 230,7
void buddy_system_free(buddy_system_t *b, link_t *block)
{
link_t *buddy, *hlp;
__u8 i;
uint8_t i;
 
/*
* Determine block's order.
/kernel/trunk/generic/src/mm/backend_phys.c
46,7 → 46,7
#include <arch.h>
#include <align.h>
 
static int phys_page_fault(as_area_t *area, __address addr, pf_access_t access);
static int phys_page_fault(as_area_t *area, uintptr_t addr, pf_access_t access);
static void phys_share(as_area_t *area);
 
mem_backend_t phys_backend = {
65,9 → 65,9
*
* @return AS_PF_FAULT on failure (i.e. page fault) or AS_PF_OK on success (i.e. serviced).
*/
int phys_page_fault(as_area_t *area, __address addr, pf_access_t access)
int phys_page_fault(as_area_t *area, uintptr_t addr, pf_access_t access)
{
__address base = area->backend_data.base;
uintptr_t base = area->backend_data.base;
 
if (!as_area_check_access(area, access))
return AS_PF_FAULT;
/kernel/trunk/generic/src/mm/frame.c
69,7 → 69,7
 
typedef struct {
count_t refcount; /**< tracking of shared frames */
__u8 buddy_order; /**< buddy system block order */
uint8_t buddy_order; /**< buddy system block order */
link_t buddy_link; /**< link to the next free block inside one order */
void *parent; /**< If allocated by slab, this points there */
} frame_t;
217,7 → 217,7
}
 
/** @return True if zone can allocate specified order */
static int zone_can_alloc(zone_t *z, __u8 order)
static int zone_can_alloc(zone_t *z, uint8_t order)
{
return buddy_system_can_alloc(z->buddy_system, order);
}
230,7 → 230,7
* @param order Size (2^order) of free space we are trying to find
* @param pzone Pointer to preferred zone or NULL, on return contains zone number
*/
static zone_t * find_free_zone_lock(__u8 order, int *pzone)
static zone_t * find_free_zone_lock(uint8_t order, int *pzone)
{
int i;
zone_t *z;
271,7 → 271,7
* @param order - Order of parent must be different then this parameter!!
*/
static link_t *zone_buddy_find_block(buddy_system_t *b, link_t *child,
__u8 order)
uint8_t order)
{
frame_t * frame;
zone_t * zone;
380,7 → 380,7
* @param block Buddy system block
* @param order Order to set
*/
static void zone_buddy_set_order(buddy_system_t *b, link_t * block, __u8 order) {
static void zone_buddy_set_order(buddy_system_t *b, link_t * block, uint8_t order) {
frame_t * frame;
frame = list_get_instance(block, frame_t, buddy_link);
frame->buddy_order = order;
393,7 → 393,7
*
* @return Order of block
*/
static __u8 zone_buddy_get_order(buddy_system_t *b, link_t * block) {
static uint8_t zone_buddy_get_order(buddy_system_t *b, link_t * block) {
frame_t * frame;
frame = list_get_instance(block, frame_t, buddy_link);
return frame->buddy_order;
450,7 → 450,7
* @return Frame index in zone
*
*/
static pfn_t zone_frame_alloc(zone_t *zone, __u8 order)
static pfn_t zone_frame_alloc(zone_t *zone, uint8_t order)
{
pfn_t v;
link_t *tmp;
483,7 → 483,7
static void zone_frame_free(zone_t *zone, index_t frame_idx)
{
frame_t *frame;
__u8 order;
uint8_t order;
 
frame = &zone->frames[frame_idx];
537,7 → 537,7
 
static void _zone_merge(zone_t *z, zone_t *z1, zone_t *z2)
{
__u8 max_order;
uint8_t max_order;
int i, z2idx;
pfn_t frame_idx;
frame_t *frame;
624,7 → 624,7
count_t cframes;
int i;
 
pfn = ADDR2PFN((__address)KA2PA(oldzone));
pfn = ADDR2PFN((uintptr_t)KA2PA(oldzone));
cframes = SIZE2FRAMES(zone_conf_size(oldzone->count));
if (pfn < newzone->base || pfn >= newzone->base + newzone->count)
653,7 → 653,7
static void zone_reduce_region(zone_t *zone, pfn_t frame_idx, count_t count)
{
count_t i;
__u8 order;
uint8_t order;
frame_t *frame;
ASSERT(frame_idx+count < zone->count);
689,7 → 689,7
ipl_t ipl;
zone_t *zone1, *zone2, *newzone;
int cframes;
__u8 order;
uint8_t order;
int i;
pfn_t pfn;
 
779,7 → 779,7
static void zone_construct(pfn_t start, count_t count, zone_t *z, int flags)
{
int i;
__u8 max_order;
uint8_t max_order;
 
spinlock_initialize(&z->lock, "zone_lock");
z->base = start;
817,7 → 817,7
* @param count Size of zone in frames
* @return Size of zone configuration info (in bytes)
*/
__address zone_conf_size(count_t count)
uintptr_t zone_conf_size(count_t count)
{
int size = sizeof(zone_t) + count*sizeof(frame_t);
int max_order;
845,7 → 845,7
int zone_create(pfn_t start, count_t count, pfn_t confframe, int flags)
{
zone_t *z;
__address addr;
uintptr_t addr;
count_t confcount;
int i;
int znum;
931,7 → 931,7
* @return Physical address of the allocated frame.
*
*/
void * frame_alloc_generic(__u8 order, int flags, int *pzone)
void * frame_alloc_generic(uint8_t order, int flags, int *pzone)
{
ipl_t ipl;
int freed;
990,7 → 990,7
*
* @param Frame Physical Address of of the frame to be freed.
*/
void frame_free(__address frame)
void frame_free(uintptr_t frame)
{
ipl_t ipl;
zone_t *zone;
1099,7 → 1099,7
for (i = 0; i < zones.count; i++) {
zone = zones.info[i];
spinlock_lock(&zone->lock);
printf("%d: %.*p \t%10zd\t%10zd\n", i, sizeof(__address) * 2, PFN2ADDR(zone->base), zone->free_count, zone->busy_count);
printf("%d: %.*p \t%10zd\t%10zd\n", i, sizeof(uintptr_t) * 2, PFN2ADDR(zone->base), zone->free_count, zone->busy_count);
spinlock_unlock(&zone->lock);
}
spinlock_unlock(&zones.lock);
1131,7 → 1131,7
spinlock_lock(&zone->lock);
printf("Memory zone information\n");
printf("Zone base address: %#.*p\n", sizeof(__address) * 2, PFN2ADDR(zone->base));
printf("Zone base address: %#.*p\n", sizeof(uintptr_t) * 2, PFN2ADDR(zone->base));
printf("Zone size: %zd frames (%zdK)\n", zone->count, ((zone->count) * FRAME_SIZE) >> 10);
printf("Allocated space: %zd frames (%zdK)\n", zone->busy_count, (zone->busy_count * FRAME_SIZE) >> 10);
printf("Available space: %zd (%zdK)\n", zone->free_count, (zone->free_count * FRAME_SIZE) >> 10);
/kernel/trunk/generic/src/mm/page.c
69,7 → 69,7
* @param s Address of the structure.
* @param size Size of the structure.
*/
void map_structure(__address s, size_t size)
void map_structure(uintptr_t s, size_t size)
{
int i, cnt, length;
 
93,7 → 93,7
* @param frame Physical address of memory frame to which the mapping is done.
* @param flags Flags to be used for mapping.
*/
void page_mapping_insert(as_t *as, __address page, __address frame, int flags)
void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags)
{
ASSERT(page_mapping_operations);
ASSERT(page_mapping_operations->mapping_insert);
112,7 → 112,7
* @param as Address space to wich page belongs.
* @param page Virtual address of the page to be demapped.
*/
void page_mapping_remove(as_t *as, __address page)
void page_mapping_remove(as_t *as, uintptr_t page)
{
ASSERT(page_mapping_operations);
ASSERT(page_mapping_operations->mapping_remove);
131,7 → 131,7
*
* @return NULL if there is no such mapping; requested mapping otherwise.
*/
pte_t *page_mapping_find(as_t *as, __address page)
pte_t *page_mapping_find(as_t *as, uintptr_t page)
{
ASSERT(page_mapping_operations);
ASSERT(page_mapping_operations->mapping_find);
/kernel/trunk/generic/src/mm/backend_elf.c
50,8 → 50,8
#include <macros.h>
#include <arch.h>
 
static int elf_page_fault(as_area_t *area, __address addr, pf_access_t access);
static void elf_frame_free(as_area_t *area, __address page, __address frame);
static int elf_page_fault(as_area_t *area, uintptr_t addr, pf_access_t access);
static void elf_frame_free(as_area_t *area, uintptr_t page, uintptr_t frame);
static void elf_share(as_area_t *area);
 
mem_backend_t elf_backend = {
70,12 → 70,12
*
* @return AS_PF_FAULT on failure (i.e. page fault) or AS_PF_OK on success (i.e. serviced).
*/
int elf_page_fault(as_area_t *area, __address addr, pf_access_t access)
int elf_page_fault(as_area_t *area, uintptr_t addr, pf_access_t access)
{
elf_header_t *elf = area->backend_data.elf;
elf_segment_header_t *entry = area->backend_data.segment;
btree_node_t *leaf;
__address base, frame;
uintptr_t base, frame;
index_t i;
 
if (!as_area_check_access(area, access))
83,7 → 83,7
 
ASSERT((addr >= entry->p_vaddr) && (addr < entry->p_vaddr + entry->p_memsz));
i = (addr - entry->p_vaddr) >> PAGE_WIDTH;
base = (__address) (((void *) elf) + entry->p_offset);
base = (uintptr_t) (((void *) elf) + entry->p_offset);
ASSERT(ALIGN_UP(base, FRAME_SIZE) == base);
 
if (area->sh_info) {
94,7 → 94,7
*/
mutex_lock(&area->sh_info->lock);
frame = (__address) btree_search(&area->sh_info->pagemap,
frame = (uintptr_t) btree_search(&area->sh_info->pagemap,
ALIGN_DOWN(addr, PAGE_SIZE) - area->base, &leaf);
if (!frame) {
int i;
134,7 → 134,7
* as COW.
*/
if (entry->p_flags & PF_W) {
frame = (__address)frame_alloc(ONE_FRAME, 0);
frame = (uintptr_t)frame_alloc(ONE_FRAME, 0);
memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), FRAME_SIZE);
if (area->sh_info) {
153,7 → 153,7
* To resolve the situation, a frame must be allocated
* and cleared.
*/
frame = (__address)frame_alloc(ONE_FRAME, 0);
frame = (uintptr_t)frame_alloc(ONE_FRAME, 0);
memsetb(PA2KA(frame), FRAME_SIZE, 0);
 
if (area->sh_info) {
170,7 → 170,7
* the upper part is anonymous memory.
*/
size = entry->p_filesz - (i<<PAGE_WIDTH);
frame = (__address)frame_alloc(ONE_FRAME, 0);
frame = (uintptr_t)frame_alloc(ONE_FRAME, 0);
memsetb(PA2KA(frame) + size, FRAME_SIZE - size, 0);
memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), size);
 
201,16 → 201,16
* @param frame Frame to be released.
*
*/
void elf_frame_free(as_area_t *area, __address page, __address frame)
void elf_frame_free(as_area_t *area, uintptr_t page, uintptr_t frame)
{
elf_header_t *elf = area->backend_data.elf;
elf_segment_header_t *entry = area->backend_data.segment;
__address base;
uintptr_t base;
index_t i;
ASSERT((page >= entry->p_vaddr) && (page < entry->p_vaddr + entry->p_memsz));
i = (page - entry->p_vaddr) >> PAGE_WIDTH;
base = (__address) (((void *) elf) + entry->p_offset);
base = (uintptr_t) (((void *) elf) + entry->p_offset);
ASSERT(ALIGN_UP(base, FRAME_SIZE) == base);
if (page + PAGE_SIZE < ALIGN_UP(entry->p_vaddr + entry->p_filesz, PAGE_SIZE)) {
245,7 → 245,7
elf_segment_header_t *entry = area->backend_data.segment;
link_t *cur;
btree_node_t *leaf, *node;
__address start_anon = entry->p_vaddr + entry->p_filesz;
uintptr_t start_anon = entry->p_vaddr + entry->p_filesz;
 
/*
* Find the node in which to start linear search.
269,7 → 269,7
node = list_get_instance(cur, btree_node_t, leaf_link);
for (i = 0; i < node->keys; i++) {
__address base = node->key[i];
uintptr_t base = node->key[i];
count_t count = (count_t) node->value[i];
int j;
/kernel/trunk/generic/src/syscall/copy.c
67,7 → 67,7
ASSERT(!THREAD->in_copy_from_uspace);
if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
if (overlaps((__address) uspace_src, size,
if (overlaps((uintptr_t) uspace_src, size,
KERNEL_ADDRESS_SPACE_START, KERNEL_ADDRESS_SPACE_END-KERNEL_ADDRESS_SPACE_START)) {
/*
* The userspace source block conflicts with kernel address space.
108,7 → 108,7
ASSERT(!THREAD->in_copy_from_uspace);
if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
if (overlaps((__address) uspace_dst, size,
if (overlaps((uintptr_t) uspace_dst, size,
KERNEL_ADDRESS_SPACE_START, KERNEL_ADDRESS_SPACE_END-KERNEL_ADDRESS_SPACE_START)) {
/*
* The userspace destination block conflicts with kernel address space.
/kernel/trunk/generic/src/syscall/syscall.c
58,7 → 58,7
* Some simulators can print only through kernel. Userspace can use
* this syscall to facilitate it.
*/
static __native sys_io(int fd, const void * buf, size_t count)
static unative_t sys_io(int fd, const void * buf, size_t count)
{
size_t i;
char *data;
85,7 → 85,7
}
 
/** Tell kernel to get keyboard/console access again */
static __native sys_debug_enable_console(void)
static unative_t sys_debug_enable_console(void)
{
arch_grab_console();
return 0;
92,10 → 92,10
}
 
/** Dispatch system call */
__native syscall_handler(__native a1, __native a2, __native a3,
__native a4, __native id)
unative_t syscall_handler(unative_t a1, unative_t a2, unative_t a3,
unative_t a4, unative_t id)
{
__native rc;
unative_t rc;
 
if (id < SYSCALL_END)
rc = syscall_table[id](a1,a2,a3,a4);
/kernel/trunk/generic/src/ipc/ipcrsc.c
138,7 → 138,7
* TODO: Some speedup (hash table?)
* @return NULL on not found, otherwise pointer to call structure
*/
call_t * get_call(__native callid)
call_t * get_call(unative_t callid)
{
link_t *lst;
call_t *call, *result = NULL;
147,7 → 147,7
for (lst = TASK->answerbox.dispatched_calls.next;
lst != &TASK->answerbox.dispatched_calls; lst = lst->next) {
call = list_get_instance(lst, call_t, link);
if ((__native)call == callid) {
if ((unative_t)call == callid) {
result = call;
break;
}
/kernel/trunk/generic/src/ipc/sysipc.c
56,7 → 56,7
#define STRUCT_TO_USPACE(dst,src) copy_to_uspace(dst,src,sizeof(*(src)))
 
/** Return true if the method is a system method */
static inline int is_system_method(__native method)
static inline int is_system_method(unative_t method)
{
if (method <= IPC_M_LAST_SYSTEM)
return 1;
68,7 → 68,7
* - some system messages may be forwarded, for some of them
* it is useless
*/
static inline int is_forwardable(__native method)
static inline int is_forwardable(unative_t method)
{
if (method == IPC_M_PHONE_HUNGUP || method == IPC_M_AS_AREA_SEND \
|| method == IPC_M_AS_AREA_RECV)
131,7 → 131,7
/* The connection was accepted */
phone_connect(phoneid,&answer->sender->answerbox);
/* Set 'phone identification' as arg3 of response */
IPC_SET_ARG3(answer->data, (__native)&TASK->phones[phoneid]);
IPC_SET_ARG3(answer->data, (unative_t)&TASK->phones[phoneid]);
}
} else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_ME_TO) {
/* If the users accepted call, connect */
191,7 → 191,7
if (newphid < 0)
return ELIMIT;
/* Set arg3 for server */
IPC_SET_ARG3(call->data, (__native)&TASK->phones[newphid]);
IPC_SET_ARG3(call->data, (unative_t)&TASK->phones[newphid]);
call->flags |= IPC_CALL_CONN_ME_TO;
call->private = newphid;
break;
253,8 → 253,8
* @return Call identification, returns -1 on fatal error,
-2 on 'Too many async request, handle answers first
*/
__native sys_ipc_call_sync_fast(__native phoneid, __native method,
__native arg1, ipc_data_t *data)
unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method,
unative_t arg1, ipc_data_t *data)
{
call_t call;
phone_t *phone;
277,7 → 277,7
}
 
/** Synchronous IPC call allowing to send whole message */
__native sys_ipc_call_sync(__native phoneid, ipc_data_t *question,
unative_t sys_ipc_call_sync(unative_t phoneid, ipc_data_t *question,
ipc_data_t *reply)
{
call_t call;
288,7 → 288,7
ipc_call_static_init(&call);
rc = copy_from_uspace(&call.data.args, &question->args, sizeof(call.data.args));
if (rc != 0)
return (__native) rc;
return (unative_t) rc;
 
GET_CHECK_PHONE(phone, phoneid, return ENOENT);
 
323,8 → 323,8
* @return Call identification, returns -1 on fatal error,
-2 on 'Too many async request, handle answers first
*/
__native sys_ipc_call_async_fast(__native phoneid, __native method,
__native arg1, __native arg2)
unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method,
unative_t arg1, unative_t arg2)
{
call_t *call;
phone_t *phone;
346,7 → 346,7
else
ipc_backsend_err(phone, call, res);
 
return (__native) call;
return (unative_t) call;
}
 
/** Synchronous IPC call allowing to send whole message
353,7 → 353,7
*
* @return The same as sys_ipc_call_async
*/
__native sys_ipc_call_async(__native phoneid, ipc_data_t *data)
unative_t sys_ipc_call_async(unative_t phoneid, ipc_data_t *data)
{
call_t *call;
phone_t *phone;
369,7 → 369,7
rc = copy_from_uspace(&call->data.args, &data->args, sizeof(call->data.args));
if (rc != 0) {
ipc_call_free(call);
return (__native) rc;
return (unative_t) rc;
}
if (!(res=request_preprocess(call)))
ipc_call(phone, call);
376,7 → 376,7
else
ipc_backsend_err(phone, call, res);
 
return (__native) call;
return (unative_t) call;
}
 
/** Forward received call to another destination
386,8 → 386,8
* Warning: If implementing non-fast version, make sure that
* arg3 is not rewritten for certain system IPC
*/
__native sys_ipc_forward_fast(__native callid, __native phoneid,
__native method, __native arg1)
unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid,
unative_t method, unative_t arg1)
{
call_t *call;
phone_t *phone;
428,8 → 428,8
}
 
/** Send IPC answer */
__native sys_ipc_answer_fast(__native callid, __native retval,
__native arg1, __native arg2)
unative_t sys_ipc_answer_fast(unative_t callid, unative_t retval,
unative_t arg1, unative_t arg2)
{
call_t *call;
ipc_data_t saved_data;
459,7 → 459,7
}
 
/** Send IPC answer */
__native sys_ipc_answer(__native callid, ipc_data_t *data)
unative_t sys_ipc_answer(unative_t callid, ipc_data_t *data)
{
call_t *call;
ipc_data_t saved_data;
493,7 → 493,7
/** Hang up the phone
*
*/
__native sys_ipc_hangup(int phoneid)
unative_t sys_ipc_hangup(int phoneid)
{
phone_t *phone;
 
513,7 → 513,7
*
* @return Callid, if callid & 1, then the call is answer
*/
__native sys_ipc_wait_for_call(ipc_data_t *calldata, __u32 usec, int flags)
unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec, int flags)
{
call_t *call;
 
532,7 → 532,7
 
ipc_call_free(call);
return ((__native)call) | IPC_CALLID_NOTIFICATION;
return ((unative_t)call) | IPC_CALLID_NOTIFICATION;
}
 
if (call->flags & IPC_CALL_ANSWERED) {
550,7 → 550,7
STRUCT_TO_USPACE(&calldata->args, &call->data.args);
ipc_call_free(call);
 
return ((__native)call) | IPC_CALLID_ANSWERED;
return ((unative_t)call) | IPC_CALLID_ANSWERED;
}
 
if (process_request(&TASK->answerbox, call))
561,17 → 561,17
if (STRUCT_TO_USPACE(calldata, &call->data)) {
return 0;
}
return (__native)call;
return (unative_t)call;
}
 
/** Connect irq handler to task */
__native sys_ipc_register_irq(int irq, irq_code_t *ucode)
unative_t sys_ipc_register_irq(int irq, irq_code_t *ucode)
{
if (!(cap_get(TASK) & CAP_IRQ_REG))
return EPERM;
 
if (irq >= IRQ_COUNT || irq <= -IPC_IRQ_RESERVED_VIRTUAL)
return (__native) ELIMIT;
return (unative_t) ELIMIT;
irq_ipc_bind_arch(irq);
 
579,13 → 579,13
}
 
/* Disconnect irq handler from task */
__native sys_ipc_unregister_irq(int irq)
unative_t sys_ipc_unregister_irq(int irq)
{
if (!(cap_get(TASK) & CAP_IRQ_REG))
return EPERM;
 
if (irq >= IRQ_COUNT || irq <= -IPC_IRQ_RESERVED_VIRTUAL)
return (__native) ELIMIT;
return (unative_t) ELIMIT;
 
ipc_irq_unregister(&TASK->answerbox, irq);
 
/kernel/trunk/generic/src/ipc/ipc.c
61,7 → 61,7
/* Initialize new call */
static void _ipc_call_init(call_t *call)
{
memsetb((__address)call, sizeof(*call), 0);
memsetb((uintptr_t)call, sizeof(*call), 0);
call->callerbox = &TASK->answerbox;
call->sender = TASK;
}
185,7 → 185,7
* Most errors are better handled by forming a normal backward
* message and sending it as a normal answer.
*/
void ipc_backsend_err(phone_t *phone, call_t *call, __native err)
void ipc_backsend_err(phone_t *phone, call_t *call, unative_t err)
{
call->data.phone = phone;
atomic_inc(&phone->active_calls);
308,7 → 308,7
* @return Recived message address
* - to distinguish between call and answer, look at call->flags
*/
call_t * ipc_wait_for_call(answerbox_t *box, __u32 usec, int flags)
call_t * ipc_wait_for_call(answerbox_t *box, uint32_t usec, int flags)
{
call_t *request;
ipl_t ipl;
/kernel/trunk/generic/src/ipc/irq.c
72,7 → 72,7
static void code_execute(call_t *call, irq_code_t *code)
{
int i;
__native dstval = 0;
unative_t dstval = 0;
if (!code)
return;
80,28 → 80,28
for (i=0; i < code->cmdcount;i++) {
switch (code->cmds[i].cmd) {
case CMD_MEM_READ_1:
dstval = *((__u8 *)code->cmds[i].addr);
dstval = *((uint8_t *)code->cmds[i].addr);
break;
case CMD_MEM_READ_2:
dstval = *((__u16 *)code->cmds[i].addr);
dstval = *((uint16_t *)code->cmds[i].addr);
break;
case CMD_MEM_READ_4:
dstval = *((__u32 *)code->cmds[i].addr);
dstval = *((uint32_t *)code->cmds[i].addr);
break;
case CMD_MEM_READ_8:
dstval = *((__u64 *)code->cmds[i].addr);
dstval = *((uint64_t *)code->cmds[i].addr);
break;
case CMD_MEM_WRITE_1:
*((__u8 *)code->cmds[i].addr) = code->cmds[i].value;
*((uint8_t *)code->cmds[i].addr) = code->cmds[i].value;
break;
case CMD_MEM_WRITE_2:
*((__u16 *)code->cmds[i].addr) = code->cmds[i].value;
*((uint16_t *)code->cmds[i].addr) = code->cmds[i].value;
break;
case CMD_MEM_WRITE_4:
*((__u32 *)code->cmds[i].addr) = code->cmds[i].value;
*((uint32_t *)code->cmds[i].addr) = code->cmds[i].value;
break;
case CMD_MEM_WRITE_8:
*((__u64 *)code->cmds[i].addr) = code->cmds[i].value;
*((uint64_t *)code->cmds[i].addr) = code->cmds[i].value;
break;
#if defined(ia32) || defined(amd64)
case CMD_PORT_READ_1:
234,7 → 234,7
/** Send notification message
*
*/
void ipc_irq_send_msg(int irq, __native a1, __native a2, __native a3)
void ipc_irq_send_msg(int irq, unative_t a1, unative_t a2, unative_t a3)
{
call_t *call;
int mq = irq + IPC_IRQ_RESERVED_VIRTUAL;