| [1e19a15] | 1 | /*
|
|---|
| 2 | * Copyright (c) 2012 Maurizio Lombardi
|
|---|
| 3 | * All rights reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 6 | * modification, are permitted provided that the following conditions
|
|---|
| 7 | * are met:
|
|---|
| 8 | *
|
|---|
| 9 | * - Redistributions of source code must retain the above copyright
|
|---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 13 | * documentation and/or other materials provided with the distribution.
|
|---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 15 | * derived from this software without specific prior written permission.
|
|---|
| 16 | *
|
|---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 27 | */
|
|---|
| 28 |
|
|---|
| 29 | /**
|
|---|
| 30 | * @defgroup CMOS RTC driver.
|
|---|
| 31 | * @brief HelenOS RTC driver.
|
|---|
| 32 | * @{
|
|---|
| 33 | */
|
|---|
| 34 |
|
|---|
| 35 | /** @file
|
|---|
| 36 | */
|
|---|
| 37 |
|
|---|
| [4863bb52] | 38 | #include <errno.h>
|
|---|
| [1e19a15] | 39 | #include <ddi.h>
|
|---|
| [8fde078] | 40 | #include <as.h>
|
|---|
| 41 | #include <libarch/barrier.h>
|
|---|
| [1e19a15] | 42 | #include <stdio.h>
|
|---|
| 43 | #include <ddf/driver.h>
|
|---|
| [a2e4889] | 44 | #include <ddf/log.h>
|
|---|
| [aeef318] | 45 | #include <ops/clock_dev.h>
|
|---|
| [917797f] | 46 | #include <ops/battery_dev.h>
|
|---|
| [6b329749] | 47 | #include <fibril_synch.h>
|
|---|
| [b3db669] | 48 | #include <device/hw_res.h>
|
|---|
| [8fde078] | 49 | #include <macros.h>
|
|---|
| [83298e8] | 50 | #include <time.h>
|
|---|
| [1e19a15] | 51 |
|
|---|
| [f30ee571] | 52 | #include "cmos-regs.h"
|
|---|
| 53 |
|
|---|
| [5ef13847] | 54 | #define NAME "cmos-rtc"
|
|---|
| [1e19a15] | 55 |
|
|---|
| [0883de8] | 56 | #define REG_COUNT 2
|
|---|
| 57 |
|
|---|
| [78ca12b] | 58 | #define REG_SEL_PORT(port) (port)
|
|---|
| 59 | #define REG_RW_PORT(port) ((port) + 1)
|
|---|
| 60 |
|
|---|
| [b3db669] | 61 | typedef struct rtc {
|
|---|
| 62 | /** DDF device node */
|
|---|
| 63 | ddf_dev_t *dev;
|
|---|
| 64 | /** DDF function node */
|
|---|
| 65 | ddf_fun_t *fun;
|
|---|
| 66 | /** The fibril mutex for synchronizing the access to the device */
|
|---|
| 67 | fibril_mutex_t mutex;
|
|---|
| [c47f1b6] | 68 | /** The base I/O address of the device registers */
|
|---|
| [971f50e7] | 69 | ioport8_t *io_addr;
|
|---|
| [0883de8] | 70 | /** The I/O port used to access the CMOS registers */
|
|---|
| 71 | ioport8_t *port;
|
|---|
| [bb8f69d] | 72 | /** true if device is removed */
|
|---|
| 73 | bool removed;
|
|---|
| [9673fd3] | 74 | /** number of connected clients */
|
|---|
| 75 | int clients_connected;
|
|---|
| [60af6fc2] | 76 | /** time at which the system booted */
|
|---|
| [7f9d97f3] | 77 | struct timeval boot_time;
|
|---|
| [b3db669] | 78 | } rtc_t;
|
|---|
| 79 |
|
|---|
| [6f445a67] | 80 | static rtc_t *dev_rtc(ddf_dev_t *dev);
|
|---|
| 81 | static rtc_t *fun_rtc(ddf_fun_t *fun);
|
|---|
| [b7fd2a0] | 82 | static errno_t
|
|---|
| [efcfab9] | 83 | rtc_battery_status_get(ddf_fun_t *fun, battery_status_t *status);
|
|---|
| [b7fd2a0] | 84 | static errno_t rtc_time_get(ddf_fun_t *fun, struct tm *t);
|
|---|
| 85 | static errno_t rtc_time_set(ddf_fun_t *fun, struct tm *t);
|
|---|
| 86 | static errno_t rtc_dev_add(ddf_dev_t *dev);
|
|---|
| 87 | static errno_t rtc_dev_initialize(rtc_t *rtc);
|
|---|
| [2a5171db] | 88 | static bool rtc_pio_enable(rtc_t *rtc);
|
|---|
| 89 | static void rtc_dev_cleanup(rtc_t *rtc);
|
|---|
| [b7fd2a0] | 90 | static errno_t rtc_open(ddf_fun_t *fun);
|
|---|
| [2a5171db] | 91 | static void rtc_close(ddf_fun_t *fun);
|
|---|
| [f30ee571] | 92 | static bool rtc_update_in_progress(rtc_t *rtc);
|
|---|
| [db8d552] | 93 | static int rtc_register_read(rtc_t *rtc, int reg);
|
|---|
| [1170ea3c] | 94 | static unsigned bcd2bin(unsigned bcd);
|
|---|
| 95 | static unsigned bin2bcd(unsigned binary);
|
|---|
| [b7fd2a0] | 96 | static errno_t rtc_dev_remove(ddf_dev_t *dev);
|
|---|
| [a8a0d43] | 97 | static void rtc_register_write(rtc_t *rtc, int reg, int data);
|
|---|
| [0a586f4c] | 98 | static bool is_battery_ok(rtc_t *rtc);
|
|---|
| [b7fd2a0] | 99 | static errno_t rtc_fun_online(ddf_fun_t *fun);
|
|---|
| 100 | static errno_t rtc_fun_offline(ddf_fun_t *fun);
|
|---|
| [4863bb52] | 101 |
|
|---|
| [1e19a15] | 102 | static ddf_dev_ops_t rtc_dev_ops;
|
|---|
| 103 |
|
|---|
| [a31ca11f] | 104 | /** The RTC device driver's standard operations */
|
|---|
| 105 | static driver_ops_t rtc_ops = {
|
|---|
| 106 | .dev_add = rtc_dev_add,
|
|---|
| [bb8f69d] | 107 | .dev_remove = rtc_dev_remove,
|
|---|
| [b801f2d] | 108 | .fun_online = rtc_fun_online,
|
|---|
| 109 | .fun_offline = rtc_fun_offline,
|
|---|
| [a31ca11f] | 110 | };
|
|---|
| 111 |
|
|---|
| 112 | /** The RTC device driver structure */
|
|---|
| [1e19a15] | 113 | static driver_t rtc_driver = {
|
|---|
| 114 | .name = NAME,
|
|---|
| [a31ca11f] | 115 | .driver_ops = &rtc_ops,
|
|---|
| [1e19a15] | 116 | };
|
|---|
| 117 |
|
|---|
| [a31ca11f] | 118 | /** Clock interface */
|
|---|
| [4863bb52] | 119 | static clock_dev_ops_t rtc_clock_dev_ops = {
|
|---|
| 120 | .time_get = rtc_time_get,
|
|---|
| 121 | .time_set = rtc_time_set,
|
|---|
| 122 | };
|
|---|
| 123 |
|
|---|
| [917797f] | 124 | /** Battery powered device interface */
|
|---|
| 125 | static battery_dev_ops_t rtc_battery_dev_ops = {
|
|---|
| [efcfab9] | 126 | .battery_status_get = rtc_battery_status_get,
|
|---|
| [917797f] | 127 | .battery_charge_level_get = NULL,
|
|---|
| 128 | };
|
|---|
| 129 |
|
|---|
| [6f445a67] | 130 | /** Obtain soft state structure from device node */
|
|---|
| 131 | static rtc_t *
|
|---|
| 132 | dev_rtc(ddf_dev_t *dev)
|
|---|
| 133 | {
|
|---|
| 134 | return ddf_dev_data_get(dev);
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | /** Obtain soft state structure from function node */
|
|---|
| 138 | static rtc_t *
|
|---|
| 139 | fun_rtc(ddf_fun_t *fun)
|
|---|
| 140 | {
|
|---|
| 141 | return dev_rtc(ddf_fun_get_dev(fun));
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| [4863bb52] | 144 | /** Initialize the RTC driver */
|
|---|
| [1e19a15] | 145 | static void
|
|---|
| 146 | rtc_init(void)
|
|---|
| 147 | {
|
|---|
| [289fa65] | 148 | ddf_log_init(NAME);
|
|---|
| [1e19a15] | 149 |
|
|---|
| [923b2eba] | 150 | rtc_dev_ops.open = rtc_open;
|
|---|
| [2a5171db] | 151 | rtc_dev_ops.close = rtc_close;
|
|---|
| [4863bb52] | 152 |
|
|---|
| 153 | rtc_dev_ops.interfaces[CLOCK_DEV_IFACE] = &rtc_clock_dev_ops;
|
|---|
| [917797f] | 154 | rtc_dev_ops.interfaces[BATTERY_DEV_IFACE] = &rtc_battery_dev_ops;
|
|---|
| 155 | rtc_dev_ops.default_handler = NULL;
|
|---|
| [4863bb52] | 156 | }
|
|---|
| 157 |
|
|---|
| [4b44de57] | 158 | /** Clean up the RTC soft state
|
|---|
| 159 | *
|
|---|
| 160 | * @param rtc The RTC device
|
|---|
| 161 | */
|
|---|
| 162 | static void
|
|---|
| 163 | rtc_dev_cleanup(rtc_t *rtc)
|
|---|
| 164 | {
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| [0883de8] | 167 | /** Enable the I/O ports of the device
|
|---|
| 168 | *
|
|---|
| 169 | * @param rtc The real time clock device
|
|---|
| 170 | *
|
|---|
| 171 | * @return true in case of success, false otherwise
|
|---|
| 172 | */
|
|---|
| 173 | static bool
|
|---|
| 174 | rtc_pio_enable(rtc_t *rtc)
|
|---|
| 175 | {
|
|---|
| [85f7369] | 176 | if (pio_enable((void *) rtc->io_addr, REG_COUNT,
|
|---|
| [0883de8] | 177 | (void **) &rtc->port)) {
|
|---|
| 178 |
|
|---|
| [276e44a] | 179 | ddf_msg(LVL_ERROR, "Cannot map the port %lx"
|
|---|
| [7ff35c7] | 180 | " for device %s", (long unsigned int)rtc->io_addr,
|
|---|
| [276e44a] | 181 | ddf_dev_get_name(rtc->dev));
|
|---|
| [0883de8] | 182 | return false;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | return true;
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| [b3db669] | 188 | /** Initialize the RTC device
|
|---|
| 189 | *
|
|---|
| 190 | * @param rtc Pointer to the RTC device
|
|---|
| 191 | *
|
|---|
| [cde999a] | 192 | * @return EOK on success or an error code
|
|---|
| [1b20da0] | 193 | */
|
|---|
| [b7fd2a0] | 194 | static errno_t
|
|---|
| [b3db669] | 195 | rtc_dev_initialize(rtc_t *rtc)
|
|---|
| 196 | {
|
|---|
| [b7fd2a0] | 197 | errno_t rc;
|
|---|
| [c47f1b6] | 198 | size_t i;
|
|---|
| 199 | hw_resource_t *res;
|
|---|
| 200 | bool ioport = false;
|
|---|
| [6f445a67] | 201 | async_sess_t *parent_sess;
|
|---|
| [b3db669] | 202 |
|
|---|
| [6f445a67] | 203 | ddf_msg(LVL_DEBUG, "rtc_dev_initialize %s", ddf_dev_get_name(rtc->dev));
|
|---|
| [b3db669] | 204 |
|
|---|
| [7f9d97f3] | 205 | rtc->boot_time.tv_sec = 0;
|
|---|
| 206 | rtc->boot_time.tv_usec = 0;
|
|---|
| [9673fd3] | 207 | rtc->clients_connected = 0;
|
|---|
| [762083b] | 208 |
|
|---|
| [b3db669] | 209 | hw_resource_list_t hw_resources;
|
|---|
| 210 | memset(&hw_resources, 0, sizeof(hw_resource_list_t));
|
|---|
| 211 |
|
|---|
| 212 | /* Connect to the parent's driver */
|
|---|
| 213 |
|
|---|
| [2fd26bb] | 214 | parent_sess = ddf_dev_parent_sess_get(rtc->dev);
|
|---|
| 215 | if (parent_sess == NULL) {
|
|---|
| [b3db669] | 216 | ddf_msg(LVL_ERROR, "Failed to connect to parent driver\
|
|---|
| [6f445a67] | 217 | of device %s.", ddf_dev_get_name(rtc->dev));
|
|---|
| [4b44de57] | 218 | rc = ENOENT;
|
|---|
| 219 | goto error;
|
|---|
| [b3db669] | 220 | }
|
|---|
| 221 |
|
|---|
| 222 | /* Get the HW resources */
|
|---|
| [6f445a67] | 223 | rc = hw_res_get_resource_list(parent_sess, &hw_resources);
|
|---|
| [b3db669] | 224 | if (rc != EOK) {
|
|---|
| 225 | ddf_msg(LVL_ERROR, "Failed to get HW resources\
|
|---|
| [6f445a67] | 226 | for device %s", ddf_dev_get_name(rtc->dev));
|
|---|
| [4b44de57] | 227 | goto error;
|
|---|
| [b3db669] | 228 | }
|
|---|
| 229 |
|
|---|
| [c47f1b6] | 230 | for (i = 0; i < hw_resources.count; ++i) {
|
|---|
| 231 | res = &hw_resources.resources[i];
|
|---|
| 232 |
|
|---|
| [ae827d0] | 233 | if (res->res.io_range.size < REG_COUNT) {
|
|---|
| 234 | ddf_msg(LVL_ERROR, "I/O range assigned to \
|
|---|
| 235 | device %s is too small",
|
|---|
| 236 | ddf_dev_get_name(rtc->dev));
|
|---|
| 237 | rc = ELIMIT;
|
|---|
| 238 | continue;
|
|---|
| [c47f1b6] | 239 | }
|
|---|
| [ae827d0] | 240 |
|
|---|
| [7ff35c7] | 241 | rtc->io_addr = (ioport8_t *) (long) res->res.io_range.address;
|
|---|
| [ae827d0] | 242 | ioport = true;
|
|---|
| 243 | ddf_msg(LVL_NOTE, "Device %s was assigned I/O address "
|
|---|
| [276e44a] | 244 | "0x%lx", ddf_dev_get_name(rtc->dev),
|
|---|
| [7ff35c7] | 245 | (unsigned long int) rtc->io_addr);
|
|---|
| [ae827d0] | 246 | rc = EOK;
|
|---|
| 247 | break;
|
|---|
| [c47f1b6] | 248 | }
|
|---|
| 249 |
|
|---|
| [ae827d0] | 250 | if (rc != EOK)
|
|---|
| 251 | goto error;
|
|---|
| 252 |
|
|---|
| [c47f1b6] | 253 | if (!ioport) {
|
|---|
| 254 | /* No I/O address assigned to this device */
|
|---|
| 255 | ddf_msg(LVL_ERROR, "Missing HW resource for device %s",
|
|---|
| [6f445a67] | 256 | ddf_dev_get_name(rtc->dev));
|
|---|
| [4b44de57] | 257 | rc = ENOENT;
|
|---|
| 258 | goto error;
|
|---|
| [c47f1b6] | 259 | }
|
|---|
| 260 |
|
|---|
| 261 | hw_res_clean_resource_list(&hw_resources);
|
|---|
| 262 |
|
|---|
| [b3db669] | 263 | return EOK;
|
|---|
| [4b44de57] | 264 |
|
|---|
| 265 | error:
|
|---|
| 266 | rtc_dev_cleanup(rtc);
|
|---|
| 267 | hw_res_clean_resource_list(&hw_resources);
|
|---|
| 268 |
|
|---|
| 269 | return rc;
|
|---|
| [b3db669] | 270 | }
|
|---|
| 271 |
|
|---|
| [3b79ba5] | 272 | /** Read a register from the CMOS memory
|
|---|
| 273 | *
|
|---|
| [1170ea3c] | 274 | * @param rtc The rtc device
|
|---|
| [3b79ba5] | 275 | * @param reg The index of the register to read
|
|---|
| 276 | *
|
|---|
| 277 | * @return The value of the register
|
|---|
| 278 | */
|
|---|
| 279 | static int
|
|---|
| [db8d552] | 280 | rtc_register_read(rtc_t *rtc, int reg)
|
|---|
| [3b79ba5] | 281 | {
|
|---|
| [78ca12b] | 282 | pio_write_8(REG_SEL_PORT(rtc->port), reg);
|
|---|
| 283 | return pio_read_8(REG_RW_PORT(rtc->port));
|
|---|
| [3b79ba5] | 284 | }
|
|---|
| 285 |
|
|---|
| [1170ea3c] | 286 | /** Write a register to the CMOS memory
|
|---|
| 287 | *
|
|---|
| 288 | * @param rtc The rtc device
|
|---|
| 289 | * @param reg The index of the register to write
|
|---|
| 290 | * @param data The data to write
|
|---|
| 291 | */
|
|---|
| 292 | static void
|
|---|
| 293 | rtc_register_write(rtc_t *rtc, int reg, int data)
|
|---|
| 294 | {
|
|---|
| [78ca12b] | 295 | pio_write_8(REG_SEL_PORT(rtc->port), reg);
|
|---|
| 296 | pio_write_8(REG_RW_PORT(rtc->port), data);
|
|---|
| [1170ea3c] | 297 | }
|
|---|
| 298 |
|
|---|
| [f30ee571] | 299 | /** Check if an update is in progress
|
|---|
| 300 | *
|
|---|
| 301 | * @param rtc The rtc device
|
|---|
| 302 | *
|
|---|
| 303 | * @return true if an update is in progress, false otherwise
|
|---|
| 304 | */
|
|---|
| 305 | static bool
|
|---|
| 306 | rtc_update_in_progress(rtc_t *rtc)
|
|---|
| 307 | {
|
|---|
| [6a3808e] | 308 | return rtc_register_read(rtc, RTC_STATUS_A) & RTC_A_UPDATE;
|
|---|
| [f30ee571] | 309 | }
|
|---|
| 310 |
|
|---|
| [0b8a3e7] | 311 | /** Read the current time from the CMOS
|
|---|
| 312 | *
|
|---|
| 313 | * @param fun The RTC function
|
|---|
| 314 | * @param t Pointer to the time variable
|
|---|
| 315 | *
|
|---|
| [cde999a] | 316 | * @return EOK on success or an error code
|
|---|
| [0b8a3e7] | 317 | */
|
|---|
| [b7fd2a0] | 318 | static errno_t
|
|---|
| [8d2963d] | 319 | rtc_time_get(ddf_fun_t *fun, struct tm *t)
|
|---|
| [4863bb52] | 320 | {
|
|---|
| [db8d552] | 321 | bool bcd_mode;
|
|---|
| [95060d5b] | 322 | bool pm_mode = false;
|
|---|
| [6f445a67] | 323 | rtc_t *rtc = fun_rtc(fun);
|
|---|
| [f30ee571] | 324 |
|
|---|
| [60af6fc2] | 325 | fibril_mutex_lock(&rtc->mutex);
|
|---|
| 326 |
|
|---|
| [7f9d97f3] | 327 | if (rtc->boot_time.tv_sec) {
|
|---|
| [7c3fb9b] | 328 | /*
|
|---|
| 329 | * There is no need to read the current time from the
|
|---|
| [ea5cc5b] | 330 | * device because it has already been cached.
|
|---|
| 331 | */
|
|---|
| 332 |
|
|---|
| [7f9d97f3] | 333 | struct timeval curtime;
|
|---|
| [a35b458] | 334 |
|
|---|
| [7f9d97f3] | 335 | getuptime(&curtime);
|
|---|
| 336 | tv_add(&curtime, &rtc->boot_time);
|
|---|
| [60af6fc2] | 337 | fibril_mutex_unlock(&rtc->mutex);
|
|---|
| 338 |
|
|---|
| [7f9d97f3] | 339 | return time_tv2tm(&curtime, t);
|
|---|
| [ea5cc5b] | 340 | }
|
|---|
| 341 |
|
|---|
| [0a586f4c] | 342 | /* Check if the RTC battery is OK */
|
|---|
| 343 | if (!is_battery_ok(rtc)) {
|
|---|
| 344 | fibril_mutex_unlock(&rtc->mutex);
|
|---|
| 345 | return EIO;
|
|---|
| 346 | }
|
|---|
| 347 |
|
|---|
| [7f9d97f3] | 348 | /* Microseconds are below RTC's resolution, assume 0. */
|
|---|
| 349 | t->tm_usec = 0;
|
|---|
| 350 |
|
|---|
| [db8d552] | 351 | /* now read the registers */
|
|---|
| 352 | do {
|
|---|
| 353 | /* Suspend until the update process has finished */
|
|---|
| [7f9d97f3] | 354 | while (rtc_update_in_progress(rtc))
|
|---|
| 355 | ;
|
|---|
| [db8d552] | 356 |
|
|---|
| [7f9d97f3] | 357 | t->tm_sec = rtc_register_read(rtc, RTC_SEC);
|
|---|
| 358 | t->tm_min = rtc_register_read(rtc, RTC_MIN);
|
|---|
| [db8d552] | 359 | t->tm_hour = rtc_register_read(rtc, RTC_HOUR);
|
|---|
| 360 | t->tm_mday = rtc_register_read(rtc, RTC_DAY);
|
|---|
| [7f9d97f3] | 361 | t->tm_mon = rtc_register_read(rtc, RTC_MON);
|
|---|
| [db8d552] | 362 | t->tm_year = rtc_register_read(rtc, RTC_YEAR);
|
|---|
| 363 |
|
|---|
| 364 | /* Now check if it is stable */
|
|---|
| [18b6a88] | 365 | } while (t->tm_sec != rtc_register_read(rtc, RTC_SEC) ||
|
|---|
| [7f9d97f3] | 366 | t->tm_min != rtc_register_read(rtc, RTC_MIN) ||
|
|---|
| [c9abf50] | 367 | t->tm_mday != rtc_register_read(rtc, RTC_DAY) ||
|
|---|
| [7f9d97f3] | 368 | t->tm_mon != rtc_register_read(rtc, RTC_MON) ||
|
|---|
| [c9abf50] | 369 | t->tm_year != rtc_register_read(rtc, RTC_YEAR));
|
|---|
| [db8d552] | 370 |
|
|---|
| [95060d5b] | 371 | /* Check if the RTC is working in 12h mode */
|
|---|
| 372 | bool _12h_mode = !(rtc_register_read(rtc, RTC_STATUS_B) &
|
|---|
| [6a3808e] | 373 | RTC_B_24H);
|
|---|
| [95060d5b] | 374 | if (_12h_mode) {
|
|---|
| 375 | /* The RTC is working in 12h mode, check if it is AM or PM */
|
|---|
| 376 | if (t->tm_hour & 0x80) {
|
|---|
| [f004318] | 377 | /* PM flag is active, it must be cleared */
|
|---|
| [95060d5b] | 378 | t->tm_hour &= ~0x80;
|
|---|
| 379 | pm_mode = true;
|
|---|
| 380 | }
|
|---|
| 381 | }
|
|---|
| 382 |
|
|---|
| [db8d552] | 383 | /* Check if the RTC is working in BCD mode */
|
|---|
| [6a3808e] | 384 | bcd_mode = !(rtc_register_read(rtc, RTC_STATUS_B) & RTC_B_BCD);
|
|---|
| [fc7d28e] | 385 | if (bcd_mode) {
|
|---|
| [7f9d97f3] | 386 | t->tm_sec = bcd2bin(t->tm_sec);
|
|---|
| 387 | t->tm_min = bcd2bin(t->tm_min);
|
|---|
| [1170ea3c] | 388 | t->tm_hour = bcd2bin(t->tm_hour);
|
|---|
| 389 | t->tm_mday = bcd2bin(t->tm_mday);
|
|---|
| [7f9d97f3] | 390 | t->tm_mon = bcd2bin(t->tm_mon);
|
|---|
| [1170ea3c] | 391 | t->tm_year = bcd2bin(t->tm_year);
|
|---|
| [db8d552] | 392 | }
|
|---|
| [f30ee571] | 393 |
|
|---|
| [95060d5b] | 394 | if (_12h_mode) {
|
|---|
| 395 | /* Convert to 24h mode */
|
|---|
| 396 | if (pm_mode) {
|
|---|
| 397 | if (t->tm_hour < 12)
|
|---|
| 398 | t->tm_hour += 12;
|
|---|
| 399 | } else if (t->tm_hour == 12)
|
|---|
| 400 | t->tm_hour = 0;
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| [05ed9d7] | 403 | /* Count the months starting from 0, not from 1 */
|
|---|
| 404 | t->tm_mon--;
|
|---|
| 405 |
|
|---|
| [fc7d28e] | 406 | if (t->tm_year < 100) {
|
|---|
| [7c3fb9b] | 407 | /*
|
|---|
| 408 | * tm_year is the number of years since 1900 but the
|
|---|
| [e5fbe06] | 409 | * RTC epoch is 2000.
|
|---|
| [fc7d28e] | 410 | */
|
|---|
| 411 | t->tm_year += 100;
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| [af7e3d3] | 414 | /* Try to normalize the content of the tm structure */
|
|---|
| [fa18523] | 415 | time_t r = mktime(t);
|
|---|
| [b7fd2a0] | 416 | errno_t result;
|
|---|
| [fa18523] | 417 |
|
|---|
| [508fff8] | 418 | if (r < 0)
|
|---|
| 419 | result = EINVAL;
|
|---|
| 420 | else {
|
|---|
| [7f9d97f3] | 421 | struct timeval uptime;
|
|---|
| 422 |
|
|---|
| 423 | getuptime(&uptime);
|
|---|
| 424 | rtc->boot_time.tv_sec = r;
|
|---|
| 425 | rtc->boot_time.tv_usec = t->tm_usec; /* normalized */
|
|---|
| 426 | tv_sub(&rtc->boot_time, &uptime);
|
|---|
| [508fff8] | 427 | result = EOK;
|
|---|
| 428 | }
|
|---|
| [60af6fc2] | 429 |
|
|---|
| 430 | fibril_mutex_unlock(&rtc->mutex);
|
|---|
| [ea5cc5b] | 431 |
|
|---|
| [508fff8] | 432 | return result;
|
|---|
| [4863bb52] | 433 | }
|
|---|
| 434 |
|
|---|
| [0b8a3e7] | 435 | /** Set the time in the RTC
|
|---|
| 436 | *
|
|---|
| 437 | * @param fun The RTC function
|
|---|
| 438 | * @param t The time value to set
|
|---|
| 439 | *
|
|---|
| [cde999a] | 440 | * @return EOK or an error code
|
|---|
| [0b8a3e7] | 441 | */
|
|---|
| [b7fd2a0] | 442 | static errno_t
|
|---|
| [8d2963d] | 443 | rtc_time_set(ddf_fun_t *fun, struct tm *t)
|
|---|
| [4863bb52] | 444 | {
|
|---|
| [1170ea3c] | 445 | bool bcd_mode;
|
|---|
| [8fde078] | 446 | time_t norm_time;
|
|---|
| [7f9d97f3] | 447 | struct timeval uptime;
|
|---|
| 448 | struct timeval ntv;
|
|---|
| [a8a0d43] | 449 | int reg_b;
|
|---|
| 450 | int reg_a;
|
|---|
| [e5fbe06] | 451 | int epoch;
|
|---|
| [6f445a67] | 452 | rtc_t *rtc = fun_rtc(fun);
|
|---|
| [1170ea3c] | 453 |
|
|---|
| [af7e3d3] | 454 | /* Try to normalize the content of the tm structure */
|
|---|
| [8fde078] | 455 | if ((norm_time = mktime(t)) < 0)
|
|---|
| [fa18523] | 456 | return EINVAL;
|
|---|
| 457 |
|
|---|
| [7f9d97f3] | 458 | ntv.tv_sec = norm_time;
|
|---|
| 459 | ntv.tv_usec = t->tm_usec;
|
|---|
| 460 | getuptime(&uptime);
|
|---|
| 461 |
|
|---|
| 462 | if (tv_gteq(&uptime, &ntv)) {
|
|---|
| [8fde078] | 463 | /* This is not acceptable */
|
|---|
| 464 | return EINVAL;
|
|---|
| 465 | }
|
|---|
| 466 |
|
|---|
| [e5fbe06] | 467 | fibril_mutex_lock(&rtc->mutex);
|
|---|
| 468 |
|
|---|
| [0a586f4c] | 469 | if (!is_battery_ok(rtc)) {
|
|---|
| 470 | fibril_mutex_unlock(&rtc->mutex);
|
|---|
| 471 | return EIO;
|
|---|
| 472 | }
|
|---|
| 473 |
|
|---|
| [7f9d97f3] | 474 | /* boot_time must be recomputed */
|
|---|
| 475 | rtc->boot_time.tv_sec = 0;
|
|---|
| 476 | rtc->boot_time.tv_usec = 0;
|
|---|
| [60af6fc2] | 477 |
|
|---|
| [e5fbe06] | 478 | /* Detect the RTC epoch */
|
|---|
| 479 | if (rtc_register_read(rtc, RTC_YEAR) < 100)
|
|---|
| 480 | epoch = 2000;
|
|---|
| 481 | else
|
|---|
| 482 | epoch = 1900;
|
|---|
| 483 |
|
|---|
| [fa18523] | 484 | if (epoch == 2000 && t->tm_year < 100) {
|
|---|
| 485 | /* Can't set a year before the epoch */
|
|---|
| [e5fbe06] | 486 | fibril_mutex_unlock(&rtc->mutex);
|
|---|
| [fa18523] | 487 | return EINVAL;
|
|---|
| [e5fbe06] | 488 | }
|
|---|
| [1170ea3c] | 489 |
|
|---|
| [a8a0d43] | 490 | t->tm_mon++; /* counts from 1, not from 0 */
|
|---|
| [1170ea3c] | 491 |
|
|---|
| [a8a0d43] | 492 | reg_b = rtc_register_read(rtc, RTC_STATUS_B);
|
|---|
| 493 |
|
|---|
| [6a3808e] | 494 | if (!(reg_b & RTC_B_24H)) {
|
|---|
| [f004318] | 495 | /* Force 24h mode of operation */
|
|---|
| [6a3808e] | 496 | reg_b |= RTC_B_24H;
|
|---|
| [f004318] | 497 | rtc_register_write(rtc, RTC_STATUS_B, reg_b);
|
|---|
| 498 | }
|
|---|
| [f6af126] | 499 |
|
|---|
| [a44b58c] | 500 | if (epoch == 2000) {
|
|---|
| [7c3fb9b] | 501 | /*
|
|---|
| 502 | * The RTC epoch is year 2000 but the tm_year
|
|---|
| [a44b58c] | 503 | * field counts years since 1900.
|
|---|
| 504 | */
|
|---|
| [074324f1] | 505 | t->tm_year -= 100;
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| [1170ea3c] | 508 | /* Check if the rtc is working in bcd mode */
|
|---|
| [6a3808e] | 509 | bcd_mode = !(reg_b & RTC_B_BCD);
|
|---|
| [1170ea3c] | 510 | if (bcd_mode) {
|
|---|
| 511 | /* Convert the tm struct fields in BCD mode */
|
|---|
| 512 | t->tm_sec = bin2bcd(t->tm_sec);
|
|---|
| 513 | t->tm_min = bin2bcd(t->tm_min);
|
|---|
| 514 | t->tm_hour = bin2bcd(t->tm_hour);
|
|---|
| 515 | t->tm_mday = bin2bcd(t->tm_mday);
|
|---|
| [709476f4] | 516 | t->tm_mon = bin2bcd(t->tm_mon);
|
|---|
| [1170ea3c] | 517 | t->tm_year = bin2bcd(t->tm_year);
|
|---|
| 518 | }
|
|---|
| 519 |
|
|---|
| [a8a0d43] | 520 | /* Inhibit updates */
|
|---|
| [6a3808e] | 521 | rtc_register_write(rtc, RTC_STATUS_B, reg_b | RTC_B_INH);
|
|---|
| [a8a0d43] | 522 |
|
|---|
| 523 | /* Write current time to RTC */
|
|---|
| 524 | rtc_register_write(rtc, RTC_SEC, t->tm_sec);
|
|---|
| 525 | rtc_register_write(rtc, RTC_MIN, t->tm_min);
|
|---|
| 526 | rtc_register_write(rtc, RTC_HOUR, t->tm_hour);
|
|---|
| 527 | rtc_register_write(rtc, RTC_DAY, t->tm_mday);
|
|---|
| 528 | rtc_register_write(rtc, RTC_MON, t->tm_mon);
|
|---|
| 529 | rtc_register_write(rtc, RTC_YEAR, t->tm_year);
|
|---|
| 530 |
|
|---|
| 531 | /* Stop the clock */
|
|---|
| 532 | reg_a = rtc_register_read(rtc, RTC_STATUS_A);
|
|---|
| [6a3808e] | 533 | rtc_register_write(rtc, RTC_STATUS_A, RTC_A_CLK_STOP | reg_a);
|
|---|
| [a35b458] | 534 |
|
|---|
| [a8a0d43] | 535 | /* Enable updates */
|
|---|
| 536 | rtc_register_write(rtc, RTC_STATUS_B, reg_b);
|
|---|
| 537 | rtc_register_write(rtc, RTC_STATUS_A, reg_a);
|
|---|
| [1170ea3c] | 538 |
|
|---|
| 539 | fibril_mutex_unlock(&rtc->mutex);
|
|---|
| 540 |
|
|---|
| [4863bb52] | 541 | return EOK;
|
|---|
| [1e19a15] | 542 | }
|
|---|
| 543 |
|
|---|
| [efcfab9] | 544 | /** Get the status of the real time clock battery
|
|---|
| 545 | *
|
|---|
| 546 | * @param fun The RTC function
|
|---|
| 547 | * @param status The status of the battery
|
|---|
| 548 | *
|
|---|
| [cde999a] | 549 | * @return EOK on success or an error code
|
|---|
| [efcfab9] | 550 | */
|
|---|
| [b7fd2a0] | 551 | static errno_t
|
|---|
| [efcfab9] | 552 | rtc_battery_status_get(ddf_fun_t *fun, battery_status_t *status)
|
|---|
| 553 | {
|
|---|
| 554 | rtc_t *rtc = fun_rtc(fun);
|
|---|
| [0a586f4c] | 555 |
|
|---|
| 556 | fibril_mutex_lock(&rtc->mutex);
|
|---|
| 557 | const bool batt_ok = is_battery_ok(rtc);
|
|---|
| 558 | fibril_mutex_unlock(&rtc->mutex);
|
|---|
| [efcfab9] | 559 |
|
|---|
| 560 | *status = batt_ok ? BATTERY_OK : BATTERY_LOW;
|
|---|
| 561 |
|
|---|
| 562 | return EOK;
|
|---|
| 563 | }
|
|---|
| 564 |
|
|---|
| [0a586f4c] | 565 | /** Check if the battery is working properly or not.
|
|---|
| 566 | * The caller already holds the rtc->mutex lock.
|
|---|
| 567 | *
|
|---|
| 568 | * @param rtc The RTC instance.
|
|---|
| 569 | *
|
|---|
| 570 | * @return true if the battery is ok, false otherwise.
|
|---|
| 571 | */
|
|---|
| 572 | static bool
|
|---|
| 573 | is_battery_ok(rtc_t *rtc)
|
|---|
| 574 | {
|
|---|
| 575 | return rtc_register_read(rtc, RTC_STATUS_D) & RTC_D_BATTERY_OK;
|
|---|
| 576 | }
|
|---|
| 577 |
|
|---|
| [a31ca11f] | 578 | /** The dev_add callback of the rtc driver
|
|---|
| 579 | *
|
|---|
| 580 | * @param dev The RTC device
|
|---|
| 581 | *
|
|---|
| [cde999a] | 582 | * @return EOK on success or an error code
|
|---|
| [a31ca11f] | 583 | */
|
|---|
| [b7fd2a0] | 584 | static errno_t
|
|---|
| [a31ca11f] | 585 | rtc_dev_add(ddf_dev_t *dev)
|
|---|
| 586 | {
|
|---|
| [6b329749] | 587 | rtc_t *rtc;
|
|---|
| [4b44de57] | 588 | ddf_fun_t *fun = NULL;
|
|---|
| [b7fd2a0] | 589 | errno_t rc;
|
|---|
| [4b44de57] | 590 | bool need_cleanup = false;
|
|---|
| [6b329749] | 591 |
|
|---|
| 592 | ddf_msg(LVL_DEBUG, "rtc_dev_add %s (handle = %d)",
|
|---|
| [6f445a67] | 593 | ddf_dev_get_name(dev), (int) ddf_dev_get_handle(dev));
|
|---|
| [6b329749] | 594 |
|
|---|
| 595 | rtc = ddf_dev_data_alloc(dev, sizeof(rtc_t));
|
|---|
| 596 | if (!rtc)
|
|---|
| 597 | return ENOMEM;
|
|---|
| 598 |
|
|---|
| 599 | rtc->dev = dev;
|
|---|
| 600 | fibril_mutex_initialize(&rtc->mutex);
|
|---|
| 601 |
|
|---|
| [b3db669] | 602 | rc = rtc_dev_initialize(rtc);
|
|---|
| 603 | if (rc != EOK)
|
|---|
| [4b44de57] | 604 | goto error;
|
|---|
| [b3db669] | 605 |
|
|---|
| [4b44de57] | 606 | need_cleanup = true;
|
|---|
| 607 |
|
|---|
| 608 | if (!rtc_pio_enable(rtc)) {
|
|---|
| 609 | rc = EADDRNOTAVAIL;
|
|---|
| 610 | goto error;
|
|---|
| 611 | }
|
|---|
| [0883de8] | 612 |
|
|---|
| 613 | fun = ddf_fun_create(dev, fun_exposed, "a");
|
|---|
| 614 | if (!fun) {
|
|---|
| 615 | ddf_msg(LVL_ERROR, "Failed creating function");
|
|---|
| [4b44de57] | 616 | rc = ENOENT;
|
|---|
| 617 | goto error;
|
|---|
| [0883de8] | 618 | }
|
|---|
| 619 |
|
|---|
| [6f445a67] | 620 | ddf_fun_set_ops(fun, &rtc_dev_ops);
|
|---|
| [0883de8] | 621 | rc = ddf_fun_bind(fun);
|
|---|
| 622 | if (rc != EOK) {
|
|---|
| 623 | ddf_msg(LVL_ERROR, "Failed binding function");
|
|---|
| [4b44de57] | 624 | goto error;
|
|---|
| [0883de8] | 625 | }
|
|---|
| 626 |
|
|---|
| 627 | rtc->fun = fun;
|
|---|
| 628 |
|
|---|
| 629 | ddf_fun_add_to_category(fun, "clock");
|
|---|
| 630 |
|
|---|
| 631 | ddf_msg(LVL_NOTE, "Device %s successfully initialized",
|
|---|
| [6f445a67] | 632 | ddf_dev_get_name(dev));
|
|---|
| [0883de8] | 633 |
|
|---|
| [b3db669] | 634 | return rc;
|
|---|
| [4b44de57] | 635 |
|
|---|
| 636 | error:
|
|---|
| 637 | if (fun)
|
|---|
| 638 | ddf_fun_destroy(fun);
|
|---|
| 639 | if (need_cleanup)
|
|---|
| 640 | rtc_dev_cleanup(rtc);
|
|---|
| 641 | return rc;
|
|---|
| [a31ca11f] | 642 | }
|
|---|
| 643 |
|
|---|
| [bb8f69d] | 644 | /** The dev_remove callback for the rtc driver
|
|---|
| 645 | *
|
|---|
| 646 | * @param dev The RTC device
|
|---|
| 647 | *
|
|---|
| [cde999a] | 648 | * @return EOK on success or an error code
|
|---|
| [bb8f69d] | 649 | */
|
|---|
| [b7fd2a0] | 650 | static errno_t
|
|---|
| [bb8f69d] | 651 | rtc_dev_remove(ddf_dev_t *dev)
|
|---|
| 652 | {
|
|---|
| [6f445a67] | 653 | rtc_t *rtc = dev_rtc(dev);
|
|---|
| [b7fd2a0] | 654 | errno_t rc;
|
|---|
| [bb8f69d] | 655 |
|
|---|
| 656 | fibril_mutex_lock(&rtc->mutex);
|
|---|
| [9673fd3] | 657 | if (rtc->clients_connected > 0) {
|
|---|
| 658 | fibril_mutex_unlock(&rtc->mutex);
|
|---|
| 659 | return EBUSY;
|
|---|
| 660 | }
|
|---|
| [bb8f69d] | 661 |
|
|---|
| 662 | rtc->removed = true;
|
|---|
| 663 | fibril_mutex_unlock(&rtc->mutex);
|
|---|
| 664 |
|
|---|
| [b801f2d] | 665 | rc = rtc_fun_offline(rtc->fun);
|
|---|
| 666 | if (rc != EOK) {
|
|---|
| 667 | ddf_msg(LVL_ERROR, "Failed to offline function");
|
|---|
| 668 | return rc;
|
|---|
| 669 | }
|
|---|
| 670 |
|
|---|
| [bb8f69d] | 671 | rc = ddf_fun_unbind(rtc->fun);
|
|---|
| 672 | if (rc != EOK) {
|
|---|
| 673 | ddf_msg(LVL_ERROR, "Failed to unbind function");
|
|---|
| 674 | return rc;
|
|---|
| 675 | }
|
|---|
| 676 |
|
|---|
| 677 | ddf_fun_destroy(rtc->fun);
|
|---|
| 678 | rtc_dev_cleanup(rtc);
|
|---|
| 679 |
|
|---|
| 680 | return rc;
|
|---|
| 681 | }
|
|---|
| 682 |
|
|---|
| [923b2eba] | 683 | /** Open the device
|
|---|
| 684 | *
|
|---|
| 685 | * @param fun The function node
|
|---|
| 686 | *
|
|---|
| [cde999a] | 687 | * @return EOK on success or an error code
|
|---|
| [923b2eba] | 688 | */
|
|---|
| [b7fd2a0] | 689 | static errno_t
|
|---|
| [923b2eba] | 690 | rtc_open(ddf_fun_t *fun)
|
|---|
| 691 | {
|
|---|
| [b7fd2a0] | 692 | errno_t rc;
|
|---|
| [6f445a67] | 693 | rtc_t *rtc = fun_rtc(fun);
|
|---|
| [923b2eba] | 694 |
|
|---|
| 695 | fibril_mutex_lock(&rtc->mutex);
|
|---|
| 696 |
|
|---|
| [43e660c] | 697 | if (rtc->removed)
|
|---|
| [bb8f69d] | 698 | rc = ENXIO;
|
|---|
| [9673fd3] | 699 | else {
|
|---|
| [923b2eba] | 700 | rc = EOK;
|
|---|
| [9673fd3] | 701 | rtc->clients_connected++;
|
|---|
| 702 | }
|
|---|
| [923b2eba] | 703 |
|
|---|
| 704 | fibril_mutex_unlock(&rtc->mutex);
|
|---|
| 705 | return rc;
|
|---|
| 706 | }
|
|---|
| 707 |
|
|---|
| [2a5171db] | 708 | /** Close the device
|
|---|
| 709 | *
|
|---|
| 710 | * @param fun The function node
|
|---|
| 711 | */
|
|---|
| 712 | static void
|
|---|
| 713 | rtc_close(ddf_fun_t *fun)
|
|---|
| 714 | {
|
|---|
| [9673fd3] | 715 | rtc_t *rtc = fun_rtc(fun);
|
|---|
| 716 |
|
|---|
| 717 | fibril_mutex_lock(&rtc->mutex);
|
|---|
| 718 |
|
|---|
| 719 | rtc->clients_connected--;
|
|---|
| 720 | assert(rtc->clients_connected >= 0);
|
|---|
| 721 |
|
|---|
| 722 | fibril_mutex_unlock(&rtc->mutex);
|
|---|
| [2a5171db] | 723 | }
|
|---|
| 724 |
|
|---|
| [db8d552] | 725 | /** Convert from BCD mode to binary mode
|
|---|
| 726 | *
|
|---|
| 727 | * @param bcd The number in BCD format to convert
|
|---|
| 728 | *
|
|---|
| 729 | * @return The converted value
|
|---|
| 730 | */
|
|---|
| [1b20da0] | 731 | static unsigned
|
|---|
| [1170ea3c] | 732 | bcd2bin(unsigned bcd)
|
|---|
| [db8d552] | 733 | {
|
|---|
| 734 | return ((bcd & 0xF0) >> 1) + ((bcd & 0xF0) >> 3) + (bcd & 0xf);
|
|---|
| 735 | }
|
|---|
| 736 |
|
|---|
| [1170ea3c] | 737 | /** Convert from binary mode to BCD mode
|
|---|
| 738 | *
|
|---|
| 739 | * @param bcd The number in binary mode to convert
|
|---|
| 740 | *
|
|---|
| 741 | * @return The converted value
|
|---|
| 742 | */
|
|---|
| 743 | static unsigned
|
|---|
| 744 | bin2bcd(unsigned binary)
|
|---|
| 745 | {
|
|---|
| 746 | return ((binary / 10) << 4) + (binary % 10);
|
|---|
| 747 | }
|
|---|
| 748 |
|
|---|
| [b7fd2a0] | 749 | static errno_t
|
|---|
| [b801f2d] | 750 | rtc_fun_online(ddf_fun_t *fun)
|
|---|
| 751 | {
|
|---|
| [b7fd2a0] | 752 | errno_t rc;
|
|---|
| [a582dff] | 753 |
|
|---|
| [b801f2d] | 754 | ddf_msg(LVL_DEBUG, "rtc_fun_online()");
|
|---|
| [a582dff] | 755 |
|
|---|
| 756 | rc = ddf_fun_online(fun);
|
|---|
| 757 | if (rc == EOK)
|
|---|
| 758 | ddf_fun_add_to_category(fun, "clock");
|
|---|
| 759 |
|
|---|
| 760 | return rc;
|
|---|
| [b801f2d] | 761 | }
|
|---|
| 762 |
|
|---|
| [b7fd2a0] | 763 | static errno_t
|
|---|
| [b801f2d] | 764 | rtc_fun_offline(ddf_fun_t *fun)
|
|---|
| 765 | {
|
|---|
| 766 | ddf_msg(LVL_DEBUG, "rtc_fun_offline()");
|
|---|
| 767 | return ddf_fun_offline(fun);
|
|---|
| 768 | }
|
|---|
| 769 |
|
|---|
| [1e19a15] | 770 | int
|
|---|
| 771 | main(int argc, char **argv)
|
|---|
| 772 | {
|
|---|
| 773 | printf(NAME ": HelenOS RTC driver\n");
|
|---|
| 774 | rtc_init();
|
|---|
| 775 | return ddf_driver_main(&rtc_driver);
|
|---|
| 776 | }
|
|---|
| 777 |
|
|---|
| 778 | /**
|
|---|
| 779 | * @}
|
|---|
| 780 | */
|
|---|