linux_init.h
来自「一个用在mips体系结构中的操作系统」· C头文件 代码 · 共 513 行
H
513 行
/* * Copyright (C) 1996-1998 by the Board of Trustees * of Leland Stanford Junior University. * * This file is part of the SimOS distribution. * See LICENSE file for terms of the license. * *//***************************************************************** * $Author: bosch $ * $Date: 1998/02/10 00:32:53 $ ****************************************************************/#ifndef LINUX_INIT_H#include "simtypes.h"/* Taken from Linux-1.3.62/include/asm/bootinfo.h *//* * New style bootinfo * * Add new tags only at the end of the enum; *never* remove any tags * or you'll break compatibility! * Which compatibility ? compatibility consideration lead to * MS-DOG :) -Stoned *//* * Valid machtype values * FIXME: note that we really need a hierarchy for this stuff, as there are * several models of DECStation (for example). PMA */#define MACH_UNKNOWN 0 /* whatever... */#define MACH_DESKSTATION_RPC44 1 /* Deskstation rPC44 */#define MACH_DESKSTATION_TYNE 2 /* Deskstation Tyne */#define MACH_ACER_PICA_61 3 /* Acer PICA-61 (PICA1) */#define MACH_MIPS_MAGNUM_4000 4 /* Mips Magnum 4000 "RC4030" */#define MACH_OLIVETTI_M700 4 /* only a clone... */#define MACH_DECSTATION 5 /* DECStation 5000/2x for now */#define MACH_LAST 6/* * Values for machgroup */#define MACH_GROUP_UNKNOWN 0 /* whatever... */#define MACH_GROUP_JAZZ 1 /* Acer Pica 61, Mips Magnum 4000, Olivetti */ /* M700-10 */#define MACH_GROUP_DEC 2 /* Digital (just an example, sure it needs) */ /* tuning :) */#define MACH_GROUP_ARC 3 /* Deskstation Tyne, rpc44, possibly other */#define MACH_GROUP_SNI_RM 4 /* Siemens Nixdorf RM series */#define MACH_GROUP_ACN 5#define MACH_GROUP_SIMOS 6#define MACH_SIMOS_PORT0 0/* * Valid cputype values */#define CPU_UNKNOWN 0#define CPU_R2000 1#define CPU_R3000 2#define CPU_R3000A 3#define CPU_R3041 4#define CPU_R3051 5#define CPU_R3052 6#define CPU_R3081 7#define CPU_R3081E 8#define CPU_R4000PC 9#define CPU_R4000SC 10#define CPU_R4000MC 11#define CPU_R4200 12#define CPU_R4400PC 13#define CPU_R4400SC 14#define CPU_R4400MC 15#define CPU_R4600 16#define CPU_R6000 17#define CPU_R6000A 18#define CPU_R8000 19#define CPU_R10000 20#define CPU_R4300 21#define CPU_R4650 22#define CPU_R4670 23#define CPU_R5000 24#define CPU_R5000A 25#define CPU_LAST 25/* * Some machine parameters passed by the bootloaders. */struct drive_info_struct { char dummy[32];};enum bi_tag { /* * not a real tag */ tag_dummy, /* * machine type */ tag_machtype, /* * system CPU & FPU */ tag_cputype, /* * Installed RAM */ tag_memlower, tag_memupper, /* * Cache Sizes (0xffffffff = unknown) */ tag_icache_size, tag_icache_linesize, tag_dcache_size, tag_dcache_linesize, tag_scache_size, tag_scache_linesize, /* * TLB Info */ tag_tlb_entries, /* * DMA buffer size (Deskstation only) */ tag_dma_cache_size, tag_dma_cache_base, /* * Ramdisk Info */ tag_ramdisk_size, /* ramdisk size in 1024 byte blocks */ tag_ramdisk_base, /* address of the ram disk in mem */ /* * Boot flags for the kernel */ tag_mount_root_rdonly, tag_drive_info, /* * Video ram info (not in tty.h) */ tag_vram_base, /* video ram base address */ tag_command_line, /* kernel command line parameters */ /* * machine group */ tag_machgroup };/* struct defining a tag */typedef struct { enum bi_tag tag; unsigned long size;} tag;/* struct to define a tag and it's data */typedef struct { tag t; void* d;} tag_def;#define COMMAND_LINE_SIZE 256struct TagList;typedef struct { unsigned int data; tag atag;} int_tag;typedef struct { unsigned long data; tag atag;} long_tag;typedef struct { unsigned char data; tag atag;} char_tag;typedef struct { struct drive_info_struct data; tag atag;} drive_tag; typedef struct { unsigned char data[COMMAND_LINE_SIZE]; tag atag;} cmdline_tag;typedef struct { tag dummy; int_tag machtype; int_tag cputype; long_tag memlower; long_tag memupper; long_tag icache_size; long_tag icache_linesize; long_tag dcache_size; long_tag dcache_linesize; long_tag scache_size; long_tag scache_linesize; int_tag tlb_entries; int_tag ramdisk_size; int_tag ramdisk_base; int_tag mount_root_rdonly; /*check this?!!!*/ drive_tag drive_info; int_tag vram_base; int_tag machgroup; cmdline_tag command_line;} TagList;void TagInit(int machine, TagList *);int LinuxLoadImage(char *pathname, VA startaddr, int nbytes, VA *entry, int filter);extern TagList tagPairs;#define __GNU_EXEC_MACROS__#ifndef __STRUCT_EXEC_OVERRIDE__struct exec{ unsigned long a_info; /* Use macros N_MAGIC, etc for access */ unsigned a_text; /* length of text, in bytes */ unsigned a_data; /* length of data, in bytes */ unsigned a_bss; /* length of uninitialized data area for file, in bytes */ unsigned a_syms; /* length of symbol table data in file, in bytes */ unsigned a_entry; /* start address */ unsigned a_trsize; /* length of relocation info for text, in bytes */ unsigned a_drsize; /* length of relocation info for data, in bytes */};#define N_TRSIZE(a) ((a).a_trsize)#define N_DRSIZE(a) ((a).a_drsize)#define N_SYMSIZE(a) ((a).a_syms)#endif /* __STRUCT_EXEC_OVERRIDE__ *//* these go in the N_MACHTYPE field */enum machine_type {#if defined (M_OLDSUN2) M__OLDSUN2 = M_OLDSUN2,#else M_OLDSUN2 = 0,#endif#if defined (M_68010) M__68010 = M_68010,#else M_68010 = 1,#endif#if defined (M_68020) M__68020 = M_68020,#else M_68020 = 2,#endif#if defined (M_SPARC) M__SPARC = M_SPARC,#else M_SPARC = 3,#endif /* skip a bunch so we don't run into any of sun's numbers */ M_386 = 100, M_MIPS1 = 151, /* MIPS R3000/R3000 binary */ M_MIPS2 = 152 /* MIPS R6000/R4000 binary */};#if !defined (N_MAGIC)#define N_MAGIC(exec) ((exec).a_info & 0xffff)#endif#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)#define N_SET_INFO(exec, magic, type, flags) \ ((exec).a_info = ((magic) & 0xffff) \ | (((int)(type) & 0xff) << 16) \ | (((flags) & 0xff) << 24))#define N_SET_MAGIC(exec, magic) \ ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))#define N_SET_MACHTYPE(exec, machtype) \ ((exec).a_info = \ ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))#define N_SET_FLAGS(exec, flags) \ ((exec).a_info = \ ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))/* Code indicating object file or impure executable. */#define OMAGIC 0407/* Code indicating pure executable. */#define NMAGIC 0410/* Code indicating demand-paged executable. */#define ZMAGIC 0413/* This indicates a demand-paged executable with the header in the text. The first page is unmapped to help trap NULL pointer references */#define QMAGIC 0314/* Code indicating core file. */#define CMAGIC 0421#if !defined (N_BADMAG)#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \ && N_MAGIC(x) != NMAGIC \ && N_MAGIC(x) != ZMAGIC \ && N_MAGIC(x) != QMAGIC)#endif#define _N_HDROFF(x) (1024 - sizeof (struct exec))#if !defined (N_TXTOFF)#define N_TXTOFF(x) \ (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \ (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))#endif#if !defined (N_DATOFF)#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)#endif#if !defined (N_TRELOFF)#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)#endif#if !defined (N_DRELOFF)#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)#endif#if !defined (N_SYMOFF)#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)#endif#if !defined (N_STROFF)#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)#endif/* Address of text segment in memory after it is loaded. */#if !defined (N_TXTADDR)#define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)#endif/* Address of data segment in memory after it is loaded. Note that it is up to you to define SEGMENT_SIZE on machines not listed here. */#if defined(vax) || defined(hp300) || defined(pyr)#define SEGMENT_SIZE page_size#endif#ifdef sony#define SEGMENT_SIZE 0x2000#endif /* Sony. */#ifdef is68k#define SEGMENT_SIZE 0x20000#endif#if defined(m68k) && defined(PORTAR)#define PAGE_SIZE 0x400#define SEGMENT_SIZE PAGE_SIZE#endif#ifdef linux#include <asm/page.h>#ifdef __i386__#define SEGMENT_SIZE 1024#else#define SEGMENT_SIZE PAGE_SIZE#endif#endif#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)#ifndef N_DATADDR#define N_DATADDR(x) \ (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \ : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))#endif/* Address of bss segment in memory after it is loaded. */#if !defined (N_BSSADDR)#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)#endif#if !defined (N_NLIST_DECLARED)struct nlist { union { char *n_name; struct nlist *n_next; long n_strx; } n_un; unsigned char n_type; char n_other; short n_desc; unsigned long n_value;};#endif /* no N_NLIST_DECLARED. */#if !defined (N_UNDF)#define N_UNDF 0#endif#if !defined (N_ABS)#define N_ABS 2#endif#if !defined (N_TEXT)#define N_TEXT 4#endif#if !defined (N_DATA)#define N_DATA 6#endif#if !defined (N_BSS)#define N_BSS 8#endif#if !defined (N_FN)#define N_FN 15#endif#if !defined (N_EXT)#define N_EXT 1#endif#if !defined (N_TYPE)#define N_TYPE 036#endif#if !defined (N_STAB)#define N_STAB 0340#endif/* The following type indicates the definition of a symbol as being an indirect reference to another symbol. The other symbol appears as an undefined reference, immediately following this symbol. Indirection is asymmetrical. The other symbol's value will be used to satisfy requests for the indirect symbol, but not vice versa. If the other symbol does not have a definition, libraries will be searched to find a definition. */#define N_INDR 0xa/* The following symbols refer to set elements. All the N_SET[ATDB] symbols with the same name form one set. Space is allocated for the set in the text section, and each set element's value is stored into one word of the space. The first word of the space is the length of the set (number of elements). The address of the set is made into an N_SETV symbol whose name is the same as the name of the set. This symbol acts like a N_DATA global symbol in that it can satisfy undefined external references. *//* These appear as input to LD, in a .o file. */#define N_SETA 0x14 /* Absolute set element symbol */#define N_SETT 0x16 /* Text set element symbol */#define N_SETD 0x18 /* Data set element symbol */#define N_SETB 0x1A /* Bss set element symbol *//* This is output from LD. */#define N_SETV 0x1C /* Pointer to set vector in data area. */#if !defined (N_RELOCATION_INFO_DECLARED)/* This structure describes a single relocation to be performed. The text-relocation section of the file is a vector of these structures, all of which apply to the text section. Likewise, the data-relocation section applies to the data section. */struct relocation_info{ /* Address (within segment) to be relocated. */ int r_address; /* The meaning of r_symbolnum depends on r_extern. */ unsigned int r_symbolnum:24; /* Nonzero means value is a pc-relative offset and it should be relocated for changes in its own address as well as for changes in the symbol or section specified. */ unsigned int r_pcrel:1; /* Length (as exponent of 2) of the field to be relocated. Thus, a value of 2 indicates 1<<2 bytes. */ unsigned int r_length:2; /* 1 => relocate with value of symbol. r_symbolnum is the index of the symbol in file's the symbol table. 0 => relocate with the address of a segment. r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS (the N_EXT bit may be set also, but signifies nothing). */ unsigned int r_extern:1; /* Four bits that aren't used, but when writing an object file it is desirable to clear them. */#ifdef NS32K unsigned r_bsr:1; unsigned r_disp:1; unsigned r_pad:2;#else unsigned int r_pad:4;#endif};#endif /* no N_RELOCATION_INFO_DECLARED. */#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?