fix: coding style

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
Julien CLEMENT 2021-07-12 18:01:40 +02:00
parent 3e881a6f33
commit d0f6a2592b
6 changed files with 221 additions and 221 deletions

View File

@ -70,18 +70,18 @@
# define PACKET_COMMAND_COMPLETE 3
struct SCSI_packet {
u8 op_code;
u8 flags_lo;
u8 lba_hi;
u8 lba_mihi;
u8 lba_milo;
u8 lba_lo;
u8 transfer_length_hi;
u8 transfer_length_mihi;
u8 transfer_length_milo;
u8 transfer_length_lo;
u8 flags_hi;
u8 control;
u8 op_code;
u8 flags_lo;
u8 lba_hi;
u8 lba_mihi;
u8 lba_milo;
u8 lba_lo;
u8 transfer_length_hi;
u8 transfer_length_mihi;
u8 transfer_length_milo;
u8 transfer_length_lo;
u8 flags_hi;
u8 control;
} __packed;
#endif /* !ATAPI_H_ */

View File

@ -7,33 +7,33 @@
struct blockdev;
struct blk_ops {
void *(*read)(struct blockdev *, size_t);
void (*free_blk)(struct blockdev *, void *);
void *(*read)(struct blockdev *, size_t);
void (*free_blk)(struct blockdev *, void *);
};
struct blockdev {
size_t blk_size;
size_t blk_size;
struct blk_ops *ops;
void *blocks;
struct blk_ops *ops;
void *blocks;
};
static inline void *block_read(struct blockdev *bd, size_t lba)
{
assert(bd);
assert(bd->ops);
assert(bd->ops->read);
assert(bd);
assert(bd->ops);
assert(bd->ops->read);
return bd->ops->read(bd, lba);
return bd->ops->read(bd, lba);
}
static inline void block_free(struct blockdev *bd, void *ptr)
{
assert(bd);
assert(bd->ops);
assert(bd->ops->free_blk);
assert(bd);
assert(bd->ops);
assert(bd->ops->free_blk);
bd->ops->free_blk(bd, ptr);
bd->ops->free_blk(bd, ptr);
}
#endif /* BLOCKDEV_H_ */
#endif /* BLOCKDEV_H_ */

View File

@ -1,7 +1,7 @@
#ifndef COMPILER_H
#define COMPILER_H
#define array_size(arr) (sizeof(arr) / sizeof(*arr))
#define array_size(arr) (sizeof(arr) / sizeof(*arr))
#define __packed __attribute__((__packed__))
#define align_up(addr, bytes) (((addr) + (bytes) - 1) & ~((bytes) - 1))

View File

