‫Hello and welcome to this lecture.
‫In the last lecture, we implement their pages, set pages in the page tables, we are now going to
‫implement the desk functionality so that we go to the booth Dadaism file.
‫We can see that we previously wrote a routine that could read from the desk.
‫We are now going to write the same in the C programming language.
‫So the first thing I want you to do is go to the source directory and we are going to create a new folder
‫and we're going to call it desk.
‫So we're now going to create a new file in the disk directory and we're going to call it desktop C,
‫OK?
‫And I'll follow what I'm doing.
‫We're going to create a function called Desk Read Sector, and we're just going to go in a desk sector
‫and it'll be A.
‫S logical block address that we want to read from and how we're going to go in it.
‫So this is the total number of blocks to reap from that LBA.
‫And then finally, we're going to have pointed to the buffer where we load that data to and we're just
‫going to return zero here, which means everything went OK.
‫And we're now going to start implementing the functionality that reads from the desk.
‫So we're going to do is we're going to include Eyo Forward, slash Ayodeji each, and that'll give us
‫access to the Outby and the Inbee instructions.
‫And we're just going to simply go out be Xerox one F six lba shifted to the right by twenty four bits
‫and then we're going to operate with zero X e0.
‫So when are we going to go out be zero x one, F two total outby zero x one F three, and then we're
‫going to go and unsign Char.
‫We're going to do a cashier lba ampersands zero x f.
‫OK, now I know, I know it's probably getting a little bit confusing, but if you check back at the
‫boot lecture, I explain this as I'm going along, essentially these are the parts we need to output
‫data to.
‫We need to output the LBA and the total to these parts.
‫And then we can then later initialize a read which would allow us to read from the disk, essentially.
‫So we're now going to go out be zero x one ashfall unsigned char, we're going to do another cast.
‫LBA shifted to the right by a bit.
‫So we're now going to go outby zero x one f five unsigned char.
‫LBA shifted to the right by 16.
‫And now we're going to go out Xbox One, F seven, Xbox Twenty.
‫And before we continue, let me just show you this this document here, right?
‫OS dev.
‫Atay.
‫And, you know, you can see here, you know, essentially making this making what we made in the boot
‫lecture, but we're making it in see.
‫Right.
‫And you can find all of the comments here, essentially, right?
‫So this is what's going on.
‫OK.
‫So we're just outputting bikes to those parts to instruct the disk controller with that, we want to
‫read from it.
‫OK, OK, let's continue.
‫OK, so we're now going to go and assign shots.
‫PTI equals unsigned shots, so we're doing our punch Carsia to the buffer.
‫Right.
‫And the reason for this is because we're going to read two bytes at a time from the disk controller,
‫not one bite at a time.
‫Right.
‫So we're going to go for it should be zero B below bippolo total B plus plus.
‫OK.
‫And I would just compare a little common way for the buffer to be ready.
‫So when I go in a loop until the buffer is ready for us to read from essentially.
‫Right.
‫So we're going to go see equals in speed and we're going to read one bite from the next one, F seven.
‫OK, so again, the Outby will write to the part on the on the on the on the bus, OK.
‫And the hardware will listen for that right in B here.
‫We're going to read from the bus from this port.
‫So all happen is when we make a read like this, the hardware in the computer will send a bike to us
‫and that's what we read here.
‫OK, and there's the part no we're reading from.
‫So what we're going to say is, is, well, see ampersand zero zero eight.
‫So we're just checking for a flag here, OK?
‫And these these numbers are a little bit magic.
‫But, you know, let's go through this and we'll have something we can read from.
‫So we're now going to go see cuisine's B zero x one, F seven.
‫OK, so this will just wait essentially until that bit in the pit mask is set and then we can finally
‫leave the slope.
‫OK, so at this point in time when I'm ready to read from the controller, so we're just going to go
‫comment copy from hard disk to memory, because that's exactly what we're going to do now.
‫And we'll get a girlfriend IQ zero eight below 256 EI plus plus we're going to go ask Chris Point because
‫we're changing point to the value that the point is pointing at now equals NSW, because we're reading
‫a word two bytes zero one zero.
‫OK, so that'll be two bytes for us into our buffer here that they pass to us.
‫Right.
‫And obviously we've casted it to an unsigned choke point here.
‫So we're changing two bytes at a time and then we're just going to go pointer plus plus.
‫OK, and that is it for the actual discrete sector function, this will read from the primary desk,
‫not the secondary, but nevertheless this is pretty decent.
‫OK, so we're now going to test this now.
‫So let's create a new file called This Stage and which is going to set that up properly.
‫And we're going to go the distance, see, and we're going to copy and paste this function into the
‫header file as so.
‫Now that's going to make file and we are going to actually build that.
‫OK, so we're just going to go double slash build desk desks, dot o dot sauce, desk, desk dot, see,
‫and we're going to copy and paste this come here and we're just going to change it.
‫So we're going to go source desk.
‫Source desk, desktop C and I will be.
‫Build disc disc Dotto.
‫Now we're just going to copy and paste build this STUTO and we're going to put it at the top here with
‫the requirements.
‫OK, now if we just make clean and we build that again, we see no such file directory.
‫That's because we need to create the directory in the directory called disk.
‫So just do that, create a directory in build called disk.
‫And then if you now run that again and we see under undefined reference to NSW.
‫OK, so if we just go to iodized here and I can see the problem straight away, there's been a little
‫typo here.
‫You see NSW s it should actually be NSW, right.
‫Because we want to export this symbol here, NSW.
‫So if we now change that from NSW to NSW press control, that's to say we now build now we can see everything
‫works just as expected.
‫OK, so we are now able to test that rerouting.
‫So we're going to do that now.
‫OK, so to test this, we've got to kernel that C we're going to go to the very top.
‫We're going to include disk distortion.
‫And now down here we're going to give it to this paging test.
‫We did.
‫We don't need that now.
‫And also get rid of this one here, guys, OK?
‫And we're just going to go in here and we're going to we're going to go chop off five, 12, OK, and
‫we're just going to go discrete sector and we're going to go LBA zero because we want to read the very
‫first sector on the desk.
‫We're going to be one sector and we're going to read it into both, OK?
‫And now if we now do make clean build that S.H. CD been gdb, OK, because we're going to we're going
‫to actually bag this so we can see the Buffa contents and we're going to go out simbel file dot dot
‫backslash build's.
‫Colonel Foldes, although zero one one, two, three, four, five, five zeros we're going to press.
‫Yes.
‫That's not loaded.
‫The symbols we're going to break on Colonel Dot see a line 99 and then we're going to go target remotes
‫and we're going to pipe that out.
‫Kumu Dash System Dashi three eight six dash hda top forward slash ozalp in dash capitalist's dash gdb
‫stadio.
‫I was just press enter.
‫OK, and now this a launch Qumu and we're going to go see to continue, we can see it's now broke here.
‫We're going to go next and we're going to print Baff.
‫And there we go, we can see it has successfully read into the buffer, OK?
‫And just to demonstrate that, again, if we go print unsigned char and we go puff zero, here, we
‫see two, three, five.
‫OK, if we now open up, bless Osama bin WAPs.
‫Typo that guy's.
‫Blessed are Ben, and we click the very first by what do we see unsigned, a bed, two, three, five,
‫so we can see that our routine has now been successfully implemented.
‫Excellent.