interrupts.inc 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. (*
  2. $Id: interrupts.inc 25 2007-12-10 21:06:46Z p4p3r0 $
  3. ------------------------------------------------------------------------------
  4. Copyright (C) 2005
  5. Jason Rogers (dovoto)
  6. Dave Murphy (WinterMute)
  7. This software is provided 'as-is', without any express or implied
  8. warranty. In no event will the authors be held liable for any
  9. damages arising from the use of this software.
  10. Permission is granted to anyone to use this software for any
  11. purpose, including commercial applications, and to alter it and
  12. redistribute it freely, subject to the following restrictions:
  13. 1. The origin of this software must not be misrepresented; you
  14. must not claim that you wrote the original software. If you use
  15. this software in a product, an acknowledgment in the product
  16. documentation would be appreciated but is not required.
  17. 2. Altered source versions must be plainly marked as such, and
  18. must not be misrepresented as being the original software.
  19. 3. This notice may not be removed or altered from any source
  20. distribution.
  21. ------------------------------------------------------------------------------
  22. Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
  23. (http://www.freepascal.org)
  24. Copyright (C) 2006 Francesco Lombardi
  25. Check http://sourceforge.net/projects/libndsfpc for updates
  26. ------------------------------------------------------------------------------
  27. $Log$
  28. *)
  29. {$ifdef NDS_INTERFACE}
  30. type
  31. IRQ_MASKS = cuint;
  32. IRQ_MASK = IRQ_MASKS;
  33. const
  34. IRQ_VBLANK : IRQ_MASK = (1 shl 0); (* vertical blank interrupt mask *)
  35. IRQ_HBLANK : IRQ_MASK = (1 shl 1); (* horizontal blank interrupt mask *)
  36. IRQ_VCOUNT : IRQ_MASK = (1 shl 2); (* vcount match interrupt mask *)
  37. IRQ_TIMER0 : IRQ_MASK = (1 shl 3); (* timer 0 interrupt mask *)
  38. IRQ_TIMER1 : IRQ_MASK = (1 shl 4); (* timer 1 interrupt mask *)
  39. IRQ_TIMER2 : IRQ_MASK = (1 shl 5); (* timer 2 interrupt mask *)
  40. IRQ_TIMER3 : IRQ_MASK = (1 shl 6); (* timer 3 interrupt mask *)
  41. IRQ_NETWORK : IRQ_MASK = (1 shl 7); (* serial interrupt mask *)
  42. IRQ_DMA0 : IRQ_MASK = (1 shl 8); (* DMA 0 interrupt mask *)
  43. IRQ_DMA1 : IRQ_MASK = (1 shl 9); (* DMA 1 interrupt mask *)
  44. IRQ_DMA2 : IRQ_MASK = (1 shl 10); (* DMA 2 interrupt mask *)
  45. IRQ_DMA3 : IRQ_MASK = (1 shl 11); (* DMA 3 interrupt mask *)
  46. IRQ_KEYS : IRQ_MASK = (1 shl 12); (* Keypad interrupt mask *)
  47. IRQ_CART : IRQ_MASK = (1 shl 13); (* GBA cartridge interrupt mask *)
  48. IRQ_IPC_SYNC : IRQ_MASK = (1 shl 16); (* IPC sync interrupt mask *)
  49. IRQ_FIFO_EMPTY : IRQ_MASK = (1 shl 17); (* Send FIFO empty interrupt mask *)
  50. IRQ_FIFO_NOT_EMPTY : IRQ_MASK = (1 shl 18); (* Receive FIFO empty interrupt mask *)
  51. IRQ_CARD : IRQ_MASK = (1 shl 19); (* interrupt mask *)
  52. IRQ_CARD_LINE : IRQ_MASK = (1 shl 20); (* interrupt mask *)
  53. IRQ_GEOMETRY_FIFO : IRQ_MASK = (1 shl 21); (* geometry FIFO interrupt mask *)
  54. IRQ_LID : IRQ_MASK = (1 shl 22); (* interrupt mask *)
  55. IRQ_SPI : IRQ_MASK = (1 shl 23); (* SPI interrupt mask *)
  56. IRQ_WIFI : IRQ_MASK = (1 shl 24); (* WIFI interrupt mask (ARM7)*)
  57. IRQ_ALL : IRQ_MASK = $FFFFFF {not 0};
  58. const
  59. MAX_INTERRUPTS = 25;
  60. const
  61. REG_IE : pcuint32 = pointer($04000210);
  62. REG_IF : pcuint32 = pointer($04000214);
  63. REG_IME : pcuint16 = pointer($04000208);
  64. type
  65. IME_VALUE = integer;
  66. const
  67. IME_DISABLE : IME_VALUE = 0; (* Disable all interrupts. *)
  68. IME_ENABLE : IME_VALUE = 1; (* Enable all interrupts not masked out in REG_IE *)
  69. var
  70. // __irq_vector: array [0..0] of VoidFunctionPointer; cvar; external;
  71. // __irq_vector: array [0..0] of Pointer; cvar; external;
  72. // __irq_flags: array [0..0] of cuint32; cvar; external;
  73. // __irq_flags: pcuint32; cvar; external;
  74. // __irq_vector: ^VoidFunctionPointer; cvar; external;
  75. __irq_vector: Pointer; cvar; external;
  76. __irq_flags: pcuint32; cvar; external;
  77. {$define VBLANK_INTR_WAIT_FLAGS := __irq_flags}
  78. {$define IRQ_HANDLER := __irq_vector}
  79. type
  80. IntTable = record
  81. handler: IntFn;
  82. mask: cuint32;
  83. end;
  84. procedure irqInit(); cdecl; external;
  85. //procedure irqSet(irq: IRQ_MASK; handler: VoidFunctionPointer); cdecl; external;
  86. procedure irqSet(irq: IRQ_MASK; handler: pointer); cdecl; external;
  87. procedure irqClear(irq: IRQ_MASK); cdecl; external;
  88. //procedure irqInitHandler(handler: VoidFunctionPointer); cdecl; external;
  89. procedure irqInitHandler(handler: pointer); cdecl; external;
  90. procedure irqEnable(irq: cuint32); cdecl; external;
  91. procedure irqDisable(irq: cuint32); cdecl; external;
  92. {$endif NDS_INTERFACE}