Changeset 69146b93 in mainline for uspace/lib/c/generic
- Timestamp:
- 2012-11-26T19:02:45Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 04552324
- Parents:
- 5d230a30 (diff), 7462674 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib/c/generic
- Files:
-
- 1 added
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/ddi.c
r5d230a30 r69146b93 34 34 35 35 #include <assert.h> 36 #include <atomic.h> 36 37 #include <unistd.h> 38 #include <stdio.h> 37 39 #include <errno.h> 38 40 #include <sys/types.h> … … 47 49 #include "private/libc.h" 48 50 51 49 52 /** Return unique device number. 50 53 * … … 120 123 * 121 124 */ 122 int iospace_enable(task_id_t id, void *ioaddr, unsigned longsize)123 { 124 ddi_ioarg_t arg;125 126 arg.task_id = id;127 arg.ioaddr = ioaddr;128 arg.size = size;125 static int iospace_enable(task_id_t id, void *ioaddr, size_t size) 126 { 127 const ddi_ioarg_t arg = { 128 .task_id = id, 129 .ioaddr = ioaddr, 130 .size = size 131 }; 129 132 130 133 return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg); … … 136 139 * @param size Size of the I/O region. 137 140 * @param virt Virtual address for application's 138 * PIO operations. 141 * PIO operations. Can be NULL for PMIO. 139 142 * 140 143 * @return EOK on success. … … 146 149 #ifdef IO_SPACE_BOUNDARY 147 150 if (pio_addr < IO_SPACE_BOUNDARY) { 148 *virt = pio_addr; 151 if (virt) 152 *virt = pio_addr; 149 153 return iospace_enable(task_get_id(), pio_addr, size); 150 154 } 155 #else 156 (void) iospace_enable; 151 157 #endif 152 158 if (!virt) 159 return EINVAL; 160 153 161 void *phys_frame = 154 162 (void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE); … … 166 174 } 167 175 176 void pio_write_8(ioport8_t *reg, uint8_t val) 177 { 178 pio_trace_log(reg, val, true); 179 arch_pio_write_8(reg, val); 180 } 181 182 void pio_write_16(ioport16_t *reg, uint16_t val) 183 { 184 pio_trace_log(reg, val, true); 185 arch_pio_write_16(reg, val); 186 } 187 188 void pio_write_32(ioport32_t *reg, uint32_t val) 189 { 190 pio_trace_log(reg, val, true); 191 arch_pio_write_32(reg, val); 192 } 193 194 uint8_t pio_read_8(const ioport8_t *reg) 195 { 196 const uint8_t val = arch_pio_read_8(reg); 197 pio_trace_log(reg, val, false); 198 return val; 199 } 200 201 uint16_t pio_read_16(const ioport16_t *reg) 202 { 203 const uint16_t val = arch_pio_read_16(reg); 204 pio_trace_log(reg, val, false); 205 return val; 206 } 207 208 uint32_t pio_read_32(const ioport32_t *reg) 209 { 210 const uint32_t val = arch_pio_read_32(reg); 211 pio_trace_log(reg, val, false); 212 return val; 213 } 214 168 215 /** Register IRQ notification. 169 216 * -
uspace/lib/c/generic/fibril.c
r5d230a30 r69146b93 37 37 #include <fibril.h> 38 38 #include <thread.h> 39 #include <stack.h> 39 40 #include <tls.h> 40 41 #include <malloc.h> 42 #include <abi/mm/as.h> 43 #include <as.h> 41 44 #include <unistd.h> 42 45 #include <stdio.h> … … 46 49 #include <assert.h> 47 50 #include <async.h> 48 49 #ifndef FIBRIL_INITIAL_STACK_PAGES_NO50 #define FIBRIL_INITIAL_STACK_PAGES_NO 151 #endif52 51 53 52 /** … … 195 194 * stack member filled. 196 195 */ 197 free(stack);196 as_area_destroy(stack); 198 197 } 199 198 fibril_teardown(srcf->clean_after_me); … … 269 268 return 0; 270 269 271 fibril->stack = 272 (char *) malloc(FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize()); 273 if (!fibril->stack) { 270 size_t stack_size = stack_size_get(); 271 fibril->stack = as_area_create((void *) -1, stack_size, 272 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD | 273 AS_AREA_LATE_RESERVE); 274 if (fibril->stack == (void *) -1) { 274 275 fibril_teardown(fibril); 275 276 return 0; … … 281 282 context_save(&fibril->ctx); 282 283 context_set(&fibril->ctx, FADDR(fibril_main), fibril->stack, 283 FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize(), fibril->tcb);284 stack_size, fibril->tcb); 284 285 285 286 return (fid_t) fibril; … … 298 299 fibril_t *fibril = (fibril_t *) fid; 299 300 300 free(fibril->stack);301 as_area_destroy(fibril->stack); 301 302 fibril_teardown(fibril); 302 303 } -
uspace/lib/c/generic/malloc.c
r5d230a30 r69146b93 289 289 size_t asize = ALIGN_UP(size, PAGE_SIZE); 290 290 void *astart = as_area_create(AS_AREA_ANY, asize, 291 AS_AREA_WRITE | AS_AREA_READ );291 AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE); 292 292 if (astart == AS_MAP_FAILED) 293 293 return false; -
uspace/lib/c/generic/stack.c
r5d230a30 r69146b93 1 1 /* 2 * Copyright (c) 201 1 Martin Sucha2 * Copyright (c) 2012 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup lib ext229 /** @addtogroup libc 30 30 * @{ 31 31 */ 32 /** 33 * @file 32 /** @file 34 33 */ 35 34 36 #i fndef LIBEXT2_LIBEXT2_BLOCK_GROUP_H_37 # define LIBEXT2_LIBEXT2_BLOCK_GROUP_H_35 #include <stack.h> 36 #include <sysinfo.h> 38 37 39 #include <block.h> 38 size_t stack_size_get(void) 39 { 40 static sysarg_t stack_size = 0; 40 41 41 typedef struct ext2_block_group { 42 uint32_t block_bitmap_block; // Block ID for block bitmap 43 uint32_t inode_bitmap_block; // Block ID for inode bitmap 44 uint32_t inode_table_first_block; // Block ID of first block of inode table 45 uint16_t free_block_count; // Count of free blocks 46 uint16_t free_inode_count; // Count of free inodes 47 uint16_t directory_inode_count; // Number of inodes allocated to directories 48 } ext2_block_group_t; 42 if (!stack_size) 43 sysinfo_get_value("default.stack_size", &stack_size); 49 44 50 typedef struct ext2_block_group_ref { 51 block_t *block; // Reference to a block containing this block group descr 52 ext2_block_group_t *block_group; 53 } ext2_block_group_ref_t; 54 55 #define EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE 32 56 57 extern uint32_t ext2_block_group_get_block_bitmap_block(ext2_block_group_t *); 58 extern uint32_t ext2_block_group_get_inode_bitmap_block(ext2_block_group_t *); 59 extern uint32_t ext2_block_group_get_inode_table_first_block(ext2_block_group_t *); 60 extern uint16_t ext2_block_group_get_free_block_count(ext2_block_group_t *); 61 extern uint16_t ext2_block_group_get_free_inode_count(ext2_block_group_t *); 62 extern uint16_t ext2_block_group_get_directory_inode_count(ext2_block_group_t *); 63 64 extern void ext2_block_group_set_free_block_count(ext2_block_group_t *, uint16_t); 65 66 #endif 45 return (size_t) stack_size; 46 } 67 47 68 48 /** @} -
uspace/lib/c/generic/thread.c
r5d230a30 r69146b93 39 39 #include <abi/proc/uarg.h> 40 40 #include <fibril.h> 41 #include <stack.h> 41 42 #include <str.h> 42 43 #include <async.h> … … 44 45 #include <as.h> 45 46 #include "private/thread.h" 46 47 #ifndef THREAD_INITIAL_STACK_PAGES48 #define THREAD_INITIAL_STACK_PAGES 249 #endif50 47 51 48 /** Main thread function. … … 101 98 return ENOMEM; 102 99 103 size_t stack_size = getpagesize() * THREAD_INITIAL_STACK_PAGES;100 size_t stack_size = stack_size_get(); 104 101 void *stack = as_area_create(AS_AREA_ANY, stack_size, 105 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE); 102 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD | 103 AS_AREA_LATE_RESERVE); 106 104 if (stack == AS_MAP_FAILED) { 107 105 free(uarg);
Note:
See TracChangeset
for help on using the changeset viewer.
