Index: commands/ieee1275/mandelbrot.c =================================================================== RCS file: commands/ieee1275/mandelbrot.c diff -N commands/ieee1275/mandelbrot.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ commands/ieee1275/mandelbrot.c 25 Aug 2005 09:05:09 -0000 @@ -0,0 +1,145 @@ +/* mandelbrot.c - Draws a nice Manldebrot fractal. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005 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 2 of the License, or + * (at your option) any later version. + * + * This program 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifndef GRUB_EMBED +static grub_err_t +grub_cmd_mandelbrot (struct grub_arg_list *state __attribute__ ((unused)), + int argc, char **argv) +#else /* GRUB_EMBED */ +static void +grub_cmd_mandelbrot (int argc, char *argv[]) +#endif /* ! GRUB_EMBED */ +{ + grub_ieee1275_ihandle_t screen; + grub_ieee1275_phandle_t pscreen; + const unsigned int nmax = 25; + unsigned int n, x, y, w, h, a; + const double xmin = -2.5, xmax = 2.5, ymin = -2, ymax = 2; + double dx, dy, rz, iz, tz, rc, ic; + unsigned char *fb, tmp[4]; + char *device; + grub_ssize_t actual; + + if(argc == 1) + device = argv[0]; + else + device = "screen"; + grub_printf("Using device %s...\n",device); + if (!grub_ieee1275_open (device, &screen)) + { + grub_ieee1275_finddevice (device, &pscreen); + h = grub_ieee1275_fb_height (pscreen); + w = grub_ieee1275_fb_width (pscreen); + grub_printf("w=%d h=%d\n",w,h); + grub_ieee1275_get_property (pscreen,"address",tmp,sizeof(tmp),&actual); + fb = (unsigned char *) grub_ieee1275_decode_int_4(tmp); +// fb = (unsigned char *) grub_ieee1275_fb_addr (pscreen); + grub_printf ("Framebuffer is at %p.\nClearing screen...\n", fb); + for (a = 0; a < w * h; a++) + fb[a] = 0; + for (a = 0; a < 256; a++) /* Fill palette with shades of gray. */ + grub_ieee1275_setcolor (screen, a, a, a, a); + dx = (xmax - xmin) / w; + dy = (ymax - ymin) / h; + for (x = 0; x < w; x++) + { + rc = xmin + x * dx; + for (y = 0; y < h; y++) + { + ic = ymin + y * dy; + rz = 0; + iz = 0; + for (n = 1; n < nmax; n++) + { + tz = rz * rz - iz * iz + rc; + iz = 2 * rz * iz + ic; + rz = tz; + if (rz * rz + iz * iz >= 4) + { + fb[x+w*y] = (n*255/nmax) % 256; + n = nmax; + } + } + if (rz * rz + iz * iz < 4) + fb[x+w*y]=255; + } + } +#if 0 + grub_ieee1275_close (screen); /* If screen is closed, it goes black. */ +#endif + } + grub_printf("Finished !\n"); +#ifndef GRUB_EMBED + return 0; +#endif /* ! GRUB_EMBED */ +} + + +#ifdef GRUB_EMBED +void +grub_mandelbrot_init (void) +{ + grub_rescue_register_command ("mandelbrot", grub_cmd_mandelbrot, + "Draws a fractal."); +} + +void +grub_mandelbrot_fini (void) +{ + grub_rescue_unregister_command ("mandelbrot"); +} +#else /* ! GRUB_EMBED */ +#ifdef GRUB_UTIL +void +grub_mandelbrot_init (void) +{ + grub_register_command ("mandelbrot", grub_cmd_mandelbrot, + GRUB_COMMAND_FLAG_BOTH, "mandelbrot", + "Draws a fractal.", 0); +} + +void +grub_mandelbrot_fini (void) +{ + grub_unregister_command ("mandelbrot"); +} +#else /* ! GRUB_UTIL */ +GRUB_MOD_INIT +{ + (void)mod; /* To stop warning. */ + grub_register_command ("mandelbrot", grub_cmd_mandelbrot, + GRUB_COMMAND_FLAG_BOTH, "mandelbrot", + "Draws a fractal.", 0); +} + +GRUB_MOD_FINI +{ + grub_unregister_command ("mandelbrot"); +} +#endif /* GRUB_UTIL */ +#endif /* GRUB_EMBED */ Index: commands/ieee1275/mousetest.c =================================================================== RCS file: commands/ieee1275/mousetest.c diff -N commands/ieee1275/mousetest.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ commands/ieee1275/mousetest.c 25 Aug 2005 09:05:09 -0000 @@ -0,0 +1,240 @@ +/* mousetest.c - Basic mouse handling. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005 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 2 of the License, or + * (at your option) any later version. + * + * This program 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifndef GRUB_EMBED +static grub_err_t +grub_cmd_mousetest (struct grub_arg_list *state __attribute__ ((unused)), + int argc, char **argv) +#else /* GRUB_EMBED */ +static void +grub_cmd_mousetest (int argc, char *argv[]) +#endif /* ! GRUB_EMBED */ +{ + int x, y, w, h, a; + unsigned char color; + grub_ieee1275_ihandle_t screen, serial; + grub_ieee1275_phandle_t pscreen; + char *device, *mdevice, tmp[3]; + static char car; + static grub_ssize_t actual; + static const unsigned char mousepic[16*16] = { + 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0, + 1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, + 1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0, + 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, + 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, + 1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, + 1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0, + 1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0, + 1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0, + 1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0}; + if(argc == 2) + { + device = argv[0]; + mdevice = argv[1]; + } + else + { + device = "screen"; + mdevice = "mouse"; + } + grub_printf("Using screen device '%s', mouse device '%s'...\n",device, mdevice); + if (!grub_ieee1275_open (device, &screen)) + { + grub_ieee1275_finddevice (device, &pscreen); + h = grub_ieee1275_fb_height (pscreen); + w = grub_ieee1275_fb_width (pscreen); + grub_ieee1275_fillrectangle (screen, 0, 0, 0, w, h); /* Clear screen. */ + grub_ieee1275_setcolor (screen, 0, 0, 0, 0); + grub_ieee1275_setcolor (screen, 1, 255, 255, 255); + grub_ieee1275_setcolor (screen, 2, 255, 255, 255); /* cadre */ + grub_ieee1275_setcolor (screen, 3, 255, 0, 0); /* bg */ + grub_ieee1275_setcolor (screen, 4, 0, 255, 0); /* bd */ + grub_ieee1275_setcolor (screen, 5, 128, 128, 0); /* x */ + grub_ieee1275_setcolor (screen, 6, 0, 128, 128); /* y */ + x = w / 2; + y = h / 2; + color = 255; + if (! grub_ieee1275_open (mdevice, &serial)) + { + tmp[0]='*'; + tmp[1]='n'; + grub_ieee1275_write (serial, tmp, 2, &actual); + /* XXX: Set as 1200 bauds. Is it really needed ? */ + grub_ieee1275_setcolor (screen, 1, color, color, color); + grub_ieee1275_drawrectangle (screen, mousepic, x, y, 16, 16); + while (1) + { + /* Decode Microsoft mouse protocol. */ + a = 0; + while (a < 3) + { + grub_ieee1275_read (serial, &car, 1, &actual); + if(a == 0 && ! (car & 0x40)) + continue; + /* We thought it was the first, and it isn't, loop. */ + else if(a != 0 && (car & 0x40)) + tmp[a = 0] = car; /* We accidentaly found the first. */ + else + tmp[a++] = car; /* Nothing suspicious. */ + } + if (tmp[0] & 16) /* Right button. */ + color += 16; + if (tmp[0] & 32) /* Left button. */ + color -= 16; + grub_ieee1275_fillrectangle (screen, 0, x, y, 16, 16); + x += (signed char) (((tmp[0] & 0x3) << 6) | (tmp[1] & 0x3F)); + y += (signed char) (((tmp[0] & 0xC) << 4) | (tmp[2] & 0x3F)); + if (x < 0) + x = 0; + if (y < 0) + y = 0; + if (x > w) + x = w; + if (y > h) + y = h; + + grub_ieee1275_setcolor (screen, 1, color, color, color); + grub_ieee1275_drawrectangle (screen, mousepic, x, y, 16, 16); + + grub_ieee1275_fillrectangle (screen, 2, 0, 0, 90, 40); + + grub_ieee1275_fillrectangle (screen, tmp[0] & 128 ? 1 : 0, + 5, 5, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[0] & 64 ? 1 : 0, + 15, 5, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[0] & 32 ? 3 : 0, + 25, 5, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[0] & 16 ? 4 : 0, + 35, 5, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[0] & 8 ? 6 : 0, + 45, 5, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[0] & 4 ? 6 : 0, + 55, 5, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[0] & 2 ? 5 : 0, + 65, 5, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[0] & 1 ? 5 : 0, + 75, 5, 10, 10); + + grub_ieee1275_fillrectangle (screen, tmp[1] & 128 ? 1 : 0, + 5, 15, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[1] & 64 ? 1 : 0, + 15, 15, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[1] & 32 ? 5 : 0, + 25, 15, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[1] & 16 ? 5 : 0, + 35, 15, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[1] & 8 ? 5 : 0, + 45, 15, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[1] & 4 ? 5 : 0, + 55, 15, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[1] & 2 ? 5 : 0, + 65, 15, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[1] & 1 ? 5 : 0, + 75, 15, 10, 10); + + grub_ieee1275_fillrectangle (screen, tmp[2] & 128 ? 1 : 0, + 5, 25, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[2] & 64 ? 1 : 0, + 15, 25, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[2] & 32 ? 6 : 0, + 25, 25, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[2] & 16 ? 6 : 0, + 35, 25, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[2] & 8 ? 6 : 0, + 45, 25, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[2] & 4 ? 6 : 0, + 55, 25, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[2] & 2 ? 6 : 0, + 65, 25, 10, 10); + grub_ieee1275_fillrectangle (screen, tmp[2] & 1 ? 6 : 0, + 75, 25, 10, 10); + } + } + else + grub_printf ("Unable to open mouse device !\n"); +#if 0 + grub_ieee1275_close (screen); /* If screen is closed, it goes black. */ +#endif + } + grub_printf("Finished !\n"); +#ifndef GRUB_EMBED + return 0; +#endif /* ! GRUB_EMBED */ +} + + +#ifdef GRUB_EMBED +void +grub_mousetest_init (void) +{ + grub_rescue_register_command ("mousetest", grub_cmd_mousetest, + "Mouse test program."); +} + +void +grub_mousetest_fini (void) +{ + grub_rescue_unregister_command ("mousetest"); +} +#else /* ! GRUB_EMBED */ +#ifdef GRUB_UTIL +void +grub_mousetest_init (void) +{ + grub_register_command ("mousetest", grub_cmd_mousetest, + GRUB_COMMAND_FLAG_BOTH, "mousetest", + "Mouse test program.", 0); +} + +void +grub_mousetest_fini (void) +{ + grub_unregister_command ("mousetest"); +} +#else /* ! GRUB_UTIL */ +GRUB_MOD_INIT +{ + (void)mod; /* To stop warning. */ + grub_register_command ("mousetest", grub_cmd_mousetest, + GRUB_COMMAND_FLAG_BOTH, "mousetest", + "Mouse test program.", 0); +} + +GRUB_MOD_FINI +{ + grub_unregister_command ("mousetest"); +} +#endif /* GRUB_UTIL */ +#endif /* GRUB_EMBED */ Index: conf/powerpc-ieee1275.rmk =================================================================== RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.37 diff -u -p -r1.37 powerpc-ieee1275.rmk --- conf/powerpc-ieee1275.rmk 20 Aug 2005 07:49:01 -0000 1.37 +++ conf/powerpc-ieee1275.rmk 25 Aug 2005 09:05:26 -0000 @@ -75,7 +75,8 @@ pkgdata_MODULES = _linux.mod linux.mod f hfs.mod jfs.mod normal.mod hello.mod font.mod ls.mod \ boot.mod cmp.mod cat.mod terminal.mod fshelp.mod amiga.mod apple.mod \ pc.mod suspend.mod loopback.mod help.mod reboot.mod halt.mod sun.mod \ - default.mod timeout.mod configfile.mod search.mod + default.mod timeout.mod configfile.mod search.mod mandelbrot.mod \ + mousetest.mod fb.mod # For fshelp.mod. fshelp_mod_SOURCES = fs/fshelp.c @@ -204,3 +205,16 @@ configfile_mod_CFLAGS = $(COMMON_CFLAGS) # For search.mod. search_mod_SOURCES = commands/search.c search_mod_CFLAGS = $(COMMON_CFLAGS) + +# For mandelbrot.mod +mandelbrot_mod_SOURCES = commands/ieee1275/mandelbrot.c +mandelbrot_mod_CFLAGS = $(COMMON_CFLAGS) + +# For mousetest.mod +mousetest_mod_SOURCES = commands/ieee1275/mousetest.c +mousetest_mod_CFLAGS = $(COMMON_CFLAGS) + +# For fb.mod +fb_mod_SOURCES = video/ieee1275/fb.c video/ieee1275/fbprops.c +fb_mod_CFLAGS = $(COMMON_CFLAGS) + Index: conf/sparc64-ieee1275.rmk =================================================================== RCS file: /cvsroot/grub/grub2/conf/sparc64-ieee1275.rmk,v retrieving revision 1.2 diff -u -p -r1.2 sparc64-ieee1275.rmk --- conf/sparc64-ieee1275.rmk 21 Aug 2005 19:33:14 -0000 1.2 +++ conf/sparc64-ieee1275.rmk 25 Aug 2005 09:05:27 -0000 @@ -12,7 +12,8 @@ DEFSYMFILES += kernel_syms.lst grubof_HEADERS = arg.h boot.h device.h disk.h dl.h elf.h env.h err.h \ file.h fs.h kernel.h misc.h mm.h net.h rescue.h symbol.h \ term.h types.h loader.h \ - partition.h pc_partition.h ieee1275/ieee1275.h machine/time.h + partition.h pc_partition.h ieee1275/ieee1275.h machine/time.h \ + ieee1275/fb.h ieee1275/fbprops.h grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) gensymlist.sh sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@ @@ -59,9 +60,11 @@ grubof_SOURCES = kern/sparc64/ieee1275/i kern/rescue.c kern/term.c term/ieee1275/ofconsole.c \ kern/sparc64/ieee1275/openfw.c disk/ieee1275/ofdisk.c \ kern/partition.c kern/env.c kern/sparc64/dl.c grubof_symlist.c \ - kern/sparc64/cache.c + kern/sparc64/cache.c \ + video/ieee1275/fb.c video/ieee1275/fbprops.c \ + commands/ieee1275/mandelbrot.c commands/ieee1275/mousetest.c grubof_HEADERS = grub/sparc64/ieee1275/ieee1275.h -grubof_CFLAGS = $(COMMON_CFLAGS) +grubof_CFLAGS = $(COMMON_CFLAGS) -DGRUB_EMBED grubof_ASFLAGS = $(COMMON_ASFLAGS) grubof_LDFLAGS = -m64 -nostdlib -Wl,-N,-Ttext,0x200000,-Bstatic -Xlinker --oformat -Xlinker elf64-sparc @@ -73,7 +76,8 @@ genmoddep_SOURCES = util/genmoddep.c # hfs.mod jfs.mod normal.mod hello.mod font.mod ls.mod \ # boot.mod cmp.mod cat.mod terminal.mod fshelp.mod amiga.mod apple.mod \ # pc.mod suspend.mod loopback.mod help.mod reboot.mod halt.mod sun.mod \ -# default.mod timeout.mod configfile.mod search.mod +# default.mod timeout.mod configfile.mod search.mod mandelbrot.mod \ +# mousetest.mod fb.mod # For fshelp.mod. fshelp_mod_SOURCES = fs/fshelp.c @@ -202,3 +206,16 @@ configfile_mod_CFLAGS = $(COMMON_CFLAGS) # For search.mod. search_mod_SOURCES = commands/search.c search_mod_CFLAGS = $(COMMON_CFLAGS) + +# For mandelbrot.mod +mandelbrot_mod_SOURCES = commands/ieee1275/mandelbrot.c +mandelbrot_mod_CFLAGS = $(COMMON_CFLAGS) + +# For mousetest.mod +mousetest_mod_SOURCES = commands/ieee1275/mousetest.c +mousetest_mod_CFLAGS = $(COMMON_CFLAGS) + +# For fb.mod +fb_mod_SOURCES = video/ieee1275/fb.c video/ieee1275/fbprops.c +fb_mod_CFLAGS = $(COMMON_CFLAGS) + Index: include/grub/ieee1275/fb.h =================================================================== RCS file: include/grub/ieee1275/fb.h diff -N include/grub/ieee1275/fb.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ include/grub/ieee1275/fb.h 25 Aug 2005 09:05:29 -0000 @@ -0,0 +1,54 @@ +/* fb.h - Access the Open Firmware client interface - framebuffer + * functions. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005 Free Software Foundation, Inc. + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef GRUB_IEEE1275_FB_HEADER +#define GRUB_IEEE1275_FB_HEADER 1 + +#include +#include + +int EXPORT_FUNC(grub_ieee1275_setcolor) (grub_ieee1275_ihandle_t ihandle, + grub_ieee1275_cell_t index, grub_ieee1275_cell_t red, + grub_ieee1275_cell_t green, grub_ieee1275_cell_t blue); +int EXPORT_FUNC(grub_ieee1275_getcolor) (grub_ieee1275_ihandle_t ihandle, + grub_ieee1275_cell_t index, grub_ieee1275_cell_t *red, + grub_ieee1275_cell_t *green, grub_ieee1275_cell_t *blue); +/* XXX: Test me ! */ +int EXPORT_FUNC(grub_ieee1275_setcolors) (grub_ieee1275_ihandle_t ihandle, + const void *adr, grub_ieee1275_cell_t index, grub_ieee1275_cell_t indices); +/* XXX: Test me ! */ +int EXPORT_FUNC(grub_ieee1275_getcolors) (grub_ieee1275_ihandle_t ihandle, + void *adr, grub_ieee1275_cell_t index, grub_ieee1275_cell_t indices); +/* XXX: Test me ! */ +int EXPORT_FUNC(grub_ieee1275_drawrectangle) (grub_ieee1275_ihandle_t ihandle, + const void *image, grub_ieee1275_cell_t left, grub_ieee1275_cell_t top, + grub_ieee1275_cell_t width, grub_ieee1275_cell_t height); +/* XXX: Test me ! */ +int EXPORT_FUNC(grub_ieee1275_fillrectangle) (grub_ieee1275_ihandle_t ihandle, + grub_ieee1275_cell_t color, grub_ieee1275_cell_t left, + grub_ieee1275_cell_t top, grub_ieee1275_cell_t width, + grub_ieee1275_cell_t height); +int EXPORT_FUNC(grub_ieee1275_readrectangle) (grub_ieee1275_ihandle_t ihandle, + void **image, grub_ieee1275_cell_t left, grub_ieee1275_cell_t top, + grub_ieee1275_cell_t width, grub_ieee1275_cell_t height); +/* XXX: Test me ! */ + +#endif /* ! GRUB_IEEE1275_FB_HEADER */ Index: include/grub/ieee1275/fbprops.h =================================================================== RCS file: include/grub/ieee1275/fbprops.h diff -N include/grub/ieee1275/fbprops.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ include/grub/ieee1275/fbprops.h 25 Aug 2005 09:05:29 -0000 @@ -0,0 +1,43 @@ +/* fbprops.h - Access the Open Firmware client interface - framebuffer + * properties. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005 Free Software Foundation, Inc. + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef GRUB_IEEE1275_FBPROPS_HEADER +#define GRUB_IEEE1275_FBPROPS_HEADER 1 + +#include +#include + +void * EXPORT_FUNC(grub_ieee1275_decode_address) (void *address); + /* XXX: Test me ! */ +void * EXPORT_FUNC(grub_ieee1275_getproperty_addr) + (grub_ieee1275_phandle_t phandle, char *property); /* XXX: Test me ! */ +void * EXPORT_FUNC(grub_ieee1275_fb_addr) + (grub_ieee1275_phandle_t phandle); /* XXX: Test me ! */ +int EXPORT_FUNC(grub_ieee1275_getproperty_4) (grub_ieee1275_phandle_t phandle, + char *property); +int EXPORT_FUNC(grub_ieee1275_fb_height) (grub_ieee1275_phandle_t phandle); +int EXPORT_FUNC(grub_ieee1275_fb_width) (grub_ieee1275_phandle_t phandle); +/*int EXPORT_NO!_FUNC(grub_ieee1275_fb_linebytes) + (grub_ieee1275_phandle_t phandle); *//* XXX: Test me ! */ +/*int EXPORT_NO!_FUNC(grub_ieee1275_fb_depth) + (grub_ieee1275_phandle_t phandle);*//* XXX: Test me ! */ + +#endif /* ! GRUB_IEEE1275_FBPROPS_HEADER */ Index: kern/sparc64/ieee1275/init.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/sparc64/ieee1275/init.c,v retrieving revision 1.1 diff -u -p -r1.1 init.c --- kern/sparc64/ieee1275/init.c 21 Aug 2005 18:42:55 -0000 1.1 +++ kern/sparc64/ieee1275/init.c 25 Aug 2005 09:05:30 -0000 @@ -205,11 +205,20 @@ grub_machine_init (void) } } +#ifdef GRUB_EMBED + grub_mandelbrot_init (); + grub_mousetest_init (); +#endif /* GRUB_EMBED */ + } void grub_machine_fini (void) { +#ifdef GRUB_EMBED + grub_mousetest_fini (); + grub_mandelbrot_fini (); +#endif /* GRUB_EMBED */ grub_ofdisk_fini (); grub_console_fini (); } Index: video/ieee1275/fb.c =================================================================== RCS file: video/ieee1275/fb.c diff -N video/ieee1275/fb.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ video/ieee1275/fb.c 25 Aug 2005 09:05:31 -0000 @@ -0,0 +1,222 @@ +/* fb.c - Access the Open Firmware client interface - framebuffer + * functions. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005 Free Software Foundation, Inc. + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include + +int +grub_ieee1275_setcolor (grub_ieee1275_ihandle_t ihandle, + grub_ieee1275_cell_t index, grub_ieee1275_cell_t red, + grub_ieee1275_cell_t green, grub_ieee1275_cell_t blue) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + char *method; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t index; + grub_ieee1275_cell_t blue; + grub_ieee1275_cell_t green; + grub_ieee1275_cell_t red; + } args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 0); + args.method = "color!"; + args.ihandle = ihandle; + args.index = index; + args.red = red; + args.green = green; + args.blue = blue; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + return 0; +} + +int +grub_ieee1275_getcolor (grub_ieee1275_ihandle_t ihandle, + grub_ieee1275_cell_t index, grub_ieee1275_cell_t *red, + grub_ieee1275_cell_t *green, grub_ieee1275_cell_t *blue) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + char *method; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t index; + grub_ieee1275_cell_t blue; /* XXX: Right order for return values ? */ + grub_ieee1275_cell_t green;/* (here, top of stack last) */ + grub_ieee1275_cell_t red; + } args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 3, 3); + args.method = "color@"; + args.ihandle = ihandle; + args.index = index; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + *red = args.red; + *green = args.green; + *blue = args.blue; + + return 0; +} + +int +grub_ieee1275_setcolors (grub_ieee1275_ihandle_t ihandle, const void *adr, + grub_ieee1275_cell_t index, grub_ieee1275_cell_t indices) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + char *method; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t indices; + grub_ieee1275_cell_t index; + const void *adr; + } args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 3, 0); + args.method = "set-colors"; + args.ihandle = ihandle; + args.adr = adr; + args.index = index; + args.indices = indices; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + return 0; +} + +int +grub_ieee1275_getcolors (grub_ieee1275_ihandle_t ihandle, void *adr, + grub_ieee1275_cell_t index, grub_ieee1275_cell_t indices) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + char *method; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t indices; + grub_ieee1275_cell_t index; + void *adr; + } args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 3, 0); + args.method = "get-colors"; + args.ihandle = ihandle; + args.adr = adr; + args.index = index; + args.indices = indices; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + return 0; +} + +int +grub_ieee1275_drawrectangle (grub_ieee1275_ihandle_t ihandle, const void *image, + grub_ieee1275_cell_t left, grub_ieee1275_cell_t top, + grub_ieee1275_cell_t width, grub_ieee1275_cell_t height) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + char *method; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t height; + grub_ieee1275_cell_t width; + grub_ieee1275_cell_t top; + grub_ieee1275_cell_t left; + const void *image; + } args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 7, 0); + args.method = "draw-rectangle"; + args.ihandle = ihandle; + args.image = image; + args.left = left; + args.top = top; + args.width = width; + args.height = height; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + return 0; +} + +int +grub_ieee1275_fillrectangle (grub_ieee1275_ihandle_t ihandle, + grub_ieee1275_cell_t color, grub_ieee1275_cell_t left, + grub_ieee1275_cell_t top, grub_ieee1275_cell_t width, + grub_ieee1275_cell_t height) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + char *method; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t height; + grub_ieee1275_cell_t width; + grub_ieee1275_cell_t top; + grub_ieee1275_cell_t left; + grub_ieee1275_cell_t color; + } args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 7, 0); + args.method = "fill-rectangle"; + args.ihandle = ihandle; + args.color = color; + args.left = left; + args.top = top; + args.width = width; + args.height = height; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + return 0; +} + +int +grub_ieee1275_readrectangle (grub_ieee1275_ihandle_t ihandle, void **image, + grub_ieee1275_cell_t left, grub_ieee1275_cell_t top, + grub_ieee1275_cell_t width, grub_ieee1275_cell_t height) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + char *method; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t height; + grub_ieee1275_cell_t width; + grub_ieee1275_cell_t top; + grub_ieee1275_cell_t left; + void **image; + } args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 7, 0); + args.method = "read-rectangle"; + args.ihandle = ihandle; + args.image = image; + args.left = left; + args.top = top; + args.width = width; + args.height = height; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + return 0; +} + Index: video/ieee1275/fbprops.c =================================================================== RCS file: video/ieee1275/fbprops.c diff -N video/ieee1275/fbprops.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ video/ieee1275/fbprops.c 25 Aug 2005 09:05:31 -0000 @@ -0,0 +1,96 @@ +/* fbprops.c - Access the Open Firmware client interface - framebuffer + * properties. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005 Free Software Foundation, Inc. + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include + +void * +grub_ieee1275_decode_address (void *address) +{ + union { + void *adr; + unsigned char bytes[GRUB_HOST_SIZEOF_VOID_P]; + } from, to; + int pos; + from.adr = address; + for (pos = 0; pos < GRUB_HOST_SIZEOF_VOID_P; pos++) + to.bytes[pos] = from.bytes[GRUB_HOST_SIZEOF_VOID_P - pos - 1]; + return to.adr; +} + +int +grub_ieee1275_getproperty_4 (grub_ieee1275_phandle_t phandle, + char *property) +{ + unsigned char tmp[4]; + grub_ssize_t actual; + if (grub_ieee1275_get_property (phandle, property, tmp, sizeof (tmp), &actual) + || actual != sizeof (tmp)) + return -1; + return grub_ieee1275_decode_int_4 (tmp); +} + +void * +grub_ieee1275_getproperty_addr (grub_ieee1275_phandle_t phandle, + char *property) +{ + void *tmp; +/* unsigned char tmp[4];*/ + grub_ssize_t actual; + if (grub_ieee1275_get_property (phandle, property, &tmp, sizeof (tmp), &actual) + || actual != sizeof (tmp)) + return (void *) -1; + return grub_ieee1275_decode_address (tmp); +/* return (void *) grub_ieee1275_decode_int_4 (tmp);*/ +} + +void * +grub_ieee1275_fb_addr (grub_ieee1275_phandle_t phandle) +{ + return (void *) grub_ieee1275_getproperty_4 (phandle, "address"); + /* XXX: this address is 4 bytes long only. */ +} + +int +grub_ieee1275_fb_height(grub_ieee1275_phandle_t phandle) +{ + return grub_ieee1275_getproperty_4 (phandle, "height"); +} + +int +grub_ieee1275_fb_width(grub_ieee1275_phandle_t phandle) +{ + return grub_ieee1275_getproperty_4 (phandle, "width"); +} + +/* XXX: Not always supported. */ +/*int +grub_ieee1275_fb_linebytes(grub_ieee1275_phandle_t phandle) +{ + return grub_ieee1275_getproperty_4 (phandle, "linebytes"); +}*/ + +/* XXX: Not always supported. */ +/*int +grub_ieee1275_fb_depth(grub_ieee1275_phandle_t phandle) +{ + return grub_ieee1275_getproperty_4 (phandle, "depth"); +}*/ +