当前位置: 首页>>代码示例>>C++>>正文


C++ readsb函数代码示例

本文整理汇总了C++中readsb函数的典型用法代码示例。如果您正苦于以下问题:C++ readsb函数的具体用法?C++ readsb怎么用?C++ readsb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了readsb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ialloc

//PAGEBREAK!
// Allocate a new inode with the given type on device dev.
// A free inode has a type of zero.
struct inode*
ialloc(uint dev, short type)
{
  int inum;
  struct buf *bp;
  struct dinode *dip;
  struct superblock sb;

  readsb(dev, &sb);

  for(inum = 1; inum < sb.ninodes; inum++){
    bp = bread(dev, IBLOCK(inum));
    dip = (struct dinode*)bp->data + inum%IPB;
    if(dip->type == 0){  // a free inode
      memset(dip, 0, sizeof(*dip));
      dip->type = type;
      log_write(bp);   // mark it allocated on the disk
      brelse(bp);
      return iget(dev, inum);
    }
    brelse(bp);
  }
  panic("ialloc: no inodes");
  return 0;
}
开发者ID:Lulkafe,项目名称:xv6_rpi_port,代码行数:28,代码来源:fs.c

示例2: balloc

// Allocate a disk block.
static uint
balloc(uint dev)
{
  int b, bi, m, bound;
  struct buf *bp;
  struct superblock sb;
  
  bp = 0;
  readsb(dev, &sb);
  for(b = 0; b < sb.size; b += BPB){
    bp = bread(dev, BBLOCK(b, sb.ninodes));
    
    if(b+BPB > sb.size){ //last bitmap block
      bound = sb.size % BPB;
    } else {
      bound = BPB;
    }
    
    for(bi = 0; bi < bound; bi++){
      m = 1 << (bi % 8);
      if((bp->data[bi/8] & m) == 0){  // Is block free?
        bp->data[bi/8] |= m;  // Mark block in use on disk.
        bwrite(bp);
        brelse(bp);
        return b + bi;
      }
    }
    brelse(bp);
  }
  
  //panic("balloc: out of blocks");
  return 0;
}
开发者ID:cquagliana,项目名称:something_short,代码行数:34,代码来源:fs.c

示例3: log_balloc

static uint
log_balloc(uint dev)
{
  int b, bi, m, i;
  struct superblock sb;

  readsb(dev, &sb);
  for(b = 0; b < sb.size; b += BPB){
    for(i = 0; i < b_index; i++)
      if(bp[i]->sector == BBLOCK(b, sb.ninodes)) {
	for(bi = 0; bi < BPB; bi++){
	  m = 1 << (bi % 8);
	  if((bp[i]->data[bi/8] & m) == 0){
	    bp[i]->data[bi/8] |= m;
	    return b + bi;
	  }
	}
      }

    bp[b_index] = bread(dev, BBLOCK(b, sb.ninodes));
    for(bi = 0; bi < BPB; bi++){
      m = 1 << (bi % 8);
      if((bp[b_index]->data[bi/8] & m) == 0){
	bp[b_index]->data[bi/8] |= m;
	b_index++;
	return b + bi;
      }
    }
    brelse(bp[b_index]);
  }
  panic("balloc: out of blocks");
}
开发者ID:fenster,项目名称:xv6-staus-treffert,代码行数:32,代码来源:logfs.c

示例4: balloc

// Allocate a zeroed disk block.
static uint
balloc(uint dev)
{
  int b, bi, m;
  struct buf *bp;
  struct superblock sb;

  bp = 0;
  readsb(dev, &sb);
  for(b = 0; b < sb.size; b += BPB){
    bp = bread(dev, BBLOCK(b, sb.ninodes));
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
      m = 1 << (bi % 8);
      if((bp->data[bi/8] & m) == 0){  // Is block free?
        bp->data[bi/8] |= m;  // Mark block in use.
        log_write(bp);
        brelse(bp);
        bzero(dev, b + bi);
        return b + bi;
      }
    }
    brelse(bp);
  }
  panic("balloc: out of blocks");
}
开发者ID:lxmonk,项目名称:OS122-3,代码行数:26,代码来源:fs.c

示例5: balloc

