0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome/*
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * Copyright (c) 1998 Robert Nordier
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * All rights reserved.
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome *
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * Redistribution and use in source and binary forms, with or without
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * modification, are permitted provided that the following conditions
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * are met:
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * 1. Redistributions of source code must retain the above copyright
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * notice, this list of conditions and the following disclaimer.
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * 2. Redistributions in binary form must reproduce the above copyright
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * notice, this list of conditions and the following disclaimer in the
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * documentation and/or other materials provided with the distribution.
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome *
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome *
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * $FreeBSD$
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#ifndef _BTX_H_
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#define _BTX_H_
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#include <sys/types.h>
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#define BTX_PGSIZE 0x1000 /* Page size */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#define BTX_PGBASE 0x5000 /* Start of page tables */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#define BTX_MAXCWR 0x3bc /* Max. btx_pgctl adjustment */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome/*
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome * BTX image header.
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soomestruct btx_hdr {
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome uint8_t btx_machid; /* Machine ID */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome uint8_t btx_hdrsz; /* Header size */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome uint8_t btx_magic[3]; /* Magic */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome uint8_t btx_majver; /* Major version */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome uint8_t btx_minver; /* Minor version */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome uint8_t btx_flags; /* Flags */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome uint16_t btx_pgctl; /* Paging control */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome uint16_t btx_textsz; /* Text size */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome uint32_t btx_entry; /* Client entry address */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome};
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome/* btx_machid */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#define BTX_I386 0xeb /* Intel i386 or compatible */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome/* btx_magic */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#define BTX_MAG0 'B'
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#define BTX_MAG1 'T'
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#define BTX_MAG2 'X'
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome/* btx_flags */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#define BTX_MAPONE 0x80 /* Start mapping at page 1 */
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#define BTX_MAPPED(btx) (((btx).btx_pgctl | (BTX_PGSIZE / 4 - 1)) + 1)
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#define BTX_ORIGIN(btx) (BTX_PGBASE + BTX_MAPPED(btx) * 4)
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#define BTX_ENTRY(btx) (BTX_ORIGIN(btx) + 2 + (btx).btx_hdrsz)
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome
0cc5983c8a077e6396dc7c492ee928b40bf0fed1Toomas Soome#endif /* !_BTX_H_ */