## $Id$
## -----------------------------------------------------------------------
-##
+##
## Copyright 1998-2005 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
RANLIB = ranlib
NASM = nasm -O99
-NINCLUDE =
+NINCLUDE =
BINDIR = /usr/bin
SBINDIR = /sbin
LIBDIR = /usr/lib
#
# The BTARGET refers to objects that are derived from ldlinux.asm; we
-# like to keep those uniform for debugging reasons; however, distributors
+# like to keep those uniform for debugging reasons; however, distributors
# want to recompile the installers (ITARGET).
-#
+#
# BOBJECTS and IOBJECTS are the same thing, except used for
# installation, so they include objects that may be in subdirectories
# with their own Makefiles. Finally, there is a list of those
# _bin.c files required by both BTARGET and ITARGET installers
BINFILES = bootsect_bin.c ldlinux_bin.c mbr_bin.c \
- extlinux_bss_bin.c extlinux_sys_bin.c
+ extlinux_bss_bin.c extlinux_sys_bin.c
# syslinux.exe is BTARGET so as to not require everyone to have the
# mingw suite installed
## -*- makefile -*- ------------------------------------------------------
-##
+##
## Copyright 2000-2005 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
$(MAKE) -C $(PRERELDIR)/$(PREREL) dist
cd $(PRERELDIR)/$(PREREL) && rm -rf $(PRIVATE)
cd $(PRERELDIR) && tar cvvf - $(PREREL) | \
- gzip -9 > $(PREREL).tar.gz
+ gzip -9 > $(PREREL).tar.gz
cd $(PRERELDIR) && \
uuencode $(PREREL).tar.gz $(PREREL).tar.gz > uu/$(PREREL).uu
cd $(PRERELDIR)/$(PREREL) && \
due to a spec bug; match the most recent spec since that
seems to be what implementations actually do.
* SYSLINUX: Add some smarts to the boot sector, which
- hopefully should reduce the number of systems which require
+ hopefully should reduce the number of systems which require
stupid mode ("syslinux -s").
* PXELINUX: Document further some of the pathologies with old
PXE stacks.
* Added a "safe, slow and stupid" (-s) option to the
installers. This option will lobotomize the boot sector to
hopefully work on even very buggy BIOSes.
-
+
Changes in 1.34:
* Ability to load a VGA font on bootup (for localized Linux
- distributions.)
+ distributions.)
Changes in 1.33:
* Bug fix in the Linux installer.
; $Id$
; -----------------------------------------------------------------------
-;
+;
; Copyright 2005 H. Peter Anvin - All Rights Reserved
;
; This program is free software; you can redistribute it and/or modify
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2005 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;;
;; bcopy32.inc
-;;
+;;
;; 32-bit bcopy routine for real mode
;;
and ecx,3
shr eax,2
a32 rep movsb
-
+
; Change ESI/EDI to point to the last dword, instead
; of the last byte.
sub esi,3
; IBM ThinkPad 760EL.
;
; We typically toggle A20 twice for every 64K transferred.
-;
+;
%define io_delay call _io_delay
%define IO_DELAY_PORT 80h ; Invalid port (we hope!)
%define disable_wait 32 ; How long to wait for a disable
test al,2
jnz empty_8042
io_delay
-.done: ret
+.done: ret
;
; Execute a WBINVD instruction if possible on this CPU
#!/usr/bin/perl
## $Id$
## -----------------------------------------------------------------------
-##
+##
## Copyright 1998-2004 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
#!/usr/bin/perl
## "$Id$"
## -----------------------------------------------------------------------
-##
+##
## Copyright 2003 H. Peter Anvin - All Rights Reserved
##
## Permission is hereby granted, free of charge, to any person
## 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
}
print "\n" if ( $len );
exit 0;
-
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;;
;; bios.inc
-;;
+;;
;; Header file for the BIOS data structures etc.
;;
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2005 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;;
;; bootsect.inc
-;;
+;;
;; Load a boot sector (or other bootstrap program.)
;;
;; Unlike previous versions of this software, this doesn't require that
push word 1 ; Length of descriptor list
; Fall through
-;
+;
; Entrypoint for "shut down and replace bootstrap" -- also invoked by
; the COMBOOT API. This routine expects two words on the stack:
; address of the copy list (versus DS) and count. Additionally,
; the values of ESI and EDX are passed on to the new bootstrap;
; the value of BX becomes the new DS.
-;
+;
replace_bootstrap:
;
; Prepare for shutting down
;
xor ax,ax
mov ds,ax
- mov es,ax
+ mov es,ax
%if IS_PXELINUX
test byte [KeepPXE],01h
; -*- fundamental -*- ---------------------------------------------------
-;
+;
; Copyright 2004 H. Peter Anvin - All Rights Reserved
;
; This program is free software; you can redistribute it and/or modify
sub overlap($$$$) {
my($s1,$e1,$s2,$e2) = @_;
-
+
return 1 if ( $s2 < $e1 && $e2 > $s1 );
return 1 if ( $s1 < $e2 && $e1 > $s2 );
foreach $o ( keys(%start) ) {
next if ( $s ge $o );
-
+
$ostart = $start{$o};
$ovstart = $vstart{$o};
$oend = $ostart + $length{$o};
$ovend = $ovstart + $length{$o};
-
+
if ( overlap($sstart, $send, $ostart, $oend) ||
overlap($svstart, $svend, $ostart, $oend) ||
overlap($sstart, $send, $ovstart, $ovend) ||
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 2003 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
mov si,[CmdOptPtr]
mov di,[CmdLinePtr]
-
+
call strcpy
dec di
pop es
ret
-
-
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2003 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
or al,1
mov cr0,eax ; Enter protected mode
jmp 20h:.in_pm
-
+
bits 32
.in_pm:
xor eax,eax ; Available for future use...
libcom32 and libutil are licensed under the MIT license:
## -----------------------------------------------------------------------
-##
+##
## Copyright 2004 H. Peter Anvin - All Rights Reserved
##
## Permission is hereby granted, free of charge, to any person
## 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
extern const struct output_dev dev_ansiserial_w;
#endif /* _CONSOLE_H */
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
extern const struct output_dev dev_error_w;
#endif /* _DEV_H */
-
#define EMEDIUMTYPE 124 /* Wrong medium type */
#endif /* _ERRNO_H */
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
xx > yy ? xx : yy; })
#endif /* _MINMAX_H */
-
#define ntohq(x) __htonq(x)
#endif /* _NETINET_IN_H */
-
-
-
#define PNG_LIBPNG_BUILD_RC 3
#define PNG_LIBPNG_BUILD_STABLE 4
#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
-
+
/* Release-Specific Flags */
#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
PNG_LIBPNG_BUILD_STABLE only */
/* Ref MSDN: Private as priority over Special
* VS_FF_PRIVATEBUILD File *was not* built using standard release
* procedures. If this value is given, the StringFileInfo block must
- * contain a PrivateBuild string.
+ * contain a PrivateBuild string.
*
* VS_FF_SPECIALBUILD File *was* built by the original company using
* standard release procedures but is a variation of the standard
* file of the same version number. If this value is given, the
- * StringFileInfo block must contain a SpecialBuild string.
+ * StringFileInfo block must contain a SpecialBuild string.
*/
#if defined(PNG_USER_PRIVATEBUILD)
#define PNG_1_2_X
-/*
+/*
* PNG_USER_CONFIG has to be defined on the compiler command line. This
* includes the resource compiler for Windows DLL configurations.
*/
/*
* Added at libpng-1.2.8
- *
+ *
* If you create a private DLL you need to define in "pngusr.h" the followings:
* #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
* the DLL was built>
* number and must match your private DLL name>
* e.g. // private DLL "libpng13gx.dll"
* #define PNG_USER_DLLFNAME_POSTFIX "gx"
- *
- * The following macros are also at your disposal if you want to complete the
+ *
+ * The following macros are also at your disposal if you want to complete the
* DLL VERSIONINFO structure.
* - PNG_USER_VERSIONINFO_COMMENTS
* - PNG_USER_VERSIONINFO_COMPANYNAME
* 'Cygwin' defines/defaults:
* PNG_BUILD_DLL -- (ignored) building the dll
* (no define) -- (ignored) building an application, linking to the dll
- * PNG_STATIC -- (ignored) building the static lib, or building an
+ * PNG_STATIC -- (ignored) building the static lib, or building an
* application that links to the static lib.
- * ALL_STATIC -- (ignored) building various static libs, or building an
+ * ALL_STATIC -- (ignored) building various static libs, or building an
* application that links to the static libs.
* Thus,
* a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
* PNG_BUILD_DLL
* PNG_STATIC
* (nothing) == PNG_USE_DLL
- *
+ *
* CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
- * of auto-import in binutils, we no longer need to worry about
+ * of auto-import in binutils, we no longer need to worry about
* __declspec(dllexport) / __declspec(dllimport) and friends. Therefore,
* we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
- * to __declspec() stuff. However, we DO need to worry about
+ * to __declspec() stuff. However, we DO need to worry about
* PNG_BUILD_DLL and PNG_STATIC because those change some defaults
* such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed.
*/
# if !defined(PNG_DLL)
# define PNG_DLL
# endif
-# endif
-# endif
+# endif
+# endif
# endif
#endif
# define PNG_EASY_ACCESS_SUPPORTED
#endif
-/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
+/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
# ifndef PNG_ASSEMBLER_CODE_SUPPORTED
# define PNGAPI __cdecl
# undef PNG_IMPEXP
# define PNG_IMPEXP
-#endif
+#endif
/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
* you may get warnings regarding the linkage of png_zalloc and png_zfree.
# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */
#endif
#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT
-# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */
+# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */
#endif
/* Set this in the makefile for VC++ on Pentium, not here. */
#endif /* STDC_CONSTANT_MACROS */
#endif /* _STDINT_H */
-
-
-
-
static inline uint64_t rdmsr(uint32_t msr)
{
uint64_t v;
-
+
asm volatile("rdmsr" : "=A" (v) : "c" (msr));
return v;
}
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2005 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
.c.ls:
$(CC) $(CFLAGS) $(SOFLAGS) -S -o $@ $<
-
cp -r ../include $(INSTALLROOT)$(COM32DIR)
-include .*.d */.*.d
-
*bufp = p = malloc(bytes);
if ( !p )
return -1;
-
+
rv = vsnprintf(p, bytes, format, ap);
va_end(ap);
};
#endif /* ATEXIT_H */
-
__ctype_cntrl, /* control character */
__ctype_cntrl, /* control character */
__ctype_cntrl, /* control character */
-
+
__ctype_print|__ctype_space, /* space */
__ctype_print|__ctype_punct, /* punctuation */
__ctype_print|__ctype_punct, /* punctuation */
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
return (_fread(&ch, 1, f) == 1) ? (int)ch : EOF;
}
-
}
if ( n )
*p = '\0';
-
+
return s;
}
-
-
-
(void)argc;
/* First, eliminate all non-option cases */
-
+
if ( !carg || carg[0] != '-' || !carg[1] ) {
return -1;
}
return '?';
}
}
-
-
#endif
cmpb $32,%cl
jae 1f
-
+
shldl %cl,%eax,%edx
shl %cl,%eax
ret
-
+
1:
xorl %edx,%edx
shl %cl,%eax
#endif
cmpb $32,%cl
jae 1f
-
+
shrdl %cl,%edx,%eax
sarl %cl,%edx
ret
-
+
1:
sarl %cl,%edx
movl %edx,%eax
den = -den;
minus ^= 1;
}
-
+
v = __udivmoddi4(num, den, NULL);
if ( minus )
v = -v;
#endif
cmpb $32,%cl
jae 1f
-
+
shrdl %cl,%edx,%eax
shrl %cl,%edx
ret
-
+
1:
shrl %cl,%edx
xorl %eax,%eax
den = -den;
minus ^= 1;
}
-
+
(void) __udivmoddi4(num, den, &v);
if ( minus )
v = -v;
pop %esi
imull %esi,%ecx
addl %ecx,%edx
-#endif
+#endif
pop %esi
ret
.size __muldi3,.-__muldi3
*
* 64-bit negation
*/
-
+
.text
.align 4
.globl __negdi2
uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p)
{
uint64_t quot = 0, qbit = 1;
-
+
if ( den == 0 ) {
__divide_error();
return 0; /* If trap returns... */
Plugged memory leak of row_buf in pngtest.c when there is a png_error().
Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data.
Added "test-installed" target to makefile.32sunu, makefile.64sunu,
- makefile.beos, makefile.darwin, makefile.dec, makefile.macosx,
+ makefile.beos, makefile.darwin, makefile.dec, makefile.macosx,
makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9.
version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002]
Added "test-installed" target to makefile.cygwin and makefile.sco.
Use png_ptr->flags instead of png_ptr->transformations to pass
PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI
compatibility.
- Revised handling of SPECIALBUILD, PRIVATEBUILD,
+ Revised handling of SPECIALBUILD, PRIVATEBUILD,
PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING.
version 1.2.8rc1 [November 24, 2004]
Moved handling of BUILD macros from pngconf.h to png.h
STATUS: Under investigation. The change to pnggccrd.c in libpng-1.2.1
fixed a problem under FreeBSD but not the problem with NetBSD, which
still fails as of libpng-1.2.2rc1.
-
* In this function you will receive a pointer to new row data from
* libpng called new_row that is to replace a corresponding row (of
* the same data format) in a buffer allocated by your application.
- *
+ *
* The new row data pointer new_row may be NULL, indicating there is
* no new data to be replaced (in cases of interlace loading).
- *
+ *
* If new_row is not NULL then you need to call
* png_progressive_combine_row() to replace the corresponding row as
* shown below:
December 3, 2004
.\" end of man page
-
Technology. See the specification for conditions of use and distribution.
.LP
.\" end of man page
-
{
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
{
- msg[0]='0';
+ msg[0]='0';
msg[1]='\0';
error_message=msg;
}
case 1: sprintf(filnm, "sub-%s",
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
#if !defined(PNG_1_0_X)
- (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" :
+ (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" :
#endif
#endif
"x86");
// , "memory" // if write to a variable gcc thought was in a reg
// , "cc" // "condition codes" (flag bits)
);
-#else
+#else
_mmx_supported = 0;
#endif /* PNG_MMX_CODE_SUPPORTED */
png_size_t new_max;
png_bytep old_buffer;
- if (png_ptr->save_buffer_size > PNG_SIZE_MAX -
+ if (png_ptr->save_buffer_size > PNG_SIZE_MAX -
(png_ptr->current_buffer_size + 256))
{
png_error(png_ptr, "Potential overflow of save_buffer");
png_free(png_ptr, png_ptr->zbuf);
png_ptr->zbuf=NULL;
#ifdef PNG_USER_MEM_SUPPORTED
- png_destroy_struct_2((png_voidp)png_ptr,
+ png_destroy_struct_2((png_voidp)png_ptr,
(png_free_ptr)free_fn, (png_voidp)mem_ptr);
#else
png_destroy_struct((png_voidp)png_ptr);
{
/* We only come here via pre-1.0.12-compiled applications */
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
- if(png_sizeof(png_struct) > png_struct_size ||
+ if(png_sizeof(png_struct) > png_struct_size ||
png_sizeof(png_info) > png_info_size)
{
char msg[80];
png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
png_ptr->rowbytes + 1);
-
+
#if defined(PNG_MNG_FEATURES_SUPPORTED)
if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
{
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
- /* could skip if no transparency and
+ /* could skip if no transparency and
*/
png_color back, back_1;
png_colorp palette = png_ptr->palette;
if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
- (color_type == PNG_COLOR_TYPE_RGB ||
+ (color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
png_error(png_ptr, "Unknown filter method in IHDR");
if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
current_allocation);
while (pinfo != NULL)
{
- fprintf(STDERR, " %lu bytes at %x\n", pinfo->size,
+ fprintf(STDERR, " %lu bytes at %x\n", pinfo->size,
(unsigned int) pinfo->pointer);
pinfo = pinfo->next;
}
((uint64_t)xsubi[2] << 32);
x = (0x5deece66dULL * x) + 0xb;
-
+
xsubi[0] = (unsigned short)x;
xsubi[1] = (unsigned short)(x >> 16);
xsubi[2] = (unsigned short)(x >> 32);
{
return (long)((uint32_t)(mrand48() >> 1));
}
-
if ( __stack_size == 0 || __stack_size > total_space >> 1 )
__stack_size = total_space >> 1; /* Half for the stack, half for the heap... */
-
+
if ( total_space < __stack_size + 4*sizeof(struct arena_header) )
__stack_size = total_space - 4*sizeof(struct arena_header);
fp = (struct free_arena_header *)start;
fp->a.type = ARENA_TYPE_FREE;
fp->a.size = total_space - __stack_size;
-
+
/* Insert into chains */
fp->a.next = fp->a.prev = &__malloc_head;
fp->next_free = fp->prev_free = &__malloc_head;
struct free_arena_header *nfp, *na;
fsize = fp->a.size;
-
+
/* We need the 2* to account for the larger requirements of a free block */
if ( fsize >= size+2*sizeof(struct arena_header) ) {
/* Bigger block than required -- split block */
nfp->a.next = na;
na->a.prev = nfp;
fp->a.next = nfp;
-
+
/* Replace current block on free chain */
nfp->next_free = fp->next_free;
nfp->prev_free = fp->prev_free;
fp->next_free->prev_free = fp->prev_free;
fp->prev_free->next_free = fp->next_free;
}
-
+
return (void *)(&fp->a + 1);
}
tmp = *p;
*p = *q;
*q = tmp;
-
+
p++; q++;
}
}
static __noreturn on_exit_exit(int rv)
{
struct atexit *ap;
-
+
for ( ap = __atexit_list ; ap ; ap = ap->next ) {
ap->fctn(rv, ap->arg); /* This assumes extra args are harmless */
}
-
+
_exit(rv);
}
outb(0, 0xcf8);
oldcfa = inb(0xcfa);
outb(0, 0xcfa);
-
+
cf8 = inb(0xcf8);
cfa = inb(0xcfa);
-
+
outb(oldcf8, 0xcf8);
outb(oldcfa, 0xcfa);
sti();
-
+
return cf8 == 0 && cfa == 0;
}
return (__pci_cfg_type = type);
}
-
rs.ebx.w[0] = a >> 8; /* bus:device:function */
rs.edi.b[0] = a; /* address:reg */
__intcall(0x1a, &rs, &rs);
-
+
return (rs.eflags.l & EFLAGS_CF) ? ~(uint32_t)0 : rs.ecx.l;
}
-
case PCI_CFG_AUTO:
pci_set_config_type(PCI_CFG_AUTO);
break; /* Try again */
-
+
case PCI_CFG_TYPE1:
{
uint32_t oldcf8;
sti();
}
return r;
-
+
case PCI_CFG_TYPE2:
{
uint8_t oldcf8, oldcfa;
-
+
if ( a & (0x10 << 11) )
return (TYPE)~0; /* Device 16-31 not supported */
-
+
cli();
oldcf8 = inb(0xcf8);
oldcfa = inb(0xcfa);
case PCI_CFG_BIOS:
return (TYPE) __pci_read_bios(BIOSCALL, a);
-
+
default:
return (TYPE)~0;
}
case PCI_CFG_TYPE2:
{
uint8_t oldcf8, oldcfa;
-
+
if ( a & (0x10 << 11) )
return; /* Devices 16-31 not supported */
-
+
cli();
oldcf8 = inb(0xcf8);
oldcfa = inb(0xcfa);
do {
gap = newgap(gap);
swapped = 0;
-
+
for ( i = 0, p1 = base ; i < nmemb-gap ; i++, p1 += size ) {
j = i+gap;
if ( compar(p1, p2 = (char *)base+j*size) > 0 ) {
}
} while ( gap > 1 || swapped );
}
-
/* Make me a new block. This is kind of bogus; we should
be checking the adjacent blocks to see if we can do an
in-place adjustment... fix that later. */
-
+
oldsize = ah->a.size - sizeof(struct arena_header);
newptr = malloc(size);
return newptr;
}
}
-
static unsigned short oldseed[3];
memcpy(oldseed, __rand48_seed, sizeof __rand48_seed);
memcpy(__rand48_seed, xsubi, sizeof __rand48_seed);
-
+
return oldseed;
}
-
.globl _setjmp
.type _setjmp, @function
_setjmp: # gcc 4.0.1 wants this as an alias?
-
+
.globl setjmp
.type setjmp, @function
setjmp:
movl %eax,%edx
#else
movl 4(%esp),%edx
-#endif
+#endif
popl %ecx # Return address, and adjust the stack
xorl %eax,%eax # Return value
movl %ebx,(%edx)
return (char *)memcpy(message+6, p, (numbuf+sizeof numbuf)-p);
}
-
*q = '\0';
return bytes;
}
-
-
*q = '\0';
return bytes;
}
-
-
char *strrchr(const char *s, int c)
{
const char *found = NULL;
-
+
while ( *s ) {
if ( *s == (char) c )
found = s;
strpbrk(const char *s, const char *accept)
{
const char *ss = s+strxspn(s, accept, 1);
-
+
return *ss ? (char *)ss : NULL;
}
-
return strsep(&holder, delim);
}
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
static void ansicon_erase(int x0, int y0, int x1, int y1)
{
static com32sys_t ireg;
-
+
ireg.eax.w[0] = 0x0600; /* Clear window */
ireg.ebx.b[1] = st.attr; /* Fill with current attribute */
ireg.ecx.b[0] = x0;
break;
}
break;
-
+
case st_esc:
switch ( ch ) {
case '%':
break;
}
break;
-
+
case st_csi:
{
int p0 = st.parms[0] ? st.parms[0] : 1;
case 2:
ansicon_erase(0, xy.y, cols-1, xy.y);
break;
-
+
default:
/* Ignore */
break;
break;
}
}
-
+
/* Turn into an attribute code */
{
int bg = st.bg;
ireg.edx.b[1] = xy.y;
ireg.edx.b[0] = xy.x;
__intcall(0x10, &ireg, NULL);
-}
-
+}
+
ssize_t __ansicon_write(struct file_info *fp, const void *buf, size_t count)
{
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
arg = ALIGN_UP(q,char *);
*argv = arg;
*arg++ = argv0; /* argv[0] */
-
+
q--; /* Point q to final null */
if ( mem < q )
*arg++ = mem; /* argv[1] */
return argc;
}
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
if ( rv )
return rv;
}
-
+
if ( fp->oop->close ) {
rv = fp->oop->close(fp);
if ( rv )
return rv;
}
-
+
memset(fp, 0, sizeof *fp); /* File structure unused */
return 0;
}
#ident "$Id$"
# -----------------------------------------------------------------------
-#
+#
# Copyright 2003-2004 H. Peter Anvin - All Rights Reserved
#
# Permission is hereby granted, free of charge, to any person
# 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
# COM32 start up code - must be linked first in the binary
-
+
.section ".init","ax"
.globl _start
.type _start, @function
call *(__exit_handler)
hlt
.size _start, .-_start
-
+
.bss
.globl __entry_esp
__entry_esp: .space 4
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ifdef REGPARM
pushl %eax
#endif
-
+
# Run any destructors
movl $__dtors_start, %esi
2:
call *(%esi)
addl $4,%esi
jmp 2b
-
+
1:
#ifdef REGPARM
popl %eax
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2003-2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
ireg.esi.w[0] = fp->i.filedes;
ireg.ecx.w[0] = MAXBLOCK >> fp->i.blocklg2;
-
+
__intcall(0x22, &ireg, &oreg);
if ( oreg.eflags.l & EFLAGS_CF ) {
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2005 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
int fstat(int fd, struct stat *buf)
{
struct file_info *fp = &__file_info[fd];
-
+
if ( fd >= NFILES || !fp->iop ) {
errno = EBADF;
return -1;
}
-
+
if ( fp->iop->flags & __DEV_FILE ) {
buf->st_mode = S_IFREG | 0444;
buf->st_size = fp->i.length;
return 0;
}
-
-
{
int fd = fileno(stream);
struct file_info *fp = &__file_info[fd];
-
+
return fp->i.offset;
}
-
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2005 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
/* This call isn't supported on SYSLINUX < 3.08, but all it does
is return an error, so we don't care. */
-
+
if ( do_idle ) {
__intcall(0x22, &sys_idle, &idle_result);
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
switch ( ch ) {
case '\n': /* Ignore incoming linefeed */
break;
-
+
case '\r':
*buf = '\n';
Write(fp, "\n", 1);
return n+1;
-
+
case '\b':
if ( n > 0 ) {
n--; buf--;
Write(fp, "\b \b", 3);
}
break;
-
+
default:
if ( n < bufsize-1 ) {
*buf = ch;
}
}
}
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2003-2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
if ( fd < 0 )
return -1;
-
+
fp = &__file_info[fd];
strlcpy(__com32.cs_bounce, pathname, __com32.cs_bounce_size);
regs.es = SEG(__com32.cs_bounce);
__com32.cs_intcall(0x22, ®s, ®s);
-
+
if ( (regs.eflags.l & EFLAGS_CF) || regs.esi.w[0] == 0 ) {
errno = ENOENT;
return -1;
fp->i.nbytes = 0;
return fd;
-}
+}
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2003-2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
(void)fp;
- memset(&ireg, 0, sizeof ireg);
+ memset(&ireg, 0, sizeof ireg);
start = times(NULL);
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
(void)fp;
- memset(&ireg, 0, sizeof ireg);
+ memset(&ireg, 0, sizeof ireg);
ireg.eax.b[1] = 0x02;
while ( count-- ) {
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
ssize_t read(int fd, void *buf, size_t count)
{
struct file_info *fp = &__file_info[fd];
-
+
if ( fd >= NFILES || !fp->iop ) {
errno = EBADF;
return -1;
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
(void)fp;
- memset(&ireg, 0, sizeof ireg);
+ memset(&ireg, 0, sizeof ireg);
ireg.eax.b[1] = 0x04;
while ( count-- ) {
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
(void)fp;
- memset(&ireg, 0, sizeof ireg);
+ memset(&ireg, 0, sizeof ireg);
ireg.eax.b[1] = 0x02;
while ( count-- ) {
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
*bufp = p = malloc(bytes);
if ( !p )
return -1;
-
+
return vsnprintf(p, bytes, format, ap);
}
{
char sch;
int i;
-
+
if ( prec != -1 && slen > prec )
slen = prec;
-
+
if ( width > slen && !(flags & FL_MINUS) ) {
char pad = (flags & FL_ZERO) ? '0' : ' ';
while ( width > slen ) {
}
}
break;
-
+
default: /* Anything else, including % */
EMIT(ch);
break;
case 'u': /* Unsigned decimal integer */
base = 10; sign = 0;
goto scan_int;
-
+
case 'x': /* Hexadecimal integer */
case 'X':
base = 16; sign = 0;
}
}
break;
-
+
case 'c': /* Character */
width = (flags & FL_WIDTH) ? width : 1; /* Default width == 1 */
sarg = va_arg(ap, char *);
}
}
break;
-
+
case '[': /* Character range */
sarg = va_arg(ap, char *);
state = st_match_init;
}
}
break;
-
+
case st_match_init: /* Initial state for %[ match */
if ( ch == '^' && !(flags & FL_INV) ) {
matchinv = 1;
state = st_match;
}
break;
-
+
case st_match: /* Main state for %[ match */
if ( ch == ']' ) {
goto match_run;
set_bit(matchmap, (unsigned char)ch);
}
break;
-
+
case st_match_range: /* %[ match after - */
if ( ch == ']' ) {
set_bit(matchmap, (unsigned char)'-'); /* - was last character */
32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
};
-
#ident "$Id$"
## -----------------------------------------------------------------------
-##
+##
## Copyright 2001-2004 H. Peter Anvin - All Rights Reserved
##
## Permission is hereby granted, free of charge, to any person
## 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
install: all
mkdir -m 755 -p $(INSTALLROOT)$(COM32DIR)
install -m 644 libutil_com.a libutil_lnx.a $(INSTALLROOT)$(COM32DIR)
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
fputs("\033[0m\033[20h", stdout);
}
-#else
+#else
#include <stdio.h>
#include <termios.h>
fputs("\033[0m\033[20l", stdout);
tcsetattr(0, TCSANOW, &original_termios_settings);
}
-
+
void console_ansi_std(void)
{
}
#endif
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
fputs("\033[0m\033[20h", stdout);
}
-#else
+#else
#include <stdio.h>
#include <termios.h>
fputs("\033[0m\033[20l", stdout);
tcsetattr(0, TCSANOW, &original_termios_settings);
}
-
+
void console_ansi_raw(void)
{
}
#endif
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2005 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
/* We really should remember this and return subsequent characters later */
return buffer[0];
}
-
-
-
-
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2005 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2005 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
void console_ansi_raw(void);
#endif /* LIBUTIL_CONSOLES_H */
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2005 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
xx > yy ? xx : yy; })
#endif /* _MINMAX_H */
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2005 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
fclose(f);
return -1;
}
-
-
if ( !ml )
return NULL;
-
+
ml->dst = dst;
ml->src = src;
ml->len = len;
assert(start >= ml->src);
assert(start < ml->src+ml->len);
-
+
/* Split off the beginning */
if ( start > ml->src ) {
uintptr_t l = start - ml->src;
parentptr = split_movelist(start, len, parentptr);
c = *parentptr;
}
-
+
*parentptr = c->next;
free(c);
}
/*
* Remove any chunk from the freelist which is already
* claimed by source data. This somewhat frivolously
- * assumes that the fragments are either completely
+ * assumes that the fragments are either completely
* covered by a free zone or not covered at all.
*/
static void
copylen = (*ep)->len;
}
allocate_from(copydst, copylen, ep);
-
+
if ( copylen >= o->len - (needbase-o->src) ) {
copysrc = o->src + (o->len - copylen);
} else {
goto move_chunk;
}
return -1; /* Stuck! */
-
+
move_chunk:
/* We're allowed to move the chunk into place now. */
fp = split_movelist(f->src, copylen+(needbase-f->dst), fp);
f = *fp;
}
-
+
mv = new_movelist(f->dst, f->src, f->len);
dprintf("A: 0x%08x bytes at 0x%08x -> 0x%08x\n",
mv->len, mv->src, mv->dst);
}
#endif /* TEST */
-
100% Public Domain
-----------------
-Modified 7/98
+Modified 7/98
By James H. Brown <jbrown@burgoyne.com>
Still 100% Public Domain
be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
"a"s).
-I also changed the declaration of variables i & j in SHA1Update to
+I also changed the declaration of variables i & j in SHA1Update to
unsigned long from unsigned int for the same reason.
These changes should make no difference to any 32 bit implementations since
Modified 4/01
By Saul Kravitz <Saul.Kravitz@celera.com>
Still 100% PD
-Modified to run on Compaq Alpha hardware.
+Modified to run on Compaq Alpha hardware.
-----------------
Modified 2/03
void SHAPrintContext(SHA1_CTX *context, char *msg){
printf("%s (%d,%d) %x %x %x %x %x\n",
msg,
- context->count[0], context->count[1],
+ context->count[0], context->count[1],
context->state[0],
context->state[1],
context->state[2],
SHA1Transform(context->state, context->buffer);
#endif
}
-
+
/*************************************************************/
/* This is not quite the MIME base64 algorithm: it uses _ instead of /,
fputs("Unable to open file.", stderr);
return(-1);
}
- }
+ }
SHA1Init(&context);
while (!feof(file)) { /* note: what if ferror(file) */
i = fread(buffer, 1, 16384, file);
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2005 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
char v;
size_t nbytes = 0;
-
+
memset(base64tbl, -1, sizeof base64tbl);
for ( i = 0 ; _base64chars[i] ; i++ ) {
base64tbl[_base64chars[i]] = i;
}
-
+
/* Also support filesystem safe alternate base64 encoding */
base64tbl['.'] = 62;
base64tbl['-'] = 62;
nbytes++;
nbits -= 8;
}
- }
+ }
txt++;
}
return nbytes;
}
-
#ident "$Id$"
## -----------------------------------------------------------------------
-##
+##
## Copyright 2001-2004 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
install: all
mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
install -m 644 $(MODULES) $(INSTALLROOT)$(AUXDIR)
-
fputs("Error: no recognized network card found!\n", stderr);
return 1;
}
-
or, as a choice in a menu:
LABEL Xen
- KERNEL mboot.c32
+ KERNEL mboot.c32
APPEND xen.gz dom0_mem=15000 nosmp noacpi --- linux.gz console=tty0 root=/dev/hda1 --- initrd.img
mboot.c32 requires version 2.12 or later of SYSLINUX.
Tim Deegan, May 2005
-
#ident "$Id$"
## -----------------------------------------------------------------------
-##
+##
## Copyright 2001-2004 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
break;
printf(": %s", buffer);
}
-
+
return 0;
}
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
exit(0);
} else if ( key == '?' )
return;
-
+
if ( key >= 0x20 && key < 0x100 ) {
putchar(key);
} else {
exit(0);
} else if ( key == '!' )
return;
-
+
printf("<%02x>", key);
}
}
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
} else {
printf("%s not found\n", argv[1]);
}
-
+
return 0;
}
characters received from the keyboard are returned as NUL (00h)
+ the extended character code.
-
+
INT 21h AH=02h [2.01] Write Character
Writes a character in DL to the console (video and serial)
The copies must not touch memory below address 7C00h.
ES:DI points to a list of CX descriptors each of the form:
-
+
Offset Size Meaning
0 dword destination address
4 dword source address
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2005 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;;
;; comboot.inc
-;;
+;;
;; Common code for running a COMBOOT image
;;
jmp comboot_exit_special ; Terminate task, clean up
;
-; INT 22h AX=0004h Run default command
+; INT 22h AX=0004h Run default command
;
; Terminates the COMBOOT program and executes the default command line
; as if a timeout had happened or the user pressed <Enter>.
%else
comapi_dnsresolv equ comapi_err
%endif
-
+
section .text
;
mov [Kernel_SI],si
mov [Kernel_EAX],ax
mov [Kernel_EAX+2],dx
-
+
; It's not just possible, but quite likely, that ES:BX
; points into real_mode_seg, so we need to exercise some
; special care here... use xfer_buf_seg as an intermediary
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 2002-2005 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2005 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
rep movsd
loadkeys_ret: ret
-
+
;
; get_msg_file: Load a text file and write its contents to the screen,
; interpreting color codes. Is called with SI and DX:AX
in al,dx
and al,ah
cmp al,ah
- jne .waitspace
-.no_flow:
+ jne .waitspace
+.no_flow:
xchg dx,bx ; DX -> THR
pop ax
; -*- fundamental -*- (asm-mode sucks)
; $Id$
; -----------------------------------------------------------------------
-;
+;
; Copyright 1998-2004 H. Peter Anvin - All Rights Reserved
;
; This program is free software; you can redistribute it and/or modify
xor cx,cx
mov si,pspCommandArg
mov cl,[pspCommandLen]
-
+
cmdscan1: jcxz bad_usage ; End of command line?
lodsb ; Load character
dec cx
cmp al,' '
ja copyfile
jmp short got_cmdline
-
+
;
; We end up here if the command line doesn't parse
;
inc dl ; 1-based
mov ah,32h
int 21h ; Get Drive Parameter Block
-
+
and al,al
jnz filesystem_error
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;;
;; cpuinit.inc
-;;
+;;
;; CPU-dependent initialization and related checks.
;;
mov byte [try_wbinvd],0c3h ; Near RET
is_486:
%endif ; DO_WBINVD
-
I appreciate your assistance in this matter.
H. Peter Anvin
-
; -*- fundamental -*-
; -----------------------------------------------------------------------
-;
+;
; Copyright 2004-2005 H. Peter Anvin - All Rights Reserved
;
; This program is free software; you can redistribute it and/or modify
; this should be the normal thing for client-serving DNS servers.)
;
-DNS_PORT equ htons(53) ; Default DNS port
+DNS_PORT equ htons(53) ; Default DNS port
DNS_MAX_PACKET equ 512 ; Defined by protocol
; TFTP uses the range 49152-57343
DNS_LOCAL_PORT equ htons(60053) ; All local DNS queries come from this port #
movzx cx,al ; End label?
and cx,cx ; ZF = 1 if match
jz .done
-
+
; We have a string of bytes that need to match now
repe cmpsb
je .label
stosw
stosw
stosw
-
+
call dns_mangle ; Convert name to DNS labels
push cs ; DS <- CS
push cx
push dx
- mov word [pxe_udp_write_pkt_dns.status],0
+ mov word [pxe_udp_write_pkt_dns.status],0
mov [pxe_udp_write_pkt_dns.sip],eax
mov [pxe_udp_read_pkt_dns.sip],eax
xor al,80h ; Query#/Answer bit
test ax,htons(0F80Fh)
jnz .badness
-
+
lodsw
xchg ah,al ; ntohs
mov cx,ax ; Questions echoed
; then at least try a different setver...
test word [DNSRecvBuf+dnshdr.flags],htons(0480h)
jz .timeout
-
+
xor eax,eax
jmp .gotresult
$(CC) $(CFLAGS) -D__ASSEMBLY__ -S -o $@ $<
-include .*.d
-
-
-
den = -den;
minus ^= 1;
}
-
+
v = __udivmoddi4(num, den, NULL);
if ( minus )
v = -v;
uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p)
{
uint64_t quot = 0, qbit = 1;
-
+
if ( den == 0 ) {
asm volatile("int $0");
return 0; /* If trap returns... */
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* 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
return argc;
}
-
i = i*10 + (*s++ - '0');
return i;
}
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2001-2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
#ifndef REGPARM
# error "This file assumes -mregparm=3 -DREGPARM=3"
#endif
-
+
.section ".init","ax"
.globl _start
.type _start,@function
_start:
# Align the stack and make sure the high half is zero
andl $0xfff8,%esp
-
+
# Clear the .bss
cld
xorl %eax,%eax
calll main
# Here %eax is the exit code, fall through into exit
-
+
.size _start,.-_start
.globl exit
fp = (struct free_arena_header *)start;
fp->a.type = ARENA_TYPE_FREE;
fp->a.size = total_space - __stack_size;
-
+
/* Insert into chains */
fp->a.next = fp->a.prev = &__malloc_head;
fp->next_free = fp->prev_free = &__malloc_head;
struct free_arena_header *nfp, *na;
fsize = fp->a.size;
-
+
/* We need the 2* to account for the larger requirements of a free block */
if ( fsize >= size+2*sizeof(struct arena_header) ) {
/* Bigger block than required -- split block */
nfp->a.next = na;
na->a.prev = nfp;
fp->a.next = nfp;
-
+
/* Replace current block on free chain */
nfp->next_free = fp->next_free;
nfp->prev_free = fp->prev_free;
fp->next_free->prev_free = fp->prev_free;
fp->prev_free->next_free = fp->next_free;
}
-
+
return (void *)(&fp->a + 1);
}
{
printf("%s: error %s\n", msg, errno);
}
-
char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
int i;
-
+
if (type & LARGE)
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (type & LEFT)
int i, base;
char * str;
const char *s;
-
+
int flags; /* flags to number() */
-
+
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
-
+
for (str=buf ; *fmt ; ++fmt) {
if (*fmt != '%') {
*str++ = *fmt;
continue;
}
-
+
/* process flags */
flags = 0;
repeat:
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
-
+
/* get field width */
field_width = -1;
if (isdigit(*fmt))
flags |= LEFT;
}
}
-
+
/* get the precision */
precision = -1;
if (*fmt == '.') {
- ++fmt;
+ ++fmt;
if (isdigit(*fmt))
precision = skip_atou(&fmt);
else if (*fmt == '*') {
if (precision < 0)
precision = 0;
}
-
+
/* get the conversion qualifier */
qualifier = -1;
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
qualifier = *fmt;
++fmt;
}
-
+
/* default base */
base = 10;
-
+
switch (*fmt) {
case 'c':
if (!(flags & LEFT))
while (--field_width > 0)
*str++ = ' ';
continue;
-
+
case 's':
s = va_arg(args, char *);
len = strnlen(s, precision);
-
+
if (!(flags & LEFT))
while (len < field_width--)
*str++ = ' ';
while (len < field_width--)
*str++ = ' ';
continue;
-
+
case 'p':
if (field_width == -1) {
field_width = 2*sizeof(void *);
(unsigned long) va_arg(args, void *), 16,
field_width, precision, flags);
continue;
-
-
+
+
case 'n':
if (qualifier == 'l') {
long * ip = va_arg(args, long *);
*ip = (str - buf);
}
continue;
-
+
case '%':
*str++ = '%';
continue;
-
+
/* integer number formats - set up the flags and "break" */
case 'o':
base = 8;
break;
-
+
case 'X':
flags |= LARGE;
case 'x':
base = 16;
break;
-
+
case 'd':
case 'i':
flags |= SIGN;
case 'u':
break;
-
+
default:
*str++ = '%';
if (*fmt)
{
va_list args;
int i;
-
+
va_start(args, fmt);
i=vsprintf(buf,fmt,args);
va_end(args);
return printed;
}
-
unsigned int skip_atou(const char **s)
{
int i=0;
-
+
while (isdigit(**s))
i = i*10 + *((*s)++) - '0';
return i;
#define fprintf(x, y, ...) printf(y, ## __VA_ARGS__)
#endif /* STDIO_H */
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 1998-2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
if ( err )
die("sector read error");
-}
+}
/* Both traditional DOS and FAT32 DOS return this structure, but
FAT32 return a lot more data, so make sure we have plenty of space */
struct deviceparams dp;
dp.specfunc = 1; /* Get current information */
-
+
rv = 0x440d;
asm volatile("int $0x21 ; setc %0"
: "=abcdm" (err), "+a" (rv)
if ( !err )
return dp.hiddensecs;
-
+
rv = 0x440d;
asm volatile("int $0x21 ; setc %0"
: "=abcdm" (err), "+a" (rv)
asm volatile("int $0x21 ; setc %0"
: "=abcdm" (err), "+a" (rv)
: "c" (0x4841), "d" (&mbr), "b" (drive));
-
+
if ( err )
die("mbr write error");
}
asm volatile("int $0x21 ; setc %0"
: "=abcdm" (err), "+a" (rv)
: "c" (0x4861), "d" (&mbr), "b" (drive));
-
+
if ( err )
die("mbr read error");
}
memcpy(sectbuf, syslinux_mbr, syslinux_mbr_len);
*(uint16_t *)(sectbuf+510) = 0xaa55;
}
-
+
if ( set_active ) {
uint32_t offset = get_partition_offset(device);
struct mbr_entry *me = (struct mbr_entry *)(sectbuf+446);
int found = 0;
-
+
for ( i = 0 ; i < 4 ; i++ ) {
if ( me->startlba == offset ) {
me->active = 0x80;
die("multiple aliased partitions found");
}
}
-
+
write_mbr(device, sectbuf);
}
dprintf("argv[%d] = %p = \"%s\"\n", i, argv[i], argv[i]);
(void)argc; /* Unused */
-
+
get_dos_version();
for ( argp = argv+1 ; *argp ; argp++ ) {
putchar('\n');
exit(1);
}
-
+
ldlinux_name[0] = dev_fd | 0x40;
set_attributes(ldlinux_name, 0);
return 0;
}
-
; $Id$
; -----------------------------------------------------------------------
-;
+;
; Copyright 1998-2005 H. Peter Anvin - All Rights Reserved
;
; This program is free software; you can redistribute it and/or modify
; Structure definition for the ext2 superblock
;
struc ext2_super_block
-s_inodes_count resd 1 ; Inodes count
-s_blocks_count resd 1 ; Blocks count
-s_r_blocks_count resd 1 ; Reserved blocks count
-s_free_blocks_count resd 1 ; Free blocks count
-s_free_inodes_count resd 1 ; Free inodes count
-s_first_data_block resd 1 ; First Data Block
-s_log_block_size resd 1 ; Block size
-s_log_frag_size resd 1 ; Fragment size
-s_blocks_per_group resd 1 ; # Blocks per group
-s_frags_per_group resd 1 ; # Fragments per group
-s_inodes_per_group resd 1 ; # Inodes per group
-s_mtime resd 1 ; Mount time
-s_wtime resd 1 ; Write time
-s_mnt_count resw 1 ; Mount count
-s_max_mnt_count resw 1 ; Maximal mount count
-s_magic resw 1 ; Magic signature
-s_state resw 1 ; File system state
-s_errors resw 1 ; Behaviour when detecting errors
-s_minor_rev_level resw 1 ; minor revision level
-s_lastcheck resd 1 ; time of last check
-s_checkinterval resd 1 ; max. time between checks
-s_creator_os resd 1 ; OS
-s_rev_level resd 1 ; Revision level
-s_def_resuid resw 1 ; Default uid for reserved blocks
-s_def_resgid resw 1 ; Default gid for reserved blocks
-s_first_ino resd 1 ; First non-reserved inode
-s_inode_size resw 1 ; size of inode structure
-s_block_group_nr resw 1 ; block group # of this superblock
-s_feature_compat resd 1 ; compatible feature set
-s_feature_incompat resd 1 ; incompatible feature set
-s_feature_ro_compat resd 1 ; readonly-compatible feature set
-s_uuid resb 16 ; 128-bit uuid for volume
-s_volume_name resb 16 ; volume name
-s_last_mounted resb 64 ; directory where last mounted
-s_algorithm_usage_bitmap resd 1 ; For compression
+s_inodes_count resd 1 ; Inodes count
+s_blocks_count resd 1 ; Blocks count
+s_r_blocks_count resd 1 ; Reserved blocks count
+s_free_blocks_count resd 1 ; Free blocks count
+s_free_inodes_count resd 1 ; Free inodes count
+s_first_data_block resd 1 ; First Data Block
+s_log_block_size resd 1 ; Block size
+s_log_frag_size resd 1 ; Fragment size
+s_blocks_per_group resd 1 ; # Blocks per group
+s_frags_per_group resd 1 ; # Fragments per group
+s_inodes_per_group resd 1 ; # Inodes per group
+s_mtime resd 1 ; Mount time
+s_wtime resd 1 ; Write time
+s_mnt_count resw 1 ; Mount count
+s_max_mnt_count resw 1 ; Maximal mount count
+s_magic resw 1 ; Magic signature
+s_state resw 1 ; File system state
+s_errors resw 1 ; Behaviour when detecting errors
+s_minor_rev_level resw 1 ; minor revision level
+s_lastcheck resd 1 ; time of last check
+s_checkinterval resd 1 ; max. time between checks
+s_creator_os resd 1 ; OS
+s_rev_level resd 1 ; Revision level
+s_def_resuid resw 1 ; Default uid for reserved blocks
+s_def_resgid resw 1 ; Default gid for reserved blocks
+s_first_ino resd 1 ; First non-reserved inode
+s_inode_size resw 1 ; size of inode structure
+s_block_group_nr resw 1 ; block group # of this superblock
+s_feature_compat resd 1 ; compatible feature set
+s_feature_incompat resd 1 ; incompatible feature set
+s_feature_ro_compat resd 1 ; readonly-compatible feature set
+s_uuid resb 16 ; 128-bit uuid for volume
+s_volume_name resb 16 ; volume name
+s_last_mounted resb 64 ; directory where last mounted
+s_algorithm_usage_bitmap resd 1 ; For compression
s_prealloc_blocks resb 1 ; Nr of blocks to try to preallocate
-s_prealloc_dir_blocks resb 1 ; Nr to preallocate for dirs
+s_prealloc_dir_blocks resb 1 ; Nr to preallocate for dirs
s_padding1 resw 1
-s_reserved resd 204 ; Padding to the end of the block
+s_reserved resd 204 ; Padding to the end of the block
endstruc
%ifndef DEPEND
; Structure definition for the ext2 inode
;
struc ext2_inode
-i_mode resw 1 ; File mode
-i_uid resw 1 ; Owner Uid
-i_size resd 1 ; Size in bytes
-i_atime resd 1 ; Access time
-i_ctime resd 1 ; Creation time
-i_mtime resd 1 ; Modification time
-i_dtime resd 1 ; Deletion Time
-i_gid resw 1 ; Group Id
-i_links_count resw 1 ; Links count
-i_blocks resd 1 ; Blocks count
-i_flags resd 1 ; File flags
+i_mode resw 1 ; File mode
+i_uid resw 1 ; Owner Uid
+i_size resd 1 ; Size in bytes
+i_atime resd 1 ; Access time
+i_ctime resd 1 ; Creation time
+i_mtime resd 1 ; Modification time
+i_dtime resd 1 ; Deletion Time
+i_gid resw 1 ; Group Id
+i_links_count resw 1 ; Links count
+i_blocks resd 1 ; Blocks count
+i_flags resd 1 ; File flags
l_i_reserved1 resd 1
i_block resd EXT2_N_BLOCKS ; Pointer to blocks
-i_version resd 1 ; File version (for NFS)
-i_file_acl resd 1 ; File ACL
-i_dir_acl resd 1 ; Directory ACL
-i_faddr resd 1 ; Fragment address
-l_i_frag resb 1 ; Fragment number
-l_i_fsize resb 1 ; Fragment size
+i_version resd 1 ; File version (for NFS)
+i_file_acl resd 1 ; File ACL
+i_dir_acl resd 1 ; Directory ACL
+i_faddr resd 1 ; Fragment address
+l_i_frag resb 1 ; Fragment number
+l_i_fsize resb 1 ; Fragment size
i_pad1 resw 1
l_i_reserved2 resd 2
endstruc
; 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.
-;
+;
; ****************************************************************************
%define IS_EXTLINUX 1
mov eax,[FirstSector] ; Sector start
mov bx,ldlinux_sys ; Where to load it
call getonesec
-
+
; Some modicum of integrity checking
cmp dword [ldlinux_magic+4],LDLINUX_MAGIC^HEXDATE
jne kaboom
cmp bp,si
jna .bp_ok
mov bp,si
-.bp_ok:
+.bp_ok:
shl ah,6 ; Because IBM was STOOPID
; and thought 8 bits were enough
shr word [MaxTransfer],1
jnz .resume
; Fall through to disk_error
-
+
;
; kaboom: write a message and bail out.
;
disk_error:
kaboom:
xor si,si
- mov ss,si
+ mov ss,si
mov sp,StackBuf-4 ; Reset stack
mov ds,si ; Reset data segment
pop dword [fdctab] ; Restore FDC table
SectorPtrs times 64 dd 0
ldlinux_ent:
-;
+;
; Note that some BIOSes are buggy and run the boot sector at 07C0:0000
; instead of 0000:7C00 and the like. We don't want to add anything
; more to the boot sector, so it is written to not assume a fixed
; Now, we need the block group descriptor.
; To get that, we first need the relevant descriptor block.
-
+
shl eax, ext2_group_desc_lg2size ; Get byte offset in desc table
xor edx,edx
div dword [ClustSize]
cmp byte [di],0 ; More path?
je .err ; If not, bad
-
+
.skipslash: ; Skip redundant slashes
cmp byte [di],'/'
jne .readdir
.getent:
cmp dword [bx+d_inode],0
je .endblock
-
+
push di
movzx cx,byte [bx+d_name_len]
lea si,[bx+d_name]
.maybe:
mov eax,[bx+d_inode]
-
+
; Does this match the end of the requested filename?
cmp byte [di],0
je .finish
;
; FIX: we may want to support \-escapes here (and this would
; be the place.)
-;
+;
mangle_name:
push bx
xor ax,ax
mkdir -p /boot/extlinux
extlinux -i /boot/extlinux
- ... to create a subdirectory and install extlinux in it.
+ ... to create a subdirectory and install extlinux in it.
2. The configuration file is called "extlinux.conf", and is expected
$(CC) $(CFLAGS) -S -o $@ $<
-include .*.d
-
-
-
#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
#define EXT2_NOCOMP_FL 0x00000400 /* Don't compress */
#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */
-/* End compression flags --- maybe not all used */
+/* End compression flags --- maybe not all used */
#define EXT2_BTREE_FL 0x00001000 /* btree format dir */
#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
* the incompatible feature set is that if there is a bit set
* in the incompatible feature set that the kernel doesn't
* know about, it should refuse to mount the filesystem.
- *
+ *
* e2fsck's requirements are more strict; if it doesn't know
* about a feature in either the compatible or incompatible
* feature set, it must abort and not try to meddle with
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 1998-2005 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
{ "help", 0, NULL, 'h' },
{ 0, 0, 0, 0 }
};
-
+
static const char short_options[] = "iUuzS:H:vh";
bs32VolumeLabel = 71,
bs32FileSysType = 82,
bs32Code = 90,
-
+
bsSignature = 0x1fe
};
nblk = 0;
while ( nsectors ) {
-
+
blk = nblk++;
dprintf("querying block %u\n", blk);
if ( ioctl(fd, FIBMAP, &blk) )
geo->cylinders = fd_str.track;
geo->start = 0;
return 0;
- }
+ }
/* Didn't work. Let's see if this is one of the standard geometries */
for ( gp = standard_geometries ; gp->bytes ; gp++ ) {
/* First sector need pointer in boot sector */
set_32(boot_block+0x1F8, *sectp++);
nsect--;
-
+
/* Search for LDLINUX_MAGIC to find the patch area */
for ( p = boot_image ; get_32(p) != LDLINUX_MAGIC ; p += 4 );
patcharea = p+8;
-
+
/* Set up the totals */
dw = boot_image_len >> 2; /* COMPLETE dwords! */
set_16(patcharea, dw);
set_16(patcharea+2, nsect); /* Does not include the first sector! */
set_32(patcharea+8, dirst.st_ino); /* "Current" directory */
-
+
/* Set the sector pointers */
p = patcharea+12;
-
+
memset(p, 0, 64*4);
while ( nsect-- ) {
set_32(p, *sectp++);
p += 4;
}
-
+
/* Now produce a checksum */
set_32(patcharea+4, 0);
csum = LDLINUX_MAGIC;
for ( i = 0, p = boot_image ; i < dw ; i++, p += 4 )
csum -= get_32(p); /* Negative checksum */
-
+
set_32(patcharea+4, csum);
}
fprintf(stderr, "no ext2/ext3 superblock found on %s\n", device);
return 1;
}
-
+
if ( xpwrite(fd, boot_block, boot_block_len, 0) != boot_block_len ) {
perror("writing bootblock");
return 1;
perror(path);
goto bail;
}
-
+
fd = open(file, O_RDONLY);
if ( fd < 0 ) {
if ( errno != ENOENT ) {
perror(file);
goto bail;
}
-
+
/* Write it the first time */
if ( xpwrite(fd, boot_image, boot_image_len, 0) != boot_image_len ) {
fprintf(stderr, "%s: write failure on %s\n", program, file);
fprintf(stderr, "%s: Not a directory: %s\n", program, path);
return 1;
}
-
+
devfd = -1;
if ( (mtab = setmntent("/proc/mounts", "r")) ) {
fprintf(stderr, "%s: cannot open device %s\n", program, devname);
return 1;
}
-
+
if ( update_only && !already_installed(devfd) ) {
fprintf(stderr, "%s: no previous extlinux boot sector found\n", program);
return 1;
}
-
+
install_file(path, devfd, &fst);
if ( fst.st_dev != st.st_dev ) {
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
popa
ret
-
+
; VGA font buffer at the end of memory (so loading a font works even
; in graphics mode, but don't put too much pressure on the .bss)
section .latebss
align 2, db 0
VGAFontSize dw 16 ; Defaults to 16 byte font
UserFont db 0 ; Using a user-specified font
-
-
while ( defined($keywd = <STDIN>) ) {
chomp $keywd;
-
+
($keywd,$keywdname) = split(/\s+/, $keywd);
$keywdname = $keywd unless ( $keywdname );
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2001-2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
xor bx,bx ; First register number
mov cx,16 ; 16 registers
int 10h
-
+
.movecursor:
mov ax,[es:xbs_vgabuf+6] ; Number of pixel rows
mov dx,[VGAFontSize]
%endif
VGAFileBufEnd equ $
VGAFileMBuf resb FILENAME_MAX ; Mangled VGA image name
-
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;;
;; 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.
;;
jnb .int_loop
mov [E820Max],edx
jmp .int_loop
-
+
.ram_range:
stc
sbb eax,eax ; eax <- 0xFFFFFFFF
mov ax,bx
shl eax,16 ; 64K chunks
add eax,(16 << 20) ; Add first 16M
- jmp short got_highmem
+ jmp short got_highmem
;
; INT 15:E801 failed. Try INT 15:88.
; -*- fundamental -*-
; -----------------------------------------------------------------------
-;
+;
; Copyright 2004 H. Peter Anvin - All Rights Reserved
;
; This program is free software; you can redistribute it and/or modify
linuxauto_len equ $-linuxauto_cmd
section .text ; This is an inline file...
-
mov si,noinfotable_msg
call writemsg
%endif
-
+
; No such luck. See if the the spec packet contained one.
mov eax,[sp_lba]
and eax,eax
mov si,noinfoinspec_msg
call writemsg
%endif
-
+
; No such luck. Get the Boot Record Volume, assuming single
; session disk, and that we're the first entry in the chain
mov eax,17 ; Assumed address of BRV
mov eax,[trackbuf+28h] ; First boot entry
; And hope and pray this is us...
- ; Some BIOSes apparently have limitations on the size
+ ; Some BIOSes apparently have limitations on the size
; that may be loaded (despite the El Torito spec being very
; clear on the fact that it must all be loaded.) Therefore,
; we load it ourselves, and *bleep* the BIOS.
;; Start of BrokenAwardHack --- 10-nov-2002 Knut_Petersen@t-online.de
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
-;; There is a problem with certain versions of the AWARD BIOS ...
+;; There is a problem with certain versions of the AWARD BIOS ...
;; the boot sector will be loaded and executed correctly, but, because the
;; int 13 vector points to the wrong code in the BIOS, every attempt to
;; load the spec packet will fail. We scan for the equivalent of
;; for anybody to change it now or in the future. There are no opcodes
;; that use encodings relativ to IP, so scanning is easy. If we find the
;; code above in the BIOS code we can be pretty sure to run on a machine
-;; with an broken AWARD BIOS ...
+;; with an broken AWARD BIOS ...
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
%ifdef DEBUG_MESSAGES ;
;
call writehex8 ;
- mov si,award_not_crlf ;
+ mov si,award_not_crlf ;
call writestr ;
%endif ;
push es ; save ES
pop di ; restore DI
jcxz award_found ; jmp if found
inc di ; not found, inc di
- jno award_loop ;
+ jno award_loop ;
;
award_failed: pop es ; No, not this way :-((
award_fail2: ;
;
%ifdef DEBUG_MESSAGES ;
;
- push eax ; display message and
+ push eax ; display message and
mov si,award_not_new ; new vector address
call writemsg ;
pop eax ;
mov ax,4B01h ; try to read the spec packet
mov dl,[DriveNo] ; now ... it should not fail
mov si,spec_packet ; any longer
- int 13h ;
+ int 13h ;
jc award_fail2 ;
;
%ifdef DEBUG_MESSAGES ;
call writestr
pop si
call writestr
- pop ax
+ pop ax
ret
;
; mkisofs gave us a pointer to the primary volume descriptor
; (which will be at 16 only for a single-session disk!); from the PVD
; we should be able to find the rest of what we need to know.
-;
+;
get_fs_structures:
mov eax,[bi_pvd]
mov bx,trackbuf
call crlf
%endif
mov eax,[trackbuf+156+10]
- mov [RootDir+dir_len],eax
+ mov [RootDir+dir_len],eax
mov [CurDir+dir_len],eax
add eax,SECTOR_SIZE-1
shr eax,SECTOR_SHIFT
mov bx,trackbuf
mov cx,1 ; Load 1 sector
call getfssec
-
+
cmp word [trackbuf+510],0aa55h ; Boot signature
jne .bad_image ; Image not bootable
.part_loop:
add di,byte 16
loop .part_scan
-
+
push eax ; H/S
push edx ; File size
mov bl,ah
call writestr
cmp ax,-1
je .int18
-
+
; Load boot sector from the specified BIOS device and jump to it.
mov dl,al
xor dh,dh
ret
;
-; iso_compare_names:
+; iso_compare_names:
; Compare the names DS:SI and DS:DI and report if they are
; equal from an ISO 9660 perspective. SI is the name from
; the filesystem; CX indicates its length, and ';' terminates.
; and removes trailing dots and redundant slashes,
; so "repe cmpsb" can do a compare, and the
; path-searching routine gets a bit of an easier job.
-;
+;
mangle_name:
push bx
xor ax,ax
one partition, marked active, that covers the entire size of the disk
image file. Even so, hard disk images are not supported on all
BIOSes.
-
-
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;;
;; kernel.inc
-;;
+;;
;; Header file for the kernel interface definitions
;;
Keyboard translation
--------------------
-The PC keyboard emits so-called scan codes, which are basically key
-numbers. The BIOS then translates those scan codes to the character codes
-of the characters printed on the key-caps. By default, the BIOS normally
-assumes that the keyboard has a US layout. Once an operating system is
+The PC keyboard emits so-called scan codes, which are basically key
+numbers. The BIOS then translates those scan codes to the character codes
+of the characters printed on the key-caps. By default, the BIOS normally
+assumes that the keyboard has a US layout. Once an operating system is
loaded, this operating system can use a different mapping.
-At boot time, LILO only has access to the basic services provided by the
-BIOS and therefore receives the character codes for an US keyboard. It
-provides a simple mechanism to re-map the character codes to what is
+At boot time, LILO only has access to the basic services provided by the
+BIOS and therefore receives the character codes for an US keyboard. It
+provides a simple mechanism to re-map the character codes to what is
appropriate for the actual layout.*
- * The current mechanism isn't perfect, because it sits on top of the
- scan code to character code translation performed by the BIOS. This
- means that key combinations that don't produce any useful character on
- the US keyboard will be ignored by LILO. The advantage of this approach
+ * The current mechanism isn't perfect, because it sits on top of the
+ scan code to character code translation performed by the BIOS. This
+ means that key combinations that don't produce any useful character on
+ the US keyboard will be ignored by LILO. The advantage of this approach
is its simplicity.
Compiling keyboard translation tables
- - - - - - - - - - - - - - - - - - -
-LILO obtains layout information from the keyboard translation tables Linux
-uses for the text console. They are usually stored in
-/usr/lib/kbd/keytables. LILO comes with a program keytab-lilo.pl that reads
-those tables and generates a table suitable for use by the map installer.
-keytab-lilo.pl invokes the program loadkeys to print the tables in a format
+LILO obtains layout information from the keyboard translation tables Linux
+uses for the text console. They are usually stored in
+/usr/lib/kbd/keytables. LILO comes with a program keytab-lilo.pl that reads
+those tables and generates a table suitable for use by the map installer.
+keytab-lilo.pl invokes the program loadkeys to print the tables in a format
that is easy to parse.*
- * On some systems, only root can execute loadkeys. It is then necessary
+ * On some systems, only root can execute loadkeys. It is then necessary
to run keytab-lilo.pl as root too.
keytab-lilo.pl is used as follows:
- keytab-lilo.pl [ -p <old_code>=<new_code> ] ...
+ keytab-lilo.pl [ -p <old_code>=<new_code> ] ...
[<path>]<default_layout>[.<extension>] ]
- [<path>]<kbd_layout>[.<extension>] ]
-
- -p <old_code>=<new_code>
- Specifies corrections ("patches") to the mapping obtained from the
- translation table files. E.g. if pressing the upper case "A" should
- yield an at sign, -p 65=64 would be used. The -p option can be
- repeated any number of times. The codes can also be given as
- hexadecimal or as octal numbers if they are prefixed with 0x or 0,
- respectively.
- <path> The directory in which the file resides. The default path is
- /usr/lib/kbd/keytables.
- <extension> Usually the trailing .map, which is automatically added if
- the file name doesn't contain dots.
- <default_layout> Is the layout which specifies the translation by the
- BIOS. If none is specified, us is assumed.
- <kbd_layout> Is the actual layout of the keyboard.
-
-keytab-lilo.pl writes the resulting translation table as a binary string to
-standard output. Such tables can be stored anywhere with any name, but the
-suggested naming convention is /boot/<kbd>.ktl ("Keyboard Table for Lilo"),
+ [<path>]<kbd_layout>[.<extension>] ]
+
+ -p <old_code>=<new_code>
+ Specifies corrections ("patches") to the mapping obtained from the
+ translation table files. E.g. if pressing the upper case "A" should
+ yield an at sign, -p 65=64 would be used. The -p option can be
+ repeated any number of times. The codes can also be given as
+ hexadecimal or as octal numbers if they are prefixed with 0x or 0,
+ respectively.
+ <path> The directory in which the file resides. The default path is
+ /usr/lib/kbd/keytables.
+ <extension> Usually the trailing .map, which is automatically added if
+ the file name doesn't contain dots.
+ <default_layout> Is the layout which specifies the translation by the
+ BIOS. If none is specified, us is assumed.
+ <kbd_layout> Is the actual layout of the keyboard.
+
+keytab-lilo.pl writes the resulting translation table as a binary string to
+standard output. Such tables can be stored anywhere with any name, but the
+suggested naming convention is /boot/<kbd>.ktl ("Keyboard Table for Lilo"),
where <kbd> is the name of the keyboard layout.
Example:
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
%endif
keywd_count equ ($-keywd_table)/keywd_size
-
; $Id$
; -----------------------------------------------------------------------
-;
+;
; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
;
; This program is free software; you can redistribute it and/or modify
; NASM BUG: refers to hacks to handle NASM 0.98.38 bugs; might need
; conditional compilation
-
+
section .earlybss nobits start=BSS_START
section .bcopy32 align=4 valign=16 follows=.data vfollows=.earlybss
; NASM BUG: follows= here should be vfollows=
; Reserve space for stack
section .stack nobits align=16 start=STACK_START
Stack resb STACK_SIZE
-
; 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.
-;
+;
; ****************************************************************************
%ifndef IS_MDSLINUX
mov eax,[FirstSector] ; Sector start
mov bx,ldlinux_sys ; Where to load it
call getonesec
-
+
; Some modicum of integrity checking
cmp dword [ldlinux_magic+4],LDLINUX_MAGIC^HEXDATE
jne kaboom
cmp bp,si
jna .bp_ok
mov bp,si
-.bp_ok:
+.bp_ok:
shl ah,6 ; Because IBM was STOOPID
; and thought 8 bits were enough
shr word [MaxTransfer],1
jnz .resume
; Fall through to disk_error
-
+
;
; kaboom: write a message and bail out.
;
disk_error:
kaboom:
xor si,si
- mov ss,si
+ mov ss,si
mov sp,StackBuf-4 ; Reset stack
mov ds,si ; Reset data segment
pop dword [fdctab] ; Restore FDC table
SectorPtrs times 64 dd 0
ldlinux_ent:
-;
+;
; Note that some BIOSes are buggy and run the boot sector at 07C0:0000
; instead of 0000:7C00 and the like. We don't want to add anything
; more to the boot sector, so it is written to not assume a fixed
;
exten_table: db 'CBT',0 ; COMBOOT (specific)
db 'BSS',0 ; Boot Sector (add superblock)
- db 'BS ',0 ; Boot Sector
+ db 'BS ',0 ; Boot Sector
db 'COM',0 ; COMBOOT (same as DOS)
db 'C32',0 ; COM32
exten_table_end:
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;;
;; loadhigh.inc
-;;
+;;
;; Load a file into high memory
;;
; load_high: loads (the remainder of) a file into high memory.
; This routine prints dots for each 64K transferred, and
; calls abort_check periodically.
-;
+;
; The xfer_buf_seg is used as a bounce buffer.
;
; The input address (EDI) should be dword aligned, and the final
call getfssec ; Load the data into xfer_buf_seg
pop edi ; <C> Target buffer
pop ecx ; <B> Byte count this round
- push ecx ; <B> Byte count this round
+ push ecx ; <B> Byte count this round
push edi ; <C> Target buffer
.fix_slop:
test cx,dx
add edi,ecx
sub eax,ecx
jnz .read_loop ; More to read...
-
+
.eof:
pop es
ret
-
#!/usr/bin/perl
## $Id$
## -----------------------------------------------------------------------
-##
+##
## Copyright 2001-2004 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;;
;; macros.inc
-;;
+;;
;; Convenient macros
;;
; -----------------------------------------------------------------------
-;
+;
; Copyright 2003-2004 H. Peter Anvin - All Rights Reserved
;
; Permission is hereby granted, free of charge, to any person
; 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
; mbr.asm
;
; Simple Master Boot Record, including support for EBIOS extensions.
-;
+;
; The MBR lives in front of the boot sector, and is responsible for
; loading the boot sector of the active partition. The EBIOS support
; is needed if the active partition starts beyond cylinder 1024.
-;
+;
; This MBR determines all geometry info at runtime. It uses only the
; linear block field in the partition table. It does, however, pass
; the partition table information unchanged to the target OS.
;
%include "bios.inc"
-
+
;
; Note: The MBR is actually loaded at 0:7C00h, but we quickly move it down to
; 0600h.
;
jmp 0:next ; Jump to copy at 0600h
-
+
next:
mov [DriveNo], dl ; Drive number stored in DL
;
#ident "$Id$"
## -----------------------------------------------------------------------
-##
+##
## Copyright 2001-2004 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
LD = ld -m elf_i386
NASM = nasm -O99 # -dWITH_EDD
NFLAGS = -dVERSION='"$(VERSION)"' -dDATE='"$(DATE)"'
-NINCLUDE =
+NINCLUDE =
OBJCOPY = objcopy
PERL = perl
unzip.o memdisk.o
CSRC = setup.c msetup.c e820func.c conio.c unzip.c
-SSRC =
+SSRC =
NASMSRC = memdisk.asm memdisk16.asm
all: memdisk e820test
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2001 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
/* \n -> \r\n */
putchar('\r');
}
-
+
regs.eax.w[0] = 0x0e00|(ch&0xff);
syscall(0x10, ®s, NULL);
static int skip_atoi(const char **s)
{
int i=0;
-
+
while (isdigit(**s))
i = i*10 + *((*s)++) - '0';
return i;
char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
int i;
-
+
if (type & LARGE)
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (type & LEFT)
int i, base;
char * str;
const char *s;
-
+
int flags; /* flags to number() */
-
+
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
-
+
for (str=buf ; *fmt ; ++fmt) {
if (*fmt != '%') {
*str++ = *fmt;
continue;
}
-
+
/* process flags */
flags = 0;
repeat:
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
-
+
/* get field width */
field_width = -1;
if (isdigit(*fmt))
flags |= LEFT;
}
}
-
+
/* get the precision */
precision = -1;
if (*fmt == '.') {
- ++fmt;
+ ++fmt;
if (isdigit(*fmt))
precision = skip_atoi(&fmt);
else if (*fmt == '*') {
if (precision < 0)
precision = 0;
}
-
+
/* get the conversion qualifier */
qualifier = -1;
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
qualifier = *fmt;
++fmt;
}
-
+
/* default base */
base = 10;
-
+
switch (*fmt) {
case 'c':
if (!(flags & LEFT))
while (--field_width > 0)
*str++ = ' ';
continue;
-
+
case 's':
s = va_arg(args, char *);
len = strnlen(s, precision);
-
+
if (!(flags & LEFT))
while (len < field_width--)
*str++ = ' ';
while (len < field_width--)
*str++ = ' ';
continue;
-
+
case 'p':
if (field_width == -1) {
field_width = 2*sizeof(void *);
(unsigned long) va_arg(args, void *), 16,
field_width, precision, flags);
continue;
-
-
+
+
case 'n':
if (qualifier == 'l') {
long * ip = va_arg(args, long *);
*ip = (str - buf);
}
continue;
-
+
case '%':
*str++ = '%';
continue;
-
+
/* integer number formats - set up the flags and "break" */
case 'o':
base = 8;
break;
-
+
case 'X':
flags |= LARGE;
case 'x':
base = 16;
break;
-
+
case 'd':
case 'i':
flags |= SIGN;
case 'u':
break;
-
+
default:
*str++ = '%';
if (*fmt)
{
va_list args;
int i;
-
+
va_start(args, fmt);
i=vsprintf(buf,fmt,args);
va_end(args);
return printed;
}
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2001 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2001 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2001 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
for ( i = nranges ; i > where ; i-- )
ranges[i] = ranges[i-1];
-
+
ranges[where].start = start;
ranges[where].type = type;
/* Remove this to make len == 0 mean all of memory */
if ( len == 0 )
return; /* Nothing to insert */
-
+
last = start+len-1; /* May roll over */
i = 0;
nranges -= (i-j);
}
}
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2001-2003 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
p = strchr(line, ':');
p = p ? p+1 : line;
if ( sscanf(p, " %llx %llx %d", &start, &len, &type) == 3 ) {
- putchar('\n');
+ putchar('\n');
printf("%016llx %016llx %d <-\n", start, len, type);
- putchar('\n');
+ putchar('\n');
insertrange(start, len, type);
- printranges();
+ printranges();
}
}
/* Now, steal a chunk (2K) of DOS memory and make sure it registered OK */
insertrange(dos_mem-2048, 2048, 2); /* Type 2 = reserved */
-
+
printranges();
parse_mem();
/* inflate.c -- Not copyrighted 1992 by Mark Adler
version c10p1, 10 January 1993 */
-/*
+/*
* Adapted for booting Linux by Hannu Savolainen 1993
- * based on gzip-1.0.3
+ * based on gzip-1.0.3
*
* Nicolas Pitre <nico@cam.org>, 1999/04/14 :
* Little mods for all variable to reside either into rodata or bss segments
chunks), otherwise the dynamic method is used. In the latter case, the
codes are customized to the probabilities in the current block, and so
can code it much better than the pre-determined fixed codes.
-
+
The Huffman codes themselves are decoded using a multi-level table
lookup, in order to maximize the speed of decoding plus the speed of
building the decoding tables. See the comments below that precede the
/* Function prototypes */
-STATIC int huft_build OF((unsigned *, unsigned, unsigned,
+STATIC int huft_build OF((unsigned *, unsigned, unsigned,
const ush *, const ush *, struct huft **, int *));
STATIC int huft_free OF((struct huft *));
STATIC int inflate_codes OF((struct huft *, struct huft *, int, int));
/* Macros for inflate() bit peeking and grabbing.
The usage is:
-
+
NEEDBITS(j)
x = b & mask_bits[j];
DUMPBITS(j)
memzero(c, sizeof(c));
p = b; i = n;
do {
- Tracecv(*p, (stderr, (n-i >= ' ' && n-i <= '~' ? "%c %d\n" : "0x%x %d\n"),
+ Tracecv(*p, (stderr, (n-i >= ' ' && n-i <= '~' ? "%c %d\n" : "0x%x %d\n"),
n-i, *p));
c[*p]++; /* assume all entries <= BMAX */
p++; /* Can't combine with above line (Solaris bug) */
q = (--p)->v.t;
free((char*)p);
p = q;
- }
+ }
return 0;
}
hufts = 0;
gzip_mark(&ptr);
if ((r = inflate_block(&e)) != 0) {
- gzip_release(&ptr);
+ gzip_release(&ptr);
return r;
}
gzip_release(&ptr);
#define CRC_VALUE (crc ^ 0xffffffffL)
/*
- * Code to compute the CRC-32 table. Borrowed from
+ * Code to compute the CRC-32 table. Borrowed from
* gzip-1.0.3/makecrc.c.
*/
; 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.
-;
+;
; ****************************************************************************
%ifndef DEPEND
je int15_88
oldint15: pop bp
jmp far [cs:OldInt15]
-
+
int15_e801:
mov ax,[cs:Mem1MB]
mov cx,ax
; Routine to copy in/out of high memory
; esi = linear source address
; edi = linear target address
-; ecx = 32-bit word count
+; ecx = 32-bit word count
;
; Assumes cs = ds = es
;
add dx,8
; DX = 16 for BIGRAW, 8 for RAW
; 8 is selector for a 64K flat segment,
- ; 16 is selector for a 4GB flat segment.
+ ; 16 is selector for a 4GB flat segment.
lgdt [cs:Shaker]
mov eax,cr0
[ES:DI+2] byte MEMDISK minor version
[ES:DI+3] byte MEMDISK major version
[ES:DI+4] dword Pointer to MEMDISK data in high memory
- [ES:DI+8] dword Size of MEMDISK data in 512-byte sectors
+ [ES:DI+8] dword Size of MEMDISK data in 512-byte sectors
[ES:DI+12] 16:16 Far pointer to command line
[ES:DI+16] 16:16 Old INT 13h pointer
[ES:DI+20] 16:16 Old INT 15h pointer
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2001-2003 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
;; -*- fundamental -*-
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
dd (%2 & 0xffff) | ((%1 & 0xffff) << 16)
dd (%1 & 0xff000000) | (%2 & 0xf0000) | ((%3 & 0xf0ff) << 8) | ((%1 & 0x00ff0000) >> 16)
%endmacro
-
+
align 8, db 0
call32_gdt: dw call32_gdt_size-1 ; Null descriptor - contains GDT
.adj1: dd call32_gdt+CS_BASE ; pointer for LGDT instruction
dw 0
-
+
; 0008: Code segment, use16, readable, dpl 0, base CS_BASE, 64K
desc CS_BASE, 0xffff, 0x009b
; 0028: Data segment, use32, read/write, dpl 0, base 0, 4G
desc 0, 0xfffff, 0xc093
-
+
call32_gdt_size: equ $-call32_gdt
err_a20: db 'ERROR: A20 gate not responding!',13,10,0
-
+
section .bss
alignb 4
SavedSSSP resd 1 ; Place to save SS:SP
Return resd 1 ; Return value
A20Test resw 1 ; Space to test A20
A20Tries resb 1
-
+
section .data
alignb 4
Target dd 0 ; Target address
Target_Seg dw 20h ; Target CS
A20Type dw 0 ; Default = unknown
-
+
section .text
bits 16
;
; IBM ThinkPad 760EL.
;
; We typically toggle A20 twice for every 64K transferred.
-;
+;
%define io_delay call _io_delay
%define IO_DELAY_PORT 80h ; Invalid port (we hope!)
%define disable_wait 32 ; How long to wait for a disable
test al,2
jnz empty_8042
io_delay
-.done: ret
+.done: ret
;
; Execute a WBINVD instruction if possible on this CPU
or al,1
mov cr0,eax ; Enter protected mode
jmp 20h:dword .in_pm+CS_BASE
-
+
bits 32
.in_pm:
xor eax,eax ; Available for future use...
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2001-2003 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
regs.edx.l = 0x534d4150;
regs.edi.w[0] = OFFS(buf);
regs.es = SEG(buf);
-
+
syscall(0x15, ®s, ®s);
copied = (regs.eflags.l & 1) ? 0 : regs.ecx.l;
-
+
if ( regs.eax.l != 0x534d4150 || copied < 20 )
break;
-
+
printf("e820: %08x%08x %08x%08x %d\n",
(uint32_t)(buf->base >> 32), (uint32_t)buf->base,
(uint32_t)(buf->len >> 32), (uint32_t)buf->len,
#!/usr/bin/perl
## -----------------------------------------------------------------------
-##
+##
## Copyright 2001 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
close(FILE);
close(OUT);
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2001-2005 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
const char memdisk_version[] =
"MEMDISK " VERSION " " DATE;
-const char copyright[] =
+const char copyright[] =
"Copyright " FIRSTYEAR "-" COPYYEAR " H. Peter Anvin";
extern const char _binary_memdisk_bin_start[], _binary_memdisk_bin_end[];
uint32_t diskbuf;
uint32_t disksize;
uint16_t cmdline_off, cmdline_seg;
-
+
uint32_t oldint13;
uint32_t oldint15;
break;
}
}
-
+
/* Check for matching string at end of line */
if ( match == 1 && *wp == '\0' )
return CMD_BOOL;
-
+
return CMD_NOTFOUND;
}
for ( i = nranges-1 ; i >= 0 ; i-- ) {
/* We can't use > 4G memory (32 bits only.) Truncate to 2^32-1
so we don't have to deal with funny wraparound issues. */
-
+
/* Must be memory */
if ( ranges[i].type != 1 )
continue;
if ( (uint64_t)where+size >= gzwhere && where < endrange ) {
/* Need to move source data to avoid compressed/uncompressed overlap */
uint32_t newwhere;
-
+
if ( gzwhere-startrange < size )
continue; /* Can't fit both old and new */
-
+
newwhere = (gzwhere - size) & ~(UNZIP_ALIGN-1);
printf("Moving compressed data from 0x%08x to 0x%08x\n",
where, newwhere);
-
+
/* Our memcpy() is OK, because we always move from a higher
address to a lower one */
memcpy((void *)newwhere, (void *)where, size);
};
static const struct geometry geometries[] =
-{
+{
{ 360*2, 40, 2, 9, 0, 0x01, 0 }, /* 360 K */
{ 720*2, 80, 2, 9, 0, 0x03, 0 }, /* 720 K*/
{ 1200*2, 80, 2, 15, 0, 0x02, 0 }, /* 1200 K */
hd_geometry.h = v;
if ( CMD_HASDATA(p = getcmditem("s")) && (v = atou(p)) )
hd_geometry.s = v;
-
+
if ( (p = getcmditem("floppy")) != CMD_NOTFOUND ) {
hd_geometry.driveno = CMD_HASDATA(p) ? atou(p) & 0x7f : 0;
if ( hd_geometry.type == 0 )
(hd_geometry.s == 0) ) {
/* Hard disk image, need to examine the partition table for geometry */
memcpy(&ptab, (char *)where+hd_geometry.offset+(512-2-4*16), sizeof ptab);
-
+
max_c = max_h = 0; max_s = 1;
for ( i = 0 ; i < 4 ; i++ ) {
if ( ptab[i].type ) {
c = ptab[i].start_c + (ptab[i].start_s >> 6);
s = (ptab[i].start_s & 0x3f);
h = ptab[i].start_h;
-
+
if ( max_c < c ) max_c = c;
if ( max_h < h ) max_h = h;
if ( max_s < s ) max_s = s;
-
+
c = ptab[i].end_c + (ptab[i].end_s >> 6);
s = (ptab[i].end_s & 0x3f);
h = ptab[i].end_h;
-
+
if ( max_c < c ) max_c = c;
if ( max_h < h ) max_h = h;
if ( max_s < s ) max_s = s;
}
}
-
+
max_c++; max_h++; /* Convert to count (1-based) */
-
+
if ( !hd_geometry.h )
hd_geometry.h = max_h;
if ( !hd_geometry.s )
regs.eax.b[1] = 0x08;
regs.edx.b[0] = geometry->driveno & 0x80;
syscall(0x13, ®s, ®s);
-
+
if ( regs.eflags.l & 1 ) {
printf("INT 13 08: Failure, assuming this is the only drive\n");
pptr->drivecnt = 1;
/* Install the interrupt handlers */
printf("old: int13 = %08x int15 = %08x\n",
rdz_32(BIOS_INT13), rdz_32(BIOS_INT15));
-
+
wrz_32(BIOS_INT13, driverptr+hptr->int13_offs);
wrz_32(BIOS_INT15, driverptr+hptr->int15_offs);
-
+
printf("new: int13 = %08x int15 = %08x\n",
rdz_32(BIOS_INT13), rdz_32(BIOS_INT15));
nflop = 4;
equip &= 0x3E;
- if ( nflop )
+ if ( nflop )
equip |= ((nflop-1) << 6) | 0x01;
wrz_8(BIOS_EQUIP, equip);
puts("MEMDISK: Failed to load new boot sector\n");
die();
}
-
+
if ( getcmditem("pause") != CMD_NOTFOUND ) {
puts("press any key to boot... ");
regs.eax.w[0] = 0;
/*
* unzip.c
- *
- * This is a collection of several routines from gzip-1.0.3
+ *
+ * This is a collection of several routines from gzip-1.0.3
* adapted for Linux.
*
* malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
static void *malloc(int size)
{
void *p;
-
+
if (size < 0) error("malloc error");
-
+
free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
-
+
p = (void *)free_mem_ptr;
free_mem_ptr += size;
-
+
if (free_mem_ptr >= free_mem_end_ptr)
error("out of memory");
-
+
return p;
}
{
free_mem_ptr = (long) *ptr;
}
-
+
/* ===========================================================================
* Fill the input buffer. This is called only when the buffer is empty
* and at least one byte is really needed.
if ( bytes_out+outcnt > output_size )
error("output buffer overrun");
-
+
in = window;
out = output_data;
for (n = 0; n < outcnt; n++) {
}
offset++;
}
-
+
if (gzh->flags & COMMENT) {
/* Discard the comment */
uint8_t *p = indata;
}
else if (pkzh->magic == 0x04034b50UL) {
/* Magic number matches pkzip file. */
-
+
offset = sizeof (*pkzh);
if (pkzh->flags & PK_ENCRYPTED) {
error("pkzip file is encrypted; not supported");
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2002 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
Changes in v1.2
---------------
-* Allowed menu's to have names. Submenu's can be referred to by names
- instead of their index in the menu system. This allows user to refer
+* Allowed menu's to have names. Submenu's can be referred to by names
+ instead of their index in the menu system. This allows user to refer
to submenus which are not yet part of the menusystem.
-* help pages can be longer than one screen
+* help pages can be longer than one screen
* menugen.py: Python script for converting .menu files to C source code
- .menu files can be used to descibe most static uses of menu system,
+ .menu files can be used to descibe most static uses of menu system,
including SubMenus, Checkboxes, RadioButtons, User Authentication and
Context sensitive help. You can also restrict use of certain items
to users with certain credentials.
See MENU_FORMAT for the format of .menu files
* display.c32: Takes the name of the text file to display and displays it
- allowing user to scroll through the text.
+ allowing user to scroll through the text.
USAGE: display.c32 <filename>
* Additional handler type: Keys handler
* Menuitem handlers now have a return value of type t_handler_return.
For all simple cases, you just return ACTION_VALID or ACTION_INVALID
- (For some types of menu items, handlers are ignored, and for
+ (For some types of menu items, handlers are ignored, and for
others the return value is ignored)
* add_menu takes an extra argument (to better control memory footprint)
You can just set it to -1 to choose the default value
* Now the menu system support long menu's using scroll bars.
* Support for passwords and context sensitive help is added.
-
GCC & 32-bit code
-----------------
Due to the limitations of the COM file format,
-(64KB limit on memory footprint) the code has been changed
+(64KB limit on memory footprint) the code has been changed
so that the code compiles to a 32-bit COMBOOT program.
Since the code makes use of BIOS calls, this code cannot be
-compiled into a format which can execute under Linux. As a
+compiled into a format which can execute under Linux. As a
side effect, there is no nice way to debug this code. In order
to debug this code, you will have to run the code under syslinux.
GCC & 16-bit code
-----------------
-The code was ported to GCC by Peter Anvin.
+The code was ported to GCC by Peter Anvin.
OpenWatcom & 16-bit code
------------------------
Originally this code was written for the Openwatcom compiler
and generated .COM files, which could execute under DOS as well as
-SYSLINUX.
+SYSLINUX.
complex.c illustrates most of the features available in the menu system.
Menu Features currently supported are:
-* menu items,
-* submenus,
+* menu items,
+* submenus,
* disabled items,
* checkboxes,
* invisible items (useful for dynamic menus), and
* Radio menus,
* Context sensitive help
-* Authenticated users
+* Authenticated users
The keys used are:
1. Overview
-----------
-The code usually consists of many stages.
+The code usually consists of many stages.
* Configuring the menusytem
* Installing global handlers [optional]
- * Populating the menusystem
+ * Populating the menusystem
* Executing the menusystem
* Processing the result
1.1 Configuring the menusystem
------------------------------
-This includes setting the window the menu system should use,
+This includes setting the window the menu system should use,
the choice of colors, the title of the menu etc. In most functions
calls, a value of -1 indicates that the default value be used.
-For details about what the arguments are look at function
+For details about what the arguments are look at function
declarations in menu.h
<code>
// Choose the default title and setup default values for all attributes....
init_menusystem(NULL);
set_window_size(1,1,23,78); // Leave one row/col border all around
-
+
// Choose the default values for all attributes and char's
// -1 means choose defaults (Actually the next 4 lines are not needed)
- set_normal_attr (-1,-1,-1,-1);
- set_status_info (-1,-1);
- set_title_info (-1,-1);
+ set_normal_attr (-1,-1,-1,-1);
+ set_status_info (-1,-1);
+ set_title_info (-1,-1);
set_misc_info(-1,-1,-1,-1);
</code>
-
+
1.2 Populating the menusystem
-----------------------------
This involves adding a menu to the system, and the options which
add_item("Exit ","Status String",OPT_EXITMENU,NULL,0);
</code>
-The call to add_menu has two arguments, the first being the title of
+The call to add_menu has two arguments, the first being the title of
the menu and the second an upper bound on the number of items in the menu.
Putting a -1, will use the default (see MENUSIZE in menu.h). If you try
-to add more items than specified, the extra items will not appear in
+to add more items than specified, the extra items will not appear in
the menu. The accuracy of this number affects the memory required
-to run the system.
+to run the system.
-If you do not want to keep track of the return values, you can also use
+If you do not want to keep track of the return values, you can also use
the following variant of add_menu
<code>
the following
* OPT_RUN : executable content
- * OPT_EXITMENU : exits menu to parent
+ * OPT_EXITMENU : exits menu to parent
* OPT_SUBMENU : if selected, displays a submenu
* OPT_CHECKBOX : associates a boolean with this item which can be toggled
- * OPT_RADIOMENU: associates this with a radio menu.
- After execution, the data field of this item will point
+ * OPT_RADIOMENU: associates this with a radio menu.
+ After execution, the data field of this item will point
to the option selected.
* OPT_SEP : A menu seperator (visually divide menu into parts)
* OPT_RADIOITEM: this item is one of the options in a RADIOMENU
* OPT_INACTIVE : A disabled item (user cannot select this)
* OPT_INVISIBLE: This item will not be displayed.
-
-The fourth argument is the value of the data field always a string.
+
+The fourth argument is the value of the data field always a string.
Usually this string is just copied and nothing is done with it. Two
cases, where it is used.
In case of a radiomenu the input string is ignored and the "data" field
-points to the menuitem chosen (Dont forget to typecast this pointer to
+points to the menuitem chosen (Dont forget to typecast this pointer to
(t_menuitem *) when reading this info).
-In case of a submenu, this string if non-trivial is interpreted as the
+In case of a submenu, this string if non-trivial is interpreted as the
name of the submenu which should be linked there. This interpretation
-happens when the menu is first run and not when the menu system is being
-created. This allows the user to create the menusystem in an arbitrary
-order.
+happens when the menu is first run and not when the menu system is being
+created. This allows the user to create the menusystem in an arbitrary
+order.
-The fifth argument is a number whose meaning depends on the type of the
+The fifth argument is a number whose meaning depends on the type of the
item. For a CHECKBOX it should be 0/1 setting the initial state of the
checkbox. For a SUBMENU it should be the index of the menu which should
-be displayed if this option is chosen. Incase the data field is non-trivial,
+be displayed if this option is chosen. Incase the data field is non-trivial,
this number is ignored and computed later. For a RADIOMENU it should be the
index of the menu which contains all the options (All items in that menu
not of type RADIOITEM are ignored). For all other types, this
<code>
choice = showmenus(MAIN); // Initial menu is the one with index MAIN
- // or choice = showmenus(find_menu_num("main")); // Initial menu is the one named "main"
+ // or choice = showmenus(find_menu_num("main")); // Initial menu is the one named "main"
</code>
1.4 Processing the result
-------------------------
-This pointer will either be NULL (user hit Escape) or always point
+This pointer will either be NULL (user hit Escape) or always point
to a menuitem which can be "executed", i.e. it will be of type OPT_RUN.
-Usually at this point, all we need to do is to ask syslinux to run
+Usually at this point, all we need to do is to ask syslinux to run
the command associated with this menuitem. The following code executes
-the command stored in choice->data (there is no other use for the data
+the command stored in choice->data (there is no other use for the data
field, except for radiomenu's)
<code>
----------
Every item also has a field called "helpid". It is meant to hold some
kind of identifier which can be referenced and used to generate
-a context sensitive help system. This can be set after a call to
+a context sensitive help system. This can be set after a call to
add_item as follows
<code>
add_item("selfloop","Status 2",OPT_SUBMENU,NULL,MAINMENU);
that the shortcut key is not reset. The second is some unsigned integer.
If this value is 0xFFFF, then the helpid is not changed.
-2.3 Installing global handlers
+2.3 Installing global handlers
------------------------------
It is possible to register handlers for the menu system. These are
-user functions which are called by the menusystem in certain
+user functions which are called by the menusystem in certain
situations. Usually the handlers get a pointer to the menusystem
datastructure as well as a pointer to the current item selected.
Some handlers may get additional information. Some handlers are
2.3.1 timeout handler
---------------------
-This is installed using a call to "reg_ontimeout(fn,numsteps,stepsize)"
+This is installed using a call to "reg_ontimeout(fn,numsteps,stepsize)"
function. fn is a pointer to a function which takes no arguments and
returns one of CODE_WAIT, CODE_ENTER, CODE_ESCAPE. This function is
called when numsteps*stepsize Centiseconds have gone by without any
2.3.2 Screen handler
--------------------
This is installed using a call to "reg_handler(HDLR_SCREEN,fn)". fn is
-a pointer to a function which takes a pointer to the menusystem
+a pointer to a function which takes a pointer to the menusystem
datastructure and the current item selected and returns nothing.
-This is called everytime a menu is drawn (i.e. everytime user changes
+This is called everytime a menu is drawn (i.e. everytime user changes
the current selection). This is meant for displaying any additional
information which reflects the current state of the system.
This is installed using a call to "reg_handler(HDLR_KEYS,fn)". fn is
a pointer to a function which takes a pointer to the menusystem
datastructure, the current item and the scan code of a key and returns
-nothing. This function is called when the user presses a key which
-the menusystem does not know to dealwith. In any case, when this call
+nothing. This function is called when the user presses a key which
+the menusystem does not know to dealwith. In any case, when this call
returns the screen should not have changed in any way. Usually,
-one can change the active page and display any output needed and
+one can change the active page and display any output needed and
reset the active page when you return from this call.
complex.c implements a key_handler, which implements a simple
-context sensitive help system, by displaying the contents of a
+context sensitive help system, by displaying the contents of a
file whose name is based on the helpid of the active item.
Also, complex.c's handler allows certain users to make changes
2.4 Installing item level handlers
----------------------------------
-In addition to global handlers, one can also install handlers for each
+In addition to global handlers, one can also install handlers for each
individual item. A handler for an individual item is a function which
-takes a pointer to the menusystem datastructure and a pointer to the
+takes a pointer to the menusystem datastructure and a pointer to the
current item and return a structure of type t_handler_return. Currently
it has two bit fields "valid" and "refresh".
on the menuitem depending on which choice was selected (see complex.c
for an example). The return values are ignored for RADIOMENU's.
-In case of RUN items: the return values are used as follows. If the
+In case of RUN items: the return values are used as follows. If the
return value of "valid" was false, then this user choice is ignored.
-This is useful if the handler has useful side effects. For e.g.
-complex.c has a Login item, whose handler always return INVALID. It
+This is useful if the handler has useful side effects. For e.g.
+complex.c has a Login item, whose handler always return INVALID. It
sets a global variable to the name of the user logged in, and enables
-some menu items, and makes some invisible items visible.
-
-* If the handler does not change the visibility status of any items,
- the handler should set "refresh" to 0.
-* If the handler changes the visibility status of items in the current
- menu set "refresh" to 1.
-* If you are changing the visibility status of items in menu's currently
- not displayed, then you can set "refresh" to 0.
+some menu items, and makes some invisible items visible.
+
+* If the handler does not change the visibility status of any items,
+ the handler should set "refresh" to 0.
+* If the handler changes the visibility status of items in the current
+ menu set "refresh" to 1.
+* If you are changing the visibility status of items in menu's currently
+ not displayed, then you can set "refresh" to 0.
* Changing the visibility status of items in another menu
- which is currently displayed, is not supported. If you do it,
- the screen contents may not reflect the change until you get to the
+ which is currently displayed, is not supported. If you do it,
+ the screen contents may not reflect the change until you get to the
menu which was changed. When you do get to that menu, you may notice
pieces of the old menu still on the screen.
-In case of CHECKBOXES: the return value of "valid" is ignored. Because,
+In case of CHECKBOXES: the return value of "valid" is ignored. Because,
the handler can change the value of checkbox if the user selected value
is not appropriate. only the value of "refresh" is honored. In this case
all the caveats in the previous paragraph apply.
-menu.h defines two instances of t_handler_return
-ACTION_VALID and ACTION_INVALID for common use. These set the valid flag
+menu.h defines two instances of t_handler_return
+ACTION_VALID and ACTION_INVALID for common use. These set the valid flag
to 1 and 0 respectively and the refresh flag to 0.
3. Things to look out for
-------------------------
-When you define the menu system, always declare it in the opposite
+When you define the menu system, always declare it in the opposite
order, i.e. all lower level menu's should be defined before the higher
-level menus. This is because in order to define the MAINMENU, you need
+level menus. This is because in order to define the MAINMENU, you need
to know the index assigned to all its submenus.
4. Additional Modules
-------------
This module was written by Th. Gebhardt. This is basically a modification
of the DES crypt function obtained by removing the dependence of the
-original crypt function on C libraries. The following functions are
+original crypt function on C libraries. The following functions are
defined
- init_passwords(PWDFILE)
+ init_passwords(PWDFILE)
// Read in the password database from the file
- authenticate_user(user,pwd)
+ authenticate_user(user,pwd)
// Checks if user,pwd is valid
- isallowed(user,perm)
+ isallowed(user,perm)
// Checks if the user has a specified permission
- close_passwords()
+ close_passwords()
// Unloads password database from memory
See the sample password file for more details about the file format
and the implementation of permissions.
-See complex.c for a example of how to use this.
+See complex.c for a example of how to use this.
4.2 Help
--------
the base directory.
The first line of this file assumed to be the title of the help screen.
-You can use ^N and ^O to change attributes absolutely and relatively,
-i.e. [^O]46 (i.e. Ctrl-O followed by chars 4 and 6) will set the
-attribute to 46, while [^N]08 will XOR the current attribute with
-specified number, thus in this case the first [^N]08 will turn on
+You can use ^N and ^O to change attributes absolutely and relatively,
+i.e. [^O]46 (i.e. Ctrl-O followed by chars 4 and 6) will set the
+attribute to 46, while [^N]08 will XOR the current attribute with
+specified number, thus in this case the first [^N]08 will turn on
highlighting and the second one will turn it off.
-
-A .menu file can be used to describe basic menu structures which can be converted
-into C code which can then be compiled into a .c32 file for use with SYSLINUX.
-The format of a .menu file is similar to an ini file, but with important
+A .menu file can be used to describe basic menu structures which can be converted
+into C code which can then be compiled into a .c32 file for use with SYSLINUX.
+The format of a .menu file is similar to an ini file, but with important
differences.
-Lines starting with # and ; are treated as comments. Blank lines are used to
-separate the attributes of one menu item from another. Multiple blank lines are
+Lines starting with # and ; are treated as comments. Blank lines are used to
+separate the attributes of one menu item from another. Multiple blank lines are
equivalent to a single one. In other contexts Blank lines are not significant.
Menus
-----
Each menu declaration starts with a line containing the name of menu in [ ].
This is the "nickname" of the menu and should be different for different menus.
-This is not visible to the user of the menu system. The initial menu must
+This is not visible to the user of the menu system. The initial menu must
be called "main"
The menu declaration is followed by lines which set the attributes of the menu.
-This is followed by a blank line and followed by declaration of menu items in
+This is followed by a blank line and followed by declaration of menu items in
that menu.
-All lines which occur before the first menu declaration is considered as
-a global declaration.
+All lines which occur before the first menu declaration is considered as
+a global declaration.
Abstract Format
---------------
GLOBAL SETTINGS
---------------
The following global settings are now supported. Many of the keywords
-accept what we call a "DOT COMMAND" as argument. Simply put they are
-instructions to the menu system to perform certain actions.
-The syntax and semantics of DOT COMMANDS are given later in the section
+accept what we call a "DOT COMMAND" as argument. Simply put they are
+instructions to the menu system to perform certain actions.
+The syntax and semantics of DOT COMMANDS are given later in the section
titled "DOT COMMANDS".
videomode: (default 0xFF) [Use with care]
The textmode in which the whole menu system should operate.
Must be a number (use 0x notation for hexadecimal).
- Lookup Ralph Brown Interrupt List and search for Video Mode
+ Lookup Ralph Brown Interrupt List and search for Video Mode
to find a number to put here.
- setting to 0xFF will mean, menu system will use the current
+ setting to 0xFF will mean, menu system will use the current
video mode.
-title:
+title:
The title of the whole menu system
top, left, bot, right: (default 0,0,21,79)
The area of the screen used by the menu system. The remaining
- part of the screen can be used by the user for anything.
+ part of the screen can be used by the user for anything.
helpdir: (default /isolinux/help)
- Location of the directory where help information is stored. The
+ Location of the directory where help information is stored. The
help files must be called "hlpNNNNN.txt" where NNNNN is the helpid.
pwdfile: (default /isolinux/passwd)
to be skipped all together (0 means menu system always runs). It can also
be a combination of "Alt","Ctrl","Shift","Caps","Ins","Scroll".
When menu system starts it checks if any of the specified keys are On/pressed.
- If true, the system exits immediately and executes the skipcmd.
+ If true, the system exits immediately and executes the skipcmd.
- e.g. setting it to "shift-alt-caps" means menu will be skipped if alt OR shift
+ e.g. setting it to "shift-alt-caps" means menu will be skipped if alt OR shift
is pressed OR caps is on. setting to "0" means menu will always run.
skipcmd: (default .exit)
quits back to the boot prompt.
startfile: (default "")
- if non-empty the system will display the contents of this file before launching
- the menusystem. This happens only if the menusystem is not skipped. Can be used
+ if non-empty the system will display the contents of this file before launching
+ the menusystem. This happens only if the menusystem is not skipped. Can be used
to display licensing, usage or welcome messages. A file with given name
is expected to be found in the helpdir directory.
exitcmd: (default .exit)
valid terminal commands: .exit .repeat or any syslinux command
- The default command to execute when user quits the menu system.
+ The default command to execute when user quits the menu system.
exitcmdroot: (default =exitcmd)
Same as exitcmd except applies when current user has "root" privileges. If not
specified, it is assumed to be the same as exitcmd
-
+
timeout: (default 3000)
The amount of time (in multiple of 0.1 seconds) to wait for user keypress. If no
- key pressed for specified duration then the timeoutcmd is executed.
+ key pressed for specified duration then the timeoutcmd is executed.
totaltimeout: (default 0)
The total amount of time (in multiples of 0.1 seconds) the system will wait for
user to make a decision. If no decision has been made in the specified duration
totaltimeoutcmd will be executed
- NOTE: This does not include the time spent browsing the help system or
+ NOTE: This does not include the time spent browsing the help system or
the time taken for the user to enter his/her authentication credentials.
timeoutcmd: (default .beep)
ITEM ATTRIBUTES
---------------
-item:
+item:
The string displayed to the user. Characters enclosed in < > are highlighted.
shortcut: (default -1) valid values A-Za-z0-9 or -1 [Usage not recommended]
info: (default same as data)
Additional textual information displayed in the status bar
-type:
+type:
the type of entry this item represents. This is one of the following:
run: choosing this will run something in SYSLINUX
use data to specify the actual command to execute
exitmenu: exit to parent menu
submenu: choosing will open up submenu
- use data to specify the "nickname" of the menu
+ use data to specify the "nickname" of the menu
which should come here
sep: Position a separator here
inactive: menu item is disabled
- checkbox: this is a checkbox
+ checkbox: this is a checkbox
use state to set initial state
invisible: User does not see this item
radioitem: One choice in a radiomenu
- radiomenu: Allow user to choose one of many choices
+ radiomenu: Allow user to choose one of many choices
(initial choice is always NULL)
login: Selecting this will allow user to login to system
-
+
data:
for run items, the syslinux command to execute
for submenus and radiomenus, nickname of menu
ipappend:
ipappend flag to pass to PXELINUX (harmless for other variants of SYSLINUX)
- See syslinux documentation for meaning of the FLAGS
+ See syslinux documentation for meaning of the FLAGS
helpid: (default 65535 which is not a valid id)
associates a context for the help system.
then user needs the permission in order to open the submenu
argsmenu: (default "")
- Name of the menu to be scanned for setting additional arguments to
+ Name of the menu to be scanned for setting additional arguments to
pass to command line when this item is chosen for execution. Submenus
- of specified menu are also scanned. Only checkboxes and radiomenu's
+ of specified menu are also scanned. Only checkboxes and radiomenu's
are scanned. Items of other type in this menu is silently ignored.
A "single command" is one of the following
[NT] A syslinux command (any DOT command not starting with a "." is assumed to be this)
-[NT] .beep [n]
-[NT] .help <file>
+[NT] .beep [n]
+[NT] .help <file>
[NT] .nop
[T] .exit or .quit (equivalent)
[T] .repeat or .wait or .ignore (all three are equivalent)
A dot command is a sequence of "single commands" separated by a "%". When a dot command
is executed the system executes all the given "single commands" in the specified order.
-All the commands marked "[T]" are terminal commands, i.e. when the system encounters
+All the commands marked "[T]" are terminal commands, i.e. when the system encounters
such a command it stops processing the dot command and returns the terminal command
-which caused the termination to the caller (who usually interprets the command
+which caused the termination to the caller (who usually interprets the command
appropriately).
-All commands marked with [NT] are non-terminal commands, i.e. once these commands are
-processed the system continues to process the remaining "single commands" specified in
+All commands marked with [NT] are non-terminal commands, i.e. once these commands are
+processed the system continues to process the remaining "single commands" specified in
the "DOT COMMAND".
Note: The case of a syslinux command is tricky. When executed, the command should never return
-(if the specified kernel exists) so the fact that we consider it a [NT] should be taken with
-a pinch of salt. However, if the syslinux command does return (in case of no kernel), then
+(if the specified kernel exists) so the fact that we consider it a [NT] should be taken with
+a pinch of salt. However, if the syslinux command does return (in case of no kernel), then
remaining "single commands" are processed. In particular "ker1 arg1 % ker2 arg2 % ker3 args"
has the effect of executing the first kernel which exists
.nop:
Does nothing.
-.beep:
+.beep:
.beep [n] produces a beep n times. n must be between 0 and 9. If not specified n=1.
(hence .beep 0 is equivalent to .nop)
.help:
a ".enter" or ".escape" does not have any meaning in the "onerrorcmd" context but it has a meaning
in the "ontimeout" context. In case the user gives a Terminal command which does not make sense, it
is upto the code (in this case adv_menu.tpl) to do what it pleases.
-
#ident "$Id$"
## -----------------------------------------------------------------------
-##
+##
## Copyright 2001-2005 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
LDIR = $(COM32DIR)/lib
CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os -fomit-frame-pointer -I$(LUDIR)/include -I$(COM32DIR)/include -Ilibmenu -D__COM32__
SFLAGS = -D__COM32__ -march=i386
-LDFLAGS = -T $(LDIR)/com32.ld
+LDFLAGS = -T $(LDIR)/com32.ld
OBJCOPY = objcopy
LIBGCC := $(shell $(CC) --print-libgcc)
LIBS = libmenu/libmenu.a $(LUDIR)/libutil_com.a $(LDIR)/libcom32.a $(LIBGCC)
LIBMENU = libmenu/syslnx.o libmenu/com32io.o libmenu/tui.o \
- libmenu/menu.o libmenu/passwords.o libmenu/des.o libmenu/help.o
+ libmenu/menu.o libmenu/passwords.o libmenu/des.o libmenu/help.o
CMENUS = $(patsubst %.c,%.c32,$(wildcard *.c))
IMENUS = $(patsubst %.menu,%.c32,$(wildcard *.menu))
%.o: %.c %.h
$(CC) $(CFLAGS) -c -o $@ $<
-.PRECIOUS: %.elf
+.PRECIOUS: %.elf
%.elf: %.o $(LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
+ $(LD) $(LDFLAGS) -o $@ $^
%.c32: %.elf
$(OBJCOPY) -O binary $< $@
$(RANLIB) $@
tidy:
- rm -f *.o *.lo *.a *.lst *.elf
+ rm -f *.o *.lo *.a *.lst *.elf
libclean:
rm -f libmenu/*.o libmenu/*.a
To configure the menus, you need to set up a menu configuration file
to have the menu items you desire, then build the menu system using
make. You can use either simple.c or complex.c as a starting point
-for your own menu configuration file; If your menu system is only going
-to have entries corresponding to things which can be executed directly,
+for your own menu configuration file; If your menu system is only going
+to have entries corresponding to things which can be executed directly,
then you can create a file in ".menu" format instead of the C code.
See MENU_FORMAT for the syntax of .menu files
The resulting code is a 32-bit COMBOOT code, and hence can be executed
only under syslinux. You can use tools like bochs to help debug your
-code.
+code.
Menu Features currently supported are:
-* menu items,
-* submenus,
+* menu items,
+* submenus,
* disabled items,
* checkboxes,
* invisible items (useful for dynamic menus), and
* Radio menus,
* Context sensitive help
-* Authenticated users
+* Authenticated users
* Editing commands associated with items
The keys used are:
Features
--------
-This is a general purpose menu system implemented using only BIOS calls,
+This is a general purpose menu system implemented using only BIOS calls,
so it can be executed in a COMBOOT environment as well. It is highly
customizable. Some features include:
Specify a window within which the menu system draws all its menu's.
It is upto the user to ensure that the menu's fit within the window.
* Positioning submenus
- By default, each submenu is positioned just below the corresponding
+ By default, each submenu is positioned just below the corresponding
entry of the parent menu. However, the user may position each menu
at a specific location of his choice. This is useful, when the menu's
have lots of options.
-* Registering handlers for each menu item
+* Registering handlers for each menu item
This is mainly used for checkboxes and radiomenu's, where a selection may
- result in disabling other menu items/checkboxes
+ result in disabling other menu items/checkboxes
* Global Screen Handler
This is called every time the menu is redrawn. The user can display
- additional information (usually outside the window where the menu is
+ additional information (usually outside the window where the menu is
being displayed). See the complex.c for an example, where the global
handler is used to display the choices made so far.
* Global Keys Handler
This is called every time the user presses a key which the menu
system does not understand. This can be used to display context
sensitive help. See complex.c for how to use this hook to implement
- a context sensitive help system as well as "On the fly" editing
- of commands associated with menus.
+ a context sensitive help system as well as "On the fly" editing
+ of commands associated with menus.
* Shortcut Keys
- With each item one can register a shortcut key from [A-Za-z0-9].
+ With each item one can register a shortcut key from [A-Za-z0-9].
Pressing a key within that range, will take you to the next item
with that shortcut key (so you can have multiple items with the
- same shortcut key). The default shortcut key for each item, is
- the lower case version of the first char of the item in the range
+ same shortcut key). The default shortcut key for each item, is
+ the lower case version of the first char of the item in the range
[A-Za-z0-9].
* Escape Keys
Each item entry can have a substring enclosed in < and >. This part
if an item has a <, then the first char inside < and > in the range
[A-Za-z0-9] is converted to lower case and set as the shortcut key.
* Ontimeout handler
- The user can register an ontimeout handler, which gets called if
+ The user can register an ontimeout handler, which gets called if
no key has been pressed for a user specific amount of time (default 5 min).
For an example see the complex.c file.
Credits
-------
-* The Watcom developers and Peter Anvin for figuring out an OS
+* The Watcom developers and Peter Anvin for figuring out an OS
independent startup code.
-* Thomas for porting the crypt function and removing all C library
+* Thomas for porting the crypt function and removing all C library
dependencies
-* Peter Anvin for porting the code to GCC
+* Peter Anvin for porting the code to GCC
- Murali (gmurali+guicd@cs.uchicago.edu)
-
* Write COMBOOT code to read .menu files and parse them directly
- - take the name of menu file to parse from commandline
-
+ - take the name of menu file to parse from commandline
All the lines in this file not in between --something BEGINS-- and --something ENDS--
is ignored completely and will not make it into the generated C file
-This file has sections of C code each section delimited by --secname BEGINS--
+This file has sections of C code each section delimited by --secname BEGINS--
and --secname ENDS--. In the generated C code certain section may be used multiple
times. Currently the different section which must be defined are
to the C code if you do not modify menugen.py to use it.
header and footer go through unmolested. The remaining are % substituted using
-python rules. Basically it means %(var)s gets replaced by the value of the variable
+python rules. Basically it means %(var)s gets replaced by the value of the variable
"var" which is a processed form of what is read from the .menu file
-NOTE: There is absolutely no C code in the python script, so you are free to
+NOTE: There is absolutely no C code in the python script, so you are free to
modify this template to suit your needs
--header BEGINS--
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2006 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
// Types of dot commands for which caller takes responsibility of handling
// In some case some commands may not make sense, it is up to the caller
// to handle cases which do not make sense
-typedef enum {QUIT_CMD, REPEAT_CMD, ENTER_CMD, ESCAPE_CMD} t_dotcmd;
+typedef enum {QUIT_CMD, REPEAT_CMD, ENTER_CMD, ESCAPE_CMD} t_dotcmd;
/*----------------- Global Variables */
{
char *p,*s,*e;
if (!str) return NULL;
- p = str;
+ p = str;
s = NULL;
e = NULL;
while (*p) {
return s;
}
-// executes a list of % separated commands
+// executes a list of % separated commands
// non-dot commands are assumed to be syslinux commands
// All syslinux commands are appended with the contents of kerargs
-// If it fails (kernel not found) then the next one is tried in the
+// If it fails (kernel not found) then the next one is tried in the
// list
// returns QUIT_CMD or RPT_CMD
t_dotcmd execdotcmd(const char *cmd, char *defcmd, const char *kerargs)
p = strchr(next,'%');
if (p) {
*p--='\0'; next=p+2;
- while (*p == ' ') p--;
+ while (*p == ' ') p--;
*(++p)='\0'; // remove trailing spaces
} else {
if (*defcmd) { // execute defcmd next
- next=defcmd;
+ next=defcmd;
defcmd=NULL; // exec def cmd only once
} else next=NULL;
}
while (*args == ' ') args++; // skip over spaces
}
if ( (strcmp(curr,".exit")==0) ||
- (strcmp(curr,".quit")==0)
+ (strcmp(curr,".quit")==0)
)
return QUIT_CMD;
if ( (strcmp(curr,".repeat")==0) ||
)
return RPT_CMD;
if (strcmp(curr,".beep")==0) {
- if ((args) && ('0' <= args[0]) && (args[0] <= '9'))
+ if ((args) && ('0' <= args[0]) && (args[0] <= '9'))
ctr = args[0]-'0';
else ctr=1;
for (;ctr>0; ctr--) beep();
t_dotcmd c;
c = execdotcmd(cmd,".wait",NULL);
switch(c) {
- case ENTER_CMD:
+ case ENTER_CMD:
return CODE_ENTER;
- case ESCAPE_CMD:
+ case ESCAPE_CMD:
return CODE_ESCAPE;
default:
return CODE_WAIT;
// and user has privileges to edit it, edit it in place.
if (((scancode & 0xFF) == 0x09) && (mi->action == OPT_RUN) &&
(EDIT_ROW < getnumrows()) && (EDIT_ROW > 0) &&
- (isallowed(username,"editcmd") || isallowed(username,"root"))) {
+ (isallowed(username,"editcmd") || isallowed(username,"root"))) {
nc = getnumcols();
// User typed TAB and has permissions to edit command line
gotoxy(EDIT_ROW,1,ms->menupage);
if (authenticate_user(login,pwd))
{
- strcpy(username,login);
+ strcpy(username,login);
strcpy(logoutstr,"<L>ogout ");
strcat(logoutstr,username);
mi->item = logoutstr; // Change item to read "Logout"
if (!bad_argsmenu) {
xtra->argsmenu = (char *) malloc(sizeof(char)*(strlen(argsmenu)+1));
strcpy(xtra->argsmenu,argsmenu);
- }
+ }
if (!bad_perms) {
xtra->perms = (char *) malloc(sizeof(char)*(strlen(perms)+1));
strcpy(xtra->perms,perms);
char exitcmd[MAX_CMD_LINE_LENGTH];
char exitcmdroot[MAX_CMD_LINE_LENGTH];
char onerrcmd[MAX_CMD_LINE_LENGTH];
- char startfile[MAX_CMD_LINE_LENGTH];
+ char startfile[MAX_CMD_LINE_LENGTH];
char *ecmd; // effective exit command or onerrorcmd
char skipbits;
char skipcmd[MAX_CMD_LINE_LENGTH];
strcpy(exitcmd,"%(exitcmd)s");
strcpy(exitcmdroot,"%(exitcmdroot)s");
// If not specified exitcmdroot = exitcmd
- if (exitcmdroot[0] == '\0') strcpy(exitcmdroot,exitcmd);
+ if (exitcmdroot[0] == '\0') strcpy(exitcmdroot,exitcmd);
// Timeout stuff
timeout = %(timeout)s;
strcpy(timeoutcmd,"%(timeoutcmd)s");
if (getshiftflags() & skipbits) { // we must skip the menu altogther and execute skipcmd
dotrv = execdotcmd(skipcmd,".beep%.exit",NULL); // Worst case we beep and exit
if (dotrv == QUIT_CMD) quit = 1;
- }
+ }
// Switch vide mode if required
if (vmode != 0xFF) setvideomode(vmode);
}
}
-// Deallocate space used and quit
+// Deallocate space used and quit
close_passwords();
close_help();
- close_menusystem();
+ close_menusystem();
return 0;
}
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
// If user hit TAB, and item is an "executable" item
// and user has privileges to edit it, edit it in place.
if (((scancode & 0xFF) == 0x09) && (mi->action == OPT_RUN) &&
- (isallowed(username,"editcmd") || isallowed(username,"root"))) {
+ (isallowed(username,"editcmd") || isallowed(username,"root"))) {
nc = getnumcols();
// User typed TAB and has permissions to edit command line
gotoxy(EDITPROMPT,1,ms->menupage);
if (authenticate_user(login,pwd))
{
- strcpy(username,login);
+ strcpy(username,login);
mi->item = logoutstr; // Change item to read "Logout"
}
else strcpy(username,GUEST_USER);
prepopt->action = OPT_INACTIVE;
secret->action = OPT_INVISIBLE;
}
- else
+ else
{
prepopt->action = OPT_SUBMENU;
prepopt->itemdata.radiomenunum = PREPMENU;
(void)ms; /* Unused */
if (mi->action != OPT_CHECKBOX) return ACTION_INVALID;
-
+
if (strcmp(mi->data,"baseurl") == 0) flags.baseurl = (mi->itemdata.checked ? 1 : 0);
if (strcmp(mi->data,"winrepair") == 0) {
if (mi->itemdata.checked)
}
/*
- Clears keyboard buffer and then
+ Clears keyboard buffer and then
wait for stepsize*numsteps milliseconds for user to press any key
checks for keypress every stepsize milliseconds.
Returns: 1 if user pressed a key (not read from the buffer),
init_help("/isolinux/help");
init_menusystem(NULL);
set_window_size(1,1,20,78); // Leave some space around
-
+
// Choose the default values for all attributes and char's
// -1 means choose defaults (Actually the next 4 lines are not needed)
- //set_normal_attr (-1,-1,-1,-1);
+ //set_normal_attr (-1,-1,-1,-1);
//set_status_info (-1,-1); // Display status on the last line
- //set_title_info (-1,-1);
+ //set_title_info (-1,-1);
//set_misc_info(-1,-1,-1,-1);
// Register the menusystem handler
// Register the ontimeout handler, with a time out of 10 seconds
reg_ontimeout(ontimeout,1000,0);
- NETMENU = add_menu(" Init Network ",-1);
+ NETMENU = add_menu(" Init Network ",-1);
none = add_item("<N>one","Dont start network",OPT_RADIOITEM,"no ",0);
dhcp = add_item("<d>hcp","Use DHCP",OPT_RADIOITEM,"dhcp ",0);
stat = add_item("<s>tatic","Use static IP I will specify later",OPT_RADIOITEM,"static ",0);
add_item("<8>","A",OPT_RUN,"A",0);
add_item("<9>","A",OPT_RUN,"A",0);
- MAIN = add_menu(" Main Menu ",8);
+ MAIN = add_menu(" Main Menu ",8);
curr = add_item(loginstr,"Login as a privileged user",OPT_RUN,NULL,0);
set_item_options(-1,23);
curr->handler = &login_handler;
// Deallocate space used for these data structures
close_passwords();
close_help();
- close_menusystem();
+ close_menusystem();
// Return to prompt
return 0;
}
-
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2006 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
__intcall(0x10,&inreg,&outreg);
}
-char getdisppage() // Get current display page
+char getdisppage() // Get current display page
{
REG_AH(inreg) = 0x0f;
__intcall(0x10,&inreg,&outreg);
{
REG_AH(inreg) = 0x0E;
REG_AL(inreg) = 0x07;
- REG_BH(inreg) = 0;
+ REG_BH(inreg) = 0;
__intcall(0x10,&inreg,&outreg);
}
if (scancode) *scancode = REG_AH(outreg);
return REG_AL(outreg);
}
-
+
void getcursorshape(char *start, char *end)
{
char page = getdisppage();
__intcall(0x16,&inreg,&outreg);
return REG_AL(outreg);
}
-
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
/* BIOS Assisted output routines */
-void cswprint(const char *str, char attr, char left);
+void cswprint(const char *str, char attr, char left);
// Print a C str (NUL-terminated) respecting the left edge of window
// i.e. \n in str will move cursor to column left
// Print a C str (NUL-terminated)
cswprint(str,attr,0);
}
-void cprint(char chr,char attr,unsigned int times, char disppage); // Print a char
+void cprint(char chr,char attr,unsigned int times, char disppage); // Print a char
void setdisppage(char num); // Set the display page to specified number
-char getdisppage(); // Get current display page
+char getdisppage(); // Get current display page
void gotoxy(char row,char col, char page);
char inputc(char * scancode); // Return ASCII char by val, and scancode by reference
static inline void putch(char x, char attr, char page)
-{
+{
cprint(x,attr,1,page);
}
void getcursorshape(char *start,char *end); // Get shape for current page
// Get char displayed at current position in specified page
-unsigned char getcharat(char page);
+unsigned char getcharat(char page);
static inline void cursoroff(void) /* Turns off cursor */
{
{
scrollupwindow(0,0,getnumrows(),getnumcols(),0x07,1);
}
-
+
void setvideomode(char mode); // Set the video mode.
-static inline char getvideomode(void) // Get the current video mode
+static inline char getvideomode(void) // Get the current video mode
{
return readbiosb(0x449);
}
unsigned char checkkbdbuf(); // Check to see if there is kbd buffer is non-empty?
static inline void clearkbdbuf() // Clear the kbd buffer (how many chars removed?)
-{
+{
while (checkkbdbuf()) inputc(NULL);
-}
+}
#endif
typedef unsigned long my_u_int32_t;
typedef unsigned char my_u_char_t;
-/* Re-entrantify me -- all this junk needs to be in
+/* Re-entrantify me -- all this junk needs to be in
* struct crypt_data to make this really reentrant... */
static my_u_char_t inv_key_perm[64];
static my_u_char_t inv_comp_perm[56];
static my_u_int32_t common[8][256];
#endif
-/* Static stuff that stays resident and doesn't change after
- * being initialized, and therefore doesn't need to be made
+/* Static stuff that stays resident and doesn't change after
+ * being initialized, and therefore doesn't need to be made
* reentrant. */
static my_u_char_t init_perm[64], final_perm[64];
static my_u_char_t m_sbox[4][4096];
// static const my_u_int32_t *bits28, *bits24;
-static int
+static int
ascii_to_bin(char ch)
{
if (ch > 'z')
* and for the key initial and compression permutations.
*/
-#ifndef LOWSPACE
+#ifndef LOWSPACE
for (k = 0; k < 8; k++) {
for (i = 0; i < 256; i++) {
*(il = &ip_maskl[k][i]) = 0L;
for (i = 0; i < 32; i++)
un_pbox[pbox[i] - 1] = (my_u_char_t)i;
-#ifndef LOWSPACE
+#ifndef LOWSPACE
for (b = 0; b < 4; b++)
for (i = 0; i < 256; i++) {
*(p = &psbox[b][i]) = 0L;
{
int i, j, k, inbit, obit;
my_u_int32_t *il;
-
+
for (k = 0; k < 8; k++) {
for (i = 0; i < 256; i++) {
*(il = &common[k][i]) = 0L;
{
int i, j, k, inbit, obit;
my_u_int32_t *ir;
-
+
for (k = 0; k < 8; k++) {
for (i = 0; i < 256; i++) {
*(ir = &common[k][i]) = 0L;
}
}
}
-
+
static void
setup_fp_maskr(void)
{
}
}
}
-
+
static void
setup_key_perm_maskl(void)
{
}
}
}
-
+
static void
setup_comp_maskl(void)
{
{
int i, j, b;
my_u_int32_t *p;
-
+
for (b = 0; b < 4; b++)
for (i = 0; i < 256; i++) {
*(p = &common[b][i]) = 0L;
* Do key permutation and split into two 28-bit subkeys.
*/
-#ifdef LOWSPACE
+#ifdef LOWSPACE
setup_key_perm_maskl();
k0 = common[0][rawkey0 >> 25]
| common[1][(rawkey0 >> 17) & 0x7f]
t0 = (k0 << shifts) | (k0 >> (28 - shifts));
t1 = (k1 << shifts) | (k1 >> (28 - shifts));
-#ifdef LOWSPACE
+#ifdef LOWSPACE
setup_comp_maskl();
de_keysl[15 - round] =
en_keysl[round] = common[0][(t0 >> 21) & 0x7f]
/*
* Do initial permutation (IP).
*/
-
+
#ifdef LOWSPACE
setup_ip_maskl();
l = common[0][l_in >> 24]
*/
output[9] = '\0';
p = (my_u_char_t *)output + strlen(output);
- } else
+ } else
#endif
{
/*
return(output);
}
-
extern char *crypt (const char *key, const char *salt);
#endif
-
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
{
int ctr;
char *p= buffer-1;
-
+
if (count < 1) return buffer;
for (ctr=0; ctr < count; ctr++) {
p = strchr(p+1,'\n');
char *p,*f;
char right,bot,nlines;
- // clear window to print
+ // clear window to print
right = getnumcols() - HELP_RIGHT_MARGIN;
bot = getnumrows() - HELP_BOTTOM_MARGIN;
nlines = bot-HELP_BODY_ROW+1;
- scrollupwindow(HELP_BODY_ROW,HELP_LEFT_MARGIN,bot,right,0x07,nlines);
+ scrollupwindow(HELP_BODY_ROW,HELP_LEFT_MARGIN,bot,right,0x07,nlines);
f = findline(buf,from);
if (!f) return; // nothing to print
if (*f=='\n') f++; // start of from+1st line
- p = findline(f,nlines);
+ p = findline(f,nlines);
if (p && (*p=='\n')) *p = '\0'; // change to NUL
gotoxy(HELP_BODY_ROW,HELP_LEFT_MARGIN,HELPPAGE);
cswprint(f,0x07,HELP_LEFT_MARGIN);
char nc,nr,ph;
char *title,*text;
union { char *buffer; void *vbuf; } buf; // This is to avoild type-punning issues
-
+
char line[512];
size_t size;
char scan;
cls();
return;
}
-
+
rv = loadfile(filename,(void **)&buf.vbuf, &size); // load entire file into memory
if (rv < 0) { // Error reading file or no such file
sprintf(line, "Error reading file or file not found\n file=%s",filename);
while(scan != ESCAPE) {
printtext(text,curr_line);
gotoxy(HELP_BODY_ROW-1,nc-HELP_RIGHT_MARGIN,HELPPAGE);
- if (curr_line > 0)
+ if (curr_line > 0)
putch(HELP_MORE_ABOVE,0x07,HELPPAGE);
else putch(' ',0x07,HELPPAGE);
gotoxy(nr-HELP_BOTTOM_MARGIN+1,nc-HELP_RIGHT_MARGIN,HELPPAGE);
- if (curr_line < numlines - ph)
+ if (curr_line < numlines - ph)
putch(HELP_MORE_BELOW,0x07,HELPPAGE);
else putch(' ',0x07,HELPPAGE);
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
/* Forward declarations */
int calc_visible(pt_menu menu,int first);
-int next_visible(pt_menu menu,int index);
-int prev_visible(pt_menu menu,int index);
-int next_visible_sep(pt_menu menu,int index);
-int prev_visible_sep(pt_menu menu,int index);
+int next_visible(pt_menu menu,int index);
+int prev_visible(pt_menu menu,int index);
+int next_visible_sep(pt_menu menu,int index);
+int prev_visible_sep(pt_menu menu,int index);
int calc_first_early(pt_menu menu,int curr);
int calc_first_late(pt_menu menu,int curr);
int isvisible(pt_menu menu,int first, int curr);
if (checkkbdbuf()) return inputc(scan);
sleep(ms->tm_stepsize);
if ( (ms->tm_total_timeout == 0) || (ms->ontotaltimeout==NULL))
- continue; // Dont bother with calculations if no handler
+ continue; // Dont bother with calculations if no handler
ms->tm_sofar_timeout += ms->tm_stepsize;
if (ms->tm_sofar_timeout >= ms->tm_total_timeout) {
th = ms->ontotaltimeout;
getpos(&row,&col,page);
while ( *str ) {
- switch (*str)
+ switch (*str)
{
case '\b':
--col;
}
}
-int find_shortcut(pt_menu menu,uchar shortcut, int index)
+int find_shortcut(pt_menu menu,uchar shortcut, int index)
// Find the next index with specified shortcut key
{
int ans;
pt_menuitem mi;
// Garbage in garbage out
- if ((index <0) || (index >= menu->numitems)) return index;
+ if ((index <0) || (index >= menu->numitems)) return index;
ans = index+1;
// Go till end of menu
- while (ans < menu->numitems)
+ while (ans < menu->numitems)
{
mi = menu->items[ans];
if ((mi->action == OPT_INVISIBLE) || (mi->action == OPT_SEP)
uchar *attr; // attribute attr
char sep[MENULEN];// and inbetween the item or a seperator is printed
pt_menuitem ci;
-
+
numitems = calc_visible(menu,first);
if (numitems > menu->menuheight) numitems = menu->menuheight;
drawbox(top-1,left-3,top+numitems,left+menuwidth,
ms->menupage,ms->normalattr[NOHLITE],ms->menubt);
memset(sep,ms->box_horiz,menuwidth); // String containing the seperator string
- sep[menuwidth-1] = 0;
+ sep[menuwidth-1] = 0;
// Menu title
x = (menuwidth - strlen(menu->title) - 1) >> 1;
gotoxy(top-1,left+x,ms->menupage);
row++;
if (row >= numitems) break; // Already have enough number of items
// Setup the defaults now
- lchar[0] = fchar[0] = ' ';
+ lchar[0] = fchar[0] = ' ';
lchar[1] = fchar[1] = '\0'; // fchar and lchar are just spaces
str = ci->item; // Pointer to item string
attr = (x==curr ? ms->reverseattr : ms->normalattr); // Normal attributes
csprint(lchar,attr[NOHLITE]); // Print last part
}
// Check if we need to MOREABOVE and MOREBELOW to be added
- // reuse x
+ // reuse x
row = 0;
x = next_visible_sep(menu,0); // First item
if (! isvisible(menu,first,x)) // There is more above
if (ms->handler) ms->handler(ms,menu->items[curr]);
}
-// Difference between this and regular menu, is that only
-// OPT_INVISIBLE, OPT_SEP are honoured
+// Difference between this and regular menu, is that only
+// OPT_INVISIBLE, OPT_SEP are honoured
void printradiomenu(pt_menu menu, int curr, uchar top, uchar left, int first)
{
int x,row; // x = index, row = position from top
uchar *attr; // all in the attribute attr
char sep[MENULEN];// and inbetween the item or a seperator is printed
pt_menuitem ci;
-
+
numitems = calc_visible(menu,first);
if (numitems > menu->menuheight) numitems = menu->menuheight;
drawbox(top-1,left-3,top+numitems,left+menuwidth,
ms->menupage,ms->normalattr[NOHLITE],ms->menubt);
memset(sep,ms->box_horiz,menuwidth); // String containing the seperator string
- sep[menuwidth-1] = 0;
+ sep[menuwidth-1] = 0;
// Menu title
x = (menuwidth - strlen(menu->title) - 1) >> 1;
gotoxy(top-1,left+x,ms->menupage);
if (row > numitems) break;
// Setup the defaults now
fchar[0] = RADIOUNSEL; fchar[1]='\0'; // Unselected ( )
- lchar[0] = '\0'; // Nothing special after
+ lchar[0] = '\0'; // Nothing special after
str = ci->item; // Pointer to item string
attr = ms->normalattr; // Always same attribute
- fchar[0] = (x==curr ? RADIOSEL : RADIOUNSEL);
+ fchar[0] = (x==curr ? RADIOSEL : RADIOUNSEL);
switch (ci->action) // set up attr,str,fchar,lchar for everything
{
case OPT_INACTIVE:
csprint(lchar,attr[NOHLITE]); // Print last part
}
// Check if we need to MOREABOVE and MOREBELOW to be added
- // reuse x
+ // reuse x
row = 0;
x = next_visible_sep(menu,0); // First item
if (! isvisible(menu,first,x)) // There is more above
uchar asc,scan;
uchar numitems;
pt_menuitem ci; // Current item
-
+
numitems = calc_visible(menu,0);
// Setup status line
gotoxy(ms->minrow+ms->statline,ms->mincol,ms->menupage);
{
printradiomenu(menu,curr,top,left,first);
ci = menu->items[curr];
-
+
asc = getch(&scan);
switch (scan)
{
break;
case DNARROW:
curr = next_visible(menu,curr+1);
- if (! isvisible(menu,first,curr))
+ if (! isvisible(menu,first,curr))
first = calc_first_late(menu,curr);
break;
case LTARROW:
tmp = find_shortcut(menu,asc,curr);
if ((tmp > curr) && (! isvisible(menu,first,tmp)))
first = calc_first_late(menu,tmp);
- if (tmp < curr)
+ if (tmp < curr)
first = calc_first_early(menu,tmp);
curr = tmp;
}
uchar numitems;
pt_menuitem ci; // Current item
t_handler_return hr; // Return value of handler
-
+
numitems = calc_visible(menu,0);
// Setup status line
gotoxy(ms->minrow+ms->statline,ms->mincol,ms->menupage);
cprint(ms->spacechar,ms->statusattr[NOHLITE],ms->numcols,ms->menupage);
- // Initialise current menu item
+ // Initialise current menu item
curr = next_visible(menu,startopt);
gotoxy(ms->minrow+ms->statline,ms->mincol,ms->menupage);
break;
case DNARROW:
curr = next_visible(menu,curr+1);
- if (! isvisible(menu,first,curr))
+ if (! isvisible(menu,first,curr))
first = calc_first_late(menu,curr);
break;
case LTARROW:
if (ci->action == OPT_RADIOMENU) return ci;
if (ci->handler != NULL) // Do we have a handler
{
- hr = ci->handler(ms,ci);
+ hr = ci->handler(ms,ci);
if (hr.refresh) // Do we need to refresh
{
// Cleanup menu using old number of items
- cleanupmenu(menu,top,left,numitems);
+ cleanupmenu(menu,top,left,numitems);
// Recalculate the number of items
numitems = calc_visible(menu,0);
// Reprint the menu
printmenu(menu,curr,top,left,first);
}
- if (hr.valid) return ci;
+ if (hr.valid) return ci;
}
else return ci;
break;
ci->itemdata.checked = !ci->itemdata.checked;
if (ci->handler != NULL) // Do we have a handler
{
- hr = ci->handler(ms,ci);
+ hr = ci->handler(ms,ci);
if (hr.refresh) // Do we need to refresh
{
// Cleanup menu using old number of items
- cleanupmenu(menu,top,left,numitems);
+ cleanupmenu(menu,top,left,numitems);
// Recalculate the number of items
numitems = calc_visible(menu,0);
// Reprint the menu
tmp = find_shortcut(menu,asc,curr);
if ((tmp > curr) && (! isvisible(menu,first,tmp)))
first = calc_first_late(menu,tmp);
- if (tmp < curr)
+ if (tmp < curr)
first = calc_first_early(menu,tmp);
curr = tmp;
}
startover:
// Set the menu height
cmenu->menuheight = ms->maxrow - top-3;
- if (cmenu->menuheight > ms->maxmenuheight)
+ if (cmenu->menuheight > ms->maxmenuheight)
cmenu->menuheight = ms->maxmenuheight;
if (menutype == NORMALMENU)
opt = getmenuoption(cmenu,top,left,startopt);
return NULL;
}
// Are we done with the menu system?
- if ((opt->action != OPT_SUBMENU) && (opt->action != OPT_RADIOMENU))
+ if ((opt->action != OPT_SUBMENU) && (opt->action != OPT_RADIOMENU))
{
cleanupmenu(cmenu,top,left,calc_visible(cmenu,0));
return opt; // parent cleanup other menus
}
// Either radiomenu or submenu
- // Do we have a valid menu number? The next hack uses the fact that
+ // Do we have a valid menu number? The next hack uses the fact that
// itemdata.submenunum = itemdata.radiomenunum (since enum data type)
if (opt->itemdata.submenunum >= ms->nummenus) // This is Bad....
{
if (opt->action == OPT_RADIOMENU)
{
if (choice != NULL) opt->data = (void *)choice; // store choice in data field
- if (opt->handler != NULL) opt->handler(ms,opt);
+ if (opt->handler != NULL) opt->handler(ms,opt);
choice = NULL; // Pretend user hit esc
}
if (choice==NULL) // User hit Esc in submenu
if (name == NULL) return (uchar)(-1);
for (i=0; i < ms->nummenus; i++)
- {
+ {
m = ms->menus[i];
if ((m->name) && (strcmp(m->name,name)==0)) return i;
}
for (j=0; j < m->numitems; j++)
{
mi = m->items[j];
- // if submenu with non-trivial data string
+ // if submenu with non-trivial data string
// again using hack that itemdata is a union data type
if ( mi->data && ((mi->action == OPT_SUBMENU) || (mi->action == OPT_RADIOMENU)) )
mi->itemdata.submenunum = find_menu_num (mi->data);
pt_menuitem rv;
uchar oldpage,tpos;
- fix_submenus(); // Fix submenu numbers incase nick names were used
+ fix_submenus(); // Fix submenu numbers incase nick names were used
// Setup screen for menusystem
oldpage = getdisppage();
setdisppage(ms->menupage);
cls();
- clearwindow(ms->minrow, ms->mincol, ms->maxrow, ms->maxcol,
+ clearwindow(ms->minrow, ms->mincol, ms->maxrow, ms->maxcol,
ms->menupage, ms->fillchar, ms->fillattr);
- tpos = (ms->numcols - strlen(ms->title) - 1) >> 1; // center it on line
+ tpos = (ms->numcols - strlen(ms->title) - 1) >> 1; // center it on line
gotoxy(ms->minrow,ms->mincol,ms->menupage);
cprint(ms->tfillchar,ms->titleattr,ms->numcols,ms->menupage);
gotoxy(ms->minrow,ms->mincol+tpos,ms->menupage);
cursoroff(); // Doesn't seem to work?
- // Go, main menu cannot be a radio menu
- rv = runmenusystem(ms->minrow+MENUROW, ms->mincol+MENUCOL,
+ // Go, main menu cannot be a radio menu
+ rv = runmenusystem(ms->minrow+MENUROW, ms->mincol+MENUCOL,
ms->menus[(unsigned int)startmenu], 0, NORMALMENU);
// Hide the garbage we left on the screen
pt_menusystem init_menusystem(const char *title)
{
int i;
-
+
ms = NULL;
ms = (pt_menusystem) malloc(sizeof(t_menusystem));
if (ms == NULL) return NULL;
ms->nummenus = 0;
// Initialise all menu pointers
- for (i=0; i < MAXMENUS; i++) ms->menus[i] = NULL;
-
- ms->title = (char *)malloc(TITLELEN+1);
+ for (i=0; i < MAXMENUS; i++) ms->menus[i] = NULL;
+
+ ms->title = (char *)malloc(TITLELEN+1);
if (title == NULL)
strcpy(ms->title,TITLESTR); // Copy string
else strcpy(ms->title,title);
ms->tm_stepsize = TIMEOUTSTEPSIZE;
ms->tm_numsteps = TIMEOUTNUMSTEPS;
- ms->normalattr[NOHLITE] = NORMALATTR;
+ ms->normalattr[NOHLITE] = NORMALATTR;
ms->normalattr[HLITE] = NORMALHLITE;
ms->reverseattr[NOHLITE] = REVERSEATTR;
ms->statline = STATLINE;
ms->tfillchar= TFILLCHAR;
ms->titleattr= TITLEATTR;
-
+
ms->fillchar = FILLCHAR;
ms->fillattr = FILLATTR;
ms->spacechar= SPACECHAR;
// Initialise all handlers
ms->handler = NULL;
- ms->keys_handler = NULL;
+ ms->keys_handler = NULL;
ms->ontimeout=NULL; // No timeout handler
- ms->tm_total_timeout = 0;
+ ms->tm_total_timeout = 0;
ms->tm_sofar_timeout = 0;
ms->ontotaltimeout = NULL;
// How many entries per menu can we display at a time
ms->maxmenuheight = ms->maxrow - ms->minrow - 3;
- if (ms->maxmenuheight > MAXMENUHEIGHT)
- ms->maxmenuheight= MAXMENUHEIGHT;
+ if (ms->maxmenuheight > MAXMENUHEIGHT)
+ ms->maxmenuheight= MAXMENUHEIGHT;
// Set up the look of the box
set_box_type(MENUBOXTYPE);
ms->menubt = bt;
bxc = getboxchars(bt);
ms->box_horiz = bxc[BOX_HORIZ]; // The char used to draw top line
- ms->box_ltrt = bxc[BOX_LTRT];
- ms->box_rtlt = bxc[BOX_RTLT];
+ ms->box_ltrt = bxc[BOX_LTRT];
+ ms->box_rtlt = bxc[BOX_RTLT];
}
-void set_menu_options(uchar maxmenuheight)
+void set_menu_options(uchar maxmenuheight)
{
if (maxmenuheight != 0xFF) ms->maxmenuheight = maxmenuheight;
}
// Set the window which menusystem should use
-void set_window_size(uchar top, uchar left, uchar bot, uchar right)
+void set_window_size(uchar top, uchar left, uchar bot, uchar right)
{
-
+
uchar nr,nc;
if ((top > bot) || (left > right)) return; // Sorry no change will happen here
nr = getnumrows();
}
-int next_visible(pt_menu menu, int index)
+int next_visible(pt_menu menu, int index)
{
int ans;
if (index < 0) ans = 0 ;
else if (index >= menu->numitems) ans = menu->numitems-1;
else ans = index;
- while ((ans < menu->numitems-1) &&
- ((menu->items[ans]->action == OPT_INVISIBLE) ||
- (menu->items[ans]->action == OPT_SEP)))
+ while ((ans < menu->numitems-1) &&
+ ((menu->items[ans]->action == OPT_INVISIBLE) ||
+ (menu->items[ans]->action == OPT_SEP)))
ans++;
return ans;
}
if (index < 0) ans = 0;
else if (index >= menu->numitems) ans = menu->numitems-1;
else ans = index;
- while ((ans > 0) &&
+ while ((ans > 0) &&
((menu->items[ans]->action == OPT_INVISIBLE) ||
- (menu->items[ans]->action == OPT_SEP)))
+ (menu->items[ans]->action == OPT_SEP)))
ans--;
return ans;
}
-int next_visible_sep(pt_menu menu, int index)
+int next_visible_sep(pt_menu menu, int index)
{
int ans;
if (index < 0) ans = 0 ;
else if (index >= menu->numitems) ans = menu->numitems-1;
else ans = index;
- while ((ans < menu->numitems-1) &&
- (menu->items[ans]->action == OPT_INVISIBLE))
+ while ((ans < menu->numitems-1) &&
+ (menu->items[ans]->action == OPT_INVISIBLE))
ans++;
return ans;
}
if (index < 0) ans = 0;
else if (index >= menu->numitems) ans = menu->numitems-1;
else ans = index;
- while ((ans > 0) &&
- (menu->items[ans]->action == OPT_INVISIBLE))
+ while ((ans > 0) &&
+ (menu->items[ans]->action == OPT_INVISIBLE))
ans--;
return ans;
}
{
int ans,i;
- if (menu == NULL) return 0;
+ if (menu == NULL) return 0;
ans = 0;
for (i=first; i < menu->numitems; i++)
if (menu->items[i]->action != OPT_INVISIBLE) ans++;
nv = calc_visible(menu,0);
if (nv <= menu->menuheight) return 0;
- // Start with curr and go back till >= menu->menuheight
- // items are visible
+ // Start with curr and go back till >= menu->menuheight
+ // items are visible
nv = calc_visible(menu,curr); // Already nv of them are visible
ans = curr;
for (i=0; i < menu->menuheight - nv; i++)
}
// Create a new menu and return its position
-uchar add_menu(const char *title, int maxmenusize)
+uchar add_menu(const char *title, int maxmenusize)
{
int num,i;
pt_menu m;
else m->maxmenusize = maxmenusize;
m->items = (pt_menuitem *) malloc(sizeof(pt_menuitem)*(m->maxmenusize));
for (i=0; i < m->maxmenusize; i++) m->items[i] = NULL;
-
+
m->title = (char *)malloc(MENULEN+1);
if (title)
{
if (strlen(title) > MENULEN - 2)
strcpy(m->title,TITLELONG);
- else strcpy(m->title,title);
+ else strcpy(m->title,title);
}
- else strcpy(m->title,EMPTYSTR);
+ else strcpy(m->title,EMPTYSTR);
m ->menuwidth = strlen(m->title);
ms->nummenus ++;
return ms->nummenus - 1;
if (name)
{
m->name = (char *)malloc(strlen(name)+1);
- strcpy(m->name,name);
+ strcpy(m->name,name);
}
}
// Create a new named menu and return its position
-uchar add_named_menu(const char * name, const char *title, int maxmenusize)
+uchar add_named_menu(const char * name, const char *title, int maxmenusize)
{
add_menu(title,maxmenusize);
set_menu_name(name);
}
// Add item to the "current" menu
-pt_menuitem add_item(const char *item, const char *status, t_action action,
- const char *data, uchar itemdata)
+pt_menuitem add_item(const char *item, const char *status, t_action action,
+ const char *data, uchar itemdata)
{
pt_menuitem mi;
pt_menu m;
if (item) {
if (strlen(item) > MENULEN) {
- strcpy(mi->item,ITEMLONG);
+ strcpy(mi->item,ITEMLONG);
} else {
- strcpy(mi->item,item);
+ strcpy(mi->item,item);
}
if (strlen(mi->item) > m->menuwidth) m->menuwidth = strlen(mi->item);
- } else strcpy(mi->item,EMPTYSTR);
+ } else strcpy(mi->item,EMPTYSTR);
if (status) {
if (strlen(status) > STATLEN) {
- strcpy(mi->status,STATUSLONG);
+ strcpy(mi->status,STATUSLONG);
} else {
- strcpy(mi->status,status);
+ strcpy(mi->status,status);
}
- } else strcpy(mi->status,EMPTYSTR);
-
+ } else strcpy(mi->status,EMPTYSTR);
+
mi->action=action;
str = mi->item;
mi->shortcut = 0;
// Find the first char in [A-Za-z0-9] after ENABLEHLITE and not arg to control char
while (*str)
{
- if (*str == ENABLEHLITE)
+ if (*str == ENABLEHLITE)
{
inhlite=1;
}
{
inhlite = 0;
}
- if ( (inhlite == 1) &&
- (((*str >= 'A') && (*str <= 'Z')) ||
+ if ( (inhlite == 1) &&
+ (((*str >= 'A') && (*str <= 'Z')) ||
((*str >= 'a') && (*str <= 'z')) ||
((*str >= '0') && (*str <= '9'))))
{
if (data) {
if (strlen(data) > ACTIONLEN) {
- strcpy(mi->data,ACTIONLONG);
+ strcpy(mi->data,ACTIONLONG);
} else {
- strcpy(mi->data,data);
+ strcpy(mi->data,data);
}
} else strcpy(mi->data,EMPTYSTR);
pt_menuitem mi;
pt_menu m;
- m = (ms->menus[ms->nummenus-1]);
+ m = (ms->menus[ms->nummenus-1]);
if (m->numitems <= 0) return;
mi = m->items[(unsigned int) m->numitems-1];
if (menunum < 0) return; // No such menu
append_line_helper(menunum,line);
}
-
* Could just quit the menu program
* beep and return.
- TIMEOUTSTEPSIZE is the interval for which the program sleeps without checking for
+ TIMEOUTSTEPSIZE is the interval for which the program sleeps without checking for
any keystroke. So increasing this will make the response of the system slow.
Decreasing this will make a lot of interrupt calls using up your CPU. Default
value of TIMEOUTSTEPSIZE of 0.1 seconds should be right in most cases.
TIMEOUTNUMSTEPS of 3000 corresponds to a wait time of 300 seconds or 5 minutes
*/
-#define TIMEOUTSTEPSIZE 10
+#define TIMEOUTSTEPSIZE 10
#define TIMEOUTNUMSTEPS 30000L
// Attributes
// Other Chars
#define SUBMENUCHAR 175 // This is >> symbol
-#define RADIOMENUCHAR '>' // > symbol for radio menu?
+#define RADIOMENUCHAR '>' // > symbol for radio menu?
#define EXITMENUCHAR 174 // This is << symbol
#define CHECKED 251 // Check mark
#define UNCHECKED 250 // Light bullet
-#define RADIOSEL '.' // Current Radio Selection
+#define RADIOSEL '.' // Current Radio Selection
#define RADIOUNSEL ' ' // Radio option not selected
typedef unsigned char uchar;
// Types of menu's
-#define NORMALMENU 1
+#define NORMALMENU 1
#define RADIOMENU 2
typedef enum {OPT_INACTIVE, OPT_SUBMENU, OPT_RUN, OPT_EXITMENU, OPT_CHECKBOX,
unsigned int reserved:6; // For future expansion
} t_handler_return;
-t_handler_return ACTION_VALID,ACTION_INVALID; // Specific values
+t_handler_return ACTION_VALID,ACTION_INVALID; // Specific values
typedef t_handler_return (*t_item_handler)(struct s_menusystem *, struct s_menuitem *);
typedef void (*t_menusystem_handler)(struct s_menusystem *, struct s_menuitem *);
typedef void (*t_keys_handler)(struct s_menusystem *, struct s_menuitem *,
- unsigned int scancode);
+ unsigned int scancode);
// Last parameter = HIGH BYTE = scan code , LOW BYTE = ASCII CODE
-typedef enum {HDLR_SCREEN, HDLR_KEYS } t_handler;
-// Types of handlers for menu system
+typedef enum {HDLR_SCREEN, HDLR_KEYS } t_handler;
+// Types of handlers for menu system
// TIMEOUT is the list of possible values which can be returned by the handler
// instructing the menusystem what to do. The default is CODE_WAIT
typedef struct s_menuitem {
char *item;
char *status;
- char *data; // string containing kernel to run.. but...
+ char *data; // string containing kernel to run.. but...
// for radio menu's this is a pointer to the item selected or NULL (initially)
- // for submenu's this string could be name of menu
+ // for submenu's this string could be name of menu
void * extra_data; // Any other data user can point to
unsigned int helpid; // Used for Context sensitive help
t_item_handler handler; // Pointer to function of type menufn
t_itemdata itemdata; // Data depends on action value
uchar shortcut; // one of [A-Za-z0-9] shortcut for this menu item
uchar index; // Index within the menu array
- uchar parindex; // Index of the menu in which this item appears.
-
+ uchar parindex; // Index of the menu in which this item appears.
+
} t_menuitem;
typedef t_menuitem *pt_menuitem; // Pointer to type menuitem
typedef struct s_menu {
pt_menuitem *items; // pointer to array of pointer to menuitems
char *title; // Title string for menu
- char *name; // menu can be referred to by this string
+ char *name; // menu can be referred to by this string
int maxmenusize; // the size of array allocated
uchar numitems; // how many items do we actually have
uchar menuwidth;
typedef struct s_menusystem {
pt_menu menus[MAXMENUS];
- char *title;
- t_menusystem_handler handler; // Menu system handler
+ char *title;
+ t_menusystem_handler handler; // Menu system handler
t_keys_handler keys_handler; // Handler for unknown keys
t_timeout_handler ontimeout; // Timeout handler
- unsigned long tm_numsteps;
+ unsigned long tm_numsteps;
// Time to wait for key press=numsteps * stepsize milliseconds
unsigned int tm_stepsize; // Timeout step size (in milliseconds)
// Total timeout max time spent idle before we call handler
uchar shadowattr;
uchar statline;
uchar menupage;
- uchar maxrow,minrow,numrows; // Number of rows in the window
+ uchar maxrow,minrow,numrows; // Number of rows in the window
uchar maxcol,mincol,numcols; // Number of columns in the window
// Menu box look
- boxtype menubt; // What type of boxes should be drawn
+ boxtype menubt; // What type of boxes should be drawn
char box_horiz,box_ltrt,box_rtlt; // Some chars of the box, for redrawing portions of the box
} t_menusystem;
pt_menuitem showmenus(uchar startmenu);
-pt_menusystem init_menusystem(const char *title);
+pt_menusystem init_menusystem(const char *title);
void close_menusystem(); // Deallocate memory used
void set_window_size(uchar top, uchar left, uchar bot, uchar right); // Set the window which menusystem should use
-void set_menu_options(uchar maxmenuheight);
+void set_menu_options(uchar maxmenuheight);
// maximum height of a menu
void reg_handler(t_handler htype, void * handler); // Register handler
-void unreg_handler( t_handler htype);
+void unreg_handler( t_handler htype);
-void reg_ontimeout(t_timeout_handler, unsigned int numsteps, unsigned int stepsize);
+void reg_ontimeout(t_timeout_handler, unsigned int numsteps, unsigned int stepsize);
// Set timeout handler, set 0 for default values.
// So stepsize=0 means numsteps is measured in centiseconds.
void unreg_ontimeout();
uchar find_menu_num(const char *name);
// Create a new menu and return its position
-uchar add_menu(const char *title, int maxmenusize);
+uchar add_menu(const char *title, int maxmenusize);
// Create a named menu and return its position
-uchar add_named_menu(const char *name, const char *title, int maxmenusize);
+uchar add_named_menu(const char *name, const char *title, int maxmenusize);
void set_menu_pos(uchar row,uchar col); // Set the position of this menu.
-// Add item to the "current" menu
+// Add item to the "current" menu
pt_menuitem add_item(const char *item, const char *status, t_action action, const char *data, uchar itemdata);
// Set shortcut key and help id
void set_item_options(uchar shortcut,int helpid);
// Set the shortcut key for the current item
-static inline void set_shortcut(uchar shortcut)
-{
+static inline void set_shortcut(uchar shortcut)
+{
set_item_options(shortcut,0xFFFF);
}
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
#include <stdio.h>
#include "tui.h"
-#define MAX_LINE 512
+#define MAX_LINE 512
// Max line length in a pwdfile
p_pwdentry userdb[MAX_USERS]; // Array of pointers
int numusers; // Actual number of users
for (i=0; i < MAX_USERS; i++) userdb[i] = NULL;
numusers = 0;
-
+
if ( !filename ) return; // No filename specified
f = fopen(filename,"r");
*p = '\0';
pwdhash = p+1;
if (*pwdhash == 0) continue; // Malformed line (no password specified)
- p = strchr(pwdhash,':');
+ p = strchr(pwdhash,':');
if (p == NULL) { // No perms specified
perms = NULL;
} else {
perms = p+1;
if (*perms == 0) perms = NULL;
}
- // At this point we have user,pwdhash and perms setup
+ // At this point we have user,pwdhash and perms setup
userdb[numusers] = (p_pwdentry)malloc(sizeof(pwdentry));
strcpy(userdb[numusers]->username,user);
strcpy(userdb[numusers]->pwdhash,pwdhash);
#ifndef _PASSWORDS_H_
#define _PASSWORDS_H_
-
+
char authenticate_user(const char * username, const char* pwd);
char isallowed(const char *username, const char * perm);
typedef struct {
char username[USERNAME_LENGTH+1];
- char pwdhash[PWDHASH_LENGTH+1];
+ char pwdhash[PWDHASH_LENGTH+1];
char *perms; // pointer to string containing ":" delimited permissions
} pwdentry;
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
#define ALT_PRESSED (1<<3)
#define CTRL_PRESSED (1<<2)
// actually 1<<1 is Left Shift, 1<<0 is right shift
-#define SHIFT_PRESSED (1<<1 | 1 <<0)
+#define SHIFT_PRESSED (1<<1 | 1 <<0)
#endif
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
REG_EAX(inreg) = 0x00003000;
REG_EBX(inreg) = REG_ECX(inreg) = REG_EDX(inreg) = 0xFFFFFFFF;
__intcall(0x21,&inreg,&outreg);
- return (REG_EAX(outreg) == 0x59530000) &&
+ return (REG_EAX(outreg) == 0x59530000) &&
(REG_EBX(outreg) == 0x4c530000) &&
- (REG_ECX(outreg) == 0x4e490000) &&
+ (REG_ECX(outreg) == 0x4e490000) &&
(REG_EDX(outreg) == 0x58550000);
}
// Function 16h not supported Fall back to runcommand
if (numfun < 0x16) runsyslinuxcmd(cmd);
// Try the Run Kernel Image function
- // Split command line into
+ // Split command line into
strcpy(__com32.cs_bounce,cmd);
ptr = __com32.cs_bounce;
// serach for first space or end of string
__intcall(0x22,&inreg,&outreg); // If successful does not return
}
-
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
#include <com32.h>
-//Macros which help user not have to remember the structure of register
+//Macros which help user not have to remember the structure of register
// Data structure
#define REG_AH(x) ((x).eax.b[1])
/* Run command line with ipappend, returns if kernel image not found
If syslinux version too old, then defaults to runsyslinuxcmd */
-void runsyslinuximage(const char*cmd, long ipappend);
+void runsyslinuximage(const char*cmd, long ipappend);
#endif
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2006 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
// showoldvalue <> 0 implies currentvalue displayed first
// If showoldvalue <> 0 then caller responsibility to ensure that
// str is NULL terminated.
-void getuserinput(char *stra, unsigned int size, unsigned int password,
+void getuserinput(char *stra, unsigned int size, unsigned int password,
unsigned int showoldvalue)
{
unsigned char c,scan;
// Invariants: p is the current char
// col is the corresponding column on the screen
if (password == 0) // Not a password, print initial value
- {
+ {
gotoxy(row,col,page);
csprint(str,GETSTRATTR);
}
break;
}
fudge = 0;
- // if scan code is regognized do something
+ // if scan code is regognized do something
// else if char code is recognized do something
// else ignore
switch(scan) {
case LTARROW:
if (p > str) p--;
break;
- case CTRLLT:
+ case CTRLLT:
if (p==str) break;
- if (*p == ' ')
+ if (*p == ' ')
while ((p > str) && (*p == ' ')) p--;
else {
if (*(p-1) == ' ') {
- p--;
+ p--;
while ((p > str) && (*p == ' ')) p--;
}
}
case RTARROW:
if (p < last) p++;
break;
- case CTRLRT:
+ case CTRLRT:
if (*p==0) break; // At end of string
- if (*p != ' ')
+ if (*p != ' ')
while ((*p!=0) && (*p != ' ')) p++;
while ((*p!=0) && ((*p == ' ') && (*(p+1) != ' '))) p++;
if (*p==' ') p++;
p = str; *p=0; last = str;
break;
default: // Handle insert and overwrite mode
- if ((c >= ' ') && (c < 128) &&
+ if ((c >= ' ') && (c < 128) &&
((unsigned int)(p-str) < size-1) ) {
if (insmode == 0) { // Overwrite mode
if (p==last) last++;
nc = getnumcols();
getpos(&row,&col,page);
while ( *str ) {
- switch (*str)
+ switch (*str)
{
case '\b':
--col;
case CHABSATTR: // change attribute (absolute)
cha = *(str+1);
chb = *(str+2);
- if ((((cha >= '0') && (cha <= '9')) ||
+ if ((((cha >= '0') && (cha <= '9')) ||
((cha >= 'A') && (cha <= 'F'))) &&
- (((chb >= '0') && (chb <= '9')) ||
+ (((chb >= '0') && (chb <= '9')) ||
((chb >= 'A') && (chb <= 'F')))) // Next two chars are legal
{
if ((cha >= 'A') && (cha <= 'F'))
{
switch (bt)
{
- case BOX_SINSIN:
+ case BOX_SINSIN:
return SINSIN_CHARS;
break;
case BOX_DBLDBL:
}
// Draw box and lines
-void drawbox(char top,char left,char bot, char right,
+void drawbox(char top,char left,char bot, char right,
char page, char attr,boxtype bt)
{
unsigned char *box_chars; // pointer to array of box chars
unsigned char x;
-
+
box_chars = getboxchars(bt);
// Top border
gotoxy(top,left,page);
}
}
-void drawhorizline(char top, char left, char right, char page, char attr,
+void drawhorizline(char top, char left, char right, char page, char attr,
boxtype bt, char dumb)
{
unsigned char start,end;
{
gotoxy(top,left,page);
cprint(box_chars[BOX_LTRT],attr,1,page);
- gotoxy(top,right,page);
+ gotoxy(top,right,page);
cprint(box_chars[BOX_RTLT],attr,1,page);
}
}
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
#define BELL 0x07
// CHRELATTR = ^N, CHABSATTR = ^O
-#define CHABSATTR 15
+#define CHABSATTR 15
#define CHRELATTR 14
-void clearwindow(char top, char left, char bot, char right,
+void clearwindow(char top, char left, char bot, char right,
char page, char fillchar, char fillattr);
void cls(void); /* Clears the entire current screen page */
-// Generic user input,
+// Generic user input,
// password = 0 iff chars echoed on screen
// showoldvalue <> 0 iff current displayed for editing
-void getuserinput(char *str, unsigned int size,
+void getuserinput(char *str, unsigned int size,
unsigned int password, unsigned int showoldvalue);
-static inline void getstring(char *str, unsigned int size)
+static inline void getstring(char *str, unsigned int size)
{
getuserinput(str,size,0,0);
}
#define BOX_LEFT 0x5
#define BOX_RIGHT 0x5
#define BOX_VERT 0x5 // LEFT=RIGHT=VERT
-#define BOX_LTRT 0x6
-#define BOX_RTLT 0x7
+#define BOX_LTRT 0x6
+#define BOX_RTLT 0x7
#define BOX_TOPBOT 0x8
#define BOX_BOTTOP 0x9
#define BOX_MIDDLE 0xA
unsigned char * getboxchars(boxtype bt);
-void drawbox(char top,char left,char bot, char right,
+void drawbox(char top,char left,char bot, char right,
char page, char attr,boxtype bt);
// Draw a horizontal line
import sys, re, getopt
class Menusystem:
-
+
types = {"run" : "OPT_RUN",
- "inactive" : "OPT_INACTIVE",
+ "inactive" : "OPT_INACTIVE",
"checkbox" : "OPT_CHECKBOX",
- "radiomenu": "OPT_RADIOMENU",
- "sep" : "OPT_SEP",
+ "radiomenu": "OPT_RADIOMENU",
+ "sep" : "OPT_SEP",
"invisible": "OPT_INVISIBLE",
"radioitem": "OPT_RADIOITEM",
"exitmenu" : "OPT_EXITMENU",
"perms" : "", # permission required to execute this entry
"_updated" : None, # has this dictionary been updated
"type" : "run" }
-
+
menu_init = { "title" : "",
"row" : "0xFF", # let system decide position
- "col" : "0xFF",
+ "col" : "0xFF",
"_updated" : None,
"name" : "" }
system_init ={ "videomode" : "0xFF",
"title" : "Menu System",
- "top" : "1",
- "left" : "1" ,
- "bot" : "21",
+ "top" : "1",
+ "left" : "1" ,
+ "bot" : "21",
"right":"79",
"helpdir" : "/isolinux/help",
"pwdfile" : "",
self.menus[-1][0].update(self.menu)
self.init_menu()
if self.entry["_updated"]:
- if not self.entry["info"]:
+ if not self.entry["info"]:
self.entry["info"] = self.entry["data"]
if not self.menus:
print "Error before line %d" % self.lineno
if name == "skipcondn":
try: # is skipcondn a number?
a = int(value)
- except: # it is a "-" delimited sequence
+ except: # it is a "-" delimited sequence
value = value.lower()
parts = [ self.shift_flags.get(x.strip(),None) for x in value.split("-") ]
self.system["skipcondn"] = " | ".join(filter(None, parts))
if self.state == "menu":
err = self.set_menu(name,value)
# change state to entry it menu returns error
- if err:
+ if err:
err = None
self.state = "item"
if self.state == "item":
entry["type"] = self.types[entry["type"]]
if entry["type"] == "login": #special type
fd.write(self.templates["login"] % entry)
- else:
+ else:
fd.write(self.templates["item"] % entry)
def print_menu(self,menu,fd):
fd.write(self.templates["menu"] % menu)
if (menu["row"] != "0xFF") or (menu["col"] != "0xFF"):
fd.write(' set_menu_pos(%(row)s,%(col)s);\n' % menu)
-
+
def output(self,filename):
curr_template = None
if not curr_template: continue # lines between templates are ignored
contents.append(line)
ifd.close()
-
+
missing = None
for x in self.reqd_templates:
if not self.templates.has_key(x): missing = x
if missing:
print "Template %s required but not defined in %s" % (missing,self.code_template_filename)
-
+
if filename == "-":
fd = sys.stdout
else: fd = open(filename,"w")
self.foundmain = None
- fd.write(self.templates["header"])
+ fd.write(self.templates["header"])
fd.write(self.templates["system"] % self.system)
for (menu,items) in self.menus:
self.print_menu(menu,fd)
for entry in items: self.print_entry(entry,fd)
- fd.write(self.templates["footer"])
+ fd.write(self.templates["footer"])
fd.close()
if not self.foundmain:
print "main menu not found"
print self.menus
sys.exit(1)
-
+
def input(self,filename):
if filename == "-":
fd = sys.stdin
self.state = "menu"
self.add_menu(line[1:-1])
continue
-
+
# add property of current entry
pos = line.find("=") # find the first = in string
if pos < 0:
print "Unknown options %s" % args
usage()
for o,a in opts:
- if o in ["-i","--input"]:
+ if o in ["-i","--input"]:
ifile = a
elif o in ["-o", "--output"]:
ofile = a
if __name__ == "__main__":
main()
-
-
-# This file should be available as /isolinux/password
+# This file should be available as /isolinux/password
# for complex.c to use.
#
# All lines starting with # and empty lines are ignored
#
# All non-comment lines here are of the form
# USERNAME:PWDHASH:PERM1:PERM2:...:
-#
+#
# where USERNAME is maximum of 12 chars,
# PWDHASH is maximum of 40 chars (DES ENCRYPTED)
# PERM1,... are arbitrary strings
#
-# The current lines correspond to
+# The current lines correspond to
# user1:secret1, user2:secret2, user3:secret3
user1:LcMRo3YZGtP0c:editcmd
user2:FqewzyxP78a7A:
user3:MKjmc.IHoXBNU:root
-
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
// Choose the default title and setup default values for all attributes....
init_menusystem(NULL);
set_window_size(1,1,23,78); // Leave one row/col border all around
-
+
// Choose the default values for all attributes and char's
// -1 means choose defaults (Actually the next 4 lines are not needed)
- //set_normal_attr (-1,-1,-1,-1);
- //set_status_info (-1,-1);
- //set_title_info (-1,-1);
+ //set_normal_attr (-1,-1,-1,-1);
+ //set_status_info (-1,-1);
+ //set_title_info (-1,-1);
//set_misc_info(-1,-1,-1,-1);
-
+
// menuindex = add_named_menu("name"," Menu Title ",-1);
// add_item("Item string","Status String",TYPE,"any string",NUM)
// TYPE = OPT_RUN | OPT_EXITMENU | OPT_SUBMENU | OPT_CHECKBOX | OPT_INACTIVE
// "any string" useful for storing kernel names
// In case of OPT_SUBMENU, "any string" can be set to "name" of menu to be linked
// in which case value NUM is ignored
- // NUM = index of submenu if OPT_SUBMENU,
+ // NUM = index of submenu if OPT_SUBMENU,
// 0/1 default checked state if OPT_CHECKBOX
// unused otherwise.
add_item("Windows Rescue","winresc",OPT_RUN,"winresc",0);
add_item("Exit this menu","Go one level up",OPT_EXITMENU,"exit",0);
- add_named_menu("main"," Main Menu ",-1);
+ add_named_menu("main"," Main Menu ",-1);
add_item("Prepare","prep",OPT_RUN,"prep",0);
add_item("Rescue options...","Troubleshoot a system",OPT_SUBMENU,"rescue",0);
add_item("Testing...","Options to test hardware",OPT_SUBMENU,"testing",0);
item="Exit this menu"
info="Go one level up"
type=exitmenu
-
item="<E>xit to prompt"
info="Exit the menu system"
type=exitmenu
-
#!/usr/bin/perl
## -----------------------------------------------------------------------
## $Id$
-##
+##
## Copyright 2002-2004 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
}
seek(OUTPUT, $offset + 0x36, 0);
read(OUTPUT, $fsname, 8);
-
+
# FAT12: adjust partition type
if ( $fsname eq 'FAT12 ' ) {
$fstype = 0x01; # FAT12
$(CC) $(CFLAGS) -S -o $@ $<
-include .*.d
-
-
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 1998-2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
mypid = getpid();
program = argv[0];
-
+
device = NULL;
for ( argp = argv+1 ; *argp ; argp++ ) {
}
xpread(dev_fd, sectbuf, 512, filesystem_offset);
-
+
/*
* Check to see that what we got was indeed an MS-DOS boot sector/superblock
*/
dev_fd,
(unsigned long long)filesystem_offset);
fclose(mtc);
-
+
/*
* Run mtools to create the LDLINUX.SYS file
*/
mtp = popen("mcopy -D o -D O -o - s:ldlinux.sys", "w");
if ( !mtp ||
- (fwrite(syslinux_ldlinux, 1, syslinux_ldlinux_len, mtp)
+ (fwrite(syslinux_ldlinux, 1, syslinux_ldlinux_len, mtp)
!= syslinux_ldlinux_len) ||
(status = pclose(mtp), !WIFEXITED(status) || WEXITSTATUS(status)) ) {
die("failed to create ldlinux.sys");
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
section .text
;
; "default" command
-;
+;
pc_default: mov di,default_cmd
call getline
mov byte [di-1],0 ; null-terminate
call getint
mov [FlowControl], word 0 ; Default to no flow control
jc .nobaud
-.valid_baud:
+.valid_baud:
push ebx
call skipspace
jc .no_flow
#!/usr/bin/perl
## $Id$
## -----------------------------------------------------------------------
-##
+##
## Copyright 2004 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
$r = ( $getrgb_leftover_bit_val & 0x80 ) ? 0x00 : 0xff;
$getrgb_leftover_bit_val <<= 1;
$getrgb_leftover_bit_cnt--;
-
+
return ($r,$r,$r);
} elsif ( $form == 1 ) {
# Plain PBM
my($ch);
-
+
do {
$ch = getc(STDIN);
return undef if ( !defined($ch) );
# If same, sort based on RGB components,
# with highest priority given to G, then R, then B.
-
+
return ( $ga <=> $gb ) if ( $ga != $gb );
return ( $ra <=> $rb ) if ( $ra != $rb );
return ( $ba <=> $bb );
}
}
}
-
+
$bytes = 0;
undef $nybble_tmp;
$size = ($pixels+1)/2;
printf STDERR "%d pixels, %d bytes, (%2.2f%% compression)\n",
$pixels, $bytes, 100*($size-$bytes)/$size;
-
-
-
-
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1999-2004 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
%define PXENV_START_BASE 0075h
%define PXENV_STOP_BASE 0076h
-%define PXENV_EXIT_SUCCESS 0x0000
-%define PXENV_EXIT_FAILURE 0x0001
+%define PXENV_EXIT_SUCCESS 0x0000
+%define PXENV_EXIT_FAILURE 0x0001
-%define PXENV_STATUS_SUCCESS 0x00
-%define PXENV_STATUS_FAILURE 0x01
-%define PXENV_STATUS_BAD_FUNC 0x02
-%define PXENV_STATUS_UNSUPPORTED 0x03
-%define PXENV_STATUS_KEEP_UNDI 0x04
-%define PXENV_STATUS_KEEP_ALL 0x05
-%define PXENV_STATUS_OUT_OF_RESOURCES 0x06
-%define PXENV_STATUS_ARP_TIMEOUT 0x11
-%define PXENV_STATUS_UDP_CLOSED 0x18
-%define PXENV_STATUS_UDP_OPEN 0x19
-%define PXENV_STATUS_TFTP_CLOSED 0x1A
-%define PXENV_STATUS_TFTP_OPEN 0x1B
-%define PXENV_STATUS_MCOPY_PROBLEM 0x20
-%define PXENV_STATUS_BIS_INTEGRITY_FAILURE 0x21
-%define PXENV_STATUS_BIS_VALIDATE_FAILURE 0x22
-%define PXENV_STATUS_BIS_INIT_FAILURE 0x23
-%define PXENV_STATUS_BIS_SHUTDOWN_FAILURE 0x24
-%define PXENV_STATUS_BIS_GBOA_FAILURE 0x25
-%define PXENV_STATUS_BIS_FREE_FAILURE 0x26
-%define PXENV_STATUS_BIS_GSI_FAILURE 0x27
-%define PXENV_STATUS_BIS_BAD_CKSUM 0x28
-%define PXENV_STATUS_TFTP_CANNOT_ARP_ADDRESS 0x30
+%define PXENV_STATUS_SUCCESS 0x00
+%define PXENV_STATUS_FAILURE 0x01
+%define PXENV_STATUS_BAD_FUNC 0x02
+%define PXENV_STATUS_UNSUPPORTED 0x03
+%define PXENV_STATUS_KEEP_UNDI 0x04
+%define PXENV_STATUS_KEEP_ALL 0x05
+%define PXENV_STATUS_OUT_OF_RESOURCES 0x06
+%define PXENV_STATUS_ARP_TIMEOUT 0x11
+%define PXENV_STATUS_UDP_CLOSED 0x18
+%define PXENV_STATUS_UDP_OPEN 0x19
+%define PXENV_STATUS_TFTP_CLOSED 0x1A
+%define PXENV_STATUS_TFTP_OPEN 0x1B
+%define PXENV_STATUS_MCOPY_PROBLEM 0x20
+%define PXENV_STATUS_BIS_INTEGRITY_FAILURE 0x21
+%define PXENV_STATUS_BIS_VALIDATE_FAILURE 0x22
+%define PXENV_STATUS_BIS_INIT_FAILURE 0x23
+%define PXENV_STATUS_BIS_SHUTDOWN_FAILURE 0x24
+%define PXENV_STATUS_BIS_GBOA_FAILURE 0x25
+%define PXENV_STATUS_BIS_FREE_FAILURE 0x26
+%define PXENV_STATUS_BIS_GSI_FAILURE 0x27
+%define PXENV_STATUS_BIS_BAD_CKSUM 0x28
+%define PXENV_STATUS_TFTP_CANNOT_ARP_ADDRESS 0x30
%define PXENV_STATUS_TFTP_OPEN_TIMEOUT 0x32
-%define PXENV_STATUS_TFTP_UNKNOWN_OPCODE 0x33
-%define PXENV_STATUS_TFTP_READ_TIMEOUT 0x35
-%define PXENV_STATUS_TFTP_ERROR_OPCODE 0x36
-%define PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION 0x38
-%define PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION 0x39
-%define PXENV_STATUS_TFTP_TOO_MANY_PACKAGES 0x3A
-%define PXENV_STATUS_TFTP_FILE_NOT_FOUND 0x3B
-%define PXENV_STATUS_TFTP_ACCESS_VIOLATION 0x3C
-%define PXENV_STATUS_TFTP_NO_MCAST_ADDRESS 0x3D
-%define PXENV_STATUS_TFTP_NO_FILESIZE 0x3E
-%define PXENV_STATUS_TFTP_INVALID_PACKET_SIZE 0x3F
-%define PXENV_STATUS_DHCP_TIMEOUT 0x51
-%define PXENV_STATUS_DHCP_NO_IP_ADDRESS 0x52
-%define PXENV_STATUS_DHCP_NO_BOOTFILE_NAME 0x53
-%define PXENV_STATUS_DHCP_BAD_IP_ADDRESS 0x54
-%define PXENV_STATUS_UNDI_INVALID_FUNCTION 0x60
-%define PXENV_STATUS_UNDI_MEDIATEST_FAILED 0x61
-%define PXENV_STATUS_UNDI_CANNOT_INIT_NIC_FOR_MCAST 0x62
-%define PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC 0x63
-%define PXENV_STATUS_UNDI_CANNOT_INITIALIZE_PHY 0x64
-%define PXENV_STATUS_UNDI_CANNOT_READ_CONFIG_DATA 0x65
-%define PXENV_STATUS_UNDI_CANNOT_READ_INIT_DATA 0x66
-%define PXENV_STATUS_UNDI_BAD_MAC_ADDRESS 0x67
-%define PXENV_STATUS_UNDI_BAD_EEPROM_CHECKSUM 0x68
-%define PXENV_STATUS_UNDI_ERROR_SETTING_ISR 0x69
-%define PXENV_STATUS_UNDI_INVALID_STATE 0x6A
-%define PXENV_STATUS_UNDI_TRANSMIT_ERROR 0x6B
-%define PXENV_STATUS_UNDI_INVALID_PARAMETER 0x6C
-%define PXENV_STATUS_BSTRAP_PROMPT_MENU 0x74
-%define PXENV_STATUS_BSTRAP_MCAST_ADDR 0x76
-%define PXENV_STATUS_BSTRAP_MISSING_LIST 0x77
-%define PXENV_STATUS_BSTRAP_NO_RESPONSE 0x78
-%define PXENV_STATUS_BSTRAP_FILE_TOO_BIG 0x79
-%define PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE 0xA0
-%define PXENV_STATUS_BINL_NO_PXE_SERVER 0xA1
-%define PXENV_STATUS_NOT_AVAILABLE_IN_PMODE 0xA2
-%define PXENV_STATUS_NOT_AVAILABLE_IN_RMODE 0xA3
-%define PXENV_STATUS_BUSD_DEVICE_NOT_SUPPORTED 0xB0
-%define PXENV_STATUS_LOADER_NO_FREE_BASE_MEMORY 0xC0
-%define PXENV_STATUS_LOADER_NO_BC_ROMID 0xC1
-%define PXENV_STATUS_LOADER_BAD_BC_ROMID 0xC2
-%define PXENV_STATUS_LOADER_BAD_BC_RUNTIME_IMAGE 0xC3
-%define PXENV_STATUS_LOADER_NO_UNDI_ROMID 0xC4
-%define PXENV_STATUS_LOADER_BAD_UNDI_ROMID 0xC5
-%define PXENV_STATUS_LOADER_BAD_UNDI_DRIVER_IMAGE 0xC6
-%define PXENV_STATUS_LOADER_NO_PXE_STRUCT 0xC8
-%define PXENV_STATUS_LOADER_NO_PXENV_STRUCT 0xC9
-%define PXENV_STATUS_LOADER_UNDI_START 0xCA
-%define PXENV_STATUS_LOADER_BC_START 0xCB
+%define PXENV_STATUS_TFTP_UNKNOWN_OPCODE 0x33
+%define PXENV_STATUS_TFTP_READ_TIMEOUT 0x35
+%define PXENV_STATUS_TFTP_ERROR_OPCODE 0x36
+%define PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION 0x38
+%define PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION 0x39
+%define PXENV_STATUS_TFTP_TOO_MANY_PACKAGES 0x3A
+%define PXENV_STATUS_TFTP_FILE_NOT_FOUND 0x3B
+%define PXENV_STATUS_TFTP_ACCESS_VIOLATION 0x3C
+%define PXENV_STATUS_TFTP_NO_MCAST_ADDRESS 0x3D
+%define PXENV_STATUS_TFTP_NO_FILESIZE 0x3E
+%define PXENV_STATUS_TFTP_INVALID_PACKET_SIZE 0x3F
+%define PXENV_STATUS_DHCP_TIMEOUT 0x51
+%define PXENV_STATUS_DHCP_NO_IP_ADDRESS 0x52
+%define PXENV_STATUS_DHCP_NO_BOOTFILE_NAME 0x53
+%define PXENV_STATUS_DHCP_BAD_IP_ADDRESS 0x54
+%define PXENV_STATUS_UNDI_INVALID_FUNCTION 0x60
+%define PXENV_STATUS_UNDI_MEDIATEST_FAILED 0x61
+%define PXENV_STATUS_UNDI_CANNOT_INIT_NIC_FOR_MCAST 0x62
+%define PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC 0x63
+%define PXENV_STATUS_UNDI_CANNOT_INITIALIZE_PHY 0x64
+%define PXENV_STATUS_UNDI_CANNOT_READ_CONFIG_DATA 0x65
+%define PXENV_STATUS_UNDI_CANNOT_READ_INIT_DATA 0x66
+%define PXENV_STATUS_UNDI_BAD_MAC_ADDRESS 0x67
+%define PXENV_STATUS_UNDI_BAD_EEPROM_CHECKSUM 0x68
+%define PXENV_STATUS_UNDI_ERROR_SETTING_ISR 0x69
+%define PXENV_STATUS_UNDI_INVALID_STATE 0x6A
+%define PXENV_STATUS_UNDI_TRANSMIT_ERROR 0x6B
+%define PXENV_STATUS_UNDI_INVALID_PARAMETER 0x6C
+%define PXENV_STATUS_BSTRAP_PROMPT_MENU 0x74
+%define PXENV_STATUS_BSTRAP_MCAST_ADDR 0x76
+%define PXENV_STATUS_BSTRAP_MISSING_LIST 0x77
+%define PXENV_STATUS_BSTRAP_NO_RESPONSE 0x78
+%define PXENV_STATUS_BSTRAP_FILE_TOO_BIG 0x79
+%define PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE 0xA0
+%define PXENV_STATUS_BINL_NO_PXE_SERVER 0xA1
+%define PXENV_STATUS_NOT_AVAILABLE_IN_PMODE 0xA2
+%define PXENV_STATUS_NOT_AVAILABLE_IN_RMODE 0xA3
+%define PXENV_STATUS_BUSD_DEVICE_NOT_SUPPORTED 0xB0
+%define PXENV_STATUS_LOADER_NO_FREE_BASE_MEMORY 0xC0
+%define PXENV_STATUS_LOADER_NO_BC_ROMID 0xC1
+%define PXENV_STATUS_LOADER_BAD_BC_ROMID 0xC2
+%define PXENV_STATUS_LOADER_BAD_BC_RUNTIME_IMAGE 0xC3
+%define PXENV_STATUS_LOADER_NO_UNDI_ROMID 0xC4
+%define PXENV_STATUS_LOADER_BAD_UNDI_ROMID 0xC5
+%define PXENV_STATUS_LOADER_BAD_UNDI_DRIVER_IMAGE 0xC6
+%define PXENV_STATUS_LOADER_NO_PXE_STRUCT 0xC8
+%define PXENV_STATUS_LOADER_NO_PXENV_STRUCT 0xC9
+%define PXENV_STATUS_LOADER_UNDI_START 0xCA
+%define PXENV_STATUS_LOADER_BC_START 0xCB
%endif ; _PXE_INC
-
; 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.
-;
+;
; ****************************************************************************
%define IS_PXELINUX 1
MAX_OPEN_LG2 equ 5 ; log2(Max number of open sockets)
MAX_OPEN equ (1 << MAX_OPEN_LG2)
PKTBUF_SIZE equ (65536/MAX_OPEN) ; Per-socket packet buffer size
-TFTP_PORT equ htons(69) ; Default TFTP port
+TFTP_PORT equ htons(69) ; Default TFTP port
PKT_RETRY equ 6 ; Packet transmit retry count
PKT_TIMEOUT equ 12 ; Initial timeout, timer ticks @ 55 ms
; Desired TFTP block size
;
; BOOTP/DHCP packet pattern
;
- struc bootp_t
+ struc bootp_t
bootp:
.opcode resb 1 ; BOOTP/DHCP "opcode"
.hardware resb 1 ; ARP hardware type
.bootfile resb 128 ; Boot file name
.option_magic resd 1 ; Vendor option magic cookie
.options resb 1260 ; Vendor options
- endstruc
+ endstruc
BOOTP_OPTION_MAGIC equ htonl(0x63825363) ; See RFC 2132
xor ax,ax
mov ds,ax
- mov es,ax
+ mov es,ax
%ifndef DEPEND
%if TEXT_START != 0x7c00
; to by SS:[SP+4], but support INT 1Ah, AX=5650h method as well.
; FIX: ES:BX should point to the PXENV+ structure on entry as well.
; We should make that the second test, and not trash ES:BX...
-;
+;
cmp dword [es:bx], '!PXE'
je have_pxe
sub cx,di
xor ax,ax
rep stosb
-
+
mov si,bootif_str
mov di,BOOTIFStr
mov cx,bootif_str_len
rep movsb
-
+
pop cx
mov si,MACType
inc cx
jnz .got_magic
mov byte [DHCPMagic], 0 ; If not, kill all other options
.got_magic:
-
+
;
; Initialize UDP stack
; On exit, if found:
; CF = 0, ES:BX -> !PXE structure
; Otherwise CF = 1, all registers saved
-;
+;
memory_scan_for_pxe_struct:
push ds
pusha
; On exit, if found:
; CF = 0, ES:BX -> PXENV+ structure
; Otherwise CF = 1, all registers saved
-;
+;
memory_scan_for_pxenv_struct:
pusha
mov si,trymempxenv_msg
;
; searchdir:
;
-; Open a TFTP connection to the server
+; Open a TFTP connection to the server
;
; On entry:
; DS:DI = mangled filename
mov ax,PKT_RETRY ; Retry counter
mov word [PktTimeout],PKT_TIMEOUT ; Initial timeout
-
+
.sendreq: push ax ; [bp-2] - Retry counter
- push si ; [bp-4] - File name
+ push si ; [bp-4] - File name
mov di,packet_buf
mov [pxe_udp_write_pkt.buffer],di
pop ax
shl word [PktTimeout],1 ; Exponential backoff
jmp .failure
-
+
.got_packet:
mov si,[bp-6] ; TFTP pointer
mov bx,[bp-8] ; TID
; Success, done!
.done_pkt:
- pop si ; Junk
+ pop si ; Junk
pop si ; We want the packet ptr in SI
mov eax,[si+tftp_filesize]
movzx ecx,cx
shl ecx,TFTP_BLOCKSIZE_LG2 ; Convert to bytes
jz .hit_eof ; Nothing to do?
-
+
.need_more:
push ecx
get_packet:
mov ax,ds
mov es,ax
-
+
.packet_loop:
; Start by ACKing the previous packet; this should cause the
; next packet to be sent.
cmp ax,dx ; Same time -> don't advance timeout
je .wait_data ; Same clock tick
loop .wait_data ; Decrease timeout
-
+
pop cx ; <D> Didn't get any, send another ACK
shl word [PktTimeout],1 ; Exponential backoff
loop .send_ack
; Make sure we know we are at end of file
mov eax,[si+tftp_filepos]
mov [si+tftp_filesize],eax
-
+
ret
;
jae .new_api
mov si,old_api_unload
.new_api:
-
+
.call_loop: xor ax,ax
lodsb
and ax,ax
; Update the base stack pointer since it's in use
lss sp,[SavedSSSP]
-
+
.combootstack:
pop gs
popf
pop es
pop ds
ret
-
+
.cant_free:
mov si,cant_free_msg
call writestr
aam 10
; Now AH = 10-digit; AL = remainder
add ah,'0'
- mov [es:di],ah
+ mov [es:di],ah
inc di
.lt10:
trymempxe_msg db 'Scanning memory for !PXE structure... ', 0
trymempxenv_msg db 'Scanning memory for PXENV+ structure... ', 0
undi_data_msg db 'UNDI data segment at: ',0
-undi_data_len_msg db 'UNDI data segment size: ',0
+undi_data_len_msg db 'UNDI data segment size: ',0
undi_code_msg db 'UNDI code segment at: ',0
-undi_code_len_msg db 'UNDI code segment size: ',0
+undi_code_len_msg db 'UNDI code segment size: ',0
cant_free_msg db 'Failed to free base memory, error ', 0
notfound_msg db 'not found', CR, LF, 0
myipaddr_msg db 'My IP address seems to be ',0
with dash separators; for example, for an Ethernet (ARP type 1)
with address 88:99:AA:BB:CC:DD it would search for the filename
01-88-99-aa-bb-cc-dd.
-
+
Next, it will search for the config file using its own IP address
in upper case hexadecimal, e.g. 192.0.2.91 -> C000025B
(you can use the included progam "gethostip" to compute the
/mybootdir/pxelinux.cfg/C0
/mybootdir/pxelinux.cfg/C
/mybootdir/pxelinux.cfg/default
-
+
... in that order.
Note that all filename references are relative to the directory
ja .scroll
.curxyok: mov bh,[BIOS_page]
mov ah,02h ; Set cursor position
- int 10h
+ int 10h
.ret: popad
.nothing:
popfd
jnc .curxyok
xor dh,dh
jmp short .curxyok
-
.fs db ' FS: ',0
.gs db ' GS: ',0
.ip db ' IP: ',0
-
-
; -*- fundamental -*-
; -----------------------------------------------------------------------
-;
+;
; Copyright 2004 H. Peter Anvin - All Rights Reserved
;
; This program is free software; you can redistribute it and/or modify
jnz .normal
dec di ; We killed a whole stretch, remove start byte
.normal:
- inc bx
+ inc bx
sub di,bx
mov bp,di
mov al,bl
; rllunpack:
; Unpack bytes from DS:SI into ES:DI
; On return SI, DI are updated and CX contains number of bytes output
-;
+;
rllunpack:
push ax
push di
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2005 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;;
;; runkernel.inc
-;;
+;;
;; Common code for running a Linux kernel
;;
#ident "$Id$"
## -----------------------------------------------------------------------
-##
+##
## Copyright 2001-2004 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
i = i*10 + (*s++ - '0');
return i;
}
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2002 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
#ident "$Id$"
# -----------------------------------------------------------------------
-#
+#
# Copyright 2003 H. Peter Anvin - All Rights Reserved
#
# Permission is hereby granted, free of charge, to any person
# 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
# COM32 start up code - must be linked first in the binary
-
+
.section ".text","ax"
.globl _start
_start:
mov dl,"<"
mov ah,02h
int 21h
-
+
.writechar:
lodsb
mov dl,al
; Exit with near return, INT 20h, or INT 21h AX=4C00h
ret
-
-
+
+
end_str db ">", 0Dh, 0Ah, "$"
-
-
-
\ No newline at end of file
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2001-2003 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
/* \n -> \r\n */
putchar('\r');
}
-
+
regs.eax.b[1] = 0x02;
regs.edx.b[0] = ch;
__com32.cs_intcall(0x21, ®s, NULL);
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2003 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
/* If we get here, badness happened */
return 255;
}
-
-
-
unsigned int ax,cx,si,t;
com32sys_t inreg,outreg;
char *p;
-
+
/* Test null system call */
inreg.eflags.l = 0xffffffff;
inreg.eax.l = 0x11110000;
__com32.cs_intcall(0x22, &inreg, &outreg);
printregs(&outreg);
printf("----\n");
-
+
si = outreg.esi.w[0]; /* File handle */
cx = outreg.ecx.w[0]; /* Block size */
ax = outreg.eax.l; /* File length */
while ( si ) {
/* We can only read 64K per call */
t = ( ax > 65536 ) ? 65536/cx : (ax+cx-1)/cx;
-
+
memset(&inreg, 0, sizeof inreg);
inreg.esi.w[0] = si;
inreg.ecx.w[0] = t; /* Block count */
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2002 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2002 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
inreg.ebx.w[0] = OFFS(__com32.cs_bounce);
inreg.es = SEG(__com32.cs_bounce);
__com32.cs_intcall(0x22, &inreg, NULL);
-};
+};
int __start(void)
{
/* -*- c -*- ------------------------------------------------------------- *
- *
+ *
* Copyright 2003-2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
mov _es, es ;
mov _di, di ;
}
-
+
if ( _eax >> 16 != 0x4d21 ||
_ecx >> 16 != 0x4d45 ||
_edx >> 16 != 0x4944 ||
mm.cylinders = ((_ecx >> 8) & 0xff) + ((_ecx & 0xc0) << 2) + 1;
mm.heads = ((_edx >> 8) & 0xff) + 1;
mm.sectors = (_ecx & 0x3f);
-
+
return &mm;
}
found++;
}
}
-
+
return found;
}
char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
int i;
-
+
if (type & LARGE)
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (type & LEFT)
int i, base;
char * str;
const char *s;
-
+
int flags; /* flags to number() */
-
+
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
-
+
for (str=buf ; *fmt ; ++fmt) {
if (*fmt != '%') {
*str++ = *fmt;
continue;
}
-
+
/* process flags */
flags = 0;
repeat:
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
-
+
/* get field width */
field_width = -1;
if (isdigit(*fmt))
flags |= LEFT;
}
}
-
+
/* get the precision */
precision = -1;
if (*fmt == '.') {
- ++fmt;
+ ++fmt;
if (isdigit(*fmt))
precision = skip_atou(&fmt);
else if (*fmt == '*') {
if (precision < 0)
precision = 0;
}
-
+
/* get the conversion qualifier */
qualifier = -1;
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
qualifier = *fmt;
++fmt;
}
-
+
/* default base */
base = 10;
-
+
switch (*fmt) {
case 'c':
if (!(flags & LEFT))
while (--field_width > 0)
*str++ = ' ';
continue;
-
+
case 's':
s = va_arg(args, char *);
len = strnlen(s, precision);
-
+
if (!(flags & LEFT))
while (len < field_width--)
*str++ = ' ';
while (len < field_width--)
*str++ = ' ';
continue;
-
+
case 'p':
if (field_width == -1) {
field_width = 2*sizeof(void *);
(unsigned long) va_arg(args, void *), 16,
field_width, precision, flags);
continue;
-
-
+
+
case 'n':
if (qualifier == 'l') {
long * ip = va_arg(args, long *);
*ip = (str - buf);
}
continue;
-
+
case '%':
*str++ = '%';
continue;
-
+
/* integer number formats - set up the flags and "break" */
case 'o':
base = 8;
break;
-
+
case 'X':
flags |= LARGE;
case 'x':
base = 16;
break;
-
+
case 'd':
case 'i':
flags |= SIGN;
case 'u':
break;
-
+
default:
*str++ = '%';
if (*fmt)
{
va_list args;
int i;
-
+
va_start(args, fmt);
i=vsprintf(buf,fmt,args);
va_end(args);
return printed;
}
-
unsigned int skip_atou(const char **s)
{
int i=0;
-
+
while (isdigit(**s))
i = i*10 + *((*s)++) - '0';
return i;
sub random_bytes($) {
my($n) = @_;
my($v, $i);
-
+
if ( open(RANDOM, '<', '/dev/random') ||
open(RANDOM, '<', '/dev/urandom') ) {
read(RANDOM, $v, $n);
; BP holds a pointer to the first byte beyond the end of the
; target buffer; return with CF=1 if target buffer overflows;
; the output is still zero-terminated.
-;
+;
section .text
strecpy:
pop bp
pop ax
ret
-
syslinux [-s] a:
-(or whichever drive letter is appropriate; the [] meaning -s is optional)
+(or whichever drive letter is appropriate; the [] meaning -s is optional)
Use "syslinux.com" (in the dos subdirectory of the distribution) for
plain DOS (MS-DOS, DR-DOS, PC-DOS, FreeDOS...) or Win9x/ME.
... SYSLINUX will execute the following as if entered by the
user:
-
+
xyzzy plugh foo bar baz
SERIAL port [[baudrate] flowcontrol]
can be used to create such keymaps. The file keytab-lilo.doc
contains the documentation for this program.
-DISPLAY filename
+DISPLAY filename
Displays the indicated file on the screen at boot time (before
the boot: prompt, if displayed). Please see the section below
on DISPLAY files.
For example:
<DC1>Text mode<DC2>Graphics mode<DC4>Serial port<ETB>
-
+
... will actually print out which mode the console is in!
<SUB> <SUB> = <Ctrl-Z> = ASCII 26
6. Unmount the disk (if applicable.)
umount /mnt
-
+
---- DOS/Windows procedure ----
To make this installation in DOS only, you need the utility copybs.com
copy vmlinux a:
copy initrd.gz a:
-
+
++++ COMBOOT EXECUTABLES ++++
SYSLINUX supports simple standalone programs, using a file format
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 1998-2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 1998-2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
bs32VolumeLabel = 71,
bs32FileSysType = 82,
bs32Code = 90,
-
+
bsSignature = 0x1fe
};
/* Access only one sector at a time */
set_16(syslinux_bootsect+0x1FC, 1);
}
-
+
void syslinux_make_bootsect(void *bs)
{
unsigned char *bootsect = bs;
if ( get_8(sectbuf+bsMedia) != 0xF0 &&
get_8(sectbuf+bsMedia) < 0xF8 )
goto invalid;
-
+
sectorsize = get_16(sectbuf+bsBytesPerSec);
if ( sectorsize == 512 )
; /* ok */
} else {
goto invalid;
}
-
+
return NULL;
invalid:
/* First sector need pointer in boot sector */
set_32(syslinux_bootsect+0x1F8, *sectors++);
nsect--;
-
+
/* Search for LDLINUX_MAGIC to find the patch area */
for ( p = syslinux_ldlinux ; get_32(p) != LDLINUX_MAGIC ; p += 4 );
patcharea = p+8;
return 0;
}
-
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;;
;; tracers.inc
-;;
+;;
;; Debugging tracers
;;
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2005 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
mov [CmdLinePtr],di ; Where to add rest of cmd
pop es
mov di,KernelName
- push di
+ push di
mov si,VKernelBuf+vk_rname
mov cx,FILENAME_MAX ; We need ECX == CX later
rep movsb
mov cx,FILENAME_MAX-5 ; Need 4 chars + null
repne scasb ; Scan for final null
jne .no_skip
- dec di ; Point to final null
+ dec di ; Point to final null
.no_skip: mov [KernelExtPtr],di
%endif
mov bx,exten_table
cmp ax,[BIOS_timer] ; Has the timer advanced?
je .loop
DO_IDLE
-
+
dec dword [ThisKbdTo]
jz .timeout
dec dword [ThisTotalTo]
sub di,KernelCName
mov [KernelCNameLen],di
popa
-
+
%if IS_SYSLINUX || IS_MDSLINUX
mov ecx,[KernelName+7]
mov cl,'.'
$(CC) $(CFLAGS) -S -o $@ $<
-include .*.d
-
-
-
#ident "$Id$"
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 1998-2005 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
program = argv[0];
mypid = getpid();
-
+
device = NULL;
umask(077);
else
continue;
}
-
+
if ( ioctl(loop_fd, LOOP_GET_STATUS64, &loopinfo) ||
(loopinfo.lo_offset = filesystem_offset,
ioctl(loop_fd, LOOP_SET_STATUS64, &loopinfo)) )
rmdir(mntpath);
exit(1); /* Mount failed */
}
-
+
#endif
}
-
+
ldlinux_name = alloca(strlen(mntpath)+13);
if ( !ldlinux_name ) {
perror(program);
return 0;
}
-
print VI "$def VER_MAJOR $vma\n";
print VI "$def VER_MINOR $vmi\n";
close(VI);
-
-
## $Id$
## -----------------------------------------------------------------------
-##
+##
## Copyright 1998-2004 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2003 Lars Munch Christensen - All Rights Reserved
* Copyright 1998-2004 H. Peter Anvin - All Rights Reserved
- *
+ *
* Based on the Linux installer program for SYSLINUX by H. Peter Anvin
*
* This program is free software; you can redistribute it and/or modify
BOOL GetStorageDeviceNumberByHandle( HANDLE handle, const STORAGE_DEVICE_NUMBER *sdn ) {
BOOL result = FALSE;
DWORD count;
-
+
if ( DeviceIoControl( handle, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL,
0, (LPVOID)sdn, sizeof( *sdn ), &count, NULL ) ) {
result = TRUE;
else {
error("GetDriveNumber: DeviceIoControl failed");
}
-
+
return( result );
}
int result = 0;
DISK_GEOMETRY g;
DWORD count;
-
+
if ( DeviceIoControl( drive, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0,
&g, sizeof( g ), &count, NULL ) ) {
result = g.BytesPerSector;
}
-
+
return( result );
}
BOOL FixMBR(int driveNum, int partitionNum, int write_mbr, int set_active) {
BOOL result = TRUE;
HANDLE drive;
-
+
char driveName[128];
-
+
sprintf( driveName, "\\\\.\\PHYSICALDRIVE%d", driveNum );
-
+
drive = CreateFile( driveName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_WRITE | FILE_SHARE_READ,
OPEN_EXISTING,
0,
NULL );
-
+
if( drive == INVALID_HANDLE_VALUE ) {
error("Accessing physical drive");
result = FALSE;
}
-
+
if( result ) {
unsigned char sector[SECTOR_SIZE];
DWORD howMany;
-
+
if( GetBytesPerSector( drive ) != SECTOR_SIZE ) {
fprintf(stderr, "Error: Sector size of this drive is %d; must be %d\n",
GetBytesPerSector( drive ), SECTOR_SIZE );
result = FALSE;
}
-
+
if ( result ) {
if ( ReadFile( drive, sector, sizeof( sector ), &howMany, NULL ) == 0 ) {
error("Reading raw drive");
result = FALSE;
}
}
-
+
// Copy over the MBR code if specified (-m)
if ( write_mbr ) {
if ( result ) {
}
}
}
-
+
// Check that our partition is active if specified (-a)
if ( set_active ) {
if ( sector[ PART_TABLE + ( PART_SIZE * ( partitionNum - 1 ) ) ] != 0x80 ) {
if ( result ) {
SetFilePointer( drive, 0, NULL, FILE_BEGIN );
-
+
if ( WriteFile( drive, sector, sizeof( sector ), &howMany, NULL ) == 0 ) {
error("Writing MBR");
result = FALSE;
result = FALSE;
}
}
-
+
if( !CloseHandle( drive ) ) {
error("CloseFile on drive");
result = FALSE;
}
}
-
+
return( result );
}
LPVOID lpMsgBuf;
/* Format the Windows error message */
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf, 0, NULL );
-
+
/* Print it */
fprintf(stderr, "%s: %s", msg, (char*) lpMsgBuf);
syslinux_make_stupid();
break;
case 'f': /* Force install */
- force = 1;
+ force = 1;
break;
case 'm': /* Install MBR */
mbr = 1;
/*
* Make sure we can read the boot sector
- */
+ */
if ( !ReadFile(d_handle, sectbuf, 512, &bytes_read, NULL) ) {
error("Reading boot sector");
exit(1);
fprintf(stderr, "Could not read the whole boot sector\n");
exit(1);
}
-
+
/* Check to see that what we got was indeed an MS-DOS boot sector/superblock */
if( (errmsg = syslinux_check_bootsect(sectbuf)) ) {
fprintf(stderr, "%s\n", errmsg);
/* Create ldlinux.sys file */
f_handle = CreateFile(ldlinux_name, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL, CREATE_ALWAYS,
+ NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM |
FILE_ATTRIBUTE_HIDDEN,
NULL );
-
+
if (f_handle == INVALID_HANDLE_VALUE) {
error("Unable to create ldlinux.sys");
exit(1);
}
}
- /* Close file */
+ /* Close file */
CloseHandle(f_handle);
/* Make the syslinux boot sector */
if ( bootsecfile ) {
f_handle = CreateFile(bootsecfile, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL, CREATE_ALWAYS,
+ NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_ARCHIVE,
NULL );
if (f_handle == INVALID_HANDLE_VALUE) {
fprintf(stderr, "Could not write the whole boot sector\n");
exit(1);
}
-
- /* Close file */
+
+ /* Close file */
CloseHandle(d_handle);
/* Done! */
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
popad
popfd
ret
-
;; $Id$
;; -----------------------------------------------------------------------
-;;
+;;
;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify