meet this criteria ?
1. On bynary plain ( its not the source ).
2. Free.
3. Auto Switch to Pmode.
4. Auto read sector 2 ( after Pmode switch ).

So I can easyly made a kernel and place it to sector 2 on my disket.
:alright:
Posted on 2003-06-03 03:29:09 by realvampire
Use a little tweaked SOLAR OS boot.bin file ?

i actually read more that one sector starting from sector 2 upwards

check the sourcecode of boot.asm and learn where to place your kernel, aka replace system32.bin with your own kerner or even replace system16.bin...

or i could write one for you in a few hours, eh ....minutes but i am lazy :P
Posted on 2003-06-03 15:57:42 by BogdanOntanu
Please write it for me. Im failed to studied it. My system now 1.7 Ghz Prosesor. Is it all the same ?
Im just woke from sleep, it still morning here.
Posted on 2003-06-03 16:01:26 by realvampire
Afternoon, realvampire.

Have a look at:
http://osdev.neopages.net/tutorials/brunmar/tutorial_01.php
http://osdev.neopages.net/tutorials/brunmar/tutorial_02.php

Reading those pages, as well as having a look at SolarOS, will be all you need for what you want.

When you decide to expand on your code, then take a look at the other tuts on:
http://osdev.neopages.net/tutorials.php

Also:
Which assembler are you coding this in?
Bogdans code is in Tasm.
It's illegal to use Masm for coding anything non-Windows.
I'm using Fasm.

Are you going to build the kernal in C or assembly?

Plus:
If you wish to use VESA vid modes in PMode, then you've really got to grab the info *before* switching to PMode (i.e. call int 10h inside 16-bit code).

If you just want to muck about with the default text-mode, then the first two links I gave are all you need.

Cheers,
Scronty
Posted on 2003-06-03 18:03:46 by Scronty
Thanks for the link. I found Bosch Emulator here. Im gonna try it.
Posted on 2003-06-05 06:59:16 by realvampire
Afternoon, realvampire.

Regarding Bochs:

It's great for when you're mucking about with a text-based or VGA-based OS, however it falls down when mucking about with VESA2 stuff (i.e. using 800*600*24bit vid mode).

For testing your basic bootloader code, it's ideal:alright: .

Cheers,
Scronty
Posted on 2003-06-05 16:59:37 by Scronty
How to use it ? to which directory I must copy my Boot loader ? And how to tell the emulator to load it. Thanks

My GDT is located at Mem 0000:8000. My Gdt info are



GDTr:
dw 1Fh ; Limit are 0x20 - 1. So there are 4 Ent.
dd 8000 ; Located at Linier address 00008000

and load GDT like This:
xor ax,ax
mov ds,ax
mov ax,8000
lgdt ds:[ax]





Is it Right ?
Posted on 2003-06-05 18:44:55 by realvampire
personally i think its not nessecary to switch to pm in the bootloader. furthermore you'll have very little space for your gdt. in my system i have just the copying from disk in my bootloader and the jumping to the code.
i think you've aleady asked for your problem somewhen else. you tell the cpu that the gdt is located at 0000:8000 - but do you know what there's in the memory? you just load the gdtr with an address. you must have at least a complete gdt in your code containing a null-selector, a code-selector, a data-selector and a stack-selector. before you load the gdtr you have to copy this gdt to 0000:8000 (->rep movsd), then you load the gdtr.
hope this helps
Posted on 2003-06-06 13:29:59 by hartyl
Yes I have it





jmp start ; Skip GDT data loaded at 0000:7c00

GDTinfo: ; Jmp instruction need 2 bytes. It at 0000:7c02
dw 001f
dd 7c08

GDTnull : ; It at 0000:7c08
dd 0
dd 0
GDTlin :
dw FFFF
dw 0
dw 9a00
dw cf
GDTdat:
dw FFFF
dw 0
dw 9200
dw cf

start:
lgdt [GDTinfo]



