333 questions with no answers
1
vote
0
answers
101
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 ...
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 ...
0
votes
0
answers
137
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 (...
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 ...
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(...
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 ...
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 ...
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/...
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
64
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
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 ...
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
73
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 ...
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 ...
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 ...
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 ...
1
vote
0
answers
119
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 ...
2
votes
0
answers
104
views
Updating the Linear Frame Buffer much slower on real hardware than QEMU
I am currently booting my system into a 640x480x32b VESA mode with a linear frame buffer.
Using the following code, I flash red and green on the screen:
void clear(Color color) {
u8* cursor = ...
1
vote
0
answers
92
views
How can I get disk information by using limine bootloader?
I want to get disk information like no. of disks, size of disks, type of disk etc. I have read this doc but do not understand how can I get disk information by using limine bootloader. I have tried by ...
0
votes
0
answers
27
views
Why does switching Process is not working properly in this code?
I want to strat process with schedular so I have written following code
#define STACK_SIZE 16*1024 // 16 KB
process_t *process_list = NULL;
process_t *current_process = NULL;
uint64_t next_pid = 1;
...
1
vote
0
answers
82
views
Qemu emulator flickers when entering protected mode for custom bootloader
Currently I'm having a hard time with my bootloader after I enter protected mode by setting the lsb in register cr0 to 1. I perform a far jump to the kernel code segment as defined by jmp 0x8:...
2
votes
0
answers
111
views
What is the reason of general protection fault due to GDT selector 1113 in my x86_64 OS?
I am developing a x86 architecture based 64 bit Operating System which is using limine-8.6.0 bootloader. I have enabled GDT by
global gdt_flush
gdt_flush:
LGDT [RDI]
jmp reloadSegments
RET
...
1
vote
0
answers
88
views
Why could not I apply call gate successfully?
I am studying call gate in x86 asm now.
I try to use call gate to achieve a segment-to-segment transfer and the virtual machine I use is Bochs. Althougn I say it's a "segment-to-segment" ...
2
votes
0
answers
173
views
Making an IDT in assembly
I know this is naive but I want my entire OS code written in assembly and that includes the IDT, but I don't recall there having ever been an IDT in assembly so I used objconv but it outputs some code ...
0
votes
0
answers
66
views
ISR not returning properly
I get the error "check_cs(0x0020): not a valid code segment !" from Bochs after going through the isr for the timer: 0x20.
Here's the code for the isr:
void timer_isr() {
// Acknowledge ...
0
votes
0
answers
86
views
Why is `isr_common_stub` not calling my `isr_handler` function?
I want to enable IDT in x86_64 OS so I have written isr_common_stub function
isr_common_stub:
call save_registers
mov eax, 0x10 ; Load the kernel data segment descriptor
mov ...
1
vote
0
answers
168
views
Invariant Timestamp Counter is synchronised between cores of the same CPU?
I'm interested in how Invariant TSC behaves on a multi-core CPU, on a classic PC with a single physical CPU.
The only thing I could find is that its frequency is constant and the same for all CPU ...
0
votes
0
answers
72
views
Why pml4 pointer address(uint64_t) is not loading in cr3 register?
I am using limine bootloader to load my x86_64 Kernel. I want to use my custom Paging so I made following codes.
Structers
#define PML4_INDEX(va) (((va) >> 39) & 0x1FF) // Bits 39-47
#...
0
votes
0
answers
161
views
Bochs not showing any output on screen
this is my first question here
I am new to the operating system world, I am trying to run this basic bootloder
after one hour of troubleshooting I am in a situation that my simulator is opening, but ...
1
vote
0
answers
101
views
Handling the .bss Section in Raw Binary Formats and Freestanding Environments
When working in a raw/freestanding environment, I have a question about the .bss section in ELF files. If I link and set the output format to binary (not ELF), where will the .bss section be in the ...
1
vote
0
answers
92
views
Kernel Double Fault When Loading IDT - OS dev
I'm encountering a double fault in my kernel when loading the Interrupt Descriptor Table (IDT). The interrupt handler outputs the following error:
Got Signal: Double Fault (4144)
Since a double fault ...
0
votes
0
answers
60
views
CPU jumping in garbage after interrupt
I am trying to make an IDT, but when i trigger an interrupt it goes to a location i don't know. I am in 32-bit protected mode using and i am using QEMU.
I have created only one entry for the moment, ...
1
vote
0
answers
59
views
Map an address to itself in protected mode?
I'm experimenting with Linux kernel, trying to reduce its codebase to a minimal "hello, world" that is made of as few files as possible, so that I can get a good understanding of its build ...
2
votes
0
answers
167
views
How to solve Triple fault in my x86_64 OS GDT?
I want to enable GDT in x86_64 OS by init_gdt() function in kernel.c Where, gdt_entry_t is looks
struct gdt_entry_struct
{// 128 Bit
uint64_t limit_low :16; // limit = 16+4 = 20
...
1
vote
0
answers
121
views
Using global variables after booting from GRUB before setting up the GDT
I'm writing a toy-kernel and the first step would be to set-up the GDT. Obviously I will be using variables on the stack to initialize the GDT; for which, a GDT must already be set up, which is indeed ...
1
vote
0
answers
92
views
My VGA driver set_char_in_mem function is not taking s[i] as input
So i am following a blog about building an os trying to build a simple kernel.I am on step 2 and am using VGA to display things
the function setcharinmem.
When i pass 'a' in it displays normally but ...
0
votes
0
answers
60
views
Keyboard driver not printing anything on my x64 OS
I have recently made an x86-64 OS and wanted to create a keyboard driver. I made basic logic for it and make it register its handler into IRQ1 tried it no faults were made but inside QEMU when I tap a ...
0
votes
0
answers
118
views
Custom bootloader doesn't load second sector while using FAT12
I am learning how an operating system works. So I started by writing a bootloader. Everything was working fine until I tried to format my image containing my stages 1 and 2 in FAT12.
Currently the ...
2
votes
0
answers
106
views
How to Remap Kernel to Virtual Address 0xC0000000 in My Paging Setup?
I'm working on implementing paging for my custom 32-bit kernel. Currently, my kernel is loaded at the physical address 0x100000 (1MB), and I want to remap it to the virtual address 0xC0000000 after ...
2
votes
0
answers
91
views
How to work with audio in my os i386 (for example, sound blaster 16)
I need a way to play sound at a certain frequency for a while in C without libraries (the most important thing). How can this be implemented, for example, on the sound blaster 16 audio card (AC97 is ...
2
votes
0
answers
164
views
Kernel Not Loading Properly at 1MB in Bootloader – Showing Empty Memory in QEMU
I am working on building a simple bootloader that loads a kernel from disk into memory at the 1MB mark (0x100000). The bootloader consists of two stages: Stage 1 reads the second stage, and Stage 2 ...
0
votes
0
answers
79
views
Protected Mode Not Enabled
I am developing a custom bootloader for my 64-bit OS in x86_64 NASM on macOS aarch64 (yup, LLDB is only available to me) environment using QEMU. The bootloader is a 2-stage.
Current Behavior
Prints '...
1
vote
0
answers
142
views
Stage 2 Bootloader Does Not Jump Into the Kernel Entry Correctly
I am developing a custom bootloader for my 64-bit OS in x86_64 NASM on macOS environment using QEMU. The bootloader is a 2-stage, and is designed to load operating systems from disks. I am ...
1
vote
0
answers
74
views
Can't print to VGA memory outside main asm file
I'm getting into OS Develop and recently finished writing my bootloader, now I started to make the kernel. The first thing I've decided to implement was writing text from my kernel_main.cpp (using VGA ...