These changes are the raw update to qemu-2.6.
[kvmfornfv.git] / qemu / roms / SLOF / lib / libhvcall / rfill.c
1 /*****************************************************************************
2  * Fast function for filling cache-inhibited memory regions via h-call.
3  *
4  * Copyright 2015 Red Hat, Inc.
5  *
6  * This program and the accompanying materials
7  * are made available under the terms of the BSD License
8  * which accompanies this distribution, and is available at
9  * http://www.opensource.org/licenses/bsd-license.php
10  *
11  * Contributors:
12  *     Thomas Huth, Red Hat Inc. - initial implementation
13  *****************************************************************************/
14
15 #include <cache.h>
16 #include <string.h>
17
18 typedef unsigned long type_u;
19
20 /**
21  * fast_rfill is the implementation of the FAST_RFILL macro with h-calls.
22  * This is defined here instead of cache.h since we need a temporary
23  * local buffer - and that caused stack size problems in engine() when
24  * we used it directly in the FAST_RFILL macro.
25  */
26 void fast_rfill(char *dst, long size, char pat)
27 {
28         type_u buf[64];
29
30         memset(buf, pat, size < sizeof(buf) ? size : sizeof(buf));
31
32         while (size > sizeof(buf)) {
33                 FAST_MRMOVE(buf, dst, sizeof(buf));
34                 dst += sizeof(buf);
35                 size -= sizeof(buf);
36         }
37         FAST_MRMOVE(buf, dst, size);
38 }