|
|
1.1 root 1: /*
2: Hatari - cycInt.h
3:
1.1.1.5 root 4: This file is distributed under the GNU General Public License, version 2
5: or at your option any later version. Read the file gpl.txt for details.
1.1 root 6: */
7:
8: #ifndef HATARI_CYCINT_H
9: #define HATARI_CYCINT_H
10:
11: /* Interrupt handlers in system */
12: typedef enum
13: {
14: INTERRUPT_NULL,
15: INTERRUPT_VIDEO_VBL,
16: INTERRUPT_VIDEO_HBL,
17: INTERRUPT_VIDEO_ENDLINE,
18: INTERRUPT_MFP_TIMERA,
19: INTERRUPT_MFP_TIMERB,
20: INTERRUPT_MFP_TIMERC,
21: INTERRUPT_MFP_TIMERD,
1.1.1.5 root 22: INTERRUPT_ACIA_IKBD,
1.1 root 23: INTERRUPT_IKBD_RESETTIMER,
24: INTERRUPT_IKBD_AUTOSEND,
1.1.1.4 root 25: INTERRUPT_DMASOUND_MICROWIRE, /* Used for both STE and Falcon Microwire emulation */
1.1 root 26: INTERRUPT_CROSSBAR_25MHZ,
27: INTERRUPT_CROSSBAR_32MHZ,
28: INTERRUPT_FDC,
29: INTERRUPT_BLITTER,
30: INTERRUPT_MIDI,
31:
32: MAX_INTERRUPTS
33: } interrupt_id;
34:
35:
36: #define INT_CPU_CYCLE 1
37: #define INT_MFP_CYCLE 2
1.1.1.7 ! root 38: #define INT_CPU8_CYCLE 3
1.1 root 39:
40: #define INT_CPU_TO_INTERNAL 9600
41: #define INT_MFP_TO_INTERNAL 31333
42:
1.1.1.7 ! root 43: #ifdef OLD_CPU_SHIFT
! 44:
1.1 root 45: /* Convert cpu or mfp cycles to internal cycles */
46: #define INT_CONVERT_TO_INTERNAL( cyc , type ) ( type == INT_CPU_CYCLE ? (cyc)*INT_CPU_TO_INTERNAL : (cyc)*INT_MFP_TO_INTERNAL )
47: /*
48: #define INT_CONVERT_TO_INTERNAL( cyc , type ) ( type == INT_CPU_CYCLE ? cyc*INT_CPU_TO_INTERNAL :\
49: ( ( (cyc*INT_MFP_TO_INTERNAL + INT_CPU_TO_INTERNAL*4 - 1) / (INT_CPU_TO_INTERNAL*4) ) * INT_CPU_TO_INTERNAL*4 ) )
50: */
51:
52: /* Convert internal cycles to real mfp or cpu cycles */
53: /* Rounding is important : for example 9500 internal is 0.98 cpu and should give 1 cpu cycle, not 0 */
54: /* so we do (9500+9600-1)/9600 to get the closest higher integer */
55: //#define INT_CONVERT_FROM_INTERNAL( cyc , type ) ( type == INT_CPU_CYCLE ? (cyc+INT_CPU_TO_INTERNAL-1)/INT_CPU_TO_INTERNAL : (cyc+INT_MFP_TO_INTERNAL-1)/INT_MFP_TO_INTERNAL )
56: #define INT_CONVERT_FROM_INTERNAL( cyc , type ) ( type == INT_CPU_CYCLE ? (cyc)/INT_CPU_TO_INTERNAL : ((cyc)+INT_MFP_TO_INTERNAL-1)/INT_MFP_TO_INTERNAL )
57:
1.1.1.7 ! root 58: #else /* ! OLD_CPU_SHIFT */
! 59:
! 60: /* Convert cpu or mfp cycles to internal cycles */
! 61: #define INT_CONVERT_TO_INTERNAL( cyc , type ) ( type == INT_CPU_CYCLE ? (cyc)*INT_CPU_TO_INTERNAL : \
! 62: type == INT_MFP_CYCLE ? ( (cyc)*INT_MFP_TO_INTERNAL ) << nCpuFreqShift : \
! 63: ( (cyc)*INT_CPU_TO_INTERNAL ) << nCpuFreqShift )
! 64:
! 65: //#define INT_CONVERT_TO_INTERNAL( cyc , type ) ( ( type == INT_CPU_CYCLE ? (cyc)*INT_CPU_TO_INTERNAL : (cyc)*INT_MFP_TO_INTERNAL ) << nCpuFreqShift )
! 66: //#define INT_CONVERT_TO_INTERNAL_NO_FREQSHIFT( cyc , type ) ( type == INT_CPU_CYCLE ? (cyc)*INT_CPU_TO_INTERNAL : (cyc)*INT_MFP_TO_INTERNAL )
! 67:
! 68: /* Convert internal cycles to real mfp or cpu cycles */
! 69: /* Rounding is important : for example 9500 internal is 0.98 cpu and should give 1 cpu cycle, not 0 */
! 70: /* so we do (9500+9600-1)/9600 to get the closest higher integer */
! 71: //#define INT_CONVERT_FROM_INTERNAL( cyc , type ) ( type == INT_CPU_CYCLE ? (cyc+INT_CPU_TO_INTERNAL-1)/INT_CPU_TO_INTERNAL : (cyc+INT_MFP_TO_INTERNAL-1)/INT_MFP_TO_INTERNAL )
! 72: //#define INT_CONVERT_FROM_INTERNAL( cyc , type ) ( ( type == INT_CPU_CYCLE ? (cyc)/INT_CPU_TO_INTERNAL : ((cyc)+INT_MFP_TO_INTERNAL-1)/INT_MFP_TO_INTERNAL ) >> nCpuFreqShift )
! 73:
! 74: #define INT_CONVERT_FROM_INTERNAL( cyc , type ) ( type == INT_CPU_CYCLE ? (cyc)/INT_CPU_TO_INTERNAL : \
! 75: type == INT_MFP_CYCLE ? ( ((cyc)+INT_MFP_TO_INTERNAL-1)/INT_MFP_TO_INTERNAL ) >> nCpuFreqShift : \
! 76: ( (cyc)/INT_CPU_TO_INTERNAL ) >> nCpuFreqShift )
! 77:
! 78: #endif
1.1 root 79:
80:
81: extern void (*PendingInterruptFunction)(void);
82: extern int PendingInterruptCount;
83:
84: extern void CycInt_Reset(void);
85: extern void CycInt_MemorySnapShot_Capture(bool bSave);
86: extern void CycInt_AcknowledgeInterrupt(void);
87: extern void CycInt_AddAbsoluteInterrupt(int CycleTime, int CycleType, interrupt_id Handler);
88: extern void CycInt_AddRelativeInterrupt(int CycleTime, int CycleType, interrupt_id Handler);
89: extern void CycInt_AddRelativeInterruptWithOffset(int CycleTime, int CycleType, interrupt_id Handler, int CycleOffset);
1.1.1.6 root 90: extern void CycInt_ModifyInterrupt(int CycleTime, int CycleType, interrupt_id Handler);
1.1 root 91: extern void CycInt_RemovePendingInterrupt(interrupt_id Handler);
92: extern void CycInt_ResumeStoppedInterrupt(interrupt_id Handler);
93: extern bool CycInt_InterruptActive(interrupt_id Handler);
1.1.1.7 ! root 94: extern int CycInt_GetActiveInt(void);
1.1 root 95: extern int CycInt_FindCyclesPassed(interrupt_id Handler, int CycleType);
96:
97: #endif /* ifndef HATARI_CYCINT_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.