ISR trouble

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Shvets04
Member
Member
Posts: 28
Joined: Wed Feb 13, 2019 3:07 pm

ISR trouble

Post by Shvets04 »

When i get interrupt i have that output on a screen. https://ibb.co/1bPsH5Z.
How to fix it?

OS github - https://github.com/s04v/locOS
tabz
Member
Member
Posts: 35
Joined: Fri Apr 20, 2018 9:15 am
Location: Cambridge, UK

Re: ISR trouble

Post by tabz »

You should narrow down the problem a bit more. What source line is the page fault happening on? etc.
MichaelPetch
Member
Member
Posts: 798
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: ISR trouble

Post by MichaelPetch »

I recommended BOCHS for debugging, but stepping through the code in QEMU would have found this as well. In kernel.c

Code: Select all

u32 *ptr = (u32*)0xA00000;
should have been:

Code: Select all

u32 *ptr = (u32*)0xA0000;
You had one too many zeroes and your original memory address was not mapped, thus the page fault.
A few changes to your Makefile to improve/enable debugging with QEMU, and some cleanup:

Code: Select all

C_SOURCES = $(wildcard kernel/*.c drivers/*.c cpu/*.c shell/*.c mm/*.c)
HEADERS = $(wildcard kernel/*.h drivers/*.h cpu/*.h shell/*.h mm/*.h)
# Nice syntax for file extension replacement
OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o}

# Change this if your cross-compiler is somewhere else
CC = gcc
GDB = gdb
# -g: Use debugging symbols in gcc
CFLAGS = -g -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector \
         -nostartfiles -nodefaultlibs -std=gnu99 -fno-PIC
# First rule is run by default
os-image.bin: boot/boot.bin kernel.bin
        cat $^ > os-image.bin

# '--oformat binary' deletes all symbols as a collateral, so we don't need
# to 'strip' them manually on this case
kernel.bin: kernel.elf
        objcopy -O binary $^ $@
# or you can use:
#       ld -melf_i386 -o $@ -T link.ld $^ --oformat binary

# Used for debugging purposes
kernel.elf: kernel/kernel.o ${OBJ}
        ld -melf_i386 -o $@ -T link.ld $^

run: os-image.bin
        qemu-system-i386 -fda os-image.bin

# Open the connection to qemu and load our kernel-object file with symbols
debug: os-image.bin kernel.elf
        qemu-system-i386 -s -fda os-image.bin &
        ${GDB} kernel.elf \
           -ex "target remote localhost:1234" \
           -ex "b start" \
           -ex "continue"
# If running from a terminal use these layouts to improve the debug experience
# by placing them before -ex "continue"
#           -ex "layout src" \
#           -ex "layout reg" \

# Generic rules for wildcards
# To make an object, always compile from its .c
%.o: %.c ${HEADERS}
        ${CC} ${CFLAGS} -ffreestanding -c $< -o $@

%.o: %.asm
        nasm $< -f elf -Fdwarf -g -o $@

%.bin: %.asm
        nasm $< -f bin -o $@

clean:
        rm -rf *.bin *.dis  os-image.bin *.elf
        rm -rf  boot/*.bin drivers/*.o boot/*.o cpu/*.o mm/*.o shell/*.o kernel/*.o
Post Reply