What is TYRON JOSH OS ?
TYRON JOSH is a modified version of JOSH operating system in order to display the hardware information of the machine and it was implemented as an assignment for the module CS 2042-OPERATING SYSTEM.
The main issue in JOSH operating system is that it was implemented in order to boot from a floppy disk (FAT12 file format). But for this I followed following instructions to boot JOSH OS using a USB pen drive.
Linux Environment uses ordinary files format to represent various I/O devices and these files are in /dev directory and when an USB pen is plugged in, ansdb file and sdb1 file is created in /dev directory.
sdb -represents the device itself
sdb1 -primary partition on that device.
Procedure
Step 1-
Format the pen to FAT32 file system using following command.
1
| sudo /sbin/mkdosfs -F 32 -I /dev/sdb |
–F 32flag – causes the device to be formatted in FAT32 file system format
-Iflag -required to force direct formatting of the device file
FAT12 file format can handle disks minimum than 32MB. Because of that I failed to directly use the following command
-Iflag -required to force direct formatting of the device file
FAT12 file format can handle disks minimum than 32MB. Because of that I failed to directly use the following command
1
| sudo/sbin/mkdosfs -F 12 -I /dev/sdb |
Step 2-
Create a floppy disk image,
Create a floppy disk image,
1
| sudo dd if=/dev/zero bs=512 count=2880 of=./floppy.img |
Format the floppy image,
1
| sudo /sbin/mkdosfs –F 12 ./floppy.img |
Override thefloppy image to the USB pen,
1
| sudo dd if=./floppy.img of=/dev/sdc |
Put the boot binary file into the boot sector of the disk.
1
| sudo dd if=./boot.bin of=/dev/sdc |
Then I successfully booted the JOSH operating system using my USB drive.
There are two basic methods are using in assembly language to get the hardware information.
1. Use BIOS Service interrupts
2. Use special commands
In this implementation both two approaches are used and handling BIOS service interrupts is quite complex with comparing to the use special processor commands.
Approach
There are two basic methods are using in assembly language to get the hardware information.
1. Use BIOS Service interrupts
2. Use special commands
In this implementation both two approaches are used and handling BIOS service interrupts is quite complex with comparing to the use special processor commands.
1. Use BIOS Service interrupts
By using the BIOS interrupts we can get the hardware information which are stored in BIOS data area. Basically when we call an interrupt it will return the AX register with corresponding data.Ex: Print a word to the screen using BIOS interrupt 0x21, the following x86 assembly language instructions would be executed:
1
2
3
| mov si, strproserialmov al, 0x01int 0x21 |
There are two kinds of interrupts.
a. Processor interrupts
Interrupts 00h to 07h are called by the processor directly, but can also be called from software using the INT (int) instruction.
a. Processor interrupts
Interrupts 00h to 07h are called by the processor directly, but can also be called from software using the INT (int) instruction.
b. Hardware interrupts
The hardware interrupts differ from all the software interrupts. They have a direct channel to the processor thorough an Interrupt Request Line. The 8259 Programmable Interrupt Controller or PIC on the motherboard manages all the hardware interrupts.
We can use a special command to view processor details. These special commands are provided by the processor manufacturers. The CPUID (cpuid)command requires without any operand, but it takes an argument from the EAX register. Therefore we should store a value in EAX register before calling the CPUID command.
Ex: CPUID functions that return the basic processor information, the program should set the EAX register parameter value to “0”and then execute the CPUID instruction as follows:
The hardware interrupts differ from all the software interrupts. They have a direct channel to the processor thorough an Interrupt Request Line. The 8259 Programmable Interrupt Controller or PIC on the motherboard manages all the hardware interrupts.
2. Use special commands
We can use a special command to view processor details. These special commands are provided by the processor manufacturers. The CPUID (cpuid)command requires without any operand, but it takes an argument from the EAX register. Therefore we should store a value in EAX register before calling the CPUID command.
Ex: CPUID functions that return the basic processor information, the program should set the EAX register parameter value to “0”and then execute the CPUID instruction as follows:
1
2
| MOV EAX, 00hCPUID |
Methods that are implemented-
Display the hardware details separately.
1
2
3
4
5
6
7
8
9
10
11
| _cmd_displayHardwareInfo:call _display_endlmov si, strCPUIDmov al, 0x01int 0x21call _cmd_cpuVendorIDcall _cmd_ProcessorTypecall _cmd_ProcessorSerialNo;call _cmd_ProcessorFeature;call _cmd_MouseStatusret |
display the vendor ID of the processor
1
2
3
4
5
6
7
8
9
10
11
| _cmd_cpuVendorID:mov eax,0cpuid; call cpuid commandmov [strcpuid],ebx; load last stringmov [strcpuid+4],edx; load middle stringmov [strcpuid+8],ecx; load first stringcall _display_endlmov si, strcpuid;print CPU vender IDmov al, 0x01int 0x21ret |
This method is implemented using the special commands.

