github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/include/cli_env.h (about)

     1  /*
     2   * Copyright (c) 2013 Intel Corporation
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *     http://www.apache.org/licenses/LICENSE-2.0
     8   * Unless required by applicable law or agreed to in writing, software
     9   * distributed under the License is distributed on an "AS IS" BASIS,
    10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11   * See the License for the specific language governing permissions and
    12   * limitations under the License.
    13   */
    14  
    15  #ifndef _CLI_ENV_H_
    16  #define _CLI_ENV_H_
    17  
    18  #ifdef CLI_INCLUDE
    19  #define CLI_CODE(__xxx) __xxx
    20  #else
    21  #define CLI_CODE(__xxx)
    22  #endif
    23  
    24  #include "vmm_defs.h"
    25  #include "cli_libc.h"
    26  #include "memory_allocator.h"
    27  #include "lock.h"
    28  #include "hw_utils.h"
    29  #include "vt100.h"
    30  
    31  #define STRING_PRINT_FORMAT                         "s"
    32  #define CLI_MEMFREE(__buffer)
    33  #define CLI_MEMALLOC(__bytes)                       vmm_malloc(__bytes)
    34  
    35  #define CLI_READ_CHAR   vt100_getch
    36  #define CLI_PRINT_CHAR  vt100_putch
    37  #define CLI_FLUSH_INPUT vt100_flush_input
    38  
    39  
    40  #define CLI_PRINT(...)                              VMM_LOG(mask_cli, level_print_always, __VA_ARGS__)
    41  #define CLI_STRLEN(__string)                        vmm_strlen(__string)
    42  #define CLI_STRCMP(__string1, __string2)            CLI_strcmp(__string1, __string2)
    43  #define CLI_STRNCMP(__string1, __string2, __n)      CLI_strncmp(__string1, __string2, __n)
    44  #define CLI_MEMSET(__buffer, __filler, __size)      vmm_memset(__buffer, __filler, __size)
    45  #define CLI_MEMCPY(__dst, __src, __size)            vmm_memcpy(__dst, __src, __size)
    46  
    47  #define CLI_ATOL(__string)                                                     \
    48      ((__string[0] == '0' && (__string[1] == 'x' || __string[1] == 'X')) ?      \
    49      CLI_atol32(__string + 2, 16, NULL) :                                       \
    50      CLI_atol32(__string, 10, NULL))
    51  
    52  #define CLI_ATOL64(__string)                                                   \
    53      ((__string[0] == '0' && (__string[1] == 'x' || __string[1] == 'X')) ?      \
    54      CLI_atol64(__string + 2, 16, NULL) :                                       \
    55      CLI_atol64(__string, 10, NULL))
    56  #define CLI_GET_CPU_ID()                            hw_cpu_id()
    57  #define CLI_IS_SUBSTR(__bigstring, __smallstring)   CLI_is_substr(__bigstring, __smallstring)
    58  
    59  
    60  typedef enum  {
    61      LED_KEY_CR      = VT100_KEY_CR,
    62      LED_KEY_LN      = VT100_KEY_LN,
    63      LED_KEY_ABORT   = VT100_KEY_ABORT,
    64      LED_KEY_UP      = VT100_KEY_UP,
    65      LED_KEY_DOWN    = VT100_KEY_DOWN,
    66      LED_KEY_LEFT    = VT100_KEY_LEFT,
    67      LED_KEY_RIGHT   = VT100_KEY_RIGHT,
    68      LED_KEY_HOME    = VT100_KEY_HOME,
    69      LED_KEY_END     = VT100_KEY_END,
    70      LED_KEY_DELETE  = VT100_KEY_DELETE,
    71      LED_KEY_RUBOUT  = VT100_KEY_RUBOUT,
    72      LED_KEY_INSERT  = VT100_KEY_INSERT
    73  } CTRL_KEY;
    74  
    75  
    76  
    77  // locks
    78  #define CLI_LOCK                                    VMM_LOCK
    79  #define CLI_LOCK_INIT                               lock_initialize
    80  #define CLI_LOCK_ACQUIRE                            interruptible_lock_acquire
    81  #define CLI_LOCK_RELEASE                            lock_release
    82  
    83  
    84  // Note, CLI_ACCESS_LEVELs must be powers of 2
    85  #define CLI_ACCESS_LEVEL_SYSTEM     0x00000001
    86  #define CLI_ACCESS_LEVEL_USER       0x00000002
    87  
    88  #endif // _CLI_ENV_H_