예제 #1
0
파일: reset.c 프로젝트: abferm/modemmanager
int
main (int argc, char *argv[])
{
    const char *dmport = argv[1];
    int fd, err;

    if (argc < 1 || argc > 3) {
        usage (argv[0]);
        return 1;
    }

    if (argc == 3 && strcasecmp (argv[2], "--debug") == 0)
        debug = 1;

    if (debug)
        putenv ("QCDM_DEBUG=1");

    fd = com_setup (dmport);
    if (fd < 0)
        return 1;

    err = qcdm_port_setup (fd);
    if (err != QCDM_SUCCESS) {
        fprintf (stderr, "E: failed to set up DM port %s: %d\n", dmport, err);
        return 1;
    }

    /* Send DM reset command */
    printf ("setting offline...\n");
    qcdm_set_mode (fd, QCDM_CMD_CONTROL_MODE_OFFLINE);
    sleep (2);
    printf ("reset...\n");
    qcdm_set_mode (fd, QCDM_CMD_CONTROL_MODE_RESET);
    sleep (2);
    printf ("done\n");

    return 0;
}
예제 #2
0
파일: boot.c 프로젝트: rohsaini/mkunity
void
boot(int drive)
{
	int 		addr;
	int 		top;
	int 		kern_entry;
	int 		boot_start;
	int 		boot_region_desc;
	int 		boot_thread_state;
	unsigned 	int size;
	int 		env_start;
	int 		env_size = 0;
	char 		*p;
	char 		*env = 0;
	char		*defaults = 0;
	int		defaults_size = 0;
	int 		i;
	int		idt[2];

	delayprompt = 10;	/* default to 10s at the prompt */

	switch(drive) {
	    case BIOS_DEV_FLOPPY:
		dev = DEV_FLOPPY;
		break;
	    case BIOS_FAKE_WD:
		dev = DEV_WD;
		break;
	    case BIOS_DEV_WIN:
	    default:
		dev = DEV_HD;
		break;
	}
	cnvmem = memsize(0);
	extmem = memsize(1);

	printf("\n>> Secondary Mach boot %s\n>> %d/%dk (? for help, ^C for intr)\n",
	       VERSIONDATE, cnvmem, extmem);
#ifdef	DEBUG
	printf("end x%x data 0x%x\n",end,edata);
#endif
	/* sanity check: */
	if ((int)end > KALLOC_OFFSET || (int)end > (BOOTSTACK-0x300)) {
		printf("Size problem: 0x%x > 0x%x\n",end,
		       ((int)end > KALLOC_OFFSET)?KALLOC_OFFSET:BOOTSTACK-0x300);
	}

#if	DEBUG
	if (debug) {
		printf("dev = %x\n", dev);
		printf("unit = %x\n", unit);
		printf("part = %x\n", part);
	}
#endif
#if 0
	dev = DEV_HD;
	unit = 0;
	part = 0;
#endif

	reset_pic(); 		/* Lilo breaks PIC, BIOS disk ints fail */

	calibrate_delay();	/* adjust delay for i/o operation */

	gateA20();
	if (dev == DEV_FLOPPY && devfs()) {
		printf("No fd FS, using hd\n");
		dev = DEV_HD;
		part = 0;
	}


	bcopy(MACH_KERNEL, kern_prog.name, sizeof(MACH_KERNEL));
	bcopy(BOOTSTRAP, boot_prog.name, sizeof(BOOTSTRAP));
	bcopy(MACH_BOOT_ENV, env_prog.name, sizeof(MACH_BOOT_ENV));

reload_env_file:
	if (openrd(env_prog.name, NULL) == 0 && fsize() != 0) {
		const char 	*value;
		/*
		 * Read mach_boot environment file if exists
		 */
		printf("Reading defaults from %s:\n",env_prog.name);
		defaults_size = fsize()+1;
		if (defaults != (char *)0)
			free(defaults);
		defaults = (char *)malloc(defaults_size);
		read(defaults, defaults_size-1);
		*(defaults+defaults_size-1) = 0;
		printf("%s", defaults);
		for (p = defaults; p < defaults + defaults_size; p++)
			if (*p == '\n')
				*p = '\0';
		value = get_env("CONSOLE", defaults, defaults_size);
		if (strcmp(value, "vga") == 0 || strcmp(value, "VGA") == 0)
			com_enabled = 0;
		/* WARNING: do not enable the remote console based
		 * on the latter argument in an environment file, since
		 * now, remote console enabling is decided by the primary
		 * boot ONLY and passed along through secondary's.
		 */
		if (*get_env("PROMPT", defaults, defaults_size) == '1')
			prompt = 1;
		if (com_enabled &&
		    (value = get_env("COM1_SETUP", defaults, defaults_size)))
			com_setup(value);
		if (value = get_env("DELAYPROMPT", defaults, defaults_size)) {
			delayprompt = atoi(value);
			/* don't allow stupid values */
			if (delayprompt < 3)
				delayprompt = 3;			
		}
	}
	for (;;) {
	    	if ((!getbootline(kern_prog.name, boot_prog.name)) && defaults ) {
		  	/*
			 * Get defaults from /mach_boot.env if any.
			 */
			const char 	*value;

			if (value = get_env("KERNEL_NAME",
					    defaults, defaults_size)) {
				strcpy(kern_prog.name, (char *)value);
				strcpy(kern_prog.args, (char *)value);
				kern_prog.args_size = strlen(value)+1;
			}
			if (value = get_env("KERNEL_ARGS",
					    defaults, defaults_size)) {
			  	char *args;
				args = kern_prog.args + kern_prog.args_size;
				while (*value)
					value = copyargs((char *)value, &args);
				kern_prog.args_size = args - kern_prog.args;
			}
			if (value = get_env("BOOTSTRAP_NAME",
					    defaults, defaults_size)) {
				strcpy(boot_prog.name, (char *)value);
				strcpy(boot_prog.args, (char *)value);
				boot_prog.args_size = strlen(value)+1;
			}
			if (value = get_env("BOOTSTRAP_ARGS",
					    defaults, defaults_size)) {
			  	char *args;
				args = boot_prog.args + boot_prog.args_size;
				while (*value)
					value = copyargs((char *)value, &args);
				boot_prog.args_size = args - boot_prog.args;
			}
	        }
		if (cons_is_com) {
			printf("console is COM1\n");
			/* check if we already enabled remote console? */
			p = kern_prog.args + kern_prog.args_size;
			*p++ = '-';
			*p++ = 'r';
			*p++ = 0;
			kern_prog.args_size += 3;
	        }

		addr = KERNEL_BOOT_ADDR;
		if (loadtext(&addr, &kern_prog)) {
			strcpy(env_prog.name, kern_prog.name);
			goto reload_env_file;
		} else if (loadprog(&addr, &kern_prog)) {
			printf("Can't load %s\n", kern_prog.name);
			usage();
			continue;
		}
		kern_entry = entry;

		if (dev == DEV_WD)
			net_get_root_device();
		env_start = addr;
		if (openrd("/mach_servers/environment", NULL) == 0 &&
		    fsize() != 0) {
			unsigned int total = fsize()+1;

			printf("Loading environment from /mach_servers/environment\n");
			env = (char *)malloc(total);
			read(env, total-1);
			*(env+total-1) = 0;
			for (p = env; p < env + total; p++)
				if (*p == '\n')
					*p = '\0';
			pcpy(env, (void *)addr, total);
			addr += total;
			env_size += total;
			free(env);
		} 
		env = (char *)malloc(BOOT_LINE_LENGTH);
#if	BOOT_ENV_COMPAT
		/* should go away when all kernels are converted 
		   to use BOOT_DEVICE */
		p = env;
		strcpy(p, "BOOTOFFSET=");
		p = itoa(p + strlen(p), boff) + 1;
		strcpy(p, "BOOTDEV=hd");
		p += strlen(p)+1;
		*(p-3) = dev;
		strcpy(p, "BOOTUNIT=");
		p = itoa(p + strlen(p), unit) + 1;
		strcpy(p, "BOOTPART=");
		p = itoa(p + strlen(p), part) + 1;
		size = p - env;
		pcpy(env, (void *)addr, size);
		addr += size;
		env_size += size;
#endif	/* BOOT_ENV_COMPAT */

		p = env;
		strcpy(p, "BOOT_DEVICE=hd");
		p += strlen(p);
		*(p-2) = dev;
		p = itoa(p, unit);
		*p++ = 'a'+part;

		size = p - env;
		pcpy(env, (void *)addr, size);
		addr += size;
		env_size += size;
		free(env);

		if (strncmp("none",boot_prog.name,sizeof("none"))==0
		    ||strncmp("null",boot_prog.name,sizeof("null"))==0) {
			boot_start = 0;
			boot_region_desc = 0;
			boot_prog.sym_start = 0;
			boot_prog.sym_size = 0;
			boot_prog.args_start = 0;
			boot_prog.args_size = 0;
			region_count = 0;
			boot_thread_state = 0;
		        top = page_align(addr);
			goto boot_kernel_only;
		}
		boot_start = addr = page_align(addr);
		if (loadprog(&addr, &boot_prog)) {
			printf("Can't load %s\n", boot_prog.name);
			usage();
			continue;
		}

		boot_region_desc = addr;
		addr = boot_region_desc + (region_count * sizeof(regions[0]));
		pcpy(regions, (void *) boot_region_desc,
		     addr - boot_region_desc);
		boot_thread_state = addr;
		addr += sizeof(thread_state);
		pcpy(&thread_state, (void *) boot_thread_state,
		     addr - boot_thread_state);

		top = page_align(addr);
boot_kernel_only:
#ifdef DEBUG
		if (debug) {
			printf("startprog(\n");
			printf("    entry 0x%x,\n", kern_entry);
			printf("    -1,\n");
			printf("    extmem 0x%x,\n", extmem);
			printf("    cnvmem 0x%x,\n", cnvmem);
			printf("    kern_sym_start 0x%x,\n",
			       kern_prog.sym_start);
			printf("    kern_sym_size 0x%x,\n",
			       kern_prog.sym_size);
			printf("    kern_args_start 0x%x,\n",
			       kern_prog.args_start);
			printf("    kern_args_size 0x%x,\n",
			       kern_prog.args_size);
			for (p = kern_prog.args;
			     p < &kern_prog.args[kern_prog.args_size];
			     p += strlen(p)+1)
				printf("<%s>", p);
			printf("\n");
			printf("    boot_sym_start 0x%x,\n",
			       boot_prog.sym_start);
			printf("    boot_sym_size 0x%x,\n",
			       boot_prog.sym_size);
			printf("    boot_args_start 0x%x,\n",
			       boot_prog.args_start);
			printf("    boot_args_size 0x%x,\n",
			       boot_prog.args_size);
			for (p = boot_prog.args;
			     p < &boot_prog.args[boot_prog.args_size];
			     p += strlen(p)+1)
				printf("<%s>", p);
			printf("\n");
			printf("    boot_start 0x%x,\n", boot_start);
			printf("    boot_size 0x%x,\n",
			       boot_prog.sym_start - boot_start);
			printf("    boot_region_desc 0x%x,\n",
			       boot_region_desc);
			printf("    boot_region_count 0x%x,\n", region_count);
			printf("    boot_thread_state_flavor %d,\n",
			       THREAD_SYSCALL_STATE);
			printf("    boot_thread_state 0x%x (eip 0x%x, esp 0x%x),\n",
			       boot_thread_state,
			       thread_state.eip, thread_state.esp);
			printf("    boot_thread_state_count %d,\n",
			       (int) i386_THREAD_SYSCALL_STATE_COUNT);
			printf("    env_start 0x%x,\n", env_start);
			printf("    env_size 0x%x,\n", env_size);
			printf("    top 0x%x)\n", (int) top);
getchar();
			continue;
		}
#endif /* DEBUG */

/*
 * New calling convention
 *
 * %esp ->	-1
 *		size of extended memory (K)
 *		size of conventional memory (K)
 *		kern_sym_start
 *		kern_sym_size
 *		kern_args_start
 *		kern_args_size
 *		boot_sym_start
 *		boot_sym_size
 *		boot_args_start
 *		boot_args_size
 *		boot_start
 *		boot_size
 *		boot_region_desc
 *		boot_region_count
 *		boot_thread_state_flavor
 *		boot_thread_state
 *		boot_thread_state_count
 *		env_start
 *		env_size
 *		top of loaded memory
 */
		startprog(
			  kern_entry,
			  -1,
			  extmem, cnvmem,
			  kern_prog.sym_start, kern_prog.sym_size,
			  kern_prog.args_start, kern_prog.args_size,
			  boot_prog.sym_start, boot_prog.sym_size,
			  boot_prog.args_start, boot_prog.args_size,
			  boot_start, boot_prog.sym_start - boot_start,
			  boot_region_desc, region_count,
			  THREAD_SYSCALL_STATE, boot_thread_state,
			  i386_THREAD_SYSCALL_STATE_COUNT,
			  env_start, env_size,
			  top);
	}
}
예제 #3
0
void md_init_no_logo(void)
{
u08 force_setup;

    cli();    // disable interrupts
    hw_init();

#ifdef MOUSE_UART3
sbi(PORTD, 7); cbi(DDRD, 7);   //!!!! mouse uart
sbi(PORTD, 6); sbi(DDRD, 6);   //!!!! mouse uart
#endif

    sei();    // enable interrupts - the Donkey is off and running

    #ifdef TIME_CLOCK
       if(1) {   //!!! for time clock maximum wrap test
          time.hours= 23;
          time.mins = 59;
          time.secs = 00;
          time.month = 12;
          time.day  = 31;
          time.year = 2007;
          time.weekday = 6;
          time.adjust = 0;
       } 
    #endif

#ifdef PANEL_CODE
    lcd_init();          // initialize LCD hardware
    lcd_set_stdout();    // make printf() use bitmapped chars
#endif

#ifdef VCHAR_CODE
//  vchar_init();        // initialize vector characters
//  vchar_set_stdout();  // make printf use vector chars
#endif

    lcd_backlight(0xFF);

    force_setup = 0;
    user_input_init();

#ifdef CKSUM_CODE
    check_flash(DELAY_FLAG);   // verify FLASH checksum - can also add HALT_FLAG
#endif

#ifdef CKPT_CODE
    check_point(0);   // see if last run produced a system RAM checkpoint dump to eeprom
#endif

void contrast_demo(void);
//contrast_demo();

//zadc_demo(2);
//sketch_a_etch();

//void gps_demo(void);
//gps_demo();

//fill_screen(BLACK);
//arc(80,40, 20, 30,170, 10);
//arc(80,40, 10, 40,160, 1);
//wait_until_touched();
//wait_while_touched();


#ifdef USER_INPUT
    delay_ms(10);  // allow some time to pass
	               // might be needed for first get_touch?

    if(get_touch(1) || MouseRB || MouseLB) {   // if screen touched on powerup,  force setup menus
       lcd_clear();
       force_setup = 1;
       set_charsize(3);
       lcd_textPS(0, 0, "Setup");
       set_charsize(1);
//     wait_while_touched();        // not a good idea.  touch cal could be off
       delay_ms(2000);
    }

    calibrate_touch(force_setup);   // calibrate touch screen if not already done 

    misc_setup(force_setup);        // setup backlight, etc, if not already done

    #ifdef UART0   // do com0 setup menu, if not already done or forced setup
       com_setup(0, force_setup);     
    #endif

    #ifdef UART1   // do com1 setup menu, if not already done or forced setup
       com_setup(1, force_setup);
    #endif
#endif   // no user input device: set default com port parameters


// if library build then do donkey splash screen for 2.5 seconds

#ifdef LIBRARY_BUILD
  lcd_clear();
#endif

#ifdef MENU_CODE
 MenuBeep = 1; 
#endif


}