/* Get the url from a url object, special wrapper. * Owner object is passed, look for obj.href, obj.src, or obj.action. * Return that if it's a string, or its member href if it is a url. * The result, coming from get_property_string, is allocated. */ char *get_property_url(jsobjtype owner, bool action) { enum ej_proptype mtype; /* member type */ jsobjtype uo = 0; /* url object */ if (action) { mtype = has_property(owner, "action"); if (mtype == EJ_PROP_STRING) return get_property_string(owner, "action"); if (mtype != EJ_PROP_OBJECT) return 0; uo = get_property_object(owner, "action"); if (has_property(uo, "actioncrash")) return 0; } else { mtype = has_property(owner, "href"); if (mtype == EJ_PROP_STRING) return get_property_string(owner, "href"); if (mtype == EJ_PROP_OBJECT) uo = get_property_object(owner, "href"); else if (mtype) return 0; if (!uo) { mtype = has_property(owner, "src"); if (mtype == EJ_PROP_STRING) return get_property_string(owner, "src"); if (mtype == EJ_PROP_OBJECT) uo = get_property_object(owner, "src"); } } if (uo == NULL) return 0; /* should this be href$val? */ return get_property_string(uo, "href"); } /* get_property_url */
void arduino_board_inst(void * dev, void * opaque) { mem_region * sysmem = get_sysmem(); Device * bootmem = create_device("boot", "memory-alias"); Device * rom = create_device("rom", "generic_rom"); Device * ram1 = create_device("ram1", "generic_ram"); Device * ram2 = create_device("ram2", "generic_ram"); Device * eef0 = create_device("eef0", "generic_ram"); Device * uart = create_device("uart", "arduinodue_uart"); Device * pmc = create_device("pmc", "arduinodue_pmc"); Device * uotghs = create_device("usb", "arduinodue_uotghs"); Device * log1 = create_device("log1", "c_logger"); Device * log2 = create_device("log2", "py_logger"); Device * log3 = create_device("log3", "rust_logger"); set_property_ptr(bootmem, "target", rom); set_property_int32(bootmem, "offset", 0); set_property_int32(bootmem, "size", 0xffff); set_property_string(rom, "file", get_property_string(dev, "kernel_file")); /* map device what where at how large */ map_device_to_memory(rom, sysmem, 0x80000, 0xf00000); map_device_to_memory(bootmem, sysmem, 0x0, 0xffff); map_device_to_memory(ram1, sysmem, 0x20000000, 0xFFFF); map_device_to_memory(ram2, sysmem, 0x20070000, 0x17FFF); map_device_to_memory(eef0, sysmem, 0x400E0A00, 0x400); map_device_to_memory(uart, sysmem, 0x400E0800, 0x200); map_device_to_memory(pmc, sysmem, 0x400E0600, 0x200); map_device_to_memory(uotghs, sysmem, 0x400AC800, 0x830); map_device_to_memory(log1, sysmem, 0x400E1000, 0x50); map_device_to_memory(log2, sysmem, 0x400E1200, 0x50); map_device_to_memory(log3, sysmem, 0x400E1400, 0x50); Device * processor = create_device("mcu", "cortex_m3"); Device * intctl = create_device("nvic", "armv7m_nvic"); set_property_ptr(intctl, "target", processor); set_property_int32(intctl, "num_irq", 64); /* Instantiate all created devices */ instantiate_devices(); }
/* The object is a select-one field in the form, and this function returns * object.options[selectedIndex].value */ char *get_property_option(jsobjtype obj) { int n; jsobjtype oa; /* option array */ jsobjtype oo; /* option object */ char *val; if (!allowJS || !cw->winobj || !obj) return 0; n = get_property_number(obj, "selectedIndex"); if (n < 0) return 0; oa = get_property_object(obj, "options"); if (!oa) return 0; oo = get_array_element_object(oa, n); if (!oo) return 0; return get_property_string(oo, "value"); } /* get_property_option */
/*================================================================================================== FUNCTION: tal_clock_open DESCRIPTION: Open a clock handle for the specified UART device. If successful, this function will return a clock handle, and may acquire other resources, which must be released by calling tal_clock_close(). ==================================================================================================*/ TAL_RESULT tal_clock_open(TAL_CLOCK_HANDLE *phandle, uint32 client_id) { DALSYS_PROPERTY_HANDLE_DECLARE(property_handle); TAL_CLOCK_HANDLE handle = NULL; DalDeviceHandle *clock_dal = NULL; char *clock_name = NULL; ICBArb_MasterSlaveType uart_arb_master_slave; ICBArb_RequestType pnoc_request; ICBArb_ErrorType arb_error; DALResult result; if (DALSYS_Malloc(sizeof(TAL_CLOCK_CONTEXT), (void **)&handle) != DAL_SUCCESS) { goto error; } if (DAL_DeviceAttach(DALDEVICEID_CLOCK, &clock_dal) != DAL_SUCCESS) { goto error; } handle->daldev_clock = clock_dal; // No open needed for clock handle->dal_id = client_id; handle->manage_pclk = FALSE; // Read this clock's Clock Regime-specific parameters from the UART configuration: // // UartClockName: This is the name of the core clock. It must be present. // // ManagePCLK: In recent chips there are two clock inputs to the UART HW block: the // core clock and the peripheral bus clock. The peripheral bus clock // operates the bus interface (it must be enabled when reading/writing // registers). On some builds CLKREGIM manages the peripheral bus clock // for us and turns it on/off along with the core clock. On other builds // we must manage the peripheral bus clock ourselves. This property is // used to specify whether we must manage it ourselves. // // PClockName: This is the name of the peripheral clock (if present) // // ResetClock: Flag indicating whether the clock block must be reset before // it can be used. // // ClockFundFreq: The fundamental frequency of the bit clock, to which an // integer divider can be applied. If unspecified, the clock // has an M/N:D divider and the clock frequency can be // specified directly. result = DALSYS_GetDALPropertyHandle(handle->dal_id, property_handle); if (result != DAL_SUCCESS) { goto error; } // Read the name of the UART clock result = get_property_string(handle->dal_id, property_handle, "UartClockName", &clock_name, NULL); if (result != DAL_SUCCESS || clock_name == 0) { goto error; } // Look up the clock ID for the core clock result = DalClock_GetClockId(handle->daldev_clock, clock_name, &handle->core_clk_id); if (result != DAL_SUCCESS) { DALSYS_LogEvent(handle->dal_id, DALSYS_LOGEVENT_ERROR, "Core GetClockId( %s ) = %d", clock_name, result); goto error; } handle->periph_clk_id = 0; get_property_dword(handle->dal_id,property_handle,"ManagePCLK", &handle->manage_pclk,FALSE); if (handle->manage_pclk) { // Read the name of the peripheral clock result = get_property_string(handle->dal_id, property_handle, "PClockName", &clock_name, NULL); // Look up the clock ID for the peripheral clock if (result == DAL_SUCCESS && clock_name) { result = DalClock_GetClockId(handle->daldev_clock, clock_name, &handle->periph_clk_id); if (result != DAL_SUCCESS) { DALSYS_LogEvent(handle->dal_id, DALSYS_LOGEVENT_ERROR, "Periph GetClockId(%s) = %d", clock_name, result); goto error; } } } get_property_dword(handle->dal_id,property_handle,"ResetClock", &handle->reset_clock,0); get_property_dword(handle->dal_id,property_handle,"ClockFundFreq", &handle->fundamental_frequency,0); get_property_dword(handle->dal_id,property_handle,"PnocVoteEnable", &handle->pnoc_enable, 0); if(handle->pnoc_enable) { get_property_dword(handle->dal_id,property_handle,"PnocArbMaster", &handle->pnoc_master,0); get_property_dword(handle->dal_id,property_handle,"PnocArbSlave", &handle->pnoc_slave, 0); if(!(handle->pnoc_master)){ goto error;} get_property_dword(handle->dal_id,property_handle,"PnocIBval", &handle->pnoc_ib_val,0); get_property_dword(handle->dal_id,property_handle,"PnocABval", &handle->pnoc_ab_val,0); if(!(handle->pnoc_ib_val && handle->pnoc_ab_val)){ goto error;} DALSYS_LogEvent(handle->dal_id, DALSYS_LOGEVENT_INFO, "Pnoc vote is enabled:Master %d & SLAVE %d", handle->pnoc_master,handle->pnoc_slave); uart_arb_master_slave.eMaster = handle->pnoc_master; uart_arb_master_slave.eSlave = handle->pnoc_slave; /* Create a NPA client for the "/node/core/bus/uart/pnocclk" client to make PNOC voting request*/ handle->npa_pnoc_client = icbarb_create_suppressible_client_ex ("/node/core/bus/uart/pnocclk", &uart_arb_master_slave, UART_ICB_CLIENT_CNT, NULL); if (NULL == handle->npa_pnoc_client) { DALSYS_LogEvent(handle->dal_id, DALSYS_LOGEVENT_ERROR, "tal_clock_open: " "Unable to create a pnoc npa client"); goto error; } pnoc_request.arbType = ICBARB_REQUEST_TYPE_3; /* Ib/Ab pair */ /* Bandwidth in Bytes/second */ pnoc_request.arbData.type3.uIb = (uint64) handle->pnoc_ib_val; pnoc_request.arbData.type3.uAb = (uint64) handle->pnoc_ab_val; arb_error = icbarb_issue_request(handle->npa_pnoc_client, &pnoc_request, UART_PNOC_MSTRSLV_PAIRS_NUM); if(arb_error != ICBARB_ERROR_SUCCESS) { DALSYS_LogEvent(handle->dal_id, DALSYS_LOGEVENT_ERROR, "tal_clock_enable: " "pnoc request is failed witht the error: %d",arb_error); goto error; } } else { handle->pnoc_master = 0; handle->pnoc_slave = 0; handle->pnoc_ib_val = 0; handle->pnoc_ab_val = 0; handle->npa_pnoc_client = NULL; DALSYS_LogEvent(handle->dal_id, DALSYS_LOGEVENT_INFO, "Pnoc vote is not enabled"); } *phandle = handle; return TAL_SUCCESS; error: if (clock_dal) { DAL_DeviceDetach(clock_dal); } if (handle) { DALSYS_Free(handle); } return TAL_ERROR; }
static void rebuildSelector(struct htmlTag *sel, jsobjtype oa, int len2) { int i1, i2, len1; bool check2; char *s; const char *selname; bool changed = false; struct htmlTag *t; jsobjtype oo; /* option object */ len1 = cw->numTags; i1 = i2 = 0; selname = sel->name; if (!selname) selname = "?"; debugPrint(4, "testing selector %s %d %d", selname, len1, len2); sel->lic = (sel->multiple ? 0 : -1); while (i1 < len1 && i2 < len2) { /* there is more to both lists */ t = tagList[i1++]; if (t->action != TAGACT_OPTION) continue; if (t->controller != sel) continue; /* find the corresponding option object */ if ((oo = get_array_element_object(oa, i2)) == NULL) { /* Wow this shouldn't happen. */ /* Guess I'll just pretend the array stops here. */ len2 = i2; --i1; break; } t->jv = oo; /* should already equal oo */ t->rchecked = get_property_bool(oo, "defaultSelected"); check2 = get_property_bool(oo, "selected"); if (check2) { if (sel->multiple) ++sel->lic; else sel->lic = i2; } ++i2; if (t->checked != check2) changed = true; t->checked = check2; s = get_property_string(oo, "text"); if (s && !t->textval || !stringEqual(t->textval, s)) { nzFree(t->textval); t->textval = s; changed = true; } else nzFree(s); s = get_property_string(oo, "value"); if (s && !t->value || !stringEqual(t->value, s)) { nzFree(t->value); t->value = s; } else nzFree(s); } /* one list or the other or both has run to the end */ if (i2 == len2) { for (; i1 < len1; ++i1) { t = tagList[i1]; if (t->action != TAGACT_OPTION) continue; if (t->controller != sel) continue; /* option is gone in js, disconnect this option tag from its select */ t->jv = 0; t->controller = 0; t->action = TAGACT_NOP; changed = true; } } else if (i1 == len1) { for (; i2 < len2; ++i2) { if ((oo = get_array_element_object(oa, i2)) == NULL) break; t = newTag("option"); t->lic = i2; t->controller = sel; t->jv = oo; t->step = 2; // already decorated t->textval = get_property_string(oo, "text"); t->value = get_property_string(oo, "value"); t->checked = get_property_bool(oo, "selected"); if (t->checked) { if (sel->multiple) ++sel->lic; else sel->lic = i2; } t->rchecked = get_property_bool(oo, "defaultSelected"); changed = true; } } if (!changed) return; debugPrint(4, "selector %s has changed", selname); /* If js change the menu, it should have also changed select.value * according to the checked options, but did it? * Don't know, so I'm going to do it here. */ s = displayOptions(sel); if (!s) s = emptyString; set_property_string(sel->jv, "value", s); javaSetsTagVar(sel->jv, s); nzFree(s); if (!sel->multiple) set_property_number(sel->jv, "selectedIndex", sel->lic); } /* rebuildSelector */