Rev 931 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
////// Copyright 2010 TheSeven////// This file is part of emCORE.//// emCORE 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 2 of the// License, or (at your option) any later version.//// emCORE 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 emCORE. If not, see <http://www.gnu.org/licenses/>.////#include "global.h"#include "usb/usbtarget.h"#include "usb/usb.h"#include "storage_ata-target.h"#include "thread.h"int usb_target_handle_request(uint32_t* buf, int bufsize, void** addr){int len = 0;switch (buf[0]){case 0xffff0001: // GET DISK INFObuf[0] = 1;buf[1] = (uint32_t)ata_identify_data;buf[2] = ata_total_sectors;buf[3] = ata_total_sectors >> 32;#ifdef ATA_HAVE_BBTbuf[4] = ata_virtual_sectors;buf[5] = ata_virtual_sectors >> 32;buf[6] = (uint32_t)ata_bbt;buf[7] = 0;#elsebuf[4] = ata_total_sectors;buf[5] = ata_total_sectors >> 32;buf[6] = 0;buf[7] = 0;#endiflen = 16;break;case 0xffff0002: // LOWLEVEL DISK ACCESSbuf[0] = 1;mutex_lock(&ata_mutex, TIMEOUT_BLOCK);#ifdef ATA_HAVE_BBTbuf[1] = (uint32_t)ata_rw_sectors_internal((((uint64_t)(buf[3])) << 32) | buf[2],buf[4], (void*)(buf[5]), (bool)(buf[1]));#elsebuf[1] = (uint32_t)ata_rw_sectors((((uint64_t)(buf[3])) << 32) | buf[2],buf[4], (void*)(buf[5]), (bool)(buf[1]));#endifmutex_unlock(&ata_mutex);break;case 0xffff0003: // ATA_BBT_RELOAData_bbt_reload();buf[0] = 1;break;case 0xffff0004: // ATA_BBT_DISABLEata_bbt_disable();buf[0] = 1;break;default:buf[0] = 2;break;}return len;}