(2006-08-06) rescue-bootcd

This commit is contained in:
2006-08-06 00:00:00 +02:00
parent 2f796b816a
commit decb062d20
21091 changed files with 7076462 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
#ident "$Id: Makefile,v 1.7 2005/01/04 03:05:17 hpa Exp $"
## -----------------------------------------------------------------------
##
## Copyright 2001-2004 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
## Boston MA 02111-1307, USA; either version 2 of the License, or
## (at your option) any later version; incorporated herein by reference.
##
## -----------------------------------------------------------------------
##
## samples for syslinux users
##
gcc_ok = $(shell if gcc $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; \
then echo $(1); else echo $(2); fi)
M32 := $(call gcc_ok,-m32,)
CC = gcc
LD = ld -m elf_i386
AR = ar
NASM = nasm
RANLIB = ranlib
CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os -fomit-frame-pointer -I../libutil/include -I../include -D__COM32__
LNXCFLAGS = -W -Wall -O -g -I../libutil/include
LNXSFLAGS = -g
LNXLDFLAGS = -g
SFLAGS = -D__COM32__ -march=i386
LDFLAGS = -T ../lib/com32.ld
OBJCOPY = objcopy
PPMTOLSS16 = ../ppmtolss16
LIBGCC := $(shell $(CC) --print-libgcc)
LIBS = ../libutil/libutil_com.a ../lib/libcom32.a $(LIBGCC)
LNXLIBS = ../libutil/libutil_lnx.a
.SUFFIXES: .lss .c .o .elf .c32 .lnx
all: hello.c32 cat.c32 resolv.c32 \
fancyhello.c32 fancyhello.lnx \
keytest.c32 keytest.lnx \
.PRECIOUS: %.o
%.o: %.S
$(CC) $(SFLAGS) -c -o $@ $<
.PRECIOUS: %.o
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
.PRECIOUS: %.elf
%.elf: %.o $(LIBS)
$(LD) $(LDFLAGS) -o $@ $^
.PRECIOUS: %.lo
%.lo: %.S
$(CC) $(LNXSFLAGS) -c -o $@ $<
.PRECIOUS: %.lo
%.lo: %.c
$(CC) $(LNXCFLAGS) -c -o $@ $<
.PRECIOUS: %.lnx
%.lnx: %.lo $(LNXLIBS)
$(CC) $(LNXLDFLAGS) -o $@ $^
%.c32: %.elf
$(OBJCOPY) -O binary $< $@
tidy:
rm -f *.o *.lo *.a *.lst *.elf
clean: tidy
rm -f *.lss *.c32 *.lnx *.com
spotless: clean
rm -f *~ \#*
install: # Don't install samples

View File

