Search code examples
cassemblyoperating-systeminterruptlow-level

How to reset IVT in asm ? without relaunch the computer


I am creating an operating system in c and asm, I have a problem with my IVT I am thinking it's corrupt. So I want to reinitialize IVT without relaunch the computer I don't really know if it's possible because I found nothing on google. Thank you for your answers


Solution

  • For the obsolete BIOS there's no way to do it without some kind of reset (which could be a "warm reset" rather than a "cold reset", which is faster but still prevents your code from continuing).

    For alternatives; you can:

    a) create a copy of the old IVT yourself (e.g. early during boot when you know it's still good) and restore it from the copy. This could also be used for detecting if/when/where the IVT became corrupted (e.g. compare the IVT to your copy at various places in your code, so that you can figure out something like "it was good before I called foo() but corrupted after foo() returned, and the corruption was at address 0x00123".

    b) calculate a checksum of the IVT and use that to determine if/when the IVT was modified (without being able to restore the IVT).

    c) if you know a specific part of the IVT is being corrupted; set up the CPU's debug registers to generate a trap exception when that part of the IVT is modified. This is more complicated (you'd have to hook/replace the interrupt handler for "interrupt 0x01").

    d) Use an emulator with a debugger (Bochs, Qemu, VirtualBox) that allows you to single-step and inspect memory, and/or set breakpoints (including "break when data at address .... is modified"), to find out if/when the IVT is being corrupted.

    e) Find the problem using "desk checking" (reading and analyzing the source code looking for bugs that can explain the symptoms). This is probably the best way because you might find other bugs too; and because there shouldn't be much code to check anyway (typically it's a few KiB in a boot loader that's executed before the OS takes control of the hardware, reconfigures the hardware so the BIOS can't work anyway, then starts treating the memory that contained the IVT as "free RAM" that is recycled/allocated for any other purpose).