]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* kern/sparc64/ieee1275/ieee1275.c: New file.
authordavem <davem@localhost>
Mon, 13 Apr 2009 07:06:09 +0000 (07:06 +0000)
committerdavem <davem@localhost>
Mon, 13 Apr 2009 07:06:09 +0000 (07:06 +0000)
* 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.

ChangeLog
DISTLIST
include/grub/sparc64/ieee1275/ieee1275.h
kern/sparc64/ieee1275/ieee1275.c [new file with mode: 0644]

index 90864f5cf802fe9233be823f95f3894037d2c080..0c222adda3bb050b49763b07cb87c29fecffee36 100644 (file)
--- a/ChangeLog
+++ b/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
index 1eceb8e4899b0415cf9ff16082211f591f403e33..461600fcf19ebf1f7179719b80168a22ba7ad4de 100644 (file)
--- a/DISTLIST
+++ b/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
index 1ef95f91a6234fd2719a51aa566d55faa2efb3bd..7626e93c168d0bf2e1be9240239456ab018e0e31 100644 (file)
 
 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 */
diff --git a/kern/sparc64/ieee1275/ieee1275.c b/kern/sparc64/ieee1275/ieee1275.c
new file mode 100644 (file)
index 0000000..438a171
--- /dev/null
@@ -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;
+}