[SeaBIOS] How to add user-defined interrupt to SeaBIOS?

Kevin O'Connor kevin at koconnor.net
Sun Dec 12 20:25:10 CET 2010

On Wed, Dec 08, 2010 at 06:00:04PM +0100, Andreas H. wrote:
> Hi,
> as part of a small exercise project for university I have to add a
> custom software interrupt to the bios code which is then used by some
> later booting stages. I already had a close look to the sourcefiles
> and although I don't understand many of the stuff (I can read and
> understand the individual parts but don't get the real big picture) I
> have some anchorpoints which I think are necessary to complete my
> work. I'd really appreciate if someone had a quick look on those
> points and just confirmed or denied (maybe with other hints) them :)
> 1.) the IVT is set up in "post.c", to add my interrupt, I have to add
> a line "SET_IVT(0x60, FUNC16(entry_60));" to init_ivt()


> 2.) romlayout.S contains the declarations for the IRQ handler, I have
> to add a "DECL_IRQ_ENTRY_ARG 60" to the section "irqentryarg:"

Anywhere in romlayout.S.  ("irqentryarg:" is a goto label, not a
section definition.)

> 3.) in my own .c-file I have to add a function "void VISIBLE16
> handle_60(struct bregs *regs)" which receives the IRQ


> 4.) in this custom function I receive the set parameters from the
> caller in the register-structure and also set my return values in this


> 5.) usable registers for arguments/return values are AX, BX, CX, DX,
> DS, etc. I'd need DS:DX (analog to DOS) for passing a memory address
> and CS:CX for a buffer size.

You can read/set any registers in "struct bregs" - whatever your
handler needs.

> 6.) the IRQ handler has to end with "set_success(regs);" or
> "set_invalid(regs);" to return success/failure in CF (or should I use
> AX for this and just call set_success?)

What to return is up to you.  The set_success/set_invalid calls are
just wrappers around manipulating CF in the "struct bregs".

> One last question: I chose IRQ 60 because it's stated as "user
> defined" in "post.c". Should I use another one to not run into issues
> with later stages of OS booting or will it just get overwritten at
> some point?

It's really hard to say what's appropriate - the best I can do is
point you to Ralph Brown's Interrupt list:



More information about the SeaBIOS mailing list