prom_mem.c (7c478bd9) | prom_mem.c (986fd29a) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the |
5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. | 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. |
8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* | 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* |
23 * Copyright (c) 1991-1994, by Sun Microsystems, Inc. 24 * All rights reserved. | 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. |
25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29/* 30 * This file contains platform-dependent memory support routines, 31 * suitable for memory methods with 2-cell physical addresses. 32 * Use of these routines makes the caller platform-dependent, --- 24 unchanged lines hidden (view full) --- 57 * Allocate physical memory, unmapped and possibly aligned. 58 * Returns 0: Success; Non-zero: failure. 59 * Returns *physaddr only if successful. 60 * 61 * This routine is suitable for platforms with 2-cell physical addresses 62 * and a single size cell in the "memory" node. 63 */ 64int | 24 */ 25 26#pragma ident "%Z%%M% %I% %E% SMI" 27 28/* 29 * This file contains platform-dependent memory support routines, 30 * suitable for memory methods with 2-cell physical addresses. 31 * Use of these routines makes the caller platform-dependent, --- 24 unchanged lines hidden (view full) --- 56 * Allocate physical memory, unmapped and possibly aligned. 57 * Returns 0: Success; Non-zero: failure. 58 * Returns *physaddr only if successful. 59 * 60 * This routine is suitable for platforms with 2-cell physical addresses 61 * and a single size cell in the "memory" node. 62 */ 63int |
65prom_allocate_phys(size_t size, u_int align, unsigned long long *physaddr) | 64prom_allocate_phys(size_t size, uint_t align, unsigned long long *physaddr) |
66{ 67 cell_t ci[10]; 68 int rv; 69 ihandle_t imemory = prom_memory_ihandle(); 70 71 if ((imemory == (ihandle_t)-1)) 72 return (-1); 73 74 if (align == 0) | 65{ 66 cell_t ci[10]; 67 int rv; 68 ihandle_t imemory = prom_memory_ihandle(); 69 70 if ((imemory == (ihandle_t)-1)) 71 return (-1); 72 73 if (align == 0) |
75 align = (u_int)1; | 74 align = (uint_t)1; |
76 77 ci[0] = p1275_ptr2cell("call-method"); /* Service name */ 78 ci[1] = (cell_t)4; /* #argument cells */ 79 ci[2] = (cell_t)3; /* #result cells */ 80 ci[3] = p1275_ptr2cell("claim"); /* Arg1: Method name */ 81 ci[4] = p1275_ihandle2cell(imemory); /* Arg2: memory ihandle */ 82 ci[5] = p1275_uint2cell(align); /* Arg3: SA1: align */ 83 ci[6] = p1275_size2cell(size); /* Arg4: SA2: size */ --- 73 unchanged lines hidden (view full) --- 157 ci[5] = p1275_size2cell(size); /* Arg3: SA1: size */ 158 ci[6] = p1275_ull2cell_high(physaddr); /* Arg4: SA2: phys.hi */ 159 ci[7] = p1275_ull2cell_low(physaddr); /* Arg5: SA3: phys.lo */ 160 161 promif_preprom(); 162 (void) p1275_cif_handler(&ci); 163 promif_postprom(); 164} | 75 76 ci[0] = p1275_ptr2cell("call-method"); /* Service name */ 77 ci[1] = (cell_t)4; /* #argument cells */ 78 ci[2] = (cell_t)3; /* #result cells */ 79 ci[3] = p1275_ptr2cell("claim"); /* Arg1: Method name */ 80 ci[4] = p1275_ihandle2cell(imemory); /* Arg2: memory ihandle */ 81 ci[5] = p1275_uint2cell(align); /* Arg3: SA1: align */ 82 ci[6] = p1275_size2cell(size); /* Arg4: SA2: size */ --- 73 unchanged lines hidden (view full) --- 156 ci[5] = p1275_size2cell(size); /* Arg3: SA1: size */ 157 ci[6] = p1275_ull2cell_high(physaddr); /* Arg4: SA2: phys.hi */ 158 ci[7] = p1275_ull2cell_low(physaddr); /* Arg5: SA3: phys.lo */ 159 160 promif_preprom(); 161 (void) p1275_cif_handler(&ci); 162 promif_postprom(); 163} |
164 165static pnode_t 166prom_mem_phandle(void) 167{ 168 static pnode_t pmem = 0; 169 170 if (pmem == (pnode_t)0) { 171 ihandle_t ih; 172 173 if ((ih = prom_memory_ihandle()) == (ihandle_t)-1) 174 prom_panic("Can't get memory ihandle"); 175 pmem = prom_getphandle(ih); 176 } 177 return (pmem); 178} 179 180 181int 182prom_phys_installed_len(void) 183{ 184 return (prom_getproplen(prom_mem_phandle(), "reg")); 185} 186 187int 188prom_phys_avail_len(void) 189{ 190 return (prom_getproplen(prom_mem_phandle(), "available")); 191} 192 193int 194prom_phys_installed(caddr_t prop) 195{ 196 return (prom_getprop(prom_mem_phandle(), "reg", prop)); 197} 198 199int 200prom_phys_avail(caddr_t prop) 201{ 202 return (prom_getprop(prom_mem_phandle(), "available", prop)); 203} |
|