Some cleanups based on patch by Nguyen Anh Quynh

Add include guards to header files.
Disable stack protector on gcc versions with that option.
Fix lds bug in src/rombios32.lds.S
Don't forward declare "struct bregs;" - it may be confusing gcc on some versions.
This commit is contained in:
Kevin O'Connor 2008-02-27 10:41:41 -05:00
parent a2e7380fdf
commit 786502d783
5 changed files with 30 additions and 9 deletions

View File

@ -11,9 +11,17 @@ OUT=out/
SRC16=floppy.c disk.c system.c clock.c serial.c kbd.c mouse.c output.c boot.c
SRC32=post.c output.c
cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
/dev/null 2>&1`"; then echo "$(2)"; else echo "$(3)"; fi ;)
# Default compiler flags
CFLAGS = -Wall -g -Os -MD -m32 -march=i386 -mregparm=2 -ffreestanding
CFLAGS16 = -Wall -Os -MD -m32 -DMODE16 -march=i386 -mregparm=2 -ffreestanding -fno-jump-tables
COMMONCFLAGS = -Wall -Os -MD -m32 -march=i386 -mregparm=2 -ffreestanding
COMMONCFLAGS += $(call cc-option,$(CC),-nopie,)
COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
CFLAGS = $(COMMONCFLAGS) -g
CFLAGS16 = $(COMMONCFLAGS) -DMODE16 -fno-jump-tables
all: $(OUT) $(OUT)rom.bin

View File

@ -3,8 +3,11 @@
// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
#ifndef __DISK_H
#define __DISK_H
#include "ioport.h" // outb
#include "biosvar.h" // struct bregs
#define DISK_RET_SUCCESS 0x00
#define DISK_RET_EPARAM 0x01
@ -15,6 +18,7 @@
#define DISK_RET_EMEDIA 0xC0
// floppy.c
struct bregs;
void floppy_13(struct bregs *regs, u8 drive);
void floppy_tick();
#endif // disk.h

View File

@ -3,6 +3,8 @@
// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
#ifndef __FARPTR_H
#define __FARPTR_H
#define READ8_SEG(SEG, var) ({ \
u8 __value; \
@ -97,3 +99,5 @@ extern void __force_link_error__unknown_type();
#define GET_FARPTR(ptr) (ptr)
#define SET_FARPTR(ptr, val) do { (var) = (val); } while (0)
#endif
#endif // farptr.h

View File

@ -9,7 +9,7 @@
#include "../out/rom16.offset.auto.h"
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
OUTPUT_ARCH("i386")
ENTRY(_start);
SECTIONS
{

View File

@ -3,16 +3,20 @@
// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
#ifndef __UTIL_H
#define __UTIL_H
#include "ioport.h" // outb
#include "biosvar.h" // struct bregs
static inline void irq_disable(void) {
asm volatile("cli": : :"memory");
static inline void irq_disable(void)
{
asm volatile("cli": : :"memory");
}
static inline void irq_enable(void) {
asm volatile("sti": : :"memory");
static inline void irq_enable(void)
{
asm volatile("sti": : :"memory");
}
static inline unsigned long irq_save(void)
@ -91,7 +95,6 @@ void call16(struct bregs *callregs)
// output.c
void bprintf(u16 action, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
struct bregs;
void __debug_enter(const char *fname, struct bregs *regs);
void __debug_exit(const char *fname, struct bregs *regs);
#define debug_enter(regs) \
@ -115,3 +118,5 @@ handle_ret(struct bregs *regs, u8 code)
regs->ah = code;
set_cf(regs, code);
}
#endif // util.h