From 5c93f03c0747ab78c887283e32e190969aa729bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20K=C3=B6ken?= Date: Sat, 28 Jun 2014 23:24:25 +0300 Subject: [PATCH 1/6] Update boot.h a few types definition and basic i/o port change --- arch/x86/boot/boot.h | 49 +++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h index 50f8c5e0f37e1d..3ed072b9c1f6c5 100644 --- a/arch/x86/boot/boot.h +++ b/arch/x86/boot/boot.h @@ -39,43 +39,54 @@ extern struct boot_params boot_params; #define cpu_relax() asm volatile("rep; nop") + +/* + * unsigned short-u16 port_t + * perhaps, be defined in linux/types.h + */ +typedef u16 port_t; +typedef u8 byte_t; +typedef u16 word_t; +typedef u32 dword_t; + + /* Basic port I/O */ -static inline void outb(u8 v, u16 port) +static inline void outb(byte_t value, port_t port) { - asm volatile("outb %0,%1" : : "a" (v), "dN" (port)); + asm volatile("outb %0,%1" : : "a" (value), "dN" (port)); } -static inline u8 inb(u16 port) +static inline byte_t inb(port_t port) { - u8 v; - asm volatile("inb %1,%0" : "=a" (v) : "dN" (port)); - return v; + byte_t ret_val; + asm volatile("inb %1,%0" : "=a" (ret_val) : "dN" (port)); + return ret_val; } -static inline void outw(u16 v, u16 port) +static inline void outw(word_t value, port_t port) { - asm volatile("outw %0,%1" : : "a" (v), "dN" (port)); + asm volatile("outw %0,%1" : : "a" (value), "dN" (port)); } -static inline u16 inw(u16 port) +static inline word_t inw(port_t port) { - u16 v; - asm volatile("inw %1,%0" : "=a" (v) : "dN" (port)); - return v; + word_t ret_val; + asm volatile("inw %1,%0" : "=a" (ret_val) : "dN" (port)); + return ret_val; } -static inline void outl(u32 v, u16 port) +static inline void outl(dword_t value, port_t port) { - asm volatile("outl %0,%1" : : "a" (v), "dN" (port)); + asm volatile("outl %0,%1" : : "a" (value), "dN" (port)); } -static inline u32 inl(u16 port) +static inline dword_t inl(port_t port) { - u32 v; - asm volatile("inl %1,%0" : "=a" (v) : "dN" (port)); - return v; + dword ret_val; + asm volatile("inl %1,%0" : "=a" (ret_val) : "dN" (port)); + return ret_val; } static inline void io_delay(void) { - const u16 DELAY_PORT = 0x80; + const port_t DELAY_PORT = 0x80; asm volatile("outb %%al,%0" : : "dN" (DELAY_PORT)); } From 68171eedd00348756a85e964831f2574563de657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20K=C3=B6ken?= Date: Sun, 29 Jun 2014 00:06:21 +0300 Subject: [PATCH 2/6] Bit Macros Get & set bit macro definitions --- include/linux/bit.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 include/linux/bit.h diff --git a/include/linux/bit.h b/include/linux/bit.h new file mode 100644 index 00000000000000..12dfbbc1c73a4c --- /dev/null +++ b/include/linux/bit.h @@ -0,0 +1,35 @@ +/* + * + * Copyright (C) 2014 Burak Köken + * + * Get & set bits + * + */ + +#ifndef __LINUX_BITS_H__ +#define __LINUX_BITS_H__ + +#include + +/* get bit */ +#define getbit8_high(x) x >> 4 +#define getbit8_low(x) x & 0x0f + +#define getbit16_high(x) x >> 8 +#define getbit16_low(x) x & 0xff + +#define getbit32_high(x) x >> 16 +#define getbit32_low(x) x & 0xffff + +#define getbit64_high(x) x >> 32 +#define getbit64_low(x) x & 0xffffffff + +/* set bit */ +#define setbit8(high_4bit,low_4bit) ((u8) high_4bit << 4 | low_4bit) +#define setbit16(high_8bit,low_8bit) ((u16) high_8bit << 8 | low_8bit) +#define setbit32(high_16bit,low_16bit) ((u32) high_16bit << 16 | low_16bit) +#define setbit64(high_32bit,low_32bit) ((u64) high_32bit << 32 | low_32bit) + + + +#endif /* __LINUX_BITS_H__ */ From 06f2b5433534c17bf88360eaf59e406a6771f6d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20K=C3=B6ken?= Date: Sun, 29 Jun 2014 00:13:20 +0300 Subject: [PATCH 3/6] Update bit.h edit & add comments --- include/linux/bit.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/linux/bit.h b/include/linux/bit.h index 12dfbbc1c73a4c..398407bb8b624a 100644 --- a/include/linux/bit.h +++ b/include/linux/bit.h @@ -1,13 +1,18 @@ /* * - * Copyright (C) 2014 Burak Köken + * Copyright (C) 2014 Burak Köken - colcsky@gmail.com * - * Get & set bits + * Get & set bit macro + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. * */ -#ifndef __LINUX_BITS_H__ -#define __LINUX_BITS_H__ +#ifndef __LINUX_BIT_H__ +#define __LINUX_BIT_H__ #include @@ -32,4 +37,4 @@ -#endif /* __LINUX_BITS_H__ */ +#endif /* __LINUX_BIT_H__ */ From 5b72db0149a700ff68f6f5492acc62460d6a1d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20K=C3=B6ken?= Date: Mon, 30 Jun 2014 23:31:59 +0300 Subject: [PATCH 4/6] a few crc32 defines crc32 defines & endian select function prototype extern u32 crc32_sel(u32 crc,unsigned char const *p,size_t len,u8 endian_type); --- include/linux/crc32.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/linux/crc32.h b/include/linux/crc32.h index 7d275c4fc01108..22ca2cf54d874a 100644 --- a/include/linux/crc32.h +++ b/include/linux/crc32.h @@ -8,9 +8,28 @@ #include #include +#ifndef __CRC32DEFS +#define __CRC32DEFS +#define CRCBIG_ENDIAN (1) +#define CRCLITTLE_ENDIAN (0) + +#define CRCPOLY32_BIGEND 0x04C11DB7 /* big endian poly. */ +#define CRCPOLY32_LITEND 0xEDB88320 /* little endian poly.*/ +#define CRCPOLY32_TENTRY 256 /* crc32 table entries */ +#endif + extern u32 crc32_le(u32 crc, unsigned char const *p, size_t len); extern u32 crc32_be(u32 crc, unsigned char const *p, size_t len); +/* + * crc32 endian select + * + * endian type : CRCBIG_ENDIAN , CRCLITTLE_ENDIAN + * + */ +extern u32 crc32_sel(u32 crc,unsigned char const *p,size_t len,u8 endian_type); + + /** * crc32_le_combine - Combine two crc32 check values into one. For two * sequences of bytes, seq1 and seq2 with lengths len1 From 6ea5393b4913e76d6709948993c28b6df7264159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20K=C3=B6ken?= Date: Mon, 30 Jun 2014 23:32:51 +0300 Subject: [PATCH 5/6] crc32_sel(...) crc32_sel(u32 crc,unsigned char const *p,size_t len,u8 endian_type); function --- lib/crc32.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/crc32.c b/lib/crc32.c index 70f00ca5ef1e8f..6bbfe0de1793c8 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -155,6 +155,20 @@ crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256]) } #endif +/* + * crc32 select endian + * + */ + +u32 crc32_sel(u32 crc,unsigned char const *p,size_t len,u8 endian_type){ + + /* + * (endian_type) ? big endian : little endian + */ + return (endian_type) ? crc32_be(crc,p,len) : crc_le(crc,p,len); + +} + /* For conditions of distribution and use, see copyright notice in zlib.h */ static u32 crc32_generic_combine(u32 crc1, u32 crc2, size_t len2, u32 polynomial) From 0131d367fa05d8bf72f2c34140ce64a9b98b5278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20K=C3=B6ken?= Date: Mon, 30 Jun 2014 23:38:07 +0300 Subject: [PATCH 6/6] Update crc32.h changed a definition name --- include/linux/crc32.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/crc32.h b/include/linux/crc32.h index 22ca2cf54d874a..d0058a1cf25a8d 100644 --- a/include/linux/crc32.h +++ b/include/linux/crc32.h @@ -15,7 +15,7 @@ #define CRCPOLY32_BIGEND 0x04C11DB7 /* big endian poly. */ #define CRCPOLY32_LITEND 0xEDB88320 /* little endian poly.*/ -#define CRCPOLY32_TENTRY 256 /* crc32 table entries */ +#define CRC_TENTRY 256 /* crc32 table entries */ #endif extern u32 crc32_le(u32 crc, unsigned char const *p, size_t len);