1,252 questions
1
vote
0
answers
88
views
interrupt(): gate descriptor is not valid sys seg (vector=0x0X)
I am making my own UNIX like OS called Connor's UNIX and I am implementing kernel and userspace separation and I have been all day and this is as far as I can get it to work and if you need any more ...
Advice
0
votes
8
replies
99
views
Implementing brace-enclosed initializer lists in a custom C++ standard library
I am developing my own operating system, and I’ve reached the point where I need to port the C++ standard library to it. I have already ported most components, including memory management and related ...
1
vote
0
answers
77
views
Can't assemble bare-metal i586 protected mode no paging code using openwatcom1.9
I'm trying to compile code in OpenWatcom 1.9 written in assembly.
On Windows, utils in use:
wasm
msys2
command:
/d/Maksym/WATCOM/binnt/wasm.exe -5p kstart.asm -fo=kstart.obj
output:
Open Watcom ...
3
votes
2
answers
135
views
How can I correctly load the kernel to its canonical high address space
I am working on a small os with a custom boot loader targeting BIOS. For this, I need to map the kernel to its canonical high address space (0xFFFFFFFF80000000) and jump to its entry point.
For this, ...
1
vote
1
answer
107
views
Trouble setting up Interrupts in custom Assembly based Kernel
I am working on an assembly kernel, using the OSDev Wiki and a PDF from Nick Blundell. I have set up my GDT and it seems to work fine. I am also able to load the IDTR as well. However, when I try to ...
2
votes
1
answer
137
views
OSDev: Stuck at adding GDT
I've followed the book OS01 by Tuhdo, kind of made a simple bootloader, that loads the kernel. Then I tried to add some code to set up GDT, but I've witnessed unusual behavior in gdb.
Here I stopped ...
-1
votes
1
answer
213
views
MIT OS course 6.828, boot/main.c - outw to port 0x8A00 with magic numbers? [closed]
void bootmain(void)
{
struct Proghdr *ph, *eph;
// read 1st page off disk
readseg((uint32_t) ELFHDR, SECTSIZE*8, 0);
// is this a valid ELF?
if (ELFHDR->e_magic != ELF_MAGIC)
...
15
votes
1
answer
395
views
Using OUTB to set cursor position in my minimal OS kernel causes QEMU screen to flicker
I am getting started with a minimal OS kernel (just gdt and place holder idt). Using i386 assembly and freestanding C. I wanted to change the position of the cursor for which i found several sites ...
0
votes
0
answers
136
views
Nightly Rust #[unsafe(naked)] function leads to undefined symbol linker error in --release mode on RISC-V
I am writing a hobby OS kernel in Rust for the riscv64gc-unknown-none-elf target. I have defined my trap_entry, as a #[unsafe(naked)] function within a Rust module.
When I compile in release mode (...
3
votes
1
answer
153
views
INT 13, AH=42h fails with AH=1, CF=1
I am trying to write a simple bootloader which loads my program from LBA=1 into memory and jumps to its start. I emulate my bootloader in qemu with -drive flag passed. When I try to read blocks from ...
4
votes
1
answer
191
views
Is 0x0000:0x7000 a unsafe address to load your kernel? Or is it just qemu annoying me
So I thought I'd try to make a DOS copy but it runs on a floppy and its just a simple plug and play with fat12 partition for user applications and drivers.
I first attempted to load my kernel using ...
2
votes
1
answer
83
views
Double fault when i enable interrupts (via sti)
im making an os kernel in zig (grub to boot) and im trying to get interrupts to work specifically hardware interrupts and as soon as i enable them (i have a pic, gdt and idt setup) it gives me a ...
2
votes
1
answer
91
views
Why does UEFI GetMemoryMap return EFI_BUFFER_TOO_SMALL after allocating a buffer of the reported size?
I'm writing a UEFI application in Zig.
I'm calling GetMemoryMap() twice: once to get the required buffer size, then again after allocating the buffer using AllocatePool().
Here's my code:
fn ...
2
votes
0
answers
114
views
Mouse Cursor in 16-bit Assembly (NASM) Overwrites Screen Content in VGA Mode 0x12
I'm developing a PS/2 mouse driver in 16-bit assembly (NASM) for a custom operating system running in VGA mode 0x12 (640x480, 16 colors). The driver initializes the mouse, handles mouse events, and ...
0
votes
0
answers
96
views
Bootloader flickers after enabling paging in x64 long mode
I am working on a simple bootloader in assembly. everything works fine until i enable paging and jump to 64 bit mode but then qemu just flickers. i think its a page fault but i am not sure what's ...
0
votes
0
answers
100
views
OSDev (NASM/QEMU): VGA Text Output Cut Off in Protected Mode
I've embarked on the exciting journey of OS development, following the tutorials on BrokenThorn.com. It's an older resource, but I've found it to be incredibly insightful for learning the ropes.
I've ...
-5
votes
2
answers
94
views
Why does my 32bit kernel randomly flicker?
For some reason every time I try entering 32bit protected mode.. it always FLICKERS AND FLICKERS FOR NO REASON..
I am using QEMU and my kernel is being assembled into a raw binary and then written ...
1
vote
1
answer
159
views
In kernel development, why do developers avoid pasting in high level libraries directly to the kernel?
Context: I am a somewhat seasoned C++ and Python developer, and a beginner in Rust with no experience in assembly or machine code following the blogOS guide trying to create a minimal kernel that ...
1
vote
0
answers
81
views
Debugging GDT in assembly/D lang
I've been dabbling with writing a small OS in D lang but I'm crashing on boot. I've been debugging my main file and think that the issue is with gdt_flush which is called in gdt.d and defined in gdt.s....
1
vote
0
answers
150
views
Function Call leads to infinite loop
I've been trying to get a program running on the QEMU emulator. The issue is that when I pass an empty string or a non-empty string to the print function, the program prints ABC indefinitely.
#[unsafe(...
2
votes
1
answer
180
views
Handling PCIe INTx interrupts (Virtual Wire Signaling) for AHCI without MSI/MSI-X (PIC-only mode)
I am writing an AHCI driver for a minimal kernel and need to handle PCIe interrupts without MSI, relying solely on the legacy PIC 8259 and PCIe INTx virtual wire signaling.
I have already implemented ...
3
votes
1
answer
88
views
Why does working Assembly code not work when loaded into different memory by disk read?
Problem
I have assembly code that switches to 32bit mode and prints a character successfully when I have it inside the boot sector -
But when I use a disk read to load the code to the next sector the ...
1
vote
0
answers
85
views
IDT in NASM assembly jumps to wrong address
I've been making a kernel in pure NASM assembly. And the problem lies in the IDT not jumping to the correct address and triple faulting (expected); and as shown in gdb, causes it to go at the wrong ...
0
votes
1
answer
49
views
Placement of %include in my NASM bootloader affects program behavior
I am learning to write a 16-bit bootloader using NASM with BIOS interrupts to print strings to the screen. I’ve created a simple print subroutine in an external file (printer.asm), and I'm using %...
2
votes
0
answers
76
views
From-VESA VBE Not Displaying Any Output as Intended
I've recently been working on a mini operating system written completely from scratch. After implementing a bootloader and minimalised kernel, I tested the whole program on GDB, with the breakpoint ...
1
vote
1
answer
111
views
How to enable paging in x86 Protected Mode
I'm progressing along developing my OS, and I recently implemented a virtual memory manager that handles paging. I used 2 Page Tables: (1) to identity map the first 4 MB and (2) to map the kernel (...
0
votes
0
answers
32
views
Issue when Porting Newlib (sys/crt0.o: No such file)
I'm trying to port Newlib following this tutorial after following this tutorial, and I'm running into an issue near the end. I'm at this step:
mkdir build-newlib
cd build-newlib
../newlib-x.y.z/...
2
votes
1
answer
171
views
x86 Page Fault with error code 0 when PRESENT flag is enabled and CR3 is correctly set
I'm developing an operating system and I'm taking 'Nanobyte OS' as a base because I had trouble with the toolchain and compilation system. The problem comes when loading an ELF, because it throws a ...
1
vote
1
answer
73
views
How do I output a character in protected mode in x86 Assembly (AT&T syntax)?
This is the code for a program that, when booted by a bootloader, disables interrupts, loads a GDT descriptor, enables the A20 Line, enables protected mode, and jumps into 32-bit code.
.code16
....
0
votes
1
answer
116
views
Why is a memset causing my higher-half kernel to page (interrupt 14)?
Currently, a memset to kernel_dir is causing my kernel to page fault. The kernel is a higher-half kernel, and is mapped to 0xC0000000 in virtual memory.
#include "paging.h"
#include "...
1
vote
1
answer
165
views
FDC (floppy disk controller) driver works on QEMU and VIRTUAL BOX but fails on BOCHS
I’m currently implementing a floppy disk controller (FDC) driver for my hobby OS, and I’ve run into a strange issue.
Here’s the driver source code:
👉 fdc.c on GitHub
After initializing the FDC via ...
4
votes
1
answer
113
views
How do I get the x86 current CPU mode (code bit size) using the GDB remote protocol?
I'm running qemu-system-i386 -s -S -singlestep (and sometimes qemu-system-x86_64), and I connect to it over TCP to address 127.0.0.1:1234 using the GDB remote protocol. I issue the g command to get (...
0
votes
0
answers
53
views
What is the cause of x86_64 CPU do not receive the interrupt after switching into user mode?
I want to switch into user mode from kernel mode by
switch_to_user_mode:
cli
mov ax, 0x23
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
push 0x23
push rdi
pushfq
...
1
vote
0
answers
63
views
What is causing the GPF error during switching into user mode?
I am developing a x86 architecture based 64 bit Operating System. I have implemented GDT(Null, Kernel-code, kernel-data, user-code, user-data, tss) . Now I want to switch into user space(Lower half ...
1
vote
0
answers
65
views
Segment selector pointing to invalid descriptor. GP# Fault occurs on STI
I am trying to setup GDT/IDT/Paging. Below code is what i do,
global start
global CODE_SEG
global isr_asm
global DATA_SEG
global loadGDT
global isr_wrapper
extern main
extern isr
section .text
bits ...
1
vote
0
answers
72
views
Bootloader Fails to Load More Than 53 Sectors Despite Modifications
https://github.com/UdayKhare09/EXO_OS is my repo.
I am working on a custom bootloader for my operating system, and I am encountering an issue where the bootloader fails to load more than 53 sectors ...
3
votes
1
answer
166
views
Returning from 32-bit protected mode to real mode without a far jump
I'm following the advice on https://wiki.osdev.org/Real_Mode to return from 32-bit protected mode to real mode. That code includes a far jump. My code looks like this now:
; At this point we are ...
1
vote
0
answers
93
views
KVM crashes with General Protection Fault when enabling paging in my 32-bit kernel. OSDEV
I'm writing a 32-bit OS kernel with support for PAE paging. When I enable paging with mov %eax, %cr0 (setting the PG bit), the kernel works fine under QEMU with TCG, but crashes with a General ...
0
votes
0
answers
76
views
what I do wrong when trying to switch in protected mode?
[ORG 0x7C00]
[BITS 16]
CODE_OFFSET equ 0x8
DATA_OFFSET equ 0x10
KERNEL_POS equ 0x1000 ; 4096 bits dec, 512 bytes
; loader - 512 size bytes,
; then kernel will placed to ...
4
votes
1
answer
136
views
Can't get welcome messages to load in QEMU
I am trying to make my own OS and am currently stuck on one tiny problem.
My welcome messages are not loading in the terminal.
Other than that, everything seems to work fine. (I'm not too sure, so ...
2
votes
1
answer
135
views
Issue when running Makefile on boot.asm, "init :: non dos media"
I've been trying to build a custom OS following the steps in this guide. However, I continue to get the following error from my Makefile,
init :: non DOS media
Cannot initialize '::' ::kernel.bin: ...
1
vote
1
answer
93
views
My Multiboot Info Structure is not correct. Why?
I am trying to write a physical allocator, and to do so I need the base address for available memory, the high address for available memory, and a memory map. This is all provided to me by the BIOS (...
0
votes
0
answers
40
views
If CLGI can block virtual interrupt or not?
amd sdm implies CLGI can block vINTR
Table 15-10 Effect of the GIF on Interrupt Handling
15.21.4 Injecting Virtual (INTR) Interrupts
The processor takes a virtual INTR interrupt if:
V_IRQ and ...
3
votes
1
answer
67
views
NASM+WCC+WLINK (OW 1.9): strange error addressing CONST data (wrong/even addressing)
I'm porting a tiny experimental 80286 kernel from pure assembler (NASM) to assembler+C (NASM+Open Watcom 1.9). Boot sector code loads the BIN kernel image at address 0x010000 and then jumps to that ...
2
votes
0
answers
80
views
How do I resolve the recursive dependency in my page frame allocator (custom OS)?
I’m developing a custom OS and facing a chicken-and-egg problem with my page frame allocator. I need to map a specific page, but if the corresponding PML4 entry is NULL, I must allocate a PDPT. ...
2
votes
0
answers
78
views
How could I resolve this round robin process switching?
I have made three threads inside of process init_thread, thread1, thread2 by below code
void init_processes() {
// Create the init process
process_t *process = create_process("process0&...
1
vote
0
answers
66
views
Keyboard Driver Not Switching to Scancode Set 2 (custom OS)
I'm developing an OS and encountering an issue with my PS/2 keyboard driver: despite attempting to set the keyboard to scancode set 2, it continues to send scancode set 1 codes.
Below is the function ...
3
votes
1
answer
92
views
Custom Bootloader Fails to Load C Kernel (kernel.c), But Works with Assembly (kernel.asm)
I'm writing a custom OS with my own bootloader and trying to switch from an assembly-based kernel (kernel.asm) to a C-based kernel (kernel.c).
When using kernel.asm, everything works fine. But when I ...
1
vote
0
answers
118
views
CPU Reset When Remapping the PIC Using Limine Bootloader in My OS
I'm currently developing an operating system that uses the limine bootloader and follows the limine boot protocol. However, I've encountered an issue: when I call init_PIC(), the CPU resets ...
0
votes
0
answers
41
views
Why does`LAPIC_SVR`, `LAPIC_TDCR`, `LAPIC_TICR`, `LAPIC_TCCR`, address value is zero even after write?
I am trying to enable periodic APIC Timer in x86 architecture based 64 bit OS.
void apic_timer_init(uint32_t frequency) {
disable_interrupts();
// Ensure APIC is enabled (set Spurious ...