blob: fafa3893fd70cda02c05f5e3dc9198efff09e739 [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#ifndef _PARISC_MMZONE_H
3#define _PARISC_MMZONE_H
4
John David Anglin872420b2013-02-02 23:42:25 +00005#define MAX_PHYSMEM_RANGES 8 /* Fix the size for now (current known max is 3) */
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#ifdef CONFIG_DISCONTIGMEM
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009extern int npmem_ranges;
10
11struct node_map_data {
12 pg_data_t pg_data;
13};
14
15extern struct node_map_data node_data[];
16
17#define NODE_DATA(nid) (&node_data[nid].pg_data)
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019/* We have these possible memory map layouts:
20 * Astro: 0-3.75, 67.75-68, 4-64
21 * zx1: 0-1, 257-260, 4-256
22 * Stretch (N-class): 0-2, 4-32, 34-xxx
23 */
24
25/* Since each 1GB can only belong to one region (node), we can create
26 * an index table for pfn to nid lookup; each entry in pfnnid_map
27 * represents 1GB, and contains the node that the memory belongs to. */
28
29#define PFNNID_SHIFT (30 - PAGE_SHIFT)
30#define PFNNID_MAP_MAX 512 /* support 512GB */
Helge Deller91ea8202013-06-05 20:50:01 +000031extern signed char pfnnid_map[PFNNID_MAP_MAX];
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Helge Deller513e7ec2007-01-28 15:09:20 +010033#ifndef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#define pfn_is_io(pfn) ((pfn & (0xf0000000UL >> PAGE_SHIFT)) == (0xf0000000UL >> PAGE_SHIFT))
35#else
36/* io can be 0xf0f0f0f0f0xxxxxx or 0xfffffffff0000000 */
37#define pfn_is_io(pfn) ((pfn & (0xf000000000000000UL >> PAGE_SHIFT)) == (0xf000000000000000UL >> PAGE_SHIFT))
38#endif
39
40static inline int pfn_to_nid(unsigned long pfn)
41{
42 unsigned int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
44 if (unlikely(pfn_is_io(pfn)))
45 return 0;
46
47 i = pfn >> PFNNID_SHIFT;
Nikitas Angelinas1dda59b2010-09-08 21:11:13 +000048 BUG_ON(i >= ARRAY_SIZE(pfnnid_map));
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Helge Deller91ea8202013-06-05 20:50:01 +000050 return pfnnid_map[i];
Linus Torvalds1da177e2005-04-16 15:20:36 -070051}
52
53static inline int pfn_valid(int pfn)
54{
55 int nid = pfn_to_nid(pfn);
56
57 if (nid >= 0)
58 return (pfn < node_end_pfn(nid));
59 return 0;
60}
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#endif
63#endif /* _PARISC_MMZONE_H */