Changeset 98000fb in mainline for kernel/generic/src
- Timestamp:
- 2009-06-03T19:34:45Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 301ff30
- Parents:
- 69e68e3
- Location:
- kernel/generic/src
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/adt/bitmap.c
r69e68e3 r98000fb 55 55 * @param bits Number of bits stored in bitmap. 56 56 */ 57 void bitmap_initialize(bitmap_t *bitmap, uint8_t *map, count_t bits)57 void bitmap_initialize(bitmap_t *bitmap, uint8_t *map, size_t bits) 58 58 { 59 59 bitmap->map = map; … … 67 67 * @param bits Number of bits to set. 68 68 */ 69 void bitmap_set_range(bitmap_t *bitmap, index_t start, count_t bits)69 void bitmap_set_range(bitmap_t *bitmap, size_t start, size_t bits) 70 70 { 71 index_t i=0;72 index_t aligned_start;73 count_t lub; /* leading unaligned bits */74 count_t amb; /* aligned middle bits */75 count_t tab; /* trailing aligned bits */71 size_t i = 0; 72 size_t aligned_start; 73 size_t lub; /* leading unaligned bits */ 74 size_t amb; /* aligned middle bits */ 75 size_t tab; /* trailing aligned bits */ 76 76 77 77 ASSERT(start + bits <= bitmap->bits); … … 117 117 * @param bits Number of bits to clear. 118 118 */ 119 void bitmap_clear_range(bitmap_t *bitmap, index_t start, count_t bits)119 void bitmap_clear_range(bitmap_t *bitmap, size_t start, size_t bits) 120 120 { 121 index_t i=0;122 index_t aligned_start;123 count_t lub; /* leading unaligned bits */124 count_t amb; /* aligned middle bits */125 count_t tab; /* trailing aligned bits */121 size_t i = 0; 122 size_t aligned_start; 123 size_t lub; /* leading unaligned bits */ 124 size_t amb; /* aligned middle bits */ 125 size_t tab; /* trailing aligned bits */ 126 126 127 127 ASSERT(start + bits <= bitmap->bits); … … 169 169 * @param bits Number of bits to copy. 170 170 */ 171 void bitmap_copy(bitmap_t *dst, bitmap_t *src, count_t bits)171 void bitmap_copy(bitmap_t *dst, bitmap_t *src, size_t bits) 172 172 { 173 index_t i;173 size_t i; 174 174 175 175 ASSERT(bits <= dst->bits); -
kernel/generic/src/adt/btree.c
r69e68e3 r98000fb 64 64 static btree_node_t *node_split(btree_node_t *node, btree_key_t key, void *value, btree_node_t *rsubtree, btree_key_t *median); 65 65 static btree_node_t *node_combine(btree_node_t *node); 66 static index_t find_key_by_subtree(btree_node_t *node, btree_node_t *subtree, bool right);67 static void rotate_from_right(btree_node_t *lnode, btree_node_t *rnode, index_t idx);68 static void rotate_from_left(btree_node_t *lnode, btree_node_t *rnode, index_t idx);66 static size_t find_key_by_subtree(btree_node_t *node, btree_node_t *subtree, bool right); 67 static void rotate_from_right(btree_node_t *lnode, btree_node_t *rnode, size_t idx); 68 static void rotate_from_left(btree_node_t *lnode, btree_node_t *rnode, size_t idx); 69 69 static bool try_insert_by_rotation_to_left(btree_node_t *node, btree_key_t key, void *value, btree_node_t *rsubtree); 70 70 static bool try_insert_by_rotation_to_right(btree_node_t *node, btree_key_t key, void *value, btree_node_t *rsubtree); … … 138 138 void btree_destroy_subtree(btree_node_t *root) 139 139 { 140 count_t i;140 size_t i; 141 141 142 142 if (root->keys) { … … 270 270 271 271 if (node->keys > FILL_FACTOR) { 272 count_t i;272 size_t i; 273 273 274 274 /* … … 286 286 287 287 } else { 288 index_t idx;288 size_t idx; 289 289 btree_node_t *rnode, *parent; 290 290 … … 336 336 } else { 337 337 void *val; 338 count_t i;338 size_t i; 339 339 340 340 /* … … 443 443 void node_insert_key_and_lsubtree(btree_node_t *node, btree_key_t key, void *value, btree_node_t *lsubtree) 444 444 { 445 count_t i;445 size_t i; 446 446 447 447 for (i = 0; i < node->keys; i++) { 448 448 if (key < node->key[i]) { 449 count_t j;449 size_t j; 450 450 451 451 for (j = node->keys; j > i; j--) { … … 479 479 void node_insert_key_and_rsubtree(btree_node_t *node, btree_key_t key, void *value, btree_node_t *rsubtree) 480 480 { 481 count_t i;481 size_t i; 482 482 483 483 for (i = 0; i < node->keys; i++) { 484 484 if (key < node->key[i]) { 485 count_t j;485 size_t j; 486 486 487 487 for (j = node->keys; j > i; j--) { … … 511 511 void node_remove_key_and_lsubtree(btree_node_t *node, btree_key_t key) 512 512 { 513 count_t i, j;513 size_t i, j; 514 514 515 515 for (i = 0; i < node->keys; i++) { … … 539 539 void node_remove_key_and_rsubtree(btree_node_t *node, btree_key_t key) 540 540 { 541 count_t i, j;541 size_t i, j; 542 542 543 543 for (i = 0; i < node->keys; i++) { … … 577 577 { 578 578 btree_node_t *rnode; 579 count_t i, j;579 size_t i, j; 580 580 581 581 ASSERT(median); … … 604 604 * If this is an index node, do not copy the median. 605 605 */ 606 i = ( count_t) INDEX_NODE(node);606 i = (size_t) INDEX_NODE(node); 607 607 for (i += MEDIAN_HIGH_INDEX(node), j = 0; i < node->keys; i++, j++) { 608 608 rnode->key[j] = node->key[i]; … … 637 637 btree_node_t *node_combine(btree_node_t *node) 638 638 { 639 index_t idx;639 size_t idx; 640 640 btree_node_t *rnode; 641 count_t i;641 size_t i; 642 642 643 643 ASSERT(!ROOT_NODE(node)); … … 686 686 * @return Index of the key associated with the subtree. 687 687 */ 688 index_t find_key_by_subtree(btree_node_t *node, btree_node_t *subtree, bool right)689 { 690 count_t i;688 size_t find_key_by_subtree(btree_node_t *node, btree_node_t *subtree, bool right) 689 { 690 size_t i; 691 691 692 692 for (i = 0; i < node->keys + 1; i++) { … … 707 707 * @param idx Index of the parent node key that is taking part in the rotation. 708 708 */ 709 void rotate_from_left(btree_node_t *lnode, btree_node_t *rnode, index_t idx)709 void rotate_from_left(btree_node_t *lnode, btree_node_t *rnode, size_t idx) 710 710 { 711 711 btree_key_t key; … … 744 744 * @param idx Index of the parent node key that is taking part in the rotation. 745 745 */ 746 void rotate_from_right(btree_node_t *lnode, btree_node_t *rnode, index_t idx)746 void rotate_from_right(btree_node_t *lnode, btree_node_t *rnode, size_t idx) 747 747 { 748 748 btree_key_t key; … … 787 787 bool try_insert_by_rotation_to_left(btree_node_t *node, btree_key_t inskey, void *insvalue, btree_node_t *rsubtree) 788 788 { 789 index_t idx;789 size_t idx; 790 790 btree_node_t *lnode; 791 791 … … 834 834 bool try_insert_by_rotation_to_right(btree_node_t *node, btree_key_t inskey, void *insvalue, btree_node_t *rsubtree) 835 835 { 836 index_t idx;836 size_t idx; 837 837 btree_node_t *rnode; 838 838 … … 873 873 bool try_rotation_from_left(btree_node_t *rnode) 874 874 { 875 index_t idx;875 size_t idx; 876 876 btree_node_t *lnode; 877 877 … … 908 908 bool try_rotation_from_right(btree_node_t *lnode) 909 909 { 910 index_t idx;910 size_t idx; 911 911 btree_node_t *rnode; 912 912 … … 941 941 void btree_print(btree_t *t) 942 942 { 943 count_t i;943 size_t i; 944 944 int depth = t->root->depth; 945 945 link_t head, *cur; -
kernel/generic/src/adt/hash_table.c
r69e68e3 r98000fb 52 52 * @param op Hash table operations structure. 53 53 */ 54 void hash_table_create(hash_table_t *h, count_t m, count_t max_keys, hash_table_operations_t *op)54 void hash_table_create(hash_table_t *h, size_t m, size_t max_keys, hash_table_operations_t *op) 55 55 { 56 index_t i;56 size_t i; 57 57 58 58 ASSERT(h); … … 84 84 void hash_table_insert(hash_table_t *h, unative_t key[], link_t *item) 85 85 { 86 index_t chain;86 size_t chain; 87 87 88 88 ASSERT(item); … … 108 108 { 109 109 link_t *cur; 110 index_t chain;110 size_t chain; 111 111 112 112 ASSERT(h); … … 138 138 * @param keys Number of keys in the key array. 139 139 */ 140 void hash_table_remove(hash_table_t *h, unative_t key[], count_t keys)140 void hash_table_remove(hash_table_t *h, unative_t key[], size_t keys) 141 141 { 142 index_t chain;142 size_t chain; 143 143 link_t *cur; 144 144 -
kernel/generic/src/console/cmd.c
r69e68e3 r98000fb 514 514 515 515 link_t *cur; 516 count_t len = 0;516 size_t len = 0; 517 517 for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { 518 518 cmd_info_t *hlp; … … 652 652 */ 653 653 654 count_t i;654 size_t i; 655 655 for (i = 0; i < config.cpu_count; i++) { 656 656 if (!cpus[i].active) … … 971 971 int cmd_tests(cmd_arg_t *argv) 972 972 { 973 count_t len = 0;973 size_t len = 0; 974 974 test_t *test; 975 975 for (test = tests; test->name != NULL; test++) { -
kernel/generic/src/console/console.c
r69e68e3 r98000fb 62 62 static bool klog_inited = false; 63 63 /** First kernel log characters */ 64 static index_t klog_start = 0;64 static size_t klog_start = 0; 65 65 /** Number of valid kernel log characters */ 66 66 static size_t klog_len = 0; … … 171 171 * 172 172 */ 173 count_t gets(indev_t *indev, char *buf, size_t buflen)173 size_t gets(indev_t *indev, char *buf, size_t buflen) 174 174 { 175 175 size_t offset = 0; 176 count_t count = 0;176 size_t count = 0; 177 177 buf[offset] = 0; 178 178 … … 227 227 if ((klog_stored > 0) && (stdout) && (stdout->op->write)) { 228 228 /* Print charaters stored in kernel log */ 229 index_t i;229 size_t i; 230 230 for (i = klog_len - klog_stored; i < klog_len; i++) 231 231 stdout->op->write(stdout, klog[(klog_start + i) % KLOG_LENGTH], silent); -
kernel/generic/src/console/kconsole.c
r69e68e3 r98000fb 87 87 88 88 static wchar_t history[KCONSOLE_HISTORY][MAX_CMDLINE] = {}; 89 static count_t history_pos = 0;89 static size_t history_pos = 0; 90 90 91 91 /** Initialize kconsole data structures … … 160 160 161 161 /** Print count times a character */ 162 static void print_cc(wchar_t ch, count_t count)163 { 164 count_t i;162 static void print_cc(wchar_t ch, size_t count) 163 { 164 size_t i; 165 165 for (i = 0; i < count; i++) 166 166 putchar(ch); … … 170 170 static const char *cmdtab_search_one(const char *name, link_t **startpos) 171 171 { 172 count_t namelen = str_length(name);172 size_t namelen = str_length(name); 173 173 174 174 spinlock_lock(&cmd_lock); … … 206 206 const char *name = input; 207 207 208 count_t found = 0;208 size_t found = 0; 209 209 link_t *pos = NULL; 210 210 const char *hint; … … 241 241 printf("%s> ", prompt); 242 242 243 count_t position = 0;243 size_t position = 0; 244 244 wchar_t *current = history[history_pos]; 245 245 current[0] = 0; … … 281 281 /* Find the beginning of the word 282 282 and copy it to tmp */ 283 count_t beg;283 size_t beg; 284 284 for (beg = position - 1; (beg > 0) && (!isspace(current[beg])); 285 285 beg--); … … 314 314 315 315 size_t off = 0; 316 count_t i = 0;316 size_t i = 0; 317 317 while ((ch = str_decode(tmp, &off, STR_NO_LIMIT)) != 0) { 318 318 if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE)) … … 543 543 if (str_lcmp(hlp->name, cmdline + start, 544 544 max(str_length(hlp->name), 545 str_nlength(cmdline + start, ( count_t) (end - start) - 1))) == 0) {545 str_nlength(cmdline + start, (size_t) (end - start) - 1))) == 0) { 546 546 cmd = hlp; 547 547 break; … … 569 569 570 570 bool error = false; 571 count_t i;571 size_t i; 572 572 for (i = 0; i < cmd->argc; i++) { 573 573 start = end; … … 660 660 while (true) { 661 661 wchar_t *tmp = clever_readline((char *) prompt, stdin); 662 count_t len = wstr_length(tmp);662 size_t len = wstr_length(tmp); 663 663 if (!len) 664 664 continue; -
kernel/generic/src/ddi/ddi.c
r69e68e3 r98000fb 98 98 * 99 99 */ 100 static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, count_t pages, int flags)100 static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, size_t pages, int flags) 101 101 { 102 102 ASSERT(TASK); … … 119 119 /* Find the zone of the physical memory */ 120 120 spinlock_lock(&zones.lock); 121 count_t znum = find_zone(ADDR2PFN(pf), pages, 0);122 123 if (znum == ( count_t) -1) {121 size_t znum = find_zone(ADDR2PFN(pf), pages, 0); 122 123 if (znum == (size_t) -1) { 124 124 /* Frames not found in any zones 125 125 * -> assume it is hardware device and allow mapping … … 243 243 return (unative_t) ddi_physmem_map(ALIGN_DOWN((uintptr_t) phys_base, 244 244 FRAME_SIZE), ALIGN_DOWN((uintptr_t) virt_base, PAGE_SIZE), 245 ( count_t) pages, (int) flags);245 (size_t) pages, (int) flags); 246 246 } 247 247 -
kernel/generic/src/ddi/irq.c
r69e68e3 r98000fb 100 100 * there will be collisions between different keys. 101 101 */ 102 static index_t irq_ht_hash(unative_t *key);103 static bool irq_ht_compare(unative_t *key, count_t keys, link_t *item);102 static size_t irq_ht_hash(unative_t *key); 103 static bool irq_ht_compare(unative_t *key, size_t keys, link_t *item); 104 104 static void irq_ht_remove(link_t *item); 105 105 … … 116 116 * elements with single key (sharing of one IRQ). 117 117 */ 118 static index_t irq_lin_hash(unative_t *key);119 static bool irq_lin_compare(unative_t *key, count_t keys, link_t *item);118 static size_t irq_lin_hash(unative_t *key); 119 static bool irq_lin_compare(unative_t *key, size_t keys, link_t *item); 120 120 static void irq_lin_remove(link_t *item); 121 121 … … 127 127 128 128 /** Number of buckets in either of the hash tables. */ 129 static count_t buckets;129 static size_t buckets; 130 130 131 131 /** Initialize IRQ subsystem. … … 134 134 * @param chains Number of chains in the hash table. 135 135 */ 136 void irq_init( count_t inrs, count_t chains)136 void irq_init(size_t inrs, size_t chains) 137 137 { 138 138 buckets = chains; … … 299 299 * @return Index into the hash table. 300 300 */ 301 index_t irq_ht_hash(unative_t key[])301 size_t irq_ht_hash(unative_t key[]) 302 302 { 303 303 inr_t inr = (inr_t) key[KEY_INR]; … … 325 325 * @return True on match or false otherwise. 326 326 */ 327 bool irq_ht_compare(unative_t key[], count_t keys, link_t *item)327 bool irq_ht_compare(unative_t key[], size_t keys, link_t *item) 328 328 { 329 329 irq_t *irq = hash_table_get_instance(item, irq_t, link); … … 372 372 * @return Index into the hash table. 373 373 */ 374 index_t irq_lin_hash(unative_t key[])374 size_t irq_lin_hash(unative_t key[]) 375 375 { 376 376 inr_t inr = (inr_t) key[KEY_INR]; … … 398 398 * @return True on match or false otherwise. 399 399 */ 400 bool irq_lin_compare(unative_t key[], count_t keys, link_t *item)400 bool irq_lin_compare(unative_t key[], size_t keys, link_t *item) 401 401 { 402 402 irq_t *irq = list_get_instance(item, irq_t, link); -
kernel/generic/src/debug/symtab.c
r69e68e3 r98000fb 56 56 { 57 57 #ifdef CONFIG_SYMTAB 58 count_t i;58 size_t i; 59 59 60 60 for (i = 1; symbol_table[i].address_le; i++) { … … 113 113 * 114 114 */ 115 static const char *symtab_search_one(const char *name, count_t *startpos)116 { 117 count_t namelen = str_length(name);118 119 count_t pos;115 static const char *symtab_search_one(const char *name, size_t *startpos) 116 { 117 size_t namelen = str_length(name); 118 119 size_t pos; 120 120 for (pos = *startpos; symbol_table[pos].address_le; pos++) { 121 121 const char *curname = symbol_table[pos].symbol_name; … … 154 154 { 155 155 #ifdef CONFIG_SYMTAB 156 count_t found = 0;157 count_t pos = 0;156 size_t found = 0; 157 size_t pos = 0; 158 158 const char *hint; 159 159 … … 183 183 { 184 184 #ifdef CONFIG_SYMTAB 185 count_t pos = 0;185 size_t pos = 0; 186 186 while (symtab_search_one(name, &pos)) { 187 187 uintptr_t addr = uint64_t_le2host(symbol_table[pos].address_le); … … 204 204 * 205 205 */ 206 int symtab_compl(char *input, count_t size)206 int symtab_compl(char *input, size_t size) 207 207 { 208 208 #ifdef CONFIG_SYMTAB … … 217 217 return 0; 218 218 219 count_t found = 0;220 count_t pos = 0;219 size_t found = 0; 220 size_t pos = 0; 221 221 const char *hint; 222 222 char output[MAX_SYMBOL_NAME]; -
kernel/generic/src/ipc/event.c
r69e68e3 r98000fb 65 65 } 66 66 67 static int 68 event_subscribe(event_type_t evno, unative_t method,answerbox_t *answerbox)67 static int event_subscribe(event_type_t evno, unative_t method, 68 answerbox_t *answerbox) 69 69 { 70 70 if (evno >= EVENT_END) … … 123 123 } 124 124 125 void 126 event_notify(event_type_t evno, unative_t a1, unative_t a2, unative_t a3, 125 void event_notify(event_type_t evno, unative_t a1, unative_t a2, unative_t a3, 127 126 unative_t a4, unative_t a5) 128 127 { -
kernel/generic/src/lib/sort.c
r69e68e3 r98000fb 46 46 #define EBUFSIZE 32 47 47 48 void _qsort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b), void *tmp, void *pivot);49 void _bubblesort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b), void *slot);48 void _qsort(void * data, size_t n, size_t e_size, int (* cmp) (void * a, void * b), void *tmp, void *pivot); 49 void _bubblesort(void * data, size_t n, size_t e_size, int (* cmp) (void * a, void * b), void *slot); 50 50 51 51 /** Quicksort wrapper … … 62 62 * 63 63 */ 64 void qsort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b))64 void qsort(void * data, size_t n, size_t e_size, int (* cmp) (void * a, void * b)) 65 65 { 66 66 uint8_t buf_tmp[EBUFSIZE]; … … 94 94 * 95 95 */ 96 void _qsort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b), void *tmp, void *pivot)96 void _qsort(void * data, size_t n, size_t e_size, int (* cmp) (void * a, void * b), void *tmp, void *pivot) 97 97 { 98 98 if (n > 4) { … … 134 134 * 135 135 */ 136 void bubblesort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b))136 void bubblesort(void * data, size_t n, size_t e_size, int (* cmp) (void * a, void * b)) 137 137 { 138 138 uint8_t buf_slot[EBUFSIZE]; … … 161 161 * 162 162 */ 163 void _bubblesort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b), void *slot)163 void _bubblesort(void * data, size_t n, size_t e_size, int (* cmp) (void * a, void * b), void *slot) 164 164 { 165 165 bool done = false; -
kernel/generic/src/lib/string.c
r69e68e3 r98000fb 63 63 * 64 64 * [wide] string length number of CHARACTERS in a [wide] string (excluding 65 * the NULL-terminator), count_t65 * the NULL-terminator), size_t 66 66 * 67 67 * [wide] string width number of display cells on a monospace display taken 68 * by a [wide] string, count_t68 * by a [wide] string, size_t 69 69 * 70 70 * … … 76 76 * NULL-terminator) 77 77 * 78 * length l count_tnumber of CHARACTERS in a string (excluding the78 * length l size_t number of CHARACTERS in a string (excluding the 79 79 * null terminator) 80 80 * 81 * width w count_tnumber of display cells on a monospace display81 * width w size_t number of display cells on a monospace display 82 82 * taken by a string 83 83 * … … 98 98 * pointer (char *, wchar_t *) 99 99 * byte offset (size_t) 100 * character index ( count_t)100 * character index (size_t) 101 101 * 102 102 */ … … 310 310 * 311 311 */ 312 size_t str_lsize(const char *str, count_t max_len)313 { 314 count_t len = 0;312 size_t str_lsize(const char *str, size_t max_len) 313 { 314 size_t len = 0; 315 315 size_t offset = 0; 316 316 … … 338 338 * 339 339 */ 340 size_t wstr_lsize(const wchar_t *str, count_t max_len)340 size_t wstr_lsize(const wchar_t *str, size_t max_len) 341 341 { 342 342 return (wstr_nlength(str, max_len * sizeof(wchar_t)) * sizeof(wchar_t)); … … 350 350 * 351 351 */ 352 count_t str_length(const char *str)353 { 354 count_t len = 0;352 size_t str_length(const char *str) 353 { 354 size_t len = 0; 355 355 size_t offset = 0; 356 356 … … 368 368 * 369 369 */ 370 count_t wstr_length(const wchar_t *wstr)371 { 372 count_t len = 0;370 size_t wstr_length(const wchar_t *wstr) 371 { 372 size_t len = 0; 373 373 374 374 while (*wstr++ != 0) … … 386 386 * 387 387 */ 388 count_t str_nlength(const char *str, size_t size)389 { 390 count_t len = 0;388 size_t str_nlength(const char *str, size_t size) 389 { 390 size_t len = 0; 391 391 size_t offset = 0; 392 392 … … 405 405 * 406 406 */ 407 count_t wstr_nlength(const wchar_t *str, size_t size)408 { 409 count_t len = 0;410 count_t limit = ALIGN_DOWN(size, sizeof(wchar_t));411 count_t offset = 0;407 size_t wstr_nlength(const wchar_t *str, size_t size) 408 { 409 size_t len = 0; 410 size_t limit = ALIGN_DOWN(size, sizeof(wchar_t)); 411 size_t offset = 0; 412 412 413 413 while ((offset < limit) && (*str++ != 0)) { … … 497 497 * 498 498 */ 499 int str_lcmp(const char *s1, const char *s2, count_t max_len)499 int str_lcmp(const char *s1, const char *s2, size_t max_len) 500 500 { 501 501 wchar_t c1 = 0; … … 505 505 size_t off2 = 0; 506 506 507 count_t len = 0;507 size_t len = 0; 508 508 509 509 while (true) { … … 616 616 617 617 wchar_t ch; 618 count_t src_idx = 0;618 size_t src_idx = 0; 619 619 size_t dst_off = 0; 620 620 … … 667 667 * 668 668 */ 669 bool wstr_linsert(wchar_t *str, wchar_t ch, count_t pos, count_t max_pos)670 { 671 count_t len = wstr_length(str);669 bool wstr_linsert(wchar_t *str, wchar_t ch, size_t pos, size_t max_pos) 670 { 671 size_t len = wstr_length(str); 672 672 673 673 if ((pos > len) || (pos + 1 > max_pos)) 674 674 return false; 675 675 676 count_t i;676 size_t i; 677 677 for (i = len; i + 1 > pos; i--) 678 678 str[i + 1] = str[i]; … … 695 695 * 696 696 */ 697 bool wstr_remove(wchar_t *str, count_t pos)698 { 699 count_t len = wstr_length(str);697 bool wstr_remove(wchar_t *str, size_t pos) 698 { 699 size_t len = wstr_length(str); 700 700 701 701 if (pos >= len) 702 702 return false; 703 703 704 count_t i;704 size_t i; 705 705 for (i = pos + 1; i <= len; i++) 706 706 str[i - 1] = str[i]; -
kernel/generic/src/main/kinit.c
r69e68e3 r98000fb 128 128 129 129 if (config.cpu_count > 1) { 130 count_t i;130 size_t i; 131 131 132 132 /* … … 141 141 thread_ready(thread); 142 142 } else 143 printf("Unable to create kcpulb thread for cpu" PRI c"\n", i);143 printf("Unable to create kcpulb thread for cpu" PRIs "\n", i); 144 144 } 145 145 } … … 169 169 * Create user tasks, load RAM disk images. 170 170 */ 171 count_t i;171 size_t i; 172 172 program_t programs[CONFIG_INIT_TASKS]; 173 173 174 174 for (i = 0; i < init.cnt; i++) { 175 175 if (init.tasks[i].addr % FRAME_SIZE) { 176 printf("init[%" PRI c"].addr is not frame aligned\n", i);176 printf("init[%" PRIs "].addr is not frame aligned\n", i); 177 177 continue; 178 178 } … … 214 214 215 215 if (rd != RE_OK) 216 printf("Init binary %" PRI c" not used (error %d)\n", i, rd);216 printf("Init binary %" PRIs " not used (error %d)\n", i, rd); 217 217 } 218 218 } -
kernel/generic/src/main/main.c
r69e68e3 r98000fb 154 154 155 155 /* Avoid placing stack on top of init */ 156 count_t i;156 size_t i; 157 157 for (i = 0; i < init.cnt; i++) { 158 158 if (PA_overlaps(config.stack_base, config.stack_size, … … 234 234 LOG_EXEC(slab_enable_cpucache()); 235 235 236 printf("Detected %" PRI c" CPU(s), %" PRIu64" MiB free memory\n",236 printf("Detected %" PRIs " CPU(s), %" PRIu64" MiB free memory\n", 237 237 config.cpu_count, SIZE2MB(zone_total_size())); 238 238 … … 248 248 249 249 if (init.cnt > 0) { 250 count_t i;250 size_t i; 251 251 for (i = 0; i < init.cnt; i++) 252 LOG("init[%" PRI c "].addr=%#" PRIp ", init[%" PRIc252 LOG("init[%" PRIs "].addr=%#" PRIp ", init[%" PRIs 253 253 "].size=%#" PRIs, i, init.tasks[i].addr, i, 254 254 init.tasks[i].size); -
kernel/generic/src/mm/as.c
r69e68e3 r98000fb 419 419 if ((cond = (bool) node->keys)) { 420 420 uintptr_t b = node->key[node->keys - 1]; 421 count_t c =422 ( count_t) node->value[node->keys - 1];421 size_t c = 422 (size_t) node->value[node->keys - 1]; 423 423 unsigned int i = 0; 424 424 … … 556 556 for (i = 0; i < node->keys; i++) { 557 557 uintptr_t b = node->key[i]; 558 count_t j;558 size_t j; 559 559 pte_t *pte; 560 560 561 for (j = 0; j < ( count_t) node->value[i]; j++) {561 for (j = 0; j < (size_t) node->value[i]; j++) { 562 562 page_table_lock(as, false); 563 563 pte = page_mapping_find(as, b + j * PAGE_SIZE); … … 789 789 int page_flags; 790 790 uintptr_t *old_frame; 791 index_t frame_idx;792 count_t used_pages;791 size_t frame_idx; 792 size_t used_pages; 793 793 794 794 /* Flags for the new memory mapping */ … … 828 828 node = list_get_instance(cur, btree_node_t, leaf_link); 829 829 for (i = 0; i < node->keys; i++) { 830 used_pages += ( count_t) node->value[i];830 used_pages += (size_t) node->value[i]; 831 831 } 832 832 } … … 854 854 for (i = 0; i < node->keys; i++) { 855 855 uintptr_t b = node->key[i]; 856 count_t j;856 size_t j; 857 857 pte_t *pte; 858 858 859 for (j = 0; j < ( count_t) node->value[i]; j++) {859 for (j = 0; j < (size_t) node->value[i]; j++) { 860 860 page_table_lock(as, false); 861 861 pte = page_mapping_find(as, b + j * PAGE_SIZE); … … 904 904 for (i = 0; i < node->keys; i++) { 905 905 uintptr_t b = node->key[i]; 906 count_t j;906 size_t j; 907 907 908 for (j = 0; j < ( count_t) node->value[i]; j++) {908 for (j = 0; j < (size_t) node->value[i]; j++) { 909 909 page_table_lock(as, false); 910 910 … … 1398 1398 * @return Zero on failure and non-zero on success. 1399 1399 */ 1400 int used_space_insert(as_area_t *a, uintptr_t page, count_t count)1400 int used_space_insert(as_area_t *a, uintptr_t page, size_t count) 1401 1401 { 1402 1402 btree_node_t *leaf, *node; 1403 count_t pages;1403 size_t pages; 1404 1404 unsigned int i; 1405 1405 … … 1407 1407 ASSERT(count); 1408 1408 1409 pages = ( count_t) btree_search(&a->used_space, page, &leaf);1409 pages = (size_t) btree_search(&a->used_space, page, &leaf); 1410 1410 if (pages) { 1411 1411 /* … … 1424 1424 uintptr_t left_pg = node->key[node->keys - 1]; 1425 1425 uintptr_t right_pg = leaf->key[0]; 1426 count_t left_cnt = (count_t) node->value[node->keys - 1];1427 count_t right_cnt = (count_t) leaf->value[0];1426 size_t left_cnt = (size_t) node->value[node->keys - 1]; 1427 size_t right_cnt = (size_t) leaf->value[0]; 1428 1428 1429 1429 /* … … 1479 1479 } else if (page < leaf->key[0]) { 1480 1480 uintptr_t right_pg = leaf->key[0]; 1481 count_t right_cnt = (count_t) leaf->value[0];1481 size_t right_cnt = (size_t) leaf->value[0]; 1482 1482 1483 1483 /* … … 1514 1514 uintptr_t left_pg = leaf->key[leaf->keys - 1]; 1515 1515 uintptr_t right_pg = node->key[0]; 1516 count_t left_cnt = (count_t) leaf->value[leaf->keys - 1];1517 count_t right_cnt = (count_t) node->value[0];1516 size_t left_cnt = (size_t) leaf->value[leaf->keys - 1]; 1517 size_t right_cnt = (size_t) node->value[0]; 1518 1518 1519 1519 /* … … 1569 1569 } else if (page >= leaf->key[leaf->keys - 1]) { 1570 1570 uintptr_t left_pg = leaf->key[leaf->keys - 1]; 1571 count_t left_cnt = (count_t) leaf->value[leaf->keys - 1];1571 size_t left_cnt = (size_t) leaf->value[leaf->keys - 1]; 1572 1572 1573 1573 /* … … 1607 1607 uintptr_t left_pg = leaf->key[i - 1]; 1608 1608 uintptr_t right_pg = leaf->key[i]; 1609 count_t left_cnt = (count_t) leaf->value[i - 1];1610 count_t right_cnt = (count_t) leaf->value[i];1609 size_t left_cnt = (size_t) leaf->value[i - 1]; 1610 size_t right_cnt = (size_t) leaf->value[i]; 1611 1611 1612 1612 /* … … 1666 1666 } 1667 1667 1668 panic("Inconsistency detected while adding %" PRI c" pages of used "1668 panic("Inconsistency detected while adding %" PRIs " pages of used " 1669 1669 "space at %p.", count, page); 1670 1670 } … … 1680 1680 * @return Zero on failure and non-zero on success. 1681 1681 */ 1682 int used_space_remove(as_area_t *a, uintptr_t page, count_t count)1682 int used_space_remove(as_area_t *a, uintptr_t page, size_t count) 1683 1683 { 1684 1684 btree_node_t *leaf, *node; 1685 count_t pages;1685 size_t pages; 1686 1686 unsigned int i; 1687 1687 … … 1689 1689 ASSERT(count); 1690 1690 1691 pages = ( count_t) btree_search(&a->used_space, page, &leaf);1691 pages = (size_t) btree_search(&a->used_space, page, &leaf); 1692 1692 if (pages) { 1693 1693 /* … … 1718 1718 if (node && page < leaf->key[0]) { 1719 1719 uintptr_t left_pg = node->key[node->keys - 1]; 1720 count_t left_cnt = (count_t) node->value[node->keys - 1];1720 size_t left_cnt = (size_t) node->value[node->keys - 1]; 1721 1721 1722 1722 if (overlaps(left_pg, left_cnt * PAGE_SIZE, page, … … 1734 1734 } else if (page + count * PAGE_SIZE < 1735 1735 left_pg + left_cnt*PAGE_SIZE) { 1736 count_t new_cnt;1736 size_t new_cnt; 1737 1737 1738 1738 /* … … 1758 1758 if (page > leaf->key[leaf->keys - 1]) { 1759 1759 uintptr_t left_pg = leaf->key[leaf->keys - 1]; 1760 count_t left_cnt = (count_t) leaf->value[leaf->keys - 1];1760 size_t left_cnt = (size_t) leaf->value[leaf->keys - 1]; 1761 1761 1762 1762 if (overlaps(left_pg, left_cnt * PAGE_SIZE, page, … … 1773 1773 } else if (page + count * PAGE_SIZE < left_pg + 1774 1774 left_cnt * PAGE_SIZE) { 1775 count_t new_cnt;1775 size_t new_cnt; 1776 1776 1777 1777 /* … … 1800 1800 if (page < leaf->key[i]) { 1801 1801 uintptr_t left_pg = leaf->key[i - 1]; 1802 count_t left_cnt = (count_t) leaf->value[i - 1];1802 size_t left_cnt = (size_t) leaf->value[i - 1]; 1803 1803 1804 1804 /* … … 1820 1820 } else if (page + count * PAGE_SIZE < 1821 1821 left_pg + left_cnt * PAGE_SIZE) { 1822 count_t new_cnt;1822 size_t new_cnt; 1823 1823 1824 1824 /* … … 1845 1845 1846 1846 error: 1847 panic("Inconsistency detected while removing %" PRI c" pages of used "1847 panic("Inconsistency detected while removing %" PRIs " pages of used " 1848 1848 "space from %p.", count, page); 1849 1849 } … … 1944 1944 1945 1945 mutex_lock(&area->lock); 1946 printf("as_area: %p, base=%p, pages=%" PRI c1946 printf("as_area: %p, base=%p, pages=%" PRIs 1947 1947 " (%p - %p)\n", area, area->base, area->pages, 1948 1948 area->base, area->base + FRAMES2SIZE(area->pages)); -
kernel/generic/src/mm/backend_anon.c
r69e68e3 r98000fb 196 196 for (i = 0; i < node->keys; i++) { 197 197 uintptr_t base = node->key[i]; 198 count_t count = (count_t) node->value[i];198 size_t count = (size_t) node->value[i]; 199 199 unsigned int j; 200 200 -
kernel/generic/src/mm/backend_elf.c
r69e68e3 r98000fb 83 83 btree_node_t *leaf; 84 84 uintptr_t base, frame, page, start_anon; 85 index_t i;85 size_t i; 86 86 bool dirty = false; 87 87 … … 235 235 elf_segment_header_t *entry = area->backend_data.segment; 236 236 uintptr_t base, start_anon; 237 index_t i;237 size_t i; 238 238 239 239 ASSERT((page >= ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) && … … 305 305 for (i = 0; i < node->keys; i++) { 306 306 uintptr_t base = node->key[i]; 307 count_t count = (count_t) node->value[i];307 size_t count = (size_t) node->value[i]; 308 308 unsigned int j; 309 309 -
kernel/generic/src/mm/frame.c
r69e68e3 r98000fb 68 68 mutex_t mem_avail_mtx; 69 69 condvar_t mem_avail_cv; 70 count_t mem_avail_req = 0; /**< Number of frames requested. */71 count_t mem_avail_gen = 0; /**< Generation counter. */70 size_t mem_avail_req = 0; /**< Number of frames requested. */ 71 size_t mem_avail_gen = 0; /**< Generation counter. */ 72 72 73 73 /********************/ … … 75 75 /********************/ 76 76 77 static inline index_t frame_index(zone_t *zone, frame_t *frame)78 { 79 return ( index_t) (frame - zone->frames);80 } 81 82 static inline index_t frame_index_abs(zone_t *zone, frame_t *frame)83 { 84 return ( index_t) (frame - zone->frames) + zone->base;85 } 86 87 static inline bool frame_index_valid(zone_t *zone, index_t index)77 static inline size_t frame_index(zone_t *zone, frame_t *frame) 78 { 79 return (size_t) (frame - zone->frames); 80 } 81 82 static inline size_t frame_index_abs(zone_t *zone, frame_t *frame) 83 { 84 return (size_t) (frame - zone->frames) + zone->base; 85 } 86 87 static inline bool frame_index_valid(zone_t *zone, size_t index) 88 88 { 89 89 return (index < zone->count); 90 90 } 91 91 92 static inline index_t make_frame_index(zone_t *zone, frame_t *frame)92 static inline size_t make_frame_index(zone_t *zone, frame_t *frame) 93 93 { 94 94 return (frame - zone->frames); … … 121 121 * 122 122 */ 123 static count_t zones_insert_zone(pfn_t base, count_t count)123 static size_t zones_insert_zone(pfn_t base, size_t count) 124 124 { 125 125 if (zones.count + 1 == ZONES_MAX) { 126 126 printf("Maximum zone count %u exceeded!\n", ZONES_MAX); 127 return ( count_t) -1;128 } 129 130 count_t i;127 return (size_t) -1; 128 } 129 130 size_t i; 131 131 for (i = 0; i < zones.count; i++) { 132 132 /* Check for overlap */ … … 134 134 zones.info[i].base, zones.info[i].count)) { 135 135 printf("Zones overlap!\n"); 136 return ( count_t) -1;136 return (size_t) -1; 137 137 } 138 138 if (base < zones.info[i].base) … … 141 141 142 142 /* Move other zones up */ 143 count_t j;143 size_t j; 144 144 for (j = zones.count; j > i; j--) { 145 145 zones.info[j] = zones.info[j - 1]; … … 162 162 */ 163 163 #ifdef CONFIG_DEBUG 164 static count_t total_frames_free(void)165 { 166 count_t total = 0;167 count_t i;164 static size_t total_frames_free(void) 165 { 166 size_t total = 0; 167 size_t i; 168 168 for (i = 0; i < zones.count; i++) 169 169 total += zones.info[i].free_count; … … 185 185 * 186 186 */ 187 count_t find_zone(pfn_t frame, count_t count, count_t hint)187 size_t find_zone(pfn_t frame, size_t count, size_t hint) 188 188 { 189 189 if (hint >= zones.count) 190 190 hint = 0; 191 191 192 count_t i = hint;192 size_t i = hint; 193 193 do { 194 194 if ((zones.info[i].base <= frame) … … 201 201 } while (i != hint); 202 202 203 return ( count_t) -1;203 return (size_t) -1; 204 204 } 205 205 … … 221 221 * 222 222 */ 223 static count_t find_free_zone(uint8_t order, zone_flags_t flags, count_t hint)223 static size_t find_free_zone(uint8_t order, zone_flags_t flags, size_t hint) 224 224 { 225 225 if (hint >= zones.count) 226 226 hint = 0; 227 227 228 count_t i = hint;228 size_t i = hint; 229 229 do { 230 230 /* … … 244 244 } while (i != hint); 245 245 246 return ( count_t) -1;246 return (size_t) -1; 247 247 } 248 248 … … 266 266 zone_t *zone = (zone_t *) buddy->data; 267 267 268 index_t index = frame_index(zone, frame);268 size_t index = frame_index(zone, frame); 269 269 do { 270 270 if (zone->frames[index].buddy_order != order) … … 292 292 bool is_left = IS_BUDDY_LEFT_BLOCK_ABS(zone, frame); 293 293 294 index_t index;294 size_t index; 295 295 if (is_left) { 296 296 index = (frame_index(zone, frame)) + … … 447 447 * 448 448 */ 449 static void zone_frame_free(zone_t *zone, index_t frame_idx)449 static void zone_frame_free(zone_t *zone, size_t frame_idx) 450 450 { 451 451 ASSERT(zone_flags_available(zone->flags)); … … 468 468 469 469 /** Return frame from zone. */ 470 static frame_t *zone_get_frame(zone_t *zone, index_t frame_idx)470 static frame_t *zone_get_frame(zone_t *zone, size_t frame_idx) 471 471 { 472 472 ASSERT(frame_idx < zone->count); … … 475 475 476 476 /** Mark frame in zone unavailable to allocation. */ 477 static void zone_mark_unavailable(zone_t *zone, index_t frame_idx)477 static void zone_mark_unavailable(zone_t *zone, size_t frame_idx) 478 478 { 479 479 ASSERT(zone_flags_available(zone->flags)); … … 504 504 * 505 505 */ 506 static void zone_merge_internal( count_t z1, count_t z2, zone_t *old_z1, buddy_system_t *buddy)506 static void zone_merge_internal(size_t z1, size_t z2, zone_t *old_z1, buddy_system_t *buddy) 507 507 { 508 508 ASSERT(zone_flags_available(zones.info[z1].flags)); … … 530 530 531 531 /* This marks all frames busy */ 532 count_t i;532 size_t i; 533 533 for (i = 0; i < zones.info[z1].count; i++) 534 534 frame_initialize(&zones.info[z1].frames[i]); … … 600 600 * 601 601 */ 602 static void return_config_frames( count_t znum, pfn_t pfn, count_t count)602 static void return_config_frames(size_t znum, pfn_t pfn, size_t count) 603 603 { 604 604 ASSERT(zone_flags_available(zones.info[znum].flags)); 605 605 606 count_t cframes = SIZE2FRAMES(zone_conf_size(count));606 size_t cframes = SIZE2FRAMES(zone_conf_size(count)); 607 607 608 608 if ((pfn < zones.info[znum].base) … … 615 615 ASSERT(!frame->buddy_order); 616 616 617 count_t i;617 size_t i; 618 618 for (i = 0; i < cframes; i++) { 619 619 zones.info[znum].busy_count++; … … 635 635 * 636 636 */ 637 static void zone_reduce_region( count_t znum, pfn_t frame_idx, count_t count)637 static void zone_reduce_region(size_t znum, pfn_t frame_idx, size_t count) 638 638 { 639 639 ASSERT(zone_flags_available(zones.info[znum].flags)); … … 641 641 642 642 uint8_t order = zones.info[znum].frames[frame_idx].buddy_order; 643 ASSERT(( count_t) (1 << order) >= count);643 ASSERT((size_t) (1 << order) >= count); 644 644 645 645 /* Reduce all blocks to order 0 */ 646 count_t i;647 for (i = 0; i < ( count_t) (1 << order); i++) {646 size_t i; 647 for (i = 0; i < (size_t) (1 << order); i++) { 648 648 frame_t *frame = &zones.info[znum].frames[i + frame_idx]; 649 649 frame->buddy_order = 0; … … 654 654 655 655 /* Free unneeded frames */ 656 for (i = count; i < ( count_t) (1 << order); i++)656 for (i = count; i < (size_t) (1 << order); i++) 657 657 zone_frame_free(&zones.info[znum], i + frame_idx); 658 658 } … … 671 671 * 672 672 */ 673 bool zone_merge( count_t z1, count_t z2)673 bool zone_merge(size_t z1, size_t z2) 674 674 { 675 675 ipl_t ipl = interrupts_disable(); … … 734 734 735 735 /* Move zones down */ 736 count_t i;736 size_t i; 737 737 for (i = z2 + 1; i < zones.count; i++) { 738 738 zones.info[i - 1] = zones.info[i]; … … 759 759 void zone_merge_all(void) 760 760 { 761 count_t i = 0;761 size_t i = 0; 762 762 while (i < zones.count) { 763 763 if (!zone_merge(i, i + 1)) … … 777 777 * 778 778 */ 779 static void zone_construct(zone_t *zone, buddy_system_t *buddy, pfn_t start, count_t count, zone_flags_t flags)779 static void zone_construct(zone_t *zone, buddy_system_t *buddy, pfn_t start, size_t count, zone_flags_t flags) 780 780 { 781 781 zone->base = start; … … 800 800 buddy_conf_size(order)); 801 801 802 count_t i;802 size_t i; 803 803 for (i = 0; i < count; i++) 804 804 frame_initialize(&zone->frames[i]); … … 820 820 * 821 821 */ 822 uintptr_t zone_conf_size( count_t count)822 uintptr_t zone_conf_size(size_t count) 823 823 { 824 824 return (count * sizeof(frame_t) + buddy_conf_size(fnzb(count))); … … 841 841 * 842 842 */ 843 count_t zone_create(pfn_t start, count_t count, pfn_t confframe, zone_flags_t flags)843 size_t zone_create(pfn_t start, size_t count, pfn_t confframe, zone_flags_t flags) 844 844 { 845 845 ipl_t ipl = interrupts_disable(); … … 856 856 * it does not span kernel & init 857 857 */ 858 count_t confcount = SIZE2FRAMES(zone_conf_size(count));858 size_t confcount = SIZE2FRAMES(zone_conf_size(count)); 859 859 if ((confframe >= start) && (confframe < start + count)) { 860 860 for (; confframe < start + count; confframe++) { … … 869 869 870 870 bool overlap = false; 871 count_t i;871 size_t i; 872 872 for (i = 0; i < init.cnt; i++) 873 873 if (overlaps(addr, PFN2ADDR(confcount), … … 887 887 } 888 888 889 count_t znum = zones_insert_zone(start, count);890 if (znum == ( count_t) -1) {889 size_t znum = zones_insert_zone(start, count); 890 if (znum == (size_t) -1) { 891 891 spinlock_unlock(&zones.lock); 892 892 interrupts_restore(ipl); 893 return ( count_t) -1;893 return (size_t) -1; 894 894 } 895 895 … … 899 899 /* If confdata in zone, mark as unavailable */ 900 900 if ((confframe >= start) && (confframe < start + count)) { 901 count_t i;901 size_t i; 902 902 for (i = confframe; i < confframe + confcount; i++) 903 903 zone_mark_unavailable(&zones.info[znum], … … 912 912 913 913 /* Non-available zone */ 914 count_t znum = zones_insert_zone(start, count);915 if (znum == ( count_t) -1) {914 size_t znum = zones_insert_zone(start, count); 915 if (znum == (size_t) -1) { 916 916 spinlock_unlock(&zones.lock); 917 917 interrupts_restore(ipl); 918 return ( count_t) -1;918 return (size_t) -1; 919 919 } 920 920 zone_construct(&zones.info[znum], NULL, start, count, flags); … … 931 931 932 932 /** Set parent of frame. */ 933 void frame_set_parent(pfn_t pfn, void *data, count_t hint)933 void frame_set_parent(pfn_t pfn, void *data, size_t hint) 934 934 { 935 935 ipl_t ipl = interrupts_disable(); 936 936 spinlock_lock(&zones.lock); 937 937 938 count_t znum = find_zone(pfn, 1, hint);939 940 ASSERT(znum != ( count_t) -1);938 size_t znum = find_zone(pfn, 1, hint); 939 940 ASSERT(znum != (size_t) -1); 941 941 942 942 zone_get_frame(&zones.info[znum], … … 947 947 } 948 948 949 void *frame_get_parent(pfn_t pfn, count_t hint)949 void *frame_get_parent(pfn_t pfn, size_t hint) 950 950 { 951 951 ipl_t ipl = interrupts_disable(); 952 952 spinlock_lock(&zones.lock); 953 953 954 count_t znum = find_zone(pfn, 1, hint);955 956 ASSERT(znum != ( count_t) -1);954 size_t znum = find_zone(pfn, 1, hint); 955 956 ASSERT(znum != (size_t) -1); 957 957 958 958 void *res = zone_get_frame(&zones.info[znum], … … 974 974 * 975 975 */ 976 void *frame_alloc_generic(uint8_t order, frame_flags_t flags, count_t *pzone)977 { 978 count_t size = ((count_t) 1) << order;976 void *frame_alloc_generic(uint8_t order, frame_flags_t flags, size_t *pzone) 977 { 978 size_t size = ((size_t) 1) << order; 979 979 ipl_t ipl; 980 count_t hint = pzone ? (*pzone) : 0;980 size_t hint = pzone ? (*pzone) : 0; 981 981 982 982 loop: … … 987 987 * First, find suitable frame zone. 988 988 */ 989 count_t znum = find_free_zone(order,989 size_t znum = find_free_zone(order, 990 990 FRAME_TO_ZONE_FLAGS(flags), hint); 991 991 992 992 /* If no memory, reclaim some slab memory, 993 993 if it does not help, reclaim all */ 994 if ((znum == ( count_t) -1) && (!(flags & FRAME_NO_RECLAIM))) {994 if ((znum == (size_t) -1) && (!(flags & FRAME_NO_RECLAIM))) { 995 995 spinlock_unlock(&zones.lock); 996 996 interrupts_restore(ipl); 997 997 998 count_t freed = slab_reclaim(0);998 size_t freed = slab_reclaim(0); 999 999 1000 1000 ipl = interrupts_disable(); … … 1005 1005 FRAME_TO_ZONE_FLAGS(flags), hint); 1006 1006 1007 if (znum == ( count_t) -1) {1007 if (znum == (size_t) -1) { 1008 1008 spinlock_unlock(&zones.lock); 1009 1009 interrupts_restore(ipl); … … 1020 1020 } 1021 1021 1022 if (znum == ( count_t) -1) {1022 if (znum == (size_t) -1) { 1023 1023 if (flags & FRAME_ATOMIC) { 1024 1024 spinlock_unlock(&zones.lock); … … 1028 1028 1029 1029 #ifdef CONFIG_DEBUG 1030 count_t avail = total_frames_free();1030 size_t avail = total_frames_free(); 1031 1031 #endif 1032 1032 … … 1039 1039 1040 1040 #ifdef CONFIG_DEBUG 1041 printf("Thread %" PRIu64 " waiting for %" PRI c" frames, "1042 "%" PRI c" available.\n", THREAD->tid, size, avail);1041 printf("Thread %" PRIu64 " waiting for %" PRIs " frames, " 1042 "%" PRIs " available.\n", THREAD->tid, size, avail); 1043 1043 #endif 1044 1044 … … 1049 1049 else 1050 1050 mem_avail_req = size; 1051 count_t gen = mem_avail_gen;1051 size_t gen = mem_avail_gen; 1052 1052 1053 1053 while (gen == mem_avail_gen) … … 1096 1096 */ 1097 1097 pfn_t pfn = ADDR2PFN(frame); 1098 count_t znum = find_zone(pfn, 1, NULL);1099 1100 ASSERT(znum != ( count_t) -1);1098 size_t znum = find_zone(pfn, 1, NULL); 1099 1100 ASSERT(znum != (size_t) -1); 1101 1101 1102 1102 zone_frame_free(&zones.info[znum], pfn - zones.info[znum].base); … … 1135 1135 * First, find host frame zone for addr. 1136 1136 */ 1137 count_t znum = find_zone(pfn, 1, NULL);1138 1139 ASSERT(znum != ( count_t) -1);1137 size_t znum = find_zone(pfn, 1, NULL); 1138 1139 ASSERT(znum != (size_t) -1); 1140 1140 1141 1141 zones.info[znum].frames[pfn - zones.info[znum].base].refcount++; … … 1146 1146 1147 1147 /** Mark given range unavailable in frame zones. */ 1148 void frame_mark_unavailable(pfn_t start, count_t count)1148 void frame_mark_unavailable(pfn_t start, size_t count) 1149 1149 { 1150 1150 ipl_t ipl = interrupts_disable(); 1151 1151 spinlock_lock(&zones.lock); 1152 1152 1153 count_t i;1153 size_t i; 1154 1154 for (i = 0; i < count; i++) { 1155 count_t znum = find_zone(start + i, 1, 0);1156 if (znum == ( count_t) -1) /* PFN not found */1155 size_t znum = find_zone(start + i, 1, 0); 1156 if (znum == (size_t) -1) /* PFN not found */ 1157 1157 continue; 1158 1158 … … 1183 1183 SIZE2FRAMES(config.stack_size)); 1184 1184 1185 count_t i;1185 size_t i; 1186 1186 for (i = 0; i < init.cnt; i++) { 1187 1187 pfn_t pfn = ADDR2PFN(KA2PA(init.tasks[i].addr)); … … 1208 1208 1209 1209 uint64_t total = 0; 1210 count_t i;1210 size_t i; 1211 1211 for (i = 0; i < zones.count; i++) 1212 1212 total += (uint64_t) FRAMES2SIZE(zones.info[i].count); … … 1242 1242 */ 1243 1243 1244 count_t i;1244 size_t i; 1245 1245 for (i = 0;; i++) { 1246 1246 ipl_t ipl = interrupts_disable(); … … 1254 1254 1255 1255 uintptr_t base = PFN2ADDR(zones.info[i].base); 1256 count_t count = zones.info[i].count;1256 size_t count = zones.info[i].count; 1257 1257 zone_flags_t flags = zones.info[i].flags; 1258 count_t free_count = zones.info[i].free_count;1259 count_t busy_count = zones.info[i].busy_count;1258 size_t free_count = zones.info[i].free_count; 1259 size_t busy_count = zones.info[i].busy_count; 1260 1260 1261 1261 spinlock_unlock(&zones.lock); … … 1264 1264 bool available = zone_flags_available(flags); 1265 1265 1266 printf("%-2" PRI c, i);1266 printf("%-2" PRIs, i); 1267 1267 1268 1268 #ifdef __32_BITS__ … … 1274 1274 #endif 1275 1275 1276 printf(" %12" PRI c" %c%c%c ", count,1276 printf(" %12" PRIs " %c%c%c ", count, 1277 1277 available ? 'A' : ' ', 1278 1278 (flags & ZONE_RESERVED) ? 'R' : ' ', … … 1280 1280 1281 1281 if (available) 1282 printf("%12" PRI c " %12" PRIc,1282 printf("%12" PRIs " %12" PRIs, 1283 1283 free_count, busy_count); 1284 1284 … … 1292 1292 * 1293 1293 */ 1294 void zone_print_one( count_t num)1294 void zone_print_one(size_t num) 1295 1295 { 1296 1296 ipl_t ipl = interrupts_disable(); 1297 1297 spinlock_lock(&zones.lock); 1298 count_t znum = (count_t) -1;1299 1300 count_t i;1298 size_t znum = (size_t) -1; 1299 1300 size_t i; 1301 1301 for (i = 0; i < zones.count; i++) { 1302 1302 if ((i == num) || (PFN2ADDR(zones.info[i].base) == num)) { … … 1306 1306 } 1307 1307 1308 if (znum == ( count_t) -1) {1308 if (znum == (size_t) -1) { 1309 1309 spinlock_unlock(&zones.lock); 1310 1310 interrupts_restore(ipl); … … 1315 1315 uintptr_t base = PFN2ADDR(zones.info[i].base); 1316 1316 zone_flags_t flags = zones.info[i].flags; 1317 count_t count = zones.info[i].count;1318 count_t free_count = zones.info[i].free_count;1319 count_t busy_count = zones.info[i].busy_count;1317 size_t count = zones.info[i].count; 1318 size_t free_count = zones.info[i].free_count; 1319 size_t busy_count = zones.info[i].busy_count; 1320 1320 1321 1321 spinlock_unlock(&zones.lock); … … 1324 1324 bool available = zone_flags_available(flags); 1325 1325 1326 printf("Zone number: %" PRI c"\n", znum);1326 printf("Zone number: %" PRIs "\n", znum); 1327 1327 printf("Zone base address: %p\n", base); 1328 printf("Zone size: %" PRI c" frames (%" PRIs " KiB)\n", count,1328 printf("Zone size: %" PRIs " frames (%" PRIs " KiB)\n", count, 1329 1329 SIZE2KB(FRAMES2SIZE(count))); 1330 1330 printf("Zone flags: %c%c%c\n", … … 1334 1334 1335 1335 if (available) { 1336 printf("Allocated space: %" PRI c" frames (%" PRIs " KiB)\n",1336 printf("Allocated space: %" PRIs " frames (%" PRIs " KiB)\n", 1337 1337 busy_count, SIZE2KB(FRAMES2SIZE(busy_count))); 1338 printf("Available space: %" PRI c" frames (%" PRIs " KiB)\n",1338 printf("Available space: %" PRIs " frames (%" PRIs " KiB)\n", 1339 1339 free_count, SIZE2KB(FRAMES2SIZE(free_count))); 1340 1340 } -
kernel/generic/src/mm/slab.c
r69e68e3 r98000fb 157 157 link_t link; /**< List of full/partial slabs. */ 158 158 void *start; /**< Start address of first available item. */ 159 count_t available; /**< Count of available items in this slab. */160 index_t nextavail; /**< The index of next available item. */159 size_t available; /**< Count of available items in this slab. */ 160 size_t nextavail; /**< The index of next available item. */ 161 161 } slab_t; 162 162 … … 178 178 size_t fsize; 179 179 unsigned int i; 180 count_t zone = 0;180 size_t zone = 0; 181 181 182 182 data = frame_alloc_generic(cache->order, FRAME_KA | flags, &zone); … … 216 216 * @return number of freed frames 217 217 */ 218 static count_t slab_space_free(slab_cache_t *cache, slab_t *slab)218 static size_t slab_space_free(slab_cache_t *cache, slab_t *slab) 219 219 { 220 220 frame_free(KA2PA(slab->start)); … … 244 244 * @return Number of freed pages 245 245 */ 246 static count_t slab_obj_destroy(slab_cache_t *cache, void *obj, slab_t *slab)246 static size_t slab_obj_destroy(slab_cache_t *cache, void *obj, slab_t *slab) 247 247 { 248 248 int freed = 0; … … 372 372 * @return Number of freed pages 373 373 */ 374 static count_t magazine_destroy(slab_cache_t *cache, slab_magazine_t *mag)374 static size_t magazine_destroy(slab_cache_t *cache, slab_magazine_t *mag) 375 375 { 376 376 unsigned int i; 377 count_t frames = 0;377 size_t frames = 0; 378 378 379 379 for (i = 0; i < mag->busy; i++) { … … 650 650 * @return Number of freed pages 651 651 */ 652 static count_t _slab_reclaim(slab_cache_t *cache, int flags)652 static size_t _slab_reclaim(slab_cache_t *cache, int flags) 653 653 { 654 654 unsigned int i; 655 655 slab_magazine_t *mag; 656 count_t frames = 0;656 size_t frames = 0; 657 657 int magcount; 658 658 … … 772 772 773 773 /* Go through all caches and reclaim what is possible */ 774 count_t slab_reclaim(int flags)774 size_t slab_reclaim(int flags) 775 775 { 776 776 slab_cache_t *cache; 777 777 link_t *cur; 778 count_t frames = 0;778 size_t frames = 0; 779 779 780 780 spinlock_lock(&slab_cache_lock); -
kernel/generic/src/mm/tlb.c
r69e68e3 r98000fb 80 80 */ 81 81 void tlb_shootdown_start(tlb_invalidate_type_t type, asid_t asid, 82 uintptr_t page, count_t count)82 uintptr_t page, size_t count) 83 83 { 84 84 unsigned int i; … … 109 109 * Enqueue the message. 110 110 */ 111 index_t idx = cpu->tlb_messages_count++;111 size_t idx = cpu->tlb_messages_count++; 112 112 cpu->tlb_messages[idx].type = type; 113 113 cpu->tlb_messages[idx].asid = asid; … … 144 144 asid_t asid; 145 145 uintptr_t page; 146 count_t count;146 size_t count; 147 147 unsigned int i; 148 148 -
kernel/generic/src/printf/printf_core.c
r69e68e3 r98000fb 175 175 static int print_char(const char ch, int width, uint32_t flags, printf_spec_t *ps) 176 176 { 177 count_t counter = 0;177 size_t counter = 0; 178 178 if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { 179 179 while (--width > 0) { … … 213 213 static int print_wchar(const wchar_t ch, int width, uint32_t flags, printf_spec_t *ps) 214 214 { 215 count_t counter = 0;215 size_t counter = 0; 216 216 if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { 217 217 while (--width > 0) { … … 256 256 257 257 /* Print leading spaces. */ 258 count_t strw = str_length(str);258 size_t strw = str_length(str); 259 259 if (precision == 0) 260 260 precision = strw; 261 261 262 262 /* Left padding */ 263 count_t counter = 0;263 size_t counter = 0; 264 264 width -= precision; 265 265 if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { … … 312 312 313 313 /* Left padding */ 314 count_t counter = 0;314 size_t counter = 0; 315 315 width -= precision; 316 316 if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { … … 434 434 435 435 width -= precision + size - number_size; 436 count_t counter = 0;436 size_t counter = 0; 437 437 438 438 if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { … … 597 597 size_t j = 0; /* Index to the first not printed nonformating character */ 598 598 599 count_t counter = 0;/* Number of characters printed */599 size_t counter = 0; /* Number of characters printed */ 600 600 int retval; /* Return values from nested functions */ 601 601 -
kernel/generic/src/printf/vprintf.c
r69e68e3 r98000fb 47 47 { 48 48 size_t offset = 0; 49 count_t chars = 0;49 size_t chars = 0; 50 50 51 51 while (offset < size) { … … 60 60 { 61 61 size_t offset = 0; 62 count_t chars = 0;62 size_t chars = 0; 63 63 64 64 while (offset < size) { … … 74 74 { 75 75 size_t offset = 0; 76 count_t chars = 0;76 size_t chars = 0; 77 77 wchar_t uc; 78 78 -
kernel/generic/src/printf/vsnprintf.c
r69e68e3 r98000fb 83 83 * of string 84 84 */ 85 index_t index = 0;85 size_t index = 0; 86 86 87 87 while (index < size) { … … 131 131 static int vsnprintf_wstr_write(const wchar_t *str, size_t size, vsnprintf_data_t *data) 132 132 { 133 index_t index = 0;133 size_t index = 0; 134 134 135 135 while (index < (size / sizeof(wchar_t))) { -
kernel/generic/src/proc/scheduler.c
r69e68e3 r98000fb 709 709 710 710 spinlock_lock(&cpus[cpu].lock); 711 printf("cpu%u: address=%p, nrdy=%ld, needs_relink=%" PRI c"\n",711 printf("cpu%u: address=%p, nrdy=%ld, needs_relink=%" PRIs "\n", 712 712 cpus[cpu].id, &cpus[cpu], atomic_get(&cpus[cpu].nrdy), 713 713 cpus[cpu].needs_relink); -
kernel/generic/src/synch/futex.c
r69e68e3 r98000fb 60 60 61 61 static futex_t *futex_find(uintptr_t paddr); 62 static index_t futex_ht_hash(unative_t *key);63 static bool futex_ht_compare(unative_t *key, count_t keys, link_t *item);62 static size_t futex_ht_hash(unative_t *key); 63 static bool futex_ht_compare(unative_t *key, size_t keys, link_t *item); 64 64 static void futex_ht_remove_callback(link_t *item); 65 65 … … 289 289 * @return Index into futex hash table. 290 290 */ 291 index_t futex_ht_hash(unative_t *key)292 { 293 return *key & (FUTEX_HT_SIZE-1);291 size_t futex_ht_hash(unative_t *key) 292 { 293 return (*key & (FUTEX_HT_SIZE - 1)); 294 294 } 295 295 … … 301 301 * @return True if the item matches the key. False otherwise. 302 302 */ 303 bool futex_ht_compare(unative_t *key, count_t keys, link_t *item)303 bool futex_ht_compare(unative_t *key, size_t keys, link_t *item) 304 304 { 305 305 futex_t *futex; -
kernel/generic/src/synch/spinlock.c
r69e68e3 r98000fb 76 76 void spinlock_lock_debug(spinlock_t *sl) 77 77 { 78 count_t i = 0;78 size_t i = 0; 79 79 bool deadlock_reported = false; 80 80 -
kernel/generic/src/synch/waitq.c
r69e68e3 r98000fb 416 416 { 417 417 thread_t *t; 418 count_t count = 0;418 size_t count = 0; 419 419 420 420 loop: -
kernel/generic/src/time/clock.c
r69e68e3 r98000fb 135 135 timeout_handler_t f; 136 136 void *arg; 137 count_t missed_clock_ticks = CPU->missed_clock_ticks;137 size_t missed_clock_ticks = CPU->missed_clock_ticks; 138 138 unsigned int i; 139 139
Note:
See TracChangeset
for help on using the changeset viewer.