Skip to content

Commit

Permalink
fix typedef
Browse files Browse the repository at this point in the history
  • Loading branch information
chenall committed Aug 19, 2014
1 parent 2820540 commit 5087499
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 76 deletions.
8 changes: 4 additions & 4 deletions stage2/char_io.c
Expand Up @@ -1683,7 +1683,7 @@ grub_isspace (int c)
return 0;
}

static uint32_t crc32_tab[256] = {
static grub_u32_t crc32_tab[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
Expand Down Expand Up @@ -1718,9 +1718,9 @@ static uint32_t crc32_tab[256] = {
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};

static uint32_t calc_crc32(uint32_t crc, const void *data, uint32_t size)
static grub_u32_t calc_crc32(grub_u32_t crc, const void *data, grub_u32_t size)
{
const uint8_t *p;
const grub_u8_t *p;

p = data;
crc ^= ~0U;
Expand All @@ -1730,7 +1730,7 @@ static uint32_t calc_crc32(uint32_t crc, const void *data, uint32_t size)
return crc^~0U;
}

int grub_crc32(char *data,uint32_t size)
int grub_crc32(char *data,grub_u32_t size)
{
int crc = 0;
int len = 0;
Expand Down
4 changes: 2 additions & 2 deletions stage2/fsys_pxe.c
Expand Up @@ -101,9 +101,9 @@ unsigned short pxe_basemem, pxe_freemem;
unsigned long pxe_keep;

//IP4 pxe_yip, pxe_sip, pxe_gip;
UINT8 pxe_mac_len, pxe_mac_type;
grub_u8_t pxe_mac_len, pxe_mac_type;
MAC_ADDR pxe_mac;
static UINT8 pxe_tftp_opened;
static grub_u8_t pxe_tftp_opened;
static unsigned long pxe_saved_pos, pxe_cur_ofs, pxe_read_ofs;

extern PXENV_TFTP_OPEN_t pxe_tftp_open; /* now it is defined in asm.S */
Expand Down
60 changes: 30 additions & 30 deletions stage2/pxe.h
Expand Up @@ -152,24 +152,24 @@
//#define PXE_ERR_LEN 0xFFFFFFFF
#define PXE_ERR_LEN 0

typedef UINT16 PXENV_STATUS;
typedef UINT32 SEGOFS16;
typedef UINT32 IP4;
typedef UINT16 UDP_PORT;
typedef grub_u16_t PXENV_STATUS;
typedef grub_u32_t SEGOFS16;
typedef grub_u32_t IP4;
typedef grub_u16_t UDP_PORT;

#define MAC_ADDR_LEN 16
typedef UINT8 MAC_ADDR[MAC_ADDR_LEN];
typedef grub_u8_t MAC_ADDR[MAC_ADDR_LEN];

#define PXENV_PACKET_TYPE_DHCP_DISCOVER 1
#define PXENV_PACKET_TYPE_DHCP_ACK 2
#define PXENV_PACKET_TYPE_CACHED_REPLY 3

typedef struct {
PXENV_STATUS Status;
UINT16 PacketType;
UINT16 BufferSize;
grub_u16_t PacketType;
grub_u16_t BufferSize;
SEGOFS16 Buffer;
UINT16 BufferLimit;
grub_u16_t BufferLimit;
} PACKED PXENV_GET_CACHED_INFO_t;

#define BOOTP_REQ 1
Expand All @@ -188,26 +188,26 @@ typedef struct {
#endif

typedef struct {
UINT8 opcode;
UINT8 Hardware; /* hardware type */
UINT8 Hardlen; /* hardware addr len */
UINT8 Gatehops; /* zero it */
UINT32 ident; /* random number chosen by client */
UINT16 seconds; /* seconds since did initial bootstrap */
UINT16 Flags; /* seconds since did initial bootstrap */
grub_u8_t opcode;
grub_u8_t Hardware; /* hardware type */
grub_u8_t Hardlen; /* hardware addr len */
grub_u8_t Gatehops; /* zero it */
grub_u32_t ident; /* random number chosen by client */
grub_u16_t seconds; /* seconds since did initial bootstrap */
grub_u16_t Flags; /* seconds since did initial bootstrap */
IP4 cip; /* Client IP */
IP4 yip; /* Your IP */
IP4 sip; /* IP to use for next boot stage */
IP4 gip; /* Relay IP ? */
MAC_ADDR CAddr; /* Client hardware address */
UINT8 Sname[64]; /* Server's hostname (Optional) */
UINT8 bootfile[128]; /* boot filename */
grub_u8_t Sname[64]; /* Server's hostname (Optional) */
grub_u8_t bootfile[128]; /* boot filename */
union {
UINT8 d[BOOTP_DHCPVEND]; /* raw array of vendor/dhcp options */
grub_u8_t d[BOOTP_DHCPVEND]; /* raw array of vendor/dhcp options */
struct {
UINT8 magic[4]; /* DHCP magic cookie */
UINT32 flags; /* bootp flags/opcodes */
UINT8 pad[56];
grub_u8_t magic[4]; /* DHCP magic cookie */
grub_u32_t flags; /* bootp flags/opcodes */
grub_u8_t pad[56];
} v;
} vendor;
} PACKED BOOTPLAYER;
Expand All @@ -216,9 +216,9 @@ typedef struct {
PXENV_STATUS Status;
IP4 ServerIPAddress;
IP4 GatewayIPAddress;
UINT8 FileName[128];
grub_u8_t FileName[128];
UDP_PORT TFTPPort;
UINT16 PacketSize;
grub_u16_t PacketSize;
} PACKED PXENV_TFTP_OPEN_t;

typedef struct {
Expand All @@ -227,17 +227,17 @@ typedef struct {

typedef struct {
PXENV_STATUS Status;
UINT16 PacketNumber;
UINT16 BufferSize;
grub_u16_t PacketNumber;
grub_u16_t BufferSize;
SEGOFS16 Buffer;
} PACKED PXENV_TFTP_READ_t;

typedef struct {
PXENV_STATUS Status;
IP4 ServerIPAddress;
IP4 GatewayIPAddress;
UINT8 FileName[128];
UINT32 FileSize;
grub_u8_t FileName[128];
grub_u32_t FileSize;
} PACKED PXENV_TFTP_GET_FSIZE_t;

typedef struct {
Expand All @@ -255,7 +255,7 @@ typedef struct {
IP4 gw;
UDP_PORT src_port;
UDP_PORT dst_port;
UINT16 buffer_size;
grub_u16_t buffer_size;
SEGOFS16 buffer;
} PACKED PXENV_UDP_WRITE_t;

Expand All @@ -265,13 +265,13 @@ typedef struct {
IP4 dst_ip;
UDP_PORT src_port;
UDP_PORT dst_port;
UINT16 buffer_size;
grub_u16_t buffer_size;
SEGOFS16 buffer;
} PACKED PXENV_UDP_READ_t;

typedef struct {
PXENV_STATUS Status;
UINT8 reserved[10];
grub_u8_t reserved[10];
} PACKED PXENV_UNLOAD_STACK_t;

#undef PACKED
Expand Down
72 changes: 32 additions & 40 deletions stage2/shared.h
Expand Up @@ -437,22 +437,14 @@

#ifndef ASM_FILE

typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef unsigned long long UINT64;
typedef signed char INT8;
typedef short INT16;
typedef int INT32;
typedef long long INT64;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char grub_u8_t;
typedef unsigned short grub_u16_t;
typedef unsigned int grub_u32_t;
typedef unsigned long long grub_u64_t;
typedef signed char grub_s8_t;
typedef short grub_s16_t;
typedef int grub_s32_t;
typedef long long grub_s64_t;
#define PACKED __attribute__ ((packed))

/*
Expand Down Expand Up @@ -1254,7 +1246,7 @@ int grub_strncat (char *s1, const char *s2, int n);
char *grub_strstr (const char *s1, const char *s2);
char *grub_strtok (char *s, const char *delim);
int grub_memcmp (const char *s1, const char *s2, int n);
int grub_crc32(char *data,uint32_t size);
int grub_crc32(char *data,grub_u32_t size);
int grub_strcmp (const char *s1, const char *s2);
int strncmpx(const char *s1,const char *s2, unsigned long n, int case_insensitive);
#define strncmp(s1,s2,n) strncmpx(s1,s2,n,0)
Expand Down Expand Up @@ -1510,9 +1502,9 @@ typedef struct {
union {
char raw[GUID_SIZE];
struct {
UINT32 time_low;
UINT16 time_mid;
UINT16 time_high_and_version;
grub_u32_t time_low;
grub_u16_t time_mid;
grub_u16_t time_high_and_version;
char clock_seq_high_and_reserved;
char clock_seq_low;
char node[UUID_NODE_LEN];
Expand All @@ -1523,33 +1515,33 @@ typedef struct {
//GPT_HDR_SIG "EFI PART"
#define GPT_HDR_SIG 0x5452415020494645LL
typedef struct {
UINT64 hdr_sig;
UINT32 hdr_revision;
UINT32 hdr_size;
UINT32 hdr_crc_self;
UINT32 __reserved;
UINT64 hdr_lba_self;
UINT64 hdr_lba_alt;
UINT64 hdr_lba_start;
UINT64 hdr_lba_end;
grub_u64_t hdr_sig;
grub_u32_t hdr_revision;
grub_u32_t hdr_size;
grub_u32_t hdr_crc_self;
grub_u32_t __reserved;
grub_u64_t hdr_lba_self;
grub_u64_t hdr_lba_alt;
grub_u64_t hdr_lba_start;
grub_u64_t hdr_lba_end;
GUID hdr_uuid;
UINT64 hdr_lba_table;
UINT32 hdr_entries;
UINT32 hdr_entsz;
UINT32 hdr_crc_table;
UINT32 padding;
grub_u64_t hdr_lba_table;
grub_u32_t hdr_entries;
grub_u32_t hdr_entsz;
grub_u32_t hdr_crc_table;
grub_u32_t padding;
} PACKED GPT_HDR;

typedef struct {
GUID type;
GUID uid;
UINT64 starting_lba;
UINT64 ending_lba;
grub_u64_t starting_lba;
grub_u64_t ending_lba;
union{
UINT64 attributes;
grub_u64_t attributes;
struct {
UINT16 unused[3];
UINT16 gpt_att;
grub_u16_t unused[3];
grub_u16_t gpt_att;
} PACKED ms_attr;
};
char name[72];
Expand All @@ -1573,7 +1565,7 @@ extern unsigned char saved_pxe_mac[6];
#ifdef FSYS_PXE

#include "pxe.h"
extern UINT8 pxe_mac_len, pxe_mac_type;
extern grub_u8_t pxe_mac_len, pxe_mac_type;
extern MAC_ADDR pxe_mac;
extern IP4 pxe_yip, pxe_sip, pxe_gip;
extern unsigned long pxe_keep;
Expand Down

0 comments on commit 5087499

Please sign in to comment.