예제 #1
0
파일: mod.c 프로젝트: ErisBlastar/osfree
/* Get's a name (pascal string) from Import Module Table at index in mod_idx.*/
char * get_imp_mod_name(struct LX_module * lx_mod, int mod_idx)
{
  char * mod_name, *p;
  long i;

  int offs_mod_table = lx_mod->lx_head_e32_exe->e32_impmod -
                     lx_mod->lx_head_e32_exe->e32_fpagetab;

  mod_name=(&lx_mod->fixup_section[offs_mod_table]);

  io_log("mex3: mod_idx=%u, mod_name=", mod_idx);

  for (p = mod_name; *p; p++)
  {
    if (*p < 9)
      io_log("%c", *p + 0x30);
    else
      io_log("%c", *p);
  }

  io_log("\n");

  for (i=0;
       i!=(mod_idx-1);
       i++)
  {
    mod_name=mod_name+(char)*mod_name+1;
  }

  return mod_name;
}
예제 #2
0
파일: mod.c 프로젝트: ErisBlastar/osfree
        /* Get the ordinal for the entry_name from the Non-resident Names Table.
           If the table is not loaded, it is loaded and a pointer is saved in LX_module.
        */
int get_non_res_name_tbl_entry(struct LX_module * lx_mod, char *entry_name) {

        io_log("Non-resident Names Table size: %d, 0x%x \n",
                                lx_mod->lx_head_e32_exe->e32_cbnrestab,
                                lx_mod->lx_head_e32_exe->e32_cbnrestab );
        io_log("Non-resident Names Table offset: %d, 0x%x \n",
                                lx_mod->lx_head_e32_exe->e32_nrestab,
                                lx_mod->lx_head_e32_exe->e32_nrestab );
        return 0;
}
예제 #3
0
파일: mod.c 프로젝트: ErisBlastar/osfree
        /*
        Reads the lx file from filehandle fh into structure lx_mod.
        Constructor for disk based file.
        */
struct LX_module *
load_lx(FILE* fh, struct LX_module * lx_mod)
{
        int fstorlek;

        lx_mod->lx_head_e32_exe = 0;
        lx_mod->offs_lx_head = 0;
        lx_mod->lx_file_stream = 0; /* Zero out the memory buffer, which is not used here. */
        lx_mod->fh = fh;
        lx_mod->lx_fseek = &lx_fseek_disk_file;
        lx_mod->lx_fread = &lx_fread_disk_file;
        //io_log("Load from filehandle: %p \n", fh);

        /* Find out size of file. */
        fstorlek = fseek(fh, 0, SEEK_END);
        fstorlek = fstorlek;
        fseek(fh, 0, SEEK_SET);


        if(LXLoadHeader(lx_mod)) {
                //io_log("Succeeded to load LX header.\n");
                LXLoadLoaderSection(lx_mod);
                LXLoadFixupSection(lx_mod);
        }
        else {
                io_log("Could not load LX header!!!!\n");
                return 0;
        }

        return lx_mod;
}
예제 #4
0
파일: mod.c 프로젝트: ErisBlastar/osfree
void print_o32_obj_info(struct o32_obj o_obj, char * name)
{
  io_log("%s: virtual memory size              = %08XH\n", name, O32_SIZE(o_obj));
  io_log("          relocation base address          = %08XH\n", O32_BASE(o_obj));
  io_log("          object flag bits                 = %08XH\n", O32_FLAGS(o_obj));
  io_log("          object page table index          = %08XH\n", O32_PAGEMAP(o_obj));
  io_log("          # of object page table entries   = %08XH\n", O32_MAPSIZE(o_obj));
  io_log("          reserved                         = %08XH\n", O32_RESERVED(o_obj));
  io_log("          flags = READABLE|EXECUTABLE|16:16_ALIAS\n");
  io_log("\n");
}
예제 #5
0
파일: mod.c 프로젝트: ErisBlastar/osfree
struct o32_obj *
get_code(struct LX_module * lx_mod) {
        if(lx_mod->lx_head_e32_exe->e32_startobj == 0) {
                if (options.debugixfmgr) 
                {
                  io_log("Invalid start object for code ==0\n");
                }
                return (struct o32_obj *)0;
        }
        return get_obj(lx_mod, lx_mod->lx_head_e32_exe->e32_startobj);
}
예제 #6
0
void exec_protshell(cfg_opts *options)
{
    int  rc;

    rc = PrcExecuteModule(NULL,
                          0,
                          EXEC_SYNC,
                          NULL,                 // pArgs
                          NULL,                 // pEnv
                          NULL,
                          options->protshell,
                          0);

    if (rc != NO_ERROR)
        io_log("Error execute: %d ('%s')\n", rc, options->protshell);

    // Clean up config data
    rc = CfgCleanup();
    if (rc != NO_ERROR)
        io_log("CONFIG.SYS parser cleanup error.\n");
}
예제 #7
0
파일: memmgr.c 프로젝트: ErisBlastar/osfree
void  print_used_mem(struct t_mem_area *root_area) {


        unsigned long int start_pos = 0;
        struct t_mem_area *el = root_area;
        unsigned int i_start = (unsigned int) start_pos;
        unsigned int el_start = (unsigned int) el->start;
        io_log("--- Used Mem in Memmgr ---\n");
        while(el || el->next) {

                i_start = start_pos;
                el_start = (unsigned int) el->start;

                io_log("Allocated: %p - 0x%lx \n", el->start, (unsigned long int)el->size+el_start);
                if(!el->next)
                        break;
                if(el->next)
                        el = (struct t_mem_area*)el->next;
        }
        io_log("---    End Mem dump    ---\n");
} 
예제 #8
0
파일: mod.c 프로젝트: ErisBlastar/osfree
        /* Get the ordinal for the entry_name from the Resident Names Table. */
