#ifndef HAL_INTR_H_
#define HAL_INTR_H_

#define INTR_IRQBASE 0x20

#include "compiler/attr.h"

typedef struct {
  uint64_t r15;
  uint64_t r14;
  uint64_t r13;
  uint64_t r12;
  uint64_t r11;
  uint64_t r10;
  uint64_t r9;
  uint64_t r8;
  uint64_t rbp;
  uint64_t rdi;
  uint64_t rsi;
  uint64_t rdx;
  uint64_t rcx;
  uint64_t rax;
} PACKED SavedRegs;

typedef struct {
  SavedRegs regs;
  uint64_t trapnum;
  uint64_t errnum;
  uint64_t rip;
  uint64_t cs;
  uint64_t rflags;
  uint64_t rsp;
  uint64_t ss;
} PACKED IntrStackFrame;

void intr_attchhandler(void (*fn)(void), int irq);
void intr_init(void);

#endif // HAL_INTR_H_
