在我阅读 Singularity 史前活动的代码时,这个 BootInfo 结构多次出现在代码中,并且来回传递与 C 与 Asm 之间。所以单独提出来方便查阅。
\base.obj\Boot\Prototype.x86\halclass.h[530] & halclass.inc[715]
1: struct Struct_Microsoft_Singularity_BootInfo 2: { 3: 4: uint32 RecSize; // 0 5: Struct_Microsoft_Singularity_X86_IDTP BiosIdtPtr; // 4 6: uint16 BiosPicMask; // 12 7: uint8 BiosWarmResetCmos; // 14 8: int8 __padding000[1]; // 15 9: uint32 BiosWarmResetVector; // 16 10: uint32 Info16; // 20 11: uint16 DebugBasePort; // 24 12: int8 __padding001[2]; // 26 13: uint64 IdtEnter0; // 28 14: uint64 IdtEnter1; // 36 15: uint64 IdtEnterN; // 44 16: uint64 IdtTarget; // 52 17: uint64 Info32; // 60 18: uint64 Kill32; // 68 19: uint32 KillAction; // 76 20: uint64 MpEnter32; // 80 21: uint32 MpCpuCount; // 88 22: uint32 MpStatus32; // 92 23: uint64 MpStartupLock32; // 96 24: uint64 MpBootInfo32; // 104 25: Struct_Microsoft_Singularity_CpuInfo Cpu0; // 112 26: uint64 Pdpt32; // 228 27: uint64 Undump; // 236 28: uint64 DumpAddr32; // 244 29: uint32 DumpSize32; // 252 30: uint64 DumpRemainder; // 256 31: uint64 DumpBase; // 264 32: uint64 DumpLimit; // 272 33: uint64 Heap32; // 280 34: uint32 PciBiosAX; // 288 35: uint32 PciBiosBX; // 292 36: uint32 PciBiosCX; // 296 37: uint32 PciBiosEDX; // 300 38: uint64 AcpiRoot32; // 304 39: uint64 PnpNodesAddr32; // 312 40: uint32 PnpNodesSize32; // 320 41: uint64 SmbiosRoot32; // 324 42: uint64 DmiRoot32; // 332 43: uint32 IsaCsns; // 340 44: uint16 IsaReadPort; // 344 45: int8 __padding002[2]; // 346 46: uint32 Ebda32; // 348 47: uint32 MpFloat32; // 352 48: uint32 SmapCount; // 356 49: uint64 SmapData32; // 360 50: uint64 Ohci1394Base; // 368 51: uint64 Ohci1394BufferAddr32; // 376 52: uint32 Ohci1394BufferSize32; // 384 53: uint64 FileImageTableBase32; // 388 54: uint32 FileImageTableEntries; // 396 55: uint64 CmdLine32; // 400 56: uint32 BootCount; // 408 57: // bartok layout dataSize = 412 58: 59: static Struct_Microsoft_Singularity_BootInfo * g_HalGetBootInfo(); 60: };这两个文件是 Bartok 自动生成的。.h 文件用于 C 语言代码,而 .inc 文件用于汇编语言代码。
Bartok 是一个类似于 JIT 的东东,负责把 IL 代码编译为本机可执行代码。
真正的 BootInfo 在 \base\Kernel\Singularity\BootInfo.cs 文件中定义。
1: // 2: // Copyright (c) Microsoft Corporation. All rights reserved. 3: // 4: 5: using System; 6: using System.Runtime.InteropServices; 7: using System.Runtime.CompilerServices; 8: 9: namespace Microsoft.Singularity 10: { 11: [StructLayout(LayoutKind.Sequential, Pack=4)] 12: [CLSCompliant(false)] 13: public struct BootInfo 14: { 15: // 16: // These constants control the gross layout of physical memory. 17: // 18: // Physical Addresses 19: // 00000000..000fffff Reserved for boot loaders 20: // 00007000..00017fff 16-bit segment 21: // 00007b00..0000efff 16-bit real-mode code 22: // 0000f000..00017fff 16-bit stack 23: // 00018000..0005ffff boot heap 24: // 00060000..000affff 32-bit boot loader code (undump) 25: // 26: // 00100000..001fffff Reserved for ? (1MB..) 27: // 28: // 00200000..002fffff Kernel stack (1MB..2MB) 29: // 00310000..004fffff Kernel code & static Data (2MB..4MB...) 30: // 31: // 00500000..?? Mp ABI stub (haryadi) 32: // 33: // 04000000..07ffffff Runtime heaps preferred memory (64MB..128MB) 34: // 35: // top-size..top ram minidump load. 36: // 37: // fe000000..ffffffff Uncached mapped memory 38: 39: // Memory Layout Constants 40: [AccessedByRuntime("referenced in c++")] 41: // 4KB is currently the only supported size 42: internal const uint PAGE_SIZE = 0x00001000; // 4KB 43: 44: // Make sure zero through this address is always unmapped 45: [AccessedByRuntime("referenced in c++")] 46: internal const uint PHYSICAL_DISABLED = 0x00004000; 47: 48: [AccessedByRuntime("referenced in c++")] 49: internal const uint REAL_CODE_BASE = 0x00007b00; 50: [AccessedByRuntime("referenced in c++")] 51: internal const uint REAL_STACK = 0x00017FF0; 52: [AccessedByRuntime("referenced in c++")] 53: internal const uint REAL_PBOOTINFO = 0x00017FF8; 54: [AccessedByRuntime("referenced in c++")] 55: internal const uint REAL_HEAP = 0x00018000; 56: 57: [AccessedByRuntime("referenced in c++")] 58: internal const uint DUMP_CODE_BASE = 0x00060000; 59: 60: // Addresses for hypervisor overlay pages 61: [AccessedByRuntime("referenced in c++")] 62: internal const uint HYPERCALL_PAGE = 0x00100000; 63: [AccessedByRuntime("referenced in c++")] 64: internal const uint HYPERVISOR_SIM_PAGE = 0x00101000; 65: [AccessedByRuntime("referenced in c++")] 66: internal const uint HYPERVISOR_SIEF_PAGE= 0x00102000; 67: 68: [AccessedByRuntime("referenced in c++")] 69: internal const uint KERNEL_LOGREC_BEGIN = 0x00200000; 70: [AccessedByRuntime("referenced in c++")] 71: internal const uint KERNEL_LOGREC_LIMIT = 0x00220000; 72: [AccessedByRuntime("referenced in c++")] 73: internal const uint KERNEL_LOGTXT_BEGIN = 0x00220000; 74: [AccessedByRuntime("referenced in c++")] 75: internal const uint KERNEL_LOGTXT_LIMIT = 0x00240000; 76: 77: [AccessedByRuntime("referenced in c++")] 78: internal const uint KERNEL_STACK_BEGIN = 0x00240000; 79: [AccessedByRuntime("referenced in c++")] 80: internal const uint KERNEL_STACK = 0x002ff000; 81: [AccessedByRuntime("referenced in c++")] 82: internal const uint KERNEL_STACK_LIMIT = 0x00300000; 83: 84: [AccessedByRuntime("referenced in c++")] 85: internal const uint KERNEL_BASE = 0x00310000; 86: 87: // haryadi -- this is the ABI Stub (MpSyscalls.x86) 88: [AccessedByRuntime("referenced in c++")] 89: internal const uint MP_ABI_BASE = 0x00600000; 90: 91: // The physical address and extent of the high-memory 92: // range to map into the Kernel space, and mark 93: // "uncached". This window is for communicating with 94: // hardware. 95: [AccessedByRuntime("referenced in c++")] 96: internal const uint UNCACHED_PHYSICAL = 0xFE000000; 97: [AccessedByRuntime("referenced in c++")] 98: internal const uint UNCACHED_MAPPED = 0x02000000; 99: 100: // This is the amount of *contiguous, physical* memory 101: // to reserve at boot for use as I/O memory 102: internal const uint IO_MEMORY_SIZE = 0x00800000; // 8MB 103: 104: // 105: // These constants control the gross layout of *virtual* 106: // memory 107: // 108: 109: // This is the maximum size of a communication-heap 110: // (used to reserve enough space in virtual address 111: // spaces to map in communication heaps as necessary) 112: // For ease of mapping, this should be a multiple of 2MB 113: internal const uint COMM_HEAP_MAX_SIZE = 0x02000000; // 32MB 114: 115: // This determines where the kernel/user boundary is. 116: // Currently, it needs to be multiple of 1GB. 117: internal const uint KERNEL_BOUNDARY = 0x40000000; // 1GB 118: 119: // This determines the maximum virtual address 120: // we will use. Setting this to less than the 121: // machine's maximum pointer size can reduce the 122: // overhead of paging structures. 123: // 124: // NOTE we are not currently safe to use the top 125: // bit of addresses (because of the "mark" bit in the 126: // multi-use word header), so restrict ourselves to the 127: // bottom 2GB. 128: [AccessedByRuntime("referenced in c++")] 129: internal const uint MAX_VIRTUAL_ADDR = 0x80000000; // 2GB 130: 131: // Exit Codes: 132: [AccessedByRuntime("referenced in c++")] 133: internal const int EXIT_AND_RESTART = 0x1fff; 134: [AccessedByRuntime("referenced in c++")] 135: internal const int EXIT_AND_SHUTDOWN = 0x1ffe; 136: [AccessedByRuntime("referenced in c++")] 137: internal const int EXIT_AND_WARMBOOT = 0x1ffd; 138: [AccessedByRuntime("referenced in c++")] 139: internal const int EXIT_AND_HALT = 0x1ffc; 140: 141: // Sanity Check 142: [AccessedByRuntime("referenced in c++")] 143: internal uint RecSize; 144: 145: // IDT and PIC 146: [AccessedByRuntime("referenced in c++")] 147: internal X86.IDTP BiosIdtPtr; 148: [AccessedByRuntime("referenced in c++")] 149: internal ushort BiosPicMask; 150: [AccessedByRuntime("referenced in c++")] 151: internal byte BiosWarmResetCmos; 152: [AccessedByRuntime("referenced in c++")] 153: internal uint BiosWarmResetVector; 154: [AccessedByRuntime("referenced in c++")] 155: internal uint Info16; 156: 157: // Debug Stub Information 158: [AccessedByRuntime("referenced in c++")] 159: internal ushort DebugBasePort; 160: 161: // Temporary IDT 162: [AccessedByRuntime("referenced in c++")] 163: internal ulong IdtEnter0; 164: [AccessedByRuntime("referenced in c++")] 165: internal ulong IdtEnter1; 166: [AccessedByRuntime("referenced in c++")] 167: internal ulong IdtEnterN; 168: [AccessedByRuntime("referenced in c++")] 169: internal ulong IdtTarget; 170: 171: // Self-descriptive information 172: [AccessedByRuntime("referenced in c++")] 173: internal ulong Info32; 174: [AccessedByRuntime("referenced in c++")] 175: internal ulong Kill32; 176: [AccessedByRuntime("referenced in c++")] 177: internal uint KillAction; 178: 179: // MP specific variables 180: [AccessedByRuntime("referenced in c++")] 181: public ulong MpEnter32; // Entry point 182: [AccessedByRuntime("referenced in c++")] 183: public uint MpCpuCount; // No of AP's booted 184: [AccessedByRuntime("referenced in c++")] 185: public uint MpStatus32; // Error indicator 186: [AccessedByRuntime("referenced in c++")] 187: public ulong MpStartupLock32; // Pointer to MP init lock var 188: [AccessedByRuntime("referenced in c++")] 189: public ulong MpBootInfo32; // Pointer to MpBootInfo 190: 191: // Per CPU state - in initialization order (CPU0 = BSP, CPUX = AP) 192: [AccessedByRuntime("referenced in c++")] 193: public CpuInfo Cpu0; 194: #if SINGULARITY_MP 195: [AccessedByRuntime("referenced in c++")] 196: public CpuInfo Cpu1; 197: [AccessedByRuntime("referenced in c++")] 198: public CpuInfo Cpu2; 199: [AccessedByRuntime("referenced in c++")] 200: public CpuInfo Cpu3; 201: # if !MAX_CPU2 && !MAX_CPU3 && !MAX_CPU4 202: # error "MAX_CPUx value is either not defined or not supported." 203: # endif // MAX_CPUx 204: #endif // SINGULARITY_MP 205: 206: [AccessedByRuntime("referenced in c++")] 207: internal ulong Pdpt32; 208: 209: [AccessedByRuntime("referenced in c++")] 210: internal ulong Undump; 211: 212: // Location (in high memory) of the executable 213: // images 214: [AccessedByRuntime("referenced in c++")] 215: internal ulong DumpAddr32; 216: 217: // Extent of that data 218: [AccessedByRuntime("referenced in c++")] 219: internal uint DumpSize32; 220: 221: [AccessedByRuntime("referenced in c++")] 222: internal ulong DumpRemainder; 223: 224: // Start of the undumped kernel image 225: [AccessedByRuntime("referenced in c++")] 226: internal ulong DumpBase; 227: 228: // Marks the highest address used by the 229: // kernel image (undumped from high memory) 230: [AccessedByRuntime("referenced in c++")] 231: internal ulong DumpLimit; 232: 233: // 234: [AccessedByRuntime("referenced in c++")] 235: internal ulong Heap32; 236: 237: // PCI Information (V2.0+) 238: [AccessedByRuntime("referenced in c++")] 239: internal uint PciBiosAX; 240: [AccessedByRuntime("referenced in c++")] 241: internal uint PciBiosBX; 242: [AccessedByRuntime("referenced in c++")] 243: internal uint PciBiosCX; 244: [AccessedByRuntime("referenced in c++")] 245: internal uint PciBiosEDX; 246: 247: // BIOS Information 248: [AccessedByRuntime("referenced in c++")] 249: public ulong AcpiRoot32; 250: [AccessedByRuntime("referenced in c++")] 251: internal ulong PnpNodesAddr32; 252: [AccessedByRuntime("referenced in c++")] 253: internal uint PnpNodesSize32; 254: [AccessedByRuntime("referenced in c++")] 255: internal ulong SmbiosRoot32; 256: [AccessedByRuntime("referenced in c++")] 257: internal ulong DmiRoot32; 258: [AccessedByRuntime("referenced in c++")] 259: internal uint IsaCsns; 260: [AccessedByRuntime("referenced in c++")] 261: internal ushort IsaReadPort; 262: [AccessedByRuntime("referenced in c++")] 263: internal uint Ebda32; 264: [AccessedByRuntime("referenced in c++")] 265: public uint MpFloat32; 266: 267: // SMAP Information 268: [AccessedByRuntime("referenced in c++")] 269: internal uint SmapCount; 270: [AccessedByRuntime("referenced in c++")] 271: internal ulong SmapData32; 272: 273: // 1394 Information 274: [AccessedByRuntime("referenced in c++")] 275: internal ulong Ohci1394Base; 276: [AccessedByRuntime("referenced in c++")] 277: internal ulong Ohci1394BufferAddr32; 278: [AccessedByRuntime("referenced in c++")] 279: internal uint Ohci1394BufferSize32; 280: 281: // File image table 282: [AccessedByRuntime("referenced in c++")] 283: internal ulong FileImageTableBase32; 284: [AccessedByRuntime("referenced in c++")] 285: internal uint FileImageTableEntries; 286: 287: // BOOT Information 288: [AccessedByRuntime("referenced in c++")] 289: internal ulong CmdLine32; 290: [AccessedByRuntime("referenced in c++")] 291: internal uint BootCount; 292: 293: [MethodImpl(MethodImplOptions.InternalCall)] 294: [StackBound(8)] 295: [NoHeapAllocation] 296: internal static unsafe extern BootInfo * HalGetBootInfo(); 297: 298: [NoHeapAllocation] 299: public static unsafe BootInfo GetBootInfo() 300: { 301: BootInfo *ptr; 302: 303: ptr = HalGetBootInfo(); 304: return *ptr; 305: } 306: 307: [NoHeapAllocation] 308: public unsafe CpuInfo GetCpuInfo(int processorId) 309: { 310: fixed (CpuInfo* ci = &Cpu0) 311: { 312: return *(ci + processorId); 313: } 314: } 315: } 316: }转载于:https://www.cnblogs.com/eclairs/archive/2008/10/15/1313121.html
相关资源:Singularity-POS-Tagger:Node.JS中的葡萄牙语POS-Tagger-源码