本文整理汇总了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;
}
示例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;
}
示例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");
}
示例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");
}
示例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;
}
示例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));
}
示例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); //???
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}