misc_no_hyper.cpp
Go to the documentation of this file.
1 //
2 // Bareflank Hypervisor
3 //
4 // Copyright (C) 2015 Assured Information Security, Inc.
5 // Author: Rian Quinn <quinnr@ainfosec.com>
6 // Author: Brendan Kerrigan <kerriganb@ainfosec.com>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 
22 #include <stdint.h>
23 #include <string.h>
24 #include <stdlib.h>
25 
26 #include <debug_ring/debug_ring.h>
28 
29 debug_ring *dr = nullptr;
30 
31 extern "C" int
32 write(int file, const void *buffer, size_t count)
33 {
34  (void) file;
35 
36  if (buffer == nullptr || count == 0)
37  return 0;
38 
39  try
40  {
41  auto str = std::string(static_cast<const char *>(buffer), count);
42 
43  if (dr == nullptr)
44  dr = new debug_ring(0);
45 
46  dr->write(str);
48  return static_cast<int>(count);
49  }
50  catch (...) { }
51 
52  return 0;
53 }
54 
55 extern "C" int64_t
56 start_vmm(uint64_t arg) noexcept
57 {
58  (void) arg;
59 
60  auto msg = "start_vmm\n";
61  write(1, msg, strlen(msg));
62 
63  return 0;
64 }
65 
66 extern "C" int64_t
67 stop_vmm(uint64_t arg) noexcept
68 {
69  (void) arg;
70 
71  auto msg = "stop_vmm\n";
72  write(1, msg, strlen(msg));
73 
74  return 0;
75 }
Definition: file.h:35
void write(char c) noexcept
int64_t stop_vmm(uint64_t arg) noexcept
int write(int file, const void *buffer, size_t count)
virtual void write(const std::string &str) noexcept
Definition: debug_ring.cpp:79
void uint64_t uint64_t uint64_t *rdx noexcept
int64_t start_vmm(uint64_t arg) noexcept
static serial_port_intel_x64 * instance() noexcept
debug_ring * dr