When we call cpuid method with value of 0 to the register EAX ,it returns vendor ID and return it as 12 bytes value and this values stores in EBX, EDX, ECX registers because these registers each is 32 bit. So first I declare a memory location by the reference strcpuid name with the size of 12 bytes.

When we call cpuid method with value of 0 to the register EAX ,it returns vendor ID and return it as 12 bytes value and this values stores in EBX, EDX, ECX registers because these registers each is 32 bit. So first I declare a memory location by the reference strcpuid name with the size of 12 bytes.
1
| strcpuidresb12 ;12 bytes for store vendor ID string |
Display the processor type, speed of the processor.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| _cmd_ProcessorType:mov eax,0x80000002cupid ; call cpuid commandmov [strcputype] ,eaxmov [strcputype+4] ,ebxmov [strcputype+8] ,ecxmov [strcputype+12],edxmov eax,0x80000003cpuid; call cpuid commandmov [strcputype+16],eaxmov [strcputype+20],ebxmov [strcputype+24],ecxmov [strcputype+28],edxmov eax,0x80000004cupid ; call cpuid commandmov [strcputype+32],eaxmov [strcputype+36],ebxmov [strcputype+40],ecxmov [strcputype+44],edxcall _display_endl;mov si, strProcessor;mov al, 0x01;int 0x21call _display_spacemov si, strcputype ;print processor typemov al, 0x01int 0x21ret |
Same as the above method when we call cpuid method with value of 0x80000002,0x80000003, 0x80000004 seperately to the register EAX ,it returns processor type and return it as 12bytesvalueand this values stores in EBX, EBX, ECX, EDX at each time that calls cpuid command. So first I declare a memory location by the reference strcputype name with the size of 48bytes.
1
| strcputype resb48 ; 48 bytes for store cpu type string |
Prints TRUE if a mouse is connected to the machine, if not it prints FALSE. This method is implemented using interrupt and BIOS data area.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| call _display_endlxor ax,ax ; clean out the AX register;mov si, strmouse;mov al, 0x01;int 0x21call _display_spacepush axpush dxint 33h ; call interrupt 33h function 0cmp ax,0ffffh ; compare AX and FFFFh (installed)jne _mouseAvailable ; if so Jump to print truejmp _mouseNotAvailable ; if notDisplay the word "false"ret_mouseAvailable: ;print 'true'mov si, strmousetruemov al, 0x01int 0x21ret<_mouseNotAvailable: ;print ‘false’mov si, strmousefalsemov al, 0x01int 0x21ret_cmd_callHelp:call _display_endlmov si, strCmd0mov di, cmdHelpmov cx, 5repecmpsb;jne_cmd_verjne_cmd_exitcall cmd_displayHelpMenucall _display_endljmp _cmd_done |
Prints the help menu,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| cmd_displayHelpMenu:call _display_endlmov si, strHelpMsg0;print help messagemov al, 0x01int 0x21call _display_endlmov si, strHelpMsg1mov al, 0x01int 0x21call _display_endlmov si, strHelpMsg2mov al, 0x01int 0x21call _display_endlmov si, strHelpMsg3mov al, 0x01int 0x21ret |



No comments:
Post a Comment