[2092] * kern/sparc64/ieee1275/ieee1275.c: New file.

"David S. Miller" <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2092
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2092
Author:   davem
Date:     2009-04-13 07:06:09 +0000 (Mon, 13 Apr 2009)
Log Message:
-----------
	* 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.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/DISTLIST
    trunk/grub2/include/grub/sparc64/ieee1275/ieee1275.h

Added Paths:
-----------
    trunk/grub2/kern/sparc64/ieee1275/ieee1275.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-04-13 07:02:46 UTC (rev 2091)
+++ trunk/grub2/ChangeLog	2009-04-13 07:06:09 UTC (rev 2092)
@@ -1,3 +1,13 @@
+2009-04-13  David S. Miller  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* kern/misc.c (grub_ltoa): Fix cast when handling negative

Modified: trunk/grub2/DISTLIST
===================================================================
--- trunk/grub2/DISTLIST	2009-04-13 07:02:46 UTC (rev 2091)
+++ trunk/grub2/DISTLIST	2009-04-13 07:06:09 UTC (rev 2092)
@@ -380,6 +380,7 @@
 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

Modified: trunk/grub2/include/grub/sparc64/ieee1275/ieee1275.h
===================================================================
--- trunk/grub2/include/grub/sparc64/ieee1275/ieee1275.h	2009-04-13 07:02:46 UTC (rev 2091)
+++ trunk/grub2/include/grub/sparc64/ieee1275/ieee1275.h	2009-04-13 07:06:09 UTC (rev 2092)
@@ -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 */

Added: trunk/grub2/kern/sparc64/ieee1275/ieee1275.c
===================================================================
--- trunk/grub2/kern/sparc64/ieee1275/ieee1275.c	                        (rev 0)
+++ trunk/grub2/kern/sparc64/ieee1275/ieee1275.c	2009-04-13 07:06:09 UTC (rev 2092)
@@ -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;
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.