summaryrefslogtreecommitdiff
path: root/cpu/amd/geode_lx/gplvsa_ii/lxvg/vsa2.c
blob: 91cfb9856829e8487eb5f4d318bccc19af66fb84 (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
132
133
/*
* 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 module contains the main code to handle the VSA II interface.


#include "vsa2.h"
#include "vr.h"
#include "lxvg.h"

// This is required here because of inclusion problems in LXVG.h
extern Hardware SystemInfo;

// ARRAY TO STORE VSA II MESSAGE PARAMETERS
unsigned long VSAparam[MAX_MSG_PARAM];


//---------------------------------------------------------------------------
// vsa2_message_loop
//
// This is the main routine that handles the VSA II message interface.
//---------------------------------------------------------------------------

void vsa2_message_loop(void)
{
	MSG Msg;

	// SPIN FOREVER ON MESSAGE LOOP
	// The VSA system manager branches here after loading the VSM.	Control
	// is returned to the system manager using an SMI.

	do {

		// GET THE NEXT MESSAGE
		// If a message is available, the macro reads the parameter data
		// from the VSM header and copies it to the VSAparam global array.
		// If a message is not available, control returns to the main VSA
		// dispatcher.
		Msg = SYS_GET_NEXT_MSG(&VSAparam);

		// DECODE THE MESSAGE
		switch(Msg)
		{
			case MSG_INITIALIZE:

				// CHECK IF NORMAL INITIALIZATION
				// Currently there is no "end of post" initialization.
				if (VSAparam[0] == EARLY_INIT)	{

					// Get information about the system I'm executing on.
					SYS_GET_SYSTEM_INFO(&SystemInfo);

					// REGISTER FOR VGA VIRTUAL REGISTER EVENTS
					SYS_REGISTER_EVENT(EVENT_VIRTUAL_REGISTER, VRC_VG, 0, NORMAL_PRIORITY);

				}
				else
				{
					// Now we can handle DPMS and driver active
					VGState |= SF_END_POST;
				}
				break;

			case MSG_EVENT:

				// DECODE THE EVENT
				decode_vsa2_event();
				break;

			case MSG_WARM_BOOT:
				break;


			default:
				break;
		}


	} while(1);
}

//---------------------------------------------------------------------------
// decode_vsa2_event
//
// This routine is called when the message loop receives an event. For
// LXVG, this is either a Virtual Rgister event or a pci event
// (trapping PCI config cycles to our device).
//---------------------------------------------------------------------------

void decode_vsa2_event(void)
{
	// PARSE EVENT

	switch((unsigned short)VSAparam[0])
	{
		case EVENT_VIRTUAL_REGISTER:
			if (VRC_VG == (unsigned char)(VSAparam[1] >> 8))
				virtual_register_event((unsigned char)VSAparam[1], VSAparam[2], VSAparam[3]);

			break;

		case EVENT_PCI_TRAP:
			// If LXVG isn't enabled, just leave
			if (VGState & SF_DISABLED) break;

			// CALL LXVG TO DECODE THE PCI TRAP EVENT
			// address = VSAparam[1]
			// size = VSAparam[2], bit 7 indicates write.
			// data = VSAparam[3]

			pci_trap_event(VSAparam[1], VSAparam[2], VSAparam[3]);
			break;

		default:
			break;
	}
}