コード例 #1
0
ファイル: bc.c プロジェクト: kurutoga/mtx_system
main() {

    prints("booting MTX\n\r");
    tsize = *(int *)(512+2);
    dsize = *(int *)(512+4);
    ksectors= ((tsize<<4)+dsize+511)/512;
    setes(0x1000);
    for (i=1;i<=ksectors+1;i++) {
        getsector(i);
        inces();
        putc('-');
    }
    prints("\n\rready to go?");
    getc();
}
コード例 #2
0
ファイル: bc.c プロジェクト: zapat0s/CptS460
int main()
{ 
	u16    i,iblk;
	char  *loc;
	u32   *l;
	GD    *gp;
	INODE *ip;

	prints("What image: ");
	gets(kstr);
	prints("\r\n");

	// Read group descriptor block and find inode table
	getblk(2, buf1);
	gp = (GD *)buf1;
	iblk = (u16)gp->bg_inode_table;

	getblk((u16)iblk, buf1);  // read first inode block
	ip = (INODE *)buf1 + 1;   // ip->root inode #2 ( / directory)

	// Read through directory entries looking for /boot
	i = findentry((u16)ip->i_block[0], "boot");

	// get inode
	ip = getinode(iblk, i);

	i = findentry((u16)ip->i_block[0], kstr);

	// Get inode
	ip = getinode(iblk, i);

	// get single indirect blocks
	getblk((u16)ip->i_block[12], buf2);
	
	// Copy file into memory
	prints("Loading: ");
	setes(0x1000);
	loc = 0;
	i = 0;

	// Get first 12 blocks
	while(i < 12 && ip->i_block[i] != 0)
	{
		getblk((u16)ip->i_block[i], loc);
		i++;
		loc += 1024;
		putc('.');
	}

	l = buf2;
	i = 0;
	while(i < 256 && l[i] > 0)
	{
		getblk((u16)(l[i]), loc);
		i++;
		loc += 1024;
		putc('+');
	}

	prints("\n\rReady?\n\r");
	getc();
	return 1;
}  
コード例 #3
0
ファイル: t.c プロジェクト: dqhoang/schoolwork
main()
{ 
  u16  i, iblk, disp, sino;
  u32	*d;
  char c;
  char name[64];
  char buf1[BLK], buf2[BLK];
  u32 buf3[BLK];
  
  /* read blk#2 to get group descriptor 0 */
  getblk((u16)2, buf1);
  gp = (GD *)buf1;
  iblk = (u16)gp->bg_inode_table; // typecast u32 to u16
  sino = (u16)gp->bg_inode_table;	// starting inode
  
  // Find boot directory
  name[0] = 'b';
  name[1] = 'o';
  name[2] = 'o';
  name[3] = 't';
  name[4] = 0;
  
  //inode block into buf1[ ]
  getblk( (u16)iblk, buf1);
  //ip point to INODE
  ip = (INODE *)buf1 + 1;
    
  i=0;
  while(i<2)
  {
    if(i == 1)
    {
      //prints("Boot:");
      gets(name);
      if(name[0] == 0)
      {
	name[0] = 'm';
	name[1] = 't';
	name[2] = 'x';
	name[3] = 0;
      }
    }
    getblk( (u16)ip->i_block[0], buf2);
    dp = (DIR *)buf2;
    while ( (char *)dp < &buf2[BLK])
    {
      c = dp->name[dp->name_len];
      dp->name[dp->name_len] = '\0';
      if (!strcmp(dp->name , name))
      {
	dp->name[dp->name_len] = c;
	iblk = (u16)dp->inode;
	break;
      }
      dp->name[dp->name_len] = c;
      dp = (DIR *)((char *)dp + dp->rec_len);
    }
    
    disp = ( iblk-1 ) % 8;
    iblk = ( (iblk-1) / 8 ) + sino;
    
    //inode block into buf1[ ]
    getblk( (u16)iblk, buf1);
    //ip point to INODE
    ip = (INODE *)buf1 + 1;
    ip += (disp -1);
    ++i;
  }
  /*******************************************************         
  (3). From the file's inode, find the disk blocks of the file:
      i_block[0] to i_block[11] are DIRECT blocks
      MTX kerenl has at most 64 (1KB) blocks, so no double-indirect blocks.
  *******************************************************/
  getblk( (u16)ip->i_block[12], buf2);
  getblk( (u16)ip->i_block[13], buf3);
  d = buf2;
  setes(0x1000);
  /*******************************************************
  (4). Load the blocks of /boot/mtx into memory at the segment 0x1000.
  *******************************************************/
  prints("\n\r");
  for ( i =0 ; i < 12 ; ++i)
  {
    getblk( (u16)ip->i_block[i], 0);
    putc('.');
    inces();
  }
  
  while ( (char *)d < &buf2[BLK] && *d != 0)
  {
    getblk( (u16)*d, 0);
    inces();
    putc('.');
    ++d;
  }
  /*
  while ( i=0;i<256;++i)
  {
    
    while ( (char *)d < &buf2[BLK] && *d != 0)
    {
      getblk( (u16)*d, 0);
      inces();
      ++d;
    }
  }
  /*******************************************************
  (5). Any errro condition, call error() in assembly.
  *******************************************************/
}