I/O functions
Re: I/O functions
I have a only one question... Bare Bones switch CPU to pmode or real mode?
Re: I/O functions
Hi,
Cheers,
Brendan
GRUB switches to protected mode and then starts the Bare Bones code, and the Bare Bones code stays in protected mode.p0s1x wrote:I have a only one question... Bare Bones switch CPU to pmode or real mode?
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: I/O functions
Thanks, but i have a problem, ld linking my kernel into PE file, how to make ELF file?Brendan wrote:Hi,
GRUB switches to protected mode and then starts the Bare Bones code, and the Bare Bones code stays in protected mode.p0s1x wrote:I have a only one question... Bare Bones switch CPU to pmode or real mode?
Cheers,
Brendan
Upd: I don't use GRUB
Re: I/O functions
Please help, I need make elf binary.
Re: I/O functions
Hi,
Cheers,
Brendan
Where in the relevant part of the multi-boot specification does it say you need to use ELF?p0s1x wrote:Thanks, but i have a problem, ld linking my kernel into PE file, how to make ELF file?Brendan wrote:GRUB switches to protected mode and then starts the Bare Bones code, and the Bare Bones code stays in protected mode.
If you're not using GRUB or multi-boot, then just use "flat binary" (it's easier).p0s1x wrote:Upd: I don't use GRUB
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: I/O functions
I can't create bootable image, my bat:Brendan wrote:Hi,
Where in the relevant part of the multi-boot specification does it say you need to use ELF?p0s1x wrote:Thanks, but i have a problem, ld linking my kernel into PE file, how to make ELF file?Brendan wrote:GRUB switches to protected mode and then starts the Bare Bones code, and the Bare Bones code stays in protected mode.
If you're not using GRUB or multi-boot, then just use "flat binary" (it's easier).p0s1x wrote:Upd: I don't use GRUB
Cheers,
Brendan
Code: Select all
@echo off
path = C:\MinGW\bin
gcc -o bin\kernel.o -c kernel.c -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs
ld -T bin\linker.ld -o bin\kernel.bin bin\loader.o bin\kernel.o
objcopy -O elf32-i386 bin\kernel.bin
dd if=bin\kernel.bin of=bin\image.img bs=1440k
PAUSE
Thanks.
Re: I/O functions
What you need is not being babysit with every problem you encountered, not that we're not willing to help (indeed we are willing to help), but it's not the way to learn and proceed for os development.
You should check out the Main_Page, Required_Knowledge, Beginner_Mistakes and Getting_Started before copy & paste the tutorials.
You should check out the Main_Page, Required_Knowledge, Beginner_Mistakes and Getting_Started before copy & paste the tutorials.
Re: I/O functions
Also when you should copy & paste tutorials make sure they work _before_ adding your own code.bluemoon wrote:before copy & paste the tutorials.
Also make sure the tutorial is compatible with your tool chain because the bare bones tutorial you linked says:
"This tutorial assumes you have a compiler / assembler / linker toolchain capable of handling ELF files."
"[...] GRUB will be the bootloader, and the kernel will be in ELF format."
"GRUB (a Multiboot compliant boot loader) puts [...] the system [into] 32-bit Protected Mode"
This contrasts sharply with your statements in this thread:
p0s1x wrote:Bare Bones switch CPU to Real or Protected mode?
p0s1x wrote:I have a only one question... Bare Bones switch CPU to pmode or real mode?
Anyway I would highly recommend using Linux as your development platform because it makes away with lots of your problems such as PE files.p0s1x wrote:Thanks, but i have a problem, ld linking my kernel into PE file, how to make ELF file?
Upd: I don't use GRUB :)
But even if you don't want to the original Bare Bones tutorial already explains what you need to do to make ELF files:
"On a Windows machine, you are strongly encouraged to set up a GCC Cross-Compiler, as it removes all the various toolchain-specific issues you might have ("PE operation on a non-PE file", "unsupported file format", and a number of others)."
But again as already said try Linux, you can even use Virtualbox so you can run it inside Windows. Ubuntu is an easy to use Linux distribution.
Then try to follow the Bare Bones tutorial again, step by step to the point where you see "character 'A'" in "light grey (7) on black (0)" on the screen of your favourite emulator. I personally prefer, and would recommend, QEMU because it has a build in Multiboot boot loader thus booting is as simple as "$ qemu -kernel kernel.elf".
P.S.
You need a Multiboot loader to load the Bare Bone tutorial. Please read the Bare Bone tutorial. And every time it says you need something, such as GRUB, please don't consider it optional but rather mandatory!p0s1x wrote: I can't create bootable image, my bat:Bootable image (output) don't boot in Bochs. If I boot it with VMware Player, I get black screen.Code: Select all
@echo off path = C:\MinGW\bin gcc -o bin\kernel.o -c kernel.c -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs ld -T bin\linker.ld -o bin\kernel.bin bin\loader.o bin\kernel.o objcopy -O elf32-i386 bin\kernel.bin dd if=bin\kernel.bin of=bin\image.img bs=1440k PAUSE
Thanks.
Also you batch file is missing this whole chapter of the Bare Bone tutorial or how do you try to boot the not-bootable[1] image in Bochs?
[1] The Bare Bones tutorial does not give you a bootable kernel. It is just a Multiboot compliant binary and needs a Multiboot boot loader to boot.
Re: I/O functions
Qemu is difficult to set up on windows, and onx86, bochs is just as good.
PS, technically, you can set up ubuntu in an emulator, then qemu in that, but...
PS, technically, you can set up ubuntu in an emulator, then qemu in that, but...
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
If you're new, check this out.
Re: I/O functions
Sources, please?m12 wrote:Qemu is difficult to set up on windows
This site has pre-compiled windows binaries. I do not see how easier can it get.
http://lassauge.free.fr/qemu/
l2google
Re: I/O functions
Why don't we put that link in the wiki under Qemu?Nessphoro wrote:Sources, please?m12 wrote:Qemu is difficult to set up on windows
This site has pre-compiled windows binaries. I do not see how easier can it get.
http://lassauge.free.fr/qemu/
l2google
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
If you're new, check this out.
Re: I/O functions
It's on the first link from the official qemu wiki / Links / "Unofficial QEMU binaries" section, it should be easy to find it.m12 wrote:Why don't we put that link in the wiki under Qemu?
Re: I/O functions
You can use this code:
Anyone here should know how to #define their own WHITE_TEXT value.
Anyone here should know how to #define their own WHITE_TEXT value.
Code: Select all
unsigned int k_printf(char *message, unsigned int line) {
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
i=(line*80*2);
while(*message!=0) {
if(*message=='\n') {
line++;
i=(line*80*2);
*message++;
} else {
vidmem[i]=*message;
*message++;
i++;
vidmem[i]=WHITE_TXT;
i++;
};
};
return(1);
};
Re: I/O functions
Ok, I normally builded OS.
printf and cls functions works. How about keyboard input?
I try this:
but I don't know how to use c variables in inline assembler.
printf and cls functions works. How about keyboard input?
I try this:
Code: Select all
char getch() {
asm ("mov $1, %ah");
asm ("int $0x16");
}
Re: I/O functions
I know that I'm jumping late in to the printf game, but I wanted to share my tiny writef implementation https://github.com/gusc/mbr2gpt/blob/ma ... rnel/lib.c
If it helps, you're welcome!
If it helps, you're welcome!