Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef _PARISC_MMZONE_H |
3 | #define _PARISC_MMZONE_H | |
4 | ||
872420b3 JDA |
5 | #define MAX_PHYSMEM_RANGES 8 /* Fix the size for now (current known max is 3) */ |
6 | ||
1da177e4 LT |
7 | #ifdef CONFIG_DISCONTIGMEM |
8 | ||
1da177e4 LT |
9 | extern int npmem_ranges; |
10 | ||
11 | struct node_map_data { | |
12 | pg_data_t pg_data; | |
13 | }; | |
14 | ||
15 | extern struct node_map_data node_data[]; | |
16 | ||
17 | #define NODE_DATA(nid) (&node_data[nid].pg_data) | |
18 | ||
1da177e4 LT |
19 | /* 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 */ | |
91ea8207 | 31 | extern signed char pfnnid_map[PFNNID_MAP_MAX]; |
1da177e4 | 32 | |
513e7ecd | 33 | #ifndef CONFIG_64BIT |
1da177e4 LT |
34 | #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 | ||
40 | static inline int pfn_to_nid(unsigned long pfn) | |
41 | { | |
42 | unsigned int i; | |
1da177e4 LT |
43 | |
44 | if (unlikely(pfn_is_io(pfn))) | |
45 | return 0; | |
46 | ||
47 | i = pfn >> PFNNID_SHIFT; | |
1dda59b4 | 48 | BUG_ON(i >= ARRAY_SIZE(pfnnid_map)); |
1da177e4 | 49 | |
91ea8207 | 50 | return pfnnid_map[i]; |
1da177e4 LT |
51 | } |
52 | ||
53 | static 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 | ||
1da177e4 LT |
62 | #endif |
63 | #endif /* _PARISC_MMZONE_H */ |