| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pmap_bootstrap.c,v 1.8 2016/12/22 14:47:54 cherry Exp $ */ | | 1 | /* $NetBSD: pmap_bootstrap.c,v 1.9 2018/03/10 02:48:51 tsutsui Exp $ */ |
2 | /*- | | 2 | /*- |
3 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | | 3 | * Copyright (c) 1999 The NetBSD Foundation, Inc. |
4 | * All rights reserved. | | 4 | * All rights reserved. |
5 | * | | 5 | * |
6 | * This code is derived from software contributed to The NetBSD Foundation | | 6 | * This code is derived from software contributed to The NetBSD Foundation |
7 | * by Jason R. Thorpe. | | 7 | * by Jason R. Thorpe. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -103,46 +103,46 @@ pmap_bootstrap(vaddr_t vstart) | | | @@ -103,46 +103,46 @@ pmap_bootstrap(vaddr_t vstart) |
103 | { | | 103 | { |
104 | vaddr_t va; | | 104 | vaddr_t va; |
105 | int i; | | 105 | int i; |
106 | | | 106 | |
107 | /* | | 107 | /* |
108 | * Announce page-size to the VM-system | | 108 | * Announce page-size to the VM-system |
109 | */ | | 109 | */ |
110 | uvmexp.pagesize = NBPG; | | 110 | uvmexp.pagesize = NBPG; |
111 | uvm_md_init(); | | 111 | uvm_md_init(); |
112 | | | 112 | |
113 | /* | | 113 | /* |
114 | * Setup physical address ranges | | 114 | * Setup physical address ranges |
115 | */ | | 115 | */ |
116 | for (i = 0; usable_segs[i + 1].start; i++) | | 116 | for (i = 0; i < NMEM_SEGS && usable_segs[i].start; i++) |
117 | ; | | 117 | continue; |
118 | /* XXX: allow for msgbuf */ | | 118 | /* XXX: allow for msgbuf */ |
119 | usable_segs[i].end -= m68k_round_page(MSGBUFSIZE); | | 119 | usable_segs[i - 1].end -= m68k_round_page(MSGBUFSIZE); |
120 | msgbufpa = usable_segs[i].end; | | 120 | msgbufpa = usable_segs[i - 1].end; |
121 | | | 121 | |
122 | /* | | 122 | /* |
123 | * Count physical memory | | 123 | * Count physical memory |
124 | */ | | 124 | */ |
125 | mem_size = 0; | | 125 | mem_size = 0; |
126 | for (i = 0; i < NMEM_SEGS; i++) { | | 126 | for (i = 0; i < NMEM_SEGS; i++) { |
127 | if (boot_segs[i].start == boot_segs[i].end) | | 127 | if (boot_segs[i].start == boot_segs[i].end) |
128 | break; | | 128 | break; |
129 | mem_size += boot_segs[i].end - boot_segs[i].start; | | 129 | mem_size += boot_segs[i].end - boot_segs[i].start; |
130 | } | | 130 | } |
131 | | | 131 | |
132 | /* | | 132 | /* |
133 | * Announce available memory to the VM-system | | 133 | * Announce available memory to the VM-system |
134 | */ | | 134 | */ |
135 | for (i = 0; usable_segs[i].start; i++) | | 135 | for (i = 0; i < NMEM_SEGS && usable_segs[i].start; i++) |
136 | uvm_page_physload(atop(usable_segs[i].start), | | 136 | uvm_page_physload(atop(usable_segs[i].start), |
137 | atop(usable_segs[i].end), | | 137 | atop(usable_segs[i].end), |
138 | atop(usable_segs[i].start), | | 138 | atop(usable_segs[i].start), |
139 | atop(usable_segs[i].end), | | 139 | atop(usable_segs[i].end), |
140 | usable_segs[i].free_list); | | 140 | usable_segs[i].free_list); |
141 | | | 141 | |
142 | avail_start = usable_segs[0].start; | | 142 | avail_start = usable_segs[0].start; |
143 | avail_end = usable_segs[i - 1].end; | | 143 | avail_end = usable_segs[i - 1].end; |
144 | | | 144 | |
145 | virtual_avail = vstart; | | 145 | virtual_avail = vstart; |
146 | virtual_end = VM_MAX_KERNEL_ADDRESS; | | 146 | virtual_end = VM_MAX_KERNEL_ADDRESS; |
147 | | | 147 | |
148 | /* | | 148 | /* |