@ -27,13 +27,13 @@
/* Structures used for twin values */
struct endian32 {
u32 le; /* little endian value */
u32 be; /* big endian value */
u32 le; /* little endian value */
u32 be; /* big endian value */
} __packed;
struct endian16 {
u16 le; /* little endian value */
u16 be; /* big endian value */
u16 le; /* little endian value */
u16 be; /* big endian value */
} __packed;
# define ISO_BLOCK_SIZE 2048
@ -41,11 +41,11 @@ struct endian16 {
/* ISO9660 Path table structure */
struct iso_path_table_le {
u8 idf_len; /* Identifier name length */
u8 ext_size; /* Extended attribute record length */
u32 data_blk; /* File data block index */
u16 parent_dir; /* Number of the parent dir */
char idf[0]; /* directory name */
u8 idf_len; /* Identifier name length */
u8 ext_size; /* Extended attribute record length */
u32 data_blk; /* File data block index */
u16 parent_dir; /* Number of the parent dir */
char idf[0]; /* directory name */
} __packed;
/* ISO9660 directory structure */
@ -54,31 +54,31 @@ struct iso_path_table_le {
# define ISO_DATE_LEN 7
enum iso_file_type {
ISO_FILE_HIDDEN = 1, /* File is Hidden */
ISO_FILE_ISDIR = 2, /* Entry is a Directory */
ISO_FILE_ASSOCIAT = 4, /* Entry is an Associated */
ISO_FILE_USEEXT = 8,
/* Information is structured according to the extended attribute record */
ISO_FILE_USEPERM = 16,
/* Permissions are specified in the extended attribute record */
ISO_FILE_MULTIDIR = 128 /* File has more than one directory record */
ISO_FILE_HIDDEN = 1, /* File is Hidden */
ISO_FILE_ISDIR = 2, /* Entry is a Directory */
ISO_FILE_ASSOCIAT = 4, /* Entry is an Associated */
ISO_FILE_USEEXT = 8,
/* Information is structured according to the extended attribute record */
ISO_FILE_USEPERM = 16,
/* Permissions are specified in the extended attribute record */
ISO_FILE_MULTIDIR = 128 /* File has more than one directory record */
};
struct iso_dir {
u8 dir_size; /* Length of directory record */
u8 ext_size; /* Extended attribute record length */
struct endian32 data_blk; /* File data block index */
struct endian32 file_size; /* File size */
char date[ISO_DATE_LEN];
u8 type; /* File type (enum iso_file_type) */
u8 dir_size; /* Length of directory record */
u8 ext_size; /* Extended attribute record length */
struct endian32 data_blk; /* File data block index */
struct endian32 file_size; /* File size */
char date[ISO_DATE_LEN];
u8 type; /* File type (enum iso_file_type) */
/* only valid if the file is recorded in interleave mode */
u8 unit_size; /* File Unit Size */
u8 gap_size; /* Interleave Gap Size */
/* only valid if the file is recorded in interleave mode */
u8 unit_size; /* File Unit Size */
u8 gap_size; /* Interleave Gap Size */
struct endian16 vol_seq;
u8 idf_len;
char idf[0]; /* file name */
struct endian16 vol_seq;
u8 idf_len;
char idf[0]; /* file name */
} __packed;
/* ISO9660 Primary volume descriptor structure */
@ -97,42 +97,42 @@ struct iso_dir {
# define ISO_LDATE_LEN 17
struct iso_prim_voldesc {
u8 vol_desc_type; /* Volume Descriptor Type (1) */
char std_identifier[5]; /* Standard Identifier (CD001) */
u8 vol_desc_version; /* Volume Descriptor Version (1) */
u8 unused1; /* Unused Field */
char syidf[ISO_SYSIDF_LEN]; /* System Identifier */
char vol_idf[ISO_VOLIDF_LEN]; /* Volume Identifier */
u8 unused2[8]; /* Unused Field */
struct endian32 vol_blk_count;
/* Number of logical blocks in the Volume (LE)*/
u8 unused4[32]; /* Unused Field */
struct endian16 vol_set_size; /* The Volume Set size of the Volume */
struct endian16 vol_seq_num; /* The number of the volume in the Set */
struct endian16 vol_blk_size; /* The size in bytes of a Logical Block */
struct endian32 path_table_size; /* Length in bytes of the path table */
u32 le_path_table_blk; /* LittleEndian path table block index */
u32 le_opath_table_blk;
/* LittleEndian optional path table block index */
u32 be_path_table_blk; /* BigEndian path table block index */
u32 be_opath_table_blk; /* BigEndian optional path table block index */
u8 vol_desc_type; /* Volume Descriptor Type (1) */
char std_identifier[5]; /* Standard Identifier (CD001) */
u8 vol_desc_version; /* Volume Descriptor Version (1) */
u8 unused1; /* Unused Field */
char syidf[ISO_SYSIDF_LEN]; /* System Identifier */
char vol_idf[ISO_VOLIDF_LEN]; /* Volume Identifier */
u8 unused2[8]; /* Unused Field */
struct endian32 vol_blk_count;
/* Number of logical blocks in the Volume (LE)*/
u8 unused4[32]; /* Unused Field */
struct endian16 vol_set_size; /* The Volume Set size of the Volume */
struct endian16 vol_seq_num; /* The number of the volume in the Set */
struct endian16 vol_blk_size; /* The size in bytes of a Logical Block */
struct endian32 path_table_size; /* Length in bytes of the path table */
u32 le_path_table_blk; /* LittleEndian path table block index */
u32 le_opath_table_blk;
/* LittleEndian optional path table block index */
u32 be_path_table_blk; /* BigEndian path table block index */
u32 be_opath_table_blk; /* BigEndian optional path table block index */
struct iso_dir root_dir; /* Root directory entry */
u8 unused5[34 - sizeof (struct iso_dir)];/* padding */
struct iso_dir root_dir; /* Root directory entry */
u8 unused5[34 - sizeof (struct iso_dir)];/* padding */
char volset_idf[ISO_VOLSET_LEN]; /* Name of the multiple volume set */
char pub_idf[ISO_PUBIDF_LEN]; /* Publisher name */
char dprep_idf[ISO_DPREP_LEN]; /* Data preparer name */
char app_idf[ISO_APP_LEN]; /* Application name */
char volset_idf[ISO_VOLSET_LEN]; /* Name of the multiple volume set */
char pub_idf[ISO_PUBIDF_LEN]; /* Publisher name */
char dprep_idf[ISO_DPREP_LEN]; /* Data preparer name */
char app_idf[ISO_APP_LEN]; /* Application name */
char copyright_file[ISO_CPRFIL_LEN]; /* Copyright file name in root dir */
char abstract_file[ISO_ABSFIL_LEN]; /* Abstract file name in root dir */
char bibli_file[ISO_BIBFIL_LEN]; /* Bibliographic file name in root dir */
char date_creat[ISO_LDATE_LEN]; /* Creation date */
char date_modif[ISO_LDATE_LEN]; /* Modification date */
char date_expir[ISO_LDATE_LEN]; /* Expiration date */
char date_effect[ISO_LDATE_LEN]; /* Effective date */
u8 filestrutc_version; /* File Structure Version (1) */
char copyright_file[ISO_CPRFIL_LEN]; /* Copyright file name in root dir */
char abstract_file[ISO_ABSFIL_LEN]; /* Abstract file name in root dir */
char bibli_file[ISO_BIBFIL_LEN]; /* Bibliographic file name in root dir */
char date_creat[ISO_LDATE_LEN]; /* Creation date */
char date_modif[ISO_LDATE_LEN]; /* Modification date */
char date_expir[ISO_LDATE_LEN]; /* Expiration date */
char date_effect[ISO_LDATE_LEN]; /* Effective date */
u8 filestrutc_version; /* File Structure Version (1) */
} __packed;
#endif /* !ISO9660_H */

View File

@ -24,50 +24,50 @@
#define __packed __attribute__((__packed__))
struct kfs_block {
u32 idx;
u32 usage;
u32 cksum;
u8 data[KFS_BLK_DATA_SZ];
u32 idx;
u32 usage;
u32 cksum;
u8 data[KFS_BLK_DATA_SZ];
} __packed;
struct kfs_iblock {
u32 idx;
u32 blk_cnt;
u32 blks[KFS_INDIRECT_BLK_CNT];
u32 cksum;
u32 idx;
u32 blk_cnt;
u32 blks[KFS_INDIRECT_BLK_CNT];
u32 cksum;
} __packed;
struct kfs_inode {
u32 inumber;
char filename[KFS_FNAME_SZ];
u32 file_sz;
u32 idx;
u32 blk_cnt;
u32 next_inode;
u32 d_blk_cnt;
u32 i_blk_cnt;
u32 d_blks[KFS_DIRECT_BLK];
u32 i_blks[KFS_INDIRECT_BLK];
u32 cksum;
u32 inumber;
char filename[KFS_FNAME_SZ];
u32 file_sz;
u32 idx;
u32 blk_cnt;
u32 next_inode;
u32 d_blk_cnt;
u32 i_blk_cnt;
u32 d_blks[KFS_DIRECT_BLK];
u32 i_blks[KFS_INDIRECT_BLK];
u32 cksum;
} __packed;
struct kfs_blk {
union {
struct kfs_block blk;
struct kfs_iblock iblk;
struct kfs_inode ino;
u8 whole_blk[KFS_BLK_SZ];
};
union {
struct kfs_block blk;
struct kfs_iblock iblk;
struct kfs_inode ino;
u8 whole_blk[KFS_BLK_SZ];
};
};
struct kfs_superblock {
u32 magic;
char name[KFS_NAME_SZ];
s32 ctime;
u32 blk_cnt;
u32 inode_cnt;
u32 inode_idx;
u32 cksum;
u32 magic;
char name[KFS_NAME_SZ];
s32 ctime;
u32 blk_cnt;
u32 inode_cnt;
u32 inode_idx;
u32 cksum;
} __packed;
#define ADLER32_MOD 65521
@ -77,16 +77,16 @@ struct kfs_superblock {
*/
static inline unsigned int kfs_checksum(const void *data, size_t size)
{
unsigned int a = 1;
unsigned int b = 0;
size_t i = 0;
const u8 *buf = data;
unsigned int a = 1;
unsigned int b = 0;
size_t i = 0;
const u8 *buf = data;
while (i < size) {
a += buf[i++];
b += a;
}
return ((b % ADLER32_MOD) << 16) | (a % ADLER32_MOD);
while (i < size) {
a += buf[i++];
b += a;
}
return ((b % ADLER32_MOD) << 16) | (a % ADLER32_MOD);
}
#endif

View File

@ -30,8 +30,8 @@ typedef s32 ssize_t;
typedef s32 off_t;
struct melody {
unsigned long freq;
unsigned long duration;
unsigned long freq;
unsigned long duration;
};
/*
@ -40,115 +40,115 @@ struct melody {
/* console */
enum e_cons_codes {
CONS_ESCAPE = 255,
CONS_CLEAR = 1,
CONS_COLOR = 2,
CONS_SETX = 3,
CONS_SETY = 4,
CONS_BLACK = 0,
CONS_BLUE = 1,
CONS_GREEN = 2,
CONS_CYAN = 3,
CONS_RED = 4,
CONS_MAGENTA = 5,
CONS_YELLOW = 6,
CONS_WHITE = 7,
CONS_BLINK = (1 << 7),
CONS_LIGHT = (1 << 3)
CONS_ESCAPE = 255,
CONS_CLEAR = 1,
CONS_COLOR = 2,
CONS_SETX = 3,
CONS_SETY = 4,
CONS_BLACK = 0,
CONS_BLUE = 1,
CONS_GREEN = 2,
CONS_CYAN = 3,
CONS_RED = 4,
CONS_MAGENTA = 5,
CONS_YELLOW = 6,
CONS_WHITE = 7,
CONS_BLINK = (1 << 7),
CONS_LIGHT = (1 << 3)
};
#define CONS_FRONT(Color) (Color)
#define CONS_BACK(Color) (Color << 4)
#define CONS_FRONT(Color) (Color)
#define CONS_BACK(Color) (Color << 4)
/* keyboard */
enum e_kbd_codes {
KEY_ESC = 1,
KEY_F1 = 59,
KEY_F2 = 60,
KEY_F3 = 61,
KEY_F4 = 62,
KEY_F5 = 63,
KEY_F6 = 64,
KEY_F7 = 65,
KEY_F8 = 66,
KEY_f9 = 67,
KEY_F10 = 68,
KEY_F11 = 87,
KEY_F12 = 88,
KEY_1 = 2,
KEY_2 = 3,
KEY_3 = 4,
KEY_4 = 5,
KEY_5 = 6,
KEY_6 = 7,
KEY_7 = 8,
KEY_8 = 9,
KEY_9 = 10,
KEY_0 = 11,
KEY_TAB = 15,
KEY_MAJLOCK = 58,
KEY_LSHIFT = 42,
KEY_RSHIFT = 54,
KEY_ALT = 56,
KEY_SPACE = 57,
KEY_CTRL = 29,
KEY_ENTER = 28,
KEY_BACKSPACE = 14,
KEY_LEFT = 75,
KEY_RIGHT = 77,
KEY_UP = 72,
KEY_DOWN = 80,
KEY_PAUSE = 69,
KEY_SYST = 55,
KEY_INSER = 82,
KEY_SUPPR = 83,
KEY_ESC = 1,
KEY_F1 = 59,
KEY_F2 = 60,
KEY_F3 = 61,
KEY_F4 = 62,
KEY_F5 = 63,
KEY_F6 = 64,
KEY_F7 = 65,
KEY_F8 = 66,
KEY_f9 = 67,
KEY_F10 = 68,
KEY_F11 = 87,
KEY_F12 = 88,
KEY_1 = 2,
KEY_2 = 3,
KEY_3 = 4,
KEY_4 = 5,
KEY_5 = 6,
KEY_6 = 7,
KEY_7 = 8,
KEY_8 = 9,
KEY_9 = 10,
KEY_0 = 11,
KEY_TAB = 15,
KEY_MAJLOCK = 58,
KEY_LSHIFT = 42,
KEY_RSHIFT = 54,
KEY_ALT = 56,
KEY_SPACE = 57,
KEY_CTRL = 29,
KEY_ENTER = 28,
KEY_BACKSPACE = 14,
KEY_LEFT = 75,
KEY_RIGHT = 77,
KEY_UP = 72,
KEY_DOWN = 80,
KEY_PAUSE = 69,
KEY_SYST = 55,
KEY_INSER = 82,
KEY_SUPPR = 83,
};
enum e_k_mode {
KEY_PRESSED,
KEY_RELEASED,
KEY_PRESSED,
KEY_RELEASED,
};
/* mouse */
enum e_mouse_codes {
BUTTON_LEFT = 1,
BUTTON_RIGHT = 2
BUTTON_LEFT = 1,
BUTTON_RIGHT = 2
};
/* misc */
#define O_RDONLY 0
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#define VIDEO_GRAPHIC 0
#define VIDEO_TEXT 1
#define O_RDONLY 0
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#define VIDEO_GRAPHIC 0
#define VIDEO_TEXT 1
/*
** syscalls
*/
#define SYSCALL_WRITE 1
#define SYSCALL_SBRK 2
#define SYSCALL_GETKEY 3
#define SYSCALL_GETTICK 4
#define SYSCALL_OPEN 5
#define SYSCALL_READ 6
#define SYSCALL_SEEK 7
#define SYSCALL_CLOSE 8
#define SYSCALL_SETVIDEO 9
#define SYSCALL_SWAP_FRONTBUFFER 10
#define SYSCALL_PLAYSOUND 11
#define SYSCALL_SETPALETTE 12
#define SYSCALL_WRITE 1
#define SYSCALL_SBRK 2
#define SYSCALL_GETKEY 3
#define SYSCALL_GETTICK 4
#define SYSCALL_OPEN 5
#define SYSCALL_READ 6
#define SYSCALL_SEEK 7
#define SYSCALL_CLOSE 8
#define SYSCALL_SETVIDEO 9
#define SYSCALL_SWAP_FRONTBUFFER 10
#define SYSCALL_PLAYSOUND 11
#define SYSCALL_SETPALETTE 12
#define SYSCALL_GETMOUSE 13
#define NR_SYSCALL (SYSCALL_GETMOUSE + 1)
#define SYSCALL_GETMOUSE 13
#define NR_SYSCALL (SYSCALL_GETMOUSE + 1)
#define ENOMEM 1 /* Not enough space */
#define ENOENT 2 /* No such file or directory */
#define EIO 3 /* I/O error */
#define EINVAL 4 /* Invalid argument */
#define ENOSYS 5 /* Invalid system call number */
#define EBADF 6 /* fd is not an open file descriptor */
#define EAGAIN 7 /* Temporary unavailable */
#define ENOMEM 1 /* Not enough space */
#define ENOENT 2 /* No such file or directory */
#define EIO 3 /* I/O error */
#define EINVAL 4 /* Invalid argument */
#define ENOSYS 5 /* Invalid system call number */
#define EBADF 6 /* fd is not an open file descriptor */
#define EAGAIN 7 /* Temporary unavailable */
#endif /* !KSTD_H_ */
#endif /* !KSTD_H_ */