A problem about datas in memories and BIOS interrupt

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
one737
Posts: 13
Joined: Sun Jul 17, 2022 4:41 am

A problem about datas in memories and BIOS interrupt

Post by one737 »

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?
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: A problem about datas in memories and BIOS interrupt

Post by Octocontrabass »

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.
one737
Posts: 13
Joined: Sun Jul 17, 2022 4:41 am

Re: A problem about datas in memories and BIOS interrupt

Post by one737 »

My loader.asm file is very long, so I will attach that below. And here is my kernel.asm and main.c:

Code: Select all

[section .text]

global _start

_start:
    jmp main ; jump into main.c

Code: Select all

void main()
{
    char vmode = *(char *) 0x0ff1;
    while (1) __asm__ __volatile__("hlt");
}
Attachments
loader.asm
(10.34 KiB) Downloaded 40 times
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: A problem about datas in memories and BIOS interrupt

Post by Octocontrabass »

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

Re: A problem about datas in memories and BIOS interrupt

Post by one737 »

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 25 times
one737
Posts: 13
Joined: Sun Jul 17, 2022 4:41 am

Re: A problem about datas in memories and BIOS interrupt

Post by one737 »

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 38 times
load.asm
(351 Bytes) Downloaded 26 times
fat12hdr.asm
(697 Bytes) Downloaded 27 times
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: A problem about datas in memories and BIOS interrupt

Post by Octocontrabass »

I still don't see the "data exceeds bounds" error.
Post Reply