/*
 **************************************************************************
 *
 * Boot-ROM-Code to load an operating system across a TCP/IP network.
 *
 * Module:  kernel/romlib.h
 * Purpose: Header file for interfacing with the C library functions
 * Entries: none
 *
 **************************************************************************
 *
 * Copyright (C) 1995-2003 Gero Kuhlmann <gero@gkminix.han.de>
 *
 *  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; either version 2 of the License, or
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id: romlib.h,v 1.4 2003/01/25 23:29:40 gkminix Exp $
 */

#ifndef _KERNEL_ROMLIB_H
#define _KERNEL_ROMLIB_H
#ifndef _USE_ASSEMBLER


/*
 **************************************************************************
 *
 * We need some includes before we can include this file
 */
#include <general.h>



/*
 **************************************************************************
 *
 * Special characters from ASCII character set:
 */
#define CHR_BS		'\010'
#define CHR_LF		'\012'
#define CHR_FF		'\014'
#define CHR_CR		'\015'
#define CHR_STOP	'\023'
#define CHR_ESC		'\033'



/*
 **************************************************************************
 *
 * Definition of jump tables to be used for the PXE interface
 */
struct funcentry {
	int             (*func)();	/* pointer to function handler */
	int               paramsize;	/* size of parameter structure */
};

struct functab {
	int               minfunc;	/* minimum function number */
	int               maxfunc;	/* maximum function number */
	struct funcentry  funcs[];	/* array of function pointers */
};

extern struct functab tftp_func_tab;	/* TFTP PXE functions */
extern struct functab udp_func_tab;	/* UDP PXE functions */



/*
 **************************************************************************
 *
 * Definitions used for setjmp/longjmp
 */
#define JMP_BUF_SIZE	6		/* number of words in jump env	*/

typedef unsigned int jmp_buf[JMP_BUF_SIZE];

extern int setjmp __P((jmp_buf env));		/* set jump buffer	*/
extern int longjmp __P((jmp_buf env, int val));	/* jump to saved env	*/



/*
 **************************************************************************
 *
 * I/O functions:
 */
extern int getkey __P((int timeout));		/* wait for key input	*/
extern int chkkey __P((void));			/* check if key pressed	*/
extern void printf __P((char *format, ...));	/* print formatted str	*/



/*
 **************************************************************************
 *
 * Time related functions:
 */
extern void set_timeout __P((int ticks));	/* set timeout ticks	*/
extern int chk_timeout __P((void));		/* timeout reached	*/
extern unsigned long get_ticks __P((void));	/* get timer ticks	*/



/*
 **************************************************************************
 *
 * String and memory handling functions:
 */
#define memcpy(b1, b2, len) fmemcpy((unsigned int)(b1), getds(), (b2), (len))
extern void fmemcpy __P((unsigned int offset, unsigned int segment,
					void *b2, unsigned int length));

extern int  memcmp __P((void *b1, void *b2, unsigned int length));
extern void memset __P((void *b, int c, unsigned int length));
extern int lmove __P((unsigned long dest, void *src, unsigned int len));



/*
 **************************************************************************
 *
 * Miscellaneous routines:
 */
extern unsigned int getds __P((void));		/* get current data seg	*/
extern short int random __P((short int mask));	/* get random value	*/
extern unsigned long far2long __P((unsigned long ptr));
extern unsigned long long2far __P((unsigned long l));


#endif				/* _USE_ASSEMBLER */
#endif				/* _KERNEL_ROMLIB_H */



syntax highlighted by Code2HTML, v. 0.9.1