Changeset 8b863a62 in mainline for uspace/lib/c/generic/corecfg.c
- Timestamp:
- 2014-04-16T17:14:06Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f857e8b
- Parents:
- dba3e2c (diff), 70b570c (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/corecfg.c
rdba3e2c r8b863a62 1 1 /* 2 * Copyright (c) 201 2 Maurizio Lombardi2 * Copyright (c) 2013 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc 30 * @{ 31 */ 32 /** @file 33 */ 29 #include <async.h> 30 #include <assert.h> 31 #include <corecfg.h> 32 #include <errno.h> 33 #include <ipc/corecfg.h> 34 #include <ipc/services.h> 35 #include <loc.h> 36 #include <stdlib.h> 34 37 35 #include <ipc/dev_iface.h> 36 #include <device/battery_dev.h> 37 #include <errno.h> 38 #include <async.h> 39 #include <time.h> 38 static async_sess_t *corecfg_sess = NULL; 40 39 41 /** Read the current battery status from the device 42 * 43 * @param sess Session of the device 44 * @param status Current status of the battery 45 * 46 * @return EOK on success or a negative error code 47 */ 48 int 49 battery_status_get(async_sess_t *sess, battery_status_t *batt_status) 40 int corecfg_init(void) 50 41 { 51 sysarg_t status; 42 service_id_t corecfg_svc; 43 int rc; 52 44 53 as ync_exch_t *exch = async_exchange_begin(sess);45 assert(corecfg_sess == NULL); 54 46 55 int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE), 56 BATTERY_STATUS_GET, &status); 47 rc = loc_service_get_id(SERVICE_NAME_CORECFG, &corecfg_svc, 48 IPC_FLAG_BLOCKING); 49 if (rc != EOK) 50 return ENOENT; 51 52 corecfg_sess = loc_service_connect(EXCHANGE_SERIALIZE, corecfg_svc, 53 IPC_FLAG_BLOCKING); 54 if (corecfg_sess == NULL) 55 return ENOENT; 56 57 return EOK; 58 } 59 60 /** Get core dump enable status. */ 61 int corecfg_get_enable(bool *renable) 62 { 63 async_exch_t *exch = async_exchange_begin(corecfg_sess); 64 sysarg_t enable; 65 66 int rc = async_req_0_1(exch, CORECFG_GET_ENABLE, &enable); 57 67 58 68 async_exchange_end(exch); 59 69 60 if (rc == EOK)61 *batt_status = (battery_status_t) status;70 if (rc != EOK) 71 return rc; 62 72 63 return rc; 73 *renable = enable; 74 return EOK; 64 75 } 65 76 66 /** Read the current battery charge level from the device 67 * 68 * @param sess Session of the device 69 * @param level Battery charge level (0 - 100) 70 * 71 * @return EOK on success or a negative error code 72 */ 73 int 74 battery_charge_level_get(async_sess_t *sess, int *level) 77 /** Enable or disable core dumps. */ 78 int corecfg_set_enable(bool enable) 75 79 { 76 sysarg_t charge_level; 77 78 async_exch_t *exch = async_exchange_begin(sess); 79 80 int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE), 81 BATTERY_CHARGE_LEVEL_GET, &charge_level); 80 async_exch_t *exch = async_exchange_begin(corecfg_sess); 81 int rc = async_req_1_0(exch, CORECFG_SET_ENABLE, (sysarg_t) enable); 82 82 83 83 async_exchange_end(exch); 84 84 85 if (rc == EOK)86 *level = (int) charge_level;85 if (rc != EOK) 86 return rc; 87 87 88 return rc;88 return EOK; 89 89 } 90 90 91 91 /** @} 92 92 */ 93
Note:
See TracChangeset
for help on using the changeset viewer.