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
May 2016
- 4 participants
- 7 discussions

[PATCH] libopenbios/bootinfo_load.c: Implement Mac OS 9.2 boot script support
by Programmingkid Dec. 25, 2017
by Programmingkid Dec. 25, 2017
Dec. 25, 2017
This patch makes booting Mac OS 9.2 possible. It replaces all occurrences of
>r and r> with sub_>r and sub_r>. This allows for the return stack to be left
alone. This patch also makes it so that the boot script is executed one line at a time.
Signed-off-by: John Arbuckle <programmingkidx(a)gmail.com>
Note: this patch depends on the strstr() and return stack substitution patches.
Index: libopenbios/bootinfo_load.c
===================================================================
--- libopenbios/bootinfo_load.c (revision 1395)
+++ libopenbios/bootinfo_load.c (working copy)
@@ -19,6 +19,7 @@
#include "libopenbios/bootinfo_load.h"
#include "libopenbios/ofmem.h"
#include "libc/vsprintf.h"
+#include "libc/string.h"
//#define DEBUG_BOOTINFO
@@ -116,6 +117,75 @@
return LOADER_NOT_SUPPORT;
}
+// Replace all occurrences of orig_str in buffer with replace_str
+static void replace_string(char *buffer, const char *orig_str, const char *replace_str)
+{
+ char *ptr;
+ int index, new_buf_index = 0;
+ const int max_size = 5000;
+ char *new_buffer = malloc(max_size * sizeof(char));
+
+ for (index = 0; index < strlen(buffer); index++) {
+ if (buffer[index] == orig_str[0]) {
+ ptr = strstr(buffer + index, orig_str);
+
+ // if we encountered an orig_str in the buffer
+ if (index == (ptr - buffer)) {
+ sprintf(new_buffer + new_buf_index, "%s ", replace_str);
+ new_buf_index += strlen(replace_str) + 1;
+ index += strlen(orig_str);
+ continue;
+ }
+ }
+ new_buffer[new_buf_index++] = buffer[index];
+ }
+
+ // copy new_buffer into buffer
+ for (index = 0; index < strlen(new_buffer); index++) {
+ buffer[index] = new_buffer[index];
+ }
+ buffer[index+1] = '\0';
+}
+
+/* Replace >r and r> with sub_>r and sub_r> */
+static void replace_return_stack_words(char *bootscript)
+{
+ const char *find_str1 = ">r";
+ const char *replace_str1 = "sub_>r";
+ const char *find_str2 = "r>";
+ const char *replace_str2 = "sub_r>";
+
+ replace_string(bootscript, find_str1, replace_str1);
+ replace_string(bootscript, find_str2, replace_str2);
+}
+
+/* Runs the bootscript one line at a time */
+void run_script(char *bootscript)
+{
+ int index = 0, buf_index = 0;
+ char c;
+ char *buffer = malloc(1000 * sizeof(char));
+
+ while (1) {
+ c = bootscript[index];
+
+ // fill up buffer
+ while (c != '\n' && c != '\r' && c != '\0') {
+ buffer[buf_index++] = c;
+ c = bootscript[++index];
+ }
+ buffer[buf_index] = '\0';
+ buf_index = 0;
+ index++;
+ DPRINTF("%s\n", buffer);
+ feval(buffer);
+ if (c == '\0') {
+ break;
+ }
+ }
+ free(buffer);
+}
+
/*
Parse SGML structure like:
<chrp-boot>
@@ -209,9 +279,6 @@
script = 0;
bootscript[scriptlen] = '\0';
- DPRINTF("got bootscript %s\n",
- bootscript);
-
scriptvalid = -1;
break;
@@ -261,8 +328,8 @@
/* If the payload is bootinfo then we execute it immediately */
if (scriptvalid) {
- DPRINTF("bootscript: %s\n", bootscript);
- feval(bootscript);
+ replace_return_stack_words(bootscript);
+ run_script(bootscript);
}
else
DPRINTF("Unable to parse bootinfo bootscript\n");
4
9

