CptS Lab1 - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

CptS Lab1

Description:

How to find /boot/mtx. Call getBlock(5, buf), the second inode in buf is root ... Search for boot directory, return boot's inode no. ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 7
Provided by: eecs8
Category:
Tags: cpts | boot | lab1

less

Transcript and Presenter's Notes

Title: CptS Lab1


1
CptS Lab1
  • Jiong Wang

2
Program logic
  • Clear screen and home cursor
  • Prompt for a file name to boot, and read in the
    filename (e.g. /boot/mtx)
  • Locate the file's inode, hence its disk blocks
  • Load the file's blocks to the segment 0x1000
  • return 0 if no error, else return 1

3
How to load blocks into memory
  • Write a function in C
  • getBlock(b_no, buf)
  • In your function, do following steps
  • Convert a blocks logic address (b_no) to its
    physical address (cyl, head, sector)
  • Call function diskr(cyl, head, sector, buf)
  • Reminder
  • cyl, head, and sector all start from 0
  • Make sure ES is correct before calling getBlock()

4
Convert b_no to CHS
  • Define CYLSIZE 36
  • Define trackSIZE 16
  • startSector 2blk
  • cyl startSector/CYLSIZE
  • head (startSector CYLSIZE) / trackSIZE
  • sector (startSector CYLSIZE) trackSIZE

5
How to find /boot/mtx
  • Call getBlock(5, buf), the second inode in buf is
    root
  • In roots inode, find roots first data block
    (i_block0)
  • Call getBlock(i_block0, buf)
  • Search for boot directory, return boots inode
    no.
  • Find the blk_no of boots inode and the position
    of boots inode in that blk (inode starts from 1)
  • Call getBlock(blk_no, buf), locate boots inode
    in the buf
  • Repeat the same steps to find MTXs inode

6
Load os to memery
  • You obtained MTXs innode in buf1
  • Load indirect block into buf2
  • Load first double indirect block into buf3
  • Set ES to 0x1000
  • getBlock(blk, 0)
  • inces()
  • Repeat until MTX has been loaded into memory
    completely
Write a Comment
User Comments (0)
About PowerShow.com