summaryrefslogtreecommitdiff
path: root/cpu/amd/geode_lx/gplvsa_ii/legacy/virtregs.c
blob: 04ee3633e91592457464c71ebac85a5fbfa48fa8 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* 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 
*/

//*   Function:                                                         *
//*     This file handles virtual registers. 

#include "vsa2.h"
#include "chipset.h"
#include "vr.h"
#include "protos.h"
#include "acpi.h"

extern void Handle_Misc_VR(UCHAR, USHORT);
extern void Handle_SysInfo_VR(UCHAR);
extern void Handle_5536_UART(UCHAR, UCHAR, USHORT);

extern USHORT PCI_Int_AB, PCI_Int_CD;
extern USHORT DiskTimeout, SerialTimeout, ParallelTimeout, FloppyTimeout;
USHORT WatchDogDelay;

void Handle_VirtualRegs(UCHAR Class, UCHAR Index, UCHAR WrFlag, USHORT Data)
{
  ULONG Param[MAX_MSG_PARAM];  // Select on virtual register class
  switch (Class) {

    case VRC_MISCELLANEOUS:
      if (WrFlag) {
        if (Index == WATCHDOG) {
          static ULONG WatchDogKey=0;
          ULONG Key;

          Key = GET_REGISTER(R_ECX);
          if (WatchDogKey) {
            // The key has already been set...check it
            if (WatchDogKey != Key) {
/*MEJ              // Broadcast to all VSM's
              Param[0] = S5_STATE;
              Param[1] = CLASS_ALL;
              SYS_BROADCAST_MSG(MSG_SET_POWER_STATE, &Param[0], VSM_ANY);
*/
            }
          } else {
            // Set the key (only once)
            WatchDogKey = Key;
          }
          WatchDogDelay = Data;
          SYS_REGISTER_EVENT(EVENT_TIMER, WatchDogDelay*1000L, ONE_SHOT, 0);
          break;
        }
        Handle_Misc_VR(Index, Data);
      } else {
        switch (Index) {
          case PCI_INT_AB:
            SET_AX(PCI_Int_AB);
            break;

          case PCI_INT_CD:
            SET_AX(PCI_Int_CD);
            break;

          case WATCHDOG:
            SET_AX(WatchDogDelay);
            break;
        }
      }
      break;

    case VRC_PM:
      // Ignore READs
      if (WrFlag) {
/*MEJ        switch (Index) {
          case DISK_TIMEOUT:
            DiskTimeout = Data;
            break;

          case SERIAL_TIMEOUT:
            SerialTimeout = Data;
            break;

          case PARALLEL_TIMEOUT:
            ParallelTimeout = Data;
            break;

          case FLOPPY_TIMEOUT:
            FloppyTimeout = Data;
            break;
        }
*/
      }
      break;

    case VRC_SYSINFO:
      if (!WrFlag) {
        Handle_SysInfo_VR(Index);
      }
      break;


    case VRC_CHIPSET:
      switch (Index) {
        case VRC_CS_UART1:
        case VRC_CS_UART2:
          Handle_5536_UART(Index, WrFlag, Data);
          break;

      }
      break;
  }
}