From 32c4d58bd3f0cc284c95103e8c970dda643e57f4 Mon Sep 17 00:00:00 2001 From: Yongcong Du Date: Thu, 5 Jul 2012 00:11:53 +0800 Subject: [PATCH] driver: add cpuidle device driver Currently, it's only used to load generic cpuidle module. But in the future, we will add some features such as stats reporting etc. Signed-off-by: Yongcong Du Signed-off-by: Fredrik Holmqvist --- src/add-ons/kernel/drivers/cpuidle/Jamfile | 5 + .../kernel/drivers/cpuidle/cpuidle.cpp | 117 ++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 src/add-ons/kernel/drivers/cpuidle/Jamfile create mode 100644 src/add-ons/kernel/drivers/cpuidle/cpuidle.cpp diff --git a/src/add-ons/kernel/drivers/cpuidle/Jamfile b/src/add-ons/kernel/drivers/cpuidle/Jamfile new file mode 100644 index 0000000000..50b92909b1 --- /dev/null +++ b/src/add-ons/kernel/drivers/cpuidle/Jamfile @@ -0,0 +1,5 @@ +SubDir HAIKU_TOP src add-ons kernel drivers cpuidle ; + +KernelAddon cpuidle : + cpuidle.cpp + ; diff --git a/src/add-ons/kernel/drivers/cpuidle/cpuidle.cpp b/src/add-ons/kernel/drivers/cpuidle/cpuidle.cpp new file mode 100644 index 0000000000..9440358dfe --- /dev/null +++ b/src/add-ons/kernel/drivers/cpuidle/cpuidle.cpp @@ -0,0 +1,117 @@ +/* + * Copyright 2012, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Yongcong Du + */ + +#include +#include + +#include + +#define DEVICE_NAME "cpuidle" + +int32 api_version = B_CUR_DRIVER_API_VERSION; + +CpuidleModuleInfo *sCpuidleModule; + +static status_t +cpuidle_open(const char *name, uint32 flags, void **cookie) +{ + *cookie = NULL; + return B_OK; +} + + +static status_t +cpuidle_close(void *cookie) +{ + return B_OK; +} + + +static status_t +cpuidle_free(void *cookie) +{ + return B_OK; +} + + +static status_t +cpuidle_ioctl(void *cookie, uint32 op, void *buffer, size_t length) +{ + return B_OK; +} + + +static status_t +cpuidle_read(void *cookie, off_t pos, void *buffer, size_t *length) +{ + *length = 0; + return B_OK; +} + + +static status_t +cpuidle_write(void *cookie, off_t pos, const void *buffer, size_t *_length) +{ + return B_OK; +} + + +status_t +init_hardware(void) +{ + return B_OK; +} + + +const char ** +publish_devices(void) +{ + static const char *devices[] = { + DEVICE_NAME, + NULL + }; + + return devices; +} + + +device_hooks * +find_device(const char *name) +{ + static device_hooks hooks = { + &cpuidle_open, + &cpuidle_close, + &cpuidle_free, + &cpuidle_ioctl, + &cpuidle_read, + &cpuidle_write, + }; + + + return &hooks; +} + + +status_t +init_driver(void) +{ + status_t err; + + err = get_module(B_CPUIDLE_MODULE_NAME, (module_info **)&sCpuidleModule); + if (err != B_OK) { + dprintf("can't load "B_CPUIDLE_MODULE_NAME"\n"); + } + return B_OK; +} + + +void +uninit_driver(void) +{ + put_module(B_CPUIDLE_MODULE_NAME); +}