unit |= t[7] << 8;
(*set)(c000x, c2aaa, c5555, unit);
}
-static uint8_t cpu_buffer[FLASH_PACKET_SIZE];
-static uint8_t ppu_buffer[FLASH_PACKET_SIZE];
+/*static uint8_t cpu_buffer[FLASH_PACKET_SIZE];
+static uint8_t ppu_buffer[FLASH_PACKET_SIZE];*/
uchar usbFunctionWrite(uchar *data, uchar len)
{
-// static uint8_t cpu_buffer[FLASH_PACKET_SIZE];
-// static uint8_t ppu_buffer[FLASH_PACKET_SIZE];
+ static uint8_t cpu_buffer[FLASH_PACKET_SIZE];
+ static uint8_t ppu_buffer[FLASH_PACKET_SIZE];
const uint16_t length = (uint16_t) len;
-
+ uchar i;
+ //decode masked data
+ for(i = 0; i < len; i++){
+ data[i] ^= 0xa5;
+ }
switch(request_both_write.request){
case REQUEST_CPU_WRITE_6502:
cpu_write_6502(request_both_write.address + request_both_write.offset, length, data);
memcpy(w, data, length);
w += length;
request_cpu_program.offset += length;
- int ret = request_cpu_program.offset >= request_cpu_program.length;
+ int ret = request_cpu_program.offset == request_cpu_program.length;
if(ret){
if(request_cpu_program.request == REQUEST_FLASH_CONFIG_SET){
flash_config_set(cpu_buffer, flash_cpu_config);
memcpy(w, data, length);
w += length;
request_ppu_program.offset += length;
- int ret = request_ppu_program.offset >= request_ppu_program.length;
+ int ret = request_ppu_program.offset == request_ppu_program.length;
if(ret){
if(request_ppu_program.request == REQUEST_FLASH_CONFIG_SET){
flash_config_set(ppu_buffer, flash_ppu_config);
write_command->address = rq->wValue.word;
write_command->offset = 0;
return USB_NO_MSG; //goto usbFunctionWrite
- case REQUEST_FLASH_BUFFER_GET:
+/* case REQUEST_FLASH_BUFFER_GET:
if(rq->wIndex.word == INDEX_CPU){
usbMsgPtr = cpu_buffer;
}else{
usbMsgPtr = ppu_buffer;
}
- return FLASH_PACKET_SIZE;
+ return FLASH_PACKET_SIZE;*/
case REQUEST_DISK_STATUS_GET:
usbMsgPtr = status;
return disk_status_get(status);
case REQUEST_DISK_WRITE:
disk_init(DISK_WRITE);
return 0;
- case REQUEST_BOTH_FLASH_STATUS:
- status[0] = flash_cpu_status();
- status[1] = flash_ppu_status();
- usbMsgPtr = status;
- return 2;
case REQUEST_FLASH_STATUS:
- if(rq->wIndex.word == INDEX_CPU){
+ usbMsgPtr = status;
+ switch((enum index) rq->wIndex.word){
+ case INDEX_CPU:
status[0] = flash_cpu_status();
- }else{
+ return 1;
+ case INDEX_PPU:
status[0] = flash_ppu_status();
+ return 1;
+ default:
+ status[0] = flash_cpu_status();
+ status[1] = flash_ppu_status();
+ return 2;
}
- usbMsgPtr = status;
return 1;
case REQUEST_FLASH_DEVICE:
if(rq->wIndex.word == INDEX_CPU){
REQUEST_CPU_READ_6502, REQUEST_CPU_READ,
REQUEST_CPU_WRITE_6502, REQUEST_CPU_WRITE_FLASH,
REQUEST_PPU_READ, REQUEST_PPU_WRITE,
- REQUEST_BOTH_FLASH_STATUS,
REQUEST_FLASH_STATUS, REQUEST_FLASH_CONFIG_SET,
REQUEST_FLASH_PROGRAM, REQUEST_FLASH_ERASE,
- REQUEST_FLASH_DEVICE, REQUEST_FLASH_BUFFER_GET,
+ REQUEST_FLASH_DEVICE, //REQUEST_FLASH_BUFFER_GET,
REQUEST_VRAM_CONNECTION,
//future expanstion
- REQUEST_CPU_WRITE_FLASH is assigned for debugging.
- REQUEST_PPU_WRITE is assigned for dectecting charcter ROM or RAM.
-REQUEST_CPU_FLASH_CONFIG_SET
-REQUEST_PPU_FLASH_CONFIG_SET
+REQUEST_FLASH_CONFIG_SET
R/W: write (task)
Arguments:
wLength: must be set as a value of 8
wValue: not used
- wIndex: not used
+ wIndex: target memory region. INDEX_CPU or INDEX_PPU
bData: programmed data for current memory region
bData[0] bit0-7 for command address 0x0000 (c000x)
bData[1] bit8-15 for command address 0x0000 (c000x)
mapper and flash memory device. Please note that address (c000x) is
reserved for future expansion, so currently that address has no effect.
-REQUEST_CPU_FLASH_PROGRAM
-REQUEST_PPU_FLASH_PROGRAM
+REQUEST_FLASH_PROGRAM
R/W: write (task)
Arguments:
wLength: programming length
wValue: target address on current memory region
- wIndex: not used
+ wIndex: target memory region. INDEX_CPU or INDEX_PPU
bData: programming data for current memory region
Returns: nothing
Description:
REQUEST_DISK_READ
REQUEST_DISK_WRITE
(For reference only, these are currently reserved for future expansion.)
-
-REQUEST_BOTH_FLASH_STATUS
+REQUEST_FLASH_STATUS
R/W: read
Arguments:
- wLength: must be set as a value of 2
+ wLength: must be set as a value of 1 or 2
wValue: not used
- wIndex: not used
+ wIndex: target memory region. INDEX_CPU, INDEX_PPU or INDEX_BOTH
Returns:
+when wIndex is INDEX_CPU or INDEX_PPU:
+ data[0]: current memory region's flash programming task status
+when wIndex is INDEX_BOTH:
data[0]: CPU flash programming task status
data[1]: PPU flash programming task status
Description:
-This request determines the flash programming task status for both the
-CPU and PPU. If the request returns a value of 0, the current task is
-considered idle. In this case, the host software can proceed to send
-the next programming request.
-
-REQUEST_CPU_FLASH_STATUS
-REQUEST_PPU_FLASH_STATUS
-R/W: read
-Arguments:
- wLength: must be set as a value of 1
- wValue: not used
- wIndex: not used
-Returns:
- data[0]: current memory region's flash programming task status
-Description:
This request determines the flash programming task status for either
the CPU or PPU individually. Please see the description for
REQUEST_BOTH_FLASH_STATUS for more info.
-REQUEST_CPU_FLASH_DEVICE
-REQUEST_PPU_FLASH_DEVICE
+REQUEST_FLASH_DEVICE
R/W: read
Arguments:
wLength: must be set as a value of 2
wValue: not used
- wIndex: not used
+ wIndex: target memory region. INDEX_CPU or INDEX_PPU
Returns:
data[0]: flash memory device manufacturer code
data[1]: flash memory device device code
to retrieve the flash memory's product ID. Otherwise this does not
function correctly at this time.
-REQUEST_CPU_FLASH_ERASE
-REQUEST_PPU_FLASH_ERASE
+REQUEST_FLASH_ERASE
R/W: write (task)
Arguments:
wLength: must be set as a value of 0
wValue: confirmed current region address during erase
- wIndex: not used
+ wIndex: target memory region. INDEX_CPU or INDEX_PPU
Returns: nothing
Description:
Firmware registers an 'erase task' on flash memory. The host software
can retrieve the current progress status via the aforementioned
-REQUEST_xxx_FLASH_STATUS requests.
+REQUEST_FLASH_STATUS requests.
REQUEST_VRAM_CONNECTION
R/W: read