Page 1 of 1
A problem about datas in memories and BIOS interrupt
Posted: Sun Jul 17, 2022 4:56 am
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?
Re: A problem about datas in memories and BIOS interrupt
Posted: Wed Jul 20, 2022 8:00 pm
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.
Re: A problem about datas in memories and BIOS interrupt
Posted: Fri Jul 22, 2022 11:49 pm
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");
}
Re: A problem about datas in memories and BIOS interrupt
Posted: Sat Jul 23, 2022 3:12 pm
by Octocontrabass
I can't assemble your code without the missing files. Which line is causing the assembler error?
Re: A problem about datas in memories and BIOS interrupt
Posted: Fri Aug 05, 2022 12:53 am
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.
Re: A problem about datas in memories and BIOS interrupt
Posted: Fri Aug 05, 2022 1:03 am
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.
Re: A problem about datas in memories and BIOS interrupt
Posted: Fri Aug 05, 2022 10:21 am
by Octocontrabass
I still don't see the "data exceeds bounds" error.