1 | ; $Id: bootsector-shutdown.asm 82968 2020-02-04 10:35:17Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; Bootsector for grub chainloading that shutdowns the VM.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2020 Oracle Corporation
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | ; available from http://www.virtualbox.org. This file is free software;
|
---|
11 | ; you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | ; General Public License (GPL) as published by the Free Software
|
---|
13 | ; Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | ;
|
---|
17 | ; The contents of this file may alternatively be used under the terms
|
---|
18 | ; of the Common Development and Distribution License Version 1.0
|
---|
19 | ; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | ; VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | ; CDDL are applicable instead of those of the GPL.
|
---|
22 | ;
|
---|
23 | ; You may elect to license modified versions of this file under the
|
---|
24 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | ;
|
---|
26 |
|
---|
27 | %include "VBox/bios.mac"
|
---|
28 |
|
---|
29 |
|
---|
30 | BITS 16
|
---|
31 | start:
|
---|
32 | ; Start with a jump just to follow the convention.
|
---|
33 | jmp short the_code
|
---|
34 | nop
|
---|
35 | times 3ah db 0
|
---|
36 |
|
---|
37 | the_code:
|
---|
38 | cli
|
---|
39 |
|
---|
40 | ;
|
---|
41 | ; VBox/Bochs shutdown request - write "Shutdown" byte by byte to shutdown port.
|
---|
42 | ;
|
---|
43 | mov cx, 64
|
---|
44 | mov dx, VBOX_BIOS_SHUTDOWN_PORT
|
---|
45 | mov bx, VBOX_BIOS_OLD_SHUTDOWN_PORT
|
---|
46 | retry:
|
---|
47 | mov al, 'S'
|
---|
48 | out dx, al
|
---|
49 | mov al, 'h'
|
---|
50 | out dx, al
|
---|
51 | mov al, 'u'
|
---|
52 | out dx, al
|
---|
53 | mov al, 't'
|
---|
54 | out dx, al
|
---|
55 | mov al, 'd'
|
---|
56 | out dx, al
|
---|
57 | mov al, 'o'
|
---|
58 | out dx, al
|
---|
59 | mov al, 'w'
|
---|
60 | out dx, al
|
---|
61 | mov al, 'n'
|
---|
62 | out dx, al
|
---|
63 | xchg dx, bx ; alternate between the new (VBox) and old (Bochs) ports.
|
---|
64 | loop retry
|
---|
65 |
|
---|
66 | ;
|
---|
67 | ; Shutdown failed!
|
---|
68 | ;
|
---|
69 |
|
---|
70 | ;; @todo print some message before halting.
|
---|
71 | hlt
|
---|
72 |
|
---|
73 | ;
|
---|
74 | ; Padd the remainder of the sector with zeros and
|
---|
75 | ; end it with the dos signature.
|
---|
76 | ;
|
---|
77 | padding:
|
---|
78 | times 510 - (padding - start) db 0
|
---|
79 | db 055h, 0aah
|
---|
80 |
|
---|