On 09/08/11 22:55, William Hahne wrote:
> It is possible for BootX to purposefully divide by zero expecting 0 as
> the result.
>
> Index: kernel/forth.c
> ===================================================================
> --- kernel/forth.c (revision 1041)
> +++ kernel/forth.c (working copy)
> @@ -1157,6 +1157,12 @@
> {
> const ucell b = POP();
> const ducell a = DPOP();
> +
> + if (b == 0) { // can't divide by zero
> + PUSH(0);
> + DPUSH(0);
> + return;
> + }
> #ifdef NEED_FAKE_INT128_T
> if (a.hi != 0) {
> fprintf(stderr, "mudivmod called (0x%016llx %016llx /
> 0x%016llx)\n",
There is something wrong here: nothing will purposefully divide by zero
as it will invoke a trap somewhere. Again, I think this is hiding
another bug somewhere and is not necessarily the correct fix.
ATB,
Mark.
--
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063
Sirius Labs: http://www.siriusit.co.uk/labs
On 09/08/11 22:55, William Hahne wrote:
> BootX will sometimes set the stdout variable to null and then
> subsequently call io-emit which can eventually result in an infinite loop.
>
> Index: forth/admin/iocontrol.fs
> ===================================================================
> --- forth/admin/iocontrol.fs (revision 1041)
> +++ forth/admin/iocontrol.fs (working copy)
> @@ -80,6 +80,7 @@
> ;
> : io-emit ( char -- )
> + stdout @ 0= if drop exit then \ make sure stdout pointer is not null
> io-out-char c!
> io-out-char 1 " write" stdout @ $call-method drop
> ;
Hmmm isn't this just hiding another bug which is that the stdout
variable/defer is being set?
ATB,
Mark.
--
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063
Sirius Labs: http://www.siriusit.co.uk/labs
On 09/08/11 22:54, William Hahne wrote:
> The void partitions can be occasionally found on Mac OS discs (10.2 for
> example.) Previously mac-parts would just stop at the first void
> partition meaning it would never try to boot from the HFS partition.
>
> Index: packages/mac-parts.c
> ===================================================================
> --- packages/mac-parts.c (revision 1041)
> +++ packages/mac-parts.c (working copy)
> @@ -165,9 +165,12 @@
> for (parnum = 1; parnum <= __be32_to_cpu(par.pmMapBlkCnt); parnum++) {
> SEEK( bs * parnum );
> READ( &par, sizeof(par) );
> - if( __be16_to_cpu(par.pmSig) != DESC_PART_SIGNATURE ||
> - !__be32_to_cpu(par.pmPartBlkCnt) )
> + if( __be16_to_cpu(par.pmSig) != DESC_PART_SIGNATURE) {
> break;
> + }
> + if ( !__be32_to_cpu(par.pmPartBlkCnt) ) {
> + continue; /* Just a void partition, ignore it. */
> + }
> DPRINTF("found partition type: %s with status %x\n", par.pmPartType,
> __be32_to_cpu(par.pmPartStatus));
Same as my comment for patch 2/10.
ATB,
Mark.
--
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063
Sirius Labs: http://www.siriusit.co.uk/labs
On 09/08/11 22:54, William Hahne wrote:
> BootX will only check the first few partitions from mac-parts to find
> the Mac OS partition. So it must expect drivers and void partitions to
> be ignored. This patch makes it so that if you specify the partition
> cd:1 and partition 1 is a driver it will keep checking partitions until
> reaching the first non-driver and non-void partition.
>
> Index: packages/mac-parts.c
> ===================================================================
> --- packages/mac-parts.c (revision 1041)
> +++ packages/mac-parts.c (working copy)
> @@ -200,15 +203,26 @@
> } else {
> /* Another partition was explicitly requested */
> - SEEK( bs * parnum );
> - READ( &par, sizeof(par) );
> +
> + /* We have to find the first valid partition corresponding to the
> given number.
> + This is because Apple sometimes includes a bunch of extra partitions
> that
> + BootX expects to be ignored */
> + while (parnum < par.pmMapBlkCnt) {
> + 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) ) {
> + /* Check if valid, also device driver partitions are expected to be
> ignored */
> + if( (__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsValid) &&
> + (__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsAllocated) &&
> + (__be32_to_cpu(par.pmPartStatus) & kPartitionAUXIsReadable) &&
> + !(__be32_to_cpu(par.pmPartStatus) & kPartitionIsRealDeviceDriver)) {
> - offs = (long long)__be32_to_cpu(par.pmPyPartStart) * bs;
> - size = (long long)__be32_to_cpu(par.pmPartBlkCnt) * bs;
> + offs = (long long)__be32_to_cpu(par.pmPyPartStart) * bs;
> + size = (long long)__be32_to_cpu(par.pmPartBlkCnt) * bs;
> + break;
> + }
> +
> + parnum++;
> }
> }
I remember last time I reworked this, I had to spend a lot of time
reading the Apple HFS documentation with regard to this. Could you add a
link to the documentation on the Apple site into the commit message, and
confirm whether this is something I missed which is documented or it's
new behaviour that you have discoverd through testing.
ATB,
Mark.
--
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063
Sirius Labs: http://www.siriusit.co.uk/labs
On 09/08/11 22:54, William Hahne wrote:
> "get-key-map" is a Forth word that provides a map of all the keys
> currently pressed on the keyboard. Since it is only used by BootX to
> determine if one of the shortcuts for verbose or single user mode is
> pressed. It is a waste of time to provide a full implementation. This
> just hands out a dummy key map which specifies verbose mode.
>
> Index: drivers/adb_kbd.c
> ===================================================================
> --- drivers/adb_kbd.c (revision 1041)
> +++ drivers/adb_kbd.c (working copy)
> @@ -43,10 +43,13 @@
> static void keyboard_read(void);
> +static void keyboard_get_key_map(void);
> +
> NODE_METHODS( keyboard ) = {
> { "open", keyboard_open },
> { "close", keyboard_close },
> { "read", keyboard_read },
> + { "get-key-map", keyboard_get_key_map },
> };
> /* VT100 escape sequences */
> @@ -566,3 +569,18 @@
> }
> PUSH(i);
> }
> +
> +static unsigned char fake_keymap[32] = {
> + 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00
> +};
> +
> +static void keyboard_get_key_map(void)
> +{
> + /* This is a bit of a hack since BootX requires a get-key-map word.
> + In the future this should be changed to give the actual current
> keymap,
> + but since this only effects keyboard input in BootX it isn't a
> priority. */
> + PUSH( (int)fake_keymap );
> +}
Can you add a reference in the commit message to the documentation for
the keymap layout? It's not clear how you generated the contents of the
keymap blob.
ATB,
Mark.
--
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063
Sirius Labs: http://www.siriusit.co.uk/labs
On 09/08/11 22:54, William Hahne wrote:
> Hello,
>
> I apologize for my earlier post which I failed to break up. I have not
> done much posting to mailing lists. These 10 patches it all relate to
> getting OpenBIOS able to boot Mac OS X on Qemu. While Mac OS does not
> yet fully boot, with these patches I have gotten the Mac OS 10.2 kernel
> to load and begin booting. The rest of the work will mostly be in Qemu.
>
> William Hahne
>
> M kernel/forth.c
> M kernel/bootstrap.c
> M forth/admin/iocontrol.fs
> M forth/bootstrap/bootstrap.fs
> M fs/hfsplus/hfsp_volume.c
> M arch/ppc/qemu/init.c
> M packages/video.c
> M packages/mac-parts.c
> M drivers/adb_kbd.c
Hi William,
Thanks for this - this looks like a very interesting patch series.
Comments to follow shortly.
ATB,
Mark.
--
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063
Sirius Labs: http://www.siriusit.co.uk/labs
On Tue, Aug 9, 2011 at 11:55 PM, William Hahne <will07c5(a)gmail.com> wrote:
> It is possible for BootX to purposefully divide by zero expecting 0 as the
> result.
OBP behaves differently. It puts the result only if there was no
devision by zero:
ok showstack
ok 0 0 /
Trap 3e
ok 1 0 /
Trap 3e
ok 10 8 /
2 ok
Maybe it has to be done platform-dependent.
> Index: kernel/forth.c
> ===================================================================
> --- kernel/forth.c (revision 1041)
> +++ kernel/forth.c (working copy)
> @@ -1157,6 +1157,12 @@
> {
> const ucell b = POP();
> const ducell a = DPOP();
> +
> + if (b == 0) { // can't divide by zero
> + PUSH(0);
> + DPUSH(0);
> + return;
> + }
> #ifdef NEED_FAKE_INT128_T
> if (a.hi != 0) {
> fprintf(stderr, "mudivmod called (0x%016llx %016llx /
> 0x%016llx)\n",
> --
> OpenBIOS http://openbios.org/
> Mailinglist: http://lists.openbios.org/mailman/listinfo
> Free your System - May the Forth be with you
>
--
Regards,
Artyom Tarasenko
solaris/sparc under qemu blog: http://tyom.blogspot.com/