Changeset 8b863a62 in mainline for uspace/lib/c/generic/corecfg.c


Ignore:
Timestamp:
2014-04-16T17:14:06Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
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.
Message:

Merge mainline changes

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/corecfg.c

    rdba3e2c r8b863a62  
    11/*
    2  * Copyright (c) 2012 Maurizio Lombardi
     2 * Copyright (c) 2013 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    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>
    3437
    35 #include <ipc/dev_iface.h>
    36 #include <device/battery_dev.h>
    37 #include <errno.h>
    38 #include <async.h>
    39 #include <time.h>
     38static async_sess_t *corecfg_sess = NULL;
    4039
    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)
     40int corecfg_init(void)
    5041{
    51         sysarg_t status;
     42        service_id_t corecfg_svc;
     43        int rc;
    5244
    53         async_exch_t *exch = async_exchange_begin(sess);
     45        assert(corecfg_sess == NULL);
    5446
    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. */
     61int 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);
    5767
    5868        async_exchange_end(exch);
    5969
    60         if (rc == EOK)
    61                 *batt_status = (battery_status_t) status;
     70        if (rc != EOK)
     71                return rc;
    6272
    63         return rc;
     73        *renable = enable;
     74        return EOK;
    6475}
    6576
    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. */
     78int corecfg_set_enable(bool enable)
    7579{
    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);
    8282
    8383        async_exchange_end(exch);
    8484
    85         if (rc == EOK)
    86                 *level = (int) charge_level;
     85        if (rc != EOK)
     86                return rc;
    8787
    88         return rc;
     88        return EOK;
    8989}
    9090
    9191/** @}
    9292 */
    93 
Note: See TracChangeset for help on using the changeset viewer.