summaryrefslogtreecommitdiff
path: root/cros_ec/include/ec_common.h
blob: 1a409585092d8caf504c8af4ee177bfa1bb1f8a0 (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
39
40
41
42
43
44
45
46
47
48
49
/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/* ec_common.h - Common includes for Chrome EC */

#ifndef __CROS_EC_COMMON_H
#define __CROS_EC_COMMON_H

#include <stdint.h>
#include <stdio.h>  /* FIXME: will be removed for portibility in the future */

/* Functions which return error return one of these.  This is an
 * integer instead of an enum to support module-internal error
 * codes. */
typedef int EcError;

/* List of common EcError codes that can be returned */
enum EcErrorList {
  /* Success - no error */
  EC_SUCCESS = 0,
  /* Unknown error */
  EC_ERROR_UNKNOWN = 1,
  /* Function not implemented yet */
  EC_ERROR_UNIMPLEMENTED = 2,
  /* Overflow error; too much input provided. */
  EC_ERROR_OVERFLOW = 3,
  /* Timeout */
  EC_ERROR_TIMEOUT = 4,

  /* Module-internal error codes may use this range.   */
  EC_ERROR_INTERNAL_FIRST = 0x10000,
  EC_ERROR_INTERNAL_LAST =  0x1FFFF
};


/* TODO: move to a proper .h file */
#define PRINTF(fmt, ...) printf(fmt, __VA_ARGS__)

/* TODO: move to a proper .h file */
#define ASSERT(expr) do { \
      if (!(expr)) {  \
        PRINTF("ASSERT(%s) failed at file %s:%d.\n", \
               #expr, __FILE__, __LINE__);  \
      }  \
    } while (0)

#endif  /* __CROS_EC_COMMON_H */