[haiku-commits] BRANCH mmu_man-github.sam460ex [4d84cda92d5d] src/system/boot/platform/u-boot src/system/kernel/arch/ppc src/system/kernel build/jam

  • From: mmu_man-github.sam460ex <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 22 Oct 2016 16:15:32 +0200 (CEST)

added 10 changesets to branch 'refs/remotes/mmu_man-github/sam460ex'
old head: 9346f5ebceab0c435fe88d3abb282235096fe90c
new head: 4d84cda92d5d4202e681b1281b77300c7197e8ea
overview: https://github.com/mmuman/haiku/compare/9346f5ebceab...4d84cda92d5d

----------------------------------------------------------------------------

4037ffb83f61: PPC: u-boot: define bootloader stack in linker script
  
  Align with ARM stuff from hrev47834. It's not yet used though.

a309dc5f50d0: PPC: add stub for arch_int_assign_to_cpu

cd8b03eb8698: PPC: add stub for arch_smp_send_multicast_ici

8e7490b6dc57: HACK: U-Boot: add a GraphicsDevice arch_video prober + hardcode 
Sam460
  
  Sadly even digging the RAM for a valid GraphicsDevice struct fails
  on my Sam460 board... so for now I hardcode the address anyway.
  
  TODO: clean this mess

cc86b6caa6cf: PPC: work around a gcc/binutils bug on DEBUG build
  
  cf. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37758

fe46afb724b8: HACK: PPC: stub out arch_cpu_user_{memcpy,memset,strlcpy}
  
  Someone should write the PPC asm for this...

ad4295d3fbe5: HACK: PPC: work around some atomic issue
  
  TODO: Is it still needed?

2fc2941517a7: HACK: PPC: work around some atomic issue
  
  TODO: Is this still needed?

4a6572a1d44e: FIXME: (disabled) PPC: add generic atomic implementation

4d84cda92d5d: HACK: PPC: add some build flags to try to work around alignment 
issue
  
  didn't really work...

                                          [ François Revol <revol@xxxxxxx> ]

----------------------------------------------------------------------------

12 files changed, 495 insertions(+), 9 deletions(-)
build/jam/ArchitectureRules                      |  10 +
src/system/boot/platform/u-boot/Jamfile          |   1 +
src/system/boot/platform/u-boot/arch/ppc/shell.S |   3 +
.../boot/platform/u-boot/video_gd_probe.cpp      | 327 +++++++++++++++++++
src/system/kernel/arch/ppc/arch_asm.S            | 118 +++++++
src/system/kernel/arch/ppc/arch_int.cpp          |   7 +
src/system/kernel/arch/ppc/arch_smp.cpp          |   7 +
.../classic/PPCVMTranslationMapClassic.cpp       |   4 +-
src/system/kernel/lib/arch/ppc/Jamfile           |   1 +
src/system/kernel/main.cpp                       |   8 +-
src/system/kernel/smp.cpp                        |   8 +-
src/system/ldscripts/ppc/boot_loader_u-boot.ld   |  10 +

############################################################################

Commit:      4037ffb83f619ca219141c1a609bd9e0265e3ed5
Author:      François Revol <revol@xxxxxxx>
Date:        Fri Jun 12 22:09:35 2015 UTC

PPC: u-boot: define bootloader stack in linker script

Align with ARM stuff from hrev47834. It's not yet used though.

----------------------------------------------------------------------------

diff --git a/src/system/boot/platform/u-boot/arch/ppc/shell.S 
b/src/system/boot/platform/u-boot/arch/ppc/shell.S
index 43d2314..add656a 100644
--- a/src/system/boot/platform/u-boot/arch/ppc/shell.S
+++ b/src/system/boot/platform/u-boot/arch/ppc/shell.S
@@ -36,6 +36,8 @@ SYMBOL(_start_common):
        stw             %r2, 0(%r12)
        stw             %r11, gUBootOS-gUBootGlobalData(%r12)   // gUBootOS
 
+       // TODO: set up stack properly like on ARM
+
        b               start_linux_ppc_fdt
 
        // return
@@ -46,6 +48,7 @@ SYMBOL_END(_start_common)
 //XXX: doesn't seem to work
 //.data
 
