xref: /openbsd/sys/dev/pci/amas.h (revision 264ca280)
1 /*	$OpenBSD: amas.h,v 1.1 2009/05/07 11:30:27 ariane Exp $	*/
2 
3 /*
4  * Copyright (c) 2009 Ariane van der Steldt <ariane@stack.nl>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /*
20  * Device: amas (AMD memory access/address switch).
21  *
22  * Driver for the amd athlon/opteron 64 address map.
23  * This device is integrated in 64-bit Athlon and Opteron cpus
24  * and contains mappings for memory to processor nodes.
25  *
26  * The AMD cpu can access memory in two ways: interleaved and non-interleaved.
27  *
28  * In interleaved mode, 16 MB regions are rotated across each node,
29  * example for 2 nodes:
30  * - region 0 (0-16 MB) on node 0.
31  * - region 1 (16-32 MB) on node 1.
32  * - region 2 (33-48 MB) on node 0.
33  * - region 3 (48-64 MB) on node 1.
34  * ...
35  * - region 2 * N on node 0.
36  * - region 2 * N + 1 on node 1.
37  * Interleaved mode requires that each node has the same amount of physical
38  * memory.
39  *
40  * In non-interleaved mode, memory for each node is a continuous address space,
41  * example for 2 nodes:
42  * - region 0 (all memory on CPU package 0) on node 0.
43  * - region 1 (all memory on CPU package 1) on node 1.
44  * Non-interleaved mode requires either that each node has the same amount of
45  * physical memory or that memory holes are allowed between each node.
46  *
47  * Configuring memory for interleaved or non-interleaved mode is handled by
48  * the BIOS.
49  */
50 
51 #ifndef _MACHINE_AMAS_H_
52 #define _MACHINE_AMAS_H_
53 
54 #include <sys/types.h>
55 #include <sys/device.h>
56 
57 #include <dev/pci/pcivar.h>
58 
59 #ifdef _KERNEL
60 
61 #define AMAS_MAX_NODES (8) /* AMAS supports 8 nodes at maximum. */
62 
63 /* Device configuration. */
64 struct amas_softc {
65 	struct device sc_dev;
66 	/* PCI location of this device. */
67 	pcitag_t pa_tag;
68 	pci_chipset_tag_t pa_pc;
69 	int family;
70 };
71 
72 /* AMAS driver. */
73 extern struct cfdriver amas_cd;
74 
75 int amas_match(struct device*, void*, void*);
76 void amas_attach(struct device*, struct device*, void*);
77 
78 int amas_intl_nodes(struct amas_softc*);
79 void amas_get_pagerange(struct amas_softc*, int node, paddr_t*, paddr_t*);
80 
81 #endif /* _KERNEL */
82 #endif /*  _MACHINE_AMAS_H_ */
83