command.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * =====================================================================================
  3. *
  4. * ________ .__ __ ________ ____ ________
  5. * \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
  6. * / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
  7. * / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
  8. * \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
  9. * \__> \/ \/ \/ \/ \/
  10. *
  11. * www.optixx.org
  12. *
  13. *
  14. * Version: 1.0
  15. * Created: 07/21/2009 03:32:16 PM
  16. * Author: david@optixx.org
  17. *
  18. * =====================================================================================
  19. */
  20. #include <avr/io.h>
  21. #include <avr/interrupt.h>
  22. #include <util/delay.h>
  23. #include <stdlib.h>
  24. #include "config.h"
  25. #include "requests.h"
  26. #include "sram.h"
  27. #include "info.h"
  28. #include "irq.h"
  29. #include "usbdrv.h"
  30. #include "rle.h"
  31. #include "loader.h"
  32. #include "system.h"
  33. #include "neginf/neginf.h"
  34. #include "inflate.h"
  35. extern usb_transaction_t usb_trans;
  36. extern system_t system;
  37. extern const char *_rom[];
  38. extern const char _rom01[];
  39. extern const int _rom_size[];
  40. void usb_connect()
  41. {
  42. uint8_t i = 0;
  43. info_P(PSTR("USB init\n"));
  44. usbDeviceDisconnect(); /* enforce re-enumeration, do this while */
  45. cli();
  46. info_P(PSTR("USB disconnect\n"));
  47. i = 10;
  48. while (--i) { /* fake USB disconnect for > 250 ms */
  49. _delay_ms(50);
  50. }
  51. led_on();
  52. usbDeviceConnect();
  53. info_P(PSTR("USB connect\n"));
  54. }
  55. void boot_startup_rom(uint16_t init_delay)
  56. {
  57. uint8_t i;
  58. uint8_t c;
  59. uint16_t j;
  60. uint32_t addr = 0x000000;
  61. PGM_VOID_P p_addr;
  62. info_P(PSTR("Fetch loader rom\n"));
  63. system_set_bus_avr();
  64. snes_irq_lo();
  65. system_snes_irq_off();
  66. system_set_rom_lorom();
  67. inflate_init();
  68. for (i=0; i<ROM_BUFFER_CNT; i++){
  69. p_addr = _rom[i];
  70. printf("idx: %i %lx\n",i,p_addr);
  71. for (j=0; j<_rom_size[i]; j++){
  72. //rle_decode(_rom[i], _rom_size[i], addr);
  73. c = pgm_read_byte((PGM_VOID_P)p_addr++);
  74. printf("%02x ",c);
  75. neginf_process_byte(c);
  76. }
  77. }
  78. info_P(PSTR("\n"));
  79. #if DO_CRC_CHECK_LOADER
  80. dump_memory(0x010000 - 0x100, 0x010000);
  81. uint16_t crc;
  82. crc = crc_check_bulk_memory((uint32_t)0x000000,0x010000, 0x010000);
  83. info(PSTR("crc=%x\n"),crc);
  84. #endif
  85. snes_irq_lo();
  86. system_snes_irq_off();
  87. system_set_rom_hirom();
  88. system_set_wr_disable();
  89. system_set_bus_snes();
  90. system_send_snes_reset();
  91. _delay_ms(init_delay);
  92. }
  93. void banner(){
  94. }
  95. void transaction_status(){
  96. }