[PATCH 0/5] Enable bus master support for rtl8139 network cards on Apple PPC machines
by Mark Cave-Ayland Aug. 7, 2016
by Mark Cave-Ayland Aug. 7, 2016
Aug. 7, 2016
This patchset is loosely based on earlier work by BALATON Zoltan <balaton(a)eik.bme.hu>
and provides basic infrastructure to allow OpenBIOS to enable PCI device
bus mastering.
Following on from discussions on the QEMU mailing list, it seems that Apple's OF
enables bus mastering for some PCI devices by default, and as a result some buggy
drivers forget to explicitly enable it and hence these devices fail under QEMU's
emulation.
The first 3 patches add the basic support routines while the last 2 patches enable
bus mastering for the rtl8139 card on Apple PPC machines which is required for
OS X and MorphOS.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Mark Cave-Ayland (5):
pci: introduce ob_pci_enable_bus_master() function
pci: introduce ob_pci_is_bus_master_capable() function
pci: add PCI database entry for rtl8139 network card
pci: add rtl8139_config_cb() to configure rtl8139 network cards
ppc: mark PCI slots 0-2 for Apple PPC machies as bus master capable
openbios-devel/arch/ppc/qemu/init.c | 9 ++++---
openbios-devel/drivers/pci.c | 44 +++++++++++++++++++++++++++++++++
openbios-devel/drivers/pci_database.c | 6 +++++
openbios-devel/drivers/pci_database.h | 4 +++
openbios-devel/include/drivers/pci.h | 2 ++
5 files changed, 62 insertions(+), 3 deletions(-)
--
1.7.10.4
5
17