@@ -0,0 +1,31 @@
#include <stdio.h>
#include <stdlib.h>
#include <console.h>
int main(int argc, char *argv[])
{
FILE *f;
int ch;
int i;
openconsole(&dev_stdcon_r, &dev_stdcon_w);
printf("argv = %p\n", argv);
for ( i = 0 ; i <= argc ; i++ )
printf("argv[%d] = %p = \"%s\"\n", i, argv[i], argv[i]);
if ( argc < 2 ) {
fprintf(stderr, "Missing file name!\n");
exit(1);
}
printf("File = %s\n", argv[1]);
f = fopen(argv[1], "r");
while ( (ch = getc(f)) != EOF )
putchar(ch);
fclose(f);
return 0;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,43 @@
#ident "$Id: fancyhello.c,v 1.2 2004/12/14 22:46:25 hpa Exp $"
/* ----------------------------------------------------------------------- *
*
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
* Boston MA 02111-1307, USA; either version 2 of the License, or
* (at your option) any later version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */
/*
* fancyhello.c
*
* Hello, World! using libcom32 and ANSI console; also possible to compile
* as a Linux application for testing.
*/
#include <string.h>
#include <stdio.h>
#include <consoles.h> /* Provided by libutil */
int main(void)
{
char buffer[1024];
console_ansi_std();
printf("\033[1;33;44m *** \033[37mHello, World!\033[33m *** \033[0m\n");
for (;;) {
printf("\033[1;36m>\033[0m ");
fgets(buffer, sizeof buffer, stdin);
if ( !strncmp(buffer, "exit", 4) )
break;
printf("\033[1m:\033[0m %s", buffer);
}
return 0;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,41 @@
#ident "$Id: hello.c,v 1.2 2004/12/14 22:46:25 hpa Exp $"
/* ----------------------------------------------------------------------- *
*
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
* Boston MA 02111-1307, USA; either version 2 of the License, or
* (at your option) any later version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */
/*
* hello.c
*
* Hello, World! using libcom32
*/
#include <string.h>
#include <stdio.h>
#include <console.h>
int main(void)
{
char buffer[1024];
openconsole(&dev_stdcon_r, &dev_stdcon_w);
printf("Hello, World!\n");
for (;;) {
printf("> ");
fgets(buffer, sizeof buffer, stdin);
if ( !strncmp(buffer, "exit", 4) )
break;
printf(": %s", buffer);
}
return 0;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,82 @@
#ident "$Id: keytest.c,v 1.4 2004/12/21 23:31:45 hpa Exp $"
/* ----------------------------------------------------------------------- *
*
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
* Boston MA 02111-1307, USA; either version 2 of the License, or
* (at your option) any later version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */
/*
* keytest.c
*
* Test the key parsing library
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/times.h>
#include <consoles.h> /* Provided by libutil */
#include <getkey.h>
static void cooked_keys(void)
{
int key;
printf("[cooked]");
for(;;) {
key = get_key(stdin, 0);
if ( key == 0x03 ) {
printf("[done]\n");
exit(0);
} else if ( key == '?' )
return;
if ( key >= 0x20 && key < 0x100 ) {
putchar(key);
} else {
printf("[%04x]", key);
}
}
}
static void raw_keys(void)
{
int key;
printf("[raw]");
for(;;) {
key = getc(stdin);
if ( key == 0x03 ) {
printf("[done]\n");
exit(0);
} else if ( key == '!' )
return;
printf("<%02x>", key);
}
}
int main(void)
{
console_ansi_raw();
printf("CLK_TCK = %d\n", (int)CLK_TCK);
printf("Press keys, end with Ctrl-C...\n");
for (;;) {
cooked_keys();
raw_keys();
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,67 @@
#ident "$Id: resolv.c,v 1.1 2004/12/28 23:49:43 hpa Exp $"
/* ----------------------------------------------------------------------- *
*
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
* Boston MA 02111-1307, USA; either version 2 of the License, or
* (at your option) any later version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */
/*
* resolv.c
*
* Resolve an IP address
*/
#include <string.h>
#include <stdio.h>
#include <console.h>
#include <stdlib.h>
#include <com32.h>
uint32_t resolv(const char *name)
{
com32sys_t reg;
strcpy((char *)__com32.cs_bounce, name);
memset(&reg, 0, sizeof reg);
reg.eax.w[0] = 0x0010;
reg.ebx.w[0] = OFFS(__com32.cs_bounce);
reg.es = SEG(__com32.cs_bounce);
__intcall(0x22, &reg, &reg);
if ( reg.eflags.l & EFLAGS_CF )
return 0;
else
return reg.eax.l;
}
int main(int argc, char *argv[])
{
uint32_t ip;
openconsole(&dev_null_r, &dev_stdcon_w);
if ( argc < 2 ) {
fputs("Usage: resolv hostname\n", stderr);
exit(1);
}
ip = resolv(argv[1]);
if ( ip ) {
printf("%s = %u.%u.%u.%u\n", argv[1],
(ip & 0xff), (ip >> 8) & 0xff,
(ip >> 16) & 0xff, (ip >> 24) & 0xff);
} else {
printf("%s not found\n", argv[1]);
}
return 0;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.