Lines Matching +full:gpa +full:- +full:0

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
60 * It is allocated in page-multiple blocks on a first-come first-serve basis,
63 static char *romptr; /* Pointer to userspace-mapped bootrom region. */
64 static vm_paddr_t gpa_base; /* GPA of low end of region. */
65 static vm_paddr_t gpa_allocbot; /* Low GPA of free region. */
66 static vm_paddr_t gpa_alloctop; /* High GPA, minus 1, of free region. */
68 #define CFI_BCS_WRITE_BYTE 0x10
69 #define CFI_BCS_CLEAR_STATUS 0x50
70 #define CFI_BCS_READ_STATUS 0x70
71 #define CFI_BCS_READ_ARRAY 0xff
75 uint64_t gpa; member
78 } var = { NULL, 0, 0, CFI_BCS_READ_ARRAY };
90 offset = addr - var.gpa; in bootrom_var_mem_handler()
91 if (offset + size > var.size || offset < 0 || offset + size <= offset) in bootrom_var_mem_handler()
107 memset(val, 0, size); in bootrom_var_mem_handler()
115 return (0); in bootrom_var_mem_handler()
127 gpa_base = highmem - BOOTROM_SIZE; in init_bootrom()
129 gpa_alloctop = highmem - 1; in init_bootrom()
138 vm_paddr_t gpa; in bootrom_alloc() local
152 if (len == 0 || len > BOOTROM_SIZE) { in bootrom_alloc()
163 gpa = (gpa_alloctop - len) + 1; in bootrom_alloc()
164 if (gpa < gpa_allocbot) { in bootrom_alloc()
169 gpa = gpa_allocbot; in bootrom_alloc()
170 if (gpa > (gpa_alloctop - len) + 1) { in bootrom_alloc()
176 segoff = gpa - gpa_base; in bootrom_alloc()
177 if (vm_mmap_memseg(ctx, gpa, VM_BOOTROM, segoff, len, prot) != 0) { in bootrom_alloc()
184 gpa_alloctop = gpa - 1; in bootrom_alloc()
186 gpa_allocbot = gpa + len; in bootrom_alloc()
190 *gpa_out = gpa; in bootrom_alloc()
191 return (0); in bootrom_alloc()
204 rv = -1; in bootrom_loadrom()
205 varfd = -1; in bootrom_loadrom()
209 return (0); in bootrom_loadrom()
220 return (-1); in bootrom_loadrom()
224 if (fd < 0) { in bootrom_loadrom()
230 if (fstat(fd, &sbuf) < 0) { in bootrom_loadrom()
239 var_size = 0; in bootrom_loadrom()
242 if (varfd < 0) { in bootrom_loadrom()
248 if (fstat(varfd, &sbuf) < 0) { in bootrom_loadrom()
259 (var_size != 0 && var_size < PAGE_SIZE)) { in bootrom_loadrom()
275 BOOTROM_ALLOC_TOP, &ptr, NULL) != 0) { in bootrom_loadrom()
280 for (i = 0; i < rom_size / PAGE_SIZE; i++) { in bootrom_loadrom()
289 if (varfd >= 0) { in bootrom_loadrom()
291 MAP_SHARED, varfd, 0); in bootrom_loadrom()
295 var.gpa = (gpa_alloctop - var_size) + 1; in bootrom_loadrom()
296 gpa_alloctop = var.gpa - 1; in bootrom_loadrom()
301 .base = var.gpa, in bootrom_loadrom()
304 if (rv != 0) in bootrom_loadrom()
308 rv = 0; in bootrom_loadrom()
310 if (varfd >= 0) in bootrom_loadrom()
312 if (fd >= 0) in bootrom_loadrom()