Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel'
[palacios.git] / kitten / drivers / console / rcal0.c
1 #include <lwk/driver.h>
2 #include <lwk/console.h>
3 #include <lwk/string.h>
4 #include <lwk/delay.h>
5 #include <rca/rca_l0.h>
6
7 /** Template event heder with static fields filled in. */
8 static rs_event_t ev_hdr = {0};
9
10 /** Set when L0 console has been initialized. */
11 static int initialized = 0;
12
13 /**
14  * Writes a message to the Cray L0 console.
15  */
16 static void l0_write(struct console *con, const char *str)
17 {
18         int ret = 0;
19         unsigned int n = strlen(str);
20
21         while (n) {
22                 if ((ret =
23                         ch_send_data(L0RCA_CH_CON_UP, &ev_hdr, (void *)str, n))
24                      <= 0)
25                 {
26                         /* either error or we are done */
27                         break;
28                 }
29
30                 if (n > ret) {
31                         /* some bytes were sent, point to the remaining data */
32                         str += (n - ret);
33                         n = ret;
34                 }
35
36                 /* busy wait if the buf is full */
37                 udelay(1000);
38         }
39
40         /* if error, give up and spin forever */
41         if (ret < 0)
42                 while (1) {}
43
44         return;
45 }
46
47 /**
48  * Cray L0 console device.
49  */
50 static struct console l0_console = {
51         .name  = "Cray RCA L0 Console",
52         .write = l0_write
53 };
54
55 /**
56  * Initializes the Cray XT L0 console.
57  */
58 void l0_console_init(void)
59 {
60         if (initialized) {
61                 printk(KERN_ERR "RCA L0 console already initialized.\n");
62                 return;
63         }
64
65         /* Read the configuration information provided by the L0 */
66         l0rca_init_config();
67
68         /* Setup the event template to use for outgoing events */
69         ev_hdr.ev_id            =       ec_console_log;
70         ev_hdr.ev_gen           =       RCA_MKSVC(
71                                                 RCA_INST_ANY,
72                                                 RCA_SVCTYPE_CONS,
73                                                 l0rca_get_proc_id()
74                                         );
75         ev_hdr.ev_src           =       ev_hdr.ev_gen;
76         ev_hdr.ev_priority      =       RCA_LOG_DEBUG;
77         ev_hdr.ev_flag          =       0;
78         /* Timestamp, len & data is filled at the time of sending event */
79         
80         /* Register with the Cray RCA subsystem */
81         register_ch_up(L0RCA_CH_CON_UP, NULL, 0, -1);
82
83         /* Register the L0 console with the LWK */
84         console_register(&l0_console);
85         initialized = 1;
86 }
87
88 driver_init(l0_console_init);
89