blob: 73d8dd14dda268ee2ae9a4ab6f56f493e7cf4c04 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002
4 *
5 */
6
H. Peter Anvin1965aae2008-10-22 22:26:29 -07007#ifndef _ASM_X86_MMZONE_32_H
8#define _ASM_X86_MMZONE_32_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10#include <asm/smp.h>
11
Dave Jones8ff8b272005-07-07 17:56:39 -070012#ifdef CONFIG_NUMA
Andy Whitcroft05b79bd2005-06-23 00:07:57 -070013extern struct pglist_data *node_data[];
14#define NODE_DATA(nid) (node_data[nid])
Andy Whitcroft05b79bd2005-06-23 00:07:57 -070015#endif /* CONFIG_NUMA */
16
17#ifdef CONFIG_DISCONTIGMEM
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
19/*
20 * generic node memory support, the following assumptions apply:
21 *
André Goddard Rosaaf901ca2009-11-14 13:09:05 -020022 * 1) memory comes in 64Mb contiguous chunks which are either present or not
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 * 2) we will not have more than 64Gb in total
24 *
25 * for now assume that 64Gb is max amount of RAM for whole system
26 * 64Gb / 4096bytes/page = 16777216 pages
27 */
28#define MAX_NR_PAGES 16777216
Tejun Heod0ead152011-07-12 09:44:22 +020029#define MAX_SECTIONS 1024
30#define PAGES_PER_SECTION (MAX_NR_PAGES/MAX_SECTIONS)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
32extern s8 physnode_map[];
33
34static inline int pfn_to_nid(unsigned long pfn)
35{
36#ifdef CONFIG_NUMA
Tejun Heod0ead152011-07-12 09:44:22 +020037 return((int) physnode_map[(pfn) / PAGES_PER_SECTION]);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#else
39 return 0;
40#endif
41}
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043static inline int pfn_valid(int pfn)
44{
45 int nid = pfn_to_nid(pfn);
46
47 if (nid >= 0)
48 return (pfn < node_end_pfn(nid));
49 return 0;
50}
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Tejun Heoa26474e2011-06-28 11:41:07 +020052#define early_pfn_valid(pfn) pfn_valid((pfn))
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#endif /* CONFIG_DISCONTIGMEM */
Andy Whitcroftb159d432005-06-23 00:07:52 -070055
H. Peter Anvin1965aae2008-10-22 22:26:29 -070056#endif /* _ASM_X86_MMZONE_32_H */