static int bi_udc_resume(struct device *dev, u32 level) { int ret = 0; struct usb_device_instance *device = device_array[0]; switch (level) { case RESUME_POWER_ON: dbg_pm (0, "RESUME_POWER_ON"); if (udc_init ()) { dbg_init (0, "udc_init failed"); } if (device) { udc_enable (device); /* enable UDC */ udc_all_interrupts (device); /* enable interrupts */ } udc_connect (); /* enable USB pullup */ dbg_init (1, "MOD_INC_USE_COUNT %d", GET_USE_COUNT (THIS_MODULE)); dbg_pm (0, "RESUME_POWER_ON: finished"); break; } return ret; }
/* bi_udc_init - initialize USB Device Controller This function is called for each physical bus interface that is found. Register an interrupt handler and IO region. Return non-zero for error. */ int bi_udc_init() { dbg_init(1,"Loading %s", udc_name()); bi_driver.name = udc_name(); bi_driver.max_endpoints = udc_max_endpoints(); bi_driver.maxpacketsize = udc_ep0_packetsize(); dbg_init(1,"name: %s endpoints: %d ep0: %d", bi_driver.name, bi_driver.max_endpoints, bi_driver.maxpacketsize); // request device IRQ. if (udc_request_udc_irq()) { dbg_init(0,"name: %s request udc irq failed", udc_name()); return -EINVAL; } // request device IO if (udc_request_io()) { udc_release_udc_irq(); dbg_init(0,"name: %s request udc io failed", udc_name()); return -EINVAL; } if (udc_init()) { udc_release_udc_irq(); udc_release_io(); dbg_init(1,"name: %s probe failed", udc_name()); return -EINVAL; } return 0; }
/* * usbd_pm_callback * @dev: * @rqst: * @unused: * * Used to signal power management events. */ static int bi_pm_event (struct pm_dev *pm_dev, pm_request_t request, void *unused) { struct usb_device_instance *device; dbg_pm (0, "request: %d pm_dev: %p data: %p", request, pm_dev, pm_dev->data); if (!(device = pm_dev->data)) { dbg_pm (0, "DATA NULL, NO DEVICE"); return 0; } switch (request) { #if defined(CONFIG_IRIS) case PM_STANDBY: case PM_BLANK: #endif case PM_SUSPEND: dbg_pm (0, "PM_SUSPEND"); if (!pm_suspended) { pm_suspended = 1; dbg_init (1, "MOD_INC_USE_COUNT %d", GET_USE_COUNT (THIS_MODULE)); udc_disconnect (); // disable USB pullup if we can udc_disable_interrupts (device); // disable interupts udc_disable (); // disable UDC dbg_pm (0, "PM_SUSPEND: finished"); } break; #if defined(CONFIG_IRIS) case PM_UNBLANK: #endif case PM_RESUME: dbg_pm (0, "PM_RESUME"); if (pm_suspended) { // probe for device if (udc_init ()) { dbg_init (0, "udc_init failed"); //return -EINVAL; } udc_enable (device); // enable UDC udc_all_interrupts (device); // enable interrupts udc_connect (); // enable USB pullup if we can //udc_set_address(device->address); //udc_reset_ep(0); pm_suspended = 0; dbg_init (1, "MOD_INC_USE_COUNT %d", GET_USE_COUNT (THIS_MODULE)); dbg_pm (0, "PM_RESUME: finished"); } break; } return 0; }
/* * * serial_open - open serial device * @tty: tty device * @filp: file structure * * Called to open serial device. */ static int serial_open (struct tty_struct *tty, struct file *filp) { unsigned long flags; int n = 0, rc = 0; struct serproto_dev *device = NULL; dbg_oc (3, "tty #%p file #%p", tty, filp); if (NULL == tty || 0 > (n = MINOR (tty->device) - tty->driver.minor_start) || n >= serproto_devices || NULL == (device = serproto_device_array[n])) { dbg_oc (1, "FAIL ENODEV"); return -ENODEV; } MOD_INC_USE_COUNT; dbg_init (1, "OPEN uc=%d", GET_USE_COUNT (THIS_MODULE)); write_lock_irqsave (&device->rwlock, flags); if (1 == ++device->opencnt) { // First open tty->driver_data = device; device->tty = tty; tty->low_latency = 1; /* force low_latency on so that our tty_push actually forces the data through, * otherwise it is scheduled, and with high data rates (like with OHCI) data * can get lost. * */ tty->low_latency = 1; } else if (tty->driver_data != device || device->tty != tty) { // Second or later open, different tty/device combo rc = -EBUSY; } // XXX Should extract info from somewhere to see if receive is OK write_unlock_irqrestore (&device->rwlock, flags); if (0 != rc) { if (-EBUSY == rc) { dbg_oc (1, "2nd, conflict: old dev #%p new #%p, old tty #%p new #%p", tty->driver_data, device, device->tty, tty); } MOD_DEC_USE_COUNT; dbg_init (0, "OPEN rc=%d uc=%d", rc, GET_USE_COUNT (THIS_MODULE)); } dbg_oc (3, "->%d n=%d", rc, n); return (rc); }
static void serial_close (struct tty_struct *tty, struct file *filp) { unsigned long flags; struct serproto_dev *device; int uc; uc = GET_USE_COUNT (THIS_MODULE); dbg_oc (3, "tty #%p file #%p uc=%d", tty, filp, uc); if ((device = tty->driver_data) != NULL) { write_lock_irqsave (&device->rwlock, flags); if (0 >= --device->opencnt) { // Last (or extra) close dbg_oc (1, "Last: old tty #%p new #%p oc=%d", device->tty, tty, device->opencnt); tty->driver_data = NULL; device->tty = NULL; device->opencnt = 0; } write_unlock_irqrestore (&device->rwlock, flags); } else { dbg_oc (1, "not presently connected"); } if (uc > 0) { // Should really check that uc hasn't changed since start of fn... MOD_DEC_USE_COUNT; dbg_init (1, "CLOSE uc=%d", GET_USE_COUNT (THIS_MODULE)); } dbg_oc (3, "OK"); return; }
int main(int argc, char **argv) { struct options_st opt = { 0, 0, 0, 0, NULL, 1 }; #ifdef DEBUG dbg_init(); #endif process_options(argc, argv, &opt); setverbosity(opt.verbose); #ifdef DEBUG dbg_setdebug(opt.debug); char *subsys[] = { "default", "gui", "opengl", "world", NULL }; dbg_msetsubsysnames(subsys); if (opt.mdebug != NULL) dbg_parsearg(opt.mdebug); #endif gui_init(opt.width, opt.height, opt.fullscreen); gui_loop(); gui_finish(); }
//============================================================================= // dbg_print_all_alloc_block //============================================================================= void dbg_print_all_alloc_block(FILE * fp) { struct memory_count * mcp; dbg_init(); for (mcp = dbg_memory_count_head; mcp; mcp = mcp->next) print_alloc_block(fp, mcp); }
int main(int argc, char *argv[]) { WSADATA data; int index; DBG *d = dbg_init(); WSAStartup(MAKEWORD(2, 2), &data); dbg_open_stream(d, stderr); dbg_open_stream(d, stdout); dbg_open_dummy(d); index = dbg_open_net(d, "localhost", 8888); dbg_open_file(d, "log.txt"); dbg_open_stream(d, stderr); dbg_open_custom(d, WriteToMessageBox); dbg_printf_raw(d, "Hello %s", "World"); dbg_hexdump_ascii(d, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", strlen("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); dbg_switch(d, 0); dbg_hexdump(d, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", strlen("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); dbg_switch(d, 1); dbg_hexdump_ascii(d, (const unsigned char *) d, sizeof(*d)); dbg_close(d); return 0; }
/* One start -----------------------------------------------------------------*/ static void startup() { unsigned char err = 0; init_hardware(); dbg_init(); dbg_print_app_ver(); crc32_init(); pins_init(); //spi0_init(); // used in m25pexx.c (FLASH) spi1_init(); adc_init(); err = memory_init(); // memory initialization, external EEPROM (used in pref.c, orion.c), external FLASH, internal FLASH if (err) goto err; pref_init(); ds1390_init(); evt_fifo_init(); GPS_init(); //SIM900_init(); light_init(); saveDatePorojectIP();//новые параметры связи vpu_init(); /*VPU start*/ //Init_USB(); //if (PROJ.jornal.power_on) //Event_Push_Str("СТАРТ"); return; err: Err_led(err); }
int main(int argc, char * argv[]) { int verbose = 0; int level = 0; FILE * dest = stderr; char optchar = -1; while (optchar = getopt(argc, argv, "c:vd:e:h")) { if (-1 == optchar) break; switch (optchar) { case 'c': conf.source = strdup(optarg); if (NULL == conf.source) fprintf(stderr, "cannot open config file: %s\n", optarg); break; case 'v': verbose = 1; break; case 'e': if (0 == strcmp(optarg, "stderr")) dest = stderr; else if (0 == strcmp(optarg, "stdout")) dest = stdout; else { FILE * out = fopen(optarg, "r"); if (NULL == out) { fprintf(stderr, "failed to open destination for debug, using stderr\n"); dest = stderr; } else dest = out; } break; case 'd': level = atoi(optarg); break; case 'h': show_help(argv[0]); exit(1); break; default: break; } } if (NULL == conf.source) { fprintf(stderr, "no config file in use\n"); exit(1); } dbg_init(dest, level, verbose); DBG(1, "mpsd startup\n"); if (RET_OK == conf_load(&conf)) { core_init(&conf); core_deinit(&conf); DBG(1, "mpsd closing\n"); } conf_unload(&conf); return 0; }
/** * serproto_modinit - initialize the serproto library * @name: name * @num: number of interfaces to allow * */ int serproto_modinit (char *name, int num) { dbg_init (1, "%s[%d]", name, num); rwlock_init (&serproto_rwlock); serproto_devices = num; if (!(serproto_device_array = kmalloc (sizeof (struct serproto_dev *) * num, GFP_KERNEL))) { dbg_init (0, "kmalloc failed"); return -EINVAL; } memset (serproto_device_array, 0, sizeof (struct serproto_dev *) * num); dbg_loop (1, "LOOPBACK mode"); return 0; }
/** * usbd_hotplug - call a hotplug script * @action: hotplug action */ int usbd_hotplug (char *interface, char *action) { #ifdef CONFIG_HOTPLUG dbg_init (1, "agent: usbd interface: %s action: %s", interface, action); return hotplug ("usbd", interface, action); #else return (0); #endif }
/* * * usbd_device_function_instance - find a function instance for this device * @device: * @configuration: index to configuration, 0 - N-1 * * Get specifed device configuration. Index should be bConfigurationValue-1. */ struct usb_function_instance *usbd_device_function_instance (struct usb_device_instance *device, unsigned int port) { //dbg_init(2,"device: %p port: %d functions: %d", device, port, device->functions); if (port >= device->functions) { dbg_init (0, "configuration out of range: %d %d", port, device->functions); return NULL; } return device->function_instance_array + port; }
//============================================================================= // dbg_print_alloc_block //============================================================================= void dbg_print_alloc_block(FILE * fp, const char * file, int line) { struct memory_count * mcp; dbg_init(); for (mcp = dbg_memory_count_head; mcp; mcp = mcp->next) { if ( (!strcmp(file, mcp->file)) && ((line == 0) || (line == mcp->line)) ) print_alloc_block(fp, mcp); } }
void hal_init() { CLKPR = 0x80; CLKPR = 0x00; led_init(); dbg_init(); clock_timer_start(); }
Karaoke::Karaoke() : background() { LOG_API(); /* init IPC */ ipc = new IPC(IPCHandler, "ipc"); ipc->start(); /* init CLI */ cli = new Cli(); cli->start(); /* init log */ log_init(); dbg_init(); /* create gui modules */ login = new Login(&background); guiManager.append(login); category = new Category(&background); guiManager.append(category); player = new Player(&background); guiManager.append(player); playlistview = new PlayListView(&background); guiManager.append(playlistview); searchresult = new SearchResult(&background); guiManager.append(searchresult); singerlist = new SingerList(&background); guiManager.append(singerlist); menu = new Menu(&background); guiManager.append(menu); dbg_init(); // reinstall signal handler. }
/** * Pre-initialize the pSipcc stack. * @return */ cc_return_t CC_Service_create() { //Preinitialize memory ccPreInit(); //Initialize debug settings dbg_init(); //Prepopulate the Configuration data table protCfgTblInit(); return CC_SUCCESS; }
/** * udc_cable_event - called from cradle interrupt handler */ void udc_cable_event(void) { struct usb_bus_instance *bus; struct usb_device_instance *device; struct bi_data *data; dbgENTER(dbgflg_usbdbi_init,1); // sanity check if (!(device = device_array[0]) || !(bus = device->bus) || !(data = bus->privdata)) { return; } { unsigned long flags; local_irq_save(flags); if (udc_connected()) { dbg_init(1, "state: %d connected: %d", device->device_state, 1);; if (device->device_state == STATE_ATTACHED) { dbg_init(1, "LOADING"); usbd_device_event_irq(device, DEVICE_HUB_CONFIGURED, 0); usbd_device_event_irq(device, DEVICE_RESET, 0); } } else { dbg_init(1, "state: %d connected: %d", device->device_state, 0);; if (device->device_state != STATE_ATTACHED) { dbg_init(1, "UNLOADING"); usbd_device_event_irq(device, DEVICE_RESET, 0); usbd_device_event_irq(device, DEVICE_POWER_INTERRUPTION, 0); usbd_device_event_irq(device, DEVICE_HUB_RESET, 0); } } local_irq_restore(flags); } dbgLEAVE(dbgflg_usbdbi_init,1); }
enum dbg_start tgt_module_load(const char* name, BOOL keep) { DWORD opts = SymGetOptions(); HANDLE hDummy = (HANDLE)0x87654321; enum dbg_start ret = start_ok; WCHAR* nameW; unsigned len; SymSetOptions((opts & ~(SYMOPT_UNDNAME|SYMOPT_DEFERRED_LOADS)) | SYMOPT_LOAD_LINES | SYMOPT_AUTO_PUBLICS | 0x40000000); if (!dbg_init(hDummy, NULL, FALSE)) return start_error_init; len = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0); nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (!nameW) { ret = start_error_init; keep = FALSE; } else { len = MultiByteToWideChar(CP_ACP, 0, name, -1, nameW, len); if (!dbg_load_module(hDummy, NULL, nameW, 0, 0)) { ret = start_error_init; keep = FALSE; } HeapFree(GetProcessHeap(), 0, nameW); } if (keep) { dbg_printf("Non supported mode... errors may occur\n" "Use at your own risks\n"); SymSetOptions(SymGetOptions() | 0x40000000); dbg_curr_process = dbg_add_process(&be_process_module_io, 1, hDummy); dbg_curr_pid = 1; dbg_curr_thread = dbg_add_thread(dbg_curr_process, 2, NULL, NULL); /* FIXME: missing thread creation, fetching frames, restoring dbghelp's options... */ } else { SymCleanup(hDummy); SymSetOptions(opts); } return ret; }
/* * * usbd_device_configuration_instance - find a configuration instance for this device * @device: * @configuration: index to configuration, 0 - N-1 * * Get specifed device configuration. Index should be bConfigurationValue-1. */ static struct usb_configuration_instance *usbd_device_configuration_instance (struct usb_device_instance *device, unsigned int port, unsigned int configuration) { struct usb_function_instance *function_instance; struct usb_function_driver *function_driver; // XXX configuration = configuration ? configuration - 1 : 0; if (!(function_instance = usbd_device_function_instance (device, port))) { dbg_init (0, "function_instance NULL"); return NULL; } if (!(function_driver = function_instance->function_driver)) { dbg_init (0, "function_driver NULL"); return NULL; } if (configuration >= function_driver->configurations) { dbg_init (0, "configuration out of range: %d %d %d", port, configuration, function_driver->configurations); return NULL; } return function_driver->configuration_instance_array + configuration; }
int main(int argc, char *argv[]) { signal(SIGPIPE, SIG_IGN); signal(SIGCHLD, sig_child); clog_init(); us_mon_init(); dbg_init(); us_mon_register_notifier(&mn); us_mon_register_notifier(&mn1); us_mon_enum_dev(); us_loop(); us_mod_release(); clog_release(); return 0; }
/** * This is the first real C function ever called. It performs a lot of * hardware-specific initialization, then creates a pseudo-context to * execute the bootstrap function in. */ void kmain() { GDB_CALL_HOOK(boot); dbg_init(); dbgq(DBG_CORE, "Kernel binary:\n"); dbgq(DBG_CORE, " text: 0x%p-0x%p\n", &kernel_start_text, &kernel_end_text); dbgq(DBG_CORE, " data: 0x%p-0x%p\n", &kernel_start_data, &kernel_end_data); dbgq(DBG_CORE, " bss: 0x%p-0x%p\n", &kernel_start_bss, &kernel_end_bss); page_init(); pt_init(); slab_init(); pframe_init(); acpi_init(); apic_init(); pci_init(); intr_init(); gdt_init(); /* initialize slab allocators */ #ifdef __VM__ anon_init(); shadow_init(); #endif vmmap_init(); proc_init(); kthread_init(); #ifdef __DRIVERS__ bytedev_init(); blockdev_init(); #endif void *bstack = page_alloc(); pagedir_t *bpdir = pt_get(); KASSERT(NULL != bstack && "Ran out of memory while booting."); context_setup(&bootstrap_context, bootstrap, 0, NULL, bstack, PAGE_SIZE, bpdir); context_make_active(&bootstrap_context); panic("\nReturned to kmain()!!!\n"); }
int main(void) { dbg_init(); dbg_set(0xA); uart_rb_init(); uart_printf_init(); nrf_init(rxbuf); nrf_set_channel(115); nrf_set_power(NRF_CFG_RF_GAIN_M12); nrf_enable_pipe(0, tx_addr); sei(); while (1) { transmitter_loop(); } }
int main (void) { //! [init_calls] system_init(); dbg_init(); //! [init_calls] //! [main_task_create] xTaskCreate(&main_task, (const char *)"Main task", configMINIMAL_STACK_SIZE + 100, NULL, tskIDLE_PRIORITY + 2, NULL); //! [main_task_create] //! [freertos_start] vTaskStartScheduler(); //! [freertos_start] }
static int bi_udc_suspend(struct device *dev, u32 state, u32 level) { struct usb_device_instance *device = device_array[0]; switch (level) { case SUSPEND_POWER_DOWN: dbg_pm (0, "SUSPEND_POWER_DOWN"); dbg_init (1, "MOD_INC_USE_COUNT %d", GET_USE_COUNT (THIS_MODULE)); udc_disconnect (); /* disable USB pullup */ if (device) udc_disable_interrupts (device); /* disable interrupts */ udc_disable (); /* disable UDC */ dbg_pm (0, "SUSPEND_POWER_DOWN: finished"); break; } return 0; }
/** * bi_udc_exit - Stop using the USB Device Controller * * Stop using the USB Device Controller. * * Shutdown and free dma channels, de-register the interrupt handler. */ void bi_udc_exit(void) { int i; dbg_init(1, "Unloading %s", udc_name()); for (i = 0; i < udc_max_endpoints(); i++) { udc_disable_ep(i); } // free io and irq udc_disconnect(); udc_disable(); udc_release_io(); udc_release_udc_irq(); if (have_cable_irq) { udc_release_cable_irq(); } }
/** * Configure the system with default settings * * @return 0 if success, otherwise errorcode */ int conf_configure(void) { char path[FS_PATH_MAX], file[FS_PATH_MAX]; int err; #if defined (WIN32) dbg_init(DBG_INFO, DBG_NONE); #endif err = conf_path_get(path, sizeof(path)); if (err) { warning("conf: could not get config path: %m\n", err); return err; } if (re_snprintf(file, sizeof(file), "%s/config", path) < 0) return ENOMEM; if (!conf_fileexist(file)) { (void)fs_mkdir(path, 0700); err = config_write_template(file, conf_config()); if (err) goto out; } conf_obj = mem_deref(conf_obj); err = conf_alloc(&conf_obj, file); if (err) goto out; err = config_parse_conf(conf_config(), conf_obj); if (err) goto out; out: return err; }
//============================================================================= // dbg_print_alloc_count //============================================================================= void dbg_print_alloc_count(FILE * fp) { int number; struct memory_count * mcp; dbg_init(); fprintf(fp, "malloc() count = %u\n", dbg_malloc_count); fprintf(fp, "free() count = %u\n", dbg_free_count); fprintf(fp, "malloc() all block number = %u\n", dbg_malloc_number); fprintf(fp, "malloc() all block size = %u\n", dbg_malloc_size); fprintf(fp, "\n"); fprintf(fp, " number alloc free size (filename line)\n"); number = 0; for (mcp = dbg_memory_count_head; mcp; mcp = mcp->next) { number++; fprintf(fp, "#%03d %6d %8u %8u %8d (%s %d)\n", number, mcp->number, mcp->alloc_count, mcp->free_count, mcp->size, mcp->file, mcp->line); } fprintf(fp, "\n"); }
/** * bi_udc_init - initialize USB Device Controller * * Get ready to use the USB Device Controller. * * Register an interrupt handler and IO region. Return non-zero for error. */ int bi_udc_init (void) { dbg_init (1, "Loading %s", udc_name ()); bi_driver.name = udc_name (); bi_driver.max_endpoints = udc_max_endpoints (); bi_driver.maxpacketsize = udc_ep0_packetsize (); dbg_init (1, "name: %s endpoints: %d ep0: %d", bi_driver.name, bi_driver.max_endpoints, bi_driver.maxpacketsize); // request device IRQ if (udc_request_udc_irq ()) { dbg_init (0, "name: %s request udc irq failed", udc_name ()); return -EINVAL; } // request device IO if (udc_request_io ()) { udc_release_udc_irq (); dbg_init (0, "name: %s request udc io failed", udc_name ()); return -EINVAL; } // probe for device if (udc_init ()) { udc_release_udc_irq (); udc_release_io (); dbg_init (1, "name: %s probe failed", udc_name ()); return -EINVAL; } // optional cable IRQ have_cable_irq = !udc_request_cable_irq (); dbg_init (1, "name: %s request cable irq %d", udc_name (), have_cable_irq); return 0; }
int main(int argc, char *argv[]) { uint8_t *buf; int i; if (NULL == (buf=malloc(FLASH_SIZE))) { fprintf(stderr, "out of ram\n"); return 1; } if (0 != parse_options(argc, argv)) { usage(); return 1; } if (!opt_flash) { usage(); return 1; } if (opt_flash) { if (0 != dbg_init()) { fprintf(stderr, "Failed to initialise (run as root for /dev/mem access)\n"); return 1; } memset(buf, 0xFF, FLASH_SIZE); if (0 != read_hexfile(buf, FLASH_SIZE, flash_filename)) { fprintf(stderr, "Failed to read %s\n", flash_filename); return 1; } if (0 != dbg_mass_erase()) { fprintf(stderr, "CC1110 mass erase failed\n"); return 1; } for (i=0;i<FLASH_SIZE;i+=1024) { bool skip = true; int j; for (j=i;j<i+1024;j++) { if (buf[j] != 0xFF) { skip = false; break; } } if (skip) { printf("Skipping blank page %d\n", i/1024); continue; } printf("Programming and verifying page %d\n", i/1024); if (0 != program_verify_page(buf + i, i/1024)) { fprintf(stderr, "FAILED\n"); return 1; } } printf("Programming complete\n"); dbg_reset(); } return 0; }