linux/arch/hexagon/include/asm/hexagon_vm.h
<<
>>
Prefs
   1/*
   2 * Declarations for to Hexagon Virtal Machine.
   3 *
   4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
   5 *
   6 * This program is free software; you can redistribute it and/or modify
   7 * it under the terms of the GNU General Public License version 2 and
   8 * only version 2 as published by the Free Software Foundation.
   9 *
  10 * This program is distributed in the hope that it will be useful,
  11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13 * GNU General Public License for more details.
  14 *
  15 * You should have received a copy of the GNU General Public License
  16 * along with this program; if not, write to the Free Software
  17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18 * 02110-1301, USA.
  19 */
  20
  21#ifndef ASM_HEXAGON_VM_H
  22#define ASM_HEXAGON_VM_H
  23
  24/*
  25 * In principle, a Linux kernel for the VM could
  26 * selectively define the virtual instructions
  27 * as inline assembler macros, but for a first pass,
  28 * we'll use subroutines for both the VM and the native
  29 * kernels.  It's costing a subroutine call/return,
  30 * but it makes for a single set of entry points
  31 * for tracing/debugging.
  32 */
  33
  34/*
  35 * Lets make this stuff visible only if configured,
  36 * so we can unconditionally include the file.
  37 */
  38
  39#ifndef __ASSEMBLY__
  40
  41enum VM_CACHE_OPS {
  42        ickill,
  43        dckill,
  44        l2kill,
  45        dccleaninva,
  46        icinva,
  47        idsync,
  48        fetch_cfg
  49};
  50
  51enum VM_INT_OPS {
  52        nop,
  53        globen,
  54        globdis,
  55        locen,
  56        locdis,
  57        affinity,
  58        get,
  59        peek,
  60        status,
  61        post,
  62        clear
  63};
  64
  65extern void _K_VM_event_vector(void);
  66
  67void __vmrte(void);
  68long __vmsetvec(void *);
  69long __vmsetie(long);
  70long __vmgetie(void);
  71long __vmintop(enum VM_INT_OPS, long, long, long, long);
  72long __vmclrmap(void *, unsigned long);
  73long __vmnewmap(void *);
  74long __vmcache(enum VM_CACHE_OPS op, unsigned long addr, unsigned long len);
  75unsigned long long __vmgettime(void);
  76long __vmsettime(unsigned long long);
  77long __vmstart(void *, void *);
  78void __vmstop(void);
  79long __vmwait(void);
  80void __vmyield(void);
  81long __vmvpid(void);
  82
  83static inline long __vmcache_ickill(void)
  84{
  85        return __vmcache(ickill, 0, 0);
  86}
  87
  88static inline long __vmcache_dckill(void)
  89{
  90        return __vmcache(dckill, 0, 0);
  91}
  92
  93static inline long __vmcache_l2kill(void)
  94{
  95        return __vmcache(l2kill, 0, 0);
  96}
  97
  98static inline long __vmcache_dccleaninva(unsigned long addr, unsigned long len)
  99{
 100        return __vmcache(dccleaninva, addr, len);
 101}
 102
 103static inline long __vmcache_icinva(unsigned long addr, unsigned long len)
 104{
 105        return __vmcache(icinva, addr, len);
 106}
 107
 108static inline long __vmcache_idsync(unsigned long addr,
 109                                           unsigned long len)
 110{
 111        return __vmcache(idsync, addr, len);
 112}
 113
 114static inline long __vmcache_fetch_cfg(unsigned long val)
 115{
 116        return __vmcache(fetch_cfg, val, 0);
 117}
 118
 119/* interrupt operations  */
 120
 121static inline long __vmintop_nop(void)
 122{
 123        return __vmintop(nop, 0, 0, 0, 0);
 124}
 125
 126static inline long __vmintop_globen(long i)
 127{
 128        return __vmintop(globen, i, 0, 0, 0);
 129}
 130
 131static inline long __vmintop_globdis(long i)
 132{
 133        return __vmintop(globdis, i, 0, 0, 0);
 134}
 135
 136static inline long __vmintop_locen(long i)
 137{
 138        return __vmintop(locen, i, 0, 0, 0);
 139}
 140
 141static inline long __vmintop_locdis(long i)
 142{
 143        return __vmintop(locdis, i, 0, 0, 0);
 144}
 145
 146static inline long __vmintop_affinity(long i, long cpu)
 147{
 148        return __vmintop(locdis, i, cpu, 0, 0);
 149}
 150
 151static inline long __vmintop_get(void)
 152{
 153        return __vmintop(get, 0, 0, 0, 0);
 154}
 155
 156static inline long __vmintop_peek(void)
 157{
 158        return __vmintop(peek, 0, 0, 0, 0);
 159}
 160
 161static inline long __vmintop_status(long i)
 162{
 163        return __vmintop(status, i, 0, 0, 0);
 164}
 165
 166static inline long __vmintop_post(long i)
 167{
 168        return __vmintop(post, i, 0, 0, 0);
 169}
 170
 171static inline long __vmintop_clear(long i)
 172{
 173        return __vmintop(clear, i, 0, 0, 0);
 174}
 175
 176#else /* Only assembly code should reference these */
 177
 178#define HVM_TRAP1_VMRTE                 1
 179#define HVM_TRAP1_VMSETVEC              2
 180#define HVM_TRAP1_VMSETIE               3
 181#define HVM_TRAP1_VMGETIE               4
 182#define HVM_TRAP1_VMINTOP               5
 183#define HVM_TRAP1_VMCLRMAP              10
 184#define HVM_TRAP1_VMNEWMAP              11
 185#define HVM_TRAP1_FORMERLY_VMWIRE       12
 186#define HVM_TRAP1_VMCACHE               13
 187#define HVM_TRAP1_VMGETTIME             14
 188#define HVM_TRAP1_VMSETTIME             15
 189#define HVM_TRAP1_VMWAIT                16
 190#define HVM_TRAP1_VMYIELD               17
 191#define HVM_TRAP1_VMSTART               18
 192#define HVM_TRAP1_VMSTOP                19
 193#define HVM_TRAP1_VMVPID                20
 194#define HVM_TRAP1_VMSETREGS             21
 195#define HVM_TRAP1_VMGETREGS             22
 196
 197#endif /* __ASSEMBLY__ */
 198
 199/*
 200 * Constants for virtual instruction parameters and return values
 201 */
 202
 203/* vmsetie arguments */
 204
 205#define VM_INT_DISABLE  0
 206#define VM_INT_ENABLE   1
 207
 208/* vmsetimask arguments */
 209
 210#define VM_INT_UNMASK   0
 211#define VM_INT_MASK     1
 212
 213#define VM_NEWMAP_TYPE_LINEAR   0
 214#define VM_NEWMAP_TYPE_PGTABLES 1
 215
 216
 217/*
 218 * Event Record definitions useful to both C and Assembler
 219 */
 220
 221/* VMEST Layout */
 222
 223#define HVM_VMEST_UM_SFT        31
 224#define HVM_VMEST_UM_MSK        1
 225#define HVM_VMEST_IE_SFT        30
 226#define HVM_VMEST_IE_MSK        1
 227#define HVM_VMEST_EVENTNUM_SFT  16
 228#define HVM_VMEST_EVENTNUM_MSK  0xff
 229#define HVM_VMEST_CAUSE_SFT     0
 230#define HVM_VMEST_CAUSE_MSK     0xffff
 231
 232/*
 233 * The initial program gets to find a system environment descriptor
 234 * on its stack when it begins exection. The first word is a version
 235 * code to indicate what is there.  Zero means nothing more.
 236 */
 237
 238#define HEXAGON_VM_SED_NULL     0
 239
 240/*
 241 * Event numbers for vector binding
 242 */
 243
 244#define HVM_EV_RESET            0
 245#define HVM_EV_MACHCHECK        1
 246#define HVM_EV_GENEX            2
 247#define HVM_EV_TRAP             8
 248#define HVM_EV_INTR             15
 249/* These shoud be nuked as soon as we know the VM is up to spec v0.1.1 */
 250#define HVM_EV_INTR_0           16
 251#define HVM_MAX_INTR            240
 252
 253/*
 254 * Cause values for General Exception
 255 */
 256
 257#define HVM_GE_C_BUS    0x01
 258#define HVM_GE_C_XPROT  0x11
 259#define HVM_GE_C_XUSER  0x14
 260#define HVM_GE_C_INVI   0x15
 261#define HVM_GE_C_PRIVI  0x1B
 262#define HVM_GE_C_XMAL   0x1C
 263#define HVM_GE_C_RMAL   0x20
 264#define HVM_GE_C_WMAL   0x21
 265#define HVM_GE_C_RPROT  0x22
 266#define HVM_GE_C_WPROT  0x23
 267#define HVM_GE_C_RUSER  0x24
 268#define HVM_GE_C_WUSER  0x25
 269#define HVM_GE_C_CACHE  0x28
 270
 271/*
 272 * Cause codes for Machine Check
 273 */
 274
 275#define HVM_MCHK_C_DOWN         0x00
 276#define HVM_MCHK_C_BADSP        0x01
 277#define HVM_MCHK_C_BADEX        0x02
 278#define HVM_MCHK_C_BADPT        0x03
 279#define HVM_MCHK_C_REGWR        0x29
 280
 281#endif
 282