/*
* Copyright (c) 2000 Daniel Capo Sobral
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
/*
* l o a d e r . c
* Additional FICL words designed for FreeBSD's loader
*/
#ifndef STAND
#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <strings.h>
#include <termios.h>
#else
#include <stand.h>
#ifdef __i386__
#endif
#include "bootstrap.h"
#endif
#include <string.h>
#include "ficl.h"
extern int biospci_count_device_type(uint32_t);
/*
* FreeBSD's loader interaction words and extras
*
* setenv ( value n name n' -- )
* setenv? ( value n name n' flag -- )
* getenv ( addr n -- addr' n' | -1 )
* unsetenv ( addr n -- )
* copyin ( addr addr' len -- )
* copyout ( addr addr' len -- )
* findfile ( name len type len' -- addr )
* pnpdevices ( -- addr )
* pnphandlers ( -- addr )
* ccall ( [[...[p10] p9] ... p1] n addr -- result )
* .# ( value -- )
*/
void
{
if (!name)
if (!value)
}
void
{
if (!name)
if (!value)
}
void
{
char *namep;
int names;
if (!name)
} else
}
void
{
char *name;
char *namep;
int names;
if (!name)
}
void
{
#ifdef STAND
void* src;
#endif
#ifdef STAND
#else
#endif
}
void
{
#ifdef STAND
void* dest;
#endif
#ifdef STAND
#else
#endif
}
void
{
#ifdef STAND
#endif
#ifdef STAND
if (!name)
if (!type)
#else
#endif
}
#ifdef STAND
#ifdef HAVE_PNP
void
{
static int pnp_devices_initted = 0;
if (!pnp_devices_initted) {
pnp_devices_initted = 1;
}
}
void
{
}
#endif
#endif /* ifdef STAND */
void
{
int (*func)(int, ...);
int nparam, i;
for (i = 0; i < nparam; i++)
p[9]);
}
/*
* f i c l E x e c F D
* reads in text from file fd and passes it to ficlExec()
* returns FICL_VM_STATUS_OUT_OF_TEXT on success or the ficlExec() error
* code on failure.
*/
int
{
char ch;
ficlString s;
/* feed each line to ficlExec */
while (1) {
int status, i;
i = 0;
nLine++;
if (!i) {
if (status < 1)
break;
continue;
}
if (cp[i] == '\n')
cp[i] = '\0';
FICL_STRING_SET_LENGTH(s, i);
if (rval != FICL_VM_STATUS_QUIT &&
rval != FICL_VM_STATUS_USER_EXIT &&
return (rval);
}
}
/*
* Pass an empty line with SOURCE-ID == -1 to flush
* any pending REFILLs (as required by FILE wordset)
*/
if (rval == FICL_VM_STATUS_USER_EXIT)
return (rval);
}
{
ficlCell c;
}
/*
* isdir? - Return whether an fd corresponds to a directory.
*
* isdir? ( fd -- bool )
*/
static void
{
int fd;
flag = FICL_FALSE;
do {
if (fd < 0)
break;
break;
break;
} while (0);
}
/*
* fopen - open a file and return new fd on stack.
*
* fopen ( ptr count mode -- fd )
*/
extern char *get_dev(const char *);
static void
{
#ifndef STAND
char *tmp;
#endif
return;
}
/* ensure that the string is null terminated */
#ifndef STAND
#endif
/* open the file */
}
/*
* fclose - close a file who's fd is on stack.
* fclose ( fd -- )
*/
static void
{
int fd;
if (fd != -1)
}
/*
* fread - read file contents
* fread ( fd buf nbytes -- nread )
*/
static void
{
char *buf;
else
}
/*
* fopendir - open directory
*
* fopendir ( addr len -- ptr TRUE | FALSE )
*/
{
#ifndef STAND
char *tmp;
#else
int fd;
#endif
int count;
return;
}
/* ensure that the string is null terminated */
#ifndef STAND
#else
do {
if (fd < 0)
break;
break;
break;
return;
} while (0);
if (fd >= 0)
return;
#endif
#ifndef STAND
return;
} else
#endif
}
/*
* freaddir - read directory contents
* freaddir ( fd -- ptr len TRUE | FALSE )
*/
static void
{
#ifndef STAND
#else
int fd;
#endif
/*
* libstand readdir does not always return . nor .. so filter
* them out to have consistent behaviour.
*/
#ifndef STAND
do {
continue;
continue;
break;
} while (d != NULL);
#else
if (fd != -1)
do {
continue;
continue;
break;
} while (d != NULL);
#endif
if (d != NULL) {
} else {
}
}
/*
* fclosedir - close a dir on stack.
*
* fclosedir ( fd -- )
*/
static void
{
#ifndef STAND
#else
int fd;
#endif
#ifndef STAND
#else
if (fd != -1)
#endif
}
/*
* fload - interpret file contents
*
* fload ( fd -- )
*/
{
int fd;
if (fd != -1)
}
/*
* fwrite - write file contents
*
* fwrite ( fd buf nbytes -- nwritten )
*/
static void
{
char *buf;
else
}
/*
* fseek - seek to a new position in a file
*
* fseek ( fd ofs whence -- pos )
*/
static void
{
}
/*
* key - get a character from stdin
*
* key ( -- char )
*/
static void
{
}
/*
* key? - check for a character from stdin (FACILITY)
* key? ( -- flag )
*/
static void
{
#ifndef STAND
#endif
#ifndef STAND
if (ch != -1)
#else
#endif
}
/*
* seconds - gives number of seconds since beginning of time
*
* beginning of time is defined as:
*
* BTX - number of seconds since midnight
* FreeBSD - number of seconds since Jan 1 1970
*
* seconds ( -- u )
*/
static void
{
}
/*
* ms - wait at least that many milliseconds (FACILITY)
* ms ( u -- )
*/
static void
{
#ifndef STAND
#else
#endif
}
/*
* fkey - get a character from a file
* fkey ( file -- char )
*/
static void
{
int i, fd;
char ch;
}
#ifdef STAND
#ifdef __i386__
/*
* outb ( port# c -- )
* Store a byte to I/O port number port#
*/
void
{
uint8_t c;
}
/*
* inb ( port# -- c )
* Fetch a byte from I/O port number port#
*/
void
{
uint8_t c;
}
/*
* pcibios-device-count (devid -- count)
*
* Returns the PCI BIOS' count of how many devices matching devid are
* in the system. devid is the 32-bit vendor + device.
*/
static void
{
int i;
}
/*
* pcibios-write-config (locator offset width value -- )
*
* Writes the specified config register.
* Locator is bus << 8 | device << 3 | fuction
* offset is the pci config register
* width is 0 for byte, 1 for word, 2 for dword
* value is the value to write
*/
static void
{
}
/*
* pcibios-read-config (locator offset width -- value)
*
* Reads the specified config register.
* Locator is bus << 8 | device << 3 | fuction
* offset is the pci config register
* width is 0 for byte, 1 for word, 2 for dword
* value is the value to read from the register
*/
static void
{
}
/*
* pcibios-find-devclass (class index -- locator)
*
* Finds the index'th instance of class in the pci tree.
* must be an exact match.
* class is the class to search for.
* index 0..N (set to 0, increment until error)
*
* Locator is bus << 8 | device << 3 | fuction (or -1 on error)
*/
static void
{
locator = 0xffffffff;
}
/*
* pcibios-find-device(devid index -- locator)
*
* Finds the index'th instance of devid in the pci tree.
* must be an exact match.
* class is the class to search for.
* index 0..N (set to 0, increment until error)
*
* Locator is bus << 8 | device << 3 | fuction (or -1 on error)
*/
static void
{
locator = 0xffffffff;
}
/*
* pcibios-find-device(bus device function -- locator)
*
* converts bus, device, function to locator.
*
* Locator is bus << 8 | device << 3 | fuction
*/
static void
{
}
#endif
#endif
/*
* Retrieves free space remaining on the dictionary
*/
static void
{
}
/*
* f i c l C o m p i l e P l a t f o r m
* Build FreeBSD platform extensions into the system dictionary
*/
void
{
#ifdef STAND
#ifdef __i386__
#endif
#ifdef HAVE_PNP
#endif
#ifdef __i386__
#endif
#endif
#endif
#ifdef __sparc
#endif
}