Index: boot/arch/ppc32/loader/main.c
===================================================================
--- boot/arch/ppc32/loader/main.c	(revision eddf924f5f99dc38d90f38b3639bf6757299c64b)
+++ boot/arch/ppc32/loader/main.c	(revision fd375a8d1ed315622d230241a9b3227ec34ba99e)
@@ -177,4 +177,6 @@
 	fix_overlap(&bootinfo, &bootinfo_pa, "boot info", &top);
 	
+	ofw_setup_palette();
+	
 	printf("\nBooting the kernel...\n");
 	jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa, (void *) bootinfo.screen.addr, bootinfo.screen.scanline);
Index: boot/arch/sparc64/loader/main.c
===================================================================
--- boot/arch/sparc64/loader/main.c	(revision eddf924f5f99dc38d90f38b3639bf6757299c64b)
+++ boot/arch/sparc64/loader/main.c	(revision fd375a8d1ed315622d230241a9b3227ec34ba99e)
@@ -270,5 +270,5 @@
 #endif
 
-	setup_palette();
+	ofw_setup_palette();
 
 	printf("\nBooting the kernel...\n");
Index: boot/genarch/ofw.c
===================================================================
--- boot/genarch/ofw.c	(revision eddf924f5f99dc38d90f38b3639bf6757299c64b)
+++ boot/genarch/ofw.c	(revision fd375a8d1ed315622d230241a9b3227ec34ba99e)
@@ -26,5 +26,5 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
- 
+
 #include <ofw.h>
 #include <ofwarch.h>
@@ -373,13 +373,20 @@
 }
 
+#define RED(i)    (((i) >> 5) & ((1 << 3) - 1))
+#define GREEN(i)  (((i) >> 3) & ((1 << 2) - 1))
+#define BLUE(i)   ((i) & ((1 << 3) - 1))
+#define CLIP(i)   ((i) <= 255 ? (i) : 255)
+
+
 /**
  * Sets up the palette for the 8-bit color depth configuration so that the
  * 3:2:3 color scheme can be used. Checks that setting the palette makes sense
  * (appropriate nodes exist in the OBP tree and the color depth is not greater
- * than 8). 
- *
- * @return	true if the palette has been set, false otherwise
+ * than 8).
+ *
+ * @return true if the palette has been set, false otherwise
+ *
  */
-int setup_palette(void)
+int ofw_setup_palette(void)
 {
 	char device_name[BUF_SIZE];
@@ -387,7 +394,7 @@
 	/* resolve alias */
 	if (ofw_get_property(ofw_aliases, "screen", device_name,
-		sizeof(device_name)) <= 0)
-		return false;
-
+	    sizeof(device_name)) <= 0)
+		return false;
+	
 	/* for depth greater than 8 it makes no sense to set up the palette */
 	uint32_t depth;
@@ -404,13 +411,10 @@
 	if (screen == -1)
 		return false;
-
+	
 	/* setup the palette so that the (inverted) 3:2:3 scheme is usable */
 	unsigned int i;
 	for (i = 0; i < 256; i++)
-		if (ofw_call("call-method", 6, 1, NULL, "color!", screen,
-			255 - i,
-			i << 5,
-			(i >> 3) << 6,
-			(i >> 5) << 5) != 0); 
+		ofw_call("call-method", 6, 1, NULL, "color!", screen,
+		    255 - i, CLIP(BLUE(i) * 37), GREEN(i) * 85, CLIP(RED(i) * 37));
 	return true;
 }
Index: boot/genarch/ofw.h
===================================================================
--- boot/genarch/ofw.h	(revision eddf924f5f99dc38d90f38b3639bf6757299c64b)
+++ boot/genarch/ofw.h	(revision fd375a8d1ed315622d230241a9b3227ec34ba99e)
@@ -124,5 +124,5 @@
 extern int ofw_screen(screen_t *screen);
 extern int ofw_macio(macio_t *macio);
-extern int setup_palette(void);
+extern int ofw_setup_palette(void);
 extern void ofw_quiesce(void);
 
Index: boot/tools/ia32/gen_vga323.c
===================================================================
--- boot/tools/ia32/gen_vga323.c	(revision eddf924f5f99dc38d90f38b3639bf6757299c64b)
+++ boot/tools/ia32/gen_vga323.c	(revision fd375a8d1ed315622d230241a9b3227ec34ba99e)
@@ -1,7 +1,35 @@
+/*
+ * Copyright (c) 2008 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #include <stdio.h>
 
-#define RED(i) ((i >> 5) & ((1 << 3) - 1))
-#define GREEN(i) ((i >> 3) & ((1 << 2) - 1))
-#define BLUE(i) (i & ((1 << 3) - 1))
+#define RED(i)    (((i) >> 5) & ((1 << 3) - 1))
+#define GREEN(i)  (((i) >> 3) & ((1 << 2) - 1))
+#define BLUE(i)   ((i) & ((1 << 3) - 1))
 
 int main(int argc, char *argv[]) {
