mf.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283
  1. /*
  2. * mf.c
  3. * Copyright (C) 2001 Troy D. Armstrong IBM Corporation
  4. * Copyright (C) 2004-2005 Stephen Rothwell IBM Corporation
  5. *
  6. * This modules exists as an interface between a Linux secondary partition
  7. * running on an iSeries and the primary partition's Virtual Service
  8. * Processor (VSP) object. The VSP has final authority over powering on/off
  9. * all partitions in the iSeries. It also provides miscellaneous low-level
  10. * machine facility type operations.
  11. *
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26. */
  27. #include <linux/types.h>
  28. #include <linux/errno.h>
  29. #include <linux/kernel.h>
  30. #include <linux/init.h>
  31. #include <linux/completion.h>
  32. #include <linux/delay.h>
  33. #include <linux/dma-mapping.h>
  34. #include <linux/bcd.h>
  35. #include <asm/time.h>
  36. #include <asm/uaccess.h>
  37. #include <asm/paca.h>
  38. #include <asm/iSeries/vio.h>
  39. #include <asm/iSeries/mf.h>
  40. #include <asm/iSeries/HvLpConfig.h>
  41. #include <asm/iSeries/ItLpQueue.h>
  42. /*
  43. * This is the structure layout for the Machine Facilites LPAR event
  44. * flows.
  45. */
  46. struct vsp_cmd_data {
  47. u64 token;
  48. u16 cmd;
  49. HvLpIndex lp_index;
  50. u8 result_code;
  51. u32 reserved;
  52. union {
  53. u64 state; /* GetStateOut */
  54. u64 ipl_type; /* GetIplTypeOut, Function02SelectIplTypeIn */
  55. u64 ipl_mode; /* GetIplModeOut, Function02SelectIplModeIn */
  56. u64 page[4]; /* GetSrcHistoryIn */
  57. u64 flag; /* GetAutoIplWhenPrimaryIplsOut,
  58. SetAutoIplWhenPrimaryIplsIn,
  59. WhiteButtonPowerOffIn,
  60. Function08FastPowerOffIn,
  61. IsSpcnRackPowerIncompleteOut */
  62. struct {
  63. u64 token;
  64. u64 address_type;
  65. u64 side;
  66. u32 length;
  67. u32 offset;
  68. } kern; /* SetKernelImageIn, GetKernelImageIn,
  69. SetKernelCmdLineIn, GetKernelCmdLineIn */
  70. u32 length_out; /* GetKernelImageOut, GetKernelCmdLineOut */
  71. u8 reserved[80];
  72. } sub_data;
  73. };
  74. struct vsp_rsp_data {
  75. struct completion com;
  76. struct vsp_cmd_data *response;
  77. };
  78. struct alloc_data {
  79. u16 size;
  80. u16 type;
  81. u32 count;
  82. u16 reserved1;
  83. u8 reserved2;
  84. HvLpIndex target_lp;
  85. };
  86. struct ce_msg_data;
  87. typedef void (*ce_msg_comp_hdlr)(void *token, struct ce_msg_data *vsp_cmd_rsp);
  88. struct ce_msg_comp_data {
  89. ce_msg_comp_hdlr handler;
  90. void *token;
  91. };
  92. struct ce_msg_data {
  93. u8 ce_msg[12];
  94. char reserved[4];
  95. struct ce_msg_comp_data *completion;
  96. };
  97. struct io_mf_lp_event {
  98. struct HvLpEvent hp_lp_event;
  99. u16 subtype_result_code;
  100. u16 reserved1;
  101. u32 reserved2;
  102. union {
  103. struct alloc_data alloc;
  104. struct ce_msg_data ce_msg;
  105. struct vsp_cmd_data vsp_cmd;
  106. } data;
  107. };
  108. #define subtype_data(a, b, c, d) \
  109. (((a) << 24) + ((b) << 16) + ((c) << 8) + (d))
  110. /*
  111. * All outgoing event traffic is kept on a FIFO queue. The first
  112. * pointer points to the one that is outstanding, and all new
  113. * requests get stuck on the end. Also, we keep a certain number of
  114. * preallocated pending events so that we can operate very early in
  115. * the boot up sequence (before kmalloc is ready).
  116. */
  117. struct pending_event {
  118. struct pending_event *next;
  119. struct io_mf_lp_event event;
  120. MFCompleteHandler hdlr;
  121. char dma_data[72];
  122. unsigned dma_data_length;
  123. unsigned remote_address;
  124. };
  125. static spinlock_t pending_event_spinlock;
  126. static struct pending_event *pending_event_head;
  127. static struct pending_event *pending_event_tail;
  128. static struct pending_event *pending_event_avail;
  129. static struct pending_event pending_event_prealloc[16];
  130. /*
  131. * Put a pending event onto the available queue, so it can get reused.
  132. * Attention! You must have the pending_event_spinlock before calling!
  133. */
  134. static void free_pending_event(struct pending_event *ev)
  135. {
  136. if (ev != NULL) {
  137. ev->next = pending_event_avail;
  138. pending_event_avail = ev;
  139. }
  140. }
  141. /*
  142. * Enqueue the outbound event onto the stack. If the queue was
  143. * empty to begin with, we must also issue it via the Hypervisor
  144. * interface. There is a section of code below that will touch
  145. * the first stack pointer without the protection of the pending_event_spinlock.
  146. * This is OK, because we know that nobody else will be modifying
  147. * the first pointer when we do this.
  148. */
  149. static int signal_event(struct pending_event *ev)
  150. {
  151. int rc = 0;
  152. unsigned long flags;
  153. int go = 1;
  154. struct pending_event *ev1;
  155. HvLpEvent_Rc hv_rc;
  156. /* enqueue the event */
  157. if (ev != NULL) {
  158. ev->next = NULL;
  159. spin_lock_irqsave(&pending_event_spinlock, flags);
  160. if (pending_event_head == NULL)
  161. pending_event_head = ev;
  162. else {
  163. go = 0;
  164. pending_event_tail->next = ev;
  165. }
  166. pending_event_tail = ev;
  167. spin_unlock_irqrestore(&pending_event_spinlock, flags);
  168. }
  169. /* send the event */
  170. while (go) {
  171. go = 0;
  172. /* any DMA data to send beforehand? */
  173. if (pending_event_head->dma_data_length > 0)
  174. HvCallEvent_dmaToSp(pending_event_head->dma_data,
  175. pending_event_head->remote_address,
  176. pending_event_head->dma_data_length,
  177. HvLpDma_Direction_LocalToRemote);
  178. hv_rc = HvCallEvent_signalLpEvent(
  179. &pending_event_head->event.hp_lp_event);
  180. if (hv_rc != HvLpEvent_Rc_Good) {
  181. printk(KERN_ERR "mf.c: HvCallEvent_signalLpEvent() "
  182. "failed with %d\n", (int)hv_rc);
  183. spin_lock_irqsave(&pending_event_spinlock, flags);
  184. ev1 = pending_event_head;
  185. pending_event_head = pending_event_head->next;
  186. if (pending_event_head != NULL)
  187. go = 1;
  188. spin_unlock_irqrestore(&pending_event_spinlock, flags);
  189. if (ev1 == ev)
  190. rc = -EIO;
  191. else if (ev1->hdlr != NULL)
  192. (*ev1->hdlr)((void *)ev1->event.hp_lp_event.xCorrelationToken, -EIO);
  193. spin_lock_irqsave(&pending_event_spinlock, flags);
  194. free_pending_event(ev1);
  195. spin_unlock_irqrestore(&pending_event_spinlock, flags);
  196. }
  197. }
  198. return rc;
  199. }
  200. /*
  201. * Allocate a new pending_event structure, and initialize it.
  202. */
  203. static struct pending_event *new_pending_event(void)
  204. {
  205. struct pending_event *ev = NULL;
  206. HvLpIndex primary_lp = HvLpConfig_getPrimaryLpIndex();
  207. unsigned long flags;
  208. struct HvLpEvent *hev;
  209. spin_lock_irqsave(&pending_event_spinlock, flags);
  210. if (pending_event_avail != NULL) {
  211. ev = pending_event_avail;
  212. pending_event_avail = pending_event_avail->next;
  213. }
  214. spin_unlock_irqrestore(&pending_event_spinlock, flags);
  215. if (ev == NULL) {
  216. ev = kmalloc(sizeof(struct pending_event), GFP_ATOMIC);
  217. if (ev == NULL) {
  218. printk(KERN_ERR "mf.c: unable to kmalloc %ld bytes\n",
  219. sizeof(struct pending_event));
  220. return NULL;
  221. }
  222. }
  223. memset(ev, 0, sizeof(struct pending_event));
  224. hev = &ev->event.hp_lp_event;
  225. hev->xFlags.xValid = 1;
  226. hev->xFlags.xAckType = HvLpEvent_AckType_ImmediateAck;
  227. hev->xFlags.xAckInd = HvLpEvent_AckInd_DoAck;
  228. hev->xFlags.xFunction = HvLpEvent_Function_Int;
  229. hev->xType = HvLpEvent_Type_MachineFac;
  230. hev->xSourceLp = HvLpConfig_getLpIndex();
  231. hev->xTargetLp = primary_lp;
  232. hev->xSizeMinus1 = sizeof(ev->event) - 1;
  233. hev->xRc = HvLpEvent_Rc_Good;
  234. hev->xSourceInstanceId = HvCallEvent_getSourceLpInstanceId(primary_lp,
  235. HvLpEvent_Type_MachineFac);
  236. hev->xTargetInstanceId = HvCallEvent_getTargetLpInstanceId(primary_lp,
  237. HvLpEvent_Type_MachineFac);
  238. return ev;
  239. }
  240. static int signal_vsp_instruction(struct vsp_cmd_data *vsp_cmd)
  241. {
  242. struct pending_event *ev = new_pending_event();
  243. int rc;
  244. struct vsp_rsp_data response;
  245. if (ev == NULL)
  246. return -ENOMEM;
  247. init_completion(&response.com);
  248. response.response = vsp_cmd;
  249. ev->event.hp_lp_event.xSubtype = 6;
  250. ev->event.hp_lp_event.x.xSubtypeData =
  251. subtype_data('M', 'F', 'V', 'I');
  252. ev->event.data.vsp_cmd.token = (u64)&response;
  253. ev->event.data.vsp_cmd.cmd = vsp_cmd->cmd;
  254. ev->event.data.vsp_cmd.lp_index = HvLpConfig_getLpIndex();
  255. ev->event.data.vsp_cmd.result_code = 0xFF;
  256. ev->event.data.vsp_cmd.reserved = 0;
  257. memcpy(&(ev->event.data.vsp_cmd.sub_data),
  258. &(vsp_cmd->sub_data), sizeof(vsp_cmd->sub_data));
  259. mb();
  260. rc = signal_event(ev);
  261. if (rc == 0)
  262. wait_for_completion(&response.com);
  263. return rc;
  264. }
  265. /*
  266. * Send a 12-byte CE message to the primary partition VSP object
  267. */
  268. static int signal_ce_msg(char *ce_msg, struct ce_msg_comp_data *completion)
  269. {
  270. struct pending_event *ev = new_pending_event();
  271. if (ev == NULL)
  272. return -ENOMEM;
  273. ev->event.hp_lp_event.xSubtype = 0;
  274. ev->event.hp_lp_event.x.xSubtypeData =
  275. subtype_data('M', 'F', 'C', 'E');
  276. memcpy(ev->event.data.ce_msg.ce_msg, ce_msg, 12);
  277. ev->event.data.ce_msg.completion = completion;
  278. return signal_event(ev);
  279. }
  280. /*
  281. * Send a 12-byte CE message (with no data) to the primary partition VSP object
  282. */
  283. static int signal_ce_msg_simple(u8 ce_op, struct ce_msg_comp_data *completion)
  284. {
  285. u8 ce_msg[12];
  286. memset(ce_msg, 0, sizeof(ce_msg));
  287. ce_msg[3] = ce_op;
  288. return signal_ce_msg(ce_msg, completion);
  289. }
  290. /*
  291. * Send a 12-byte CE message and DMA data to the primary partition VSP object
  292. */
  293. static int dma_and_signal_ce_msg(char *ce_msg,
  294. struct ce_msg_comp_data *completion, void *dma_data,
  295. unsigned dma_data_length, unsigned remote_address)
  296. {
  297. struct pending_event *ev = new_pending_event();
  298. if (ev == NULL)
  299. return -ENOMEM;
  300. ev->event.hp_lp_event.xSubtype = 0;
  301. ev->event.hp_lp_event.x.xSubtypeData =
  302. subtype_data('M', 'F', 'C', 'E');
  303. memcpy(ev->event.data.ce_msg.ce_msg, ce_msg, 12);
  304. ev->event.data.ce_msg.completion = completion;
  305. memcpy(ev->dma_data, dma_data, dma_data_length);
  306. ev->dma_data_length = dma_data_length;
  307. ev->remote_address = remote_address;
  308. return signal_event(ev);
  309. }
  310. /*
  311. * Initiate a nice (hopefully) shutdown of Linux. We simply are
  312. * going to try and send the init process a SIGINT signal. If
  313. * this fails (why?), we'll simply force it off in a not-so-nice
  314. * manner.
  315. */
  316. static int shutdown(void)
  317. {
  318. int rc = kill_proc(1, SIGINT, 1);
  319. if (rc) {
  320. printk(KERN_ALERT "mf.c: SIGINT to init failed (%d), "
  321. "hard shutdown commencing\n", rc);
  322. mf_power_off();
  323. } else
  324. printk(KERN_INFO "mf.c: init has been successfully notified "
  325. "to proceed with shutdown\n");
  326. return rc;
  327. }
  328. /*
  329. * The primary partition VSP object is sending us a new
  330. * event flow. Handle it...
  331. */
  332. static void handle_int(struct io_mf_lp_event *event)
  333. {
  334. struct ce_msg_data *ce_msg_data;
  335. struct ce_msg_data *pce_msg_data;
  336. unsigned long flags;
  337. struct pending_event *pev;
  338. /* ack the interrupt */
  339. event->hp_lp_event.xRc = HvLpEvent_Rc_Good;
  340. HvCallEvent_ackLpEvent(&event->hp_lp_event);
  341. /* process interrupt */
  342. switch (event->hp_lp_event.xSubtype) {
  343. case 0: /* CE message */
  344. ce_msg_data = &event->data.ce_msg;
  345. switch (ce_msg_data->ce_msg[3]) {
  346. case 0x5B: /* power control notification */
  347. if ((ce_msg_data->ce_msg[5] & 0x20) != 0) {
  348. printk(KERN_INFO "mf.c: Commencing partition shutdown\n");
  349. if (shutdown() == 0)
  350. signal_ce_msg_simple(0xDB, NULL);
  351. }
  352. break;
  353. case 0xC0: /* get time */
  354. spin_lock_irqsave(&pending_event_spinlock, flags);
  355. pev = pending_event_head;
  356. if (pev != NULL)
  357. pending_event_head = pending_event_head->next;
  358. spin_unlock_irqrestore(&pending_event_spinlock, flags);
  359. if (pev == NULL)
  360. break;
  361. pce_msg_data = &pev->event.data.ce_msg;
  362. if (pce_msg_data->ce_msg[3] != 0x40)
  363. break;
  364. if (pce_msg_data->completion != NULL) {
  365. ce_msg_comp_hdlr handler =
  366. pce_msg_data->completion->handler;
  367. void *token = pce_msg_data->completion->token;
  368. if (handler != NULL)
  369. (*handler)(token, ce_msg_data);
  370. }
  371. spin_lock_irqsave(&pending_event_spinlock, flags);
  372. free_pending_event(pev);
  373. spin_unlock_irqrestore(&pending_event_spinlock, flags);
  374. /* send next waiting event */
  375. if (pending_event_head != NULL)
  376. signal_event(NULL);
  377. break;
  378. }
  379. break;
  380. case 1: /* IT sys shutdown */
  381. printk(KERN_INFO "mf.c: Commencing system shutdown\n");
  382. shutdown();
  383. break;
  384. }
  385. }
  386. /*
  387. * The primary partition VSP object is acknowledging the receipt
  388. * of a flow we sent to them. If there are other flows queued
  389. * up, we must send another one now...
  390. */
  391. static void handle_ack(struct io_mf_lp_event *event)
  392. {
  393. unsigned long flags;
  394. struct pending_event *two = NULL;
  395. unsigned long free_it = 0;
  396. struct ce_msg_data *ce_msg_data;
  397. struct ce_msg_data *pce_msg_data;
  398. struct vsp_rsp_data *rsp;
  399. /* handle current event */
  400. if (pending_event_head == NULL) {
  401. printk(KERN_ERR "mf.c: stack empty for receiving ack\n");
  402. return;
  403. }
  404. switch (event->hp_lp_event.xSubtype) {
  405. case 0: /* CE msg */
  406. ce_msg_data = &event->data.ce_msg;
  407. if (ce_msg_data->ce_msg[3] != 0x40) {
  408. free_it = 1;
  409. break;
  410. }
  411. if (ce_msg_data->ce_msg[2] == 0)
  412. break;
  413. free_it = 1;
  414. pce_msg_data = &pending_event_head->event.data.ce_msg;
  415. if (pce_msg_data->completion != NULL) {
  416. ce_msg_comp_hdlr handler =
  417. pce_msg_data->completion->handler;
  418. void *token = pce_msg_data->completion->token;
  419. if (handler != NULL)
  420. (*handler)(token, ce_msg_data);
  421. }
  422. break;
  423. case 4: /* allocate */
  424. case 5: /* deallocate */
  425. if (pending_event_head->hdlr != NULL)
  426. (*pending_event_head->hdlr)((void *)event->hp_lp_event.xCorrelationToken, event->data.alloc.count);
  427. free_it = 1;
  428. break;
  429. case 6:
  430. free_it = 1;
  431. rsp = (struct vsp_rsp_data *)event->data.vsp_cmd.token;
  432. if (rsp == NULL) {
  433. printk(KERN_ERR "mf.c: no rsp\n");
  434. break;
  435. }
  436. if (rsp->response != NULL)
  437. memcpy(rsp->response, &event->data.vsp_cmd,
  438. sizeof(event->data.vsp_cmd));
  439. complete(&rsp->com);
  440. break;
  441. }
  442. /* remove from queue */
  443. spin_lock_irqsave(&pending_event_spinlock, flags);
  444. if ((pending_event_head != NULL) && (free_it == 1)) {
  445. struct pending_event *oldHead = pending_event_head;
  446. pending_event_head = pending_event_head->next;
  447. two = pending_event_head;
  448. free_pending_event(oldHead);
  449. }
  450. spin_unlock_irqrestore(&pending_event_spinlock, flags);
  451. /* send next waiting event */
  452. if (two != NULL)
  453. signal_event(NULL);
  454. }
  455. /*
  456. * This is the generic event handler we are registering with
  457. * the Hypervisor. Ensure the flows are for us, and then
  458. * parse it enough to know if it is an interrupt or an
  459. * acknowledge.
  460. */
  461. static void hv_handler(struct HvLpEvent *event, struct pt_regs *regs)
  462. {
  463. if ((event != NULL) && (event->xType == HvLpEvent_Type_MachineFac)) {
  464. switch(event->xFlags.xFunction) {
  465. case HvLpEvent_Function_Ack:
  466. handle_ack((struct io_mf_lp_event *)event);
  467. break;
  468. case HvLpEvent_Function_Int:
  469. handle_int((struct io_mf_lp_event *)event);
  470. break;
  471. default:
  472. printk(KERN_ERR "mf.c: non ack/int event received\n");
  473. break;
  474. }
  475. } else
  476. printk(KERN_ERR "mf.c: alien event received\n");
  477. }
  478. /*
  479. * Global kernel interface to allocate and seed events into the
  480. * Hypervisor.
  481. */
  482. void mf_allocate_lp_events(HvLpIndex target_lp, HvLpEvent_Type type,
  483. unsigned size, unsigned count, MFCompleteHandler hdlr,
  484. void *user_token)
  485. {
  486. struct pending_event *ev = new_pending_event();
  487. int rc;
  488. if (ev == NULL) {
  489. rc = -ENOMEM;
  490. } else {
  491. ev->event.hp_lp_event.xSubtype = 4;
  492. ev->event.hp_lp_event.xCorrelationToken = (u64)user_token;
  493. ev->event.hp_lp_event.x.xSubtypeData =
  494. subtype_data('M', 'F', 'M', 'A');
  495. ev->event.data.alloc.target_lp = target_lp;
  496. ev->event.data.alloc.type = type;
  497. ev->event.data.alloc.size = size;
  498. ev->event.data.alloc.count = count;
  499. ev->hdlr = hdlr;
  500. rc = signal_event(ev);
  501. }
  502. if ((rc != 0) && (hdlr != NULL))
  503. (*hdlr)(user_token, rc);
  504. }
  505. EXPORT_SYMBOL(mf_allocate_lp_events);
  506. /*
  507. * Global kernel interface to unseed and deallocate events already in
  508. * Hypervisor.
  509. */
  510. void mf_deallocate_lp_events(HvLpIndex target_lp, HvLpEvent_Type type,
  511. unsigned count, MFCompleteHandler hdlr, void *user_token)
  512. {
  513. struct pending_event *ev = new_pending_event();
  514. int rc;
  515. if (ev == NULL)
  516. rc = -ENOMEM;
  517. else {
  518. ev->event.hp_lp_event.xSubtype = 5;
  519. ev->event.hp_lp_event.xCorrelationToken = (u64)user_token;
  520. ev->event.hp_lp_event.x.xSubtypeData =
  521. subtype_data('M', 'F', 'M', 'D');
  522. ev->event.data.alloc.target_lp = target_lp;
  523. ev->event.data.alloc.type = type;
  524. ev->event.data.alloc.count = count;
  525. ev->hdlr = hdlr;
  526. rc = signal_event(ev);
  527. }
  528. if ((rc != 0) && (hdlr != NULL))
  529. (*hdlr)(user_token, rc);
  530. }
  531. EXPORT_SYMBOL(mf_deallocate_lp_events);
  532. /*
  533. * Global kernel interface to tell the VSP object in the primary
  534. * partition to power this partition off.
  535. */
  536. void mf_power_off(void)
  537. {
  538. printk(KERN_INFO "mf.c: Down it goes...\n");
  539. signal_ce_msg_simple(0x4d, NULL);
  540. for (;;)
  541. ;
  542. }
  543. /*
  544. * Global kernel interface to tell the VSP object in the primary
  545. * partition to reboot this partition.
  546. */
  547. void mf_reboot(void)
  548. {
  549. printk(KERN_INFO "mf.c: Preparing to bounce...\n");
  550. signal_ce_msg_simple(0x4e, NULL);
  551. for (;;)
  552. ;
  553. }
  554. /*
  555. * Display a single word SRC onto the VSP control panel.
  556. */
  557. void mf_display_src(u32 word)
  558. {
  559. u8 ce[12];
  560. memset(ce, 0, sizeof(ce));
  561. ce[3] = 0x4a;
  562. ce[7] = 0x01;
  563. ce[8] = word >> 24;
  564. ce[9] = word >> 16;
  565. ce[10] = word >> 8;
  566. ce[11] = word;
  567. signal_ce_msg(ce, NULL);
  568. }
  569. /*
  570. * Display a single word SRC of the form "PROGXXXX" on the VSP control panel.
  571. */
  572. void mf_display_progress(u16 value)
  573. {
  574. u8 ce[12];
  575. u8 src[72];
  576. memcpy(ce, "\x00\x00\x04\x4A\x00\x00\x00\x48\x00\x00\x00\x00", 12);
  577. memcpy(src, "\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
  578. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  579. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  580. "\x00\x00\x00\x00PROGxxxx ",
  581. 72);
  582. src[6] = value >> 8;
  583. src[7] = value & 255;
  584. src[44] = "0123456789ABCDEF"[(value >> 12) & 15];
  585. src[45] = "0123456789ABCDEF"[(value >> 8) & 15];
  586. src[46] = "0123456789ABCDEF"[(value >> 4) & 15];
  587. src[47] = "0123456789ABCDEF"[value & 15];
  588. dma_and_signal_ce_msg(ce, NULL, src, sizeof(src), 9 * 64 * 1024);
  589. }
  590. /*
  591. * Clear the VSP control panel. Used to "erase" an SRC that was
  592. * previously displayed.
  593. */
  594. void mf_clear_src(void)
  595. {
  596. signal_ce_msg_simple(0x4b, NULL);
  597. }
  598. /*
  599. * Initialization code here.
  600. */
  601. void mf_init(void)
  602. {
  603. int i;
  604. /* initialize */
  605. spin_lock_init(&pending_event_spinlock);
  606. for (i = 0;
  607. i < sizeof(pending_event_prealloc) / sizeof(*pending_event_prealloc);
  608. ++i)
  609. free_pending_event(&pending_event_prealloc[i]);
  610. HvLpEvent_registerHandler(HvLpEvent_Type_MachineFac, &hv_handler);
  611. /* virtual continue ack */
  612. signal_ce_msg_simple(0x57, NULL);
  613. /* initialization complete */
  614. printk(KERN_NOTICE "mf.c: iSeries Linux LPAR Machine Facilities "
  615. "initialized\n");
  616. }
  617. struct rtc_time_data {
  618. struct completion com;
  619. struct ce_msg_data ce_msg;
  620. int rc;
  621. };
  622. static void get_rtc_time_complete(void *token, struct ce_msg_data *ce_msg)
  623. {
  624. struct rtc_time_data *rtc = token;
  625. memcpy(&rtc->ce_msg, ce_msg, sizeof(rtc->ce_msg));
  626. rtc->rc = 0;
  627. complete(&rtc->com);
  628. }
  629. static int rtc_set_tm(int rc, u8 *ce_msg, struct rtc_time *tm)
  630. {
  631. tm->tm_wday = 0;
  632. tm->tm_yday = 0;
  633. tm->tm_isdst = 0;
  634. if (rc) {
  635. tm->tm_sec = 0;
  636. tm->tm_min = 0;
  637. tm->tm_hour = 0;
  638. tm->tm_mday = 15;
  639. tm->tm_mon = 5;
  640. tm->tm_year = 52;
  641. return rc;
  642. }
  643. if ((ce_msg[2] == 0xa9) ||
  644. (ce_msg[2] == 0xaf)) {
  645. /* TOD clock is not set */
  646. tm->tm_sec = 1;
  647. tm->tm_min = 1;
  648. tm->tm_hour = 1;
  649. tm->tm_mday = 10;
  650. tm->tm_mon = 8;
  651. tm->tm_year = 71;
  652. mf_set_rtc(tm);
  653. }
  654. {
  655. u8 year = ce_msg[5];
  656. u8 sec = ce_msg[6];
  657. u8 min = ce_msg[7];
  658. u8 hour = ce_msg[8];
  659. u8 day = ce_msg[10];
  660. u8 mon = ce_msg[11];
  661. BCD_TO_BIN(sec);
  662. BCD_TO_BIN(min);
  663. BCD_TO_BIN(hour);
  664. BCD_TO_BIN(day);
  665. BCD_TO_BIN(mon);
  666. BCD_TO_BIN(year);
  667. if (year <= 69)
  668. year += 100;
  669. tm->tm_sec = sec;
  670. tm->tm_min = min;
  671. tm->tm_hour = hour;
  672. tm->tm_mday = day;
  673. tm->tm_mon = mon;
  674. tm->tm_year = year;
  675. }
  676. return 0;
  677. }
  678. int mf_get_rtc(struct rtc_time *tm)
  679. {
  680. struct ce_msg_comp_data ce_complete;
  681. struct rtc_time_data rtc_data;
  682. int rc;
  683. memset(&ce_complete, 0, sizeof(ce_complete));
  684. memset(&rtc_data, 0, sizeof(rtc_data));
  685. init_completion(&rtc_data.com);
  686. ce_complete.handler = &get_rtc_time_complete;
  687. ce_complete.token = &rtc_data;
  688. rc = signal_ce_msg_simple(0x40, &ce_complete);
  689. if (rc)
  690. return rc;
  691. wait_for_completion(&rtc_data.com);
  692. return rtc_set_tm(rtc_data.rc, rtc_data.ce_msg.ce_msg, tm);
  693. }
  694. struct boot_rtc_time_data {
  695. int busy;
  696. struct ce_msg_data ce_msg;
  697. int rc;
  698. };
  699. static void get_boot_rtc_time_complete(void *token, struct ce_msg_data *ce_msg)
  700. {
  701. struct boot_rtc_time_data *rtc = token;
  702. memcpy(&rtc->ce_msg, ce_msg, sizeof(rtc->ce_msg));
  703. rtc->rc = 0;
  704. rtc->busy = 0;
  705. }
  706. int mf_get_boot_rtc(struct rtc_time *tm)
  707. {
  708. struct ce_msg_comp_data ce_complete;
  709. struct boot_rtc_time_data rtc_data;
  710. int rc;
  711. memset(&ce_complete, 0, sizeof(ce_complete));
  712. memset(&rtc_data, 0, sizeof(rtc_data));
  713. rtc_data.busy = 1;
  714. ce_complete.handler = &get_boot_rtc_time_complete;
  715. ce_complete.token = &rtc_data;
  716. rc = signal_ce_msg_simple(0x40, &ce_complete);
  717. if (rc)
  718. return rc;
  719. /* We need to poll here as we are not yet taking interrupts */
  720. while (rtc_data.busy) {
  721. extern unsigned long lpevent_count;
  722. struct ItLpQueue *lpq = get_paca()->lpqueue_ptr;
  723. if (lpq && ItLpQueue_isLpIntPending(lpq))
  724. lpevent_count += ItLpQueue_process(lpq, NULL);
  725. }
  726. return rtc_set_tm(rtc_data.rc, rtc_data.ce_msg.ce_msg, tm);
  727. }
  728. int mf_set_rtc(struct rtc_time *tm)
  729. {
  730. char ce_time[12];
  731. u8 day, mon, hour, min, sec, y1, y2;
  732. unsigned year;
  733. year = 1900 + tm->tm_year;
  734. y1 = year / 100;
  735. y2 = year % 100;
  736. sec = tm->tm_sec;
  737. min = tm->tm_min;
  738. hour = tm->tm_hour;
  739. day = tm->tm_mday;
  740. mon = tm->tm_mon + 1;
  741. BIN_TO_BCD(sec);
  742. BIN_TO_BCD(min);
  743. BIN_TO_BCD(hour);
  744. BIN_TO_BCD(mon);
  745. BIN_TO_BCD(day);
  746. BIN_TO_BCD(y1);
  747. BIN_TO_BCD(y2);
  748. memset(ce_time, 0, sizeof(ce_time));
  749. ce_time[3] = 0x41;
  750. ce_time[4] = y1;
  751. ce_time[5] = y2;
  752. ce_time[6] = sec;
  753. ce_time[7] = min;
  754. ce_time[8] = hour;
  755. ce_time[10] = day;
  756. ce_time[11] = mon;
  757. return signal_ce_msg(ce_time, NULL);
  758. }
  759. #ifdef CONFIG_PROC_FS
  760. static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
  761. int count, int *eof, void *data)
  762. {
  763. int len;
  764. char *p;
  765. struct vsp_cmd_data vsp_cmd;
  766. int rc;
  767. dma_addr_t dma_addr;
  768. /* The HV appears to return no more than 256 bytes of command line */
  769. if (off >= 256)
  770. return 0;
  771. if ((off + count) > 256)
  772. count = 256 - off;
  773. dma_addr = dma_map_single(iSeries_vio_dev, page, off + count,
  774. DMA_FROM_DEVICE);
  775. if (dma_mapping_error(dma_addr))
  776. return -ENOMEM;
  777. memset(page, 0, off + count);
  778. memset(&vsp_cmd, 0, sizeof(vsp_cmd));
  779. vsp_cmd.cmd = 33;
  780. vsp_cmd.sub_data.kern.token = dma_addr;
  781. vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
  782. vsp_cmd.sub_data.kern.side = (u64)data;
  783. vsp_cmd.sub_data.kern.length = off + count;
  784. mb();
  785. rc = signal_vsp_instruction(&vsp_cmd);
  786. dma_unmap_single(iSeries_vio_dev, dma_addr, off + count,
  787. DMA_FROM_DEVICE);
  788. if (rc)
  789. return rc;
  790. if (vsp_cmd.result_code != 0)
  791. return -ENOMEM;
  792. p = page;
  793. len = 0;
  794. while (len < (off + count)) {
  795. if ((*p == '\0') || (*p == '\n')) {
  796. if (*p == '\0')
  797. *p = '\n';
  798. p++;
  799. len++;
  800. *eof = 1;
  801. break;
  802. }
  803. p++;
  804. len++;
  805. }
  806. if (len < off) {
  807. *eof = 1;
  808. len = 0;
  809. }
  810. return len;
  811. }
  812. #if 0
  813. static int mf_getVmlinuxChunk(char *buffer, int *size, int offset, u64 side)
  814. {
  815. struct vsp_cmd_data vsp_cmd;
  816. int rc;
  817. int len = *size;
  818. dma_addr_t dma_addr;
  819. dma_addr = dma_map_single(iSeries_vio_dev, buffer, len,
  820. DMA_FROM_DEVICE);
  821. memset(buffer, 0, len);
  822. memset(&vsp_cmd, 0, sizeof(vsp_cmd));
  823. vsp_cmd.cmd = 32;
  824. vsp_cmd.sub_data.kern.token = dma_addr;
  825. vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
  826. vsp_cmd.sub_data.kern.side = side;
  827. vsp_cmd.sub_data.kern.offset = offset;
  828. vsp_cmd.sub_data.kern.length = len;
  829. mb();
  830. rc = signal_vsp_instruction(&vsp_cmd);
  831. if (rc == 0) {
  832. if (vsp_cmd.result_code == 0)
  833. *size = vsp_cmd.sub_data.length_out;
  834. else
  835. rc = -ENOMEM;
  836. }
  837. dma_unmap_single(iSeries_vio_dev, dma_addr, len, DMA_FROM_DEVICE);
  838. return rc;
  839. }
  840. static int proc_mf_dump_vmlinux(char *page, char **start, off_t off,
  841. int count, int *eof, void *data)
  842. {
  843. int sizeToGet = count;
  844. if (!capable(CAP_SYS_ADMIN))
  845. return -EACCES;
  846. if (mf_getVmlinuxChunk(page, &sizeToGet, off, (u64)data) == 0) {
  847. if (sizeToGet != 0) {
  848. *start = page + off;
  849. return sizeToGet;
  850. }
  851. *eof = 1;
  852. return 0;
  853. }
  854. *eof = 1;
  855. return 0;
  856. }
  857. #endif
  858. static int proc_mf_dump_side(char *page, char **start, off_t off,
  859. int count, int *eof, void *data)
  860. {
  861. int len;
  862. char mf_current_side = ' ';
  863. struct vsp_cmd_data vsp_cmd;
  864. memset(&vsp_cmd, 0, sizeof(vsp_cmd));
  865. vsp_cmd.cmd = 2;
  866. vsp_cmd.sub_data.ipl_type = 0;
  867. mb();
  868. if (signal_vsp_instruction(&vsp_cmd) == 0) {
  869. if (vsp_cmd.result_code == 0) {
  870. switch (vsp_cmd.sub_data.ipl_type) {
  871. case 0: mf_current_side = 'A';
  872. break;
  873. case 1: mf_current_side = 'B';
  874. break;
  875. case 2: mf_current_side = 'C';
  876. break;
  877. default: mf_current_side = 'D';
  878. break;
  879. }
  880. }
  881. }
  882. len = sprintf(page, "%c\n", mf_current_side);
  883. if (len <= (off + count))
  884. *eof = 1;
  885. *start = page + off;
  886. len -= off;
  887. if (len > count)
  888. len = count;
  889. if (len < 0)
  890. len = 0;
  891. return len;
  892. }
  893. static int proc_mf_change_side(struct file *file, const char __user *buffer,
  894. unsigned long count, void *data)
  895. {
  896. char side;
  897. u64 newSide;
  898. struct vsp_cmd_data vsp_cmd;
  899. if (!capable(CAP_SYS_ADMIN))
  900. return -EACCES;
  901. if (count == 0)
  902. return 0;
  903. if (get_user(side, buffer))
  904. return -EFAULT;
  905. switch (side) {
  906. case 'A': newSide = 0;
  907. break;
  908. case 'B': newSide = 1;
  909. break;
  910. case 'C': newSide = 2;
  911. break;
  912. case 'D': newSide = 3;
  913. break;
  914. default:
  915. printk(KERN_ERR "mf_proc.c: proc_mf_change_side: invalid side\n");
  916. return -EINVAL;
  917. }
  918. memset(&vsp_cmd, 0, sizeof(vsp_cmd));
  919. vsp_cmd.sub_data.ipl_type = newSide;
  920. vsp_cmd.cmd = 10;
  921. (void)signal_vsp_instruction(&vsp_cmd);
  922. return count;
  923. }
  924. #if 0
  925. static void mf_getSrcHistory(char *buffer, int size)
  926. {
  927. struct IplTypeReturnStuff return_stuff;
  928. struct pending_event *ev = new_pending_event();
  929. int rc = 0;
  930. char *pages[4];
  931. pages[0] = kmalloc(4096, GFP_ATOMIC);
  932. pages[1] = kmalloc(4096, GFP_ATOMIC);
  933. pages[2] = kmalloc(4096, GFP_ATOMIC);
  934. pages[3] = kmalloc(4096, GFP_ATOMIC);
  935. if ((ev == NULL) || (pages[0] == NULL) || (pages[1] == NULL)
  936. || (pages[2] == NULL) || (pages[3] == NULL))
  937. return -ENOMEM;
  938. return_stuff.xType = 0;
  939. return_stuff.xRc = 0;
  940. return_stuff.xDone = 0;
  941. ev->event.hp_lp_event.xSubtype = 6;
  942. ev->event.hp_lp_event.x.xSubtypeData =
  943. subtype_data('M', 'F', 'V', 'I');
  944. ev->event.data.vsp_cmd.xEvent = &return_stuff;
  945. ev->event.data.vsp_cmd.cmd = 4;
  946. ev->event.data.vsp_cmd.lp_index = HvLpConfig_getLpIndex();
  947. ev->event.data.vsp_cmd.result_code = 0xFF;
  948. ev->event.data.vsp_cmd.reserved = 0;
  949. ev->event.data.vsp_cmd.sub_data.page[0] = ISERIES_HV_ADDR(pages[0]);
  950. ev->event.data.vsp_cmd.sub_data.page[1] = ISERIES_HV_ADDR(pages[1]);
  951. ev->event.data.vsp_cmd.sub_data.page[2] = ISERIES_HV_ADDR(pages[2]);
  952. ev->event.data.vsp_cmd.sub_data.page[3] = ISERIES_HV_ADDR(pages[3]);
  953. mb();
  954. if (signal_event(ev) != 0)
  955. return;
  956. while (return_stuff.xDone != 1)
  957. udelay(10);
  958. if (return_stuff.xRc == 0)
  959. memcpy(buffer, pages[0], size);
  960. kfree(pages[0]);
  961. kfree(pages[1]);
  962. kfree(pages[2]);
  963. kfree(pages[3]);
  964. }
  965. #endif
  966. static int proc_mf_dump_src(char *page, char **start, off_t off,
  967. int count, int *eof, void *data)
  968. {
  969. #if 0
  970. int len;
  971. mf_getSrcHistory(page, count);
  972. len = count;
  973. len -= off;
  974. if (len < count) {
  975. *eof = 1;
  976. if (len <= 0)
  977. return 0;
  978. } else
  979. len = count;
  980. *start = page + off;
  981. return len;
  982. #else
  983. return 0;
  984. #endif
  985. }
  986. static int proc_mf_change_src(struct file *file, const char __user *buffer,
  987. unsigned long count, void *data)
  988. {
  989. char stkbuf[10];
  990. if (!capable(CAP_SYS_ADMIN))
  991. return -EACCES;
  992. if ((count < 4) && (count != 1)) {
  993. printk(KERN_ERR "mf_proc: invalid src\n");
  994. return -EINVAL;
  995. }
  996. if (count > (sizeof(stkbuf) - 1))
  997. count = sizeof(stkbuf) - 1;
  998. if (copy_from_user(stkbuf, buffer, count))
  999. return -EFAULT;
  1000. if ((count == 1) && (*stkbuf == '\0'))
  1001. mf_clear_src();
  1002. else
  1003. mf_display_src(*(u32 *)stkbuf);
  1004. return count;
  1005. }
  1006. static int proc_mf_change_cmdline(struct file *file, const char __user *buffer,
  1007. unsigned long count, void *data)
  1008. {
  1009. struct vsp_cmd_data vsp_cmd;
  1010. dma_addr_t dma_addr;
  1011. char *page;
  1012. int ret = -EACCES;
  1013. if (!capable(CAP_SYS_ADMIN))
  1014. goto out;
  1015. dma_addr = 0;
  1016. page = dma_alloc_coherent(iSeries_vio_dev, count, &dma_addr,
  1017. GFP_ATOMIC);
  1018. ret = -ENOMEM;
  1019. if (page == NULL)
  1020. goto out;
  1021. ret = -EFAULT;
  1022. if (copy_from_user(page, buffer, count))
  1023. goto out_free;
  1024. memset(&vsp_cmd, 0, sizeof(vsp_cmd));
  1025. vsp_cmd.cmd = 31;
  1026. vsp_cmd.sub_data.kern.token = dma_addr;
  1027. vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
  1028. vsp_cmd.sub_data.kern.side = (u64)data;
  1029. vsp_cmd.sub_data.kern.length = count;
  1030. mb();
  1031. (void)signal_vsp_instruction(&vsp_cmd);
  1032. ret = count;
  1033. out_free:
  1034. dma_free_coherent(iSeries_vio_dev, count, page, dma_addr);
  1035. out:
  1036. return ret;
  1037. }
  1038. static ssize_t proc_mf_change_vmlinux(struct file *file,
  1039. const char __user *buf,
  1040. size_t count, loff_t *ppos)
  1041. {
  1042. struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
  1043. ssize_t rc;
  1044. dma_addr_t dma_addr;
  1045. char *page;
  1046. struct vsp_cmd_data vsp_cmd;
  1047. rc = -EACCES;
  1048. if (!capable(CAP_SYS_ADMIN))
  1049. goto out;
  1050. dma_addr = 0;
  1051. page = dma_alloc_coherent(iSeries_vio_dev, count, &dma_addr,
  1052. GFP_ATOMIC);
  1053. rc = -ENOMEM;
  1054. if (page == NULL) {
  1055. printk(KERN_ERR "mf.c: couldn't allocate memory to set vmlinux chunk\n");
  1056. goto out;
  1057. }
  1058. rc = -EFAULT;
  1059. if (copy_from_user(page, buf, count))
  1060. goto out_free;
  1061. memset(&vsp_cmd, 0, sizeof(vsp_cmd));
  1062. vsp_cmd.cmd = 30;
  1063. vsp_cmd.sub_data.kern.token = dma_addr;
  1064. vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
  1065. vsp_cmd.sub_data.kern.side = (u64)dp->data;
  1066. vsp_cmd.sub_data.kern.offset = *ppos;
  1067. vsp_cmd.sub_data.kern.length = count;
  1068. mb();
  1069. rc = signal_vsp_instruction(&vsp_cmd);
  1070. if (rc)
  1071. goto out_free;
  1072. rc = -ENOMEM;
  1073. if (vsp_cmd.result_code != 0)
  1074. goto out_free;
  1075. *ppos += count;
  1076. rc = count;
  1077. out_free:
  1078. dma_free_coherent(iSeries_vio_dev, count, page, dma_addr);
  1079. out:
  1080. return rc;
  1081. }
  1082. static struct file_operations proc_vmlinux_operations = {
  1083. .write = proc_mf_change_vmlinux,
  1084. };
  1085. static int __init mf_proc_init(void)
  1086. {
  1087. struct proc_dir_entry *mf_proc_root;
  1088. struct proc_dir_entry *ent;
  1089. struct proc_dir_entry *mf;
  1090. char name[2];
  1091. int i;
  1092. mf_proc_root = proc_mkdir("iSeries/mf", NULL);
  1093. if (!mf_proc_root)
  1094. return 1;
  1095. name[1] = '\0';
  1096. for (i = 0; i < 4; i++) {
  1097. name[0] = 'A' + i;
  1098. mf = proc_mkdir(name, mf_proc_root);
  1099. if (!mf)
  1100. return 1;
  1101. ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf);
  1102. if (!ent)
  1103. return 1;
  1104. ent->nlink = 1;
  1105. ent->data = (void *)(long)i;
  1106. ent->read_proc = proc_mf_dump_cmdline;
  1107. ent->write_proc = proc_mf_change_cmdline;
  1108. if (i == 3) /* no vmlinux entry for 'D' */
  1109. continue;
  1110. ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf);
  1111. if (!ent)
  1112. return 1;
  1113. ent->nlink = 1;
  1114. ent->data = (void *)(long)i;
  1115. ent->proc_fops = &proc_vmlinux_operations;
  1116. }
  1117. ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
  1118. if (!ent)
  1119. return 1;
  1120. ent->nlink = 1;
  1121. ent->data = (void *)0;
  1122. ent->read_proc = proc_mf_dump_side;
  1123. ent->write_proc = proc_mf_change_side;
  1124. ent = create_proc_entry("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
  1125. if (!ent)
  1126. return 1;
  1127. ent->nlink = 1;
  1128. ent->data = (void *)0;
  1129. ent->read_proc = proc_mf_dump_src;
  1130. ent->write_proc = proc_mf_change_src;
  1131. return 0;
  1132. }
  1133. __initcall(mf_proc_init);
  1134. #endif /* CONFIG_PROC_FS */