コード例 #1
0
static int configure_port(const unsigned char *buf, struct resource *io_parent,
		     char *board)
{
	int len;
	u_int8_t c;
	int i;
	struct resource *res;
	int result;
	
	len=0;
	
	for (i=0;i<HPEE_PORT_MAX_ENT;i++) {
		c = get_8(buf+len);
		
		if (NULL != (res = kmalloc(sizeof(struct resource), GFP_KERNEL))) {
			res->name = board;
			res->start = get_16(buf+len+1);
			res->end = get_16(buf+len+1)+(c&HPEE_PORT_SIZE_MASK)+1;
			res->flags = IORESOURCE_IO;
			printk("ioports %lx-%lx ", res->start, res->end);
			result = request_resource(io_parent, res);
			if (result < 0) {
				printk("\n" KERN_ERR "EISA Enumerator: failed to claim EISA Bus address space!\n");
				return result;
			}
		}

		len+=3;      
		if (!(c & HPEE_PORT_MORE)) {
			break;
		}
	}
	
	return len;
}
コード例 #2
0
ファイル: fs.c プロジェクト: 1stMaster/syslinux
const char *syslinux_check_bootsect(const void *bs, int *fs_type)
{
    uint8_t media_sig;
    int sectorsize;
    const struct fat_boot_sector *sectbuf = bs;
    const char *retval;

    media_sig = get_8(&sectbuf->bsMedia);
    /* Must be 0xF0 or 0xF8-0xFF for FAT/NTFS volumes */
    if (media_sig != 0xF0 && media_sig < 0xF8)
	return "invalid media signature (not an FAT/NTFS volume?)";

    sectorsize = get_16(&sectbuf->bsBytesPerSec);
    if (sectorsize == SECTOR_SIZE) ;	/* ok */
    else if (sectorsize >= 512 && sectorsize <= 4096 &&
	     (sectorsize & (sectorsize - 1)) == 0)
	return "unsupported sectors size";
    else
	return "impossible sector size";

    if (ntfs_check_zero_fields((struct ntfs_boot_sector *)bs))
	retval = check_ntfs_bootsect(bs, fs_type);
    else
	retval = check_fat_bootsect(bs, fs_type);

    return retval;
}
コード例 #3
0
static int configure_function(const unsigned char *buf, int *more) 
{
	
	*more = get_16(buf);
	
	return 2;
}
コード例 #4
0
ファイル: info.c プロジェクト: machineroom/ttm50m
void SpGetInfo(void)
{
   unsigned char  item;
   int            replymax;
   char           name[MAX_SLICE_LENGTH];
   
   dbgmsg("SP.GETINFO");
   
   InBuf = &Tbuf[3];
   OutBuf = &Tbuf[2];
   OutCount = 0;
   
   item = get_8();
   replymax = get_16();
   
   switch (item) {
      case INFO_SWITCH:
         put_8(ER_SUCCESS);
         put_8(SWITCH_CHAR);
         break;
         
      case INFO_EOL:
         put_8(ER_SUCCESS);
         put_slice(strlen(NEWLINE_SEQUENCE), NEWLINE_SEQUENCE);
         break;
         
      case INFO_STDERR:
         put_8(ER_SUCCESS);
         put_8(REDIRECT_STDERR);
         break;
         
      case INFO_SERVERID:
         put_8(ER_SUCCESS);
         sprintf(name,"%s %s", PROGRAM_NAME, VERSION_NAME);
         put_slice(strlen(name), name);
         break;
         
      case INFO_SERVERMAJ:
         put_8(ER_SUCCESS);
         put_32((long) MAJOR_ID);
         break;
         
      case INFO_SERVERMIN:
         put_8(ER_SUCCESS);
         put_32((long) MINOR_ID);
         break;
         
      case INFO_PKTSIZE:
         put_8(ER_SUCCESS);
         put_32((long) TRANSACTION_BUFFER_SIZE);
         break;
         
      default:
         put_8(ER_ERROR);
         break;
   }
   
   put_count(OutCount);
}
コード例 #5
0
ファイル: file_access.cpp プロジェクト: dataxerik/godot
uint32_t FileAccess::get_32() const {

	uint32_t res;
	uint16_t a, b;

	a = get_16();
	b = get_16();

	if (endian_swap) {

		SWAP(a, b);
	}

	res = b;
	res <<= 16;
	res |= a;

	return res;
}
コード例 #6
0
static int configure_function(const unsigned char *buf, int *more) 
{
	/* the init field seems to be a two-byte field
	 * which is non-zero if there are an other function following
	 * I think it is the length of the function def 
	 */
	*more = get_16(buf);
	
	return 2;
}
コード例 #7
0
static int configure_memory(const unsigned char *buf, 
		       struct resource *mem_parent,
		       char *name)
{
	int len;
	u_int8_t c;
	int i;
	struct resource *res;
	
	len=0;
	
	for (i=0;i<HPEE_MEMORY_MAX_ENT;i++) {
		c = get_8(buf+len);
		
		if (NULL != (res = kmalloc(sizeof(struct resource), GFP_KERNEL))) {
			int result;
			
			res->name = name;
			res->start = mem_parent->start + get_24(buf+len+2);
			res->end = res->start + get_16(buf+len+5)*1024;
			res->flags = IORESOURCE_MEM;
			printk("memory %lx-%lx ", res->start, res->end);
			result = request_resource(mem_parent, res);
			if (result < 0) {
				printk("\n" KERN_ERR "EISA Enumerator: failed to claim EISA Bus address space!\n");
				return result;
			}
		}
		 	
		len+=7;      
	
		if (!(c & HPEE_MEMORY_MORE)) {
			break;
		}
	}
	
	return len;
}
コード例 #8
0
ファイル: fs.c プロジェクト: 1stMaster/syslinux
static const char *check_fat_bootsect(const void *bs, int *fs_type)
{
    int sectorsize;
    const struct fat_boot_sector *sectbuf = bs;
    long long sectors, fatsectors, dsectors;
    long long clusters;
    int rootdirents, clustersize;

    sectorsize = get_16(&sectbuf->bsBytesPerSec);

    clustersize = get_8(&sectbuf->bsSecPerClust);
    if (clustersize == 0 || (clustersize & (clustersize - 1)))
	return "impossible cluster size on an FAT volume";

    sectors = get_16(&sectbuf->bsSectors);
    sectors = sectors ? sectors : get_32(&sectbuf->bsHugeSectors);

    dsectors = sectors - get_16(&sectbuf->bsResSectors);

    fatsectors = get_16(&sectbuf->bsFATsecs);
    fatsectors = fatsectors ? fatsectors : get_32(&sectbuf->bs32.FATSz32);
    fatsectors *= get_8(&sectbuf->bsFATs);
    dsectors -= fatsectors;

    rootdirents = get_16(&sectbuf->bsRootDirEnts);
    dsectors -= (rootdirents + sectorsize / 32 - 1) / sectorsize;

    if (dsectors < 0)
	return "negative number of data sectors on an FAT volume";

    clusters = dsectors / clustersize;

    fatsectors = get_16(&sectbuf->bsFATsecs);
    fatsectors = fatsectors ? fatsectors : get_32(&sectbuf->bs32.FATSz32);
    fatsectors *= get_8(&sectbuf->bsFATs);

    if (!fatsectors)
	return "zero FAT sectors";

    if (clusters < 0xFFF5) {
	/* FAT12 or FAT16 */
	if (!get_16(&sectbuf->bsFATsecs))
	    return "zero FAT sectors (FAT12/16)";

	if (get_8(&sectbuf->bs16.BootSignature) == 0x29) {
	    if (!memcmp(&sectbuf->bs16.FileSysType, "FAT12   ", 8)) {
		if (clusters >= 0xFF5)
		    return "more than 4084 clusters but claims FAT12";
	    } else if (!memcmp(&sectbuf->bs16.FileSysType, "FAT16   ", 8)) {
		if (clusters < 0xFF5)
		    return "less than 4084 clusters but claims FAT16";
	    } else if (!memcmp(&sectbuf->bs16.FileSysType, "FAT32   ", 8)) {
		return "less than 65525 clusters but claims FAT32";
	    } else if (memcmp(&sectbuf->bs16.FileSysType, "FAT     ", 8)) {
		static char fserr[] = "filesystem type \"????????\" not "
		    "supported";
		memcpy(fserr + 17, &sectbuf->bs16.FileSysType, 8);
		return fserr;
	    }
	}
    } else if (clusters < 0x0FFFFFF5) {
	/*
	 * FAT32...
	 *
	 * Moving the FileSysType and BootSignature was a lovely stroke
	 * of M$ idiocy...
	 */
	if (get_8(&sectbuf->bs32.BootSignature) != 0x29 ||
	    memcmp(&sectbuf->bs32.FileSysType, "FAT32   ", 8))
	    return "missing FAT32 signature";
    } else {
	return "impossibly large number of clusters on an FAT volume";
    }

    if (fs_type)
	*fs_type = VFAT;

    return NULL;
}
コード例 #9
0
ファイル: record.c プロジェクト: machineroom/ttm50m
void SpGetRec(void)
{
   long              fileid;
   FILE              *fd;
   int               chunksize;
   long              offset;
   bool              doread=false;
   struct FILE_INFO  *info;
   int               res=ER_SUCCESS;
   
   dbgmsg("SP.GETREC");

   InBuf = &Tbuf[3];
   OutBuf = &Tbuf[2];
   OutCount = 0;
   
   fileid = get_32();
   chunksize = get_16();
   offset    = get_32();
   
   if (get_8())
      doread = true;
      
   dbgmsg("fileid=%d, chunksize=%d, offset=%ld, doread=%d",
               fileid, chunksize, offset, doread);
               
   if ((fileid < 0) || (fileid > MAX_FILES)) {
      put_8(ER_BADID);
      put_count(OutCount);
      return;
   }

   info = &FileInfo[fileid];
   
   if (info->lastop == FIOP_WRITE) {
      put_8(ER_NOPOSN);
      put_count(OutCount);
      return;
   }
   
   if ((offset > info->mrs) || (offset < 0)) {
      put_8(ER_ERROR);
      put_count(OutCount);
      return;
   }
      
   if (doread == true) {
      info->recno++;
#ifdef VMS
      res = vmsget(info);
      vmssavepos(info);
#else
      res = info->getfn(info);
#endif
   }
   
   dbgmsg("res=%d", res);
   
   if ((offset + (long)chunksize) > info->recordsize)
      chunksize = info->recordsize - offset;
      
   dbgmsg("recsiz=%ld, offset=%ld, chunksize=%d",
               info->recordsize, offset, chunksize);
   
   info->lastop = FIOP_READ;
   
   put_8(res);
   if (res == ER_SUCCESS) {
      put_32(info->recordsize);
      put_slice(chunksize, &(info->buff[offset]));
   }
   put_count(OutCount);
}
コード例 #10
0
ファイル: record.c プロジェクト: machineroom/ttm50m
void SpPutRec(void)
{
   long              fileid;
   FILE              *fd;
   long              recordsize;
   int               chunksize;
   long              offset;
   bool              dowrite=false;
   struct FILE_INFO  *info;
   int               res;
   
   dbgmsg("SP.PUTREC");

   InBuf = &Tbuf[3];
   OutBuf = &Tbuf[2];
   OutCount = 0;
   
   fileid = get_32();
   recordsize = get_32();
   chunksize = get_16();
   offset    = get_32();
   
   if (get_8())
      dowrite = true;
      
   dbgmsg("fileid=%ld, recordsize=%ld, chunksize=%d, offset=%ld, write=%d",
            fileid, recordsize, chunksize, offset, dowrite);
      
   if ((fileid < 0) || (fileid > MAX_FILES)) {
      put_8(ER_BADID);
      put_count(OutCount);
      return;
   }

   info = &FileInfo[fileid];
   
   if (info->fd == NULL) {
      put_8(ER_BADID);
      put_count(OutCount);
      return;
   }
   
   if (info->lastop == FIOP_READ) {
      put_8(ER_NOPOSN);
      put_count(OutCount);
      return;
   }
   
   if (info->recordsize == -1)
      info->recordsize = recordsize;
      
   dbgmsg("recordsize=%ld, info->recordsize=%ld", recordsize, info->recordsize);
   dbgmsg("info->mrs=%ld", info->mrs);
   
   if ((recordsize > info->recordsize) || 
     (recordsize > info->mrs) || (offset+(long)chunksize > info->mrs)) {
      dbgmsg("ER_ERROR: recordsize screwup");
      put_8(ER_ERROR);
      put_count(OutCount);
      return;
   }
   
   get_slice(&(info->buff[offset]));
   info->dirty = true;
   
   if (dowrite == true) {
      info->recno++;
#ifdef VMS
      res = vmsput(info->rab, info->buff, (int) recordsize);
      vmssavepos(info);
#else
      res = info->putfn(info->fd, info->buff, recordsize);
#endif /* VMS */
      info->dirty = false;
      info->recordsize = -1;
   }
   else
      res = ER_SUCCESS;
   
   info->lastop = FIOP_WRITE;
   info->pasteof = false;
   
   put_8(res);
   put_count(OutCount);
}
コード例 #11
0
/* byte 1 and 2 is the port number to write
 * and at byte 3 the value to write starts.
 * I assume that there are and- and or- masks
 * here when HPEE_PORT_INIT_MASK is set but I have 
 * not yet encountered this. */
