An Extension to JOSH

Neminda Prabhashwara
6 min readJul 25, 2020

This will lead you to develop a simple operating system that displays your machine’s hardware information.

An excellent operating system to help you understand the PC better is JOSH. I added an extension to this single tasking interrupt driven operating system which enables it to display the hardware information of the PC.

JOSH is designed to boot from a floppy disk. So we can boot JOSH from using a floppy disk image, and if you want we can burn the boot part and the kernel part of JOSH to an iso image. I’ll give a detailed explanation about how to achieve displaying hardware information and how to create this virtual floppy image.

JOSH has two files one is the bootstrap loader and the other one is the kernel which actually is the operating system itself.

As JOSH implementer done his part with designing the bootstrap loader and designing an interrupt driven kernel along with a shell, what we have to do is implement methods to display hardware information.

As I found there are two ways to achieve this.

First method:- Use BIOS data area to get the hardware information stored in there

Second method:- Use special commands

Using the BIOS data area

There are two ways to get the data stored in the BIOS data area

1.Using the BIOS service interrupts

There are various ways to use the BIOS interrupts to get related details. We should provide them the requiring parameters and it will return the corresponding data to our registers.

About return values:- the storing register for the return value depends on the size of the value.

ex:- if it is an 8-bit value it stored in the AL register, if it is a 16-bit value it is stored in the AX register, and so on.

For an example we can use the int 0x11 interrupt to get the dma status you can use the following interrupt

interrupt signal code for dma status
interrupt signal code for dma status check

likewise you can get related data for your task by using interrupts. This would provide you with all the necessary interrupt details.

Below are the subroutines that I created to display hardware information.

Memory info subroutine part 1
memory info subroutine part 1
memory info subroutine part 2
memory info subroutine part 2
video mode displaying subroutine
video mode displaying subroutine
serial ports displaying subroutine
serial ports displaying subroutine
printer ports displaying subroutine
printer ports displaying subroutine
pointing device checking and floppy disk status checking subroutines
pointing device checking and floppy disk status checking subroutines

2. Using BIOS Data area and access it using the offset

Although we can get data using interrupts, it’s better to use the alternative method too. BIOS data area is created at memory location 0x0040:0000h. This data area can be accessed by setting the relevant offset where the required data is.

For an example to get available hard disk drives we can set the AX register to 0x0040 and set the AL register with a 0x0075 offset then required data would be available at the AL register.

BIOS data area code for getting the available hard disk drive information
BIOS data area code for getting the available hard disk drive information

With this concept you can all the required data. This would provide you the BIOS data area offsets required to get the necessary data.

Using special commands

cpuid command used to get processor details
cpuid command used to get processor details.

The special commands are supplied by the processor manufactures. The cpuid command requires no operands, but takes arguments from the EAX register.

By providing necessary arguments at EAX you can get cpu details.

As you can see the numerous arguments used at each cpuid command and how the return values are stored at EAX, EBX, ECX and EDX registers.

Now we are done with our hardware displaying implementation, what we have to do is provide a help menu and a command at the shell to type to display hardware information.

Adding the system commands to display hardware and command list
Adding the system commands to display hardware and command list

After this you have to done this you can have to add your desired command strings to the .data section.

Then you can compile the kernel.asm file with NASM withnew features.

JOSH version 0.04 displaying the hardware information
JOSH version 0.04 displaying the hardware information

I implemented subroutines for displaying hardware using all the techniques that I described above. You can see what are the implemented subroutines from the left side screenshot.

Creating the virtual floppy disk image

You need to have a linux operating system to create the disk image. I’ll describe the creation of this step by step.

Create the floppy disk image by using, these steps

First open the terminal in your home directory and head to media directory and create a directory in there.

~$ cd /media/media$ sudo mkdir floppy

Now go back to home directory and create the floppy image by using,

~$ mkfs.msdos -C myfloppy.img 1440

Now mount the floppy image by using,

~$ sudo mount -o loop myfloppy.img /media/floppy

Now open the terminal from the folder where your boot.bin file and the kernel.bin files are. Now get the mounted disk name by the following command (for me it was loop0, it could be whole another number for you. Locate the name by checking a disk which has 1.5M size.),

/os$ lsblk

Then burn the boot.bin file to the master boot record (MBR) of the floppy image by using,

/os$ sudo dd if=./boot.bin of=/dev/loop0

Now copy the kernel.bin file to the floppy disk by using,

/os$ sudo cp kernel.bin /media/floppy/

Now unmount the disk from the home terminal and delete the created directory in /media directory by using,

~$ sudo umount /media/floppy
~$ sudo rm -rf /media/floppy/

Now that’s it you have done the work. Finally all you have to do is, run the floppy image in the virtual machine and it will display your PC’s hardware information.

--

--

Neminda Prabhashwara

Software engineering undergraduate, University of Kelaniya Sri Lanka