Branch data Line data Source code
1 : : // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
2 : : /*
3 : : * Stubs for libflash test
4 : : *
5 : : * Copyright 2013-2018 IBM Corp.
6 : : */
7 : :
8 : : #include <stdbool.h>
9 : : #include <stdio.h>
10 : : #include <stdlib.h>
11 : : #include <stdint.h>
12 : : #include <string.h>
13 : : #include <stdarg.h>
14 : : #include <sys/unistd.h> /* for usleep */
15 : :
16 : : #include "../../include/lpc-mbox.h"
17 : : #include "stubs.h"
18 : :
19 : : #define __unused __attribute__((unused))
20 : :
21 : 0 : __attribute__((weak)) void check_timers(bool __unused unused)
22 : : {
23 : 0 : return;
24 : : }
25 : :
26 : 0 : void time_wait_ms(unsigned long ms)
27 : : {
28 : 0 : usleep(ms * 1000);
29 : 0 : }
30 : :
31 : : /* skiboot stubs */
32 : 1888 : unsigned long mftb(void)
33 : : {
34 : 1888 : return 42;
35 : : }
36 : : unsigned long tb_hz = 512000000ul;
37 : :
38 : 6159 : void _prlog(int __unused log_level, const char* fmt, ...)
39 : : {
40 : : va_list ap;
41 : :
42 : 6159 : va_start(ap, fmt);
43 : 6159 : vprintf(fmt, ap);
44 : 6159 : va_end(ap);
45 : 6159 : }
46 : :
47 : : /* accessor junk */
48 : :
49 : 2201 : void bmc_put_u16(struct bmc_mbox_msg *msg, int offset, uint16_t data)
50 : : {
51 : 2201 : msg->args[offset + 0] = data & 0xff;
52 : 2201 : msg->args[offset + 1] = data >> 8;
53 : 2201 : }
54 : :
55 : 2 : void bmc_put_u32(struct bmc_mbox_msg *msg, int offset, uint32_t data)
56 : : {
57 : 2 : msg->args[offset + 0] = (data) & 0xff;
58 : 2 : msg->args[offset + 1] = (data >> 8) & 0xff;
59 : 2 : msg->args[offset + 2] = (data >> 16) & 0xff;
60 : 2 : msg->args[offset + 3] = (data >> 24) & 0xff;
61 : 2 : }
62 : :
63 : 48 : u32 bmc_get_u32(struct bmc_mbox_msg *msg, int offset)
64 : : {
65 : 48 : u32 data = 0;
66 : :
67 : 48 : data |= msg->args[offset + 0];
68 : 48 : data |= msg->args[offset + 1] << 8;
69 : 48 : data |= msg->args[offset + 2] << 16;
70 : 48 : data |= msg->args[offset + 3] << 24;
71 : :
72 : 48 : return data;
73 : : }
74 : :
75 : 1666 : u16 bmc_get_u16(struct bmc_mbox_msg *msg, int offset)
76 : : {
77 : 1666 : u16 data = 0;
78 : :
79 : 1666 : data |= msg->args[offset + 0];
80 : 1666 : data |= msg->args[offset + 1] << 8;
81 : :
82 : 1666 : return data;
83 : : }
84 : :
85 : 57 : void *__zalloc(size_t sz)
86 : : {
87 : 57 : return calloc(1, sz);
88 : : }
89 : :
90 : 57 : void __free(const void *p)
91 : : {
92 : 57 : free((void *)p);
93 : 57 : }
94 : :
95 : 635 : void lock_caller(struct lock *l __attribute__((unused)),
96 : : const char *caller __attribute__((unused)))
97 : : {
98 : 635 : }
99 : :
100 : 635 : void unlock(struct lock *l __attribute__((unused)))
101 : : {
102 : 635 : }
|