@@ -61,21 +61,29 @@ LIST_HEAD(, vm_amap) amap_list;
6161 */
6262
6363static struct vm_amap * amap_alloc1 (int , int , int );
64- static __inline void amap_list_insert (struct vm_amap * );
65- static __inline void amap_list_remove (struct vm_amap * );
64+ static inline void amap_list_insert (struct vm_amap * );
65+ static inline void amap_list_remove (struct vm_amap * );
66+ static inline int amap_b2slot (voff_t );
6667
67- static __inline void
68+ static inline void
6869amap_list_insert (struct vm_amap * amap )
6970{
7071 LIST_INSERT_HEAD (& amap_list , amap , am_list );
7172}
7273
73- static __inline void
74+ static inline void
7475amap_list_remove (struct vm_amap * amap )
75- {
76+ {
7677 LIST_REMOVE (amap , am_list );
7778}
7879
80+ static inline int
81+ amap_b2slot (voff_t byte_off )
82+ {
83+ KASSERT ((byte_off & (PAGE_SIZE - 1 )) == 0 );
84+ return ((int )(byte_off >> PAGE_SHIFT ));
85+ }
86+
7987#ifdef UVM_AMAP_PPREF
8088/*
8189 * what is ppref? ppref is an _optional_ amap feature which is used
@@ -219,8 +227,8 @@ amap_alloc(vaddr_t sz, vaddr_t padsz, int waitf)
219227 struct vm_amap * amap ;
220228 int slots , padslots ;
221229
222- AMAP_B2SLOT ( slots , sz ); /* load slots */
223- AMAP_B2SLOT ( padslots , padsz );
230+ slots = amap_b2slot ( sz );
231+ padslots = amap_b2slot ( padsz );
224232
225233 amap = amap_alloc1 (slots , padslots , waitf );
226234 if (amap ) {
@@ -283,8 +291,8 @@ amap_extend(struct vm_map_entry *entry, vsize_t addsize)
283291 * forget that ar_pageoff could be non-zero: this means that
284292 * there are some unused slots before us in the amap.
285293 */
286- AMAP_B2SLOT ( slotmapped , entry -> end - entry -> start ); /* slots mapped */
287- AMAP_B2SLOT ( slotadd , addsize ); /* slots to add */
294+ slotmapped = amap_b2slot ( entry -> end - entry -> start );
295+ slotadd = amap_b2slot ( addsize );
288296 slotneed = slotoff + slotmapped + slotadd ;
289297
290298 /*
@@ -430,7 +438,7 @@ amap_share_protect(struct vm_map_entry *entry, vm_prot_t prot)
430438 struct vm_amap * amap = entry -> aref .ar_amap ;
431439 int slots , lcv , slot , stop ;
432440
433- AMAP_B2SLOT ( slots , (entry -> end - entry -> start ) );
441+ slots = amap_b2slot (entry -> end - entry -> start );
434442 stop = entry -> aref .ar_pageoff + slots ;
435443
436444 if (slots < amap -> am_nused ) {
@@ -570,7 +578,7 @@ amap_copy(struct vm_map *map, struct vm_map_entry *entry, int waitf,
570578 }
571579
572580 /* looks like we need to copy the map. */
573- AMAP_B2SLOT ( slots , entry -> end - entry -> start );
581+ slots = amap_b2slot ( entry -> end - entry -> start );
574582 amap = amap_alloc1 (slots , 0 , waitf );
575583 if (amap == NULL )
576584 return ;
@@ -758,7 +766,7 @@ amap_splitref(struct vm_aref *origref, struct vm_aref *splitref, vaddr_t offset)
758766{
759767 int leftslots ;
760768
761- AMAP_B2SLOT ( leftslots , offset );
769+ leftslots = amap_b2slot ( offset );
762770 if (leftslots == 0 )
763771 panic ("amap_splitref: split at zero offset" );
764772
@@ -1029,7 +1037,7 @@ amap_lookup(struct vm_aref *aref, vaddr_t offset)
10291037 int slot ;
10301038 struct vm_amap * amap = aref -> ar_amap ;
10311039
1032- AMAP_B2SLOT ( slot , offset );
1040+ slot = amap_b2slot ( offset );
10331041 slot += aref -> ar_pageoff ;
10341042
10351043 if (slot >= amap -> am_nslot )
@@ -1051,7 +1059,7 @@ amap_lookups(struct vm_aref *aref, vaddr_t offset,
10511059 int slot ;
10521060 struct vm_amap * amap = aref -> ar_amap ;
10531061
1054- AMAP_B2SLOT ( slot , offset );
1062+ slot = amap_b2slot ( offset );
10551063 slot += aref -> ar_pageoff ;
10561064
10571065 if ((slot + (npages - 1 )) >= amap -> am_nslot )
@@ -1077,7 +1085,7 @@ amap_add(struct vm_aref *aref, vaddr_t offset, struct vm_anon *anon,
10771085 int slot ;
10781086 struct vm_amap * amap = aref -> ar_amap ;
10791087
1080- AMAP_B2SLOT ( slot , offset );
1088+ slot = amap_b2slot ( offset );
10811089 slot += aref -> ar_pageoff ;
10821090
10831091 if (slot < 0 || slot >= amap -> am_nslot )
@@ -1117,7 +1125,7 @@ amap_unadd(struct vm_aref *aref, vaddr_t offset)
11171125 int ptr , slot ;
11181126 struct vm_amap * amap = aref -> ar_amap ;
11191127
1120- AMAP_B2SLOT ( slot , offset );
1128+ slot = amap_b2slot ( offset );
11211129 slot += aref -> ar_pageoff ;
11221130
11231131 if (slot >= amap -> am_nslot )
0 commit comments