I think it was right. But it still Restarted. I upload the bin file.
Posted on 2003-06-07 06:31:54 by realvampire
weired code here... i don't get it.
after the lmsw-command the cpu executes the instructions in 32bit mode. also after this you should make a far intersegmented jump - to set cs:eip at once - the nop-s are not enough! (jmp 0008:00dac0de where 0008 is the code-selector). btw, i coudn't find a code-selector in your gdt.
Posted on 2003-06-07 12:05:20 by hartyl
Thank you for answering. So my GDT dont have a code selector? I dont understand it. can you explain the solution. I have read a lot of tutorial about it, but never could to do it. :alright:

Null selector are at CS:IP + Fh.
Code selector are at CS:IP + 17h.
Data Selector are at CS+IP + 1Fh.

GDTdesc are at CS:IP + 9h. 001f:FFFFFF and will be modified to linear address of program, where it loaded.

Jmp far code need 5 bytes at Real mode and 7 bytes at Pmode. the 5 nop will be changed to EA xx xx xx xx 08 00. A function at CS:IP +61d will modified it.
Posted on 2003-06-07 16:41:07 by realvampire
heh, i've just noticed that you don't even have an idt (interrupt descriptor table), you'll need it. i also have to tell you that an idt is very big - you won't have enough space for it in your 512-bytes-bootloader, that's why i think it's not nessecary to switch to pm in bootloader.

there are several things i don't understand in your code:


:0001.005C E8FAFF call 0059 ;here you get the ip
:0001.005F 8BD8 mov bx, ax
:0001.0061 0F01E0 smsw ax
:0001.0064 A801 test al, 01 ;check for pm
:0001.0066 7401 je 0069
:0001.0068 C3 ret



* Referenced by a (U)nconditional or (C)onditional Jump at Address:
|:0001.0066(C)
|
:0001.0069 8BC3 mov ax, bx ;but here... you move the ip to ax
:0001.006B 81E300FF and bx, FF00 ;and mask out the lower byte?
:0001.006F 8BEB mov bp, bx ;save it in bp?
:0001.0071 8CD8 mov ax, ds
:0001.0073 66C1E004 shl eax, 04 ;then you seem to calculate a linear address...
:0001.0077 6603C5 add eax, ebp ;of you gdt?
:0001.007A 6683C00F add eax, 0000000F
:0001.007E 8BF5 mov si, bp
:0001.0080 83C60B add si, 000B
:0001.0083 668904 mov [si], eax

then after reading from disk:


:0001.00C0 8BC5 mov ax, bp
:0001.00C2 83C02F add ax, 002F
:0001.00C5 FFD0 call ax ;where do you call to?!
:0001.00C7 8BF5 mov si, bp ;you get this calculated address again
:0001.00C9 83C603 add si, 0003
:0001.00CC 83C606 add si, 0006
:0001.00CF 0F0114 lgdt [si] ;and load the gdtr from there?

i don't think that you get the correct gdtr in the end. since you have no idt you'll have a triple fault and that's why the computer resets. if you really want me to help you, please post the sourcecode, it's hard work digging in the binary.
Posted on 2003-06-08 04:57:17 by hartyl
Im happy you willing to help me help me. Yes, IP are saved to BP. it called a Function at 7c2f, that function are check key function. GDT are located at offset 9. So by put IP and then add it with 9 we are get the GDT. Function after read the Disk are used to Wait Key.


Also, I take A20 Enable Bit from your code.



about:
mov ax bp

Yes, it was a useless instruction.
I forgot to remove it. Compile it with my compiler.
It gonna be painfull checking my source code.


I dont know, the tutorial said IDT was not too important, it was optional.
But IDT descriptor are located after next instruction. If you compiled the source code, it will not work. I have fix my compiler and have not upload it. So, compile it with DDEB.exe
Posted on 2003-06-08 05:27:32 by realvampire
one thing i noticed: you know that your code will be loaded at 0000:7c00, so you even know at assemblertime the address of your gdt. you know where you will load your code to (0000:8000) and therefore you can use fixed values in the gdt:



jmp 59 ;2 bytes
gdtr:
dw 20 ;the gdtr, limit: 20, address 7c08 (physical address of gdt)
dd 00007c08

