mf.c 31 KB

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