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, strproserial mov al, 0x01 int 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, 00h CPUID |
Methods that are implemented-
Display the hardware details separately.
1
2
3
4
5
6
7
8
9
10
11
| _cmd_displayHardwareInfo: call _display_endl mov si, strCPUID mov al, 0x01 int 0x21 call _cmd_cpuVendorID call _cmd_ProcessorType call _cmd_ProcessorSerialNo ;call _cmd_ProcessorFeature ;call _cmd_MouseStatus ret |
display the vendor ID of the processor
1
2
3
4
5
6
7
8
9
10
11
| _cmd_cpuVendorID: mov eax,0 cpuid; call cpuid command mov [strcpuid],ebx; load last string mov [strcpuid+4],edx; load middle string mov [strcpuid+8],ecx; load first string call _display_endl mov si, strcpuid;print CPU vender ID mov al, 0x01 int 0x21 ret |
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,0x80000002 cupid ; call cpuid command mov [strcputype] ,eax mov [strcputype+4] ,ebx mov [strcputype+8] ,ecx mov [strcputype+12],edx mov eax,0x80000003 cpuid; call cpuid command mov [strcputype+16],eax mov [strcputype+20],ebx mov [strcputype+24],ecx mov [strcputype+28],edx mov eax,0x80000004 cupid ; call cpuid command mov [strcputype+32],eax mov [strcputype+36],ebx mov [strcputype+40],ecx mov [strcputype+44],edx call _display_endl ;mov si, strProcessor ;mov al, 0x01 ;int 0x21 call _display_space mov si, strcputype ;print processor type mov al, 0x01 int 0x21 ret |
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_endl xor ax,ax ; clean out the AX register ;mov si, strmouse ;mov al, 0x01 ;int 0x21 call _display_space push ax push dx int 33h ; call interrupt 33h function 0 cmp ax,0ffffh ; compare AX and FFFFh (installed) jne _mouseAvailable ; if so Jump to print true jmp _mouseNotAvailable ; if notDisplay the word "false" ret _mouseAvailable: ;print 'true' mov si, strmousetrue mov al, 0x01 int 0x21 ret< _mouseNotAvailable: ;print ‘false’ mov si, strmousefalse mov al, 0x01 int 0x21 ret _cmd_callHelp: call _display_endl mov si, strCmd0 mov di, cmdHelp mov cx, 5 repecmpsb ;jne_cmd_ver jne_cmd_exit call cmd_displayHelpMenu call _display_endl jmp _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_endl mov si, strHelpMsg0;print help message mov al, 0x01 int 0x21 call _display_endl mov si, strHelpMsg1 mov al, 0x01 int 0x21 call _display_endl mov si, strHelpMsg2 mov al, 0x01 int 0x21 call _display_endl mov si, strHelpMsg3 mov al, 0x01 int 0x21 ret |
No comments:
Post a Comment