xref: /haiku/src/add-ons/kernel/cpu/x86/amd.cpp (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
1 /*
2  * Copyright 2005-2006, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Axel Dörfler, axeld@pinc-software.de
7  */
8 
9 
10 #include "amd.h"
11 #include "generic_x86.h"
12 
13 #include <OS.h>
14 
15 
16 static void
17 amd_init_mtrrs(void)
18 {
19 	generic_init_mtrrs(generic_count_mtrrs());
20 }
21 
22 
23 static status_t
24 amd_init(void)
25 {
26 	system_info info;
27 	if (get_system_info(&info) != B_OK)
28 		return B_ERROR;
29 
30 	if ((info.cpu_type & B_CPU_x86_VENDOR_MASK) != B_CPU_AMD_x86)
31 		return B_ERROR;
32 
33 	// The K6-2 doesn't seem to support write-combining (before model 9),
34 	// so we ignore anything before that one.
35 	if (info.cpu_type <= B_CPU_AMD_K6_2)
36 		return B_ERROR;
37 
38 	generic_mtrr_compute_physical_mask();
39 	generic_dump_mtrrs(generic_count_mtrrs());
40 
41 	return B_OK;
42 }
43 
44 
45 static status_t
46 amd_stdops(int32 op, ...)
47 {
48 	switch (op) {
49 		case B_MODULE_INIT:
50 			return amd_init();
51 		case B_MODULE_UNINIT:
52 			return B_OK;
53 	}
54 
55 	return B_ERROR;
56 }
57 
58 
59 x86_cpu_module_info gAMDModule = {
60 	{
61 		"cpu/generic_x86/amd/v1",
62 		0,
63 		amd_stdops,
64 	},
65 
66 	generic_count_mtrrs,
67 	amd_init_mtrrs,
68 
69 	generic_set_mtrr,
70 	generic_get_mtrr,
71 };
72