Esempio n. 1
0
void uart_init(void)
{
	/* TODO the divisor calculation is hard coded to standard UARTs. Some
	 * UARTs won't work with these values. This should be a property of the
	 * UART used, worst case a Kconfig variable. For now live with hard
	 * codes as the only devices that might be different are the iWave
	 * iRainbowG6 and the OXPCIe952 card (and the latter is memory mapped)
	 */
	unsigned int div = (115200 / CONFIG_TTYS0_BAUD);

#if !defined(__SMM__) && CONFIG_USE_OPTION_TABLE
	static const unsigned char divisor[8] = { 1, 2, 3, 6, 12, 24, 48, 96 };
	unsigned b_index = 0;
#if defined(__PRE_RAM__)
	b_index = read_option(baud_rate, 0);
	b_index &= 7;
	div = divisor[b_index];
#else
	if (get_option(&b_index, "baud_rate") == CB_SUCCESS)
		div = divisor[b_index];
#endif
#endif

	uart8250_init(CONFIG_TTYS0_BASE, div);
}
Esempio n. 2
0
list *read_cfg(char *filename)
{
    FILE *file = fopen(filename, "r");
    if(file == 0) file_error(filename);
    char *line;
    int nu = 0;
    list *sections = make_list();
    section *current = 0;
    while((line=fgetl(file)) != 0){
        ++ nu;
        strip(line);
        switch(line[0]){
            case '[':
                current = malloc(sizeof(section));
                list_insert(sections, current);
                current->options = make_list();
                current->type = line;
                break;
            case '\0':
            case '#':
            case ';':
                free(line);
                break;
            default:
                if(!read_option(line, current->options)){
                    fprintf(stderr, "Config file error line %d, could parse: %s\n", nu, line);
                    free(line);
                }
                break;
        }
    }
    fclose(file);
    return sections;
}
Esempio n. 3
0
list *read_data_cfg(char *filename)
{
    FILE *file = fopen(filename, "r");
    if(file == 0) file_error(filename);
    char *line;
    int nu = 0;
    list *options = make_list();
    while((line=fgetl(file)) != 0){
        ++ nu;
        strip(line);
        switch(line[0]){
            case '\0':
            case '#':
            case ';':
                free(line);
                break;
            default:
                if(!read_option(line, options)){
                    fprintf(stderr, "Config file error line %d, could parse: %s\n", nu, line);
                    free(line);
                }
                break;
        }
    }
    fclose(file);
    return options;
}
Esempio n. 4
0
static void ms7135_set_ram_voltage(void)
{
	u8 b;
	b = read_option(ram_voltage, 0);
	if (b > 4) /* default if above 2.70v */
		b = 0;
	printk(BIOS_INFO, "setting RAM voltage %08x\n", b);
	ck804_smbus_write_byte(1, 0x2f, 0x00, b);
}
Esempio n. 5
0
static void ms7135_set_nf4_voltage(void)
{
	u8 b;
	b = read_option(nf4_voltage, 0);
	if (b > 2) /* default if above 1.60v */
		b = 0;
	b |= 0x10;
	printk(BIOS_INFO, "setting NF4 voltage %08x\n", b);
	ck804_smbus_write_byte(1, 0x2f, 0x02, b);
}
Esempio n. 6
0
void uart_init(void)
{
#if CONFIG_USE_OPTION_TABLE
        static const unsigned char divisor[] = { 1,2,3,6,12,24,48,96 };
        unsigned ttys0_div, ttys0_index;
        ttys0_index = read_option(CMOS_VSTART_baud_rate, CMOS_VLEN_baud_rate, 0);
        ttys0_index &= 7;
        ttys0_div = divisor[ttys0_index];
	uart8250_init(CONFIG_TTYS0_BASE, ttys0_div, UART_LCS);
#else
	uart8250_init(CONFIG_TTYS0_BASE, CONFIG_TTYS0_DIV, UART_LCS);
#endif
}
Esempio n. 7
0
u32 uart_mem_init(void)
{
	unsigned uart_baud = CONFIG_TTYS0_BAUD;
	u32 uart_bar = 0;
	unsigned div;

	/* find out the correct baud rate */
#if !defined(__SMM__) && CONFIG_USE_OPTION_TABLE
	static const unsigned baud[8] = { 115200, 57600, 38400, 19200, 9600, 4800, 2400, 1200 };
	unsigned b_index = 0;
#if defined(__PRE_RAM__)
	b_index = read_option(baud_rate, 0);
	b_index &= 7;
	uart_baud = baud[b_index];
#else
	if (get_option(&b_index, "baud_rate") == CB_SUCCESS)
		uart_baud = baud[b_index];
#endif
#endif

	/* Now find the UART base address and calculate the divisor */
#if CONFIG_DRIVERS_OXFORD_OXPCIE

#if defined(MORE_TESTING) && !defined(__SIMPLE_DEVICE__)
	device_t dev = dev_find_device(0x1415, 0xc158, NULL);
	if (!dev)
		dev = dev_find_device(0x1415, 0xc11b, NULL);

	if (dev) {
		struct resource *res = find_resource(dev, 0x10);

		if (res) {
			uart_bar = res->base + 0x1000; // for 1st UART
			// uart_bar = res->base + 0x2000; // for 2nd UART
		}
	}

	if (!uart_bar)
#endif
	uart_bar = CONFIG_OXFORD_OXPCIE_BASE_ADDRESS + 0x1000; // 1st UART
	// uart_bar = CONFIG_OXFORD_OXPCIE_BASE_ADDRESS + 0x2000; // 2nd UART

	div = 4000000 / uart_baud;
#endif

	if (uart_bar)
		uart8250_mem_init(uart_bar, div);

	return uart_bar;
}
Esempio n. 8
0
//it is running on core0 of node0
static inline void start_other_cores(void)
{
	unsigned nodes;
	unsigned nodeid;

	if (read_option(multi_core, 0))  {
		return; // disable multi_core
	}

	nodes = get_nodes();

	for (nodeid=0; nodeid<nodes; nodeid++) {
		if ( get_core_num_in_bsp(nodeid) > 0) {
			real_start_other_core(nodeid);
		}
	}
}
Esempio n. 9
0
unsigned int default_baudrate(void)
{
#if !defined(__SMM__) && CONFIG_USE_OPTION_TABLE
	static const unsigned baud[8] =
		{ 115200, 57600, 38400, 19200, 9600, 4800, 2400, 1200 };
	unsigned b_index = 0;
#if defined(__PRE_RAM__)
	b_index = read_option(baud_rate, 0xff);
#else
	if (get_option(&b_index, "baud_rate") != CB_SUCCESS)
		b_index = 0xff;
#endif
	if (b_index < 8)
		return baud[b_index];
#endif
	return CONFIG_TTYS0_BAUD;
}
Esempio n. 10
0
static void ich7_enable_lpc(void)
{
    int lpt_en = 0;
    if (read_option(lpt, 0) != 0) {
        lpt_en = 1 << 2; // enable LPT
    }
    // Enable Serial IRQ
    pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x64, 0xd0);
    // decode range
    pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x80, 0x0007);
    // decode range
    pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x82, 0x3f0b | lpt_en);
    // Enable 0x02e0 - 0x2ff
    pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x84, 0x001c02e1);
    // Enable 0x600 - 0x6ff
    pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x88, 0x00fc0601);
    // Enable 0x68 - 0x6f
    pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x8c, 0x00040069);
}
Esempio n. 11
0
File: main.c Progetto: qstemper/42
int				main(int ac, char **av)
{
	t_env		*e;

	e = init_env();
	read_option(e, ac, av);
	if (!(e->mlx.win = mlx_new_window(e->mlx.mlx, WIDTH, HEIGHT, "WOLF3D")))
	{
		ft_putendl("ERROR CREATING WINDOW");
		return (-1);
	}
	usable_key();
	mlx_do_key_autorepeatoff(e->mlx.mlx);
	mlx_loop_hook(e->mlx.mlx, loop_hook, e);
	mlx_hook(e->mlx.win, PRESS, PRESS_MASK, key_press, e);
	mlx_key_hook(e->mlx.win, key_hook, e);
	mlx_loop(e->mlx.mlx);
	return (0);
}
Esempio n. 12
0
static twin_bool_t pboot_proc_client_sock(int sock, twin_file_op_t ops,
		void *closure)
{
	struct device_context *dev_ctx = closure;
	uint8_t action;

	if (read_action(sock, &action))
		goto out_err;

	if (action == DEV_ACTION_ADD_DEVICE) {
		if (!read_device(sock, dev_ctx))
			goto out_err;

	} else if (action == DEV_ACTION_ADD_OPTION) {
		if (dev_ctx->device_idx == -1) {
			LOG("option, but no device has been sent?\n");
			goto out_err;
		}

		if (!read_option(sock, dev_ctx))
			goto out_err;

	} else if (action == DEV_ACTION_REMOVE_DEVICE) {
		char *dev_id = read_string(sock);
		if (!dev_id)
			goto out_err;
		
		LOG("remove device %s\n", dev_id);
		pboot_remove_device(dev_id);

	} else {
		LOG("unsupported action %d\n", action);
		goto out_err;
	}

	return TWIN_TRUE;

out_err:
	close(sock);
	return TWIN_FALSE;
}
Esempio n. 13
0
static void ich7_enable_lpc(void)
{
	int lpt_en = 0;
	if (read_option(lpt, 0) != 0) {
		lpt_en = 1<<2; // enable LPT
	}
	// Enable Serial IRQ
	pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x64, 0xd0);
	// Set COM1/COM2 decode range
	pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x80, 0x0010);
	// Enable COM1/COM2/KBD/SuperIO1+2
	pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x82, 0x340b | lpt_en);
	// Enable HWM at 0xa00
	pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x84, 0x00fc0a01);
	// COM3 decode
	pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x88, 0x000403e9);
	// COM4 decode
	pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x8c, 0x000402e9);
	// io 0x300 decode
	pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x90, 0x00000301);
}
Esempio n. 14
0
static void ich7_enable_lpc(void)
{
	int lpt_en = 0;
	if (read_option(lpt, 0) != 0)
		lpt_en = LPT_LPC_EN;

	// Enable Serial IRQ
	pci_write_config8(PCI_DEV(0, 0x1f, 0), SERIRQ_CNTL, 0xd0);
	// decode range
	pci_write_config16(PCI_DEV(0, 0x1f, 0), LPC_IO_DEC, 0x0007);
	// decode range
	pci_write_config16(PCI_DEV(0, 0x1f, 0), LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN
			| MC_LPC_EN | KBC_LPC_EN | GAMEH_LPC_EN | GAMEL_LPC_EN
			| FDD_LPC_EN| lpt_en | COMB_LPC_EN | COMA_LPC_EN);
	// Enable 0x02e0 - 0x2ff
	pci_write_config32(PCI_DEV(0, 0x1f, 0), GEN1_DEC, 0x001c02e1);
	// Enable 0x600 - 0x6ff
	pci_write_config32(PCI_DEV(0, 0x1f, 0), GEN2_DEC, 0x00fc0601);
	// Enable 0x68 - 0x6f
	pci_write_config32(PCI_DEV(0, 0x1f, 0), GEN3_DEC, 0x00040069);
}
Esempio n. 15
0
void uart_init(void)
{
	/* disable interrupts */
	outb(0x0, CONFIG_TTYS0_BASE + UART_IER);
	/* enable fifo's */
	outb(0x01, CONFIG_TTYS0_BASE + UART_FCR);
	/* Set Baud Rate Divisor to 12 ==> 115200 Baud */
	outb(0x80 | UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
#if CONFIG_USE_OPTION_TABLE
	static const unsigned char divisor[] = { 1,2,3,6,12,24,48,96 };
	unsigned ttys0_div, ttys0_index;
	ttys0_index = read_option(CMOS_VSTART_baud_rate, CMOS_VLEN_baud_rate, 0);
	ttys0_index &= 7;
	ttys0_div = divisor[ttys0_index];
	outb(ttys0_div & 0xff, CONFIG_TTYS0_BASE + UART_DLL);
	outb(0, CONFIG_TTYS0_BASE + UART_DLM);
#else
	outb(CONFIG_TTYS0_DIV & 0xFF,   CONFIG_TTYS0_BASE + UART_DLL);
	outb((CONFIG_TTYS0_DIV >> 8) & 0xFF,    CONFIG_TTYS0_BASE + UART_DLM);
#endif
	outb(UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
}
Esempio n. 16
0
/*
 *	Read a switch configuration
 */
SWITCH *
switch_conf()
{
	char						*keyword;
	char						*argument;
	int							token;

	SWITCH						*sw;

	char						*name;

	struct switch_attributes	*attributes;


	sw = (SWITCH *) malloc(sizeof(SWITCH));

	if (sw == NULL) {
		config_error("malloc() failed.\n");
		exit(1);
	}

	name = read_option();		/* Read name			*/
  
	argument = read_option();	/* Read type			*/

	if ((name == NULL) || (argument == NULL)) {
		config_error("Name and type required for switch. Skipping.\n");
		next_keyword();
		return NULL;
	}

	sw->sw_type = parse_token(argument, switch_keywords);

	if (sw->sw_type == TOKEN_NOT_FOUND) {
		config_error("Switch type \"%s\" unknown. Assuming PS32.\n", argument);
		sw->sw_type = HIPPISW_PS32;
	}

	/*
	 *	Fill in defaults
	 */
	strncpy(sw->sw_name, name, SWNAMELEN);
	sw->sw_version = 1;

	/*	Set a bunch of stuff here in one wave of the hand	*/
	attributes = get_sw_attributes(sw->sw_type);
	bcopy(attributes, &(sw->sw_attributes), sizeof(sw->sw_attributes));
     
	sw->sw_ports = NULL;
	NULL_STRING(sw->sw_hostname);
	sw->sw_tport = TELNET_PORT;
	sw->sw_linenum = parsed_linenumber();
	NULL_STRING(sw->sw_comment);
	sw->sw_virt_attached  = NULL;
	NULL_STRING(sw->sw_password);
  
	/*
	 *	Read rest of options
	 */
	while ((keyword = read_option()) != NULL) {
    
		if ((token = parse_token(keyword, keywords)) == TOKEN_NOT_FOUND) {
			config_error("\"%s\" is not recognized. Skipping.\n", keyword);
			continue;
		}

		/*	Currently all options take arguments
		 */
		argument = read_option();

		if (argument == NULL) {
			config_error("Argument required for %s option.\n", keyword);
			continue;
		}

		switch(token) {
		case KEYWD_SIZE:
			if (is_numeric(argument) == FALSE) {
				config_error("\"%s\" is not a legal numeric argument. Skipping.\n",
							 argument);
				continue;
			}
			sw->sw_num_ports = str_to_int(argument);

			break;

		case KEYWD_ADDRESS:
			if (hostname_to_netaddr(argument) == NETADDR_NULL)
				config_error("Warning: can't resolve net address for \"%s\".\n",
							 argument);
      
			strncpy(sw->sw_hostname, argument, HNAMELEN);
			break;

		case KEYWD_PORT:
			if (is_numeric(argument) == FALSE) {
				config_error("\"%s\" is not a legal numeric argument. Skipping.\n",
							 argument);
				continue;
			}
			sw->sw_tport = str_to_int(argument);
			break;

		case KEYWD_PROMPT:
			config_error("\"prompt\" no longer supported. Skipping.\n");	
			break;

		case KEYWD_SMS:
			if (is_numeric(argument) == FALSE) {
				config_error("\"%s\" is not a legal numeric argument. Skipping.\n",
							 argument);
				continue;
			}
			sw->sw_version = str_to_int(argument);
			break;

		case KEYWD_COMMENT:
			strncpy(sw->sw_comment, argument, COMMENTLEN);
			break;

		case KEYWD_START_LOG:
			config_error("\"start_log\" no longer supported.\n");
			continue;
		}
	}

	if ((sw->sw_num = add_switch(sw)) == ERROR) {
		config_error("Error adding switch to list.\n");
		exit(1);
	}

	return sw;
}
Esempio n. 17
0
void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
{
	static const u16 spd_addr[] = { DIMM0, 0, 0, 0, DIMM1, 0, 0, 0, };
	int needs_reset = 0;
	u32 bsp_apicid = 0;
	msr_t msr;
	struct cpuid_result cpuid1;
	struct sys_info *sysinfo = &sysinfo_car;

	if (!cpu_init_detectedx && boot_cpu()) {
		/* Nothing special needs to be done to find bus 0 */
		/* Allow the HT devices to be found */
		enumerate_ht_chain();

		/* sb600_lpc_port80(); */
		sb600_pci_port80();
	}

	if (bist == 0) {
		bsp_apicid = init_cpus(cpu_init_detectedx, sysinfo);
	}

	enable_rs690_dev8(); // enable CFG access to Dev8, which is the SB P2P Bridge
	sb600_lpc_init();
#if defined(DUMP_CMOS_RAM) && (DUMP_CMOS_RAM == 0)
	check_cmos();  // rebooting in case of corrupted cmos !!!!!
#endif
	/* it8712f_enable_serial does not use its 1st parameter. */
	it8712f_enable_serial(0, CONFIG_TTYS0_BASE);
	it8712f_kill_watchdog();

	console_init();
#if defined(DUMP_CMOS_RAM) && (DUMP_CMOS_RAM == 1)
	check_cmos();  // rebooting in case of corrupted cmos !!!!!
#endif
	post_code(0x03);

	/* Halt if there was a built in self test failure */
	report_bist_failure(bist);
	__DEBUG__("bsp_apicid=0x%x\n", bsp_apicid);

	setup_sitemp_resource_map();

	setup_coherent_ht_domain();

#if CONFIG_LOGICAL_CPUS
	/* It is said that we should start core1 after all core0 launched */
	wait_all_core0_started();
	start_other_cores();
#endif
	wait_all_aps_started(bsp_apicid);

	ht_setup_chains_x(sysinfo);

	/* run _early_setup before soft-reset. */
	rs690_early_setup();
	sb600_early_setup();

	post_code(0x04);

	/* Check to see if processor is capable of changing FIDVID  */
	/* otherwise it will throw a GP# when reading FIDVID_STATUS */
	cpuid1 = cpuid(0x80000007);
	if( (cpuid1.edx & 0x6) == 0x6 ) {

		/* Read FIDVID_STATUS */
		msr=rdmsr(0xc0010042);
		__DEBUG__("begin msr fid, vid: hi=0x%x, lo=0x%x\n", msr.hi, msr.lo);

		enable_fid_change();
		enable_fid_change_on_sb(sysinfo->sbbusn, sysinfo->sbdn);
		init_fidvid_bsp(bsp_apicid);

		/* show final fid and vid */
		msr=rdmsr(0xc0010042);
		__DEBUG__("end msr fid, vid: hi=0x%x, lo=0x%x\n", msr.hi, msr.lo);

	} else {
		__DEBUG__("Changing FIDVID not supported\n");
	}

	post_code(0x05);

	needs_reset = optimize_link_coherent_ht();
	needs_reset |= optimize_link_incoherent_ht(sysinfo);
	rs690_htinit();
	__DEBUG__("needs_reset=0x%x\n", needs_reset);

	post_code(0x06);

	if (needs_reset) {
		__INFO__("ht reset -\n");
		soft_reset();
	}

	allow_all_aps_stop(bsp_apicid);

	/* It's the time to set ctrl now; */
	__DEBUG__("sysinfo->nodes: %2x  sysinfo->ctrl: %p  spd_addr: %p\n",
		     sysinfo->nodes, sysinfo->ctrl, spd_addr);
	fill_mem_ctrl(sysinfo->nodes, sysinfo->ctrl, spd_addr);

	post_code(0x07);

	sdram_initialize(sysinfo->nodes, sysinfo->ctrl, sysinfo);

	post_code(0x08);

	rs690_before_pci_init(); // does nothing
	sb600_before_pci_init();

#if CONFIG_USE_OPTION_TABLE
	if( read_option(cmos_defaults_loaded, 0) )
		__WARNING__("WARNING: CMOS DEFAULTS LOADED. PLEASE CHECK CMOS OPTION \"cmos_default_loaded\" !\n");
#endif

	post_cache_as_ram();
}
Esempio n. 18
0
void isom_options (int format, struct pcp_vars *pcp)
{
   register int *y = y_address;

   FILE *Status;
   FILE *FileName;
   FILE *Subgroup;

   struct pga_vars pga;

   Logical user_supplied = FALSE;
   Logical group_present = FALSE;
   Logical identity_map;
   Logical finished;
   Logical valid;
   Logical equal;

   int output = DEFAULT_STANDARD_PRINT;
   int start_class, final_class;
   int option;
   int t;
   int status;
   int complete;
   int iteration;
   int *seq1;
   int *seq2;
   int len1, len2;
   int nmr_items;
   int ***auts;
   int x_dim, y_dim;
   FILE * GAP_library;
   char *name;
   int nmr_of_exponents;

   StandardPresentation = TRUE;
   pga.nmr_soluble = 0;

   list_isom_menu ();

   do {
      option = read_option (MAXOPTION);      
      switch (option) {

      case -1:
	 list_isom_menu ();
	 break;

      case START_INFO:
	 t = runTime ();
	 group_present = setup_start_info (FALSE, 0, stdin, format, &pga, pcp);
	 handle_error (group_present);
	 user_supplied = TRUE;
	 t = runTime () - t;
	 /* it is possible that the p-quotient is trivial */
	 if (pcp->cc == 0) {
	    group_present = FALSE; 
	    break; 
	 }
	 printf ("Class %d %d-quotient and its %d-covering group computed in %.2f seconds\n", 
		 pcp->cc - 1, pcp->p, pcp->p, t * CLK_SCALE);
	 break;

      case CONSTRUCT:
	 if (!user_supplied) {
	    name = GetString ("Enter input file name for group information: ");
	    FileName = OpenFile (name, "r");
	    if (FileName == NULL) break;
	 }
            
	 name = GetString ("Enter output file name for group information: ");

	 read_value (TRUE, "Standardise presentation to what class? ",
		     &final_class, 0);
	 if (user_supplied && final_class < pcp->cc) { 
	    printf ("Value supplied for end class must be at least %d\n", 
		    pcp->cc);
	 }

	 /* read in data from file and set up group to end of start_class 
	    and compute its p-covering group */

	 if (!user_supplied) {
	    group_present = setup_start_info (FALSE, 0, FileName, 
					      FILE_INPUT, &pga, pcp);
	    handle_error (group_present);
	    if (final_class < pcp->cc) {
	       CloseFile (FileName);
	       printf ("Value supplied for end class must be at least %d\n", 
		       pcp->cc);
	    }
	 }

	 if (pcp->cc == 0) { 
	    printf ("%d-quotient is trivial\n", pcp->p); 
	    break;
	 }

	 complete = (pcp->newgen == 0) ? TERMINAL : CAPABLE; 
	 iteration = 0;

	 for (start_class = pcp->cc; start_class <= final_class && 
		 complete != TERMINAL; ++start_class) {

	    t = runTime ();

	    identity_map = FALSE;
	    Subgroup = OpenFile ("ISOM_Subgroup", "w");

	    do {
	       ++iteration;
	       set_defaults (&pga);
	       /*
		 pga.space_efficient = TRUE;
		 */

	       /* either prompt for information or read it from file */
	       if (user_supplied) {
		  auts = read_auts (STANDARDISE, &pga.m, &nmr_of_exponents, pcp)
		     ;
		  pga.fixed = 0;
		  query_solubility (&pga);
		  user_supplied = FALSE;
#ifdef HAVE_GMP
		  autgp_order (&pga, pcp);
#endif 
	       }
	       else {
		  auts = read_auts_from_file (FileName, &pga.m, pcp);
		  nmr_items = fscanf (FileName, "%d", &pga.fixed);
		  verify_read (nmr_items, 1);
		  nmr_items = fscanf (FileName, "%d", &pga.soluble);
		  verify_read (nmr_items, 1);

#ifdef HAVE_GMP
		  fscanf (FileName, "\n");
		  mpz_init (&pga.aut_order);
		  mpz_inp_str (&pga.aut_order, FileName, 10);
#endif
		  CloseFile (FileName);
	       }
	       x_dim = pga.m; y_dim = pcp->lastg;

	       /* construct standard presentation relative to smallest 
		  permissible characteristic subgroup in p-multiplicator */

	       standard_presentation (&identity_map, output, auts, &pga, pcp);

	       free_array (auts, x_dim, y_dim, 1);

	       /* was the characteristic subgroup chosen in this iteration
		  the whole of the p-multiplicator? */

	       Status = OpenFile ("ISOM_Status", "r");
	       fscanf (Status, "%d", &status);
	       fscanf (Status, "%d", &complete);
	       CloseFile (Status);
                 
	       /* have we finished the construction? */
	       finished = (status == END_OF_CLASS && 
			   (start_class == final_class || complete == TERMINAL));

	       /* organise to write modified presentation + automorphisms 
		  to file ISOM_PP */
              
	       if (!identity_map || finished)  
	       {
		  copy_file( "ISOM_present", "ISOM_PP" );
		  append_file( "ISOM_NextClass", "ISOM_PP" );
	       }
	       else
		  copy_file( "ISOM_NextClass", "ISOM_PP" );

	       if (finished) break;

	       /* if necessary, set up new presentation + other information */
	       FileName = OpenFile ("ISOM_PP", "r");
	       group_present = setup_start_info (identity_map, status, 
						 FileName, FILE_INPUT, &pga, pcp);

	       handle_error (group_present);

	       /* if appropriate, factor subgroup from p-multiplicator */
	       if (status != END_OF_CLASS) 
		  factor_subgroup (pcp);

	       /* reinitialise pga structure */
	       initialise_pga (&pga, pcp);
	       pga.m = 0;
	       pga.ndgen = y[pcp->clend + 1];
	       set_values (&pga, pcp);

	    } while (status != END_OF_CLASS && complete != TERMINAL);

	    CloseFile (Subgroup);

	    /* the group may have completed only when relations are enforced;
	       this is an attempt to determine this case */
	    if (pga.nuclear_rank != 0 && pcp->complete) 
	       break;
            
	    t = runTime () - t;
	    printf ("Computing standard presentation for class %d took %.2f seconds\n", 
		    start_class, t * CLK_SCALE);
	 }

	 /* we currently may have presentation for p-covering group;
	    or is the starting group terminal? if so, we may want to 
	    use last_class to revert to group presentation */

	 if (!user_supplied && iteration == 0 && !pcp->complete)
	    last_class (pcp);

	 /* is the group terminal? */
	 if (complete == TERMINAL) 
	    printf ("The largest %d-quotient of the group has class %d\n", 
		    pcp->p, pcp->cc);

	 if (iteration == 0) break;

	 /* rename file ISOM_PP containing iteration info to nominated file */
	 rename( "ISOM_PP", name );

	 break;

      case PRINT_PCP:
	 if (group_present) 
	    print_presentation (TRUE, pcp);
	 break;

      case SAVE_PRES:
	 name = GetString ("Enter output file name: ");
	 FileName = OpenFileOutput (name);
	 if (group_present && FileName != NULL) {
	    save_pcp (FileName, pcp);
	    CloseFile (FileName);
	    printf ("Presentation written to file\n");
	 }
	 break;
 
      case COMPARE:
	 valid = get_description ("Enter file name storing first presentation: ",
				  &len1, &seq1, pcp);
	 if (!valid) break;
	 valid = get_description ("Enter file name storing second presentation: ", 
				  &len2, &seq2, pcp);

	 if (!valid) break;
	 equal = (len1 == len2) ? compare_sequences (seq1, seq2, len1): FALSE;

	 printf ("Identical presentations? %s\n", equal == TRUE ? 
		 "True" : "False");
	 free_vector (seq1, 1);
	 free_vector (seq2, 1);
	 break;

      case STANDARD_PRINT_LEVEL: 
	 read_value (TRUE, "Input print level for construction (0-2): ",
		     &output, 0);
	 /* allow user to supply same max print level as for 
	    p-quotient calculations */
	 if (output == MAX_STANDARD_PRINT + 1)
	    --output; 
	 if (output > MAX_STANDARD_PRINT) {
	    printf ("Print level must lie between %d and %d\n",
		    MIN_STANDARD_PRINT, MAX_STANDARD_PRINT);
	    output = DEFAULT_STANDARD_PRINT;
	 }
	 break;

      case PQ_MENU:
	 options (ISOM_MENU, format, pcp);
	 break;

      case ISOM_OPTION:
	 FileName = OpenFile (name, "r");
	 group_present = setup_start_info (FALSE, 0, FileName, 
					   FILE_INPUT, &pga, pcp);
         pcp->multiplicator_rank = pcp->lastg - y[pcp->clend + pcp->cc-1];
	 last_class (pcp);
	 auts = read_auts_from_file (FileName, &pga.m, pcp);
	 nmr_items = fscanf (FileName, "%d", &pga.fixed);
	 verify_read (nmr_items, 1);
	 nmr_items = fscanf (FileName, "%d", &pga.soluble);
	 verify_read (nmr_items, 1);
        
	 printf ("Images of user-supplied generators are listed last below\n"); 
	 print_map (pcp);
#ifdef HAVE_GMP
	 fscanf (FileName, "\n");
	 mpz_init (&pga.aut_order);
	 mpz_inp_str (&pga.aut_order, FileName, 10);
#endif
	 CloseFile (FileName);
	 GAP_library = OpenFile ("GAP_library", "a+");
	 write_GAP_library (GAP_library, pcp);
	 pga.nmr_centrals = pga.m;
	 pga.nmr_stabilisers = 0;

	 GAP_auts (GAP_library, auts, auts, &pga, pcp);
	 CloseFile (GAP_library);
	 printf ("Presentation listing images of user-supplied generators written to GAP_library\n");
	 break;

      case EXIT: case MAXOPTION:
	 unlink( "ISOM_present" );
	 unlink( "ISOM_Subgroup" );
	 unlink( "ISOM_cover_file" );
	 unlink( "ISOM_group_file" );
	 unlink( "ISOM_XX" );
	 unlink( "ISOM_NextClass" );
	 unlink( "ISOM_Status" );
	 printf ("Exiting from ANU p-Quotient Program\n");
	 break;

      }                         /* switch */
   } while (option != 0 && option != MAXOPTION);      
}
Esempio n. 19
0
void interactive_pga(Logical group_present,
                     FILE *StartFile,
                     int group_nmr,
                     int ***auts,
                     struct pga_vars *pga,
                     struct pcp_vars *pcp)
{
   struct pga_vars flag;
   int option;
   Logical soluble_group = TRUE;

   FILE *OutputFile = 0;
   FILE *LINK_input = 0;

   char *StartName = 0;
   int t;

   int **perms = 0;
   int index;
   int **S = 0;
   int k;
   int K;
   int label;
   int *a = 0, *b = 0;
   char *c = 0;
   int *orbit_length = 0;
   int nmr_of_exponents;
   int *subset = 0;
   int alpha;
   int upper_step;
   int rep;
   int i;

   list_interactive_pga_menu();

   do {
      option = read_option(MAX_INTERACTIVE_OPTION);
      switch (option) {

      case -1:
         list_interactive_pga_menu();
         break;

      case SUPPLY_AUTS:
         auts = read_auts(PGA, &pga->m, &nmr_of_exponents, pcp);
#ifdef HAVE_GMP
         autgp_order(pga, pcp);
#endif
         pga->soluble = TRUE;
         start_group(&StartFile, auts, pga, pcp);
         break;

      case EXTEND_AUTS:
         extend_automorphisms(auts, pga->m, pcp);
         print_auts(pga->m, pcp->lastg, auts, pcp);
         break;

      case RESTORE_GP:
         StartName = GetString("Enter input file name: ");
         StartFile = OpenFileInput(StartName);
         if (StartFile != NULL) {
            read_value(TRUE, "Which group? ", &group_nmr, 0);
            auts = restore_group(TRUE, StartFile, group_nmr, pga, pcp);
            RESET(StartFile);
         }
         break;

      case DISPLAY_GP:
         print_presentation(FALSE, pcp);
         print_structure(1, pcp->lastg, pcp);
         print_pcp_relations(pcp);
         break;

      case SINGLE_STAGE:
         t = runTime();
         if (group_present && pga->m == 0)
            start_group(&StartFile, auts, pga, pcp);
         assert(OutputFile);
         construct(1,
                   &flag,
                   SINGLE_STAGE,
                   OutputFile,
                   StartFile,
                   0,
                   ALL,
                   group_nmr,
                   pga,
                   pcp);
         t = runTime() - t;
         printf("Time for intermediate stage is %.2f seconds\n", t * CLK_SCALE);
         break;

      case DEGREE:
         read_step_size(pga, pcp);
         read_subgroup_rank(&k);
         query_exponent_law(pga);
         enforce_laws(pga, pga, pcp);
         extend_automorphisms(auts, pga->m, pcp);
         step_range(k, &pga->s, &upper_step, auts, pga, pcp);

         if (pga->s > upper_step)
            printf("Desired step size is invalid for current group\n");
         else {
            if (pga->s < upper_step) {
               printf("The permitted relative step sizes range from %d to %d\n",
                      pga->s,
                      upper_step);
               read_value(
                   TRUE, "Input the chosen relative step size: ", &pga->s, 0);
            }


            store_definition_sets(pga->r, pga->s, pga->s, pga);
            get_definition_sets(pga);
            pga->print_degree = TRUE;
            compute_degree(pga);
            pga->print_degree = FALSE;
         }
         break;

      case PERMUTATIONS:
         if (pga->Degree != 0) {
            t = runTime();

            query_solubility(pga);
            pga->trace = FALSE;
            if (pga->soluble)
               query_space_efficiency(pga);
            else
               pga->space_efficient = FALSE;
            query_perm_information(pga);

            strip_identities(auts, pga, pcp);
            soluble_group =
                (pga->soluble || pga->Degree == 1 || pga->nmr_of_perms == 0);
            if (!soluble_group) {
#if defined(GAP_LINK)
               StartGapFile(pga);
#else
#if defined(GAP_LINK_VIA_FILE)
               start_GAP_file(&LINK_input, auts, pga, pcp);
#endif
#endif
            }
            perms = permute_subgroups(LINK_input, &a, &b, &c, auts, pga, pcp);

#if defined(GAP_LINK_VIA_FILE)
            if (!soluble_group)
               CloseFile(LINK_input);
#endif
            t = runTime() - t;
            printf("Time to compute permutations is %.2f seconds\n",
                   t * CLK_SCALE);
         } else
            printf("You must first select option %d\n", DEGREE);

         break;

      case ORBITS:
         orbit_option(option, perms, &a, &b, &c, &orbit_length, pga);
         break;

      case STABILISERS:
      case STABILISER:
         assert(perms);
         stabiliser_option(
             option, auts, perms, a, b, c, orbit_length, pga, pcp);
         /*
           free_space (pga->soluble, perms, orbit_length,
           a, b, c, pga);
           */
         break;

      case MATRIX_TO_LABEL:
         S = allocate_matrix(pga->s, pga->q, 0, FALSE);
         subset = allocate_vector(pga->s, 0, FALSE);
         printf("Input the %d x %d subgroup matrix:\n", pga->s, pga->q);
         read_matrix(S, pga->s, pga->q);
         K = echelonise_matrix(S, pga->s, pga->q, pga->p, subset, pga);
         printf("The standard matrix is:\n");
         print_matrix(S, pga->s, pga->q);
         printf("The label is %d\n", subgroup_to_label(S, K, subset, pga));
         free_vector(subset, 0);
         break;

      case LABEL_TO_MATRIX:
         read_value(TRUE, "Input allowable subgroup label: ", &label, 1);
         S = label_to_subgroup(&index, &subset, label, pga);
         printf("The corresponding standard matrix is\n");
         print_matrix(S, pga->s, pga->q);
         break;

      case IMAGE:
         t = runTime();
         /*
           invert_automorphisms (auts, pga, pcp);
           print_auts (pga->m, pcp->lastg, auts, pcp);
           */
         printf("Input the subgroup label and automorphism number: ");
         read_value(TRUE, "", &label, 1);
         read_value(FALSE, "", &alpha, 1);
         printf("Image is %d\n", find_image(label, auts[alpha], pga, pcp));
         t = runTime() - t;
         printf("Computation time in seconds is %.2f\n", t * CLK_SCALE);
         break;

      case SUBGROUP_RANK:
         read_subgroup_rank(&k);
         printf("Closure of initial segment subgroup has rank %d\n",
                close_subgroup(k, auts, pga, pcp));
         break;

      case ORBIT_REP:
         printf("Input label for subgroup: ");
         read_value(TRUE, "", &label, 1);
         rep = abs(a[label]);
         for (i = 1; i <= pga->nmr_orbits && pga->rep[i] != rep; ++i)
            ;
         printf("Subgroup with label %d has representative %d and is in orbit "
                "%d\n",
                label,
                rep,
                i);
         break;


      case COMPACT_DESCRIPTION:
         Compact_Description = TRUE;
         read_value(TRUE,
                    "Lower bound for order (0 for all groups generated)? ",
                    &Compact_Order,
                    0);
         break;

      case AUT_CLASSES:
         t = runTime();
         permute_elements();
         t = runTime() - t;
         printf("Time to compute orbits is %.2f seconds\n", t * CLK_SCALE);
         break;

      /*
        printf ("Input label: ");
        scanf ("%d", &l);
        process_complete_orbit (a, l, pga, pcp);
        break;

        case TEMP:
        printf ("Input label: ");
        scanf ("%d", &l);
        printf ("Input label: ");
        scanf ("%d", &u);
        for (i = l; i <= u; ++i) {
        x = IsValidAllowableSubgroup (i, pga);
        printf ("%d is %d\n", i, x);
        }
        StartName = GetString ("Enter output file name: ");
        OutputFile = OpenFileOutput (StartName);
        part_setup_reps (pga->rep, pga->nmr_orbits, orbit_length, perms, a, b,
        c,
        auts, OutputFile, OutputFile, pga, pcp);

        list_word (pga, pcp);

        read_value (TRUE, "Input the rank of the subgroup: ", &pga->q, 1);
        strip_identities (auts, pga, pcp);
        break;
        */

      case EXIT:
      case MAX_INTERACTIVE_OPTION:
         printf("Exiting from interactive p-group generation menu\n");
         break;

      } /* switch */

   } while (option != 0 && option != MAX_INTERACTIVE_OPTION);

#if defined(GAP_LINK)
   if (!soluble_group)
      QuitGap();
#endif
}
Esempio n. 20
0
/******************************************************************************

  run_test()
  
  Run the given test case.

******************************************************************************/
void run_test(char *test)
{
  char temp[PATH_MAX];
  char *rstr;
  double elapsed = 0;
  int skip = FALSE, ignore=FALSE;
  int restart = FALSE;
  int flag = FALSE;
  struct stat info;
  
  // skip tests in the skip list
  snprintf(temp, PATH_MAX, " %s ", test);
  skip = (strindex(skip_test, temp) != NULL);
  if (skip == FALSE)
    ignore = (strindex(ignore_test, temp) != NULL);
    
  if (ignore)
  {
    // show test
    log_msg("%-46s ", test);
         
    // ignore
    rstr = TEST_IGNORE;
    ++total_ignore;
  }  
  else if (!skip)     // skip test?
  {
    char test_file[PATH_MAX];
    char master_opt_file[PATH_MAX];
    char slave_opt_file[PATH_MAX];
    char slave_master_info_file[PATH_MAX];
    char result_file[PATH_MAX];
    char reject_file[PATH_MAX];
    char out_file[PATH_MAX];
    char err_file[PATH_MAX];
    int err;
    arg_list_t al;
    NXTime_t start, stop;
    
    // skip slave?
    flag = skip_slave;
    skip_slave = (strncmp(test, "rpl", 3) != 0);
    if (flag != skip_slave) restart = TRUE;
    
    // create files
    snprintf(master_opt_file, PATH_MAX, "%s/%s-master.opt", test_dir, test);
    snprintf(slave_opt_file, PATH_MAX, "%s/%s-slave.opt", test_dir, test);
    snprintf(slave_master_info_file, PATH_MAX, "%s/%s.slave-mi", test_dir, test);
    snprintf(reject_file, PATH_MAX, "%s/%s%s", result_dir, test, REJECT_SUFFIX);
    snprintf(out_file, PATH_MAX, "%s/%s%s", result_dir, test, OUT_SUFFIX);
    snprintf(err_file, PATH_MAX, "%s/%s%s", result_dir, test, ERR_SUFFIX);
    
    // netware specific files
    snprintf(test_file, PATH_MAX, "%s/%s%s", test_dir, test, NW_TEST_SUFFIX);
    if (stat(test_file, &info))
    {
      snprintf(test_file, PATH_MAX, "%s/%s%s", test_dir, test, TEST_SUFFIX);
      if (access(test_file,0))
      {
        printf("Invalid test name %s, %s file not found\n",test,test_file);
        return;
      }
    }

    snprintf(result_file, PATH_MAX, "%s/%s%s", result_dir, test, NW_RESULT_SUFFIX);
    if (stat(result_file, &info))
    {
      snprintf(result_file, PATH_MAX, "%s/%s%s", result_dir, test, RESULT_SUFFIX);
    }

    // init scripts
    snprintf(master_init_script, PATH_MAX, "%s/%s-master.sh", test_dir, test);
    if (stat(master_init_script, &info))
      master_init_script[0] = NULL;
    else
      restart = TRUE;
    
    snprintf(slave_init_script, PATH_MAX, "%s/%s-slave.sh", test_dir, test);
    if (stat(slave_init_script, &info))
      slave_init_script[0] = NULL;
    else
      restart = TRUE;

    // read options
    if (read_option(master_opt_file, master_opt)) restart = TRUE;
    if (read_option(slave_opt_file, slave_opt)) restart = TRUE;
    if (read_option(slave_master_info_file, slave_master_info)) restart = TRUE;
    
    // cleanup previous run
    remove(reject_file);
    remove(out_file);
    remove(err_file);
    
    // start or restart?
    if (!master_running) mysql_start();
      else if (restart) mysql_restart();
    
    // let the system stabalize
    sleep(1);

    // show test
    log_msg("%-46s ", test);
    
    // args
    init_args(&al);
    add_arg(&al, "%s", mysqltest_file);
    add_arg(&al, "--no-defaults");
    add_arg(&al, "--port=%u", master_port);
    add_arg(&al, "--database=%s", db);
    add_arg(&al, "--user=%s", user);
    add_arg(&al, "--password=%s", password);
    add_arg(&al, "--silent");
    add_arg(&al, "--basedir=%s/", mysql_test_dir);
    add_arg(&al, "--host=127.0.0.1");
    add_arg(&al, "-v");
    add_arg(&al, "-R");
    add_arg(&al, "%s", result_file);

    if (use_openssl)
    {
      add_arg(&al, "--ssl-ca=%s", ca_cert);
      add_arg(&al, "--ssl-cert=%s", client_cert);
      add_arg(&al, "--ssl-key=%s", client_key);
    }

    // start timer
    NXGetTime(NX_SINCE_BOOT, NX_USECONDS, &start);
    
    // spawn
    err = spawn(mysqltest_file, &al, TRUE, test_file, out_file, err_file);
    
    // stop timer
    NXGetTime(NX_SINCE_BOOT, NX_USECONDS, &stop);
    
    // calculate
    elapsed = ((double)(stop - start)) / NX_USECONDS;
    total_time += elapsed;
    
    // free args
    free_args(&al);
    
    if (err == 0)
    {
      // pass
      rstr = TEST_PASS;
      ++total_pass;
      
      // increment total
      ++total_test;
    }
    else if (err == 62)
    {
      // skip
      rstr = TEST_SKIP;
      ++total_skip;
    }
    else if (err == 1)
    {
      // fail
      rstr = TEST_FAIL;
      ++total_fail;
      
      // increment total
      ++total_test;
    }
    else
    {
      rstr = TEST_BAD;
    }
  }
  else // early skips
  {
    // show test
    log_msg("%-46s ", test);
    
    // skip
    rstr = TEST_SKIP;
    ++total_skip;
  }
  
  // result
  log_msg("%10.06f   %-14s\n", elapsed, rstr);
}
static void parse_options(char *options) {
    char *tmp;
    int (*read_option)(char *, char *);
    char opt_name[MAX_PATH_LEN];
    char opt_val[MAX_PATH_LEN];
    int i;

    if (options == NULL)
        return;

    if ((opt_cmp(options, OPT_HELP)) == 0) {
        jcov_usage();
    }
    
    cur_opt = options;
    read_option = read_option_cmdline;
    
    while (1) {
        if (read_option(opt_name, opt_val) == 0) {
            jcov_close(&opt_file);
            if (read_option == read_option_disk)
                read_option = read_option_cmdline;
            else
                break;
        } else if (opt_cmp(opt_name, OPT_OPTIONS_FILE) == 0) {
            if ((opt_file = fopen(opt_val, "rb")) == NULL) {
                sprintf(opt_name,"cannot open file : %s\n", opt_val);
                jcov_error_stop(opt_name);
            }
            read_option = read_option_disk;
        } else if (opt_cmp(opt_name, OPT_FILE) == 0) {
            jcov_file = (char*)jcov_calloc(strlen(opt_val) + 1);
            strcpy(jcov_file, opt_val);
        } else if (opt_cmp(opt_name, OPT_TYPE) == 0) {
            jcov_data_type = opt_val[0];
            if (jcov_data_type == 'M' || jcov_data_type == 'm')
                jcov_data_type = JCOV_DATA_M;
            else if (jcov_data_type == 'B' || jcov_data_type == 'b')
                jcov_data_type = JCOV_DATA_B;
            else {
                printf("Invalid data type : %c\n", jcov_data_type);
                jcov_usage();
            }
        } else if (opt_cmp(opt_name, OPT_ABSTR_METH) == 0) {
            if (opt_cmp(opt_val, OPT_ON) == 0)
                include_abstracts = 1;
        } else if (opt_cmp(opt_name, OPT_OVERWRITE) == 0) {
            if (opt_cmp(opt_val, OPT_ON) == 0)
                overwrite_jcov_file = 1;
        } else if (opt_cmp(opt_name, OPT_EC) == 0) {
            if (opt_cmp(opt_val, OPT_ON) == 0)
                load_early_classes = 1;
        } else if (opt_cmp(opt_name, OPT_VERBOSITY) == 0) {
            if (strlen(opt_val) > 1) {
                jcov_usage();
            }
            i = opt_val[0] - '0';
            if (i < 0 || i > 9) {
                jcov_usage();
            }
            verbose_mode = i;
        } else if (opt_cmp(opt_name, OPT_INCLUDE) == 0) {
            ADD_FILTER(class_filter, incl);
        } else if (opt_cmp(opt_name, OPT_EXCLUDE) == 0) {
            ADD_FILTER(class_filter, excl);
        } else if (opt_cmp(opt_name, OPT_CALLER_INCL) == 0) {
            ADD_FILTER(caller_filter, incl);
        } else if (opt_cmp(opt_name, OPT_CALLER_EXCL) == 0) {
            ADD_FILTER(caller_filter, excl);
        } else {
            printf("Unrecognized option : %s\n", opt_name);
            jcov_usage();
        }
    }
}