Changeset ea15a89a in mainline for uspace/lib/c
- Timestamp:
- 2013-04-29T14:26:22Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 533e2d7, 94dfb92
- Parents:
- b2fa2d86 (diff), 9e7898e (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
- Files:
-
- 1 added
- 11 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/ia32/src/setjmp.S
rb2fa2d86 rea15a89a 35 35 .type setjmp,@function 36 36 setjmp: 37 movl 0(%esp),%eax # save pc value into eax38 movl 4(%esp),%edx # address of the jmp_buf structure to save context to39 40 37 movl 0(%esp),%eax # save pc value into eax 38 movl 4(%esp),%edx # address of the jmp_buf structure to save context to 39 40 # save registers to the jmp_buf structure 41 41 CONTEXT_SAVE_ARCH_CORE %edx %eax 42 43 xorl %eax,%eax 42 43 xorl %eax,%eax # set_jmp returns 0 44 44 ret 45 45 46 46 .type longjmp,@function 47 47 longjmp: 48 49 movl 4(%esp), %ecx # put address of jmp_buf into ecx 50 movl 8(%esp), %eax # put return value into eax 51 52 # restore registers from the jmp_buf structure 48 movl 4(%esp), %ecx # put address of jmp_buf into ecx 49 movl 8(%esp), %eax # put return value into eax 50 51 # restore registers from the jmp_buf structure 53 52 CONTEXT_RESTORE_ARCH_CORE %ecx %edx 54 55 movl %edx,0(%esp) 53 54 movl %edx,0(%esp) # put saved pc on stack 56 55 ret 57 -
uspace/lib/c/generic/adt/hash_table.c
rb2fa2d86 rea15a89a 81 81 * @param init_size Initial desired number of hash table buckets. Pass zero 82 82 * if you want the default initial size. 83 * @param max_keys Maximal number of keys needed to identify an item. 83 * @param max_load The table is resized when the average load per bucket 84 * exceeds this number. Pass zero if you want the default. 84 85 * @param op Hash table operations structure. remove_callback() 85 86 * is optional and can be NULL if no action is to be taken -
uspace/lib/c/generic/async.c
rb2fa2d86 rea15a89a 2090 2090 * @param arg User defined argument. 2091 2091 * @param flags Storage for the received flags. Can be NULL. 2092 * @param dst Destination address space area base. Cannot be NULL. 2092 * @param dst Address of the storage for the destination address space area 2093 * base address. Cannot be NULL. 2093 2094 * 2094 2095 * @return Zero on success or a negative error code from errno.h. … … 2218 2219 * 2219 2220 * @param callid Hash of the IPC_M_DATA_WRITE call to answer. 2220 * @param dst Destination address space area base address. 2221 * @param dst Address of the storage for the destination address space area 2222 * base address. 2221 2223 * 2222 2224 * @return Zero on success or a value from @ref errno.h on failure. -
uspace/lib/c/generic/io/con_srv.c
rb2fa2d86 rea15a89a 35 35 */ 36 36 #include <errno.h> 37 #include <io/cons_event.h> 37 38 #include <ipc/console.h> 38 39 #include <stdlib.h> … … 40 41 41 42 #include <io/con_srv.h> 43 44 static int console_ev_encode(cons_event_t *event, ipc_call_t *call) 45 { 46 IPC_SET_ARG1(*call, event->type); 47 48 switch (event->type) { 49 case CEV_KEY: 50 IPC_SET_ARG2(*call, event->ev.key.type); 51 IPC_SET_ARG3(*call, event->ev.key.key); 52 IPC_SET_ARG4(*call, event->ev.key.mods); 53 IPC_SET_ARG5(*call, event->ev.key.c); 54 break; 55 case CEV_POS: 56 IPC_SET_ARG2(*call, (event->ev.pos.pos_id << 16) | (event->ev.pos.type & 0xffff)); 57 IPC_SET_ARG3(*call, event->ev.pos.btn_num); 58 IPC_SET_ARG4(*call, event->ev.pos.hpos); 59 IPC_SET_ARG5(*call, event->ev.pos.vpos); 60 break; 61 default: 62 return EIO; 63 } 64 65 return EOK; 66 } 42 67 43 68 static void con_read_srv(con_srv_t *srv, ipc_callid_t callid, … … 273 298 { 274 299 int rc; 275 kbd_event_t event; 300 cons_event_t event; 301 ipc_call_t result; 276 302 277 303 if (srv->srvs->ops->get_event == NULL) { … … 281 307 282 308 rc = srv->srvs->ops->get_event(srv, &event); 283 async_answer_4(callid, rc, event.type, event.key, event.mods, event.c); 309 if (rc != EOK) { 310 async_answer_0(callid, rc); 311 return; 312 } 313 314 rc = console_ev_encode(&event, &result); 315 if (rc != EOK) { 316 async_answer_0(callid, rc); 317 return; 318 } 319 320 async_answer_5(callid, rc, IPC_GET_ARG1(result), IPC_GET_ARG2(result), 321 IPC_GET_ARG3(result), IPC_GET_ARG4(result), IPC_GET_ARG5(result)); 284 322 } 285 323 -
uspace/lib/c/generic/io/console.c
rb2fa2d86 rea15a89a 154 154 } 155 155 156 bool console_get_kbd_event(console_ctrl_t *ctrl, kbd_event_t *event) 156 static int console_ev_decode(ipc_call_t *call, cons_event_t *event) 157 { 158 event->type = IPC_GET_ARG1(*call); 159 160 switch (event->type) { 161 case CEV_KEY: 162 event->ev.key.type = IPC_GET_ARG2(*call); 163 event->ev.key.key = IPC_GET_ARG3(*call); 164 event->ev.key.mods = IPC_GET_ARG4(*call); 165 event->ev.key.c = IPC_GET_ARG5(*call); 166 break; 167 case CEV_POS: 168 event->ev.pos.pos_id = IPC_GET_ARG2(*call) >> 16; 169 event->ev.pos.type = IPC_GET_ARG2(*call) & 0xffff; 170 event->ev.pos.btn_num = IPC_GET_ARG3(*call); 171 event->ev.pos.hpos = IPC_GET_ARG4(*call); 172 event->ev.pos.vpos = IPC_GET_ARG5(*call); 173 break; 174 default: 175 return EIO; 176 } 177 178 return EOK; 179 } 180 181 bool console_get_event(console_ctrl_t *ctrl, cons_event_t *event) 157 182 { 158 183 if (ctrl->input_aid == 0) { 159 sysarg_t type; 160 sysarg_t key; 161 sysarg_t mods; 162 sysarg_t c; 184 ipc_call_t result; 163 185 164 186 async_exch_t *exch = async_exchange_begin(ctrl->input_sess); 165 int rc = async_req_0_4(exch, CONSOLE_GET_EVENT, &type, &key, &mods, &c);187 aid_t aid = async_send_0(exch, CONSOLE_GET_EVENT, &result); 166 188 async_exchange_end(exch); 189 190 sysarg_t rc; 191 async_wait_for(aid, &rc); 167 192 168 193 if (rc != EOK) { … … 171 196 } 172 197 173 event->type = type; 174 event->key = key; 175 event->mods = mods; 176 event->c = c; 198 rc = console_ev_decode(&result, event); 199 if (rc != EOK) { 200 errno = rc; 201 return false; 202 } 177 203 } else { 178 204 sysarg_t retval; … … 186 212 } 187 213 188 event->type = IPC_GET_ARG1(ctrl->input_call); 189 event->key = IPC_GET_ARG2(ctrl->input_call); 190 event->mods = IPC_GET_ARG3(ctrl->input_call); 191 event->c = IPC_GET_ARG4(ctrl->input_call); 214 int rc = console_ev_decode(&ctrl->input_call, event); 215 if (rc != EOK) { 216 errno = rc; 217 return false; 218 } 192 219 } 193 220 … … 195 222 } 196 223 197 bool console_get_ kbd_event_timeout(console_ctrl_t *ctrl, kbd_event_t *event,224 bool console_get_event_timeout(console_ctrl_t *ctrl, cons_event_t *event, 198 225 suseconds_t *timeout) 199 226 { … … 223 250 } 224 251 225 event->type = IPC_GET_ARG1(ctrl->input_call); 226 event->key = IPC_GET_ARG2(ctrl->input_call); 227 event->mods = IPC_GET_ARG3(ctrl->input_call); 228 event->c = IPC_GET_ARG4(ctrl->input_call); 252 rc = console_ev_decode(&ctrl->input_call, event); 253 if (rc != EOK) { 254 errno = rc; 255 return false; 256 } 229 257 230 258 /* Update timeout */ -
uspace/lib/c/include/io/con_srv.h
rb2fa2d86 rea15a89a 41 41 #include <io/color.h> 42 42 #include <io/concaps.h> 43 #include <io/ kbd_event.h>43 #include <io/cons_event.h> 44 44 #include <io/pixel.h> 45 45 #include <io/style.h> … … 82 82 void (*set_rgb_color)(con_srv_t *, pixel_t, pixel_t); 83 83 void (*set_cursor_visibility)(con_srv_t *, bool); 84 int (*get_event)(con_srv_t *, kbd_event_t *);84 int (*get_event)(con_srv_t *, cons_event_t *); 85 85 } con_ops_t; 86 86 -
uspace/lib/c/include/io/console.h
rb2fa2d86 rea15a89a 39 39 #include <io/concaps.h> 40 40 #include <io/kbd_event.h> 41 #include <io/cons_event.h> 41 42 #include <io/keycode.h> 42 43 #include <async.h> … … 82 83 extern void console_cursor_visibility(console_ctrl_t *, bool); 83 84 extern int console_get_color_cap(console_ctrl_t *, sysarg_t *); 84 extern bool console_get_ kbd_event(console_ctrl_t *, kbd_event_t *);85 extern bool console_get_ kbd_event_timeout(console_ctrl_t *, kbd_event_t *,85 extern bool console_get_event(console_ctrl_t *, cons_event_t *); 86 extern bool console_get_event_timeout(console_ctrl_t *, cons_event_t *, 86 87 suseconds_t *); 87 88 -
uspace/lib/c/include/io/pos_event.h
rb2fa2d86 rea15a89a 1 1 /* 2 * Copyright (c) 2008 Martin Decky 2 * Copyright (c) 2012 Petr Koupy 3 * Copyright (c) 2013 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 27 28 */ 28 29 29 /** @addtogroup genarch30 /** @addtogroup libc 30 31 * @{ 31 32 */ … … 33 34 */ 34 35 35 #ifndef KERN_LOGO_196X66_H_36 #define KERN_LOGO_196X66_H_36 #ifndef LIBC_IO_POS_EVENT_H_ 37 #define LIBC_IO_POS_EVENT_H_ 37 38 38 #define LOGO_WIDTH 196 39 #define LOGO_HEIGHT 66 40 #define LOGO_COLOR 0xffffff 39 #include <sys/types.h> 41 40 42 #include <typedefs.h> 41 typedef enum { 42 POS_UPDATE, 43 POS_PRESS, 44 POS_RELEASE 45 } pos_event_type_t; 43 46 44 extern uint32_t fb_logo[LOGO_WIDTH * LOGO_HEIGHT]; 47 /** Positioning device event */ 48 typedef struct { 49 sysarg_t pos_id; 50 pos_event_type_t type; 51 sysarg_t btn_num; 52 sysarg_t hpos; 53 sysarg_t vpos; 54 } pos_event_t; 45 55 46 56 #endif -
uspace/lib/c/include/io/window.h
rb2fa2d86 rea15a89a 40 40 #include <async.h> 41 41 #include <loc.h> 42 #include <io/console.h> 43 44 typedef enum { 45 POS_UPDATE, 46 POS_PRESS, 47 POS_RELEASE 48 } pos_event_type_t; 49 50 typedef struct { 51 sysarg_t pos_id; 52 pos_event_type_t type; 53 sysarg_t btn_num; 54 sysarg_t hpos; 55 sysarg_t vpos; 56 } pos_event_t; 42 #include <io/kbd_event.h> 43 #include <io/pos_event.h> 57 44 58 45 typedef struct { -
uspace/lib/c/include/mem.h
rb2fa2d86 rea15a89a 40 40 #define bzero(ptr, len) memset((ptr), 0, (len)) 41 41 42 extern void *memset(void *, int, size_t); 43 extern void *memcpy(void *, const void *, size_t); 42 extern void *memset(void *, int, size_t) 43 __attribute__ ((optimize("-fno-tree-loop-distribute-patterns"))); 44 extern void *memcpy(void *, const void *, size_t) 45 __attribute__ ((optimize("-fno-tree-loop-distribute-patterns"))); 44 46 extern void *memmove(void *, const void *, size_t); 45 47 -
uspace/lib/c/include/setjmp.h
rb2fa2d86 rea15a89a 38 38 #include <libarch/fibril.h> 39 39 40 typedef context_t jmp_buf ;40 typedef context_t jmp_buf[1]; 41 41 42 42 extern int setjmp(jmp_buf env); … … 47 47 /** @} 48 48 */ 49 -
uspace/lib/c/include/sys/types.h
rb2fa2d86 rea15a89a 50 50 typedef volatile uint32_t ioport32_t; 51 51 52 typedef int16_t unaligned_int16_t __attribute__ ((aligned(1))); 53 typedef int32_t unaligned_int32_t __attribute__ ((aligned(1))); 54 typedef int64_t unaligned_int64_t __attribute__ ((aligned(1))); 55 56 typedef uint16_t unaligned_uint16_t __attribute__ ((aligned(1))); 57 typedef uint32_t unaligned_uint32_t __attribute__ ((aligned(1))); 58 typedef uint64_t unaligned_uint64_t __attribute__ ((aligned(1))); 59 52 60 #endif 53 61
Note:
See TracChangeset
for help on using the changeset viewer.