Changeset 5d494b3 in mainline


Ignore:
Timestamp:
2008-04-03T20:05:06Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
776f2e6
Parents:
dfa7bac
Message:

Each architecture should only announce its endianity.
The conversion macros should be defined only once.

Location:
kernel
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/include/byteorder.h

    rdfa7bac r5d494b3  
    3636#define KERN_amd64_BYTEORDER_H_
    3737
    38 #include <byteorder.h>
    39 
    4038/* AMD64 is little-endian */
    41 #define uint16_t_le2host(n)             (n)
    42 #define uint32_t_le2host(n)             (n)
    43 #define uint64_t_le2host(n)             (n)
    44 
    45 #define uint16_t_be2host(n)             uint16_t_byteorder_swap(n)
    46 #define uint32_t_be2host(n)             uint32_t_byteorder_swap(n)
    47 #define uint64_t_be2host(n)             uint64_t_byteorder_swap(n)
     39#define ARCH_IS_LITTLE_ENDIAN
    4840
    4941#endif
  • kernel/arch/arm32/include/byteorder.h

    rdfa7bac r5d494b3  
    3737#define KERN_arm32_BYTEORDER_H_
    3838
    39 #include <byteorder.h>
    40 
    4139#ifdef BIG_ENDIAN
    42 
    43 #define uint16_t_le2host(n)             uint16_t_byteorder_swap(n)
    44 #define uint32_t_le2host(n)             uint32_t_byteorder_swap(n)
    45 #define uint64_t_le2host(n)             uint64_t_byteorder_swap(n)
    46 
    47 #define uint16_t_be2host(n)             (n)
    48 #define uint32_t_be2host(n)             (n)
    49 #define uint64_t_be2host(n)             (n)
    50 
     40#define ARCH_IS_BIG_ENDIAN
    5141#else
    52 
    53 #define uint16_t_le2host(n)             (n)
    54 #define uint32_t_le2host(n)             (n)
    55 #define uint64_t_le2host(n)             (n)
    56 
    57 #define uint16_t_be2host(n)             uint16_t_byteorder_swap(n)
    58 #define uint32_t_be2host(n)             uint32_t_byteorder_swap(n)
    59 #define uint64_t_be2host(n)             uint64_t_byteorder_swap(n)
    60 
     42#define ARCH_IS_LITTLE_ENDIAN
    6143#endif
    6244
  • kernel/arch/ia32/include/byteorder.h

    rdfa7bac r5d494b3  
    3636#define KERN_ia32_BYTEORDER_H_
    3737
    38 #include <byteorder.h>
    39 
    4038/* IA-32 is little-endian */
    41 #define uint16_t_le2host(n)             (n)
    42 #define uint32_t_le2host(n)             (n)
    43 #define uint64_t_le2host(n)             (n)
    44 
    45 #define uint16_t_be2host(n)             uint16_t_byteorder_swap(n)
    46 #define uint32_t_be2host(n)             uint32_t_byteorder_swap(n)
    47 #define uint64_t_be2host(n)             uint64_t_byteorder_swap(n)
     39#define ARCH_IS_LITTLE_ENDIAN
    4840
    4941#endif
  • kernel/arch/ia64/include/byteorder.h

    rdfa7bac r5d494b3  
    3636#define KERN_ia64_BYTEORDER_H_
    3737
    38 #include <byteorder.h>
    39 
    4038/* IA-64 is little-endian */
    41 #define uint16_t_le2host(n)             (n)
    42 #define uint32_t_le2host(n)             (n)
    43 #define uint64_t_le2host(n)             (n)
    44 
    45 #define uint16_t_be2host(n)             uint16_t_byteorder_swap(n)
    46 #define uint32_t_be2host(n)             uint32_t_byteorder_swap(n)
    47 #define uint64_t_be2host(n)             uint64_t_byteorder_swap(n)
     39#define ARCH_IS_LITTLE_ENDIAN
    4840
    4941#endif
  • kernel/arch/mips32/include/byteorder.h

    rdfa7bac r5d494b3  
    3636#define KERN_mips32_BYTEORDER_H_
    3737
    38 #include <byteorder.h>
    39 
    4038#ifdef BIG_ENDIAN
    41 
    42 #define uint16_t_le2host(n)             uint16_t_byteorder_swap(n)
    43 #define uint32_t_le2host(n)             uint32_t_byteorder_swap(n)
    44 #define uint64_t_le2host(n)             uint64_t_byteorder_swap(n)
    45 
    46 #define uint16_t_be2host(n)             (n)
    47 #define uint32_t_be2host(n)             (n)
    48 #define uint64_t_be2host(n)             (n)
    49 
     39#define ARCH_IS_BIG_ENDIAN
    5040#else
    51 
    52 #define uint16_t_le2host(n)             (n)
    53 #define uint32_t_le2host(n)             (n)
    54 #define uint64_t_le2host(n)             (n)
    55 
    56 #define uint16_t_be2host(n)             uint16_t_byteorder_swap(n)
    57 #define uint32_t_be2host(n)             uint32_t_byteorder_swap(n)
    58 #define uint64_t_be2host(n)             uint64_t_byteorder_swap(n)
    59 
     41#define ARCH_IS_LITTLE_ENDIAN
    6042#endif
    6143
  • kernel/arch/mips32/src/drivers/arc.c

    rdfa7bac r5d494b3  
    3737#include <print.h>
    3838#include <arch.h>
    39 #include <arch/byteorder.h>
     39#include <byteorder.h>
    4040#include <arch/mm/frame.h>
    4141#include <mm/frame.h>
  • kernel/arch/ppc32/include/byteorder.h

    rdfa7bac r5d494b3  
    3636#define KERN_ppc32_BYTEORDER_H_
    3737
    38 #include <byteorder.h>
    39 
    40 #define uint16_t_le2host(n)             uint16_t_byteorder_swap(n)
    41 #define uint32_t_le2host(n)             uint32_t_byteorder_swap(n)
    42 #define uint64_t_le2host(n)             uint64_t_byteorder_swap(n)
    43 
    44 #define uint16_t_be2host(n)             (n)
    45 #define uint32_t_be2host(n)             (n)
    46 #define uint64_t_be2host(n)             (n)
     38#define ARCH_IS_BIG_ENDIAN
    4739
    4840#endif
  • kernel/arch/ppc64/include/byteorder.h

    rdfa7bac r5d494b3  
    3636#define KERN_ppc64_BYTEORDER_H_
    3737
    38 #include <byteorder.h>
    39 
    40 #define uint16_t_le2host(n)             uint16_t_byteorder_swap(n)
    41 #define uint32_t_le2host(n)             uint32_t_byteorder_swap(n)
    42 #define uint64_t_le2host(n)             uint64_t_byteorder_swap(n)
    43 
    44 #define uint16_t_be2host(n)             (n)
    45 #define uint32_t_be2host(n)             (n)
    46 #define uint64_t_be2host(n)             (n)
     38#define ARCH_IS_BIG_ENDIAN
    4739
    4840#endif
  • kernel/arch/sparc64/include/byteorder.h

    rdfa7bac r5d494b3  
    3636#define KERN_sparc64_BYTEORDER_H_
    3737
    38 #include <byteorder.h>
    39 
    40 #define uint16_t_le2host(n)             uint16_t_byteorder_swap(n)
    41 #define uint32_t_le2host(n)             uint32_t_byteorder_swap(n)
    42 #define uint64_t_le2host(n)             uint64_t_byteorder_swap(n)
    43 
    44 #define uint16_t_be2host(n)             (n)
    45 #define uint32_t_be2host(n)             (n)
    46 #define uint64_t_be2host(n)             (n)
     38#define ARCH_IS_BIG_ENDIAN
    4739
    4840#endif
  • kernel/generic/include/byteorder.h

    rdfa7bac r5d494b3  
    3636#define KERN_BYTEORDER_H_
    3737
     38#include <arch/byteorder.h>
     39
     40#if !(defined(ARCH_IS_BIG_ENDIAN) ^ defined(ARCH_IS_LITTLE_ENDIAN))
     41#error The architecture must be either big-endian or little-endian.
     42#endif
     43
     44#ifdef ARCH_IS_BIG_ENDIAN
     45
     46#define uint16_t_le2host(n)             uint16_t_byteorder_swap(n)
     47#define uint32_t_le2host(n)             uint32_t_byteorder_swap(n)
     48#define uint64_t_le2host(n)             uint64_t_byteorder_swap(n)
     49
     50#define uint16_t_be2host(n)             (n)
     51#define uint32_t_be2host(n)             (n)
     52#define uint64_t_be2host(n)             (n)
     53
     54#else
     55
     56#define uint16_t_le2host(n)             (n)
     57#define uint32_t_le2host(n)             (n)
     58#define uint64_t_le2host(n)             (n)
     59
     60#define uint16_t_be2host(n)             uint16_t_byteorder_swap(n)
     61#define uint32_t_be2host(n)             uint32_t_byteorder_swap(n)
     62#define uint64_t_be2host(n)             uint64_t_byteorder_swap(n)
     63
     64#endif
     65
    3866static inline uint64_t uint64_t_byteorder_swap(uint64_t n)
    3967{
  • kernel/generic/src/debug/symtab.c

    rdfa7bac r5d494b3  
    3737
    3838#include <symtab.h>
    39 #include <arch/byteorder.h>
     39#include <byteorder.h>
    4040#include <func.h>
    4141#include <print.h>
     
    5454        count_t i;
    5555
    56         for (i=1;symbol_table[i].address_le;++i) {
     56        for (i = 1; symbol_table[i].address_le; ++i) {
    5757                if (addr < uint64_t_le2host(symbol_table[i].address_le))
    5858                        break;
    5959        }
    60         if (addr >= uint64_t_le2host(symbol_table[i-1].address_le))
    61                 return symbol_table[i-1].symbol_name;
     60        if (addr >= uint64_t_le2host(symbol_table[i - 1].address_le))
     61                return symbol_table[i - 1].symbol_name;
    6262        return NULL;
    6363}
     
    7373        unsigned int namelen = strlen(name);
    7474        char *curname;
    75         int i,j;
     75        int i, j;
    7676        int colonoffset = -1;
    7777
    78         for (i=0;name[i];i++)
     78        for (i = 0; name[i]; i++)
    7979                if (name[i] == ':') {
    8080                        colonoffset = i;
     
    8282                }
    8383
    84         for (i=*startpos;symbol_table[i].address_le;++i) {
     84        for (i = *startpos; symbol_table[i].address_le; ++i) {
    8585                /* Find a ':' in name */
    8686                curname = symbol_table[i].symbol_name;
    87                 for (j=0; curname[j] && curname[j] != ':'; j++)
     87                for (j = 0; curname[j] && curname[j] != ':'; j++)
    8888                        ;
    8989                if (!curname[j])
     
    9595                if (strncmp(curname, name, namelen) == 0) {
    9696                        *startpos = i;
    97                         return curname+namelen;
     97                        return curname + namelen;
    9898                }
    9999        }
     
    116116
    117117        i = 0;
    118         while ((hint=symtab_search_one(name, &i))) {
     118        while ((hint = symtab_search_one(name, &i))) {
    119119                if (!strlen(hint)) {
    120120                        addr =  uint64_t_le2host(symbol_table[i].address_le);
     
    152152int symtab_compl(char *input)
    153153{
    154         char output[MAX_SYMBOL_NAME+1];
     154        char output[MAX_SYMBOL_NAME + 1];
    155155        int startpos = 0;
    156156        char *foundtxt;
     
    173173                startpos++;
    174174                if (!found)
    175                         strncpy(output, foundtxt, strlen(foundtxt)+1);
     175                        strncpy(output, foundtxt, strlen(foundtxt) + 1);
    176176                else {
    177                         for (i=0; output[i] && foundtxt[i] && output[i]==foundtxt[i]; i++)
     177                        for (i = 0; output[i] && foundtxt[i] &&
     178                             output[i] == foundtxt[i]; i++)
    178179                                ;
    179180                        output[i] = '\0';
  • kernel/generic/src/lib/rd.c

    rdfa7bac r5d494b3  
    3939
    4040#include <lib/rd.h>
    41 #include <arch/byteorder.h>
     41#include <byteorder.h>
    4242#include <mm/frame.h>
    4343#include <sysinfo/sysinfo.h>
Note: See TracChangeset for help on using the changeset viewer.