Main Page | Data Structures | File List | Data Fields | Globals

emit.h

Go to the documentation of this file.
00001 #ifndef _TOKE_EMIT_H
00002 #define _TOKE_EMIT_H
00003 
00004 /*
00005  *                     OpenBIOS - free your system! 
00006  *                         ( FCode tokenizer )
00007  *                          
00008  *  emit.h - prototypes for fcode emitters
00009  *  
00010  *  This program is part of a free implementation of the IEEE 1275-1994 
00011  *  Standard for Boot (Initialization Configuration) Firmware.
00012  *
00013  *  Copyright (C) 2001-2005 Stefan Reinauer, <stepan@openbios.org>
00014  *
00015  *  This program is free software; you can redistribute it and/or modify
00016  *  it under the terms of the GNU General Public License as published by
00017  *  the Free Software Foundation; version 2 of the License.
00018  *
00019  *  This program is distributed in the hope that it will be useful,
00020  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  *  GNU General Public License for more details.
00023  *
00024  *  You should have received a copy of the GNU General Public License
00025  *  along with this program; if not, write to the Free Software
00026  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
00027  *
00028  */
00029 
00030 /* **************************************************************************
00031  *         Modifications made in 2005 by IBM Corporation
00032  *      (C) Copyright 2005 IBM Corporation.  All Rights Reserved.
00033  *      Modifications Author:  David L. Paktor    dlpaktor@us.ibm.com
00034  **************************************************************************** */
00035  
00036 #include "types.h"
00037 
00038 /* **************************************************************************
00039  *          Structure Name:    fcode_header_t
00040  *          Synopsis:          FCode Header within the Output Buffer
00041  *                            
00042  *   Fields:
00043  *       format, checksum and length    All as prescribed in P1275, Sec 5.2.2.5
00044  *       
00045  *       Note that the Checksum and Length fields are stated as byte-arrays
00046  *           rather than as integers.  This is intended to guarantee that
00047  *           their endian-ness will remain independent of the endian-ness
00048  *           of the host-platform on which this Tokenizer is running.
00049  *       Note also that, as integers, both are BIG-Endian.      
00050  *
00051  **************************************************************************** */
00052 
00053 typedef struct {
00054     u8  format;
00055     u8  checksum[2];  /* [0] = Hi byte, [1] = Lo */
00056     u8  length[4];    /* [0] = Hi, [1] = Hi-mid, [2] = Lo-mid, [3] = Lo  */
00057 } fcode_header_t;
00058 
00059 
00060 /* **************************************************************************
00061  *          Macro Name:   STRING_LEN_MAX
00062  *                        Max number of bytes allowable in an output string
00063  *                            
00064  *   Arguments:           NONE
00065  *
00066  *       This value must remail hard-coded and immutable.  It represents the
00067  *           maximum number allowed in a FORTH counted-string's count-byte
00068  *           (which is, of course, the maximum number that can be expressed
00069  *           in an unsigned byte).
00070  *       It should not be used for anything else (e.g., buffer sizes), and
00071  *           most especially not for anything that might be changed!
00072  *
00073  **************************************************************************** */
00074 
00075 #define STRING_LEN_MAX    255
00076 
00077 
00078 /* **************************************************************************
00079  *          Macro Name:   GET_BUF_MAX
00080  *                        Size alloted to input-string buffer
00081  *                            
00082  *   Arguments:           NONE
00083  *
00084  *       This is a generous allotment for the buffer into which
00085  *           input strings are gathered.  Overflow calculations are
00086  *           also based on it.  It may be changed safely.
00087  *       We like to keep it a nice power-of-two to make the memory-
00088  *           allocation routine run efficiently and happily (Okay, so
00089  *           that's anthropormism:  It's efficient and *we*'re happy.
00090  *           Better?  I thought so...  ;-)
00091  *
00092  **************************************************************************** */
00093 
00094 #define GET_BUF_MAX    1024
00095 
00096 
00097 /* ************************************************************************** *
00098  *
00099  *      Function Prototypes / Functions Exported:
00100  *
00101  **************************************************************************** */
00102 
00103 void  emit_fcode(u16 tok);
00104 void  user_emit_byte(u8 data);
00105 
00106 void  emit_offset(s16 offs);
00107 void  emit_string(u8 *string, signed int cnt);
00108 void  emit_fcodehdr(const char *starter_name);
00109 void  finish_fcodehdr(void);
00110 void  emit_pcihdr(void);
00111 void  finish_pcihdr(void);
00112 void finish_headers(void);
00113 void  emit_end0(void);
00114 void  emit_literal(u32 num);
00115 
00116 #endif   /* _TOKE_EMIT_H */

Generated on Fri Aug 18 14:03:38 2006 for Toke1.0 by  doxygen 1.4.4