diff -Nru openbios-ppc-1.0+svn1060/.gitignore openbios-ppc-1.1/.gitignore
--- openbios-ppc-1.0+svn1060/.gitignore 2009-12-05 10:17:25.000000000 +0000
+++ openbios-ppc-1.1/.gitignore 2013-05-06 19:09:54.000000000 +0000
@@ -1,2 +1,3 @@
obj-*
.stgit-*
+config-host.mak
diff -Nru openbios-ppc-1.0+svn1060/Makefile openbios-ppc-1.1/Makefile
--- openbios-ppc-1.0+svn1060/Makefile 2009-12-05 10:17:25.000000000 +0000
+++ openbios-ppc-1.1/Makefile 2013-05-06 19:09:54.000000000 +0000
@@ -1,5 +1,4 @@
-ODIRS=$(wildcard obj-*)
-TARGETS=$(subst obj-,,$(ODIRS))
+include config-host.mak
all: requirements info build
@@ -16,18 +15,24 @@
$(MAKE) -C $$dir clean; \
done
-build:
- @printf "Building..."
+build: start-build
@for dir in $(ODIRS); do \
$(MAKE) -C $$dir > $$dir/build.log 2>&1 && echo "ok." || \
( echo "error:"; tail -15 $$dir/build.log; exit 1 ) \
done
-build-verbose:
+SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGETS))
+SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory)
+
+quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
+
+build-verbose: start-build $(SUBDIR_RULES)
+
+subdir-%:
+ $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C obj-$* V="$(V)" all,)
+
+start-build:
@echo "Building..."
- @for dir in $(ODIRS); do \
- $(MAKE) -C $$dir || exit 1; \
- done
run:
@echo "Running..."
diff -Nru openbios-ppc-1.0+svn1060/Makefile.target openbios-ppc-1.1/Makefile.target
--- openbios-ppc-1.0+svn1060/Makefile.target 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/Makefile.target 2013-05-06 19:09:54.000000000 +0000
@@ -6,7 +6,6 @@
include config.mak
ODIR := .
-SRCDIR := ..
HOSTCC := gcc
HOSTCFLAGS+= -O2 -g -DFCOMPILER -DBOOTSTRAP $(CROSSCFLAGS)
@@ -38,6 +37,10 @@
quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
+VPATH_SUFFIXES = %.c %.h %.S %.fs
+set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
+$(call set-vpath, $(SRCDIR))
+
#
# pre rules
#
diff -Nru openbios-ppc-1.0+svn1060/VERSION openbios-ppc-1.1/VERSION
--- openbios-ppc-1.0+svn1060/VERSION 2009-12-05 10:17:25.000000000 +0000
+++ openbios-ppc-1.1/VERSION 2013-05-06 19:09:54.000000000 +0000
@@ -1 +1 @@
-1.0
+1.1
diff -Nru openbios-ppc-1.0+svn1060/arch/ppc/ppc.fs openbios-ppc-1.1/arch/ppc/ppc.fs
--- openbios-ppc-1.0+svn1060/arch/ppc/ppc.fs 2009-03-08 13:07:57.000000000 +0000
+++ openbios-ppc-1.1/arch/ppc/ppc.fs 2013-05-06 19:09:54.000000000 +0000
@@ -1,3 +1,6 @@
+\ -------------------------------------------------------------------------
+\ registers
+\ -------------------------------------------------------------------------
0 value %cr
0 value %ctr
@@ -45,3 +48,10 @@
0 value %sprg1
0 value %sprg2
0 value %sprg3
+
+\ -------------------------------------------------------------------------
+\ other
+\ -------------------------------------------------------------------------
+
+\ Set by BootX when booting Mac OS X
+defer spin
diff -Nru openbios-ppc-1.0+svn1060/arch/ppc/qemu/init.c openbios-ppc-1.1/arch/ppc/qemu/init.c
--- openbios-ppc-1.0+svn1060/arch/ppc/qemu/init.c 2012-01-04 09:41:45.000000000 +0000
+++ openbios-ppc-1.1/arch/ppc/qemu/init.c 2013-05-06 19:09:54.000000000 +0000
@@ -59,6 +59,14 @@
}
}
+extern void __divide_error(void);
+
+void
+__divide_error(void)
+{
+ return;
+}
+
enum {
ARCH_PREP = 0,
ARCH_MAC99,
@@ -68,7 +76,7 @@
int is_apple(void)
{
- return 1;
+ return is_oldworld() || is_newworld();
}
int is_oldworld(void)
@@ -144,7 +152,7 @@
.cfg_len = 0x7f000000,
.host_mem_base = 0x80000000,
.pci_mem_base = 0x80000000,
- .mem_len = 0x01000000,
+ .mem_len = 0x10000000,
.io_base = 0xfe000000,
.io_len = 0x00800000,
.rbase = 0xfd000000,
@@ -613,6 +621,22 @@
fword("finish-device");
}
+/*
+ * filll ( addr bytes quad -- )
+ */
+
+static void ffilll(void)
+{
+ const u32 longval = POP();
+ u32 bytes = POP();
+ u32 *laddr = (u32 *)cell2pointer(POP());
+ u32 len;
+
+ for (len = 0; len < bytes / sizeof(u32); len++) {
+ *laddr++ = longval;
+ }
+}
+
void
arch_of_init(void)
{
@@ -831,7 +855,7 @@
}
/* Setup default boot devices */
- snprintf(buf, sizeof(buf), "%s:,\\\\:tbxi %s:,\\ppc\\bootinfo.txt", boot_path, boot_path);
+ snprintf(buf, sizeof(buf), "%s:,\\\\:tbxi %s:,\\ppc\\bootinfo.txt %s:,%%BOOT", boot_path, boot_path, boot_path);
push_str(buf);
fword("encode-string");
push_str("boot-device");
@@ -877,6 +901,9 @@
device_end();
+ /* Implementation of filll word (required by BootX) */
+ bind_func("filll", ffilll);
+
bind_func("platform-boot", boot);
bind_func("(go)", go);
}
diff -Nru openbios-ppc-1.0+svn1060/arch/ppc/qemu/ldscript openbios-ppc-1.1/arch/ppc/qemu/ldscript
--- openbios-ppc-1.0+svn1060/arch/ppc/qemu/ldscript 2009-08-18 14:16:50.000000000 +0000
+++ openbios-ppc-1.1/arch/ppc/qemu/ldscript 2013-05-06 19:09:54.000000000 +0000
@@ -1,5 +1,5 @@
OUTPUT_FORMAT(elf32-powerpc)
-OUTPUT_ARCH(powerpc)
+OUTPUT_ARCH(powerpc:common)
/* Initial load address
*/
diff -Nru openbios-ppc-1.0+svn1060/arch/ppc/qemu/main.c openbios-ppc-1.1/arch/ppc/qemu/main.c
--- openbios-ppc-1.0+svn1060/arch/ppc/qemu/main.c 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/arch/ppc/qemu/main.c 2013-05-06 19:09:54.000000000 +0000
@@ -39,141 +39,6 @@
#define ELF_DPRINTF(fmt, args...) SUBSYS_DPRINTF("ELF", fmt, ##args)
#define NEWWORLD_DPRINTF(fmt, args...) SUBSYS_DPRINTF("NEWWORLD", fmt, ##args)
-static char *
-get_device( const char *path )
-{
- int i;
- static char buf[1024];
-
- for (i = 0; i < sizeof(buf) && path[i] && path[i] != ':'; i++)
- buf[i] = path[i];
- buf[i] = 0;
-
- return buf;
-}
-
-static int
-get_partition( const char *path )
-{
- while ( *path && *path != ':' )
- path++;
-
- if (!*path)
- return -1;
- path++;
-
- if (!strchr(path, ',')) /* check if there is a ',' */
- return -1;
-
- return atol(path);
-}
-
-static char *
-get_filename( const char * path , char **dirname)
-{
- static char buf[1024];
- char *filename;
-
- while ( *path && *path != ':' )
- path++;
-
- if (!*path) {
- *dirname = NULL;
- return NULL;
- }
- path++;
-
- while ( *path && isdigit(*path) )
- path++;
-
- if (*path == ',')
- path++;
-
- strncpy(buf, path, sizeof(buf));
- buf[sizeof(buf) - 1] = 0;
-
- filename = strrchr(buf, '\\');
- if (filename) {
- *dirname = buf;
- (*filename++) = 0;
- } else {
- *dirname = NULL;
- filename = buf;
- }
-
- return filename;
-}
-
-
-static void
-encode_bootpath( const char *spec, const char *args )
-{
- char path[1024];
- phandle_t chosen_ph = find_dev("/chosen");
- char *filename, *directory;
- int partition;
-
- if (spec)
- return;
-
- filename = get_filename(spec, &directory);
- partition = get_partition(spec);
- if (partition == -1)
- snprintf(path, sizeof(path), "%s:,%s\\%s", get_device(spec),
- directory, filename);
- else
- snprintf(path, sizeof(path), "%s:%d,%s\\%s", get_device(spec),
- partition, directory, filename);
-
- ELF_DPRINTF("bootpath %s bootargs %s\n", path, args);
- set_property( chosen_ph, "bootpath", path, strlen(path)+1 );
- if (args)
- set_property( chosen_ph, "bootargs", args, strlen(args)+1 );
-}
-
-#define OLDWORLD_BOOTCODE_BASEADDR (0x3f4000)
-
-static void
-oldworld_boot( void )
-{
- int fd;
- int len, total;
- const char *path = "hd:,%BOOT";
- char *bootcode;
-
- if ((fd = open_io(path)) == -1) {
- ELF_DPRINTF("Can't open %s\n", path);
- return;
- }
-
-
- total = 0;
- bootcode = (char*)OLDWORLD_BOOTCODE_BASEADDR;
- while(1) {
- if (seek_io(fd, total) == -1)
- break;
- len = read_io(fd, bootcode, 512);
- bootcode += len;
- total += len;
- }
-
- close_io( fd );
-
- if (total == 0) {
- ELF_DPRINTF("Can't read %s\n", path);
- return;
- }
-
- encode_bootpath(path, "Linux");
-
- if( ofmem_claim( OLDWORLD_BOOTCODE_BASEADDR, total, 0 ) == -1 )
- fatal_error("Claim failed!\n");
-
- call_elf(0, 0, OLDWORLD_BOOTCODE_BASEADDR);
-
- return;
-}
-
static void check_preloaded_kernel(void)
{
unsigned long kernel_image, kernel_size;
@@ -213,9 +78,5 @@
check_preloaded_kernel();
}
- if (boot_device == 'c') {
- oldworld_boot();
- }
-
update_nvram();
}
diff -Nru openbios-ppc-1.0+svn1060/arch/ppc/qemu/ofmem.c openbios-ppc-1.1/arch/ppc/qemu/ofmem.c
--- openbios-ppc-1.0+svn1060/arch/ppc/qemu/ofmem.c 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/arch/ppc/qemu/ofmem.c 2013-05-06 19:09:54.000000000 +0000
@@ -311,10 +311,32 @@
return phys;
}
+/* Converts a global variable (from .data or .bss) into a pointer that
+ can be accessed from real mode */
+static void *
+global_ptr_real(void *p)
+{
+ return (void*)((uintptr_t)p - OF_CODE_START + get_rom_base());
+}
+
+/* Return the next slot to evict, in the range of [0..7] */
+static int
+next_evicted_slot(void)
+{
+ static int next_grab_slot;
+ int *next_grab_slot_va;
+ int r;
+
+ next_grab_slot_va = global_ptr_real(&next_grab_slot);
+ r = *next_grab_slot_va;
+ *next_grab_slot_va = (r + 1) % 8;
+
+ return r;
+}
+
static void
hash_page_64(unsigned long ea, phys_addr_t phys, ucell mode)
{
- static int next_grab_slot = 0;
uint64_t vsid_mask, page_mask, pgidx, hash;
uint64_t htab_mask, mask, avpn;
unsigned long pgaddr;
@@ -349,10 +371,8 @@
found = 1;
/* out of slots, just evict one */
- if (!found) {
- i = next_grab_slot + 1;
- next_grab_slot = (next_grab_slot + 1) % 8;
- }
+ if (!found)
+ i = next_evicted_slot() + 1;
i--;
{
mPTE_64_t p = {
@@ -381,7 +401,6 @@
hash_page_32(unsigned long ea, phys_addr_t phys, ucell mode)
{
#ifndef __powerpc64__
- static int next_grab_slot = 0;
unsigned long *upte, cmp, hash1;
int i, vsid, found;
mPTE_t *pp;
@@ -407,10 +426,8 @@
found = 1;
/* out of slots, just evict one */
- if (!found) {
- i = next_grab_slot + 1;
- next_grab_slot = (next_grab_slot + 1) % 8;
- }
+ if (!found)
+ i = next_evicted_slot() + 1;
i--;
upte[i * 2] = cmp;
upte[i * 2 + 1] = (phys & ~0xfff) | mode;
@@ -532,11 +549,22 @@
{
ofmem_t *ofmem = ofmem_arch_get_private();
- ofmem_claim_phys(0, get_ram_bottom(), 0);
- ofmem_claim_virt(0, get_ram_bottom(), 0);
- ofmem_map(0, 0, get_ram_bottom(), 0);
-
- ofmem_claim_phys(get_ram_top(), ofmem->ramsize - get_ram_top(), 0);
- ofmem_claim_virt(get_ram_top(), ofmem->ramsize - get_ram_top(), 0);
- ofmem_map(get_ram_top(), get_ram_top(), ofmem->ramsize - get_ram_top(), 0);
+ /* Map the memory (don't map page 0 to allow catching of NULL dereferences) */
+ ofmem_claim_phys(PAGE_SIZE, get_ram_bottom() - PAGE_SIZE, 0);
+ ofmem_claim_virt(PAGE_SIZE, get_ram_bottom() - PAGE_SIZE, 0);
+ ofmem_map(PAGE_SIZE, PAGE_SIZE, get_ram_bottom() - PAGE_SIZE, 0);
+
+ /* Mark the first page as non-free */
+ ofmem_claim_phys(0, PAGE_SIZE, 0);
+ ofmem_claim_virt(0, PAGE_SIZE, 0);
+
+ /* Map everything at the top of physical RAM 1:1, minus the OpenBIOS ROM in RAM copy */
+ ofmem_claim_phys(get_ram_top(), get_hash_base() + HASH_SIZE - get_ram_top(), 0);
+ ofmem_claim_virt(get_ram_top(), get_hash_base() + HASH_SIZE - get_ram_top(), 0);
+ ofmem_map(get_ram_top(), get_ram_top(), get_hash_base() + HASH_SIZE - get_ram_top(), 0);
+
+ /* Map the OpenBIOS ROM in RAM copy */
+ ofmem_claim_phys(ofmem->ramsize - OF_CODE_SIZE, OF_CODE_SIZE, 0);
+ ofmem_claim_virt(OF_CODE_START, OF_CODE_SIZE, 0);
+ ofmem_map(ofmem->ramsize - OF_CODE_SIZE, OF_CODE_START, OF_CODE_SIZE, 0);
}
diff -Nru openbios-ppc-1.0+svn1060/arch/ppc/qemu/qemu.fs openbios-ppc-1.1/arch/ppc/qemu/qemu.fs
--- openbios-ppc-1.0+svn1060/arch/ppc/qemu/qemu.fs 2010-07-31 04:23:45.000000000 +0000
+++ openbios-ppc-1.1/arch/ppc/qemu/qemu.fs 2013-05-06 19:09:54.000000000 +0000
@@ -46,6 +46,39 @@
then
;
+variable keyboard-phandle 0 keyboard-phandle !
+
+: (find-keyboard-device) ( phandle -- )
+ recursive
+ keyboard-phandle @ 0= if \ Return first match
+ >dn.child @
+ begin ?dup while
+ dup dup " device_type" rot get-package-property 0= if
+ drop dup cstrlen
+ " keyboard" strcmp 0= if
+ dup to keyboard-phandle
+ then
+ then
+ (find-keyboard-device)
+ >dn.peer @
+ repeat
+ else
+ drop
+ then
+;
+
+\ create the keyboard devalias
+:noname
+ device-tree @ (find-keyboard-device)
+ keyboard-phandle @ if
+ active-package
+ " /aliases" find-device
+ keyboard-phandle @ get-package-path
+ encode-string " keyboard" property
+ active-package!
+ then
+; SYSTEM-initializer
+
\ -------------------------------------------------------------------------
\ pre-booting
\ -------------------------------------------------------------------------
diff -Nru openbios-ppc-1.0+svn1060/arch/ppc/qemu/start.S openbios-ppc-1.1/arch/ppc/qemu/start.S
--- openbios-ppc-1.0+svn1060/arch/ppc/qemu/start.S 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/arch/ppc/qemu/start.S 2013-05-06 19:09:54.000000000 +0000
@@ -295,8 +295,15 @@
exception_return:
EXCEPTION_EPILOGUE
-_GLOBAL(__divide_error):
trap_error:
+ lis r1, 0x8000 /* r1=0x80000000 */
+ add. r1,r1,r1 /* r1=r1+r1 (high 32bit !0) */
+ beq 1f
+
+ mfmsr r1 /* unset MSR_SF */
+ clrldi r1,r1,1
+ mtmsrd r1
+1:
mflr r3
LOAD_REG_FUNC(r4, unexpected_excep)
mtctr r4
diff -Nru openbios-ppc-1.0+svn1060/arch/sparc32/entry.S openbios-ppc-1.1/arch/sparc32/entry.S
--- openbios-ppc-1.0+svn1060/arch/sparc32/entry.S 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/arch/sparc32/entry.S 2013-05-06 19:09:54.000000000 +0000
@@ -452,6 +452,7 @@
wr %g3, PSR_ET, %psr
WRITE_PAUSE
+ set 0, %fp
call __switch_context_nosave
nop
diff -Nru openbios-ppc-1.0+svn1060/arch/sparc32/init.fs openbios-ppc-1.1/arch/sparc32/init.fs
--- openbios-ppc-1.0+svn1060/arch/sparc32/init.fs 2009-03-08 13:07:58.000000000 +0000
+++ openbios-ppc-1.1/arch/sparc32/init.fs 2013-05-06 19:09:54.000000000 +0000
@@ -32,7 +32,7 @@
\ preopen device nodes (and store the ihandles under /chosen)
:noname
" memory" " /memory" preopen
- " mmu" " /cpus/@0" preopen
+ " mmu" " /virtual-memory" preopen
; SYSTEM-initializer
device-end
diff -Nru openbios-ppc-1.0+svn1060/arch/sparc32/lib.c openbios-ppc-1.1/arch/sparc32/lib.c
--- openbios-ppc-1.0+svn1060/arch/sparc32/lib.c 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/arch/sparc32/lib.c 2013-05-06 19:09:54.000000000 +0000
@@ -269,6 +269,8 @@
phys_addr_t phys;
ucell virt;
+ DPRINTF("obp_memalloc: virta 0x%x, sz %d, align %d\n", (unsigned int)va, size, align);
+
/* Claim physical memory */
phys = ofmem_claim_phys(-1, size, align);
@@ -283,26 +285,14 @@
char *obp_dumb_memalloc(char *va, unsigned int size)
{
- unsigned long align;
- int i;
+ unsigned long align = size;
+
+ DPRINTF("obp_dumb_memalloc: virta 0x%x, sz %d\n", (unsigned int)va, size);
+
+ /* Solaris seems to assume that the returned value is physically aligned to size.
+ e.g. it is used for setting up page tables. Fortunately this is now handled by
+ ofmem_claim_phys() above. */
- /* Solaris seems to assume that the returned value is physically aligned to size. For
- example, not having this here causes the Solaris 8 kernel to fault because the
- IOMMU page table base address is calculated incorrectly. */
-
- /* Enforce a minimum alignment of CONFIG_OFMEM_MALLOC_ALIGN, and choose an alignment
- which is the next power of 2 higher than the specified size */
- align = size;
- if (align <= CONFIG_OFMEM_MALLOC_ALIGN) {
- align = CONFIG_OFMEM_MALLOC_ALIGN;
- } else {
- align--;
- for (i = 1; i < sizeof(unsigned long) * 8; i<<=1) {
- align |= align >> i;
- }
- align++;
- }
-
return obp_memalloc(va, size, align);
}
@@ -401,9 +391,11 @@
size = (unsigned long)&_end - (unsigned long)&_start;
pa = va2pa(va);
ofmem_arch_map_pages(pa, va, size, ofmem_arch_default_translation_mode(pa));
+ ofmem_map_page_range(pa, va, size, ofmem_arch_default_translation_mode(pa));
- // 1:1 mapping for RAM
- ofmem_arch_map_pages(0, 0, LOWMEMSZ, ofmem_arch_default_translation_mode(0));
+ // 1:1 mapping for RAM (don't map page 0 to allow catching of NULL dereferences)
+ ofmem_arch_map_pages(PAGE_SIZE, PAGE_SIZE, LOWMEMSZ - PAGE_SIZE, ofmem_arch_default_translation_mode(0));
+ ofmem_map_page_range(PAGE_SIZE, PAGE_SIZE, LOWMEMSZ - PAGE_SIZE, ofmem_arch_default_translation_mode(0));
/*
* Flush cache
diff -Nru openbios-ppc-1.0+svn1060/arch/sparc32/ofmem_sparc32.c openbios-ppc-1.1/arch/sparc32/ofmem_sparc32.c
--- openbios-ppc-1.0+svn1060/arch/sparc32/ofmem_sparc32.c 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/arch/sparc32/ofmem_sparc32.c 2013-05-06 19:09:54.000000000 +0000
@@ -61,7 +61,7 @@
ucell ofmem_arch_get_virt_top(void)
{
- return (ucell)TOP_OF_RAM;
+ return (ucell)OFMEM_VIRT_TOP;
}
phys_addr_t ofmem_arch_get_phys_top(void)
@@ -238,6 +238,9 @@
memset(&s_ofmem_data, 0, sizeof(s_ofmem_data));
s_ofmem_data.ofmem.ramsize = qemu_mem_size;
+ /* Mark the first page as non-free */
+ ofmem_claim_virt(0, PAGE_SIZE, 0);
+
/* Claim reserved physical addresses at top of RAM */
ofmem_claim_phys(ofmem_arch_get_phys_top(), s_ofmem_data.ofmem.ramsize - ofmem_arch_get_phys_top(), 0);
diff -Nru openbios-ppc-1.0+svn1060/arch/sparc32/openbios.c openbios-ppc-1.1/arch/sparc32/openbios.c
--- openbios-ppc-1.0+svn1060/arch/sparc32/openbios.c 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/arch/sparc32/openbios.c 2013-05-06 19:09:54.000000000 +0000
@@ -25,9 +25,9 @@
#include "packages/video.h"
#define NO_QEMU_PROTOS
#include "arch/common/fw_cfg.h"
-#include "libopenbios/ofmem.h"
+#include "arch/sparc32/ofmem_sparc32.h"
-#define MEMORY_SIZE (512*1024) /* 512K ram for hosted system */
+#define MEMORY_SIZE (128*1024) /* 128K ram for hosted system */
#define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
#define FW_CFG_SUN4M_DEPTH (FW_CFG_ARCH_LOCAL + 0x00)
@@ -244,9 +244,9 @@
.iu_version = 0x04 << 24, /* Impl 0, ver 4 */
.name = "FMI,MB86904",
.psr_impl = 0,
- .psr_vers = 5,
+ .psr_vers = 4,
.impl = 0,
- .vers = 5,
+ .vers = 4,
.dcache_line_size = 0x10,
.dcache_lines = 0x200,
.dcache_assoc = 1,
@@ -813,7 +813,7 @@
if (!phys)
printk("panic: not enough physical memory on host system.\n");
- virt = ofmem_claim_virt(-1, MEMORY_SIZE, PAGE_SIZE);
+ virt = ofmem_claim_virt(OF_CODE_START - MEMORY_SIZE, MEMORY_SIZE, 0);
if (!virt)
printk("panic: not enough virtual memory on host system.\n");
@@ -832,8 +832,7 @@
static void
arch_init( void )
{
- static char cmdline[128];
- int size = 0;
+ char *cmdline;
const char *kernel_cmdline;
uint32_t temp;
uint16_t machine_id;
@@ -894,11 +893,11 @@
kernel_cmdline = (const char *) fw_cfg_read_i32(FW_CFG_KERNEL_CMDLINE);
if (kernel_cmdline) {
- size = strlen(kernel_cmdline);
- memcpy(cmdline, kernel_cmdline, size);
+ cmdline = strdup(kernel_cmdline);
obp_arg.argv[1] = cmdline;
- }
- cmdline[size] = '\0';
+ } else {
+ cmdline = strdup("");
+ }
qemu_cmdline = (uint32_t)cmdline;
/* Setup nvram variables */
diff -Nru openbios-ppc-1.0+svn1060/arch/sparc32/wuf.S openbios-ppc-1.1/arch/sparc32/wuf.S
--- openbios-ppc-1.0+svn1060/arch/sparc32/wuf.S 2009-03-08 13:07:58.000000000 +0000
+++ openbios-ppc-1.1/arch/sparc32/wuf.S 2013-05-06 19:09:54.000000000 +0000
@@ -131,6 +131,7 @@
/* LOCATION: Window 'O' */
restore %g0, %g0, %g0
+ WRITE_PAUSE
/* LOCATION: Window 'W' */
diff -Nru openbios-ppc-1.0+svn1060/arch/sparc64/openbios.c openbios-ppc-1.1/arch/sparc64/openbios.c
--- openbios-ppc-1.0+svn1060/arch/sparc64/openbios.c 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/arch/sparc64/openbios.c 2013-05-06 19:09:54.000000000 +0000
@@ -42,9 +42,6 @@
#define NVRAM_OB_START (0)
#define NVRAM_OB_SIZE ((0x1fd0 - NVRAM_OB_START) & ~15)
-#define OBIO_CMDLINE_MAX 256
-static char obio_cmdline[OBIO_CMDLINE_MAX];
-
static uint8_t idprom[NVRAM_IDPROM_SIZE];
struct hwdef {
@@ -370,6 +367,7 @@
void arch_nvram_get(char *data)
{
+ char *obio_cmdline;
uint32_t size = 0;
const struct cpudef *cpu;
char buf[256];
@@ -401,12 +399,13 @@
kernel_image = fw_cfg_read_i64(FW_CFG_KERNEL_ADDR);
size = fw_cfg_read_i32(FW_CFG_CMDLINE_SIZE);
- if (size > OBIO_CMDLINE_MAX - 1)
- size = OBIO_CMDLINE_MAX - 1;
if (size) {
+ obio_cmdline = (char *)malloc(size + 1);
fw_cfg_read(FW_CFG_CMDLINE_DATA, obio_cmdline, size);
+ obio_cmdline[size] = '\0';
+ } else {
+ obio_cmdline = strdup("");
}
- obio_cmdline[size] = '\0';
qemu_cmdline = (uint64_t)obio_cmdline;
cmdline_size = size;
boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
@@ -548,6 +547,9 @@
void udelay(unsigned int usecs)
{
+ volatile int i;
+
+ for (i = 0; i < usecs * 100; i++);
}
static void init_memory(void)
diff -Nru openbios-ppc-1.0+svn1060/config/examples/ppc_config.xml openbios-ppc-1.1/config/examples/ppc_config.xml
--- openbios-ppc-1.0+svn1060/config/examples/ppc_config.xml 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/config/examples/ppc_config.xml 2013-05-06 19:09:54.000000000 +0000
@@ -26,6 +26,7 @@
+
@@ -60,6 +61,7 @@
+
diff -Nru openbios-ppc-1.0+svn1060/config/scripts/switch-arch openbios-ppc-1.1/config/scripts/switch-arch
--- openbios-ppc-1.0+svn1060/config/scripts/switch-arch 2012-01-04 09:41:45.000000000 +0000
+++ openbios-ppc-1.1/config/scripts/switch-arch 2013-05-06 19:09:54.000000000 +0000
@@ -97,7 +97,7 @@
select_prefix()
{
- for TARGET in ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi-
+ for TARGET in ${1}-unknown-linux-gnu- ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi-
do
if type ${TARGET}gcc > /dev/null 2>&1
then
@@ -117,21 +117,18 @@
echo ""
}
-if ! test -f utils/dist/debian/rules; then
- echo "switch-arch must be run from the top-level source directory" >&2
- exit 1
-fi
-# This is needed because viewvc messes with the permissions of executables:
-chmod 755 utils/dist/debian/rules
-chmod 755 config/scripts/switch-arch
-chmod 755 config/scripts/reldir
+SRCDIR=`dirname "$0"`/../..
+BUILDDIR=`pwd`
+
+# make source path absolute
+SRCDIR=`cd "$SRCDIR"; pwd`
if test "x$HOSTARCH" = "x"; then
archname
fi
-VERSION=`head VERSION`
+VERSION=`head $SRCDIR/VERSION`
echo "Configuring OpenBIOS on $HOSTARCH for $*"
@@ -156,8 +153,8 @@
arch_list=""
for target in $target_list; do
arch=`echo $target | sed s/.*-//g`
- if ! test -f config/examples/${arch}_config.xml; then
- echo "Cannot find config/examples/${arch}_config.xml" >&2
+ if ! test -f $SRCDIR/config/examples/${arch}_config.xml; then
+ echo "Cannot find $SRCDIR/config/examples/${arch}_config.xml" >&2
exit 1
fi
if ! echo $arch_list | grep -q "$arch"; then
@@ -232,11 +229,12 @@
ppc)
select_prefix powerpc
if [ "$unix" = "no" ]; then
- CFLAGS="-msoft-float -fno-builtin-bcopy -fno-builtin-log2"
+ CFLAGS="-m32 -msoft-float -fno-builtin-bcopy -fno-builtin-log2"
+ AS_FLAGS="-m32"
else
CFLAGS="-fno-builtin"
+ AS_FLAGS=
fi
- AS_FLAGS=
;;
ppc64)
@@ -268,7 +266,8 @@
cross="yes"
fi
crosscflags $HOSTARCH $ARCH
- OBJDIR=obj-$ARCH
+ OBJDIR=$BUILDDIR/obj-$ARCH
+ ODIRS="$ODIRS $OBJDIR"
printf "Initializing build tree $OBJDIR..."
rm -rf "$OBJDIR"
@@ -293,9 +292,9 @@
mkdir -p $OBJDIR/host/include
mkdir -p $OBJDIR/host/kernel
mkdir -p $OBJDIR/forth
- ln -s ../../../include/arch/$BASEARCH $OBJDIR/target/include/asm
+ ln -s $SRCDIR/include/arch/$BASEARCH $OBJDIR/target/include/asm
#compile the host binary with target settings instead
- #ln -s ../../../include/arch/$HOSTARCH $OBJDIR/host/include/asm
+ #ln -s $SRCDIR/include/arch/$HOSTARCH $OBJDIR/host/include/asm
if [ "$mol" = "yes" ]; then
printf "\nUsing MOL path $MOLPATH...\n"
mkdir -p $OBJDIR/target/arch/ppc/mol
@@ -323,11 +322,9 @@
fi
echo "ok."
- cd $OBJDIR
- SRCDIR=..
- ODIR=.
+ ODIR=$OBJDIR
- printf "Creating target Makefile..."
+ printf "Creating target config.mak..."
echo "ARCH=$ARCH" > $ODIR/config.mak
if [ "$cross" = "yes" ]; then
echo "TARGET=$TARGET" >> $ODIR/config.mak
@@ -337,7 +334,10 @@
echo "HOSTARCH?=$HOSTARCH" >> $ODIR/config.mak
echo "CROSSCFLAGS=$CROSSCFLAGS" >> $ODIR/config.mak
echo "VERSION=\"$VERSION\"" >> $ODIR/config.mak
+ echo "SRCDIR=$SRCDIR" >> $ODIR/config.mak
+ echo "ok."
+ printf "Creating target rules.mak..."
ln -s $SRCDIR/config/xml/rules.xml $ODIR/rules.xml
echo "" > $ODIR/config.xml
# Generic
@@ -380,8 +380,9 @@
fi
cat $SRCDIR/config/examples/${ARCH}_config.xml >> $ODIR/config.xml
+ cd $ODIR
echo "" >> $ODIR/config.xml
- ln -s ../Makefile.target $ODIR/Makefile
+ ln -s $SRCDIR/Makefile.target $ODIR/Makefile
xsltproc $SRCDIR/config/xml/xinclude.xsl $SRCDIR/build.xml > $ODIR/build-full.xml
xsltproc $SRCDIR/config/xml/makefile.xsl $ODIR/build-full.xml > $ODIR/rules.mak
echo "ok."
@@ -391,5 +392,12 @@
xsltproc $SRCDIR/config/xml/config-forth.xsl $ODIR/config.xml > $ODIR/forth/config.fs
echo "ok."
- cd $SRCDIR
+ cd $BUILDDIR
done
+
+if [ "$SRCDIR" != "$BUILDDIR" ]; then
+ ln -s $SRCDIR/Makefile $BUILDDIR
+fi
+
+echo "ODIRS=$ODIRS" >> $BUILDDIR/config-host.mak
+echo "TARGETS=$arch_list" >> $BUILDDIR/config-host.mak
diff -Nru openbios-ppc-1.0+svn1060/config/xml/dictionary.xsl openbios-ppc-1.1/config/xml/dictionary.xsl
--- openbios-ppc-1.0+svn1060/config/xml/dictionary.xsl 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/config/xml/dictionary.xsl 2013-05-06 19:09:54.000000000 +0000
@@ -56,7 +56,6 @@
-DICTIONARY:=$(
-DICTIONARY)
- $(SRCDIR)/
@@ -122,6 +121,8 @@
+
+ -I$(SRCDIR)
-I$(ODIR)/forth
diff -Nru openbios-ppc-1.0+svn1060/config/xml/object.xsl openbios-ppc-1.1/config/xml/object.xsl
--- openbios-ppc-1.0+svn1060/config/xml/object.xsl 2009-12-05 10:17:26.000000000 +0000
+++ openbios-ppc-1.1/config/xml/object.xsl 2013-05-06 19:09:54.000000000 +0000
@@ -52,7 +52,6 @@
.o:
- $(SRCDIR)/
diff -Nru openbios-ppc-1.0+svn1060/debian/changelog openbios-ppc-1.1/debian/changelog
--- openbios-ppc-1.0+svn1060/debian/changelog 2013-03-15 22:37:40.000000000 +0000
+++ openbios-ppc-1.1/debian/changelog 2013-05-26 12:10:00.000000000 +0000
@@ -1,3 +1,23 @@
+openbios-ppc (1.1-1ubuntu1) saucy; urgency=low
+
+ * Merge from Debian unstable; remaining changes:
+ - Build-dep on a PowerPC cross-compiler, so we cross-build on non-PPC.
+ * Limit cross-compiler build-dep to [!powerpc] so we build on PPC too.
+
+ -- Adam Conrad Sun, 26 May 2013 05:59:39 -0600
+
+openbios-ppc (1.1-1) unstable; urgency=low
+
+ * New upstream version for QEMU 1.5.x releases.
+ * Refresh debian/patches/01_kernel-headers.diff.
+ * Switch maintainer to the Debian QEMU Team, add myself as uploader.
+ * Add Vcs-* field.
+ * Switch to debhelper compatibility level 7.
+ * Use dh_prep instead of dh_clean -k.
+ * Compress sources and binaries with xz.
+
+ -- Aurelien Jarno Mon, 06 May 2013 21:41:01 +0200
+
openbios-ppc (1.0+svn1060-1ubuntu2) raring; urgency=low
* Swap binary-arch and binary-indep rules back and make us arch:all again.
@@ -104,4 +124,3 @@
unneeded directories.
-- Aurelien Jarno Fri, 09 Jan 2009 09:44:18 +0100
-
diff -Nru openbios-ppc-1.0+svn1060/debian/compat openbios-ppc-1.1/debian/compat
--- openbios-ppc-1.0+svn1060/debian/compat 2012-11-03 18:46:16.000000000 +0000
+++ openbios-ppc-1.1/debian/compat 2013-05-06 19:40:56.000000000 +0000
@@ -1 +1 @@
-5
+7
diff -Nru openbios-ppc-1.0+svn1060/debian/control openbios-ppc-1.1/debian/control
--- openbios-ppc-1.0+svn1060/debian/control 2013-03-15 22:27:55.000000000 +0000
+++ openbios-ppc-1.1/debian/control 2013-05-26 12:08:49.000000000 +0000
@@ -1,11 +1,14 @@
Source: openbios-ppc
Maintainer: Ubuntu Developers
-XSBC-Original-Maintainer: Aurelien Jarno
+XSBC-Original-Maintainer: Debian QEMU Team
+Uploaders: Aurelien Jarno
Section: misc
Priority: extra
-Build-Depends: debhelper (>= 6.0.7), fcode-utils, xsltproc, gcc-powerpc-linux-gnu
+Build-Depends: debhelper (>= 7), fcode-utils, xsltproc, gcc-powerpc-linux-gnu [!powerpc]
Standards-Version: 3.9.3
Homepage: http://www.openbios.org/
+Vcs-Browser: http://git.debian.org/?p=pkg-qemu/openbios-ppc.git
+Vcs-Git: git://git.debian.org/git/pkg-qemu/openbios-ppc.git
Package: openbios-ppc
Architecture: all
diff -Nru openbios-ppc-1.0+svn1060/debian/patches/01_kernel-headers.diff openbios-ppc-1.1/debian/patches/01_kernel-headers.diff
--- openbios-ppc-1.0+svn1060/debian/patches/01_kernel-headers.diff 2012-11-03 18:46:16.000000000 +0000
+++ openbios-ppc-1.1/debian/patches/01_kernel-headers.diff 2013-05-06 19:26:38.000000000 +0000
@@ -1,6 +1,10 @@
---- openbios-ppc-1.0+svn1018.orig/include/arch/ppc/types.h
-+++ openbios-ppc-1.0+svn1018/include/arch/ppc/types.h
-@@ -75,4 +75,10 @@ typedef short s16;
+---
+ include/arch/ppc/types.h | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/include/arch/ppc/types.h
++++ b/include/arch/ppc/types.h
+@@ -91,4 +91,10 @@
typedef int s32;
typedef long long s64;
diff -Nru openbios-ppc-1.0+svn1060/debian/rules openbios-ppc-1.1/debian/rules
--- openbios-ppc-1.0+svn1060/debian/rules 2013-03-15 22:41:32.000000000 +0000
+++ openbios-ppc-1.1/debian/rules 2013-05-26 12:13:19.000000000 +0000
@@ -27,7 +27,7 @@
build-indep-stamp:
dh_testdir
- config/scripts/switch-arch cross-ppc
+ config/scripts/switch-arch builtin-ppc
cd obj-ppc && $(MAKE) all
touch build-indep-stamp
@@ -43,7 +43,7 @@
install: build-indep
dh_testdir
dh_testroot
- dh_clean -k
+ dh_prep
dh_installdirs
mkdir -p $(CURDIR)/debian/openbios-ppc/usr/share/openbios
@@ -64,7 +64,7 @@
dh_installdeb
dh_gencontrol
dh_md5sums
- dh_builddeb
+ dh_builddeb -- -Zxz
# Build architecture-dependent files here.
binary-arch: build-indep install
diff -Nru openbios-ppc-1.0+svn1060/debian/source/options openbios-ppc-1.1/debian/source/options
--- openbios-ppc-1.0+svn1060/debian/source/options 1970-01-01 00:00:00.000000000 +0000
+++ openbios-ppc-1.1/debian/source/options 2013-05-06 19:26:16.000000000 +0000
@@ -0,0 +1 @@
+compression = "xz"
diff -Nru openbios-ppc-1.0+svn1060/drivers/adb_kbd.c openbios-ppc-1.1/drivers/adb_kbd.c
--- openbios-ppc-1.0+svn1060/drivers/adb_kbd.c 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/drivers/adb_kbd.c 2013-05-06 19:09:54.000000000 +0000
@@ -42,11 +42,13 @@
}
static void keyboard_read(void);
+static void keyboard_getkeymap(void);
NODE_METHODS( keyboard ) = {
{ "open", keyboard_open },
{ "close", keyboard_close },
{ "read", keyboard_read },
+ { "get-key-map", keyboard_getkeymap },
};
/* VT100 escape sequences */
@@ -471,6 +473,7 @@
int next_key;
char sequence[ADB_MAX_SEQUENCE_LEN];
int len;
+ char keytable[32];
};
static adb_dev_t *my_adb_dev = NULL;
@@ -531,6 +534,21 @@
ADB_kbd_us, ADB_sequences);
kbd->next_key = -1;
kbd->len = 0;
+
+ /* Debugging BootX: the lines below force get-key-map to report that
+ * cmd-V is being held down, which forces BootX to run in verbose mode
+ * for debugging.
+ *
+ * TODO: if we can find a mapping between the get-key-map bitmap and
+ * ADB scancodes, the keyboard driver should be altered to update this
+ * accordingly.
+ */
+
+ /*
+ kbd->keytable[3] = 0x40;
+ kbd->keytable[28] = 0x10;
+ */
+
dev->state = kbd;
my_adb_dev = dev;
}
@@ -566,3 +584,12 @@
}
PUSH(i);
}
+
+/* ( -- keymap ) (?) */
+/* should return a pointer to an array with 32 bytes (256 bits) */
+static void keyboard_getkeymap(void)
+{
+ adb_kbd_t *kbd = my_adb_dev->state;
+
+ PUSH( pointer2cell(kbd->keytable) );
+}
diff -Nru openbios-ppc-1.0+svn1060/drivers/escc.c openbios-ppc-1.1/drivers/escc.c
--- openbios-ppc-1.0+svn1060/drivers/escc.c 2012-01-04 09:41:45.000000000 +0000
+++ openbios-ppc-1.1/drivers/escc.c 2013-05-06 19:09:54.000000000 +0000
@@ -131,7 +131,7 @@
/* ( addr len -- actual ) */
static void
-escc_read(phys_addr_t *address)
+escc_read(ucell *address)
{
char *addr;
int len;
@@ -152,7 +152,7 @@
/* ( addr len -- actual ) */
static void
-escc_write(phys_addr_t *address)
+escc_write(ucell *address)
{
unsigned char *addr;
int i, len;
@@ -172,7 +172,7 @@
}
static void
-escc_open(phys_addr_t *address)
+escc_open(ucell *address)
{
#ifdef CONFIG_DRIVER_ESCC_SUN
int len;
@@ -199,7 +199,7 @@
RET ( -1 );
}
-DECLARE_UNNAMED_NODE(escc, INSTALL_OPEN, sizeof(phys_addr_t));
+DECLARE_UNNAMED_NODE(escc, INSTALL_OPEN, sizeof(ucell));
NODE_METHODS(escc) = {
{ "open", escc_open },
@@ -305,7 +305,7 @@
}
}
-DECLARE_UNNAMED_NODE(escc_keyboard, INSTALL_OPEN, sizeof(phys_addr_t));
+DECLARE_UNNAMED_NODE(escc_keyboard, INSTALL_OPEN, sizeof(ucell));
NODE_METHODS(escc_keyboard) = {
{ "open", escc_open },
diff -Nru openbios-ppc-1.0+svn1060/drivers/esp.c openbios-ppc-1.1/drivers/esp.c
--- openbios-ppc-1.0+svn1060/drivers/esp.c 2012-01-04 09:41:45.000000000 +0000
+++ openbios-ppc-1.1/drivers/esp.c 2013-05-06 19:09:54.000000000 +0000
@@ -106,7 +106,7 @@
// Clear interrupts to avoid guests seeing spurious interrupts
(void)esp->ll->regs[ESP_INTRPT];
- DPRINTF("do_command: id %d, cmd[0] 0x%x, status 0x%x\n", sd->id, esp->buffer[0], status);
+ DPRINTF("do_command: id %d, cmd[0] 0x%x, status 0x%x\n", sd->id, esp->buffer[1], status);
/* Target didn't want all command data? */
if ((status & ESP_STAT_TCNT) != ESP_STAT_TCNT) {
@@ -197,11 +197,11 @@
test_unit_ready(esp_private_t *esp, sd_private_t *sd)
{
/* Setup command = Test Unit Ready */
- memset(esp->buffer, 0, 6);
+ memset(esp->buffer, 0, 7);
esp->buffer[0] = 0x80;
esp->buffer[1] = TEST_UNIT_READY;
- if (do_command(esp, sd, 6, 0)) {
+ if (do_command(esp, sd, 7, 0)) {
DPRINTF("test_unit_ready id %d failed\n", sd->id);
return 0;
}
diff -Nru openbios-ppc-1.0+svn1060/drivers/ide.c openbios-ppc-1.1/drivers/ide.c
--- openbios-ppc-1.0+svn1060/drivers/ide.c 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/drivers/ide.c 2013-05-06 19:09:54.000000000 +0000
@@ -1432,8 +1432,6 @@
props[0]=14; props[1]=0;
set_property(dnode, "interrupts",
(char *)&props, 2*sizeof(props[0]));
-#elif defined(CONFIG_SPARC64)
- set_int_property(get_cur_dev(), "interrupts", 0);
#endif
props[0] = __cpu_to_be32(chan->io_regs[0]);
@@ -1611,9 +1609,11 @@
}
props[1] = 0x00000000; /* XXX level triggered on real hw */
props[3] = 0x00000000;
- set_property(dnode, "interrupts",
- (char *)&props, 4*sizeof(props[0]));
- set_int_property(dnode, "#interrupt-cells", 2);
+ NEWWORLD(set_property(dnode, "interrupts",
+ (char *)&props, 4*sizeof(props[0])));
+ NEWWORLD(set_int_property(dnode, "#interrupt-cells", 2));
+
+ props[1] = props[2];
OLDWORLD(set_property(dnode, "AAPL,interrupts",
(char *)&props, 2*sizeof(props[0])));
diff -Nru openbios-ppc-1.0+svn1060/drivers/macio.c openbios-ppc-1.1/drivers/macio.c
--- openbios-ppc-1.0+svn1060/drivers/macio.c 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/drivers/macio.c 2013-05-06 19:09:54.000000000 +0000
@@ -57,12 +57,6 @@
} else {
nvram_offset = NW_IO_NVRAM_OFFSET;
nvram_size = NW_IO_NVRAM_SIZE;
- push_str("/");
- fword("find-device");
- fword("new-device");
- push_str("nvram");
- fword("device-name");
- fword("finish-device");
}
nvram = (char*)addr + nvram_offset;
snprintf(buf, sizeof(buf), "%s/nvram", path);
@@ -173,31 +167,41 @@
fword("finish-device");
- if (is_newworld()) {
- u32 *interrupt_map;
- int len, i;
-
- /* patch in interrupt parent */
- dnode = find_dev(buf);
-
- target_node = find_dev("/pci/mac-io");
- set_int_property(target_node, "interrupt-parent", dnode);
-
- target_node = find_dev("/pci/mac-io/escc/ch-a");
- set_int_property(target_node, "interrupt-parent", dnode);
-
- target_node = find_dev("/pci/mac-io/escc/ch-b");
- set_int_property(target_node, "interrupt-parent", dnode);
-
- target_node = find_dev("/pci");
- set_int_property(target_node, "interrupt-parent", dnode);
-
- interrupt_map = (u32 *)get_property(target_node, "interrupt-map", &len);
- for (i = 0; i < 4; i++) {
- interrupt_map[(i * 7) + PCI_INT_MAP_PIC_HANDLE] = (u32)dnode;
- }
- set_property(target_node, "interrupt-map", (char *)interrupt_map, len);
+ u32 *interrupt_map;
+ int len, i;
+
+ /* patch in interrupt parent */
+ dnode = find_dev(buf);
+
+ target_node = find_dev("/pci/mac-io");
+ set_int_property(target_node, "interrupt-parent", dnode);
+
+ target_node = find_dev("/pci/mac-io/escc/ch-a");
+ set_int_property(target_node, "interrupt-parent", dnode);
+
+ target_node = find_dev("/pci/mac-io/escc/ch-b");
+ set_int_property(target_node, "interrupt-parent", dnode);
+
+ target_node = find_dev("/pci/mac-io/ata-1");
+ set_int_property(target_node, "interrupt-parent", dnode);
+
+ target_node = find_dev("/pci/mac-io/ata-2");
+ set_int_property(target_node, "interrupt-parent", dnode);
+
+ target_node = find_dev("/pci/mac-io/ata-3");
+ set_int_property(target_node, "interrupt-parent", dnode);
+
+ target_node = find_dev("/pci/mac-io/via-cuda");
+ set_int_property(target_node, "interrupt-parent", dnode);
+
+ target_node = find_dev("/pci");
+ set_int_property(target_node, "interrupt-parent", dnode);
+
+ interrupt_map = (u32 *)get_property(target_node, "interrupt-map", &len);
+ for (i = 0; i < 8; i++) {
+ interrupt_map[(i * 7) + PCI_INT_MAP_PIC_HANDLE] = (u32)dnode;
}
+ set_property(target_node, "interrupt-map", (char *)interrupt_map, len);
}
DECLARE_NODE(ob_macio, INSTALL_OPEN, sizeof(int), "Tmac-io");
diff -Nru openbios-ppc-1.0+svn1060/drivers/pci.c openbios-ppc-1.1/drivers/pci.c
--- openbios-ppc-1.0+svn1060/drivers/pci.c 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/drivers/pci.c 2013-05-06 19:09:54.000000000 +0000
@@ -375,7 +375,7 @@
*/
#if defined(CONFIG_PPC)
phandle_t dev = get_cur_dev();
- u32 props[7 * 4];
+ u32 props[7 * 8];
int i;
#if defined(CONFIG_PPC)
@@ -384,7 +384,7 @@
return;
#endif
- for (i = 0; i < (7*4); i+=7) {
+ for (i = 0; i < (7*8); i+=7) {
props[i+PCI_INT_MAP_PCI0] = 0;
props[i+PCI_INT_MAP_PCI1] = 0;
props[i+PCI_INT_MAP_PCI2] = 0;
@@ -393,7 +393,7 @@
props[i+PCI_INT_MAP_PIC_INT] = arch->irqs[i / 7];
props[i+PCI_INT_MAP_PIC_POL] = 3;
}
- set_property(dev, "interrupt-map", (char *)props, 7 * 4 * sizeof(props[0]));
+ set_property(dev, "interrupt-map", (char *)props, 7 * 8 * sizeof(props[0]));
props[PCI_INT_MAP_PCI0] = 0;
props[PCI_INT_MAP_PCI1] = 0;
@@ -537,14 +537,6 @@
return 0;
}
-int virtio_config_cb(const pci_config_t *config)
-{
-#if defined(CONFIG_SPARC64)
- set_int_property(get_cur_dev(), "interrupts", 0);
-#endif
- return 0;
-}
-
int ide_config_cb2 (const pci_config_t *config)
{
ob_ide_init(config->path,
@@ -854,7 +846,14 @@
if (config->irq_pin) {
OLDWORLD(set_int_property(dev, "AAPL,interrupts",
config->irq_line));
- set_int_property(dev, "interrupts", config->irq_pin);
+#if defined(CONFIG_SPARC64)
+ /* direct mapping bssnn (Bus, Slot, interrupt Number */
+ set_int_property(get_cur_dev(), "interrupts",
+ ((((config->dev >> 11) << 2)
+ + config->irq_pin - 1) & 0x1f));
+#else
+ NEWWORLD(set_int_property(dev, "interrupts", config->irq_pin));
+#endif
}
set_int_property(dev, "min-grant", pci_config_read8(addr, PCI_MIN_GNT));
diff -Nru openbios-ppc-1.0+svn1060/drivers/pci_database.c openbios-ppc-1.1/drivers/pci_database.c
--- openbios-ppc-1.0+svn1060/drivers/pci_database.c 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/drivers/pci_database.c 2013-05-06 19:09:54.000000000 +0000
@@ -49,10 +49,10 @@
{
/* Virtio-block controller */
PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_BLOCK,
- NULL, "virtio-scsi", NULL,
+ NULL, "virtio-blk", NULL,
"pci1af4,1001\0pci1af4,1001\0pciclass,01018f\0",
0, 0, 0,
- virtio_config_cb, NULL,
+ NULL, NULL,
},
{
0xFFFF, 0xFFFF,
@@ -129,6 +129,14 @@
NULL, "ethernet",
},
{
+ /* Virtio-network controller */
+ PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_NET,
+ NULL, "virtio-net", NULL,
+ "pci1af4,1000\0pci1af4,1000\0pciclass,020000\0",
+ 0, 0, 0,
+ NULL, NULL,
+ },
+ {
0xFFFF, 0xFFFF,
NULL, NULL, NULL, NULL,
-1, -1, -1,
diff -Nru openbios-ppc-1.0+svn1060/drivers/pci_database.h openbios-ppc-1.1/drivers/pci_database.h
--- openbios-ppc-1.0+svn1060/drivers/pci_database.h 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/drivers/pci_database.h 2013-05-06 19:09:54.000000000 +0000
@@ -28,7 +28,6 @@
const void *private;
};
-extern int virtio_config_cb(const pci_config_t *config);
extern int ide_config_cb2(const pci_config_t *config);
extern int eth_config_cb(const pci_config_t *config);
extern int macio_heathrow_config_cb(const pci_config_t *config);
diff -Nru openbios-ppc-1.0+svn1060/forth/admin/iocontrol.fs openbios-ppc-1.1/forth/admin/iocontrol.fs
--- openbios-ppc-1.0+svn1060/forth/admin/iocontrol.fs 2009-03-08 13:07:58.000000000 +0000
+++ openbios-ppc-1.1/forth/admin/iocontrol.fs 2013-05-06 19:09:54.000000000 +0000
@@ -80,8 +80,11 @@
;
: io-emit ( char -- )
- io-out-char c!
- io-out-char 1 " write" stdout @ $call-method drop
+ stdout @ if
+ io-out-char c!
+ io-out-char 1 " write" stdout @ $call-method
+ then
+ drop
;
variable CONSOLE-IN-list
diff -Nru openbios-ppc-1.0+svn1060/forth/bootstrap/bootstrap.fs openbios-ppc-1.1/forth/bootstrap/bootstrap.fs
--- openbios-ppc-1.0+svn1060/forth/bootstrap/bootstrap.fs 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/forth/bootstrap/bootstrap.fs 2013-05-06 19:09:54.000000000 +0000
@@ -49,6 +49,10 @@
defer context
0 value vocabularies?
+defer locals-end
+0 value locals-dict
+variable locals-dict-buf
+
\
\ 7.3.7 Flag constants
\
@@ -925,6 +929,11 @@
;
: $find ( name-str name-len -- xt true | name-str name-len false )
+ locals-dict 0<> if
+ locals-dict-buf @ find-wordlist ?dup if
+ exit
+ then
+ then
vocabularies? if
#order @ 0 ?do
i cells context + @
@@ -1043,17 +1052,21 @@
3 /n* + !
then
;
-
-: to
- ['] ' execute
+
+: (to-xt) ( xt -- )
dup @ instance-cfa?
state @ if
swap ['] (lit) , , if ['] (ito) else ['] (to) then ,
else
if (ito) else /n + ! then
then
- ; immediate
+;
+: to
+ ['] ' execute
+ (to-xt)
+ ; immediate
+
: is ( xt "wordname<>" -- )
parse-word $find if
(to)
@@ -1426,6 +1439,10 @@
;
: ;
+ locals-dict 0<> if
+ 0 ['] locals-dict /n + !
+ ['] locals-end ,
+ then
['] (semis) , reveal ['] [ execute
; immediate
diff -Nru openbios-ppc-1.0+svn1060/forth/debugging/client.fs openbios-ppc-1.1/forth/debugging/client.fs
--- openbios-ppc-1.0+svn1060/forth/debugging/client.fs 2010-08-28 12:24:56.000000000 +0000
+++ openbios-ppc-1.1/forth/debugging/client.fs 2013-05-06 19:09:54.000000000 +0000
@@ -27,6 +27,9 @@
variable state-valid
0 state-valid !
+variable want-bootcode
+0 want-bootcode !
+
variable file-size
: !load-size file-size ! ;
@@ -44,6 +47,7 @@
5 constant aout
10 constant fcode
11 constant forth
+12 constant bootcode
: init-program ( -- )
@@ -126,12 +130,14 @@
: dir ( "{paths}" -- )
linefeed parse
- split-path-device
- open-dev dup 0= if
+ ascii , split-after
+ 2dup open-dev dup 0= if
drop
+ cr ." Unable to locate device " type
+ 2drop
exit
then
- -rot 2 pick
+ -rot 2drop -rot 2 pick
" dir" rot ['] $call-method catch
if
3drop
diff -Nru openbios-ppc-1.0+svn1060/forth/device/device.fs openbios-ppc-1.1/forth/device/device.fs
--- openbios-ppc-1.0+svn1060/forth/device/device.fs 2010-01-03 01:35:19.000000000 +0000
+++ openbios-ppc-1.1/forth/device/device.fs 2013-05-06 19:09:54.000000000 +0000
@@ -189,3 +189,14 @@
free-mem
then
;
+
+\ Redefine to word so that statements of the form "0 to active-package"
+\ are supported for bootloaders that require it
+: to
+ ['] ' execute
+ dup ['] active-package = if
+ drop active-package!
+ else
+ (to-xt)
+ then
+; immediate
diff -Nru openbios-ppc-1.0+svn1060/forth/device/pathres.fs openbios-ppc-1.1/forth/device/pathres.fs
--- openbios-ppc-1.0+svn1060/forth/device/pathres.fs 2012-01-04 09:41:45.000000000 +0000
+++ openbios-ppc-1.1/forth/device/pathres.fs 2013-05-06 19:09:54.000000000 +0000
@@ -177,28 +177,33 @@
\ 4.3.3 match child node
\
+\ used if package lacks a decode-unit method
+: def-decode-unit ( str len -- unitaddr ... )
+ parse-hex
+;
+
+: get-decode-unit-xt ( phandle -- xt )
+ " decode-unit" rot find-method
+ 0= if ['] def-decode-unit then
+;
+
: find-child ( sinfo -- phandle )
>r
\ decode unit address string
r@ >si.unit_addr 2@ dup if
( str len )
- " decode-unit" active-package find-method
- if
- depth 3 - >r execute depth r@ - r> swap
- ( ... a_lo ... a_hi olddepth n )
- 4 min 0 max
- dup r@ >si.unit_phys_len !
- ( ... a_lo ... a_hi olddepth n )
- r@ >si.unit_phys >r
- begin 1- dup 0>= while
- rot r> dup la1+ >r l!-be
- repeat
- r> 2drop
- depth!
- else
- \ no decode-unit method... failure
- -99 throw
- then
+ active-package get-decode-unit-xt
+ depth 3 - >r execute depth r@ - r> swap
+ ( ... a_lo ... a_hi olddepth n )
+ 4 min 0 max
+ dup r@ >si.unit_phys_len !
+ ( ... a_lo ... a_hi olddepth n )
+ r@ >si.unit_phys >r
+ begin 1- dup 0>= while
+ rot r> dup la1+ >r l!-be
+ repeat
+ r> 2drop
+ depth!
else
2drop
\ clear unit_phys
diff -Nru openbios-ppc-1.0+svn1060/forth/device/tree.fs openbios-ppc-1.1/forth/device/tree.fs
--- openbios-ppc-1.0+svn1060/forth/device/tree.fs 2010-01-03 01:35:19.000000000 +0000
+++ openbios-ppc-1.1/forth/device/tree.fs 2013-05-06 19:09:54.000000000 +0000
@@ -53,8 +53,6 @@
0 encode-int " stdout" property
\ " hda1:/boot/vmunix" encode-string " bootpath" property
\ " -as" encode-string " bootargs" property
- 0 encode-int " memory" property
- 0 encode-int " mmu" property
finish-device
\ END
diff -Nru openbios-ppc-1.0+svn1060/forth/lib/build.xml openbios-ppc-1.1/forth/lib/build.xml
--- openbios-ppc-1.0+svn1060/forth/lib/build.xml 2009-12-05 10:17:27.000000000 +0000
+++ openbios-ppc-1.1/forth/lib/build.xml 2013-05-06 19:09:54.000000000 +0000
@@ -16,6 +16,7 @@
+
diff -Nru openbios-ppc-1.0+svn1060/forth/lib/locals.fs openbios-ppc-1.1/forth/lib/locals.fs
--- openbios-ppc-1.0+svn1060/forth/lib/locals.fs 1970-01-01 00:00:00.000000000 +0000
+++ openbios-ppc-1.1/forth/lib/locals.fs 2013-05-06 19:09:54.000000000 +0000
@@ -0,0 +1,197 @@
+\ tag: local variables
+\
+\ Copyright (C) 2012 Mark Cave-Ayland
+\
+\ See the file "COPYING" for further information about
+\ the copyright and warranty status of this work.
+\
+
+[IFDEF] CONFIG_LOCALS
+
+\ Init local variable stack
+variable locals-var-stack
+here 200 cells allot locals-var-stack !
+
+\ Set initial stack pointer
+\
+\ Stack looks like this:
+\ ... (sp n-2) local1 ... localm-1 localm (sp n-1) <-- sp
+
+locals-var-stack @ value locals-var-sp
+locals-var-sp locals-var-stack @ !
+
+0 value locals-var-count
+0 value locals-flags
+
+here 200 cells allot locals-dict-buf !
+
+8 constant #locals
+
+: (local1) locals-var-sp @ /n + ;
+: (local2) locals-var-sp @ 2 cells + ;
+: (local3) locals-var-sp @ 3 cells + ;
+: (local4) locals-var-sp @ 4 cells + ;
+: (local5) locals-var-sp @ 5 cells + ;
+: (local6) locals-var-sp @ 6 cells + ;
+: (local7) locals-var-sp @ 7 cells + ;
+: (local8) locals-var-sp @ 8 cells + ;
+
+: local1@ (local1) @ ;
+: local2@ (local2) @ ;
+: local3@ (local3) @ ;
+: local4@ (local4) @ ;
+: local5@ (local5) @ ;
+: local6@ (local6) @ ;
+: local7@ (local7) @ ;
+: local8@ (local8) @ ;
+
+: local1! (local1) ! ;
+: local2! (local2) ! ;
+: local3! (local3) ! ;
+: local4! (local4) ! ;
+: local5! (local5) ! ;
+: local6! (local6) ! ;
+: local7! (local7) ! ;
+: local8! (local8) ! ;
+
+create locals-read-table
+['] local1@ ,
+['] local2@ ,
+['] local3@ ,
+['] local4@ ,
+['] local5@ ,
+['] local6@ ,
+['] local7@ ,
+['] local8@ ,
+
+create locals-write-table
+['] local1! ,
+['] local2! ,
+['] local3! ,
+['] local4! ,
+['] local5! ,
+['] local6! ,
+['] local7! ,
+['] local8! ,
+
+
+: locals-push ( n -- )
+ locals-var-sp /n + to locals-var-sp
+ locals-var-sp !
+;
+
+: locals-0-push ( -- )
+ 0 locals-push
+;
+
+: (apply-local-flags) ( lfa -- )
+ 1 - dup c@ locals-flags or swap c!
+;
+
+: locals-no-pop? ( lfa -- ? )
+ 1 - c@ 8 and 0<>
+;
+
+: locals-drop \ Destroy current stack frame
+ locals-var-sp @ to locals-var-sp
+;
+
+['] locals-drop to locals-end
+
+: (local-init) ( str len -- )
+ header 1 , \ DOCOL
+ ['] (lit) , ['] noop , \ read-xt
+ ['] (lit) , ['] noop , \ write-xt
+ ['] 2drop , \ do nothing
+ ['] (lit) ,
+ here 5 cells - ,
+ ['] @ , ['] , , \ store read-xt
+ ['] (semis) ,
+ reveal
+ immediate
+ last @ (apply-local-flags)
+;
+
+: (local-noop) ( str len -- )
+ 2drop
+;
+
+\ Word called when consuming a local variable
+defer (local)
+
+: } ( C: current latest here -- )
+ here! latest ! current ! \ Switch back to normal dict
+ locals-dict-buf @ to locals-dict \ Make locals-dict visible to $find
+ 0 to locals-var-count
+ ['] locals-var-sp , \ save previous sp on rstack
+ ['] >r ,
+ locals-dict @ \ ( last -- )
+ begin
+ ?dup 0<>
+ while
+ >r
+ locals-var-count /n *
+ locals-read-table + @ r@ 3 cells + ! \ set read-xt
+ locals-var-count /n *
+ locals-write-table + @ r@ 5 cells + ! \ set write-xt
+ locals-var-count 1+ to locals-var-count
+ r@ locals-no-pop? if
+ ['] locals-0-push , \ initialise with 0
+ else
+ ['] locals-push , \ initialise from stack
+ then
+ r> @ \ next lfa
+ repeat
+ ['] r> ,
+ ['] locals-push , \ write previous sp
+; immediate
+
+: { ( C: -- current latest here )
+ current @ latest @ here
+ ['] (local-init) to (local)
+ 0 to locals-flags
+ 0 to locals-var-count
+ locals-dict-buf @ 200 cells 0 fill \ Zero out temporary dictionary
+ locals-dict-buf @ current ! \ Switch to locals dictionary
+ locals-dict-buf @ /n + here!
+
+ begin
+ parse-word
+ 2dup s" }" strcmp 0= if
+ 2drop
+ ['] } execute -1
+ else
+ 2dup s" ;" strcmp 0= if
+ 2drop
+ 8 to locals-flags 0 \ Don't init from stack
+ else
+ 2dup s" |" strcmp 0= if
+ 2drop
+ 8 to locals-flags 0 \ Don't init from stack
+ else
+ 2dup s" --" strcmp 0= if
+ 2drop
+ ['] (local-noop) to (local) 0
+ else
+ locals-var-count #locals < if
+ (local) 0 \ accept local
+ else
+ s" maximum locals used ignoring " type type cr 0
+ then
+ locals-var-count 1+ to locals-var-count
+ then
+ then
+ then
+ then
+ until
+; immediate
+
+: -> ( n -- )
+ parse-word $find if
+ 4 cells + @ ,
+ else
+ s" unable to find word " type type
+ then
+; immediate
+
+[THEN]
diff -Nru openbios-ppc-1.0+svn1060/forth/lib/split.fs openbios-ppc-1.1/forth/lib/split.fs
--- openbios-ppc-1.0+svn1060/forth/lib/split.fs 2010-07-31 04:23:45.000000000 +0000
+++ openbios-ppc-1.1/forth/lib/split.fs 2013-05-06 19:09:54.000000000 +0000
@@ -47,24 +47,3 @@
c@ r@ = if 1- then then
r> drop
;
-
-\ split into separate path and device strings
-: split-path-device ( str len -- pathstr len devstr len )
- ascii , left-split 2 pick 0= if
- \ No comma - so either : or :
- 2dup ascii \ strchr 0= if
- \ No backslash so just or :
- s" " 2swap \ ( pathstr len devstr len )
- else
- \ Contains backslash, must be a :
- ascii : left-split \ ( pathstr len devstr len )
- then
-
- \ Remove RHS split (unused)
- 4 roll drop
- 4 roll drop
- else
- \ Contains comma so split is already correct
- then
-;
-
diff -Nru openbios-ppc-1.0+svn1060/fs/hfsplus/hfsp_fs.c openbios-ppc-1.1/fs/hfsplus/hfsp_fs.c
--- openbios-ppc-1.0+svn1060/fs/hfsplus/hfsp_fs.c 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/fs/hfsplus/hfsp_fs.c 2013-05-06 19:09:54.000000000 +0000
@@ -437,14 +437,147 @@
PUSH(pointer2cell(volname));
}
+static const int days_month[12] =
+ { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+static const int days_month_leap[12] =
+ { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+static inline int is_leap(int year)
+{
+ return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
+}
+
+static void
+print_date(uint32_t sec)
+{
+ unsigned int second, minute, hour, month, day, year;
+ int current;
+ const int *days;
+
+ second = sec % 60;
+ sec /= 60;
+
+ minute = sec % 60;
+ sec /= 60;
+
+ hour = sec % 24;
+ sec /= 24;
+
+ year = sec * 100 / 36525;
+ sec -= year * 36525 / 100;
+ year += 1904;
+
+ days = is_leap(year) ? days_month_leap : days_month;
+
+ current = 0;
+ month = 0;
+ while (month < 12) {
+ if (sec <= current + days[month]) {
+ break;
+ }
+ current += days[month];
+ month++;
+ }
+ month++;
+
+ day = sec - current + 1;
+
+ forth_printf("%d-%02d-%02d %02d:%02d:%02d ",
+ year, month, day, hour, minute, second);
+}
+
/* static method, ( pathstr len ihandle -- ) */
static void
hfsp_files_dir( hfsp_info_t *dummy )
{
- forth_printf("dir method not implemented for HFS+ filesystem\n");
- POP();
- POP();
- POP();
+ ihandle_t ih = POP_ih();
+ char *path = pop_fstr_copy();
+ int fd, found;
+ volume *vol;
+ record rec, r, folrec;
+ char name[256], *curfol, *tmppath;
+
+ fd = open_ih(ih);
+ if ( fd == -1 ) {
+ free( path );
+ RET( 0 );
+ }
+
+ vol = malloc( sizeof(volume) );
+ if (volume_open(vol, fd)) {
+ free( path );
+ close_io( fd );
+ RET( 0 );
+ }
+
+ /* First move to the specified folder */
+ tmppath = strdup(path);
+ record_init_root( &rec, &vol->catalog );
+ record_init_parent( &r, &rec );
+
+ /* Remove initial \ or / */
+ curfol = strsep(&tmppath, "\\//");
+ curfol = strsep(&tmppath, "\\//");
+ forth_printf("\n");
+
+ while (curfol && strlen(curfol)) {
+ found = 0;
+ do {
+ if (r.record.type == HFSP_FOLDER) {
+ unicode_uni2asc(name, &r.key.name, sizeof(name));
+
+ if (!strcmp(name, curfol)) {
+ folrec = r;
+ found = -1;
+ }
+ }
+ } while ( !record_next(&r) );
+
+ if (!found) {
+ forth_printf("Unable to locate path %s on filesystem\n", path);
+ goto done;
+ } else {
+ record_init_parent( &r, &folrec );
+ }
+
+ curfol = strsep(&tmppath, "\\//");
+ }
+
+ /* Output the directory contents */
+ found = 0;
+ do {
+ unicode_uni2asc(name, &r.key.name, sizeof(name));
+
+ if (r.record.type == HFSP_FILE) {
+ /* Grab the file entry */
+ hfsp_cat_file *file = &r.record.u.file;
+ forth_printf("% 10lld ", file->data_fork.total_size);
+ print_date(file->create_date);
+ forth_printf(" %s\n", name);
+ found = -1;
+ }
+
+ if (r.record.type == HFSP_FOLDER) {
+ /* Grab the directory entry */
+ hfsp_cat_folder *folder = &r.record.u.folder;
+ forth_printf(" 0 ");
+ print_date(folder->create_date);
+ forth_printf(" %s\\\n", name);
+ found = -1;
+ }
+
+ } while ( !record_next(&r) );
+
+ if (!found) {
+ forth_printf(" (Empty folder)\n");
+ }
+
+done:
+ volume_close(vol);
+ free(vol);
+ free(path);
+ if (tmppath)
+ free(tmppath);
}
/* static method, ( pos.d ih -- flag? ) */
diff -Nru openbios-ppc-1.0+svn1060/fs/hfsplus/hfsp_unicode.c openbios-ppc-1.1/fs/hfsplus/hfsp_unicode.c
--- openbios-ppc-1.0+svn1060/fs/hfsplus/hfsp_unicode.c 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/fs/hfsplus/hfsp_unicode.c 2013-05-06 19:09:54.000000000 +0000
@@ -43,7 +43,10 @@
/* might be unrepresentable (or too complicated for us) */
if( ustr[0] || !ustr[1] )
continue;
- *astr++ = ustr[1];
+ if( ustr[1] < 0x20 || ustr[1] >= 0x7f )
+ *astr++ = '?';
+ else
+ *astr++ = ustr[1];
len++;
}
*astr = 0;
diff -Nru openbios-ppc-1.0+svn1060/fs/hfsplus/hfsp_volume.c openbios-ppc-1.1/fs/hfsplus/hfsp_volume.c
--- openbios-ppc-1.0+svn1060/fs/hfsplus/hfsp_volume.c 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/fs/hfsplus/hfsp_volume.c 2013-05-06 19:09:54.000000000 +0000
@@ -171,7 +171,9 @@
UInt16 signature;
char buf[vol->blksize];
char *p = buf;
-
+ int ret;
+ UInt64 vol_size;
+
if( volume_readinbuf(vol, buf, 2) ) // Wrapper or volume header starts here
return -1;
@@ -202,7 +204,14 @@
}
else if( signature == HFSP_VOLHEAD_SIG) { /* Native HFS+ volume */
p = buf; // Restore to begin of block
- return volume_readbuf(vh, p);
+ ret = volume_readbuf(vh, p);
+ if( !ret ) {
+ /* When reading the initial partition we must use 512 byte blocks */
+ vol_size = vh->blocksize * vh->total_blocks;
+ vol->maxblocks = vol_size / HFSP_BLOCKSZ;
+ }
+
+ return ret;
} else
HFSP_ERROR(-1, "Neither Wrapper nor native HFS+ volume header found");
fail:
@@ -302,7 +311,7 @@
os_read(fd, vol, 2, HFSP_BLOCKSZ_BITS);
if (__be16_to_cpu(vol[0]) == HFS_VOLHEAD_SIG &&
- __be16_to_cpu(vol[0x7c]) == HFSP_VOLHEAD_SIG) {
+ __be16_to_cpu(vol[0x3e]) == HFSP_VOLHEAD_SIG) {
ret = -1;
} else if (__be16_to_cpu(vol[0]) == HFSP_VOLHEAD_SIG) {
ret = -1;
diff -Nru openbios-ppc-1.0+svn1060/include/arch/sparc32/ofmem_sparc32.h openbios-ppc-1.1/include/arch/sparc32/ofmem_sparc32.h
--- openbios-ppc-1.0+svn1060/include/arch/sparc32/ofmem_sparc32.h 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/include/arch/sparc32/ofmem_sparc32.h 2013-05-06 19:09:54.000000000 +0000
@@ -16,6 +16,9 @@
#include "libopenbios/ofmem.h"
+#define OF_CODE_START 0xffd00000
+#define OFMEM_VIRT_TOP 0xfe000000
+
struct mem;
extern struct mem cdvmem;
diff -Nru openbios-ppc-1.0+svn1060/include/drivers/pci.h openbios-ppc-1.1/include/drivers/pci.h
--- openbios-ppc-1.0+svn1060/include/drivers/pci.h 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/include/drivers/pci.h 2013-05-06 19:09:54.000000000 +0000
@@ -206,6 +206,7 @@
#define PCI_DEVICE_ID_QEMU_VGA 0x1111
#define PCI_VENDOR_ID_REDHAT_QUMRANET 0x1af4
+#define PCI_DEVICE_ID_VIRTIO_NET 0x1000
#define PCI_DEVICE_ID_VIRTIO_BLOCK 0x1001
#define PCI_VENDOR_ID_INTEL 0x8086
diff -Nru openbios-ppc-1.0+svn1060/include/libopenbios/bootcode_load.h openbios-ppc-1.1/include/libopenbios/bootcode_load.h
--- openbios-ppc-1.0+svn1060/include/libopenbios/bootcode_load.h 1970-01-01 00:00:00.000000000 +0000
+++ openbios-ppc-1.1/include/libopenbios/bootcode_load.h 2013-05-06 19:09:54.000000000 +0000
@@ -0,0 +1,22 @@
+/*
+ * Creation Date: <2010/03/22 18:00:00 mcayland>
+ * Time-stamp: <2010/03/22 18:00:00 mcayland>
+ *
+ *
+ *
+ * Raw bootcode (%BOOT) loader
+ *
+ * Copyright (C) 2013 Mark Cave-Ayland (mark.cave-ayland@ilande.co.uk)
+ *
+ * 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
+ *
+ */
+
+#ifndef _H_BOOTCODELOAD
+#define _H_BOOTCODELOAD
+
+extern int bootcode_load(ihandle_t dev);
+
+#endif /* _H__H_BOOTCODELOAD */
diff -Nru openbios-ppc-1.0+svn1060/libopenbios/bootcode_load.c openbios-ppc-1.1/libopenbios/bootcode_load.c
--- openbios-ppc-1.0+svn1060/libopenbios/bootcode_load.c 1970-01-01 00:00:00.000000000 +0000
+++ openbios-ppc-1.1/libopenbios/bootcode_load.c 2013-05-06 19:09:54.000000000 +0000
@@ -0,0 +1,71 @@
+/*
+ * Raw bootcode loader (CHRP/Apple %BOOT)
+ * Written by Mark Cave-Ayland 2013
+ */
+
+#include "config.h"
+#include "kernel/kernel.h"
+#include "libopenbios/bindings.h"
+#include "libopenbios/bootcode_load.h"
+#include "libc/diskio.h"
+#include "drivers/drivers.h"
+#define printf printk
+#define debug printk
+
+#define OLDWORLD_BOOTCODE_BASEADDR (0x3f4000)
+
+int
+bootcode_load(ihandle_t dev)
+{
+ int retval = -1, count = 0, fd;
+ unsigned long bootcode, loadbase, offset;
+
+ /* Mark the saved-program-state as invalid */
+ feval("0 state-valid !");
+
+ fd = open_ih(dev);
+ if (fd == -1) {
+ goto out;
+ }
+
+ /* Default to loading at load-base */
+ fword("load-base");
+ loadbase = POP();
+
+#ifdef CONFIG_PPC
+ /* However Old World Macs need to load to a different address */
+ if (is_oldworld()) {
+ loadbase = OLDWORLD_BOOTCODE_BASEADDR;
+ }
+#endif
+
+ bootcode = loadbase;
+ offset = 0;
+
+ while(1) {
+ if (seek_io(fd, offset) == -1)
+ break;
+ count = read_io(fd, (void *)bootcode, 512);
+ offset += count;
+ bootcode += count;
+ }
+
+ /* If we didn't read anything then exit */
+ if (!count) {
+ goto out;
+ }
+
+ /* Initialise saved-program-state */
+ PUSH(loadbase);
+ feval("saved-program-state >sps.entry !");
+ PUSH(offset);
+ feval("saved-program-state >sps.file-size !");
+ feval("bootcode saved-program-state >sps.file-type !");
+
+ feval("-1 state-valid !");
+
+out:
+ close_io(fd);
+ return retval;
+}
+
diff -Nru openbios-ppc-1.0+svn1060/libopenbios/build.xml openbios-ppc-1.1/libopenbios/build.xml
--- openbios-ppc-1.0+svn1060/libopenbios/build.xml 2010-07-31 04:23:45.000000000 +0000
+++ openbios-ppc-1.1/libopenbios/build.xml 2013-05-06 19:09:54.000000000 +0000
@@ -3,6 +3,7 @@
+
diff -Nru openbios-ppc-1.0+svn1060/libopenbios/load.c openbios-ppc-1.1/libopenbios/load.c
--- openbios-ppc-1.0+svn1060/libopenbios/load.c 2010-08-28 12:24:56.000000000 +0000
+++ openbios-ppc-1.1/libopenbios/load.c 2013-05-06 19:09:54.000000000 +0000
@@ -36,6 +36,10 @@
#include "libopenbios/forth_load.h"
#endif
+#ifdef CONFIG_LOADER_BOOTCODE
+#include "libopenbios/bootcode_load.h"
+#endif
+
struct sys_info sys_info;
void *elf_boot_notes = NULL;
@@ -92,4 +96,13 @@
}
#endif
+#ifdef CONFIG_LOADER_BOOTCODE
+ /* Check for a "raw" %BOOT bootcode payload */
+ feval("want-bootcode @");
+ valid = POP();
+ if (valid) {
+ bootcode_load(dev);
+ }
+#endif
+
}
diff -Nru openbios-ppc-1.0+svn1060/libopenbios/ofmem_common.c openbios-ppc-1.1/libopenbios/ofmem_common.c
--- openbios-ppc-1.0+svn1060/libopenbios/ofmem_common.c 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/libopenbios/ofmem_common.c 2013-05-06 19:09:54.000000000 +0000
@@ -107,7 +107,7 @@
}
/* waste at most 4K by taking an entry from the freelist */
- if( *pp && (**pp).size < size + 0x1000 ) {
+ if( *pp && (**pp).size > size + 0x1000 ) {
/* Alignment should be on physical not virtual address */
pa = va2pa((uintptr_t)*pp + sizeof(alloc_desc_t));
pa = align_ptr(pa, alignment);
@@ -425,13 +425,27 @@
{
phys_addr_t base = min;
range_t *r2;
+ ucell old_align;
+ int i;
if( (align & (align-1)) ) {
- OFMEM_TRACE("bad alignment " FMT_ucell "\n", align);
- align = 0x1000;
+
+ /* As per IEEE1275 specification, round up to the nearest power of 2 */
+ old_align = align;
+ if (old_align <= PAGE_SIZE) {
+ align = PAGE_SIZE;
+ } else {
+ align--;
+ for (i = 1; i < sizeof(ucell) * 8; i<<=1) {
+ align |= align >> i;
+ }
+ align++;
+ }
+
+ OFMEM_TRACE("warning: bad alignment " FMT_ucellx " rounded up to " FMT_ucellx "\n", old_align, align);
}
if( !align )
- align = 0x1000;
+ align = PAGE_SIZE;
base = reverse ? max - size : min;
r2 = reverse ? NULL : r;
diff -Nru openbios-ppc-1.0+svn1060/packages/disk-label.c openbios-ppc-1.1/packages/disk-label.c
--- openbios-ppc-1.0+svn1060/packages/disk-label.c 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/packages/disk-label.c 2013-05-06 19:09:54.000000000 +0000
@@ -73,63 +73,70 @@
di->filesystem_ph = 0;
di->parent_seek_xt = find_parent_method("seek");
di->parent_tell_xt = find_parent_method("tell");
- di->parent_read_xt = find_parent_method("read");
+ di->parent_read_xt = find_parent_method("read");
- /* Read first block from parent device */
- DPUSH(0);
- call_package(di->parent_seek_xt, my_parent());
- POP();
+ /* If arguments have been passed, determine the partition/filesystem type */
+ if (path && strlen(path)) {
- PUSH(pointer2cell(block0));
- PUSH(sizeof(block0));
- call_package(di->parent_read_xt, my_parent());
- status = POP();
- if (status != sizeof(block0))
- goto out;
-
- /* Find partition handler */
- PUSH( pointer2cell(block0) );
- selfword("find-part-handler");
- ph = POP_ph();
- if( ph ) {
- /* We found a suitable partition handler, so interpose it */
- DPRINTF("Partition found on disk - scheduling interpose with ph " FMT_ucellx "\n", ph);
-
- push_str(path);
- PUSH_ph(ph);
- fword("interpose");
+ /* Read first block from parent device */
+ DPUSH(0);
+ call_package(di->parent_seek_xt, my_parent());
+ POP();
- success = 1;
- } else {
- /* unknown (or missing) partition map,
- * try the whole disk
- */
-
- DPRINTF("Unknown or missing partition map; trying whole disk\n");
-
- /* Probe for filesystem from start of device */
- DPUSH ( 0 );
- PUSH_ih( my_self() );
- selfword("find-filesystem");
+ PUSH(pointer2cell(block0));
+ PUSH(sizeof(block0));
+ call_package(di->parent_read_xt, my_parent());
+ status = POP();
+ if (status != sizeof(block0))
+ goto out;
+
+ /* Find partition handler */
+ PUSH( pointer2cell(block0) );
+ selfword("find-part-handler");
ph = POP_ph();
if( ph ) {
- /* If we have been asked to open a particular file, interpose the filesystem package with the passed filename as an argument */
- di->filesystem_ph = ph;
+ /* We found a suitable partition handler, so interpose it */
+ DPRINTF("Partition found on disk - scheduling interpose with ph " FMT_ucellx "\n", ph);
- DPRINTF("Located filesystem with ph " FMT_ucellx "\n", ph);
- DPRINTF("path: %s length: %d\n", path, strlen(path));
-
- if (path && strlen(path)) {
- DPRINTF("INTERPOSE!\n");
-
- push_str( path );
- PUSH_ph( ph );
- fword("interpose");
+ push_str(path);
+ PUSH_ph(ph);
+ fword("interpose");
+
+ success = 1;
+ } else {
+ /* unknown (or missing) partition map,
+ * try the whole disk
+ */
+
+ DPRINTF("Unknown or missing partition map; trying whole disk\n");
+
+ /* Probe for filesystem from start of device */
+ DPUSH ( 0 );
+ PUSH_ih( my_self() );
+ selfword("find-filesystem");
+ ph = POP_ph();
+ if( ph ) {
+ /* If we have been asked to open a particular file, interpose the filesystem package with the passed filename as an argument */
+ di->filesystem_ph = ph;
+
+ DPRINTF("Located filesystem with ph " FMT_ucellx "\n", ph);
+ DPRINTF("path: %s length: %d\n", path, strlen(path));
+
+ if (path && strlen(path)) {
+ DPRINTF("INTERPOSE!\n");
+
+ push_str( path );
+ PUSH_ph( ph );
+ fword("interpose");
+ }
+ } else if (path && strcmp(path, "%BOOT") != 0) {
+ goto out;
}
- } else if (path && strcmp(path, "%BOOT") != 0) {
- goto out;
- }
+ success = 1;
+ }
+ } else {
+ /* No arguments were passed, so we just use the parent raw device directly */
success = 1;
}
diff -Nru openbios-ppc-1.0+svn1060/packages/mac-parts.c openbios-ppc-1.1/packages/mac-parts.c
--- openbios-ppc-1.0+svn1060/packages/mac-parts.c 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/packages/mac-parts.c 2013-05-06 19:09:54.000000000 +0000
@@ -49,14 +49,15 @@
macparts_open( macparts_info_t *di )
{
char *str = my_args_copy();
- char *argstr = strdup("");
- char *parstr = strdup("");
- int bs, parnum=-1;
+ char *parstr = NULL, *argstr = NULL;
+ char *tmpstr, *bootpath;
+ int bs, parnum=-1, apple_parnum=-1;
+ int parlist[2], parlist_size = 0;
desc_map_t dmap;
part_entry_t par;
- int ret = 0;
+ int ret = 0, i = 0, j = 0;
int want_bootcode = 0;
- phandle_t ph;
+ phandle_t ph, chosen_ph;
ducell offs = 0, size = -1;
DPRINTF("macparts_open '%s'\n", str );
@@ -66,44 +67,33 @@
id: [0-7]
[(id)][,][filespec]
*/
+
+ if ( str && strlen(str) ) {
+ /* Detect the arguments */
+ if ((*str >= '0' && *str <= '9') || (*str == ',')) {
+ push_str(str);
+ PUSH(',');
+ fword("left-parse-string");
+ parstr = pop_fstr_copy();
+ argstr = pop_fstr_copy();
+ } else {
+ argstr = str;
+ }
- if( str ) {
- if ( !strlen(str) )
- parnum = -1;
- else {
- /* Detect the boot parameters */
- char *ptr;
- ptr = str;
-
- /* , */
- if (*ptr >= '0' && *ptr <= '9' && *(ptr + 1) == ',') {
- parstr = ptr;
- *(ptr + 1) = '\0';
- argstr = ptr + 2;
- }
-
- /* */
- else if (*ptr >= '0' && *ptr <='9' && *(ptr + 1) == '\0') {
- parstr = ptr;
- }
-
- /* , */
- else if (*ptr == ',') {
- argstr = ptr + 1;
- }
-
- /* */
- else {
- argstr = str;
- }
+ /* Make sure argstr is not null */
+ if (argstr == NULL)
+ argstr = strdup("");
- /* Convert the id to a partition number */
- if (strlen(parstr))
- parnum = atol(parstr);
-
- /* Detect if we are looking for the bootcode */
- if (strcmp(argstr, "%BOOT") == 0)
- want_bootcode = 1;
+ /* Convert the id to a partition number */
+ if (parstr && strlen(parstr))
+ parnum = atol(parstr);
+
+ /* Detect if we are looking for the bootcode */
+ if (strcmp(argstr, "%BOOT") == 0) {
+ want_bootcode = 1;
+ feval("1 want-bootcode !");
+ } else {
+ feval("0 want-bootcode !");
}
}
@@ -140,7 +130,7 @@
* Implement partition selection as per the PowerPC Microprocessor CHRP bindings
*/
- if (str == NULL || parnum == 0) {
+ if (argstr == NULL || parnum == 0) {
/* According to the spec, partition 0 as well as no arguments means the whole disk */
offs = (long long)0;
size = (long long)__be32_to_cpu(dmap.sbBlkCount) * bs;
@@ -156,107 +146,164 @@
ret = -1;
goto out;
- } else if (parnum == -1 && strlen(argstr)) {
+ } else if (parnum == -1) {
DPRINTF("mac-parts: counted %d partitions\n", __be32_to_cpu(par.pmMapBlkCnt));
- /* No partition was explicitly requested, but an argstr was passed in.
- So let's find a suitable partition... */
- for (parnum = 1; parnum <= __be32_to_cpu(par.pmMapBlkCnt); parnum++) {
- SEEK( bs * parnum );
+ /* No partition was explicitly requested so let's find a suitable partition... */
+ for (i = 1; i <= __be32_to_cpu(par.pmMapBlkCnt); i++) {
+ SEEK( bs * i );
READ( &par, sizeof(par) );
- if( __be16_to_cpu(par.pmSig) != DESC_PART_SIGNATURE ||
+ if ( __be16_to_cpu(par.pmSig) != DESC_PART_SIGNATURE ||
!__be32_to_cpu(par.pmPartBlkCnt) )
- break;
+ continue;
- DPRINTF("found partition type: %s with status %x\n", par.pmPartType, __be32_to_cpu(par.pmPartStatus));
+ DPRINTF("found partition %d type: %s with status %x\n", i, par.pmPartType, __be32_to_cpu(par.pmPartStatus));
/* If we have a valid, allocated and readable partition... */
if( (__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsValid) &&
(__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsAllocated) &&
(__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsReadable) ) {
- offs = (long long)__be32_to_cpu(par.pmPyPartStart) * bs;
- size = (long long)__be32_to_cpu(par.pmPartBlkCnt) * bs;
- /* If the filename was set to %BOOT, we actually want the bootcode */
- if (want_bootcode && (__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsBootValid)) {
- offs += (long long)__be32_to_cpu(par.pmLgBootStart) * bs;
- size = (long long)__be32_to_cpu(par.pmBootSize);
-
- goto found;
- } else {
- /* Otherwise we were passed a filename and path. So let's
- choose the first partition with a valid filesystem */
- DPUSH( offs );
- PUSH_ih( my_parent() );
- parword("find-filesystem");
+ /* Unfortunately Apple's OF implementation doesn't follow the OF PowerPC CHRP bindings
+ * and instead will brute-force boot the first valid partition it finds with a
+ * type of either "Apple_Boot", "Apple_HFS" or "DOS_FAT_". Here we store the id
+ * of the first partition that matches these criteria to use as a fallback later
+ * if required. */
- ph = POP_ph();
- if (ph)
- goto found;
+ if (apple_parnum == -1 &&
+ (strcmp(par.pmPartType, "Apple_Boot") == 0 ||
+ strcmp(par.pmPartType, "Apple_Bootstrap") == 0 ||
+ strcmp(par.pmPartType, "Apple_HFS") == 0 ||
+ strcmp(par.pmPartType, "DOS_FAT_") == 0)) {
+ apple_parnum = i;
+
+ DPRINTF("Located Apple OF fallback partition %d\n", apple_parnum);
+ }
+
+ /* If the partition is also bootable and the pmProcessor field matches "PowerPC" (insensitive
+ * match), then according to the CHRP bindings this is our chosen partition */
+ for (j = 0; j < strlen(par.pmProcessor); j++) {
+ par.pmProcessor[j] = tolower(par.pmProcessor[j]);
+ }
+
+ if ((__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsBootValid) &&
+ strcmp(par.pmProcessor, "powerpc") == 0) {
+ parnum = i;
+
+ DPRINTF("Located CHRP-compliant boot partition %d\n", parnum);
}
}
}
+
+ /* If we found a valid CHRP partition, add it to the list */
+ if (parnum > 0) {
+ parlist[parlist_size++] = parnum;
+ }
+ /* If we found an Apple OF fallback partition, add it to the list */
+ if (apple_parnum > 0 && apple_parnum != parnum) {
+ parlist[parlist_size++] = apple_parnum;
+ }
+
} else {
/* Another partition was explicitly requested */
- SEEK( bs * parnum );
- READ( &par, sizeof(par) );
-
- if( (__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsValid) &&
- (__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsAllocated) &&
- (__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsReadable) ) {
-
- offs = (long long)__be32_to_cpu(par.pmPyPartStart) * bs;
- size = (long long)__be32_to_cpu(par.pmPartBlkCnt) * bs;
- }
- }
-
- /* If we couldn't find a partition, exit */
- if (size == -1) {
- DPRINTF("Unable to automatically find partition!\n");
- goto out;
+ parlist[parlist_size++] = parnum;
+
+ DPRINTF("Partition %d explicitly requested\n", parnum);
}
-found:
-
- ret = -1;
- di->blocksize = (unsigned int)bs;
-
- di->offs_hi = offs >> BITS;
- di->offs_lo = offs & (ucell) -1;
+ /* Attempt to use our CHRP partition, optionally followed by our Apple OF fallback partition */
+ for (j = 0; j < parlist_size; j++) {
+
+ /* Make sure our partition is valid */
+ parnum = parlist[j];
+
+ DPRINTF("Selected partition %d\n", parnum);
+
+ SEEK( bs * parnum );
+ READ( &par, sizeof(par) );
- di->size_hi = size >> BITS;
- di->size_lo = size & (ucell) -1;
-
- /* We have a valid partition - so probe for a filesystem at the current offset */
- DPRINTF("mac-parts: about to probe for fs\n");
- DPUSH( offs );
- PUSH_ih( my_parent() );
- parword("find-filesystem");
- DPRINTF("mac-parts: done fs probe\n");
-
- ph = POP_ph();
- if( ph ) {
- DPRINTF("mac-parts: filesystem found with ph " FMT_ucellx " and args %s\n", ph, argstr);
- di->filesystem_ph = ph;
-
- /* If the filename was %BOOT then it's not a real filename, so clear argstr before
- attempting interpose */
- if (want_bootcode)
- argstr = strdup("");
-
- /* If we have been asked to open a particular file, interpose the filesystem package with
- the passed filename as an argument */
- if (strlen(argstr)) {
- push_str( argstr );
- PUSH_ph( ph );
- fword("interpose");
- }
- } else {
- DPRINTF("mac-parts: no filesystem found; bypassing misc-files interpose\n");
+ if(! ((__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsValid) &&
+ (__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsAllocated) &&
+ (__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsReadable)) ) {
+ DPRINTF("Partition %d is not valid, allocated and readable\n", parnum);
+ goto out;
+ }
+
+ ret = -1;
+
+ offs = (long long)__be32_to_cpu(par.pmPyPartStart) * bs;
+ size = (long long)__be32_to_cpu(par.pmPartBlkCnt) * bs;
+
+ if (want_bootcode) {
+ offs += (long long)__be32_to_cpu(par.pmLgBootStart) * bs;
+ size = (long long)__be32_to_cpu(par.pmBootSize);
+ }
+
+ di->blocksize = (unsigned int)bs;
+
+ di->offs_hi = offs >> BITS;
+ di->offs_lo = offs & (ucell) -1;
+
+ di->size_hi = size >> BITS;
+ di->size_lo = size & (ucell) -1;
+
+ /* We have a valid partition - so probe for a filesystem at the current offset */
+ DPRINTF("mac-parts: about to probe for fs\n");
+ DPUSH( offs );
+ PUSH_ih( my_parent() );
+ parword("find-filesystem");
+ DPRINTF("mac-parts: done fs probe\n");
+
+ ph = POP_ph();
+ if( ph ) {
+ DPRINTF("mac-parts: filesystem found on partition %d with ph " FMT_ucellx " and args %s\n", parnum, ph, argstr);
+ di->filesystem_ph = ph;
+
+ /* Update bootpath to reflect where we booted from */
+ chosen_ph = find_dev("/chosen");
+ tmpstr = get_property(chosen_ph, "bootpath", &i);
+ if (tmpstr == NULL) {
+ tmpstr = strdup("");
+ }
+
+ /* Find just the device */
+ if (strlen(tmpstr)) {
+ for (i = 0; i < strlen(tmpstr); i++) {
+ if (tmpstr[i] == ':' || tmpstr[i] == ',') {
+ tmpstr[i] = '\0';
+ }
+ }
+
+ /* Rebuild bootpath with the currently selected partition number */
+ bootpath = malloc(strlen(tmpstr) + strlen(str) + 4);
+ sprintf(bootpath, "%s:%d", tmpstr, parnum);
+ if (strlen(argstr)) {
+ sprintf(bootpath, "%s:%d,%s", tmpstr, parnum, argstr);
+ } else {
+ sprintf(bootpath, "%s:%d", tmpstr, parnum);
+ }
+
+ DPRINTF("mac-parts: setting bootpath to %s\n", bootpath);
+
+ set_property(chosen_ph, "bootpath", bootpath, strlen(bootpath) + 1);
+ }
+
+ /* If we have been asked to open a particular file, interpose the filesystem package with
+ the passed filename as an argument */
+ if (!want_bootcode && strlen(argstr)) {
+ push_str( argstr );
+ PUSH_ph( ph );
+ fword("interpose");
+ }
+
+ goto out;
+ } else {
+ DPRINTF("mac-parts: no filesystem found on partition %d; bypassing misc-files interpose\n", parnum);
+ }
}
-
+
free( str );
out:
diff -Nru openbios-ppc-1.0+svn1060/packages/pc-parts.c openbios-ppc-1.1/packages/pc-parts.c
--- openbios-ppc-1.0+svn1060/packages/pc-parts.c 2011-01-25 17:44:04.000000000 +0000
+++ openbios-ppc-1.1/packages/pc-parts.c 2013-05-06 19:09:54.000000000 +0000
@@ -94,42 +94,27 @@
[(id)][,][filespec]
*/
- if( str ) {
- if ( !strlen(str) )
- parnum = -1;
- else {
- /* Detect the boot parameters */
- char *ptr;
- ptr = str;
-
- /* , */
- if (*ptr >= '0' && *ptr <= '9' && *(ptr + 1) == ',') {
- parstr = ptr;
- *(ptr + 1) = '\0';
- argstr = ptr + 2;
- }
-
- /* */
- else if (*ptr >= '0' && *ptr <='9' && *(ptr + 1) == '\0') {
- parstr = ptr;
- }
-
- /* , */
- else if (*ptr == ',') {
- argstr = ptr + 1;
- }
-
- /* */
- else {
- argstr = str;
- }
-
- /* Convert the id to a partition number */
- if (strlen(parstr))
- parnum = atol(parstr);
+ if ( strlen(str) ) {
+ /* Detect the arguments */
+ if ((*str >= '0' && *str <= '7') || (*str == ',')) {
+ push_str(str);
+ PUSH(',');
+ fword("left-parse-string");
+ parstr = pop_fstr_copy();
+ argstr = pop_fstr_copy();
+ } else {
+ argstr = str;
}
+
+ /* Convert the id to a partition number */
+ if (parstr && strlen(parstr))
+ parnum = atol(parstr);
}
+ /* Make sure argstr is not null */
+ if (argstr == NULL)
+ argstr = strdup("");
+
DPRINTF("parstr: %s argstr: %s parnum: %d\n", parstr, argstr, parnum);
free(parstr);
diff -Nru openbios-ppc-1.0+svn1060/packages/sun-parts.c openbios-ppc-1.1/packages/sun-parts.c
--- openbios-ppc-1.0+svn1060/packages/sun-parts.c 2011-01-06 16:11:49.000000000 +0000
+++ openbios-ppc-1.1/packages/sun-parts.c 2013-05-06 19:09:54.000000000 +0000
@@ -109,46 +109,31 @@
[(id)][,][filespec]
*/
- if( str ) {
- if ( !strlen(str) )
- parnum = -1;
- else {
- /* Detect the boot parameters */
- char *ptr;
- ptr = str;
-
- /* , */
- if (((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'a' && *ptr <= 'a' + 8)) && *(ptr + 1) == ',') {
- parstr = ptr;
- *(ptr + 1) = '\0';
- argstr = ptr + 2;
- }
-
- /* */
- else if (((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'a' && *ptr <= 'a' + 8)) && *(ptr + 1) == '\0') {
- parstr = ptr;
- }
-
- /* , */
- else if (*ptr == ',') {
- argstr = ptr + 1;
- }
-
- /* */
- else {
- argstr = str;
- }
+ if ( str && strlen(str) ) {
+ /* Detect the arguments */
+ if ((*str >= '0' && *str <= '9') || (*str >= 'a' && *str < ('a' + 8)) || (*str == ',')) {
+ push_str(str);
+ PUSH(',');
+ fword("left-parse-string");
+ parstr = pop_fstr_copy();
+ argstr = pop_fstr_copy();
+ } else {
+ argstr = str;
+ }
- /* Convert the id to a partition number */
- if (parstr && strlen(parstr)) {
- if (parstr[0] >= 'a' && parstr[0] < ('a' + 8))
- parnum = parstr[0] - 'a';
- else
- parnum = atol(parstr);
- }
+ /* Convert the id to a partition number */
+ if (parstr && strlen(parstr)) {
+ if (parstr[0] >= 'a' && parstr[0] < ('a' + 8))
+ parnum = parstr[0] - 'a';
+ else
+ parnum = atol(parstr);
}
}
+ /* Make sure argstr is not null */
+ if (argstr == NULL)
+ argstr = strdup("");
+
DPRINTF("parstr: %s argstr: %s parnum: %d\n", parstr, argstr, parnum);
di->filesystem_ph = 0;
diff -Nru openbios-ppc-1.0+svn1060/packages/video.c openbios-ppc-1.1/packages/video.c
--- openbios-ppc-1.0+svn1060/packages/video.c 2012-06-09 12:05:49.000000000 +0000
+++ openbios-ppc-1.1/packages/video.c 2013-05-06 19:09:54.000000000 +0000
@@ -159,7 +159,7 @@
while( ww-- )
*p++ = col;
} else {
- char *p = (char *)((unsigned short*)pp + x);
+ char *p = (char *)(pp + x);
while( ww-- )
*p++ = col;
@@ -187,12 +187,14 @@
if( video.fb.depth == 8 )
OSI_SetColor( ind, color );
#elif defined(CONFIG_SPARC32)
+#if defined(CONFIG_DEBUG_CONSOLE_VIDEO)
if( video.fb.depth == 8 ) {
dac[0] = ind << 24;
dac[1] = ((color >> 16) & 0xff) << 24; // Red
dac[1] = ((color >> 8) & 0xff) << 24; // Green
dac[1] = (color & 0xff) << 24; // Blue
}
+#endif
#else
vga_set_color(ind, ((color >> 16) & 0xff),
((color >> 8) & 0xff),
@@ -339,6 +341,9 @@
video.has_video = 1;
video.pal = malloc( 256 * sizeof(unsigned long) );
+ PUSH(video.fb.mvirt);
+ feval("to frame-buffer-adr");
+
#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI)
size = ((video.fb.h * video.fb.rb) + 0xfff) & ~0xfff;