Driver for IBM RSA service processor (1/2)
Subsystems (2)
PATCH 1/1 Driver for IBM RSA service processor (1/2)
Here is a device driver for the IBM xSeries RSA service processor. The ibmasm driver is mainly intended to be used in conjunction with a user space API and systems management applications that need to get in-band access to the service processor, such as sending commands or waiting for events. For the remote video feature the driver relays remote mouse and keyboard events to user space.
By itself the driver also allows the OS to make use the UART on the service processor board as a regular serial line.
The user interface to the driver is a custom file system. It does not use sysfs since the operations on the files are somewhat beyond the one file / one value rule for sysfs. Since it is not strictly a char driver I put it into the drivers/misc directory.
The patch is fairly big, therefore I split it up into the file system part and the everything-else part.
Any feedback is greatly appreciated.
Regards,
Max
Here is the non-filesytem part:
drivers/Kconfig +1 -1
@@ -38,7 +38,7 @@ source "drivers/char/Kconfig" -# source "drivers/misc/Kconfig" +source "drivers/misc/Kconfig" source "drivers/media/Kconfig"
drivers/misc/ibmasm/command.c +175 -0
175 lines not on this page · raw message
drivers/misc/ibmasm/dot_command.c +146 -0
146 lines not on this page · raw message
drivers/misc/ibmasm/dot_command.h +78 -0
78 lines not on this page · raw message
drivers/misc/ibmasm/event.c +172 -0
172 lines not on this page · raw message
drivers/misc/ibmasm/heartbeat.c +91 -0
91 lines not on this page · raw message
drivers/misc/ibmasm/i2o.h +77 -0
77 lines not on this page · raw message
drivers/misc/ibmasm/ibmasm.h +227 -0
227 lines not on this page · raw message
drivers/misc/ibmasm/lowlevel.c +81 -0
81 lines not on this page · raw message
drivers/misc/ibmasm/lowlevel.h +137 -0
137 lines not on this page · raw message
drivers/misc/ibmasm/Makefile +13 -0
@@ -0,0 +1,13 @@ + +obj-$(CONFIG_IBM_ASM) := ibmasm.o + +ibmasm-objs := module.o \ + ibmasmfs.o \ + event.o \ + command.o \ + remote.o \ + heartbeat.o \ + r_heartbeat.o \ + dot_command.o \ + lowlevel.o \ + uart.o
drivers/misc/ibmasm/module.c +212 -0
212 lines not on this page · raw message
drivers/misc/ibmasm/remote.c +156 -0
156 lines not on this page · raw message
drivers/misc/ibmasm/remote.h +119 -0
119 lines not on this page · raw message
drivers/misc/ibmasm/r_heartbeat.c +95 -0
95 lines not on this page · raw message
drivers/misc/ibmasm/uart.c +72 -0
72 lines not on this page · raw message
drivers/misc/Kconfig +16 -0
@@ -4,5 +4,21 @@ menu "Misc devices" +config IBM_ASM + tristate "Device driver for IBM RSA service processor" + default n + ---help--- + This option enables device driver support for in-band access to the + IBM RSA (Condor) service processor in eServer xSeries systems. + The ibmasm device driver allows user space application to access + ASM (Advanced Systems Management) functions on the service + processor. The driver is meant to be used in conjunction with + a user space API. + The ibmasm driver also enables the OS to use the UART on the + service processor board as a regular serial port. + + + If unsure, say N. + endmenu
drivers/misc/Makefile +3 -1
@@ -1,4 +1,6 @@ # # Makefile for misc devices that really don't fit anywhere else. # -obj- := misc.o # Dummy rule to force built-in.o to be made +obj- := misc.o # Dummy rule to force built-in.o to be made + +obj-$(CONFIG_IBM_ASM) += ibmasm/
On Mon, 2 Feb 2004 11:29:53 -0800 Max Asbock <[email protected]> wrote:
| Here is a device driver for the IBM xSeries RSA service processor. | The ibmasm driver is mainly intended to be used in conjunction with a user space | API and systems management applications that need to get in-band access to | the service processor, such as sending commands or waiting for events. | For the remote video feature the driver relays remote mouse and keyboard | events to user space. | By itself the driver also allows the OS to make use the UART on the service | processor board as a regular serial line. | | The user interface to the driver is a custom file system. It does not use sysfs since | the operations on the files are somewhat beyond the one file / one value rule for sysfs. | Since it is not strictly a char driver I put it into the drivers/misc directory. | | The patch is fairly big, therefore I split it up into the file system part and the | everything-else part. | | Any feedback is greatly appreciated.
Hi,
Need to be consistent with spacing in "if" -- don't add spaces on both sides of '(' and ')'.
| + if (buffer_size > IBMASM_CMD_MAX_BUFFER_SIZE)
| + return NULL;
Several good, like above....
| +static struct command *dequeue_command(struct service_processor *sp)
| +{
| + struct command *cmd;
| + struct list_head *next;
| +
| + if ( list_empty(&sp->command_queue) )
| + return NULL;Nope, no cookie for this one and others below...
| +static inline void do_exec_command(struct service_processor *sp)
| +{
| + if ( ibmasm_send_i2o_message(sp) ) {
| + sp->current_command->status = IBMASM_CMD_FAILED;
| + exec_next_command(sp);
| + }
| +}| + if ( !sp->current_command ) {
| + command_get(cmd);
| + sp->current_command = cmd;
| + spin_unlock_irqrestore(&sp->lock, flags);
| +
| + do_exec_command(sp);| + if ( sp->current_command ) {
| + command_get(sp->current_command);
| + spin_unlock_irqrestore(&sp->lock, flags);
| + do_exec_command(sp);
| + } else {
| + spin_unlock_irqrestore(&sp->lock, flags);
| + }| diff -urN linux-2.6.1/drivers/misc/ibmasm/dot_command.c linux-2.6.1-ibmasm/drivers/misc/ibmasm/dot_command.c | --- linux-2.6.1/drivers/misc/ibmasm/dot_command.c 1969-12-31 16:00:00.000000000 -0800 | +++ linux-2.6.1-ibmasm/drivers/misc/ibmasm/dot_command.c 2004-01-22 11:10:20.000000000 -0800
| diff -urN linux-2.6.1/drivers/misc/ibmasm/event.c linux-2.6.1-ibmasm/drivers/misc/ibmasm/event.c | --- linux-2.6.1/drivers/misc/ibmasm/event.c 1969-12-31 16:00:00.000000000 -0800 | +++ linux-2.6.1-ibmasm/drivers/misc/ibmasm/event.c 2004-01-20 11:16:29.000000000 -0800
| +/** | + * receive_event | + * Called by the interrupt handler when a dot command of type sp_event is | + * received. | + * Store the event in the circular event buffer, wake up any sleeping | + * event readers. | + * There is no reader marker in the buffer, therefore readers are | + * responsible for keeping up with the writer, or they will loose events.
lose
| + /* advance indices in the buffer */ | + buffer->next_index = ++(buffer->next_index) % IBMASM_NUM_EVENTS; | + buffer->next_serial_number++;
Is
+#define IBMASM_NUM_EVENTS 10
not configurable?
| + if ( wait_event_interruptible(reader->wait, event_available(buffer, reader)) )
| + return -ERESTARTSYS;
:(
| + if (!event_available(buffer, reader))
| + return 0;
:)
I'll try to look at more of it later today.
--
~Randy
kernel-janitors project: http://janitor.kernelnewbies.org/
Max Asbock <[email protected]> :
Quoted 3 lines
diff -urN
linux-2.6.1/drivers/misc/ibmasm/event.clinux-2.6.1-ibmasm/drivers/misc/ibmasm/event.cdrivers/misc/ibmasm/event.c +0
-0
[...]
Quoted 2 lines
drivers/misc/ibmasm/event.c +2
-0+void ibmasm_receive_event (struct service_processor *sp,void *data,size_t data_size) +{
[...]
drivers/misc/ibmasm/event.c line 74
Quoted 2 lines
drivers/misc/ibmasm/event.c +2
-0+/* advance indices in the buffer */ + buffer->next_index = ++(buffer->next_index) %IBMASM_NUM_EVENTS ;
-> buffer->next_index = (buffer->next_index + 1) % IBMASM_NUM_EVENTS;
Quoted 3 lines
diff -urN
linux-2.6.1/drivers/misc/ibmasm/module.clinux-2.6.1-ibmasm/drivers/misc/ibmasm/module.cdrivers/misc/ibmasm/module.c +0
-0
[...]
drivers/misc/ibmasm/module.c line 62
Quoted 3 lines
drivers/misc/ibmasm/module.c +3
-0+static int __init ibmasm_init_one (struct pci_dev *pdev,const struct pci_device_id *id) +{ +int result =0 ;
-> It can be set directly to -ENOMEM (and removed from several lines below).
It will be overriden later if everything succeeds.
Quoted 3 lines
diff -urN
linux-2.6.1/drivers/misc/ibmasm/remote.clinux-2.6.1-ibmasm/drivers/misc/ibmasm/remote.cdrivers/misc/ibmasm/remote.c +0
-0
[...]
drivers/misc/ibmasm/remote.c line 56
Quoted 5 lines
drivers/misc/ibmasm/remote.c +5
-0+void ibmasm_free_remote_queue (struct service_processor *sp) +{ +if (sp->remote_queue.start) +kfree (sp->remote_queue.start); +}
-> kfree(NULL) does not hurt. The 'if' can be removed.
[...]
drivers/misc/ibmasm/remote.c line 73
Quoted 9 lines
drivers/misc/ibmasm/remote.c +9
-0+size_t ibmasm_events_available (struct remote_queue *q) +{ +ssize_t diff = q->writer - q->reader; + +if (diff >=0 ) +return diff; +else +return (q->end - q->reader); +}
-> return (diff >= 0) ? diff : q->end - q->reader;
Your choice.
--
Ueimor