Page 1 of 2

Running Mikeos on a *real* 8086

Posted: Thu Apr 19, 2012 12:53 pm
by Burik
Hey there, this is my first post here. I am the proud owner of an Olivetti M24 [8086 CPU, 640k RAM, 20Mb HDD] and I'd like to run Mikeos on it. Too bad its 3.5" drive can't read anything above 720K floppies, hence I have to modify the bootloader according to 720K specs. Original bootloader as follows:

Code: Select all

*snip*
; Values are those used by IBM for 1.44 MB, 3.5" diskette
 23 
 24 OEMLabel                db "MIKEBOOT"   ; Disk label
 25 BytesPerSector          dw 512          ; Bytes per sector
 26 SectorsPerCluster       db 1            ; Sectors per cluster
 27 ReservedForBoot         dw 1            ; Reserved sectors for boot record
 28 NumberOfFats            db 2            ; Number of copies of the FAT
 29 RootDirEntries          dw 224          ; Number of entries in root dir
 30                                         ; (224 * 32 = 7168 = 14 sectors to read)
 31 LogicalSectors          dw 2880         ; Number of logical sectors
 32 MediumByte              db 0F0h         ; Medium descriptor byte
 33 SectorsPerFat           dw 9            ; Sectors per FAT
 34 SectorsPerTrack         dw 18           ; Sectors per track (36/cylinder)
 35 Sides                   dw 2            ; Number of sides/heads
 36 HiddenSectors           dd 0            ; Number of hidden sectors
 37 LargeSectors            dd 0            ; Number of LBA sectors
 38 DriveNo                 dw 0            ; Drive No: 0
 39 Signature               db 41           ; Drive signature: 41 for floppy
 40 VolumeID                dd 00000000h    ; Volume ID: any number
 41 VolumeLabel             db "MIKEOS     "; Volume Label: any 11 chars
 42 FileSystem              db "FAT12   "   ; File system type: don't change!
 43 
*snip*
Too bad I'um unable to find the correct values for a 720K floppy.. I tried 1440 for LogicalSectors, 9 for SectorsPerTrack and F9 for MediumByte and I've basically destroyed the FAT :|

Any help?

Re: Running Mikeos on a *real* 8086

Posted: Thu Apr 19, 2012 1:46 pm
by bubach
Those values you mention is right, but a 720kb floppy with FAT12 also uses 1kb cluster values, while 1.44mb floppies use 512byte. This might break MikeOS FAT-driver if it's not done right to account for different cluster sizes. Try setting "SectorsPerCluster db 2". It will however take some serious FAT hacking in a hex editor to convert the values inside the actual FAT for the files needed at boot. Maybe you could find software to deal with 720kb floppies, or is the 1.44mb drives incompatible with older floppy sizes?

Re: Running Mikeos on a *real* 8086

Posted: Thu Apr 19, 2012 3:55 pm
by Burik
Thanks for your reply, I gave "SectorsPerCluster db 2" a try with no luck, the bootdisk can't boot neither the M24 or my main PC. On my Linux box equipped with a 1.44mb drive I'm able to mount the 720K disk and list its contents, the disk itself looks fine. On the M24 running MSDOS5.0 I can't even read the disk. I'm going to take a look at the FAT driver and see if I can accomodate it to the new cluster size.

Re: Running Mikeos on a *real* 8086

Posted: Thu Apr 19, 2012 4:43 pm
by Rudster816
I cant find any part of the OS that uses 32 bit registers, but according to the download page, Mikeos requires a 386 with 1MB of RAM.

http://mikeos.berlios.de/#downloads

Re: Running Mikeos on a *real* 8086

Posted: Thu Apr 19, 2012 7:00 pm
by Senqo
It requires at least a 386 because the FS and GS segment registers are used.

Re: Running Mikeos on a *real* 8086

Posted: Thu Apr 19, 2012 7:35 pm
by bubach
wow, thats stupid. i mean it's a real mode OS ffs :P how hard could it be to live without fs and gs? make do.

Re: Running Mikeos on a *real* 8086

Posted: Fri Apr 20, 2012 11:33 am
by Burik
haha, I guess this settle things once and for all, I admit I didn't even read the kernel source, thanks guys.

Code: Select all

*snip*
123         mov fs, ax                      ; live entirely in 64K
124         mov gs, ax
*snip*

Re: Running Mikeos on a *real* 8086

Posted: Mon Apr 23, 2012 6:47 am
by M-Saunders
Delete those two lines and try it. I've never had access to anything pre-386 to try it on, hence why I said that was a minimum, just to be sure. But take out those two lines referring to GS and FS and see how it works.

M

Re: Running Mikeos on a *real* 8086

Posted: Tue Apr 24, 2012 3:37 am
by amd64pager
What about access to this?

Re: Running Mikeos on a *real* 8086

Posted: Tue Apr 24, 2012 1:59 pm
by Kazinsal
There are also lines of code in areas such as the FAT12 driver that (if I remember correctly) reference 32-bit registers, usually to clear EAX.

What you could do is use the "CPU 8086" NASM directive to instruct the parser to error out on any post-8086 instructions. Then you'll know where everything potentially-offending is.

Re: Running Mikeos on a *real* 8086

Posted: Tue Apr 24, 2012 3:59 pm
by Burik
M-Saunders wrote:Delete those two lines and try it. I've never had access to anything pre-386 to try it on, hence why I said that was a minimum, just to be sure. But take out those two lines referring to GS and FS and see how it works.

M
Will do. I've little spare time atm but I'll surely keep you updated.

And Blacklight, thanks for the tip.

Re: Running Mikeos on a *real* 8086

Posted: Sun Apr 29, 2012 4:57 am
by Burik
I am as stuck as a fly on flypaper :|

According to the always trustworthy PC Hardware Book, the disk description table for a 720Kb, 3.5" disk should be as follows:

Code: Select all

OEMLabel                db "MIKEBOOT"
BytesPerSector          dw 512
SectorsPerCluster       db 2            ; 1 for 1.44Mb disk
ReservedForBoot         dw 1
NumberOfFats            db 2
RootDirEntries          dw 112          ; 224 for 1.44Mb disk
LogicalSectors          dw 1440         ; 2880 for 1.44Mb disk
MediumByte              db 0F9h         ; 0F0h for 1.44Mb disk
SectorsPerFat           dw 9
SectorsPerTrack         dw 9            ; 18 for 1.44Mb disk
Sides                   dw 2
HiddenSectors           dd 0
LargeSectors            dd 0
DriveNo                 dw 0
Signature               db 41
VolumeID                dd 00000000h
VolumeLabel             db "MIKEOS     "
FileSystem              db "FAT12   "
I also changed the floppy_ok routine according to the new values:

Code: Select all

floppy_ok:
       mov ax, 19
       call l2hts

       mov si, buffer
       mov bx, ds
       mov es, bx
       mov bx, si

       mov ah, 2
       mov al, 7                      ; Read 7 sectors [14 for 1.44Mb disk]
       pusha
And I'm building the 720K image this way:

mkdosfs -C -F 12 -r 112 -s 2 -S 512 -v disk_images/mikeos720.flp 720

Too bad the kernel.bin check in the next_root_entry routine fails miserably with the "kernel.bin not found" message, way before the FAT is read into RAM. I can't for the life of me figure out what I'm doing wrong.

Re: Running Mikeos on a *real* 8086

Posted: Fri May 04, 2012 1:48 pm
by JuEeHa
If I remember correctly 8086 didn't have pusha/popa opcodes. Try manualy pushing all registers.

Re: Running Mikeos on a *real* 8086

Posted: Fri May 04, 2012 4:12 pm
by Burik
OMG you're damn right, I didn't even think about that. Too bad manually pushing and popping the registers increases the boot sector size to over 600 bytes, I'll try to cut out the non-essential stuff and see how it goes.

Re: Running Mikeos on a *real* 8086

Posted: Fri May 04, 2012 7:23 pm
by ACcurrent
Intel manual states that they were added in 286. (Volume 3A 17-5)