Changeset 13107

Show
Ignore:
Timestamp:
10/19/09 16:46:20 (1 month ago)
Author:
BrainSlayer
Message:

current progress

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ar5315_microredboot/microredboot/CHANGELOG

    r13097 r13107  
     119.10.09 
     2    * added pb44 compile target and added some changes to the stub. ar7100 remains untested, dont flash it 
     3 
    1416.10.09 
    25    * added some ar7100 specific functions to decompression stub. still alot todo 
  • ar5315_microredboot/microredboot/boot/src/Makefile

    r13099 r13107  
    2424#       and eventually executed. It will be in kseg0. 
    2525# 
     26 
     27REWRITE_REVISION_H1 := $(shell echo -n '\#define SVN_REVISION "' > revision.h) 
     28REWRITE_REVISION_H2 := $(shell svnversion -n ../ >> revision.h) 
     29REWRITE_REVISION_H3 := $(shell echo '"' >> revision.h) 
     30 
     31 
    2632CC = /xfs/toolchains/staging_dir_mips/bin/mips-linux-gcc 
    2733LD = /xfs/toolchains/staging_dir_mips/bin/mips-linux-ld 
     
    2935#LD = /home/seg/DEV/broadcom/ar5315_microredboot/microredboot/tools/ecos_build/gnutools/mipsisa32-elf/bin/mipsisa32-elf-ld 
    3036OBJCOPY = /xfs/toolchains/staging_dir_mips/bin/mips-linux-objcopy  
    31 CFLAGS = -Os -G 0 -mabi=32 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -march=mips32 -Iinclude -Iarch -Ilib -I. -Iinclude/asm-mips/mach-atheros -Iinclude/asm/mach-generic -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__ -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32 -D__KERNEL__ 
     37CFLAGS = -Os -G 0 -mabi=32 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -Iinclude -Iarch -Ilib -I. -Iinclude/asm-mips/mach-atheros -Iinclude/asm/mach-generic -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__ -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32 -D__KERNEL__ 
    3238CFLAGS+= -DCONFIG_MIPS_L1_CACHE_SHIFT=5 -DCONFIG_PAGE_SIZE_4KB -DCONFIG_32BIT -DCONFIG_BOOTLOADER 
    33 AFLAGS = -D__ASSEMBLY__ -G 0 -mabi=32 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -march=mips32 -Iinclude -I. -Iinclude/asm-mips/mach-atheros -Iinclude/asm/mach-generic -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__ -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32 
     39AFLAGS = -D__ASSEMBLY__ -G 0 -mabi=32 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -Iinclude -I. -Iinclude/asm-mips/mach-atheros -Iinclude/asm/mach-generic -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__ -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32 
    3440AFLAGS+= -DCONFIG_MIPS_L1_CACHE_SHIFT=5 -DCONFIG_PAGE_SIZE_4KB -DCONFIG_32BIT -DCONFIG_BOOTLOADER  
     41 
     42ifeq ($(PLATFORM),pb42) 
     43CFLAGS+=-march=mips32r2 
     44AFLAGS+=-march=mips32r2 
     45else 
     46CFLAGS+=-march=mips32 
     47AFLAGS+=-march=mips32 
     48endif 
    3549ifeq ($(PLATFORM),ap51) 
    3650CFLAGS+= -DHAVE_ap51 
     
    6882#endif 
    6983ZRELADDR        = 0x80000400  # 0x80002000 
     84ifeq ($(PLATFORM),pb42) 
    7085BOOTBASE        = 0xbfc00000 
    71  
     86else 
     87BOOTBASE        = 0xbf000000 
     88endif 
    7289 
    7390 
  • ar5315_microredboot/microredboot/boot/src/arch/ar2315.c

    r12370 r13107  
    348348 
    349349} 
     350 
     351static const char *get_system_type(void) 
     352{ 
     353        return "2315/6/7/8"; 
     354} 
  • ar5315_microredboot/microredboot/boot/src/arch/ar5312.c

    r13090 r13107  
    304304 
    305305} 
     306 
     307static const char *get_system_type(void) 
     308{ 
     309        return "5312"; 
     310} 
  • ar5315_microredboot/microredboot/boot/src/arch/ar7100.c

    r13099 r13107  
    9797#define STM_16MB_SECTOR_SIZE  STM_M25P128_SECTOR_SIZE 
    9898 
    99 #define AR7100_SPI_FS           AR7100_SPI_BASE+0x0 
    100 #define AR7100_SPI_CLOCK        AR7100_SPI_BASE+0x4 
    101 #define AR7100_SPI_WRITE        AR7100_SPI_BASE+0x8 
    102 #define AR7100_SPI_READ         AR7100_SPI_BASE+0x0 
    103 #define AR7100_SPI_RD_STATUS    AR7100_SPI_BASE+0xc 
    104  
    105 #define AR7100_SPI_CS_DIS       0x70000 
    106 #define AR7100_SPI_CE_LOW       0x60000 
    107 #define AR7100_SPI_CE_HIGH      0x60100 
    108  
    109 #define AR7100_SPI_CMD_WREN         0x06 
    110 #define AR7100_SPI_CMD_RD_STATUS    0x05 
    111 #define AR7100_SPI_CMD_FAST_READ    0x0b 
    112 #define AR7100_SPI_CMD_PAGE_PROG    0x02 
    113 #define AR7100_SPI_CMD_SECTOR_ERASE 0xd8 
    114  
    115 #define AR7100_SPI_SECTOR_SIZE      (1024*64) 
    116 #define AR7100_SPI_PAGE_SIZE        256 
    117  
    11899#define display(_x)     ar7100_reg_wr_nf(0x18040008, (_x)) 
    119100 
     
    281262 
    282263} 
     264 
     265static const char *get_system_type(void) 
     266{ 
     267        char *chip; 
     268        u32 id; 
     269        u32 rev; 
     270        id = ar7100_reg_rd(AR7100_REV_ID) & AR7100_REV_ID_MASK; 
     271        rev = (id >> REV_ID_REVISION_SHIFT) & REV_ID_REVISION_MASK; 
     272        switch (id & AR7100_REV_ID_CHIP_MASK) { 
     273        case AR7100_REV_ID_AR7130: 
     274                chip = "7130"; 
     275                break; 
     276        case AR7100_REV_ID_AR7141: 
     277                chip = "7141"; 
     278                break; 
     279        case AR7100_REV_ID_AR7161: 
     280                chip = "7161"; 
     281                break; 
     282        case AR7100_REV_ID_AR9130: 
     283                chip = "9130"; 
     284                break; 
     285        case AR7100_REV_ID_AR9132: 
     286                chip = "9132"; 
     287                break; 
     288        case AR7240_REV_1_0: 
     289        case AR7240_REV_1_1: 
     290        case AR7240_REV_1_2: 
     291                chip = "7240"; 
     292                break; 
     293        default: 
     294                chip = "71xx"; 
     295        } 
     296        return chip; 
     297} 
  • ar5315_microredboot/microredboot/boot/src/arch/ar7100_sio.h

    r13098 r13107  
    3535 * Register offsets from base address (in 32b words). 
    3636 */ 
    37 #define RBR             0x00    /* receiver buffer register */ 
    38 #define THR             0x00    /* transmit holding register */ 
    39 #define DLL             0x00    /* divisor latch */ 
    40 #define IER             0x01    /* interrupt enable register */ 
    41 #define DLM             0x01    /* divisor latch(MS) */ 
    42 #define IIR             0x02    /* interrupt identification register */ 
    43 #define FCR             0x02    /* FIFO control register */ 
    44 #define LCR             0x03    /* line control register */ 
    45 #define MCR             0x04    /* modem control register */ 
    46 #define LSR             0x05    /* line status register */ 
    47 #define MSR             0x06    /* modem status register */ 
    48 #define SCR             0x07    /* scratch register */ 
     37#define RBR             0x00   /* receiver buffer register */ 
     38#define THR             0x00   /* transmit holding register */ 
     39#define DLL             0x00   /* divisor latch */ 
     40#define IER             0x01   /* interrupt enable register */ 
     41#define DLM             0x01   /* divisor latch(MS) */ 
     42#define IIR             0x02   /* interrupt identification register */ 
     43#define FCR             0x02   /* FIFO control register */ 
     44#define LCR             0x03   /* line control register */ 
     45#define MCR             0x04   /* modem control register */ 
     46#define LSR             0x05   /* line status register */ 
     47#define MSR             0x06   /* modem status register */ 
     48#define SCR             0x07   /* scratch register */ 
    4949 
    5050/* 
    5151 * Line Control Register 
    5252 */ 
    53 #define CHAR_LEN_5      0x00    /* 5bits data size */ 
    54 #define CHAR_LEN_6      0x01    /* 6bits data size */ 
    55 #define CHAR_LEN_7      0x02    /* 7bits data size */ 
    56 #define CHAR_LEN_8      0x03    /* 8bits data size */ 
    57 #define LCR_STB         0x04    /* 2 stop bits */ 
    58 #define ONE_STOP        0x00    /* one stop bit */ 
    59 #define LCR_PEN         0x08    /* parity enable */ 
    60 #define PARITY_NONE     0x00    /* parity disable */ 
    61 #define LCR_EPS         0x10    /* even parity select */ 
    62 #define LCR_SP          0x20    /* stick parity select */ 
    63 #define LCR_SBRK        0x40    /* break control bit */ 
    64 #define LCR_DLAB        0x80    /* divisor latch access enable */ 
     53#define CHAR_LEN_5      0x00   /* 5bits data size */ 
     54#define CHAR_LEN_6      0x01   /* 6bits data size */ 
     55#define CHAR_LEN_7      0x02   /* 7bits data size */ 
     56#define CHAR_LEN_8      0x03   /* 8bits data size */ 
     57#define LCR_STB         0x04   /* 2 stop bits */ 
     58#define ONE_STOP        0x00   /* one stop bit */ 
     59#define LCR_PEN         0x08   /* parity enable */ 
     60#define PARITY_NONE     0x00   /* parity disable */ 
     61#define LCR_EPS         0x10   /* even parity select */ 
     62#define LCR_SP          0x20   /* stick parity select */ 
     63#define LCR_SBRK        0x40   /* break control bit */ 
     64#define LCR_DLAB        0x80   /* divisor latch access enable */ 
    6565 
    6666/* 
    6767 * Line Status Register 
    6868 */ 
    69 #define LSR_DR          0x01    /* data ready */ 
    70 #define LSR_OE          0x02    /* overrun error */ 
    71 #define LSR_PE          0x04    /* parity error */ 
    72 #define LSR_FE          0x08    /* framing error */ 
    73 #define LSR_BI          0x10    /* break interrupt */ 
    74 #define LSR_THRE        0x20    /* transmit holding register empty */ 
    75 #define LSR_TEMT        0x40    /* transmitter empty */ 
    76 #define LSR_FERR        0x80    /* in fifo mode, set when PE,FE or BI error */ 
     69#define LSR_DR          0x01   /* data ready */ 
     70#define LSR_OE          0x02   /* overrun error */ 
     71#define LSR_PE          0x04   /* parity error */ 
     72#define LSR_FE          0x08   /* framing error */ 
     73#define LSR_BI          0x10   /* break interrupt */ 
     74#define LSR_THRE        0x20   /* transmit holding register empty */ 
     75#define LSR_TEMT        0x40   /* transmitter empty */ 
     76#define LSR_FERR        0x80   /* in fifo mode, set when PE,FE or BI error */ 
    7777 
    7878/* 
    7979 * Interrupt Identification Register 
    8080 */ 
    81 #define IIR_IP          0x01    /* no pending interrupts */ 
     81#define IIR_IP          0x01   /* no pending interrupts */ 
    8282#define IIR_ID          0x0e 
    83 #define IIR_RLS         0x06    /* received line status */ 
    84 #define IIR_RDA         0x04    /* received data available */ 
    85 #define IIR_THRE        0x02    /* transmit holding register empty */ 
    86 #define IIR_MSTAT       0x00    /* modem status */ 
    87 #define IIR_TIMEOUT     0x0c    /* char receiv tiemout */ 
     83#define IIR_RLS         0x06   /* received line status */ 
     84#define IIR_RDA         0x04   /* received data available */ 
     85#define IIR_THRE        0x02   /* transmit holding register empty */ 
     86#define IIR_MSTAT       0x00   /* modem status */ 
     87#define IIR_TIMEOUT     0x0c   /* char receiv tiemout */ 
    8888 
    8989/* 
    9090 * Interrupt Enable Register 
    9191 */ 
    92 #define IER_ERDAI       0x01    /* received data avail. & timeout int */ 
    93 #define IER_ETHREI      0x02    /* transmitter holding register empty int */ 
    94 #define IER_ELSI        0x04    /* receiver line status int enable */ 
    95 #define IER_EMSI        0x08    /* modem status int enable */ 
     92#define IER_ERDAI       0x01   /* received data avail. & timeout int */ 
     93#define IER_ETHREI      0x02   /* transmitter holding register empty int */ 
     94#define IER_ELSI        0x04   /* receiver line status int enable */ 
     95#define IER_EMSI        0x08   /* modem status int enable */ 
    9696 
    9797/* 
    9898 * Modem Control Register 
    9999 */ 
    100 #define MCR_DTR         0x01    /* dtr output */ 
    101 #define MCR_RTS         0x02    /* rts output */ 
    102 #define MCR_OUT1        0x04    /* output #1 */ 
    103 #define MCR_OUT2        0x08    /* output #2 */ 
    104 #define MCR_LOOP        0x10    /* loopback enable */ 
     100#define MCR_DTR         0x01   /* dtr output */ 
     101#define MCR_RTS         0x02   /* rts output */ 
     102#define MCR_OUT1        0x04   /* output #1 */ 
     103#define MCR_OUT2        0x08   /* output #2 */ 
     104#define MCR_LOOP        0x10   /* loopback enable */ 
    105105 
    106106/* 
    107107 * Modem Status Register 
    108108 */ 
    109 #define MSR_DCTS        0x01    /* cts change */ 
    110 #define MSR_DDSR        0x02    /* dsr change */ 
    111 #define MSR_TERI        0x04    /* ring indicator change */ 
    112 #define MSR_DDCD        0x08    /* data carrier indicator change */ 
    113 #define MSR_CTS         0x10    /* complement of cts */ 
    114 #define MSR_DSR         0x20    /* complement of dsr */ 
    115 #define MSR_RI          0x40    /* complement of ring signal */ 
    116 #define MSR_DCD         0x80    /* complement of dcd */ 
     109#define MSR_DCTS        0x01   /* cts change */ 
     110#define MSR_DDSR        0x02   /* dsr change */ 
     111#define MSR_TERI        0x04   /* ring indicator change */ 
     112#define MSR_DDCD        0x08   /* data carrier indicator change */ 
     113#define MSR_CTS         0x10   /* complement of cts */ 
     114#define MSR_DSR         0x20   /* complement of dsr */ 
     115#define MSR_RI          0x40   /* complement of ring signal */ 
     116#define MSR_DCD         0x80   /* complement of dcd */ 
    117117 
    118118/* 
    119119 * FIFO Control Register 
    120120 */ 
    121 #define FCR_EN          0x01    /* enable xmit and rcvr */ 
    122 #define FCR_RXCLR       0x02    /* clears rcvr fifo */ 
    123 #define FCR_TXCLR       0x04    /* clears xmit fifo */ 
    124 #define FCR_DMA         0x08    /* dma */ 
    125 #define FCR_RXTRIG_1    0x00    /* rcvr fifo trigger at 1 byte */ 
    126 #define FCR_RXTRIG_4    0x40    /* rcvr fifo trigger at 4 bytes */ 
    127 #define FCR_RXTRIG_8    0x80    /* rcvr fifo trigger at 8 bytes */ 
    128 #define FCR_RXTRIG_14   0xc0    /* rcvr fifo trigger at X4 bytes */ 
     121#define FCR_EN          0x01   /* enable xmit and rcvr */ 
     122#define FCR_RXCLR       0x02   /* clears rcvr fifo */ 
     123#define FCR_TXCLR       0x04   /* clears xmit fifo */ 
     124#define FCR_DMA         0x08   /* dma */ 
     125#define FCR_RXTRIG_1    0x00   /* rcvr fifo trigger at 1 byte */ 
     126#define FCR_RXTRIG_4    0x40   /* rcvr fifo trigger at 4 bytes */ 
     127#define FCR_RXTRIG_8    0x80   /* rcvr fifo trigger at 8 bytes */ 
     128#define FCR_RXTRIG_14   0xc0   /* rcvr fifo trigger at X4 bytes */ 
    129129 
    130130#define FIFO_DEPTH      16 
     
    134134#define UARTDMA_ALIGN   _CACHE_ALIGN_SIZE 
    135135 
    136  
    137 #endif /* __INCar7100Sioh */ 
     136#endif                          /* __INCar7100Sioh */ 
  • ar5315_microredboot/microredboot/boot/src/arch/ar7100_soc.h

    r13098 r13107  
    55 * Address map 
    66 */ 
    7 #define AR7100_PCI_MEM_BASE             0x10000000  /* 128M */ 
    8 #define AR7100_APB_BASE                 0x18000000  /* 384M */ 
    9 #define AR7100_GE0_BASE                 0x19000000  /* 16M */ 
    10 #define AR7100_GE1_BASE                 0x1a000000  /* 16M */ 
    11 #define AR7100_USB_EHCI_BASE            0x1b000000   
     7#define AR7100_PCI_MEM_BASE             0x10000000     /* 128M */ 
     8#define AR7100_APB_BASE                 0x18000000     /* 384M */ 
     9#define AR7100_GE0_BASE                 0x19000000     /* 16M */ 
     10#define AR7100_GE1_BASE                 0x1a000000     /* 16M */ 
     11#define AR7100_USB_EHCI_BASE            0x1b000000 
    1212#define AR7100_USB_OHCI_BASE            0x1c000000 
    1313#define AR7100_SPI_BASE                 0x1f000000 
     
    5454#define AR7100_DDR_CONFIG2_BL8          (8 << 0) 
    5555 
    56 #define AR7100_DDR_CONFIG2_BT_IL        (1 << 4)        
     56#define AR7100_DDR_CONFIG2_BT_IL        (1 << 4) 
    5757#define AR7100_DDR_CONFIG2_CNTL_OE_EN   (1 << 5) 
    5858#define AR7100_DDR_CONFIG2_PHASE_SEL    (1 << 6) 
     
    6262#define AR7100_DDR_CONFIG2_TRTP_SHIFT   17 
    6363#define AR7100_DDR_CONFIG2_TWTR_SHIFT   21 
    64 #define AR7100_DDR_CONFIG2_HALF_WIDTH_L (1 << 31)    
     64#define AR7100_DDR_CONFIG2_HALF_WIDTH_L (1 << 31) 
    6565 
    6666#define AR7100_DDR_TAP_DEFAULT          0x18 
     
    6969 * PLL 
    7070 */ 
    71 #define AR7100_CPU_PLL_CONFIG           AR7100_PLL_BASE     
     71#define AR7100_CPU_PLL_CONFIG           AR7100_PLL_BASE 
    7272 
    7373/* Legacy */ 
     
    107107#define PLL_CONFIG_SW_UPDATE_MASK       (1 << 31) 
    108108 
     109#define REV_ID_REVISION_MASK    0x3 
     110#define REV_ID_REVISION_SHIFT   2 
    109111 
    110112/* These are values used in platform.inc to select PLL settings */ 
    111113 
    112114#define AR7100_REV_ID           (AR7100_RESET_BASE + 0x90) 
     115#define AR7100_REV_ID_CHIP_MASK 0xf3 
    113116#define AR7100_REV_ID_MASK      0xff 
    114117#define AR7100_REV_ID_AR7130    0xa0 
    115118#define AR7100_REV_ID_AR7141    0xa1 
    116119#define AR7100_REV_ID_AR7161    0xa2 
     120#define AR7100_REV_ID_AR9130    0xb0 
     121#define AR7100_REV_ID_AR9132    0xb1 
     122#define AR7240_REV_1_0          0xc0 
     123#define AR7240_REV_1_1          0xc1 
     124#define AR7240_REV_1_2          0xc2 
    117125 
    118126#define AR7100_PLL_USE_REV_ID    0 
     
    125133#define AR7100_PLL_600_300_150   7 
    126134#define AR7100_PLL_680_340_170   8 
     135#define AR7100_PLL_350_350_175   9 
     136 
    127137/* "Secret values", for debug only */ 
    128138#define AR7100_PLL_720_360_180   30 
    129139#define AR7100_PLL_800_400_200   31 
     140 
    130141/* 
    131142 * PLL block 
     
    168179 * PCI block 
    169180 */ 
    170 #define AR7100_PCI_WINDOW           0x8000000       /* 128MB */ 
     181#define AR7100_PCI_WINDOW           0x8000000  /* 128MB */ 
    171182#define AR7100_PCI_WINDOW0_OFFSET   AR7100_DDR_CTL_BASE+0x7c 
    172183#define AR7100_PCI_WINDOW1_OFFSET   AR7100_DDR_CTL_BASE+0x80 
     
    186197#define AR7100_PCI_WINDOW6_VAL      0x16000000 
    187198#define AR7100_PCI_WINDOW7_VAL      0x07000000 
    188  
    189199 
    190200/* 
     
    323333#define PISR_DEV2                           PIMR_DEV2 
    324334#define PISR_CORE                           PIMR_CORE 
    325  
    326335 
    327336#define AR7100_GPIO_COUNT                   16 
     
    366375#ifndef __ASSEMBLER__ 
    367376typedef enum { 
    368     AR7100_DDR_16B_LOW, 
    369     AR7100_DDR_16B_HIGH, 
    370     AR7100_DDR_32B, 
    371 }ar7100_ddr_width_t; 
     377       AR7100_DDR_16B_LOW, 
     378       AR7100_DDR_16B_HIGH, 
     379       AR7100_DDR_32B, 
     380} ar7100_ddr_width_t; 
    372381 
    373382#define KSEG1ADDR(_addr) (CYGARC_UNCACHED_ADDRESS(_addr)) 
     
    413422}while(0); 
    414423 
    415 #endif  /*__ASSEMBLY*/ 
     424#endif /*__ASSEMBLY*/ 
    416425 
    417426#endif 
  • ar5315_microredboot/microredboot/boot/src/arch/head-ar7100.S

    r13101 r13107  
    392392        nop 
    393393 
     3941:      li      t0, AR7240_REV_1_0 
     395        bne     t0, t1, 1f 
     396        li      t1, AR7100_PLL_350_350_175 
     397        b       2f 
     398        nop 
     399 
     4001:      li      t0, AR7240_REV_1_1 
     401        bne     t0, t1, 1f 
     402        li      t1, AR7100_PLL_400_400_200 
     403        b       2f 
     404        nop 
     405 
    3944061:      li      t1, AR7100_PLL_300_300_150 
    395407 
     
    416428 
    417429__AR7100_init: 
    418         lar     t0, rel_start 
    419         li      t1, 0xff3fffff 
    420         and     t0, t0, t1 
    421         j       t0 
    422         nop 
     430        /* 
     431         * Clearing CP0 registers - This is generally required for the MIPS-24k 
     432     * core used by Atheros. 
     433         */ 
     434        mtc0    zero, $0 
     435        mtc0    zero, $1 
     436        mtc0    zero, $2 
     437        mtc0    zero, $3 
     438        mtc0    zero, $4 
     439        mtc0    zero, $5 
     440        mtc0    zero, $6 
     441        mtc0    zero, $7 
     442        mtc0    zero, $8 
     443        mtc0    zero, $9 
     444        mtc0    zero, $10 
     445        mtc0    zero, $11 
     446        li      t0, 0x10000004 
     447        mtc0    t0, $12  
     448        mtc0    zero, $13  
     449        mtc0    zero, $14 
     450        mtc0    zero, $15 
     451        mtc0    zero, $16 
     452        mtc0    zero, $17 
     453        mtc0    zero, $18 
     454        mtc0    zero, $19 
     455        mtc0    zero, $20 
     456        mtc0    zero, $21 
     457        mtc0    zero, $22 
     458        mtc0    zero, $23 
     459        mtc0    zero, $24 
     460        mtc0    zero, $25 
     461        mtc0    zero, $26 
     462        mtc0    zero, $27 
     463        mtc0    zero, $28 
     464         
     465    /* 
     466    ** Clear watch registers. 
     467        */ 
     468 
     469        mtc0    zero, CP0_WATCHLO 
     470        mtc0    zero, CP0_WATCHHI 
     471 
     472        /* STATUS register */ 
     473        mfc0    k0, CP0_STATUS 
     474        li      k1, ~ST0_IE 
     475        and     k0, k1 
     476        mtc0    zero, CP0_CAUSE 
     477        mtc0    k0, CP0_STATUS 
     478 
     479        /* CAUSE register */ 
     480        mtc0    zero, CP0_CAUSE 
     481 
     482        /* Init Timer */ 
     483        mtc0    zero, CP0_COUNT 
     484        mtc0    zero, CP0_COMPARE 
     485 
     486        /* CONFIG0 register */ 
     487        li      t0, CONF_CM_UNCACHED 
     488        mtc0    t0, CP0_CONFIG 
     489 
     490 
     491        /* Initialize any external memory. 
     492         */ 
     493#if defined(AR7100) || defined(AR7240) 
     494        la      t0, rel_start 
     495        j       t0 
     496        nop 
     497#endif 
    423498 
    424499rel_start: 
     
    440515        li      t2, AR7100_PLL_400_400_200 
    441516        beq     t1, t2, pll_400_400_200 
     517        nop 
     518        li      t2, AR7100_PLL_350_350_175 
     519        beq     t1, t2, pll_350_350_175 
    442520        nop 
    443521        li      t2, AR7100_PLL_333_333_166 
     
    506584        b       got_setting 
    507585        nop 
     586 
     587pll_350_350_175: 
     588 
     589        li      t0, (0x2  << PLL_CONFIG_CPU_DIV_SHIFT) 
     590        li      t1, (0x0  << PLL_CONFIG_DDR_DIV_SHIFT) 
     591        li      t2, (0x0  << PLL_CONFIG_AHB_DIV_SHIFT) 
     592        li      t3, (0x23 << PLL_CONFIG_PLL_FB_SHIFT) 
     593        li      t4, (0x2  << PLL_CONFIG_PLL_LOOP_BW_SHIFT) 
     594        li      t5,     (0x0  << PLL_CONFIG_PLL_DIVOUT_SHIFT) 
     595        b       got_setting 
     596        nop 
     597 
    508598 
    509599pll_333_333_166: 
  • ar5315_microredboot/microredboot/boot/src/lib/LzmaDecode.c

    r12551 r13107  
    168168#ifdef _LZMA_LOC_OPT 
    169169                CProb *prob = probs + mi; 
    170                 RC_GET_BIT2(prob, mi,;, symbol |= (1 << i)) 
     170                RC_GET_BIT2(prob, mi,; 
     171                            , symbol |= (1 << i)) 
    171172#else 
    172173                int bit = RangeDecoderBitDecode(probs + mi, rd); 
  • ar5315_microredboot/microredboot/boot/src/lib/LzmaDecode.h

    r13100 r13107  
    2222#ifndef __LZMADECODE_H 
    2323#define __LZMADECODE_H 
    24  
    2524 
    2625/* #define _LZMA_IN_CB */ 
  • ar5315_microredboot/microredboot/boot/src/lib/elf.h

    r12429 r13107  
    8787//========================================================================== 
    8888 
    89  
    9089// ------------------------------------------------------------------------- 
    9190// Basic types: 
     
    102101typedef cyg_uint16 Elf32_Half; 
    103102typedef cyg_uint32 Elf32_Word; 
    104 typedef cyg_int32 Elf32_Sword; 
     103typedef cyg_int32 Elf32_Sword; 
    105104 
    106105typedef cyg_uint64 Elf64_Addr; 
     
    108107typedef cyg_uint16 Elf64_Half; 
    109108typedef cyg_uint32 Elf64_Word; 
    110 typedef cyg_int32 Elf64_Sword; 
     109typedef cyg_int32 Elf64_Sword; 
    111110typedef cyg_uint64 Elf64_Xword; 
    112 typedef cyg_int64 Elf64_Sxword; 
     111typedef cyg_int64 Elf64_Sxword; 
    113112 
    114113// ------------------------------------------------------------------------- 
     
    118117 
    119118typedef struct { 
    120     unsigned char  e_ident[EI_NIDENT]; 
    121     Elf32_Half      e_type; 
    122     Elf32_Half      e_machine; 
    123     Elf32_Word      e_version; 
    124     Elf32_Addr      e_entry; 
    125     Elf32_Off      e_phoff; 
    126     Elf32_Off      e_shoff; 
    127     Elf32_Word      e_flags; 
    128     Elf32_Half      e_ehsize; 
    129     Elf32_Half      e_phentsize; 
    130     Elf32_Half      e_phnum; 
    131     Elf32_Half      e_shentsize; 
    132     Elf32_Half      e_shnum; 
    133     Elf32_Half      e_shtrndx; 
     119       unsigned char e_ident[EI_NIDENT]; 
     120       Elf32_Half e_type; 
     121       Elf32_Half e_machine; 
     122       Elf32_Word e_version; 
     123       Elf32_Addr e_entry; 
     124       Elf32_Off e_phoff; 
     125       Elf32_Off e_shoff; 
     126       Elf32_Word e_flags; 
     127       Elf32_Half e_ehsize; 
     128       Elf32_Half e_phentsize; 
     129       Elf32_Half e_phnum; 
     130       Elf32_Half e_shentsize; 
     131       Elf32_Half e_shnum; 
     132       Elf32_Half e_shtrndx; 
    134133} Elf32_Ehdr; 
    135134 
    136135typedef struct { 
    137     unsigned char  e_ident[EI_NIDENT]; 
    138     Elf64_Half      e_type; 
    139     Elf64_Half      e_machine; 
    140     Elf64_Word      e_version; 
    141     Elf64_Addr      e_entry; 
    142     Elf64_Off      e_phoff; 
    143     Elf64_Off      e_shoff; 
    144     Elf64_Word      e_flags; 
    145     Elf64_Half      e_ehsize; 
    146     Elf64_Half      e_phentsize; 
    147     Elf64_Half      e_phnum; 
    148     Elf64_Half      e_shentsize; 
    149     Elf64_Half      e_shnum; 
    150     Elf64_Half      e_shtrndx; 
     136       unsigned char e_ident[EI_NIDENT]; 
     137       Elf64_Half e_type; 
     138       Elf64_Half e_machine; 
     139       Elf64_Word e_version; 
     140       Elf64_Addr e_entry; 
     141       Elf64_Off e_phoff; 
     142       Elf64_Off e_shoff; 
     143       Elf64_Word e_flags; 
     144       Elf64_Half e_ehsize; 
     145       Elf64_Half e_phentsize; 
     146       Elf64_Half e_phnum; 
     147       Elf64_Half e_shentsize; 
     148       Elf64_Half e_shnum; 
     149       Elf64_Half e_shtrndx; 
    151150} Elf64_Ehdr; 
    152151 
     
    154153/* e_ident[] identification indexes */ 
    155154 
    156 #define EI_MAG0         0               /* file ID */ 
    157 #define EI_MAG1         1               /* file ID */ 
    158 #define EI_MAG2         2               /* file ID */ 
    159 #define EI_MAG3         3               /* file ID */ 
    160 #define EI_CLASS        4               /* file class */ 
    161 #define EI_DATA         5               /* data encoding */ 
    162 #define EI_VERSION      6               /* ELF header version */ 
    163 #define EI_OSABI        7               /* Operating system/ABI identification */ 
    164 #define EI_ABIVERSION   8               /* ABI version */ 
    165 #define EI_PAD          9               /* start of pad bytes */ 
     155#define EI_MAG0         0      /* file ID */ 
     156#define EI_MAG1         1      /* file ID */ 
     157#define EI_MAG2         2      /* file ID */ 
     158#define EI_MAG3         3      /* file ID */ 
     159#define EI_CLASS        4      /* file class */ 
     160#define EI_DATA         5      /* data encoding */ 
     161#define EI_VERSION      6      /* ELF header version */ 
     162#define EI_OSABI        7      /* Operating system/ABI identification */ 
     163#define EI_ABIVERSION   8      /* ABI version */ 
     164#define EI_PAD          9      /* start of pad bytes */ 
    166165 
    167166// ------------------------------------------------------------------------- 
    168167/* e_ident[] magic number */ 
    169168 
    170 #define ELFMAG0         0x7f            /* e_ident[EI_MAG0] */ 
    171 #define ELFMAG1         'E'             /* e_ident[EI_MAG1] */ 
    172 #define ELFMAG2         'L'             /* e_ident[EI_MAG2] */ 
    173 #define ELFMAG3         'F'             /* e_ident[EI_MAG3] */ 
    174 #define ELFMAG          "\177ELF"       /* magic */ 
    175 #define SELFMAG         4               /* size of magic */ 
     169#define ELFMAG0         0x7f   /* e_ident[EI_MAG0] */ 
     170#define ELFMAG1         'E'    /* e_ident[EI_MAG1] */ 
     171#define ELFMAG2         'L'    /* e_ident[EI_MAG2] */ 
     172#define ELFMAG3         'F'    /* e_ident[EI_MAG3] */ 
     173#define ELFMAG          "\177ELF"      /* magic */ 
     174#define SELFMAG         4      /* size of magic */ 
    176175 
    177176// ------------------------------------------------------------------------- 
    178177/* e_ident[] file class */ 
    179178 
    180 #define ELFCLASSNONE    0               /* invalid */ 
    181 #define ELFCLASS32      1               /* 32-bit objs */ 
    182 #define ELFCLASS64      2               /* 64-bit objs */ 
    183 #define ELFCLASSNUM     3               /* number of classes */ 
     179#define ELFCLASSNONE    0      /* invalid */ 
     180#define ELFCLASS32      1      /* 32-bit objs */ 
     181#define ELFCLASS64      2      /* 64-bit objs */ 
     182#define ELFCLASSNUM     3      /* number of classes */ 
    184183 
    185184// ------------------------------------------------------------------------- 
    186185/* e_ident[] data encoding */ 
    187186 
    188 #define ELFDATANONE     0               /* invalid */ 
    189 #define ELFDATA2LSB     1               /* Little-Endian */ 
    190 #define ELFDATA2MSB     2               /* Big-Endian */ 
    191 #define ELFDATANUM      3               /* number of data encode defines */ 
     187#define ELFDATANONE     0      /* invalid */ 
     188#define ELFDATA2LSB     1      /* Little-Endian */ 
     189#define ELFDATA2MSB     2      /* Big-Endian */ 
     190#define ELFDATANUM      3      /* number of data encode defines */ 
    192191 
    193192// ------------------------------------------------------------------------- 
     
    202201/* e_type */ 
    203202 
    204 #define ET_NONE         0               /* No file type */ 
    205 #define ET_REL          1               /* relocatable file */ 
    206 #define ET_EXEC         2               /* executable file */ 
    207 #define ET_DYN          3               /* shared object file */ 
    208 #define ET_CORE         4               /* core file */ 
    209 #define ET_NUM          5               /* number of types */ 
    210 #define ET_LOOS         0xfe00          /* Operating system-specific */ 
    211 #define ET_HIOS         0xfeff          /* Operating system-specific */ 
    212 #define ET_LOPROC       0xff00          /* reserved range for processor */ 
    213 #define ET_HIPROC       0xffff          /*  specific e_type */ 
     203#define ET_NONE         0      /* No file type */ 
     204#define ET_REL          1      /* relocatable file */ 
     205#define ET_EXEC         2      /* executable file */ 
     206#define ET_DYN          3      /* shared object file */ 
     207#define ET_CORE         4      /* core file */ 
     208#define ET_NUM          5      /* number of types */ 
     209#define ET_LOOS         0xfe00 /* Operating system-specific */ 
     210#define ET_HIOS         0xfeff /* Operating system-specific */ 
     211#define ET_LOPROC       0xff00 /* reserved range for processor */ 
     212#define ET_HIPROC       0xffff /*  specific e_type */ 
    214213 
    215214// ------------------------------------------------------------------------- 
     
    218217// extra values from binutils elf/common.h. 
    219218 
    220 #define EM_NONE                 0       // No machine 
    221 #define EM_M32                  1       // AT&T WE 32100 
    222 #define EM_SPARC                2       // SPARC 
    223 #define EM_386                  3       // Intel 80386 
    224 #define EM_68K                  4       // Motorola 68000 
    225 #define EM_88K                  5       // Motorola 88000 
    226 #define EM_860                  7       // Intel 80860 
    227 #define EM_MIPS                 8       // MIPS I Architecture 
    228 #define EM_S370                 9       // IBM System/370 Processor 
    229 #define EM_MIPS_RS3_LE          10      // MIPS RS3000 Little-endian 
    230 #define EM_PARISC               15      // Hewlett-Packard PA-RISC 
    231 #define EM_VPP500               17      // Fujitsu VPP500 
    232 #define EM_SPARC32PLUS          18      // Enhanced instruction set SPARC 
    233 #define EM_960                  19      // Intel 80960 
    234 #define EM_PPC                  20      // PowerPC 
    235 #define EM_PPC64                21      // 64-bit PowerPC 
    236 #define EM_V800                 36      // NEC V800 
    237 #define EM_FR20                 37      // Fujitsu FR20 
    238 #define EM_RH32                 38      // TRW RH-32 
    239 #define EM_RCE                  39      // Motorola RCE 
    240 #define EM_ARM                  40      // Advanced RISC Machines ARM 
    241 #define EM_ALPHA                41      // Digital Alpha 
    242 #define EM_SH                   42      // Hitachi SH 
    243 #define EM_SPARCV9              43      // SPARC Version 9 
    244 #define EM_TRICORE              44      // Siemens Tricore embedded processor 
    245 #define EM_ARC                  45      // Argonaut RISC Core, Argonaut Technologies Inc. 
    246 #define EM_H8_300               46      // Hitachi H8/300 
    247 #define EM_H8_300H              47      // Hitachi H8/300H 
    248 #define EM_H8S                  48      // Hitachi H8S 
    249 #define EM_H8_500               49      // Hitachi H8/500 
    250 #define EM_IA_64                50      // Intel IA-64 processor architecture 
    251 #define EM_MIPS_X               51      // Stanford MIPS-X 
    252 #define EM_COLDFIRE             52      // Motorola ColdFire 
    253 #define EM_68HC12               53      // Motorola M68HC12 
    254 #define EM_MMA                  54      // Fujitsu MMA Multimedia Accelerator 
    255 #define EM_PCP                  55      // Siemens PCP 
    256 #define EM_NCPU                 56      // Sony nCPU embedded RISC processor 
    257 #define EM_NDR1                 57      // Denso NDR1 microprocessor 
    258 #define EM_STARCORE             58      // Motorola Star*Core processor 
    259 #define EM_ME16                 59      // Toyota ME16 processor 
    260 #define EM_ST100                60      // STMicroelectronics ST100 processor 
    261 #define EM_TINYJ                61      // Advanced Logic Corp. TinyJ embedded processor family 
    262 #define EM_FX66                 66      // Siemens FX66 microcontroller 
    263 #define EM_ST9PLUS              67      // STMicroelectronics ST9+ 8/16 bit microcontroller 
    264 #define EM_ST7                  68      // STMicroelectronics ST7 8-bit microcontroller 
    265 #define EM_68HC16               69      // Motorola MC68HC16 Microcontroller 
    266 #define EM_68HC11               70      // Motorola MC68HC11 Microcontroller 
    267 #define EM_68HC08               71      // Motorola MC68HC08 Microcontroller 
    268 #define EM_68HC05               72      // Motorola MC68HC05 Microcontroller 
    269 #define EM_SVX                  73      // Silicon Graphics SVx 
    270 #define EM_ST19                 74      // STMicroelectronics ST19 8-bit microcontroller 
    271 #define EM_VAX                  75      // Digital VAX 
    272 #define EM_CRIS                 76      // Axis Communications 32-bit embedded processor 
    273 #define EM_JAVELIN              77      // Infineon Technologies 32-bit embedded processor 
    274 #define EM_FIREPATH             78      // Element 14 64-bit DSP Processor 
    275 #define EM_ZSP                  79      // LSI Logic 16-bit DSP Processor 
    276 #define EM_MMIX                 80      // Donald Knuth's educational 64-bit processor 
    277 #define EM_HUANY                81      // Harvard University machine-independent object files 
    278 #define EM_PRISM                82      // SiTera Prism 
     219#define EM_NONE                 0      // No machine 
     220#define EM_M32                  1      // AT&T WE 32100 
     221#define EM_SPARC                2      // SPARC 
     222#define EM_386                  3      // Intel 80386 
     223#define EM_68K                  4      // Motorola 68000 
     224#define EM_88K                  5      // Motorola 88000 
     225#define EM_860                  7      // Intel 80860 
     226#define EM_MIPS                 8      // MIPS I Architecture 
     227#define EM_S370                 9      // IBM System/370 Processor 
     228#define EM_MIPS_RS3_LE          10     // MIPS RS3000 Little-endian 
     229#define EM_PARISC               15     // Hewlett-Packard PA-RISC 
     230#define EM_VPP500               17     // Fujitsu VPP500 
     231#define EM_SPARC32PLUS          18     // Enhanced instruction set SPARC 
     232#define EM_960                  19     // Intel 80960 
     233#define EM_PPC                  20     // PowerPC 
     234#define EM_PPC64                21     // 64-bit PowerPC 
     235#define EM_V800                 36     // NEC V800 
     236#define EM_FR20                 37     // Fujitsu FR20 
     237#define EM_RH32                 38     // TRW RH-32 
     238#define EM_RCE                  39     // Motorola RCE 
     239#define EM_ARM                  40     // Advanced RISC Machines ARM 
     240#define EM_ALPHA                41     // Digital Alpha 
     241#define EM_SH                   42     // Hitachi SH 
     242#define EM_SPARCV9              43     // SPARC Version 9 
     243#define EM_TRICORE              44     // Siemens Tricore embedded processor 
     244#define EM_ARC                  45     // Argonaut RISC Core, Argonaut Technologies Inc. 
     245#define EM_H8_300               46     // Hitachi H8/300 
     246#define EM_H8_300H              47     // Hitachi H8/300H 
     247#define EM_H8S                  48     // Hitachi H8S 
     248#define EM_H8_500               49     // Hitachi H8/500 
     249#define EM_IA_64                50     // Intel IA-64 processor architecture 
     250#define EM_MIPS_X               51     // Stanford MIPS-X 
     251#define EM_COLDFIRE             52     // Motorola ColdFire 
     252#define EM_68HC12               53     // Motorola M68HC12 
     253#define EM_MMA                  54     // Fujitsu MMA Multimedia Accelerator 
     254#define EM_PCP                  55     // Siemens PCP 
     255#define EM_NCPU                 56     // Sony nCPU embedded RISC processor 
     256#define EM_NDR1                 57     // Denso NDR1 microprocessor 
     257#define EM_STARCORE             58     // Motorola Star*Core processor 
     258#define EM_ME16                 59     // Toyota ME16 processor 
     259#define EM_ST100                60     // STMicroelectronics ST100 processor 
     260#define EM_TINYJ                61     // Advanced Logic Corp. TinyJ embedded processor family 
     261#define EM_FX66                 66     // Siemens FX66 microcontroller 
     262#define EM_ST9PLUS              67     // STMicroelectronics ST9+ 8/16 bit microcontroller 
     263#define EM_ST7                  68     // STMicroelectronics ST7 8-bit microcontroller 
     264#define EM_68HC16               69     // Motorola MC68HC16 Microcontroller 
     265#define EM_68HC11               70     // Motorola MC68HC11 Microcontroller 
     266#define EM_68HC08               71     // Motorola MC68HC08 Microcontroller 
     267#define EM_68HC05               72     // Motorola MC68HC05 Microcontroller 
     268#define EM_SVX                  73     // Silicon Graphics SVx 
     269#define EM_ST19                 74     // STMicroelectronics ST19 8-bit microcontroller 
     270#define EM_VAX                  75     // Digital VAX 
     271#define EM_CRIS                 76     // Axis Communications 32-bit embedded processor 
     272#define EM_JAVELIN              77     // Infineon Technologies 32-bit embedded processor 
     273#define EM_FIREPATH             78     // Element 14 64-bit DSP Processor 
     274#define EM_ZSP                  79     // LSI Logic 16-bit DSP Processor 
     275#define EM_MMIX                 80     // Donald Knuth's educational 64-bit processor 
     276#define EM_HUANY                81     // Harvard University machine-independent object files 
     277#define EM_PRISM                82     // SiTera Prism 
    279278 
    280279/* Cygnus PowerPC ELF backend.  Written in the absence of an ABI.  */ 
     
    321320/* Version */ 
    322321 
    323 #define EV_NONE         0               /* Invalid */ 
    324 #define EV_CURRENT      1               /* Current */ 
    325 #define EV_NUM          2               /* number of versions */ 
     322#define EV_NONE         0      /* Invalid */ 
     323#define EV_CURRENT      1      /* Current */ 
     324#define EV_NUM          2      /* number of versions */ 
    326325 
    327326// ------------------------------------------------------------------------- 
     
    329328 
    330329typedef struct { 
    331     Elf32_Word  sh_name;        /* name - index into section header 
    332                                    string table section */ 
    333     Elf32_Word  sh_type;        /* type */ 
    334     Elf32_Word  sh_flags;       /* flags */ 
    335     Elf32_Addr  sh_addr;        /* address */ 
    336     Elf32_Off   sh_offset;      /* file offset */ 
    337     Elf32_Word  sh_size;        /* section size */ 
    338     Elf32_Word  sh_link;        /* section header table index link */ 
    339     Elf32_Word  sh_info;        /* extra information */ 
    340     Elf32_Word  sh_addralign;   /* address alignment */ 
    341     Elf32_Word  sh_entsize;     /* section entry size */ 
     330       Elf32_Word sh_name;     /* name - index into section header 
     331                                  string table section */ 
     332       Elf32_Word sh_type;     /* type */ 
     333       Elf32_Word sh_flags;    /* flags */ 
     334       Elf32_Addr sh_addr;     /* address */ 
     335       Elf32_Off sh_offset;    /* file offset */ 
     336       Elf32_Word sh_size;     /* section size */ 
     337       Elf32_Word sh_link;     /* section header table index link */ 
     338       Elf32_Word sh_info;     /* extra information */ 
     339       Elf32_Word sh_addralign;        /* address alignment */ 
     340       Elf32_Word sh_entsize;  /* section entry size */ 
    342341} Elf32_Shdr; 
    343342 
    344343typedef struct { 
    345     Elf64_Word  sh_name;        /* section name */ 
    346     Elf64_Word  sh_type;        /* section type */ 
    347     Elf64_Xword sh_flags;       /* section flags */ 
    348     Elf64_Addr  sh_addr;        /* virtual address */ 
    349     Elf64_Off   sh_offset;      /* file offset */ 
    350     Elf64_Xword sh_size;        /* section size */ 
    351     Elf64_Word  sh_link;        /* link to another */ 
    352     Elf64_Word  sh_info;        /* misc info */ 
    353     Elf64_Xword sh_addralign;   /* memory alignment */ 
    354     Elf64_Xword sh_entsize;     /* table entry size */ 
     344       Elf64_Word sh_name;     /* section name */ 
     345       Elf64_Word sh_type;     /* section type */ 
     346       Elf64_Xword sh_flags;   /* section flags */ 
     347       Elf64_Addr sh_addr;     /* virtual address */ 
     348       Elf64_Off sh_offset;    /* file offset */ 
     349       Elf64_Xword sh_size;    /* section size */ 
     350       Elf64_Word sh_link;     /* link to another */ 
     351       Elf64_Word sh_info;     /* misc info */ 
     352       Elf64_Xword sh_addralign;       /* memory alignment */ 
     353       Elf64_Xword sh_entsize; /* table entry size */ 
    355354} Elf64_Shdr; 
    356355 
     
    358357/* Special Section Indexes */ 
    359358 
    360 #define SHN_UNDEF       0               /* undefined */ 
    361 #define SHN_LORESERVE   0xff00          /* lower bounds of reserved indexes */ 
    362 #define SHN_LOPROC      0xff00          /* reserved range for processor */ 
    363 #define SHN_HIPROC      0xff1f          /*   specific section indexes */ 
    364 #define SHN_LOOS        0xff20          /* reserved range for operating */ 
    365 #define SHN_HIOS        0xff3f          /*   system specific section indexes */ 
    366 #define SHN_ABS         0xfff1          /* absolute value */ 
    367 #define SHN_COMMON      0xfff2          /* common symbol */ 
    368 #define SHN_XINDEX      0xffff          /* escape value for oversize index */ 
    369 #define SHN_HIRESERVE   0xffff          /* upper bounds of reserved indexes */ 
     359#define SHN_UNDEF       0      /* undefined */ 
     360#define SHN_LORESERVE   0xff00 /* lower bounds of reserved indexes */ 
     361#define SHN_LOPROC      0xff00 /* reserved range for processor */ 
     362#define SHN_HIPROC      0xff1f /*   specific section indexes */ 
     363#define SHN_LOOS        0xff20 /* reserved range for operating */ 
     364#define SHN_HIOS        0xff3f /*   system specific section indexes */ 
     365#define SHN_ABS         0xfff1 /* absolute value */ 
     366#define SHN_COMMON      0xfff2 /* common symbol */ 
     367#define SHN_XINDEX      0xffff /* escape value for oversize index */ 
     368#define SHN_HIRESERVE   0xffff /* upper bounds of reserved indexes */ 
    370369 
    371370// ------------------------------------------------------------------------- 
    372371/* sh_type */ 
    373372 
    374 #define SHT_NULL        0               /* inactive */ 
    375 #define SHT_PROGBITS    1               /* program defined information */ 
    376 #define SHT_SYMTAB      2               /* symbol table section */ 
    377 #define SHT_STRTAB      3               /* string table section */ 
    378 #define SHT_RELA        4               /* relocation section with addends*/ 
    379 #define SHT_HASH        5               /* symbol hash table section */ 
    380 #define SHT_DYNAMIC     6               /* dynamic section */ 
    381 #define SHT_NOTE        7               /* note section */ 
    382 #define SHT_NOBITS      8               /* no space section */ 
    383 #define SHT_REL         9               /* relation section without addends */ 
    384 #define SHT_SHLIB       10              /* reserved - purpose unknown */ 
    385 #define SHT_DYNSYM      11              /* dynamic symbol table section */ 
    386 #define SHT_INIT_ARRAY  14              /* init procedure array */ 
    387 #define SHT_FINI_ARRAY  15              /* fini procedure array */ 
    388 #define SHT_PREINIT_ARRAY 16            /* preinit procedure array */ 
    389 #define SHT_GROUP       17              /* section group */ 
    390 #define SHT_SYMTAB_SHNDX 18             /* oversize index table */ 
    391 #define SHT_NUM         19              /* number of section types */ 
    392 #define SHT_LOOS        0x60000000      /* reserved range for O/S */ 
    393 #define SHT_HIOS        0x6fffffff      /*  specific section header types */ 
    394 #define SHT_LOPROC      0x70000000      /* reserved range for processor */ 
    395 #define SHT_HIPROC      0x7fffffff      /*  specific section header types */ 
    396 #define SHT_LOUSER      0x80000000      /* reserved range for application */ 
    397 #define SHT_HIUSER      0xffffffff      /*  specific indexes */ 
     373#define SHT_NULL        0      /* inactive */ 
     374#define SHT_PROGBITS    1      /* program defined information */ 
     375#define SHT_SYMTAB      2      /* symbol table section */ 
     376#define SHT_STRTAB      3      /* string table section */ 
     377#define SHT_RELA        4      /* relocation section with addends */ 
     378#define SHT_HASH        5      /* symbol hash table section */ 
     379#define SHT_DYNAMIC     6      /* dynamic section */ 
     380#define SHT_NOTE        7      /* note section */ 
     381#define SHT_NOBITS      8      /* no space section */ 
     382#define SHT_REL         9      /* relation section without addends */ 
     383#define SHT_SHLIB       10     /* reserved - purpose unknown */ 
     384#define SHT_DYNSYM      11     /* dynamic symbol table section */ 
     385#define SHT_INIT_ARRAY  14     /* init procedure array */ 
     386#define SHT_FINI_ARRAY  15     /* fini procedure array */ 
     387#define SHT_PREINIT_ARRAY 16   /* preinit procedure array */ 
     388#define SHT_GROUP       17     /* section group */ 
     389#define SHT_SYMTAB_SHNDX 18    /* oversize index table */ 
     390#define SHT_NUM         19     /* number of section types */ 
     391#define SHT_LOOS        0x60000000     /* reserved range for O/S */ 
     392#define SHT_HIOS        0x6fffffff     /*  specific section header types */ 
     393#define SHT_LOPROC      0x70000000     /* reserved range for processor */ 
     394#define SHT_HIPROC      0x7fffffff     /*  specific section header types */ 
     395#define SHT_LOUSER      0x80000000     /* reserved range for application */ 
     396#define SHT_HIUSER      0xffffffff     /*  specific indexes */ 
    398397 
    399398// ------------------------------------------------------------------------- 
    400399/* Section names */ 
    401400 
    402 #define ELF_BSS         ".bss"          /* uninitialized data */ 
    403 #define ELF_DATA        ".data"         /* initialized data */ 
    404 #define ELF_DEBUG       ".debug"        /* debug */ 
    405 #define ELF_DYNAMIC     ".dynamic"      /* dynamic linking information */ 
    406 #define ELF_DYNSTR      ".dynstr"       /* dynamic string table */ 
    407 #define ELF_DYNSYM      ".dynsym"       /* dynamic symbol table */ 
    408 #define ELF_FINI        ".fini"         /* termination code */ 
    409 #define ELF_GOT         ".got"          /* global offset table */ 
    410 #define ELF_HASH        ".hash"         /* symbol hash table */ 
    411 #define ELF_INIT        ".init"         /* initialization code */ 
    412 #define ELF_REL_DATA    ".rel.data"     /* relocation data */ 
    413 #define ELF_REL_FINI    ".rel.fini"     /* relocation termination code */ 
    414 #define ELF_REL_INIT    ".rel.init"     /* relocation initialization code */ 
    415 #define ELF_REL_DYN     ".rel.dyn"      /* relocaltion dynamic link info */ 
    416 #define ELF_REL_RODATA  ".rel.rodata"   /* relocation read-only data */ 
    417 #define ELF_REL_TEXT    ".rel.text"     /* relocation code */ 
    418 #define ELF_RODATA      ".rodata"       /* read-only data */ 
    419 #define ELF_SHSTRTAB    ".shstrtab"     /* section header string table */ 
    420 #define ELF_STRTAB      ".strtab"       /* string table */ 
    421 #define ELF_SYMTAB      ".symtab"       /* symbol table */ 
    422 #define ELF_TEXT        ".text"         /* code */ 
     401#define ELF_BSS         ".bss" /* uninitialized data */ 
     402#define ELF_DATA        ".data"        /* initialized data */ 
     403#define ELF_DEBUG       ".debug"       /* debug */ 
     404#define ELF_DYNAMIC     ".dynamic"     /* dynamic linking information */ 
     405#define ELF_DYNSTR      ".dynstr"      /* dynamic string table */ 
     406#define ELF_DYNSYM      ".dynsym"      /* dynamic symbol table */ 
     407#define ELF_FINI        ".fini"        /* termination code */ 
     408#define ELF_GOT         ".got" /* global offset table */ 
     409#define ELF_HASH        ".hash"        /* symbol hash table */ 
     410#define ELF_INIT        ".init"        /* initialization code */ 
     411#define ELF_REL_DATA    ".rel.data"    /* relocation data */ 
     412#define ELF_REL_FINI    ".rel.fini"    /* relocation termination code */ 
     413#define ELF_REL_INIT    ".rel.init"    /* relocation initialization code */ 
     414#define ELF_REL_DYN     ".rel.dyn"     /* relocaltion dynamic link info */ 
     415#define ELF_REL_RODATA  ".rel.rodata"  /* relocation read-only data */ 
     416#define ELF_REL_TEXT    ".rel.text"    /* relocation code */ 
     417#define ELF_RODATA      ".rodata"      /* read-only data */ 
     418#define ELF_SHSTRTAB    ".shstrtab"    /* section header string table */ 
     419#define ELF_STRTAB      ".strtab"      /* string table */ 
     420#define ELF_SYMTAB      ".symtab"      /* symbol table */ 
     421#define ELF_TEXT        ".text"        /* code */ 
    423422 
    424423// ------------------------------------------------------------------------- 
    425424/* Section Attribute Flags - sh_flags */ 
    426425 
    427 #define SHF_WRITE               0x001           /* Writable */ 
    428 #define SHF_ALLOC               0x002           /* occupies memory */ 
    429 #define SHF_EXECINSTR           0x004           /* executable */ 
    430 #define SHF_MERGE               0x010           /* merge data */ 
    431 #define SHF_STRINGS             0x020           /* contains strings */ 
    432 #define SHF_INFO_LINK           0x040           /* link in sh_info field */ 
    433 #define SHF_LINK_ORDER          0x080           /* preserve link order */ 
    434 #define SHF_OS_NONCONFORMING    0x100           /* special OS-specific */ 
    435                                                 /*  processing needed */ 
    436 #define SHF_GROUP               0x200           /* member of group */ 
    437 #define SHF_MASKOS              0x0ff00000      /* reserved bits for OS */ 
    438                                                 /*  specific section attributes */ 
    439 #define SHF_MASKPROC            0xf0000000      /* reserved bits for processor */ 
    440                                                 /*  specific section attributes */ 
     426#define SHF_WRITE               0x001  /* Writable */ 
     427#define SHF_ALLOC               0x002  /* occupies memory */ 
     428#define SHF_EXECINSTR           0x004  /* executable */ 
     429#define SHF_MERGE               0x010  /* merge data */ 
     430#define SHF_STRINGS             0x020  /* contains strings */ 
     431#define SHF_INFO_LINK           0x040  /* link in sh_info field */ 
     432#define SHF_LINK_ORDER          0x080  /* preserve link order */ 
     433#define SHF_OS_NONCONFORMING    0x100  /* special OS-specific */ 
     434                                               /*  processing needed */ 
     435#define SHF_GROUP               0x200  /* member of group */ 
     436#define SHF_MASKOS              0x0ff00000     /* reserved bits for OS */ 
     437                                               /*  specific section attributes */ 
     438#define SHF_MASKPROC            0xf0000000     /* reserved bits for processor */ 
     439                                               /*  specific section attributes */ 
    441440 
    442441// ------------------------------------------------------------------------- 
     
    444443 
    445444typedef struct { 
    446     Elf32_Word          st_name;        /* name - index into string table */ 
    447     Elf32_Addr          st_value;       /* symbol value */ 
    448     Elf32_Word          st_size;        /* symbol size */ 
    449     unsigned char       st_info;        /* type and binding */ 
    450     unsigned char       st_other;       /* visibility */ 
    451     Elf32_Half          st_shndx;       /* section header index */ 
     445       Elf32_Word st_name;     /* name - index into string table */ 
     446       Elf32_Addr st_value;    /* symbol value */ 
     447       Elf32_Word st_size;     /* symbol size */ 
     448       unsigned char st_info;  /* type and binding */ 
     449       unsigned char st_other; /* visibility */ 
     450       Elf32_Half st_shndx;    /* section header index */ 
    452451} Elf32_Sym; 
    453452 
    454453typedef struct { 
    455     Elf64_Word          st_name;        /* Symbol name index in str table */ 
    456     unsigned char       st_info;        /* type / binding attrs */ 
    457     unsigned char       st_other;       /* visibility */ 
    458     Elf64_Half          st_shndx;       /* section index of symbol */ 
    459     Elf64_Addr          st_value;       /* value of symbol */ 
    460     Elf64_Xword          st_size;        /* size of symbol */ 
     454       Elf64_Word st_name;     /* Symbol name index in str table */ 
     455       unsigned char st_info;  /* type / binding attrs */ 
     456       unsigned char st_other; /* visibility */ 
     457       Elf64_Half st_shndx;    /* section index of symbol */ 
     458       Elf64_Addr st_value;    /* value of symbol */ 
     459       Elf64_Xword st_size;    /* size of symbol */ 
    461460} Elf64_Sym; 
    462461 
     
    464463/* Symbol table index */ 
    465464 
    466 #define STN_UNDEF       0               /* undefined */ 
     465#define STN_UNDEF       0      /* undefined */ 
    467466 
    468467/* Extract symbol info - st_info */ 
     
    481480/* Symbol Binding - ELF32_ST_BIND - st_info */ 
    482481 
    483 #define STB_LOCAL       0               /* Local symbol */ 
    484 #define STB_GLOBAL      1               /* Global symbol */ 
    485 #define STB_WEAK        2               /* like global - lower precedence */ 
    486 #define STB_NUM         3               /* number of symbol bindings */ 
    487 #define STB_LOOS        10              /* reserved range for OS */ 
    488 #define STB_HIOS        12              /*  specific symbol bindings */ 
    489 #define STB_LOPROC      13              /* reserved range for processor */ 
    490 #define STB_HIPROC      15              /*  specific symbol bindings */ 
     482#define STB_LOCAL       0      /* Local symbol */ 
     483#define STB_GLOBAL      1      /* Global symbol */ 
     484#define STB_WEAK        2      /* like global - lower precedence */ 
     485#define STB_NUM         3      /* number of symbol bindings */ 
     486#define STB_LOOS        10     /* reserved range for OS */ 
     487#define STB_HIOS        12     /*  specific symbol bindings */ 
     488#define STB_LOPROC      13     /* reserved range for processor */ 
     489#define STB_HIPROC      15     /*  specific symbol bindings */ 
    491490 
    492491// ------------------------------------------------------------------------- 
    493492/* Symbol type - ELF32_ST_TYPE - st_info */ 
    494493 
    495 #define STT_NOTYPE      0               /* not specified */ 
    496 #define STT_OBJECT      1               /* data object */ 
    497 #define STT_FUNC        2               /* function */ 
    498 #define STT_SECTION     3               /* section */ 
    499 #define STT_FILE        4               /* file */ 
    500 #define STT_COMMON      5               /* common block */ 
    501 #define STT_NUM         6               /* number of symbol types */ 
    502 #define STT_LOOS        10              /* reserved range for OS */ 
    503 #define STT_HIOS        12              /*  specific symbol types */ 
    504 #define STT_LOPROC      13              /* reserved range for processor */ 
    505 #define STT_HIPROC      15              /*  specific symbol types */ 
     494#define STT_NOTYPE      0      /* not specified */ 
     495#define STT_OBJECT      1      /* data object */ 
     496#define STT_FUNC        2      /* function */ 
     497#define STT_SECTION     3      /* section */ 
     498#define STT_FILE        4      /* file */ 
     499#define STT_COMMON      5      /* common block */ 
     500#define STT_NUM         6      /* number of symbol types */ 
     501#define STT_LOOS        10     /* reserved range for OS */ 
     502#define STT_HIOS        12     /*  specific symbol types */ 
     503#define STT_LOPROC      13     /* reserved range for processor */ 
     504#define STT_HIPROC      15     /*  specific symbol types */ 
    506505 
    507506// ------------------------------------------------------------------------- 
    508507// symbol visibility in st_other 
    509508 
    510 #define STV_DEFAULT     0               /* default to binding type */ 
    511 #define STV_INTERNAL    1               /* processor specific */ 
    512 #define STV_HIDDEN      2               /* invisible */ 
    513 #define STV_PROTECTED   3               /* non-premptable */ 
     509#define STV_DEFAULT     0      /* default to binding type */ 
     510#define STV_INTERNAL    1      /* processor specific */ 
     511#define STV_HIDDEN      2      /* invisible */ 
     512#define STV_PROTECTED   3      /* non-premptable */ 
    514513 
    515514// ------------------------------------------------------------------------- 
     
    517516 
    518517/* Relocation entry with implicit addend */ 
    519 typedef struct  
    520 
    521         Elf32_Addr      r_offset;       /* offset of relocation */ 
    522         Elf32_Word      r_info;         /* symbol table index and type */ 
     518typedef struct { 
     519        Elf32_Addr r_offset;    /* offset of relocation */ 
     520        Elf32_Word r_info;      /* symbol table index and type */ 
    523521} Elf32_Rel; 
    524522 
    525523/* Relocation entry with explicit addend */ 
    526 typedef struct  
    527 
    528         Elf32_Addr      r_offset;       /* offset of relocation */ 
    529         Elf32_Word      r_info;         /* symbol table index and type */ 
    530         Elf32_Sword     r_addend; 
     524typedef struct { 
     525        Elf32_Addr r_offset;    /* offset of relocation */ 
     526        Elf32_Word r_info;      /* symbol table index and type */ 
     527        Elf32_Sword r_addend; 
    531528} Elf32_Rela; 
    532529 
     
    540537 
    541538typedef struct { 
    542         Elf64_Addr      r_offset;       /* where to do it */ 
    543         Elf64_Xword     r_info;         /* index & type of relocation */ 
     539       Elf64_Addr r_offset;    /* where to do it */ 
     540       Elf64_Xword r_info;     /* index & type of relocation */ 
    544541} Elf64_Rel; 
    545542 
    546543typedef struct { 
    547         Elf64_Addr      r_offset;       /* where to do it */ 
    548         Elf64_Xword     r_info;         /* index & type of relocation */ 
    549         Elf64_Sxword    r_addend;       /* adjustment value */ 
     544       Elf64_Addr r_offset;    /* where to do it */ 
     545       Elf64_Xword r_info;     /* index & type of relocation */ 
     546       Elf64_Sxword r_addend;  /* adjustment value */ 
    550547} Elf64_RelA; 
    551548 
     
    558555 
    559556typedef struct { 
    560     Elf32_Word  p_type;         /* segment type */ 
    561     Elf32_Off   p_offset;       /* segment offset */ 
    562     Elf32_Addr  p_vaddr;        /* virtual address of segment */ 
    563     Elf32_Addr  p_paddr;        /* physical address - ignored? */ 
    564     Elf32_Word  p_filesz;       /* number of bytes in file for seg. */ 
    565     Elf32_Word  p_memsz;        /* number of bytes in mem. for seg. */ 
    566     Elf32_Word  p_flags;        /* flags */ 
    567     Elf32_Word  p_align;        /* memory alignment */ 
     557       Elf32_Word p_type;      /* segment type */ 
     558       Elf32_Off p_offset;     /* segment offset */ 
     559       Elf32_Addr p_vaddr;     /* virtual address of segment */ 
     560       Elf32_Addr p_paddr;     /* physical address - ignored? */ 
     561       Elf32_Word p_filesz;    /* number of bytes in file for seg. */ 
     562       Elf32_Word p_memsz;     /* number of bytes in mem. for seg. */ 
     563       Elf32_Word p_flags;     /* flags */ 
     564       Elf32_Word p_align;     /* memory alignment */ 
    568565} Elf32_Phdr; 
    569566 
    570567typedef struct { 
    571     Elf64_Word  p_type;         /* entry type */ 
    572     Elf64_Word  p_flags;        /* flags */ 
    573     Elf64_Off   p_offset;       /* offset */ 
    574     Elf64_Addr  p_vaddr;        /* virtual address */ 
    575     Elf64_Addr  p_paddr;        /* physical address */ 
    576     Elf64_Xword p_filesz;       /* file size */ 
    577     Elf64_Xword p_memsz;        /* memory size */ 
    578     Elf64_Xword p_align;        /* memory & file alignment */ 
     568       Elf64_Word p_type;      /* entry type */ 
     569       Elf64_Word p_flags;     /* flags */ 
     570       Elf64_Off p_offset;     /* offset */ 
     571       Elf64_Addr p_vaddr;     /* virtual address */ 
     572       Elf64_Addr p_paddr;     /* physical address */ 
     573       Elf64_Xword p_filesz;   /* file size */ 
     574       Elf64_Xword p_memsz;    /* memory size */ 
     575       Elf64_Xword p_align;    /* memory & file alignment */ 
    579576} Elf64_Phdr; 
    580577 
     
    582579/* Segment types - p_type */ 
    583580 
    584 #define PT_NULL         0               /* unused */ 
    585 #define PT_LOAD         1               /* loadable segment */ 
    586 #define PT_DYNAMIC      2               /* dynamic linking section */ 
    587 #define PT_INTERP       3               /* the RTLD */ 
    588 #define PT_NOTE         4               /* auxiliary information */ 
    589 #define PT_SHLIB        5               /* reserved - purpose undefined */ 
    590 #define PT_PHDR         6               /* program header */ 
    591 #define PT_NUM          7               /* Number of segment types */ 
    592 #define PT_LOOS         0x60000000      /* reserved range for OS */ 
    593 #define PT_HIOS         0x6fffffff      /*  specific segment types */ 
    594 #define PT_LOPROC       0x70000000      /* reserved range for processor */ 
    595 #define PT_HIPROC       0x7fffffff      /*  specific segment types */ 
     581#define PT_NULL         0      /* unused */ 
     582#define PT_LOAD         1      /* loadable segment */ 
     583#define PT_DYNAMIC      2      /* dynamic linking section */ 
     584#define PT_INTERP       3      /* the RTLD */ 
     585#define PT_NOTE         4      /* auxiliary information */ 
     586#define PT_SHLIB        5      /* reserved - purpose undefined */ 
     587#define PT_PHDR         6      /* program header */ 
     588#define PT_NUM          7      /* Number of segment types */ 
     589#define PT_LOOS         0x60000000     /* reserved range for OS */ 
     590#define PT_HIOS         0x6fffffff     /*  specific segment types */ 
     591#define PT_LOPROC       0x70000000     /* reserved range for processor */ 
     592#define PT_HIPROC       0x7fffffff     /*  specific segment types */ 
    596593 
    597594// ------------------------------------------------------------------------- 
    598595/* Segment flags - p_flags */ 
    599596 
    600 #define PF_X            0x1             /* Executable */ 
    601 #define PF_W            0x2             /* Writable */ 
    602 #define PF_R            0x4             /* Readable */ 
    603 #define PF_MASKOS       0x0ff00000      /* reserved bits for OS */ 
    604                                         /*  specific segment flags */ 
    605 #define PF_MASKPROC     0xf0000000      /* reserved bits for processor */ 
    606                                         /*  specific segment flags */ 
     597#define PF_X            0x1    /* Executable */ 
     598#define PF_W            0x2    /* Writable */ 
     599#define PF_R            0x4    /* Readable */ 
     600#define PF_MASKOS       0x0ff00000     /* reserved bits for OS */ 
     601                                       /*  specific segment flags */ 
     602#define PF_MASKPROC     0xf0000000     /* reserved bits for processor */ 
     603                                       /*  specific segment flags */ 
    607604 
    608605// ------------------------------------------------------------------------- 
     
    610607 
    611608typedef struct { 
    612     Elf32_Sword         d_tag;  /* controls meaning of d_val */ 
    613     union { 
    614         Elf32_Word      d_val;  /* Multiple meanings - see d_tag */ 
    615         Elf32_Addr      d_ptr;  /* program virtual address */ 
    616     } d_un; 
     609       Elf32_Sword d_tag;      /* controls meaning of d_val */ 
     610       union { 
     611               Elf32_Word d_val;       /* Multiple meanings - see d_tag */ 
     612               Elf32_Addr d_ptr;       /* program virtual address */ 
     613       } d_un; 
    617614} Elf32_Dyn; 
    618615 
    619 extern Elf32_Dyn        _DYNAMIC[];     /* XXX not 64-bit clean */ 
    620  
    621 typedef struct { 
    622     Elf64_Sxword        d_tag;  /* controls meaning of d_val */ 
    623     union { 
    624         Elf64_Xword    d_val; 
    625         Elf64_Addr      d_ptr; 
    626     } d_un; 
     616extern Elf32_Dyn _DYNAMIC[];   /* XXX not 64-bit clean */ 
     617 
     618typedef struct { 
     619       Elf64_Sxword d_tag;     /* controls meaning of d_val */ 
     620       union { 
     621               Elf64_Xword d_val; 
     622               Elf64_Addr d_ptr; 
     623       } d_un; 
    627624} Elf64_Dyn; 
    628625 
     
    630627/* Dynamic Array Tags - d_tag */ 
    631628 
    632 #define DT_NULL         0               /* marks end of _DYNAMIC array */ 
    633 #define DT_NEEDED       1               /* string table offset of needed lib */ 
    634 #define DT_PLTRELSZ     2               /* size of relocation entries in PLT */ 
    635 #define DT_PLTGOT       3               /* address PLT/GOT */ 
    636 #define DT_HASH         4               /* address of symbol hash table */ 
    637 #define DT_STRTAB       5               /* address of string table */ 
    638 #define DT_SYMTAB       6               /* address of symbol table */ 
    639 #define DT_RELA         7               /* address of relocation table */ 
    640 #define DT_RELASZ       8               /* size of relocation table */ 
    641 #define DT_RELAENT      9               /* size of relocation entry */ 
    642 #define DT_STRSZ        10              /* size of string table */ 
    643 #define DT_SYMENT       11              /* size of symbol table entry */ 
    644 #define DT_INIT         12              /* address of initialization func. */ 
    645 #define DT_FINI         13              /* address of termination function */ 
    646 #define DT_SONAME       14              /* string table offset of shared obj */ 
    647 #define DT_RPATH        15              /* string table offset of library 
    648                                            search path */ 
    649 #define DT_SYMBOLIC     16              /* start sym search in shared obj. */ 
    650 #define DT_REL          17              /* address of rel. tbl. w addends */ 
    651 #define DT_RELSZ        18              /* size of DT_REL relocation table */ 
    652 #define DT_RELENT       19              /* size of DT_REL relocation entry */ 
    653 #define DT_PLTREL       20              /* PLT referenced relocation entry */ 
    654 #define DT_DEBUG        21              /* bugger */ 
    655 #define DT_TEXTREL      22              /* Allow rel. mod. to unwritable seg */ 
    656 #define DT_JMPREL       23              /* add. of PLT's relocation entries */ 
    657 #define DT_BIND_NOW     24              /* Bind now regardless of env setting */ 
    658 #define DT_INIT_ARRAY   25              /* init array address */ 
    659 #define DT_FINI_ARRAY   26              /* fini array address */ 
    660 #define DT_INIT_ARRAYSZ 27              /* init array size */ 
    661 #define DT_FINI_ARRAYSZ 28              /* fini array size */ 
    662 #define DT_RUNPATH      29              /* library search path */ 
    663 #define DT_FLAGS        30              /* flags */ 
    664 #define DT_ENCODING     32              /* encoding rules start here */ 
    665 #define DT_PREINIT_ARRAY 32             /* preinit array address */ 
    666 #define DT_PREINIT_ARRAYSZ 33           /* preinit array size */ 
    667 #define DT_NUM          26              /* Number used. */ 
    668 #define DT_LOOS         0x60000000      /* reserved range for OS */ 
    669 #define DT_HIOS         0x6fffffff      /*  specific dynamic array tags */ 
    670 #define DT_LOPROC       0x70000000      /* reserved range for processor */ 
    671 #define DT_HIPROC       0x7fffffff      /*  specific dynamic array tags */ 
     629#define DT_NULL         0      /* marks end of _DYNAMIC array */ 
     630#define DT_NEEDED       1      /* string table offset of needed lib */ 
     631#define DT_PLTRELSZ     2      /* size of relocation entries in PLT */ 
     632#define DT_PLTGOT       3      /* address PLT/GOT */ 
     633#define DT_HASH         4      /* address of symbol hash table */ 
     634#define DT_STRTAB       5      /* address of string table */ 
     635#define DT_SYMTAB       6      /* address of symbol table */ 
     636#define DT_RELA         7      /* address of relocation table */ 
     637#define DT_RELASZ       8      /* size of relocation table */ 
     638#define DT_RELAENT      9      /* size of relocation entry */ 
     639#define DT_STRSZ        10     /* size of string table */ 
     640#define DT_SYMENT       11     /* size of symbol table entry */ 
     641#define DT_INIT         12     /* address of initialization func. */ 
     642#define DT_FINI         13     /* address of termination function */ 
     643#define DT_SONAME       14     /* string table offset of shared obj */ 
     644#define DT_RPATH        15     /* string table offset of library 
     645                                  search path */ 
     646#define DT_SYMBOLIC     16     /* start sym search in shared obj. */ 
     647#define DT_REL          17     /* address of rel. tbl. w addends */ 
     648#define DT_RELSZ        18     /* size of DT_REL relocation table */ 
     649#define DT_RELENT       19     /* size of DT_REL relocation entry */ 
     650#define DT_PLTREL       20     /* PLT referenced relocation entry */ 
     651#define DT_DEBUG        21     /* bugger */ 
     652#define DT_TEXTREL      22     /* Allow rel. mod. to unwritable seg */ 
     653#define DT_JMPREL       23     /* add. of PLT's relocation entries */ 
     654#define DT_BIND_NOW     24     /* Bind now regardless of env setting */ 
     655#define DT_INIT_ARRAY   25     /* init array address */ 
     656#define DT_FINI_ARRAY   26     /* fini array address */ 
     657#define DT_INIT_ARRAYSZ 27     /* init array size */ 
     658#define DT_FINI_ARRAYSZ 28     /* fini array size */ 
     659#define DT_RUNPATH      29     /* library search path */ 
     660#define DT_FLAGS        30     /* flags */ 
     661#define DT_ENCODING     32     /* encoding rules start here */ 
     662#define DT_PREINIT_ARRAY 32    /* preinit array address */ 
     663#define DT_PREINIT_ARRAYSZ 33  /* preinit array size */ 
     664#define DT_NUM          26     /* Number used. */ 
     665#define DT_LOOS         0x60000000     /* reserved range for OS */ 
     666#define DT_HIOS         0x6fffffff     /*  specific dynamic array tags */ 
     667#define DT_LOPROC       0x70000000     /* reserved range for processor */ 
     668#define DT_HIPROC       0x7fffffff     /*  specific dynamic array tags */ 
    672669 
    673670// ------------------------------------------------------------------------- 
    674671// Values for DT_FLAGS entry 
    675672 
    676 #define DF_ORIGIN       0x1             /* Uses $ORIGIN substitution string */ 
    677 #define DF_SYMBOLIC     0x2             /* search for symbols here first */ 
    678 #define DF_TEXTREL      0x4             /* text may be relocatable */ 
    679 #define DF_BIND_NOW     0x8             /* bind references now, dammit */ 
     673#define DF_ORIGIN       0x1    /* Uses $ORIGIN substitution string */ 
     674#define DF_SYMBOLIC     0x2    /* search for symbols here first */ 
     675#define DF_TEXTREL      0x4    /* text may be relocatable */ 
     676#define DF_BIND_NOW     0x8    /* bind references now, dammit */ 
    680677 
    681678// ------------------------------------------------------------------------- 
     
    683680 
    684681typedef struct { 
    685     Elf32_Word namesz; 
    686     Elf32_Word descsz; 
    687     Elf32_Word type; 
     682       Elf32_Word namesz; 
     683       Elf32_Word descsz; 
     684       Elf32_Word type; 
    688685} Elf32_Note; 
    689686 
    690687typedef struct { 
    691     Elf64_Word namesz; 
    692     Elf64_Word descsz; 
    693     Elf64_Word type; 
     688       Elf64_Word namesz; 
     689       Elf64_Word descsz; 
     690       Elf64_Word type; 
    694691} Elf64_Note; 
    695692 
     
    699696 
    700697typedef struct { 
    701     Elf32_Word          nbucket;        /* number of buckets */ 
    702     Elf32_Word          nchain;         /* number of chains */ 
    703  
    704     /* The buckets follow this structure in memory and the chains 
    705        follow those. */ 
     698       Elf32_Word nbucket;     /* number of buckets */ 
     699       Elf32_Word nchain;      /* number of chains */ 
     700 
     701       /* The buckets follow this structure in memory and the chains 
     702          follow those. */ 
    706703} Elf_Hash; 
    707704 
    708705// ------------------------------------------------------------------------- 
    709 #endif // ifndef CYGONCE_REDBOOT_ELF_H 
     706#endif                         // ifndef CYGONCE_REDBOOT_ELF_H 
    710707// EOF elf.h 
  • ar5315_microredboot/microredboot/boot/src/lib/fis.c

    r13101 r13107  
    2424        unsigned int copy = highoffset; 
    2525        int c = SCANCOUNT; 
    26         while ((c--)>0) { 
     26        while ((c--) > 0) { 
    2727                highoffset -= erasesize; 
    2828                unsigned char *p = (unsigned char *)highoffset; 
     
    3030                        return highoffset; 
    3131        } 
    32         return copy - erasesize; // default offset, if not found 
     32        return copy - erasesize;       // default offset, if not found 
    3333} 
    3434 
     
    7272                count++; 
    7373        } 
    74         printf("no bootable image found, try default location 0x%08X\n",flashbase+0x10000); 
     74        printf("no bootable image found, try default location 0x%08X\n", 
     75               flashbase + 0x10000); 
    7576        bootoffset = 0x80041000; 
    7677        output_data = (uch *) 0x80041000; 
    77         return flashbase+0x10000;     //first available address after bootloader 
     78        return flashbase + 0x10000;   //first available address after bootloader 
    7879} 
  • ar5315_microredboot/microredboot/boot/src/misc_lzma.c

    r13100 r13107  
    2020#include <asm/uaccess.h> 
    2121#include "ramconfig.h" 
     22#include "revision.h" 
    2223#ifdef AR7100 
    2324#define inline 
     
    311312        /* initialize clock */ 
    312313        HAL_CLOCK_INITIALIZE(RTC_PERIOD); 
    313         printf("MicroRedBoot v1.4, (c) 2009 DD-WRT.COM (%s)\n", __DATE__); 
     314        printf("MicroRedBoot v1.4, (c) 2009 DD-WRT.COM (%s REVISION %s)\n", __DATE__,SVN_REVISION); 
    314315        printf("keep the reset button pushed to enter redboot!\n"); 
    315 #ifdef AR7100 
    316         printf("CPU Type: AR7100\n"); 
    317 #elif  AR5312 
    318         printf("CPU Type: AR5312\n"); 
    319 #else 
    320         printf("CPU Type: AR5315\n"); 
    321 #endif 
     316        printf("CPU Type: Atheros AR%s\n",get_system_type()); 
    322317        printf("CPU Clock: %dMhz\n", cpu_frequency() / 1000000); 
    323318        nvram_init(); 
  • ar5315_microredboot/microredboot/boot/src/ramconfig.h

    r13097 r13107  
    11#define RAM_SIZE 0x2000000 
    2 #define AR7100
     2#define AR5312
    33#define RESETBUTTON 0x06 
     4#define RESETBUTTON 0x18 
  • ar5315_microredboot/microredboot/build_targets.sh

    r13090 r13107  
    6363cp images/*.rom images_default 
    6464 
     65rm -f images/* 
     66make pb44 RESETBUTTON=0x18 FIS=0 
     67mkdir images_default 
     68cp images/*.rom images_default 
     69 
     70rm -f images/* 
     71make pb42 RESETBUTTON=0x18 FIS=0 
     72mkdir images_default 
     73cp images/*.rom images_default 
     74 
    6575 
    6676cp -rv images_senao /GruppenLW/releases/images 
  • ar5315_microredboot/microredboot/ecos/packages/devs/eth/mips/ar7100/current/src/vsc8601_phy.c

    r13097 r13107  
    4242#endif 
    4343 
     44#include "ag7100_phy.h" 
    4445#include "vsc8601_phy.h" 
    4546 
  • ar5315_microredboot/microredboot/ecos/packages/hal/mips/ar7100/current/src/ar7100_serial.c

    r13095 r13107  
    234234 
    235235    // Set baud rate. 
    236     cyg_hal_plf_serial_set_baud(port, hal_ar7100_sys_frequency() / (16 * 
    237                       CYGNUM_HAL_VIRTUAL_VECTOR_CHANNELS_DEFAULT_BAUD)); 
     236    cyg_hal_plf_serial_set_baud(port, hal_ar7100_sys_frequency() / (16 * CYGNUM_HAL_VIRTUAL_VECTOR_CHANNELS_DEFAULT_BAUD)); 
    238237 
    239238    // Enable and clear FIFO 
  • ar5315_microredboot/microredboot/ecos/packages/hal/mips/pb44/current/cdl/hal_mips_pb44.cdl

    r13095 r13107  
    195195        display         "Linked entry address" 
    196196        flavor          data 
    197         default_value   0x80010000 
     197        default_value   0x80000000 
    198198        description     "Text segment load address." 
    199199    } 
  • ar5315_microredboot/microredboot/ecos/packages/hal/mips/pb44/current/include/pkgconf/mlt_mips_pb44_ram.ldi

    r13095 r13107  
    1111{ 
    1212    SECTIONS_BEGIN 
    13     SECTION_rom_vectors (ram, CYGNUM_RAM_ENTRY, LMA_EQ_VMA) 
     13    SECTION_rom_vectors (ram, 0x80000400, LMA_EQ_VMA) 
    1414    SECTION_ROMISC (ram, ALIGN (0x4), LMA_EQ_VMA) 
    1515    SECTION_RELOCS (ram, ALIGN (0x4), LMA_EQ_VMA) 
  • ar5315_microredboot/microredboot/ecos/packages/hal/mips/pb44/current/misc/redboot_RAM.ecm

    r13095 r13107  
    2121    package -template CYGPKG_LIBC_STRING current ; 
    2222    package CYGPKG_MEMALLOC current ; 
    23     package CYGPKG_COMPRESS_ZLIB current ; 
    2423    package CYGPKG_COMPRESS_7ZIP current ; 
    2524    package CYGPKG_IO_ETH_DRIVERS current ; 
    26     package CYGPKG_IO_FILEIO current ; 
    2725    package CYGPKG_IO_FLASH current ; 
    2826    package CYGPKG_DEVS_FLASH_AR7100 current ; 
     
    8179 
    8280cdl_option CYGBLD_REDBOOT_MIN_IMAGE_SIZE { 
    83     inferred_value 0x40000 
     81    inferred_value 0x10000 
    8482}; 
    8583 
     
    123121    inferred_value 1 <cyg/fileio/dirent.h> 
    124122}; 
    125  
    126 cdl_option CYGBLD_ISO_OPEN_MAX_HEADER { 
    127     inferred_value 1 <cyg/fileio/limits.h> 
    128 }; 
    129  
    130 cdl_option CYGBLD_ISO_NAME_MAX_HEADER { 
    131     inferred_value 1 <cyg/fileio/limits.h> 
    132 }; 
    133  
    134 cdl_option CYGPKG_IO_FILEIO_INODE { 
    135     inferred_value 1 
    136 }; 
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade_senao.c

    r13090 r13107  
     1 
    12/* 
    23firmware upgrade code for senao webflash images 
     
    89#include <flash_config.h> 
    910#include "fwupgrade.h" 
     11#ifndef CYGPKG_HAL_MIPS_AR7100 
    1012 
    1113/* some variables from flash.c */ 
     
    100102        return 0; 
    101103} 
     104#endif 
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade_ubnt.c

    r13090 r13107  
    7474                diag_printf 
    7575                    ("UBNT_FW: cannot upgrade, wrong target platform. only ar2313 is valid"); 
     76                return -1; 
     77        } 
     78#endif 
     79#if defined(CYGPKG_HAL_MIPS_AR7100) 
     80        if (strncmp((unsigned char *)&header->version[4], "ar7100", 6) && strncmp((unsigned char *)&header->version[6], "ar7100pro", 9)) { 
     81                diag_printf 
     82                    ("UBNT_FW: cannot upgrade, wrong target platform. only ar7100 (RouterStation) or ar7100pro (RouterStation PRO) is valid"); 
    7683                return -1; 
    7784        } 
     
    164171                        unsigned int base = ntohl(fwp->header->baseaddr); 
    165172                        /* convert flash mappings to fit to the current bootloader flash mapping which might be incompatible */ 
     173#if defined(CYGPKG_HAL_MIPS_AR7100) 
     174                        if ((base & 0xbf00000) == 0xbf00000) { 
     175                                base ^= 0xbf00000; // for AR7100 
     176                        } 
     177#else 
    166178                        if ((base & 0xbfc00000) == 0xbfc00000) { 
    167                                 base ^= 0xbfc00000; 
     179                                base ^= 0xbfc00000;// mips mapping  
    168180                        } else if ((base & 0xbe00000) == 0xbe00000) { 
    169                                 base ^= 0xbe00000; 
     181                                base ^= 0xbe00000; // for AR5312  
    170182                        } else if ((base & 0xa800000) == 0xa800000) { 
    171                                 base ^= 0xa800000; 
    172                         } 
     183                                base ^= 0xa800000; // for AR5315 8 MB mapping 
     184                        } 
     185#endif 
    173186                        base |= CYGNUM_FLASH_BASE; 
    174187                        if ((stat = 
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade_wili.c

    r13090 r13107  
    88#include <flash_config.h> 
    99#include "fwupgrade_wili.h" 
     10#ifndef CYGPKG_HAL_MIPS_AR7100 
    1011 
    1112/* some variables from flash.c */ 
     
    278279        return 0; 
    279280} 
     281#endif 
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/tftp_server.c

    r13090 r13107  
    101101        {.name = "DD-WRT",.fw_check_image = fw_check_image_ddwrt}, 
    102102        {.name = "UBIQUITI",.fw_check_image = fw_check_image_ubnt}, 
     103#ifndef CYGPKG_HAL_MIPS_AR7100 
    103104        {.name = "WILIGEAR",.fw_check_image = fw_check_image_wili}, 
    104105        {.name = "SENAO",.fw_check_image = fw_check_image_senao}, 
     106#endif 
    105107}; 
    106108 
  • ar5315_microredboot/microredboot/makefile

    r13097 r13107  
    135135        $(PLATFORM_BLD_CUST) 
    136136        $(PLATFORM_RAM_BUILD) 
    137         cp redboot/pb42/ram/install/bin/redboot.rom images/redboot_pb42_32M_8M_kendin.rom 
    138         cp redboot/pb42/ram/install/bin/redboot.img images/redboot_pb42_32M_8M_kendin.elf 
     137        cp redboot/pb42/ram/install/bin/redboot.rom images/redboot_pb42_32M_8M_admtek.rom 
     138#       cp redboot/pb42/ram/install/bin/redboot.img images/redboot_pb42_32M_8M_admtek.elf 
     139 
     140 
     141pb44:   BOARD_TYPE=pb44 
     142pb44: 
     143# RAM version 
     144        $(PLATFORM_RAM_START) \ 
     145        ecosconfig import $(ECOS_REPOSITORY)/hal/mips/pb44/current/misc/redboot_RAM.ecm; \ 
     146        ecosconfig import $(REDBOOT_DIR)/options/eth_ar7100/vsc8601_phy; \ 
     147        ecosconfig tree; \ 
     148        $(PLATFORM_BLD_CUST) 
     149        $(PLATFORM_RAM_BUILD) 
     150        cp redboot/pb44/ram/install/bin/redboot.rom images/redboot_pb44_32M_8M_vsc8601.rom 
     151#       cp redboot/pb44/ram/install/bin/redboot.img images/redboot_pb42_32M_8M_kendin.elf 
     152 
    139153 
    140154#