/* ( -- 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 ); }
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 ); }
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"); }
/* ( -- success? ) */ static void dlabel_open( dlabel_info_t *di ) { char *path; char block0[512]; phandle_t ph; int success=0; cell status; path = my_args_copy(); DPRINTF("dlabel-open '%s'\n", path ); di->part_ih = 0; /* Find parent methods */ di->filesystem_ph = 0; di->parent_seek_xt = find_parent_method("seek"); di->parent_tell_xt = find_parent_method("tell"); di->parent_read_xt = find_parent_method("read"); /* If arguments have been passed, determine the partition/filesystem type */ if (path && strlen(path)) { /* Read first block from parent device */ DPUSH(0); call_package(di->parent_seek_xt, my_parent()); POP(); PUSH(pointer2cell(block0)); PUSH(sizeof(block0)); call_package(di->parent_read_xt, my_parent()); status = POP(); if (status != sizeof(block0)) goto out; /* Find partition handler */ PUSH( pointer2cell(block0) ); selfword("find-part-handler"); ph = POP_ph(); if( ph ) { /* We found a suitable partition handler, so interpose it */ DPRINTF("Partition found on disk - scheduling interpose with ph " FMT_ucellx "\n", ph); push_str(path); PUSH_ph(ph); fword("interpose"); success = 1; } else { /* unknown (or missing) partition map, * try the whole disk */ DPRINTF("Unknown or missing partition map; trying whole disk\n"); /* Probe for filesystem from start of device */ DPUSH ( 0 ); PUSH_ih( my_self() ); selfword("find-filesystem"); ph = POP_ph(); if( ph ) { /* If we have been asked to open a particular file, interpose the filesystem package with the passed filename as an argument */ di->filesystem_ph = ph; DPRINTF("Located filesystem with ph " FMT_ucellx "\n", ph); DPRINTF("path: %s length: %d\n", path, strlen(path)); if (path && strlen(path)) { DPRINTF("INTERPOSE!\n"); push_str( path ); PUSH_ph( ph ); fword("interpose"); } } else if (path && strcmp(path, "%BOOT") != 0) { goto out; } success = 1; } } else { /* No arguments were passed, so we just use the parent raw device directly */ success = 1; } out: if( path ) free( path ); if( !success ) { dlabel_close( di ); RET(0); } PUSH(-1); }