// Allocate a disk block.
static uint
balloc(uint dev)
{
  int b, bi, m, bound;
  struct buf *bp;
  struct superblock sb;
  
  bp = 0;
  readsb(dev, &sb); // read superblock into sb
  for(b = 0; b < sb.size; b += BPB){ // loop through all available blocks
    // Return a B_BUSY buf with the contents of the indicated disk sector.
    bp = bread(dev, BBLOCK(b, sb.ninodes)); // get inode bitmap
    
    if(b+BPB > sb.size){ //last bitmap block
      bound = sb.size % BPB;
    } else {
      bound = BPB;
    }
    
    for(bi = 0; bi < bound; bi++){ // loop through all inode bitmap
      m = 1 << (bi % 8);
      if((bp->data[bi/8] & m) == 0){  // Is block free?
        bp->data[bi/8] |= m;  // Mark block in use on disk.
        bwrite(bp);
        brelse(bp);
        return b + bi;
      }
    }
    brelse(bp);
  }
  
  //panic("balloc: out of blocks");
  return 0;
}
开发者ID:squallee,项目名称:CS537,代码行数:35,代码来源:fs.c

示例6: nand_read_buf

static void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
{
	struct nand_chip *chip = mtd->priv;
	readsl(chip->IO_ADDR_R, buf, (len >> 2));
	if (len & 3)
		readsb(chip->IO_ADDR_R, buf + (len & ~0x3), (len & 3));
}
开发者ID:advx9600,项目名称:kernel-4.4-RuiEr,代码行数:7,代码来源:nand.c

示例7: changePartition

void
changePartition(int partition){ //TODO: CHECK!
  currentPartition = partition; 
  superBlockOffset = mbr.partitions[partition].offset;  //???
  cprintf("off:%d\n",mbr.partitions[partition].offset);

  readsb(ROOTDEV, &sb); //???
}
开发者ID:galbenor,项目名称:os162-4,代码行数:8,代码来源:fs.c

示例8: iinit

void
iinit(int dev)
{
  initlock(&icache.lock, "icache");
  readsb(dev, &sb);
  cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d inodestart %d bmap start %d\n", sb.size,
          sb.nblocks, sb.ninodes, sb.nlog, sb.logstart, sb.inodestart, sb.bmapstart);
}
开发者ID:gaohannk,项目名称:xv6-system,代码行数:8,代码来源:fs.c

示例9: cadence_qspi_apb_indirect_read_execute

int cadence_qspi_apb_indirect_read_execute(struct cadence_spi_platdata *plat,
	unsigned int n_rx, u8 *rxbuf)
{
	unsigned int remaining = n_rx;
	unsigned int bytes_to_read = 0;
	int ret;

	writel(n_rx, plat->regbase + CQSPI_REG_INDIRECTRDBYTES);

	/* Start the indirect read transfer */
	writel(CQSPI_REG_INDIRECTRD_START,
	       plat->regbase + CQSPI_REG_INDIRECTRD);

	while (remaining > 0) {
		ret = cadence_qspi_wait_for_data(plat);
		if (ret < 0) {
			printf("Indirect write timed out (%i)\n", ret);
			goto failrd;
		}

		bytes_to_read = ret;

		while (bytes_to_read != 0) {
			bytes_to_read *= CQSPI_FIFO_WIDTH;
			bytes_to_read = bytes_to_read > remaining ?
					remaining : bytes_to_read;
			/* Handle non-4-byte aligned access to avoid data abort. */
			if (((uintptr_t)rxbuf % 4) || (bytes_to_read % 4))
				readsb(plat->ahbbase, rxbuf, bytes_to_read);
			else
				readsl(plat->ahbbase, rxbuf, bytes_to_read >> 2);
			rxbuf += bytes_to_read;
			remaining -= bytes_to_read;
			bytes_to_read = cadence_qspi_get_rd_sram_level(plat);
		}
	}

	/* Check indirect done status */
	ret = wait_for_bit("QSPI", plat->regbase + CQSPI_REG_INDIRECTRD,
			   CQSPI_REG_INDIRECTRD_DONE, 1, 10, 0);
	if (ret) {
		printf("Indirect read completion error (%i)\n", ret);
		goto failrd;
	}

	/* Clear indirect completion status */
	writel(CQSPI_REG_INDIRECTRD_DONE,
	       plat->regbase + CQSPI_REG_INDIRECTRD);

	return 0;

failrd:
	/* Cancel the indirect read */
	writel(CQSPI_REG_INDIRECTRD_CANCEL,
	       plat->regbase + CQSPI_REG_INDIRECTRD);
	return ret;
}
开发者ID:wowotechX,项目名称:u-boot,代码行数:57,代码来源:cadence_qspi_apb.c

