Copyright (c) Hyperion Entertainment and contributors.

How to install a hardware interrupt

From AmigaOS Documentation Wiki
Jump to navigation Jump to search

Author

Alfkil Wennermark
Copyright (c) 2010 Alfkil Wennermark
Used by permission.

Article

I was looking for a way to install a genuine hw interrupt, and this code is the proper way to do so. Thanks to Steven Solie, Thomas Frieden, Jörg Strohmayer and Colin Wenzel.

When trying to install an exec interrupt handler, I quickly realised, that the IExec->AddIntServer didn't really do the job. All the trapnumbers defined in exec/interrupts.h will make this function fail, except for TRAPNUM_ILLEGAL_INSTRUCTION, that has no relevance on ppc machines.

After some (a lot of) guidance from the real people, I have come up with this example, that uses SetIntVector to install a global interrupt handler for that particular interrupt. Beware, when you use SetIntVector, you _have to_ manually call the old interrupt handler (returned from SetIntVector) if you don't want your entire system to go boom!

Also, if you are trying to catch exceptions from a specific task (eg. for debugging purposes) you should use the AddDebugHook function from the exec debug interface (more on this in a future article).

Here is the example: