summaryrefslogtreecommitdiffstats
path: root/src/operations.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2012-11-15 01:40:09 +0100
committerPali Rohár <pali.rohar@gmail.com>2012-11-15 01:40:09 +0100
commitcc8cca84ef2ffbf6d3b901d9064abcf9fb019ba8 (patch)
tree3cc0208c45eca30edd9f382ef76dcff7ce19ab44 /src/operations.c
parente98891e52d4acc9affd206901aa4ffb40f2d89b6 (diff)
download0xFFFF-cc8cca84ef2ffbf6d3b901d9064abcf9fb019ba8.tar.bz2
operations: Added support for local device
Diffstat (limited to 'src/operations.c')
-rw-r--r--src/operations.c69
1 files changed, 68 insertions, 1 deletions
diff --git a/src/operations.c b/src/operations.c
index 1dc85c0..793499d 100644
--- a/src/operations.c
+++ b/src/operations.c
@@ -22,6 +22,7 @@
#include "usb-device.h"
#include "cold-flash.h"
#include "nolo.h"
+#include "local.h"
#include "operations.h"
@@ -35,7 +36,13 @@ struct device_info * dev_detect(void) {
if ( ! dev )
goto clean;
- /* TODO: LOCAL */
+ /* LOCAL */
+ if ( local_init() == 0 ) {
+ dev->method = METHOD_LOCAL;
+ dev->detected_device = local_get_device();
+ dev->detected_hwrev = local_get_hwrev();
+ return dev;
+ }
/* USB */
usb = usb_open_and_wait_for_device();
@@ -87,6 +94,9 @@ void dev_free(struct device_info * dev) {
enum device dev_get_device(struct device_info * dev) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_get_device();
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -182,6 +192,9 @@ int dev_boot_device(struct device_info * dev, const char * cmdline) {
int dev_reboot_device(struct device_info * dev) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_reboot_device();
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -200,6 +213,9 @@ int dev_reboot_device(struct device_info * dev) {
int dev_get_root_device(struct device_info * dev) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_get_root_device();
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -213,6 +229,9 @@ int dev_get_root_device(struct device_info * dev) {
int dev_set_root_device(struct device_info * dev, int device) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_set_root_device(device);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -231,6 +250,9 @@ int dev_set_root_device(struct device_info * dev, int device) {
int dev_get_usb_host_mode(struct device_info * dev) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_get_usb_host_mode();
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -244,6 +266,9 @@ int dev_get_usb_host_mode(struct device_info * dev) {
int dev_set_usb_host_mode(struct device_info * dev, int enable) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_set_usb_host_mode(enable);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -262,6 +287,9 @@ int dev_set_usb_host_mode(struct device_info * dev, int enable) {
int dev_get_rd_mode(struct device_info * dev) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_get_rd_mode();
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -275,6 +303,9 @@ int dev_get_rd_mode(struct device_info * dev) {
int dev_set_rd_mode(struct device_info * dev, int enable) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_set_rd_mode(enable);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -293,6 +324,9 @@ int dev_set_rd_mode(struct device_info * dev, int enable) {
int dev_get_rd_flags(struct device_info * dev, char * flags, size_t size) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_get_rd_flags(flags, size);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -306,6 +340,9 @@ int dev_get_rd_flags(struct device_info * dev, char * flags, size_t size) {
int dev_set_rd_flags(struct device_info * dev, const char * flags) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_set_rd_flags(flags);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -324,6 +361,9 @@ int dev_set_rd_flags(struct device_info * dev, const char * flags) {
int16_t dev_get_hwrev(struct device_info * dev) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_get_hwrev();
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -337,6 +377,9 @@ int16_t dev_get_hwrev(struct device_info * dev) {
int dev_set_hwrev(struct device_info * dev, int16_t hwrev) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_set_hwrev(hwrev);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -355,6 +398,9 @@ int dev_set_hwrev(struct device_info * dev, int16_t hwrev) {
int dev_get_kernel_ver(struct device_info * dev, char * ver, size_t size) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_get_kernel_ver(ver, size);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -368,6 +414,9 @@ int dev_get_kernel_ver(struct device_info * dev, char * ver, size_t size) {
int dev_set_kernel_ver(struct device_info * dev, const char * ver) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_set_kernel_ver(ver);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -386,6 +435,9 @@ int dev_set_kernel_ver(struct device_info * dev, const char * ver) {
int dev_get_nolo_ver(struct device_info * dev, char * ver, size_t size) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_get_nolo_ver(ver, size);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -399,6 +451,9 @@ int dev_get_nolo_ver(struct device_info * dev, char * ver, size_t size) {
int dev_set_nolo_ver(struct device_info * dev, const char * ver) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_set_nolo_ver(ver);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -417,6 +472,9 @@ int dev_set_nolo_ver(struct device_info * dev, const char * ver) {
int dev_get_sw_ver(struct device_info * dev, char * ver, size_t size) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_get_sw_ver(ver, size);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -430,6 +488,9 @@ int dev_get_sw_ver(struct device_info * dev, char * ver, size_t size) {
int dev_set_sw_ver(struct device_info * dev, const char * ver) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_set_sw_ver(ver);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -448,6 +509,9 @@ int dev_set_sw_ver(struct device_info * dev, const char * ver) {
int dev_get_content_ver(struct device_info * dev, char * ver, size_t size) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_get_content_ver(ver, size);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )
@@ -461,6 +525,9 @@ int dev_get_content_ver(struct device_info * dev, char * ver, size_t size) {
int dev_set_content_ver(struct device_info * dev, const char * ver) {
+ if ( dev->method == METHOD_LOCAL )
+ return local_set_content_ver(ver);
+
if ( dev->method == METHOD_USB ) {
if ( dev->usb->flash_device->protocol == FLASH_NOLO )