- Timestamp:
- 2006-12-09T20:20:50Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b82a13c
- Parents:
- 9ab9c2ec
- Location:
- uspace
- Files:
-
- 1 added
- 17 edited
-
fb/ega.c (modified) (4 diffs)
-
fb/fb.c (modified) (3 diffs)
-
fb/main.c (modified) (1 diff)
-
klog/klog.c (modified) (1 diff)
-
libc/arch/amd64/include/config.h (modified) (1 diff)
-
libc/arch/ia32/include/config.h (modified) (1 diff)
-
libc/arch/ia64/include/config.h (modified) (1 diff)
-
libc/arch/mips32/include/config.h (modified) (1 diff)
-
libc/arch/ppc32/include/config.h (modified) (1 diff)
-
libc/arch/ppc64/include/config.h (modified) (1 diff)
-
libc/arch/sparc64/include/config.h (modified) (1 diff)
-
libc/generic/as.c (modified) (5 diffs)
-
libc/generic/mman.c (modified) (1 diff)
-
libc/generic/time.c (modified) (2 diffs)
-
libc/include/as.h (modified) (2 diffs)
-
libc/include/bitops.h (added)
-
ns/ns.c (modified) (2 diffs)
-
rd/rd.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/fb/ega.c
r9ab9c2ec rf8ddd17 35 35 */ 36 36 37 38 37 #include <stdlib.h> 39 38 #include <unistd.h> … … 63 62 saved_screen saved_screens[MAX_SAVED_SCREENS]; 64 63 65 66 64 #define EGA_IO_ADDRESS 0x3d4 67 65 #define EGA_IO_SIZE 2 … … 127 125 int i; 128 126 if (rows > 0) { 129 memcpy (scr_addr,((char *)scr_addr) + rows * scr_width * 2, scr_width * scr_height * 2 - rows * scr_width * 2); 127 memcpy (scr_addr,((char *)scr_addr) + rows * scr_width * 2, 128 scr_width * scr_height * 2 - rows * scr_width * 2); 130 129 for (i = 0; i < rows * scr_width ; i ++) 131 (((short *)scr_addr) + scr_width * scr_height - rows * scr_width) [i] = ((style << 8) + ' '); 130 (((short *)scr_addr) + scr_width * scr_height - rows * 131 scr_width) [i] = ((style << 8) + ' '); 132 132 } else if (rows < 0) { 133 134 memcpy (((char *)scr_addr) - rows * scr_width * 2 ,scr_addr ,scr_width * scr_height * 2 + rows * scr_width * 2);133 memcpy (((char *)scr_addr) - rows * scr_width * 2, scr_addr, 134 scr_width * scr_height * 2 + rows * scr_width * 2); 135 135 for (i = 0; i < - rows * scr_width ; i++) 136 136 ((short *)scr_addr) [i] = ((style << 8 ) + ' '); … … 309 309 scr_width=sysinfo_value("fb.width"); 310 310 scr_height=sysinfo_value("fb.height"); 311 iospace_enable(task_get_id(),(void *)EGA_IO_ADDRESS,2); 312 313 sz = scr_width*scr_height*2; 314 scr_addr = as_get_mappable_page(sz); 315 316 physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >> PAGE_WIDTH, 317 AS_AREA_READ | AS_AREA_WRITE); 311 iospace_enable(task_get_id(), (void *) EGA_IO_ADDRESS, 2); 312 313 sz = scr_width * scr_height * 2; 314 scr_addr = as_get_mappable_page(sz, (int) 315 sysinfo_value("fb.address.color")); 316 317 physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >> 318 PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); 318 319 319 320 async_set_client_connection(ega_client_connection); -
uspace/fb/fb.c
r9ab9c2ec rf8ddd17 705 705 /* We accept one area for data interchange */ 706 706 if (IPC_GET_ARG1(*call) == shm_id) { 707 void *dest = as_get_mappable_page(IPC_GET_ARG2(*call)); 707 void *dest = as_get_mappable_page(IPC_GET_ARG2(*call), 708 PAGE_COLOR(IPC_GET_ARG1(*call))); 708 709 shm_size = IPC_GET_ARG2(*call); 709 if (!ipc_answer_fast(callid, 0, (sysarg_t) dest, 0))710 if (!ipc_answer_fast(callid, 0, (sysarg_t) dest, 0)) 710 711 shm = dest; 711 712 else … … 717 718 } else { 718 719 intersize = IPC_GET_ARG2(*call); 719 receive_comm_area(callid, call,(void *)&interbuffer);720 receive_comm_area(callid, call, (void *) &interbuffer); 720 721 } 721 722 return 1; … … 1283 1284 1284 1285 asz = fb_scanline * fb_height; 1285 fb_addr = as_get_mappable_page(asz );1286 fb_addr = as_get_mappable_page(asz, (int) sysinfo_value("fb.address.color")); 1286 1287 1287 1288 physmem_map(fb_ph_addr, fb_addr, ALIGN_UP(asz, PAGE_SIZE) >> PAGE_WIDTH, 1288 1289 AS_AREA_READ | AS_AREA_WRITE); 1289 1290 1290 if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual, fb_invert_colors)) 1291 if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual, 1292 fb_invert_colors)) 1291 1293 return 0; 1292 1294 -
uspace/fb/main.c
r9ab9c2ec rf8ddd17 44 44 void *dest; 45 45 46 dest = as_get_mappable_page(IPC_GET_ARG2(*call)); 46 dest = as_get_mappable_page(IPC_GET_ARG2(*call), 47 PAGE_COLOR(IPC_GET_ARG1(*call))); 47 48 if (ipc_answer_fast(callid, 0, (sysarg_t)dest, 0) == 0) { 48 49 if (*area) -
uspace/klog/klog.c
r9ab9c2ec rf8ddd17 64 64 printf("Kernel console output.\n"); 65 65 66 mapping = as_get_mappable_page(PAGE_SIZE );66 mapping = as_get_mappable_page(PAGE_SIZE, sysinfo_value("klog.fcolor")); 67 67 res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, 68 (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_KLOG,69 NULL, NULL,NULL);68 (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_KLOG, 69 NULL, NULL, NULL); 70 70 if (res) { 71 71 printf("Failed to initialize klog memarea\n"); -
uspace/libc/arch/amd64/include/config.h
r9ab9c2ec rf8ddd17 38 38 #define PAGE_WIDTH 12 39 39 #define PAGE_SIZE (1<<PAGE_WIDTH) 40 #define PAGE_COLOR_BITS 0 /* dummy */ 40 41 41 42 #endif -
uspace/libc/arch/ia32/include/config.h
r9ab9c2ec rf8ddd17 38 38 #define PAGE_WIDTH 12 39 39 #define PAGE_SIZE (1<<PAGE_WIDTH) 40 #define PAGE_COLOR_BITS 0 /* dummy */ 40 41 41 42 #endif -
uspace/libc/arch/ia64/include/config.h
r9ab9c2ec rf8ddd17 38 38 #define PAGE_WIDTH 14 39 39 #define PAGE_SIZE (1<<PAGE_WIDTH) 40 #define PAGE_COLOR_BITS 0 /* dummy */ 40 41 41 42 #endif -
uspace/libc/arch/mips32/include/config.h
r9ab9c2ec rf8ddd17 38 38 #define PAGE_WIDTH 14 39 39 #define PAGE_SIZE (1<<PAGE_WIDTH) 40 #define PAGE_COLOR_BITS 0 /* dummy */ 40 41 41 42 #endif -
uspace/libc/arch/ppc32/include/config.h
r9ab9c2ec rf8ddd17 38 38 #define PAGE_WIDTH 12 39 39 #define PAGE_SIZE (1<<PAGE_WIDTH) 40 #define PAGE_COLOR_BITS 0 /* dummy */ 40 41 41 42 #endif -
uspace/libc/arch/ppc64/include/config.h
r9ab9c2ec rf8ddd17 38 38 #define PAGE_WIDTH 12 39 39 #define PAGE_SIZE (1<<PAGE_WIDTH) 40 #define PAGE_COLOR_BITS 0 /* dummy */ 40 41 41 42 #endif -
uspace/libc/arch/sparc64/include/config.h
r9ab9c2ec rf8ddd17 38 38 #define PAGE_WIDTH 13 39 39 #define PAGE_SIZE (1<<PAGE_WIDTH) 40 #define PAGE_COLOR_BITS 1 /**< Bit 13 is the page color. */ 40 41 41 42 #endif -
uspace/libc/generic/as.c
r9ab9c2ec rf8ddd17 38 38 #include <align.h> 39 39 #include <types.h> 40 #include <bitops.h> 40 41 41 42 /** … … 54 55 void *as_area_create(void *address, size_t size, int flags) 55 56 { 56 return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t ) address, (sysarg_t) size, (sysarg_t) flags); 57 return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t ) address, 58 (sysarg_t) size, (sysarg_t) flags); 57 59 } 58 60 59 61 /** Resize address space area. 60 62 * 61 * @param address Virtual address pointing into already existing address space area. 63 * @param address Virtual address pointing into already existing address space 64 * area. 62 65 * @param size New requested size of the area. 63 66 * @param flags Currently unused. … … 67 70 int as_area_resize(void *address, size_t size, int flags) 68 71 { 69 return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t ) address, (sysarg_t) size, (sysarg_t) flags); 72 return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t ) address, (sysarg_t) 73 size, (sysarg_t) flags); 70 74 } 71 75 72 76 /** Destroy address space area. 73 77 * 74 * @param address Virtual address pointing into the address space area being destroyed. 78 * @param address Virtual address pointing into the address space area being 79 * destroyed. 75 80 * 76 81 * @return Zero on success or a code from @ref errno.h on failure. … … 134 139 /* Return pointer to area not managed by sbrk */ 135 140 return ((void *) &_heap + maxheapsize); 136 137 141 } 138 142 139 143 /** Return pointer to some unmapped area, where fits new as_area 140 144 * 145 * @param sz Requested size of the allocation. 146 * @param color Requested virtual color of the allocation. 147 * 148 * @return Pointer to the beginning 149 * 141 150 * TODO: make some first_fit/... algorithm, we are now just incrementing 142 151 * the pointer to last area 143 152 */ 144 void * as_get_mappable_page(size_t sz) 153 #include <stdio.h> 154 void *as_get_mappable_page(size_t sz, int color) 145 155 { 146 156 void *res; 157 uint64_t asz; 158 int i; 159 160 if (!sz) 161 return NULL; 162 163 asz = 1 << (fnzb64(sz - 1) + 1); 147 164 148 165 /* Set heapsize to some meaningful value */ … … 150 167 set_maxheapsize(MAX_HEAP_SIZE); 151 168 152 if (!last_allocated) 153 last_allocated = (void *) ALIGN_UP((void *) &_heap + maxheapsize, PAGE_SIZE); 154 155 sz = ALIGN_UP(sz, PAGE_SIZE); 169 /* 170 * Make sure we allocate from naturally aligned address and a page of 171 * appropriate color. 172 */ 173 i = 0; 174 do { 175 if (!last_allocated) { 176 last_allocated = (void *) ALIGN_UP((void *) &_heap + 177 maxheapsize, asz); 178 } else { 179 last_allocated = (void *) ALIGN_UP(((uintptr_t) 180 last_allocated) + (int) (i > 0), asz); 181 } 182 } while ((asz < (1 << (PAGE_COLOR_BITS + PAGE_WIDTH))) && 183 (PAGE_COLOR((uintptr_t) last_allocated) != color) && 184 (++i < (1 << PAGE_COLOR_BITS))); 185 156 186 res = last_allocated; 157 last_allocated += sz;187 last_allocated += ALIGN_UP(sz, PAGE_SIZE); 158 188 159 189 return res; -
uspace/libc/generic/mman.c
r9ab9c2ec rf8ddd17 40 40 { 41 41 if (!start) 42 start = as_get_mappable_page(length );42 start = as_get_mappable_page(length, 0); 43 43 44 44 // if (! ((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE))) -
uspace/libc/generic/time.c
r9ab9c2ec rf8ddd17 41 41 #include <atomic.h> 42 42 #include <futex.h> 43 #include <sysinfo.h> 43 44 #include <ipc/services.h> 44 45 … … 72 73 73 74 if (!ktime) { 74 mapping = as_get_mappable_page(PAGE_SIZE); 75 mapping = as_get_mappable_page(PAGE_SIZE, (int) 76 sysinfo_value("clock.fcolor")); 75 77 /* Get the mapping of kernel clock */ 76 res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL, &rights, NULL); 78 res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, (sysarg_t) 79 mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL, &rights, 80 NULL); 77 81 if (res) { 78 82 printf("Failed to initialize timeofday memarea\n"); -
uspace/libc/include/as.h
r9ab9c2ec rf8ddd17 40 40 #include <kernel/arch/mm/as.h> 41 41 #include <kernel/mm/as.h> 42 #include <libarch/config.h> 43 44 #define PAGE_COLOR(va) (((va) >> PAGE_WIDTH) & ((1 << PAGE_COLOR_BITS) - 1)) 42 45 43 46 extern void *as_area_create(void *address, size_t size, int flags); … … 45 48 extern int as_area_destroy(void *address); 46 49 extern void *set_maxheapsize(size_t mhs); 47 extern void * as_get_mappable_page(size_t sz );50 extern void * as_get_mappable_page(size_t sz, int color); 48 51 49 52 #endif -
uspace/ns/ns.c
r9ab9c2ec rf8ddd17 84 84 static void *klogaddr = NULL; 85 85 86 static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, void **addr)86 static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, char *colstr, void **addr) 87 87 { 88 88 void *ph_addr; 89 int ph_color; 89 90 90 91 if (!*addr) { 91 ph_addr = (void *) sysinfo_value(name);92 ph_addr = (void *) sysinfo_value(name); 92 93 if (!ph_addr) { 93 94 ipc_answer_fast(callid, ENOENT, 0, 0); 94 95 return; 95 96 } 96 *addr = as_get_mappable_page(PAGE_SIZE); 97 ph_color = (int) sysinfo_value(colstr); 98 *addr = as_get_mappable_page(PAGE_SIZE, ph_color); 97 99 physmem_map(ph_addr, *addr, 1, AS_AREA_READ | AS_AREA_CACHEABLE); 98 100 } … … 117 119 switch (IPC_GET_ARG3(call)) { 118 120 case SERVICE_MEM_REALTIME: 119 get_as_area(callid, &call, "clock.faddr", &clockaddr); 121 get_as_area(callid, &call, "clock.faddr", 122 "clock.fcolor", &clockaddr); 120 123 break; 121 124 case SERVICE_MEM_KLOG: 122 get_as_area(callid, &call, "klog.faddr", &klogaddr); 125 get_as_area(callid, &call, "klog.faddr", 126 "klog.fcolor", &klogaddr); 123 127 break; 124 128 default: -
uspace/rd/rd.c
r9ab9c2ec rf8ddd17 74 74 size_t rd_size = sysinfo_value("rd.size"); 75 75 void * rd_ph_addr = (void *) sysinfo_value("rd.address.physical"); 76 int rd_color = (int) sysinfo_value("rd.address.color"); 76 77 77 78 if (rd_size == 0) 78 79 return false; 79 80 80 void * rd_addr = as_get_mappable_page(rd_size );81 void * rd_addr = as_get_mappable_page(rd_size, rd_color); 81 82 82 83 physmem_map(rd_ph_addr, rd_addr, ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
Note:
See TracChangeset
for help on using the changeset viewer.
