10 extern uint16_t UsbDeviceDescriptor[];
13 /* This number gets bumped on each official build. */
14 // uint32_t cmnos_target_software_id = AR6K_SW_VERSION;
20 cmnos_system_reset(void)
22 /* TBD: to be finished */
24 * sytem reset backdoor
26 HAL_WORD_REG_WRITE(MAGPIE_REG_RST_RESET_ADDR, (0x1<<24));
33 #LOCAL void cmnos_wdt_reset(void)
35 HAL_WORD_REG_WRITE(MAGPIE_REG_RST_RESET_ADDR, (0x1<<24));
45 /* TBD: to be finished */
51 volatile int assloop = 1;
54 //A_COMPILE_TIME_ASSERT(verify_RD_SIZE, (RD_SIZE == sizeof(CPU_exception_frame_t)))
57 cmnos_misaligned_load_handler(struct register_dump_s *dump)
59 /* TBD: to be finished */
60 if (A_IML_IS_ASSERT(dump->badvaddr)) {
62 * Probably an Intentional Misaligned Load, used to
63 * signal an assertion failure
65 dump->assline = A_IML_ASSLINE(dump->badvaddr);
68 /* A genuine misaligned load */
69 A_PRINTF("Misaligned load: pc=0x%x badvaddr=0x%x dump area=0x%x\n",
70 dump->pc, dump->badvaddr, dump);
72 A_ASSFAIL(dump); /* Not really an assertion failure, but we'll treat it similarly. */
75 // trigger wdt, in case hang
76 HAL_WORD_REG_WRITE(MAGPIE_REG_RST_WDT_TIMER_CTRL_ADDR, 0x03);
77 HAL_WORD_REG_WRITE(MAGPIE_REG_RST_WDT_TIMER_ADDR, 0x10);
82 struct register_dump_s *current_dump = NULL;
85 * A convenient place to set a breakpoint.
86 * Whenever an A_ASSERT triggers, it comes here.
89 cmnos_assfail(struct register_dump_s *dump)
91 if (current_dump == NULL ) {
95 //A_TARGET_ID_GET(&target_id);
96 dump->target_id = target_id;
101 A_PRINTF("assertion failed? pc=0x%x, line=%d, dump area=0x%x\n",
102 dump->pc, dump->assline, dump);
103 // INF_DBG2_LOG(INF_ASSERTION_FAILED, dump->pc,
104 // A_IML_ASSLINE(dump->badvaddr));
105 // INF_DBG1_LOG(INF_ASSERTION_FAILED, (A_UINT32)dump);
107 A_PRINTF("Target ID: 0x%x (%d)\n", target_id, target_id);
108 // INF_DBG1_LOG(INF_TARGET_ID, target_id);
110 A_PRINTF("Debug Info:");
111 for (i=0; i<(sizeof(struct register_dump_s)/sizeof(A_UINT32)); i++) {
115 A_PRINTF("0x%08x ", ((A_UINT32 *)dump)[i]);
116 // INF_DBG1_LOG(INF_ASSERTION_FAILED, ((A_UINT32 *)dump)[i]);
122 * We must have assfail'ed again while processing the first assfail.
123 * Don't try to print anything -- keep it very simple.
130 * failure state report
133 cmnos_report_failure_to_host(struct register_dump_s *dump, int len)
135 /* TBD: to be removed! */
142 cmnos_target_id_get(void)
144 /* TBD: to be removed! */
148 * get keyboard hit with delay
151 cmnos_get_kbhit(uint8_t delay)
153 uint32_t last_ccount;
156 last_ccount = xthal_get_ccount();
159 if( A_GETC(&kbhit) != 0 )
162 if((xthal_get_ccount() - last_ccount)>=delay*1000*ONE_MSEC)
172 * host alive & return the hostif type
175 cmnos_is_host_present(void)
178 * TODO: check the hostif and return the type of host interface
180 A_HOSTIF mHif = HIF_USB;
181 #if defined(PROJECT_K2)
182 A_PRINTF("5. usb only!!\n");
184 #elif defined(PROJECT_MAGPIE)
187 mData = MAGPIE_REG_RST_BOOTSTRAP;
189 //@RYAN@TODO - this one is somehow not working on L5, need to turn on!!!
191 /* 4:3 of BOOTSTRAP could distinguish the host interfce
214 //A_PRINTF("5. hif (0x%08x) is read!!\n", mData);
220 * get ROM code version
223 cmnos_rom_version_get(void)
225 #if SYSTEM_MODULE_USB
226 /* USB Device Descriptor : byte 12, 13 Device BCD -> Device release number in binary-coded decimal. */
227 return UsbDeviceDescriptor[6];
234 cmnos_misc_module_install(struct misc_api *tbl)
236 tbl->_system_reset = cmnos_system_reset;
237 tbl->_mac_reset = cmnos_mac_reset;
238 tbl->_assfail = cmnos_assfail;
239 tbl->_misaligned_load_handler= cmnos_misaligned_load_handler;
240 tbl->_report_failure_to_host = cmnos_report_failure_to_host;
241 //tbl->_target_id_get = cmnos_target_id_get;
242 tbl->_is_host_present = cmnos_is_host_present;
243 tbl->_kbhit = cmnos_get_kbhit;
244 tbl->_rom_version_get = cmnos_rom_version_get;