1 | /* $Id: bs3-rm-InitAll.c 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * BS3Kit - Initialize all components, real mode.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 |
|
---|
38 | /*********************************************************************************************************************************
|
---|
39 | * Header Files *
|
---|
40 | *********************************************************************************************************************************/
|
---|
41 | //#define BS3_USE_RM_TEXT_SEG 1
|
---|
42 | #include "bs3kit-template-header.h"
|
---|
43 | #include "bs3-cmn-test.h"
|
---|
44 | #include <iprt/asm-amd64-x86.h>
|
---|
45 |
|
---|
46 | BS3_MODE_PROTO_NOSB(void, Bs3EnteredMode,(void));
|
---|
47 |
|
---|
48 |
|
---|
49 | BS3_DECL(void) Bs3InitAll_rm(void)
|
---|
50 | {
|
---|
51 | uint8_t volatile BS3_FAR *pcTicksFlpyOff;
|
---|
52 |
|
---|
53 | /*
|
---|
54 | * Detect CPU first as the memory init code will otherwise use 386
|
---|
55 | * instrunctions and cause trouble on older CPUs.
|
---|
56 | */
|
---|
57 | Bs3CpuDetect_rm_far();
|
---|
58 | Bs3InitMemory_rm_far();
|
---|
59 | Bs3InitGdt_rm_far();
|
---|
60 |
|
---|
61 | /*
|
---|
62 | * Before we disable all interrupts, try convince the BIOS to stop the
|
---|
63 | * floppy motor, as it is kind of disturbing when the floppy light remains
|
---|
64 | * on for the whole testcase execution.
|
---|
65 | */
|
---|
66 | ASMIntDisable(); /* (probably already disabled, but no guarantees) */
|
---|
67 | pcTicksFlpyOff = (uint8_t volatile BS3_FAR *)BS3_FP_MAKE(0x40, 0x40);
|
---|
68 | if (*pcTicksFlpyOff)
|
---|
69 | {
|
---|
70 | uint32_t volatile BS3_FAR *pcTicks = (uint32_t volatile BS3_FAR *)BS3_FP_MAKE(0x40, 0x6c);
|
---|
71 | uint32_t cInitialTicks;
|
---|
72 |
|
---|
73 | *pcTicksFlpyOff = 1; /* speed up the countdown, don't want to wait for two seconds here. */
|
---|
74 | cInitialTicks = *pcTicks;
|
---|
75 | ASMIntEnable();
|
---|
76 |
|
---|
77 | while (*pcTicks == cInitialTicks)
|
---|
78 | ASMHalt();
|
---|
79 | }
|
---|
80 | ASMIntDisable();
|
---|
81 | Bs3PicSetup(false /*fForcedReInit*/);
|
---|
82 |
|
---|
83 | /*
|
---|
84 | * Initialize IDTs and such.
|
---|
85 | */
|
---|
86 | if (g_uBs3CpuDetected & BS3CPU_F_LONG_MODE)
|
---|
87 | Bs3Trap64Init();
|
---|
88 | if ((g_uBs3CpuDetected & BS3CPU_TYPE_MASK) >= BS3CPU_80386)
|
---|
89 | Bs3Trap32Init();
|
---|
90 | if ((g_uBs3CpuDetected & BS3CPU_TYPE_MASK) >= BS3CPU_80286)
|
---|
91 | Bs3Trap16Init();
|
---|
92 | Bs3TrapRmV86Init();
|
---|
93 |
|
---|
94 | /*
|
---|
95 | * Perform a real-mode enter to make some final environment adjustments
|
---|
96 | * (like installing our syscall).
|
---|
97 | */
|
---|
98 | Bs3EnteredMode_rm();
|
---|
99 | }
|
---|
100 |
|
---|