函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:arch\x86\include\asm\io.h Create Date:2022-07-27 06:46:56
首页 Copyright©Brick

271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
#endif /* CONFIG_AMD_MEM_ENCRYPT */
 
#define BUILDIO(bwl, bw, type)                      \
static inline void out##bwl(unsigned type value, int port)      \
{                                   \
    asm volatile("out" #bwl " %" #bw "0, %w1"           \
             : : "a"(value), "Nd"(port));           \
}                                   \
                                    \
static inline unsigned type in##bwl(int port)               \
{                                   \
    unsigned type value;                        \
    asm volatile("in" #bwl " %w1, %" #bw "0"            \
             : "=a"(value) : "Nd"(port));           \
    return value;                           \
}                                   \
                                    \
static inline void out##bwl##_p(unsigned type value, int port)      \
{                                   \
    out##bwl(value, port);                      \
    slow_down_io();                         \
}                                   \
                                    \
static inline unsigned type in##bwl##_p(int port)           \
{                                   \
    unsigned type value = in##bwl(port);                \
    slow_down_io();                         \
    return value;                           \
}                                   \
                                    \
static inline void outs##bwl(int port, const void *addr, unsigned long count) \
{                                   \
    if (sev_key_active()) {                     \
        unsigned type *value = (unsigned type *)addr;       \
        while (count) {                     \
            out##bwl(*value, port);             \
            value++;                    \
            count--;                    \
        }                           \
    } else {                            \
        asm volatile("rep; outs" #bwl               \
                 : "+S"(addr), "+c"(count)          \
                 : "d"(port) : "memory");           \
    }                               \
}                                   \
                                    \
static inline void ins##bwl(int port, void *addr, unsigned long count)  \
{                                   \
    if (sev_key_active()) {                     \
        unsigned type *value = (unsigned type *)addr;       \
        while (count) {                     \
            *value = in##bwl(port);             \
            value++;                    \
            count--;                    \
        }                           \
    } else {                            \
        asm volatile("rep; ins" #bwl                \
                 : "+D"(addr), "+c"(count)          \
                 : "d"(port) : "memory");           \
    }                               \
}
 
BUILDIO(b, b, char)