2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2009 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#include <grub/ieee1275/ieee1275.h>
2N/A#include <grub/types.h>
2N/A
2N/A/* Sun specific ieee1275 interfaces used by GRUB. */
2N/A
2N/Aint
2N/Agrub_ieee1275_claim_vaddr (grub_addr_t vaddr, grub_size_t size)
2N/A{
2N/A struct claim_vaddr_args
2N/A {
2N/A struct grub_ieee1275_common_hdr common;
2N/A grub_ieee1275_cell_t method;
2N/A grub_ieee1275_cell_t ihandle;
2N/A grub_ieee1275_cell_t align;
2N/A grub_ieee1275_cell_t size;
2N/A grub_ieee1275_cell_t virt;
2N/A grub_ieee1275_cell_t catch_result;
2N/A }
2N/A args;
2N/A
2N/A INIT_IEEE1275_COMMON (&args.common, "call-method", 5, 2);
2N/A args.method = (grub_ieee1275_cell_t) "claim";
2N/A args.ihandle = grub_ieee1275_mmu;
2N/A args.align = 0;
2N/A args.size = size;
2N/A args.virt = vaddr;
2N/A args.catch_result = (grub_ieee1275_cell_t) -1;
2N/A
2N/A if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
2N/A return -1;
2N/A return args.catch_result;
2N/A}
2N/A
2N/Aint
2N/Agrub_ieee1275_alloc_physmem (grub_addr_t *paddr, grub_size_t size,
2N/A grub_uint32_t align)
2N/A{
2N/A grub_uint32_t memory_ihandle;
2N/A struct alloc_physmem_args
2N/A {
2N/A struct grub_ieee1275_common_hdr common;
2N/A grub_ieee1275_cell_t method;
2N/A grub_ieee1275_cell_t ihandle;
2N/A grub_ieee1275_cell_t align;
2N/A grub_ieee1275_cell_t size;
2N/A grub_ieee1275_cell_t catch_result;
2N/A grub_ieee1275_cell_t phys_high;
2N/A grub_ieee1275_cell_t phys_low;
2N/A }
2N/A args;
2N/A grub_ssize_t actual = 0;
2N/A
2N/A grub_ieee1275_get_property (grub_ieee1275_chosen, "memory",
2N/A &memory_ihandle, sizeof (memory_ihandle),
2N/A &actual);
2N/A if (actual != sizeof (memory_ihandle))
2N/A return -1;
2N/A
2N/A if (!align)
2N/A align = 1;
2N/A
2N/A INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 3);
2N/A args.method = (grub_ieee1275_cell_t) "claim";
2N/A args.ihandle = memory_ihandle;
2N/A args.align = (align ? align : 1);
2N/A args.size = size;
2N/A if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
2N/A return -1;
2N/A
2N/A *paddr = args.phys_low;
2N/A
2N/A return args.catch_result;
2N/A}