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?
A problem about datas in memories and BIOS interrupt
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: A problem about datas in memories and BIOS interrupt
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 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".
Re: A problem about datas in memories and BIOS interrupt
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 41 times
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: A problem about datas in memories and BIOS interrupt
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
There needs a boot.asm to run (because this is not a boot sector) and I put that down.Octocontrabass wrote:I can't assemble your code without the missing files. Which line is causing the assembler error?
- Attachments
-
- boot.asm
- (3.69 KiB) Downloaded 25 times
Re: A problem about datas in memories and BIOS interrupt
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:Octocontrabass wrote:I can't assemble your code without the missing files. Which line is causing the assembler error?
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 39 times
-
- load.asm
- (351 Bytes) Downloaded 27 times
-
- fat12hdr.asm
- (697 Bytes) Downloaded 28 times
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: A problem about datas in memories and BIOS interrupt
I still don't see the "data exceeds bounds" error.