summaryrefslogtreecommitdiff
path: root/tests/aapits/asl/tblm0037.asl
blob: 0aa3443ae58638e27e801a8ac938f6f197bb5345 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
DefinitionBlock(
	"tblm0037.aml",   // Output filename
	"DSDT",     // Signature
	0x02,       // DSDT Revision
	"Intel",    // OEMID
	"Many",     // TABLE ID
	0x00000001  // OEM Revision
	) {

	/*
	 * ACPICA API Test Suite.
	 * Support Table Management test 0037.
	 * Implements the following functional ASL Methods:
	 * INIT - preparing for emulation of a initialy loaded SSDT in an OpRegion,
	 * LD - loading the next modified SSDT by Load ASL operator,
	 */

	Name(BUF0, Buffer() {
	    0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000    "SSDT0..." */
		0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008    "..Intel." */
		0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010    "Many...." */
		0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018    "....INTL" */
		0x24,0x04,0x03,0x20,0x14,0x0B,0x53,0x53, /* 00000020    "$.. ..SS" */
		0x30,0x30,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028    "00.p..`." */
	})

	Name (HI0M, 100)
	Name (HI0P, Package(HI0M){})
	Name (HI0N, 0)
	Name (INIF, 0x00)

	OperationRegion (IST0, SystemMemory, 0, 0x1FA)

	Field(IST0, ByteAcc, NoLock, Preserve) {
		RFU0, 0xFD0,
	}

	Field(IST0, ByteAcc, NoLock, Preserve) {
		SIG, 32,
		LENG, 32,
		REV, 8,
		SUM, 8,
		OID, 48,
		OTID, 64,
		OREV, 32,
		CID, 32,
		CREV, 32,
		Offset(38),
		SSNM, 32
	}

	// components/utilities/utmisc.c AcpiUtGenerateChecksum() analog
	Method(CHSM, 2)	// buf, len
	{
		Name(lpN0, 0)
		Name(lpC0, 0)

		Store(0, Local0) // sum

		Store(arg1, lpN0)
		Store(0, lpC0)

		While(lpN0) {
			Store(DeRefOf(Index(arg0, lpC0)), Local1)
			Add(Local0, Local1, Local0)
			Mod(Local0, 0x100, Local0)
			Decrement(lpN0)
			Increment(lpC0)
		}

		Subtract(0, Local0, Local0)
		Mod(Local0, 0x100, Local0)

		Store("checksum", Debug)
		Store(Local0, Debug)

		return (Local0)
	}

	Method(INIT)
	{
		if (INIF) {
			Store("INIT: OpRegion has been initialized previously", Debug)
			Return (1)
		}
		Store(BUF0, RFU0)
		Store(1, INIF)
		Store("INIT: OpRegion initialized with SSDT", Debug)

		Return (0)
	}

	Method(LD)
	{
		Name(HI0, 0)

		if (LNot(LLess(Add(HI0N, 1), HI0M))) {
			Store("LD: too many tables loaded", Debug)
			Return (1)
		}
		Increment(HI0N)

		// Modify Revision field of SSDT
		Store(Add(CREV, 1), CREV)

		// Modify SSNM Object Name
		Divide(HI0N, 10, Local0, Local1)
		ShiftLeft(Local1, 16, Local1)
		ShiftLeft(Local0, 24, Local0)
		Add(Local0, Local1, Local0)
		Add(Local0, 0x30305353, Local0)
		Store(Local0, SSNM)
		Store(SSNM, Debug)

		// Recalculate and save CheckSum
		Store(RFU0, Local0)
		Store(Add(SUM, CHSM(Local0, SizeOf (Local0))), SUM)

//		Load(IST0, HI0)
		Load(RFU0, HI0)
		Store("LD: SSDT Loaded", Debug)
//		Store(HI0, Index(HI0P, HI0N))

		Return (0)
	}

	Method(UNLD)
	{
		Name(HI0, 0)

		if (LEqual(HI0N, 0)) {
			Store("UNLD: there are no SSDT loaded", Debug)
			Return (1)
		}
		Decrement(HI0N)

		Store(DerefOf(Index(HI0P, HI0N)), HI0)

		UnLoad(HI0)
		Store("UNLD: SSDT UnLoaded", Debug)

		Return (0)
	}

	Method(MAIN)
	{
		INIT()
		LD()
		LD()
//		UNLD()
//		UNLD()
	}
}