U-Boot
Threads by month
- ----- 2025 -----
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2000 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
July 2009
- 209 participants
- 698 discussions

[U-Boot] [PATCH-ARM] Add support for Embest SBC2440-II Board 2/7
by kevin.morfitt@fearnside-systems.co.uk 08 Jul '09
by kevin.morfitt@fearnside-systems.co.uk 08 Jul '09
08 Jul '09
This patch re-formats the s3c24x0 header files in preparation for changes
to add support for the Embest SBC2440-II Board.
The changes are as follows:
- re-indent the code using Lindent
- make sure register layouts are defined using a C struct, from a
comment by Wolfgang on 03/06/2009
- replace the upper-case typedef'ed C struct names with lower case
non-typedef'ed ones, from a comment by Scott on 22/06/2009
- make sure registers are accessed using the proper accessor
functions, from a comment by Wolfgang on 03/06/2009
- run checkpatch.pl and fix any error reports
Signed-off-by: Kevin Morfitt <kevin.morfitt(a)fearnside-systems.co.uk>
---
include/s3c2400.h | 493 ++++----------------------------------------
include/s3c2410.h | 158 ++++-----------
include/s3c24x0.h | 595 +++++------------------------------------------------
3 files changed, 130 insertions(+), 1116 deletions(-)
diff --git a/include/s3c2400.h b/include/s3c2400.h
index 4fdc62e..89027fa 100644
--- a/include/s3c2400.h
+++ b/include/s3c2400.h
@@ -35,12 +35,12 @@
#define S3C24X0_SPI_CHANNELS 1
#define PALETTE (0x14A00400) /* SJS */
-typedef enum {
+enum s3c24x0_uarts_nr {
S3C24X0_UART0,
S3C24X0_UART1,
-} S3C24X0_UARTS_NR;
+};
-/* S3C2400 device base addresses */
+/*S3C2400 device base addresses */
#define S3C24X0_MEMCTL_BASE 0x14000000
#define S3C24X0_USB_HOST_BASE 0x14200000
#define S3C24X0_INTERRUPT_BASE 0x14400000
@@ -63,492 +63,73 @@ typedef enum {
#include <s3c24x0.h>
-static inline S3C24X0_MEMCTL * S3C24X0_GetBase_MEMCTL(void)
+static inline struct s3c24x0_memctl *S3C24X0_GetBase_MEMCTL(void)
{
- return (S3C24X0_MEMCTL * const)S3C24X0_MEMCTL_BASE;
+ return (struct s3c24x0_memctl *)S3C24X0_MEMCTL_BASE;
}
-static inline S3C24X0_USB_HOST * S3C24X0_GetBase_USB_HOST(void)
+static inline struct s3c24x0_usb_host *S3C24X0_GetBase_USB_HOST(void)
{
- return (S3C24X0_USB_HOST * const)S3C24X0_USB_HOST_BASE;
+ return (struct s3c24x0_usb_host *)S3C24X0_USB_HOST_BASE;
}
-static inline S3C24X0_INTERRUPT * S3C24X0_GetBase_INTERRUPT(void)
+static inline struct s3c24x0_interrupt *S3C24X0_GetBase_INTERRUPT(void)
{
- return (S3C24X0_INTERRUPT * const)S3C24X0_INTERRUPT_BASE;
+ return (struct s3c24x0_interrupt *)S3C24X0_INTERRUPT_BASE;
}
-static inline S3C24X0_DMAS * S3C24X0_GetBase_DMAS(void)
+static inline struct s3c24x0_dmas *S3C24X0_GetBase_DMAS(void)
{
- return (S3C24X0_DMAS * const)S3C24X0_DMA_BASE;
+ return (struct s3c24x0_dmas *)S3C24X0_DMA_BASE;
}
-static inline S3C24X0_CLOCK_POWER * S3C24X0_GetBase_CLOCK_POWER(void)
+static inline struct s3c24x0_clock_power *S3C24X0_GetBase_CLOCK_POWER(void)
{
- return (S3C24X0_CLOCK_POWER * const)S3C24X0_CLOCK_POWER_BASE;
+ return (struct s3c24x0_clock_power *)S3C24X0_CLOCK_POWER_BASE;
}
-static inline S3C24X0_LCD * S3C24X0_GetBase_LCD(void)
+static inline struct s3c24x0_lcd *S3C24X0_GetBase_LCD(void)
{
- return (S3C24X0_LCD * const)S3C24X0_LCD_BASE;
+ return (struct s3c24x0_lcd *)S3C24X0_LCD_BASE;
}
-static inline S3C24X0_UART * S3C24X0_GetBase_UART(S3C24X0_UARTS_NR nr)
+static inline struct s3c24x0_uart *S3C24X0_GetBase_UART(enum s3c24x0_uarts_nr n)
{
- return (S3C24X0_UART * const)(S3C24X0_UART_BASE + (nr * 0x4000));
+ return (struct s3c24x0_uart *)(S3C24X0_UART_BASE + (n * 0x4000));
}
-static inline S3C24X0_TIMERS * S3C24X0_GetBase_TIMERS(void)
+static inline struct s3c24x0_timers *S3C24X0_GetBase_TIMERS(void)
{
- return (S3C24X0_TIMERS * const)S3C24X0_TIMER_BASE;
+ return (struct s3c24x0_timers *)S3C24X0_TIMER_BASE;
}
-static inline S3C24X0_USB_DEVICE * S3C24X0_GetBase_USB_DEVICE(void)
+static inline struct s3c24x0_usb_device *S3C24X0_GetBase_USB_DEVICE(void)
{
- return (S3C24X0_USB_DEVICE * const)S3C24X0_USB_DEVICE_BASE;
+ return (struct s3c24x0_usb_device *)S3C24X0_USB_DEVICE_BASE;
}
-static inline S3C24X0_WATCHDOG * S3C24X0_GetBase_WATCHDOG(void)
+static inline struct s3c24x0_watchdog *S3C24X0_GetBase_WATCHDOG(void)
{
- return (S3C24X0_WATCHDOG * const)S3C24X0_WATCHDOG_BASE;
+ return (struct s3c24x0_watchdog *)S3C24X0_WATCHDOG_BASE;
}
-static inline S3C24X0_I2C * S3C24X0_GetBase_I2C(void)
+static inline struct s3c24x0_i2c *S3C24X0_GetBase_I2C(void)
{
- return (S3C24X0_I2C * const)S3C24X0_I2C_BASE;
+ return (struct s3c24x0_i2c *)S3C24X0_I2C_BASE;
}
-static inline S3C24X0_I2S * S3C24X0_GetBase_I2S(void)
+static inline struct s3c24x0_i2s *S3C24X0_GetBase_I2S(void)
{
- return (S3C24X0_I2S * const)S3C24X0_I2S_BASE;
+ return (struct s3c24x0_i2s *)S3C24X0_I2S_BASE;
}
-static inline S3C24X0_GPIO * S3C24X0_GetBase_GPIO(void)
+static inline struct s3c24x0_gpio *S3C24X0_GetBase_GPIO(void)
{
- return (S3C24X0_GPIO * const)S3C24X0_GPIO_BASE;
+ return (struct s3c24x0_gpio *)S3C24X0_GPIO_BASE;
}
-static inline S3C24X0_RTC * S3C24X0_GetBase_RTC(void)
+static inline struct s3c24x0_rtc *S3C24X0_GetBase_RTC(void)
{
- return (S3C24X0_RTC * const)S3C24X0_RTC_BASE;
+ return (struct s3c24x0_rtc *)S3C24X0_RTC_BASE;
}
-static inline S3C2400_ADC * S3C2400_GetBase_ADC(void)
+static inline struct s3c2400_adc *S3C2400_GetBase_ADC(void)
{
- return (S3C2400_ADC * const)S3C24X0_ADC_BASE;
+ return (struct s3c2400_adc *)S3C24X0_ADC_BASE;
}
-static inline S3C24X0_SPI * S3C24X0_GetBase_SPI(void)
+static inline struct s3c24x0_spi *S3C24X0_GetBase_SPI(void)
{
- return (S3C24X0_SPI * const)S3C24X0_SPI_BASE;
+ return (struct s3c24x0_spi *)S3C24X0_SPI_BASE;
}
-static inline S3C2400_MMC * S3C2400_GetBase_MMC(void)
+static inline struct s3c2400_mmc *S3C2400_GetBase_MMC(void)
{
- return (S3C2400_MMC * const)S3C2400_MMC_BASE;
+ return (struct s3c2400_mmc *)S3C2400_MMC_BASE;
}
-#if 0
-/* Memory control */
-#define rBWSCON (*(volatile unsigned *)0x14000000)
-#define rBANKCON0 (*(volatile unsigned *)0x14000004)
-#define rBANKCON1 (*(volatile unsigned *)0x14000008)
-#define rBANKCON2 (*(volatile unsigned *)0x1400000C)
-#define rBANKCON3 (*(volatile unsigned *)0x14000010)
-#define rBANKCON4 (*(volatile unsigned *)0x14000014)
-#define rBANKCON5 (*(volatile unsigned *)0x14000018)
-#define rBANKCON6 (*(volatile unsigned *)0x1400001C)
-#define rBANKCON7 (*(volatile unsigned *)0x14000020)
-#define rREFRESH (*(volatile unsigned *)0x14000024)
-#define rBANKSIZE (*(volatile unsigned *)0x14000028)
-#define rMRSRB6 (*(volatile unsigned *)0x1400002C)
-#define rMRSRB7 (*(volatile unsigned *)0x14000030)
-
-
-/* INTERRUPT */
-#define rSRCPND (*(volatile unsigned *)0x14400000)
-#define rINTMOD (*(volatile unsigned *)0x14400004)
-#define rINTMSK (*(volatile unsigned *)0x14400008)
-#define rPRIORITY (*(volatile unsigned *)0x1440000C)
-#define rINTPND (*(volatile unsigned *)0x14400010)
-#define rINTOFFSET (*(volatile unsigned *)0x14400014)
-
-
-/* DMA */
-#define rDISRC0 (*(volatile unsigned *)0x14600000)
-#define rDIDST0 (*(volatile unsigned *)0x14600004)
-#define rDCON0 (*(volatile unsigned *)0x14600008)
-#define rDSTAT0 (*(volatile unsigned *)0x1460000C)
-#define rDCSRC0 (*(volatile unsigned *)0x14600010)
-#define rDCDST0 (*(volatile unsigned *)0x14600014)
-#define rDMASKTRIG0 (*(volatile unsigned *)0x14600018)
-#define rDISRC1 (*(volatile unsigned *)0x14600020)
-#define rDIDST1 (*(volatile unsigned *)0x14600024)
-#define rDCON1 (*(volatile unsigned *)0x14600028)
-#define rDSTAT1 (*(volatile unsigned *)0x1460002C)
-#define rDCSRC1 (*(volatile unsigned *)0x14600030)
-#define rDCDST1 (*(volatile unsigned *)0x14600034)
-#define rDMASKTRIG1 (*(volatile unsigned *)0x14600038)
-#define rDISRC2 (*(volatile unsigned *)0x14600040)
-#define rDIDST2 (*(volatile unsigned *)0x14600044)
-#define rDCON2 (*(volatile unsigned *)0x14600048)
-#define rDSTAT2 (*(volatile unsigned *)0x1460004C)
-#define rDCSRC2 (*(volatile unsigned *)0x14600050)
-#define rDCDST2 (*(volatile unsigned *)0x14600054)
-#define rDMASKTRIG2 (*(volatile unsigned *)0x14600058)
-#define rDISRC3 (*(volatile unsigned *)0x14600060)
-#define rDIDST3 (*(volatile unsigned *)0x14600064)
-#define rDCON3 (*(volatile unsigned *)0x14600068)
-#define rDSTAT3 (*(volatile unsigned *)0x1460006C)
-#define rDCSRC3 (*(volatile unsigned *)0x14600070)
-#define rDCDST3 (*(volatile unsigned *)0x14600074)
-#define rDMASKTRIG3 (*(volatile unsigned *)0x14600078)
-
-
-/* CLOCK & POWER MANAGEMENT */
-#define rLOCKTIME (*(volatile unsigned *)0x14800000)
-#define rMPLLCON (*(volatile unsigned *)0x14800004)
-#define rUPLLCON (*(volatile unsigned *)0x14800008)
-#define rCLKCON (*(volatile unsigned *)0x1480000C)
-#define rCLKSLOW (*(volatile unsigned *)0x14800010)
-#define rCLKDIVN (*(volatile unsigned *)0x14800014)
-
-
-/* LCD CONTROLLER */
-#define rLCDCON1 (*(volatile unsigned *)0x14A00000)
-#define rLCDCON2 (*(volatile unsigned *)0x14A00004)
-#define rLCDCON3 (*(volatile unsigned *)0x14A00008)
-#define rLCDCON4 (*(volatile unsigned *)0x14A0000C)
-#define rLCDCON5 (*(volatile unsigned *)0x14A00010)
-#define rLCDSADDR1 (*(volatile unsigned *)0x14A00014)
-#define rLCDSADDR2 (*(volatile unsigned *)0x14A00018)
-#define rLCDSADDR3 (*(volatile unsigned *)0x14A0001C)
-#define rREDLUT (*(volatile unsigned *)0x14A00020)
-#define rGREENLUT (*(volatile unsigned *)0x14A00024)
-#define rBLUELUT (*(volatile unsigned *)0x14A00028)
-#define rDP1_2 (*(volatile unsigned *)0x14A0002C)
-#define rDP4_7 (*(volatile unsigned *)0x14A00030)
-#define rDP3_5 (*(volatile unsigned *)0x14A00034)
-#define rDP2_3 (*(volatile unsigned *)0x14A00038)
-#define rDP5_7 (*(volatile unsigned *)0x14A0003c)
-#define rDP3_4 (*(volatile unsigned *)0x14A00040)
-#define rDP4_5 (*(volatile unsigned *)0x14A00044)
-#define rDP6_7 (*(volatile unsigned *)0x14A00048)
-#define rDITHMODE (*(volatile unsigned *)0x14A0004C)
-#define rTPAL (*(volatile unsigned *)0x14A00050)
-#define PALETTE (0x14A00400) /* SJS */
-
-
-/* UART */
-#define rULCON0 (*(volatile unsigned char *)0x15000000)
-#define rUCON0 (*(volatile unsigned short *)0x15000004)
-#define rUFCON0 (*(volatile unsigned char *)0x15000008)
-#define rUMCON0 (*(volatile unsigned char *)0x1500000C)
-#define rUTRSTAT0 (*(volatile unsigned char *)0x15000010)
-#define rUERSTAT0 (*(volatile unsigned char *)0x15000014)
-#define rUFSTAT0 (*(volatile unsigned short *)0x15000018)
-#define rUMSTAT0 (*(volatile unsigned char *)0x1500001C)
-#define rUBRDIV0 (*(volatile unsigned short *)0x15000028)
-
-#define rULCON1 (*(volatile unsigned char *)0x15004000)
-#define rUCON1 (*(volatile unsigned short *)0x15004004)
-#define rUFCON1 (*(volatile unsigned char *)0x15004008)
-#define rUMCON1 (*(volatile unsigned char *)0x1500400C)
-#define rUTRSTAT1 (*(volatile unsigned char *)0x15004010)
-#define rUERSTAT1 (*(volatile unsigned char *)0x15004014)
-#define rUFSTAT1 (*(volatile unsigned short *)0x15004018)
-#define rUMSTAT1 (*(volatile unsigned char *)0x1500401C)
-#define rUBRDIV1 (*(volatile unsigned short *)0x15004028)
-
-#ifdef __BIG_ENDIAN
-#define rUTXH0 (*(volatile unsigned char *)0x15000023)
-#define rURXH0 (*(volatile unsigned char *)0x15000027)
-#define rUTXH1 (*(volatile unsigned char *)0x15004023)
-#define rURXH1 (*(volatile unsigned char *)0x15004027)
-
-#define WrUTXH0(ch) (*(volatile unsigned char *)0x15000023)=(unsigned char)(ch)
-#define RdURXH0() (*(volatile unsigned char *)0x15000027)
-#define WrUTXH1(ch) (*(volatile unsigned char *)0x15004023)=(unsigned char)(ch)
-#define RdURXH1() (*(volatile unsigned char *)0x15004027)
-
-#define UTXH0 (0x15000020+3) /* byte_access address by DMA */
-#define URXH0 (0x15000024+3)
-#define UTXH1 (0x15004020+3)
-#define URXH1 (0x15004024+3)
-
-#else /* Little Endian */
-#define rUTXH0 (*(volatile unsigned char *)0x15000020)
-#define rURXH0 (*(volatile unsigned char *)0x15000024)
-#define rUTXH1 (*(volatile unsigned char *)0x15004020)
-#define rURXH1 (*(volatile unsigned char *)0x15004024)
-
-#define WrUTXH0(ch) (*(volatile unsigned char *)0x15000020)=(unsigned char)(ch)
-#define RdURXH0() (*(volatile unsigned char *)0x15000024)
-#define WrUTXH1(ch) (*(volatile unsigned char *)0x15004020)=(unsigned char)(ch)
-#define RdURXH1() (*(volatile unsigned char *)0x15004024)
-
-#define UTXH0 (0x15000020) /* byte_access address by DMA */
-#define URXH0 (0x15000024)
-#define UTXH1 (0x15004020)
-#define URXH1 (0x15004024)
-#endif
-
-
-/* PWM TIMER */
-#define rTCFG0 (*(volatile unsigned *)0x15100000)
-#define rTCFG1 (*(volatile unsigned *)0x15100004)
-#define rTCON (*(volatile unsigned *)0x15100008)
-#define rTCNTB0 (*(volatile unsigned *)0x1510000C)
-#define rTCMPB0 (*(volatile unsigned *)0x15100010)
-#define rTCNTO0 (*(volatile unsigned *)0x15100014)
-#define rTCNTB1 (*(volatile unsigned *)0x15100018)
-#define rTCMPB1 (*(volatile unsigned *)0x1510001C)
-#define rTCNTO1 (*(volatile unsigned *)0x15100020)
-#define rTCNTB2 (*(volatile unsigned *)0x15100024)
-#define rTCMPB2 (*(volatile unsigned *)0x15100028)
-#define rTCNTO2 (*(volatile unsigned *)0x1510002C)
-#define rTCNTB3 (*(volatile unsigned *)0x15100030)
-#define rTCMPB3 (*(volatile unsigned *)0x15100034)
-#define rTCNTO3 (*(volatile unsigned *)0x15100038)
-#define rTCNTB4 (*(volatile unsigned *)0x1510003C)
-#define rTCNTO4 (*(volatile unsigned *)0x15100040)
-
-
-/* USB DEVICE */
-#define rFUNC_ADDR_REG (*(volatile unsigned *)0x15200140)
-#define rPWR_REG (*(volatile unsigned *)0x15200144)
-#define rINT_REG (*(volatile unsigned *)0x15200148)
-#define rINT_MASK_REG (*(volatile unsigned *)0x1520014C)
-#define rFRAME_NUM_REG (*(volatile unsigned *)0x15200150)
-#define rRESUME_CON_REG (*(volatile unsigned *)0x15200154)
-#define rEP0_CSR (*(volatile unsigned *)0x15200160)
-#define rEP0_MAXP (*(volatile unsigned *)0x15200164)
-#define rEP0_OUT_CNT (*(volatile unsigned *)0x15200168)
-#define rEP0_FIFO (*(volatile unsigned *)0x1520016C)
-#define rEP1_IN_CSR (*(volatile unsigned *)0x15200180)
-#define rEP1_IN_MAXP (*(volatile unsigned *)0x15200184)
-#define rEP1_FIFO (*(volatile unsigned *)0x15200188)
-#define rEP2_IN_CSR (*(volatile unsigned *)0x15200190)
-#define rEP2_IN_MAXP (*(volatile unsigned *)0x15200194)
-#define rEP2_FIFO (*(volatile unsigned *)0x15200198)
-#define rEP3_OUT_CSR (*(volatile unsigned *)0x152001A0)
-#define rEP3_OUT_MAXP (*(volatile unsigned *)0x152001A4)
-#define rEP3_OUT_CNT (*(volatile unsigned *)0x152001A8)
-#define rEP3_FIFO (*(volatile unsigned *)0x152001AC)
-#define rEP4_OUT_CSR (*(volatile unsigned *)0x152001B0)
-#define rEP4_OUT_MAXP (*(volatile unsigned *)0x152001B4)
-#define rEP4_OUT_CNT (*(volatile unsigned *)0x152001B8)
-#define rEP4_FIFO (*(volatile unsigned *)0x152001BC)
-#define rDMA_CON (*(volatile unsigned *)0x152001C0)
-#define rDMA_UNIT (*(volatile unsigned *)0x152001C4)
-#define rDMA_FIFO (*(volatile unsigned *)0x152001C8)
-#define rDMA_TX (*(volatile unsigned *)0x152001CC)
-#define rTEST_MODE (*(volatile unsigned *)0x152001F4)
-#define rIN_CON_REG (*(volatile unsigned *)0x152001F8)
-
-
-/* WATCH DOG TIMER */
-#define rWTCON (*(volatile unsigned *)0x15300000)
-#define rWTDAT (*(volatile unsigned *)0x15300004)
-#define rWTCNT (*(volatile unsigned *)0x15300008)
-
-
-/* IIC */
-#define rIICCON (*(volatile unsigned *)0x15400000)
-#define rIICSTAT (*(volatile unsigned *)0x15400004)
-#define rIICADD (*(volatile unsigned *)0x15400008)
-#define rIICDS (*(volatile unsigned *)0x1540000C)
-
-
-/* IIS */
-#define rIISCON (*(volatile unsigned *)0x15508000)
-#define rIISMOD (*(volatile unsigned *)0x15508004)
-#define rIISPSR (*(volatile unsigned *)0x15508008)
-#define rIISFIFCON (*(volatile unsigned *)0x1550800C)
-
-#ifdef __BIG_ENDIAN
-#define IISFIF ((volatile unsigned short *)0x15508012)
-
-#else /* Little Endian */
-#define IISFIF ((volatile unsigned short *)0x15508010)
-#endif
-
-
-/* I/O PORT */
-#define rPACON (*(volatile unsigned *)0x15600000)
-#define rPADAT (*(volatile unsigned *)0x15600004)
-
-#define rPBCON (*(volatile unsigned *)0x15600008)
-#define rPBDAT (*(volatile unsigned *)0x1560000C)
-#define rPBUP (*(volatile unsigned *)0x15600010)
-
-#define rPCCON (*(volatile unsigned *)0x15600014)
-#define rPCDAT (*(volatile unsigned *)0x15600018)
-#define rPCUP (*(volatile unsigned *)0x1560001C)
-
-#define rPDCON (*(volatile unsigned *)0x15600020)
-#define rPDDAT (*(volatile unsigned *)0x15600024)
-#define rPDUP (*(volatile unsigned *)0x15600028)
-
-#define rPECON (*(volatile unsigned *)0x1560002C)
-#define rPEDAT (*(volatile unsigned *)0x15600030)
-#define rPEUP (*(volatile unsigned *)0x15600034)
-
-#define rPFCON (*(volatile unsigned *)0x15600038)
-#define rPFDAT (*(volatile unsigned *)0x1560003C)
-#define rPFUP (*(volatile unsigned *)0x15600040)
-
-#define rPGCON (*(volatile unsigned *)0x15600044)
-#define rPGDAT (*(volatile unsigned *)0x15600048)
-#define rPGUP (*(volatile unsigned *)0x1560004C)
-
-#define rOPENCR (*(volatile unsigned *)0x15600050)
-#define rMISCCR (*(volatile unsigned *)0x15600054)
-#define rEXTINT (*(volatile unsigned *)0x15600058)
-
-
-/* RTC */
-#ifdef __BIG_ENDIAN
-#define rRTCCON (*(volatile unsigned char *)0x15700043)
-#define rRTCALM (*(volatile unsigned char *)0x15700053)
-#define rALMSEC (*(volatile unsigned char *)0x15700057)
-#define rALMMIN (*(volatile unsigned char *)0x1570005B)
-#define rALMHOUR (*(volatile unsigned char *)0x1570005F)
-#define rALMDAY (*(volatile unsigned char *)0x15700063)
-#define rALMMON (*(volatile unsigned char *)0x15700067)
-#define rALMYEAR (*(volatile unsigned char *)0x1570006B)
-#define rRTCRST (*(volatile unsigned char *)0x1570006F)
-#define rBCDSEC (*(volatile unsigned char *)0x15700073)
-#define rBCDMIN (*(volatile unsigned char *)0x15700077)
-#define rBCDHOUR (*(volatile unsigned char *)0x1570007B)
-#define rBCDDAY (*(volatile unsigned char *)0x1570007F)
-#define rBCDDATE (*(volatile unsigned char *)0x15700083)
-#define rBCDMON (*(volatile unsigned char *)0x15700087)
-#define rBCDYEAR (*(volatile unsigned char *)0x1570008B)
-#define rTICINT (*(volatile unsigned char *)0x15700047)
-
-#else /* Little Endian */
-#define rRTCCON (*(volatile unsigned char *)0x15700040)
-#define rRTCALM (*(volatile unsigned char *)0x15700050)
-#define rALMSEC (*(volatile unsigned char *)0x15700054)
-#define rALMMIN (*(volatile unsigned char *)0x15700058)
-#define rALMHOUR (*(volatile unsigned char *)0x1570005C)
-#define rALMDAY (*(volatile unsigned char *)0x15700060)
-#define rALMMON (*(volatile unsigned char *)0x15700064)
-#define rALMYEAR (*(volatile unsigned char *)0x15700068)
-#define rRTCRST (*(volatile unsigned char *)0x1570006C)
-#define rBCDSEC (*(volatile unsigned char *)0x15700070)
-#define rBCDMIN (*(volatile unsigned char *)0x15700074)
-#define rBCDHOUR (*(volatile unsigned char *)0x15700078)
-#define rBCDDAY (*(volatile unsigned char *)0x1570007C)
-#define rBCDDATE (*(volatile unsigned char *)0x15700080)
-#define rBCDMON (*(volatile unsigned char *)0x15700084)
-#define rBCDYEAR (*(volatile unsigned char *)0x15700088)
-#define rTICINT (*(volatile unsigned char *)0x15700044)
-#endif
-
-
-/* ADC */
-#define rADCCON (*(volatile unsigned *)0x15800000)
-#define rADCDAT (*(volatile unsigned *)0x15800004)
-
-
-/* SPI */
-#define rSPCON (*(volatile unsigned *)0x15900000)
-#define rSPSTA (*(volatile unsigned *)0x15900004)
-#define rSPPIN (*(volatile unsigned *)0x15900008)
-#define rSPPRE (*(volatile unsigned *)0x1590000C)
-#define rSPTDAT (*(volatile unsigned *)0x15900010)
-#define rSPRDAT (*(volatile unsigned *)0x15900014)
-
-
-/* MMC INTERFACE */
-#define rMMCON (*(volatile unsigned *)0x15a00000)
-#define rMMCRR (*(volatile unsigned *)0x15a00004)
-#define rMMFCON (*(volatile unsigned *)0x15a00008)
-#define rMMSTA (*(volatile unsigned *)0x15a0000C)
-#define rMMFSTA (*(volatile unsigned *)0x15a00010)
-#define rMMPRE (*(volatile unsigned *)0x15a00014)
-#define rMMLEN (*(volatile unsigned *)0x15a00018)
-#define rMMCR7 (*(volatile unsigned *)0x15a0001C)
-#define rMMRSP0 (*(volatile unsigned *)0x15a00020)
-#define rMMRSP1 (*(volatile unsigned *)0x15a00024)
-#define rMMRSP2 (*(volatile unsigned *)0x15a00028)
-#define rMMRSP3 (*(volatile unsigned *)0x15a0002C)
-#define rMMCMD0 (*(volatile unsigned *)0x15a00030)
-#define rMMCMD1 (*(volatile unsigned *)0x15a00034)
-#define rMMCR16 (*(volatile unsigned *)0x15a00038)
-#define rMMDAT (*(volatile unsigned *)0x15a0003C)
-
-
-/* ISR */
-#define pISR_RESET (*(unsigned *)(_ISR_STARTADDRESS+0x0))
-#define pISR_UNDEF (*(unsigned *)(_ISR_STARTADDRESS+0x4))
-#define pISR_SWI (*(unsigned *)(_ISR_STARTADDRESS+0x8))
-#define pISR_PABORT (*(unsigned *)(_ISR_STARTADDRESS+0xC))
-#define pISR_DABORT (*(unsigned *)(_ISR_STARTADDRESS+0x10))
-#define pISR_RESERVED (*(unsigned *)(_ISR_STARTADDRESS+0x14))
-#define pISR_IRQ (*(unsigned *)(_ISR_STARTADDRESS+0x18))
-#define pISR_FIQ (*(unsigned *)(_ISR_STARTADDRESS+0x1C))
-
-#define pISR_EINT0 (*(unsigned *)(_ISR_STARTADDRESS+0x20))
-#define pISR_EINT1 (*(unsigned *)(_ISR_STARTADDRESS+0x24))
-#define pISR_EINT2 (*(unsigned *)(_ISR_STARTADDRESS+0x28))
-#define pISR_EINT3 (*(unsigned *)(_ISR_STARTADDRESS+0x2C))
-#define pISR_EINT4 (*(unsigned *)(_ISR_STARTADDRESS+0x30))
-#define pISR_EINT5 (*(unsigned *)(_ISR_STARTADDRESS+0x34))
-#define pISR_EINT6 (*(unsigned *)(_ISR_STARTADDRESS+0x38))
-#define pISR_EINT7 (*(unsigned *)(_ISR_STARTADDRESS+0x3C))
-#define pISR_TICK (*(unsigned *)(_ISR_STARTADDRESS+0x40))
-#define pISR_WDT (*(unsigned *)(_ISR_STARTADDRESS+0x44))
-#define pISR_TIMER0 (*(unsigned *)(_ISR_STARTADDRESS+0x48))
-#define pISR_TIMER1 (*(unsigned *)(_ISR_STARTADDRESS+0x4C))
-#define pISR_TIMER2 (*(unsigned *)(_ISR_STARTADDRESS+0x50))
-#define pISR_TIMER3 (*(unsigned *)(_ISR_STARTADDRESS+0x54))
-#define pISR_TIMER4 (*(unsigned *)(_ISR_STARTADDRESS+0x58))
-#define pISR_UERR01 (*(unsigned *)(_ISR_STARTADDRESS+0x5C))
-#define pISR_NOTUSED (*(unsigned *)(_ISR_STARTADDRESS+0x60))
-#define pISR_DMA0 (*(unsigned *)(_ISR_STARTADDRESS+0x64))
-#define pISR_DMA1 (*(unsigned *)(_ISR_STARTADDRESS+0x68))
-#define pISR_DMA2 (*(unsigned *)(_ISR_STARTADDRESS+0x6C))
-#define pISR_DMA3 (*(unsigned *)(_ISR_STARTADDRESS+0x70))
-#define pISR_MMC (*(unsigned *)(_ISR_STARTADDRESS+0x74))
-#define pISR_SPI (*(unsigned *)(_ISR_STARTADDRESS+0x78))
-#define pISR_URXD0 (*(unsigned *)(_ISR_STARTADDRESS+0x7C))
-#define pISR_URXD1 (*(unsigned *)(_ISR_STARTADDRESS+0x80))
-#define pISR_USBD (*(unsigned *)(_ISR_STARTADDRESS+0x84))
-#define pISR_USBH (*(unsigned *)(_ISR_STARTADDRESS+0x88))
-#define pISR_IIC (*(unsigned *)(_ISR_STARTADDRESS+0x8C))
-#define pISR_UTXD0 (*(unsigned *)(_ISR_STARTADDRESS+0x90))
-#define pISR_UTXD1 (*(unsigned *)(_ISR_STARTADDRESS+0x94))
-#define pISR_RTC (*(unsigned *)(_ISR_STARTADDRESS+0x98))
-#define pISR_ADC (*(unsigned *)(_ISR_STARTADDRESS+0xA0))
-
-
-/* PENDING BIT */
-#define BIT_EINT0 (0x1)
-#define BIT_EINT1 (0x1<<1)
-#define BIT_EINT2 (0x1<<2)
-#define BIT_EINT3 (0x1<<3)
-#define BIT_EINT4 (0x1<<4)
-#define BIT_EINT5 (0x1<<5)
-#define BIT_EINT6 (0x1<<6)
-#define BIT_EINT7 (0x1<<7)
-#define BIT_TICK (0x1<<8)
-#define BIT_WDT (0x1<<9)
-#define BIT_TIMER0 (0x1<<10)
-#define BIT_TIMER1 (0x1<<11)
-#define BIT_TIMER2 (0x1<<12)
-#define BIT_TIMER3 (0x1<<13)
-#define BIT_TIMER4 (0x1<<14)
-#define BIT_UERR01 (0x1<<15)
-#define BIT_NOTUSED (0x1<<16)
-#define BIT_DMA0 (0x1<<17)
-#define BIT_DMA1 (0x1<<18)
-#define BIT_DMA2 (0x1<<19)
-#define BIT_DMA3 (0x1<<20)
-#define BIT_MMC (0x1<<21)
-#define BIT_SPI (0x1<<22)
-#define BIT_URXD0 (0x1<<23)
-#define BIT_URXD1 (0x1<<24)
-#define BIT_USBD (0x1<<25)
-#define BIT_USBH (0x1<<26)
-#define BIT_IIC (0x1<<27)
-#define BIT_UTXD0 (0x1<<28)
-#define BIT_UTXD1 (0x1<<29)
-#define BIT_RTC (0x1<<30)
-#define BIT_ADC (0x1<<31)
-#define BIT_ALLMSK (0xFFFFFFFF)
-
-#define ClearPending(bit) {\
- rSRCPND = bit;\
- rINTPND = bit;\
- rINTPND;\
- }
-/* Wait until rINTPND is changed for the case that the ISR is very short. */
-#endif
#endif /*__S3C2400_H__*/
diff --git a/include/s3c2410.h b/include/s3c2410.h
index 87135b4..763418e 100644
--- a/include/s3c2410.h
+++ b/include/s3c2410.h
@@ -38,11 +38,11 @@
#define S3C2410_ECCSIZE 512
#define S3C2410_ECCBYTES 3
-typedef enum {
+enum s3c24x0_uarts_nr {
S3C24X0_UART0,
S3C24X0_UART1,
S3C24X0_UART2
-} S3C24X0_UARTS_NR;
+};
/* S3C2410 device base addresses */
#define S3C24X0_MEMCTL_BASE 0x48000000
@@ -69,159 +69,77 @@ typedef enum {
#include <s3c24x0.h>
-static inline S3C24X0_MEMCTL * S3C24X0_GetBase_MEMCTL(void)
+static inline struct s3c24x0_memctl *S3C24X0_GetBase_MEMCTL(void)
{
- return (S3C24X0_MEMCTL * const)S3C24X0_MEMCTL_BASE;
+ return (struct s3c24x0_memctl *)S3C24X0_MEMCTL_BASE;
}
-static inline S3C24X0_USB_HOST * S3C24X0_GetBase_USB_HOST(void)
+static inline struct s3c24x0_usb_host *S3C24X0_GetBase_USB_HOST(void)
{
- return (S3C24X0_USB_HOST * const)S3C24X0_USB_HOST_BASE;
+ return (struct s3c24x0_usb_host *)S3C24X0_USB_HOST_BASE;
}
-static inline S3C24X0_INTERRUPT * S3C24X0_GetBase_INTERRUPT(void)
+static inline struct s3c24x0_interrupt *S3C24X0_GetBase_INTERRUPT(void)
{
- return (S3C24X0_INTERRUPT * const)S3C24X0_INTERRUPT_BASE;
+ return (struct s3c24x0_interrupt *)S3C24X0_INTERRUPT_BASE;
}
-static inline S3C24X0_DMAS * S3C24X0_GetBase_DMAS(void)
+static inline struct s3c24x0_dmas *S3C24X0_GetBase_DMAS(void)
{
- return (S3C24X0_DMAS * const)S3C24X0_DMA_BASE;
+ return (struct s3c24x0_dmas *)S3C24X0_DMA_BASE;
}
-static inline S3C24X0_CLOCK_POWER * S3C24X0_GetBase_CLOCK_POWER(void)
+static inline struct s3c24x0_clock_power *S3C24X0_GetBase_CLOCK_POWER(void)
{
- return (S3C24X0_CLOCK_POWER * const)S3C24X0_CLOCK_POWER_BASE;
+ return (struct s3c24x0_clock_power *)S3C24X0_CLOCK_POWER_BASE;
}
-static inline S3C24X0_LCD * S3C24X0_GetBase_LCD(void)
+static inline struct s3c24x0_lcd *S3C24X0_GetBase_LCD(void)
{
- return (S3C24X0_LCD * const)S3C24X0_LCD_BASE;
+ return (struct s3c24x0_lcd *)S3C24X0_LCD_BASE;
}
-static inline S3C2410_NAND * S3C2410_GetBase_NAND(void)
+static inline struct s3c2410_nand *S3C2410_GetBase_NAND(void)
{
- return (S3C2410_NAND * const)S3C2410_NAND_BASE;
+ return (struct s3c2410_nand *)S3C2410_NAND_BASE;
}
-static inline S3C24X0_UART * S3C24X0_GetBase_UART(S3C24X0_UARTS_NR nr)
+static inline struct s3c24x0_uart *S3C24X0_GetBase_UART(enum s3c24x0_uarts_nr n)
{
- return (S3C24X0_UART * const)(S3C24X0_UART_BASE + (nr * 0x4000));
+ return (struct s3c24x0_uart *)(S3C24X0_UART_BASE + (n * 0x4000));
}
-static inline S3C24X0_TIMERS * S3C24X0_GetBase_TIMERS(void)
+static inline struct s3c24x0_timers *S3C24X0_GetBase_TIMERS(void)
{
- return (S3C24X0_TIMERS * const)S3C24X0_TIMER_BASE;
+ return (struct s3c24x0_timers *)S3C24X0_TIMER_BASE;
}
-static inline S3C24X0_USB_DEVICE * S3C24X0_GetBase_USB_DEVICE(void)
+static inline struct s3c24x0_usb_device *S3C24X0_GetBase_USB_DEVICE(void)
{
- return (S3C24X0_USB_DEVICE * const)S3C24X0_USB_DEVICE_BASE;
+ return (struct s3c24x0_usb_device *)S3C24X0_USB_DEVICE_BASE;
}
-static inline S3C24X0_WATCHDOG * S3C24X0_GetBase_WATCHDOG(void)
+static inline struct s3c24x0_watchdog *S3C24X0_GetBase_WATCHDOG(void)
{
- return (S3C24X0_WATCHDOG * const)S3C24X0_WATCHDOG_BASE;
+ return (struct s3c24x0_watchdog *)S3C24X0_WATCHDOG_BASE;
}
-static inline S3C24X0_I2C * S3C24X0_GetBase_I2C(void)
+static inline struct s3c24x0_i2c *S3C24X0_GetBase_I2C(void)
{
- return (S3C24X0_I2C * const)S3C24X0_I2C_BASE;
+ return (struct s3c24x0_i2c *)S3C24X0_I2C_BASE;
}
-static inline S3C24X0_I2S * S3C24X0_GetBase_I2S(void)
+static inline struct s3c24x0_i2s *S3C24X0_GetBase_I2S(void)
{
- return (S3C24X0_I2S * const)S3C24X0_I2S_BASE;
+ return (struct s3c24x0_i2s *)S3C24X0_I2S_BASE;
}
-static inline S3C24X0_GPIO * S3C24X0_GetBase_GPIO(void)
+static inline struct s3c24x0_gpio *S3C24X0_GetBase_GPIO(void)
{
- return (S3C24X0_GPIO * const)S3C24X0_GPIO_BASE;
+ return (struct s3c24x0_gpio *)S3C24X0_GPIO_BASE;
}
-static inline S3C24X0_RTC * S3C24X0_GetBase_RTC(void)
+static inline struct s3c24x0_rtc *S3C24X0_GetBase_RTC(void)
{
- return (S3C24X0_RTC * const)S3C24X0_RTC_BASE;
+ return (struct s3c24x0_rtc *)S3C24X0_RTC_BASE;
}
-static inline S3C2410_ADC * S3C2410_GetBase_ADC(void)
+static inline struct s3c2410_adc *S3C2410_GetBase_ADC(void)
{
- return (S3C2410_ADC * const)S3C2410_ADC_BASE;
+ return (struct s3c2410_adc *)S3C2410_ADC_BASE;
}
-static inline S3C24X0_SPI * S3C24X0_GetBase_SPI(void)
+static inline struct s3c24x0_spi *S3C24X0_GetBase_SPI(void)
{
- return (S3C24X0_SPI * const)S3C24X0_SPI_BASE;
+ return (struct s3c24x0_spi *)S3C24X0_SPI_BASE;
}
-static inline S3C2410_SDI * S3C2410_GetBase_SDI(void)
+static inline struct s3c2410_sdi *S3C2410_GetBase_SDI(void)
{
- return (S3C2410_SDI * const)S3C2410_SDI_BASE;
+ return (struct s3c2410_sdi *)S3C2410_SDI_BASE;
}
-
-/* ISR */
-#define pISR_RESET (*(unsigned *)(_ISR_STARTADDRESS+0x0))
-#define pISR_UNDEF (*(unsigned *)(_ISR_STARTADDRESS+0x4))
-#define pISR_SWI (*(unsigned *)(_ISR_STARTADDRESS+0x8))
-#define pISR_PABORT (*(unsigned *)(_ISR_STARTADDRESS+0xC))
-#define pISR_DABORT (*(unsigned *)(_ISR_STARTADDRESS+0x10))
-#define pISR_RESERVED (*(unsigned *)(_ISR_STARTADDRESS+0x14))
-#define pISR_IRQ (*(unsigned *)(_ISR_STARTADDRESS+0x18))
-#define pISR_FIQ (*(unsigned *)(_ISR_STARTADDRESS+0x1C))
-
-#define pISR_EINT0 (*(unsigned *)(_ISR_STARTADDRESS+0x20))
-#define pISR_EINT1 (*(unsigned *)(_ISR_STARTADDRESS+0x24))
-#define pISR_EINT2 (*(unsigned *)(_ISR_STARTADDRESS+0x28))
-#define pISR_EINT3 (*(unsigned *)(_ISR_STARTADDRESS+0x2C))
-#define pISR_EINT4_7 (*(unsigned *)(_ISR_STARTADDRESS+0x30))
-#define pISR_EINT8_23 (*(unsigned *)(_ISR_STARTADDRESS+0x34))
-#define pISR_BAT_FLT (*(unsigned *)(_ISR_STARTADDRESS+0x3C))
-#define pISR_TICK (*(unsigned *)(_ISR_STARTADDRESS+0x40))
-#define pISR_WDT (*(unsigned *)(_ISR_STARTADDRESS+0x44))
-#define pISR_TIMER0 (*(unsigned *)(_ISR_STARTADDRESS+0x48))
-#define pISR_TIMER1 (*(unsigned *)(_ISR_STARTADDRESS+0x4C))
-#define pISR_TIMER2 (*(unsigned *)(_ISR_STARTADDRESS+0x50))
-#define pISR_TIMER3 (*(unsigned *)(_ISR_STARTADDRESS+0x54))
-#define pISR_TIMER4 (*(unsigned *)(_ISR_STARTADDRESS+0x58))
-#define pISR_UART2 (*(unsigned *)(_ISR_STARTADDRESS+0x5C))
-#define pISR_NOTUSED (*(unsigned *)(_ISR_STARTADDRESS+0x60))
-#define pISR_DMA0 (*(unsigned *)(_ISR_STARTADDRESS+0x64))
-#define pISR_DMA1 (*(unsigned *)(_ISR_STARTADDRESS+0x68))
-#define pISR_DMA2 (*(unsigned *)(_ISR_STARTADDRESS+0x6C))
-#define pISR_DMA3 (*(unsigned *)(_ISR_STARTADDRESS+0x70))
-#define pISR_SDI (*(unsigned *)(_ISR_STARTADDRESS+0x74))
-#define pISR_SPI0 (*(unsigned *)(_ISR_STARTADDRESS+0x78))
-#define pISR_UART1 (*(unsigned *)(_ISR_STARTADDRESS+0x7C))
-#define pISR_USBD (*(unsigned *)(_ISR_STARTADDRESS+0x84))
-#define pISR_USBH (*(unsigned *)(_ISR_STARTADDRESS+0x88))
-#define pISR_IIC (*(unsigned *)(_ISR_STARTADDRESS+0x8C))
-#define pISR_UART0 (*(unsigned *)(_ISR_STARTADDRESS+0x90))
-#define pISR_SPI1 (*(unsigned *)(_ISR_STARTADDRESS+0x94))
-#define pISR_RTC (*(unsigned *)(_ISR_STARTADDRESS+0x98))
-#define pISR_ADC (*(unsigned *)(_ISR_STARTADDRESS+0xA0))
-
-
-/* PENDING BIT */
-#define BIT_EINT0 (0x1)
-#define BIT_EINT1 (0x1<<1)
-#define BIT_EINT2 (0x1<<2)
-#define BIT_EINT3 (0x1<<3)
-#define BIT_EINT4_7 (0x1<<4)
-#define BIT_EINT8_23 (0x1<<5)
-#define BIT_BAT_FLT (0x1<<7)
-#define BIT_TICK (0x1<<8)
-#define BIT_WDT (0x1<<9)
-#define BIT_TIMER0 (0x1<<10)
-#define BIT_TIMER1 (0x1<<11)
-#define BIT_TIMER2 (0x1<<12)
-#define BIT_TIMER3 (0x1<<13)
-#define BIT_TIMER4 (0x1<<14)
-#define BIT_UART2 (0x1<<15)
-#define BIT_LCD (0x1<<16)
-#define BIT_DMA0 (0x1<<17)
-#define BIT_DMA1 (0x1<<18)
-#define BIT_DMA2 (0x1<<19)
-#define BIT_DMA3 (0x1<<20)
-#define BIT_SDI (0x1<<21)
-#define BIT_SPI0 (0x1<<22)
-#define BIT_UART1 (0x1<<23)
-#define BIT_USBD (0x1<<25)
-#define BIT_USBH (0x1<<26)
-#define BIT_IIC (0x1<<27)
-#define BIT_UART0 (0x1<<28)
-#define BIT_SPI1 (0x1<<29)
-#define BIT_RTC (0x1<<30)
-#define BIT_ADC (0x1<<31)
-#define BIT_ALLMSK (0xFFFFFFFF)
-
-#define ClearPending(bit) {\
- rSRCPND = bit;\
- rINTPND = bit;\
- rINTPND;\
- }
-/* Wait until rINTPND is changed for the case that the ISR is very short. */
#endif /*__S3C2410_H__*/
diff --git a/include/s3c24x0.h b/include/s3c24x0.h
index 71f35a5..b34c880 100644
--- a/include/s3c24x0.h
+++ b/include/s3c24x0.h
@@ -36,18 +36,18 @@ typedef volatile u16 S3C24X0_REG16;
typedef volatile u32 S3C24X0_REG32;
/* Memory controller (see manual chapter 5) */
-typedef struct {
+struct s3c24x0_memctl {
S3C24X0_REG32 BWSCON;
S3C24X0_REG32 BANKCON[8];
S3C24X0_REG32 REFRESH;
S3C24X0_REG32 BANKSIZE;
S3C24X0_REG32 MRSRB6;
S3C24X0_REG32 MRSRB7;
-} /*__attribute__((__packed__))*/ S3C24X0_MEMCTL;
+};
/* USB HOST (see manual chapter 12) */
-typedef struct {
+struct s3c24x0_usb_host {
S3C24X0_REG32 HcRevision;
S3C24X0_REG32 HcControl;
S3C24X0_REG32 HcCommonStatus;
@@ -71,11 +71,11 @@ typedef struct {
S3C24X0_REG32 HcRhStatus;
S3C24X0_REG32 HcRhPortStatus1;
S3C24X0_REG32 HcRhPortStatus2;
-} /*__attribute__((__packed__))*/ S3C24X0_USB_HOST;
+};
/* INTERRUPT (see manual chapter 14) */
-typedef struct {
+struct s3c24x0_interrupt {
S3C24X0_REG32 SRCPND;
S3C24X0_REG32 INTMOD;
S3C24X0_REG32 INTMSK;
@@ -86,11 +86,11 @@ typedef struct {
S3C24X0_REG32 SUBSRCPND;
S3C24X0_REG32 INTSUBMSK;
#endif
-} /*__attribute__((__packed__))*/ S3C24X0_INTERRUPT;
+};
/* DMAS (see manual chapter 8) */
-typedef struct {
+struct s3c24x0_dma {
S3C24X0_REG32 DISRC;
#ifdef CONFIG_S3C2410
S3C24X0_REG32 DISRCC;
@@ -110,27 +110,27 @@ typedef struct {
#ifdef CONFIG_S3C2410
S3C24X0_REG32 res[7];
#endif
-} /*__attribute__((__packed__))*/ S3C24X0_DMA;
+};
-typedef struct {
- S3C24X0_DMA dma[4];
-} /*__attribute__((__packed__))*/ S3C24X0_DMAS;
+struct s3c24x0_dmas {
+ struct s3c24x0_dma dma[4];
+};
/* CLOCK & POWER MANAGEMENT (see S3C2400 manual chapter 6) */
/* (see S3C2410 manual chapter 7) */
-typedef struct {
+struct s3c24x0_clock_power {
S3C24X0_REG32 LOCKTIME;
S3C24X0_REG32 MPLLCON;
S3C24X0_REG32 UPLLCON;
S3C24X0_REG32 CLKCON;
S3C24X0_REG32 CLKSLOW;
S3C24X0_REG32 CLKDIVN;
-} /*__attribute__((__packed__))*/ S3C24X0_CLOCK_POWER;
+};
/* LCD CONTROLLER (see manual chapter 15) */
-typedef struct {
+struct s3c24x0_lcd {
S3C24X0_REG32 LCDCON1;
S3C24X0_REG32 LCDCON2;
S3C24X0_REG32 LCDCON3;
@@ -151,22 +151,22 @@ typedef struct {
S3C24X0_REG32 LCDINTMSK;
S3C24X0_REG32 LPCSEL;
#endif
-} /*__attribute__((__packed__))*/ S3C24X0_LCD;
+};
/* NAND FLASH (see S3C2410 manual chapter 6) */
-typedef struct {
+struct s3c2410_nand {
S3C24X0_REG32 NFCONF;
S3C24X0_REG32 NFCMD;
S3C24X0_REG32 NFADDR;
S3C24X0_REG32 NFDATA;
S3C24X0_REG32 NFSTAT;
S3C24X0_REG32 NFECC;
-} /*__attribute__((__packed__))*/ S3C2410_NAND;
+};
/* UART (see manual chapter 11) */
-typedef struct {
+struct s3c24x0_uart {
S3C24X0_REG32 ULCON;
S3C24X0_REG32 UCON;
S3C24X0_REG32 UFCON;
@@ -187,28 +187,28 @@ typedef struct {
S3C24X0_REG8 res2[3];
#endif
S3C24X0_REG32 UBRDIV;
-} /*__attribute__((__packed__))*/ S3C24X0_UART;
+};
/* PWM TIMER (see manual chapter 10) */
-typedef struct {
+struct s3c24x0_timer {
S3C24X0_REG32 TCNTB;
S3C24X0_REG32 TCMPB;
S3C24X0_REG32 TCNTO;
-} /*__attribute__((__packed__))*/ S3C24X0_TIMER;
+};
-typedef struct {
+struct s3c24x0_timers {
S3C24X0_REG32 TCFG0;
S3C24X0_REG32 TCFG1;
S3C24X0_REG32 TCON;
- S3C24X0_TIMER ch[4];
+ struct s3c24x0_timer ch[4];
S3C24X0_REG32 TCNTB4;
S3C24X0_REG32 TCNTO4;
-} /*__attribute__((__packed__))*/ S3C24X0_TIMERS;
+};
/* USB DEVICE (see manual chapter 13) */
-typedef struct {
+struct s3c24x0_usb_dev_fifos {
#ifdef __BIG_ENDIAN
S3C24X0_REG8 res[3];
S3C24X0_REG8 EP_FIFO_REG;
@@ -216,9 +216,9 @@ typedef struct {
S3C24X0_REG8 EP_FIFO_REG;
S3C24X0_REG8 res[3];
#endif
-} /*__attribute__((__packed__))*/ S3C24X0_USB_DEV_FIFOS;
+};
-typedef struct {
+struct s3c24x0_usb_dev_dmas {
#ifdef __BIG_ENDIAN
S3C24X0_REG8 res1[3];
S3C24X0_REG8 EP_DMA_CON;
@@ -246,9 +246,9 @@ typedef struct {
S3C24X0_REG8 EP_DMA_TTC_H;
S3C24X0_REG8 res6[3];
#endif
-} /*__attribute__((__packed__))*/ S3C24X0_USB_DEV_DMAS;
+};
-typedef struct {
+struct s3c24x0_usb_device {
#ifdef __BIG_ENDIAN
S3C24X0_REG8 res1[3];
S3C24X0_REG8 FUNC_ADDR_REG;
@@ -316,30 +316,30 @@ typedef struct {
S3C24X0_REG8 OUT_FIFO_CNT2_REG;
S3C24X0_REG8 res16[3];
#endif /* __BIG_ENDIAN */
- S3C24X0_USB_DEV_FIFOS fifo[5];
- S3C24X0_USB_DEV_DMAS dma[5];
-} /*__attribute__((__packed__))*/ S3C24X0_USB_DEVICE;
+ struct s3c24x0_usb_dev_fifos fifo[5];
+ struct s3c24x0_usb_dev_dmas dma[5];
+};
/* WATCH DOG TIMER (see manual chapter 18) */
-typedef struct {
+struct s3c24x0_watchdog {
S3C24X0_REG32 WTCON;
S3C24X0_REG32 WTDAT;
S3C24X0_REG32 WTCNT;
-} /*__attribute__((__packed__))*/ S3C24X0_WATCHDOG;
+};
/* IIC (see manual chapter 20) */
-typedef struct {
+struct s3c24x0_i2c {
S3C24X0_REG32 IICCON;
S3C24X0_REG32 IICSTAT;
S3C24X0_REG32 IICADD;
S3C24X0_REG32 IICDS;
-} /*__attribute__((__packed__))*/ S3C24X0_I2C;
+};
/* IIS (see manual chapter 21) */
-typedef struct {
+struct s3c24x0_i2s {
#ifdef __BIG_ENDIAN
S3C24X0_REG16 res1;
S3C24X0_REG16 IISCON;
@@ -363,11 +363,11 @@ typedef struct {
S3C24X0_REG16 IISFIFO;
S3C24X0_REG16 res5;
#endif
-} /*__attribute__((__packed__))*/ S3C24X0_I2S;
+};
/* I/O PORT (see manual chapter 9) */
-typedef struct {
+struct s3c24x0_gpio {
#ifdef CONFIG_S3C2400
S3C24X0_REG32 PACON;
S3C24X0_REG32 PADAT;
@@ -451,11 +451,11 @@ typedef struct {
S3C24X0_REG32 GSTATUS3;
S3C24X0_REG32 GSTATUS4;
#endif
-} /*__attribute__((__packed__))*/ S3C24X0_GPIO;
+};
/* RTC (see manual chapter 17) */
-typedef struct {
+struct s3c24x0_rtc {
#ifdef __BIG_ENDIAN
S3C24X0_REG8 res1[67];
S3C24X0_REG8 RTCCON;
@@ -528,28 +528,28 @@ typedef struct {
S3C24X0_REG8 BCDYEAR;
S3C24X0_REG8 res17[3];
#endif
-} /*__attribute__((__packed__))*/ S3C24X0_RTC;
+};
/* ADC (see manual chapter 16) */
-typedef struct {
+struct s3c2400_adc {
S3C24X0_REG32 ADCCON;
S3C24X0_REG32 ADCDAT;
-} /*__attribute__((__packed__))*/ S3C2400_ADC;
+};
/* ADC (see manual chapter 16) */
-typedef struct {
+struct s3c2410_adc {
S3C24X0_REG32 ADCCON;
S3C24X0_REG32 ADCTSC;
S3C24X0_REG32 ADCDLY;
S3C24X0_REG32 ADCDAT0;
S3C24X0_REG32 ADCDAT1;
-} /*__attribute__((__packed__))*/ S3C2410_ADC;
+};
/* SPI (see manual chapter 22) */
-typedef struct {
+struct s3c24x0_spi_channel {
S3C24X0_REG32 SPCON;
S3C24X0_REG32 SPSTA;
S3C24X0_REG32 SPPIN;
@@ -557,15 +557,15 @@ typedef struct {
S3C24X0_REG32 SPTDAT;
S3C24X0_REG32 SPRDAT;
S3C24X0_REG32 res[2];
-} __attribute__((__packed__)) S3C24X0_SPI_CHANNEL;
+};
-typedef struct {
- S3C24X0_SPI_CHANNEL ch[S3C24X0_SPI_CHANNELS];
-} /*__attribute__((__packed__))*/ S3C24X0_SPI;
+struct s3c24x0_spi {
+ struct s3c24x0_spi_channel ch[S3C24X0_SPI_CHANNELS];
+};
/* MMC INTERFACE (see S3C2400 manual chapter 19) */
-typedef struct {
+struct s3c2400_mmc {
#ifdef __BIG_ENDIAN
S3C24X0_REG8 res1[3];
S3C24X0_REG8 MMCON;
@@ -617,11 +617,11 @@ typedef struct {
S3C24X0_REG8 MMDAT;
S3C24X0_REG8 res11[3];
#endif
-} /*__attribute__((__packed__))*/ S3C2400_MMC;
+};
/* SD INTERFACE (see S3C2410 manual chapter 19) */
-typedef struct {
+struct s3c2410_sdi {
S3C24X0_REG32 SDICON;
S3C24X0_REG32 SDIPRE;
S3C24X0_REG32 SDICARG;
@@ -645,491 +645,6 @@ typedef struct {
S3C24X0_REG8 res[3];
#endif
S3C24X0_REG32 SDIIMSK;
-} /*__attribute__((__packed__))*/ S3C2410_SDI;
-
-
-#if 0
-/* Memory control */
-#define rBWSCON (*(volatile unsigned *)0x48000000)
-#define rBANKCON0 (*(volatile unsigned *)0x48000004)
-#define rBANKCON1 (*(volatile unsigned *)0x48000008)
-#define rBANKCON2 (*(volatile unsigned *)0x4800000C)
-#define rBANKCON3 (*(volatile unsigned *)0x48000010)
-#define rBANKCON4 (*(volatile unsigned *)0x48000014)
-#define rBANKCON5 (*(volatile unsigned *)0x48000018)
-#define rBANKCON6 (*(volatile unsigned *)0x4800001C)
-#define rBANKCON7 (*(volatile unsigned *)0x48000020)
-#define rREFRESH (*(volatile unsigned *)0x48000024)
-#define rBANKSIZE (*(volatile unsigned *)0x48000028)
-#define rMRSRB6 (*(volatile unsigned *)0x4800002C)
-#define rMRSRB7 (*(volatile unsigned *)0x48000030)
-
-
-/* USB HOST */
-#define rHcRevision (*(volatile unsigned *)0x49000000)
-#define rHcControl (*(volatile unsigned *)0x49000004)
-#define rHcCommonStatus (*(volatile unsigned *)0x49000008)
-#define rHcInterruptStatus (*(volatile unsigned *)0x4900000C)
-#define rHcInterruptEnable (*(volatile unsigned *)0x49000010)
-#define rHcInterruptDisable (*(volatile unsigned *)0x49000014)
-#define rHcHCCA (*(volatile unsigned *)0x49000018)
-#define rHcPeriodCuttendED (*(volatile unsigned *)0x4900001C)
-#define rHcControlHeadED (*(volatile unsigned *)0x49000020)
-#define rHcControlCurrentED (*(volatile unsigned *)0x49000024)
-#define rHcBulkHeadED (*(volatile unsigned *)0x49000028)
-#define rHcBuldCurrentED (*(volatile unsigned *)0x4900002C)
-#define rHcDoneHead (*(volatile unsigned *)0x49000030)
-#define rHcRmInterval (*(volatile unsigned *)0x49000034)
-#define rHcFmRemaining (*(volatile unsigned *)0x49000038)
-#define rHcFmNumber (*(volatile unsigned *)0x4900003C)
-#define rHcPeriodicStart (*(volatile unsigned *)0x49000040)
-#define rHcLSThreshold (*(volatile unsigned *)0x49000044)
-#define rHcRhDescriptorA (*(volatile unsigned *)0x49000048)
-#define rHcRhDescriptorB (*(volatile unsigned *)0x4900004C)
-#define rHcRhStatus (*(volatile unsigned *)0x49000050)
-#define rHcRhPortStatus1 (*(volatile unsigned *)0x49000054)
-#define rHcRhPortStatus2 (*(volatile unsigned *)0x49000058)
-
-
-/* INTERRUPT */
-#define rSRCPND (*(volatile unsigned *)0x4A000000)
-#define rINTMOD (*(volatile unsigned *)0x4A000004)
-#define rINTMSK (*(volatile unsigned *)0x4A000008)
-#define rPRIORITY (*(volatile unsigned *)0x4A00000C)
-#define rINTPND (*(volatile unsigned *)0x4A000010)
-#define rINTOFFSET (*(volatile unsigned *)0x4A000014)
-#define rSUBSRCPND (*(volatile unsigned *)0x4A000018)
-#define rINTSUBMSK (*(volatile unsigned *)0x4A00001C)
-
-
-/* DMA */
-#define rDISRC0 (*(volatile unsigned *)0x4B000000)
-#define rDISRCC0 (*(volatile unsigned *)0x4B000004)
-#define rDIDST0 (*(volatile unsigned *)0x4B000008)
-#define rDIDSTC0 (*(volatile unsigned *)0x4B00000C)
-#define rDCON0 (*(volatile unsigned *)0x4B000010)
-#define rDSTAT0 (*(volatile unsigned *)0x4B000014)
-#define rDCSRC0 (*(volatile unsigned *)0x4B000018)
-#define rDCDST0 (*(volatile unsigned *)0x4B00001C)
-#define rDMASKTRIG0 (*(volatile unsigned *)0x4B000020)
-#define rDISRC1 (*(volatile unsigned *)0x4B000040)
-#define rDISRCC1 (*(volatile unsigned *)0x4B000044)
-#define rDIDST1 (*(volatile unsigned *)0x4B000048)
-#define rDIDSTC1 (*(volatile unsigned *)0x4B00004C)
-#define rDCON1 (*(volatile unsigned *)0x4B000050)
-#define rDSTAT1 (*(volatile unsigned *)0x4B000054)
-#define rDCSRC1 (*(volatile unsigned *)0x4B000058)
-#define rDCDST1 (*(volatile unsigned *)0x4B00005C)
-#define rDMASKTRIG1 (*(volatile unsigned *)0x4B000060)
-#define rDISRC2 (*(volatile unsigned *)0x4B000080)
-#define rDISRCC2 (*(volatile unsigned *)0x4B000084)
-#define rDIDST2 (*(volatile unsigned *)0x4B000088)
-#define rDIDSTC2 (*(volatile unsigned *)0x4B00008C)
-#define rDCON2 (*(volatile unsigned *)0x4B000090)
-#define rDSTAT2 (*(volatile unsigned *)0x4B000094)
-#define rDCSRC2 (*(volatile unsigned *)0x4B000098)
-#define rDCDST2 (*(volatile unsigned *)0x4B00009C)
-#define rDMASKTRIG2 (*(volatile unsigned *)0x4B0000A0)
-#define rDISRC3 (*(volatile unsigned *)0x4B0000C0)
-#define rDISRCC3 (*(volatile unsigned *)0x4B0000C4)
-#define rDIDST3 (*(volatile unsigned *)0x4B0000C8)
-#define rDIDSTC3 (*(volatile unsigned *)0x4B0000CC)
-#define rDCON3 (*(volatile unsigned *)0x4B0000D0)
-#define rDSTAT3 (*(volatile unsigned *)0x4B0000D4)
-#define rDCSRC3 (*(volatile unsigned *)0x4B0000D8)
-#define rDCDST3 (*(volatile unsigned *)0x4B0000DC)
-#define rDMASKTRIG3 (*(volatile unsigned *)0x4B0000E0)
-
-
-/* CLOCK & POWER MANAGEMENT */
-#define rLOCKTIME (*(volatile unsigned *)0x4C000000)
-#define rMPLLCON (*(volatile unsigned *)0x4C000004)
-#define rUPLLCON (*(volatile unsigned *)0x4C000008)
-#define rCLKCON (*(volatile unsigned *)0x4C00000C)
-#define rCLKSLOW (*(volatile unsigned *)0x4C000010)
-#define rCLKDIVN (*(volatile unsigned *)0x4C000014)
-
-
-/* LCD CONTROLLER */
-#define rLCDCON1 (*(volatile unsigned *)0x4D000000)
-#define rLCDCON2 (*(volatile unsigned *)0x4D000004)
-#define rLCDCON3 (*(volatile unsigned *)0x4D000008)
-#define rLCDCON4 (*(volatile unsigned *)0x4D00000C)
-#define rLCDCON5 (*(volatile unsigned *)0x4D000010)
-#define rLCDSADDR1 (*(volatile unsigned *)0x4D000014)
-#define rLCDSADDR2 (*(volatile unsigned *)0x4D000018)
-#define rLCDSADDR3 (*(volatile unsigned *)0x4D00001C)
-#define rREDLUT (*(volatile unsigned *)0x4D000020)
-#define rGREENLUT (*(volatile unsigned *)0x4D000024)
-#define rBLUELUT (*(volatile unsigned *)0x4D000028)
-#define rDITHMODE (*(volatile unsigned *)0x4D00004C)
-#define rTPAL (*(volatile unsigned *)0x4D000050)
-#define rLCDINTPND (*(volatile unsigned *)0x4D000054)
-#define rLCDSRCPND (*(volatile unsigned *)0x4D000058)
-#define rLCDINTMSK (*(volatile unsigned *)0x4D00005C)
-
-
-/* NAND FLASH */
-#define rNFCONF (*(volatile unsigned *)0x4E000000)
-#define rNFCMD (*(volatile unsigned *)0x4E000004)
-#define rNFADDR (*(volatile unsigned *)0x4E000008)
-#define rNFDATA (*(volatile unsigned *)0x4E00000C)
-#define rNFSTAT (*(volatile unsigned *)0x4E000010)
-#define rNFECC (*(volatile unsigned *)0x4E000014)
-
-
-/* UART */
-#define rULCON0 (*(volatile unsigned *)0x50000000)
-#define rUCON0 (*(volatile unsigned *)0x50000004)
-#define rUFCON0 (*(volatile unsigned *)0x50000008)
-#define rUMCON0 (*(volatile unsigned *)0x5000000C)
-#define rUTRSTAT0 (*(volatile unsigned *)0x50000010)
-#define rUERSTAT0 (*(volatile unsigned *)0x50000014)
-#define rUFSTAT0 (*(volatile unsigned *)0x50000018)
-#define rUMSTAT0 (*(volatile unsigned *)0x5000001C)
-#define rUBRDIV0 (*(volatile unsigned *)0x50000028)
-
-#define rULCON1 (*(volatile unsigned *)0x50004000)
-#define rUCON1 (*(volatile unsigned *)0x50004004)
-#define rUFCON1 (*(volatile unsigned *)0x50004008)
-#define rUMCON1 (*(volatile unsigned *)0x5000400C)
-#define rUTRSTAT1 (*(volatile unsigned *)0x50004010)
-#define rUERSTAT1 (*(volatile unsigned *)0x50004014)
-#define rUFSTAT1 (*(volatile unsigned *)0x50004018)
-#define rUMSTAT1 (*(volatile unsigned *)0x5000401C)
-#define rUBRDIV1 (*(volatile unsigned *)0x50004028)
-
-#define rULCON2 (*(volatile unsigned *)0x50008000)
-#define rUCON2 (*(volatile unsigned *)0x50008004)
-#define rUFCON2 (*(volatile unsigned *)0x50008008)
-#define rUTRSTAT2 (*(volatile unsigned *)0x50008010)
-#define rUERSTAT2 (*(volatile unsigned *)0x50008014)
-#define rUFSTAT2 (*(volatile unsigned *)0x50008018)
-#define rUBRDIV2 (*(volatile unsigned *)0x50008028)
-
-#ifdef __BIG_ENDIAN
-#define rUTXH0 (*(volatile unsigned char *)0x50000023)
-#define rURXH0 (*(volatile unsigned char *)0x50000027)
-#define rUTXH1 (*(volatile unsigned char *)0x50004023)
-#define rURXH1 (*(volatile unsigned char *)0x50004027)
-#define rUTXH2 (*(volatile unsigned char *)0x50008023)
-#define rURXH2 (*(volatile unsigned char *)0x50008027)
-
-#define WrUTXH0(ch) (*(volatile unsigned char *)0x50000023)=(unsigned char)(ch)
-#define RdURXH0() (*(volatile unsigned char *)0x50000027)
-#define WrUTXH1(ch) (*(volatile unsigned char *)0x50004023)=(unsigned char)(ch)
-#define RdURXH1() (*(volatile unsigned char *)0x50004027)
-#define WrUTXH2(ch) (*(volatile unsigned char *)0x50008023)=(unsigned char)(ch)
-#define RdURXH2() (*(volatile unsigned char *)0x50008027)
-
-#define UTXH0 (0x50000020+3) /* byte_access address by DMA */
-#define URXH0 (0x50000024+3)
-#define UTXH1 (0x50004020+3)
-#define URXH1 (0x50004024+3)
-#define UTXH2 (0x50008020+3)
-#define URXH2 (0x50008024+3)
-
-#else /* Little Endian */
-#define rUTXH0 (*(volatile unsigned char *)0x50000020)
-#define rURXH0 (*(volatile unsigned char *)0x50000024)
-#define rUTXH1 (*(volatile unsigned char *)0x50004020)
-#define rURXH1 (*(volatile unsigned char *)0x50004024)
-#define rUTXH2 (*(volatile unsigned char *)0x50008020)
-#define rURXH2 (*(volatile unsigned char *)0x50008024)
-
-#define WrUTXH0(ch) (*(volatile unsigned char *)0x50000020)=(unsigned char)(ch)
-#define RdURXH0() (*(volatile unsigned char *)0x50000024)
-#define WrUTXH1(ch) (*(volatile unsigned char *)0x50004020)=(unsigned char)(ch)
-#define RdURXH1() (*(volatile unsigned char *)0x50004024)
-#define WrUTXH2(ch) (*(volatile unsigned char *)0x50008020)=(unsigned char)(ch)
-#define RdURXH2() (*(volatile unsigned char *)0x50008024)
-
-#define UTXH0 (0x50000020) /* byte_access address by DMA */
-#define URXH0 (0x50000024)
-#define UTXH1 (0x50004020)
-#define URXH1 (0x50004024)
-#define UTXH2 (0x50008020)
-#define URXH2 (0x50008024)
-#endif
-
-
-/* PWM TIMER */
-#define rTCFG0 (*(volatile unsigned *)0x51000000)
-#define rTCFG1 (*(volatile unsigned *)0x51000004)
-#define rTCON (*(volatile unsigned *)0x51000008)
-#define rTCNTB0 (*(volatile unsigned *)0x5100000C)
-#define rTCMPB0 (*(volatile unsigned *)0x51000010)
-#define rTCNTO0 (*(volatile unsigned *)0x51000014)
-#define rTCNTB1 (*(volatile unsigned *)0x51000018)
-#define rTCMPB1 (*(volatile unsigned *)0x5100001C)
-#define rTCNTO1 (*(volatile unsigned *)0x51000020)
-#define rTCNTB2 (*(volatile unsigned *)0x51000024)
-#define rTCMPB2 (*(volatile unsigned *)0x51000028)
-#define rTCNTO2 (*(volatile unsigned *)0x5100002C)
-#define rTCNTB3 (*(volatile unsigned *)0x51000030)
-#define rTCMPB3 (*(volatile unsigned *)0x51000034)
-#define rTCNTO3 (*(volatile unsigned *)0x51000038)
-#define rTCNTB4 (*(volatile unsigned *)0x5100003C)
-#define rTCNTO4 (*(volatile unsigned *)0x51000040)
-
-
-/* USB DEVICE */
-#ifdef __BIG_ENDIAN
-#define rFUNC_ADDR_REG (*(volatile unsigned char *)0x52000143)
-#define rPWR_REG (*(volatile unsigned char *)0x52000147)
-#define rEP_INT_REG (*(volatile unsigned char *)0x5200014B)
-#define rUSB_INT_REG (*(volatile unsigned char *)0x5200015B)
-#define rEP_INT_EN_REG (*(volatile unsigned char *)0x5200015F)
-#define rUSB_INT_EN_REG (*(volatile unsigned char *)0x5200016F)
-#define rFRAME_NUM1_REG (*(volatile unsigned char *)0x52000173)
-#define rFRAME_NUM2_REG (*(volatile unsigned char *)0x52000177)
-#define rINDEX_REG (*(volatile unsigned char *)0x5200017B)
-#define rMAXP_REG (*(volatile unsigned char *)0x52000183)
-#define rEP0_CSR (*(volatile unsigned char *)0x52000187)
-#define rIN_CSR1_REG (*(volatile unsigned char *)0x52000187)
-#define rIN_CSR2_REG (*(volatile unsigned char *)0x5200018B)
-#define rOUT_CSR1_REG (*(volatile unsigned char *)0x52000193)
-#define rOUT_CSR2_REG (*(volatile unsigned char *)0x52000197)
-#define rOUT_FIFO_CNT1_REG (*(volatile unsigned char *)0x5200019B)
-#define rOUT_FIFO_CNT2_REG (*(volatile unsigned char *)0x5200019F)
-#define rEP0_FIFO (*(volatile unsigned char *)0x520001C3)
-#define rEP1_FIFO (*(volatile unsigned char *)0x520001C7)
-#define rEP2_FIFO (*(volatile unsigned char *)0x520001CB)
-#define rEP3_FIFO (*(volatile unsigned char *)0x520001CF)
-#define rEP4_FIFO (*(volatile unsigned char *)0x520001D3)
-#define rEP1_DMA_CON (*(volatile unsigned char *)0x52000203)
-#define rEP1_DMA_UNIT (*(volatile unsigned char *)0x52000207)
-#define rEP1_DMA_FIFO (*(volatile unsigned char *)0x5200020B)
-#define rEP1_DMA_TX_LO (*(volatile unsigned char *)0x5200020F)
-#define rEP1_DMA_TX_MD (*(volatile unsigned char *)0x52000213)
-#define rEP1_DMA_TX_HI (*(volatile unsigned char *)0x52000217)
-#define rEP2_DMA_CON (*(volatile unsigned char *)0x5200021B)
-#define rEP2_DMA_UNIT (*(volatile unsigned char *)0x5200021F)
-#define rEP2_DMA_FIFO (*(volatile unsigned char *)0x52000223)
-#define rEP2_DMA_TX_LO (*(volatile unsigned char *)0x52000227)
-#define rEP2_DMA_TX_MD (*(volatile unsigned char *)0x5200022B)
-#define rEP2_DMA_TX_HI (*(volatile unsigned char *)0x5200022F)
-#define rEP3_DMA_CON (*(volatile unsigned char *)0x52000243)
-#define rEP3_DMA_UNIT (*(volatile unsigned char *)0x52000247)
-#define rEP3_DMA_FIFO (*(volatile unsigned char *)0x5200024B)
-#define rEP3_DMA_TX_LO (*(volatile unsigned char *)0x5200024F)
-#define rEP3_DMA_TX_MD (*(volatile unsigned char *)0x52000253)
-#define rEP3_DMA_TX_HI (*(volatile unsigned char *)0x52000257)
-#define rEP4_DMA_CON (*(volatile unsigned char *)0x5200025B)
-#define rEP4_DMA_UNIT (*(volatile unsigned char *)0x5200025F)
-#define rEP4_DMA_FIFO (*(volatile unsigned char *)0x52000263)
-#define rEP4_DMA_TX_LO (*(volatile unsigned char *)0x52000267)
-#define rEP4_DMA_TX_MD (*(volatile unsigned char *)0x5200026B)
-#define rEP4_DMA_TX_HI (*(volatile unsigned char *)0x5200026F)
-#else /* little endian */
-#define rFUNC_ADDR_REG (*(volatile unsigned char *)0x52000140)
-#define rPWR_REG (*(volatile unsigned char *)0x52000144)
-#define rEP_INT_REG (*(volatile unsigned char *)0x52000148)
-#define rUSB_INT_REG (*(volatile unsigned char *)0x52000158)
-#define rEP_INT_EN_REG (*(volatile unsigned char *)0x5200015C)
-#define rUSB_INT_EN_REG (*(volatile unsigned char *)0x5200016C)
-#define rFRAME_NUM1_REG (*(volatile unsigned char *)0x52000170)
-#define rFRAME_NUM2_REG (*(volatile unsigned char *)0x52000174)
-#define rINDEX_REG (*(volatile unsigned char *)0x52000178)
-#define rMAXP_REG (*(volatile unsigned char *)0x52000180)
-#define rEP0_CSR (*(volatile unsigned char *)0x52000184)
-#define rIN_CSR1_REG (*(volatile unsigned char *)0x52000184)
-#define rIN_CSR2_REG (*(volatile unsigned char *)0x52000188)
-#define rOUT_CSR1_REG (*(volatile unsigned char *)0x52000190)
-#define rOUT_CSR2_REG (*(volatile unsigned char *)0x52000194)
-#define rOUT_FIFO_CNT1_REG (*(volatile unsigned char *)0x52000198)
-#define rOUT_FIFO_CNT2_REG (*(volatile unsigned char *)0x5200019C)
-#define rEP0_FIFO (*(volatile unsigned char *)0x520001C0)
-#define rEP1_FIFO (*(volatile unsigned char *)0x520001C4)
-#define rEP2_FIFO (*(volatile unsigned char *)0x520001C8)
-#define rEP3_FIFO (*(volatile unsigned char *)0x520001CC)
-#define rEP4_FIFO (*(volatile unsigned char *)0x520001D0)
-#define rEP1_DMA_CON (*(volatile unsigned char *)0x52000200)
-#define rEP1_DMA_UNIT (*(volatile unsigned char *)0x52000204)
-#define rEP1_DMA_FIFO (*(volatile unsigned char *)0x52000208)
-#define rEP1_DMA_TX_LO (*(volatile unsigned char *)0x5200020C)
-#define rEP1_DMA_TX_MD (*(volatile unsigned char *)0x52000210)
-#define rEP1_DMA_TX_HI (*(volatile unsigned char *)0x52000214)
-#define rEP2_DMA_CON (*(volatile unsigned char *)0x52000218)
-#define rEP2_DMA_UNIT (*(volatile unsigned char *)0x5200021C)
-#define rEP2_DMA_FIFO (*(volatile unsigned char *)0x52000220)
-#define rEP2_DMA_TX_LO (*(volatile unsigned char *)0x52000224)
-#define rEP2_DMA_TX_MD (*(volatile unsigned char *)0x52000228)
-#define rEP2_DMA_TX_HI (*(volatile unsigned char *)0x5200022C)
-#define rEP3_DMA_CON (*(volatile unsigned char *)0x52000240)
-#define rEP3_DMA_UNIT (*(volatile unsigned char *)0x52000244)
-#define rEP3_DMA_FIFO (*(volatile unsigned char *)0x52000248)
-#define rEP3_DMA_TX_LO (*(volatile unsigned char *)0x5200024C)
-#define rEP3_DMA_TX_MD (*(volatile unsigned char *)0x52000250)
-#define rEP3_DMA_TX_HI (*(volatile unsigned char *)0x52000254)
-#define rEP4_DMA_CON (*(volatile unsigned char *)0x52000258)
-#define rEP4_DMA_UNIT (*(volatile unsigned char *)0x5200025C)
-#define rEP4_DMA_FIFO (*(volatile unsigned char *)0x52000260)
-#define rEP4_DMA_TX_LO (*(volatile unsigned char *)0x52000264)
-#define rEP4_DMA_TX_MD (*(volatile unsigned char *)0x52000268)
-#define rEP4_DMA_TX_HI (*(volatile unsigned char *)0x5200026C)
-#endif /* __BIG_ENDIAN */
-
-
-/* WATCH DOG TIMER */
-#define rWTCON (*(volatile unsigned *)0x53000000)
-#define rWTDAT (*(volatile unsigned *)0x53000004)
-#define rWTCNT (*(volatile unsigned *)0x53000008)
-
-
-/* IIC */
-#define rIICCON (*(volatile unsigned *)0x54000000)
-#define rIICSTAT (*(volatile unsigned *)0x54000004)
-#define rIICADD (*(volatile unsigned *)0x54000008)
-#define rIICDS (*(volatile unsigned *)0x5400000C)
-
-
-/* IIS */
-#define rIISCON (*(volatile unsigned *)0x55000000)
-#define rIISMOD (*(volatile unsigned *)0x55000004)
-#define rIISPSR (*(volatile unsigned *)0x55000008)
-#define rIISFCON (*(volatile unsigned *)0x5500000C)
-
-#ifdef __BIG_ENDIAN
-#define IISFIF ((volatile unsigned short *)0x55000012)
-#else /* little endian */
-#define IISFIF ((volatile unsigned short *)0x55000010)
-#endif
-
-
-/* I/O PORT */
-#define rGPACON (*(volatile unsigned *)0x56000000)
-#define rGPADAT (*(volatile unsigned *)0x56000004)
-
-#define rGPBCON (*(volatile unsigned *)0x56000010)
-#define rGPBDAT (*(volatile unsigned *)0x56000014)
-#define rGPBUP (*(volatile unsigned *)0x56000018)
-
-#define rGPCCON (*(volatile unsigned *)0x56000020)
-#define rGPCDAT (*(volatile unsigned *)0x56000024)
-#define rGPCUP (*(volatile unsigned *)0x56000028)
-
-#define rGPDCON (*(volatile unsigned *)0x56000030)
-#define rGPDDAT (*(volatile unsigned *)0x56000034)
-#define rGPDUP (*(volatile unsigned *)0x56000038)
-
-#define rGPECON (*(volatile unsigned *)0x56000040)
-#define rGPEDAT (*(volatile unsigned *)0x56000044)
-#define rGPEUP (*(volatile unsigned *)0x56000048)
-
-#define rGPFCON (*(volatile unsigned *)0x56000050)
-#define rGPFDAT (*(volatile unsigned *)0x56000054)
-#define rGPFUP (*(volatile unsigned *)0x56000058)
-
-#define rGPGCON (*(volatile unsigned *)0x56000060)
-#define rGPGDAT (*(volatile unsigned *)0x56000064)
-#define rGPGUP (*(volatile unsigned *)0x56000068)
-
-#define rGPHCON (*(volatile unsigned *)0x56000070)
-#define rGPHDAT (*(volatile unsigned *)0x56000074)
-#define rGPHUP (*(volatile unsigned *)0x56000078)
-
-#define rMISCCR (*(volatile unsigned *)0x56000080)
-#define rDCLKCON (*(volatile unsigned *)0x56000084)
-#define rEXTINT0 (*(volatile unsigned *)0x56000088)
-#define rEXTINT1 (*(volatile unsigned *)0x5600008C)
-#define rEXTINT2 (*(volatile unsigned *)0x56000090)
-#define rEINTFLT0 (*(volatile unsigned *)0x56000094)
-#define rEINTFLT1 (*(volatile unsigned *)0x56000098)
-#define rEINTFLT2 (*(volatile unsigned *)0x5600009C)
-#define rEINTFLT3 (*(volatile unsigned *)0x560000A0)
-#define rEINTMASK (*(volatile unsigned *)0x560000A4)
-#define rEINTPEND (*(volatile unsigned *)0x560000A8)
-#define rGSTATUS0 (*(volatile unsigned *)0x560000AC)
-#define rGSTATUS1 (*(volatile unsigned *)0x560000B0)
-
-
-/* RTC */
-#ifdef __BIG_ENDIAN
-#define rRTCCON (*(volatile unsigned char *)0x57000043)
-#define rTICNT (*(volatile unsigned char *)0x57000047)
-#define rRTCALM (*(volatile unsigned char *)0x57000053)
-#define rALMSEC (*(volatile unsigned char *)0x57000057)
-#define rALMMIN (*(volatile unsigned char *)0x5700005B)
-#define rALMHOUR (*(volatile unsigned char *)0x5700005F)
-#define rALMDATE (*(volatile unsigned char *)0x57000063)
-#define rALMMON (*(volatile unsigned char *)0x57000067)
-#define rALMYEAR (*(volatile unsigned char *)0x5700006B)
-#define rRTCRST (*(volatile unsigned char *)0x5700006F)
-#define rBCDSEC (*(volatile unsigned char *)0x57000073)
-#define rBCDMIN (*(volatile unsigned char *)0x57000077)
-#define rBCDHOUR (*(volatile unsigned char *)0x5700007B)
-#define rBCDDATE (*(volatile unsigned char *)0x5700007F)
-#define rBCDDAY (*(volatile unsigned char *)0x57000083)
-#define rBCDMON (*(volatile unsigned char *)0x57000087)
-#define rBCDYEAR (*(volatile unsigned char *)0x5700008B)
-#else /* little endian */
-#define rRTCCON (*(volatile unsigned char *)0x57000040)
-#define rTICNT (*(volatile unsigned char *)0x57000044)
-#define rRTCALM (*(volatile unsigned char *)0x57000050)
-#define rALMSEC (*(volatile unsigned char *)0x57000054)
-#define rALMMIN (*(volatile unsigned char *)0x57000058)
-#define rALMHOUR (*(volatile unsigned char *)0x5700005C)
-#define rALMDATE (*(volatile unsigned char *)0x57000060)
-#define rALMMON (*(volatile unsigned char *)0x57000064)
-#define rALMYEAR (*(volatile unsigned char *)0x57000068)
-#define rRTCRST (*(volatile unsigned char *)0x5700006C)
-#define rBCDSEC (*(volatile unsigned char *)0x57000070)
-#define rBCDMIN (*(volatile unsigned char *)0x57000074)
-#define rBCDHOUR (*(volatile unsigned char *)0x57000078)
-#define rBCDDATE (*(volatile unsigned char *)0x5700007C)
-#define rBCDDAY (*(volatile unsigned char *)0x57000080)
-#define rBCDMON (*(volatile unsigned char *)0x57000084)
-#define rBCDYEAR (*(volatile unsigned char *)0x57000088)
-#endif
-
-
-/* ADC */
-#define rADCCON (*(volatile unsigned *)0x58000000)
-#define rADCTSC (*(volatile unsigned *)0x58000004)
-#define rADCDLY (*(volatile unsigned *)0x58000008)
-#define rADCDAT0 (*(volatile unsigned *)0x5800000C)
-#define rADCDAT1 (*(volatile unsigned *)0x58000010)
-
-
-/* SPI */
-#define rSPCON0 (*(volatile unsigned *)0x59000000)
-#define rSPSTA0 (*(volatile unsigned *)0x59000004)
-#define rSPPIN0 (*(volatile unsigned *)0x59000008)
-#define rSPPRE0 (*(volatile unsigned *)0x5900000C)
-#define rSPTDAT0 (*(volatile unsigned *)0x59000010)
-#define rSPRDAT0 (*(volatile unsigned *)0x59000014)
-#define rSPCON1 (*(volatile unsigned *)0x59000020)
-#define rSPSTA1 (*(volatile unsigned *)0x59000024)
-#define rSPPIN1 (*(volatile unsigned *)0x59000028)
-#define rSPPRE1 (*(volatile unsigned *)0x5900002C)
-#define rSPTDAT1 (*(volatile unsigned *)0x59000030)
-#define rSPRDAT1 (*(volatile unsigned *)0x59000034)
-
-
-/* SD INTERFACE */
-#define rSDICON (*(volatile unsigned *)0x5A000000)
-#define rSDIPRE (*(volatile unsigned *)0x5A000004)
-#define rSDICmdArg (*(volatile unsigned *)0x5A000008)
-#define rSDICmdCon (*(volatile unsigned *)0x5A00000C)
-#define rSDICmdSta (*(volatile unsigned *)0x5A000010)
-#define rSDIRSP0 (*(volatile unsigned *)0x5A000014)
-#define rSDIRSP1 (*(volatile unsigned *)0x5A000018)
-#define rSDIRSP2 (*(volatile unsigned *)0x5A00001C)
-#define rSDIRSP3 (*(volatile unsigned *)0x5A000020)
-#define rSDIDTimer (*(volatile unsigned *)0x5A000024)
-#define rSDIBSize (*(volatile unsigned *)0x5A000028)
-#define rSDIDatCon (*(volatile unsigned *)0x5A00002C)
-#define rSDIDatCnt (*(volatile unsigned *)0x5A000030)
-#define rSDIDatSta (*(volatile unsigned *)0x5A000034)
-#define rSDIFSTA (*(volatile unsigned *)0x5A000038)
-#ifdef __BIG_ENDIAN
-#define rSDIDAT (*(volatile unsigned char *)0x5A00003F)
-#else
-#define rSDIDAT (*(volatile unsigned char *)0x5A00003C)
-#endif
-#define rSDIIntMsk (*(volatile unsigned *)0x5A000040)
-
-#endif
+};
#endif /*__S3C24X0_H__*/
--
1.6.1.2
2
1
The following changes since commit 3e88337b225bf796f6df21d0a7f591530e9d4ce0:
Mike Frysinger (1):
Blackfin: move ALL += u-boot.ldr to blackfin_config.mk
are available in the git repository at:
git://www.denx.de/git/u-boot-blackfin.git sf
Mike Frysinger (2):
sf: sst: fix sector size
sf: sst: add sst25vf###b ids
Prafulla Wadaskar (1):
sf: Macronix additional chips supported
drivers/mtd/spi/macronix.c | 49 +++++++++++++++++++++++++++++++++----------
drivers/mtd/spi/sst.c | 24 ++++++++++++++++++---
2 files changed, 57 insertions(+), 16 deletions(-)
2
5

Re: [U-Boot] [PATCH] asm-generic: Consolidate errno.h to asm-generic/errno.h
by Liew Tsi Chung-R5AAHP 08 Jul '09
by Liew Tsi Chung-R5AAHP 08 Jul '09
08 Jul '09
Michal,
Looks good to me.
Best Regards,
TsiChung
1
0
I have created a patch for the OMAP3EVM u-boot to create an image for
download into OMAP internal RAM (64k). This allows a complete boot to
Linux over USB only, without any RS-232 serial cables. The difference
between this and Nishanth Menon's procedures (found here:
http://nishanthmenon.blogspot.com/2008/12/towards-creating-beagleboard-n
and.html) is simply that the RS232 serial port is not required.
If anybody has any input into this, or finds this useful, please
share...
Here's an executive summary of the boot process:
- Setup OMAP3EVM to boot via USB
- Start Martin Mueller's omap3_usbload to download the u-boot.bin
image
- Run a kermit script to talk to the board over /dev/ttyACM0, and
download uImage/ramdisk images.
- bootm
- Linux boots to the command line.
Also note: this builds off of a u-boot USB dev branch, not mainline
u-boot.
The details:
- Images:
- omap3_usbload:
- Download and build omap3_usbload (Nishanth Menon's pusb should
work as well):
http://groups.google.com/group/beagleboard/browse_thread/thread/2b9e9988
6bb7a747
- Note: requires the libusb package.
- u-boot
- Get Steve's Sakoman's u-boot usb dev branch:
- See http://elinux.org/U-boot_musb_gadget_support
- In short (from gitorious):
git clone git://gitorious.org/u-boot-omap3/mainline.git
cd mainline
git checkout --track -b omap3-dev-usb
origin/omap3-dev-usb
- Current latest commit is commit
6c4dabfd6e32eed49624f773fc39140c4b1322b1
- Apply the attached patch (Note: I'm new to git, and I've just
attached a "diff -urN" patch. With a little help, I'd be happy to
upload a proper "git" patch). For example:
- cd mainline
- patch -p1 < ../u-boot-omap3evm-usb-boot.patch
- Build u-boot:
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
omap3_evm_config
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
- You now have a downloadable u-boot.bin. Copy it to
u-boot2.bin to avoid confusion. I'll use that name in the script later.
- Kermit
- Download CKermit with your favorite package manager.
- Also you'll need the attached kermrc script. It was created
from: http://www.denx.de/wiki/DULG/SystemSetup, section 4.3,
with the notable exception about send/recv buffers (see notes at
end of this email).
- uImage
- You'll need the default OMAP3EVM Linux image, but you'll have
to rebuild it and make one change:
- Remove defines for the ethernet driver. If you include
it, the driver will crash on boot because this u-boot does not
initialize the Ethernet core. The applicable configs
are:
# CONFIG_MII is not set
# CONFIG_SMSC911X_OMAP3EVM is not set
- ramdisk:
- For my example below, I convert the ramdisk to uboot format.
To do this:
mkimage -n 'uboot ext2 ramdisk rootfs' -A arm -O linux -T
ramdisk -C gzip -d \
~/OMAP35x_SDK_1.0.2/ramdisk-min.gz ramdisk.ext2.gz.uboot
- OMAP3EVM Board setup:
- The jumpers need to be set for USB boot. For my board, I've set
it to boot USB boot first, MMC boot second, which is:
SW4 (1-8): ON OFF OFF ON ON OFF OFF OFF
- Connect the USB cable to your Linux host
- Connect a serial cable to see the Linux console (not required, but
recommened for first time at least).
- On the host:
- Given the attached scripts and the above built binaries, run:
./usbload
- usbload/kermrc scripts currently have the image names embedded in
them. They should all be in the current dir.
- Output you should see on host:
bri@bri-desktop:~/tmp/Beagle/omap3_usb/host$ ./usbload
TI OMAP3 USB boot ROM tool, version 0.1
(c) 2008 Martin Mueller <martinmm(a)pfump.org>
.......................
found device!
download ok
Loading Linux image...
Done Loading Linux image.
Loading RamDisk image...
Done Loading RamDisk image.
Booting Linux... Check serial console for more messages.
In addition, you will see the kermit download manager in the terminal in
full screen.
- Notes:
- The memory map on the target is:
0x40200000 Internal RAM start. Max top of stack
0x40201000 Top of stack, start of code/data/bss
0x4020F000 Reserved for ROM boot code.
- The u-boot image created is VERY tight in memory. We have 60k to
use, and the image is within 256 bytes of the max.
Be aware of this if/when porting to the beagle board. Most of the
changes in the patch were to reduce the code size.
- kermit download over /dev/ttyACM0 will not work if the
send/receive buffers are greater than 128 or so. They have been
set to 128 in kermrc.
- omap3_usbload must be run as root, as libusb seems to require it.
The usbload script uses sudo to do this.
Hope this is useful to someone. If I've missed anything, just ask...
Thanks for all the community support!
----
Brian Silverman
Principal Engineer
iVeia
----
Brian Silverman
Principal Engineer
iVeia
2
1
The following changes since commit 59869ca72df8bc4e4ffa9dd17cb6673bbe010272:
Wolfgang Denk (1):
Merge branch 'master' of git://git.denx.de/u-boot-video
are available in the git repository at:
git://www.denx.de/git/u-boot-ppc4xx.git master
Alessio Centazzo (1):
ppc4xx: Fixed PPC4xx debug compilation error in uic.c
Felix Radensky (2):
ppc4xx: Fix FDT EBC mappings on Canyonlands
4xx: Fix compilation warnings and MQ registers dump in SPD DDR2 code
Matthias Fuchs (2):
ppc4xx: Implement is_pci_host() for 405 CPUs
ppc4xx: Make pll_write global
Stefan Roese (1):
ppc4xx: Remove compilation warning "pci_async_enabled defined but not used"
board/amcc/canyonlands/canyonlands.c | 6 +++-
cpu/ppc4xx/44x_spd_ddr2.c | 42 ++++++++++++++++++++-------------
cpu/ppc4xx/4xx_pci.c | 19 +++++++++++++--
cpu/ppc4xx/cpu.c | 2 +
cpu/ppc4xx/start.S | 1 +
cpu/ppc4xx/uic.c | 2 +-
include/configs/canyonlands.h | 2 +
7 files changed, 51 insertions(+), 23 deletions(-)
2
1

Re: [U-Boot] [PATCH] asm-generic: Consolidate errno.h to asm-generic/errno.h
by Jean-Christophe PLAGNIOL-VILLARD 08 Jul '09
by Jean-Christophe PLAGNIOL-VILLARD 08 Jul '09
08 Jul '09
On 09:52 Wed 08 Jul , Michal Simek wrote:
> Hi Custodians,
>
> Do you have any problem with this asm-generic/errno.h patch?
>
> Patch is available in u-boot-microblaze.git asm-generic branch.
>
> Thanks,
> Michal
>
>
>
> > From: Michal Simek <monstr(a)monstr.eu>
> >
> > This patch use blackfin errno.h implementation which
> > correspond Linux kernel one.
> >
> > MIPS implemetation is different that's why I keep it.
> >
> > I removed ppc_error_no.h from Marvell boards which
> > was the same too.
> >
> > Signed-off-by: Michal Simek <monstr(a)monstr.eu>
> > ---
> > board/Marvell/common/ppc_error_no.h | 164 -----------------------------------
> > board/Marvell/db64360/mv_eth.h | 3 +-
> > board/Marvell/db64460/mv_eth.h | 2 +-
> > board/prodrive/p3mx/mv_eth.h | 2 +-
> > include/asm-arm/errno.h | 139 +-----------------------------
> > include/asm-avr32/errno.h | 133 +----------------------------
> > include/asm-blackfin/errno.h | 157 +---------------------------------
> > include/asm-generic/errno.h | 155 +++++++++++++++++++++++++++++++++
> > include/asm-m68k/errno.h | 139 +-----------------------------
> > include/asm-microblaze/errno.h | 1 +
> > include/asm-ppc/errno.h | 139 +-----------------------------
> > include/asm-sh/errno.h | 157 +---------------------------------
> > include/asm-sparc/errno.h | 163 +----------------------------------
> > 13 files changed, 166 insertions(+), 1188 deletions(-)
> > delete mode 100644 board/Marvell/common/ppc_error_no.h
> > create mode 100644 include/asm-generic/errno.h
> > create mode 100644 include/asm-microblaze/errno.h
looks fine for me too
Best Regards,
J.
1
0
Signed-off-by: Kumar Gala <galak(a)kernel.crashing.org>
---
This is an attempt at using dlmalloc v2.8.4. Its a work in progress, but
wanted to post to see what peoples feelings are on updating. This version
resolves all the various warnings we see w/gcc4.4 and the older version of
dlmalloc however the trade of is the code size has increased.
I still need to see if we need to hand relocate the global structs or not.
This diff is just of malloc.h to see how things are cfg, and of
dmalloc.src vs dmalloc.c to see the changes to it.
- k
diff --git a/include/malloc.h b/include/malloc.h
index 47154b0..2af6c8a 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -1,942 +1,784 @@
-/*
- A version of malloc/free/realloc written by Doug Lea and released to the
- public domain. Send questions/comments/complaints/performance data
- to dl(a)cs.oswego.edu
-
-* VERSION 2.6.6 Sun Mar 5 19:10:03 2000 Doug Lea (dl at gee)
-
- Note: There may be an updated version of this malloc obtainable at
- ftp://g.oswego.edu/pub/misc/malloc.c
- Check before installing!
-
-* Why use this malloc?
-
- This is not the fastest, most space-conserving, most portable, or
- most tunable malloc ever written. However it is among the fastest
- while also being among the most space-conserving, portable and tunable.
- Consistent balance across these factors results in a good general-purpose
- allocator. For a high-level description, see
- http://g.oswego.edu/dl/html/malloc.html
-
-* Synopsis of public routines
-
- (Much fuller descriptions are contained in the program documentation below.)
-
- malloc(size_t n);
- Return a pointer to a newly allocated chunk of at least n bytes, or null
- if no space is available.
- free(Void_t* p);
- Release the chunk of memory pointed to by p, or no effect if p is null.
- realloc(Void_t* p, size_t n);
- Return a pointer to a chunk of size n that contains the same data
- as does chunk p up to the minimum of (n, p's size) bytes, or null
- if no space is available. The returned pointer may or may not be
- the same as p. If p is null, equivalent to malloc. Unless the
- #define REALLOC_ZERO_BYTES_FREES below is set, realloc with a
- size argument of zero (re)allocates a minimum-sized chunk.
- memalign(size_t alignment, size_t n);
- Return a pointer to a newly allocated chunk of n bytes, aligned
- in accord with the alignment argument, which must be a power of
- two.
- valloc(size_t n);
- Equivalent to memalign(pagesize, n), where pagesize is the page
- size of the system (or as near to this as can be figured out from
- all the includes/defines below.)
- pvalloc(size_t n);
- Equivalent to valloc(minimum-page-that-holds(n)), that is,
- round up n to nearest pagesize.
- calloc(size_t unit, size_t quantity);
- Returns a pointer to quantity * unit bytes, with all locations
- set to zero.
- cfree(Void_t* p);
- Equivalent to free(p).
- malloc_trim(size_t pad);
- Release all but pad bytes of freed top-most memory back
- to the system. Return 1 if successful, else 0.
- malloc_usable_size(Void_t* p);
- Report the number usable allocated bytes associated with allocated
- chunk p. This may or may not report more bytes than were requested,
- due to alignment and minimum size constraints.
- malloc_stats();
- Prints brief summary statistics on stderr.
- mallinfo()
- Returns (by copy) a struct containing various summary statistics.
- mallopt(int parameter_number, int parameter_value)
- Changes one of the tunable parameters described below. Returns
- 1 if successful in changing the parameter, else 0.
-
-* Vital statistics:
-
- Alignment: 8-byte
- 8 byte alignment is currently hardwired into the design. This
- seems to suffice for all current machines and C compilers.
-
- Assumed pointer representation: 4 or 8 bytes
- Code for 8-byte pointers is untested by me but has worked
- reliably by Wolfram Gloger, who contributed most of the
- changes supporting this.
-
- Assumed size_t representation: 4 or 8 bytes
- Note that size_t is allowed to be 4 bytes even if pointers are 8.
-
- Minimum overhead per allocated chunk: 4 or 8 bytes
- Each malloced chunk has a hidden overhead of 4 bytes holding size
- and status information.
-
- Minimum allocated size: 4-byte ptrs: 16 bytes (including 4 overhead)
- 8-byte ptrs: 24/32 bytes (including, 4/8 overhead)
-
- When a chunk is freed, 12 (for 4byte ptrs) or 20 (for 8 byte
- ptrs but 4 byte size) or 24 (for 8/8) additional bytes are
- needed; 4 (8) for a trailing size field
- and 8 (16) bytes for free list pointers. Thus, the minimum
- allocatable size is 16/24/32 bytes.
-
- Even a request for zero bytes (i.e., malloc(0)) returns a
- pointer to something of the minimum allocatable size.
-
- Maximum allocated size: 4-byte size_t: 2^31 - 8 bytes
- 8-byte size_t: 2^63 - 16 bytes
-
- It is assumed that (possibly signed) size_t bit values suffice to
- represent chunk sizes. `Possibly signed' is due to the fact
- that `size_t' may be defined on a system as either a signed or
- an unsigned type. To be conservative, values that would appear
- as negative numbers are avoided.
- Requests for sizes with a negative sign bit when the request
- size is treaded as a long will return null.
-
- Maximum overhead wastage per allocated chunk: normally 15 bytes
-
- Alignnment demands, plus the minimum allocatable size restriction
- make the normal worst-case wastage 15 bytes (i.e., up to 15
- more bytes will be allocated than were requested in malloc), with
- two exceptions:
- 1. Because requests for zero bytes allocate non-zero space,
- the worst case wastage for a request of zero bytes is 24 bytes.
- 2. For requests >= mmap_threshold that are serviced via
- mmap(), the worst case wastage is 8 bytes plus the remainder
- from a system page (the minimal mmap unit); typically 4096 bytes.
-
-* Limitations
-
- Here are some features that are NOT currently supported
-
- * No user-definable hooks for callbacks and the like.
- * No automated mechanism for fully checking that all accesses
- to malloced memory stay within their bounds.
- * No support for compaction.
-
-* Synopsis of compile-time options:
-
- People have reported using previous versions of this malloc on all
- versions of Unix, sometimes by tweaking some of the defines
- below. It has been tested most extensively on Solaris and
- Linux. It is also reported to work on WIN32 platforms.
- People have also reported adapting this malloc for use in
- stand-alone embedded systems.
-
- The implementation is in straight, hand-tuned ANSI C. Among other
- consequences, it uses a lot of macros. Because of this, to be at
- all usable, this code should be compiled using an optimizing compiler
- (for example gcc -O2) that can simplify expressions and control
- paths.
-
- __STD_C (default: derived from C compiler defines)
- Nonzero if using ANSI-standard C compiler, a C++ compiler, or
- a C compiler sufficiently close to ANSI to get away with it.
- DEBUG (default: NOT defined)
- Define to enable debugging. Adds fairly extensive assertion-based
- checking to help track down memory errors, but noticeably slows down
- execution.
- REALLOC_ZERO_BYTES_FREES (default: NOT defined)
- Define this if you think that realloc(p, 0) should be equivalent
- to free(p). Otherwise, since malloc returns a unique pointer for
- malloc(0), so does realloc(p, 0).
- HAVE_MEMCPY (default: defined)
- Define if you are not otherwise using ANSI STD C, but still
- have memcpy and memset in your C library and want to use them.
- Otherwise, simple internal versions are supplied.
- USE_MEMCPY (default: 1 if HAVE_MEMCPY is defined, 0 otherwise)
- Define as 1 if you want the C library versions of memset and
- memcpy called in realloc and calloc (otherwise macro versions are used).
- At least on some platforms, the simple macro versions usually
- outperform libc versions.
- HAVE_MMAP (default: defined as 1)
- Define to non-zero to optionally make malloc() use mmap() to
- allocate very large blocks.
- HAVE_MREMAP (default: defined as 0 unless Linux libc set)
- Define to non-zero to optionally make realloc() use mremap() to
- reallocate very large blocks.
- malloc_getpagesize (default: derived from system #includes)
- Either a constant or routine call returning the system page size.
- HAVE_USR_INCLUDE_MALLOC_H (default: NOT defined)
- Optionally define if you are on a system with a /usr/include/malloc.h
- that declares struct mallinfo. It is not at all necessary to
- define this even if you do, but will ensure consistency.
- INTERNAL_SIZE_T (default: size_t)
- Define to a 32-bit type (probably `unsigned int') if you are on a
- 64-bit machine, yet do not want or need to allow malloc requests of
- greater than 2^31 to be handled. This saves space, especially for
- very small chunks.
- INTERNAL_LINUX_C_LIB (default: NOT defined)
- Defined only when compiled as part of Linux libc.
- Also note that there is some odd internal name-mangling via defines
- (for example, internally, `malloc' is named `mALLOc') needed
- when compiling in this case. These look funny but don't otherwise
- affect anything.
- WIN32 (default: undefined)
- Define this on MS win (95, nt) platforms to compile in sbrk emulation.
- LACKS_UNISTD_H (default: undefined if not WIN32)
- Define this if your system does not have a <unistd.h>.
- LACKS_SYS_PARAM_H (default: undefined if not WIN32)
- Define this if your system does not have a <sys/param.h>.
- MORECORE (default: sbrk)
- The name of the routine to call to obtain more memory from the system.
- MORECORE_FAILURE (default: -1)
- The value returned upon failure of MORECORE.
- MORECORE_CLEARS (default 1)
- True (1) if the routine mapped to MORECORE zeroes out memory (which
- holds for sbrk).
- DEFAULT_TRIM_THRESHOLD
- DEFAULT_TOP_PAD
- DEFAULT_MMAP_THRESHOLD
- DEFAULT_MMAP_MAX
- Default values of tunable parameters (described in detail below)
- controlling interaction with host system routines (sbrk, mmap, etc).
- These values may also be changed dynamically via mallopt(). The
- preset defaults are those that give best performance for typical
- programs/systems.
- USE_DL_PREFIX (default: undefined)
- Prefix all public routines with the string 'dl'. Useful to
- quickly avoid procedure declaration conflicts and linker symbol
- conflicts with existing memory allocation routines.
-
-
-*/
-
-
-
-
-/* Preliminaries */
-
-#ifndef __STD_C
-#ifdef __STDC__
-#define __STD_C 1
-#else
-#if __cplusplus
-#define __STD_C 1
-#else
-#define __STD_C 0
-#endif /*__cplusplus*/
-#endif /*__STDC__*/
-#endif /*__STD_C*/
-
-#ifndef Void_t
-#if (__STD_C || defined(WIN32))
-#define Void_t void
-#else
-#define Void_t char
-#endif
-#endif /*Void_t*/
-
-#if __STD_C
-#include <linux/stddef.h> /* for size_t */
-#else
-#include <sys/types.h>
-#endif /* __STD_C */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if 0 /* not for U-Boot */
-#include <stdio.h> /* needed for malloc_stats */
-#endif
-
-
-/*
- Compile-time options
-*/
-
-
-/*
- Debugging:
-
- Because freed chunks may be overwritten with link fields, this
- malloc will often die when freed memory is overwritten by user
- programs. This can be very effective (albeit in an annoying way)
- in helping track down dangling pointers.
-
- If you compile with -DDEBUG, a number of assertion checks are
- enabled that will catch more memory errors. You probably won't be
- able to make much sense of the actual assertion errors, but they
- should help you locate incorrectly overwritten memory. The
- checking is fairly extensive, and will slow down execution
- noticeably. Calling malloc_stats or mallinfo with DEBUG set will
- attempt to check every non-mmapped allocated and free chunk in the
- course of computing the summmaries. (By nature, mmapped regions
- cannot be checked very much automatically.)
-
- Setting DEBUG may also be helpful if you are trying to modify
- this code. The assertions in the check routines spell out in more
- detail the assumptions and invariants underlying the algorithms.
-
-*/
-
-#ifdef DEBUG
-/* #include <assert.h> */
-#define assert(x) ((void)0)
-#else
-#define assert(x) ((void)0)
-#endif
-
-
-/*
- INTERNAL_SIZE_T is the word-size used for internal bookkeeping
- of chunk sizes. On a 64-bit machine, you can reduce malloc
- overhead by defining INTERNAL_SIZE_T to be a 32 bit `unsigned int'
- at the expense of not being able to handle requests greater than
- 2^31. This limitation is hardly ever a concern; you are encouraged
- to set this. However, the default version is the same as size_t.
-*/
-
-#ifndef INTERNAL_SIZE_T
-#define INTERNAL_SIZE_T size_t
-#endif
-
-/*
- REALLOC_ZERO_BYTES_FREES should be set if a call to
- realloc with zero bytes should be the same as a call to free.
- Some people think it should. Otherwise, since this malloc
- returns a unique pointer for malloc(0), so does realloc(p, 0).
-*/
-
-
-/* #define REALLOC_ZERO_BYTES_FREES */
-
-
-/*
- WIN32 causes an emulation of sbrk to be compiled in
- mmap-based options are not currently supported in WIN32.
-*/
-
-/* #define WIN32 */
-#ifdef WIN32
-#define MORECORE wsbrk
-#define HAVE_MMAP 0
-
-#define LACKS_UNISTD_H
-#define LACKS_SYS_PARAM_H
-
-/*
- Include 'windows.h' to get the necessary declarations for the
- Microsoft Visual C++ data structures and routines used in the 'sbrk'
- emulation.
-
- Define WIN32_LEAN_AND_MEAN so that only the essential Microsoft
- Visual C++ header files are included.
-*/
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#define HAVE_MMAP 0
+#define HAVE_MREMAP 0
+#define HAVE_MORECORE 1
+#define LACKS_SYS_TYPES_H 1
+#define LACKS_ERRNO_H 1
+#define LACKS_STDLIB_H 1
+#define LACKS_STRING_H 1
+#define LACKS_STRINGS_H 1
+#define LACKS_UNISTD_H 1
+#define LACKS_SYS_PARAM_H 1
+#define EXEC_PAGESIZE 4096
+#define MALLOC_FAILURE_ACTION 0
+#define ABORT_ON_ASSERT_FAILURE 0
+#define ABORT
+#define INSECURE 1
+#define NO_MALLINFO 1
+
+#include <linux/types.h>
+
+
+
+/* Version identifier to allow people to support multiple versions */
+#ifndef DLMALLOC_VERSION
+#define DLMALLOC_VERSION 20804
+#endif /* DLMALLOC_VERSION */
+
+#if defined(DARWIN) || defined(_DARWIN)
+/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */
+#ifndef HAVE_MORECORE
+#define HAVE_MORECORE 0
+#define HAVE_MMAP 1
+/* OSX allocators provide 16 byte alignment */
+#ifndef MALLOC_ALIGNMENT
+#define MALLOC_ALIGNMENT ((size_t)16U)
#endif
+#endif /* HAVE_MORECORE */
+#endif /* DARWIN */
+#ifndef LACKS_SYS_TYPES_H
+#include <sys/types.h> /* For size_t */
+#endif /* LACKS_SYS_TYPES_H */
-/*
- HAVE_MEMCPY should be defined if you are not otherwise using
- ANSI STD C, but still have memcpy and memset in your C library
- and want to use them in calloc and realloc. Otherwise simple
- macro versions are defined here.
-
- USE_MEMCPY should be defined as 1 if you actually want to
- have memset and memcpy called. People report that the macro
- versions are often enough faster than libc versions on many
- systems that it is better to use them.
-
-*/
-
-#define HAVE_MEMCPY
-
-#ifndef USE_MEMCPY
-#ifdef HAVE_MEMCPY
-#define USE_MEMCPY 1
+#if (defined(__GNUC__) && ((defined(__i386__) || defined(__x86_64__)))) || (defined(_MSC_VER) && _MSC_VER>=1310)
+#define SPIN_LOCKS_AVAILABLE 1
#else
-#define USE_MEMCPY 0
-#endif
+#define SPIN_LOCKS_AVAILABLE 0
#endif
-#if (__STD_C || defined(HAVE_MEMCPY))
+/* The maximum possible size_t value has all bits set */
+#define MAX_SIZE_T (~(size_t)0)
-#if __STD_C
-void* memset(void*, int, size_t);
-void* memcpy(void*, const void*, size_t);
+#ifndef ONLY_MSPACES
+#define ONLY_MSPACES 0 /* define to a value */
#else
-#ifdef WIN32
-/* On Win32 platforms, 'memset()' and 'memcpy()' are already declared in */
-/* 'windows.h' */
+#define ONLY_MSPACES 1
+#endif /* ONLY_MSPACES */
+#ifndef MSPACES
+#if ONLY_MSPACES
+#define MSPACES 1
+#else /* ONLY_MSPACES */
+#define MSPACES 0
+#endif /* ONLY_MSPACES */
+#endif /* MSPACES */
+#ifndef MALLOC_ALIGNMENT
+#define MALLOC_ALIGNMENT ((size_t)8U)
+#endif /* MALLOC_ALIGNMENT */
+#ifndef FOOTERS
+#define FOOTERS 0
+#endif /* FOOTERS */
+#ifndef ABORT
+#define ABORT abort()
+#endif /* ABORT */
+#ifndef ABORT_ON_ASSERT_FAILURE
+#define ABORT_ON_ASSERT_FAILURE 1
+#endif /* ABORT_ON_ASSERT_FAILURE */
+#ifndef PROCEED_ON_ERROR
+#define PROCEED_ON_ERROR 0
+#endif /* PROCEED_ON_ERROR */
+#ifndef USE_LOCKS
+#define USE_LOCKS 0
+#endif /* USE_LOCKS */
+#ifndef USE_SPIN_LOCKS
+#if USE_LOCKS && SPIN_LOCKS_AVAILABLE
+#define USE_SPIN_LOCKS 1
#else
-Void_t* memset();
-Void_t* memcpy();
-#endif
-#endif
-#endif
-
-#if USE_MEMCPY
-
-/* The following macros are only invoked with (2n+1)-multiples of
- INTERNAL_SIZE_T units, with a positive integer n. This is exploited
- for fast inline execution when n is small. */
-
-#define MALLOC_ZERO(charp, nbytes) \
-do { \
- INTERNAL_SIZE_T mzsz = (nbytes); \
- if(mzsz <= 9*sizeof(mzsz)) { \
- INTERNAL_SIZE_T* mz = (INTERNAL_SIZE_T*) (charp); \
- if(mzsz >= 5*sizeof(mzsz)) { *mz++ = 0; \
- *mz++ = 0; \
- if(mzsz >= 7*sizeof(mzsz)) { *mz++ = 0; \
- *mz++ = 0; \
- if(mzsz >= 9*sizeof(mzsz)) { *mz++ = 0; \
- *mz++ = 0; }}} \
- *mz++ = 0; \
- *mz++ = 0; \
- *mz = 0; \
- } else memset((charp), 0, mzsz); \
-} while(0)
-
-#define MALLOC_COPY(dest,src,nbytes) \
-do { \
- INTERNAL_SIZE_T mcsz = (nbytes); \
- if(mcsz <= 9*sizeof(mcsz)) { \
- INTERNAL_SIZE_T* mcsrc = (INTERNAL_SIZE_T*) (src); \
- INTERNAL_SIZE_T* mcdst = (INTERNAL_SIZE_T*) (dest); \
- if(mcsz >= 5*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \
- *mcdst++ = *mcsrc++; \
- if(mcsz >= 7*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \
- *mcdst++ = *mcsrc++; \
- if(mcsz >= 9*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \
- *mcdst++ = *mcsrc++; }}} \
- *mcdst++ = *mcsrc++; \
- *mcdst++ = *mcsrc++; \
- *mcdst = *mcsrc ; \
- } else memcpy(dest, src, mcsz); \
-} while(0)
-
-#else /* !USE_MEMCPY */
-
-/* Use Duff's device for good zeroing/copying performance. */
-
-#define MALLOC_ZERO(charp, nbytes) \
-do { \
- INTERNAL_SIZE_T* mzp = (INTERNAL_SIZE_T*)(charp); \
- long mctmp = (nbytes)/sizeof(INTERNAL_SIZE_T), mcn; \
- if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp %= 8; } \
- switch (mctmp) { \
- case 0: for(;;) { *mzp++ = 0; \
- case 7: *mzp++ = 0; \
- case 6: *mzp++ = 0; \
- case 5: *mzp++ = 0; \
- case 4: *mzp++ = 0; \
- case 3: *mzp++ = 0; \
- case 2: *mzp++ = 0; \
- case 1: *mzp++ = 0; if(mcn <= 0) break; mcn--; } \
- } \
-} while(0)
-
-#define MALLOC_COPY(dest,src,nbytes) \
-do { \
- INTERNAL_SIZE_T* mcsrc = (INTERNAL_SIZE_T*) src; \
- INTERNAL_SIZE_T* mcdst = (INTERNAL_SIZE_T*) dest; \
- long mctmp = (nbytes)/sizeof(INTERNAL_SIZE_T), mcn; \
- if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp %= 8; } \
- switch (mctmp) { \
- case 0: for(;;) { *mcdst++ = *mcsrc++; \
- case 7: *mcdst++ = *mcsrc++; \
- case 6: *mcdst++ = *mcsrc++; \
- case 5: *mcdst++ = *mcsrc++; \
- case 4: *mcdst++ = *mcsrc++; \
- case 3: *mcdst++ = *mcsrc++; \
- case 2: *mcdst++ = *mcsrc++; \
- case 1: *mcdst++ = *mcsrc++; if(mcn <= 0) break; mcn--; } \
- } \
-} while(0)
-
-#endif
-
-
-/*
- Define HAVE_MMAP to optionally make malloc() use mmap() to
- allocate very large blocks. These will be returned to the
- operating system immediately after a free().
-*/
-
-/***
+#define USE_SPIN_LOCKS 0
+#endif /* USE_LOCKS && SPIN_LOCKS_AVAILABLE. */
+#endif /* USE_SPIN_LOCKS */
+#ifndef INSECURE
+#define INSECURE 0
+#endif /* INSECURE */
#ifndef HAVE_MMAP
#define HAVE_MMAP 1
-#endif
-***/
-#undef HAVE_MMAP /* Not available for U-Boot */
-
-/*
- Define HAVE_MREMAP to make realloc() use mremap() to re-allocate
- large blocks. This is currently only possible on Linux with
- kernel versions newer than 1.3.77.
-*/
-
-/***
+#endif /* HAVE_MMAP */
+#ifndef MMAP_CLEARS
+#define MMAP_CLEARS 1
+#endif /* MMAP_CLEARS */
#ifndef HAVE_MREMAP
-#ifdef INTERNAL_LINUX_C_LIB
+#ifdef linux
#define HAVE_MREMAP 1
-#else
+#else /* linux */
#define HAVE_MREMAP 0
-#endif
-#endif
-***/
-#undef HAVE_MREMAP /* Not available for U-Boot */
-
+#endif /* linux */
+#endif /* HAVE_MREMAP */
+#ifndef MALLOC_FAILURE_ACTION
+#define MALLOC_FAILURE_ACTION errno = ENOMEM;
+#endif /* MALLOC_FAILURE_ACTION */
+#ifndef HAVE_MORECORE
+#if ONLY_MSPACES
+#define HAVE_MORECORE 0
+#else /* ONLY_MSPACES */
+#define HAVE_MORECORE 1
+#endif /* ONLY_MSPACES */
+#endif /* HAVE_MORECORE */
+#if !HAVE_MORECORE
+#define MORECORE_CONTIGUOUS 0
+#else /* !HAVE_MORECORE */
+#define MORECORE_DEFAULT sbrk
+#ifndef MORECORE_CONTIGUOUS
+#define MORECORE_CONTIGUOUS 1
+#endif /* MORECORE_CONTIGUOUS */
+#endif /* HAVE_MORECORE */
+#ifndef DEFAULT_GRANULARITY
+#if (MORECORE_CONTIGUOUS || defined(WIN32))
+#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */
+#else /* MORECORE_CONTIGUOUS */
+#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U)
+#endif /* MORECORE_CONTIGUOUS */
+#endif /* DEFAULT_GRANULARITY */
+#ifndef DEFAULT_TRIM_THRESHOLD
+#ifndef MORECORE_CANNOT_TRIM
+#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U)
+#else /* MORECORE_CANNOT_TRIM */
+#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T
+#endif /* MORECORE_CANNOT_TRIM */
+#endif /* DEFAULT_TRIM_THRESHOLD */
+#ifndef DEFAULT_MMAP_THRESHOLD
#if HAVE_MMAP
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
-#define MAP_ANONYMOUS MAP_ANON
-#endif
-
+#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U)
+#else /* HAVE_MMAP */
+#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T
+#endif /* HAVE_MMAP */
+#endif /* DEFAULT_MMAP_THRESHOLD */
+#ifndef MAX_RELEASE_CHECK_RATE
+#if HAVE_MMAP
+#define MAX_RELEASE_CHECK_RATE 4095
+#else
+#define MAX_RELEASE_CHECK_RATE MAX_SIZE_T
#endif /* HAVE_MMAP */
+#endif /* MAX_RELEASE_CHECK_RATE */
+#ifndef USE_BUILTIN_FFS
+#define USE_BUILTIN_FFS 0
+#endif /* USE_BUILTIN_FFS */
+#ifndef USE_DEV_RANDOM
+#define USE_DEV_RANDOM 0
+#endif /* USE_DEV_RANDOM */
+#ifndef NO_MALLINFO
+#define NO_MALLINFO 0
+#endif /* NO_MALLINFO */
+#ifndef MALLINFO_FIELD_TYPE
+#define MALLINFO_FIELD_TYPE size_t
+#endif /* MALLINFO_FIELD_TYPE */
+#ifndef NO_SEGMENT_TRAVERSAL
+#define NO_SEGMENT_TRAVERSAL 0
+#endif /* NO_SEGMENT_TRAVERSAL */
/*
- Access to system page size. To the extent possible, this malloc
- manages memory from the system in page-size units.
-
- The following mechanics for getpagesize were adapted from
- bsd/gnu getpagesize.h
+ mallopt tuning options. SVID/XPG defines four standard parameter
+ numbers for mallopt, normally defined in malloc.h. None of these
+ are used in this malloc, so setting them has no effect. But this
+ malloc does support the following options.
*/
-#define LACKS_UNISTD_H /* Shortcut for U-Boot */
-#define malloc_getpagesize 4096
-
-#ifndef LACKS_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifndef malloc_getpagesize
-# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */
-# ifndef _SC_PAGE_SIZE
-# define _SC_PAGE_SIZE _SC_PAGESIZE
-# endif
-# endif
-# ifdef _SC_PAGE_SIZE
-# define malloc_getpagesize sysconf(_SC_PAGE_SIZE)
-# else
-# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE)
- extern size_t getpagesize();
-# define malloc_getpagesize getpagesize()
-# else
-# ifdef WIN32
-# define malloc_getpagesize (4096) /* TBD: Use 'GetSystemInfo' instead */
-# else
-# ifndef LACKS_SYS_PARAM_H
-# include <sys/param.h>
-# endif
-# ifdef EXEC_PAGESIZE
-# define malloc_getpagesize EXEC_PAGESIZE
-# else
-# ifdef NBPG
-# ifndef CLSIZE
-# define malloc_getpagesize NBPG
-# else
-# define malloc_getpagesize (NBPG * CLSIZE)
-# endif
-# else
-# ifdef NBPC
-# define malloc_getpagesize NBPC
-# else
-# ifdef PAGESIZE
-# define malloc_getpagesize PAGESIZE
-# else
-# define malloc_getpagesize (4096) /* just guess */
-# endif
-# endif
-# endif
-# endif
-# endif
-# endif
-# endif
-#endif
+#define M_TRIM_THRESHOLD (-1)
+#define M_GRANULARITY (-2)
+#define M_MMAP_THRESHOLD (-3)
+/* ------------------------ Mallinfo declarations ------------------------ */
+#if !NO_MALLINFO
/*
-
This version of malloc supports the standard SVID/XPG mallinfo
- routine that returns a struct containing the same kind of
- information you can get from malloc_stats. It should work on
- any SVID/XPG compliant system that has a /usr/include/malloc.h
- defining struct mallinfo. (If you'd like to install such a thing
- yourself, cut out the preliminary declarations as described above
- and below and save them in a malloc.h file. But there's no
- compelling reason to bother to do this.)
-
- The main declaration needed is the mallinfo struct that is returned
- (by-copy) by mallinfo(). The SVID/XPG malloinfo struct contains a
- bunch of fields, most of which are not even meaningful in this
- version of malloc. Some of these fields are are instead filled by
- mallinfo() with other numbers that might possibly be of interest.
+ routine that returns a struct containing usage properties and
+ statistics. It should work on any system that has a
+ /usr/include/malloc.h defining struct mallinfo. The main
+ declaration needed is the mallinfo struct that is returned (by-copy)
+ by mallinfo(). The malloinfo struct contains a bunch of fields that
+ are not even meaningful in this version of malloc. These fields are
+ are instead filled by mallinfo() with other numbers that might be of
+ interest.
HAVE_USR_INCLUDE_MALLOC_H should be set if you have a
/usr/include/malloc.h file that includes a declaration of struct
- mallinfo. If so, it is included; else an SVID2/XPG2 compliant
- version is declared below. These must be precisely the same for
- mallinfo() to work.
-
+ mallinfo. If so, it is included; else a compliant version is
+ declared below. These must be precisely the same for mallinfo() to
+ work. The original SVID version of this struct, defined on most
+ systems with mallinfo, declares all fields as ints. But some others
+ define as unsigned long. If your system defines the fields using a
+ type of different width than listed here, you MUST #include your
+ system version and #define HAVE_USR_INCLUDE_MALLOC_H.
*/
/* #define HAVE_USR_INCLUDE_MALLOC_H */
-#if HAVE_USR_INCLUDE_MALLOC_H
+#ifdef HAVE_USR_INCLUDE_MALLOC_H
#include "/usr/include/malloc.h"
-#else
-
-/* SVID2/XPG mallinfo structure */
-
+#else /* HAVE_USR_INCLUDE_MALLOC_H */
+#ifndef STRUCT_MALLINFO_DECLARED
+#define STRUCT_MALLINFO_DECLARED 1
struct mallinfo {
- int arena; /* total space allocated from system */
- int ordblks; /* number of non-inuse chunks */
- int smblks; /* unused -- always zero */
- int hblks; /* number of mmapped regions */
- int hblkhd; /* total space in mmapped regions */
- int usmblks; /* unused -- always zero */
- int fsmblks; /* unused -- always zero */
- int uordblks; /* total allocated space */
- int fordblks; /* total non-inuse space */
- int keepcost; /* top-most, releasable (via malloc_trim) space */
+ MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */
+ MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */
+ MALLINFO_FIELD_TYPE smblks; /* always 0 */
+ MALLINFO_FIELD_TYPE hblks; /* always 0 */
+ MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */
+ MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */
+ MALLINFO_FIELD_TYPE fsmblks; /* always 0 */
+ MALLINFO_FIELD_TYPE uordblks; /* total allocated space */
+ MALLINFO_FIELD_TYPE fordblks; /* total free space */
+ MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */
};
+#endif /* STRUCT_MALLINFO_DECLARED */
+#endif /* HAVE_USR_INCLUDE_MALLOC_H */
+#endif /* NO_MALLINFO */
-/* SVID2/XPG mallopt options */
-
-#define M_MXFAST 1 /* UNUSED in this malloc */
-#define M_NLBLKS 2 /* UNUSED in this malloc */
-#define M_GRAIN 3 /* UNUSED in this malloc */
-#define M_KEEP 4 /* UNUSED in this malloc */
+/*
+ Try to persuade compilers to inline. The most critical functions for
+ inlining are defined as macros, so these aren't used for them.
+*/
+#ifndef FORCEINLINE
+ #if defined(__GNUC__)
+#define FORCEINLINE __inline __attribute__ ((always_inline))
+ #elif defined(_MSC_VER)
+ #define FORCEINLINE __forceinline
+ #endif
+#endif
+#ifndef NOINLINE
+ #if defined(__GNUC__)
+ #define NOINLINE __attribute__ ((noinline))
+ #elif defined(_MSC_VER)
+ #define NOINLINE __declspec(noinline)
+ #else
+ #define NOINLINE
+ #endif
#endif
-/* mallopt options that actually do something */
-
-#define M_TRIM_THRESHOLD -1
-#define M_TOP_PAD -2
-#define M_MMAP_THRESHOLD -3
-#define M_MMAP_MAX -4
+#ifdef __cplusplus
+extern "C" {
+#ifndef FORCEINLINE
+ #define FORCEINLINE inline
+#endif
+#endif /* __cplusplus */
+#ifndef FORCEINLINE
+ #define FORCEINLINE
+#endif
+
+#if !ONLY_MSPACES
+
+/* ------------------- Declarations of public routines ------------------- */
+
+#ifndef USE_DL_PREFIX
+#define dlcalloc calloc
+#define dlfree free
+#define dlmalloc malloc
+#define dlmemalign memalign
+#define dlrealloc realloc
+#define dlvalloc valloc
+#define dlpvalloc pvalloc
+#define dlmallinfo mallinfo
+#define dlmallopt mallopt
+#define dlmalloc_trim malloc_trim
+#define dlmalloc_stats malloc_stats
+#define dlmalloc_usable_size malloc_usable_size
+#define dlmalloc_footprint malloc_footprint
+#define dlmalloc_max_footprint malloc_max_footprint
+#define dlindependent_calloc independent_calloc
+#define dlindependent_comalloc independent_comalloc
+#endif /* USE_DL_PREFIX */
-#ifndef DEFAULT_TRIM_THRESHOLD
-#define DEFAULT_TRIM_THRESHOLD (128 * 1024)
-#endif
+/*
+ malloc(size_t n)
+ Returns a pointer to a newly allocated chunk of at least n bytes, or
+ null if no space is available, in which case errno is set to ENOMEM
+ on ANSI C systems.
+
+ If n is zero, malloc returns a minimum-sized chunk. (The minimum
+ size is 16 bytes on most 32bit systems, and 32 bytes on 64bit
+ systems.) Note that size_t is an unsigned type, so calls with
+ arguments that would be negative if signed are interpreted as
+ requests for huge amounts of space, which will often fail. The
+ maximum supported value of n differs across systems, but is in all
+ cases less than the maximum representable value of a size_t.
+*/
+void* dlmalloc(size_t);
/*
- M_TRIM_THRESHOLD is the maximum amount of unused top-most memory
- to keep before releasing via malloc_trim in free().
-
- Automatic trimming is mainly useful in long-lived programs.
- Because trimming via sbrk can be slow on some systems, and can
- sometimes be wasteful (in cases where programs immediately
- afterward allocate more large chunks) the value should be high
- enough so that your overall system performance would improve by
- releasing.
-
- The trim threshold and the mmap control parameters (see below)
- can be traded off with one another. Trimming and mmapping are
- two different ways of releasing unused memory back to the
- system. Between these two, it is often possible to keep
- system-level demands of a long-lived program down to a bare
- minimum. For example, in one test suite of sessions measuring
- the XF86 X server on Linux, using a trim threshold of 128K and a
- mmap threshold of 192K led to near-minimal long term resource
- consumption.
-
- If you are using this malloc in a long-lived program, it should
- pay to experiment with these values. As a rough guide, you
- might set to a value close to the average size of a process
- (program) running on your system. Releasing this much memory
- would allow such a process to run in memory. Generally, it's
- worth it to tune for trimming rather tham memory mapping when a
- program undergoes phases where several large chunks are
- allocated and released in ways that can reuse each other's
- storage, perhaps mixed with phases where there are no such
- chunks at all. And in well-behaved long-lived programs,
- controlling release of large blocks via trimming versus mapping
- is usually faster.
-
- However, in most programs, these parameters serve mainly as
- protection against the system-level effects of carrying around
- massive amounts of unneeded memory. Since frequent calls to
- sbrk, mmap, and munmap otherwise degrade performance, the default
- parameters are set to relatively high values that serve only as
- safeguards.
-
- The default trim value is high enough to cause trimming only in
- fairly extreme (by current memory consumption standards) cases.
- It must be greater than page size to have any useful effect. To
- disable trimming completely, you can set to (unsigned long)(-1);
-
-
-*/
-
-
-#ifndef DEFAULT_TOP_PAD
-#define DEFAULT_TOP_PAD (0)
-#endif
+ free(void* p)
+ Releases the chunk of memory pointed to by p, that had been previously
+ allocated using malloc or a related routine such as realloc.
+ It has no effect if p is null. If p was not malloced or already
+ freed, free(p) will by default cause the current program to abort.
+*/
+void dlfree(void*);
/*
- M_TOP_PAD is the amount of extra `padding' space to allocate or
- retain whenever sbrk is called. It is used in two ways internally:
+ calloc(size_t n_elements, size_t element_size);
+ Returns a pointer to n_elements * element_size bytes, with all locations
+ set to zero.
+*/
+void* dlcalloc(size_t, size_t);
- * When sbrk is called to extend the top of the arena to satisfy
- a new malloc request, this much padding is added to the sbrk
- request.
+/*
+ realloc(void* p, size_t n)
+ Returns a pointer to a chunk of size n that contains the same data
+ as does chunk p up to the minimum of (n, p's size) bytes, or null
+ if no space is available.
- * When malloc_trim is called automatically from free(),
- it is used as the `pad' argument.
+ The returned pointer may or may not be the same as p. The algorithm
+ prefers extending p in most cases when possible, otherwise it
+ employs the equivalent of a malloc-copy-free sequence.
- In both cases, the actual amount of padding is rounded
- so that the end of the arena is always a system page boundary.
+ If p is null, realloc is equivalent to malloc.
- The main reason for using padding is to avoid calling sbrk so
- often. Having even a small pad greatly reduces the likelihood
- that nearly every malloc request during program start-up (or
- after trimming) will invoke sbrk, which needlessly wastes
- time.
+ If space is not available, realloc returns null, errno is set (if on
+ ANSI) and p is NOT freed.
- Automatic rounding-up to page-size units is normally sufficient
- to avoid measurable overhead, so the default is 0. However, in
- systems where sbrk is relatively slow, it can pay to increase
- this value, at the expense of carrying around more memory than
- the program needs.
+ if n is for fewer bytes than already held by p, the newly unused
+ space is lopped off and freed if possible. realloc with a size
+ argument of zero (re)allocates a minimum-sized chunk.
+ The old unix realloc convention of allowing the last-free'd chunk
+ to be used as an argument to realloc is not supported.
*/
-
-#ifndef DEFAULT_MMAP_THRESHOLD
-#define DEFAULT_MMAP_THRESHOLD (128 * 1024)
-#endif
+void* dlrealloc(void*, size_t);
/*
+ memalign(size_t alignment, size_t n);
+ Returns a pointer to a newly allocated chunk of n bytes, aligned
+ in accord with the alignment argument.
- M_MMAP_THRESHOLD is the request size threshold for using mmap()
- to service a request. Requests of at least this size that cannot
- be allocated using already-existing space will be serviced via mmap.
- (If enough normal freed space already exists it is used instead.)
+ The alignment argument should be a power of two. If the argument is
+ not a power of two, the nearest greater power is used.
+ 8-byte alignment is guaranteed by normal malloc calls, so don't
+ bother calling memalign with an argument of 8 or less.
- Using mmap segregates relatively large chunks of memory so that
- they can be individually obtained and released from the host
- system. A request serviced through mmap is never reused by any
- other request (at least not directly; the system may just so
- happen to remap successive requests to the same locations).
+ Overreliance on memalign is a sure way to fragment space.
+*/
+void* dlmemalign(size_t, size_t);
- Segregating space in this way has the benefit that mmapped space
- can ALWAYS be individually released back to the system, which
- helps keep the system level memory demands of a long-lived
- program low. Mapped memory can never become `locked' between
- other chunks, as can happen with normally allocated chunks, which
- menas that even trimming via malloc_trim would not release them.
+/*
+ valloc(size_t n);
+ Equivalent to memalign(pagesize, n), where pagesize is the page
+ size of the system. If the pagesize is unknown, 4096 is used.
+*/
+void* dlvalloc(size_t);
- However, it has the disadvantages that:
+/*
+ mallopt(int parameter_number, int parameter_value)
+ Sets tunable parameters The format is to provide a
+ (parameter-number, parameter-value) pair. mallopt then sets the
+ corresponding parameter to the argument value if it can (i.e., so
+ long as the value is meaningful), and returns 1 if successful else
+ 0. To workaround the fact that mallopt is specified to use int,
+ not size_t parameters, the value -1 is specially treated as the
+ maximum unsigned size_t value.
+
+ SVID/XPG/ANSI defines four standard param numbers for mallopt,
+ normally defined in malloc.h. None of these are use in this malloc,
+ so setting them has no effect. But this malloc also supports other
+ options in mallopt. See below for details. Briefly, supported
+ parameters are as follows (listed defaults are for "typical"
+ configurations).
+
+ Symbol param # default allowed param values
+ M_TRIM_THRESHOLD -1 2*1024*1024 any (-1 disables)
+ M_GRANULARITY -2 page size any power of 2 >= page size
+ M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support)
+*/
+int dlmallopt(int, int);
- 1. The space cannot be reclaimed, consolidated, and then
- used to service later requests, as happens with normal chunks.
- 2. It can lead to more wastage because of mmap page alignment
- requirements
- 3. It causes malloc performance to be more dependent on host
- system memory management support routines which may vary in
- implementation quality and may impose arbitrary
- limitations. Generally, servicing a request via normal
- malloc steps is faster than going through a system's mmap.
+/*
+ malloc_footprint();
+ Returns the number of bytes obtained from the system. The total
+ number of bytes allocated by malloc, realloc etc., is less than this
+ value. Unlike mallinfo, this function returns only a precomputed
+ result, so can be called frequently to monitor memory consumption.
+ Even if locks are otherwise defined, this function does not use them,
+ so results might not be up to date.
+*/
+size_t dlmalloc_footprint(void);
- All together, these considerations should lead you to use mmap
- only for relatively large requests.
+/*
+ malloc_max_footprint();
+ Returns the maximum number of bytes obtained from the system. This
+ value will be greater than current footprint if deallocated space
+ has been reclaimed by the system. The peak number of bytes allocated
+ by malloc, realloc etc., is less than this value. Unlike mallinfo,
+ this function returns only a precomputed result, so can be called
+ frequently to monitor memory consumption. Even if locks are
+ otherwise defined, this function does not use them, so results might
+ not be up to date.
+*/
+size_t dlmalloc_max_footprint(void);
+#if !NO_MALLINFO
+/*
+ mallinfo()
+ Returns (by copy) a struct containing various summary statistics:
+
+ arena: current total non-mmapped bytes allocated from system
+ ordblks: the number of free chunks
+ smblks: always zero.
+ hblks: current number of mmapped regions
+ hblkhd: total bytes held in mmapped regions
+ usmblks: the maximum total allocated space. This will be greater
+ than current total if trimming has occurred.
+ fsmblks: always zero
+ uordblks: current total allocated space (normal or mmapped)
+ fordblks: total free space
+ keepcost: the maximum number of bytes that could ideally be released
+ back to system via malloc_trim. ("ideally" means that
+ it ignores page restrictions etc.)
+
+ Because these fields are ints, but internal bookkeeping may
+ be kept as longs, the reported values may wrap around zero and
+ thus be inaccurate.
+*/
+struct mallinfo dlmallinfo(void);
+#endif /* NO_MALLINFO */
+/*
+ independent_calloc(size_t n_elements, size_t element_size, void* chunks[]);
+
+ independent_calloc is similar to calloc, but instead of returning a
+ single cleared space, it returns an array of pointers to n_elements
+ independent elements that can hold contents of size elem_size, each
+ of which starts out cleared, and can be independently freed,
+ realloc'ed etc. The elements are guaranteed to be adjacently
+ allocated (this is not guaranteed to occur with multiple callocs or
+ mallocs), which may also improve cache locality in some
+ applications.
+
+ The "chunks" argument is optional (i.e., may be null, which is
+ probably the most typical usage). If it is null, the returned array
+ is itself dynamically allocated and should also be freed when it is
+ no longer needed. Otherwise, the chunks array must be of at least
+ n_elements in length. It is filled in with the pointers to the
+ chunks.
+
+ In either case, independent_calloc returns this pointer array, or
+ null if the allocation failed. If n_elements is zero and "chunks"
+ is null, it returns a chunk representing an array with zero elements
+ (which should be freed if not wanted).
+
+ Each element must be individually freed when it is no longer
+ needed. If you'd like to instead be able to free all at once, you
+ should instead use regular calloc and assign pointers into this
+ space to represent elements. (In this case though, you cannot
+ independently free elements.)
+
+ independent_calloc simplifies and speeds up implementations of many
+ kinds of pools. It may also be useful when constructing large data
+ structures that initially have a fixed number of fixed-sized nodes,
+ but the number is not known at compile time, and some of the nodes
+ may later need to be freed. For example:
+
+ struct Node { int item; struct Node* next; };
+
+ struct Node* build_list() {
+ struct Node** pool;
+ int n = read_number_of_nodes_needed();
+ if (n <= 0) return 0;
+ pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0);
+ if (pool == 0) die();
+ // organize into a linked list...
+ struct Node* first = pool[0];
+ for (i = 0; i < n-1; ++i)
+ pool[i]->next = pool[i+1];
+ free(pool); // Can now free the array (or not, if it is needed later)
+ return first;
+ }
*/
+void** dlindependent_calloc(size_t, size_t, void**);
+/*
+ independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]);
+
+ independent_comalloc allocates, all at once, a set of n_elements
+ chunks with sizes indicated in the "sizes" array. It returns
+ an array of pointers to these elements, each of which can be
+ independently freed, realloc'ed etc. The elements are guaranteed to
+ be adjacently allocated (this is not guaranteed to occur with
+ multiple callocs or mallocs), which may also improve cache locality
+ in some applications.
+
+ The "chunks" argument is optional (i.e., may be null). If it is null
+ the returned array is itself dynamically allocated and should also
+ be freed when it is no longer needed. Otherwise, the chunks array
+ must be of at least n_elements in length. It is filled in with the
+ pointers to the chunks.
+
+ In either case, independent_comalloc returns this pointer array, or
+ null if the allocation failed. If n_elements is zero and chunks is
+ null, it returns a chunk representing an array with zero elements
+ (which should be freed if not wanted).
+
+ Each element must be individually freed when it is no longer
+ needed. If you'd like to instead be able to free all at once, you
+ should instead use a single regular malloc, and assign pointers at
+ particular offsets in the aggregate space. (In this case though, you
+ cannot independently free elements.)
+
+ independent_comallac differs from independent_calloc in that each
+ element may have a different size, and also that it does not
+ automatically clear elements.
+
+ independent_comalloc can be used to speed up allocation in cases
+ where several structs or objects must always be allocated at the
+ same time. For example:
+
+ struct Head { ... }
+ struct Foot { ... }
+
+ void send_message(char* msg) {
+ int msglen = strlen(msg);
+ size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) };
+ void* chunks[3];
+ if (independent_comalloc(3, sizes, chunks) == 0)
+ die();
+ struct Head* head = (struct Head*)(chunks[0]);
+ char* body = (char*)(chunks[1]);
+ struct Foot* foot = (struct Foot*)(chunks[2]);
+ // ...
+ }
+
+ In general though, independent_comalloc is worth using only for
+ larger values of n_elements. For small values, you probably won't
+ detect enough difference from series of malloc calls to bother.
+
+ Overuse of independent_comalloc can increase overall memory usage,
+ since it cannot reuse existing noncontiguous small chunks that
+ might be available for some of the elements.
+*/
+void** dlindependent_comalloc(size_t, size_t*, void**);
-#ifndef DEFAULT_MMAP_MAX
-#if HAVE_MMAP
-#define DEFAULT_MMAP_MAX (64)
-#else
-#define DEFAULT_MMAP_MAX (0)
-#endif
-#endif
/*
- M_MMAP_MAX is the maximum number of requests to simultaneously
- service using mmap. This parameter exists because:
+ pvalloc(size_t n);
+ Equivalent to valloc(minimum-page-that-holds(n)), that is,
+ round up n to nearest pagesize.
+ */
+void* dlpvalloc(size_t);
- 1. Some systems have a limited number of internal tables for
- use by mmap.
- 2. In most systems, overreliance on mmap can degrade overall
- performance.
- 3. If a program allocates many large regions, it is probably
- better off using normal sbrk-based allocation routines that
- can reclaim and reallocate normal heap memory. Using a
- small value allows transition into this mode after the
- first few allocations.
+/*
+ malloc_trim(size_t pad);
- Setting to 0 disables all use of mmap. If HAVE_MMAP is not set,
- the default value is 0, and attempts to set it to non-zero values
- in mallopt will fail.
+ If possible, gives memory back to the system (via negative arguments
+ to sbrk) if there is unused memory at the `high' end of the malloc
+ pool or in unused MMAP segments. You can call this after freeing
+ large blocks of memory to potentially reduce the system-level memory
+ requirements of a program. However, it cannot guarantee to reduce
+ memory. Under some allocation patterns, some large free blocks of
+ memory will be locked between two used chunks, so they cannot be
+ given back to the system.
+
+ The `pad' argument to malloc_trim represents the amount of free
+ trailing space to leave untrimmed. If this argument is zero, only
+ the minimum amount of memory to maintain internal data structures
+ will be left. Non-zero arguments can be supplied to maintain enough
+ trailing space to service future expected allocations without having
+ to re-obtain memory from the system.
+
+ Malloc_trim returns 1 if it actually released any memory, else 0.
*/
-
+int dlmalloc_trim(size_t);
/*
- USE_DL_PREFIX will prefix all public routines with the string 'dl'.
- Useful to quickly avoid procedure declaration conflicts and linker
- symbol conflicts with existing memory allocation routines.
+ malloc_stats();
+ Prints on stderr the amount of space obtained from the system (both
+ via sbrk and mmap), the maximum amount (which may be more than
+ current if malloc_trim and/or munmap got called), and the current
+ number of bytes allocated via malloc (or realloc, etc) but not yet
+ freed. Note that this is the number of bytes allocated, not the
+ number requested. It will be larger than the number requested
+ because of alignment and bookkeeping overhead. Because it includes
+ alignment wastage as being in use, this figure may be greater than
+ zero even when no user-level chunks are allocated.
+
+ The reported current and maximum system memory can be inaccurate if
+ a program makes other calls to system memory allocation functions
+ (normally sbrk) outside of malloc.
+
+ malloc_stats prints only the most commonly interesting statistics.
+ More information can be obtained by calling mallinfo.
+*/
+void dlmalloc_stats(void);
+
+#endif /* ONLY_MSPACES */
+/*
+ malloc_usable_size(void* p);
+
+ Returns the number of bytes you can actually use in
+ an allocated chunk, which may be more than you requested (although
+ often not) due to alignment and minimum size constraints.
+ You can use this many bytes without worrying about
+ overwriting other allocated objects. This is not a particularly great
+ programming practice. malloc_usable_size can be more useful in
+ debugging and assertions, for example:
+
+ p = malloc(n);
+ assert(malloc_usable_size(p) >= 256);
*/
+size_t dlmalloc_usable_size(void*);
-/* #define USE_DL_PREFIX */
+#if MSPACES
+
+/*
+ mspace is an opaque type representing an independent
+ region of space that supports mspace_malloc, etc.
+*/
+typedef void* mspace;
/*
+ create_mspace creates and returns a new independent space with the
+ given initial capacity, or, if 0, the default granularity size. It
+ returns null if there is no system memory available to create the
+ space. If argument locked is non-zero, the space uses a separate
+ lock to control access. The capacity of the space will grow
+ dynamically as needed to service mspace_malloc requests. You can
+ control the sizes of incremental increases of this space by
+ compiling with a different DEFAULT_GRANULARITY or dynamically
+ setting with mallopt(M_GRANULARITY, value).
+*/
+mspace create_mspace(size_t capacity, int locked);
- Special defines for linux libc
+/*
+ destroy_mspace destroys the given space, and attempts to return all
+ of its memory back to the system, returning the total number of
+ bytes freed. After destruction, the results of access to all memory
+ used by the space become undefined.
+*/
+size_t destroy_mspace(mspace msp);
- Except when compiled using these special defines for Linux libc
- using weak aliases, this malloc is NOT designed to work in
- multithreaded applications. No semaphores or other concurrency
- control are provided to ensure that multiple malloc or free calls
- don't run at the same time, which could be disasterous. A single
- semaphore could be used across malloc, realloc, and free (which is
- essentially the effect of the linux weak alias approach). It would
- be hard to obtain finer granularity.
+/*
+ create_mspace_with_base uses the memory supplied as the initial base
+ of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this
+ space is used for bookkeeping, so the capacity must be at least this
+ large. (Otherwise 0 is returned.) When this initial space is
+ exhausted, additional memory will be obtained from the system.
+ Destroying this space will deallocate all additionally allocated
+ space (if possible) but not the initial base.
+*/
+mspace create_mspace_with_base(void* base, size_t capacity, int locked);
+/*
+ mspace_track_large_chunks controls whether requests for large chunks
+ are allocated in their own untracked mmapped regions, separate from
+ others in this mspace. By default large chunks are not tracked,
+ which reduces fragmentation. However, such chunks are not
+ necessarily released to the system upon destroy_mspace. Enabling
+ tracking by setting to true may increase fragmentation, but avoids
+ leakage when relying on destroy_mspace to release all memory
+ allocated using this space. The function returns the previous
+ setting.
*/
+int mspace_track_large_chunks(mspace msp, int enable);
-#ifdef INTERNAL_LINUX_C_LIB
+/*
+ mspace_malloc behaves as malloc, but operates within
+ the given space.
+*/
+void* mspace_malloc(mspace msp, size_t bytes);
-#if __STD_C
+/*
+ mspace_free behaves as free, but operates within
+ the given space.
-Void_t * __default_morecore_init (ptrdiff_t);
-Void_t *(*__morecore)(ptrdiff_t) = __default_morecore_init;
+ If compiled with FOOTERS==1, mspace_free is not actually needed.
+ free may be called instead of mspace_free because freed chunks from
+ any space are handled by their originating spaces.
+*/
+void mspace_free(mspace msp, void* mem);
-#else
+/*
+ mspace_realloc behaves as realloc, but operates within
+ the given space.
-Void_t * __default_morecore_init ();
-Void_t *(*__morecore)() = __default_morecore_init;
+ If compiled with FOOTERS==1, mspace_realloc is not actually
+ needed. realloc may be called instead of mspace_realloc because
+ realloced chunks from any space are handled by their originating
+ spaces.
+*/
+void* mspace_realloc(mspace msp, void* mem, size_t newsize);
-#endif
+/*
+ mspace_calloc behaves as calloc, but operates within
+ the given space.
+*/
+void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size);
-#define MORECORE (*__morecore)
-#define MORECORE_FAILURE 0
-#define MORECORE_CLEARS 1
+/*
+ mspace_memalign behaves as memalign, but operates within
+ the given space.
+*/
+void* mspace_memalign(mspace msp, size_t alignment, size_t bytes);
-#else /* INTERNAL_LINUX_C_LIB */
+/*
+ mspace_independent_calloc behaves as independent_calloc, but
+ operates within the given space.
+*/
+void** mspace_independent_calloc(mspace msp, size_t n_elements,
+ size_t elem_size, void* chunks[]);
-#if __STD_C
-extern Void_t* sbrk(ptrdiff_t);
-#else
-extern Void_t* sbrk();
-#endif
+/*
+ mspace_independent_comalloc behaves as independent_comalloc, but
+ operates within the given space.
+*/
+void** mspace_independent_comalloc(mspace msp, size_t n_elements,
+ size_t sizes[], void* chunks[]);
-#ifndef MORECORE
-#define MORECORE sbrk
-#endif
+/*
+ mspace_footprint() returns the number of bytes obtained from the
+ system for this space.
+*/
+size_t mspace_footprint(mspace msp);
-#ifndef MORECORE_FAILURE
-#define MORECORE_FAILURE -1
-#endif
+/*
+ mspace_max_footprint() returns the peak number of bytes obtained from the
+ system for this space.
+*/
+size_t mspace_max_footprint(mspace msp);
-#ifndef MORECORE_CLEARS
-#define MORECORE_CLEARS 1
-#endif
-#endif /* INTERNAL_LINUX_C_LIB */
-
-#if defined(INTERNAL_LINUX_C_LIB) && defined(__ELF__)
-
-#define cALLOc __libc_calloc
-#define fREe __libc_free
-#define mALLOc __libc_malloc
-#define mEMALIGn __libc_memalign
-#define rEALLOc __libc_realloc
-#define vALLOc __libc_valloc
-#define pvALLOc __libc_pvalloc
-#define mALLINFo __libc_mallinfo
-#define mALLOPt __libc_mallopt
-
-#pragma weak calloc = __libc_calloc
-#pragma weak free = __libc_free
-#pragma weak cfree = __libc_free
-#pragma weak malloc = __libc_malloc
-#pragma weak memalign = __libc_memalign
-#pragma weak realloc = __libc_realloc
-#pragma weak valloc = __libc_valloc
-#pragma weak pvalloc = __libc_pvalloc
-#pragma weak mallinfo = __libc_mallinfo
-#pragma weak mallopt = __libc_mallopt
+#if !NO_MALLINFO
+/*
+ mspace_mallinfo behaves as mallinfo, but reports properties of
+ the given space.
+*/
+struct mallinfo mspace_mallinfo(mspace msp);
+#endif /* NO_MALLINFO */
-#else
+/*
+ malloc_usable_size(void* p) behaves the same as malloc_usable_size;
+*/
+ size_t mspace_usable_size(void* mem);
-#ifdef USE_DL_PREFIX
-#define cALLOc dlcalloc
-#define fREe dlfree
-#define mALLOc dlmalloc
-#define mEMALIGn dlmemalign
-#define rEALLOc dlrealloc
-#define vALLOc dlvalloc
-#define pvALLOc dlpvalloc
-#define mALLINFo dlmallinfo
-#define mALLOPt dlmallopt
-#else /* USE_DL_PREFIX */
-#define cALLOc calloc
-#define fREe free
-#define mALLOc malloc
-#define mEMALIGn memalign
-#define rEALLOc realloc
-#define vALLOc valloc
-#define pvALLOc pvalloc
-#define mALLINFo mallinfo
-#define mALLOPt mallopt
-#endif /* USE_DL_PREFIX */
+/*
+ mspace_malloc_stats behaves as malloc_stats, but reports
+ properties of the given space.
+*/
+void mspace_malloc_stats(mspace msp);
-#endif
+/*
+ mspace_trim behaves as malloc_trim, but
+ operates within the given space.
+*/
+int mspace_trim(mspace msp, size_t pad);
-/* Public routines */
-
-#if __STD_C
-
-Void_t* mALLOc(size_t);
-void fREe(Void_t*);
-Void_t* rEALLOc(Void_t*, size_t);
-Void_t* mEMALIGn(size_t, size_t);
-Void_t* vALLOc(size_t);
-Void_t* pvALLOc(size_t);
-Void_t* cALLOc(size_t, size_t);
-void cfree(Void_t*);
-int malloc_trim(size_t);
-size_t malloc_usable_size(Void_t*);
-void malloc_stats(void);
-int mALLOPt(int, int);
-struct mallinfo mALLINFo(void);
-#else
-Void_t* mALLOc();
-void fREe();
-Void_t* rEALLOc();
-Void_t* mEMALIGn();
-Void_t* vALLOc();
-Void_t* pvALLOc();
-Void_t* cALLOc();
-void cfree();
-int malloc_trim();
-size_t malloc_usable_size();
-void malloc_stats();
-int mALLOPt();
-struct mallinfo mALLINFo();
-#endif
+/*
+ An alias for mallopt.
+*/
+int mspace_mallopt(int, int);
+#endif /* MSPACES */
#ifdef __cplusplus
}; /* end of extern "C" */
-#endif
+#endif /* __cplusplus */
+
+/*
+ ========================================================================
+ To make a fully customizable malloc.h header file, cut everything
+ above this line, put into file malloc.h, edit to suit, and #include it
+ on the next line, as well as in programs that use this malloc.
+ ========================================================================
+*/
+
+/* #include "malloc.h" */
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index 155171d..d03ad95 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -662,7 +662,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
cmd_tbl_t *cmdtp;
char *s;
bd_t *bd;
- extern void malloc_bin_reloc (void);
#ifndef CONFIG_ENV_IS_NOWHERE
extern char * env_name_spec;
#endif
@@ -777,7 +776,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
/* initialize malloc() area */
mem_malloc_init ();
- malloc_bin_reloc ();
#if !defined(CONFIG_SYS_NO_FLASH)
puts ("FLASH: ");
--
1.6.0.6
--- common/dlmalloc.src 2009-07-06 22:17:36.000000000 -0500
+++ common/dlmalloc.c 2009-07-07 11:23:46.000000000 -0500
@@ -1,3 +1,5 @@
+#include <common.h>
+
/*
This is a version (aka dlmalloc) of malloc/free/realloc written by
Doug Lea and released to the public domain, as explained at
@@ -480,6 +482,7 @@
improvement at the expense of carrying around more memory.
*/
+#if 0
/* Version identifier to allow people to support multiple versions */
#ifndef DLMALLOC_VERSION
#define DLMALLOC_VERSION 20804
@@ -1274,14 +1277,18 @@
*/
/* #include "malloc.h" */
+#else
+#include <malloc.h>
+#endif
/*------------------------------ internal #includes ---------------------- */
#ifdef WIN32
#pragma warning( disable : 4146 ) /* no "unsigned" warnings */
#endif /* WIN32 */
-
+#if 0
#include <stdio.h> /* for printing in malloc_stats */
+#endif
#ifndef LACKS_ERRNO_H
#include <errno.h> /* for MALLOC_FAILURE_ACTION */
@@ -3017,7 +3024,9 @@
#ifdef WIN32
magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U);
#else
- magic = (size_t)(time(0) ^ (size_t)0x55555555U);
+// magic = (size_t)(time(0) ^ (size_t)0x55555555U);
+ magic = (size_t)0x55555555U;
+
#endif
magic |= (size_t)8U; /* ensure nonzero */
magic &= ~(size_t)7U; /* improve chances of fault for bad values */
8
16

Re: [U-Boot] [PATCH] asm-generic: Consolidate errno.h to asm-generic/errno.h
by Mike Frysinger 08 Jul '09
by Mike Frysinger 08 Jul '09
08 Jul '09
On Wednesday 08 July 2009 03:52:03 Michal Simek wrote:
> Do you have any problem with this asm-generic/errno.h patch?
i thought i acked it already ... but if not, sounds fine to me
-mike
1
0
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu(a)nigauri.org>
---
MAKEALL | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/MAKEALL b/MAKEALL
index 41f1445..4f9fec1 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -848,6 +848,7 @@ LIST_sh4=" \
sh7763rdp \
sh7785lcr \
ap325rxa \
+ espt
"
LIST_sh=" \
--
1.6.3.3
2
1
Hi,
I'm trying to use the sprintf function in a C program written for
U-boot. As far as I understand, to get the function I have to add it to
the exports.h, _exports.h and exports.c file as per the
README.Standalone file in /doc (the function is declared in common.h).
Now if I do this, the program compiles fine, and all is dandy, until I
actually start using the function. It generates garbage. printf and
alike works fine, and the program runs like it should, except the places
where sprintf is used, I get garbage (meaning some environment variables
are looking pretty nasty since the result of the sprintf functions are
used for these).
When compiling I link to the examples/libstubs.a file and
lib_generic/libgeneric.a where the code I'm using should be present.
Can anyone give me a clue to what the problem could be or if I
misunderstood the concept completely?
I searched the lists and in my frustration I tried to use some code from
an earlier post where some guy had problems with sprintf. Here Wolfgang
Denk wrote a small piece of code that used the function, and this was
what I then put in my own code, just to see if I could get *anything*
working with sprintf. The code I used was this:
...
unsigned char buf[128];
unsigned char a[6] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, };
int i;
...
printf ("Before: "); for (i=0; i<6; ++i) printf (" %02X",a[i]); putc
('\n');
sprintf (buf, "%02X:%02X:%02X:%02X:%02X:%02X", a[0], a[1], a[2], a[3],
a[4], a[5]);
printf ("After: "); for (i=0; i<6; ++i) printf (" %02X",a[i]); putc
('\n');
printf ("buf=\"%s\"\n", buf);
...
When I do this, the line that defines the a[6] thing generates a
compiler error stating an undefined reference to memcpy. Since this
error is present every time I try to initialize a string (char*) or char
array I'm guessing this might be the problem, but I'm not sure...
The platform is ARM (AT91RM9200)... U-boot version is 2009.06.
I'm new to standalone programming for U-boot so this might surely be the
problem, so any help is appreciated :)
Kind regards,
Martin Hejnfelt
2
1