+.global __stack_end, __stack_start
 
 SYMBOL(gUBootGlobalData):
        .long   0
diff --git a/src/system/ldscripts/ppc/boot_loader_u-boot.ld 
b/src/system/ldscripts/ppc/boot_loader_u-boot.ld
index 5e29f69..06d6d3c 100644
--- a/src/system/ldscripts/ppc/boot_loader_u-boot.ld
+++ b/src/system/ldscripts/ppc/boot_loader_u-boot.ld
@@ -1,6 +1,8 @@
 OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc")
 OUTPUT_ARCH(powerpc)
 
+STACK_SIZE = 16384;
+
 ENTRY(_start)
 SECTIONS
 {
@@ -30,6 +32,14 @@ SECTIONS
        __bss_start = .;
        .sbss : { *(.sbss .sbss.* .gnu.linkonce.sb.*) }
        .bss : { *(.bss .bss.* .gnu.linkonce.b.*) }
+       __bss_end = .;
+
+       .stack : {
+               __stack_start = .;
+               . += STACK_SIZE;
+               . = ALIGN(0x8);
+               __stack_top = .;
+       }
 
        . = ALIGN(0x1000);
        _end = . ;

############################################################################

Commit:      a309dc5f50d0777a55a34ad519a1b2e748bdd4fb
Author:      François Revol <revol@xxxxxxx>
Date:        Thu Nov  5 21:37:16 2015 UTC

PPC: add stub for arch_int_assign_to_cpu

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/ppc/arch_int.cpp 
b/src/system/kernel/arch/ppc/arch_int.cpp
index b4c9778..b866d36 100644
--- a/src/system/kernel/arch/ppc/arch_int.cpp
+++ b/src/system/kernel/arch/ppc/arch_int.cpp
@@ -76,6 +76,13 @@ arch_int_disable_io_interrupt(int irq)
 /* arch_int_*_interrupts() and friends are in arch_asm.S */
 
 
+void
+arch_int_assign_to_cpu(int32 irq, int32 cpu)
+{
+        // intentionally left blank; no SMP support (yet)
+}
+
+
 static void
 print_iframe(struct iframe *frame)
 {

############################################################################

Commit:      cd8b03eb86986853c2d408874a6b7792877b81d4
Author:      François Revol <revol@xxxxxxx>
Date:        Thu Nov  5 21:37:42 2015 UTC

PPC: add stub for arch_smp_send_multicast_ici

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/ppc/arch_smp.cpp 
b/src/system/kernel/arch/ppc/arch_smp.cpp
index dd590b8..9e3966e 100644
--- a/src/system/kernel/arch/ppc/arch_smp.cpp
+++ b/src/system/kernel/arch/ppc/arch_smp.cpp
@@ -33,6 +33,13 @@ arch_smp_send_ici(int32 target_cpu)
 
 
 void
+arch_smp_send_multicast_ici(CPUSet& cpuSet)
+{
+       panic("called arch_smp_send_multicast_ici\n");
+}
+
+
+void
 arch_smp_send_broadcast_ici()
 {
        panic("called arch_smp_send_broadcast_ici\n");

############################################################################

Commit:      8e7490b6dc57f47c98b61526a5dc4ac702dd347b
Author:      François Revol <revol@xxxxxxx>
Date:        Fri Apr 22 15:12:19 2016 UTC

HACK: U-Boot: add a GraphicsDevice arch_video prober + hardcode Sam460

Sadly even digging the RAM for a valid GraphicsDevice struct fails
on my Sam460 board... so for now I hardcode the address anyway.

TODO: clean this mess

----------------------------------------------------------------------------

diff --git a/src/system/boot/platform/u-boot/Jamfile 
b/src/system/boot/platform/u-boot/Jamfile
index a2e84e1..d0e3af8 100644
--- a/src/system/boot/platform/u-boot/Jamfile
+++ b/src/system/boot/platform/u-boot/Jamfile
@@ -52,6 +52,7 @@ BootMergeObject boot_platform_u-boot_common.o :
        cpu.cpp
        uimage.cpp
        video.cpp
+       video_gd_probe.cpp
        fdt_serial.cpp
        fdt_support.cpp
        openfirmware.cpp
diff --git a/src/system/boot/platform/u-boot/video_gd_probe.cpp 
b/src/system/boot/platform/u-boot/video_gd_probe.cpp
new file mode 100644
index 0000000..37c49a8
--- /dev/null
+++ b/src/system/boot/platform/u-boot/video_gd_probe.cpp
@@ -0,0 +1,327 @@
+/*
+ * Copyright 215, François Revol
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include "video.h"
+
+#include <arch/cpu.h>
+#include <boot/stage2.h>
+#include <boot/platform.h>
+#include <boot/menu.h>
+#include <boot/kernel_args.h>
+#include <boot/platform/generic/video.h>
+#include <util/list.h>
+#include <drivers/driver_settings.h>
+#include <board_config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "arch_framebuffer.h"
+#include "arch_mmu.h"
+#include "mmu.h"
+
+
+/*
+       This is a crude hack that tries to find U-Boot's framebuffer 
configuration
+       by probing memory locations known from the U-Boot symbol table.
+       Of course you must have System.map for the U-Boot you actually use.
+       TODO:check for the U-Boot version string
+ */
+
+
+/* U-Boot's own framebuffer descriptor */
+
+typedef struct {
+    unsigned int isaBase;
+    unsigned int pciBase;
+    unsigned int dprBase;
+    unsigned int vprBase;
+    unsigned int cprBase;
+    unsigned int frameAdrs;
+    unsigned int memSize;
+    unsigned int mode;
+    unsigned int gdfIndex;
+    unsigned int gdfBytesPP;
+    unsigned int fg;
+    unsigned int bg;
+    unsigned int plnSizeX;
+    unsigned int plnSizeY;
+    unsigned int winSizeX;
+    unsigned int winSizeY;
+    char modeIdent[80];
+} GraphicDevice;
+
+
+static struct {
+       const char *name;
+       const char *fw;
+       GraphicDevice *gd;      // global GraphicDevice struct from the driver
+       void **fb;      // direct pointer to the framebuffer, should match 
gd->frameAdrs
+       void **fb_phys_base;    // physical address
+} sMatchList[] = {
+#ifdef __POWERPC__
+       {
+               "sm502",
+               "u-boot-2010.06.05_20110414_prod (Sam460)",
+               // nm u-boot| grep 'B sm501$'
+               (GraphicDevice *)0x00011320,
+               // nm u-boot| grep 'B video_fb_address$'
+               (void **)0x000001ec,
+               NULL
+       },
+       {
+               "sm502",
+               "u-boot-2010.06.05_20110414_prod (Sam460)",
+               // nm u-boot| grep 'B sm501$'
+               (GraphicDevice *)0x00011318,
+               // nm u-boot| grep 'B video_fb_address$'
+               (void **)0x000001ec,
+               NULL
+       },
+#endif
+       {}
+};
+
+class ArchGDFrameBuffer : public ArchFramebuffer {
+public:
+                                                       
ArchGDFrameBuffer(addr_t base, GraphicDevice *gd)
+                                                               : 
ArchFramebuffer(base) {
+                                                                       
memcpy(&fGD, gd, sizeof(fGD));
+                                                                       
fPhysicalBase = 0xC84000000LL;
+                                                               }
+                                                       ~ArchGDFrameBuffer() {}
+
+virtual        status_t                        Init();
+virtual        status_t                        Probe();
+virtual        status_t                        SetDefaultMode();
+virtual        status_t                        SetVideoMode(int width, int 
height, int depth);
+
+GraphicDevice                          fGD;
+};
+
+
+typedef struct uboot_gd {
+       // those are the only few members that we can trust
+       // others depend on compile-time config
+       struct board_data *bd;
+       uint32 flags;
+       uint32 baudrate;
+       // those are ARM-only
+       uint32 have_console;
+       uint32 reloc_off;
+       uint32 env_addr;
+       uint32 env_valid;
+       uint32 fb_base;
+} uboot_gd;
+
+extern uboot_gd *gUBootGlobalData;
+
+struct board_data {
+       unsigned long   bi_memstart;    /* start of DRAM memory */
+       uint64  bi_memsize;     /* size  of DRAM memory in bytes */
+       unsigned long   bi_flashstart;  /* start of FLASH memory */
+       unsigned long   bi_flashsize;   /* size  of FLASH memory */
+       unsigned long   bi_flashoffset; /* reserved area for startup monitor */
+       unsigned long   bi_sramstart;   /* start of SRAM memory */
+       unsigned long   bi_sramsize;    /* size  of SRAM memory */
+};
+
+extern "C" ArchFramebuffer*
+video_gd_probe()
+{
+       dprintf("Probing U-Boot's framebuffer config...\n");
+       //      return NULL;
+
+       dprintf("candidates ? ...\n");
+       for (uint8 *pi = (uint8 *)/*0xe500000*/0; pi < (uint8 
*)/*0xe500000*/0+0x13000; pi++) {
+               GraphicDevice *p = (GraphicDevice *)pi;
+               //dprintf("? %p\n", p);
+               if (p->gdfIndex > 5)
+                       continue;
+               if (p->gdfBytesPP != 1
+                       && p->gdfBytesPP != 2
+                       && p->gdfBytesPP != 3
+                       && p->gdfBytesPP != 4)
+                       continue;
+               dprintf("@ %p bytespp %d winSizeX %d winSizeY %d\n", p, 
p->gdfBytesPP, p->winSizeX, p->winSizeY);
+               if (p->winSizeX < 300)
+                       continue;
+               if (p->winSizeY < 200)
+                       continue;
+               if (p->winSizeX > 4000)
+                       continue;
+               if (p->winSizeY > 4000)
+                       continue;
+               dprintf("candidate @ %p\n", p);
+       }
+
+       for (int i = 0; sMatchList[i].name; i++) {
+               // some sanity checks
+               dprintf("GD @ %p ?\n", sMatchList[i].gd);
+               dprintf("bytespp %d winSizeX %d winSizeY %d\n", 
sMatchList[i].gd->gdfBytesPP, sMatchList[i].gd->winSizeX, 
sMatchList[i].gd->winSizeY);
+               if (sMatchList[i].gd->gdfIndex > 5)
+                       continue;
+               if (sMatchList[i].gd->gdfBytesPP != 1
+                       && sMatchList[i].gd->gdfBytesPP != 2
+                       && sMatchList[i].gd->gdfBytesPP != 3
+                       && sMatchList[i].gd->gdfBytesPP != 4)
+                       continue;
+               if (sMatchList[i].gd->winSizeX < 300)
+                       continue;
+               if (sMatchList[i].gd->winSizeY < 200)
+                       continue;
+               if (sMatchList[i].gd->winSizeX > 4000)
+                       continue;
+               if (sMatchList[i].gd->winSizeY > 4000)
+                       continue;
+               dprintf("GD-frameAdrs = %lx ?\n", sMatchList[i].gd->frameAdrs);
+               if ((void *)sMatchList[i].gd->frameAdrs == NULL)
+                       continue;
+               if ((void *)sMatchList[i].gd->frameAdrs != *sMatchList[i].fb)
+                       continue;
+               dprintf("match\n");
+               addr_t base = sMatchList[i].gd->frameAdrs;
+               dprintf("Detected %s card from %s\n", sMatchList[i].name,
+                       sMatchList[i].fw);
+               dprintf("Framebuffer @ %p\n", *sMatchList[i].fb);
+
+           return new ArchGDFrameBuffer(base, sMatchList[i].gd);
+       }
+
+       GraphicDevice forced = {0, 0x84000000LL, 0, 0, 0, 0x84000000, 0, 0, 0, 
1, 0, 0, 0, 0, 640, 400, "test"
+};
+       forced.frameAdrs = mmu_map_physical_memory(0xC84000000LL, 16*1024*1024, 
kDefaultPageFlags);
+       dprintf("forced FB @ %lx\n", forced.frameAdrs);
+       uint32 * p = (uint32 *)forced.frameAdrs;
+       *p++ = 0xffffffff;
+       *p++ = 0x55555555;
+       *p++ = 0xaaaaaaaa;
+       return new ArchGDFrameBuffer(forced.frameAdrs, &forced);
+
+    return NULL;
+}
+
+
+status_t
+ArchGDFrameBuffer::Init()
+{
+       dprintf("FB::Init\n");
+       gKernelArgs.frame_buffer.enabled = true;
+       return B_OK;
+}
+
+
+status_t
+ArchGDFrameBuffer::Probe()
+{
+       dprintf("FB::Probe\n");
+       return B_OK;
+}
+
+
+status_t
+ArchGDFrameBuffer::SetDefaultMode()
+{
+       dprintf("FB::SetDefaultMode\n");
+       status_t result;
+       do {
+               result = SetVideoMode(fGD.winSizeX, fGD.winSizeY, 
fGD.gdfBytesPP * 8);
+       } while (result != B_OK);
+
+       return B_OK;
+}
+
+
+status_t
+ArchGDFrameBuffer::SetVideoMode(int width, int height, int depth)
+{
+       dprintf("FB::SetVideoMode\n");
+//     gKernelArgs.frame_buffer.physical_buffer.start = );;//0xC84000000;
+       fCurrentWidth = width;
+       fCurrentHeight = height;
+       fCurrentDepth = depth;
+       fCurrentBytesPerRow = width * depth / 8;
+       fSize = fCurrentBytesPerRow * fCurrentHeight;
+
+
+
+       //debug_assert(((uint32)&sFramebufferConfig & 0x0f) == 0);
+#if 0
+       sFramebufferConfig.width = width;
+       sFramebufferConfig.height = height;
+       sFramebufferConfig.virtual_width = sFramebufferConfig.width;
+       sFramebufferConfig.virtual_height = sFramebufferConfig.height;
+       sFramebufferConfig.bytes_per_row = 0; // from GPU
+       sFramebufferConfig.bits_per_pixel = depth;
+       sFramebufferConfig.x_offset = 0;
+       sFramebufferConfig.y_offset = 0;
+       sFramebufferConfig.frame_buffer_address = 0; // from GPU
+       sFramebufferConfig.screen_size = 0; // from GPU
+
+       if (depth < 16) {
+               const int colorMapEntries = sizeof(sFramebufferConfig.color_map)
+                       / sizeof(sFramebufferConfig.color_map[0]);
+               for (int i = 0; i < colorMapEntries; i++)
+                       sFramebufferConfig.color_map[i] = 0x1111 * i;
+       }
+
+       status_t result = gMailbox->Write(ARM_MAILBOX_CHANNEL_FRAMEBUFFER,
+               (uint32)&sFramebufferConfig | BCM283X_VIDEO_CORE_L2_COHERENT);
+       if (result != B_OK)
+               return result;
+
+       uint32 value;
+       result = gMailbox->Read(ARM_MAILBOX_CHANNEL_FRAMEBUFFER, value);
+       if (result != B_OK)
+               return result;
+
+       if (value != 0) {
+               dprintf("failed to configure framebuffer: %" B_PRIx32 "\n", 
value);
+               return B_ERROR;
+       }
+
+       if (sFramebufferConfig.frame_buffer_address == 0) {
+               dprintf("didn't get the framebuffer address\n");
+               return B_ERROR;
+       }
+
+       //debug_assert(sFramebufferConfig.x_offset == 0
+       //      && sFramebufferConfig.y_offset == 0
+       //      && sFramebufferConfig.width == (uint32)width
+       //      && sFramebufferConfig.height == (uint32)height
+       //      && sFramebufferConfig.virtual_width == sFramebufferConfig.width
+       //      && sFramebufferConfig.virtual_height == 
sFramebufferConfig.height
+       //      && sFramebufferConfig.bits_per_pixel == (uint32)depth
+       //      && sFramebufferConfig.bytes_per_row
+       //              >= sFramebufferConfig.bits_per_pixel / 8
+       //                      * sFramebufferConfig.width
+       //      && sFramebufferConfig.screen_size >= 
sFramebufferConfig.bytes_per_row
+       //              * sFramebufferConfig.height);
+
+       fPhysicalBase
+               = 
BCM283X_BUS_TO_PHYSICAL(sFramebufferConfig.frame_buffer_address);
+       fSize = sFramebufferConfig.screen_size;
+
+       fBase = (addr_t)mmu_map_physical_memory(fPhysicalBase, fSize, 
kDefaultPageFlags);
+
+       dprintf("video framebuffer: va: %p pa: %p\n", (void *)fBase,
+               (void *)fPhysicalBase);
+
+       fCurrentWidth = width;
+       fCurrentHeight = height;
+       fCurrentDepth = depth;
+       fCurrentBytesPerRow = sFramebufferConfig.bytes_per_row;
+
+       gKernelArgs.frame_buffer.physical_buffer.start = (addr_t)fPhysicalBase;
+#endif
+//     fCurrentWidth = fGD.winSizeX;
+//     fCurrentHeight = fGD.winSizeY;
+//     fCurrentDepth = fGD.gdfBytesPP * 8;
+//     fCurrentBytesPerRow = fGD.gdfBytesPP * fGD.winSizeX;
+       return B_OK;
+}
+

############################################################################

Commit:      cc86b6caa6cfa3d7b09f59b9e8626f53c55bf2a6
Author:      François Revol <revol@xxxxxxx>
Date:        Fri Apr 22 15:19:34 2016 UTC

PPC: work around a gcc/binutils bug on DEBUG build

cf. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37758

----------------------------------------------------------------------------

diff --git 
a/src/system/kernel/arch/ppc/paging/classic/PPCVMTranslationMapClassic.cpp 
b/src/system/kernel/arch/ppc/paging/classic/PPCVMTranslationMapClassic.cpp
index 253bbc4..28147e2 100644
--- a/src/system/kernel/arch/ppc/paging/classic/PPCVMTranslationMapClassic.cpp
+++ b/src/system/kernel/arch/ppc/paging/classic/PPCVMTranslationMapClassic.cpp
@@ -263,7 +263,9 @@ PPCVMTranslationMapClassic::ChangeASID()
 #if KERNEL_BASE != 0x80000000
 #error fix me
 #endif
-       int vsidBase = VSIDBase();
+       // XXX: volatile here prevents a gcc/gas bug on DEBUG build
+       // cf. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37758
+       volatile int vsidBase = VSIDBase();
 
        isync();        // synchronize context
        asm("mtsr       0,%0" : : "g"(vsidBase));

############################################################################

Commit:      fe46afb724b87a5b5b6203664a2b6a442af7874a
Author:      François Revol <revol@xxxxxxx>
Date:        Fri Apr 22 15:32:30 2016 UTC

HACK: PPC: stub out arch_cpu_user_{memcpy,memset,strlcpy}

Someone should write the PPC asm for this...

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/ppc/arch_asm.S 
b/src/system/kernel/arch/ppc/arch_asm.S
index ba641e5..800c0a3 100644
--- a/src/system/kernel/arch/ppc/arch_asm.S
+++ b/src/system/kernel/arch/ppc/arch_asm.S
@@ -358,6 +358,124 @@ FUNCTION(ppc_kernel_thread_root):
 FUNCTION_END(ppc_kernel_thread_root)
 
 
+/* status_t arch_cpu_user_memcpy(void *to, const void *from, size_t size, 
addr_t *faultHandler) */
+FUNCTION(_arch_cpu_user_memcpy):
+#warning FIXME
+#if 0
+       stmfd   sp!, { r4-r6, lr }
+
+       ldr     r6, [r3]
+       ldr     r4, =.L_user_memcpy_error
+       str     r4, [r3]        /* set fault handler */
+       mov     r4, r2, lsr #2  /* size / 4 */
+1:
+       ldr     r5, [r1]
+       str     r5, [r0]
+       add     r1, #4
+       add     r0, #4
+       subs    r4, #1
+       bne     1b
+
+       ands    r4, r2, #3      /* size % 4 */
+       beq     3f
+
+2:
+       ldrb    r5, [r1]
+       strb    r5, [r0]
+       add     r1, #1
+       add     r0, #1
+       subs    r4, #1
+       bne     2b
+3:
+       str     r6, [r3]        /* restore fault handler */
+       mov     r0, #0
+       ldmfd   sp!, { r4-r6, pc }
+
+.L_user_memcpy_error:
+       str     r6, [r3]        /* restore fault handler */
+       mov     r0, #-1
+
+       ldmfd   sp!, { r4-r6, pc }
+#endif
+FUNCTION_END(_arch_cpu_user_memcpy)
+
+/* status_t arch_cpu_user_memset(void *to, char c, size_t count, addr_t 
*faultHandler) */
+FUNCTION(_arch_cpu_user_memset):
+#warning FIXME
+#if 0
+       stmfd   sp!, { r4-r5, lr }
+
+       ldr     r5, [r3]
+       ldr     r4, =.L_user_memset_error
+       str     r4, [r3]
+
+       and     r1, r1, #0xff
+       add     r1, r1, lsl #8
+       add     r1, r1, lsl #16
+       add     r1, r1, lsl #24
+
+       mov     r4, r2, lsr #2  /* count / 4 */
+1:
+       str     r1, [r0]
+       add     r0, r0, #4
+       subs    r4, r4, #1
+       bne     1b
+
+       and     r4, r2, #3      /* count % 4 */
+2:
+       strb    r1, [r0]
+       add     r0, r0, #1
+       subs    r4, r4, #1
+       bne     2b
+
+       mov     r0, #0
+       str     r5, [r3]
+
+       ldmfd   sp!, { r4-r5, pc }
+
+.L_user_memset_error:
+       mov     r0, #-1
+       str     r5, [r3]
+
+       ldmfd   sp!, { r4-r5, pc }
+#endif
+FUNCTION_END(_arch_cpu_user_memset)
+
+/* ssize_t arch_cpu_user_strlcpy(void *to, const void *from, size_t size, 
addr_t *faultHandler) */
+FUNCTION(_arch_cpu_user_strlcpy):
+#warning FIXME
+#if 0
+       stmfd   sp!, { r4-r6, lr }
+       ldr     r5, [r3]
+       ldr     r4, =.L_user_strlcpy_error
+       str     r4, [r3]
+       mov     r6, #0
+1:
+       ldrb    r4, [r1, r6]
+       strb    r4, [r0, r6]
+       add     r6, r6, #1
+       cmp     r4, #0
+       beq     2f
+       cmp     r6, r2          /* reached max length? */
+       blt     1b
+2:
+       mov     r4, #0
+       strb    r4, [r0, r6]
+
+       mov     r0, r6          /* return length */
+       str     r5, [r3]        /* restore fault handler */
+
+       ldmfd   sp!, { r4-r6, pc }
+
+.L_user_strlcpy_error:
+       mov     r0, #-1
+       str     r5, [r3]
+
+       ldmfd   sp!, { r4-r6, pc }
+#endif
+FUNCTION_END(_arch_cpu_user_strlcpy)
+
+
 /*!    \fn void arch_debug_call_with_fault_handler(cpu_ent* cpu,
                jmp_buf jumpBuffer, void (*function)(void*), void* parameter)
 

############################################################################

Commit:      ad4295d3fbe5f4c36562fcb412183de0f919a41e
Author:      François Revol <revol@xxxxxxx>
Date:        Fri Apr 22 15:35:23 2016 UTC

HACK: PPC: work around some atomic issue

TODO: Is it still needed?

----------------------------------------------------------------------------

diff --git a/src/system/kernel/main.cpp b/src/system/kernel/main.cpp
index f3a0a9b..7a32ab8 100644
--- a/src/system/kernel/main.cpp
+++ b/src/system/kernel/main.cpp
@@ -59,7 +59,7 @@
 #include "vm/VMAnonymousCache.h"
 
 
-//#define TRACE_BOOT
+#define TRACE_BOOT
 #ifdef TRACE_BOOT
 #      define TRACE(x...) dprintf("INIT: " x)
 #else
@@ -73,9 +73,9 @@ bool gKernelStartup = true;
 bool gKernelShutdown = false;
 
 static kernel_args sKernelArgs;
-static uint32 sCpuRendezvous;
-static uint32 sCpuRendezvous2;
-static uint32 sCpuRendezvous3;
+static uint32 sCpuRendezvous = 0;
+static uint32 sCpuRendezvous2 = 0;
+static uint32 sCpuRendezvous3 = 0;
 
 static int32 main2(void *);
 

############################################################################

Commit:      2fc2941517a796defed6b2792db666fb549e028b
Author:      François Revol <revol@xxxxxxx>
Date:        Fri Apr 22 15:35:58 2016 UTC

HACK: PPC: work around some atomic issue

TODO: Is this still needed?

----------------------------------------------------------------------------

diff --git a/src/system/kernel/smp.cpp b/src/system/kernel/smp.cpp
index 29e3dfc..3a43838 100644
--- a/src/system/kernel/smp.cpp
+++ b/src/system/kernel/smp.cpp
@@ -29,6 +29,7 @@
 #include <spinlock_contention.h>
 #include <thread.h>
 #include <util/atomic.h>
+#include <atomic>
 #if DEBUG_SPINLOCK_LATENCIES
 #      include <safemode.h>
 #endif
@@ -1394,10 +1395,9 @@ smp_wake_up_non_boot_cpus()
 void
 smp_cpu_rendezvous(uint32* var)
 {
-       atomic_add((int32*)var, 1);
-
-       while (*var < (uint32)sNumCPUs)
-               cpu_wait((int32*)var, sNumCPUs);
+       auto& v = *reinterpret_cast<std::atomic<uint32_t>*>(var);
+       v++;
+       while (v.load() < uint32_t(sNumCPUs)) { }
 }
 
 

############################################################################

Commit:      4a6572a1d44e0c44f40c1349f3998b2c8deb9db9
Author:      François Revol <revol@xxxxxxx>
Date:        Fri Apr 22 15:36:41 2016 UTC

FIXME: (disabled) PPC: add generic atomic implementation

----------------------------------------------------------------------------

diff --git a/src/system/kernel/lib/arch/ppc/Jamfile 
b/src/system/kernel/lib/arch/ppc/Jamfile
index 028bff7..96d049c 100644
--- a/src/system/kernel/lib/arch/ppc/Jamfile
+++ b/src/system/kernel/lib/arch/ppc/Jamfile
@@ -14,6 +14,7 @@ KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o :
        system_time_asm.S
        system_time.c
 
+       #generic_atomic.cpp
        generic_system_time_nsecs.cpp
 
        : $(TARGET_KERNEL_PIC_CCFLAGS)

############################################################################

Commit:      4d84cda92d5d4202e681b1281b77300c7197e8ea
Author:      François Revol <revol@xxxxxxx>
Date:        Fri Apr 22 15:37:59 2016 UTC

HACK: PPC: add some build flags to try to work around alignment issue

didn't really work...

----------------------------------------------------------------------------

diff --git a/build/jam/ArchitectureRules b/build/jam/ArchitectureRules
index 274789f..ce77c5a 100644
--- a/build/jam/ArchitectureRules
+++ b/build/jam/ArchitectureRules
@@ -382,6 +382,16 @@ rule KernelArchitectureSetup architecture
                        # boot time is not fixed.
                        HAIKU_KERNEL_PIC_CCFLAGS = -fPIE ;
                        HAIKU_KERNEL_PIC_LINKFLAGS = -shared -fPIE ;
+                       HAIKU_KERNEL_CCFLAGS += -malign-natural ;
+                       HAIKU_KERNEL_C++FLAGS += -malign-natural ;
+                       HAIKU_BOOT_CCFLAGS += -mno-strict-align ;
+                       HAIKU_BOOT_C++FLAGS += -mno-strict-align ;
+#-malign-natural -mfloat-gprs=no -mno-mfpgpr
+#-mcpu=440fp
+#                      HAIKU_KERNEL_CCFLAGS += -mcpu=750 ;
+#                      HAIKU_KERNEL_C++FLAGS += -mcpu=750 ;
+#                      HAIKU_KERNEL_CCFLAGS += -mcpu=G5 ;
+#                      HAIKU_KERNEL_C++FLAGS += -mcpu=G5 ;
 
                case m68k :
                        # We don't want to have to handle emulating missing FPU 
opcodes for


Other related posts:

  • » [haiku-commits] BRANCH mmu_man-github.sam460ex [4d84cda92d5d] src/system/boot/platform/u-boot src/system/kernel/arch/ppc src/system/kernel build/jam - mmu_man-github . sam460ex