diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/common.h | 23 | ||||
-rw-r--r-- | include/complete.h | 2 | ||||
-rw-r--r-- | include/cramfs/cramfs_fs.h | 8 | ||||
-rw-r--r-- | include/dma.h | 30 | ||||
-rw-r--r-- | include/driver.h | 28 | ||||
-rw-r--r-- | include/envfs.h | 22 | ||||
-rw-r--r-- | include/fs.h | 12 | ||||
-rw-r--r-- | include/linux/byteorder/generic.h | 7 | ||||
-rw-r--r-- | include/linux/stat.h | 2 | ||||
-rw-r--r-- | include/partition.h | 2 | ||||
-rw-r--r-- | include/usb/usb.h | 9 |
11 files changed, 100 insertions, 45 deletions
diff --git a/include/common.h b/include/common.h index d2347f8629..c7707bae50 100644 --- a/include/common.h +++ b/include/common.h @@ -34,6 +34,24 @@ #include <linux/stddef.h> #include <asm/common.h> +/* + * sanity check. The Linux Kernel defines only one of __LITTLE_ENDIAN and + * __BIG_ENDIAN. Endianess can then be tested with #ifdef __xx_ENDIAN. Userspace + * always defined both __LITTLE_ENDIAN and __BIG_ENDIAN and byteorder can then + * be tested with #if __BYTE_ORDER == __xx_ENDIAN. + * + * As we tend to use a lot of Kernel code in barebox we use the kernel way of + * determing the byte order. Make sure here that architecture code properly + * defines it. + */ +#include <asm/byteorder.h> +#if defined __LITTLE_ENDIAN && defined __BIG_ENDIAN +#error "both __LITTLE_ENDIAN and __BIG_ENDIAN are defined" +#endif +#if !defined __LITTLE_ENDIAN && !defined __BIG_ENDIAN +#error "None of __LITTLE_ENDIAN and __BIG_ENDIAN are defined" +#endif + #define pr_info(fmt, arg...) printf(fmt, ##arg) #define pr_notice(fmt, arg...) printf(fmt, ##arg) #define pr_err(fmt, arg...) printf(fmt, ##arg) @@ -138,10 +156,11 @@ struct memarea_info { unsigned long flags; }; -int parse_area_spec(const char *str, ulong *start, ulong *size); +int parse_area_spec(const char *str, loff_t *start, loff_t *size); /* Just like simple_strtoul(), but this one honors a K/M/G suffix */ unsigned long strtoul_suffix(const char *str, char **endp, int base); +unsigned long long strtoull_suffix(const char *str, char **endp, int base); void start_barebox(void); void shutdown_barebox(void); @@ -210,7 +229,7 @@ int run_shell(void); #define PAGE_SIZE 4096 #define PAGE_SHIFT 12 -int memory_display(char *addr, ulong offs, ulong nbytes, int size); +int memory_display(char *addr, loff_t offs, ulong nbytes, int size); extern const char version_string[]; #ifdef CONFIG_BANNER diff --git a/include/complete.h b/include/complete.h index 8248c64d0c..33b848c91e 100644 --- a/include/complete.h +++ b/include/complete.h @@ -15,7 +15,7 @@ int command_complete(struct string_list *sl, char *instr); int device_complete(struct string_list *sl, char *instr); int empty_complete(struct string_list *sl, char *instr); int eth_complete(struct string_list *sl, char *instr); -int cammand_var_complete(struct string_list *sl, char *instr); +int command_var_complete(struct string_list *sl, char *instr); int devfs_partition_complete(struct string_list *sl, char *instr); #endif /* __COMPLETE_ */ diff --git a/include/cramfs/cramfs_fs.h b/include/cramfs/cramfs_fs.h index af2940be05..8c53fc737d 100644 --- a/include/cramfs/cramfs_fs.h +++ b/include/cramfs/cramfs_fs.h @@ -84,11 +84,7 @@ struct cramfs_super { | CRAMFS_FLAG_WRONG_SIGNATURE \ | CRAMFS_FLAG_SHIFTED_ROOT_OFFSET ) -#ifndef __BYTE_ORDER -#error "No byte order defined in __BYTE_ORDER" -#endif - -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN #define CRAMFS_16(x) (x) #define CRAMFS_24(x) (x) #define CRAMFS_32(x) (x) @@ -96,7 +92,7 @@ struct cramfs_super { #define CRAMFS_GET_OFFSET(x) ((x)->offset) #define CRAMFS_SET_OFFSET(x,y) ((x)->offset = (y)) #define CRAMFS_SET_NAMELEN(x,y) ((x)->namelen = (y)) -#elif __BYTE_ORDER ==__BIG_ENDIAN +#elif defined __BIG_ENDIAN #ifdef __KERNEL__ #define CRAMFS_16(x) swab16(x) #define CRAMFS_24(x) ((swab32(x)) >> 8) diff --git a/include/dma.h b/include/dma.h new file mode 100644 index 0000000000..899f831faa --- /dev/null +++ b/include/dma.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2012 by Marc Kleine-Budde <mkl@pengutronix.de> + * + * This file is released under the GPLv2 + * + */ + +#ifndef __DMA_H +#define __DMA_H + +#include <malloc.h> +#include <xfuncs.h> + +#include <asm/dma.h> + +#ifndef dma_alloc +static inline void *dma_alloc(size_t size) +{ + return xmalloc(size); +} +#endif + +#ifndef dma_free +static inline void dma_free(void *mem) +{ + free(mem); +} +#endif + +#endif /* __DMA_H */ diff --git a/include/driver.h b/include/driver.h index 470ae2d5f8..a5e3f44212 100644 --- a/include/driver.h +++ b/include/driver.h @@ -301,8 +301,8 @@ struct cdev; int dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot); /* These are used by drivers which work with direct memory accesses */ -ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags); -ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags); +ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags); +ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags); int mem_memmap(struct cdev *cdev, void **map, int flags); /* Use this if you have nothing to do in your drivers probe function */ @@ -316,7 +316,7 @@ void devices_shutdown(void); int generic_memmap_ro(struct cdev *dev, void **map, int flags); int generic_memmap_rw(struct cdev *dev, void **map, int flags); -static inline off_t dev_lseek_default(struct cdev *cdev, off_t ofs) +static inline loff_t dev_lseek_default(struct cdev *cdev, loff_t ofs) { return ofs; } @@ -373,18 +373,18 @@ extern struct bus_type platform_bus; struct file_operations { /*! Called in response of reading from this device. Required */ - ssize_t (*read)(struct cdev*, void* buf, size_t count, ulong offset, ulong flags); + ssize_t (*read)(struct cdev*, void* buf, size_t count, loff_t offset, ulong flags); /*! Called in response of write to this device. Required */ - ssize_t (*write)(struct cdev*, const void* buf, size_t count, ulong offset, ulong flags); + ssize_t (*write)(struct cdev*, const void* buf, size_t count, loff_t offset, ulong flags); int (*ioctl)(struct cdev*, int, void *); - off_t (*lseek)(struct cdev*, off_t); + loff_t (*lseek)(struct cdev*, loff_t); int (*open)(struct cdev*, unsigned long flags); int (*close)(struct cdev*); int (*flush)(struct cdev*); - int (*erase)(struct cdev*, size_t count, unsigned long offset); - int (*protect)(struct cdev*, size_t count, unsigned long offset, int prot); + int (*erase)(struct cdev*, size_t count, loff_t offset); + int (*protect)(struct cdev*, size_t count, loff_t offset, int prot); int (*memmap)(struct cdev*, void **map, int flags); }; @@ -395,8 +395,8 @@ struct cdev { struct list_head list; struct list_head devices_list; char *name; - unsigned long offset; - size_t size; + loff_t offset; + loff_t size; unsigned int flags; int open; struct mtd_info *mtd; @@ -409,16 +409,16 @@ struct cdev *cdev_by_name(const char *filename); struct cdev *cdev_open(const char *name, unsigned long flags); void cdev_close(struct cdev *cdev); int cdev_flush(struct cdev *cdev); -ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags); -ssize_t cdev_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags); +ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags); +ssize_t cdev_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags); int cdev_ioctl(struct cdev *cdev, int cmd, void *buf); -int cdev_erase(struct cdev *cdev, size_t count, unsigned long offset); +int cdev_erase(struct cdev *cdev, size_t count, loff_t offset); #define DEVFS_PARTITION_FIXED (1 << 0) #define DEVFS_PARTITION_READONLY (1 << 1) #define DEVFS_IS_PARTITION (1 << 2) -int devfs_add_partition(const char *devname, unsigned long offset, size_t size, +int devfs_add_partition(const char *devname, loff_t offset, loff_t size, int flags, const char *name); int devfs_del_partition(const char *name); diff --git a/include/envfs.h b/include/envfs.h index 67b890222c..ba976d6d13 100644 --- a/include/envfs.h +++ b/include/envfs.h @@ -34,11 +34,25 @@ struct envfs_super { uint32_t sb_crc; /* crc for the superblock */ }; -#ifndef __BYTE_ORDER -#error "No byte order defined in __BYTE_ORDER" +#ifdef __BAREBOX__ +# ifdef __LITTLE_ENDIAN +# define ENVFS_ORDER_LITTLE +# elif defined __BIG_ENDIAN +# define ENVFS_ORDER_BIG +# else +# error "could not determine byte order" +# endif +#else +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define ENVFS_ORDER_LITTLE +# elif __BYTE_ORDER == __BIG_ENDIAN +# define ENVFS_ORDER_BIG +# else +# error "could not determine byte order" +# endif #endif -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifdef ENVFS_ORDER_LITTLE #define ENVFS_16(x) (x) #define ENVFS_24(x) (x) #define ENVFS_32(x) (x) @@ -46,7 +60,7 @@ struct envfs_super { #define ENVFS_GET_OFFSET(x) ((x)->offset) #define ENVFS_SET_OFFSET(x,y) ((x)->offset = (y)) #define ENVFS_SET_NAMELEN(x,y) ((x)->namelen = (y)) -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif defined ENVFS_ORDER_BIG #ifdef __KERNEL__ #define ENVFS_16(x) swab16(x) #define ENVFS_24(x) ((swab32(x)) >> 8) diff --git a/include/fs.h b/include/fs.h index d82f02626a..2b1023e453 100644 --- a/include/fs.h +++ b/include/fs.h @@ -23,8 +23,8 @@ typedef struct dir { typedef struct filep { struct device_d *dev; /* The device this FILE belongs to */ - ulong pos; /* current position in stream */ - ulong size; /* The size of this inode */ + loff_t pos; /* current position in stream */ + loff_t size; /* The size of this inode */ ulong flags; /* the O_* flags from open */ void *inode; /* private to the filesystem driver */ @@ -54,7 +54,7 @@ struct fs_driver_d { int (*read)(struct device_d *dev, FILE *f, void *buf, size_t size); int (*write)(struct device_d *dev, FILE *f, const void *buf, size_t size); int (*flush)(struct device_d *dev, FILE *f); - off_t (*lseek)(struct device_d *dev, FILE *f, off_t pos); + loff_t (*lseek)(struct device_d *dev, FILE *f, loff_t pos); struct dir* (*opendir)(struct device_d *dev, const char *pathname); struct dirent* (*readdir)(struct device_d *dev, struct dir *dir); @@ -63,9 +63,9 @@ struct fs_driver_d { int (*ioctl)(struct device_d *dev, FILE *f, int request, void *buf); int (*erase)(struct device_d *dev, FILE *f, size_t count, - unsigned long offset); + loff_t offset); int (*protect)(struct device_d *dev, FILE *f, size_t count, - unsigned long offset, int prot); + loff_t offset, int prot); int (*memmap)(struct device_d *dev, FILE *f, void **map, int flags); @@ -109,7 +109,7 @@ ssize_t write(int fd, const void *buf, size_t count); #define SEEK_CUR 2 #define SEEK_END 3 -off_t lseek(int fildes, off_t offset, int whence); +loff_t lseek(int fildes, loff_t offset, int whence); int mkdir (const char *pathname, mode_t mode); /* Create a directory and its parents */ diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h index aab8f4b6bf..2d68d99fa4 100644 --- a/include/linux/byteorder/generic.h +++ b/include/linux/byteorder/generic.h @@ -78,13 +78,6 @@ * */ -#ifndef __LITTLE_ENDIAN -#define __LITTLE_ENDIAN 1234 -#endif -#ifndef __BIG_ENDIAN -#define __BIG_ENDIAN 4321 -#endif - #if defined(__KERNEL__) /* * inside the kernel, we can use nicknames; diff --git a/include/linux/stat.h b/include/linux/stat.h index bc7dce4508..af022c5c79 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -52,7 +52,7 @@ struct stat { unsigned short st_gid; unsigned short st_rdev; unsigned short __pad2; - unsigned long st_size; + loff_t st_size; unsigned long st_blksize; unsigned long st_blocks; unsigned long st_atime; diff --git a/include/partition.h b/include/partition.h index 0827bb40c6..8ad7490d85 100644 --- a/include/partition.h +++ b/include/partition.h @@ -8,7 +8,7 @@ struct partition { int flags; - unsigned long offset; + loff_t offset; struct device_d *physdev; struct device_d device; diff --git a/include/usb/usb.h b/include/usb/usb.h index 296e4e8ea8..19b092ea65 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -159,8 +159,9 @@ struct usb_device { int epmaxpacketout[16]; /* OUTput endpoint specific maximums */ int configno; /* selected config number */ - struct usb_device_descriptor descriptor; /* Device Descriptor */ + struct usb_device_descriptor *descriptor; /* Device Descriptor */ struct usb_config_descriptor config; /* config descriptor */ + struct devrequest *setup_packet; int have_langid; /* whether string_langid is valid yet */ int string_langid; /* language ID for strings */ @@ -270,12 +271,14 @@ void usb_rescan(void); ((x_ & 0xFF000000UL) >> 24)); \ }) -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN # define swap_16(x) (x) # define swap_32(x) (x) -#else +#elif defined BIG_ENDIAN # define swap_16(x) __swap_16(x) # define swap_32(x) __swap_32(x) +#else +#error "could not determine byte order" #endif /* |