/** * Handle possible command line arguments. * * We also store them for later use by possible test applications */ void native_handle_cmd_line(int argc, char *argv[]) { int i; native_add_tracing_options(); native_add_testargs_option(); s_argv = argv; s_argc = argc; cmd_args_set_defaults(args_struct); for (i = 1; i < argc; i++) { if ((cmd_is_option(argv[i], "testargs", 0))) { test_argc = argc - i - 1; test_argv = &argv[i+1]; break; } if (!cmd_parse_one_arg(argv[i], args_struct)) { cmd_print_switches_help(args_struct); posix_print_error_and_exit("Incorrect option '%s'\n", argv[i]); } } }
static inline void vector_to_irq(int irq_nbr, int *may_swap) { /* * As in this architecture an irq (code) executes in 0 time, * it is a bit senseless to call z_int_latency_start/stop() */ /* z_int_latency_start(); */ sys_trace_isr_enter(); if (irq_vector_table[irq_nbr].func == NULL) { /* LCOV_EXCL_BR_LINE */ /* LCOV_EXCL_START */ posix_print_error_and_exit("Received irq %i without a " "registered handler\n", irq_nbr); /* LCOV_EXCL_STOP */ } else { if (irq_vector_table[irq_nbr].flags & ISR_FLAG_DIRECT) { *may_swap |= ((direct_irq_f_ptr) irq_vector_table[irq_nbr].func)(); } else { #ifdef CONFIG_SYS_POWER_MANAGEMENT posix_irq_check_idle_exit(); #endif ((normal_irq_f_ptr)irq_vector_table[irq_nbr].func) (irq_vector_table[irq_nbr].param); *may_swap = 1; } } sys_trace_isr_exit(); /* z_int_latency_stop(); */ }
/** * Thru this function the IRQ controller can raise an immediate interrupt which * will interrupt the SW itself * (this function should only be called from the HW model code, from SW threads) */ void posix_irq_handler_im_from_sw(void) { /* * if a higher priority interrupt than the possibly currently running is * pending we go immediately into irq_handler() to vector into its * handler */ if (hw_irq_ctrl_get_highest_prio_irq() != -1) { if (!posix_is_cpu_running()) { /* LCOV_EXCL_BR_LINE */ /* LCOV_EXCL_START */ posix_print_error_and_exit("programming error: %s " "called from a HW model thread\n", __func__); /* LCOV_EXCL_STOP */ } posix_irq_handler(); } }
static inline void vector_to_irq(int irq_nbr, int *may_swap) { /** * Call the test IRQ sniffer, and if it returns * true ignore the interrupt */ bool ret; ret = bst_irq_sniffer(irq_nbr); if (ret) { return; } bs_trace_raw_time(6, "Vectoring to irq %i (%s)\n", irq_nbr, irqnames[irq_nbr]); sys_trace_isr_enter(); if (irq_vector_table[irq_nbr].func == NULL) { /* LCOV_EXCL_BR_LINE */ /* LCOV_EXCL_START */ posix_print_error_and_exit("Received irq %i without a " "registered handler\n", irq_nbr); /* LCOV_EXCL_STOP */ } else { if (irq_vector_table[irq_nbr].flags & ISR_FLAG_DIRECT) { *may_swap |= ((direct_irq_f_ptr) irq_vector_table[irq_nbr].func)(); } else { #ifdef CONFIG_SYS_POWER_MANAGEMENT posix_irq_check_idle_exit(); #endif ((normal_irq_f_ptr)irq_vector_table[irq_nbr].func) (irq_vector_table[irq_nbr].param); *may_swap = 1; } } sys_trace_isr_exit(); bs_trace_raw_time(7, "Irq %i (%s) ended\n", irq_nbr, irqnames[irq_nbr]); }
/** * Add a set of command line options to the program. * * Each option to be added is described in one entry of the input <args> * This input must be terminated with an entry containing ARG_TABLE_ENDMARKER. */ void native_add_command_line_opts(struct args_struct_t *args) { int count = 0; while (args[count].option != NULL) { count++; } count++; /*for the end marker*/ if (used_args + count >= args_aval) { int growby = count; /* reallocs are expensive let's do them only in big chunks */ if (growby < ARGS_ALLOC_CHUNK_SIZE) { growby = ARGS_ALLOC_CHUNK_SIZE; } args_struct = realloc(args_struct, (args_aval + growby)* sizeof(struct args_struct_t)); args_aval += growby; /* LCOV_EXCL_START */ if (args_struct == NULL) { posix_print_error_and_exit("Could not allocate memory"); } /* LCOV_EXCL_STOP */ } memcpy(&args_struct[used_args], args, count*sizeof(struct args_struct_t)); used_args += count - 1; /* * -1 as the end marker should be overwritten next time something * is added */ }