Advertisement
Guest User

Untitled

a guest
Nov 29th, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. - The code is a polling loop that will check the status register for BUSY_MASK.
  2. - If it is set, then the code will wait until STATUS_REGISTER returns to 0.
  3. - The two functions are called by ata_busy_poll and ata_device_ready respectively.- The code attempts to poll the status register for BUSY_MASK and DEVICE_READY_MASK.
  4.  
  5. - The while loop in ata_busy_poll() will cause it to be executed until STATUS_REGISTER & BUSY_MASK == 0, which means that the device is not busy.
  6. - The while loop in ata_devicereadywill cause it to be executed until STATUS REGISTER & DEVICE READY MASK == 0, which means that the device has been ready for a long enough time (in this case since its last read).- The code is reading a sector from the disk.
  7. - It starts by setting up a loop that will read 256 bytes, then it sets up another loop to read 5 sectors.
  8.  
  9. - The first thing the code does is set up an infinite loop that will run until it reads 256 bytes of data.
  10. - The second thing the code does is set up a for-loop that will run until it reads 5 sectors worth of data (256 * 5 = 1000).
  11.  
  12. - In both loops, there are two things happening:
  13.  
  14. - 1) ata_busy_poll() which tells us when we can start reading again; and 2) ata_drq_poll(), which tells us when we should stop reading so as not to miss any more data."}- The code is not actually doing anything.
  15.  
  16. - The code is not actually doing anything.- The code starts by sending the drive head register with 0xE0 for master.
  17. - This is followed by a bitwise operation that sets the last 4 bits of lba to 0xF0, which means it's set to read 256 sectors at once.
  18. - The code then sends a null byte to error register and sends the number of sectors in Count Register (s=256) to Sector Count Register.
  19.  
  20. - The code starts by sending the drive head register with 0xE0 for master.
  21. - This is followed by a bitwise operation that sets the last 4 bits of lba to 0xF0, which means it's set to read 256 sectors at once.
  22. - The code then sends a null byte to error register and sends the number of sectors in Count Register (s=256) to Sector Count Register.- The code attempts to set the head register of a drive to 0xE0, which is master.
  23. - The last 4 bits of the lba are then set to 0xF0, which means that it will be in LBA space (the lower 24 bits).
  24.  
  25. - Send to the drive-head-register, 0xE0 for master, then set the last 4 bits of the lba.
  26. - This register shares multiple values, so we do this here
  27.  
  28. - */
  29.  
  30. - outb(DRIVE_HEAD_REGISTER, 0xE0 | (0xF0 << 4) | ((lba >> 24) & 0x0F));
  31.  
  32. - // Send a null byte to error register as in- The code starts by setting the LBA_LO_REGISTER to 0x00.
  33. - This is done so that the first 8 bits of our LBA are set to 0, which means we're starting at sector 1.
  34. - Next, it sets the LBA_MI_REGISTER to 0x01 and then sends a read command with an address of 0x02.
  35. - The next line does this for sectors 2 through 4, sending commands with addresses of 0x03, 0x04, and finally ending on sector 5 where it sends a command with an address of 0xff.
  36.  
  37. - The code loops over each sector in turn until all sectors have been sent (i < sectors).
  38. - For each loop iteration i = 1; i <= n; i++ {
  39.  
  40. - Next eight bits: outb(LBA_MI_REGISTER, (uint8_t) (lba >> 8));
  41.  
  42. - Next eight bits: outb(LBA_HI_REGISTER, (uint8_t) lba);
  43.  
  44. - Send our read command: outb(COMMAND REGISTERSETREADSECTORSWITHRETRY); }- The code attempts to read the first sector of a hard drive.
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement