Ejemplo n.º 1
0
static void
ob_sd_open(ATTRIBUTE_UNUSEDsd_private_t **sd)
{
    int ret = 1, id;
    phandle_t ph;

    fword("my-unit");
    id = POP();
    POP(); // unit id is 2 ints but we only need one.
    *sd = &global_esp->sd[id];

#ifdef CONFIG_DEBUG_ESP
    {
        char *args;

        fword("my-args");
        args = pop_fstr_copy();
        DPRINTF("opening drive %d args %s\n", id, args);
        free(args);
    }
#endif

    selfword("open-deblocker");

    /* interpose disk-label */
    ph = find_dev("/packages/disk-label");
    fword("my-args");
    PUSH_ph( ph );
    fword("interpose");

    RET ( -ret );
}
Ejemplo n.º 2
0
/* ( -- success? ) */
static void
scsi_open( instance_data_t *sd )
{
    static int once = 0;
    phandle_t ph;

    fword("my-unit");
    sd->target = POP();

    if( !once ) {
        once++;
        OSI_SCSIControl( SCSI_CTRL_INIT, 0 );
    }

    /* obtiain device information */
    if( inquiry(sd) )
        RET(0);

    selfword("open-deblocker");

    /* interpose disk-label */
    ph = find_dev("/packages/disk-label");
    fword("my-args");
    PUSH_ph( ph );
    fword("interpose");

    PUSH( -1 );
}
Ejemplo n.º 3
0
void init_forth_context(void)
{
	/* Execute Forth payload */
	printk("Evaluating Forth...\n");
	fword("load-base");
	feval("load-state >ls.file-size @");
	fword("eval2");
}
Ejemplo n.º 4
0
void init_fcode_context(void)
{
	/* Execute FCode payload */
	printk("Evaluating FCode...\n");
	fword("load-base");
	PUSH(1);
	fword("byte-load");
}
Ejemplo n.º 5
0
void
ob_init_iommu(uint64_t base)
{
    struct iommu_regs *regs;

    regs = iommu_init(&ciommu, base);

    push_str("/iommu");
    fword("find-device");
    PUSH((unsigned long)regs);
    fword("encode-int");
    push_str("address");
    fword("property");

    PUSH(base >> 32);
    fword("encode-int");
    PUSH(base & 0xffffffff);
    fword("encode-int");
    fword("encode+");
    PUSH(IOMMU_REGS);
    fword("encode-int");
    fword("encode+");
    push_str("reg");
    fword("property");

    bind_func("map-in", ob_iommu_map_in);
    bind_func("map-out", ob_iommu_map_out);
}
Ejemplo n.º 6
0
static void
add_alias(const char *device, const char *alias)
{
    DPRINTF("add_alias dev \"%s\" = alias \"%s\"\n", device, alias);
    push_str("/aliases");
    fword("find-device");
    push_str(device);
    fword("encode-string");
    push_str(alias);
    fword("property");
}
Ejemplo n.º 7
0
Archivo: boot.c Proyecto: 3a9LL/panda
void go(void)
{
	ucell address, type, size;
	int image_retval = 0;

	/* Get the entry point and the type (see forth/debugging/client.fs) */
	feval("saved-program-state >sps.entry @");
	address = POP();
	feval("saved-program-state >sps.file-type @");
	type = POP();
	feval("saved-program-state >sps.file-size @");
	size = POP();

	printk("\nJumping to entry point " FMT_ucellx " for type " FMT_ucellx "...\n", address, type);

	switch (type) {
		case 0x0:
			/* Start ELF boot image */
			image_retval = start_elf(address, (uint32_t)&elf_boot_notes);
			break;

		case 0x1:
			/* Start ELF image */
			image_retval = start_elf(address, (uint32_t)NULL);
			break;

		case 0x5:
			/* Start a.out image */
			image_retval = start_elf(address, (uint32_t)NULL);
			break;

		case 0x10:
			/* Start Fcode image */
			printk("Evaluating FCode...\n");
			PUSH(address);
			PUSH(1);
			fword("byte-load");
			image_retval = 0;
			break;

		case 0x11:
			/* Start Forth image */
			PUSH(address);
			PUSH(size);
			fword("eval2");
			image_retval = 0;
			break;
	}

	printk("Image returned with return value %#x\n", image_retval);
}
Ejemplo n.º 8
0
Archivo: init.c Proyecto: 3a9LL/panda
static void
setenv( char *env, char *value )
{
	push_str( value );
	push_str( env );
	fword("$setenv");
}
Ejemplo n.º 9
0
void
bind_func( const char *name, void (*func)(void) )
{
	PUSH( pointer2cell(func) );
	push_str( name );
	fword("is-cfunc");
}
Ejemplo n.º 10
0
xt_t
bind_noname_func( void (*func)(void) )
{
	PUSH( pointer2cell(func) );
	fword("is-noname-cfunc");
	return POP_xt();
}
Ejemplo n.º 11
0
void
update_nvram( void )
{
	PUSH( pointer2cell(nvram.config->data) );
	PUSH( nvram.config_size );
	fword("nvram-store-configs");
	arch_nvram_put( nvram.data );
}
Ejemplo n.º 12
0
void
nvconf_init( void )
{
	int once=0;

	/* initialize nvram structure completely */
	nvram.config = NULL;
	nvram.config_size = 0;

	nvram.size = arch_nvram_size();
	nvram.data = malloc( nvram.size );
	arch_nvram_get( nvram.data );

	bind_func( "update-nvram", update_nvram );

	for( ;; ) {
		nvpart_t *p = NULL;
		int err;

		while( (err=next_nvpart(&p)) > 0 ) {
			if( nvpart_checksum(p) != p->checksum ) {
				err = -1;
				break;
			}
			if( p->signature == NV_SIG_SYSTEM ) {
				nvram.config = p;
				nvram.config_size = nvpart_size(p) - 0x10;

				if( !once++ ) {
					PUSH( pointer2cell(p->data) );
					PUSH( nvram.config_size );
					fword("nvram-load-configs");
				}
			}
		}
		if( err || !nvram.config ) {
			printk("nvram error detected, zapping pram\n");
			zap_nvram();
			if( !once++ )
				fword("set-defaults");
			continue;
		}
		break;
	}
}
Ejemplo n.º 13
0
static void
ob_esp_initialize(ATTRIBUTE_UNUSED esp_private_t **esp)
{
    phandle_t ph = get_cur_dev();

    set_int_property(ph, "#address-cells", 2);
    set_int_property(ph, "#size-cells", 0);

    /* set device type */
    push_str("scsi");
    fword("device-type");

    /* QEMU's ESP emulation does not support mixing DMA and FIFO messages. By
       setting this attribute, we prevent the Solaris ESP kernel driver from
       trying to use this feature when booting a disk image (and failing) */
    PUSH(0x58);
    fword("encode-int");
    push_str("scsi-options");
    fword("property");

    PUSH(0x24);
    fword("encode-int");
    PUSH(0);
    fword("encode-int");
    fword("encode+");
    push_str("intr");
    fword("property");
}
Ejemplo n.º 14
0
void
bind_xtfunc( const char *name, xt_t xt, ucell arg, void (*func)(void) )
{
	PUSH_xt( xt );
	PUSH( arg );
	PUSH( pointer2cell(func) );
	push_str( name );
	fword("is-xt-cfunc");
}
Ejemplo n.º 15
0
int 
bootcode_load(ihandle_t dev)
{
    int retval = -1, count = 0, fd;
    unsigned long bootcode, loadbase, offset;

    /* Mark the saved-program-state as invalid */
    feval("0 state-valid !");

    fd = open_ih(dev);
    if (fd == -1) {
        goto out;
    }

    /* Default to loading at load-base */
    fword("load-base");
    loadbase = POP();
    
#ifdef CONFIG_PPC
    /* However Old World Macs need to load to a different address */
    if (is_oldworld()) {
        loadbase = OLDWORLD_BOOTCODE_BASEADDR;
    }
#endif
    
    bootcode = loadbase;
    offset = 0;
    
    while(1) {
        if (seek_io(fd, offset) == -1)
            break;
        count = read_io(fd, (void *)bootcode, 512);
        offset += count;
        bootcode += count;
    }

    /* If we didn't read anything then exit */
    if (!count) {
        goto out;
    }
    
    /* Initialise saved-program-state */
    PUSH(loadbase);
    feval("saved-program-state >sps.entry !");
    PUSH(offset);
    feval("saved-program-state >sps.file-size !");
    feval("bootcode saved-program-state >sps.file-type !");

    feval("-1 state-valid !");

out:
    close_io(fd);
    return retval;
}
Ejemplo n.º 16
0
int openbios(void)
{
#ifdef CONFIG_DEBUG_CONSOLE
#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
	uart_init(CONFIG_SERIAL_PORT, CONFIG_SERIAL_SPEED);
#endif
	/* Clear the screen.  */
	cls();
#endif

        collect_sys_info(&sys_info);

        dict = (unsigned char *)sys_info.dict_start;
        dicthead = (cell)sys_info.dict_end;
        last = sys_info.dict_last;
        dictlimit = sys_info.dict_limit;

	forth_init();

	relocate(&sys_info);

#ifdef CONFIG_DEBUG_CONSOLE_VGA
	video_init();
#endif
#ifdef CONFIG_DEBUG_BOOT
	printk("forth started.\n");
	printk("initializing memory...");
#endif

	init_memory();

#ifdef CONFIG_DEBUG_BOOT
	printk("done\n");
#endif

	PUSH_xt( bind_noname_func(arch_init) );
	fword("PREPOST-initializer");

	PC = (ucell)findword("initialize-of");

	if (!PC) {
		printk("panic: no dictionary entry point.\n");
		return -1;
	}
#ifdef CONFIG_DEBUG_DICTIONARY
	printk("done (%d bytes).\n", dicthead);
	printk("Jumping to dictionary...\n");
#endif

	enterforth((xt_t)PC);

	return 0;
}
Ejemplo n.º 17
0
void
boot( void )
{
        uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);

	fword("update-chosen");
	if (boot_device == 'm') {
	        check_preloaded_kernel();
	}

	if (is_apple()) {
		update_nvram();
	}
}
Ejemplo n.º 18
0
static void
ob_cuda_initialize (int *idx)
{
	phandle_t ph=get_cur_dev();
	int props[2];

	push_str("via-cuda");
	fword("device-type");

	set_int_property(ph, "#address-cells", 1);
        set_int_property(ph, "#size-cells", 0);

	set_property(ph, "compatible", "cuda", 5);

	props[0] = __cpu_to_be32(IO_CUDA_OFFSET);
	props[1] = __cpu_to_be32(IO_CUDA_SIZE);

	set_property(ph, "reg", (char *)&props, sizeof(props));

	/* on newworld machines the cuda is on interrupt 0x19 */

	props[0] = 0x19;
	props[1] = 0;
	NEWWORLD(set_property(ph, "interrupts", (char *)props, sizeof(props)));
	NEWWORLD(set_int_property(ph, "#interrupt-cells", 2));

	/* we emulate an oldworld hardware, so we must use
	 * non-standard oldworld property (needed by linux 2.6.18)
	 */

	OLDWORLD(set_int_property(ph, "AAPL,interrupts", 0x12));

        bind_func("ppc32-reset-all", ppc32_reset_all);
        push_str("' ppc32-reset-all to reset-all");
        fword("eval");
}
Ejemplo n.º 19
0
void boot(void)
{
	char *path, *param;

	/* Copy the incoming path */
	fword("2dup");
	path = pop_fstr_copy();

	/* Boot preloaded kernel */
        if (kernel_size) {
            void (*entry)(unsigned long p1, unsigned long p2, unsigned long p3,
                          unsigned long p4, unsigned long p5);

            printk("[sparc64] Kernel already loaded\n");
            entry = (void *) (unsigned long)kernel_image;
            entry(0, 0, 0, 0, (unsigned long)&sparc64_of_client_interface);
        }

	/* Invoke Linux directly -- probably not supported */
	if(!path) {
            /* No path specified, so grab defaults from /chosen */
            push_str("bootpath");
	    push_str("/chosen");
            fword("(find-dev)");
            POP();
            fword("get-package-property");
            POP();
	    /* Update our local copy of path as well as the one on the stack */
	    fword("2dup");
            path = pop_fstr_copy();
	}

        if (path) {
            param = strchr(path, ' ');
            if(param) {
                *param = '\0';
                param++;
            } else if (cmdline_size) {
                param = (char *)qemu_cmdline;
            } else {
                push_str("boot-args");
                push_str("/options");
                fword("(find-dev)");
                POP();
                fword("get-package-property");
                POP();
                param = pop_fstr_copy();
            }

            /* Invoke platform-specific Linux loader */
            linux_load(&sys_info, path, param);

            free(path);
        }
}
Ejemplo n.º 20
0
static void
ofmem_set_property( phandle_t ph, const char *name, const char *buf, int len )
{
    /* This is very similar to set_property() in libopenbios/bindings.c but allows
       us to set the property pointer directly, rather than having to copy it
       into the Forth dictonary every time we update the memory properties */
    if( !ph ) {
        printk("ofmem_set_property: NULL phandle\n");
        return;
    }
    PUSH(pointer2cell(buf));
    PUSH(len);
    push_str(name);
    PUSH_ph(ph);
    fword("encode-property");
}
Ejemplo n.º 21
0
void Dictionary::printall(){
	uint wit = 0;
	for(std::vector<Wordinfo>::iterator _wit = fwa.begin(); _wit < fwa.end(); _wit ++){
		for(std::map<uint,uint>::iterator pit = fwa[wit].pairs.begin(); pit != fwa[wit].pairs.end(); pit++){
			Word fword(french,wit);
			Word eword(english,(*pit).first);
			std::cout << fwa[fword].relFreq(eword);
			std::cout << " " << ewa[eword].relFreq(fword);
			//std::cout << "@" << fwa[fword].pairs[(*pit).first] << "/" << fwa[fword].singlecount;
			//std::cout << "@" << ewa[eword].pairs[(*pit).first] << "/" << ewa[eword].singlecount;
			std::cout << " # " << flex.getString(fword) << " # ";
			std::cout << elex.getString(eword) << "\n";
		}
		wit++;
	}
}
Ejemplo n.º 22
0
void
arch_of_init( void )
{
#if USE_RTAS
	phandle_t ph;
#endif
	int autoboot;

	devtree_init();
	node_methods_init();
	modules_init();
        setup_timers();
#ifdef CONFIG_DRIVER_PCI
	ob_pci_init();
#endif

#if USE_RTAS
	if( !(ph=find_dev("/rtas")) )
		printk("Warning: No /rtas node\n");
	else {
		ulong size = 0x1000;
		while( size < (ulong)of_rtas_end - (ulong)of_rtas_start )
			size *= 2;
		set_property( ph, "rtas-size", (char*)&size, sizeof(size) );
	}
#endif

#if 0
	/* tweak boot settings */
	autoboot = !!get_bool_res("autoboot");
#endif
	autoboot = 0;
	if( !autoboot )
		printk("Autobooting disabled - dropping into OpenFirmware\n");
	setenv("auto-boot?", autoboot ? "true" : "false" );
	setenv("boot-command", "briqboot");

#if 0
	if( get_bool_res("tty-interface") == 1 )
#endif
		fword("activate-tty-interface");

	/* hack */
	device_end();
	bind_func("briqboot", boot );
}
Ejemplo n.º 23
0
int forth_load(const char *filename)
{
    char magic[2];
    unsigned long forthsize;
    int retval = -1;

    if (!file_open(filename))
	goto out;

    if (lfile_read(magic, 2) != 2) {
	debug("Can't read magic header\n");
	retval = LOADER_NOT_SUPPORT;
	goto out;
    }

    if (magic[0] != '\\' || magic[1] != ' ') {
	debug("No forth source image\n");
	retval = LOADER_NOT_SUPPORT;
	goto out;
    }

    forthsize = file_size();

    forthtext = malloc(forthsize+1);
    file_seek(0);

    printk("Loading forth source ...");
    if ((unsigned long)lfile_read(forthtext, forthsize) != forthsize) {
	printk("Can't read forth text\n");
	goto out;
    }
    forthtext[forthsize]=0;
    printk("ok\n");

    PUSH ( (ucell)forthtext );
    PUSH ( (ucell)forthsize );
    fword("eval2");
    retval=0;

out:
    //if (forthtext)
    //	free(forthtext);
    return retval;
}
Ejemplo n.º 24
0
Archivo: boot.c Proyecto: 3a9LL/panda
void
boot( void )
{
	char *path;
	void *entry;

        /* Copy the incoming path */
        fword("2dup");
        path = pop_fstr_copy();

	if(!path) {
		printk("[unix] Booting default not supported.\n");
		return;
	}
	printk("[unix] Booting '%s'\n",path);
	entry=load_elf(path);
	if(entry)
                printk("successfully loaded client at %llx.\n", (unsigned long long)(ucell)entry);
	else
		printk("failed.\n");
}
Ejemplo n.º 25
0
void 
aout_init_program(void)
{
    ucell start, size;
    
    // Relocate a.out text down from load-base to load-base - header. This
    // is similar to what OBP does and is needed for NextStep.
    fword("load-base");
    start = POP();
    feval("load-state >ls.file-size @");
    size = POP();
    
    memmove((char *)start - sizeof(struct exec), (char *)start, size);
    
    PUSH(start);
    feval("load-state >ls.entry !");
    
    arch_init_program();
    
    feval("-1 state-valid !");
}
Ejemplo n.º 26
0
Archivo: init.c Proyecto: 3a9LL/panda
void
arch_of_init( void )
{
	mol_phandle_t ph;
	int autoboot;

	devtree_init();
	node_methods_init();
	nvram_init("/pci/mac-io/nvram");
	openbios_init();
	modules_init();
	pseudodisk_init();
	osiblk_init();
	osiscsi_init();
	init_video();

	if( (ph=prom_find_device("/rtas")) == -1 )
		printk("Warning: No /rtas node\n");
	else {
		unsigned long size = 0x1000;
		while( size < (unsigned long)of_rtas_end - (unsigned long)of_rtas_start )
			size *= 2;
		prom_set_prop( ph, "rtas-size", (char*)&size, sizeof(size) );
	}

	/* tweak boot settings */
	autoboot = !!get_bool_res("autoboot");
	if( !autoboot )
		printk("Autobooting disabled - dropping into OpenFirmware\n");
	setenv("auto-boot?", autoboot ? "true" : "false" );
	setenv("boot-command", "molboot");

	if( get_bool_res("tty-interface") == 1 )
		fword("activate-tty-interface");

	/* hack */
	device_end();
	bind_func("molboot", boot );
}
Ejemplo n.º 27
0
/*
 * v_wordw -- [count]w
 *	Move forward a word at a time.
 *
 * PUBLIC: int v_wordw __P((SCR *, VICMD *));
 */
