3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
11 #include <linux/stddef.h>
12 #include <linux/kernel.h>
14 #include <linux/slab.h>
15 #include <asm/system.h>
17 #include <asm/iSeries/HvCall.h>
19 #include <asm/iSeries/HvCallSc.h>
21 #include <asm/iSeries/LparData.h>
24 #include <asm/iSeries/HvTypes.h>
28 /*=====================================================================
29 * Note that this call takes at MOST one page worth of data
31 int HvCall_readLogBuffer(HvLpIndex lpIndex, void *buffer, u64 bufLen)
33 struct HvLpBufferList *bufList;
34 u64 bytesLeft = bufLen;
36 u64 curPtr = virt_to_absolute( (unsigned long) buffer );
44 leftThisPage = ((curPtr & PAGE_MASK) + PAGE_SIZE) - curPtr;
46 if (leftThisPage > bytesLeft)
49 bytesLeft -= leftThisPage;
51 curPtr = (curPtr & PAGE_MASK) + PAGE_SIZE;
57 bufList = (struct HvLpBufferList *)
58 kmalloc(npages * sizeof(struct HvLpBufferList), GFP_ATOMIC);
60 curPtr = virt_to_absolute( (unsigned long) buffer );
61 for(i=0; i<npages; i++) {
62 bufList[i].addr = curPtr;
64 leftThisPage = ((curPtr & PAGE_MASK) + PAGE_SIZE) - curPtr;
66 if (leftThisPage > bytesLeft) {
67 bufList[i].len = bytesLeft;
70 bufList[i].len = leftThisPage;
71 bytesLeft -= leftThisPage;
74 curPtr = (curPtr & PAGE_MASK) + PAGE_SIZE;
78 retVal = HvCall3(HvCallBaseReadLogBuffer, lpIndex,
79 virt_to_absolute((unsigned long)bufList), bufLen);
86 /*=====================================================================
88 void HvCall_writeLogBuffer(const void *buffer, u64 bufLen)
90 struct HvLpBufferList bufList;
91 u64 bytesLeft = bufLen;
93 u64 curPtr = virt_to_absolute((unsigned long) buffer);
96 bufList.addr = curPtr;
98 leftThisPage = ((curPtr & PAGE_MASK) + PAGE_SIZE) - curPtr;
100 if (leftThisPage > bytesLeft) {
101 bufList.len = bytesLeft;
104 bufList.len = leftThisPage;
105 bytesLeft -= leftThisPage;
109 HvCall2(HvCallBaseWriteLogBuffer,
110 virt_to_absolute((unsigned long) &bufList),
113 curPtr = (curPtr & PAGE_MASK) + PAGE_SIZE;