Menu
  • HOME
  • TAGS

Do I have to link the files with -lgcc?

c,gcc,osdev

If you do some driver/kernel dev, you may use the -nostdlib to remove your module from the bloated stdlib. However, you also remove all the internal hacks GCC has in order to have a consistent behaviour on a whole range of hardware. http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/Link-Options.html -nostdlib Do not use the standard system...

Strange behaviour of C pointers with memory mapped I/O

c,pointers,kernel,osdev

If you add an integer n to a <type> pointer the address is incremented by sizeof( <type> ) * n bytes. So in your first example, you have *((uint16_t *)0xB8000 + 2) = 0x0741; so what happens here is: 0xB8000 is cast to unit16_t * and then that pointer is...

PCI Address Spaces

osdev,pci

For physical plug-in PCI cards it is always on the device. The device has to announce what it is (configuration space), and keeps it local state independent of the host machine (I/O and memory space) PCI is however often abused as just the mechanism for configuration, and there are many...

Programming an Operating System [closed]

operating-system,osdev

If you were going to write an operating system you should probably write it in a language close to the hardware such as assembly language and\or C. Creating an OS from scratch, incredibly difficult. Especially by yourself. Forgive me, but you seem to be inexperienced. Which is okay. I would...

How to get Keyboard inputs into a kernel?

c,keyboard,kernel,osdev

You need to write a driver in your kernel for the keyboard. Assuming a standard PC, the 8042 keyboard controller is pretty well documented (see http://wiki.osdev.org/%228042%22_PS/2_Controller for example). You'll also need to write a driver for the display, and again assuming VGA it is pretty well documented (see http://wiki.osdev.org/VGA_Hardware). Then...

Using pointer as an array - C

c,arrays,pointers,types,osdev

What does it mean? Is it the same as uint16_t *terminal_buffer;? Yes it is, the position of the * is irrelevant if it's in between the type name and the variable name so you can write uint16_t * terminal_buffer; if you want, because spaces are ignored. Than variable terminal_buffer...

Rustc/LLVM generates faulty code for aarch64 with opt-level=0

rust,qemu,arm64,osdev

I've succeeded to run the non-optimised code without abnormalities. Thanks to Notlikethat for the idea. My stack was just mapped into readonly memory. So I've just added the offset statement into my linker script (". = 1024M;") in order to make all the symbols to start from 1GiB (where RAM...

MinGW's ld cannot perform PE operations on non PE output file

gcc,assembly,mingw,nasm,osdev

Old MinGW versions had the problem that "ld" was not able to create non-PE files at all. Maybe current versions have the same problem. The work-around was creating a PE file with "ld" and then to transform the PE file to binary, HEX or S19 using "objcopy"....

How to implement terminal scrolling

c,terminal,scroll,osdev,barebones

This is how I did this: void terminal_scroll(){ for(int i = 0; i < vga_height; i++){ for (int m = 0; m < vga_width; m++){ terminal_buffer[i * vga_width + m] = terminal_buffer[(i + 1) * vga_width + m]; } } } Hope this will help....

C++ add up all bytes in a structure

c++,struct,osdev

Here is some code that shows two ways to do it. The first way is easier and more efficient, but will give the wrong result for a struct that doesn't have the packed attribute (since it will incorrectly include the padding bytes in its tally). The second approach will work...

GCC 5.1.0-4 cross compiler build fail

gcc,osdev

My understanding is that gcc-5.x no longer requires CLooG. It's recommended that you use isl-0.14 available here or here. You might find the current (gcc-5.1) instructions at Linux from Scratch helpful. There are a lot of configure options, as you are no doubt aware, so it's difficult to know the...

What to do with information collected from PCI devices

pci,osdev

The PCI information gets stored into kernel data structures eg: struct resource which particularly stores the BAR's physically mapped addresses. These would then be used by device drivers by first remapping them to virtual addresses and then accessing them....

GCC linker does not link standard library

c,gcc,assembly,osdev

You cannot use the C library for a kernel as it is build for an existing kernel and relies on the syscalls of its target OS. Instead, you have to write a driver for keyboards and everything else you need to get characters from anywhere. getc() is a very advanced...

Toy OS Filesystem [on hold]

c,assembly,filesystems,kernel,osdev

First, read wikipage on file systems to have some broad view. The relevant resource about operating system development is OSdev (but perhaps your question is off-topic here). Kernelnewbies could also help (explaining how Linux is doing). OSdev have wikipages explaining FAT & Ext2 in details. You could design an OS...

How is the data segment set when using sysenter

assembly,operating-system,system-calls,osdev

ds and the other data segment registers are not changed automatically because they do not need to be. sysenter was designed to be as simple as possible, so that it would execute as quickly as possible. As part of this, many things are not done, including updating most segment registers...

Compiling custom kernel for HP Thin client and creating bootable ISO with grub

c,osdev,grub,thin-client

The command for copying was invalid, resp. target partion was invalid. C compiled with gcc -m32, ASM compiled with nasm -m elf32, linked with ld -T Link.ld -m elf_i386, iso created with grub-mkrescue -o bin/os.iso ./iso/ and copied to usb with dd if=bin/os.iso of=/dev/sdd (no digits). Working well (on laptop...

Does using “pushf” and popping to a 32 bit register destroy the stack?

c,assembly,kernel,osdev

The instruction set reference says this: Decrements the stack pointer by 4 (if the current operand-size attribute is 32) and pushes the entire contents of the EFLAGS register onto the stack It also says: The PUSHF (push flags) and PUSHFD (push flags double) mnemonics reference the same opcode. The PUSHF...