示例10: s3c2410_udc_read_packet

static inline int s3c2410_udc_read_packet(int fifo, u8 *buf,
		struct s3c2410_request *req, unsigned avail)
{
	unsigned len;

	len = min(req->req.length - req->req.actual, avail);
	req->req.actual += len;

	readsb(fifo + base_addr, buf, len);
	return len;
}
开发者ID:realmz,项目名称:blackfin-linux,代码行数:11,代码来源:s3c2410_udc.c

示例11: initlog

void
initlog(void)
{
  if (sizeof(struct logheader) >= BSIZE)
    panic("initlog: too big logheader");

  struct superblock sb;
  initlock(&log.lock, "log");
  readsb(ROOTDEV, &sb);
  log.start = sb.size - sb.nlog;
  log.size = sb.nlog;
  log.dev = ROOTDEV;
  recover_from_log();
}
开发者ID:joaobatalha,项目名称:zv6,代码行数:14,代码来源:log.c

示例12: initlog

void
initlog(int dev)
{
  if (sizeof(struct logheader) >= BSIZE)
    panic("initlog: too big logheader");

  struct superblock sb;
  initlock(&log.lock, "log");
  readsb(dev, &sb);
  log.start = sb.logstart;
  log.size = sb.nlog;
  log.dev = dev;
  recover_from_log();
}
开发者ID:jlledom,项目名称:MIT_6.828-xv6,代码行数:14,代码来源:log.c

示例13: bfree

// Free a disk block.
static void
bfree(int dev, uint b)
{
  struct buf *bp;
  int bi, m;

  readsb(dev, &sb);
  bp = bread(dev, BBLOCK(b, sb));
  bi = b % BPB;
  m = 1 << (bi % 8);
  if((bp->data[bi/8] & m) == 0)
    panic("freeing free block");
  bp->data[bi/8] &= ~m;
  log_write(bp);
  brelse(bp);
}
开发者ID:gaohannk,项目名称:xv6-system,代码行数:17,代码来源:fs.c

示例14: bfree

// Free a disk block.
static void
bfree(int dev, uint b)
{
  struct buf *bp;
  struct superblock sb;
  int bi, m;

  bzero(dev, b);

  readsb(dev, &sb);
  bp = bread(dev, BBLOCK(b, sb.ninodes));
  bi = b % BPB;
  m = 1 << (bi % 8);
  if((bp->data[bi/8] & m) == 0)
    panic("freeing free block");
  bp->data[bi/8] &= ~m;  // Mark block free on disk.
  bwrite(bp);
  brelse(bp);
}
开发者ID:guneetsinghmehta,项目名称:CS537_OS,代码行数:20,代码来源:fs.c

示例15: iinit

int iinit(struct proc* p, int dev)
{
    struct inode* rootNode;
    struct superblock sb;
    // TODO: change ot iterate over all partitions
    cprintf("kernal by Asaf and Ilana \n");
    initlock(&icache.lock, "icache");

    rootNode = p->cwd;
    // acquire(&icache.lock);

    initMbr(dev);
    printMBR(&mbrI);
    cprintf("booting from %d \n", bootfrom);
    if (bootfrom == -1) {
        panic("no bootable partition");
    }
    rootNode->part = &(partitions[bootfrom]);
    int i;
    for (i = 0; i < NPARTITIONS; i++) {
        readsb(dev, i);
        sb = sbs[i];
        cprintf("sb: offset %d size %d nblocks %d ninodes %d nlog %d logstart %d inodestart %d bmap start %d\n",
                sb.offset,
                sb.size,
                sb.nblocks,
                sb.ninodes,
                sb.nlog,
                sb.logstart,
                sb.inodestart,
                sb.bmapstart);
    }

    // set root inode

    // release(&icache.lock);

    // cprintf("root node init %d \n",rootNode->part->offset);

    return bootfrom;
}
开发者ID:asafbennatan,项目名称:xv6-public,代码行数:41,代码来源:fs.c


注:本文中的readsb函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。