static int configure_port_init(const unsigned char *buf)
{
	int len=0;
	u_int8_t c;
	
	while (len<HPEE_PORT_INIT_MAX_LEN) {
		int s=0;
		c = get_8(buf+len);
		
		switch (c & HPEE_PORT_INIT_WIDTH_MASK)  {
		 case HPEE_PORT_INIT_WIDTH_BYTE:
			s=1;
			if (c & HPEE_PORT_INIT_MASK) {
				printk("\n" KERN_WARNING "port_init: unverified mask attribute\n");
				outb((inb(get_16(buf+len+1) & 
					  get_8(buf+len+3)) | 
				      get_8(buf+len+4)), get_16(buf+len+1));
				      
			} else {
				outb(get_8(buf+len+3), get_16(buf+len+1));
				      
			}
			break;
		 case HPEE_PORT_INIT_WIDTH_WORD:
			s=2;
			if (c & HPEE_PORT_INIT_MASK) {
 				printk(KERN_WARNING "port_init: unverified mask attribute\n");
				       outw((inw(get_16(buf+len+1)) &
					     get_16(buf+len+3)) |
					    get_16(buf+len+5), 
					    get_16(buf+len+1));
			} else {
				outw(cpu_to_le16(get_16(buf+len+3)), get_16(buf+len+1));
			}
			break;
		 case HPEE_PORT_INIT_WIDTH_DWORD:
			s=4;
			if (c & HPEE_PORT_INIT_MASK) {
 				printk("\n" KERN_WARNING "port_init: unverified mask attribute\n");
				outl((inl(get_16(buf+len+1) &
					  get_32(buf+len+3)) |
				      get_32(buf+len+7)), get_16(buf+len+1));
			} else {
				outl(cpu_to_le32(get_32(buf+len+3)), get_16(buf+len+1));
			}

			break;
		 default:
			printk("\n" KERN_ERR "Invalid port init word %02x\n", c);
			return 0;
		}
		
		if (c & HPEE_PORT_INIT_MASK) {   
			s*=2;
		}
		
		len+=s+3;
		if (!(c & HPEE_PORT_INIT_MORE)) {
			break;
		}
	}
	
	return len;
}
コード例 #12
0
ファイル: client.c プロジェクト: Fuhuiang/rscheme
signed short get_s16( void )
{
    return get_16();
}
コード例 #13
0
ファイル: fat.c プロジェクト: Acidburn0zzz/syslinux-mac
/*
 * Check to see that what we got was indeed an MS-DOS boot sector/superblock;
 * Return NULL if OK and otherwise an error message;
 */
