Skip to contentSkip to conversation

word alignment fixes for word aligned NS16550 UART peripheral

PATCH New jean-paul.saman at philips.com 2 participants 2 messages Feb 23, 2005 – Feb 24, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 word alignment fixes for word aligned NS16550 UART peripheral

The patch is created against current CVS 2005 feb. 23 and fixes problems for boards that only have word access to the NS16550 UART peripheral.

CHANGELOG:
* Patch by Jean-Paul Saman, 23 Feb 2005
common/cmd_bdinfo.c - fixes bug with negative baudrate:
correct use of unsigned long datatype for
bi_baudrate,
properly cast bd_t *bd = (bd_t*) gd->bd; make information more clear:
print_num("DRAM bank nr", i);
include/asm-arm/u-boot.h - fixes bug with negative baudrate:
use of unsigned long for bi_baudrate and adding an unsigned char pad[2] makes the struct
word aligned
changed ulong into unsigned long for consistency
include/ns16550.h - fixes alignement bug with UART that only supports
word aligned access:

                      removed "__attribute__ ((packed));" for 

"(CFG_NS16550_REG_SIZE == 4)"
GCC generates bytes access when it encounters the
packed attribute regardless
if the struct is already word aligned for a
platform. Peripherals that can only
handle word aligned access won't work properly when
accessed with byte access.
The struct NS16550 is already word aligned for
REG_SIZE = 4, so there is no need
to packed the struct in that case.

Kind greetings,

Jean-Paul Saman

Philips Semiconductors CTO/RTG
Philips HighTech Campus, building WDB 3.29
Professor van den Holstlaan 4
5655 AA Eindhoven
tel: +31 (0)40 27 45131
-------------- next part --------------
A non-text attachment was scrubbed...
Name: u-boot-20050223-alignment-jpsaman-1.patch
Type: application/octet-stream
Size: 4199 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20050223/738d6358/attachment.obj

#1 lore raw

PATCH 1/1 word alignment fixes for word aligned NS16550 UART peripheral

Dear Jean-Paul,

Quoted 20 lines · in message <OF43B05629.5234CA85-ONC1256FB1.003C850C-C1256FB1.003CAA59@philips.c…

The patch is created against current CVS 2005 feb. 23 and fixes problems for boards that only have word access to the NS16550 UART peripheral.

CHANGELOG:
* Patch by Jean-Paul Saman, 23 Feb 2005
common/cmd_bdinfo.c - fixes bug with negative baudrate:
correct use of unsigned long datatype for
bi_baudrate,
properly cast bd_t *bd = (bd_t*) gd->bd; make information more clear:
print_num("DRAM bank nr", i);
include/asm-arm/u-boot.h - fixes bug with negative baudrate:
use of unsigned long for bi_baudrate and adding an unsigned char pad[2] makes the struct
word aligned
changed ulong into unsigned long for consistency
include/ns16550.h - fixes alignement bug with UART that only supports
word aligned access:

                      removed "__attribute__ ((packed));" for 
Quoted 10 lines

"(CFG_NS16550_REG_SIZE == 4)"
GCC generates bytes access when it encounters the
packed attribute regardless
if the struct is already word aligned for a
platform. Peripherals that can only
handle word aligned access won't work properly when
accessed with byte access.
The struct NS16550 is already word aligned for
REG_SIZE = 4, so there is no need
to packed the struct in that case.

I reject this patch because I cannot read the "CHANGELOG". Please stick to standard netiquette rules for formatting. See also the Coding Style rules in the README.

common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 int do_bdinfo ( cmd_tbl_t *cmdtp, int fl · line 219

Quoted 9 lines

diff -X ignore -urNpb u-boot-cvs/common/cmd_bdinfo.c u-boot-aps/common/cmd_bdinfo.c

common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 renamed from common/cmd_bdinfo.c 2004-12-31 10:32:50.000000000 +0100 +1 -1
@@ -216,14 +216,14 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int fl
        DECLARE_GLOBAL_DATA_PTR;
 
        int i;
-       bd_t *bd = gd->bd;
+       bd_t *bd = (bd_t*) gd->bd;

Why do you add a cast here? None is needed - "bd" is already of type "bd_t *". Rejected.

common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 int do_bdinfo ( cmd_tbl_t *cmdtp, int fl · line 220

Quoted 2 lines
common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 renamed from common/cmd_bdinfo.c 2004-12-31 10:32:50.000000000 +0100 +1 -1
-               print_num("DRAM bank",  i);
+               print_num("DRAM bank nr",       i);

Why do you change the output format here? Rejected.

common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 int do_bdinfo ( cmd_tbl_t *cmdtp, int fl · line 239

Quoted 6 lines
common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 renamed from common/cmd_bdinfo.c 2004-12-31 10:32:50.000000000 +0100 +1 -1
@@ -236,7 +236,7 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int fl
                "ip_addr     = ");
        print_IPaddr (bd->bi_ip_addr);
        printf ("\n"
-               "baudrate    = %d bps\n", bd->bi_baudrate);
+               "baudrate    = %u bps\n", bd->bi_baudrate );

How could you end up with a negative baudrate?

common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 line 33

Quoted 7 lines
common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 renamed from common/cmd_bdinfo.c 2004-12-31 10:32:50.000000000 +0100 +2 -1
+++ u-boot-aps/include/asm-arm/u-boot.h 2005-02-04 15:24:04.000000000 +0100
@@ -30,16 +30,17 @@
 #define _U_BOOT_H_     1
 
 typedef struct bd_info {
-    int                        bi_baudrate;    /* serial console baudrate */
+    unsigned long      bi_baudrate;    /* serial console baudrate */

Not necessary.

common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 line 36

Quoted 3 lines
common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 renamed from common/cmd_bdinfo.c 2004-12-31 10:32:50.000000000 +0100 +1 -0
     unsigned long      bi_ip_addr;     /* IP Address */
     unsigned char      bi_enetaddr[6]; /* Ethernet adress */
+    unsigned char       pad[2];

Not necessary.

common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 line 39

Quoted 5 lines
common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 renamed from common/cmd_bdinfo.c 2004-12-31 10:32:50.000000000 +0100 +2 -2
     struct environment_s              *bi_env;
-    ulong              bi_arch_number; /* unique id for this board */
-    ulong              bi_boot_params; /* where this board expects params */
+    unsigned long       bi_arch_number;        /* unique id for this board */
+    unsigned long       bi_boot_params;        /* where this board expects params */

Bogus change.

common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 line 43

Quoted 6 lines
common/cmd_bdinfo.c 2005-02-23 09:18:42.000000000 +0100 renamed from common/cmd_bdinfo.c 2004-12-31 10:32:50.000000000 +0100 +2 -2
     struct                             /* RAM configuration */
     {
-       ulong start;
-       ulong size;
+       unsigned long start;
+       unsigned long size;

Bogus change.

Rejected.

Best regards,

Wolfgang Denk

Signature · 4 lines
See us @ Embedded World, Nuremberg, Feb 22 - 24,  Hall 10.0 Booth 310
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Humans do claim a great deal for that particular emotion (love).
	-- Spock, "The Lights of Zetar", stardate 5725.6