summaryrefslogtreecommitdiff
path: root/cpu/amd/geode_lx/gplvsa_ii/sysmgr/mapper.c
blob: bc1e9bcf0d3e78a896476de3b0ca6a22d49ead82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* Copyright (c) 2006-2008 Advanced Micro Devices,Inc. ("AMD").
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of the
* License, or (at your option) any later version.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.

* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA 
*/

//******************************************************************************
//*     This file contains code specific to the IRQ Mapper  
//******************************************************************************

#include "VSA2.H"
#include "SYSMGR.H"
#include "PROTOS.H"
#include "VPCI.H"
#include "PCI.H"
#include "MDD.H"
#include "MAPPER.H"
#include "ISA.H"

// Local Variables:
UCHAR PCI_INTs[4] = {0,0,0,0};   // Current PCI INT mappings
UCHAR Max_PCI_Interrupt=4;

// External Variables:
extern ULONG MDD_Base;
extern USHORT Saved_AX;




// External Functions:
void PCI_Interrupts(void);



//************************************************************************************
// Maps an Unrestricted Source to a PIC IRQ via the IRQ Mapper logic
//************************************************************************************
void pascal IRQ_Mapper(UCHAR Reg, UCHAR Source, UCHAR Irq)
{ ULONG MsrAddr, MsrData;
  UCHAR ShiftCount;

  // 8 sources per MSR 
  Reg += Source/8;

  MsrAddr = MDD_Base + Reg;

  // 4 bits per field
  ShiftCount = (Source % 8) * 4;

  // Map Unrestricted Source[Source] to Irq via IRQ Mapper
  MsrData = Read_MSR_LO(MsrAddr);
  MsrData &= ~(0x0000000FL << ShiftCount);
  MsrData |=  (ULONG)Irq   << ShiftCount;
  Write_MSR_LO(MsrAddr, MsrData);
}

//************************************************************************************
// Maps an Unrestricted Source Y to a PIC IRQ
//************************************************************************************
void pascal IRQY_Mapper(UCHAR Y_Source, UCHAR Irq)
{ 
  IRQ_Mapper(MSR_IRQM_YLOW, Y_Source, Irq);
}


//************************************************************************************
// Maps an Unrestricted Source Z to a PIC IRQ
//************************************************************************************
void pascal IRQZ_Mapper(UCHAR Z_Source, UCHAR Irq)
{
  IRQ_Mapper(MSR_IRQM_ZLOW, Z_Source, Irq);
}



//************************************************************************************
// Implements the SYS_GENERATE_IRQ macro for CS5536
//************************************************************************************
void pascal Generate_IRQ_5536(USHORT IRQ_Mask) 
{ UCHAR Irq=0;
  USHORT Level;
  
  Level = in_16(PIC1_EDGE);

  // Don't attempt to generate a level-sensitive interrupt
  if (IRQ_Mask & Level) {
    Log_Error("Attempt to generate a level-sensitive IRQ. Mask= 0x%04X", IRQ_Mask);
    return;
  }       

  while (IRQ_Mask) {
    if (IRQ_Mask & 1) {
      // Map the software IRQ to the requested IRQ
      IRQY_Mapper(Y_IRQ_SW, Irq);

      // Generate an edge to the PIC
      Write_MSR_LO(MDD_Base + MSR_SOFT_IRQ, 0L);
      Write_MSR_LO(MDD_Base + MSR_SOFT_IRQ, 1L);
    }
    IRQ_Mask >>= 1;
	Irq++;
  }
}