OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 6:43 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 77 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 12:21 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
-shared is not needed. -fno-stack-protector is needed for every .c file. You may have something not recompiled with new flags. You also need -fno-pic flag for .c files. PIC code will make some weird crashes when you implement paging and may trash EBX register in some cases. BTW. just look at 'make clean all' output of non modified demo. It shows you exactly what it's doing.


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 6:34 am 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
when i try to pass -fno-stack-protector flag in LD, it says that it can be done without -shared flag.could be that it was in gcc and not in ld?


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 6:47 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
You use -fno-stack-protector and -fno-pic for gcc.


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 6:49 am 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
ok.will see if it works


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 6:53 am 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
not crashing, and can work fine. now the last step; see if i can call a bios interrupt


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 7:01 am 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
ld cant recognize vm86int. actually hating LD


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 7:06 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
Post your build script. I would help a lot.


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 7:12 am 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
its a .sh file.

Code:
nasm -f elf32 bootloader.asm -o bootloader.bin
nasm -f elf32 bootloader.asm -o bootloader.o
gcc -m32 -fno-stack-protector -fno-pic -c kernel.c -o kc.o
cd include
cd VM86
nasm -f elf32 isrs.asm -o isrs.o
nasm -f elf32 cpu.asm -o cpu.o
nasm -f elf32 vm86asm.asm -o vm86asm.o
gcc -m32 -c ints.c -o ints.o
gcc -m32 -c vm86.c -o vm86.o ; don't used 'cause ld gives a lot of undefined references
cp isrs.o (the kernel dir)
cp cpu.o (the kernel dir)
cp ints.o (the kernel dir)
cp vm86asm.o (the kernel dir)
cd ..
cd ..
ld -m elf_i386 -T link.ld -o bootloader.bin bootloader.o kc.o isrs.o cpu.o ints.o vm86asm.o
cp bootloader.bin OS/boot/
grub-mkrescue -o OS.iso OS/
qemu-system-x86_64 -hda OS.iso


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 7:30 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
you're missing gcc -m32 -c idt.c -o idt.o and you're not linking idt.o and vm86.o. Also first line is not needed because you overwrite bootloader.bin with ld command anyway. You should also use my boot.asm instead since it sets up TSS which is needed tof V86 mode to work.

I would try this:
Code:
nasm -f elf32 boot.asm -o boot.o
gcc -m32 -fno-stack-protector -fno-pic -c kernel.c -o kc.o
cd include
cd VM86
nasm -f elf32 isrs.asm -o isrs.o
nasm -f elf32 cpu.asm -o cpu.o
nasm -f elf32 vm86asm.asm -o vm86asm.o
gcc -m32 -fno-stack-protector -fno-pic -c ints.c -o ints.o
gcc -m32 -fno-stack-protector -fno-pic -c idt.c -o idt.o
gcc -m32 -fno-stack-protector -fno-pic -c vm86.c -o vm86.o ; you have to use it
cp boot.o (the kernel dir)
cp ints.o (the kernel dir)
cp idt.o (the kernel dir)
cp cpu.o (the kernel dir)
cp ints.o (the kernel dir)
cp vm86.o (the kernel dir)
cp vm86asm.o (the kernel dir)
cd ..
cd ..
ld -m elf_i386 -T link.ld -o bootloader.bin boot.o kc.o isrs.o idt.o cpu.o ints.o vm86.o vm86asm.o
cp bootloader.bin OS/boot/
grub-mkrescue -o OS.iso OS/
qemu-system-x86_64 -hda OS.iso


If you really want to use your bootloader.asm you have to set up GDT and TSS just as I do in boot.asm.


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 7:35 am 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
multiple definitions of 'vm86Initialize', 'vm86Enter', 'vm86Int', and undefined reference to 'vm86Int' --> in LD. how do i fix it?i dont know where is the multiple definition!!

also your boot.asm is the same of my bootloader.asm


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 8:16 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
I've recreated what I think is your directory structure and compiled it just fine. BIOS interrupt gets called ok but there is a problem with exiting. When I run it with -kernel option for QEMU it works just fine but when I try using GRUB ISO then there is still something wrong with my code. Let me fix it and I'll let you know later today.


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 8:18 am 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
ok.. but i can't link with LD it says the undefined reference and multiple definitions described above


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 8:42 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
I know I tend to harp on this a lot, but: do you have an offsite repo hosted on someplace such as GitHub, Gitlab, or CloudForge? Aside from everything else you would get from one, it would make it a lot easier for us to look at your current code, and review what you've done over time, so you wouldn't need to paste large pieces of your code into your posts here - you can just put a link to the repo in your user signature.

You'd still probably want to paste some code here, to make things easier when you are pointing out a specific piece of code, but overall, having us view it from a repo would save us and you a lot of trouble.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 8:55 am 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
no, i dont have github or other types of repo


Top
 Profile  
 
 Post subject: Re: x86 asm bios interrupts in C
PostPosted: Sat Sep 15, 2018 9:18 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
Ok, I've fixed the problem with exiting from V86 mode back to protected mode. I forgot to initialize segment registers in boot.asm. And QEMU internal loader and GRUB do things a little bit different when it comes to GDT.

I've made a version for you that works with your build script. I've tried to guess your directory structure based on the script, so it may be wrong.
I've also uploaded fixed version of my previous archive.


Attachments:
File comment: fixed version of previous vm86.tar.gz
vm86.tar.gz [8.94 KiB]
Downloaded 13 times
alberinfo_vm86.tar.gz [8.67 KiB]
Downloaded 14 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 77 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot], SemrushBot [Bot] and 270 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