const char *syslinux_check_bootsect(const void *bs)
{
    int veryold;
    int sectorsize;
    long long sectors, fatsectors, dsectors;
    long long clusters;
    int rootdirents, clustersize;
    const struct boot_sector *sectbuf = bs;

    veryold = 0;

    /* Must be 0xF0 or 0xF8..0xFF */
    if (get_8(&sectbuf->bsMedia) != 0xF0 && get_8(&sectbuf->bsMedia) < 0xF8)
	return "invalid media signature (not a FAT filesystem?)";

    sectorsize = get_16(&sectbuf->bsBytesPerSec);
    if (sectorsize == SECTOR_SIZE)
	;			/* ok */
    else if (sectorsize >= 512 && sectorsize <= 4096 &&
	     (sectorsize & (sectorsize - 1)) == 0)
	return "unsupported sectors size";
    else
	return "impossible sector size";

    clustersize = get_8(&sectbuf->bsSecPerClust);
    if (clustersize == 0 || (clustersize & (clustersize - 1)))
	return "impossible cluster size";

    sectors = get_16(&sectbuf->bsSectors);
    sectors = sectors ? sectors : get_32(&sectbuf->bsHugeSectors);

    dsectors = sectors - get_16(&sectbuf->bsResSectors);

    fatsectors = get_16(&sectbuf->bsFATsecs);
    fatsectors = fatsectors ? fatsectors : get_32(&sectbuf->bs32.FATSz32);
    fatsectors *= get_8(&sectbuf->bsFATs);
    dsectors -= fatsectors;

    rootdirents = get_16(&sectbuf->bsRootDirEnts);
    dsectors -= (rootdirents + sectorsize / 32 - 1) / sectorsize;

    if (dsectors < 0)
	return "negative number of data sectors";

    if (fatsectors == 0)
	return "zero FAT sectors";

    clusters = dsectors / clustersize;

    if (clusters < 0xFFF5) {
	/* FAT12 or FAT16 */

	if (!get_16(&sectbuf->bsFATsecs))
	    return "zero FAT sectors (FAT12/16)";

	if (get_8(&sectbuf->bs16.BootSignature) == 0x29) {
	    if (!memcmp(&sectbuf->bs16.FileSysType, "FAT12   ", 8)) {
		if (clusters >= 0xFF5)
		    return "more than 4084 clusters but claims FAT12";
	    } else if (!memcmp(&sectbuf->bs16.FileSysType, "FAT16   ", 8)) {
		if (clusters < 0xFF5)
		    return "less than 4084 clusters but claims FAT16";
	    } else if (!memcmp(&sectbuf->bs16.FileSysType, "FAT32   ", 8)) {
		    return "less than 65525 clusters but claims FAT32";
	    } else if (memcmp(&sectbuf->bs16.FileSysType, "FAT     ", 8)) {
		static char fserr[] =
		    "filesystem type \"????????\" not supported";
		memcpy(fserr + 17, &sectbuf->bs16.FileSysType, 8);
		return fserr;
	    }
	}
    } else if (clusters < 0x0FFFFFF5) {
	/*
	 * FAT32...
	 *
	 * Moving the FileSysType and BootSignature was a lovely stroke
	 * of M$ idiocy...
	 */
	if (get_8(&sectbuf->bs32.BootSignature) != 0x29 ||
	    memcmp(&sectbuf->bs32.FileSysType, "FAT32   ", 8))
	    return "missing FAT32 signature";
    } else {
	return "impossibly large number of clusters";
    }

    return NULL;
}