OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:48 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: A problem about datas in memories and BIOS interrupt
PostPosted: Sun Jul 17, 2022 4:56 am 
Offline

Joined: Sun Jul 17, 2022 4:41 am
Posts: 13
I'm working on a simple OS project, but now I had a problem about handing datas between different pages - I need to let the kernel to read the datas in Loader, but they're in different pages. When I use physical addresses, the assembler had an error called "data exceeds bounds".

Because of the Loader's data is from BIOS calls, I decide to go back to the real mode at the start of the kernel, but after I did it, I can't use the BIOS calls and I don't know how to solve it.

May I use the alternatives of the BIOS calls by using outb/inb or V86?


Top
 Profile  
 
 Post subject: Re: A problem about datas in memories and BIOS interrupt
PostPosted: Wed Jul 20, 2022 8:00 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
one737 wrote:
I'm working on a simple OS project, but now I had a problem about handing datas between different pages - I need to let the kernel to read the datas in Loader, but they're in different pages. When I use physical addresses, the assembler had an error called "data exceeds bounds".

It sounds like you're having trouble with segmented addressing. Can you share your code? There might be an easy way to fix this.


Top
 Profile  
 
 Post subject: Re: A problem about datas in memories and BIOS interrupt
PostPosted: Fri Jul 22, 2022 11:49 pm 
Offline

Joined: Sun Jul 17, 2022 4:41 am
Posts: 13
My loader.asm file is very long, so I will attach that below. And here is my kernel.asm and main.c:

Code:
[section .text]

global _start

_start:
    jmp main ; jump into main.c


Code:
void main()
{
    char vmode = *(char *) 0x0ff1;
    while (1) __asm__ __volatile__("hlt");
}


Attachments:
loader.asm [10.34 KiB]
Downloaded 15 times
Top
 Profile  
 
 Post subject: Re: A problem about datas in memories and BIOS interrupt
PostPosted: Sat Jul 23, 2022 3:12 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
I can't assemble your code without the missing files. Which line is causing the assembler error?


Top
 Profile  
 
 Post subject: Re: A problem about datas in memories and BIOS interrupt
PostPosted: Fri Aug 05, 2022 12:53 am 
Offline

Joined: Sun Jul 17, 2022 4:41 am
Posts: 13
Octocontrabass wrote:
I can't assemble your code without the missing files. Which line is causing the assembler error?

There needs a boot.asm to run (because this is not a boot sector) and I put that down.


Attachments:
boot.asm [3.69 KiB]
Downloaded 10 times
Top
 Profile  
 
 Post subject: Re: A problem about datas in memories and BIOS interrupt
PostPosted: Fri Aug 05, 2022 1:03 am 
Offline

Joined: Sun Jul 17, 2022 4:41 am
Posts: 13
Octocontrabass wrote:
I can't assemble your code without the missing files. Which line is causing the assembler error?

Please compile boot.asm as boot.bin, loader.asm as loader.bin, then compile the kernel.asm to kernel.o by using ELF, and main.c to main.o either (add -m32 if your computer is x86_64). Then use ld to link like this:
ld -s -Ttext 0x30400 -o kernel.bin kernel.o main.o

Then do these commands under Linux:
dd if=/dev/zero of=a.img bs=512 count=2880
dd if=boot.bin of=a.img bs=512 count=1 conv=notrunc
sudo mount -o loop a.img /mnt/floppy/
cp -fv loader.bin /mnt/floppy/
cp -fv kernel.bin /mnt/floppy/
sudo umount /mnt/floppy/

And also, use an VM to run a.img.
There're still three headers missing (fat12hdr.inc, pm.inc, load.inc) and I also put them down there.
Because of this forum can't accept *.inc, so I changed the suffix to asm and please change that back.


Attachments:
pm.asm [877 Bytes]
Downloaded 11 times
load.asm [351 Bytes]
Downloaded 11 times
fat12hdr.asm [697 Bytes]
Downloaded 11 times
Top
 Profile  
 
 Post subject: Re: A problem about datas in memories and BIOS interrupt
PostPosted: Fri Aug 05, 2022 10:21 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
I still don't see the "data exceeds bounds" error.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 71 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group