Hi, in this lecture. We will add some new stuff in the boot file. As you see, this is our boot file
we just write in the last video.
What we are going to do first is we are going to test disk extension service.
Because we need to load our kernel from disk to the memory and jump to the kernel.
We know that we use BIOS disk services to load our file from disk in boot process.
When we read file from disk, we should provide CHS value in order to locate the sector we want to read.
And using chs value requires extra calculation.
To make our boot file simple, we choose logical block address which disk extension service
use to access the disk.
Modern computers should support the extension service, but we will check it anyway.
To check for this service is really simple.
First off, we define a label
called test.
disk extension.
The parameters we should pass includes
save 41 in register ah,
55AA in bx.
Also note that dl holds the drive id when BIOS transfers control to our boot code.
Since we will call disk service more than once later in the boot process, and we need to pass the drive id
to dl register before we call the disk service like we do here.
So we define a variable called driveid
And save the value of dl to variable driveid
Because we want to write the value into the memory location the driveid represents
So here we use square brackets to access the location.
Then we can call interrupt 13
.
If the services is not supported, the carry flag is set. So we use jc instruction
which will jump to label not support if carry flag is set.
Let�s define the label not support. We simply place the label at the end of our code.
The label end and not support represent the same address which is the address of hlt instruction.
So if it is not supported, we just jump to the end and end our program.
If it passed the test,
we compare bx with the value AA55.
If bx is not equal to AA55, it means that extension service is not supported.
Similarly, we jump to not support.
We use jne instruction.
which is jump, if not equal.
Before we build our project, there is another change we need to do. When our computer support the extension service,
what we want to do is print extension support message on the screen.
So we change the message
to disk extension is supported.
By the way, there is no need to change the message length because $ represents the end of string
in this case and the message represents the start of the string.
So the message length is automatically adjusted to the correct value.
OK, let's build our project.
We open the terminal and run the built script.
The binary file is written into the image file. Now we can open the bochs
by double clicking it.
If everything goes as expected, we will see disk extension is supported on screen.
Here is a test on the real machine which supports the service, don't forget to write the boot image to
USB flash drive before you boot the computer.
If there is no message showing up on your real machine, you can run the programs on virtual machine
bochs should support the extension service.
In the next video, we will load another file called loader file
See you in the next lecture.