$(OUT)%.proc.16.s: $(OUT)%.16.s
@echo " Moving data sections to text in $@"
- $(Q)sed 's/\t\.section\t\.rodata.*// ; s/\t\.data//' < $< > $@
+ $(Q)sed 's/^\t\.section\t\.\(ro\)\?data.*// ; s/^\t\.data$$//' < $< > $@
$(OUT)%.16.s: %.c
@echo " Compiling to assembler $@"
#define IDE_TIMEOUT 32000u //32 seconds max for IDE ops
-struct ata_s ATA VAR16;
+struct ata_s ATA VAR16_32;
/****************************************************************
// INT 16/AH=09h (keyboard functionality) supported
#define CBT_F2_INT1609 (1<<6)
-struct bios_config_table_s BIOS_CONFIG_TABLE __aligned(1) = {
+struct bios_config_table_s BIOS_CONFIG_TABLE __aligned(1) VAR16 = {
.size = sizeof(BIOS_CONFIG_TABLE) - 2,
.model = CONFIG_MODEL_ID,
.submodel = CONFIG_SUBMODEL_ID,
#include "bregs.h" // struct bregs
#include "biosvar.h" // GET_EBDA
-struct cdemu_s CDEMU VAR16;
+struct cdemu_s CDEMU VAR16_32;
/****************************************************************
#define PIT_TICK_RATE 1193182 // Underlying HZ of PIT
#define CALIBRATE_COUNT 0x800 // Approx 1.7ms
-u32 cpu_khz VAR16;
+u32 cpu_khz VAR16_32;
static void
calibrate_tsc()
// Since no provisions are made for multiple drive types, most
// values in this table are ignored. I set parameters for 1.44M
// floppy here
-struct floppy_ext_dbt_s diskette_param_table2 VAR16 = {
+struct floppy_ext_dbt_s diskette_param_table2 VAR16_32 = {
.dbt = {
.specify1 = 0xAF,
.specify2 = 0x02, // head load time 0000001, DMA used
//
// This file may be distributed under the terms of the GNU GPLv3 license.
-#include "disk.h" // diskette_param_table
+#include "disk.h" // struct floppy_dbt_s
// Since no provisions are made for multiple drive types, most
// values in this table are ignored. I set parameters for 1.44M
* found at ftp://ftp.simtel.net/pub/simtelnet/msdos/screen/fntcol16.zip
* This font is public domain
*/
-const u8 vgafont8[128*8] __aligned(1) = {
+const u8 vgafont8[128*8] __aligned(1) VAR16 = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e,
0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e,
ascii_code = 0;
regs->ax = (scan_code << 8) | ascii_code;
- if (incr) {
- u16 buffer_start = GET_BDA(kbd_buf_start_offset);
- u16 buffer_end = GET_BDA(kbd_buf_end_offset);
-
- buffer_head += 2;
- if (buffer_head >= buffer_end)
- buffer_head = buffer_start;
- SET_BDA(kbd_buf_head, buffer_head);
- } else {
+ if (!incr) {
regs->flags &= ~F_ZF;
+ return;
}
+ u16 buffer_start = GET_BDA(kbd_buf_start_offset);
+ u16 buffer_end = GET_BDA(kbd_buf_end_offset);
+
+ buffer_head += 2;
+ if (buffer_head >= buffer_end)
+ buffer_head = buffer_start;
+ SET_BDA(kbd_buf_head, buffer_head);
}
// read keyboard input
u16 control;
u16 alt;
u8 lock_flags;
-} scan_to_scanascii[MAX_SCAN_CODE + 1] = {
+} scan_to_scanascii[MAX_SCAN_CODE + 1] VAR16 = {
{ none, none, none, none, none },
{ 0x011b, 0x011b, 0x011b, 0x0100, none }, /* escape */
{ 0x0231, 0x0221, none, 0x7800, none }, /* 1! */
#include "util.h" // checksum
#include "biosvar.h" // SET_EBDA
-u16 PirOffset VAR16;
+u16 PirOffset VAR16_32;
struct pir_table {
struct pir_header pir;
extern struct pir_table PIR_TABLE;
#if CONFIG_PIRTABLE && !CONFIG_COREBOOT
-struct pir_table PIR_TABLE __aligned(16) VAR16 = {
+struct pir_table PIR_TABLE __aligned(16) VAR16_32 = {
.pir = {
.version = 0x0100,
.size = sizeof(struct pir_table),
extern const char pnp_string[];
#if CONFIG_PNPBIOS
-struct pnpheader PNPHEADER __aligned(16) VAR16 = {
+struct pnpheader PNPHEADER __aligned(16) VAR16_32 = {
.signature = PNP_SIGNATURE,
.version = 0x10,
.length = sizeof(PNPHEADER),
// We need a copy of this string in the 0xf000 segment, but we are not
// actually a PnP BIOS, so make sure it is *not* aligned, so OSes will
// not see it if they scan.
-const char pnp_string[] __aligned(2) VAR16 = " $PnP";
+const char pnp_string[] __aligned(2) VAR16_32 = " $PnP";
#endif
#define FUNCTION_NOT_SUPPORTED 0x82
*(.text)
code16_rodata = . ;
*(.rodata*)
- *(.data)
- code16_bss = . ;
- *(.bss)
- *(COMMON)
+ *(.data.var16)
}
freespace1_start = . ;
code16_end = . ;
*(.text.fixed.addr)
}
code16_fixed_end = . ;
+
+ // Discard regular data sections to force a link error if
+ // 16bit code attempts to access data not marked with VAR16.
+ /DISCARD/ : { *(.data) *(.bss) *(COMMON) }
}
return *(volatile const u8 *)addr;
}
-u32 smp_cpus VAR16;
+u32 smp_cpus VAR16_32;
extern void smp_ap_boot_code();
ASM16(
" .global smp_ap_boot_code\n"
}
// Info on e820 map location and size.
-struct e820entry *e820_list VAR16;
-int e820_count VAR16;
+struct e820entry *e820_list VAR16_32;
+int e820_count VAR16_32;
// Amount of continuous ram under 4Gig
-u32 RamSize VAR16;
+u32 RamSize VAR16_32;
// Amount of continuous ram >4Gig
-u64 RamSizeOver4G VAR16;
+u64 RamSizeOver4G;
static void
handle_15e820(struct bregs *regs)
# define VISIBLE16 __VISIBLE
// Notes a function as externally visible in the 32bit code chunk.
# define VISIBLE32
+// Designate a variable as (only) visible to 16bit code.
+# define VAR16 __attribute__((section(".data.var16")))
// Designate a variable as visible to both 32bit and 16bit code.
-# define VAR16 __VISIBLE
+# define VAR16_32 VAR16 __VISIBLE
// Designate top-level assembler as 16bit only.
# define ASM16(code) asm(code)
#else
# define VISIBLE16
# define VISIBLE32 __VISIBLE
-# define VAR16 __VISIBLE __attribute__((section(".discard.var16"))) __attribute__((weak))
+# define VAR16 __attribute__((section(".discard.var16")))
+# define VAR16_32 VAR16 __VISIBLE __attribute__((weak))
# define ASM16(code)
#endif
if (!(reg & 0x80))
goto err;
- static u8 mem_power[] = {0, 3, 4, 5, 6, 7, 8, 9};
+ static u8 mem_power[] VAR16 = {0, 3, 4, 5, 6, 7, 8, 9};
return GET_GLOBAL(mem_power[(reg >> 4) & 0x7]);
err:
dprintf(1, "Warning: VGA memory size is hardcoded\n");