July 17, 2016
On Apr 17, 2016, at 11:05 AM, Mark Cave-Ayland wrote:
> On 17/04/16 15:50, Programmingkid wrote:
>
>> Good news, I found out why replacing '\r' with '\n' works to boot Mac OS 9. It is because there are several words that require that character to be at the end of the line.
>>
>> http://www.complang.tuwien.ac.at/forth/1275.ps
>> This is the specifications to Open Firmware. Just do a search for EOL (End of Line a.k.a '\n'). You will see that several words need it in order to work.
>>
>> They will look like this:
>>
>> dev ( "device-specifier<eol>" -- )
>>
>> The <eol> text is what specifies that '\n' should be at the end of the line.
>
> Really? Interesting. Can you provide a self-contained test case that
> demonstrates that it is in fact the line ending that causes this
> independent of the r-stack manipulation? Bear in mind that OpenBIOS may
> deviate from the specification in its behaviour here.
I implemented another stack that two new words use in place of >r and r> when running code in the bootscript. I see this message with and without the '\r' to '\n' patch:
>> Dictionary space overflow: dicthead=000c3fe4 dictlimit=00080000
this image is not for this platform
This means the implementing another stack did not fix the problem. It appears to make it worse.
Here is the patch:
Index: include/libc/string.h
===================================================================
--- include/libc/string.h (revision 1391)
+++ include/libc/string.h (working copy)
@@ -47,7 +47,7 @@
extern char *strdup( const char *str );
extern int strcasecmp( const char *cs, const char *ct );
extern int strncasecmp( const char *cs, const char *ct, size_t count );
-
+extern char *strstr(char *buffer, const char *search_string);
extern char *strncpy_nopad( char *dest, const char *src, size_t n );
#define _U 0x01 /* upper */
Index: kernel/bootstrap.c
===================================================================
--- kernel/bootstrap.c (revision 1391)
+++ kernel/bootstrap.c (working copy)
@@ -89,7 +89,7 @@
"here", "here!", "dobranch", "do?branch", "unaligned-w@",
"unaligned-w!", "unaligned-l@", "unaligned-l!", "ioc@", "iow@",
"iol@", "ioc!", "iow!", "iol!", "i", "j", "call", "sys-debug",
- "$include", "$encode-file", "(debug", "(debug-off)"
+ "$include", "$encode-file", "(debug", "(debug-off)", "sub_>r", "sub_r>"
};
/*
Index: kernel/forth.c
===================================================================
--- kernel/forth.c (revision 1391)
+++ kernel/forth.c (working copy)
@@ -1848,6 +1848,37 @@
PUSH(rstack[rstackcnt - 2]);
}
+/* The substitute return stack */
+#define MAX_SUB_RSTACK_SIZE 100
+static int sub_return_stack[MAX_SUB_RSTACK_SIZE];
+static int top = 0;
+
+/*
+ * sub_>r ( i -- ) (Substitute R: -- i )
+ */
+
+static void sub_gt_r(void)
+{
+ if (top >= MAX_SUB_RSTACK_SIZE) {
+ printf_console("Stack overflow\n");
+ return;
+ }
+ sub_return_stack[top++] = POP();
+}
+
+/*
+ * sub_r> ( -- i ) (Substitute R: i -- )
+ */
+
+static void sub_r_gt(void)
+{
+ if (top < 0 ) {
+ printf_console("Stack underflow\n");
+ return;
+ }
+ PUSH(sub_return_stack[top--]);
+}
+
/* words[] is a function array of all native code functions used by
* the dictionary, i.e. CFAs and primitives.
* Any change here needs a matching change in the primitive word's
@@ -1963,4 +1994,6 @@
do_encode_file, /* $encode-file */
do_debug_xt, /* (debug */
do_debug_off, /* (debug-off) */
+ sub_gt_r, /* sub_>r */
+ sub_r_gt /* sub_r> */
};
Index: libc/string.c
===================================================================
--- libc/string.c (revision 1391)
+++ libc/string.c (working copy)
@@ -385,3 +385,30 @@
return __res;
}
+// Search for a string within another string
+char *strstr(char *buffer, const char *search_string)
+{
+ if (!*search_string || (strlen(search_string) == 0)) {
+ return buffer;
+ }
+
+ int match_found, index, index2;
+ for (index = 0; index < strlen(buffer); index++) {
+ if (buffer[index] == search_string[0]) {
+ match_found = 1;
+ // see if we have a match
+ for (index2 = 0; index2 < strlen(search_string); index2++) {
+ if (buffer[index + index2] != search_string[index2]) {
+ match_found = 0; // match not found
+ break;
+ }
+ }
+ if(match_found == 1) {
+ return &buffer[index];
+ }
+ }
+ }
+
+ // Could not find search_string in buffer
+ return NULL;
+}
Index: libopenbios/bootinfo_load.c
===================================================================
--- libopenbios/bootinfo_load.c (revision 1391)
+++ libopenbios/bootinfo_load.c (working copy)
@@ -19,6 +19,7 @@
#include "libopenbios/bootinfo_load.h"
#include "libopenbios/ofmem.h"
#include "libc/vsprintf.h"
+#include "libc/string.h"
//#define DEBUG_BOOTINFO
@@ -116,6 +117,60 @@
return LOADER_NOT_SUPPORT;
}
+static void erase_memory(char *memory, int size)
+{
+ int i;
+ for(i = 0; i < size; i++) {
+ memory[i] = ' ';
+ }
+}
+
+// Replace all occurrences of orig_str in buffer with replace_str
+static void replace_string(char *buffer, const char *orig_str, const char *replace_str)
+{
+ char *ptr;
+ int index, new_buf_index = 0;
+ const int max_size = 5000;
+ char *new_buffer = malloc(max_size * sizeof(char));
+ erase_memory(new_buffer, max_size);
+
+ for (index = 0; index < strlen(buffer); index++) {
+ if (buffer[index] == orig_str[0]) {
+ ptr = strstr(buffer + index, orig_str);
+
+ // if we encountered an orig_str in the buffer
+ if (index == (ptr - buffer)) {
+ sprintf(new_buffer + new_buf_index, "%s ", replace_str);
+ new_buf_index += strlen(replace_str) + 1;
+ index += strlen(orig_str);
+ continue;
+ }
+ }
+ new_buffer[new_buf_index++] = buffer[index];
+ }
+
+ // Clear the origial buffer
+ erase_memory(buffer, max_size);
+
+ // copy new_buffer into buffer
+ for (index = 0; index < strlen(new_buffer); index++) {
+ buffer[index] = new_buffer[index];
+ }
+ buffer[index+1] = '\0';
+}
+
+/* Replace >r and r> with sub_>r and sub_r> */
+static void replace_return_stack_words(char *bootscript)
+{
+ const char *find_str1 = ">r";
+ const char *replace_str1 = "sub_>r";
+ const char *find_str2 = "r>";
+ const char *replace_str2 = "sub_r>";
+
+ replace_string(bootscript, find_str1, replace_str1);
+ replace_string(bootscript, find_str2, replace_str2);
+}
+
/*
Parse SGML structure like:
<chrp-boot>
@@ -190,8 +245,11 @@
while (current < size) {
c = base[current++];
+
+ if(c == '\r')
+ c = '\n';
- if (c == '<') {
+ if (c == '<') {
script = 0;
tag = 1;
taglen = 0;
@@ -262,6 +320,7 @@
/* If the payload is bootinfo then we execute it immediately */
if (scriptvalid) {
DPRINTF("bootscript: %s\n", bootscript);
+ replace_return_stack_words(bootscript);
feval(bootscript);
}
else
3
13
This patch series is part of a much larger WIP series designed to remove various hacks
from the load/init-program/go words. However in order for the follow-on series to work,
all architectures must build an execution context similar to the IEEE1275 specification
description of saved-program-state.
PPC is the only architecture which doesn't make use of contexts when entering/leaving the
Forth environment, so start by adding this functionality in order that it can be expanded
on further with later patches. While no functionality is changed by this patch, there should
be no regressions when attempting to boot existing client images.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Mark Cave-Ayland (4):
ppc: move call_elf() to separate switch.S file
ppc: add new context handler
ppc: use separate context to call client images
ppc: unify CIF save stack layout with that of new context stack
openbios-devel/arch/ppc/build.xml | 2 +
openbios-devel/arch/ppc/qemu/context.c | 138 ++++++++++++++++++
openbios-devel/arch/ppc/qemu/context.h | 34 +++++
openbios-devel/arch/ppc/qemu/init.c | 4 +-
openbios-devel/arch/ppc/qemu/ldscript | 6 +-
openbios-devel/arch/ppc/qemu/start.S | 244 +++++++++++++-------------------
openbios-devel/arch/ppc/qemu/switch.S | 211 +++++++++++++++++++++++++++
openbios-devel/include/arch/ppc/io.h | 2 +-
8 files changed, 492 insertions(+), 149 deletions(-)
create mode 100644 openbios-devel/arch/ppc/qemu/context.c
create mode 100644 openbios-devel/arch/ppc/qemu/context.h
create mode 100644 openbios-devel/arch/ppc/qemu/switch.S
--
1.7.10.4
3
25
You know how you see messages about writing to missing registers like these:
OS 9.2] Trying to write invalid spr 0 (0x000) at 00f113c0
11:26:23.910 WARNING [Mac OS 9.2] Trying to read invalid spr 0 (0x000) at 00f113c8
11:26:24.055 WARNING [Mac OS 9.2] Trying to write privileged spr 955 (0x3bb) at 00f164b8
11:26:24.055 WARNING [Mac OS 9.2] Trying to write invalid spr 959 (0x3bf) at 00f16520
11:26:24.055 WARNING [Mac OS 9.2] Trying to read invalid spr 959 (0x3bf) at 00f16528
11:26:24.056 WARNING [Mac OS 9.2] Trying to write invalid spr 944 (0x3b0) at 00f1653c
11:26:24.056 WARNING [Mac OS 9.2] Trying to read invalid spr 944 (0x3b0) at 00f16544
11:26:24.056 WARNING [Mac OS 9.2] Trying to write invalid spr 951 (0x3b7) at 00f16550
11:26:24.056 WARNING [Mac OS 9.2] Trying to read invalid spr 951 (0x3b7) at 00f16558
11:26:24.204 WARNING [Mac OS 9.2] Trying to write privileged spr 955 (0x3bb) at 00f164b8
11:26:24.204 WARNING [Mac OS 9.2] Trying to write invalid spr 959 (0x3bf) at 00f16520
11:26:24.204 WARNING [Mac OS 9.2] Trying to read invalid spr 959 (0x3bf) at 00f16528
11:26:24.204 WARNING [Mac OS 9.2] Trying to write invalid spr 944 (0x3b0) at 00f1653c
11:26:24.204 WARNING [Mac OS 9.2] Trying to read invalid spr 944 (0x3b0) at 00f16544
11:26:24.205 WARNING [Mac OS 9.2] Trying to write invalid spr 951 (0x3b7) at 00f16550
11:26:24.205 WARNING [Mac OS 9.2] Trying to read invalid spr 951 (0x3b7) at 00f16558
Should these registers be implemented? Maybe Apple expected these registers to be available on their hardware.
Using these files:
http://www.nxp.com/files/32bit/doc/ref_manual/MPC7450UM.pdf page 1-36
and http://www.nxp.com/files/32bit/doc/data_sheet/MPC604.pdf page 19,
as a guide, here is what I found out:
SPR Name
944 Monitor Control Register 2
951 Breakpoint Address Mask Register1
955 Sampled Instruction Address 1
959 Sampled Data Address * PowerPC 604 only
My current theory is there might be implementation details that are off in QEMU's emulated PowerPC 750 processor. The only way I know how to test this out is run QEMU in KVM mode on PowerPC hardware. I'm hoping someone out there has this setup available and can tell us if Mac OS 9.2 works better in KVM mode or not.
3
5
This patch series is part of a much larger WIP series designed to remove various hacks
from the load/init-program/go words. However in order for the follow-on series to work,
all architectures must build an execution context similar to the IEEE1275 specification
description of saved-program-state.
PPC is the only architecture which doesn't make use of contexts when entering/leaving the
Forth environment, so start by adding this functionality in order that it can be expanded
on further with later patches. While no functionality is changed by this patch, there should
be no regressions when attempting to boot existing client images.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
v2:
- Use single asm invocation in switch_to() with clobber register
- Fix unsigned int -> unsigned long
- Fix missing volatile from __context pointer
Mark Cave-Ayland (4):
ppc: move call_elf() to separate switch.S file
ppc: add new context handler
ppc: use separate context to call client images
ppc: unify CIF save stack layout with that of new context stack
openbios-devel/arch/ppc/build.xml | 2 +
openbios-devel/arch/ppc/qemu/context.c | 140 ++++++++++++++++++
openbios-devel/arch/ppc/qemu/context.h | 34 +++++
openbios-devel/arch/ppc/qemu/init.c | 4 +-
openbios-devel/arch/ppc/qemu/ldscript | 6 +-
openbios-devel/arch/ppc/qemu/start.S | 244 +++++++++++++-------------------
openbios-devel/arch/ppc/qemu/switch.S | 211 +++++++++++++++++++++++++++
openbios-devel/include/arch/ppc/io.h | 2 +-
8 files changed, 494 insertions(+), 149 deletions(-)
create mode 100644 openbios-devel/arch/ppc/qemu/context.c
create mode 100644 openbios-devel/arch/ppc/qemu/context.h
create mode 100644 openbios-devel/arch/ppc/qemu/switch.S
--
1.7.10.4
2
7
I made a patch that prints everything that (evaluate) does, hoping it would tell me where execution stopped in the boot script. Here is the patch:
Index: forth/bootstrap/interpreter.fs
===================================================================
--- forth/bootstrap/interpreter.fs (revision 1395)
+++ forth/bootstrap/interpreter.fs (working copy)
@@ -151,6 +151,7 @@
;
: (evaluate) ( str len -- ??? )
+ 2dup fprintk
save-source
-1 ['] source-id (to)
dup
Index: kernel/bootstrap.c
===================================================================
--- kernel/bootstrap.c (revision 1395)
+++ kernel/bootstrap.c (working copy)
@@ -89,7 +89,7 @@
"here", "here!", "dobranch", "do?branch", "unaligned-w@",
"unaligned-w!", "unaligned-l@", "unaligned-l!", "ioc@", "iow@",
"iol@", "ioc!", "iow!", "iol!", "i", "j", "call", "sys-debug",
- "$include", "$encode-file", "(debug", "(debug-off)"
+ "$include", "$encode-file", "(debug", "(debug-off)", "fprintk"
};
/*
Index: kernel/forth.c
===================================================================
--- kernel/forth.c (revision 1395)
+++ kernel/forth.c (working copy)
@@ -1848,6 +1848,26 @@
PUSH(rstack[rstackcnt - 2]);
}
+/*
+ * fprintk ( addr len -- )
+ * writes a forth string to the serial output
+ */
+
+static void fprintk(void)
+{
+ int len = POP();
+ int addr = POP();
+ char *message = malloc(sizeof(char) * 5000);
+ snprintf(message, len + 1, "%s", addr);
+ int i;
+ for (i = 0; i < len; i++) {
+ if (message[i] == '\r')
+ message[i] = ' ';
+ }
+ printk(message);
+ free(message);
+}
+
/* words[] is a function array of all native code functions used by
* the dictionary, i.e. CFAs and primitives.
* Any change here needs a matching change in the primitive word's
@@ -1963,4 +1983,5 @@
do_encode_file, /* $encode-file */
do_debug_xt, /* (debug */
do_debug_off, /* (debug-off) */
+ fprintk, /* fprintk */
};
Index: libc/extra.c
===================================================================
--- libc/extra.c (revision 1395)
+++ libc/extra.c (working copy)
@@ -31,7 +31,7 @@
int forth_printf( const char *fmt, ... )
{
- char buf[512];
+ char buf[5000];
va_list args;
int i;
Well after trying to run Mac OS 9.2 several times, this was the output:
['] display-ih cell+['] frame-buffer-adr cell+['] openbios-video-width cell+['] openbios-video-height cell+['] depth-bits cell+['] line-bytes cell+['] color-palette cell+to fb8-blitmaskto fb8-fillrectto fb8-invertrectto (romfont)to (romfont-height)to (romfont-width)['] vga-driver-fcode 2 cells + 1 byte-load: write dup >r bounds do i c@ fb-emit loop r> ; : draw-logo draw-logo ; : restore reset-screen ; fcode-debug?
>> =============================================================
>> OpenBIOS 1.1 [May 2 2016 02:45]
>> Configuration device id QEMU version 1 machine id 1
>> CPUs: 1
>> Memory: 384M
>> UUID: 00000000-0000-0000-0000-000000000000
>> CPU type PowerPC,750
milliseconds isn't unique.
>> bootstrdup encode-string " selected-partition-args" propertystrdup encode-string " selected-partition-args" propertyload-baseload-baseload-baseload-size here >r dev / " model" active-package get-package-property abort" can't find MODEL" decode-string 2swap 2drop " iMac,1" $= ?dup 0= if " compatible" active-package get-package-property abort" can't find COMPATIBLE" false >r begin dup while decode-string here over 2swap bounds ?do i c@ dup [char] A [char] Z between if h# 20 xor then c, loop 2dup " macrisc" $= r> or >r 2drop repeat 2drop r> then r> here - allot 0= abort" this image is not for this platform" decimal 1 load-base load-size 14 - adler32 load-base load-size + 12 - 12 ['] eval catch if 2drop ." , bad checksum value" -1 then <> if ." , checksum error" abort then hex dev /openprom 0 0 " supports-bootinfo" property device-end " /chosen" find-package 0= abort" can't find '/chosen'" constant /chosen " memory" /chosen get-package-property abort" memory??" decode-int constant xmem 2drop " mmu" /chosen get-package-property abort" mmu??" decode-int constant xmmu 2drop " AAPL,debug" " /" find-package 0= abort" can't find '/'"
I don't know if I can trust this output because there appears to be a limit to how much can be printed to the serial console. Sometimes I would see at the end "h# C864630D". I'm not sure why. This text is located at the very end of the boot script file. Past the forth section. I don't think the abort" word is the problem because there is no indication that it aborted the script. Hopefully someone will find this information useful.
2
1