flat assembler
Message board for the users of flat assembler.

Index > OS Construction > How to read sectors in Protected mode?

Author
Thread Post new topic Reply to topic
blueone



Joined: 01 Apr 2007
Posts: 10
blueone 30 Dec 2007, 03:04
I'm having trouble reading sectors in protected mode. But when i read sectors in real mode, there's no problem. Can anyone help me to read a file in protected mode because i really need it in this mode because i need to use 32 bits Sad . Any help would be greatly apreciated Wink
Post 30 Dec 2007, 03:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 30 Dec 2007, 03:30
More info needed. Are you using your own OS or existing OS? What device are you reading? FDD, HDD, USB?

Basically you will need to have I/O routines written for PM. The standard BIOS code only supports RM access to devices.

Also don't forget to check out my web site to find info regarding PM sector access.
Post 30 Dec 2007, 03:30
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 30 Dec 2007, 03:47
Or switching back to RM to call the INT and getting back to PM. Some DOS extenders do that AFAIK.
Post 30 Dec 2007, 03:47
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 30 Dec 2007, 04:28
IO ports are the same for RM and PM
So, if you can read/write sectors PIO or DMA in RM, you can in PM with the same program.
Modifications in theses functions are only for X86 PM addressing mode support
Differences between PM and RM is the addressing mode... of the x86 µP.
IO ports works exactlly the same in all modes as it is not X86 engines, but some other standard µP and µC

It's, i think, the first serious and usefull function that you can ever code.. it decides on how will work all the parts of the OS...

Probably, reversing int 13h can be a good start...
Post 30 Dec 2007, 04:28
View user's profile Send private message Visit poster's website Reply with quote
blueone



Joined: 01 Apr 2007
Posts: 10
blueone 30 Dec 2007, 06:03
I think i figured out my true problem. Im really confused regarding what mode i will use in my own OS. Ive read that real mode uses 16 bit only and protected mode uses 32 bit and can access 4GB of memory. So i use protected mode for the reason of memory access but after i read about flat real mode... Im dropping my plan to make my OS in protected mode hehehe.
My second problem is after i entered Flat Real Mode, do i need the code using "use32" or "use16"? BTW im writting a bootsector and kernel in 1 assembly code. Thanks for the reply Wink
Post 30 Dec 2007, 06:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 30 Dec 2007, 06:05
FRM is a 32 bit mode. You will still need custom I/O code for your peripherals unless you do the RM switching trick, but then your peripherals can only use data in the first 1meg.
Post 30 Dec 2007, 06:05
View user's profile Send private message Visit poster's website Reply with quote
blueone



Joined: 01 Apr 2007
Posts: 10
blueone 30 Dec 2007, 07:26
I still need help figuring things out. I didnt got he step by step to enter in UNREAL mode + A20 + VESA + INTERUPTS ENABLED. Ive read lots of codes in this forum but they pointed me in different ways. Can anyone help me out elaborate things how they are arranged? Which comes first second and so on? Sad
*Bootsector*
[use16]
clear segments
a20
unreal
[use32]
load kernel from sector 2
jump kernel (600h)
*endof bootsector*

*kernel*
[use32]
org 600h
setvesa
....codes....
*end of kernel*
any help is apreciated Smile
Post 30 Dec 2007, 07:26
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 30 Dec 2007, 07:40
blueone wrote:
unreal
[use32]
load kernel from sector 2
If you go into unreal mode before loading the sector then how will you do the I/O?
Post 30 Dec 2007, 07:40
View user's profile Send private message Visit poster's website Reply with quote
blueone



Joined: 01 Apr 2007
Posts: 10
blueone 30 Dec 2007, 07:44
Thanks for the reply. I was wondering on how will i manage the I/O when in unreal mode. I heard about interrupt masks or something, will it make my I/O possible?
Post 30 Dec 2007, 07:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 30 Dec 2007, 07:54
"interrupt masks" won't help, this is going back to your original question. You need 32bit I/O code if you want to stay in unreal mode. There is no way around it except to leave unreal mode then do the I/O.

Have a look at MinuetOS. I'm not sure, but I would expect there is 32bit disk access code in there somewhere, perhaps you can extract that and try it.
Post 30 Dec 2007, 07:54
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 30 Dec 2007, 14:12
Check fasm DOS sources, it uses the unreal 32-bit mode by doing some tricks with the IDT.
Post 30 Dec 2007, 14:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 30 Dec 2007, 14:21
The DOS fasm does not use 32bit disk accesses, it jumps to 16bit DOS to do the transfers. That's not what the OP is asking for.
Post 30 Dec 2007, 14:21
View user's profile Send private message Visit poster's website Reply with quote
blueone



Joined: 01 Apr 2007
Posts: 10
blueone 30 Dec 2007, 15:41
I already figured out entering into unreal mode. Now the problem is... when i try to load a 900kb bitmap using EXTENDED int 13h ax=42h. It wont let me read the whole bitmap, this is what i use

thank you very much in replies!

my DAP is this:
video_mode = 0x4112
count dw 0
dap db 10h,0
.len db 12,0
.mem dd 1000000 ; load it to offset 1MB
.sec dq 3
drive db 0

my code is this:
mov ecx,15 ;read fifteen 120 sectors = 15*120*512 nearly 900kb
read:
mov ah,42h
mov esi,dap
mov dl,[drive]
int 13h
add dword[dap.sec],120
add [dap.mem],120*512
loop read
Post 30 Dec 2007, 15:41
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 30 Dec 2007, 20:12
First forget about unrealmode, use pmode, I have written a demo that may help you .
Its sets up vesa and goes to pmode and loads a high res bmp img.
http://www.dex4u.com/Vesa/BmpView.zip

I also have done a demo of a bootable Pmode Floppy Driver, let me know if you need it.

Ps: Any code you may use in your own OS, you should acknowledge the names in the demos.
PPs: I have not seen the latest ver of menuetOS, but it use to use unreal-mode, to load the whole image from floppy into ram.
ScreenShot


Description:
Filesize: 30.8 KB
Viewed: 10160 Time(s)

test.jpg


Post 30 Dec 2007, 20:12
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 31 Dec 2007, 00:51
LocoDelAssembly wrote:

> Or switching back to RM to call the INT and getting back to PM. Some DOS extenders do that AFAIK.

All DOS extenders (or 99% at least) do the same way: switch to RM if no EMM386 present, let EMM386 switch to "V86" if it is present

revolution (= DOS386 ??? Laughing ) wrote:

> The DOS fasm does not use 32bit disk accesses, it jumps to 16bit DOS to do the transfers. That's not what the OP is asking for.

FASM DOS version uses file accesses only using INT $21 , no low level sector access with INT$13 or DMA/ATA ports Wink

blueone wrote:

> .mem dd 1000000 ; load it to offset 1MB

Strange Confused

PS: use code tags next time Idea
Post 31 Dec 2007, 00:51
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.