Example #1
0
unsigned short get_16( void )
{
unsigned short x;

    x = get_8() << 8;
    x += get_8();
    return x;
}
Example #2
0
unsigned long get_32( void )
{
unsigned long x;

    x = get_8() << 24;
    x += get_8() << 16;
    x += get_8() << 8;
    x += get_8();
    return x;
}
Example #3
0
static int configure_choise(const unsigned char *buf, u_int8_t *info)
{
	int len;
	
	
	len = get_8(buf);
	*info=get_8(buf+len+1);
	 
	return len+2;
}
Example #4
0
static int configure_choise(const unsigned char *buf, u_int8_t *info)
{
	int len;
	
	/* theis record contain the value of the functions
	 * configuration choises and an info byte which 
	 * describes which other records to expect in this 
	 * function */
	len = get_8(buf);
	*info=get_8(buf+len+1);
	 
	return len+2;
}
Example #5
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;
}
Example #6
0
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;
}
Example #7
0
static int configure_irq(const unsigned char *buf)
{
	int len;
	u_int8_t c;
	int i;
	
	len=0;
	
	for (i=0;i<HPEE_IRQ_MAX_ENT;i++) {
		c = get_8(buf+len);
		
		printk("IRQ %d ", c & HPEE_IRQ_CHANNEL_MASK);
		if (c & HPEE_IRQ_TRIG_LEVEL) {
			eisa_make_irq_level(c & HPEE_IRQ_CHANNEL_MASK);
		} else {
			eisa_make_irq_edge(c & HPEE_IRQ_CHANNEL_MASK);
		}
		
		len+=2; 
		
		if  (!(c & HPEE_IRQ_MORE)) {
			break;
		}
	}
	
	return len;
}
Example #8
0
static int configure_irq(const unsigned char *buf)
{
	int len;
	u_int8_t c;
	int i;
	
	len=0;
	
	for (i=0;i<HPEE_IRQ_MAX_ENT;i++) {
		c = get_8(buf+len);
		
		printk("IRQ %d ", c & HPEE_IRQ_CHANNEL_MASK);
		if (c & HPEE_IRQ_TRIG_LEVEL) {
			eisa_make_irq_level(c & HPEE_IRQ_CHANNEL_MASK);
		} else {
			eisa_make_irq_edge(c & HPEE_IRQ_CHANNEL_MASK);
		}
		
		len+=2; 
		/* hpux seems to allow for
		 * two bytes of irq data but only defines one of
		 * them, I think */
		if  (!(c & HPEE_IRQ_MORE)) {
			break;
		}
	}
	
	return len;
}
Example #9
0
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);
}
Example #10
0
int FileAccess::get_buffer(uint8_t *p_dst, int p_length) const {

	int i = 0;
	for (i = 0; i < p_length && !eof_reached(); i++)
		p_dst[i] = get_8();

	return i;
}
Example #11
0
String FileAccess::get_token() const {

	CharString token;

	CharType c = get_8();

	while (!eof_reached()) {

		if (c <= ' ') {
			if (token.length())
				break;
		} else {
			token += c;
		}
		c = get_8();
	}

	return String::utf8(token.get_data());
}
Example #12
0
String FileAccess::get_line() const {

	CharBuffer line;

	CharType c = get_8();

	while (!eof_reached()) {

		if (c == '\n' || c == '\0') {
			line.push_back(0);
			return String::utf8(line.get_data());
		} else if (c != '\r')
			line.push_back(c);

		c = get_8();
	}
	line.push_back(0);
	return String::utf8(line.get_data());
}
Example #13
0
uint16_t FileAccess::get_16() const {

	uint16_t res;
	uint8_t a, b;

	a = get_8();
	b = get_8();

	if (endian_swap) {

		SWAP(a, b);
	}

	res = b;
	res <<= 8;
	res |= a;

	return res;
}
Example #14
0
String FileAccess::get_token() const {

	CharString token;

	CharType c = get_8();

	while (!eof_reached()) {

		if (c <= ' ') {
			if (!token.empty())
				break;
		} else {
			token.push_back(c);
		}
		c = get_8();
	}

	token.push_back(0);
	return String::utf8(token.get_data());
}
Example #15
0
static int configure_type_string(const unsigned char *buf) 
{
	int len;
	
	/* just skip past the type field */
	len = get_8(buf);
	if (len > 80) {
		printk("\n" KERN_ERR "eisa_enumerator: type info field too long (%d, max is 80)\n", len);
	}
	
	return 1+len;
}
Example #16
0
static int configure_dma(const unsigned char *buf)
{
	int len;
	u_int8_t c;
	int i;
	
	len=0;
	
	for (i=0;i<HPEE_DMA_MAX_ENT;i++) {
		c = get_8(buf+len);
		printk("DMA %d ", c&HPEE_DMA_CHANNEL_MASK);
		
		len+=2;      
		if (!(c & HPEE_DMA_MORE)) {
			break;
		}
	}
	
	return len;
}
Example #17
0
static int configure_dma(const unsigned char *buf)
{
	int len;
	u_int8_t c;
	int i;
	
	len=0;
	
	for (i=0;i<HPEE_DMA_MAX_ENT;i++) {
		c = get_8(buf+len);
		printk("DMA %d ", c&HPEE_DMA_CHANNEL_MASK);
		/* fixme: maybe initialize the dma channel withthe timing ? */
		len+=2;      
		if (!(c & HPEE_DMA_MORE)) {
			break;
		}
	}
	
	return len;
}
Example #18
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;
}
Example #19
0
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;
}
Example #20
0
void SpOpenRec(void)
{
   char              fname[MAX_SLICE_LENGTH+1];
   int               namelen;
   int               fileorg;
   int               filemode;
   int               filetype;
   int               format;
   long              mrs;
   long              fileid;
   FILE              *fd;
   struct FILE_INFO  *info;
#ifdef VMS
   struct RAB        *rab;
   RecInfo           *rinfo;
   unsigned int      rfm,rat;
#endif /* VMS */
   
   dbgmsg("SP.OPENREC");

   InBuf = &Tbuf[3];
   OutBuf = &Tbuf[2];
   OutCount = 0;
   
   namelen  = get_slice((unsigned char *) fname);
   fname[namelen] = '\0';
   fileorg  = (int) get_8();
   filemode = (int) get_8();
   filetype = (int) get_8();
   format   = (int) get_8();
   mrs      = get_32();
   
   dbgmsg("file=\"%s\" %d:%d:%d:%d %ld", fname, fileorg, filemode, 
                                                filetype, format, mrs);                                                    
   
   /* Validate request */
   if ((strlen(fname) == 0) || (fileorg < 3) || (fileorg > 4) ||
                                 (filetype < 0) || (filetype > 2) ||
                                   (filemode < 1) || (filemode > 6) ||
                                    (format < 0) || (format > 1)) {
      SpFail(ER_ERROR);
      return;
   }
      
   if (filetype == TYPE_DONTCARE)
      filetype = TYPE_RECORD;
   
#ifdef VMS
   if (fileorg == ORG_VARIABLE)
      rfm = FAB$C_VAR;
   rfm = (fileorg == ORG_VARIABLE)?FAB$C_VAR:FAB$C_FIX;
   rat = (filetype == TYPE_RECORD)?FAB$M_FTN:0;    /* FTN:FAB$M_CR */
   
   /* We ignore format under VMS */
   
   /* decide whether to open or create file */
   if ((filemode == 1) || (filemode == 4))
      rab = vmsopen(fname, rfm, rat);
   else
      rab = vmscreate(fname, rfm, rat, rfm);

   if (rab == (struct RAB *) NULL) {
      SpFail(ER_NOFILE);
      return;
   }
   
   rinfo = newinfo();
   if (rinfo == (RecInfo *) NULL) {
      vmsclose(rab);
      SpFail(ER_ERROR);
   }
   else {
      rinfo->baserec = 0;
      rinfo->prev = (FilePos *) NULL;
      rinfo->next = (FilePos *) NULL;
   }
   
   fd = stdout;         /* Must be something ! */
#else
   fd = fopen(fname, OpenModes[fileorg-1][filemode-1]);
   if (fd == NULL) {
      SpFail(ER_NOFILE);
      return;
   }
#endif /* VMS */
   
   /* File opened OK */
   fileid = RememberFile(fd, fileorg);
   if (fileid == NO_SLOT) {
      SpFail(ER_NORESOURCE);
      return;
   }
   
   /* Things are looking good Houston....beep */
   info = &FileInfo[fileid];
   info->buff = (unsigned char *) malloc((int) mrs+3); /* Room for CR, NL, EOS */
   if (info->buff == (unsigned char *) NULL) {      
      ForgetFile(fileid);
      SpFail(ER_NORESOURCE);
      return;
   }
   
   info->mrs = mrs;
   info->recordsize = -1;
   info->format = format;
   info->type = filetype;
   info->recno = 0;
   info->lastop = FIOP_NONE;
   info->pasteof = false;
   
#ifdef VMS
   info->rab = rab;
   info->poslist = rinfo;
#else
   if (fileorg == ORG_VARIABLE) {
      info->putfn = (format == FMT_FORMATTED)?form_seq_write_rec:unform_seq_write_rec;
      info->getfn = (format == FMT_FORMATTED)?form_seq_read_rec:unform_seq_read_rec;
      
      /* Need to allocate a read-ahead buffer for formatted files */
      if (format == FMT_FORMATTED) {
         info->llbuff = (unsigned char *) malloc(LL_BUF_SIZE);
         info->llind = LL_BUF_SIZE;
         if (info->llbuff == (unsigned char *) NULL) {
            free(info->buff);
            ForgetFile(fileid);
            SpFail(ER_NORESOURCE);
            return;
         }
      }
      else {
         info->llbuff = NULL;
         info->llind = 0;
      }
   }
   else {
      info->putfn = direct_write_rec;
      info->getfn = direct_read_rec;
      info->llbuff = NULL;
      info->llind = 0;
   }
#endif /* VMS */
   
   put_8(ER_SUCCESS);
   put_32(mrs);
   put_32(fileid);
   put_32(filetype);
   
   put_count(OutCount);
}
Example #21
0
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);
}
Example #22
0
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);
}
Example #23
0
/*
 * 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;
}
Example #24
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;
}
Example #25
0
signed char get_s8( void )
{
    return get_8();
}