int get_res_name_tbl_entry(struct LX_module * lx_mod, char *entry_name)
{
        int c_len;
        char buf_name[255];
        char *ptr_buf_name = (char *)&buf_name;
        int entry_lenghts = 0;
        int ordinal = 0;

        int offs_res_name_table = lx_mod->lx_head_e32_exe->e32_restab -
                                                                lx_mod->lx_head_e32_exe->e32_objtab;
        int size_res_name_table = lx_mod->lx_head_e32_exe->e32_enttab -
                                                                lx_mod->lx_head_e32_exe->e32_restab;

        io_log("Resident Names Table size: %d, 0x%x \n",
                                lx_mod->lx_head_e32_exe->e32_enttab - lx_mod->lx_head_e32_exe->e32_restab,
                                lx_mod->lx_head_e32_exe->e32_enttab - lx_mod->lx_head_e32_exe->e32_restab );
        io_log("Resident Names Table offset: %d, 0x%x \n",
                                lx_mod->lx_head_e32_exe->e32_restab,
                                lx_mod->lx_head_e32_exe->e32_restab );
        c_len = lx_mod->loader_section[offs_res_name_table];


        while(entry_lenghts < (size_res_name_table-1)) {
                c_len = lx_mod->loader_section[offs_res_name_table + entry_lenghts];
                copy_pas_str(ptr_buf_name,
                                        (char *)&lx_mod->loader_section[offs_res_name_table + entry_lenghts]);
                io_log(" Found: %s \n", ptr_buf_name);

                ordinal = *((unsigned short int*)&lx_mod->loader_section[
                                                        offs_res_name_table + c_len+1+entry_lenghts]);
                io_log(" Found (ord): %d \n", ordinal);
                if(strcmp(entry_name,ptr_buf_name)==0)
                        return ordinal;

                entry_lenghts += c_len+1+2;
                io_log("entry_lenghts: %d \n", entry_lenghts);
        }
        return 0; /* The ordinal is not found. */
}
예제 #9
0
파일: mod.c 프로젝트: ErisBlastar/osfree
struct o32_obj *
get_data_stack(struct LX_module * lx_mod) {
        if((lx_mod->lx_head_e32_exe->e32_stackobj == 0) ||
                (lx_mod->lx_head_e32_exe->e32_stackobj > get_obj_num(lx_mod))) {
                if (options.debugixfmgr) 
                {
                  io_log("Invalid data/stack object ==%lu, max=%lu\n",
                                  lx_mod->lx_head_e32_exe->e32_stackobj,
                                  get_obj_num(lx_mod));
                }
                return (struct o32_obj *)0;
        }
        return get_obj(lx_mod, lx_mod->lx_head_e32_exe->e32_stackobj);
}
예제 #10
0
파일: io.c 프로젝트: VMinute/qpid-proton
static void ensure_unique(pn_io_t *io, pn_socket_t new_socket)
{
  // A brand new socket can have the same HANDLE value as a previous
  // one after a socketclose.  If the application closes one itself
  // (i.e. not using pn_close), we don't find out about it until here.
  iocpdesc_t *iocpd = pni_iocpdesc_map_get(io->iocp, new_socket);
  if (iocpd) {
    if (io->trace)
      io_log("Stale external socket reference discarded\n");
    // Re-use means former socket instance was closed
    assert(iocpd->ops_in_progress == 0);
    assert(iocpd->external);
    // Clean up the straggler as best we can
    pn_socket_t sock = iocpd->socket;
    iocpd->socket = INVALID_SOCKET;
    pni_iocpdesc_map_del(io->iocp, sock);  // may free the iocpdesc_t depending on refcount
  }
}
예제 #11
0
파일: misc.c 프로젝트: ErisBlastar/osfree
void setdrivemap(ULONG *map)
{
  struct I_Fs_srv *fsrv;
  int  i, diskno;
  char *drive;
  char drv;

  *map = 0;

  for (i = 0; i < fsrouter.srv_num_; i++)
  {
    fsrv = fsrouter.fs_srv_arr_[i];
    drive = fsrv->drive;
    drv = tolower(*(drive));
    diskno = drv - 'a';
    *map |= (1 << diskno);    
  }

  io_log("map=%lu", *map);
}
예제 #12
0
파일: memmgr.c 프로젝트: ErisBlastar/osfree
/* dealloc_mem_area - Avallokerar minnesområdet pekaren pekar på. */
int   dealloc_mem_area(struct t_mem_area *root_area, void * p_start) {
        io_log("FIXME: memmgr.c:dealloc_mem_area()\n");
        return 0;
}
예제 #13
0
static int dev_do_io (struct devstruct *dev, uaecptr request)
{
    uae_u32 command;
    uae_u32 io_data = get_long (request + 40); // 0x28
    uae_u32 io_length = get_long (request + 36); // 0x24
    uae_u32 io_actual = get_long (request + 32); // 0x20
    uae_u32 io_offset = get_long (request + 44); // 0x2c
    uae_u32 io_error = 0;
    int async = 0;
    struct device_info di;
    struct priv_devstruct *pdev = getpdevstruct (request);

    if (!pdev)
	return 0;
    command = get_word (request+28);

    switch (command)
    {
	case CMD_READ:
	io_error = command_read (pdev->mode, dev, io_data, io_offset, io_length, &io_actual);
	break;
	case CMD_WRITE:
	case CMD_FORMAT:
	io_error = 28; /* writeprotect */
	break;
	case CMD_UPDATE:
	case CMD_CLEAR:
	case CMD_FLUSH:
	case CMD_MOTOR:
	case CMD_SEEK:
	io_actual = 0;
	break;
	case CMD_REMOVE:
	io_actual = 0;
	break;
	case CMD_CHANGENUM:
	io_actual = dev->changenum;
	break;
	case CMD_CHANGESTATE:
	io_actual = devinfo(pdev->mode, dev->unitnum, &di)->media_inserted ? 0 : 1;
	break;
	case CMD_PROTSTATUS:
	io_actual = devinfo(pdev->mode, dev->unitnum, &di)->write_protected ? -1 : 0;
	break;
	case CMD_GETDRIVETYPE:
	io_actual = dev->drivetype;
	break;
	case CMD_GETNUMTRACKS:
	io_actual = dev->di.cylinders;
	break;
	case CMD_ADDCHANGEINT:
	io_error = add_async_request (dev, request, ASYNC_REQUEST_CHANGEINT, io_data);
	if (!io_error)
	    async = 1;
	break;
	case CMD_REMCHANGEINT:
	release_async_request (dev, request);
	break;
	case 28: /* HD_SCSICMD */
	if (dev->allow_scsi && pdev->scsi) {
	    uae_u32 sdd = get_long (request + 40);
	    io_error = sys_command_scsi_direct (dev->unitnum, sdd);
	    if (log_scsi)
		write_log ("scsidev: did io: sdd %p request %p error %d\n", sdd, request, get_byte (request + 31));
	}
	break;
	default:
	io_error = -3;
	break;
    }
    put_long (request + 32, io_actual);
    put_byte (request + 31, io_error);
    io_log ("dev_io",request);
    return async;
}
예제 #14
0
파일: mod.c 프로젝트: ErisBlastar/osfree
void * get_entry(struct LX_module * lx_mod, int entry_ord_to_search,
                                        int * ret_flags,
                                        int * ret_offset,
                                        int * ret_obj,
                                        int * ret_modord,
                                        int * ret_type) {

        enum
        {
          UNUSED_ENTRY_SIZE = 2,
          _16BIT_ENTRY_SIZE = 3,
          ENTRY_HEADER_SIZE = 4, /* For all entries except UNUSED ENTRY.*/
          _286_CALL_GATE_ENTRY_SIZE = 5,
          _32BIT_ENTRY_SIZE         = 5,
          FORWARD_ENTRY_SIZE        = 7
	};
        /* For testing: lx_mod is null and ret_type contains a pointer to some entry table.*/
        int offs_to_entry_tbl;
        struct b32_bundle *entry_table,
                          *prev_entry_table = 0;
        char *cptr_ent_tbl;
        struct e32_entry *entry_post;
        unsigned char * magic;
        char bbuf[3];
        int entry_ord_index;
        int prev_ord_index = 0;
        int unused_entry;
        unsigned long int i_cptr_ent_tbl;
        int elements_in_bundle;

        if(lx_mod != 0) {

                /* Offset to Entry Table inside the Loader Section. */
                offs_to_entry_tbl = lx_mod->lx_head_e32_exe->e32_enttab - lx_mod->lx_head_e32_exe->e32_objtab;

                entry_table = (struct b32_bundle *) &lx_mod->loader_section[offs_to_entry_tbl];
                cptr_ent_tbl = &lx_mod->loader_section[offs_to_entry_tbl];

                magic = get_magic(lx_mod);
                if((magic[0] != 'L') && (magic[1] != 'X')) { /* Invalid module */
                        *ret_type = -1;
                        return (void *)0;
                }

                bbuf[0] = magic[0];
                bbuf[1] = magic[1];
                bbuf[2] = 0;
                /*io_log("magic: %s \n", (char *)&bbuf);
                  io_log("get_entry( lx_mod: %p, entry_ord_to_search: %d \n",
                              lx_mod, entry_ord_to_search); */
        }
        else {
                //io_log("Testing get_entry.\n");
                cptr_ent_tbl = (char*) *ret_type;
                entry_table = (struct b32_bundle *)cptr_ent_tbl;
        }

        entry_ord_index=1;

        /*io_log("entry_table: %p \n", entry_table);*/

      /*io_log(
          "get_entry: entry_ord_to_search: %d, b32_cnt: %d, b32_type: %d, b32_obj: %d\n",
                          entry_ord_to_search,
                         entry_table->b32_cnt, entry_table->b32_type, entry_table->b32_obj);
         */

        /*io_log("EMPTY: %d, ENTRYFWD: %d, _32BIT_ENTRY_SIZE: %d \n",
          EMPTY, ENTRYFWD, _32BIT_ENTRY_SIZE);*/

        unused_entry = 0;
        while(entry_ord_index <= entry_ord_to_search) {
                while (entry_table->b32_type == EMPTY) { /* Unused Entry, just skip over them.*/
                        prev_ord_index = entry_ord_index;
                        entry_ord_index += entry_table->b32_cnt;
                        unused_entry += UNUSED_ENTRY_SIZE;
                        cptr_ent_tbl += UNUSED_ENTRY_SIZE;
                        entry_table = (struct b32_bundle *)cptr_ent_tbl;
                        prev_entry_table = entry_table;
                        io_log("EMPTY, entry_table: %p\n", entry_table);
                }
                io_log("entry_ord_index: %d (0x%x), entry_ord_to_search: %d (0x%x)\n",
                  entry_ord_index,entry_ord_index,
                  entry_ord_to_search,entry_ord_to_search);
                if(entry_ord_to_search < entry_ord_index) {
                        if (prev_ord_index <= entry_ord_to_search)
                        {
                                entry_ord_index = prev_ord_index;
                                entry_table = prev_entry_table;
                                goto sw;
                        }
                        *ret_flags = 0; // Unused entry ==0
                        *ret_offset = 0;
                        *ret_obj = 0;
                        *ret_type = 0;
                        io_log("RET, Can't find entry.\n");
                        io_log("entry_ord_index: %d, entry_ord_to_search: %d\n", entry_ord_index, entry_ord_to_search);
                        return (void *) 0; // Can't find entry.
                }
                if(entry_table->b32_cnt == 0) {
                       //io_log("End of entry table reached! %d, entry_table: %p\n",
                       //                  entry_table->b32_cnt, entry_table);
                                *ret_flags = 0;
                                *ret_offset = 0;
                                *ret_obj = 0;
                                *ret_type = 0;
                                return (void *) 0; /* Invalid entry.*/
                }
        sw:
                switch(entry_table->b32_type) {
                    case EMPTY:;
                    case ENTRYFWD:;
                    case ENTRY32: break;
                        default: io_log("Invalid entry type! %d, entry_table: %p\n",
                                         entry_table->b32_type, entry_table);
                                *ret_flags = 0;
                                *ret_offset = 0;
                                *ret_obj = 0;
                                *ret_type = 0;
                                return (void *) 0; /* Invalid entry.*/
                }


                /*io_log("get_entry,2nd bundle: cnt: %d, type: %d, obj: %d\n",
                                entry_table->b32_cnt, entry_table->b32_type, entry_table->b32_obj);     */
                /* If ordinal to search for is less than present index ordinal and
                   ordinal to search for is less than the number of ordinals plus current index ordinal and
                   the type of bundle is 32-bit entry.
                */
//                if((entry_ord_to_search >= entry_ord_index)
//                   && (entry_ord_to_search<(entry_table->b32_cnt+entry_ord_index))
//                   &&  (entry_table->b32_type == ENTRY32))
                if((entry_ord_to_search <= entry_ord_index)
                   && (entry_ord_index - entry_ord_to_search <= entry_table->b32_cnt)
                   &&  (entry_table->b32_type == ENTRY32))
                { /* 32-bit Entry.*/

                                //io_log("32-bit Entry.\n");
                                cptr_ent_tbl = (char*)entry_table;
                                cptr_ent_tbl += ENTRY_HEADER_SIZE;
                                entry_post = (struct e32_entry *)cptr_ent_tbl;
                                i_cptr_ent_tbl = (unsigned long)cptr_ent_tbl;
                                elements_in_bundle = entry_table->b32_cnt + entry_ord_index;
                                for (entry_ord_index; entry_ord_index < elements_in_bundle; entry_ord_index++) 
				{
                                    io_log("(entry_ord_to_search %d == entry_ord_index %d)\n",
                                              entry_ord_to_search, entry_ord_index);
                                    if (entry_ord_to_search == entry_ord_index)
                                                break;
                                    i_cptr_ent_tbl += _32BIT_ENTRY_SIZE;
                                }
                                /*entry_ord_index += entry_table->b32_cnt;
                                i_cptr_ent_tbl += _32BIT_ENTRY_SIZE*entry_table->b32_cnt;*/

                                cptr_ent_tbl = (char*)i_cptr_ent_tbl;
                                entry_post = (struct e32_entry *)cptr_ent_tbl;
                                //io_log("cptr_ent_tbl: %p \n", cptr_ent_tbl);

                                //io_log("entry_post: %p \n", entry_post);
                                //io_log("32-bit Entry: Flags=0x%x, Offset=%lu \n",
                                //                entry_post->e32_flags, entry_post->e32_variant.e32_offset.offset32);
                                *ret_flags = entry_post->e32_flags;
                                *ret_offset = entry_post->e32_variant.e32_offset.offset32;
                                *ret_obj = entry_table->b32_obj;
                                *ret_type = entry_table->b32_type;
                                return (void *) entry_table;

                } else if (entry_table->b32_type == ENTRY32) { /* Jump over that bundle. */
                        //io_log("ENTRY32\n")
                        cptr_ent_tbl = (char*)entry_table;
                        cptr_ent_tbl += ENTRY_HEADER_SIZE;
                        //prev_ord_index = entry_ord_index;
                        //prev_entry_table = entry_table;
                        i_cptr_ent_tbl = (unsigned long)cptr_ent_tbl;
                        entry_ord_index += entry_table->b32_cnt;
                        i_cptr_ent_tbl += _32BIT_ENTRY_SIZE*entry_table->b32_cnt;

                        cptr_ent_tbl = (char*)i_cptr_ent_tbl;
                        entry_table= (struct b32_bundle *)cptr_ent_tbl;
                        io_log("ENTRY32, entry_table: %p\n", entry_table);
                }

                if((entry_ord_to_search >= entry_ord_index)
                    && (entry_ord_to_search<(entry_table->b32_cnt+entry_ord_index))
                    && (entry_table->b32_type == ENTRYFWD)) { /* Forward Entry.*/
                        //io_log("Forward Entry.\n");
                        cptr_ent_tbl = (char*)entry_table;
                        //io_log("cptr_ent_tbl: %p \n", cptr_ent_tbl);
                        entry_post = (struct e32_entry *)&cptr_ent_tbl[ENTRY_HEADER_SIZE];
                        cptr_ent_tbl = &cptr_ent_tbl[ENTRY_HEADER_SIZE];
                        //io_log("cptr_ent_tbl: %p \n", cptr_ent_tbl);
                                i_cptr_ent_tbl = (unsigned long int)cptr_ent_tbl;
                                elements_in_bundle = entry_table->b32_cnt + entry_ord_index;
                                for (entry_ord_index; entry_ord_index < elements_in_bundle; entry_ord_index++) 
				{
                                    io_log("(entry_ord_to_search %d == entry_ord_index %d)\n",
                                                        entry_ord_to_search, entry_ord_index);
                                    if (entry_ord_to_search == entry_ord_index)
                                           break;
                                    i_cptr_ent_tbl += FORWARD_ENTRY_SIZE;
                                }
                                cptr_ent_tbl = (char*)i_cptr_ent_tbl;
                                entry_post = (struct e32_entry *)cptr_ent_tbl;
                        io_log("entry_post: %p \n", entry_post);
                        io_log("Forward Entry: Flags=0x%x, Proc name offset or ordinal=%lu, Module ordinal number: %d \n",
                                        entry_post->e32_flags,
                                        entry_post->e32_variant.e32_fwd.value,
                                        entry_post->e32_variant.e32_fwd.modord);
                                 /* Flags */
                        *ret_flags = entry_post->e32_flags;
                         /* Procedure Name Offset or Import Ordinal Number */
                        *ret_offset = entry_post->e32_variant.e32_fwd.value;
                                /* Module ordinal */
                        *ret_modord = entry_post->e32_variant.e32_fwd.modord;
                                /* Not used */
                        *ret_obj = entry_table->b32_obj;
                                /* Entry type*/
                        *ret_type = entry_table->b32_type;
                         /* unsigned short  modord;     / Module ordinal number
                unsigned long   value;      / Proc name offset or ordinal

                                e32_fwd;        / Forwarder */
                        return (void *) entry_table;
                } else if(entry_table->b32_type == ENTRYFWD) { /* Jump over the that bundle. */
                    //io_log("ENTRYFWD\n");

                        cptr_ent_tbl = (char*)entry_table;
                        //io_log("cptr_ent_tbl: %p\n", cptr_ent_tbl);
                        cptr_ent_tbl = &cptr_ent_tbl[ENTRY_HEADER_SIZE];
                        //io_log("cptr_ent_tbl: %p\n", cptr_ent_tbl);
                        i_cptr_ent_tbl = (unsigned long int)cptr_ent_tbl;
                        entry_ord_index += entry_table->b32_cnt;
                        //io_log("FORWARD_ENTRY_SIZE: %d, entry_table->b32_cnt: %d\n", FORWARD_ENTRY_SIZE, entry_table->b32_cnt);
                        i_cptr_ent_tbl += FORWARD_ENTRY_SIZE*entry_table->b32_cnt;

                        cptr_ent_tbl = (char*)i_cptr_ent_tbl;
                        entry_table= (struct b32_bundle *)cptr_ent_tbl;
                        //io_log("ENTRYFWD, entry_table: %p\n", entry_table);
                }

        }
        //io_log("RET, get_entry()\n");
        return (void *) entry_table;
}
예제 #15
0
파일: uaeserial.c 프로젝트: Yamakuzure/PUAE
static int32_t dev_do_io (struct devstruct *dev, uaecptr request, int32_t quick)
{
	uint32_t command;
	uint32_t io_data = get_long (request + 40); // 0x28
	uint32_t io_length = get_long (request + 36); // 0x24
	uint32_t io_actual = get_long (request + 32); // 0x20
	uint32_t io_offset = get_long (request + 44); // 0x2c
	uint32_t io_error = 0;
	uint16_t io_status;
	int32_t async = 0;

	if (!dev)
		return 0;
	command = get_word (request + 28);
	io_log (_T("dev_io_START"),request);

	switch (command)
	{
	case SDCMD_QUERY:
		if (uaeser_query (dev->sysdata, &io_status, &io_actual))
			put_byte (request + io_Status, io_status);
		else
			io_error = IOERR_BADADDRESS;
		break;
	case SDCMD_SETPARAMS:
		io_error = setparams(dev, request);
		break;
	case CMD_WRITE:
		async = 1;
		break;
	case CMD_READ:
		async = 1;
		break;
	case SDCMD_BREAK:
		if (get_byte (request + io_SerFlags) & SERF_QUEUEDBRK) {
			async = 1;
		} else {
			uaeser_break (dev->sysdata,  get_long (request + io_BrkTime));
		}
		break;
	case CMD_CLEAR:
		uaeser_clearbuffers(dev->sysdata);
		break;
	case CMD_RESET:
		cmd_reset(dev, request);
		break;
	case CMD_FLUSH:
	case CMD_START:
	case CMD_STOP:
		break;
	case NSCMD_DEVICEQUERY:
		put_long (io_data + 0, 0);
		put_long (io_data + 4, 16); /* size */
		put_word (io_data + 8, NSDEVTYPE_SERIAL);
		put_word (io_data + 10, 0);
		put_long (io_data + 12, nscmd_cmd);
		io_actual = 16;
		break;
	default:
		io_error = IOERR_NOCMD;
		break;
	}
	put_long (request + 32, io_actual);
	put_byte (request + 31, io_error);
	io_log (_T("dev_io_END"),request);
	return async;
}
예제 #16
0
파일: path.c 프로젝트: ErisBlastar/osfree
unsigned int find_module_path(const char * name, char * full_path_name)
{
  CORBA_Environment env = dice_default_environment;
  l4dm_dataspace_t ds;
  l4_size_t size;
  int  rc;

  /* query default dataspace manager id */
  if (l4_is_invalid_id(dsm))
    dsm = l4env_get_default_dsm();

  if (l4_is_invalid_id(dsm))
  {
    io_log("No dataspace manager found\n");
    return 2;
  }
  //FILE *f;
  char *p = options.libpath - 1;
  STR_SAVED_TOKENS st;
  char * p_buf = full_path_name;
  //char *sep="\\";
#ifdef __LINUX__
  char *hostsep="/";
#else
  char *hostsep="\\";
#endif
  char *psep=";";

  StrTokSave(&st);
  if((p = StrTokenize((char*)options.libpath, psep)) != 0)
  do if(*p)
  {
    //int B_LEN = 250;
    char buf[251];
    //char *str_buf=(char*) &buf;
    char buf2[251];
    char * file_to_find=(char*) &buf2;
    long i=0;

    p_buf = full_path_name;
    p_buf[0] = '\0';
    while (p[i]!='\0')
    {
      if (p[i]=='\\') p[i]=*hostsep; ++i;
    }

    strcat(p_buf, p);
    if (p[strlen(p)-1]!=*hostsep)
    {
      strcat(p_buf, hostsep);
    }

    strcat(p_buf, name);

    buf[0] = '\0';
    buf2[0] = '\0';
    strcat(file_to_find, name);
    #ifndef L4API_l4v2
      if(find_case_file(file_to_find, p, str_buf, B_LEN))
      {
        p_buf[0] = 0;
        strcat(p_buf, p);
        strcat(p_buf, hostsep);
        strcat(p_buf, str_buf); /* Case corrected for file, Needed on Linux. */
      }
    #endif

    io_log(p_buf);
    //io_log(os2_fname_to_vfs_fname(p_buf));

    //f = fopen(os2_fname_to_vfs_fname(p_buf), "rb"); /* Tries to open the file, if it works f is a valid pointer.*/
    /* try opening a file from a file provider */
    rc = l4fprov_file_open_call(&fs, p_buf, &dsm, 0,
                       &ds, &size, &env);
    
    if(!rc)
    {
      l4dm_close(&ds);
      StrTokStop();
      return 0; /* NO_ERROR */
    }
  } while((p = StrTokenize(0, psep)) != 0);
  StrTokRestore(&st);

  return 2 /*ERROR_FILE_NOT_FOUND*/;
}
예제 #17
0
파일: path.c 프로젝트: ErisBlastar/osfree
unsigned int find_path(const char *name, char *full_path_name)
{
  CORBA_Environment env = dice_default_environment;
  l4dm_dataspace_t ds;
  l4_size_t size;
  int  rc;

  //FILE *f;
  char *p;
  #define buf_size 4096
  char buf[buf_size+1];
  char *path = (char *) &buf;
  STR_SAVED_TOKENS st;
  char * p_buf = full_path_name;
  char *sep="\\";
  char *psep=";";

  /* query default dataspace manager id */
  if (l4_is_invalid_id(dsm))
    dsm = l4env_get_default_dsm();

  if (l4_is_invalid_id(dsm))
  {
    io_log("No dataspace manager found\n");
    return 2;
  }

  io_log("name=%s", name);
  io_log("full_path_name=%s", full_path_name);

  cfg_Getenv("PATH", &path);
  io_log("PATH: %s", path);

  p = path - 1;

  StrTokSave(&st);
  io_log("0");
  if((p = StrTokenize((char*)path, psep)) != 0) do if(*p)
  {
    io_log("1");
    p_buf = full_path_name;
    p_buf[0] = 0;
    io_log(p);
    if (!strcmp(p,"."))
    {
      strcat(p_buf, options.bootdrive);
      strcat(p_buf, "\\"); // For OS2Server current directory is always root
    } else {
      strcat(p_buf, p);
      strcat(p_buf, sep);
    }
    strcat(p_buf, name);
    io_log("2");
    io_log("p_buf=%s", p_buf);
    //f = fopen(os2_fname_to_vfs_fname(p_buf), "rb"); /* Tries to open the file, if it works f is a valid pointer.*/
    //if(f)
    /* try opening a file from a file provider */
    io_log("call fprov");
    io_log("fs: %x.%x", fs.id.task, fs.id.lthread);
    rc = l4fprov_file_open_call(&fs, p_buf, &dsm, 0,
                       &ds, &size, &env);
    io_log("called, rc=%d", rc);
    io_log("3");
    if(!rc)
    {
      io_log("30");
      l4dm_close(&ds);
      io_log("31");
      StrTokStop();
      io_log("32");
      return 0; /* NO_ERROR */
    }
    io_log("4");
  } while((p = StrTokenize(0, psep)) != 0);
  StrTokRestore(&st);

  io_log("5");
  return 2/*ERROR_FILE_NOT_FOUND*/;
}
예제 #18
0
void
exec_runserver(int ppid)
{
    int  i, j;
    char *s, *p, *q, *name;
    char params[] = "";
    char server[0x20];
    char *srv, *to;
    int  timeout = 30000;
    l4_threadid_t tid;
    struct t_os2process *proc; // server PTDA/proc

    for (i = 0; i < 5; i++)
    {
        name = (char *)type[i].name;
        io_log("name=%s\n", name);
        if (!strcmp(name, "RUNSERVER"))
        {
            for (j = 0; j < type[i].ip; j++)
            {
                s = type[i].sp[j].string;
                p = getcmd (s);
                s = skipto(0, s);

                q = strdup(p);

                // create proc/PTDA structure
                proc = PrcCreate(ppid,      // ppid
                                 basename(q), // pPrg
                                 NULL,      // pArg
                                 NULL);     // pEnv

                free(q);

                l4os3_exec (p, params, &tid);
                io_log("started task: %x.%x\n", tid.id.task, tid.id.lthread);

                /* set task number */
                proc->task = tid;

                if (strstr(p, "os2fs"))
                {
                    io_log("os2fs started\n");
                    if (!names_waitfor_name("os2fs", &fs, 30000))
                    {
                        io_log("Can't find os2fs on name server!\n");
                        return;
                    }
                }

                srv     = getcmd (skipto(0, strstr(s, "-LOOKFOR")));

                /* skip spaces and quotes */
                for (p = srv; *p == '"' || *p == ' '; p++) ;
                srv = p;
                for (p = srv + strlen(srv) - 1; *p == '"' || *p == ' '; p--) *p = '\0';
                strcpy (server, srv);

                to      = getcmd (skipto(0, strstr(s, "-TIMEOUT")));
                timeout = atoi (to);

                io_log("LOOKFOR:%s, TIMEOUT:%d\n", server, timeout);
                if (*server && !names_waitfor_name(server, &tid, timeout))
                {
                    io_log("Timeout waiting for %s\n", server);
                    return;
                }
            }
            io_log("Server %s started\n", server);
        }
    }

    return;
}
예제 #19
0
int sysinit (cfg_opts *options)
{
    struct t_os2process *proc; // sysinit's PTDA/proc
    //l4events_ch_t event_ch = L4EVENTS_EXIT_CHANNEL;
    //l4events_nr_t event_nr = L4EVENTS_NO_NR;
    //l4events_event_t event;
    char   *env;
    APIRET rc;

    // create global environment
    create_env(&env);

    // Create the sysinit process PTDA structure (pid == ppid == 0)
    proc = PrcCreate(0,         // ppid
                     "sysinit", // pPrg
                     NULL,      // pArg
                     env);      // pEnv

    /* set task number */
    sysinit_id = l4_myself();
    proc->task = sysinit_id;

    if (!names_register("os2srv.sysinit"))
        io_log("error registering on the name server\n");

    /* Start servers */
    exec_runserver(proc->pid);

    /* Start run=/call= */
    exec_run_call(proc->pid);

    // Check PROTSHELL statement value
    if (!options->protshell || !*(options->protshell))
    {
        io_log("No PROTSHELL statement in CONFIG.SYS\n");
        rc = ERROR_INVALID_PARAMETER; /*ERROR_INVALID_PARAMETER 87; Not defined for Windows*/
    } else {
        exec_protshell(options);
        rc = 0; /* NO_ERROR */
    }

    io_log("sem wait\n");

    if (!rc) // wait until child process (protshell) terminates (this will unblock us)
        l4semaphore_down(&proc->term_sem);

    io_log("done waiting\n");

    /* if (use_events) // use events server
    {
      // terminate by sending an exit event
      event.len = sizeof(l4_threadid_t);
      *(l4_threadid_t*)event.str = l4_myself();
      // send exit event
      l4events_send(event_ch, &event, &event_nr, L4EVENTS_SEND_ACK);
      // get acknowledge
      l4events_get_ack(&event_nr, L4_IPC_NEVER);
    } */

    io_log("event notification sent\n");

    // unregister at names
    if (!names_unregister_task(sysinit_id))
        io_log("Cannot unregister at name server!\n");

    // destroy proc/PTDA
    PrcDestroy(proc);

    // destroy global environment
    destroy_env(env);

    io_log("OS/2 Server ended\n");
    // terminate OS/2 Server
    exit(rc);

    return rc;
}
예제 #20
0
파일: exec.c 프로젝트: ErisBlastar/osfree
void
l4os3_exec(char *cmd, char *params, l4_taskid_t *taskid)
{
  #define MAX_TASK_ID 16
  CORBA_Environment env = dice_default_environment;
  //char name[] = "os2app.cfg";
  char parm[1024] = "";
  char cmd_buf[0x20];
  l4_taskid_t task_ids[MAX_TASK_ID];
  char error_msg[1024];
  char *ptr = error_msg;
  l4os3_ds_t ds = L4DM_INVALID_DATASPACE;
  l4_addr_t addr;
  int error;

  // If we use events server, pass this option
  // to other servers/apps too
  if (use_events)
  {
    io_log("using events\n");
    strcat(parm, " --events ");
  }

  strcat(parm, params);
  
  io_log("cmd=%s\n", cmd);
  io_log("parm=\"%s\"\n", parm);

  /* RPC call to DM_PHYS (create a dataspace) */
  //if (if_l4dm_mem_open_call(&dsm_id, 1024, 0, 0,
  //                            name, &ds, &env))
  if (l4os3_ds_allocate(&ds, 0, 1024))
    {
      io_log("Can't allocate a dataspace!\n");
      while (1) { l4_sleep(0.1); }
    }
  io_log("dataspace created\n");
      
  /* attach the dataspace to our own address space */
  attach_ds(&ds, L4DM_RW, &addr);
  io_log("dataspace attached\n");
      
  /* create a loader script */
  strcpy((char *)addr, "modpath \"/file/system\"\n\ntask \"");
  strcat((char *)addr, cmd);
  strcat((char *)addr, "\"  \"--stdin /dev/vc0 --stdout /dev/vc0 --stderr /dev/vc0 ");
  strcat((char *)addr, parm);
  strcat((char *)addr, "\"");
  strcat((char *)addr, "\n\n  priority 0xA0");

  /* detach dataspace */
  l4rm_detach((void *)addr);

  /* transfer dataspace to loader */
  l4dm_transfer(&ds,              // dataspace
                loader_id);       // taskid
  
  /* RPC to L4 loader to start OS/2 app L4 startup */
  if ((error = l4loader_app_open_call(&loader_id, &ds, cmd_buf,
                                        &fprov_id, 0, task_ids,
                                        &ptr, &env)))
    {
      if (error == -L4_ENOTFOUND)
        io_log("file %s not found!\n", cmd_buf);

      io_log("  Error %d (%s) loading application\n",
          error, l4os3_errtostr(error));

      if (*error_msg)
        io_log("  (Loader says:'%s')\n", error_msg);
 
      while (1) l4_sleep(0.1);
    }
  *taskid = task_ids[0];
}