Changeset 03362fbd in mainline for uspace/lib/c/generic/device
- Timestamp:
- 2013-02-09T23:14:45Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 22dfd38
- Parents:
- b5d2e57 (diff), 005b765 (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/device
- Files:
-
- 2 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/device/clock_dev.c
rb5d2e57 r03362fbd 1 1 /* 2 * Copyright (c) 2007 Michal Kebrt 3 * Copyright (c) 2009 Vineeth Pillai 2 * Copyright (c) 2012 Maurizio Lombardi 4 3 * All rights reserved. 5 4 * … … 28 27 */ 29 28 30 /** @addtogroup arm32gxemul GXemul 31 * @brief GXemul machine specific parts. 32 * @ingroup arm32 29 /** @addtogroup libc 33 30 * @{ 34 31 */ 35 32 /** @file 36 * @brief GXemul peripheries drivers declarations.37 33 */ 38 34 39 #ifndef KERN_arm32_testarm_H_ 40 #define KERN_arm32_testarm_H_ 35 #include <ipc/dev_iface.h> 36 #include <device/clock_dev.h> 37 #include <errno.h> 38 #include <async.h> 39 #include <time.h> 41 40 42 #include <arch/machine_func.h> 41 /** Read the current time from the device 42 * 43 * @param sess Session of the device 44 * @param t The current time that will be read from the device 45 * 46 * @return EOK on success or a negative error code 47 */ 48 int 49 clock_dev_time_get(async_sess_t *sess, struct tm *t) 50 { 51 aid_t req; 52 int ret; 43 53 44 /** Size of GXemul IRQ number range (starting from 0) */ 45 #define GXEMUL_IRQ_COUNT 32 46 #define GXEMUL_KBD_IRQ 2 47 #define GXEMUL_TIMER_IRQ 4 54 async_exch_t *exch = async_exchange_begin(sess); 48 55 49 /** Timer frequency */ 50 #define GXEMUL_TIMER_FREQ 100 56 req = async_send_1(exch, DEV_IFACE_ID(CLOCK_DEV_IFACE), 57 CLOCK_DEV_TIME_GET, NULL); 58 ret = async_data_read_start(exch, t, sizeof(*t)); 51 59 52 #define GXEMUL_KBD_ADDRESS 0x10000000 53 #define GXEMUL_MP_ADDRESS 0x11000000 54 #define GXEMUL_FB_ADDRESS 0x12000000 55 #define GXEMUL_RTC_ADDRESS 0x15000000 56 #define GXEMUL_IRQC_ADDRESS 0x16000000 60 async_exchange_end(exch); 57 61 58 extern void *gxemul_kbd; 59 extern void *gxemul_rtc; 60 extern void *gxemul_irqc; 62 sysarg_t rc; 63 if (ret != EOK) { 64 async_forget(req); 65 return ret; 66 } 61 67 62 #define GXEMUL_HALT_OFFSET 0x010 63 #define GXEMUL_RTC_FREQ_OFFSET 0x100 64 #define GXEMUL_MP_MEMSIZE_OFFSET 0x090 65 #define GXEMUL_RTC_ACK_OFFSET 0x110 68 async_wait_for(req, &rc); 69 return (int)rc; 70 } 66 71 67 extern void gxemul_init(void); 68 extern void gxemul_output_init(void); 69 extern void gxemul_input_init(void); 70 extern void gxemul_timer_irq_start(void); 71 extern void gxemul_cpu_halt(void); 72 extern void gxemul_irq_exception(unsigned int, istate_t *); 73 extern void gxemul_get_memory_extents(uintptr_t *, size_t *); 74 extern void gxemul_frame_init(void); 75 extern size_t gxemul_get_irq_count(void); 76 extern const char *gxemul_get_platform_name(void); 72 /** Set the current time 73 * 74 * @param sess Session of the device 75 * @param t The current time that will be written to the device 76 * 77 * @return EOK on success or a negative error code 78 */ 79 int 80 clock_dev_time_set(async_sess_t *sess, struct tm *t) 81 { 82 aid_t req; 83 int ret; 77 84 78 extern struct arm_machine_ops gxemul_machine_ops;85 async_exch_t *exch = async_exchange_begin(sess); 79 86 80 #endif 87 req = async_send_1(exch, DEV_IFACE_ID(CLOCK_DEV_IFACE), 88 CLOCK_DEV_TIME_SET, NULL); 89 ret = async_data_write_start(exch, t, sizeof(*t)); 90 91 async_exchange_end(exch); 92 93 sysarg_t rc; 94 if (ret != EOK) { 95 async_forget(req); 96 return ret; 97 } 98 99 async_wait_for(req, &rc); 100 return (int)rc; 101 } 81 102 82 103 /** @} 83 104 */ 105
Note:
See TracChangeset
for help on using the changeset viewer.