usb_x.c revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
#ifdef USB_DISK
/*******************************************************************************
*
*
* Copyright 2003 Steven James <pyro@linuxlabs.com> and
* LinuxLabs http://www.linuxlabs.com
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
******************************************************************************/
#include <etherboot.h>
#include <pci.h>
#include <timer.h>
#include <lib.h>
#define DEBUG_THIS DEBUG_USB
#include <debug.h>
#include "usb.h"
#include "scsi_cmds.h"
struct usbdisk_info_t {
struct controller *ctrl;
int address_mode;
#define ADDRESS_MODE_CHS 0
#define ADDRESS_MODE_LBA 1
#define ADDRESS_MODE_LBA48 2
#define ADDRESS_MODE_PACKET 3
unsigned drive_exists : 1;
unsigned slave_absent : 1;
unsigned removable : 1;
unsigned char usb_device_address;
};
struct usbdisk_info_t usbdisk_info;
#define TEST 0
#if TEST==1
#include "usb_scsi_low.h"
typedef struct partition_entry {
unsigned int lba_start;
unsigned int lba_len;
typedef struct partition {
char loader[446];
char sig[2];
#endif
{
#if TEST==1
unsigned char sense_data[32];
#endif
int i,res;
int error_count=100;
printf("LinuxLabs USB bootloader\n");
// outb( 0x30, 0x70); // reset primary boot
// outb( 0xff, 0x71);
init_devices();
hci_init();
info->usb_device_address = 0;
// find first usb device
if(res<0)
if(!--error_count)
printf("There is a USB device, but it won't init! This is a bad thing.\n");
for(i=0; i< next_usb_dev ; i++) {
if(usb_device[i].class == 0x08 && usb_device[i].subclass == 0x06 && usb_device[i].protocol == 0x50) {
printf("Found USB block device %d\n", i);
if(drive==0) {
info->usb_device_address = i;
break;
}
drive--;
}
}
#if TEST==1
//Test
printf("Requesting initial sense data\n");
res=-1;
for(i=0; i<4; i++) {
printf("%d: boot=%02x, start=%08x length=%08x\n",i, part.entry[i].boot_flag, part.entry[i].lba_start, part.entry[i]
.lba_len);
}
#endif
return 0;
}
{
int result;
int i;
// printf("sector= %d\t", blocknum);
#if 0
for(i=0;i<128;i++) {
}
#endif
return 0;
}
#endif