[haiku-commits] haiku: hrev46239 - src/system/kernel/platform/u-boot

  • From: revol@xxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 15 Oct 2013 23:06:55 +0200 (CEST)

hrev46239 adds 1 changeset to branch 'master'
old head: 3f92e864a1b468d7e87cd763be515c44d463d269
new head: 7cbc41ae327a966125fd05eb8536931e33b555dd
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=7cbc41a+%5E3f92e86

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

7cbc41a: U-Boot: Split fdt_support.cpp, move serial stuff to fdt_serial.cpp

                                          [ François Revol <revol@xxxxxxx> ]

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

Revision:    hrev46239
Commit:      7cbc41ae327a966125fd05eb8536931e33b555dd
URL:         http://cgit.haiku-os.org/haiku/commit/?id=7cbc41a
Author:      François Revol <revol@xxxxxxx>
Date:        Tue Oct 15 21:05:09 2013 UTC

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

4 files changed, 108 insertions(+), 87 deletions(-)
src/system/boot/platform/u-boot/Jamfile          |   3 +-
src/system/kernel/platform/u-boot/Jamfile        |   1 +
src/system/kernel/platform/u-boot/fdt_serial.cpp | 105 +++++++++++++++++++
.../kernel/platform/u-boot/fdt_support.cpp       |  86 ---------------

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

diff --git a/src/system/boot/platform/u-boot/Jamfile 
b/src/system/boot/platform/u-boot/Jamfile
index dbc84fe..9143546 100644
--- a/src/system/boot/platform/u-boot/Jamfile
+++ b/src/system/boot/platform/u-boot/Jamfile
@@ -51,6 +51,7 @@ BootMergeObject boot_platform_u-boot_common.o :
        cpu.cpp
        uimage.cpp
        video.cpp
+       fdt_serial.cpp
        fdt_support.cpp
        openfirmware.cpp
        $(genericPlatformSources)
@@ -248,7 +249,7 @@ Depends haiku-mmc-image : haiku-$(HAIKU_BOOT_BOARD).mmc ;
 SEARCH on [ FGristFiles $(genericPlatformSources) ]
        = [ FDirName $(HAIKU_TOP) src system boot platform generic ] ;
 
-SEARCH on [ FGristFiles openfirmware.cpp fdt_support.cpp ]
+SEARCH on [ FGristFiles openfirmware.cpp fdt_serial.cpp fdt_support.cpp ]
        = [ FDirName $(HAIKU_TOP) src system kernel platform u-boot ] ;
 
 SEARCH on [ FGristFiles $(libFDTSources) ]
diff --git a/src/system/kernel/platform/u-boot/Jamfile 
b/src/system/kernel/platform/u-boot/Jamfile
index dbadd8c..4cfa6e4 100644
--- a/src/system/kernel/platform/u-boot/Jamfile
+++ b/src/system/kernel/platform/u-boot/Jamfile
@@ -16,6 +16,7 @@ local libFDTSources =
 
 KernelMergeObject kernel_platform_u-boot.o :
        platform.cpp
+       fdt_serial.cpp
        fdt_support.cpp
        openfirmware.cpp
        $(libFDTSources)
diff --git a/src/system/kernel/platform/u-boot/fdt_serial.cpp 
b/src/system/kernel/platform/u-boot/fdt_serial.cpp
new file mode 100644
index 0000000..628fee7
--- /dev/null
+++ b/src/system/kernel/platform/u-boot/fdt_serial.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2012, François Revol, revol@xxxxxxx.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include <KernelExport.h>
+#include <ByteOrder.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <sys/cdefs.h>
+
+#include <arch/generic/debug_uart.h>
+#include <arch/generic/debug_uart_8250.h>
+
+extern "C" {
+#include <fdt.h>
+#include <libfdt.h>
+#include <libfdt_env.h>
+};
+
+
+extern "C" DebugUART *debug_uart_from_fdt(const void *fdt);
+
+
+DebugUART *
+debug_uart_from_fdt(const void *fdt)
+{
+       const char *name;
+       const char *type;
+       int node;
+       int len;
+       phys_addr_t regs;
+       int32 clock = 0;
+       int32 speed = 0;
+       const void *prop;
+       DebugUART *uart = NULL;
+
+       if (fdt == NULL)
+               return NULL;
+
+       name = fdt_get_alias(fdt, "serial");
+       if (name == NULL)
+               name = fdt_get_alias(fdt, "serial0");
+       if (name == NULL)
+               name = fdt_get_alias(fdt, "serial1");
+       // TODO: else use /chosen linux,stdout-path
+       if (name == NULL)
+               return NULL;
+
+       node = fdt_path_offset(fdt, name);
+       //dprintf("serial: using '%s', node %d\n", name, node);
+       if (node < 0)
+               return NULL;
+
+       type = (const char *)fdt_getprop(fdt, node, "device_type", &len);
+       //dprintf("serial: type: '%s'\n", type);
+       if (type == NULL || strcmp(type, "serial"))
+               return NULL;
+
+       // determine the MMIO address
+       // TODO: ppc460 use 64bit addressing, but U-Boot seems to map it below 
4G,
+       // and the FDT is not very clear. libfdt is also getting 64bit addr 
support.
+       // so FIXME someday.
+       prop = fdt_getprop(fdt, node, "virtual-reg", &len);
+       if (prop && len == 4) {
+               regs = fdt32_to_cpu(*(uint32_t *)prop);
+               //dprintf("serial: virtual-reg 0x%08llx\n", (int64)regs);
+       } else {
+               prop = fdt_getprop(fdt, node, "reg", &len);
+               if (prop && len >= 4) {
+                       regs = fdt32_to_cpu(*(uint32_t *)prop);
+                       //dprintf("serial: reg 0x%08llx\n", (int64)regs);
+               } else
+                       return NULL;
+       }
+
+       // get the UART clock rate
+       prop = fdt_getprop(fdt, node, "clock-frequency", &len);
+       if (prop && len == 4) {
+               clock = fdt32_to_cpu(*(uint32_t *)prop);
+               //dprintf("serial: clock %ld\n", clock);
+       }
+
+       // get current speed (XXX: not yet passed over)
+       prop = fdt_getprop(fdt, node, "current-speed", &len);
+       if (prop && len == 4) {
+               speed = fdt32_to_cpu(*(uint32_t *)prop);
+               //dprintf("serial: speed %ld\n", speed);
+       }
+
+       if (fdt_node_check_compatible(fdt, node, "ns16550a") == 1
+               || fdt_node_check_compatible(fdt, node, "ns16550") == 1) {
+               uart = arch_get_uart_8250(regs, clock);
+               //dprintf("serial: using 8250\n");
+               // XXX:assume speed is already set
+               (void)speed;
+       } else {
+               // TODO: handle more UART types
+               // for when we can use U-Boot's console
+               panic("Unknown UART type %s", type);
+       }
+
+       return uart;
+}
+
diff --git a/src/system/kernel/platform/u-boot/fdt_support.cpp 
b/src/system/kernel/platform/u-boot/fdt_support.cpp
index 63e92dc..d917f0b 100644
--- a/src/system/kernel/platform/u-boot/fdt_support.cpp
+++ b/src/system/kernel/platform/u-boot/fdt_support.cpp
@@ -9,9 +9,6 @@
 #include <stdio.h>
 #include <sys/cdefs.h>
 
