Remove old devices.c code
This commit is contained in:
1 parent
6e710dcac9
commit
564b0715f1
4 files changed
+22
-149
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
include ../config.mk
|
||||
OBJ=main.o hexdump.o dump.o flash.o serial.o qmode.o
|
||||
OBJ+=fpid.o query.o pieces.o utils.o devices.o console.o
|
||||
OBJ+=fpid.o query.o pieces.o utils.o console.o
|
||||
OBJ+=squeue/squeue.o
|
||||
BIN=0xFFFF
|
||||
#LIBS=`${HAVE_USB} && echo -- '-lusb'`
|
||||
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
||||
* Copyright (C) 2007-2009 pancake <pancake@nopcode.org>
|
||||
* Copyright (C) 2012 Pali Rohár <pali.rohar@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if HAVE_USB
|
||||
#include "main.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
* The internet tablet PC (and probably most of
|
||||
* Nokia devices have different USB-IDs depending
|
||||
* on the boot state.
|
||||
*
|
||||
* The following table shows this info:
|
||||
*
|
||||
* omap-rom nolo flash-mode mass-stor pc-suite
|
||||
* 770 0421:0105 0421:0431
|
||||
* n800 0421:04c3 0421:0431
|
||||
* n810 0421:0105
|
||||
* n900 0421:0106 0421:0105 0421:01c8 0421:01c7 0421:01c8
|
||||
* n950 0421:0105 0421:01c8
|
||||
*
|
||||
* mode images protocol
|
||||
* omap-rom 2nd, secondary OMAP messages + Nokia X-Loader protocol
|
||||
* nolo all except mmc NOLO
|
||||
* flash-mode all except rootfs Mk II
|
||||
* mass-storage sd, first emmc Standard USB Mass Storage
|
||||
* pc-suite all except rootfs Mk II
|
||||
*
|
||||
*/
|
||||
struct devices supported_devices[SUPPORTED_DEVICES] = {
|
||||
{ "FFFF", 0x0000, 0x0000, FLASH_NORMAL }, // dummy
|
||||
{ "unkn", 0x0421, 0x3f00, FLASH_NORMAL }, // probably a development board
|
||||
{ "n800", 0x0421, 0x04c3, FLASH_NORMAL }, // n800
|
||||
{ "770/n810/n900/n950", 0x0421, 0x0105, FLASH_NORMAL }, // 770, n810, n900, n950
|
||||
{ "n900", 0x0421, 0x0106, FLASH_COLD }, // n900 cold flashing
|
||||
{ "n900/n950", 0x0421, 0x01c8, FLASH_MKII }, // n900 mmc flashing, n950 full flashing
|
||||
{ "770/n800", 0x0421, 0x0431, FLASH_DISK }, // 770, n800 usb mass storage
|
||||
{ "n900", 0x0421, 0x01c7, FLASH_DISK }, // n900 usb mass storage
|
||||
{ NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/** Returns 0 when no device was found and a positive
|
||||
* non-zero value when one was found.
|
||||
*
|
||||
* The return value is the index into the supported_devices
|
||||
* array which denotes the device which was found.
|
||||
*/
|
||||
int is_valid_device(struct usb_device_descriptor *udd)
|
||||
{
|
||||
int i;
|
||||
struct devices ptr = supported_devices[1];
|
||||
|
||||
for(i=1 ; ptr.vendor_id; ptr = supported_devices[++i])
|
||||
if ((udd->idVendor == ptr.vendor_id)
|
||||
&& (udd->idProduct == ptr.product_id)) {
|
||||
D printf("found %s\n", supported_devices[i].name);
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* List all supported device-ids and it's names
|
||||
*
|
||||
*/
|
||||
void list_valid_devices()
|
||||
{
|
||||
int i;
|
||||
struct devices ptr = supported_devices[1];
|
||||
|
||||
for(i=1; ptr.name; ptr = supported_devices[++i])
|
||||
printf("%04x:%04x %s\n", ptr.vendor_id, ptr.product_id, ptr.name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true (1) when a valid usb device is found and stores the udd and devices
|
||||
* structures for the specified device.
|
||||
* Otherwise returns false (0)
|
||||
*/
|
||||
int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_device)
|
||||
{
|
||||
int dev_index = 0;
|
||||
struct usb_bus *bus;
|
||||
if ((usb_find_busses()<0) || (usb_find_devices()==-1)) {
|
||||
fprintf(stderr, "\nerror: no usb bus or device found.\n");
|
||||
exit(1);
|
||||
} else {
|
||||
for (bus = usb_busses; bus; bus = bus->next) {
|
||||
struct usb_device *dev = bus->devices;
|
||||
D printf("bus: \n");
|
||||
for (; dev; dev = dev->next) {
|
||||
*udd = dev->descriptor;
|
||||
D printf(" dev (%s) - ", dev->filename);
|
||||
D printf("vendor: %04x product: %04x\n", udd->idVendor, udd->idProduct);
|
||||
|
||||
if ((dev_index = is_valid_device(udd))) {
|
||||
device = dev;
|
||||
printf("%s found!\n", dev->filename);
|
||||
*it_device = supported_devices[dev_index];
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
+14
-14
@@ -330,7 +330,7 @@ int connect_via_usb()
|
||||
{
|
||||
static char pbc[]={'/','-','\\', '|'};
|
||||
struct usb_device_descriptor udd;
|
||||
struct devices it_device;
|
||||
// struct devices it_device;
|
||||
int c = 0;
|
||||
|
||||
// usb_set_debug(5);
|
||||
@@ -346,11 +346,11 @@ int connect_via_usb()
|
||||
while(!dev) {
|
||||
usleep(0xc350); // 0.5s
|
||||
|
||||
if(!usb_device_found(&udd, &it_device)) {
|
||||
/* if(!usb_device_found(&udd, &it_device)) {
|
||||
printf("\rWaiting for device... %c", pbc[++c%4]);
|
||||
fflush(stdout);
|
||||
continue;
|
||||
}
|
||||
}*/
|
||||
|
||||
/* open device */
|
||||
if(!(dev = usb_open(device))) {
|
||||
@@ -397,8 +397,8 @@ usb_detach_kernel_driver_np(dev, 2);
|
||||
break;
|
||||
}
|
||||
|
||||
printf("found %s (%04x:%04x)\n", it_device.name,
|
||||
it_device.vendor_id, it_device.product_id);
|
||||
// printf("found %s (%04x:%04x)\n", it_device.name,
|
||||
// it_device.vendor_id, it_device.product_id);
|
||||
|
||||
/* go go go! */
|
||||
while(get_status());
|
||||
@@ -439,12 +439,12 @@ int main(int argc, char **argv)
|
||||
// case 'F':
|
||||
// fiasco_image = optarg;
|
||||
// break;
|
||||
case 'd':
|
||||
sscanf(optarg, "%04hx:%04hx",
|
||||
&supported_devices[SUPPORTED_DEVICES-2].vendor_id,
|
||||
&supported_devices[SUPPORTED_DEVICES-2].product_id);
|
||||
supported_devices[SUPPORTED_DEVICES-2].name = strdup("user");
|
||||
break;
|
||||
// case 'd':
|
||||
// sscanf(optarg, "%04hx:%04hx",
|
||||
// &supported_devices[SUPPORTED_DEVICES-2].vendor_id,
|
||||
// &supported_devices[SUPPORTED_DEVICES-2].product_id);
|
||||
// supported_devices[SUPPORTED_DEVICES-2].name = strdup("user");
|
||||
// break;
|
||||
case 'D':
|
||||
root_device = atoi(optarg);
|
||||
break;
|
||||
@@ -463,9 +463,9 @@ int main(int argc, char **argv)
|
||||
case 'r':
|
||||
rd_mode = atoi(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
list_valid_devices();
|
||||
return 0;
|
||||
// case 'l':
|
||||
// list_valid_devices();
|
||||
// return 0;
|
||||
case 'p':
|
||||
add_piece(optarg);
|
||||
break;
|
||||
|
||||
+7
-7
@@ -10,7 +10,7 @@ extern char strbuf[1024];
|
||||
#define _GNU_SOURCE
|
||||
|
||||
// Forward declaration for use in function arguments.
|
||||
struct devices;
|
||||
//struct devices;
|
||||
|
||||
int queue_mode();
|
||||
int reverse_extract_pieces(char *dir);
|
||||
@@ -36,8 +36,8 @@ int fiasco_flash(const char *file);
|
||||
extern struct usb_device *device;
|
||||
extern struct usb_dev_handle *dev;
|
||||
int is_valid_device(struct usb_device_descriptor *udd);
|
||||
void list_valid_devices();
|
||||
int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_device);
|
||||
//void list_valid_devices();
|
||||
//int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_device);
|
||||
int console(const char *device);
|
||||
int connect_via_usb();
|
||||
#endif
|
||||
@@ -70,15 +70,15 @@ enum flash_mode {
|
||||
FLASH_DISK,
|
||||
};
|
||||
|
||||
struct devices {
|
||||
/*struct devices {
|
||||
char *name;
|
||||
unsigned short vendor_id;
|
||||
unsigned short product_id;
|
||||
enum flash_mode mode;
|
||||
};
|
||||
};*/
|
||||
|
||||
#define SUPPORTED_DEVICES 10
|
||||
extern struct devices supported_devices[SUPPORTED_DEVICES];
|
||||
//#define SUPPORTED_DEVICES 10
|
||||
//extern struct devices supported_devices[SUPPORTED_DEVICES];
|
||||
|
||||
extern int pcs_n;
|
||||
extern struct piece_t pcs[10];
|
||||
|
||||
Reference in new issue
Block a user