mf.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281
  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. if (hvlpevent_is_pending())
  722. process_hvlpevents(NULL);
  723. }
  724. return rtc_set_tm(rtc_data.rc, rtc_data.ce_msg.ce_msg, tm);
  725. }
  726. int mf_set_rtc(struct rtc_time *tm)
  727. {
  728. char ce_time[12];
  729. u8 day, mon, hour, min, sec, y1, y2;
  730. unsigned year;
  731. year = 1900 + tm->tm_year;
  732. y1 = year / 100;
  733. y2 = year % 100;
  734. sec = tm->tm_sec;
  735. min = tm->tm_min;
  736. hour = tm->tm_hour;
  737. day = tm->tm_mday;
  738. mon = tm->tm_mon + 1;
  739. BIN_TO_BCD(sec);
  740. BIN_TO_BCD(min);
  741. BIN_TO_BCD(hour);
  742. BIN_TO_BCD(mon);
  743. BIN_TO_BCD(day);
  744. BIN_TO_BCD(y1);
  745. BIN_TO_BCD(y2);
  746. memset(ce_time, 0, sizeof(ce_time));
  747. ce_time[3] = 0x41;
  748. ce_time[4] = y1;
  749. ce_time[5] = y2;
  750. ce_time[6] = sec;
  751. ce_time[7] = min;
  752. ce_time[8] = hour;
  753. ce_time[10] = day;
  754. ce_time[11] = mon;
  755. return signal_ce_msg(ce_time, NULL);
  756. }
  757. #ifdef CONFIG_PROC_FS
  758. static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
  759. int count, int *eof, void *data)
  760. {
  761. int len;
  762. char *p;
  763. struct vsp_cmd_data vsp_cmd;
  764. int rc;
  765. dma_addr_t dma_addr;
  766. /* The HV appears to return no more than 256 bytes of command line */
  767. if (off >= 256)
  768. return 0;
  769. if ((off + count) > 256)
  770. count = 256 - off;
  771. dma_addr = dma_map_single(iSeries_vio_dev, page, off + count,
  772. DMA_FROM_DEVICE);
  773. if (dma_mapping_error(dma_addr))
  774. return -ENOMEM;
  775. memset(page, 0, off + count);
  776. memset(&vsp_cmd, 0, sizeof(vsp_cmd));
  777. vsp_cmd.cmd = 33;
  778. vsp_cmd.sub_data.kern.token = dma_addr;
  779. vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
  780. vsp_cmd.sub_data.kern.side = (u64)data;
  781. vsp_cmd.sub_data.kern.length = off + count;
  782. mb();
  783. rc = signal_vsp_instruction(&vsp_cmd);
  784. dma_unmap_single(iSeries_vio_dev, dma_addr, off + count,
  785. DMA_FROM_DEVICE);
  786. if (rc)
  787. return rc;
  788. if (vsp_cmd.result_code != 0)
  789. return -ENOMEM;
  790. p = page;
  791. len = 0;
  792. while (len < (off + count)) {
  793. if ((*p == '\0') || (*p == '\n')) {
  794. if (*p == '\0')
  795. *p = '\n';
  796. p++;
  797. len++;
  798. *eof = 1;
  799. break;
  800. }
  801. p++;
  802. len++;
  803. }
  804. if (len < off) {
  805. *eof = 1;
  806. len = 0;
  807. }
  808. return len;
  809. }
  810. #if 0
  811. static int mf_getVmlinuxChunk(char *buffer, int *size, int offset, u64 side)
  812. {
  813. struct vsp_cmd_data vsp_cmd;
  814. int rc;
  815. int len = *size;
  816. dma_addr_t dma_addr;
  817. dma_addr = dma_map_single(iSeries_vio_dev, buffer, len,
  818. DMA_FROM_DEVICE);
  819. memset(buffer, 0, len);
  820. memset(&vsp_cmd, 0, sizeof(vsp_cmd));
  821. vsp_cmd.cmd = 32;
  822. vsp_cmd.sub_data.kern.token = dma_addr;
  823. vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
  824. vsp_cmd.sub_data.kern.side = side;
  825. vsp_cmd.sub_data.kern.offset = offset;
  826. vsp_cmd.sub_data.kern.length = len;
  827. mb();
  828. rc = signal_vsp_instruction(&vsp_cmd);
  829. if (rc == 0) {
  830. if (vsp_cmd.result_code == 0)
  831. *size = vsp_cmd.sub_data.length_out;
  832. else
  833. rc = -ENOMEM;
  834. }
  835. dma_unmap_single(iSeries_vio_dev, dma_addr, len, DMA_FROM_DEVICE);
  836. return rc;
  837. }
  838. static int proc_mf_dump_vmlinux(char *page, char **start, off_t off,
  839. int count, int *eof, void *data)
  840. {
  841. int sizeToGet = count;
  842. if (!capable(CAP_SYS_ADMIN))
  843. return -EACCES;
  844. if (mf_getVmlinuxChunk(page, &sizeToGet, off, (u64)data) == 0) {
  845. if (sizeToGet != 0) {
  846. *start = page + off;
  847. return sizeToGet;
  848. }
  849. *eof = 1;
  850. return 0;
  851. }
  852. *eof = 1;
  853. return 0;
  854. }
  855. #endif
  856. static int proc_mf_dump_side(char *page, char **start, off_t off,
  857. int count, int *eof, void *data)
  858. {
  859. int len;
  860. char mf_current_side = ' ';
  861. struct vsp_cmd_data vsp_cmd;
  862. memset(&vsp_cmd, 0, sizeof(vsp_cmd));
  863. vsp_cmd.cmd = 2;
  864. vsp_cmd.sub_data.ipl_type = 0;
  865. mb();
  866. if (signal_vsp_instruction(&vsp_cmd) == 0) {
  867. if (vsp_cmd.result_code == 0) {
  868. switch (vsp_cmd.sub_data.ipl_type) {
  869. case 0: mf_current_side = 'A';
  870. break;
  871. case 1: mf_current_side = 'B';
  872. break;
  873. case 2: mf_current_side = 'C';
  874. break;
  875. default: mf_current_side = 'D';
  876. break;
  877. }
  878. }
  879. }
  880. len = sprintf(page, "%c\n", mf_current_side);
  881. if (len <= (off + count))
  882. *eof = 1;
  883. *start = page + off;
  884. len -= off;
  885. if (len > count)
  886. len = count;
  887. if (len < 0)
  888. len = 0;
  889. return len;
  890. }
  891. static int proc_mf_change_side(struct file *file, const char __user *buffer,
  892. unsigned long count, void *data)
  893. {
  894. char side;
  895. u64 newSide;
  896. struct vsp_cmd_data vsp_cmd;
  897. if (!capable(CAP_SYS_ADMIN))
  898. return -EACCES;
  899. if (count == 0)
  900. return 0;
  901. if (get_user(side, buffer))
  902. return -EFAULT;
  903. switch (side) {
  904. case 'A': newSide = 0;
  905. break;
  906. case 'B': newSide = 1;
  907. break;
  908. case 'C': newSide = 2;
  909. break;
  910. case 'D': newSide = 3;
  911. break;
  912. default:
  913. printk(KERN_ERR "mf_proc.c: proc_mf_change_side: invalid side\n");
  914. return -EINVAL;
  915. }
  916. memset(&vsp_cmd, 0, sizeof(vsp_cmd));
  917. vsp_cmd.sub_data.ipl_type = newSide;
  918. vsp_cmd.cmd = 10;
  919. (void)signal_vsp_instruction(&vsp_cmd);
  920. return count;
  921. }
  922. #if 0
  923. static void mf_getSrcHistory(char *buffer, int size)
  924. {
  925. struct IplTypeReturnStuff return_stuff;
  926. struct pending_event *ev = new_pending_event();
  927. int rc = 0;
  928. char *pages[4];
  929. pages[0] = kmalloc(4096, GFP_ATOMIC);
  930. pages[1] = kmalloc(4096, GFP_ATOMIC);
  931. pages[2] = kmalloc(4096, GFP_ATOMIC);
  932. pages[3] = kmalloc(4096, GFP_ATOMIC);
  933. if ((ev == NULL) || (pages[0] == NULL) || (pages[1] == NULL)
  934. || (pages[2] == NULL) || (pages[3] == NULL))
  935. return -ENOMEM;
  936. return_stuff.xType = 0;
  937. return_stuff.xRc = 0;
  938. return_stuff.xDone = 0;
  939. ev->event.hp_lp_event.xSubtype = 6;
  940. ev->event.hp_lp_event.x.xSubtypeData =
  941. subtype_data('M', 'F', 'V', 'I');
  942. ev->event.data.vsp_cmd.xEvent = &return_stuff;
  943. ev->event.data.vsp_cmd.cmd = 4;
  944. ev->event.data.vsp_cmd.lp_index = HvLpConfig_getLpIndex();
  945. ev->event.data.vsp_cmd.result_code = 0xFF;
  946. ev->event.data.vsp_cmd.reserved = 0;
  947. ev->event.data.vsp_cmd.sub_data.page[0] = ISERIES_HV_ADDR(pages[0]);
  948. ev->event.data.vsp_cmd.sub_data.page[1] = ISERIES_HV_ADDR(pages[1]);
  949. ev->event.data.vsp_cmd.sub_data.page[2] = ISERIES_HV_ADDR(pages[2]);
  950. ev->event.data.vsp_cmd.sub_data.page[3] = ISERIES_HV_ADDR(pages[3]);
  951. mb();
  952. if (signal_event(ev) != 0)
  953. return;
  954. while (return_stuff.xDone != 1)
  955. udelay(10);
  956. if (return_stuff.xRc == 0)
  957. memcpy(buffer, pages[0], size);
  958. kfree(pages[0]);
  959. kfree(pages[1]);
  960. kfree(pages[2]);
  961. kfree(pages[3]);
  962. }
  963. #endif
  964. static int proc_mf_dump_src(char *page, char **start, off_t off,
  965. int count, int *eof, void *data)
  966. {
  967. #if 0
  968. int len;
  969. mf_getSrcHistory(page, count);
  970. len = count;
  971. len -= off;
  972. if (len < count) {
  973. *eof = 1;
  974. if (len <= 0)
  975. return 0;
  976. } else
  977. len = count;
  978. *start = page + off;
  979. return len;
  980. #else
  981. return 0;
  982. #endif
  983. }
  984. static int proc_mf_change_src(struct file *file, const char __user *buffer,
  985. unsigned long count, void *data)
  986. {
  987. char stkbuf[10];
  988. if (!capable(CAP_SYS_ADMIN))
  989. return -EACCES;
  990. if ((count < 4) && (count != 1)) {
  991. printk(KERN_ERR "mf_proc: invalid src\n");
  992. return -EINVAL;
  993. }
  994. if (count > (sizeof(stkbuf) - 1))
  995. count = sizeof(stkbuf) - 1;
  996. if (copy_from_user(stkbuf, buffer, count))
  997. return -EFAULT;
  998. if ((count == 1) && (*stkbuf == '\0'))
  999. mf_clear_src();
  1000. else
  1001. mf_display_src(*(u32 *)stkbuf);
  1002. return count;
  1003. }
  1004. static int proc_mf_change_cmdline(struct file *file, const char __user *buffer,
  1005. unsigned long count, void *data)
  1006. {
  1007. struct vsp_cmd_data vsp_cmd;
  1008. dma_addr_t dma_addr;
  1009. char *page;
  1010. int ret = -EACCES;
  1011. if (!capable(CAP_SYS_ADMIN))
  1012. goto out;
  1013. dma_addr = 0;
  1014. page = dma_alloc_coherent(iSeries_vio_dev, count, &dma_addr,
  1015. GFP_ATOMIC);
  1016. ret = -ENOMEM;
  1017. if (page == NULL)
  1018. goto out;
  1019. ret = -EFAULT;
  1020. if (copy_from_user(page, buffer, count))
  1021. goto out_free;
  1022. memset(&vsp_cmd, 0, sizeof(vsp_cmd));
  1023. vsp_cmd.cmd = 31;
  1024. vsp_cmd.sub_data.kern.token = dma_addr;
  1025. vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
  1026. vsp_cmd.sub_data.kern.side = (u64)data;
  1027. vsp_cmd.sub_data.kern.length = count;
  1028. mb();
  1029. (void)signal_vsp_instruction(&vsp_cmd);
  1030. ret = count;
  1031. out_free:
  1032. dma_free_coherent(iSeries_vio_dev, count, page, dma_addr);
  1033. out:
  1034. return ret;
  1035. }
  1036. static ssize_t proc_mf_change_vmlinux(struct file *file,
  1037. const char __user *buf,
  1038. size_t count, loff_t *ppos)
  1039. {
  1040. struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
  1041. ssize_t rc;
  1042. dma_addr_t dma_addr;
  1043. char *page;
  1044. struct vsp_cmd_data vsp_cmd;
  1045. rc = -EACCES;
  1046. if (!capable(CAP_SYS_ADMIN))
  1047. goto out;
  1048. dma_addr = 0;
  1049. page = dma_alloc_coherent(iSeries_vio_dev, count, &dma_addr,
  1050. GFP_ATOMIC);
  1051. rc = -ENOMEM;
  1052. if (page == NULL) {
  1053. printk(KERN_ERR "mf.c: couldn't allocate memory to set vmlinux chunk\n");
  1054. goto out;
  1055. }
  1056. rc = -EFAULT;
  1057. if (copy_from_user(page, buf, count))
  1058. goto out_free;
  1059. memset(&vsp_cmd, 0, sizeof(vsp_cmd));
  1060. vsp_cmd.cmd = 30;
  1061. vsp_cmd.sub_data.kern.token = dma_addr;
  1062. vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
  1063. vsp_cmd.sub_data.kern.side = (u64)dp->data;
  1064. vsp_cmd.sub_data.kern.offset = *ppos;
  1065. vsp_cmd.sub_data.kern.length = count;
  1066. mb();
  1067. rc = signal_vsp_instruction(&vsp_cmd);
  1068. if (rc)
  1069. goto out_free;
  1070. rc = -ENOMEM;
  1071. if (vsp_cmd.result_code != 0)
  1072. goto out_free;
  1073. *ppos += count;
  1074. rc = count;
  1075. out_free:
  1076. dma_free_coherent(iSeries_vio_dev, count, page, dma_addr);
  1077. out:
  1078. return rc;
  1079. }
  1080. static struct file_operations proc_vmlinux_operations = {
  1081. .write = proc_mf_change_vmlinux,
  1082. };
  1083. static int __init mf_proc_init(void)
  1084. {
  1085. struct proc_dir_entry *mf_proc_root;
  1086. struct proc_dir_entry *ent;
  1087. struct proc_dir_entry *mf;
  1088. char name[2];
  1089. int i;
  1090. mf_proc_root = proc_mkdir("iSeries/mf", NULL);
  1091. if (!mf_proc_root)
  1092. return 1;
  1093. name[1] = '\0';
  1094. for (i = 0; i < 4; i++) {
  1095. name[0] = 'A' + i;
  1096. mf = proc_mkdir(name, mf_proc_root);
  1097. if (!mf)
  1098. return 1;
  1099. ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf);
  1100. if (!ent)
  1101. return 1;
  1102. ent->nlink = 1;
  1103. ent->data = (void *)(long)i;
  1104. ent->read_proc = proc_mf_dump_cmdline;
  1105. ent->write_proc = proc_mf_change_cmdline;
  1106. if (i == 3) /* no vmlinux entry for 'D' */
  1107. continue;
  1108. ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf);
  1109. if (!ent)
  1110. return 1;
  1111. ent->nlink = 1;
  1112. ent->data = (void *)(long)i;
  1113. ent->proc_fops = &proc_vmlinux_operations;
  1114. }
  1115. ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
  1116. if (!ent)
  1117. return 1;
  1118. ent->nlink = 1;
  1119. ent->data = (void *)0;
  1120. ent->read_proc = proc_mf_dump_side;
  1121. ent->write_proc = proc_mf_change_side;
  1122. ent = create_proc_entry("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
  1123. if (!ent)
  1124. return 1;
  1125. ent->nlink = 1;
  1126. ent->data = (void *)0;
  1127. ent->read_proc = proc_mf_dump_src;
  1128. ent->write_proc = proc_mf_change_src;
  1129. return 0;
  1130. }
  1131. __initcall(mf_proc_init);
  1132. #endif /* CONFIG_PROC_FS */