Simple Operating System
Start the project by following the instructions given in the resource website. To get a better understanding of the JOSH operating system, read the Tutorial written on JOSH by Dr. Mohan Raj Dhanagopal and fully understand its code.
From that Tutorial, you will understand that you do not have to edit the boot.asm to implement a new command.
Boot loader handles the loading of the kernel to the
memory. Therefore after the OS is loaded, the computer will be totally controlled by the kernel.
There will some problems when you making the image file for bootloader and kernel.use the .sh file in MikeOS which can convert bootloader and kernel to image file easily. Thenrun the JOSH OS in VirtualBox. shell implementation works for it.
http://mikeos.sourceforge.net/write-your-own-os.html
Then try to modify the kernel file to add new commands for displaying hardware information and help.
Hardware Information Command(CPU)
CPUID is a special command to get CPU details. When we set the EAX (EAX=0) to an initial value then it returns the CPU’s manufacturer ID string (a twelve character ASCII string stored in EBX, EDX, ECX — in that order)
Refer this online material.
- In CPU vendorID function,
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
- In CPU Type function,
mov eax, 0x80000002 ; get first part of the brand
cpuid
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
cpuid ; call cpuid command
mov [strcputype+32],eax
mov [strcputype+36],ebx
mov [strcputype+40],ecx
mov [strcputype+44],edx
mov si, strcputype ;print processor type
mov al, 0x01
int 0x21
ret
When “cpuid” is called with EAX=80000002h,80000003h,80000004h , we get the entire 48-byte null-terminated ASCII processor type string.Then save that string to strcputype and print using interrrupt 21.
Help Command
I use this to display the details of commands can be used within the shell.
In the help command, I used interrupt 21 methods to print 3 strings describing the commands as follows.
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
After adding new commands I copied the image file to the boot sector of my pen drive and boot with my operating system.
Here is the Screenshot of Edited version of JOSH operating System.
Github repository:
https://github.com/selvak7/Mike-OS-by-K7N.git
Refering Links:
https://medium.com/setublog/hands-on-to-operating-systems-a847e9dc75f7