/* * Configure PORT_1C as data with PORT_1D as the valid signal. Test receiving * two different words of data and check they are the correct values. */ void port_test_input(chanend c) { port p = port_enable(XS1_PORT_1C); port_set_buffered(p); port_set_transfer_width(p, 32); port p_ready = port_enable(XS1_PORT_1D); clock clk = clock_enable(XS1_CLKBLK_2); clock_start(clk); port_configure_in_strobed_slave(p, p_ready, clk); chan_output_word(c, 0); // Send ack unsigned int x = port_input(p); if (x != 0xfeedbeef) { debug_printf("Error %x received instead of 0xfeedbeef\n", x); } x = port_input(p); if (x != 0x12345678) { debug_printf("Error %x received instead of 0x12345678\n", x); } chan_output_word(c, 0); // Send ack port_disable(p); port_disable(p_ready); clock_disable(clk); // Get information about the tile/core running the server for debug messages unsigned tile_id = get_local_tile_id(); unsigned core_id = get_logical_core_id(); debug_printf("%x:%d: input done\n", tile_id, core_id); }
/* * Configure PORT_1A as data with PORT_1B as the valid signal. Ensure that the * receiver is ready using a channel end. Send a word of data, delay for a while * and send another word to ensure the valid signals are functioning. */ void port_test_output(chanend c) { port p = port_enable(XS1_PORT_1A); port_set_buffered(p); port_set_transfer_width(p, 32); port p_ready = port_enable(XS1_PORT_1B); clock clk = clock_enable(XS1_CLKBLK_1); clock_start(clk); port_configure_out_strobed_master(p, p_ready, clk, 0); chan_input_word(c); // Wait for ack port_output(p, 0xfeedbeef); timer tmr = timer_alloc(); timer_delay(tmr, 1000); timer_free(tmr); port_output(p, 0x12345678); chan_input_word(c); // Wait for ack port_disable(p); port_disable(p_ready); clock_disable(clk); // Get information about the tile/core running the server for debug messages unsigned tile_id = get_local_tile_id(); unsigned core_id = get_logical_core_id(); debug_printf("%x:%d: output done\n", tile_id, core_id); }
OMX_ERRORTYPE process_event(HTEST *hTest, MSG *pMsg) { OMX_EVENTTYPE event = pMsg->data.event.eEvent; OMX_U32 nPortIndex = pMsg->data.event.nData1; if(event == OMX_EventPortSettingsChanged) { port_disable(hTest, nPortIndex); port_enable(hTest, nPortIndex); OMX_STATETYPE eState = OMX_StateInvalid; OMX_GetState(hTest->hComponent, &eState); if(eState == OMX_StateExecuting) { /* Send output buffers */ OMX_S32 i; for(i=0; i<hTest->nBufferHdr[1]; i++) { hTest->pBufferHdr[1][i]->nFilledLen = 0; hTest->pBufferHdr[1][i]->nOffset = 0; OMX_FillThisBuffer(hTest->hComponent, hTest->pBufferHdr[1][i]); } } } return OMX_ErrorNone; }
int main(int argc, char * const *argv) { int power_up = 0; int power_down = 0; int action_taken = 0; int ret; struct state st; int ch; struct option longopts[] = { { "list-ports", no_argument, NULL, 'l' }, { "port-enable",required_argument, &power_up, 'e' }, { "port-disable",required_argument, &power_down, 'd' }, { "help", no_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; memset(&st, 0, sizeof(st)); st.progname = argv[0]; ret = novena_hub_init(&st); if (ret) return ret; while ((ch = getopt_long(argc, argv, "le:d:h", longopts, NULL)) != -1) { switch (ch) { case 'h': print_help(&st); action_taken = 1; break; case 'e': port_enable(&st, optarg); action_taken = 1; break; case 'd': port_disable(&st, optarg); action_taken = 1; break; case 'l': list_ports(&st); action_taken = 1; break; default: break; } } if (!action_taken) print_help(&st); novena_hub_deinit(&st); return 0; }
// called on kernel panic void port_halt(void) { port_disable(); palSetPad(GPIOD, 15); // turn on blue LED while(TRUE) { } }
__weak #endif void port_halt(void) { port_disable(); while (TRUE) { } }
void e2e_dispatch(struct port *p, enum fsm_event event, int mdiff) { if (!port_state_update(p, event, mdiff)) { return; } if (!portnum(p)) { /* UDS needs no timers. */ return; } port_clr_tmo(p->fda.fd[FD_ANNOUNCE_TIMER]); port_clr_tmo(p->fda.fd[FD_SYNC_RX_TIMER]); /* Leave FD_DELAY_TIMER running. */ port_clr_tmo(p->fda.fd[FD_QUALIFICATION_TIMER]); port_clr_tmo(p->fda.fd[FD_MANNO_TIMER]); port_clr_tmo(p->fda.fd[FD_SYNC_TX_TIMER]); /* * Handle the side effects of the state transition. */ switch (p->state) { case PS_INITIALIZING: break; case PS_FAULTY: case PS_DISABLED: port_disable(p); break; case PS_LISTENING: port_set_announce_tmo(p); port_set_delay_tmo(p); break; case PS_PRE_MASTER: port_set_qualification_tmo(p); break; case PS_MASTER: case PS_GRAND_MASTER: break; case PS_PASSIVE: port_set_announce_tmo(p); break; case PS_UNCALIBRATED: flush_last_sync(p); flush_delay_req(p); /* fall through */ case PS_SLAVE: port_set_announce_tmo(p); break; }; }
/** * @brief Halts the system. * @details This function is invoked by the operating system when an * unrecoverable error is detected, for example because a programming * error in the application code that triggers an assertion while * in debug mode. * @note Can be invoked from any system state. * * @param[in] reason pointer to an error string * * @special */ void chSysHalt(const char *reason) { port_disable(); #if defined(CH_CFG_SYSTEM_HALT_HOOK) || defined(__DOXYGEN__) CH_CFG_SYSTEM_HALT_HOOK(reason); #endif /* Pointing to the passed message.*/ ch.dbg.panic_msg = reason; /* Harmless infinite loop.*/ while (true) { } }
/** * @brief Halts the system. * @details This function is invoked by the operating system when an * unrecoverable error is detected, for example because a programming * error in the application code that triggers an assertion while * in debug mode. * @note Can be invoked from any system state. * * @param[in] reason pointer to an error string * * @special */ void chSysHalt(const char *reason) { port_disable(); #if NIL_DBG_ENABLED nil.dbg_panic_msg = reason; #else (void)reason; #endif NIL_CFG_SYSTEM_HALT_HOOK(reason); /* Harmless infinite loop.*/ while (true) { } }
void port_enable(port_t *port) { DEBUG("enabling port %s", port->id); port->flags |= PORT_FLAGS_ENABLED; port_t *p, **pp = all_ports; while ((p = *pp++)) { if (!IS_ENABLED(p)) { continue; } if ((p->mutual_excl_mask & (1 << port->port_no)) || (port->mutual_excl_mask & (1 << p->port_no))) { DEBUG("port %s and %s are mutually exclusive", p->id, port->id); port_disable(p); } } }
/** * @brief Halts the system. * @details This function is invoked by the operating system when an * unrecoverable error is detected, for example because a programming * error in the application code that triggers an assertion while * in debug mode. * @note Can be invoked from any system state. * * @param[in] reason pointer to an error string * * @special */ void chSysHalt(const char *reason) { port_disable(); /* Halt hook code, usually empty.*/ CH_CFG_SYSTEM_HALT_HOOK(reason); /* Logging the event.*/ _dbg_trace_halt(reason); /* Pointing to the passed message.*/ ch.dbg.panic_msg = reason; /* Harmless infinite loop.*/ while (true) { } }
/* !DO NOT ALTER FUNCTION SIGNATURE! */ int callback_ofc_capable_switch_ofc_resources_ofc_port_ofc_configuration_ofc_admin_state (void ** data, XMLDIFF_OP op, xmlNodePtr node, struct nc_err** error) { nc_verb_verbose("%s: data=%p, op=%d\n", __PRETTY_FUNCTION__, data, op); print_element_names(node, 0); int rv = EXIT_SUCCESS; int down = 0; // default is up if ((XMLDIFF_ADD|XMLDIFF_MOD) & op) { if (xmlStrEqual(XML_GET_CONTENT(node->children), BAD_CAST "down")) { down = 1; } // sanity check... if the content is not "down", it has to be "up" assert(down || xmlStrEqual(XML_GET_CONTENT(node->children), BAD_CAST "up")); // currently the resource-id is the port name (even if the name is not set xmlNodePtr tmp = find_element(BAD_CAST "resource-id", node->parent->parent->children); assert(tmp); if (down) { // set interface down nc_verb_verbose("set interface %s down\n", tmp->children->content); if (port_disable(ofc_state.xmp_client_handle, tmp->children->content)) { rv = EXIT_FAILURE; } } else { // set interface up nc_verb_verbose("set interface %s up\n", tmp->children->content); if (port_enable(ofc_state.xmp_client_handle, tmp->children->content)) { rv = EXIT_FAILURE; } } } else if (XMLDIFF_REM & op) { // setting interface up } else { nc_verb_error("unsupported op"); assert(0); } return rv; }
OMX_ERRORTYPE parser_process_port_setting_changed(HTEST *hTest,OMX_U32 nPortIndex) { OMX_ERRORTYPE ret = OMX_ErrorNone; port_disable(hTest,nPortIndex); OMX_PARAM_U32TYPE sU32; OMX_INIT_STRUCT(&sU32, OMX_PARAM_U32TYPE); sU32.nPortIndex = nPortIndex; ret = OMX_GetParameter(hTest->hComponent,OMX_IndexParamNumAvailableStreams,&sU32); if (ret != OMX_ErrorNone) return ret; printf("%s,%d,track %d, number of available stream is %d.\n",__FUNCTION__,__LINE__,sU32.nPortIndex,sU32.nU32); /*active strem number should be from 0 to NumAvailable - 1*/ sU32.nU32 = sU32.nU32 - 1; ret = OMX_SetParameter(hTest->hComponent,OMX_IndexParamActiveStream,&sU32); if (ret != OMX_ErrorNone) return ret; printf("%s,%d,track %d, set active stream number %d.\n",__FUNCTION__,__LINE__,sU32.nPortIndex,sU32.nU32); OMX_PARAM_PORTDEFINITIONTYPE sPortDef; OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE); sPortDef.nPortIndex = nPortIndex; ret = OMX_GetParameter(hTest->hComponent, OMX_IndexParamPortDefinition, &sPortDef); if (ret != OMX_ErrorNone) return ret; if (nPortIndex == hTest->nAudioTrackNum) printf("%s,%d,audio track %d, compress format %d.\n",__FUNCTION__,__LINE__,sPortDef.nPortIndex,sPortDef.format.audio.eEncoding); else printf("%s,%d,video track %d, compress format %d.\n",__FUNCTION__,__LINE__,sPortDef.nPortIndex,sPortDef.format.video.eCompressionFormat); port_enable(hTest,nPortIndex); return ret; }
void port_halt(void) { port_disable(); while (TRUE) { } }
OMX_ERRORTYPE cmd_process(HTEST *hTest) { char rep[10]; OMX_BOOL bExit = OMX_FALSE; while(bExit == OMX_FALSE) { printf("Input test cmd:\n"); printf("[f]flush\n"); printf("[x]exit\n"); scanf("%s", rep); if(rep[0] == 'l') load_component(hTest); else if(rep[0] == 's') { OMX_U32 state = 0; printf("State trans to:\n"); printf("0 -- Invalid\n"); printf("1 -- Loaded\n"); printf("2 -- Idle\n"); printf("3 -- Executing\n"); printf("4 -- Pause\n"); printf("5 -- WaitForResources\n"); scanf("%d", &state); StateTrans(hTest, (OMX_STATETYPE)state); } else if(rep[0] == 'f') { OMX_U32 nPortIndex = 0; printf("Want to flush port number:\n"); scanf("%d", &nPortIndex); port_flush(hTest, nPortIndex); } else if(rep[0] == 'd') { OMX_U32 nPortIndex = 0; printf("Want to disbale port number:\n"); scanf("%d", &nPortIndex); port_disable(hTest, nPortIndex); } else if(rep[0] == 'e') { OMX_U32 nPortIndex = 0; printf("Want to enable port number:\n"); scanf("%d", &nPortIndex); port_enable(hTest, nPortIndex); } else if(rep[0] == 'k') { OMX_U32 nSeekPos = 0; printf("seek to second:\n"); scanf("%d", &nSeekPos); OMX_U32 nSeekMode = 0; printf("seek mode [0:Fast,1:Accurate]:\n"); scanf("%d", &nSeekMode); do_seek(hTest, nSeekPos, (OMX_TIME_SEEKMODETYPE)nSeekMode); } else if(rep[0] == 'x') { MSG sMsg; sMsg.type = EXIT; hTest->pMsgQ->Add(&sMsg); hTest->bStop = OMX_TRUE; bExit = OMX_TRUE; StateTrans(hTest, (OMX_STATETYPE)2); StateTrans(hTest, (OMX_STATETYPE)1); unload_component(hTest); } } return OMX_ErrorNone; }
void bridge_close_1() { port_disable(&port_a); }
void bridge_close_2() { port_disable(&port_b); }
void port_halt(void) { port_disable(); while (true) { } }
static void halt() { port_disable(); while(true) { port_wait_for_interrupt(); } }