1 | ; $Id: bootsector-shutdown.asm 52776 2014-09-17 14:51:43Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; Bootsector for grub chainloading that shutdowns the VM.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2014 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 |
|
---|
28 | BITS 16
|
---|
29 | start:
|
---|
30 | ; Start with a jump just to follow the convention.
|
---|
31 | jmp short the_code
|
---|
32 | nop
|
---|
33 | times 3ah db 0
|
---|
34 |
|
---|
35 | the_code:
|
---|
36 | cli
|
---|
37 |
|
---|
38 | ;
|
---|
39 | ; Boch shutdown request - write "Shutdown" byte by byte to port 08900h.
|
---|
40 | ;
|
---|
41 | mov cx, 64
|
---|
42 | mov dx, 08900h
|
---|
43 | retry:
|
---|
44 | mov al, 'S'
|
---|
45 | out dx, al
|
---|
46 | mov al, 'h'
|
---|
47 | out dx, al
|
---|
48 | mov al, 'u'
|
---|
49 | out dx, al
|
---|
50 | mov al, 't'
|
---|
51 | out dx, al
|
---|
52 | mov al, 'd'
|
---|
53 | out dx, al
|
---|
54 | mov al, 'o'
|
---|
55 | out dx, al
|
---|
56 | mov al, 'w'
|
---|
57 | out dx, al
|
---|
58 | mov al, 'n'
|
---|
59 | out dx, al
|
---|
60 | loop retry
|
---|
61 |
|
---|
62 | ;
|
---|
63 | ; Shutdown failed!
|
---|
64 | ;
|
---|
65 |
|
---|
66 | ;; @todo print some message before halting.
|
---|
67 | hlt
|
---|
68 |
|
---|
69 | ;
|
---|
70 | ; Padd the remainder of the sector with zeros and
|
---|
71 | ; end it with the dos signature.
|
---|
72 | ;
|
---|
73 | padding:
|
---|
74 | times 510 - (padding - start) db 0
|
---|
75 | db 055h, 0aah
|
---|
76 |
|
---|