blob: 3223251efd8ff7a0dc2ae43cdbba7ba483fdfd2c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// This file provides functions for the wetterhorn harness that are not
// expressible directly in haskell.
//
// Currently these functions exclusively enable/disable the Haskell runtime.
#include "HsFFI.h"
#include "plugin_interface.h"
#include <stdio.h>
const char *plugin_name = "Wetterhorn";
void plugin_load(int argc, char **argv) { hs_init(&argc, &argv); }
void plugin_teardown(opqst_t st) { hs_exit(); }
static const char msg[] =
"Wetterhorn Plugin v 0.01\n\n"
"Welcome, and thank you for your interest.\n\n"
"This is merely a plugin to the Wetterhorn Compositor and not meant to be\n"
"executed as a standalone binary. This plugin requires a harness to run\n"
"To use this file, please use './wtr_harness [full-path-to-wtr.so]'\n"
"That will allow you to see how this compositor works in all its glory!\n";
static const int msg_sz = sizeof(msg);
__attribute__((naked)) void _start() {
// Make system call to print the message
asm(
// Load the address of the string into rsi
"mov %0, %%rsi\n"
// Load the string length into edx
"mov %1, %%edx\n"
// Load the file descriptor for stdout into edi
"mov $1, %%edi\n"
// Load the syscall number for sys_write into eax
"mov $1, %%eax\n"
// Make the syscall
"syscall\n"
// Exit the program.
"mov $0, %%rdi\n"
"mov $60, %%rax\n"
"syscall\n"
:
: "r"(msg), "r"(msg_sz) // Input: address of msg
: "%rsi", "%edx", "%edi" // Clobbered registers
);
}
|