#include <errno.h>
#include <unistd.h>
#include <string.h>
+#include <fs.h>
#include <syslinux/disk.h>
+#include <syslinux/pmapi.h>
#include "utility.h"
static const char *bpbtypes[] = {
uint32_t get_file_lba(const char *filename)
{
- com32sys_t inregs;
+ struct com32_filedata fd;
uint32_t lba = 0;
int size = 65536;
char *buf;
- /* Start with clean registers */
- memset(&inregs, 0, sizeof(com32sys_t));
-
buf = lmalloc(size);
if (!buf)
return 0;
/* Put the filename in the bounce buffer */
strlcpy(buf, filename, size);
- /* Call comapi_open() which returns a structure pointer in SI
- * to a structure whose first member happens to be the LBA.
- */
- inregs.eax.w[0] = 0x0006;
- inregs.esi.w[0] = OFFS(buf);
- inregs.es = SEG(buf);
- __com32.cs_intcall(0x22, &inregs, &inregs);
-
- if ((inregs.eflags.l & EFLAGS_CF) || inregs.esi.w[0] == 0) {
+ if (open_file(buf, &fd) <= 0) {
goto fail; /* Filename not found */
}
/* Since the first member is the LBA, we simply cast */
- lba = *((uint32_t *) MK_PTR(inregs.ds, inregs.esi.w[0]));
-
- /* Clean the registers for the next call */
- memset(&inregs, 0, sizeof(com32sys_t));
-
- /* Put the filename in the bounce buffer */
- strlcpy(buf, filename, size);
+ lba = *((uint32_t *) MK_PTR(0, fd.handle));
/* Call comapi_close() to free the structure */
- inregs.eax.w[0] = 0x0008;
- inregs.esi.w[0] = OFFS(buf);
- inregs.es = SEG(buf);
- __com32.cs_intcall(0x22, &inregs, &inregs);
+ close_file(fd.handle);
fail:
lfree(buf);
#include <string.h>
#include <com32.h>
+#include <core.h>
+#include <graphics.h>
#include "syslnx.h"
+#include <syslinux/config.h>
com32sys_t inreg, outreg; // Global registers for this module
return;
strcpy(bounce, cmd);
- REG_AX(inreg) = 0x0003; // Run command
- REG_BX(inreg) = OFFS(bounce);
- REG_ES(inreg) = SEG(bounce);
- __intcall(0x22, &inreg, &outreg);
+ load_kernel(bounce);
}
void gototxtmode(void)
{
- REG_AX(inreg) = 0x0005;
- __intcall(0x22, &inreg, &outreg);
+ syslinux_force_text_mode();
}
void syslinux_idle(void)
{
- REG_AX(inreg) = 0x0013;
- __intcall(0x22, &inreg, &outreg);
+ __idle();
}
unsigned int getversion(char *deriv, unsigned int *numfun)
{
- REG_AX(inreg) = 0x0001;
- __intcall(0x22, &inreg, &outreg);
if (deriv)
- *deriv = REG_DL(outreg);
+ *deriv = __syslinux_version.filesystem;
if (numfun)
- *numfun = REG_AX(outreg);
- return REG_CX(outreg);
+ *numfun = __syslinux_version.max_api;
+ return __syslinux_version.version;
}
void runsyslinuximage(const char *cmd, long ipappend)
* the the kernel. If we return the caller should call enter_cmdline()
* so that the user can help us out.
*/
-static void load_kernel(const char *command_line)
+void load_kernel(const char *command_line)
{
struct menu_entry *me;
const char *cmdline;
return &__syslinux_ipappend_strings;
}
+static inline enum syslinux_filesystem syslinux_filesystem(void)
+{
+ return syslinux_derivative_info()->c.filesystem;
+}
+
#endif /* _SYSLINUX_CONFIG_H */
#define SYSLINUX_FEATURE_LOCAL_BOOT (0*8+0)
#define SYSLINUX_FEATURE_NOOP_IDLE (0*8+1)
-extern struct __syslinux_feature_flags {
- unsigned int len;
- const unsigned char *ptr;
-} __syslinux_feature_flags;
+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 <= __syslinux_feature_flags.len)
- return (__syslinux_feature_flags.ptr[__byte] >> __bit) & 1;
+ if (__byte <= feature_flags_len)
+ return (feature_flags[__byte] >> __bit) & 1;
else
return 0;
}
LIBSYSLINUX_OBJS = \
syslinux/reboot.o syslinux/keyboard.o \
- syslinux/features.o \
syslinux/version.o \
syslinux/pxe_get_cached.o syslinux/pxe_get_nic.o \
syslinux/pxe_dns.o \
#include <syslinux/config.h>
#include "file.h"
#include "ansi.h"
+#include "graphics.h"
static void ansicon_erase(const struct term_state *, int, int, int, int);
static void ansicon_write_char(int, int, uint8_t, const struct term_state *);
ti.cols = 80;
} else {
/* Force text mode */
- ireg.eax.w[0] = 0x0005;
- __intcall(0x22, &ireg, NULL);
+ syslinux_force_text_mode();
/* Initial state */
ti.rows = BIOS_ROWS ? BIOS_ROWS + 1 : 25;
#include <errno.h>
#include <string.h>
#include <com32.h>
+#include <core.h>
#include <minmax.h>
#include "file.h"
/* Global, since it's used by stdcon_read */
ssize_t __rawcon_read(struct file_info *fp, void *buf, size_t count)
{
- com32sys_t ireg, oreg;
char *bufp = buf;
size_t n = 0;
+ char hi = 0;
(void)fp;
- memset(&ireg, 0, sizeof ireg);
-
while (n < count) {
+ if (hi) {
+ *bufp++ = hi;
+ n++;
+ hi = 0;
+ continue;
+ }
+
/* Poll */
- ireg.eax.b[1] = 0x0B;
- __intcall(0x21, &ireg, &oreg);
- if (!oreg.eax.b[0])
+ if (!pollchar())
break;
/* We have data, go get it */
- ireg.eax.b[1] = 0x08;
- __intcall(0x21, &ireg, &oreg);
- *bufp++ = oreg.eax.b[0];
+ *bufp++ = getchar(&hi);
n++;
}
#include <errno.h>
#include <string.h>
#include <com32.h>
+#include <core.h>
#include <minmax.h>
#include "file.h"
static ssize_t __rawcon_write(struct file_info *fp, const void *buf,
size_t count)
{
- com32sys_t ireg;
const char *bufp = buf;
size_t n = 0;
(void)fp;
- memset(&ireg, 0, sizeof ireg);
- ireg.eax.b[1] = 0x02;
-
while (count--) {
- ireg.edx.b[0] = *bufp++;
- __intcall(0x21, &ireg, NULL);
+ writechr(*bufp++);
n++;
}
#include <errno.h>
#include <string.h>
#include <com32.h>
+#include <core.h>
#include <minmax.h>
#include <syslinux/config.h>
#include "file.h"
ssize_t __serial_write(struct file_info *fp, const void *buf, size_t count)
{
- com32sys_t ireg;
const char *bufp = buf;
size_t n = 0;
if (!syslinux_serial_console_info()->iobase)
return count; /* Nothing to do */
- memset(&ireg, 0, sizeof ireg);
- ireg.eax.b[1] = 0x04;
-
while (count--) {
- ireg.edx.b[0] = *bufp++;
- __intcall(0x21, &ireg, NULL);
+ write_serial(*bufp++);
n++;
}
#include <errno.h>
#include <string.h>
#include <com32.h>
+#include <core.h>
#include <minmax.h>
#include "file.h"
static ssize_t __stdcon_write(struct file_info *fp, const void *buf,
size_t count)
{
- com32sys_t ireg;
const char *bufp = buf;
size_t n = 0;
(void)fp;
- memset(&ireg, 0, sizeof ireg);
- ireg.eax.b[1] = 0x02;
-
while (count--) {
- if (*bufp == '\n') {
- ireg.edx.b[0] = '\r';
- __intcall(0x21, &ireg, NULL);
- }
- ireg.edx.b[0] = *bufp++;
- __intcall(0x21, &ireg, NULL);
+ if (*bufp == '\n')
+ writechr('\r');
+
+ writechr(*bufp++);
n++;
}
#include <errno.h>
#include <string.h>
#include <com32.h>
+#include <core.h>
#include <minmax.h>
#include <colortbl.h>
#include <syslinux/config.h>
static void emit(char ch)
{
- static com32sys_t ireg; /* Zeroed with the BSS */
-
- ireg.eax.b[1] = 0x04;
- ireg.edx.b[0] = ch;
-
- __intcall(0x21, &ireg, NULL);
+ write_serial(ch);
}
ssize_t __xserial_write(struct file_info *fp, const void *buf, size_t count)
+++ /dev/null
-/* ----------------------------------------------------------------------- *
- *
- * 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.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * syslinux/features.c
- *
- * SYSLINUX feature flag query
- */
-
-#include <klibc/compiler.h>
-#include <syslinux/features.h>
-#include <string.h>
-#include <com32.h>
-
-struct __syslinux_feature_flags __syslinux_feature_flags;
-
-void __constructor __syslinux_detect_features(void)
-{
- static com32sys_t reg;
-
- memset(®, 0, sizeof reg);
- reg.eax.w[0] = 0x0015;
- __intcall(0x22, ®, ®);
-
- __syslinux_feature_flags.len = reg.ecx.w[0];
- __syslinux_feature_flags.ptr = MK_PTR(reg.es, reg.ebx.w[0]);
-}
#include <syslinux/config.h>
#include <klibc/compiler.h>
-#include <com32.h>
+#include <core.h>
struct syslinux_ipappend_strings __syslinux_ipappend_strings;
static const char *syslinux_ipappend_string_list[32];
void __constructor __syslinux_get_ipappend_strings(void)
{
- static com32sys_t reg;
- int i;
+ unsigned int i;
- reg.eax.w[0] = 0x000f;
- __intcall(0x22, ®, ®);
+ __syslinux_ipappend_strings.count = (size_t)numIPAppends;
+ __syslinux_ipappend_strings.ptr = syslinux_ipappend_string_list;
- if (!(reg.eflags.l & EFLAGS_CF)) {
- __syslinux_ipappend_strings.count = reg.ecx.w[0];
- __syslinux_ipappend_strings.ptr = syslinux_ipappend_string_list;
- for (i = 0; i < reg.ecx.w[0]; i++) {
- syslinux_ipappend_string_list[i] =
- MK_PTR(reg.es,
- *(uint16_t *) MK_PTR(reg.es, reg.ebx.w[0] + i * 2));
- }
- }
+ for (i = 0; i < (size_t)numIPAppends; i++)
+ syslinux_ipappend_string_list[i] = (const char *)(size_t)IPAppends[i];
}
* ----------------------------------------------------------------------- */
#include <syslinux/keyboard.h>
-#include <com32.h>
+#include <core.h>
struct syslinux_keyboard_map __syslinux_keyboard_map;
void __constructor __syslinux_get_keyboard_map(void)
{
- static com32sys_t reg;
-
- reg.eax.w[0] = 0x001e;
- __intcall(0x22, ®, ®);
- if (!(reg.eflags.l & EFLAGS_CF)) {
- __syslinux_keyboard_map.version = reg.eax.w[0];
- __syslinux_keyboard_map.length = reg.ecx.w[0];
- __syslinux_keyboard_map.map = MK_PTR(reg.es, reg.ebx.w[0]);
- }
+ __syslinux_keyboard_map.version = 1;
+ __syslinux_keyboard_map.length = sizeof(KbdMap);
+ __syslinux_keyboard_map.map = (void *)KbdMap;
}
#include <syslinux/boot.h>
#include <stddef.h>
#include <string.h>
-#include <com32.h>
+#include <core.h>
int syslinux_run_command(const char *command)
{
- static com32sys_t ireg;
char *lm_command = lstrdup(command);
if (!lm_command)
return -1;
- ireg.eax.w[0] = 0x0003;
- ireg.es = SEG(lm_command);
- /* ireg.ebx.w[0] = OFFS(lm_command); */
-
- __intcall(0x22, &ireg, NULL);
+ create_args_and_load(lm_command);
/* Should not return even on failure, but in case... */
lfree(lm_command);
* ----------------------------------------------------------------------- */
#include <syslinux/boot.h>
+#include <core.h>
#include <stddef.h>
-#include <com32.h>
+
+extern const char *default_cmd;
__noreturn syslinux_run_default(void)
{
- static com32sys_t ireg;
-
- ireg.eax.w[0] = 0x0004;
- __intcall(0x22, &ireg, NULL);
-
+ load_kernel(default_cmd);
/* Should not return even on failure */
for (;;) ;
}
#include <stdlib.h>
#include <string.h>
#include <syslinux/boot.h>
-#include <com32.h>
+#include <syslinux/config.h>
+#include <core.h>
+
+extern unsigned int ipappend;
void syslinux_run_kernel_image(const char *filename, const char *cmdline,
uint32_t ipappend_flags, uint32_t type)
{
- static com32sys_t ireg;
char *bbfilename = NULL;
char *bbcmdline = NULL;
+
bbfilename = lstrdup(filename);
if (!bbfilename)
goto fail;
if (!bbcmdline)
goto fail;
+ if (syslinux_filesystem() == SYSLINUX_FS_PXELINUX)
+ ipappend = ipappend_flags;
- ireg.eax.w[0] = 0x0016;
- ireg.ds = SEG(bbfilename);
- /* ireg.esi.w[0] = OFFS(bbfilename); */
- ireg.es = SEG(bbcmdline);
- /* ireg.ebx.w[0] = OFFS(bbcmdline); */
- ireg.ecx.l = ipappend_flags;
- ireg.edx.l = type;
-
- __intcall(0x22, &ireg, 0);
+ execute(bbfilename, type);
fail:
if (bbcmdline)
#include <klibc/compiler.h>
#include <syslinux/config.h>
#include <string.h>
-#include <com32.h>
+#include <bios.h>
+#include <core.h>
struct syslinux_serial_console_info __syslinux_serial_console_info;
void __constructor __syslinux_get_serial_console_info(void)
{
- static com32sys_t reg;
+ uint16_t flowctl;
- memset(®, 0, sizeof reg);
- reg.eax.w[0] = 0x000b;
- __intcall(0x22, ®, ®);
+ __syslinux_serial_console_info.iobase = SerialPort;
+ __syslinux_serial_console_info.divisor = BaudDivisor;
- __syslinux_serial_console_info.iobase = reg.edx.w[0];
- __syslinux_serial_console_info.divisor = reg.ecx.w[0];
- __syslinux_serial_console_info.flowctl = reg.ebx.w[0];
+ flowctl = FlowOutput | FlowInput | (FlowIgnore << 4);
+
+ if (!DisplayCon)
+ flowctl |= (0x80 << 8);
+
+ __syslinux_serial_console_info.flowctl = flowctl;
}
#include <string.h>
#include <inttypes.h>
#include <com32.h>
+#include <core.h>
#include <minmax.h>
#include <dprintf.h>
#include <syslinux/movebits.h>
static void __constructor __syslinux_get_shuffer_size(void)
{
- static com32sys_t reg;
-
- reg.eax.w[0] = 0x0023;
- __intcall(0x22, ®, ®);
-
- shuffler_size = (reg.eflags.l & EFLAGS_CF) ? 2048 : reg.ecx.w[0];
+ /* +15 padding is to guarantee alignment */
+ shuffler_size = __bcopyxx_len + 15;
}
/*
#include <syslinux/config.h>
#include <klibc/compiler.h>
-#include <com32.h>
+#include <core.h>
+#include <../../../version.h>
struct syslinux_version __syslinux_version;
void __constructor __syslinux_get_version(void)
{
- static com32sys_t reg;
+ __syslinux_version.version = (VERSION_MAJOR << 8) + VERSION_MINOR;
- reg.eax.w[0] = 0x0001;
- __intcall(0x22, ®, ®);
+ /* We no longer support the COMBOOT API */
+ __syslinux_version.max_api = 0xffff;
- __syslinux_version.version = reg.ecx.w[0];
- __syslinux_version.max_api = reg.eax.w[0];
- __syslinux_version.filesystem = reg.edx.b[0];
- __syslinux_version.version_string = MK_PTR(reg.es, reg.esi.w[0]);
- __syslinux_version.copyright_string = MK_PTR(reg.es, reg.edi.w[0]);
+ __syslinux_version.filesystem = syslinux_filesystem();
+
+ /* Skip leading CR LF */
+ __syslinux_version.version_string = &syslinux_banner[2];
+
+ /* Skip leading space */
+ __syslinux_version.copyright_string = ©right_str[1];
}
*/
#include <syslinux/video.h>
-#include <com32.h>
+#include <graphics.h>
/*
* Returns height of font or zero if no custom font loaded
*/
int syslinux_font_query(uint8_t **font)
{
- static com32sys_t ireg;
- com32sys_t oreg;
- int height;
+ if (!UserFont)
+ return 0;
- ireg.eax.w[0] = 0x0018;
- __intcall(0x22, &ireg, &oreg);
+ *font = (uint8_t *)fontbuf;
- height = !(oreg.eflags.l & EFLAGS_CF) ? oreg.eax.b[0] : 0;
- if (height)
- *font = MK_PTR(oreg.es, oreg.ebx.w[0]);
-
- return height;
+ return VGAFontSize;
}
*/
#include <syslinux/video.h>
-#include <com32.h>
+#include <graphics.h>
void syslinux_report_video_mode(uint16_t flags, uint16_t xsize, uint16_t ysize)
{
- static com32sys_t ireg;
+ if (flags > 0x0f)
+ return;
- ireg.eax.w[0] = 0x0017;
- ireg.ebx.w[0] = flags;
- ireg.ecx.w[0] = xsize;
- ireg.edx.w[0] = ysize;
- __intcall(0x22, &ireg, NULL);
+ using_vga(flags, xsize, ysize);
}
; 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)
#include <stddef.h>
#include <com32.h>
+#include <core.h>
#include <stdio.h>
#include <string.h>
void myputchar(int c)
{
- static com32sys_t ireg;
-
if (c == '\n')
myputchar('\r');
- ireg.eax.b[1] = 0x02;
- ireg.edx.b[0] = c;
- __intcall(0x21, &ireg, NULL);
+ writechr(c);
}
void myputs(const char *str)
section .data16
global SerialNotice
SerialNotice db 1 ; Only print this once
+ global IPAppends, numIPAppends
%if IS_PXELINUX
extern IPOption
- global IPAppends, numIPAppends
alignz 2
IPAppends dw IPOption
numIPAppends equ ($-IPAppends)/2
#include "graphics.h"
#include "core.h"
-static __lowmem char fontbuf[8192];
-
-extern uint8_t UserFont;
+__lowmem char fontbuf[8192];
uint16_t GXPixCols = 1; /* Graphics mode pixel columns */
uint16_t GXPixRows = 1; /* Graphics mode pixel rows */
/*
* Print the IPAPPEND strings, in order
*/
-extern const uint16_t IPAppends[];
-extern const char numIPAppends[];
-
static void print_ipappend(void)
{
size_t i;
void myputchar(int c)
{
- static com32sys_t ireg;
-
if (c == '\n')
myputchar('\r');
- ireg.eax.b[1] = 0x02;
- ireg.edx.b[0] = c;
- __intcall(0x21, &ireg, NULL);
+ writechr(c);
}
void myputs(const char *str)
#define VidRows _screensize.b.row
/* font.c */
-extern uint16_t VGAFontSize;
extern void use_font(void);
extern void bios_adjust_screen(void);
extern char syslinux_banner[];
extern char copyright_str[];
extern char StackBuf[];
+extern unsigned int __bcopyxx_len;
extern uint8_t KbdMap[256];
+extern const uint16_t IPAppends[];
+extern const char numIPAppends[];
+
+extern uint16_t SerialPort;
+extern uint16_t BaudDivisor;
+extern uint8_t FlowOutput;
+extern uint8_t FlowInput;
+extern uint8_t FlowIgnore;
+
/* diskstart.inc isolinux.asm*/
extern void getlinsec(void);
}
extern int start_ldlinux(char **argv);
+extern int create_args_and_load(char *);
extern void write_serial(char data);
extern void writestr(char *str);
extern void writechr(char data);
extern void crlf(void);
+extern int pollchar(void);
+extern char getchar(char *hi);
extern void cleanup_hardware(void);
extern void sirq_cleanup(void);
extern void adjust_screen(void);
extern void execute(const char *cmdline, uint32_t type);
+extern void load_kernel(const char *cmdline);
#endif /* CORE_H */
extern uint16_t *VGAFilePtr;
extern char VGAFileBuf[VGA_FILE_BUF_SIZE];
extern char VGAFileMBuf[];
+extern uint16_t VGAFontSize;
+
+extern uint8_t UserFont;
+
+extern __lowmem char fontbuf[8192];
extern void syslinux_force_text_mode(void);
extern void vgadisplayfile(FILE *_fd);
section .data16
global SerialNotice
SerialNotice db 1 ; Only print this once
+ global IPAppends, numIPAppends
%if IS_PXELINUX
extern IPOption
- global IPAppends, numIPAppends
alignz 2
IPAppends dw IPOption
numIPAppends equ ($-IPAppends)/2