OpenBIOS
Threads by month
- ----- 2025 -----
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2000 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1999 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1998 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1997 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1996 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1995 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1994 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1993 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1992 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1991 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1990 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1989 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1988 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1987 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1986 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1985 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1984 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1983 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1982 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1981 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1980 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1979 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1978 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1977 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1976 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1975 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1974 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1973 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1972 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1971 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1970 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1969 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1968 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1967 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1966 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1965 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1964 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1963 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1962 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1961 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1960 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1959 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1958 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1957 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1956 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1955 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1954 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1953 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1952 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1951 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1950 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1949 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1948 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1947 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1946 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1945 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1944 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1943 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1942 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1941 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1940 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1939 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1938 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1937 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1936 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1935 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1934 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1933 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1932 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1931 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1930 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1929 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1928 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1927 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1926 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1925 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1924 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1923 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1922 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1921 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1920 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1919 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1918 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1917 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1916 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1915 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1914 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1913 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1912 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1911 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1910 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1909 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1908 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1907 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1906 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1905 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1904 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
November 2008
- 13 participants
- 62 discussions

r258 - in openbios-devel: arch/ppc/qemu config/examples drivers modules
by svn@openbios.org Nov. 24, 2008
by svn@openbios.org Nov. 24, 2008
Nov. 24, 2008
Author: stepan
Date: 2008-11-24 13:38:23 +0100 (Mon, 24 Nov 2008)
New Revision: 258
Added:
openbios-devel/drivers/vga_vbe.c
Modified:
openbios-devel/arch/ppc/qemu/console.c
openbios-devel/arch/ppc/qemu/init.c
openbios-devel/config/examples/cross-ppc_config.xml
openbios-devel/drivers/build.xml
openbios-devel/drivers/pci.c
openbios-devel/drivers/vga.h
openbios-devel/drivers/vga_load_regs.c
openbios-devel/modules/console.c
openbios-devel/modules/video.c
Log:
Add Bochs VBE VGA support
Modified: openbios-devel/arch/ppc/qemu/console.c
===================================================================
--- openbios-devel/arch/ppc/qemu/console.c 2008-11-24 12:29:36 UTC (rev 257)
+++ openbios-devel/arch/ppc/qemu/console.c 2008-11-24 12:38:23 UTC (rev 258)
@@ -131,24 +131,26 @@
} osi_fb_info_t;
+#define openbios_GetFBInfo(x) Qemu_GetFBInfo(x)
+
+#include "../../../modules/font_8x16.c"
+#include "../../../modules/video.c"
+#include "../../../modules/console.c"
+
+static uint32_t vga_phys_mem;
+static int vga_width, vga_height, vga_depth;
+
int Qemu_GetFBInfo( osi_fb_info_t *fb )
{
+ fb->mphys = vga_phys_mem;
+ fb->w = vga_width;
+ fb->h = vga_height;
+ fb->depth = vga_depth;
+ fb->rb = fb->w * ((fb->depth + 7) / 8);
- fb->w=1024;
- fb->h=768;
- fb->depth=15;
- fb->rb=2048;
- fb->mphys=0x84000000;
-
return 0;
}
-#define openbios_GetFBInfo(x) Qemu_GetFBInfo(x)
-
-#include "../../../modules/video.c"
-
-#include "../../../modules/console.c"
-
/* ******************************************************************
* common functions, implementing simple concurrent console
* ****************************************************************** */
Modified: openbios-devel/arch/ppc/qemu/init.c
===================================================================
--- openbios-devel/arch/ppc/qemu/init.c 2008-11-24 12:29:36 UTC (rev 257)
+++ openbios-devel/arch/ppc/qemu/init.c 2008-11-24 12:38:23 UTC (rev 258)
@@ -118,7 +118,6 @@
#endif
node_methods_init();
- init_video();
#if USE_RTAS
if( !(ph=find_dev("/rtas")) )
Modified: openbios-devel/config/examples/cross-ppc_config.xml
===================================================================
--- openbios-devel/config/examples/cross-ppc_config.xml 2008-11-24 12:29:36 UTC (rev 257)
+++ openbios-devel/config/examples/cross-ppc_config.xml 2008-11-24 12:38:23 UTC (rev 258)
@@ -25,7 +25,7 @@
<option name="CONFIG_DEBUG_INTERPRETER" type="boolean" value="false"/>
<option name="CONFIG_DEBUG_CONSOLE" type="boolean" value="true"/>
<option name="CONFIG_DEBUG_CONSOLE_SERIAL" type="boolean" value="true"/>
- <option name="CONFIG_SERIAL_PORT" type="boolean" value="true"/>
+ <option name="CONFIG_SERIAL_PORT" type="integer" value="1"/>
<option name="CONFIG_SERIAL_SPEED" type="integer" value="115200"/>
<option name="CONFIG_DEBUG_CONSOLE_VGA" type="boolean" value="true"/>
@@ -67,6 +67,7 @@
<option name="CONFIG_IDE_NUM_CHANNELS" type="integer" value="4"/>
<option name="CONFIG_DEBUG_IDE" type="boolean" value="false"/>
<option name="CONFIG_DRIVER_ADB" type="boolean" value="true"/>
+ <option name="CONFIG_DRIVER_VGA" type="boolean" value="true"/>
</config>
Modified: openbios-devel/drivers/build.xml
===================================================================
--- openbios-devel/drivers/build.xml 2008-11-24 12:29:36 UTC (rev 257)
+++ openbios-devel/drivers/build.xml 2008-11-24 12:38:23 UTC (rev 258)
@@ -14,6 +14,7 @@
<object source="obio.c" condition="DRIVER_OBIO"/>
<object source="vga_load_regs.c" condition="DRIVER_VGA"/>
<object source="vga_set_mode.c" condition="DRIVER_VGA"/>
+ <object source="vga_vbe.c" condition="DRIVER_VGA"/>
</library>
<dictionary name="openbios" target="forth">
Modified: openbios-devel/drivers/pci.c
===================================================================
--- openbios-devel/drivers/pci.c 2008-11-24 12:29:36 UTC (rev 257)
+++ openbios-devel/drivers/pci.c 2008-11-24 12:38:23 UTC (rev 258)
@@ -301,11 +301,9 @@
static int vga_config_cb (pci_config_t *config)
{
-#if 0
if (config->regions[0] != 0x00000000)
vga_vbe_init(config->path, config->regions[0], config->sizes[0],
config->regions[1], config->sizes[1]);
-#endif
return 0;
}
Modified: openbios-devel/drivers/vga.h
===================================================================
--- openbios-devel/drivers/vga.h 2008-11-24 12:29:36 UTC (rev 257)
+++ openbios-devel/drivers/vga.h 2008-11-24 12:38:23 UTC (rev 258)
@@ -90,6 +90,8 @@
#define SEQ_I 0x3C4 /* Sequencer Index */
#define PEL_IW 0x3C8 /* PEL Write Index */
#define PEL_IR 0x3C7 /* PEL Read Index */
+#define DAC_REG 0x3C8 /* DAC register */
+#define DAC_VAL 0x3C9 /* DAC value */
/* standard VGA indexes max counts */
#define CRTC_C 25 /* 25 CRT Controller Registers sequentially set*/
Modified: openbios-devel/drivers/vga_load_regs.c
===================================================================
--- openbios-devel/drivers/vga_load_regs.c 2008-11-24 12:29:36 UTC (rev 257)
+++ openbios-devel/drivers/vga_load_regs.c 2008-11-24 12:38:23 UTC (rev 258)
@@ -22,6 +22,8 @@
*
*/
+static int depth;
+
// prototypes
static int vga_decode_var(const struct screeninfo *var, struct vga_par *par);
static int vga_set_regs(const struct vga_par *par);
@@ -124,11 +126,7 @@
0, // activate now
-1,-1, // height and width in mm
0, // accel flags
- 39721, // pixclock: 79442 -> 12.587 Mhz (NOT USED)
- // 70616 -> 14.161
- // 39721 -> 25.175
- // 35308 -> 28.322
-
+ 39721, // pixclock
48, 16, 39, 8, // margins left,right,upper,lower
96, // hsync length
2, // vsync length
Added: openbios-devel/drivers/vga_vbe.c
===================================================================
--- openbios-devel/drivers/vga_vbe.c (rev 0)
+++ openbios-devel/drivers/vga_vbe.c 2008-11-24 12:38:23 UTC (rev 258)
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2004-2005 Fabrice Bellard
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License V2
+ * as published by the Free Software Foundation
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "openbios/config.h"
+#include "openbios/kernel.h"
+#include "openbios/bindings.h"
+#include "openbios/pci.h"
+#include "asm/io.h"
+
+/* VGA init. We use the Bochs VESA VBE extensions */
+#define VBE_DISPI_INDEX_ID 0x0
+#define VBE_DISPI_INDEX_XRES 0x1
+#define VBE_DISPI_INDEX_YRES 0x2
+#define VBE_DISPI_INDEX_BPP 0x3
+#define VBE_DISPI_INDEX_ENABLE 0x4
+#define VBE_DISPI_INDEX_BANK 0x5
+#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
+#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
+#define VBE_DISPI_INDEX_X_OFFSET 0x8
+#define VBE_DISPI_INDEX_Y_OFFSET 0x9
+#define VBE_DISPI_INDEX_NB 0xa
+
+#define VBE_DISPI_ID0 0xB0C0
+#define VBE_DISPI_ID1 0xB0C1
+#define VBE_DISPI_ID2 0xB0C2
+
+#define VBE_DISPI_DISABLED 0x00
+#define VBE_DISPI_ENABLED 0x01
+#define VBE_DISPI_LFB_ENABLED 0x40
+#define VBE_DISPI_NOCLEARMEM 0x80
+
+static void vbe_outw(int index, int val)
+{
+ outw(index, 0x1ce);
+ outw(val, 0x1d0);
+}
+
+/* for depth = 8 mode, set a hardware palette entry */
+void vga_set_color(int i, unsigned int r, unsigned int g, unsigned int b)
+{
+ r &= 0xff;
+ g &= 0xff;
+ b &= 0xff;
+ outb(i, 0x3c8);
+ outb(r >> 2, 0x3c9);
+ outb(g >> 2, 0x3c9);
+ outb(b >> 2, 0x3c9);
+}
+
+/* build standard RGB palette */
+static void vga_build_rgb_palette(void)
+{
+ static const uint8_t pal_value[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff };
+ int i, r, g, b;
+
+ i = 0;
+ for(r = 0; r < 6; r++) {
+ for(g = 0; g < 6; g++) {
+ for(b = 0; b < 6; b++) {
+ vga_set_color(i, pal_value[r], pal_value[g], pal_value[b]);
+ i++;
+ }
+ }
+ }
+}
+
+/* depth = 8, 15, 16 or 32 */
+void vga_vbe_set_mode(int width, int height, int depth)
+{
+ outb(0x00, 0x3c0); /* enable blanking */
+ vbe_outw(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED);
+ vbe_outw(VBE_DISPI_INDEX_X_OFFSET, 0);
+ vbe_outw(VBE_DISPI_INDEX_Y_OFFSET, 0);
+ vbe_outw(VBE_DISPI_INDEX_XRES, width);
+ vbe_outw(VBE_DISPI_INDEX_YRES, height);
+ vbe_outw(VBE_DISPI_INDEX_BPP, depth);
+ vbe_outw(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED);
+ outb(0x00, 0x3c0);
+ outb(0x20, 0x3c0); /* disable blanking */
+
+ if (depth == 8)
+ vga_build_rgb_palette();
+}
+
+void vga_vbe_init(char *path, uint32_t fb, uint32_t fb_size,
+ uint32_t rom, uint32_t rom_size)
+{
+ phandle_t ph, chosen, aliases;
+
+ vga_vbe_set_mode(800, 600, 8);
+
+ ph = find_dev(path);
+
+ set_int_property(ph, "width", 800);
+ set_int_property(ph, "height", 600);
+ set_int_property(ph, "depth", 8);
+ set_int_property(ph, "linebytes", 800);
+ set_int_property(ph, "address", fb & ~0x0000000F);
+
+ chosen = find_dev("/chosen");
+ set_int_property(chosen, "display", ph);
+
+ aliases = find_dev("/aliases");
+ set_property(aliases, "screen", path, strlen(path) + 1);
+ if (rom_size >= 8) {
+ const uint8_t *p;
+ int size;
+ p = rom;
+ if (p[0] == 'N' && p[1] == 'D' && p[2] == 'R' && p[3] == 'V') {
+ size = *(uint32_t*)(p + 4);
+ set_property(ph, "driver,AAPL,MacOS,PowerPC",
+ p + 8, size);
+ }
+ }
+
+ init_video(fb, 800, 600, 8, 800);
+}
Modified: openbios-devel/modules/console.c
===================================================================
--- openbios-devel/modules/console.c 2008-11-24 12:29:36 UTC (rev 257)
+++ openbios-devel/modules/console.c 2008-11-24 12:38:23 UTC (rev 258)
@@ -153,21 +153,8 @@
osi_fb_info_t fb;
int i, x, offs, size, *dest, *src;
- openbios_GetFBInfo( &fb );
+ video_scroll( FONT_ADJ_HEIGHT );
- offs = fb.rb * FONT_ADJ_HEIGHT;
- size = (fb.h * fb.rb - offs)/16;
- dest = (int*)fb.mphys;
- src = (int*)(fb.mphys + offs);
-
- for( i=0; i<size; i++ ) {
- dest[0] = src[0];
- dest[1] = src[1];
- dest[2] = src[2];
- dest[3] = src[3];
- dest += 4;
- src += 4;
- }
for( x=0; x<cons.w; x++ )
cons.buf[(cons.h-1)*cons.w + x] = 0;
draw_line(cons.h-1);
Modified: openbios-devel/modules/video.c
===================================================================
--- openbios-devel/modules/video.c 2008-11-24 12:29:36 UTC (rev 257)
+++ openbios-devel/modules/video.c 2008-11-24 12:38:23 UTC (rev 258)
@@ -146,7 +146,7 @@
while( ww-- )
*p++ = col;
} else {
- char *p = (char*)pp + x;
+ char *p = (ushort*)pp + x;
while( ww-- )
*p++ = col;
}
@@ -179,10 +179,33 @@
dac[1] = ((color >> 8) & 0xff) << 24; // Green
dac[1] = (color & 0xff) << 24; // Blue
}
+#else
+ vga_set_color(ind, ((color >> 16) & 0xff),
+ ((color >> 8) & 0xff),
+ (color & 0xff));
#endif
}
+void
+video_scroll( int height )
+{
+ int i, x, offs, size, *dest, *src;
+ offs = video.fb.rb * height;
+ size = (video.fb.h * video.fb.rb - offs)/16;
+ dest = (int*)video.fb.mphys;
+ src = (int*)(video.fb.mphys + offs);
+
+ for( i=0; i<size; i++ ) {
+ dest[0] = src[0];
+ dest[1] = src[1];
+ dest[2] = src[2];
+ dest[3] = src[3];
+ dest += 4;
+ src += 4;
+ }
+}
+
/************************************************************************/
/* OF methods */
/************************************************************************/
@@ -257,14 +280,18 @@
PUSH(len);
}
+#if 0
static void
video_open(void)
{
RET(-1);
}
+#endif
NODE_METHODS( video ) = {
+#if 0
{"open", video_open },
+#endif
{"dimensions", video_dimensions },
{"set-colors", video_set_colors },
{"fill-rectangle", video_fill_rect },
@@ -278,22 +305,15 @@
/************************************************************************/
void
-init_video( void )
+init_video( uint32_t fb, int width, int height, int depth, int rb )
{
int i, s, size;
- phandle_t ph=0;
-
- if( openbios_GetFBInfo(&video.fb) ) {
- printk("init_video: No video display\n");
- return;
- }
- while( (ph=dt_iterate_type(ph, "display")) ) {
- set_property( ph, "width", (char*)&video.fb.w, 4 );
- set_property( ph, "height", (char*)&video.fb.h, 4 );
- set_property( ph, "depth", (char*)&video.fb.depth, 4 );
- set_property( ph, "linebytes", (char*)&video.fb.rb, 4 );
- set_property( ph, "address", (char*)&video.fb.mphys, 4 );
- }
+
+ video.fb.mphys = fb;
+ video.fb.w = width;
+ video.fb.h = height;
+ video.fb.depth = depth;
+ video.fb.rb = rb;
video.has_video = 1;
video.pal = malloc( 256 * sizeof(int) );
@@ -306,7 +326,7 @@
ofmem_claim_virt( video.fb.mphys, size, 0 );
ofmem_map( video.fb.mphys, video.fb.mphys, size, -1 );
#endif
-
+
for( i=0; i<256; i++ )
set_color( i, i * 0x010101 );
1
0
Author: stepan
Date: 2008-11-24 13:29:36 +0100 (Mon, 24 Nov 2008)
New Revision: 257
Modified:
openbios-devel/drivers/pci.c
openbios-devel/drivers/pci.h
openbios-devel/include/ppc/pci.h
Log:
Create device tree according found PCI devices.
Signed-off-by: Laurent Vivier <Laurent(a)lvivier.info>
Acked-by: Stefan Reinauer <stepan(a)coresystems.de>
Modified: openbios-devel/drivers/pci.c
===================================================================
--- openbios-devel/drivers/pci.c 2008-11-24 12:23:01 UTC (rev 256)
+++ openbios-devel/drivers/pci.c 2008-11-24 12:29:36 UTC (rev 257)
@@ -16,6 +16,7 @@
#include "openbios/config.h"
#include "openbios/bindings.h"
#include "openbios/kernel.h"
+#include "openbios/pci.h"
#include "libc/byteorder.h"
#include "libc/vsprintf.h"
@@ -53,16 +54,1229 @@
{ "close", ob_pci_close },
};
-static int ob_pci_add_properties(pci_addr addr)
+/* PCI devices database */
+typedef struct pci_class_t pci_class_t;
+typedef struct pci_subclass_t pci_subclass_t;
+typedef struct pci_iface_t pci_iface_t;
+typedef struct pci_dev_t pci_dev_t;
+
+typedef struct pci_config_t pci_config_t;
+
+struct pci_config_t {
+ char path[64];
+ uint32_t regions[7];
+ uint32_t sizes[7];
+};
+
+struct pci_iface_t {
+ uint8_t iface;
+ const char *name;
+ const char *type;
+ const pci_dev_t *devices;
+ int (*config_cb)(pci_config_t *config);
+ const void *private;
+};
+
+struct pci_subclass_t {
+ uint8_t subclass;
+ const char *name;
+ const char *type;
+ const pci_dev_t *devices;
+ const pci_iface_t *iface;
+ int (*config_cb)(pci_config_t *config);
+ const void *private;
+};
+
+struct pci_class_t {
+ const char *name;
+ const char *type;
+ const pci_subclass_t *subc;
+};
+
+struct pci_dev_t {
+ uint16_t vendor;
+ uint16_t product;
+ const char *type;
+ const char *name;
+ const char *model;
+ const char *compat;
+ int acells;
+ int scells;
+ int icells;
+ int (*config_cb)(pci_config_t *config);
+ const void *private;
+};
+
+/* Current machine description */
+
+typedef struct pci_bridge_t pci_bridge_t;
+
+/* Low level access helpers */
+struct pci_ops_t {
+ uint8_t (*config_readb)(pci_bridge_t *bridge,
+ uint8_t bus, uint8_t devfn, uint8_t offset);
+ void (*config_writeb)(pci_bridge_t *bridge,
+ uint8_t bus, uint8_t devfn,
+ uint8_t offset, uint8_t val);
+ uint16_t (*config_readw)(pci_bridge_t *bridge,
+ uint8_t bus, uint8_t devfn, uint8_t offset);
+ void (*config_writew)(pci_bridge_t *bridge,
+ uint8_t bus, uint8_t devfn,
+ uint8_t offset, uint16_t val);
+ uint32_t (*config_readl)(pci_bridge_t *bridge,
+ uint8_t bus, uint8_t devfn, uint8_t offset);
+ void (*config_writel)(pci_bridge_t *bridge,
+ uint8_t bus, uint8_t devfn,
+ uint8_t offset, uint32_t val);
+};
+
+static pci_subclass_t undef_subclass[] = {
+ {
+ 0x00, "misc undefined", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static int ide_config_cb2 (pci_config_t *config)
{
+#if 0
+ ide_init(config->path,
+ config->regions[0] & ~0x0000000F,
+ config->regions[1] & ~0x0000000F,
+ config->regions[2] & ~0x0000000F,
+ config->regions[3] & ~0x0000000F);
+#endif
+ return 0;
+}
+
+static pci_dev_t ide_devices[] = {
+ {
+ 0x1095, 0x0646, /* CMD646 IDE controller */
+ "pci-ide", "pci-ata", NULL, NULL,
+ 0, 0, 0,
+ ide_config_cb2, NULL,
+ },
+ {
+ 0xFFFF, 0xFFFF,
+ NULL, NULL, NULL, NULL,
+ -1, -1, -1,
+ NULL, NULL,
+ },
+};
+
+static pci_subclass_t mass_subclass[] = {
+ {
+ 0x00, "SCSI bus controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x01, "IDE controller", "ide", ide_devices, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x02, "Floppy disk controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x03, "IPI bus controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x04, "RAID controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x05, "ATA controller", "ata", NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x80, "misc mass-storage controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_dev_t eth_devices[] = {
+ { 0x10EC, 0x8029,
+ NULL, "NE2000", "NE2000 PCI", NULL,
+ 0, 0, 0,
+ NULL, "ethernet",
+ },
+ {
+ 0xFFFF, 0xFFFF,
+ NULL, NULL, NULL, NULL,
+ -1, -1, -1,
+ NULL, NULL,
+ },
+};
+
+static int eth_config_cb (pci_config_t *config)
+{
+ phandle_t ph;
+ int props[12];
+ int i;
+
+ ph = find_dev(config->path);
+
+ set_property(ph, "network-type", "ethernet", 9);
+ set_property(ph, "removable", "network", 8);
+ set_property(ph, "category", "net", 4);
+
+ for (i = 0; i < 7; i++)
+ {
+ props[i*2] = config->regions[i];
+ props[i*2 + 1] = config->sizes[i];
+ }
+ set_property(ph, "reg", props, i * 2 * sizeof(int));
+}
+
+static pci_subclass_t net_subclass[] = {
+ {
+ 0x00, "ethernet controller", NULL, eth_devices, NULL,
+ eth_config_cb, "ethernet",
+ },
+ {
+ 0x01, "token ring controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x02, "FDDI controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x03, "ATM controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x04, "ISDN controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x05, "WordFip controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x06, "PICMG 2.14 controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x80, "misc network controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_dev_t vga_devices[] = {
+ {
+ 0x1002, 0x5046,
+ NULL, "ATY", "ATY Rage128", "VGA",
+ 0, 0, 0,
+ NULL, NULL,
+ },
+ {
+ 0x1234, 0x1111,
+ NULL, "QEMU,VGA", "Qemu VGA", "VGA",
+ 0, 0, 0,
+ NULL, NULL,
+ },
+ {
+ 0xFFFF, 0xFFFF,
+ NULL, NULL, NULL, NULL,
+ -1, -1, -1,
+ NULL, NULL,
+ },
+};
+
+/* VGA configuration */
+
+static int vga_config_cb (pci_config_t *config)
+{
+#if 0
+ if (config->regions[0] != 0x00000000)
+ vga_vbe_init(config->path, config->regions[0], config->sizes[0],
+ config->regions[1], config->sizes[1]);
+#endif
+ return 0;
+}
+
+static struct pci_iface_t vga_iface[] = {
+ {
+ 0x00, "VGA controller", NULL,
+ vga_devices, &vga_config_cb, NULL,
+ },
+ {
+ 0x01, "8514 compatible controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL,
+ NULL, NULL, NULL,
+ },
+};
+
+static pci_subclass_t displ_subclass[] = {
+ {
+ 0x00, "display controller", NULL, NULL, vga_iface,
+ NULL, NULL,
+ },
+ {
+ 0x01, "XGA display controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x02, "3D display controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x80, "misc display controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_subclass_t media_subclass[] = {
+ {
+ 0x00, "video device", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x01, "audio device", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x02, "computer telephony device", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x80, "misc multimedia device", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_subclass_t mem_subclass[] = {
+ {
+ 0x00, "RAM controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x01, "flash controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+pci_dev_t grackle_fake_bridge = {
+ 0xFFFF, 0xFFFF,
+ "pci", "pci-bridge", "DEC,21154", "DEC,21154.pci-bridge",
+ -1, -1, -1,
+ NULL, NULL,
+};
+
+static pci_dev_t uninorth_agp_fake_bridge = {
+ 0xFFFF, 0xFFFF,
+ "uni-north-agp", "uni-north-agp", NULL, "uni-north-agp",
+ -1, -1, -1,
+ NULL, NULL,
+};
+
+static pci_dev_t uninorth_fake_bridge = {
+ 0xFFFF, 0xFFFF,
+ "uni-north", "uni-north", NULL, "uni-north",
+ -1, -1, -1,
+ NULL, NULL,
+};
+
+
+static pci_dev_t hbrg_devices[] = {
+ {
+ 0x106B, 0x0020, NULL,
+ "pci", "AAPL,UniNorth", "uni-north",
+ 3, 2, 1,
+ NULL, &uninorth_agp_fake_bridge,
+ },
+ {
+ 0x106B, 0x001F, NULL,
+ "pci", "AAPL,UniNorth", "uni-north",
+ 3, 2, 1,
+ NULL, &uninorth_fake_bridge,
+ },
+ {
+ 0x106B, 0x001E, NULL,
+ "pci", "AAPL,UniNorth", "uni-north",
+ 3, 2, 1,
+ NULL, &uninorth_fake_bridge,
+ },
+ {
+ 0x1057, 0x0002, "pci",
+ "pci", "MOT,MPC106", "grackle",
+ 3, 2, 1,
+ NULL, &grackle_fake_bridge,
+ },
+ {
+ 0x1057, 0x4801, NULL,
+ "pci-bridge", "PREP Host PCI Bridge - Motorola Raven", NULL,
+ 3, 2, 1,
+ NULL, NULL,
+ },
+ {
+ 0xFFFF, 0xFFFF,
+ NULL, NULL, NULL, NULL,
+ -1, -1, -1,
+ NULL, NULL,
+ },
+};
+
+static pci_dev_t PCIbrg_devices[] = {
+ {
+ 0x1011, 0x0026, NULL,
+ "pci-bridge", NULL, NULL,
+ 3, 2, 1,
+ NULL, NULL,
+ },
+ {
+ 0xFFFF, 0xFFFF,
+ NULL, NULL, NULL, NULL,
+ -1, -1, -1,
+ NULL, NULL,
+ },
+};
+
+static pci_subclass_t bridg_subclass[] = {
+ {
+ 0x00, "PCI host bridge", NULL, hbrg_devices, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x01, "ISA bridge", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x02, "EISA bridge", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x03, "MCA bridge", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x04, "PCI-to-PCI bridge", NULL, PCIbrg_devices, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x05, "PCMCIA bridge", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x06, "NUBUS bridge", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x07, "cardbus bridge", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x08, "raceway bridge", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x09, "semi-transparent PCI-to-PCI bridge", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x0A, "infiniband-to-PCI bridge", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x80, "misc PCI bridge", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_iface_t serial_iface[] = {
+ {
+ 0x00, "XT serial controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x01, "16450 serial controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x02, "16550 serial controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x03, "16650 serial controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x04, "16750 serial controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x05, "16850 serial controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x06, "16950 serial controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL,
+ NULL, NULL, NULL,
+ },
+};
+
+static pci_iface_t par_iface[] = {
+ {
+ 0x00, "parallel port", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x01, "bi-directional parallel port", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x02, "ECP 1.x parallel port", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x03, "IEEE 1284 controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0xFE, "IEEE 1284 device", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL,
+ NULL, NULL, NULL,
+ },
+};
+
+static pci_iface_t modem_iface[] = {
+ {
+ 0x00, "generic modem", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x01, "Hayes 16450 modem", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x02, "Hayes 16550 modem", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x03, "Hayes 16650 modem", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x04, "Hayes 16750 modem", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL,
+ NULL, NULL, NULL,
+ },
+};
+
+static pci_subclass_t comm_subclass[] = {
+ {
+ 0x00, "serial controller", NULL, NULL, serial_iface,
+ NULL, NULL,
+ },
+ {
+ 0x01, "parallel port", NULL, NULL, par_iface,
+ NULL, NULL,
+ },
+ {
+ 0x02, "multiport serial controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x03, "modem", NULL, NULL, modem_iface,
+ NULL, NULL,
+ },
+ {
+ 0x04, "GPIB controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x05, "smart card", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x80, "misc communication device", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_iface_t pic_iface[] = {
+ {
+ 0x00, "8259 PIC", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x01, "ISA PIC", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x02, "EISA PIC", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x10, "I/O APIC", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x20, "I/O APIC", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL,
+ NULL, NULL, NULL,
+ },
+};
+
+static pci_iface_t dma_iface[] = {
+ {
+ 0x00, "8237 DMA controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x01, "ISA DMA controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x02, "EISA DMA controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL,
+ NULL, NULL, NULL,
+ },
+};
+
+static pci_iface_t tmr_iface[] = {
+ {
+ 0x00, "8254 system timer", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x01, "ISA system timer", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x02, "EISA system timer", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL,
+ NULL, NULL, NULL,
+ },
+};
+
+static pci_iface_t rtc_iface[] = {
+ {
+ 0x00, "generic RTC controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x01, "ISA RTC controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL,
+ NULL, NULL, NULL,
+ },
+};
+
+static const pci_dev_t sys_devices[] = {
+ /* IBM MPIC controller */
+ {
+ 0x1014, 0x0002,
+ "open-pic", "MPIC", NULL, "chrp,open-pic",
+ 0, 0, 2,
+ NULL, NULL,
+ },
+ /* IBM MPIC2 controller */
+ {
+ 0x1014, 0xFFFF,
+ "open-pic", "MPIC2", NULL, "chrp,open-pic",
+ 0, 0, 2,
+ NULL, NULL,
+ },
+ {
+ 0xFFFF, 0xFFFF,
+ NULL, NULL, NULL, NULL,
+ -1, -1, -1,
+ NULL, NULL,
+ },
+};
+
+static pci_subclass_t sys_subclass[] = {
+ {
+ 0x00, "PIC", NULL, NULL, pic_iface,
+ NULL, NULL,
+ },
+ {
+ 0x01, "DMA controller", NULL, NULL, dma_iface,
+ NULL, NULL,
+ },
+ {
+ 0x02, "system timer", NULL, NULL, tmr_iface,
+ NULL, NULL,
+ },
+ {
+ 0x03, "RTC controller", NULL, NULL, rtc_iface,
+ NULL, NULL,
+ },
+ {
+ 0x04, "PCI hotplug controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x80, "misc system peripheral", NULL, sys_devices, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_subclass_t inp_subclass[] = {
+ {
+ 0x00, "keyboard controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x01, "digitizer", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x02, "mouse controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x03, "scanner controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x04, "gameport controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x80, "misc input device", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_subclass_t dock_subclass[] = {
+ {
+ 0x00, "generic docking station", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x80, "misc docking station", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_subclass_t cpu_subclass[] = {
+ {
+ 0x00, "i386 processor", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x01, "i486 processor", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x02, "pentium processor", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x10, "alpha processor", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x20, "PowerPC processor", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x30, "MIPS processor", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x40, "co-processor", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_iface_t usb_iface[] = {
+ {
+ 0x00, "UHCI USB controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x10, "OHCI USB controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x20, "EHCI USB controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x80, "misc USB controller", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0xFE, "USB device", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL,
+ NULL, NULL, NULL,
+ },
+};
+
+static pci_iface_t ipmi_iface[] = {
+ {
+ 0x00, "IPMI SMIC interface", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x01, "IPMI keyboard interface", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0x02, "IPMI block transfer interface", NULL,
+ NULL, NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL,
+ NULL, NULL, NULL,
+ },
+};
+
+static pci_subclass_t ser_subclass[] = {
+ {
+ 0x00, "Firewire bus controller", "ieee1394", NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x01, "ACCESS bus controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x02, "SSA controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x03, "USB controller", "usb", NULL, usb_iface,
+ NULL, NULL,
+ },
+ {
+ 0x04, "fibre channel controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x05, "SMBus controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x06, "InfiniBand controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x07, "IPMI interface", NULL, NULL, ipmi_iface,
+ NULL, NULL,
+ },
+ {
+ 0x08, "SERCOS controller", NULL, NULL, ipmi_iface,
+ NULL, NULL,
+ },
+ {
+ 0x09, "CANbus controller", NULL, NULL, ipmi_iface,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_subclass_t wrl_subclass[] = {
+ {
+ 0x00, "IRDA controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x01, "consumer IR controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x10, "RF controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x11, "bluetooth controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x12, "broadband controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x80, "misc wireless controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_subclass_t sat_subclass[] = {
+ {
+ 0x01, "satellite TV controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x02, "satellite audio controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x03, "satellite voice controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x04, "satellite data controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_subclass_t crypt_subclass[] = {
+ {
+ 0x00, "cryptographic network controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x10, "cryptographic entertainment controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x80, "misc cryptographic controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static pci_subclass_t spc_subclass[] = {
+ {
+ 0x00, "DPIO module", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x01, "performances counters", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x10, "communication synchronisation", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x20, "management card", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0x80, "misc signal processing controller", NULL, NULL, NULL,
+ NULL, NULL,
+ },
+ {
+ 0xFF, NULL, NULL, NULL, NULL,
+ NULL, NULL,
+ },
+};
+
+static const pci_class_t pci_classes[] = {
+ /* 0x00 */
+ { "undefined", NULL, undef_subclass, },
+ /* 0x01 */
+ { "mass-storage controller", NULL, mass_subclass, },
+ /* 0x02 */
+ { "network controller", "network", net_subclass, },
+ /* 0x03 */
+ { "display controller", "display", displ_subclass, },
+ /* 0x04 */
+ { "multimedia device", NULL, media_subclass, },
+ /* 0x05 */
+ { "memory controller", "memory-controller", mem_subclass, },
+ /* 0x06 */
+ { "PCI bridge", "pci", bridg_subclass, },
+ /* 0x07 */
+ { "communication device", NULL, comm_subclass,},
+ /* 0x08 */
+ { "system peripheral", NULL, sys_subclass, },
+ /* 0x09 */
+ { "input device", NULL, inp_subclass, },
+ /* 0x0A */
+ { "docking station", NULL, dock_subclass, },
+ /* 0x0B */
+ { "processor", NULL, cpu_subclass, },
+ /* 0x0C */
+ { "serial bus controller", NULL, ser_subclass, },
+ /* 0x0D */
+ { "wireless controller", NULL, wrl_subclass, },
+ /* 0x0E */
+ { "intelligent I/O controller", NULL, NULL, },
+ /* 0x0F */
+ { "satellite communication controller", NULL, sat_subclass, },
+ /* 0x10 */
+ { "cryptographic controller", NULL, crypt_subclass, },
+ /* 0x11 */
+ { "signal processing controller", NULL, spc_subclass, },
+};
+
+phandle_t pic_handle;
+static int macio_config_cb (pci_config_t *config)
+{
+ char buf[64];
+ phandle_t ph;
+ int props[2];
+
+ sprintf(buf, "%s/interrupt-controller", config->path);
+ REGISTER_NAMED_NODE(ob_pci_node, buf);
+
+ ph = find_dev(buf);
+ set_property(ph, "device_type", "interrupt-controller", 21);
+ set_property(ph, "compatible", "heathrow\0mac-risc", 18);
+ set_int_property(ph, "#interrupt-cells", 1);
+ props[0]= 0x10;
+ props[1]= 0x20;
+ set_property(ph, "reg", &props, sizeof(props));
+ pic_handle = ph;
+
+ cuda_init(config->path, config->regions[0]);
+ macio_nvram_init(config->path, config->regions[0]);
+#if 0
+ ide_init(config->path,
+ config->regions[0] + 0x1f000,
+ config->regions[0] + 0x1f000 + 0x1000,
+ config->regions[0] + 0x1f000 + 0x2000,
+ config->regions[0] + 0x1f000 + 0x3000);
+#endif
+#if 0
+ OF_finalize_pci_macio(device->common.OF_private,
+ device->regions[0] & ~0x0000000F, device->sizes[0],
+ private_data);
+#endif
+ return 0;
+}
+
+static const pci_dev_t misc_pci[] = {
+ /* Paddington Mac I/O */
+ {
+ 0x106B, 0x0017,
+ "mac-io", "mac-io", "AAPL,343S1211", "paddington\1heathrow",
+ 1, 1, 1,
+ &macio_config_cb, NULL,
+ },
+ /* KeyLargo Mac I/O */
+ {
+ 0x106B, 0x0022,
+ "mac-io", "mac-io", "AAPL,Keylargo", "Keylargo",
+ 1, 1, 2,
+ &macio_config_cb, NULL,
+ },
+ {
+ 0xFFFF, 0xFFFF,
+ NULL, NULL, NULL, NULL,
+ -1, -1, -1,
+ NULL, NULL,
+ },
+};
+
+static pci_dev_t *pci_find_device (uint8_t class, uint8_t subclass,
+ uint8_t iface, uint16_t vendor,
+ uint16_t product)
+{
+ int (*config_cb)(pci_config_t *config);
+ const pci_class_t *pclass;
+ const pci_subclass_t *psubclass;
+ const pci_iface_t *piface;
+ const pci_dev_t *dev;
+ const void *private;
+ pci_dev_t *new;
+ const char *name, *type;
+
+ name = "unknown";
+ type = "unknown";
+ config_cb = NULL;
+ private = NULL;
+
+ if (class == 0x00 && subclass == 0x01) {
+ /* Special hack for old style VGA devices */
+ class = 0x03;
+ subclass = 0x00;
+ } else if (class == 0xFF) {
+ /* Special case for misc devices */
+ dev = misc_pci;
+ goto find_device;
+ }
+ if (class > (sizeof(pci_classes) / sizeof(pci_class_t))) {
+ name = "invalid PCI device";
+ type = "invalid";
+ goto bad_device;
+ }
+ pclass = &pci_classes[class];
+ name = pclass->name;
+ type = pclass->type;
+ for (psubclass = pclass->subc; ; psubclass++) {
+ if (psubclass->subclass == 0xFF)
+ goto bad_device;
+ if (psubclass->subclass == subclass) {
+ if (psubclass->name != NULL)
+ name = psubclass->name;
+ if (psubclass->type != NULL)
+ type = psubclass->type;
+ if (psubclass->config_cb != NULL) {
+ config_cb = psubclass->config_cb;
+ }
+ if (psubclass->private != NULL)
+ private = psubclass->private;
+ if (psubclass->iface != NULL)
+ break;
+ dev = psubclass->devices;
+ goto find_device;
+ }
+ }
+ for (piface = psubclass->iface; ; piface++) {
+ if (piface->iface == 0xFF) {
+ dev = psubclass->devices;
+ break;
+ }
+ if (piface->iface == iface) {
+ if (piface->name != NULL)
+ name = piface->name;
+ if (piface->type != NULL)
+ type = piface->type;
+ if (piface->config_cb != NULL) {
+ config_cb = piface->config_cb;
+ }
+ if (piface->private != NULL)
+ private = piface->private;
+ dev = piface->devices;
+ break;
+ }
+ }
+ find_device:
+ for (;; dev++) {
+ if (dev->vendor == 0xFFFF && dev->product == 0xFFFF) {
+ goto bad_device;
+ }
+ if (dev->vendor == vendor && dev->product == product) {
+ if (dev->name != NULL)
+ name = dev->name;
+ if (dev->type != NULL)
+ type = dev->type;
+ if (dev->config_cb != NULL) {
+ config_cb = dev->config_cb;
+ }
+ if (dev->private != NULL)
+ private = dev->private;
+ new = malloc(sizeof(pci_dev_t));
+ if (new == NULL)
+ return NULL;
+ new->vendor = vendor;
+ new->product = product;
+ new->type = type;
+ new->name = name;
+ new->model = dev->model;
+ new->compat = dev->compat;
+ new->config_cb = config_cb;
+ new->private = private;
+
+ return new;
+ }
+ }
+ bad_device:
+ printk("Cannot manage '%s' PCI device type '%s':\n %x %x (%x %x %x)\n",
+ name, type, vendor, product, class, subclass, iface);
+
+ return NULL;
+}
+
+#define set_bool_property(ph, name) set_property(ph, name, NULL, 0);
+
+
+static int ob_pci_add_properties(pci_addr addr, pci_dev_t *pci_dev,
+ pci_config_t *config)
+{
phandle_t dev=get_cur_dev();
int status,id;
+ uint16_t vendor_id, device_id;
+ uint8_t rev;
+ vendor_id = pci_config_read16(addr, PCI_VENDOR_ID);
+ device_id = pci_config_read16(addr, PCI_DEVICE_ID);
+ rev = pci_config_read8(addr, PCI_REVISION_ID);
+
/* create properties as described in 2.5 */
- set_int_property(dev, "vendor-id", pci_config_read16(addr, PCI_VENDOR_ID));
- set_int_property(dev, "device-id", pci_config_read16(addr, PCI_DEVICE_ID));
- set_int_property(dev, "revision-id", pci_config_read8(addr, PCI_REVISION_ID));
+ printk("%s\n", pci_dev->name);
+ set_int_property(dev, "vendor-id", vendor_id);
+ set_int_property(dev, "device-id", device_id);
+ set_int_property(dev, "revision-id", rev);
set_int_property(dev, "interrupts",
pci_config_read8(addr, PCI_INTERRUPT_LINE));
@@ -70,7 +1284,7 @@
set_int_property(dev, "min-grant", pci_config_read8(addr, PCI_MIN_GNT));
set_int_property(dev, "max-latency", pci_config_read8(addr, PCI_MAX_LAT));
- status=pci_config_read16(addr, PCI_STATUS);
+ status = pci_config_read16(addr, PCI_STATUS);
set_int_property(dev, "devsel-speed",
(status&PCI_STATUS_DEVSEL_MASK)>>10);
@@ -82,24 +1296,41 @@
if(status&PCI_STATUS_UDF)
set_bool_property(dev, "udf-supported");
- id=pci_config_read16(addr, PCI_SUBSYSTEM_VENDOR_ID);
- if(id)
+ id = pci_config_read16(addr, PCI_SUBSYSTEM_VENDOR_ID);
+ if (id)
set_int_property(dev, "subsystem-vendor-id", id);
- id=pci_config_read16(addr, PCI_SUBSYSTEM_ID);
- if(id)
+ id = pci_config_read16(addr, PCI_SUBSYSTEM_ID);
+ if (id)
set_int_property(dev, "subsystem-id", id);
set_int_property(dev, "cache-line-size",
pci_config_read16(addr, PCI_CACHE_LINE_SIZE));
+ if (pci_dev->type) {
+ push_str(pci_dev->type);
+ fword("encode-string");
+ push_str("device_type");
+ fword("property");
+ }
+ if (pci_dev->model) {
+ push_str(pci_dev->model);
+ fword("encode-string");
+ push_str("model");
+ fword("property");
+ }
+ push_str(pci_dev->name);
+ fword("encode-string");
+ push_str("class");
+ fword("property");
+ if (pci_dev->config_cb)
+ pci_dev->config_cb(config);
}
-
static int ob_pci_add_reg(pci_addr addr)
{
PUSH(0);
PUSH(0);
- PUSH(addr&(~0x80000000u));
+ PUSH(addr&(~arch->cfg_base));
fword("pci-addr-encode");
PUSH(0);
PUSH(0);
@@ -109,118 +1340,6 @@
fword("property");
}
-static int ob_pci_add_class(pci_addr addr)
-{
- unsigned int class;
- char *strc;
-
- class=pci_config_read16(addr, PCI_CLASS_DEVICE);
- switch (class) {
- case 0x001: strc="display"; break;
- case 0x100: strc="scsi"; break;
- case 0x101: strc="ide"; break;
- case 0x102: strc="fdc"; break;
- case 0x103: strc="ipi"; break;
- case 0x104: strc="raid"; break;
- case 0x200: strc="ethernet"; break;
- case 0x201: strc="token-ring"; break;
- case 0x202: strc="fddi"; break;
- case 0x203: strc="atm"; break;
- case 0x400: strc="video"; break;
- case 0x401: strc="sound"; break;
- case 0x500: strc="memory"; break;
- case 0x501: strc="flash"; break;
- case 0x600: strc="host"; break;
- case 0x601: strc="isa"; break;
- case 0x602: strc="eisa"; break;
- case 0x603: strc="mca"; break;
- case 0x604: strc="pci"; break;
- case 0x605: strc="pcmcia"; break;
- case 0x606: strc="nubus"; break;
- case 0x607: strc="cardbus"; break;
- case 0x680: strc="pmu"; break; /* not in pci binding */
- case 0x700: strc="serial"; break;
- case 0x701: strc="parallel"; break;
- case 0x703: strc="modem"; break; /* not in pci binding */
- case 0x800: strc="interrupt-controller"; break;
- case 0x801: strc="dma-controller"; break;
- case 0x802: strc="timer"; break;
- case 0x803: strc="rtc"; break;
- case 0x900: strc="keyboard"; break;
- case 0x901: strc="pen"; break;
- case 0x902: strc="mouse"; break;
- case 0xC00: strc="firewire"; break;
- case 0xC01: strc="access-bus"; break;
- case 0xC02: strc="ssa"; break;
- case 0xC03: strc="usb"; break;
- case 0xC04: strc="fibre-channel"; break;
- default:
- switch (class>>8) {
- case 0x3: strc="display"; break;
- case 0xA: strc="dock"; break;
- case 0xB: strc="cpu"; break;
- default:strc="unknown"; break;
- }
- }
- if ((class>>8) == 0x03) {
- push_str(strc);
- fword("encode-string");
- push_str("device_type");
- fword("property");
- }
- push_str(strc);
- fword("encode-string");
- push_str("class");
- fword("property");
-
-
-#ifdef CONFIG_DEBUG_PCI
- printk("%s\n", strc);
-#endif
-}
-
-static void
-pci_enable_rom(pci_addr dev)
-{
- u32 rom_addr;
-
- rom_addr=pci_config_read32(dev, PCI_ROM_ADDRESS);
- rom_addr |= PCI_ROM_ADDRESS_ENABLE;
- pci_config_write32(dev, PCI_ROM_ADDRESS, rom_addr);
-}
-
-static void
-pci_disable_rom(pci_addr dev)
-{
- u32 rom_addr;
-
- rom_addr=pci_config_read32(dev, PCI_ROM_ADDRESS);
- rom_addr &= ~PCI_ROM_ADDRESS_ENABLE;
- pci_config_write32(dev, PCI_ROM_ADDRESS, rom_addr);
-}
-
-
-static void ob_pci_scan_rom(pci_addr addr)
-{
- unsigned long rom_addr=pci_config_read32(addr,PCI_ROM_ADDRESS);
- unsigned char *walk;
-
- rom_addr &= PCI_ROM_ADDRESS_MASK;
- if(rom_addr) {
- printk(" ROM found at 0x%lx\n",rom_addr);
- pci_enable_rom(addr);
- walk=phys_to_virt((unsigned char *)rom_addr);
- if (walk[0]!=0x55 || walk[1]!=0xaa) {
- printk("no pci rom\n");
- goto rom_err;
- }
-
-rom_err:
- pci_disable_rom(addr);
- }
-
-}
-
#ifdef CONFIG_XBOX
static char pci_xbox_blacklisted (int bus, int devnum, int fn)
{
@@ -260,14 +1379,92 @@
}
#endif
-static void ob_scan_pci_bus(int bus, char *path)
+static void
+ob_pci_configure(pci_arch_t *addr, pci_dev_t *pci_dev, pci_config_t *config,
+ uint32_t *mem_base, uint32_t *io_base)
+
{
+ uint32_t smask, omask, amask, size, reloc, min_align;
+ uint32_t *base;
+ pci_addr config_addr;
+ int reg;
+
+ omask = 0x00000000;
+ for (reg = 0; reg < 7; reg++) {
+
+ config->regions[reg] = 0x00000000;
+ config->sizes[reg] = 0x00000000;
+
+ if ((omask & 0x0000000f) == 0x4) {
+ /* 64 bits memory mapping */
+ continue;
+ }
+
+ if (reg == 6)
+ config_addr = PCI_ROM_ADDRESS;
+ else
+ config_addr = PCI_BASE_ADDR_0 + reg * 4;
+
+ /* get region size */
+
+ pci_config_write32(addr, config_addr, 0xffffffff);
+ smask = pci_config_read32(addr, config_addr);
+ if (smask == 0x00000000 || smask == 0xffffffff)
+ continue;
+
+ if (smask & 0x00000001 && reg != 6) {
+ /* I/O space */
+ base = *io_base;
+ min_align = 1 << 7;
+ amask = 0x00000001;
+ pci_config_write16(addr, PCI_COMMAND,
+ pci_config_read16(addr,
+ PCI_COMMAND) |
+ PCI_COMMAND_IO);
+ } else {
+ /* Memory Space */
+ base = *mem_base;
+ min_align = 1 << 16;
+ amask = 0x0000000F;
+ if (reg == 6) {
+ smask |= 1; /* ROM */
+ }
+ pci_config_write16(addr, PCI_COMMAND,
+ pci_config_read16(addr,
+ PCI_COMMAND) |
+ PCI_COMMAND_MEMORY);
+ }
+ omask = smask & amask;
+ smask &= ~amask;
+ size = (~smask) + 1;
+ config->sizes[reg] = size;
+ reloc = base;
+ if (size < min_align)
+ size = min_align;
+ reloc = (reloc + size -1) & ~(size - 1);
+ if (*io_base == base) {
+ *io_base = reloc + size;
+ reloc -= arch->io_base;
+ } else {
+ *mem_base = reloc + size;
+ }
+ pci_config_write32(addr, config_addr, reloc | omask);
+ config->regions[reg] = reloc;
+printk("region %08x size %08x\n", config->regions[reg], config->sizes[reg]);
+ }
+}
+
+static void ob_scan_pci_bus(pci_arch_t *arch, int bus, uint32_t *mem_base, uint32_t *io_base, char *path)
+{
int devnum, fn, is_multi, vid, did;
unsigned int htype;
pci_addr addr;
char * nodetemp = "%s/pci%x,%x";
- char nodebuff[32];
phandle_t dnode, dbus;
+ pci_config_t config;
+ pci_dev_t *pci_dev;
+ uint32_t ccode;
+ uint8_t class, subclass, iface, rev;
for (devnum = 0; devnum < 32; devnum++) {
is_multi = 0;
@@ -276,13 +1473,21 @@
if (pci_xbox_blacklisted (bus, devnum, fn))
continue;
#endif
-
addr = PCI_ADDR(bus, devnum, fn);
vid = pci_config_read16(addr, PCI_VENDOR_ID);
did = pci_config_read16(addr, PCI_DEVICE_ID);
if (vid==0xffff || vid==0)
continue;
+
+ ccode = pci_config_read16(addr, PCI_CLASS_DEVICE);
+ class = ccode >> 8;
+ subclass = ccode;
+ iface = pci_config_read8(addr, PCI_CLASS_PROG);
+ rev = pci_config_read8(addr, PCI_REVISION_ID);
+
+ pci_dev = pci_find_device(class, subclass, iface, vid, did);
+
#ifdef CONFIG_DEBUG_PCI
printk("%x:%x.%x - %x:%x - ", bus, devnum, fn,
vid, did);
@@ -294,35 +1499,55 @@
activate_device(path);
dbus=get_cur_dev();
- sprintf(nodebuff, nodetemp, path, vid, did);
+ if (pci_dev == NULL || pci_dev->name == NULL)
+ sprintf(config.path, nodetemp, path, vid, did);
+ else
+ sprintf(config.path, "%s/%s", path, pci_dev->name);
#ifdef CONFIG_DEBUG_PCI
- printk("%s - ", nodebuff);
+ printk("%s - ", config.path);
#endif
- REGISTER_NAMED_NODE(ob_pci_node, nodebuff);
- dnode=find_dev(nodebuff);
+ REGISTER_NAMED_NODE(ob_pci_node, config.path);
+ dnode=find_dev(config.path);
activate_dev( dnode );
-
- ob_pci_add_properties(addr);
+ ob_pci_configure(addr, pci_dev, &config,
+ mem_base, io_base);
+{
+ int irq_pin, irq_line;
+ static uint8_t heathrow_pci_irqs[4] = { 0x15, 0x16, 0x17, 0x18 };
+ irq_pin = pci_config_read8(addr, PCI_INTERRUPT_PIN);
+ if (irq_pin > 0) {
+ irq_pin = (devnum + irq_pin - 1) & 3;
+ irq_line = heathrow_pci_irqs[irq_pin];
+ }
+}
+ ob_pci_add_properties(addr, pci_dev, &config);
ob_pci_add_reg(addr);
- ob_pci_add_class(addr);
- ob_pci_scan_rom(addr);
device_end();
- activate_dev( dbus );
+
}
}
}
-
int ob_pci_init(void)
{
- char *path="/pci";
- int bus;
+ pci_bridge_t *pci_bridge;
+ pci_dev_t *pci_dev;
+ int bus, devfn;
+ phandle_t aliases;
+ phandle_t ph;
+ char buf[64];
+ uint32_t mem_base, io_base;
printk("Initializing PCI devices...\n");
-
+
/* brute force bus scan */
- for (bus=0; bus<0x100; bus++) {
- ob_scan_pci_bus(bus, path);
+
+ /* Find all PCI bridges */
+
+ mem_base = arch->mem_base;
+ io_base = arch->io_base;
+ for (bus = 0; bus<0x100; bus++) {
+ ob_scan_pci_bus(arch, bus, &mem_base, &io_base, "/pci");
}
return 0;
}
Modified: openbios-devel/drivers/pci.h
===================================================================
--- openbios-devel/drivers/pci.h 2008-11-24 12:23:01 UTC (rev 256)
+++ openbios-devel/drivers/pci.h 2008-11-24 12:29:36 UTC (rev 257)
@@ -4,6 +4,10 @@
#define PCI_VENDOR_ID 0x00
#define PCI_DEVICE_ID 0x02
+#define PCI_COMMAND 0x04
+#define PCI_COMMAND_IO 0x01
+#define PCI_COMMAND_MEMORY 0x02
+
#define PCI_STATUS 0x06 /* 16 bits */
#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */
#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */
@@ -46,6 +50,7 @@
#define PCI_ROM_ADDRESS_MASK (~0x7ffUL)
#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */
+#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */
#define PCI_MIN_GNT 0x3e /* 8 bits */
#define PCI_MAX_LAT 0x3f /* 8 bits */
Modified: openbios-devel/include/ppc/pci.h
===================================================================
--- openbios-devel/include/ppc/pci.h 2008-11-24 12:23:01 UTC (rev 256)
+++ openbios-devel/include/ppc/pci.h 2008-11-24 12:29:36 UTC (rev 257)
@@ -3,15 +3,6 @@
#include "asm/io.h"
-/* Sandpoint example */
-#define ISA_IO_BASE 0x80000000
-#define ISA_MEM_BASE 0xc0000000
-#define PCIC0_CFGADDR 0xfec00cf8
-#define PCIC0_CFGDATA 0xfee00cfc
-#ifndef _IO_BASE
-#define _IO_BASE ISA_IO_BASE
-#endif
-
#if !(PCI_CONFIG_1 || PCI_CONFIG_2)
#define PCI_CONFIG_1 1 /* default */
#endif
@@ -20,10 +11,10 @@
/* PCI Configuration Mechanism #1 */
-/* Have pci_addr in the same format as the values written to PCIC0_CFGADDR
- * so register accesses can be made easy. */
+extern pci_arch_t *arch;
+
#define PCI_ADDR(bus, dev, fn) \
- ((pci_addr) (0x80000000u \
+ ((pci_addr) (arch->cfg_base \
| (uint32_t) (bus) << 16 \
| (uint32_t) (dev) << 11 \
| (uint32_t) (fn) << 8))
@@ -34,49 +25,45 @@
static inline uint8_t pci_config_read8(pci_addr dev, uint8_t reg)
{
- uint8_t res;
-
- out_le32((unsigned *)PCIC0_CFGADDR, (dev | (reg & ~3)));
- res = in_8((unsigned char *)PCIC0_CFGDATA + (reg & 3));
- return res;
+ uint8_t res;
+ out_le32((unsigned *)arch->cfg_addr, dev | (reg & ~3));
+ res = in_8((unsigned char*)(arch->cfg_data + (reg & 3)));
+ return res;
}
static inline uint16_t pci_config_read16(pci_addr dev, uint8_t reg)
{
uint16_t res;
-
- out_le32((unsigned *)PCIC0_CFGADDR, (dev | (reg & ~3)));
- res = in_le16((unsigned char *)PCIC0_CFGDATA + (reg & 2));
- return res;
+ out_le32((unsigned *)arch->cfg_addr, dev | (reg & ~3));
+ res = in_le16((unsigned short*)(arch->cfg_data + (reg & 2)));
+ return res;
}
static inline uint32_t pci_config_read32(pci_addr dev, uint8_t reg)
{
uint32_t res;
-
- out_le32((unsigned *)PCIC0_CFGADDR, (dev | (reg & ~3)));
- res = in_le32((unsigned char *)PCIC0_CFGDATA);
- return res;
+ out_le32((unsigned *)arch->cfg_addr, dev | reg);
+ res = in_le32((unsigned *)(arch->cfg_data + reg));
+ return res;
}
static inline void pci_config_write8(pci_addr dev, uint8_t reg, uint8_t val)
{
- outl(dev | (reg & ~3), 0xcf8);
- outb(val, 0xcfc | (reg & 3));
+ out_le32((unsigned *)arch->cfg_addr, dev | (reg & ~3));
+ out_8((unsigned char*)(arch->cfg_data + (reg & 3)), val);
}
static inline void pci_config_write16(pci_addr dev, uint8_t reg, uint16_t val)
{
- outl(dev | (reg & ~3), 0xcf8);
- outw(val, 0xcfc | (reg & 2));
+ out_le32((unsigned *)arch->cfg_addr, dev | (reg & ~3));
+ out_le16((unsigned short *)(arch->cfg_data + (reg & 2)), val);
}
static inline void pci_config_write32(pci_addr dev, uint8_t reg, uint32_t val)
{
- outl(dev | reg, 0xcf8);
- outl(val, 0xcfc);
+ out_le32((unsigned *)arch->cfg_addr, dev | reg);
+ out_le32((unsigned *)(arch->cfg_data + reg), val);
}
-
#else /* !PCI_CONFIG_1 */
#error PCI Configuration Mechanism is not specified or implemented
#endif
1
0
Author: stepan
Date: 2008-11-24 13:23:01 +0100 (Mon, 24 Nov 2008)
New Revision: 256
Modified:
openbios-devel/arch/ppc/qemu/console.c
openbios-devel/arch/ppc/qemu/init.c
openbios-devel/arch/ppc/qemu/qemu.c
Log:
Copy serial support from arch/amd64/console.c
Signed-off-by: Laurent Vivier <Laurent(a)lvivier.info>
Acked-by: Stefan Reinauer <stepan(a)coresystems.de>
Modified: openbios-devel/arch/ppc/qemu/console.c
===================================================================
--- openbios-devel/arch/ppc/qemu/console.c 2008-11-24 12:21:36 UTC (rev 255)
+++ openbios-devel/arch/ppc/qemu/console.c 2008-11-24 12:23:01 UTC (rev 256)
@@ -1,4 +1,3 @@
-
/*
* <console.c>
*
@@ -13,12 +12,119 @@
*/
#include "openbios/config.h"
+#include "openbios/kernel.h"
#include "openbios/bindings.h"
#include "libc/diskio.h"
#include "ofmem.h"
#include "qemu/qemu.h"
+#ifdef CONFIG_DEBUG_CONSOLE
+/* ******************************************************************
+ * serial console functions
+ * ****************************************************************** */
+
+#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
+
+#define UART(port) (port==2?0x2f8:0x3f8)
+
+#define RBR(port) (UART(port) + 0)
+#define THR(port) (UART(port) + 0)
+#define IER(port) (UART(port) + 1)
+#define IIR(port) (UART(port) + 2)
+#define LCR(port) (UART(port) + 3)
+#define MCR(port) (UART(port) + 4)
+#define LSR(port) (UART(port) + 5)
+#define MSR(port) (UART(port) + 6)
+#define SCR(port) (UART(port) + 7)
+#define DLL(port) (UART(port) + 0)
+#define DLM(port) (UART(port) + 1)
+
+static int uart_charav(int port)
+{
+ if (!port)
+ return -1;
+ return ((inb(LSR(port)) & 1) != 0);
+}
+
+static char uart_getchar(int port)
+{
+ if (!port)
+ return -1;
+ while (!uart_charav(port));
+ return ((char) inb(RBR(port)) & 0177);
+}
+
+static void uart_putchar(int port, unsigned char c)
+{
+ if (!port)
+ return -1;
+ while (!(inb(LSR(port)) & 0x20));
+ outb(c, THR(port));
+}
+
+static void serial_putchar(int c)
+{
+ if (c == '\n')
+ uart_putchar(CONFIG_SERIAL_PORT, '\r');
+ uart_putchar(CONFIG_SERIAL_PORT, c);
+}
+
+static void uart_init_line(int port, unsigned long baud)
+{
+ int i, baudconst;
+
+ switch (baud) {
+ case 115200:
+ baudconst = 1;
+ break;
+ case 57600:
+ baudconst = 2;
+ break;
+ case 38400:
+ baudconst = 3;
+ break;
+ case 19200:
+ baudconst = 6;
+ break;
+ case 9600:
+ default:
+ baudconst = 12;
+ break;
+ }
+
+ outb(0x87, LCR(port));
+ outb(0x00, DLM(port));
+ outb(baudconst, DLL(port));
+ outb(0x07, LCR(port));
+ outb(0x0f, MCR(port));
+
+ for (i = 10; i > 0; i--) {
+ if (inb(LSR(port)) == (unsigned int) 0)
+ break;
+ inb(RBR(port));
+ }
+}
+
+int
+serial_init(void)
+{
+ if (CONFIG_SERIAL_PORT)
+ uart_init_line(CONFIG_SERIAL_PORT, CONFIG_SERIAL_SPEED);
+ return -1;
+}
+
+static void serial_cls(void)
+{
+ serial_putchar(27);
+ serial_putchar('[');
+ serial_putchar('H');
+ serial_putchar(27);
+ serial_putchar('[');
+ serial_putchar('J');
+}
+#endif // CONFIG_DEBUG_CONSOLE_SERIAL
+
typedef struct osi_fb_info {
unsigned long mphys;
int rb, w, h, depth;
@@ -43,5 +149,40 @@
#include "../../../modules/console.c"
+/* ******************************************************************
+ * common functions, implementing simple concurrent console
+ * ****************************************************************** */
+int putchar(int c)
+{
+#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
+ serial_putchar(c);
+#endif
+ return c;
+}
+int availchar(void)
+{
+#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
+ if (uart_charav(CONFIG_SERIAL_PORT))
+ return 1;
+#endif
+ return 0;
+}
+
+int getchar(void)
+{
+#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
+ if (uart_charav(CONFIG_SERIAL_PORT))
+ return (uart_getchar(CONFIG_SERIAL_PORT));
+#endif
+ return 0;
+}
+
+void cls(void)
+{
+#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
+ serial_cls();
+#endif
+}
+#endif // CONFIG_DEBUG_CONSOLE
Modified: openbios-devel/arch/ppc/qemu/init.c
===================================================================
--- openbios-devel/arch/ppc/qemu/init.c 2008-11-24 12:21:36 UTC (rev 255)
+++ openbios-devel/arch/ppc/qemu/init.c 2008-11-24 12:23:01 UTC (rev 256)
@@ -70,6 +70,11 @@
{
arch = &known_arch[ARCH_HEATHROW];
isa_io_base = arch->io_base;
+#ifdef CONFIG_DEBUG_CONSOLE
+#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
+ serial_init();
+#endif
+#endif
printk("\n");
printk("=============================================================\n");
printk("OpenBIOS %s [%s]\n", OPENBIOS_RELEASE, OPENBIOS_BUILD_DATE );
Modified: openbios-devel/arch/ppc/qemu/qemu.c
===================================================================
--- openbios-devel/arch/ppc/qemu/qemu.c 2008-11-24 12:21:36 UTC (rev 255)
+++ openbios-devel/arch/ppc/qemu/qemu.c 2008-11-24 12:23:01 UTC (rev 256)
@@ -19,24 +19,23 @@
#include "openbios/config.h"
#include "openbios/kernel.h"
#include "openbios/nvram.h"
+#include "openbios/bindings.h"
#include "libc/vsprintf.h"
#include "libc/string.h"
#include "libc/byteorder.h"
#include "qemu/qemu.h"
#include <stdarg.h>
-#define UART_BASE 0x3f8
-
// FIXME
unsigned long virt_offset = 0;
//#define DUMP_NVRAM
void
-exit( int status )
+exit( int status __attribute__ ((unused)))
{
for (;;);
-}
+} __attribute__ ((noreturn))
void
fatal_error( const char *err )
@@ -50,10 +49,6 @@
{
printk("Panic: %s\n", err );
exit(0);
-
- /* won't come here... this keeps the gcc happy */
- for( ;; )
- ;
}
@@ -92,62 +87,6 @@
/* TTY iface */
/************************************************************************/
-static int ttychar = -1;
-
-static int
-tty_avail( void )
-{
- return 1;
-}
-
-static int
-tty_putchar( int c )
-{
- if( tty_avail() ) {
- while (!(inb(UART_BASE + 0x05) & 0x20))
- ;
- outb(c, UART_BASE);
- while (!(inb(UART_BASE + 0x05) & 0x40))
- ;
- }
- return c;
-}
-
-int
-availchar( void )
-{
- if( !tty_avail() )
- return 0;
-
- if( ttychar < 0 )
- ttychar = inb(UART_BASE);
- return (ttychar >= 0);
-}
-
-int
-getchar( void )
-{
- int ch;
-
- if( !tty_avail() )
- return 0;
-
- if( ttychar < 0 )
- return inb(UART_BASE);
- ch = ttychar;
- ttychar = -1;
- return ch;
-}
-
-int
-putchar( int c )
-{
- if (c == '\n')
- tty_putchar('\r');
- return tty_putchar(c);
-}
-
-
/************************************************************************/
/* briQ specific stuff */
/************************************************************************/
1
0

Nov. 24, 2008
Author: stepan
Date: 2008-11-24 13:21:36 +0100 (Mon, 24 Nov 2008)
New Revision: 255
Modified:
openbios-devel/arch/ppc/qemu/init.c
openbios-devel/arch/ppc/qemu/qemu.c
openbios-devel/include/openbios/nvram.h
openbios-devel/modules/nvram.c
Log:
Access to nvram must left shifted by 4.
Initialize device tree (used by PCI patch, to follow).
Signed-off-by: Laurent Vivier <Laurent(a)lvivier.info>
Acked-by: Stefan Reinauer <stepan(a)coresystems.de>
Modified: openbios-devel/arch/ppc/qemu/init.c
===================================================================
--- openbios-devel/arch/ppc/qemu/init.c 2008-11-24 12:19:05 UTC (rev 254)
+++ openbios-devel/arch/ppc/qemu/init.c 2008-11-24 12:21:36 UTC (rev 255)
@@ -100,13 +100,12 @@
int autoboot;
devtree_init();
- nvram_init();
modules_init();
+ setup_timers();
#ifdef CONFIG_DRIVER_PCI
ob_pci_init();
#endif
#ifdef CONFIG_DRIVER_IDE
- setup_timers();
ob_ide_init();
#endif
#ifdef CONFIG_DRIVER_ADB
Modified: openbios-devel/arch/ppc/qemu/qemu.c
===================================================================
--- openbios-devel/arch/ppc/qemu/qemu.c 2008-11-24 12:19:05 UTC (rev 254)
+++ openbios-devel/arch/ppc/qemu/qemu.c 2008-11-24 12:21:36 UTC (rev 255)
@@ -21,6 +21,7 @@
#include "openbios/nvram.h"
#include "libc/vsprintf.h"
#include "libc/string.h"
+#include "libc/byteorder.h"
#include "qemu/qemu.h"
#include <stdarg.h>
@@ -29,6 +30,7 @@
// FIXME
unsigned long virt_offset = 0;
+//#define DUMP_NVRAM
void
exit( int status )
@@ -150,57 +152,84 @@
/* briQ specific stuff */
/************************************************************************/
-#define IO_NVRAM_PA_START 0x80860000
-#define IO_NVRAM_PA_END 0x80880000
+#define IO_NVRAM_SIZE 0x00020000
+#define IO_NVRAM_OFFSET 0x00060000
-static char *nvram=(char *)IO_NVRAM_PA_START;
+static char *nvram;
+void macio_nvram_init(char *path, uint32_t addr)
+{
+ phandle_t chosen, aliases;
+ phandle_t dnode;
+ int props[2];
+ char buf[64];
+
+ nvram = (char*)addr + IO_NVRAM_OFFSET;
+ sprintf(buf, "%s/nvram", path);
+ nvram_init(buf);
+ dnode = find_dev(buf);
+ set_int_property(dnode, "#bytes", IO_NVRAM_SIZE >> 4);
+ set_property(dnode, "compatible", "nvram,flash", 12);
+ props[0] = __cpu_to_be32(IO_NVRAM_OFFSET);
+ props[1] = __cpu_to_be32(IO_NVRAM_SIZE);
+ set_property(dnode, "reg", &props, sizeof(props));
+ set_property(dnode, "device_type", "nvram", 6);
+
+ chosen = find_dev("/chosen");
+ set_int_property(chosen, "nvram", dnode);
+
+ aliases = find_dev("/aliases");
+ set_property(aliases, "nvram", buf, strlen(buf) + 1);
+}
+
+#ifdef DUMP_NVRAM
void
dump_nvram(void)
{
- static char hexdigit[] = "0123456789abcdef";
- int i;
- for (i = 0; i < 16*4; i++)
+ int i, j;
+ for (i = 0; i < 10; i++)
{
- printk ("%c", hexdigit[nvram[i<<4] >> 4]);
- printk ("%c", hexdigit[nvram[i<<4] % 16]);
- if (!((i + 1) % 16))
- {
- printk ("\n");
- }
- else
- {
- printk (" ");
- }
- }
+ for (j = 0; j < 16; j++)
+ printk ("%02x ", nvram[(i*16+j)<<4]);
+ printk (" ");
+ for (j = 0; j < 16; j++)
+ if (isprint(nvram[(i*16+j)<<4]))
+ printk("%c", nvram[(i*16+j)<<4]);
+ else
+ printk(".");
+ printk ("\n");
+ }
}
+#endif
int
arch_nvram_size( void )
{
- return (IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4;
+ return IO_NVRAM_SIZE>>4;
}
void
arch_nvram_put( char *buf )
{
int i;
- for (i=0; i<(IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4; i++)
+ for (i=0; i<IO_NVRAM_SIZE>>4; i++)
nvram[i<<4]=buf[i];
- // memcpy(nvram, buf, IO_NVRAM_PA_END-IO_NVRAM_PA_START);
+#ifdef DUMP_NVRAM
printk("new nvram:\n");
dump_nvram();
+#endif
}
void
arch_nvram_get( char *buf )
{
int i;
- for (i=0; i<(IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4; i++)
+ for (i=0; i<IO_NVRAM_SIZE>>4; i++)
buf[i]=nvram[i<<4];
- //memcpy(buf, nvram, IO_NVRAM_PA_END-IO_NVRAM_PA_START);
+#ifdef DUMP_NVRAM
printk("current nvram:\n");
dump_nvram();
+#endif
}
Modified: openbios-devel/include/openbios/nvram.h
===================================================================
--- openbios-devel/include/openbios/nvram.h 2008-11-24 12:19:05 UTC (rev 254)
+++ openbios-devel/include/openbios/nvram.h 2008-11-24 12:21:36 UTC (rev 255)
@@ -21,7 +21,7 @@
extern void arch_nvram_get( char *buf );
extern void arch_nvram_put( char *buf );
-extern void nvram_init( void );
+extern void nvram_init( char *path );
extern void update_nvram( void );
#endif /* _H_NVRAM */
Modified: openbios-devel/modules/nvram.c
===================================================================
--- openbios-devel/modules/nvram.c 2008-11-24 12:19:05 UTC (rev 254)
+++ openbios-devel/modules/nvram.c 2008-11-24 12:21:36 UTC (rev 255)
@@ -18,6 +18,13 @@
#include "openbios/bindings.h"
#include "openbios/nvram.h"
+#ifdef CONFIG_DEBUG_NVRAM
+#define DPRINTF(fmt, args...) \
+do { printk("NVRAM: " fmt , ##args); } while (0)
+#else
+#define DPRINTF(fmt, args...) do {} while(0)
+#endif
+
#define DEF_SYSTEM_SIZE 0xc10
#define NV_SIG_SYSTEM 0x70
@@ -77,10 +84,12 @@
return 1;
}
- if( !(len=nvpart_size(*p)) ) {
+ len=nvpart_size(*p);
+ if( len == 0) {
printk("invalid nvram partition length\n");
return -1;
}
+
*p = (nvpart_t*)((char*)*p + len);
if( *p < end )
return 1;
@@ -219,7 +228,7 @@
uint mark_lo;
} nvram_ibuf_t;
-DECLARE_NODE( nvram, INSTALL_OPEN, sizeof(nvram_ibuf_t), "Tnvram" );
+DECLARE_UNNAMED_NODE( nvram, INSTALL_OPEN, sizeof(nvram_ibuf_t ));
/* ( pos_lo pos_hi -- status ) */
static void
@@ -228,7 +237,7 @@
int pos_hi = POP();
int pos_lo = POP();
- /* printk("NVRAM: seek %08x %08x\n", pos_hi, pos_lo ); */
+ DPRINTF("seek %08x %08x\n", pos_hi, pos_lo );
nd->mark_lo = pos_lo;
nd->mark_hi = pos_hi;
@@ -254,7 +263,7 @@
n++;
}
PUSH(n);
- /* printk("NVRAM: read %08x %x -- %x\n", (int)p, len, n); */
+ DPRINTF("read %08x %x -- %x\n", (int)p, len, n);
}
/* ( addr len -- actual ) */
@@ -270,13 +279,14 @@
n++;
}
PUSH(n);
- /* printk("NVRAM: write %08x %x -- %x\n", (int)p, len, n ); */
+ DPRINTF("write %08x %x -- %x\n", (int)p, len, n );
}
/* ( -- size ) */
static void
nvram_size( __attribute__((unused)) nvram_ibuf_t *nd )
{
+ DPRINTF("nvram_size %d\n", nvram.size);
PUSH( nvram.size );
}
@@ -289,9 +299,9 @@
void
-nvram_init( void )
+nvram_init( char *path )
{
nvconf_init();
- REGISTER_NODE( nvram );
+ REGISTER_NAMED_NODE( nvram, path );
}
1
0

r254 - in openbios-devel: arch/ppc/briq arch/ppc/mol arch/ppc/pearpc arch/ppc/qemu include/openbios include/ppc kernel
by svn@openbios.org Nov. 24, 2008
by svn@openbios.org Nov. 24, 2008
Nov. 24, 2008
Author: stepan
Date: 2008-11-24 13:19:05 +0100 (Mon, 24 Nov 2008)
New Revision: 254
Added:
openbios-devel/include/openbios/pci.h
Modified:
openbios-devel/arch/ppc/briq/init.c
openbios-devel/arch/ppc/mol/init.c
openbios-devel/arch/ppc/pearpc/init.c
openbios-devel/arch/ppc/qemu/init.c
openbios-devel/include/ppc/io.h
openbios-devel/kernel/forth.c
Log:
Define the ISA io base according machine type.
Signed-off-by: Laurent Vivier <Laurent(a)lvivier.info>
Acked-by: Stefan Reinauer <stepan(a)coresystems.de>
Modified: openbios-devel/arch/ppc/briq/init.c
===================================================================
--- openbios-devel/arch/ppc/briq/init.c 2008-11-24 12:16:22 UTC (rev 253)
+++ openbios-devel/arch/ppc/briq/init.c 2008-11-24 12:19:05 UTC (rev 254)
@@ -53,9 +53,13 @@
;
}
+uint32_t isa_io_base;
+
void
entry( void )
{
+ isa_io_base = 0x80000000;
+
printk("\n");
printk("=============================================================\n");
printk("OpenBIOS %s [%s]\n", OPENBIOS_RELEASE, OPENBIOS_BUILD_DATE );
Modified: openbios-devel/arch/ppc/mol/init.c
===================================================================
--- openbios-devel/arch/ppc/mol/init.c 2008-11-24 12:16:22 UTC (rev 253)
+++ openbios-devel/arch/ppc/mol/init.c 2008-11-24 12:19:05 UTC (rev 254)
@@ -48,9 +48,13 @@
;
}
+uint32_t isa_io_base;
+
void
entry( void )
{
+ isa_io_base = 0x80000000;
+
printk("\n");
printk("=============================================================\n");
printk("OpenBIOS %s [%s]\n", OPENBIOS_RELEASE, OPENBIOS_BUILD_DATE );
Modified: openbios-devel/arch/ppc/pearpc/init.c
===================================================================
--- openbios-devel/arch/ppc/pearpc/init.c 2008-11-24 12:16:22 UTC (rev 253)
+++ openbios-devel/arch/ppc/pearpc/init.c 2008-11-24 12:19:05 UTC (rev 254)
@@ -56,9 +56,13 @@
;
}
+uint32_t isa_io_base;
+
void
entry( void )
{
+ isa_io_base = 0x80000000;
+
printk("\n");
printk("=============================================================\n");
printk("OpenBIOS %s [%s]\n", OPENBIOS_RELEASE, OPENBIOS_BUILD_DATE );
Modified: openbios-devel/arch/ppc/qemu/init.c
===================================================================
--- openbios-devel/arch/ppc/qemu/init.c 2008-11-24 12:16:22 UTC (rev 253)
+++ openbios-devel/arch/ppc/qemu/init.c 2008-11-24 12:19:05 UTC (rev 254)
@@ -22,6 +22,7 @@
#include "openbios/config.h"
#include "openbios/bindings.h"
+#include "openbios/pci.h"
#include "openbios/nvram.h"
#include "qemu/qemu.h"
#include "ofmem.h"
@@ -33,21 +34,6 @@
extern void ob_adb_init( void );
extern void setup_timers( void );
-#if 0
-int
-get_bool_res( const char *res )
-{
- char buf[8], *p;
-
- p = BootHGetStrRes( res, buf, sizeof(buf) );
- if( !p )
- return -1;
- if( !strcasecmp(p,"true") || !strcasecmp(p,"yes") || !strcasecmp(p,"1") )
- return 1;
- return 0;
-}
-#endif
-
void
unexpected_excep( int vector )
{
@@ -56,9 +42,34 @@
;
}
+enum {
+ ARCH_PREP = 0,
+ ARCH_MAC99,
+ ARCH_HEATHROW,
+};
+
+pci_arch_t known_arch[] = {
+ [ARCH_PREP] = { "PREP", 0x1057, 0x4801, 0x80800000, 0x800c0000,
+ 0x80000000, 0x00100000, 0xf0000000, 0x10000000,
+ 0x80000000, 0x00010000, 0x00000000, 0x00400000,
+ },
+ [ARCH_MAC99] = { "MAC99", 0x106b, 0x001F, 0xf2800000, 0xf2c00000,
+ 0xf2000000, 0x02000000, 0x80000000, 0x10000000,
+ 0xf2000000, 0x00800000, 0x00000000, 0x01000000,
+ },
+ [ARCH_HEATHROW] = { "HEATHROW", 0x1057, 0x0002, 0xfec00000, 0xfee00000,
+ 0x80000000, 0x7f000000, 0x80000000, 0x01000000,
+ 0xfe000000, 0x00800000, 0xfd000000, 0x01000000,
+ },
+};
+pci_arch_t *arch;
+uint32_t isa_io_base;
+
void
entry( void )
{
+ arch = &known_arch[ARCH_HEATHROW];
+ isa_io_base = arch->io_base;
printk("\n");
printk("=============================================================\n");
printk("OpenBIOS %s [%s]\n", OPENBIOS_RELEASE, OPENBIOS_BUILD_DATE );
@@ -115,10 +126,9 @@
set_property( ph, "rtas-size", (char*)&size, sizeof(size) );
}
#endif
-
#if 0
/* tweak boot settings */
- autoboot = !!get_bool_res("autoboot");
+ autoboot = !!getbool("autoboot?");
#endif
autoboot = 0;
if( !autoboot )
@@ -127,7 +137,7 @@
setenv("boot-command", "qemuboot");
#if 0
- if( get_bool_res("tty-interface") == 1 )
+ if( getbool("tty-interface?") == 1 )
#endif
fword("activate-tty-interface");
Added: openbios-devel/include/openbios/pci.h
===================================================================
--- openbios-devel/include/openbios/pci.h (rev 0)
+++ openbios-devel/include/openbios/pci.h 2008-11-24 12:19:05 UTC (rev 254)
@@ -0,0 +1,22 @@
+#ifndef _H_PCI
+#define _H_PCI
+
+typedef struct pci_arch_t pci_arch_t;
+
+struct pci_arch_t {
+ char * name;
+ uint16_t vendor_id;
+ uint16_t device_id;
+ uint32_t cfg_addr;
+ uint32_t cfg_data;
+ uint32_t cfg_base;
+ uint32_t cfg_len;
+ uint32_t mem_base;
+ uint32_t mem_len;
+ uint32_t io_base;
+ uint32_t io_len;
+ uint32_t rbase;
+ uint32_t rlen;
+};
+
+#endif /* _H_PCI */
Modified: openbios-devel/include/ppc/io.h
===================================================================
--- openbios-devel/include/ppc/io.h 2008-11-24 12:16:22 UTC (rev 253)
+++ openbios-devel/include/ppc/io.h 2008-11-24 12:19:05 UTC (rev 254)
@@ -10,9 +10,7 @@
#ifndef BOOTSTRAP
-#ifndef _IO_BASE
-#define _IO_BASE 0x80000000
-#endif
+extern uint32_t isa_io_base;
/*
* The insw/outsw/insl/outsl macros don't do byte-swapping.
@@ -20,15 +18,15 @@
* are arrays of bytes, and byte-swapping is not appropriate in
* that case. - paulus
*/
-#define insw(port, buf, ns) _insw_ns((uint16_t *)((port)+_IO_BASE), (buf), (ns))
-#define outsw(port, buf, ns) _outsw_ns((uint16_t *)((port)+_IO_BASE), (buf), (ns))
+#define insw(port, buf, ns) _insw((uint16_t *)((port)+isa_io_base), (buf), (ns))
+#define outsw(port, buf, ns) _outsw((uint16_t *)((port)+isa_io_base), (buf), (ns))
-#define inb(port) in_8((uint8_t *)((port)+_IO_BASE))
-#define outb(val, port) out_8((uint8_t *)((port)+_IO_BASE), (val))
-#define inw(port) in_le16((uint16_t *)((port)+_IO_BASE))
-#define outw(val, port) out_le16((uint16_t *)((port)+_IO_BASE), (val))
-#define inl(port) in_le32((uint32_t *)((port)+_IO_BASE))
-#define outl(val, port) out_le32((uint32_t *)((port)+_IO_BASE), (val))
+#define inb(port) in_8((uint8_t *)((port)+isa_io_base))
+#define outb(val, port) out_8((uint8_t *)((port)+isa_io_base), (val))
+#define inw(port) in_le16((uint16_t *)((port)+isa_io_base))
+#define outw(val, port) out_le16((uint16_t *)((port)+isa_io_base), (val))
+#define inl(port) in_le32((uint32_t *)((port)+isa_io_base))
+#define outl(val, port) out_le32((uint32_t *)((port)+isa_io_base), (val))
/*
* 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
Modified: openbios-devel/kernel/forth.c
===================================================================
--- openbios-devel/kernel/forth.c 2008-11-24 12:16:22 UTC (rev 253)
+++ openbios-devel/kernel/forth.c 2008-11-24 12:19:05 UTC (rev 254)
@@ -6,6 +6,7 @@
* the copyright and warranty status of this work.
*/
+extern uint32_t isa_io_base;
/*
* dup ( x -- x x )
1
0

r253 - in openbios-devel: . arch/ppc arch/ppc/qemu config/examples
by svn@openbios.org Nov. 24, 2008
by svn@openbios.org Nov. 24, 2008
Nov. 24, 2008
Author: stepan
Date: 2008-11-24 13:16:22 +0100 (Mon, 24 Nov 2008)
New Revision: 253
Added:
openbios-devel/arch/ppc/qemu/
openbios-devel/arch/ppc/qemu/console.c
openbios-devel/arch/ppc/qemu/init.c
openbios-devel/arch/ppc/qemu/kernel.c
openbios-devel/arch/ppc/qemu/main.c
openbios-devel/arch/ppc/qemu/methods.c
openbios-devel/arch/ppc/qemu/qemu.c
openbios-devel/arch/ppc/qemu/qemu.fs
openbios-devel/arch/ppc/qemu/qemu.h
openbios-devel/arch/ppc/qemu/tree.c
openbios-devel/arch/ppc/qemu/tree.fs
openbios-devel/arch/ppc/qemu/vfd.c
Modified:
openbios-devel/Makefile
openbios-devel/arch/ppc/build.xml
openbios-devel/config/examples/cross-ppc_config.xml
Log:
Create arch/ppc/qemu by copying arch/ppc/pearpc.
Signed-off-by: Laurent Vivier <Laurent(a)lvivier.info>
Acked-by: Stefan Reinauer <stepan(a)coresystems.de>
Modified: openbios-devel/Makefile
===================================================================
--- openbios-devel/Makefile 2008-11-24 12:15:08 UTC (rev 252)
+++ openbios-devel/Makefile 2008-11-24 12:16:22 UTC (rev 253)
@@ -41,6 +41,7 @@
@mkdir -p $(ODIR)/target/arch/ppc
@mkdir -p $(ODIR)/target/arch/ppc/briq # no autodetection of those..
@mkdir -p $(ODIR)/target/arch/ppc/pearpc
+ @mkdir -p $(ODIR)/target/arch/ppc/qemu
@mkdir -p $(ODIR)/target/arch/ppc/mol
@mkdir -p $(ODIR)/target/arch/x86
@mkdir -p $(ODIR)/target/arch/x86/xbox
Modified: openbios-devel/arch/ppc/build.xml
===================================================================
--- openbios-devel/arch/ppc/build.xml 2008-11-24 12:15:08 UTC (rev 252)
+++ openbios-devel/arch/ppc/build.xml 2008-11-24 12:16:22 UTC (rev 253)
@@ -13,6 +13,12 @@
<object source="pearpc/pearpc.fs"/>
</dictionary>
+ <dictionary name="openbios-qemu" init="openbios" target="forth" condition="QEMU">
+ <object source="ppc.fs"/>
+ <object source="qemu/tree.fs"/>
+ <object source="qemu/qemu.fs"/>
+ </dictionary>
+
<dictionary name="openbios-mol" init="openbios" target="forth" condition="MOL">
<object source="ppc.fs"/>
<object source="mol/tree.fs"/>
@@ -56,6 +62,23 @@
<external-object source="target/include/pearpc-dict.h"/>
</executable>
+ <executable name="target/include/qemu-dict.h" target="target" condition="QEMU">
+ <rule><![CDATA[
+ @echo "static const char forth_dictionary[] = {" > $@
+ @cat $< | hexdump -ve '1/0 "\t" 8/1 "0x%02x, " 1/0 "\n"' \
+ | sed 's/0x ,//g' >> $@
+ @echo "};" >> $@
+ ]]></rule>
+ <external-object source="openbios-qemu.dict"/>
+ </executable>
+
+ <executable name="target/arch/ppc/qemu/kernel.o" target="target" condition="QEMU">
+ <rule><![CDATA[
+ $(CC) $$EXTRACFLAGS $(CFLAGS) $(INCLUDES) -c -o $@ arch/ppc/qemu/kernel.c
+ ]]></rule>
+ <external-object source="target/include/qemu-dict.h"/>
+ </executable>
+
<executable name="target/include/mol-dict.h" target="target" condition="MOL">
<rule><![CDATA[
@@ -112,6 +135,24 @@
<object source="pearpc/console.c" flags="-Iarch/ppc"/>
</library>
+ <library name="qemu" target="target" type="static" condition="QEMU">
+ <object source="misc.S">
+ <rule><![CDATA[
+ $(CPP) -D__ASSEMBLY__ $(INCLUDES) $< | $(M4) -s $(M4_NO_GNU) | tr ';' '\n' > $@.s
+ $(AS) $@.s $(AS_FLAGS) -o $@
+ ]]></rule>
+ </object>
+ <object source="ofmem.c"/>
+ <object source="qemu/qemu.c" flags="-Iarch/ppc"/>
+ <object source="qemu/init.c" flags="-Iarch/ppc"/>
+ <external-object source="target/arch/ppc/qemu/kernel.o"/>
+ <object source="qemu/main.c" flags="-Iarch/ppc"/>
+ <object source="qemu/methods.c" flags="-Iarch/ppc"/>
+ <object source="qemu/tree.c" flags="-Iarch/ppc"/>
+ <object source="qemu/vfd.c" flags="-Iarch/ppc"/>
+ <object source="qemu/console.c" flags="-Iarch/ppc"/>
+ </library>
+
<library name="mol" target="target" type="static" condition="MOL">
<object source="misc.S">
@@ -188,6 +229,34 @@
<external-object source="liblibc.a"/>
<external-object source="libfs.a"/>
</executable>
+
+ <executable name="openbios-qemu.elf" target="target" condition="QEMU">
+ <rule>
+ $(LD) -g -Ttext=0x01e01000 -Bstatic $^ $(shell $(CC) -print-libgcc-file-name) -o $@
+ $(NM) $@ | sort > $(ODIR)/openbios-qemu.syms
+ cp $@ $@.nostrip
+ $(STRIP) $@
+ </rule>
+ <object source="start.S">
+ <rule><![CDATA[
+ $(CPP) -D__ASSEMBLY__ $(INCLUDES) $< | $(M4) -s $(M4_NO_GNU) | tr ';' '\n' > $@.s
+ $(AS) $@.s $(AS_FLAGS) -o $@
+ ]]></rule>
+ </object>
+ <object source="timebase.S">
+ <rule><![CDATA[
+ $(CPP) -D__ASSEMBLY__ $(INCLUDES) $< | $(M4) -s $(M4_NO_GNU) | tr ';' '\n' > $@.s
+ $(AS) $@.s $(AS_FLAGS) -o $@
+ ]]></rule>
+ </object>
+ <external-object source="libqemu.a"/>
+ <external-object source="libbootstrap.a"/>
+ <external-object source="libmodules.a"/>
+ <external-object source="libdrivers.a"/>
+ <external-object source="liblibc.a"/>
+ <external-object source="libfs.a"/>
+ </executable>
+
Added: openbios-devel/arch/ppc/qemu/console.c
===================================================================
--- openbios-devel/arch/ppc/qemu/console.c (rev 0)
+++ openbios-devel/arch/ppc/qemu/console.c 2008-11-24 12:16:22 UTC (rev 253)
@@ -0,0 +1,47 @@
+
+/*
+ * <console.c>
+ *
+ * Simple text console
+ *
+ * Copyright (C) 2005 Stefan Reinauer <stepan(a)openbios.org>
+ *
+ * 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
+ *
+ */
+
+#include "openbios/config.h"
+#include "openbios/bindings.h"
+#include "libc/diskio.h"
+#include "ofmem.h"
+#include "qemu/qemu.h"
+
+
+typedef struct osi_fb_info {
+ unsigned long mphys;
+ int rb, w, h, depth;
+} osi_fb_info_t;
+
+
+int Qemu_GetFBInfo( osi_fb_info_t *fb )
+{
+
+ fb->w=1024;
+ fb->h=768;
+ fb->depth=15;
+ fb->rb=2048;
+ fb->mphys=0x84000000;
+
+ return 0;
+}
+
+#define openbios_GetFBInfo(x) Qemu_GetFBInfo(x)
+
+#include "../../../modules/video.c"
+
+#include "../../../modules/console.c"
+
+
+
Added: openbios-devel/arch/ppc/qemu/init.c
===================================================================
--- openbios-devel/arch/ppc/qemu/init.c (rev 0)
+++ openbios-devel/arch/ppc/qemu/init.c 2008-11-24 12:16:22 UTC (rev 253)
@@ -0,0 +1,137 @@
+/*
+ * Creation Date: <2004/08/28 18:38:22 greg>
+ * Time-stamp: <2004/08/28 18:38:22 greg>
+ *
+ * <init.c>
+ *
+ * Initialization for qemu
+ *
+ * Copyright (C) 2004 Greg Watson
+ * Copyright (C) 2005 Stefan Reinauer
+ *
+ * based on mol/init.c:
+ *
+ * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Samuel & David Rydh
+ * (samuel(a)ibrium.se, dary(a)lindesign.se)
+ *
+ * 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
+ *
+ */
+
+#include "openbios/config.h"
+#include "openbios/bindings.h"
+#include "openbios/nvram.h"
+#include "qemu/qemu.h"
+#include "ofmem.h"
+#include "openbios-version.h"
+
+extern void unexpected_excep( int vector );
+extern void ob_ide_init( void );
+extern void ob_pci_init( void );
+extern void ob_adb_init( void );
+extern void setup_timers( void );
+
+#if 0
+int
+get_bool_res( const char *res )
+{
+ char buf[8], *p;
+
+ p = BootHGetStrRes( res, buf, sizeof(buf) );
+ if( !p )
+ return -1;
+ if( !strcasecmp(p,"true") || !strcasecmp(p,"yes") || !strcasecmp(p,"1") )
+ return 1;
+ return 0;
+}
+#endif
+
+void
+unexpected_excep( int vector )
+{
+ printk("openbios panic: Unexpected exception %x\n", vector );
+ for( ;; )
+ ;
+}
+
+void
+entry( void )
+{
+ printk("\n");
+ printk("=============================================================\n");
+ printk("OpenBIOS %s [%s]\n", OPENBIOS_RELEASE, OPENBIOS_BUILD_DATE );
+
+ ofmem_init();
+ initialize_forth();
+ /* won't return */
+
+ printk("of_startup returned!\n");
+ for( ;; )
+ ;
+}
+
+static void
+setenv( char *env, char *value )
+{
+ push_str( value );
+ push_str( env );
+ fword("$setenv");
+}
+
+void
+arch_of_init( void )
+{
+#if USE_RTAS
+ phandle_t ph;
+#endif
+ int autoboot;
+
+ devtree_init();
+ nvram_init();
+ modules_init();
+#ifdef CONFIG_DRIVER_PCI
+ ob_pci_init();
+#endif
+#ifdef CONFIG_DRIVER_IDE
+ setup_timers();
+ ob_ide_init();
+#endif
+#ifdef CONFIG_DRIVER_ADB
+ ob_adb_init();
+#endif
+
+ node_methods_init();
+ init_video();
+
+#if USE_RTAS
+ if( !(ph=find_dev("/rtas")) )
+ printk("Warning: No /rtas node\n");
+ else {
+ ulong size = 0x1000;
+ while( size < (ulong)of_rtas_end - (ulong)of_rtas_start )
+ size *= 2;
+ set_property( ph, "rtas-size", (char*)&size, sizeof(size) );
+ }
+#endif
+
+#if 0
+ /* tweak boot settings */
+ autoboot = !!get_bool_res("autoboot");
+#endif
+ autoboot = 0;
+ if( !autoboot )
+ printk("Autobooting disabled - dropping into OpenFirmware\n");
+ setenv("auto-boot?", autoboot ? "true" : "false" );
+ setenv("boot-command", "qemuboot");
+
+#if 0
+ if( get_bool_res("tty-interface") == 1 )
+#endif
+ fword("activate-tty-interface");
+
+ /* hack */
+ device_end();
+ bind_func("qemuboot", boot );
+}
Added: openbios-devel/arch/ppc/qemu/kernel.c
===================================================================
--- openbios-devel/arch/ppc/qemu/kernel.c (rev 0)
+++ openbios-devel/arch/ppc/qemu/kernel.c 2008-11-24 12:16:22 UTC (rev 253)
@@ -0,0 +1,17 @@
+/*
+ * Creation Date: <2004/08/28 18:03:25 stepan>
+ * Time-stamp: <2004/08/28 18:03:25 stepan>
+ *
+ * <qemu/kernel.c>
+ *
+ * Copyright (C) 2005 Stefan Reinauer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2
+ *
+ */
+
+#include "qemu-dict.h"
+#include "../kernel.c"
+
Added: openbios-devel/arch/ppc/qemu/main.c
===================================================================
--- openbios-devel/arch/ppc/qemu/main.c (rev 0)
+++ openbios-devel/arch/ppc/qemu/main.c 2008-11-24 12:16:22 UTC (rev 253)
@@ -0,0 +1,145 @@
+/*
+ * Creation Date: <2004/08/28 18:38:22 greg>
+ * Time-stamp: <2004/08/28 18:38:22 greg>
+ *
+ * <main.c>
+ *
+ * Copyright (C) 2004 Greg Watson
+ *
+ * Based on MOL specific code which is
+ * Copyright (C) 2002, 2003, 2004 Samuel Rydh (samuel(a)ibrium.se)
+ *
+ * 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
+ *
+ */
+
+
+#include "openbios/config.h"
+#include "openbios/bindings.h"
+#include "openbios/elfload.h"
+#include "openbios/nvram.h"
+#include "libc/diskio.h"
+#include "libc/vsprintf.h"
+#include "qemu/qemu.h"
+#include "ofmem.h"
+
+static void
+transfer_control_to_elf( ulong entry )
+{
+ extern void call_elf( ulong entry );
+ printk("Starting ELF image at 0x%08lX\n", entry);
+ call_elf( 0x400000 );
+ //call_elf( entry );
+
+ fatal_error("call_elf returned unexpectedly\n");
+}
+
+static int
+load_elf_rom( ulong *entry, int fd )
+{
+ int i, lszz_offs, elf_offs;
+ char buf[128], *addr;
+ Elf_ehdr ehdr;
+ Elf_phdr *phdr;
+ size_t s;
+
+ printk("Loading '%s'\n", get_file_path(fd));
+
+ /* the ELF-image (usually) starts at offset 0x4000 */
+ if( (elf_offs=find_elf(fd)) < 0 ) {
+ printk("----> %s is not an ELF image\n", buf );
+ exit(1);
+ }
+ if( !(phdr=elf_readhdrs(fd, elf_offs, &ehdr)) )
+ fatal_error("elf_readhdrs failed\n");
+
+ *entry = ehdr.e_entry;
+
+ /* load segments. Compressed ROM-image assumed to be located immediately
+ * after the last segment */
+ lszz_offs = elf_offs;
+ for( i=0; i<ehdr.e_phnum; i++ ) {
+ /* p_memsz, p_flags */
+ s = MIN( phdr[i].p_filesz, phdr[i].p_memsz );
+ seek_io( fd, elf_offs + phdr[i].p_offset );
+
+ /* printk("filesz: %08lX memsz: %08lX p_offset: %08lX p_vaddr %08lX\n",
+ phdr[i].p_filesz, phdr[i].p_memsz, phdr[i].p_offset,
+ phdr[i].p_vaddr ); */
+
+ if( phdr[i].p_vaddr != phdr[i].p_paddr )
+ printk("WARNING: ELF segment virtual addr != physical addr\n");
+ lszz_offs = MAX( lszz_offs, elf_offs + phdr[i].p_offset + phdr[i].p_filesz );
+ if( !s )
+ continue;
+ if( ofmem_claim( phdr[i].p_vaddr, phdr[i].p_memsz, 0 ) == -1 )
+ fatal_error("Claim failed!\n");
+
+ addr = (char*)phdr[i].p_vaddr;
+ if( read_io(fd, addr, s) != s )
+ fatal_error("read failed\n");
+
+#if 0
+ /* patch CODE segment */
+ if( *entry >= phdr[i].p_vaddr && *entry < phdr[i].p_vaddr + s ) {
+ patch_newworld_rom( (char*)phdr[i].p_vaddr, s );
+ newworld_timer_hack( (char*)phdr[i].p_vaddr, s );
+ }
+#endif
+ flush_icache_range( addr, addr+s );
+
+ /*printk("ELF ROM-section loaded at %08lX (size %08lX)\n",
+ (ulong)phdr[i].p_vaddr, (ulong)phdr[i].p_memsz );*/
+ }
+ free( phdr );
+ return lszz_offs;
+}
+
+
+static void
+encode_bootpath( const char *spec, const char *args )
+{
+ phandle_t chosen_ph = find_dev("/chosen");
+ set_property( chosen_ph, "bootpath", spec, strlen(spec)+1 );
+ set_property( chosen_ph, "bootargs", args, strlen(args)+1 );
+}
+
+/************************************************************************/
+/* qemu booting */
+/************************************************************************/
+
+static void
+qemu_startup( void )
+{
+ const char *paths[] = { "hd:0,\\zImage.chrp", NULL };
+ const char *args[] = { "root=/dev/hda2 console=ttyS0,115200", NULL };
+ ulong entry;
+ int i, fd;
+
+ for( i=0; paths[i]; i++ ) {
+ if( (fd=open_io(paths[i])) == -1 )
+ continue;
+ (void) load_elf_rom( &entry, fd );
+ close_io( fd );
+ encode_bootpath( paths[i], args[i] );
+
+ update_nvram();
+ transfer_control_to_elf( entry );
+ /* won't come here */
+ }
+ printk("*** Boot failure! No secondary bootloader specified ***\n");
+}
+
+
+/************************************************************************/
+/* entry */
+/************************************************************************/
+
+void
+boot( void )
+{
+ fword("update-chosen");
+ qemu_startup();
+}
Added: openbios-devel/arch/ppc/qemu/methods.c
===================================================================
--- openbios-devel/arch/ppc/qemu/methods.c (rev 0)
+++ openbios-devel/arch/ppc/qemu/methods.c 2008-11-24 12:16:22 UTC (rev 253)
@@ -0,0 +1,335 @@
+/*
+ * Creation Date: <2004/08/28 18:38:22 greg>
+ * Time-stamp: <2004/08/28 18:38:22 greg>
+ *
+ * <methods.c>
+ *
+ * Misc device node methods
+ *
+ * Copyright (C) 2004 Greg Watson
+ *
+ * Based on MOL specific code which is
+ *
+ * Copyright (C) 2003, 2004 Samuel Rydh (samuel(a)ibrium.se)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2
+ *
+ */
+
+#include "openbios/config.h"
+#include "openbios/bindings.h"
+#include "libc/string.h"
+#include "qemu/qemu.h"
+#include "ofmem.h"
+
+/************************************************************************/
+/* RTAS (run-time abstraction services) */
+/************************************************************************/
+
+#ifdef USE_RTAS
+DECLARE_NODE( rtas, INSTALL_OPEN, 0, "+/rtas" );
+
+/* ( physbase -- rtas_callback ) */
+static void
+rtas_instantiate( void )
+{
+ int physbase = POP();
+ int s=0x1000, size = (int)of_rtas_end - (int)of_rtas_start;
+ ulong virt;
+
+ while( s < size )
+ s += 0x1000;
+ virt = ofmem_claim_virt( 0, s, 0x1000 );
+ ofmem_map( physbase, virt, s, -1 );
+ memcpy( (char*)virt, of_rtas_start, size );
+
+ printk("RTAS instantiated at %08x\n", physbase );
+ flush_icache_range( (char*)virt, (char*)virt + size );
+
+ PUSH( physbase );
+}
+
+NODE_METHODS( rtas ) = {
+ { "instantiate", rtas_instantiate },
+ { "instantiate-rtas", rtas_instantiate },
+};
+#endif
+
+
+/************************************************************************/
+/* stdout */
+/************************************************************************/
+
+DECLARE_NODE( video_stdout, INSTALL_OPEN, 0, "Tdisplay" );
+
+/* ( addr len -- actual ) */
+static void
+stdout_write( void )
+{
+ int len = POP();
+ char *addr = (char*)POP();
+ char *s = malloc( len + 1 );
+
+ strncpy_nopad( s, addr, len );
+ s[len]=0;
+
+ printk( "%s", s );
+ //vfd_draw_str( s );
+ console_draw_str( s );
+
+ free( s );
+
+ PUSH( len );
+}
+
+NODE_METHODS( video_stdout ) = {
+ { "write", stdout_write },
+};
+
+
+/************************************************************************/
+/* tty */
+/************************************************************************/
+
+DECLARE_NODE( tty, INSTALL_OPEN, 0, "/packages/terminal-emulator" );
+
+/* ( addr len -- actual ) */
+static void
+tty_read( void )
+{
+ int ch, len = POP();
+ char *p = (char*)POP();
+ int ret=0;
+
+ if( len > 0 ) {
+ ret = 1;
+ ch = getchar();
+ if( ch >= 0 ) {
+ *p = ch;
+ } else {
+ ret = 0;
+ }
+ }
+ PUSH( ret );
+}
+
+/* ( addr len -- actual ) */
+static void
+tty_write( void )
+{
+ int i, len = POP();
+ char *p = (char*)POP();
+ for( i=0; i<len; i++ )
+ putchar( *p++ );
+ RET( len );
+}
+
+NODE_METHODS( tty ) = {
+ { "read", tty_read },
+ { "write", tty_write },
+};
+
+/************************************************************************/
+/* client interface 'quiesce' */
+/************************************************************************/
+
+DECLARE_NODE( ciface, 0, 0, "/packages/client-iface" );
+
+/* ( -- ) */
+static void
+ciface_quiesce( ulong args[], ulong ret[] )
+{
+#if 0
+ ulong msr;
+ /* This seems to be the correct thing to do - but I'm not sure */
+ asm volatile("mfmsr %0" : "=r" (msr) : );
+ msr &= ~(MSR_IR | MSR_DR);
+ asm volatile("mtmsr %0" :: "r" (msr) );
+#endif
+ printk("=============================================================\n\n");
+}
+
+/* ( -- ms ) */
+static void
+ciface_milliseconds( ulong args[], ulong ret[] )
+{
+ extern unsigned long get_timer_freq();
+ static ulong mticks=0, usecs=0;
+ ulong t;
+
+ asm volatile("mftb %0" : "=r" (t) : );
+ if( mticks )
+ usecs += get_timer_freq() / 1000000 * ( t-mticks );
+ mticks = t;
+
+ PUSH( usecs/1000 );
+}
+
+
+NODE_METHODS( ciface ) = {
+ { "quiesce", ciface_quiesce },
+ { "milliseconds", ciface_milliseconds },
+};
+
+
+/************************************************************************/
+/* MMU/memory methods */
+/************************************************************************/
+
+DECLARE_NODE( memory, INSTALL_OPEN, 0, "/memory" );
+DECLARE_NODE( mmu, INSTALL_OPEN, 0, "/cpu@0" );
+DECLARE_NODE( mmu_ciface, 0, 0, "/packages/client-iface" );
+
+
+/* ( phys size align --- base ) */
+static void
+mem_claim( void )
+{
+ int align = POP();
+ int size = POP();
+ int phys = POP();
+ int ret = ofmem_claim_phys( phys, size, align );
+
+ if( ret == -1 ) {
+ printk("MEM: claim failure\n");
+ throw( -13 );
+ return;
+ }
+ PUSH( ret );
+}
+
+/* ( phys size --- ) */
+static void
+mem_release( void )
+{
+ POP(); POP();
+}
+
+/* ( phys size align --- base ) */
+static void
+mmu_claim( void )
+{
+ int align = POP();
+ int size = POP();
+ int phys = POP();
+ int ret = ofmem_claim_virt( phys, size, align );
+
+ if( ret == -1 ) {
+ printk("MMU: CLAIM failure\n");
+ throw( -13 );
+ return;
+ }
+ PUSH( ret );
+}
+
+/* ( phys size --- ) */
+static void
+mmu_release( void )
+{
+ POP(); POP();
+}
+
+/* ( phys virt size mode -- [ret???] ) */
+static void
+mmu_map( void )
+{
+ int mode = POP();
+ int size = POP();
+ int virt = POP();
+ int phys = POP();
+ int ret;
+
+ /* printk("mmu_map: %x %x %x %x\n", phys, virt, size, mode ); */
+ ret = ofmem_map( phys, virt, size, mode );
+
+ if( ret ) {
+ printk("MMU: map failure\n");
+ throw( -13 );
+ return;
+ }
+}
+
+/* ( virt size -- ) */
+static void
+mmu_unmap( void )
+{
+ POP(); POP();
+}
+
+/* ( virt -- false | phys mode true ) */
+static void
+mmu_translate( void )
+{
+ ulong mode;
+ int virt = POP();
+ int phys = ofmem_translate( virt, &mode );
+
+ if( phys == -1 ) {
+ PUSH( 0 );
+ } else {
+ PUSH( phys );
+ PUSH( (int)mode );
+ PUSH( -1 );
+ }
+}
+
+/* ( virt size align -- baseaddr|-1 ) */
+static void
+ciface_claim( void )
+{
+ int align = POP();
+ int size = POP();
+ int virt = POP();
+ int ret = ofmem_claim( virt, size, align );
+
+ /* printk("ciface_claim: %08x %08x %x\n", virt, size, align ); */
+ PUSH( ret );
+}
+
+/* ( virt size -- ) */
+static void
+ciface_release( void )
+{
+ POP();
+ POP();
+}
+
+
+NODE_METHODS( memory ) = {
+ { "claim", mem_claim },
+ { "release", mem_release },
+};
+
+NODE_METHODS( mmu ) = {
+ { "claim", mmu_claim },
+ { "release", mmu_release },
+ { "map", mmu_map },
+ { "unmap", mmu_unmap },
+ { "translate", mmu_translate },
+};
+
+NODE_METHODS( mmu_ciface ) = {
+ { "claim", ciface_claim },
+ { "release", ciface_release },
+};
+
+
+/************************************************************************/
+/* init */
+/************************************************************************/
+
+void
+node_methods_init( void )
+{
+#ifdef USE_RTAS
+ REGISTER_NODE( rtas );
+#endif
+ REGISTER_NODE( video_stdout );
+ REGISTER_NODE( ciface );
+ REGISTER_NODE( memory );
+ REGISTER_NODE( mmu );
+ REGISTER_NODE( mmu_ciface );
+ REGISTER_NODE( tty );
+}
Added: openbios-devel/arch/ppc/qemu/qemu.c
===================================================================
--- openbios-devel/arch/ppc/qemu/qemu.c (rev 0)
+++ openbios-devel/arch/ppc/qemu/qemu.c 2008-11-24 12:16:22 UTC (rev 253)
@@ -0,0 +1,206 @@
+/*
+ * Creation Date: <2004/08/28 18:38:22 greg>
+ * Time-stamp: <2004/08/28 18:38:22 greg>
+ *
+ * <qemu.c>
+ *
+ * Copyright (C) 2004, Greg Watson
+ *
+ * derived from mol.c
+ *
+ * Copyright (C) 2003, 2004 Samuel Rydh (samuel(a)ibrium.se)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2
+ *
+ */
+
+#include "openbios/config.h"
+#include "openbios/kernel.h"
+#include "openbios/nvram.h"
+#include "libc/vsprintf.h"
+#include "libc/string.h"
+#include "qemu/qemu.h"
+#include <stdarg.h>
+
+#define UART_BASE 0x3f8
+
+// FIXME
+unsigned long virt_offset = 0;
+
+
+void
+exit( int status )
+{
+ for (;;);
+}
+
+void
+fatal_error( const char *err )
+{
+ printk("Fatal error: %s\n", err );
+ exit(0);
+}
+
+void
+panic( const char *err )
+{
+ printk("Panic: %s\n", err );
+ exit(0);
+
+ /* won't come here... this keeps the gcc happy */
+ for( ;; )
+ ;
+}
+
+
+/************************************************************************/
+/* print using OSI interface */
+/************************************************************************/
+
+static int do_indent;
+
+int
+printk( const char *fmt, ... )
+{
+ char *p, buf[1024]; /* XXX: no buffer overflow protection... */
+ va_list args;
+ int i;
+
+ va_start(args, fmt);
+ i=vsprintf(buf,fmt,args);
+ va_end(args);
+
+ for( p=buf; *p; p++ ) {
+ if( *p == '\n' )
+ do_indent = 0;
+ if( do_indent++ == 1 ) {
+ putchar( '>' );
+ putchar( '>' );
+ putchar( ' ' );
+ }
+ putchar( *p );
+ }
+ return i;
+}
+
+
+/************************************************************************/
+/* TTY iface */
+/************************************************************************/
+
+static int ttychar = -1;
+
+static int
+tty_avail( void )
+{
+ return 1;
+}
+
+static int
+tty_putchar( int c )
+{
+ if( tty_avail() ) {
+ while (!(inb(UART_BASE + 0x05) & 0x20))
+ ;
+ outb(c, UART_BASE);
+ while (!(inb(UART_BASE + 0x05) & 0x40))
+ ;
+ }
+ return c;
+}
+
+int
+availchar( void )
+{
+ if( !tty_avail() )
+ return 0;
+
+ if( ttychar < 0 )
+ ttychar = inb(UART_BASE);
+ return (ttychar >= 0);
+}
+
+int
+getchar( void )
+{
+ int ch;
+
+ if( !tty_avail() )
+ return 0;
+
+ if( ttychar < 0 )
+ return inb(UART_BASE);
+ ch = ttychar;
+ ttychar = -1;
+ return ch;
+}
+
+int
+putchar( int c )
+{
+ if (c == '\n')
+ tty_putchar('\r');
+ return tty_putchar(c);
+}
+
+
+/************************************************************************/
+/* briQ specific stuff */
+/************************************************************************/
+
+#define IO_NVRAM_PA_START 0x80860000
+#define IO_NVRAM_PA_END 0x80880000
+
+static char *nvram=(char *)IO_NVRAM_PA_START;
+
+void
+dump_nvram(void)
+{
+ static char hexdigit[] = "0123456789abcdef";
+ int i;
+ for (i = 0; i < 16*4; i++)
+ {
+ printk ("%c", hexdigit[nvram[i<<4] >> 4]);
+ printk ("%c", hexdigit[nvram[i<<4] % 16]);
+ if (!((i + 1) % 16))
+ {
+ printk ("\n");
+ }
+ else
+ {
+ printk (" ");
+ }
+ }
+}
+
+
+int
+arch_nvram_size( void )
+{
+ return (IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4;
+}
+
+void
+arch_nvram_put( char *buf )
+{
+ int i;
+ for (i=0; i<(IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4; i++)
+ nvram[i<<4]=buf[i];
+ // memcpy(nvram, buf, IO_NVRAM_PA_END-IO_NVRAM_PA_START);
+ printk("new nvram:\n");
+ dump_nvram();
+}
+
+void
+arch_nvram_get( char *buf )
+{
+ int i;
+ for (i=0; i<(IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4; i++)
+ buf[i]=nvram[i<<4];
+
+ //memcpy(buf, nvram, IO_NVRAM_PA_END-IO_NVRAM_PA_START);
+ printk("current nvram:\n");
+ dump_nvram();
+}
Added: openbios-devel/arch/ppc/qemu/qemu.fs
===================================================================
--- openbios-devel/arch/ppc/qemu/qemu.fs (rev 0)
+++ openbios-devel/arch/ppc/qemu/qemu.fs 2008-11-24 12:16:22 UTC (rev 253)
@@ -0,0 +1,116 @@
+\ qemu specific initialization code
+\
+\ Copyright (C) 2005 Stefan Reinauer
+\
+\ 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
+\
+
+
+\ -------------------------------------------------------------------------
+\ initialization
+\ -------------------------------------------------------------------------
+
+: make-openable ( path )
+ find-dev if
+ begin ?dup while
+ \ install trivial open and close methods
+ dup active-package! is-open
+ parent
+ repeat
+ then
+;
+
+: preopen ( chosen-str node-path )
+ 2dup make-openable
+
+ " /chosen" find-device
+ open-dev ?dup if
+ encode-int 2swap property
+ else
+ 2drop
+ then
+;
+
+\ preopen device nodes (and store the ihandles under /chosen)
+:noname
+ " rtc" " /pci/isa/rtc" preopen
+ " memory" " /memory" preopen
+ " mmu" " /cpu@0" preopen
+ \ " stdout" " /packages/terminal-emulator" preopen
+ " stdout" " /pci/pci6666,6666" preopen
+ " stdin" " /pci/via-cuda/adb" preopen
+
+; SYSTEM-initializer
+
+
+\ -------------------------------------------------------------------------
+\ device tree fixing
+\ -------------------------------------------------------------------------
+
+\ add decode-address methods
+: (make-decodable) ( phandle -- )
+
+ dup " #address-cells" rot get-package-property 0= if
+ decode-int nip nip
+ over " decode-unit" rot find-method if 2drop else
+ ( save phandle ncells )
+
+ over active-package!
+ case
+ 1 of ['] parse-hex " decode-unit" is-xt-func endof
+ 3 of
+ " bus-range" active-package get-package-property 0= if
+ decode-int nip nip
+ ['] encode-unit-pci " encode-unit" is-xt-func
+ " decode-unit" is-func-begin
+ ['] (lit) , ,
+ ['] decode-unit-pci-bus ,
+ is-func-end
+ then
+ endof
+ endcase
+ then
+ then
+ drop
+;
+
+: init-qemu-tree ( -- )
+ active-package
+
+ iterate-tree-begin
+ begin ?dup while
+
+ dup (make-decodable)
+
+ iterate-tree
+ repeat
+
+ active-package!
+;
+
+\ use the tty interface if available
+: activate-tty-interface
+ " /packages/terminal-emulator" find-dev if drop
+ " /pci/via-cuda/adb" " input-device" $setenv
+ " /pci/pci6666,6666" " output-device" $setenv
+ then
+;
+
+:noname
+ " keyboard" input
+; CONSOLE-IN-initializer
+
+
+\ -------------------------------------------------------------------------
+\ pre-booting
+\ -------------------------------------------------------------------------
+
+: update-chosen
+ " /chosen" find-device
+ stdin @ encode-int " stdin" property
+ stdout @ encode-int " stdout" property
+ " /pci/isa/interrupt-controller" find-dev if encode-int " interrupt-controller" property then
+ device-end
+;
Added: openbios-devel/arch/ppc/qemu/qemu.h
===================================================================
--- openbios-devel/arch/ppc/qemu/qemu.h (rev 0)
+++ openbios-devel/arch/ppc/qemu/qemu.h 2008-11-24 12:16:22 UTC (rev 253)
@@ -0,0 +1,26 @@
+/*
+ * Creation Date: <2004/08/28 17:50:12 stepan>
+ * Time-stamp: <2004/08/28 17:50:12 stepan>
+ *
+ * <qemu.h>
+ *
+ * Copyright (C) 2005 Stefan Reinauer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2
+ *
+ */
+
+#ifndef _H_QEMU
+#define _H_QEMU
+
+/* vfd.c */
+extern int vfd_draw_str( const char *str );
+extern void vfd_close( void );
+
+extern int console_draw_str( const char *str );
+
+#include "kernel.h"
+
+#endif /* _H_QEMU */
Added: openbios-devel/arch/ppc/qemu/tree.c
===================================================================
--- openbios-devel/arch/ppc/qemu/tree.c (rev 0)
+++ openbios-devel/arch/ppc/qemu/tree.c 2008-11-24 12:16:22 UTC (rev 253)
@@ -0,0 +1,23 @@
+/*
+ * Creation Date: <2004/08/28 18:38:22 greg>
+ * Time-stamp: <2004/08/28 18:38:22 greg>
+ *
+ * <tree.c>
+ *
+ * device tree setup
+ *
+ * Copyright (C) 2004 Greg Watson
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2
+ *
+ */
+
+#include "openbios/config.h"
+#include "openbios/bindings.h"
+
+void devtree_init( void )
+{
+ fword("init-qemu-tree");
+}
Added: openbios-devel/arch/ppc/qemu/tree.fs
===================================================================
--- openbios-devel/arch/ppc/qemu/tree.fs (rev 0)
+++ openbios-devel/arch/ppc/qemu/tree.fs 2008-11-24 12:16:22 UTC (rev 253)
@@ -0,0 +1,247 @@
+\ Qemu specific initialization code
+\
+\ Copyright (C) 2005 Stefan Reinauer
+\
+\ 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
+\
+
+\ -------------------------------------------------------------
+\ device-tree
+\ -------------------------------------------------------------
+
+" /" find-device
+
+" chrp" device-type
+" OpenSource,QEMU" model
+h# 80000000 encode-int " isa-io-base" property
+1 encode-int " #interrupt-cells" property
+1 encode-int " #size-cells" property
+
+new-device
+ " memory" device-name
+ " memory" device-type
+ 0 encode-int h# 1E00000 encode-int encode+
+ h# 2000000 encode-int encode+ h# 40000000 encode-int encode+
+ " available" property
+ 0 h# 40000000 reg
+ external
+ : open true ;
+ : close ;
+finish-device
+
+new-device
+ " cpu" device-name
+ " cpu" device-type
+ " " encode-string " translations" property
+ 0 encode-phys h# 8000000 encode-int encode+ " available" property
+ d# 32 encode-int " d-cache-block-size" property
+ 8 encode-int " d-cache-sets" property
+ d# 32768 encode-int " d-cache-size" property
+ d# 32 encode-int " i-cache-block-size" property
+ 8 encode-int " i-cache-sets" property
+ d# 32768 encode-int " i-cache-size" property
+ " " encode-string " cache-unified" property
+ 2 encode-int " i-tlb-sets" property
+ d# 128 encode-int " i-tlb-size" property
+ 2 encode-int " d-tlb-sets" property
+ d# 128 encode-int " d-tlb-size" property
+ " " encode-string " tlb-split" property
+ 2 encode-int " tlb-sets" property
+ d# 256 encode-int " tlb-size" property
+ " " encode-string " performance-monitor" property
+ " " encode-string " graphics" property
+ 4 encode-int " reservation-granule-size" property
+ d# 25000000 encode-int " timebase-frequency" property
+ d# 300000000 encode-int " clock-frequency" property
+ d# 66000000 encode-int " bus-frequency" property
+ h# 88201 encode-int " cpu-version" property
+ 0 encode-int " reg" property
+finish-device
+
+" /pci" find-device
+ h# 01000000 encode-int 0 encode-int encode+ 0 encode-int encode+
+ h# 80000000 encode-int encode+ 0 encode-int encode+
+ h# 01000000 encode-int encode+
+ h# 02000000 encode-int encode+ 0 encode-int encode+ 0 encode-int encode+
+ h# C0000000 encode-int encode+ 0 encode-int encode+
+ h# 08000000 encode-int encode+
+ " ranges" property
+ " IBM,CPC710" model
+ h# FF5F7700 encode-int " 8259-interrupt-acknowledge" property
+ h# 0000F800 encode-int 0 encode-int encode+ 0 encode-int encode+
+ 7 encode-int encode+
+ " interrupt-map-mask" property
+ 1 encode-int " #interrupt-cells" property
+ h# 80000000 encode-int " system-dma-base" property
+ d# 33333333 encode-int " clock-frequency" property
+ " " encode-string " primary-bridge" property
+ 0 encode-int " pci-bridge-number" property
+ h# FEC00000 encode-int h# 100000 encode-int encode+ " reg" property
+ 0 encode-int 0 encode-int encode+ " bus-range" property
+
+new-device
+ " ide" device-name
+ " ide" device-type
+ " WINBOND,82C553" model
+ h# 28 encode-int " max-latency" property
+ h# 2 encode-int " min-grant" property
+ h# 1 encode-int " devsel-speed" property
+ h# 0 encode-int " subsystem-vendor-id" property
+ h# 0 encode-int " subsystem-id" property
+ h# 1018A encode-int " class-code" property
+ h# 5 encode-int " revision-id" property
+ h# 105 encode-int " device-id" property
+ h# 10AD encode-int " vendor-id" property
+ h# 1003110 encode-int 0 encode-int encode+ h# 10020 encode-int encode+
+ h# 10 encode-int encode+ 0 encode-int encode+
+ h# 1003114 encode-int 0 encode-int encode+ h# 10030 encode-int encode+
+ h# 4 encode-int encode+ 0 encode-int encode+
+ h# 1003118 encode-int 0 encode-int encode+ h# 10040 encode-int encode+
+ h# 10 encode-int encode+ 0 encode-int encode+
+ h# 100311C encode-int 0 encode-int encode+ h# 10034 encode-int encode+
+ h# 4 encode-int encode+ 0 encode-int encode+
+ h# 1003120 encode-int 0 encode-int encode+ h# 10050 encode-int encode+
+ h# 10 encode-int encode+ 0 encode-int encode+
+ h# 1003124 encode-int 0 encode-int encode+ h# 10060 encode-int encode+
+ h# 10 encode-int encode+ 0 encode-int encode+
+ " assigned-addresses" property
+ h# 3100 encode-int 0 encode-int encode+ 0 encode-int encode+
+ 0 encode-int encode+ 0 encode-int encode+
+ h# 1003110 encode-int 0 encode-int encode+ h# 0 encode-int encode+
+ h# 10 encode-int encode+ 0 encode-int encode+
+ h# 1003114 encode-int 0 encode-int encode+ h# 0 encode-int encode+
+ h# 4 encode-int encode+ 0 encode-int encode+
+ h# 1003118 encode-int 0 encode-int encode+ h# 0 encode-int encode+
+ h# 10 encode-int encode+ 0 encode-int encode+
+ h# 100311C encode-int 0 encode-int encode+ h# 0 encode-int encode+
+ h# 4 encode-int encode+ 0 encode-int encode+
+ h# 1003120 encode-int 0 encode-int encode+ h# 0 encode-int encode+
+ h# 10 encode-int encode+ 0 encode-int encode+
+ h# 1003124 encode-int 0 encode-int encode+ h# 0 encode-int encode+
+ h# 10 encode-int encode+ 0 encode-int encode+
+ " reg" property
+finish-device
+
+new-device
+ " ethernet" device-name
+ " network" device-type
+ " AMD,79C973" model
+ h# 3800 encode-int 0 encode-int encode+ 0 encode-int encode+
+ 0 encode-int encode+ 0 encode-int encode+
+ " reg" property
+finish-device
+
+" /pci/isa" find-device
+ 0 0 " assigned-addresses" property
+ 0 0 " ranges" property
+ 0 encode-int " slot-names" property
+ d# 8333333 encode-int " clock-frequency" property
+ 0 encode-int " eisa-slots" property
+ 2 encode-int " #interrupt-cells" property
+ " W83C553F" encode-string " compatible" property
+ " WINBOND,82C553" model
+ 0 encode-int " max-latency" property
+ 0 encode-int " min-grant" property
+ 1 encode-int " devsel-speed" property
+ 0 encode-int " subsystem-vendor-id" property
+ 0 encode-int " subsystem-id" property
+ h# 60100 encode-int " class-code" property
+ h# 10 encode-int " revision-id" property
+ h# 565 encode-int " device-id" property
+ h# 10AD encode-int " vendor-id" property
+ h# 3000 encode-int 0 encode-int encode+ 0 encode-int encode+
+ 0 encode-int encode+ 0 encode-int encode+ " reg" property
+
+new-device
+ " rtc" device-name
+ " rtc" device-type
+ " DS17285S" model
+ " MC146818" encode-string
+ " DS17285S" encode-string encode+
+ " pnpPNP,b00" encode-string encode+ " compatible" property
+ 8 encode-int 0 encode-int encode+ " interrupts" property
+ h# 70 encode-int 1 encode-int encode+
+ 2 encode-int encode+ " reg" property
+finish-device
+
+new-device
+ " interrupt-controller" device-name
+ " interrupt-controller" device-type
+ " 8259" model
+ " " encode-string " interrupt-controller" property
+ 2 encode-int " #interrupt-cells" property
+ 1 encode-int
+ 2 encode-int encode+
+ 3 encode-int encode+
+ 6 encode-int encode+
+ " reserved-interrupts" property
+ " 8259" encode-string
+ " chrp,iic" encode-string encode+
+ " compatible" property
+ h# 20 encode-int 1 encode-int encode+
+ 2 encode-int encode+ " reg" property
+finish-device
+
+new-device
+ " serial" device-name
+ " serial" device-type
+ " no" encode-string " ctsrts" property
+ " no" encode-string " xon" property
+ " no" encode-string " parity" property
+ d# 115200 encode-int " bps" property
+ 1 encode-int " stop-bits" property
+ 8 encode-int " data-bits" property
+ h# 70800 encode-int " divisor" property
+ h# 708000 encode-int " clock-frequency" property
+ 4 encode-int 0 encode-int encode+ " interrupts" property
+ h# 3F8 encode-int 1 encode-int encode+
+ 8 encode-int encode+ " reg" property
+finish-device
+
+" /pci" find-device
+ " /pci/isa/interrupt-controller" find-dev if
+ encode-int " interrupt-parent" property
+ then
+ h# 3800 encode-int 0 encode-int encode+
+ 0 encode-int encode+ 1 encode-int encode+
+ " /pci/isa/interrupt-controller" find-dev if
+ encode-int encode+
+ then
+ h# 0C encode-int encode+ 1 encode-int encode+
+ " interrupt-map" property
+
+" /pci/isa" find-device
+ " /pci/isa/interrupt-controller" find-dev if
+ encode-int " interrupt-parent" property
+ then
+
+\ -------------------------------------------------------------
+\ /packages
+\ -------------------------------------------------------------
+
+" /packages" find-device
+
+ " packages" device-name
+ external
+ \ allow packages to be opened with open-dev
+ : open true ;
+ : close ;
+
+\ /packages/terminal-emulator
+new-device
+ " terminal-emulator" device-name
+ external
+ : open true ;
+ : close ;
+ \ : write ( addr len -- actual )
+ \ dup -rot type
+ \ ;
+finish-device
+
+\ -------------------------------------------------------------
+\ The END
+\ -------------------------------------------------------------
+device-end
+
Added: openbios-devel/arch/ppc/qemu/vfd.c
===================================================================
--- openbios-devel/arch/ppc/qemu/vfd.c (rev 0)
+++ openbios-devel/arch/ppc/qemu/vfd.c 2008-11-24 12:16:22 UTC (rev 253)
@@ -0,0 +1,42 @@
+/*
+ * Creation Date: <2004/08/28 17:29:43 greg>
+ * Time-stamp: <2004/08/28 17:29:43 greg>
+ *
+ * <vfd.c>
+ *
+ * Simple text console
+ *
+ * Copyright (C) 2004 Greg Watson
+ *
+ * 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
+ *
+ */
+
+#include "openbios/config.h"
+#include "openbios/bindings.h"
+#include "qemu/qemu.h"
+
+static int vfd_is_open;
+
+static int
+vfd_init( void )
+{
+ vfd_is_open = 1;
+ return 0;
+}
+
+void
+vfd_close( void )
+{
+}
+
+int
+vfd_draw_str( const char *str )
+{
+ if (!vfd_is_open)
+ vfd_init();
+
+ return 0;
+}
Modified: openbios-devel/config/examples/cross-ppc_config.xml
===================================================================
--- openbios-devel/config/examples/cross-ppc_config.xml 2008-11-24 12:15:08 UTC (rev 252)
+++ openbios-devel/config/examples/cross-ppc_config.xml 2008-11-24 12:16:22 UTC (rev 253)
@@ -6,7 +6,8 @@
<option name="CONFIG_PPC" type="boolean" value="true"/>
<!--<option name="CONFIG_MOL" type="boolean" value="true"/>-->
<!--<option name="CONFIG_BRIQ" type="boolean" value="true"/>-->
- <option name="CONFIG_PEARPC" type="boolean" value="true"/>
+ <!--<option name="CONFIG_PEARPC" type="boolean" value="true"/>-->
+ <option name="CONFIG_QEMU" type="boolean" value="true"/>
<option name="CONFIG_BIG_ENDIAN" type="boolean" value="true"/>
<!-- Build hosted UNIX Binary -->
@@ -57,7 +58,7 @@
<option name="CONFIG_DEBUG_FS" type="boolean" value="true"/>
<!-- Miscellaneous -->
- <option name="CONFIG_LINUXBIOS" type="boolean" value="true"/>
+ <option name="CONFIG_LINUXBIOS" type="boolean" value="false"/>
<!-- Drivers -->
<option name="CONFIG_DRIVER_PCI" type="boolean" value="true"/>
1
0

Nov. 24, 2008
Author: stepan
Date: 2008-11-24 13:15:08 +0100 (Mon, 24 Nov 2008)
New Revision: 252
Modified:
openbios-devel/arch/sparc64/console.c
openbios-devel/arch/sparc64/openbios.c
openbios-devel/drivers/esp.c
openbios-devel/drivers/floppy.c
openbios-devel/drivers/ide.c
openbios-devel/drivers/obio.c
openbios-devel/drivers/pci.c
openbios-devel/include/openbios/bindings.h
Log:
This patch moves all definitions of REGISTER_NAMED_NODE and
REGISTER_NODE_METHODS to openbios/bindings.h.
Signed-off-by: Laurent Vivier <Laurent(a)lvivier.info>
Acked-by: Stefan Reinauer <stepan(a)coresystems.de>
Modified: openbios-devel/arch/sparc64/console.c
===================================================================
--- openbios-devel/arch/sparc64/console.c 2008-11-24 12:13:40 UTC (rev 251)
+++ openbios-devel/arch/sparc64/console.c 2008-11-24 12:15:08 UTC (rev 252)
@@ -14,19 +14,6 @@
#include "sys_info.h"
#include "boot.h"
-#define REGISTER_NAMED_NODE( name, path ) do { \
- bind_new_node( name##_flags_, name##_size_, \
- path, name##_m, sizeof(name##_m)/sizeof(method_t)); \
- } while(0)
-
-#define REGISTER_NODE_METHODS( name, path ) do { \
- const char *paths[1]; \
- \
- paths[0] = path; \
- bind_node( name##_flags_, name##_size_, \
- paths, 1, name##_m, sizeof(name##_m)/sizeof(method_t)); \
- } while(0)
-
/* ******************************************************************
* serial console functions
* ****************************************************************** */
Modified: openbios-devel/arch/sparc64/openbios.c
===================================================================
--- openbios-devel/arch/sparc64/openbios.c 2008-11-24 12:13:40 UTC (rev 251)
+++ openbios-devel/arch/sparc64/openbios.c 2008-11-24 12:15:08 UTC (rev 252)
@@ -30,19 +30,6 @@
#define BIOS_CFG_CMD 0x510
#define BIOS_CFG_DATA 0x511
-#define REGISTER_NAMED_NODE( name, path ) do { \
- bind_new_node( name##_flags_, name##_size_, \
- path, name##_m, sizeof(name##_m)/sizeof(method_t)); \
- } while(0)
-
-#define REGISTER_NODE_METHODS( name, path ) do { \
- const char *paths[1]; \
- \
- paths[0] = path; \
- bind_node( name##_flags_, name##_size_, \
- paths, 1, name##_m, sizeof(name##_m)/sizeof(method_t)); \
- } while(0)
-
static unsigned char intdict[256 * 1024];
// XXX
Modified: openbios-devel/drivers/esp.c
===================================================================
--- openbios-devel/drivers/esp.c 2008-11-24 12:13:40 UTC (rev 251)
+++ openbios-devel/drivers/esp.c 2008-11-24 12:15:08 UTC (rev 252)
@@ -27,19 +27,6 @@
#define BUFSIZE 4096
-#define REGISTER_NAMED_NODE( name, path ) do { \
- bind_new_node( name##_flags_, name##_size_, \
- path, name##_m, sizeof(name##_m)/sizeof(method_t)); \
- } while(0)
-
-#define REGISTER_NODE_METHODS( name, path ) do { \
- const char *paths[1]; \
- \
- paths[0] = path; \
- bind_node( name##_flags_, name##_size_, \
- paths, 1, name##_m, sizeof(name##_m)/sizeof(method_t)); \
- } while(0)
-
#ifdef CONFIG_DEBUG_ESP
#define DPRINTF(fmt, args...) \
do { printk(fmt , ##args); } while (0)
Modified: openbios-devel/drivers/floppy.c
===================================================================
--- openbios-devel/drivers/floppy.c 2008-11-24 12:13:40 UTC (rev 251)
+++ openbios-devel/drivers/floppy.c 2008-11-24 12:15:08 UTC (rev 252)
@@ -8,11 +8,6 @@
#include "timer.h"
-#define REGISTER_NAMED_NODE( name, path ) do { \
- bind_new_node( name##_flags_, name##_size_, \
- path, name##_m, sizeof(name##_m)/sizeof(method_t)); \
- } while(0)
-
/* DECLARE data structures for the nodes. */
DECLARE_UNNAMED_NODE( ob_floppy, INSTALL_OPEN, 2*sizeof(int) );
Modified: openbios-devel/drivers/ide.c
===================================================================
--- openbios-devel/drivers/ide.c 2008-11-24 12:13:40 UTC (rev 251)
+++ openbios-devel/drivers/ide.c 2008-11-24 12:15:08 UTC (rev 252)
@@ -29,12 +29,6 @@
#include "hdreg.h"
#include "timer.h"
-#define REGISTER_NAMED_NODE( name, path ) do { \
- bind_new_node( name##_flags_, name##_size_, \
- path, name##_m, sizeof(name##_m)/sizeof(method_t)); \
- } while(0)
-
-
/* DECLARE data structures for the nodes. */
DECLARE_UNNAMED_NODE( ob_ide, INSTALL_OPEN, 2*sizeof(int) );
DECLARE_UNNAMED_NODE( ob_ide_ctrl, INSTALL_OPEN, sizeof(int));
Modified: openbios-devel/drivers/obio.c
===================================================================
--- openbios-devel/drivers/obio.c 2008-11-24 12:13:40 UTC (rev 251)
+++ openbios-devel/drivers/obio.c 2008-11-24 12:15:08 UTC (rev 252)
@@ -24,19 +24,6 @@
#define NO_QEMU_PROTOS
#include "openbios/fw_cfg.h"
-#define REGISTER_NAMED_NODE( name, path ) do { \
- bind_new_node( name##_flags_, name##_size_, \
- path, name##_m, sizeof(name##_m)/sizeof(method_t)); \
- } while(0)
-
-#define REGISTER_NODE_METHODS( name, path ) do { \
- const char *paths[1]; \
- \
- paths[0] = path; \
- bind_node( name##_flags_, name##_size_, \
- paths, 1, name##_m, sizeof(name##_m)/sizeof(method_t)); \
- } while(0)
-
#define PROMDEV_KBD 0 /* input from keyboard */
#define PROMDEV_SCREEN 0 /* output to screen */
#define PROMDEV_TTYA 1 /* in/out to ttya */
Modified: openbios-devel/drivers/pci.c
===================================================================
--- openbios-devel/drivers/pci.c 2008-11-24 12:13:40 UTC (rev 251)
+++ openbios-devel/drivers/pci.c 2008-11-24 12:15:08 UTC (rev 252)
@@ -23,11 +23,6 @@
#include "timer.h"
#include "pci.h"
-#define REGISTER_NAMED_NODE( name, path ) do { \
- bind_new_node( name##_flags_, name##_size_, \
- path, name##_m, sizeof(name##_m)/sizeof(method_t)); \
- } while(0)
-
#define set_bool_property(ph, name) set_property(ph, name, NULL, 0);
/* DECLARE data structures for the nodes. */
Modified: openbios-devel/include/openbios/bindings.h
===================================================================
--- openbios-devel/include/openbios/bindings.h 2008-11-24 12:13:40 UTC (rev 251)
+++ openbios-devel/include/openbios/bindings.h 2008-11-24 12:15:08 UTC (rev 252)
@@ -106,6 +106,19 @@
void *func;
} method_t;
+#define REGISTER_NAMED_NODE( name, path ) do { \
+ bind_new_node( name##_flags_, name##_size_, \
+ path, name##_m, sizeof(name##_m)/sizeof(method_t)); \
+ } while(0)
+
+#define REGISTER_NODE_METHODS( name, path ) do { \
+ const char *paths[1]; \
+ \
+ paths[0] = path; \
+ bind_node( name##_flags_, name##_size_, \
+ paths, 1, name##_m, sizeof(name##_m)/sizeof(method_t)); \
+ } while(0)
+
#define DECLARE_UNNAMED_NODE( name, flags, size ) \
static const int name##_flags_ = flags; \
static const int name##_size_ = size;
1
0
Author: stepan
Date: 2008-11-24 13:13:40 +0100 (Mon, 24 Nov 2008)
New Revision: 251
Modified:
openbios-devel/config/examples/cross-ppc_rules.xml
openbios-devel/kernel/bootstrap.c
openbios-devel/kernel/cross.h
Log:
This patch allows me to compile openbios using the cross-pcc target
on amd64 host.
Signed-off-by: Laurent Vivier <Laurent(a)lvivier.info>
Acked-by: Stefan Reinauer <stepan(a)coresystems.de>
Modified: openbios-devel/config/examples/cross-ppc_rules.xml
===================================================================
--- openbios-devel/config/examples/cross-ppc_rules.xml 2008-11-17 19:42:11 UTC (rev 250)
+++ openbios-devel/config/examples/cross-ppc_rules.xml 2008-11-24 12:13:40 UTC (rev 251)
@@ -9,20 +9,21 @@
ARCH := ppc
ODIR := obj-$(ARCH)
HOSTCC := gcc
-HOSTCFLAGS := -Os -Wall -W -DFCOMPILER -DBOOTSTRAP $(CROSSCFLAGS)
+HOSTCFLAGS := -Os -Wall -W -DFCOMPILER -DBOOTSTRAP $(CROSSCFLAGS) -DSWAP_ENDIANNESS
HOSTINCLUDES := -Iinclude -Ikernel/include -I$(ODIR)/target/include
#
# MOLPATH is needed if you want to build openbios-mol.elf
#
MOLPATH=$(HOME)/mol-0.9.71
-CC := powerpc-linux-gcc
-AS := powerpc-linux-as
-AR := powerpc-linux-ar
-LD := powerpc-linux-ld
-NM := powerpc-linux-nm
-STRIP := powerpc-linux-strip
-RANLIB := powerpc-linux-ranlib
+TARGET=powerpc-linux-gnu-
+CC := $(TARGET)gcc
+AS := $(TARGET)as
+AR := $(TARGET)ar
+LD := $(TARGET)ld
+NM := $(TARGET)nm
+STRIP := $(TARGET)strip
+RANLIB := $(TARGET)ranlib
CFLAGS := -Os -Wall -W -msoft-float -DNATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH -USWAP_ENDIANNESS -fno-builtin-bcopy -fno-builtin-log2
INCLUDES := -Iinclude -Ikernel/include -I$(ODIR)/target/include
Modified: openbios-devel/kernel/bootstrap.c
===================================================================
--- openbios-devel/kernel/bootstrap.c 2008-11-17 19:42:11 UTC (rev 250)
+++ openbios-devel/kernel/bootstrap.c 2008-11-24 12:13:40 UTC (rev 251)
@@ -47,7 +47,7 @@
static unsigned int cursrc = 0;
#ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH
-ucell base_address;
+unsigned long base_address;
#endif
/* include path handling */
Modified: openbios-devel/kernel/cross.h
===================================================================
--- openbios-devel/kernel/cross.h 2008-11-17 19:42:11 UTC (rev 250)
+++ openbios-devel/kernel/cross.h 2008-11-24 12:13:40 UTC (rev 251)
@@ -113,7 +113,7 @@
#endif
#ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH
-extern ucell base_address;
+extern unsigned long base_address;
#define pointer2cell(x) ((ucell)(((unsigned long)(x))-base_address))
#define cell2pointer(x) ((u8 *)(((unsigned long)(x))+base_address))
#define FMT_CELL_x "x"
1
0
1
0
1
0