* kern/sparc64/ieee1275/ieee1275.c: New file.
* include/grub/sparc64/ieee1275/ieee1275.h (IEEE1275_MAP_WRITE, IEEE1275_MAP_READ, IEEE1275_MAP_EXEC, IEEE1275_MAP_LOCKED, IEEE1275_MAP_CACHED, IEEE1275_MAP_SE, IEEE1275_MAP_GLOBAL, IEEE1275_MAP_IE, IEEE1275_MAP_DEFAULT): Define. (grub_ieee1275_map_physical, grub_ieee1275_claim_vaddr, grub_ieee1275_alloc_physmem): Declare new exported functions.
This commit is contained in:
parent
91c88b1219
commit
234022fe7b
4 changed files with 157 additions and 0 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2009-04-13 David S. Miller <davem@davemloft.net>
|
||||
|
||||
* kern/sparc64/ieee1275/ieee1275.c: New file.
|
||||
* include/grub/sparc64/ieee1275/ieee1275.h (IEEE1275_MAP_WRITE,
|
||||
IEEE1275_MAP_READ, IEEE1275_MAP_EXEC, IEEE1275_MAP_LOCKED,
|
||||
IEEE1275_MAP_CACHED, IEEE1275_MAP_SE, IEEE1275_MAP_GLOBAL,
|
||||
IEEE1275_MAP_IE, IEEE1275_MAP_DEFAULT): Define.
|
||||
(grub_ieee1275_map_physical, grub_ieee1275_claim_vaddr,
|
||||
grub_ieee1275_alloc_physmem): Declare new exported functions.
|
||||
|
||||
2009-04-12 David S. Miller <davem@davemloft.net>
|
||||
|
||||
* kern/misc.c (grub_ltoa): Fix cast when handling negative
|
||||
|
|
1
DISTLIST
1
DISTLIST
|
@ -380,6 +380,7 @@ kern/powerpc/ieee1275/startup.S
|
|||
kern/sparc64/cache.S
|
||||
kern/sparc64/dl.c
|
||||
kern/sparc64/ieee1275/crt0.S
|
||||
kern/sparc64/ieee1275/ieee1275.c
|
||||
kern/sparc64/ieee1275/openfw.c
|
||||
kern/x86_64/dl.c
|
||||
kern/x86_64/efi/callwrap.S
|
||||
|
|
|
@ -24,4 +24,26 @@
|
|||
|
||||
typedef grub_uint64_t grub_ieee1275_cell_t;
|
||||
|
||||
/* Encoding of 'mode' argument to grub_ieee1275_map_physical() */
|
||||
#define IEEE1275_MAP_WRITE 0x0001 /* Writable */
|
||||
#define IEEE1275_MAP_READ 0x0002 /* Readable */
|
||||
#define IEEE1275_MAP_EXEC 0x0004 /* Executable */
|
||||
#define IEEE1275_MAP_LOCKED 0x0010 /* Locked in TLB */
|
||||
#define IEEE1275_MAP_CACHED 0x0020 /* Cacheable */
|
||||
#define IEEE1275_MAP_SE 0x0040 /* Side-effects */
|
||||
#define IEEE1275_MAP_GLOBAL 0x0080 /* Global */
|
||||
#define IEEE1275_MAP_IE 0x0100 /* Invert Endianness */
|
||||
#define IEEE1275_MAP_DEFAULT (IEEE1275_MAP_WRITE | IEEE1275_MAP_READ | \
|
||||
IEEE1275_MAP_EXEC | IEEE1275_MAP_CACHED)
|
||||
|
||||
extern int EXPORT_FUNC(grub_ieee1275_map_physical) (grub_addr_t paddr,
|
||||
grub_addr_t vaddr,
|
||||
grub_size_t size,
|
||||
grub_uint32_t mode);
|
||||
extern int EXPORT_FUNC(grub_ieee1275_claim_vaddr) (grub_addr_t vaddr,
|
||||
grub_size_t size);
|
||||
extern int EXPORT_FUNC(grub_ieee1275_alloc_physmem) (grub_addr_t *paddr,
|
||||
grub_size_t size,
|
||||
grub_uint32_t align);
|
||||
|
||||
#endif /* ! GRUB_IEEE1275_MACHINE_HEADER */
|
||||
|
|
124
kern/sparc64/ieee1275/ieee1275.c
Normal file
124
kern/sparc64/ieee1275/ieee1275.c
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
/* Sun specific ieee1275 interfaces used by GRUB. */
|
||||
|
||||
int
|
||||
grub_ieee1275_map_physical (grub_addr_t paddr, grub_addr_t vaddr,
|
||||
grub_size_t size, grub_uint32_t mode)
|
||||
{
|
||||
struct map_physical_args
|
||||
{
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_cell_t method;
|
||||
grub_ieee1275_cell_t ihandle;
|
||||
grub_ieee1275_cell_t mode;
|
||||
grub_ieee1275_cell_t size;
|
||||
grub_ieee1275_cell_t virt;
|
||||
grub_ieee1275_cell_t phys_high;
|
||||
grub_ieee1275_cell_t phys_low;
|
||||
grub_ieee1275_cell_t catch_result;
|
||||
}
|
||||
args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 7, 1);
|
||||
args.method = (grub_ieee1275_cell_t) "map";
|
||||
args.ihandle = grub_ieee1275_mmu;
|
||||
args.mode = mode;
|
||||
args.size = size;
|
||||
args.virt = vaddr;
|
||||
args.phys_high = 0;
|
||||
args.phys_low = paddr;
|
||||
args.catch_result = (grub_ieee1275_cell_t) -1;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
return args.catch_result;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_claim_vaddr (grub_addr_t vaddr, grub_size_t size)
|
||||
{
|
||||
struct claim_vaddr_args
|
||||
{
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_cell_t method;
|
||||
grub_ieee1275_cell_t ihandle;
|
||||
grub_ieee1275_cell_t align;
|
||||
grub_ieee1275_cell_t size;
|
||||
grub_ieee1275_cell_t virt;
|
||||
grub_ieee1275_cell_t catch_result;
|
||||
}
|
||||
args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 5, 2);
|
||||
args.method = (grub_ieee1275_cell_t) "claim";
|
||||
args.ihandle = grub_ieee1275_mmu;
|
||||
args.align = 0;
|
||||
args.size = size;
|
||||
args.virt = vaddr;
|
||||
args.catch_result = (grub_ieee1275_cell_t) -1;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
return args.catch_result;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_alloc_physmem (grub_addr_t *paddr, grub_size_t size,
|
||||
grub_uint32_t align)
|
||||
{
|
||||
grub_uint32_t memory_ihandle;
|
||||
struct alloc_physmem_args
|
||||
{
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_cell_t method;
|
||||
grub_ieee1275_cell_t ihandle;
|
||||
grub_ieee1275_cell_t align;
|
||||
grub_ieee1275_cell_t size;
|
||||
grub_ieee1275_cell_t catch_result;
|
||||
grub_ieee1275_cell_t phys_high;
|
||||
grub_ieee1275_cell_t phys_low;
|
||||
}
|
||||
args;
|
||||
grub_ssize_t actual = 0;
|
||||
|
||||
grub_ieee1275_get_property (grub_ieee1275_chosen, "memory",
|
||||
&memory_ihandle, sizeof (memory_ihandle),
|
||||
&actual);
|
||||
if (actual != sizeof (memory_ihandle))
|
||||
return -1;
|
||||
|
||||
if (!align)
|
||||
align = 1;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 3);
|
||||
args.method = (grub_ieee1275_cell_t) "claim";
|
||||
args.ihandle = memory_ihandle;
|
||||
args.align = (align ? align : 1);
|
||||
args.size = size;
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
|
||||
*paddr = args.phys_low;
|
||||
|
||||
return args.catch_result;
|
||||
}
|
Loading…
Reference in a new issue