int
v_wordw(SCR *sp, VICMD *vp)
{
	return (fword(sp, vp, LITTLEWORD));
}
Ejemplo n.º 28
0
/*
 * v_wordW -- [count]W
 *	Move forward a bigword at a time.
 *
 * PUBLIC: int v_wordW __P((SCR *, VICMD *));
 */
int
v_wordW(SCR *sp, VICMD *vp)
{
	return (fword(sp, vp, BIGWORD));
}
Ejemplo n.º 29
0
/* ( open -- flag ) */
static void
macparts_open( macparts_info_t *di )
{
	char *str = my_args_copy();
	char *parstr = NULL, *argstr = NULL;
	char *tmpstr;
	int bs, parnum=-1, apple_parnum=-1;
	int parlist[2], parlist_size = 0;
	desc_map_t dmap;
	part_entry_t par;
	int ret = 0, i = 0, j = 0;
	int want_bootcode = 0;
	phandle_t ph;
	ducell offs = 0, size = -1;

	DPRINTF("macparts_open '%s'\n", str );

	/* 
		Arguments that we accept:
		id: [0-7]
		[(id)][,][filespec]
	*/
	
	if ( str && strlen(str) ) {
		/* Detect the arguments */
		if ((*str >= '0' && *str <= '9') || (*str == ',')) {
		    push_str(str);
		    PUSH(',');
		    fword("left-parse-string");
		    parstr = pop_fstr_copy();
		    argstr = pop_fstr_copy();
		} else {
		    argstr = str;
		}

		/* Make sure argstr is not null */
		if (argstr == NULL)
		    argstr = strdup("");	
		
		/* Convert the id to a partition number */
		if (parstr && strlen(parstr))
		    parnum = atol(parstr);

		/* Detect if we are looking for the bootcode */
		if (strcmp(argstr, "%BOOT") == 0) {
		    want_bootcode = 1;
		}
	}

	DPRINTF("parstr: %s  argstr: %s  parnum: %d\n", parstr, argstr, parnum);

	DPRINTF("want_bootcode %d\n", want_bootcode);
	DPRINTF("macparts_open %d\n", parnum);

	di->filesystem_ph = 0;
	di->read_xt = find_parent_method("read");
	di->seek_xt = find_parent_method("seek");

	SEEK( 0 );
	if( READ(&dmap, sizeof(dmap)) != sizeof(dmap) )
		goto out;

	/* partition maps might support multiple block sizes; in this case,
	 * pmPyPartStart is typically given in terms of 512 byte blocks.
	 */
	bs = __be16_to_cpu(dmap.sbBlockSize);
	if( bs != 512 ) {
		SEEK( 512 );
		READ( &par, sizeof(par) );
		if( __be16_to_cpu(par.pmSig) == DESC_PART_SIGNATURE )
			bs = 512;
	}
	SEEK( bs );
	if( READ(&par, sizeof(par)) != sizeof(par) )
		goto out;
        if (__be16_to_cpu(par.pmSig) != DESC_PART_SIGNATURE)
		goto out;

	/*
	 * Implement partition selection as per the PowerPC Microprocessor CHRP bindings
	 */

	if (argstr == NULL || parnum == 0) {
		/* According to the spec, partition 0 as well as no arguments means the whole disk */
		offs = (long long)0;
		size = (long long)__be32_to_cpu(dmap.sbBlkCount) * bs;

		di->blocksize = (unsigned int)bs;

		di->offs_hi = offs >> BITS;
		di->offs_lo = offs & (ucell) -1;
	
		di->size_hi = size >> BITS;
		di->size_lo = size & (ucell) -1;

		ret = -1;
		goto out;

	} else if (parnum == -1) {
int main (int argc, char* argv[]) {

  BogglePlayer * p = new BogglePlayer();
  //test getAllValid

   set<string> lex;
   string line;
  std::ifstream fword("boglex.txt",ios::binary);
  while(fword.good()){
    std::getline(fword,line);
    lex.insert(line);
  }
  fword.close();
   p->buildLexicon(lex);

//   std::ifstream f("brd.txt",ios::binary);
//   // int row=0;
//   // int col=0;
//   std::getline(f,line);
//   //row=std::stoi(line);
//   std::getline(f,line);
//   //col=std::stoi(line);

// string brd[20][23];
//   for(int i=0;i<20;i++){
//     for(int j=0;j<23;j++){
//       std::getline(f,line);
//       brd[i][j]=line;
//     }
//   }
//   f.close();
//   string* bd[20];
//   for(int i=0;i<20;i++){
//     bd[i]=brd[i];
//   }
//   p->setBoard(20,23,bd);
//   for(int i=0;i<20;i++){
//     for(int j=0;j<23;j++){
//       cout << p->board[i*23+j].letter<<" ";
//     }
//     cout<<endl;
//   }
//   std::vector<int> v;
//   v= p->isOnBoard("acidified");
//   for(int i=0;i<v.size();i++){
//     cout<<v[i]<<endl;
//   }
  //cout << "size " << p->isOnBoard("acidified").size() <<endl;
  // string wordA("a");
  // string wordX("x");
  // lex.insert(wordA);
  // lex.insert("aba");
  string row0[] = {"w"};
  string row1[] = {"e"};
  string row2[] = {"r"};
  string row3[] = {"e"};
  string* board[] = {row0,row1,row2,row3};
  set<string> words;
  // vector<int> locations;

  //p->buildLexicon(lex);
  //cout << "build" << endl;

  p->setBoard(4,1,board);
  // // for(int i=0;i<4;i++){
  // //   cout << p->board[i].letter << endl;
  // // }

  // if(p->isOnBoard("aba").size() == 3){
  //   cout << "found" << endl;
  // }

  // if(p->isInLexicon(wordX)) {
  //   std::cerr << "Apparent problem with isInLexicon #1." << std::endl;
  //   return -1;
  // }
  // if(!p->isInLexicon(wordA)) {
  //   std::cerr << "Apparent problem with isInLexicon #2." << std::endl;
  //   return -1;
  // }

  // if(p->isOnBoard(wordA).size() != 1) {
  //   std::cerr << "Apparent problem with isOnBoard #1." << std::endl;
  //   return -1;
  // }

  // locations.clear();
  // locations = p->isOnBoard(wordA);
  // if(locations.size() != 1 || locations[0] != 3) {
  //   std::cerr << "Apparent problem with isOnBoard #2." << std::endl;
  //   return -1;
  // }
  
  
  // if(!p->getAllValidWords(0,&words)) {
  //   std::cerr << "Apparent problem with getAllValidWords #1." << std::endl;
  //   return -1;
  // }
  // if(words.size() != 1 || words.count(wordA) != 1) {
  //   std::cerr << "Apparent problem with getAllValidWords #2." << std::endl;
  //   return -1;
  // }
  //set<string> words;
  p->getAllValidWords(0,&words);
  int j=0;
  for (std::set<string>::iterator it = words.begin() ; it != words.end(); ++it){
             j++;
             cout<<j<< " valid words "<<*it<<endl;
           }
  cout<<"total number"<<words.size()<<endl;

  delete p;
  return 0;

}