aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-12-04 22:00:13 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-12-05 20:07:11 +0000
commit6272db928783e303d84556598ecafba9358e0448 (patch)
treedc7ee6a9b05c00aa5854119818d4148465ed8770
parent19eb366ea1945a88909c0b919980e54085e6b204 (diff)
downloadsyslinux-6272db928783e303d84556598ecafba9358e0448.tar.gz
Reduce the number of global variables
In preparation for strictly limiting the list of variables that are exported (global) in the core, delete any unused variables, rewrite variable declarations in C that are not referenced by asm and delete files that are no longer included in other asm files. Cc: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--com32/elflink/ldlinux/readconfig.c2
-rw-r--r--com32/include/syslinux/features.h48
-rw-r--r--core/bios.inc1
-rw-r--r--core/comboot.inc18
-rw-r--r--core/diskfs.inc9
-rw-r--r--core/font.c2
-rw-r--r--core/fs/pxe/pxe.c25
-rw-r--r--core/fs/pxe/pxe.h1
-rw-r--r--core/graphics.c1
-rw-r--r--core/highmem.inc158
-rw-r--r--core/include/bios.h10
-rw-r--r--core/init.c1
-rw-r--r--core/isolinux.asm9
-rw-r--r--core/kernel.inc3
-rw-r--r--core/layout.inc1
-rw-r--r--core/pxelinux.asm9
16 files changed, 28 insertions, 270 deletions
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 64c20a05..705ffa8a 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -718,7 +718,7 @@ extern uint8_t FlowInput;
extern uint8_t FlowOutput;
extern uint16_t SerialPort;
extern uint16_t BaudDivisor;
-extern uint8_t SerialNotice;
+static uint8_t SerialNotice = 1;
#define DEFAULT_BAUD 9600
#define BAUD_DIVISOR 115200
diff --git a/com32/include/syslinux/features.h b/com32/include/syslinux/features.h
deleted file mode 100644
index d25d08d5..00000000
--- a/com32/include/syslinux/features.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ----------------------------------------------------------------------- *
- *
- * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall
- * be included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * ----------------------------------------------------------------------- */
-
-#ifndef _SYSLINUX_FEATURES_H
-#define _SYSLINUX_FEATURES_H
-
-#define SYSLINUX_FEATURE_LOCAL_BOOT (0*8+0)
-#define SYSLINUX_FEATURE_NOOP_IDLE (0*8+1)
-
-extern uint8_t feature_flags;
-extern uint8_t feature_flags_len;
-
-static inline int syslinux_has_feature(unsigned int __flag)
-{
- unsigned int __byte = __flag >> 3;
- unsigned int __bit = __flag & 7;
-
- if (__byte <= feature_flags_len)
- return (feature_flags[__byte] >> __bit) & 1;
- else
- return 0;
-}
-
-#endif /* _SYSLINUX_FEATURE_H */
diff --git a/core/bios.inc b/core/bios.inc
index 33a3cd4c..2e150594 100644
--- a/core/bios.inc
+++ b/core/bios.inc
@@ -18,7 +18,6 @@
%ifndef _BIOS_INC
%define _BIOS_INC
- global BIOS_fbm, BIOS_timer
; Interrupt vectors
absolute 4*1Ch
diff --git a/core/comboot.inc b/core/comboot.inc
index 4474cd37..2e690ff8 100644
--- a/core/comboot.inc
+++ b/core/comboot.inc
@@ -522,31 +522,13 @@ APIKeyFlag db 0
zero_string db 0 ; Empty, null-terminated string
-;
-; This is the feature flag array for INT 22h AX=0015h
-;
-; Note: PXELINUX clears the idle is noop flag if appropriate
-; in pxe_detect_nic_type
-;
- global feature_flags, feature_flags_len
-feature_flags:
- db 1 ; Have local boot, idle is not noop
-feature_flags_len equ ($-feature_flags)
-
err_notdos db ': attempted DOS system call INT ',0
err_comlarge db 'COMBOOT image too large.', CR, LF, 0
- global VGAFontSize, UserFont
- alignz 2
-VGAFontSize dw 16 ; Defaults to 16 byte font
-UserFont db 0 ; Using a user-specified font
-
section .bss16
alignb 4
DOSErrTramp resd 33 ; Error trampolines
- global ConfigName
-ConfigName resb FILENAME_MAX
%ifndef HAVE_CURRENTDIRNAME
global CurrentDirName
CurrentDirName resb FILENAME_MAX
diff --git a/core/diskfs.inc b/core/diskfs.inc
index dcbc924a..9c9da267 100644
--- a/core/diskfs.inc
+++ b/core/diskfs.inc
@@ -91,24 +91,15 @@ auto_boot:
jmp kaboom
section .bss16
- global CmdOptPtr, KbdMap
alignb 4
ThisKbdTo resd 1 ; Temporary holder for KbdTimeout
ThisTotalTo resd 1 ; Temporary holder for TotalTimeout
KernelExtPtr resw 1 ; During search, final null pointer
-CmdOptPtr resw 1 ; Pointer to first option on cmd line
-KbdFlags resb 1 ; Check for keyboard escapes
FuncFlag resb 1 ; Escape sequences received from keyboard
KernelType resb 1 ; Kernel type, from vkernel, if known
-KbdMap resb 256 ; Keyboard map
global KernelName
KernelName resb FILENAME_MAX ; Mangled name for kernel
- section .config
- global PXERetry
-PXERetry dw 0 ; Extra PXE retries
section .data16
- global SerialNotice
-SerialNotice db 1 ; Only print this once
global IPAppends, numIPAppends
%if IS_PXELINUX
extern IPOption
diff --git a/core/font.c b/core/font.c
index 9e7aa8f2..38f03f58 100644
--- a/core/font.c
+++ b/core/font.c
@@ -26,6 +26,8 @@
#include "graphics.h"
#include "core.h"
+uint8_t UserFont = 0; /* Using a user-specified font */
+
__lowmem char fontbuf[8192];
uint16_t GXPixCols = 1; /* Graphics mode pixel columns */
diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c
index 3cc64973..ee818ecd 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <string.h>
#include <core.h>
+#include <bios.h>
#include <fs.h>
#include <minmax.h>
#include <sys/cpu.h>
@@ -644,7 +645,7 @@ static uint32_t pxe_getfssec(struct file *file, char *buf,
*
*/
static void __pxe_searchdir(const char *filename, struct file *file);
-extern uint16_t PXERetry;
+uint16_t PXERetry;
static void pxe_searchdir(const char *filename, struct file *file)
{
@@ -1270,9 +1271,9 @@ static const void *memory_scan(uintptr_t start, int (*func)(const void *))
static const struct pxe_t *memory_scan_for_pxe_struct(void)
{
- extern uint16_t BIOS_fbm; /* Starting segment */
+ uint16_t start = bios_fbm(); /* Starting segment */
- return memory_scan(BIOS_fbm << 10, is_pxe);
+ return memory_scan(start << 10, is_pxe);
}
static const struct pxenv_t *memory_scan_for_pxenv_struct(void)
@@ -1677,11 +1678,11 @@ void unload_pxe(uint16_t flags)
uint16_t Status; /* All calls have this as the first member */
} unload_call;
- dprintf("FBM before unload = %d\n", BIOS_fbm);
+ dprintf("FBM before unload = %d\n", bios_fbm());
err = reset_pxe();
- dprintf("FBM after reset_pxe = %d, err = %d\n", BIOS_fbm, err);
+ dprintf("FBM after reset_pxe = %d, err = %d\n", bios_fbm(), err);
/* If we want to keep PXE around, we still need to reset it */
if (flags || err)
@@ -1701,8 +1702,8 @@ void unload_pxe(uint16_t flags)
}
api = 0xff00;
- if (real_base_mem <= BIOS_fbm) { /* Sanity check */
- dprintf("FBM %d < real_base_mem %d\n", BIOS_fbm, real_base_mem);
+ if (real_base_mem <= bios_fbm()) { /* Sanity check */
+ dprintf("FBM %d < real_base_mem %d\n", bios_fbm(), real_base_mem);
goto cant_free;
}
api++;
@@ -1710,20 +1711,20 @@ void unload_pxe(uint16_t flags)
/* Check that PXE actually unhooked the INT 0x1A chain */
int_addr = (size_t)GET_PTR(*(far_ptr_t *)(4 * 0x1a));
int_addr >>= 10;
- if (int_addr >= real_base_mem || int_addr < BIOS_fbm) {
- BIOS_fbm = real_base_mem;
- dprintf("FBM after unload_pxe = %d\n", BIOS_fbm);
+ if (int_addr >= real_base_mem || int_addr < bios_fbm()) {
+ set_bios_fbm(real_base_mem);
+ dprintf("FBM after unload_pxe = %d\n", bios_fbm());
return;
}
dprintf("Can't free FBM, real_base_mem = %d, "
"FBM = %d, INT 1A = %08x (%d)\n",
- real_base_mem, BIOS_fbm,
+ real_base_mem, bios_fbm(),
*(uint32_t *)(4 * 0x1a), int_addr);
cant_free:
printf("Failed to free base memory error %04x-%08x (%d/%dK)\n",
- api, *(uint32_t *)(4 * 0x1a), BIOS_fbm, real_base_mem);
+ api, *(uint32_t *)(4 * 0x1a), bios_fbm(), real_base_mem);
return;
}
diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h
index c754106d..d4377581 100644
--- a/core/fs/pxe/pxe.h
+++ b/core/fs/pxe/pxe.h
@@ -211,7 +211,6 @@ extern bool have_uuid;
extern uint8_t uuid_type;
extern uint8_t uuid[];
-extern uint16_t BIOS_fbm;
extern const uint8_t TimeoutTable[];
/*
diff --git a/core/graphics.c b/core/graphics.c
index bdf48a85..55d91d7e 100644
--- a/core/graphics.c
+++ b/core/graphics.c
@@ -28,6 +28,7 @@
uint8_t UsingVGA = 0;
uint16_t VGAPos; /* Pointer into VGA memory */
uint16_t *VGAFilePtr; /* Pointer into VGAFileBuf */
+uint16_t VGAFontSize = 16; /* Defaults to 16 byte font */
char VGAFileBuf[VGA_FILE_BUF_SIZE]; /* Unmangled VGA image name */
char VGAFileMBuf[FILENAME_MAX]; /* Mangled VGA image name */
diff --git a/core/highmem.inc b/core/highmem.inc
deleted file mode 100644
index ea386ffc..00000000
--- a/core/highmem.inc
+++ /dev/null
@@ -1,158 +0,0 @@
-;; -----------------------------------------------------------------------
-;;
-;; Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
-;;
-;; 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, Inc., 53 Temple Place Ste 330,
-;; Boston MA 02111-1307, USA; either version 2 of the License, or
-;; (at your option) any later version; incorporated herein by reference.
-;;
-;; -----------------------------------------------------------------------
-
-;;
-;; highmem.inc
-;;
-;; Probe for the size of high memory. This can be overridden by a
-;; mem= command on the command line while booting a new kernel.
-;;
-
- section .text16
-
-;
-; This is set up as a subroutine; it will set up the global variable
-; HighMemSize. All registers are preserved.
-;
-highmemsize:
- push es
- pushfd
- pushad
-
- push cs
- pop es
-
-;
-; First, try INT 15:E820 (get BIOS memory map)
-;
-; Note: we may have to scan this multiple times, because some (daft) BIOSes
-; report main memory as multiple contiguous ranges...
-;
-get_e820:
- mov dword [E820Max],-(1 << 20) ; Max amount of high memory
- mov dword [E820Mem],(1 << 20) ; End of detected high memory
-.start_over:
- mov di,E820Buf
- xor ax,ax
- mov cx,10
- rep stosw ; Clear buffer
- xor ebx,ebx ; Start with first record
- jmp short .do_e820 ; Skip "at end" check first time!
-.int_loop: and ebx,ebx ; If we're back at beginning...
- jz .e820_done ; ... we're done
-.do_e820: mov eax,0000E820h
- mov edx,534D4150h ; "SMAP" backwards
- xor ecx,ecx
- mov cl,20 ; ECX <- 20 (size of buffer)
- mov di,E820Buf
- int 15h
- jnc .no_carry
- ; If carry, ebx == 0 means error, ebx != 0 means we're done
- and ebx,ebx
- jnz .e820_done
- jmp no_e820
-.no_carry:
- cmp eax,534D4150h
- jne no_e820
- cmp cx,20
- jb no_e820
-
-;
-; Look for a memory block starting at <= 1 MB and continuing upward
-;
- cmp dword [E820Buf+4], byte 0
- ja .int_loop ; Start >= 4 GB?
- mov eax, [E820Buf]
- cmp dword [E820Buf+16],1
- je .is_ram ; Is it memory?
- ;
- ; Non-memory range. Remember this as a limit; some BIOSes get the length
- ; of primary RAM incorrect!
- ;
-.not_ram:
- cmp eax, (1 << 20)
- jb .int_loop ; Starts in lowmem region
- cmp eax,[E820Max]
- jae .int_loop ; Already above limit
- mov [E820Max],eax ; Set limit
- jmp .int_loop
-
-.is_ram:
- cmp eax,[E820Mem]
- ja .int_loop ; Not contiguous with our starting point
- add eax,[E820Buf+8]
- jc .overflow
- cmp dword [E820Buf+12],0
- je .nooverflow
-.overflow:
- or eax,-1
-.nooverflow:
- cmp eax,[E820Mem]
- jbe .int_loop ; All is below our baseline
- mov [E820Mem],eax
- jmp .start_over ; Start over in case we find an adjacent range
-
-.e820_done:
- mov eax,[E820Mem]
- cmp eax,[E820Max]
- jna .not_limited
- mov eax,[E820Max]
-.not_limited:
- cmp eax,(1 << 20)
- ja got_highmem ; Did we actually find memory?
- ; otherwise fall through
-
-;
-; INT 15:E820 failed. Try INT 15:E801.
-;
-no_e820:
- mov ax,0e801h ; Query high memory (semi-recent)
- int 15h
- jc no_e801
- cmp ax,3c00h
- ja no_e801 ; > 3C00h something's wrong with this call
- jb e801_hole ; If memory hole we can only use low part
-
- mov ax,bx
- shl eax,16 ; 64K chunks
- add eax,(16 << 20) ; Add first 16M
- jmp short got_highmem
-
-;
-; INT 15:E801 failed. Try INT 15:88.
-;
-no_e801:
- mov ah,88h ; Query high memory (oldest)
- int 15h
- cmp ax,14*1024 ; Don't trust memory >15M
- jna e801_hole
- mov ax,14*1024
-e801_hole:
- and eax,0ffffh
- shl eax,10 ; Convert from kilobytes
- add eax,(1 << 20) ; First megabyte
-got_highmem:
-%if HIGHMEM_SLOP != 0
- sub eax,HIGHMEM_SLOP
-%endif
- mov [HighMemSize],eax
- popad
- popfd
- pop es
- ret ; Done!
-
- section .bss16
- alignb 4
-E820Buf resd 5 ; INT 15:E820 data buffer
-E820Mem resd 1 ; Memory detected by E820
-E820Max resd 1 ; Is E820 memory capped?
-; HighMemSize is defined in com32.inc
diff --git a/core/include/bios.h b/core/include/bios.h
index 42a9768c..d38f6692 100644
--- a/core/include/bios.h
+++ b/core/include/bios.h
@@ -35,6 +35,16 @@
#define BIOS_magic 0x0472 /* BIOS reset magic */
#define BIOS_vidrows 0x0484 /* Number of screen rows */
+static inline uint16_t bios_fbm(void)
+{
+ return *(volatile uint16_t *)BIOS_fbm;
+}
+
+static inline void set_bios_fbm(uint16_t mem)
+{
+ *(volatile uint16_t *)BIOS_fbm = mem;
+}
+
#define serial_buf_size 4096
#define IO_DELAY_PORT 0x80 /* Invalid port (we hope!) */
diff --git a/core/init.c b/core/init.c
index 26b4a191..ca9e413f 100644
--- a/core/init.c
+++ b/core/init.c
@@ -7,6 +7,7 @@
static uint32_t min_lowmem_heap = 65536;
extern char __lowmem_heap[];
uint8_t KbdFlags; /* Check for keyboard escapes */
+uint8_t KbdMap[256]; /* Keyboard map */
static inline void check_escapes(void)
{
diff --git a/core/isolinux.asm b/core/isolinux.asm
index 617003c6..8866298e 100644
--- a/core/isolinux.asm
+++ b/core/isolinux.asm
@@ -1202,24 +1202,15 @@ debug_tracer: pushad
%endif ; DEBUG_TRACERS
section .bss16
- global CmdOptPtr, KbdMap
alignb 4
ThisKbdTo resd 1 ; Temporary holder for KbdTimeout
ThisTotalTo resd 1 ; Temporary holder for TotalTimeout
KernelExtPtr resw 1 ; During search, final null pointer
-CmdOptPtr resw 1 ; Pointer to first option on cmd line
-KbdFlags resb 1 ; Check for keyboard escapes
FuncFlag resb 1 ; Escape sequences received from keyboard
KernelType resb 1 ; Kernel type, from vkernel, if known
-KbdMap resb 256 ; Keyboard map
global KernelName
KernelName resb FILENAME_MAX ; Mangled name for kernel
- section .config
- global PXERetry
-PXERetry dw 0 ; Extra PXE retries
section .data16
- global SerialNotice
-SerialNotice db 1 ; Only print this once
global IPAppends, numIPAppends
%if IS_PXELINUX
extern IPOption
diff --git a/core/kernel.inc b/core/kernel.inc
index 245cd6db..5e1c7a39 100644
--- a/core/kernel.inc
+++ b/core/kernel.inc
@@ -62,9 +62,6 @@ linux_fdctab resb 12
cmd_line_here equ $ ; F800 Should be out of the way
endstruc
- global cmd_line
-cmd_line equ core_real_mode + cmd_line_here
-
;
; Old kernel command line signature
;
diff --git a/core/layout.inc b/core/layout.inc
index 24843923..6d31b18e 100644
--- a/core/layout.inc
+++ b/core/layout.inc
@@ -52,7 +52,6 @@ LATEBSS_START equ 0B800h
;
; 32-bit stack layout
;
- global STACK32_LEN
STACK32_LEN equ 64*1024
section .stack nobits write align=4096
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index 63334ffa..097b856c 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -281,24 +281,15 @@ Kernel_EAX resd 1
Kernel_SI resw 1
section .bss16
- global CmdOptPtr, KbdMap
alignb 4
ThisKbdTo resd 1 ; Temporary holder for KbdTimeout
ThisTotalTo resd 1 ; Temporary holder for TotalTimeout
KernelExtPtr resw 1 ; During search, final null pointer
-CmdOptPtrj resw 1 ; Pointer to first option on cmd line
-KbdFlags resb 1 ; Check for keyboard escapes
FuncFlag resb 1 ; Escape sequences received from keyboard
KernelType resb 1 ; Kernel type, from vkernel, if known
-KbdMap resb 256 ; Keyboard map
global KernelName
KernelName resb FILENAME_MAX ; Mangled name for kernel
- section .config
- global PXERetry
-PXERetry dw 0 ; Extra PXE retries
section .data16
- global SerialNotice
-SerialNotice db 1 ; Only print this once
extern IPOption
global IPAppends, numIPAppends
alignz 2