;null descriptor (0000)
dw 0
dw 0
db 0
db 0
db 0
db 0

;code descriptor (0008)
dw 0xffff ; limit 4gb limit
dw 8000 ;base: 00008000
db 00
db PRESENT or TYPE_DATA_CODE or RING0 or CODE_SEGMENT or EXECUTE_READ ;attributes, look up the equivalent bits
db 0x0f or PAGE_GRANULARITY or BIG_BIT
db 00

;data descriptor (0010)
dw 0xffff ; limit 4gb limit
dw 8000 ;base: 00008000
db 00
db PRESENT or TYPE_DATA_CODE or RING0 or DATA_SEGMENT or READ_WRITE
db 0x0f or PAGE_GRANULARITY or BIG_BIT
db 00

;--==please check the values==--


for loading the gdtr you can:


mov si,gdtr
lgdt [si]


after


smsw ax ; Machine status Word
or al,1 ;
lmsw ax ;

you have to load all registers with descriptor values. set cs:eip with the far jump i mentioned. then load ds, ss, gs, es with the data-descriptor (remember to set esp correctly, not that you mess the thing up).
Posted on 2003-06-08 13:03:13 by hartyl
Here is a nice boot sector:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/uuu/uuu/src/boot/eks_boot/boot.asm?rev=1.1&content-type=text/vnd.viewcvs-markup

Null descriptor is never used - bytes can be filled with something else.
Posted on 2003-06-08 13:23:37 by bitRAKE
Im so sorry, but it still rebooting.
I passing the GDT address from register.

My GDT are base zero, but it was loaded at base 7c08. Is it the mistake. PAGE_GRANULITY or BIG_BIT are c0h right? so the value are CFh. About the far Jump, Im jumping to 8000h with this opcode, EA 00 80 00 00 08 00 ( jmp far 0008:00008000 ), it update the EIP and CS.

example:
bp=IP and the value is 7c00.




mov ax,bp = ax are 7c00 now.
add ax,8 = ax are 7c08 now.
lgdt [ax] = its same with lgdt [7c08]



Sorry, my compiler does not support label. Fix value are not allowwed yet. Still developing it. I need this boot for my example.
Posted on 2003-06-08 17:24:09 by realvampire
Thank you, It does not rebooting again. I forgot to disable the interupt before switch. Here is the program, you can running it from DOS real mode. Im still improving it. Also, is it realy working? If It so, im gonna rebuild my compiler and make it portable on every OS.


:alright: Thanks for your patience and kind.
Posted on 2003-06-08 21:41:02 by realvampire
I forgot to atach it.

:stupid:
Posted on 2003-06-08 21:43:20 by realvampire
:confused: Another problem occur, I cannot set ES and DS also SS and else. How to do it? I jump to a miss selector, it is 0800:00dac0de, why it valid? it does not rebooting, just hang. But when I use




mov ax,cs
mov ds,ax
mov es,ax



It does reboot?:confused: .
Posted on 2003-06-09 02:33:30 by realvampire
when i disassemble your code (result.com). at the end i get the following listing:


:
:
:000001F9 0F01E0 smsw ax
:000001FC 0C01 or al, 01
:000001FE 0F01F0 lmsw ax
:00000201 90 nop
:00000202 90 nop
:00000203 90 nop
:00000204 90 nop
:00000205 90 nop
:00000206 0800 or byte ptr [eax], al ; <---
:00000208 90 nop
:00000209 EBFD jmp 00000208
:0000020B C3 ret


i can't believe that the marked code is what you intended.
here's the code i'd use (assembled with fasm):


:
:
:0001.01F9 0F01E0 smsw ax
:0001.01FC 0C01 or al, 01
:0001.01FE 0F01F0 lmsw ax
:0001.0201 EA08020800 jmp 0008:0208 ;no NOPs before jmp, still 16bits

;from now on use32!!
;NOW set the remaining selectors to es,ds,gs

:0001.0206 90 nop
:0001.0207 EBFD jmp 0205
:
:
Posted on 2003-06-09 13:10:30 by hartyl