aboutsummaryrefslogtreecommitdiffstats
path: root/src/ortho/llvm-nodebug/llvm-cbindings.cpp
blob: 4a61ad5527eb87db7407346ece4f11e3da23d581 (plain)
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
/*  LLVM binding
  Copyright (C) 2014 Tristan Gingold

  GHDL is free software; you can redistribute it and/or modify it under
  the terms of the GNU General Public License as published by the Free
  Software Foundation; either version 2, or (at your option) any later
  version.

  GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  for more details.

  You should have received a copy of the GNU General Public License
  along with GHDL; see the file COPYING.  If not, write to the Free
  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  02111-1307, USA.  */
#include "llvm-c/Target.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/LLVMContext.h"

using namespace llvm;

extern "C" {

void
LLVMInitializeNativeTarget_noinline (void)
{
  LLVMInitializeNativeTarget ();
}

void
LLVMInitializeNativeAsmPrinter_noinline (void)
{
  LLVMInitializeNativeAsmPrinter();
}

}
; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * x86-specific gdb stub routines
 * based on x86 cdb(xen/arch/x86/cdb.c), but Extensively modified.
 * 
 * Copyright (C) 2006 Isaku Yamahata <yamahata at valinux co jp>
 *                    VA Linux Systems Japan. K.K.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */
#include <asm/debugger.h>

u16
gdb_arch_signal_num(struct cpu_user_regs *regs, unsigned long cookie)
{
    /* XXX */
    return 1;
}

void 
gdb_arch_read_reg_array(struct cpu_user_regs *regs, struct gdb_context *ctx)
{
#define GDB_REG(r) gdb_write_to_packet_hex(r, sizeof(r), ctx);
    GDB_REG(regs->eax);
    GDB_REG(regs->ecx);
    GDB_REG(regs->edx);
    GDB_REG(regs->ebx);
    GDB_REG(regs->esp);
    GDB_REG(regs->ebp);
    GDB_REG(regs->esi);
    GDB_REG(regs->edi);
    GDB_REG(regs->eip);
    GDB_REG(regs->eflags);
#undef GDB_REG
#define GDB_SEG_REG(s)  gdb_write_to_packet_hex(s, sizeof(u32), ctx);
    /* sizeof(segment) = 16bit */
    /* but gdb requires its return value as 32bit value */
    GDB_SEG_REG(regs->cs);
    GDB_SEG_REG(regs->ss);
    GDB_SEG_REG(regs->ds);
    GDB_SEG_REG(regs->es);
    GDB_SEG_REG(regs->fs);
    GDB_SEG_REG(regs->gs);
#undef GDB_SEG_REG
    gdb_send_packet(ctx);
}

void 
gdb_arch_write_reg_array(struct cpu_user_regs *regs, const char* buf,
                         struct gdb_context *ctx)
{
    /* XXX TODO */
    gdb_send_reply("E02", ctx);
}

void 
gdb_arch_read_reg(unsigned long regnum, struct cpu_user_regs *regs,
                  struct gdb_context *ctx)
{
    gdb_send_reply("", ctx);
}

/* Like copy_from_user, but safe to call with interrupts disabled.
   Trust me, and don't look behind the curtain. */
unsigned 
gdb_arch_copy_from_user(void *dest, const void *src, unsigned len)
{
    int __d0, __d1, __d2;
    ASSERT(!local_irq_is_enabled());
    __asm__ __volatile__(
        "1: rep; movsb\n"
        "2:\n"
        ".section .fixup,\"ax\"\n"
        "3:     addl $4, %%esp\n"
        "       jmp 2b\n"
        ".previous\n"
        ".section __pre_ex_table,\"a\"\n"
        "   "__FIXUP_ALIGN"\n"
        "   "__FIXUP_WORD" 1b,3b\n"
        ".previous\n"
        ".section __ex_table,\"a\"\n"
        "   "__FIXUP_ALIGN"\n"
        "   "__FIXUP_WORD" 1b,2b\n"
        ".previous\n"
        : "=c"(__d2), "=D" (__d0), "=S" (__d1)
        : "0"(len), "1"(dest), "2"(src)
        : "memory");
    ASSERT(!local_irq_is_enabled());
    return __d2;
}

unsigned int 
gdb_arch_copy_to_user(void *dest, const void *src, unsigned len)
{
    /* XXX  */
    return len;
}

void 
gdb_arch_resume(struct cpu_user_regs *regs,
                unsigned long addr, unsigned long type,
                struct gdb_context *ctx)
{
    /* XXX */
    if (type == GDB_STEP) {
        gdb_send_reply("S01", ctx);
    }
}

void
gdb_arch_print_state(struct cpu_user_regs *regs)
{
    /* XXX */
}

void
gdb_arch_enter(struct cpu_user_regs *regs)
{
    /* nothing */
}

void
gdb_arch_exit(struct cpu_user_regs *regs)
{
    /* nothing */
}

/*
 * Local variables:
 * mode: C
 * c-set-style: "BSD"
 * c-basic-offset: 4
 * tab-width: 4
 * End:
 */