-#include <arch/generic/debug_uart.h>
-#include <arch/generic/debug_uart_8250.h>
-
 extern "C" {
 #include <fdt.h>
 #include <libfdt.h>
@@ -24,7 +21,6 @@ void *gFDT;
 #endif
 
 extern "C" void dump_fdt(const void *fdt);
-extern "C" DebugUART *debug_uart_from_fdt(const void *fdt);
 
 //#define FDT_DUMP_NODES
 //#define FDT_DUMP_PROPS
@@ -120,85 +116,3 @@ void dump_fdt(const void *fdt)
 #endif
 }
 
-
-DebugUART *
-debug_uart_from_fdt(const void *fdt)
-{
-       const char *name;
-       const char *type;
-       int node;
-       int len;
-       phys_addr_t regs;
-       int32 clock = 0;
-       int32 speed = 0;
-       const void *prop;
-       DebugUART *uart = NULL;
-
-       if (fdt == NULL)
-               return NULL;
-
-       name = fdt_get_alias(fdt, "serial");
-       if (name == NULL)
-               name = fdt_get_alias(fdt, "serial0");
-       if (name == NULL)
-               name = fdt_get_alias(fdt, "serial1");
-       // TODO: else use /chosen linux,stdout-path
-       if (name == NULL)
-               return NULL;
-
-       node = fdt_path_offset(fdt, name);
-       //dprintf("serial: using '%s', node %d\n", name, node);
-       if (node < 0)
-               return NULL;
-
-       type = (const char *)fdt_getprop(fdt, node, "device_type", &len);
-       //dprintf("serial: type: '%s'\n", type);
-       if (type == NULL || strcmp(type, "serial"))
-               return NULL;
-
-       // determine the MMIO address
-       // TODO: ppc460 use 64bit addressing, but U-Boot seems to map it below 
4G,
-       // and the FDT is not very clear. libfdt is also getting 64bit addr 
support.
-       // so FIXME someday.
-       prop = fdt_getprop(fdt, node, "virtual-reg", &len);
-       if (prop && len == 4) {
-               regs = fdt32_to_cpu(*(uint32_t *)prop);
-               //dprintf("serial: virtual-reg 0x%08llx\n", (int64)regs);
-       } else {
-               prop = fdt_getprop(fdt, node, "reg", &len);
-               if (prop && len >= 4) {
-                       regs = fdt32_to_cpu(*(uint32_t *)prop);
-                       //dprintf("serial: reg 0x%08llx\n", (int64)regs);
-               } else
-                       return NULL;
-       }
-
-       // get the UART clock rate
-       prop = fdt_getprop(fdt, node, "clock-frequency", &len);
-       if (prop && len == 4) {
-               clock = fdt32_to_cpu(*(uint32_t *)prop);
-               //dprintf("serial: clock %ld\n", clock);
-       }
-
-       // get current speed (XXX: not yet passed over)
-       prop = fdt_getprop(fdt, node, "current-speed", &len);
-       if (prop && len == 4) {
-               speed = fdt32_to_cpu(*(uint32_t *)prop);
-               //dprintf("serial: speed %ld\n", speed);
-       }
-
-       if (fdt_node_check_compatible(fdt, node, "ns16550a") == 1
-               || fdt_node_check_compatible(fdt, node, "ns16550") == 1) {
-               uart = arch_get_uart_8250(regs, clock);
-               //dprintf("serial: using 8250\n");
-               // XXX:assume speed is already set
-               (void)speed;
-       } else {
-               // TODO: handle more UART types
-               // for when we can use U-Boot's console
-               panic("Unknown UART type %s", type);
-       }
-
-       return uart;
-}
-


Other related posts:

  • » [haiku-commits] haiku: hrev46239 - src/system/kernel/platform/u-boot - revol