diff options
Diffstat (limited to 'drivers/s390/char')
-rw-r--r-- | drivers/s390/char/Makefile | 5 | ||||
-rw-r--r-- | drivers/s390/char/con3215.c | 7 | ||||
-rw-r--r-- | drivers/s390/char/con3270.c | 7 | ||||
-rw-r--r-- | drivers/s390/char/sclp.c | 10 | ||||
-rw-r--r-- | drivers/s390/char/sclp.h | 72 | ||||
-rw-r--r-- | drivers/s390/char/sclp_chp.c | 196 | ||||
-rw-r--r-- | drivers/s390/char/sclp_config.c | 75 | ||||
-rw-r--r-- | drivers/s390/char/sclp_cpi.c | 4 | ||||
-rw-r--r-- | drivers/s390/char/sclp_quiesce.c | 2 | ||||
-rw-r--r-- | drivers/s390/char/sclp_rw.c | 16 | ||||
-rw-r--r-- | drivers/s390/char/sclp_sdias.c | 255 | ||||
-rw-r--r-- | drivers/s390/char/sclp_tty.c | 6 | ||||
-rw-r--r-- | drivers/s390/char/sclp_vt220.c | 8 | ||||
-rw-r--r-- | drivers/s390/char/vmlogrdr.c | 9 | ||||
-rw-r--r-- | drivers/s390/char/zcore.c | 651 |
15 files changed, 1252 insertions, 71 deletions
diff --git a/drivers/s390/char/Makefile b/drivers/s390/char/Makefile index 293e667b50f2..c210784bdf46 100644 --- a/drivers/s390/char/Makefile +++ b/drivers/s390/char/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += ctrlchar.o keyboard.o defkeymap.o sclp.o sclp_rw.o sclp_quiesce.o \ | 5 | obj-y += ctrlchar.o keyboard.o defkeymap.o sclp.o sclp_rw.o sclp_quiesce.o \ |
6 | sclp_info.o | 6 | sclp_info.o sclp_config.o sclp_chp.o |
7 | 7 | ||
8 | obj-$(CONFIG_TN3270) += raw3270.o | 8 | obj-$(CONFIG_TN3270) += raw3270.o |
9 | obj-$(CONFIG_TN3270_CONSOLE) += con3270.o | 9 | obj-$(CONFIG_TN3270_CONSOLE) += con3270.o |
@@ -29,3 +29,6 @@ obj-$(CONFIG_S390_TAPE_34XX) += tape_34xx.o | |||
29 | obj-$(CONFIG_S390_TAPE_3590) += tape_3590.o | 29 | obj-$(CONFIG_S390_TAPE_3590) += tape_3590.o |
30 | obj-$(CONFIG_MONREADER) += monreader.o | 30 | obj-$(CONFIG_MONREADER) += monreader.o |
31 | obj-$(CONFIG_MONWRITER) += monwriter.o | 31 | obj-$(CONFIG_MONWRITER) += monwriter.o |
32 | |||
33 | zcore_mod-objs := sclp_sdias.o zcore.o | ||
34 | obj-$(CONFIG_ZFCPDUMP) += zcore_mod.o | ||
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 9a328f14a641..6000bdee4082 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c | |||
@@ -813,12 +813,6 @@ con3215_unblank(void) | |||
813 | spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); | 813 | spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); |
814 | } | 814 | } |
815 | 815 | ||
816 | static int __init | ||
817 | con3215_consetup(struct console *co, char *options) | ||
818 | { | ||
819 | return 0; | ||
820 | } | ||
821 | |||
822 | /* | 816 | /* |
823 | * The console structure for the 3215 console | 817 | * The console structure for the 3215 console |
824 | */ | 818 | */ |
@@ -827,7 +821,6 @@ static struct console con3215 = { | |||
827 | .write = con3215_write, | 821 | .write = con3215_write, |
828 | .device = con3215_device, | 822 | .device = con3215_device, |
829 | .unblank = con3215_unblank, | 823 | .unblank = con3215_unblank, |
830 | .setup = con3215_consetup, | ||
831 | .flags = CON_PRINTBUFFER, | 824 | .flags = CON_PRINTBUFFER, |
832 | }; | 825 | }; |
833 | 826 | ||
diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c index 8e7f2d7633d6..fd3479119eb4 100644 --- a/drivers/s390/char/con3270.c +++ b/drivers/s390/char/con3270.c | |||
@@ -555,12 +555,6 @@ con3270_unblank(void) | |||
555 | spin_unlock_irqrestore(&cp->view.lock, flags); | 555 | spin_unlock_irqrestore(&cp->view.lock, flags); |
556 | } | 556 | } |
557 | 557 | ||
558 | static int __init | ||
559 | con3270_consetup(struct console *co, char *options) | ||
560 | { | ||
561 | return 0; | ||
562 | } | ||
563 | |||
564 | /* | 558 | /* |
565 | * The console structure for the 3270 console | 559 | * The console structure for the 3270 console |
566 | */ | 560 | */ |
@@ -569,7 +563,6 @@ static struct console con3270 = { | |||
569 | .write = con3270_write, | 563 | .write = con3270_write, |
570 | .device = con3270_device, | 564 | .device = con3270_device, |
571 | .unblank = con3270_unblank, | 565 | .unblank = con3270_unblank, |
572 | .setup = con3270_consetup, | ||
573 | .flags = CON_PRINTBUFFER, | 566 | .flags = CON_PRINTBUFFER, |
574 | }; | 567 | }; |
575 | 568 | ||
diff --git a/drivers/s390/char/sclp.c b/drivers/s390/char/sclp.c index f171de3b0b11..fa62e6944057 100644 --- a/drivers/s390/char/sclp.c +++ b/drivers/s390/char/sclp.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/timer.h> | 15 | #include <linux/timer.h> |
16 | #include <linux/reboot.h> | 16 | #include <linux/reboot.h> |
17 | #include <linux/jiffies.h> | 17 | #include <linux/jiffies.h> |
18 | #include <linux/init.h> | ||
18 | #include <asm/types.h> | 19 | #include <asm/types.h> |
19 | #include <asm/s390_ext.h> | 20 | #include <asm/s390_ext.h> |
20 | 21 | ||
@@ -510,7 +511,7 @@ sclp_state_change_cb(struct evbuf_header *evbuf) | |||
510 | } | 511 | } |
511 | 512 | ||
512 | static struct sclp_register sclp_state_change_event = { | 513 | static struct sclp_register sclp_state_change_event = { |
513 | .receive_mask = EvTyp_StateChange_Mask, | 514 | .receive_mask = EVTYP_STATECHANGE_MASK, |
514 | .receiver_fn = sclp_state_change_cb | 515 | .receiver_fn = sclp_state_change_cb |
515 | }; | 516 | }; |
516 | 517 | ||
@@ -930,3 +931,10 @@ sclp_init(void) | |||
930 | sclp_init_mask(1); | 931 | sclp_init_mask(1); |
931 | return 0; | 932 | return 0; |
932 | } | 933 | } |
934 | |||
935 | static __init int sclp_initcall(void) | ||
936 | { | ||
937 | return sclp_init(); | ||
938 | } | ||
939 | |||
940 | arch_initcall(sclp_initcall); | ||
diff --git a/drivers/s390/char/sclp.h b/drivers/s390/char/sclp.h index 7d29ab45a6ed..87ac4a3ad49d 100644 --- a/drivers/s390/char/sclp.h +++ b/drivers/s390/char/sclp.h | |||
@@ -19,33 +19,37 @@ | |||
19 | #define MAX_KMEM_PAGES (sizeof(unsigned long) << 3) | 19 | #define MAX_KMEM_PAGES (sizeof(unsigned long) << 3) |
20 | #define MAX_CONSOLE_PAGES 4 | 20 | #define MAX_CONSOLE_PAGES 4 |
21 | 21 | ||
22 | #define EvTyp_OpCmd 0x01 | 22 | #define EVTYP_OPCMD 0x01 |
23 | #define EvTyp_Msg 0x02 | 23 | #define EVTYP_MSG 0x02 |
24 | #define EvTyp_StateChange 0x08 | 24 | #define EVTYP_STATECHANGE 0x08 |
25 | #define EvTyp_PMsgCmd 0x09 | 25 | #define EVTYP_PMSGCMD 0x09 |
26 | #define EvTyp_CntlProgOpCmd 0x20 | 26 | #define EVTYP_CNTLPROGOPCMD 0x20 |
27 | #define EvTyp_CntlProgIdent 0x0B | 27 | #define EVTYP_CNTLPROGIDENT 0x0B |
28 | #define EvTyp_SigQuiesce 0x1D | 28 | #define EVTYP_SIGQUIESCE 0x1D |
29 | #define EvTyp_VT220Msg 0x1A | 29 | #define EVTYP_VT220MSG 0x1A |
30 | 30 | #define EVTYP_CONFMGMDATA 0x04 | |
31 | #define EvTyp_OpCmd_Mask 0x80000000 | 31 | #define EVTYP_SDIAS 0x1C |
32 | #define EvTyp_Msg_Mask 0x40000000 | 32 | |
33 | #define EvTyp_StateChange_Mask 0x01000000 | 33 | #define EVTYP_OPCMD_MASK 0x80000000 |
34 | #define EvTyp_PMsgCmd_Mask 0x00800000 | 34 | #define EVTYP_MSG_MASK 0x40000000 |
35 | #define EvTyp_CtlProgOpCmd_Mask 0x00000001 | 35 | #define EVTYP_STATECHANGE_MASK 0x01000000 |
36 | #define EvTyp_CtlProgIdent_Mask 0x00200000 | 36 | #define EVTYP_PMSGCMD_MASK 0x00800000 |
37 | #define EvTyp_SigQuiesce_Mask 0x00000008 | 37 | #define EVTYP_CTLPROGOPCMD_MASK 0x00000001 |
38 | #define EvTyp_VT220Msg_Mask 0x00000040 | 38 | #define EVTYP_CTLPROGIDENT_MASK 0x00200000 |
39 | 39 | #define EVTYP_SIGQUIESCE_MASK 0x00000008 | |
40 | #define GnrlMsgFlgs_DOM 0x8000 | 40 | #define EVTYP_VT220MSG_MASK 0x00000040 |
41 | #define GnrlMsgFlgs_SndAlrm 0x4000 | 41 | #define EVTYP_CONFMGMDATA_MASK 0x10000000 |
42 | #define GnrlMsgFlgs_HoldMsg 0x2000 | 42 | #define EVTYP_SDIAS_MASK 0x00000010 |
43 | 43 | ||
44 | #define LnTpFlgs_CntlText 0x8000 | 44 | #define GNRLMSGFLGS_DOM 0x8000 |
45 | #define LnTpFlgs_LabelText 0x4000 | 45 | #define GNRLMSGFLGS_SNDALRM 0x4000 |
46 | #define LnTpFlgs_DataText 0x2000 | 46 | #define GNRLMSGFLGS_HOLDMSG 0x2000 |
47 | #define LnTpFlgs_EndText 0x1000 | 47 | |
48 | #define LnTpFlgs_PromptText 0x0800 | 48 | #define LNTPFLGS_CNTLTEXT 0x8000 |
49 | #define LNTPFLGS_LABELTEXT 0x4000 | ||
50 | #define LNTPFLGS_DATATEXT 0x2000 | ||
51 | #define LNTPFLGS_ENDTEXT 0x1000 | ||
52 | #define LNTPFLGS_PROMPTTEXT 0x0800 | ||
49 | 53 | ||
50 | typedef unsigned int sclp_cmdw_t; | 54 | typedef unsigned int sclp_cmdw_t; |
51 | 55 | ||
@@ -56,15 +60,15 @@ typedef unsigned int sclp_cmdw_t; | |||
56 | #define SCLP_CMDW_READ_SCP_INFO_FORCED 0x00120001 | 60 | #define SCLP_CMDW_READ_SCP_INFO_FORCED 0x00120001 |
57 | 61 | ||
58 | #define GDS_ID_MDSMU 0x1310 | 62 | #define GDS_ID_MDSMU 0x1310 |
59 | #define GDS_ID_MDSRouteInfo 0x1311 | 63 | #define GDS_ID_MDSROUTEINFO 0x1311 |
60 | #define GDS_ID_AgUnWrkCorr 0x1549 | 64 | #define GDS_ID_AGUNWRKCORR 0x1549 |
61 | #define GDS_ID_SNACondReport 0x1532 | 65 | #define GDS_ID_SNACONDREPORT 0x1532 |
62 | #define GDS_ID_CPMSU 0x1212 | 66 | #define GDS_ID_CPMSU 0x1212 |
63 | #define GDS_ID_RoutTargInstr 0x154D | 67 | #define GDS_ID_ROUTTARGINSTR 0x154D |
64 | #define GDS_ID_OpReq 0x8070 | 68 | #define GDS_ID_OPREQ 0x8070 |
65 | #define GDS_ID_TextCmd 0x1320 | 69 | #define GDS_ID_TEXTCMD 0x1320 |
66 | 70 | ||
67 | #define GDS_KEY_SelfDefTextMsg 0x31 | 71 | #define GDS_KEY_SELFDEFTEXTMSG 0x31 |
68 | 72 | ||
69 | typedef u32 sccb_mask_t; /* ATTENTION: assumes 32bit mask !!! */ | 73 | typedef u32 sccb_mask_t; /* ATTENTION: assumes 32bit mask !!! */ |
70 | 74 | ||
diff --git a/drivers/s390/char/sclp_chp.c b/drivers/s390/char/sclp_chp.c new file mode 100644 index 000000000000..a66b914519b5 --- /dev/null +++ b/drivers/s390/char/sclp_chp.c | |||
@@ -0,0 +1,196 @@ | |||
1 | /* | ||
2 | * drivers/s390/char/sclp_chp.c | ||
3 | * | ||
4 | * Copyright IBM Corp. 2007 | ||
5 | * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> | ||
6 | */ | ||
7 | |||
8 | #include <linux/types.h> | ||
9 | #include <linux/gfp.h> | ||
10 | #include <linux/errno.h> | ||
11 | #include <linux/completion.h> | ||
12 | #include <asm/sclp.h> | ||
13 | #include <asm/chpid.h> | ||
14 | |||
15 | #include "sclp.h" | ||
16 | |||
17 | #define TAG "sclp_chp: " | ||
18 | |||
19 | #define SCLP_CMDW_CONFIGURE_CHANNEL_PATH 0x000f0001 | ||
20 | #define SCLP_CMDW_DECONFIGURE_CHANNEL_PATH 0x000e0001 | ||
21 | #define SCLP_CMDW_READ_CHANNEL_PATH_INFORMATION 0x00030001 | ||
22 | |||
23 | static inline sclp_cmdw_t get_configure_cmdw(struct chp_id chpid) | ||
24 | { | ||
25 | return SCLP_CMDW_CONFIGURE_CHANNEL_PATH | chpid.id << 8; | ||
26 | } | ||
27 | |||
28 | static inline sclp_cmdw_t get_deconfigure_cmdw(struct chp_id chpid) | ||
29 | { | ||
30 | return SCLP_CMDW_DECONFIGURE_CHANNEL_PATH | chpid.id << 8; | ||
31 | } | ||
32 | |||
33 | static void chp_callback(struct sclp_req *req, void *data) | ||
34 | { | ||
35 | struct completion *completion = data; | ||
36 | |||
37 | complete(completion); | ||
38 | } | ||
39 | |||
40 | struct chp_cfg_sccb { | ||
41 | struct sccb_header header; | ||
42 | u8 ccm; | ||
43 | u8 reserved[6]; | ||
44 | u8 cssid; | ||
45 | } __attribute__((packed)); | ||
46 | |||
47 | struct chp_cfg_data { | ||
48 | struct chp_cfg_sccb sccb; | ||
49 | struct sclp_req req; | ||
50 | struct completion completion; | ||
51 | } __attribute__((packed)); | ||
52 | |||
53 | static int do_configure(sclp_cmdw_t cmd) | ||
54 | { | ||
55 | struct chp_cfg_data *data; | ||
56 | int rc; | ||
57 | |||
58 | /* Prepare sccb. */ | ||
59 | data = (struct chp_cfg_data *) get_zeroed_page(GFP_KERNEL | GFP_DMA); | ||
60 | if (!data) | ||
61 | return -ENOMEM; | ||
62 | data->sccb.header.length = sizeof(struct chp_cfg_sccb); | ||
63 | data->req.command = cmd; | ||
64 | data->req.sccb = &(data->sccb); | ||
65 | data->req.status = SCLP_REQ_FILLED; | ||
66 | data->req.callback = chp_callback; | ||
67 | data->req.callback_data = &(data->completion); | ||
68 | init_completion(&data->completion); | ||
69 | |||
70 | /* Perform sclp request. */ | ||
71 | rc = sclp_add_request(&(data->req)); | ||
72 | if (rc) | ||
73 | goto out; | ||
74 | wait_for_completion(&data->completion); | ||
75 | |||
76 | /* Check response .*/ | ||
77 | if (data->req.status != SCLP_REQ_DONE) { | ||
78 | printk(KERN_WARNING TAG "configure channel-path request failed " | ||
79 | "(status=0x%02x)\n", data->req.status); | ||
80 | rc = -EIO; | ||
81 | goto out; | ||
82 | } | ||
83 | switch (data->sccb.header.response_code) { | ||
84 | case 0x0020: | ||
85 | case 0x0120: | ||
86 | case 0x0440: | ||
87 | case 0x0450: | ||
88 | break; | ||
89 | default: | ||
90 | printk(KERN_WARNING TAG "configure channel-path failed " | ||
91 | "(cmd=0x%08x, response=0x%04x)\n", cmd, | ||
92 | data->sccb.header.response_code); | ||
93 | rc = -EIO; | ||
94 | break; | ||
95 | } | ||
96 | out: | ||
97 | free_page((unsigned long) data); | ||
98 | |||
99 | return rc; | ||
100 | } | ||
101 | |||
102 | /** | ||
103 | * sclp_chp_configure - perform configure channel-path sclp command | ||
104 | * @chpid: channel-path ID | ||
105 | * | ||
106 | * Perform configure channel-path command sclp command for specified chpid. | ||
107 | * Return 0 after command successfully finished, non-zero otherwise. | ||
108 | */ | ||
109 | int sclp_chp_configure(struct chp_id chpid) | ||
110 | { | ||
111 | return do_configure(get_configure_cmdw(chpid)); | ||
112 | } | ||
113 | |||
114 | /** | ||
115 | * sclp_chp_deconfigure - perform deconfigure channel-path sclp command | ||
116 | * @chpid: channel-path ID | ||
117 | * | ||
118 | * Perform deconfigure channel-path command sclp command for specified chpid | ||
119 | * and wait for completion. On success return 0. Return non-zero otherwise. | ||
120 | */ | ||
121 | int sclp_chp_deconfigure(struct chp_id chpid) | ||
122 | { | ||
123 | return do_configure(get_deconfigure_cmdw(chpid)); | ||
124 | } | ||
125 | |||
126 | struct chp_info_sccb { | ||
127 | struct sccb_header header; | ||
128 | u8 recognized[SCLP_CHP_INFO_MASK_SIZE]; | ||
129 | u8 standby[SCLP_CHP_INFO_MASK_SIZE]; | ||
130 | u8 configured[SCLP_CHP_INFO_MASK_SIZE]; | ||
131 | u8 ccm; | ||
132 | u8 reserved[6]; | ||
133 | u8 cssid; | ||
134 | } __attribute__((packed)); | ||
135 | |||
136 | struct chp_info_data { | ||
137 | struct chp_info_sccb sccb; | ||
138 | struct sclp_req req; | ||
139 | struct completion completion; | ||
140 | } __attribute__((packed)); | ||
141 | |||
142 | /** | ||
143 | * sclp_chp_read_info - perform read channel-path information sclp command | ||
144 | * @info: resulting channel-path information data | ||
145 | * | ||
146 | * Perform read channel-path information sclp command and wait for completion. | ||
147 | * On success, store channel-path information in @info and return 0. Return | ||
148 | * non-zero otherwise. | ||
149 | */ | ||
150 | int sclp_chp_read_info(struct sclp_chp_info *info) | ||
151 | { | ||
152 | struct chp_info_data *data; | ||
153 | int rc; | ||
154 | |||
155 | /* Prepare sccb. */ | ||
156 | data = (struct chp_info_data *) get_zeroed_page(GFP_KERNEL | GFP_DMA); | ||
157 | if (!data) | ||
158 | return -ENOMEM; | ||
159 | data->sccb.header.length = sizeof(struct chp_info_sccb); | ||
160 | data->req.command = SCLP_CMDW_READ_CHANNEL_PATH_INFORMATION; | ||
161 | data->req.sccb = &(data->sccb); | ||
162 | data->req.status = SCLP_REQ_FILLED; | ||
163 | data->req.callback = chp_callback; | ||
164 | data->req.callback_data = &(data->completion); | ||
165 | init_completion(&data->completion); | ||
166 | |||
167 | /* Perform sclp request. */ | ||
168 | rc = sclp_add_request(&(data->req)); | ||
169 | if (rc) | ||
170 | goto out; | ||
171 | wait_for_completion(&data->completion); | ||
172 | |||
173 | /* Check response .*/ | ||
174 | if (data->req.status != SCLP_REQ_DONE) { | ||
175 | printk(KERN_WARNING TAG "read channel-path info request failed " | ||
176 | "(status=0x%02x)\n", data->req.status); | ||
177 | rc = -EIO; | ||
178 | goto out; | ||
179 | } | ||
180 | if (data->sccb.header.response_code != 0x0010) { | ||
181 | printk(KERN_WARNING TAG "read channel-path info failed " | ||
182 | "(response=0x%04x)\n", data->sccb.header.response_code); | ||
183 | rc = -EIO; | ||
184 | goto out; | ||
185 | } | ||
186 | memcpy(info->recognized, data->sccb.recognized, | ||
187 | SCLP_CHP_INFO_MASK_SIZE); | ||
188 | memcpy(info->standby, data->sccb.standby, | ||
189 | SCLP_CHP_INFO_MASK_SIZE); | ||
190 | memcpy(info->configured, data->sccb.configured, | ||
191 | SCLP_CHP_INFO_MASK_SIZE); | ||
192 | out: | ||
193 | free_page((unsigned long) data); | ||
194 | |||
195 | return rc; | ||
196 | } | ||
diff --git a/drivers/s390/char/sclp_config.c b/drivers/s390/char/sclp_config.c new file mode 100644 index 000000000000..5322e5e54a98 --- /dev/null +++ b/drivers/s390/char/sclp_config.c | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | * drivers/s390/char/sclp_config.c | ||
3 | * | ||
4 | * Copyright IBM Corp. 2007 | ||
5 | * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> | ||
6 | */ | ||
7 | |||
8 | #include <linux/init.h> | ||
9 | #include <linux/errno.h> | ||
10 | #include <linux/cpu.h> | ||
11 | #include <linux/sysdev.h> | ||
12 | #include <linux/workqueue.h> | ||
13 | #include "sclp.h" | ||
14 | |||
15 | #define TAG "sclp_config: " | ||
16 | |||
17 | struct conf_mgm_data { | ||
18 | u8 reserved; | ||
19 | u8 ev_qualifier; | ||
20 | } __attribute__((packed)); | ||
21 | |||
22 | #define EV_QUAL_CAP_CHANGE 3 | ||
23 | |||
24 | static struct work_struct sclp_cpu_capability_work; | ||
25 | |||
26 | static void sclp_cpu_capability_notify(struct work_struct *work) | ||
27 | { | ||
28 | int cpu; | ||
29 | struct sys_device *sysdev; | ||
30 | |||
31 | printk(KERN_WARNING TAG "cpu capability changed.\n"); | ||
32 | lock_cpu_hotplug(); | ||
33 | for_each_online_cpu(cpu) { | ||
34 | sysdev = get_cpu_sysdev(cpu); | ||
35 | kobject_uevent(&sysdev->kobj, KOBJ_CHANGE); | ||
36 | } | ||
37 | unlock_cpu_hotplug(); | ||
38 | } | ||
39 | |||
40 | static void sclp_conf_receiver_fn(struct evbuf_header *evbuf) | ||
41 | { | ||
42 | struct conf_mgm_data *cdata; | ||
43 | |||
44 | cdata = (struct conf_mgm_data *)(evbuf + 1); | ||
45 | if (cdata->ev_qualifier == EV_QUAL_CAP_CHANGE) | ||
46 | schedule_work(&sclp_cpu_capability_work); | ||
47 | } | ||
48 | |||
49 | static struct sclp_register sclp_conf_register = | ||
50 | { | ||
51 | .receive_mask = EVTYP_CONFMGMDATA_MASK, | ||
52 | .receiver_fn = sclp_conf_receiver_fn, | ||
53 | }; | ||
54 | |||
55 | static int __init sclp_conf_init(void) | ||
56 | { | ||
57 | int rc; | ||
58 | |||
59 | INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify); | ||
60 | |||
61 | rc = sclp_register(&sclp_conf_register); | ||
62 | if (rc) { | ||
63 | printk(KERN_ERR TAG "failed to register (%d).\n", rc); | ||
64 | return rc; | ||
65 | } | ||
66 | |||
67 | if (!(sclp_conf_register.sclp_receive_mask & EVTYP_CONFMGMDATA_MASK)) { | ||
68 | printk(KERN_WARNING TAG "no configuration management.\n"); | ||
69 | sclp_unregister(&sclp_conf_register); | ||
70 | rc = -ENOSYS; | ||
71 | } | ||
72 | return rc; | ||
73 | } | ||
74 | |||
75 | __initcall(sclp_conf_init); | ||
diff --git a/drivers/s390/char/sclp_cpi.c b/drivers/s390/char/sclp_cpi.c index 65aa2c85737f..29fe2a5ec2fe 100644 --- a/drivers/s390/char/sclp_cpi.c +++ b/drivers/s390/char/sclp_cpi.c | |||
@@ -46,7 +46,7 @@ struct cpi_sccb { | |||
46 | /* Event type structure for write message and write priority message */ | 46 | /* Event type structure for write message and write priority message */ |
47 | static struct sclp_register sclp_cpi_event = | 47 | static struct sclp_register sclp_cpi_event = |
48 | { | 48 | { |
49 | .send_mask = EvTyp_CtlProgIdent_Mask | 49 | .send_mask = EVTYP_CTLPROGIDENT_MASK |
50 | }; | 50 | }; |
51 | 51 | ||
52 | MODULE_LICENSE("GPL"); | 52 | MODULE_LICENSE("GPL"); |
@@ -201,7 +201,7 @@ cpi_module_init(void) | |||
201 | "console.\n"); | 201 | "console.\n"); |
202 | return -EINVAL; | 202 | return -EINVAL; |
203 | } | 203 | } |
204 | if (!(sclp_cpi_event.sclp_send_mask & EvTyp_CtlProgIdent_Mask)) { | 204 | if (!(sclp_cpi_event.sclp_send_mask & EVTYP_CTLPROGIDENT_MASK)) { |
205 | printk(KERN_WARNING "cpi: no control program identification " | 205 | printk(KERN_WARNING "cpi: no control program identification " |
206 | "support\n"); | 206 | "support\n"); |
207 | sclp_unregister(&sclp_cpi_event); | 207 | sclp_unregister(&sclp_cpi_event); |
diff --git a/drivers/s390/char/sclp_quiesce.c b/drivers/s390/char/sclp_quiesce.c index baa8fe669ed2..45ff25e787cb 100644 --- a/drivers/s390/char/sclp_quiesce.c +++ b/drivers/s390/char/sclp_quiesce.c | |||
@@ -43,7 +43,7 @@ sclp_quiesce_handler(struct evbuf_header *evbuf) | |||
43 | } | 43 | } |
44 | 44 | ||
45 | static struct sclp_register sclp_quiesce_event = { | 45 | static struct sclp_register sclp_quiesce_event = { |
46 | .receive_mask = EvTyp_SigQuiesce_Mask, | 46 | .receive_mask = EVTYP_SIGQUIESCE_MASK, |
47 | .receiver_fn = sclp_quiesce_handler | 47 | .receiver_fn = sclp_quiesce_handler |
48 | }; | 48 | }; |
49 | 49 | ||
diff --git a/drivers/s390/char/sclp_rw.c b/drivers/s390/char/sclp_rw.c index 2486783ea58e..bbd5b8b66f42 100644 --- a/drivers/s390/char/sclp_rw.c +++ b/drivers/s390/char/sclp_rw.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | /* Event type structure for write message and write priority message */ | 31 | /* Event type structure for write message and write priority message */ |
32 | static struct sclp_register sclp_rw_event = { | 32 | static struct sclp_register sclp_rw_event = { |
33 | .send_mask = EvTyp_Msg_Mask | EvTyp_PMsgCmd_Mask | 33 | .send_mask = EVTYP_MSG_MASK | EVTYP_PMSGCMD_MASK |
34 | }; | 34 | }; |
35 | 35 | ||
36 | /* | 36 | /* |
@@ -64,7 +64,7 @@ sclp_make_buffer(void *page, unsigned short columns, unsigned short htab) | |||
64 | memset(sccb, 0, sizeof(struct write_sccb)); | 64 | memset(sccb, 0, sizeof(struct write_sccb)); |
65 | sccb->header.length = sizeof(struct write_sccb); | 65 | sccb->header.length = sizeof(struct write_sccb); |
66 | sccb->msg_buf.header.length = sizeof(struct msg_buf); | 66 | sccb->msg_buf.header.length = sizeof(struct msg_buf); |
67 | sccb->msg_buf.header.type = EvTyp_Msg; | 67 | sccb->msg_buf.header.type = EVTYP_MSG; |
68 | sccb->msg_buf.mdb.header.length = sizeof(struct mdb); | 68 | sccb->msg_buf.mdb.header.length = sizeof(struct mdb); |
69 | sccb->msg_buf.mdb.header.type = 1; | 69 | sccb->msg_buf.mdb.header.type = 1; |
70 | sccb->msg_buf.mdb.header.tag = 0xD4C4C240; /* ebcdic "MDB " */ | 70 | sccb->msg_buf.mdb.header.tag = 0xD4C4C240; /* ebcdic "MDB " */ |
@@ -114,7 +114,7 @@ sclp_initialize_mto(struct sclp_buffer *buffer, int max_len) | |||
114 | memset(mto, 0, sizeof(struct mto)); | 114 | memset(mto, 0, sizeof(struct mto)); |
115 | mto->length = sizeof(struct mto); | 115 | mto->length = sizeof(struct mto); |
116 | mto->type = 4; /* message text object */ | 116 | mto->type = 4; /* message text object */ |
117 | mto->line_type_flags = LnTpFlgs_EndText; /* end text */ | 117 | mto->line_type_flags = LNTPFLGS_ENDTEXT; /* end text */ |
118 | 118 | ||
119 | /* set pointer to first byte after struct mto. */ | 119 | /* set pointer to first byte after struct mto. */ |
120 | buffer->current_line = (char *) (mto + 1); | 120 | buffer->current_line = (char *) (mto + 1); |
@@ -215,7 +215,7 @@ sclp_write(struct sclp_buffer *buffer, const unsigned char *msg, int count) | |||
215 | case '\a': /* bell, one for several times */ | 215 | case '\a': /* bell, one for several times */ |
216 | /* set SCLP sound alarm bit in General Object */ | 216 | /* set SCLP sound alarm bit in General Object */ |
217 | buffer->sccb->msg_buf.mdb.go.general_msg_flags |= | 217 | buffer->sccb->msg_buf.mdb.go.general_msg_flags |= |
218 | GnrlMsgFlgs_SndAlrm; | 218 | GNRLMSGFLGS_SNDALRM; |
219 | break; | 219 | break; |
220 | case '\t': /* horizontal tabulator */ | 220 | case '\t': /* horizontal tabulator */ |
221 | /* check if new mto needs to be created */ | 221 | /* check if new mto needs to be created */ |
@@ -452,12 +452,12 @@ sclp_emit_buffer(struct sclp_buffer *buffer, | |||
452 | return -EIO; | 452 | return -EIO; |
453 | 453 | ||
454 | sccb = buffer->sccb; | 454 | sccb = buffer->sccb; |
455 | if (sclp_rw_event.sclp_send_mask & EvTyp_Msg_Mask) | 455 | if (sclp_rw_event.sclp_send_mask & EVTYP_MSG_MASK) |
456 | /* Use normal write message */ | 456 | /* Use normal write message */ |
457 | sccb->msg_buf.header.type = EvTyp_Msg; | 457 | sccb->msg_buf.header.type = EVTYP_MSG; |
458 | else if (sclp_rw_event.sclp_send_mask & EvTyp_PMsgCmd_Mask) | 458 | else if (sclp_rw_event.sclp_send_mask & EVTYP_PMSGCMD_MASK) |
459 | /* Use write priority message */ | 459 | /* Use write priority message */ |
460 | sccb->msg_buf.header.type = EvTyp_PMsgCmd; | 460 | sccb->msg_buf.header.type = EVTYP_PMSGCMD; |
461 | else | 461 | else |
462 | return -ENOSYS; | 462 | return -ENOSYS; |
463 | buffer->request.command = SCLP_CMDW_WRITE_EVENT_DATA; | 463 | buffer->request.command = SCLP_CMDW_WRITE_EVENT_DATA; |
diff --git a/drivers/s390/char/sclp_sdias.c b/drivers/s390/char/sclp_sdias.c new file mode 100644 index 000000000000..52283daddaef --- /dev/null +++ b/drivers/s390/char/sclp_sdias.c | |||
@@ -0,0 +1,255 @@ | |||
1 | /* | ||
2 | * Sclp "store data in absolut storage" | ||
3 | * | ||
4 | * Copyright IBM Corp. 2003,2007 | ||
5 | * Author(s): Michael Holzheu | ||
6 | */ | ||
7 | |||
8 | #include <linux/sched.h> | ||
9 | #include <asm/sclp.h> | ||
10 | #include <asm/debug.h> | ||
11 | #include <asm/ipl.h> | ||
12 | #include "sclp.h" | ||
13 | #include "sclp_rw.h" | ||
14 | |||
15 | #define TRACE(x...) debug_sprintf_event(sdias_dbf, 1, x) | ||
16 | #define ERROR_MSG(x...) printk ( KERN_ALERT "SDIAS: " x ) | ||
17 | |||
18 | #define SDIAS_RETRIES 300 | ||
19 | #define SDIAS_SLEEP_TICKS 50 | ||
20 | |||
21 | #define EQ_STORE_DATA 0x0 | ||
22 | #define EQ_SIZE 0x1 | ||
23 | #define DI_FCP_DUMP 0x0 | ||
24 | #define ASA_SIZE_32 0x0 | ||
25 | #define ASA_SIZE_64 0x1 | ||
26 | #define EVSTATE_ALL_STORED 0x0 | ||
27 | #define EVSTATE_NO_DATA 0x3 | ||
28 | #define EVSTATE_PART_STORED 0x10 | ||
29 | |||
30 | static struct debug_info *sdias_dbf; | ||
31 | |||
32 | static struct sclp_register sclp_sdias_register = { | ||
33 | .send_mask = EVTYP_SDIAS_MASK, | ||
34 | }; | ||
35 | |||
36 | struct sdias_evbuf { | ||
37 | struct evbuf_header hdr; | ||
38 | u8 event_qual; | ||
39 | u8 data_id; | ||
40 | u64 reserved2; | ||
41 | u32 event_id; | ||
42 | u16 reserved3; | ||
43 | u8 asa_size; | ||
44 | u8 event_status; | ||
45 | u32 reserved4; | ||
46 | u32 blk_cnt; | ||
47 | u64 asa; | ||
48 | u32 reserved5; | ||
49 | u32 fbn; | ||
50 | u32 reserved6; | ||
51 | u32 lbn; | ||
52 | u16 reserved7; | ||
53 | u16 dbs; | ||
54 | } __attribute__((packed)); | ||
55 | |||
56 | struct sdias_sccb { | ||
57 | struct sccb_header hdr; | ||
58 | struct sdias_evbuf evbuf; | ||
59 | } __attribute__((packed)); | ||
60 | |||
61 | static struct sdias_sccb sccb __attribute__((aligned(4096))); | ||
62 | |||
63 | static int sclp_req_done; | ||
64 | static wait_queue_head_t sdias_wq; | ||
65 | static DEFINE_MUTEX(sdias_mutex); | ||
66 | |||
67 | static void sdias_callback(struct sclp_req *request, void *data) | ||
68 | { | ||
69 | struct sdias_sccb *sccb; | ||
70 | |||
71 | sccb = (struct sdias_sccb *) request->sccb; | ||
72 | sclp_req_done = 1; | ||
73 | wake_up(&sdias_wq); /* Inform caller, that request is complete */ | ||
74 | TRACE("callback done\n"); | ||
75 | } | ||
76 | |||
77 | static int sdias_sclp_send(struct sclp_req *req) | ||
78 | { | ||
79 | int retries; | ||
80 | int rc; | ||
81 | |||
82 | for (retries = SDIAS_RETRIES; retries; retries--) { | ||
83 | sclp_req_done = 0; | ||
84 | TRACE("add request\n"); | ||
85 | rc = sclp_add_request(req); | ||
86 | if (rc) { | ||
87 | /* not initiated, wait some time and retry */ | ||
88 | set_current_state(TASK_INTERRUPTIBLE); | ||
89 | TRACE("add request failed: rc = %i\n",rc); | ||
90 | schedule_timeout(SDIAS_SLEEP_TICKS); | ||
91 | continue; | ||
92 | } | ||
93 | /* initiated, wait for completion of service call */ | ||
94 | wait_event(sdias_wq, (sclp_req_done == 1)); | ||
95 | if (req->status == SCLP_REQ_FAILED) { | ||
96 | TRACE("sclp request failed\n"); | ||
97 | rc = -EIO; | ||
98 | continue; | ||
99 | } | ||
100 | TRACE("request done\n"); | ||
101 | break; | ||
102 | } | ||
103 | return rc; | ||
104 | } | ||
105 | |||
106 | /* | ||
107 | * Get number of blocks (4K) available in the HSA | ||
108 | */ | ||
109 | int sclp_sdias_blk_count(void) | ||
110 | { | ||
111 | struct sclp_req request; | ||
112 | int rc; | ||
113 | |||
114 | mutex_lock(&sdias_mutex); | ||
115 | |||
116 | memset(&sccb, 0, sizeof(sccb)); | ||
117 | memset(&request, 0, sizeof(request)); | ||
118 | |||
119 | sccb.hdr.length = sizeof(sccb); | ||
120 | sccb.evbuf.hdr.length = sizeof(struct sdias_evbuf); | ||
121 | sccb.evbuf.hdr.type = EVTYP_SDIAS; | ||
122 | sccb.evbuf.event_qual = EQ_SIZE; | ||
123 | sccb.evbuf.data_id = DI_FCP_DUMP; | ||
124 | sccb.evbuf.event_id = 4712; | ||
125 | sccb.evbuf.dbs = 1; | ||
126 | |||
127 | request.sccb = &sccb; | ||
128 | request.command = SCLP_CMDW_WRITE_EVENT_DATA; | ||
129 | request.status = SCLP_REQ_FILLED; | ||
130 | request.callback = sdias_callback; | ||
131 | |||
132 | rc = sdias_sclp_send(&request); | ||
133 | if (rc) { | ||
134 | ERROR_MSG("sclp_send failed for get_nr_blocks\n"); | ||
135 | goto out; | ||
136 | } | ||
137 | if (sccb.hdr.response_code != 0x0020) { | ||
138 | TRACE("send failed: %x\n", sccb.hdr.response_code); | ||
139 | rc = -EIO; | ||
140 | goto out; | ||
141 | } | ||
142 | |||
143 | switch (sccb.evbuf.event_status) { | ||
144 | case 0: | ||
145 | rc = sccb.evbuf.blk_cnt; | ||
146 | break; | ||
147 | default: | ||
148 | ERROR_MSG("SCLP error: %x\n", sccb.evbuf.event_status); | ||
149 | rc = -EIO; | ||
150 | goto out; | ||
151 | } | ||
152 | TRACE("%i blocks\n", rc); | ||
153 | out: | ||
154 | mutex_unlock(&sdias_mutex); | ||
155 | return rc; | ||
156 | } | ||
157 | |||
158 | /* | ||
159 | * Copy from HSA to absolute storage (not reentrant): | ||
160 | * | ||
161 | * @dest : Address of buffer where data should be copied | ||
162 | * @start_blk: Start Block (beginning with 1) | ||
163 | * @nr_blks : Number of 4K blocks to copy | ||
164 | * | ||
165 | * Return Value: 0 : Requested 'number' of blocks of data copied | ||
166 | * <0: ERROR - negative event status | ||
167 | */ | ||
168 | int sclp_sdias_copy(void *dest, int start_blk, int nr_blks) | ||
169 | { | ||
170 | struct sclp_req request; | ||
171 | int rc; | ||
172 | |||
173 | mutex_lock(&sdias_mutex); | ||
174 | |||
175 | memset(&sccb, 0, sizeof(sccb)); | ||
176 | memset(&request, 0, sizeof(request)); | ||
177 | |||
178 | sccb.hdr.length = sizeof(sccb); | ||
179 | sccb.evbuf.hdr.length = sizeof(struct sdias_evbuf); | ||
180 | sccb.evbuf.hdr.type = EVTYP_SDIAS; | ||
181 | sccb.evbuf.hdr.flags = 0; | ||
182 | sccb.evbuf.event_qual = EQ_STORE_DATA; | ||
183 | sccb.evbuf.data_id = DI_FCP_DUMP; | ||
184 | sccb.evbuf.event_id = 4712; | ||
185 | #ifdef __s390x__ | ||
186 | sccb.evbuf.asa_size = ASA_SIZE_64; | ||
187 | #else | ||
188 | sccb.evbuf.asa_size = ASA_SIZE_32; | ||
189 | #endif | ||
190 | sccb.evbuf.event_status = 0; | ||
191 | sccb.evbuf.blk_cnt = nr_blks; | ||
192 | sccb.evbuf.asa = (unsigned long)dest; | ||
193 | sccb.evbuf.fbn = start_blk; | ||
194 | sccb.evbuf.lbn = 0; | ||
195 | sccb.evbuf.dbs = 1; | ||
196 | |||
197 | request.sccb = &sccb; | ||
198 | request.command = SCLP_CMDW_WRITE_EVENT_DATA; | ||
199 | request.status = SCLP_REQ_FILLED; | ||
200 | request.callback = sdias_callback; | ||
201 | |||
202 | rc = sdias_sclp_send(&request); | ||
203 | if (rc) { | ||
204 | ERROR_MSG("sclp_send failed: %x\n", rc); | ||
205 | goto out; | ||
206 | } | ||
207 | if (sccb.hdr.response_code != 0x0020) { | ||
208 | TRACE("copy failed: %x\n", sccb.hdr.response_code); | ||
209 | rc = -EIO; | ||
210 | goto out; | ||
211 | } | ||
212 | |||
213 | switch (sccb.evbuf.event_status) { | ||
214 | case EVSTATE_ALL_STORED: | ||
215 | TRACE("all stored\n"); | ||
216 | case EVSTATE_PART_STORED: | ||
217 | TRACE("part stored: %i\n", sccb.evbuf.blk_cnt); | ||
218 | break; | ||
219 | case EVSTATE_NO_DATA: | ||
220 | TRACE("no data\n"); | ||
221 | default: | ||
222 | ERROR_MSG("Error from SCLP while copying hsa. " | ||
223 | "Event status = %x\n", | ||
224 | sccb.evbuf.event_status); | ||
225 | rc = -EIO; | ||
226 | } | ||
227 | out: | ||
228 | mutex_unlock(&sdias_mutex); | ||
229 | return rc; | ||
230 | } | ||
231 | |||
232 | int __init sdias_init(void) | ||
233 | { | ||
234 | int rc; | ||
235 | |||
236 | if (ipl_info.type != IPL_TYPE_FCP_DUMP) | ||
237 | return 0; | ||
238 | sdias_dbf = debug_register("dump_sdias", 4, 1, 4 * sizeof(long)); | ||
239 | debug_register_view(sdias_dbf, &debug_sprintf_view); | ||
240 | debug_set_level(sdias_dbf, 6); | ||
241 | rc = sclp_register(&sclp_sdias_register); | ||
242 | if (rc) { | ||
243 | ERROR_MSG("sclp register failed\n"); | ||
244 | return rc; | ||
245 | } | ||
246 | init_waitqueue_head(&sdias_wq); | ||
247 | TRACE("init done\n"); | ||
248 | return 0; | ||
249 | } | ||
250 | |||
251 | void __exit sdias_exit(void) | ||
252 | { | ||
253 | debug_unregister(sdias_dbf); | ||
254 | sclp_unregister(&sclp_sdias_register); | ||
255 | } | ||
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c index 076816b9d528..e3b3d390b4a3 100644 --- a/drivers/s390/char/sclp_tty.c +++ b/drivers/s390/char/sclp_tty.c | |||
@@ -648,7 +648,7 @@ sclp_eval_textcmd(struct gds_subvector *start, | |||
648 | subvec = start; | 648 | subvec = start; |
649 | while (subvec < end) { | 649 | while (subvec < end) { |
650 | subvec = find_gds_subvector(subvec, end, | 650 | subvec = find_gds_subvector(subvec, end, |
651 | GDS_KEY_SelfDefTextMsg); | 651 | GDS_KEY_SELFDEFTEXTMSG); |
652 | if (!subvec) | 652 | if (!subvec) |
653 | break; | 653 | break; |
654 | sclp_eval_selfdeftextmsg((struct gds_subvector *)(subvec + 1), | 654 | sclp_eval_selfdeftextmsg((struct gds_subvector *)(subvec + 1), |
@@ -664,7 +664,7 @@ sclp_eval_cpmsu(struct gds_vector *start, struct gds_vector *end) | |||
664 | 664 | ||
665 | vec = start; | 665 | vec = start; |
666 | while (vec < end) { | 666 | while (vec < end) { |
667 | vec = find_gds_vector(vec, end, GDS_ID_TextCmd); | 667 | vec = find_gds_vector(vec, end, GDS_ID_TEXTCMD); |
668 | if (!vec) | 668 | if (!vec) |
669 | break; | 669 | break; |
670 | sclp_eval_textcmd((struct gds_subvector *)(vec + 1), | 670 | sclp_eval_textcmd((struct gds_subvector *)(vec + 1), |
@@ -703,7 +703,7 @@ sclp_tty_state_change(struct sclp_register *reg) | |||
703 | 703 | ||
704 | static struct sclp_register sclp_input_event = | 704 | static struct sclp_register sclp_input_event = |
705 | { | 705 | { |
706 | .receive_mask = EvTyp_OpCmd_Mask | EvTyp_PMsgCmd_Mask, | 706 | .receive_mask = EVTYP_OPCMD_MASK | EVTYP_PMSGCMD_MASK, |
707 | .state_change_fn = sclp_tty_state_change, | 707 | .state_change_fn = sclp_tty_state_change, |
708 | .receiver_fn = sclp_tty_receiver | 708 | .receiver_fn = sclp_tty_receiver |
709 | }; | 709 | }; |
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index f77dc33b5f8d..726334757bbf 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c | |||
@@ -99,8 +99,8 @@ static void sclp_vt220_emit_current(void); | |||
99 | 99 | ||
100 | /* Registration structure for our interest in SCLP event buffers */ | 100 | /* Registration structure for our interest in SCLP event buffers */ |
101 | static struct sclp_register sclp_vt220_register = { | 101 | static struct sclp_register sclp_vt220_register = { |
102 | .send_mask = EvTyp_VT220Msg_Mask, | 102 | .send_mask = EVTYP_VT220MSG_MASK, |
103 | .receive_mask = EvTyp_VT220Msg_Mask, | 103 | .receive_mask = EVTYP_VT220MSG_MASK, |
104 | .state_change_fn = NULL, | 104 | .state_change_fn = NULL, |
105 | .receiver_fn = sclp_vt220_receiver_fn | 105 | .receiver_fn = sclp_vt220_receiver_fn |
106 | }; | 106 | }; |
@@ -202,7 +202,7 @@ sclp_vt220_callback(struct sclp_req *request, void *data) | |||
202 | static int | 202 | static int |
203 | __sclp_vt220_emit(struct sclp_vt220_request *request) | 203 | __sclp_vt220_emit(struct sclp_vt220_request *request) |
204 | { | 204 | { |
205 | if (!(sclp_vt220_register.sclp_send_mask & EvTyp_VT220Msg_Mask)) { | 205 | if (!(sclp_vt220_register.sclp_send_mask & EVTYP_VT220MSG_MASK)) { |
206 | request->sclp_req.status = SCLP_REQ_FAILED; | 206 | request->sclp_req.status = SCLP_REQ_FAILED; |
207 | return -EIO; | 207 | return -EIO; |
208 | } | 208 | } |
@@ -284,7 +284,7 @@ sclp_vt220_initialize_page(void *page) | |||
284 | sccb->header.length = sizeof(struct sclp_vt220_sccb); | 284 | sccb->header.length = sizeof(struct sclp_vt220_sccb); |
285 | sccb->header.function_code = SCLP_NORMAL_WRITE; | 285 | sccb->header.function_code = SCLP_NORMAL_WRITE; |
286 | sccb->header.response_code = 0x0000; | 286 | sccb->header.response_code = 0x0000; |
287 | sccb->evbuf.type = EvTyp_VT220Msg; | 287 | sccb->evbuf.type = EVTYP_VT220MSG; |
288 | sccb->evbuf.length = sizeof(struct evbuf_header); | 288 | sccb->evbuf.length = sizeof(struct evbuf_header); |
289 | 289 | ||
290 | return request; | 290 | return request; |
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c index b87d3b019936..a5a00e9ae4d0 100644 --- a/drivers/s390/char/vmlogrdr.c +++ b/drivers/s390/char/vmlogrdr.c | |||
@@ -125,7 +125,7 @@ static struct vmlogrdr_priv_t sys_ser[] = { | |||
125 | .recording_name = "EREP", | 125 | .recording_name = "EREP", |
126 | .minor_num = 0, | 126 | .minor_num = 0, |
127 | .buffer_free = 1, | 127 | .buffer_free = 1, |
128 | .priv_lock = SPIN_LOCK_UNLOCKED, | 128 | .priv_lock = __SPIN_LOCK_UNLOCKED(sys_ser[0].priv_lock), |
129 | .autorecording = 1, | 129 | .autorecording = 1, |
130 | .autopurge = 1, | 130 | .autopurge = 1, |
131 | }, | 131 | }, |
@@ -134,7 +134,7 @@ static struct vmlogrdr_priv_t sys_ser[] = { | |||
134 | .recording_name = "ACCOUNT", | 134 | .recording_name = "ACCOUNT", |
135 | .minor_num = 1, | 135 | .minor_num = 1, |
136 | .buffer_free = 1, | 136 | .buffer_free = 1, |
137 | .priv_lock = SPIN_LOCK_UNLOCKED, | 137 | .priv_lock = __SPIN_LOCK_UNLOCKED(sys_ser[1].priv_lock), |
138 | .autorecording = 1, | 138 | .autorecording = 1, |
139 | .autopurge = 1, | 139 | .autopurge = 1, |
140 | }, | 140 | }, |
@@ -143,7 +143,7 @@ static struct vmlogrdr_priv_t sys_ser[] = { | |||
143 | .recording_name = "SYMPTOM", | 143 | .recording_name = "SYMPTOM", |
144 | .minor_num = 2, | 144 | .minor_num = 2, |
145 | .buffer_free = 1, | 145 | .buffer_free = 1, |
146 | .priv_lock = SPIN_LOCK_UNLOCKED, | 146 | .priv_lock = __SPIN_LOCK_UNLOCKED(sys_ser[2].priv_lock), |
147 | .autorecording = 1, | 147 | .autorecording = 1, |
148 | .autopurge = 1, | 148 | .autopurge = 1, |
149 | } | 149 | } |
@@ -385,6 +385,9 @@ static int vmlogrdr_release (struct inode *inode, struct file *filp) | |||
385 | 385 | ||
386 | struct vmlogrdr_priv_t * logptr = filp->private_data; | 386 | struct vmlogrdr_priv_t * logptr = filp->private_data; |
387 | 387 | ||
388 | iucv_path_sever(logptr->path, NULL); | ||
389 | kfree(logptr->path); | ||
390 | logptr->path = NULL; | ||
388 | if (logptr->autorecording) { | 391 | if (logptr->autorecording) { |
389 | ret = vmlogrdr_recording(logptr,0,logptr->autopurge); | 392 | ret = vmlogrdr_recording(logptr,0,logptr->autopurge); |
390 | if (ret) | 393 | if (ret) |
diff --git a/drivers/s390/char/zcore.c b/drivers/s390/char/zcore.c new file mode 100644 index 000000000000..89d439316a53 --- /dev/null +++ b/drivers/s390/char/zcore.c | |||
@@ -0,0 +1,651 @@ | |||
1 | /* | ||
2 | * zcore module to export memory content and register sets for creating system | ||
3 | * dumps on SCSI disks (zfcpdump). The "zcore/mem" debugfs file shows the same | ||
4 | * dump format as s390 standalone dumps. | ||
5 | * | ||
6 | * For more information please refer to Documentation/s390/zfcpdump.txt | ||
7 | * | ||
8 | * Copyright IBM Corp. 2003,2007 | ||
9 | * Author(s): Michael Holzheu | ||
10 | */ | ||
11 | |||
12 | #include <linux/init.h> | ||
13 | #include <linux/miscdevice.h> | ||
14 | #include <linux/utsname.h> | ||
15 | #include <linux/debugfs.h> | ||
16 | #include <asm/ipl.h> | ||
17 | #include <asm/sclp.h> | ||
18 | #include <asm/setup.h> | ||
19 | #include <asm/sigp.h> | ||
20 | #include <asm/uaccess.h> | ||
21 | #include <asm/debug.h> | ||
22 | #include <asm/processor.h> | ||
23 | #include <asm/irqflags.h> | ||
24 | |||
25 | #define TRACE(x...) debug_sprintf_event(zcore_dbf, 1, x) | ||
26 | #define MSG(x...) printk( KERN_ALERT x ) | ||
27 | #define ERROR_MSG(x...) printk ( KERN_ALERT "DUMP: " x ) | ||
28 | |||
29 | #define TO_USER 0 | ||
30 | #define TO_KERNEL 1 | ||
31 | |||
32 | enum arch_id { | ||
33 | ARCH_S390 = 0, | ||
34 | ARCH_S390X = 1, | ||
35 | }; | ||
36 | |||
37 | /* dump system info */ | ||
38 | |||
39 | struct sys_info { | ||
40 | enum arch_id arch; | ||
41 | unsigned long sa_base; | ||
42 | u32 sa_size; | ||
43 | int cpu_map[NR_CPUS]; | ||
44 | unsigned long mem_size; | ||
45 | union save_area lc_mask; | ||
46 | }; | ||
47 | |||
48 | static struct sys_info sys_info; | ||
49 | static struct debug_info *zcore_dbf; | ||
50 | static int hsa_available; | ||
51 | static struct dentry *zcore_dir; | ||
52 | static struct dentry *zcore_file; | ||
53 | |||
54 | /* | ||
55 | * Copy memory from HSA to kernel or user memory (not reentrant): | ||
56 | * | ||
57 | * @dest: Kernel or user buffer where memory should be copied to | ||
58 | * @src: Start address within HSA where data should be copied | ||
59 | * @count: Size of buffer, which should be copied | ||
60 | * @mode: Either TO_KERNEL or TO_USER | ||
61 | */ | ||
62 | static int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode) | ||
63 | { | ||
64 | int offs, blk_num; | ||
65 | static char buf[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); | ||
66 | |||
67 | if (count == 0) | ||
68 | return 0; | ||
69 | |||
70 | /* copy first block */ | ||
71 | offs = 0; | ||
72 | if ((src % PAGE_SIZE) != 0) { | ||
73 | blk_num = src / PAGE_SIZE + 2; | ||
74 | if (sclp_sdias_copy(buf, blk_num, 1)) { | ||
75 | TRACE("sclp_sdias_copy() failed\n"); | ||
76 | return -EIO; | ||
77 | } | ||
78 | offs = min((PAGE_SIZE - (src % PAGE_SIZE)), count); | ||
79 | if (mode == TO_USER) { | ||
80 | if (copy_to_user((__force __user void*) dest, | ||
81 | buf + (src % PAGE_SIZE), offs)) | ||
82 | return -EFAULT; | ||
83 | } else | ||
84 | memcpy(dest, buf + (src % PAGE_SIZE), offs); | ||
85 | } | ||
86 | if (offs == count) | ||
87 | goto out; | ||
88 | |||
89 | /* copy middle */ | ||
90 | for (; (offs + PAGE_SIZE) <= count; offs += PAGE_SIZE) { | ||
91 | blk_num = (src + offs) / PAGE_SIZE + 2; | ||
92 | if (sclp_sdias_copy(buf, blk_num, 1)) { | ||
93 | TRACE("sclp_sdias_copy() failed\n"); | ||
94 | return -EIO; | ||
95 | } | ||
96 | if (mode == TO_USER) { | ||
97 | if (copy_to_user((__force __user void*) dest + offs, | ||
98 | buf, PAGE_SIZE)) | ||
99 | return -EFAULT; | ||
100 | } else | ||
101 | memcpy(dest + offs, buf, PAGE_SIZE); | ||
102 | } | ||
103 | if (offs == count) | ||
104 | goto out; | ||
105 | |||
106 | /* copy last block */ | ||
107 | blk_num = (src + offs) / PAGE_SIZE + 2; | ||
108 | if (sclp_sdias_copy(buf, blk_num, 1)) { | ||
109 | TRACE("sclp_sdias_copy() failed\n"); | ||
110 | return -EIO; | ||
111 | } | ||
112 | if (mode == TO_USER) { | ||
113 | if (copy_to_user((__force __user void*) dest + offs, buf, | ||
114 | PAGE_SIZE)) | ||
115 | return -EFAULT; | ||
116 | } else | ||
117 | memcpy(dest + offs, buf, count - offs); | ||
118 | out: | ||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | static int memcpy_hsa_user(void __user *dest, unsigned long src, size_t count) | ||
123 | { | ||
124 | return memcpy_hsa((void __force *) dest, src, count, TO_USER); | ||
125 | } | ||
126 | |||
127 | static int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count) | ||
128 | { | ||
129 | return memcpy_hsa(dest, src, count, TO_KERNEL); | ||
130 | } | ||
131 | |||
132 | static int memcpy_real(void *dest, unsigned long src, size_t count) | ||
133 | { | ||
134 | unsigned long flags; | ||
135 | int rc = -EFAULT; | ||
136 | register unsigned long _dest asm("2") = (unsigned long) dest; | ||
137 | register unsigned long _len1 asm("3") = (unsigned long) count; | ||
138 | register unsigned long _src asm("4") = src; | ||
139 | register unsigned long _len2 asm("5") = (unsigned long) count; | ||
140 | |||
141 | if (count == 0) | ||
142 | return 0; | ||
143 | flags = __raw_local_irq_stnsm(0xf8); /* switch to real mode */ | ||
144 | asm volatile ( | ||
145 | "0: mvcle %1,%2,0x0\n" | ||
146 | "1: jo 0b\n" | ||
147 | " lhi %0,0x0\n" | ||
148 | "2:\n" | ||
149 | EX_TABLE(1b,2b) | ||
150 | : "+d" (rc) | ||
151 | : "d" (_dest), "d" (_src), "d" (_len1), "d" (_len2) | ||
152 | : "cc", "memory"); | ||
153 | __raw_local_irq_ssm(flags); | ||
154 | |||
155 | return rc; | ||
156 | } | ||
157 | |||
158 | static int memcpy_real_user(__user void *dest, unsigned long src, size_t count) | ||
159 | { | ||
160 | static char buf[4096]; | ||
161 | int offs = 0, size; | ||
162 | |||
163 | while (offs < count) { | ||
164 | size = min(sizeof(buf), count - offs); | ||
165 | if (memcpy_real(buf, src + offs, size)) | ||
166 | return -EFAULT; | ||
167 | if (copy_to_user(dest + offs, buf, size)) | ||
168 | return -EFAULT; | ||
169 | offs += size; | ||
170 | } | ||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | #ifdef __s390x__ | ||
175 | /* | ||
176 | * Convert s390x (64 bit) cpu info to s390 (32 bit) cpu info | ||
177 | */ | ||
178 | static void __init s390x_to_s390_regs(union save_area *out, union save_area *in, | ||
179 | int cpu) | ||
180 | { | ||
181 | int i; | ||
182 | |||
183 | for (i = 0; i < 16; i++) { | ||
184 | out->s390.gp_regs[i] = in->s390x.gp_regs[i] & 0x00000000ffffffff; | ||
185 | out->s390.acc_regs[i] = in->s390x.acc_regs[i]; | ||
186 | out->s390.ctrl_regs[i] = | ||
187 | in->s390x.ctrl_regs[i] & 0x00000000ffffffff; | ||
188 | } | ||
189 | /* locore for 31 bit has only space for fpregs 0,2,4,6 */ | ||
190 | out->s390.fp_regs[0] = in->s390x.fp_regs[0]; | ||
191 | out->s390.fp_regs[1] = in->s390x.fp_regs[2]; | ||
192 | out->s390.fp_regs[2] = in->s390x.fp_regs[4]; | ||
193 | out->s390.fp_regs[3] = in->s390x.fp_regs[6]; | ||
194 | memcpy(&(out->s390.psw[0]), &(in->s390x.psw[0]), 4); | ||
195 | out->s390.psw[1] |= 0x8; /* set bit 12 */ | ||
196 | memcpy(&(out->s390.psw[4]),&(in->s390x.psw[12]), 4); | ||
197 | out->s390.psw[4] |= 0x80; /* set (31bit) addressing bit */ | ||
198 | out->s390.pref_reg = in->s390x.pref_reg; | ||
199 | out->s390.timer = in->s390x.timer; | ||
200 | out->s390.clk_cmp = in->s390x.clk_cmp; | ||
201 | } | ||
202 | |||
203 | static void __init s390x_to_s390_save_areas(void) | ||
204 | { | ||
205 | int i = 1; | ||
206 | static union save_area tmp; | ||
207 | |||
208 | while (zfcpdump_save_areas[i]) { | ||
209 | s390x_to_s390_regs(&tmp, zfcpdump_save_areas[i], i); | ||
210 | memcpy(zfcpdump_save_areas[i], &tmp, sizeof(tmp)); | ||
211 | i++; | ||
212 | } | ||
213 | } | ||
214 | |||
215 | #endif /* __s390x__ */ | ||
216 | |||
217 | static int __init init_cpu_info(enum arch_id arch) | ||
218 | { | ||
219 | union save_area *sa; | ||
220 | |||
221 | /* get info for boot cpu from lowcore, stored in the HSA */ | ||
222 | |||
223 | sa = kmalloc(sizeof(*sa), GFP_KERNEL); | ||
224 | if (!sa) { | ||
225 | ERROR_MSG("kmalloc failed: %s: %i\n",__FUNCTION__, __LINE__); | ||
226 | return -ENOMEM; | ||
227 | } | ||
228 | if (memcpy_hsa_kernel(sa, sys_info.sa_base, sys_info.sa_size) < 0) { | ||
229 | ERROR_MSG("could not copy from HSA\n"); | ||
230 | kfree(sa); | ||
231 | return -EIO; | ||
232 | } | ||
233 | zfcpdump_save_areas[0] = sa; | ||
234 | |||
235 | #ifdef __s390x__ | ||
236 | /* convert s390x regs to s390, if we are dumping an s390 Linux */ | ||
237 | |||
238 | if (arch == ARCH_S390) | ||
239 | s390x_to_s390_save_areas(); | ||
240 | #endif | ||
241 | |||
242 | return 0; | ||
243 | } | ||
244 | |||
245 | static DEFINE_MUTEX(zcore_mutex); | ||
246 | |||
247 | #define DUMP_VERSION 0x3 | ||
248 | #define DUMP_MAGIC 0xa8190173618f23fdULL | ||
249 | #define DUMP_ARCH_S390X 2 | ||
250 | #define DUMP_ARCH_S390 1 | ||
251 | #define HEADER_SIZE 4096 | ||
252 | |||
253 | /* dump header dumped according to s390 crash dump format */ | ||
254 | |||
255 | struct zcore_header { | ||
256 | u64 magic; | ||
257 | u32 version; | ||
258 | u32 header_size; | ||
259 | u32 dump_level; | ||
260 | u32 page_size; | ||
261 | u64 mem_size; | ||
262 | u64 mem_start; | ||
263 | u64 mem_end; | ||
264 | u32 num_pages; | ||
265 | u32 pad1; | ||
266 | u64 tod; | ||
267 | cpuid_t cpu_id; | ||
268 | u32 arch_id; | ||
269 | u32 build_arch; | ||
270 | char pad2[4016]; | ||
271 | } __attribute__((packed,__aligned__(16))); | ||
272 | |||
273 | static struct zcore_header zcore_header = { | ||
274 | .magic = DUMP_MAGIC, | ||
275 | .version = DUMP_VERSION, | ||
276 | .header_size = 4096, | ||
277 | .dump_level = 0, | ||
278 | .page_size = PAGE_SIZE, | ||
279 | .mem_start = 0, | ||
280 | #ifdef __s390x__ | ||
281 | .build_arch = DUMP_ARCH_S390X, | ||
282 | #else | ||
283 | .build_arch = DUMP_ARCH_S390, | ||
284 | #endif | ||
285 | }; | ||
286 | |||
287 | /* | ||
288 | * Copy lowcore info to buffer. Use map in order to copy only register parts. | ||
289 | * | ||
290 | * @buf: User buffer | ||
291 | * @sa: Pointer to save area | ||
292 | * @sa_off: Offset in save area to copy | ||
293 | * @len: Number of bytes to copy | ||
294 | */ | ||
295 | static int copy_lc(void __user *buf, void *sa, int sa_off, int len) | ||
296 | { | ||
297 | int i; | ||
298 | char *lc_mask = (char*)&sys_info.lc_mask; | ||
299 | |||
300 | for (i = 0; i < len; i++) { | ||
301 | if (!lc_mask[i + sa_off]) | ||
302 | continue; | ||
303 | if (copy_to_user(buf + i, sa + sa_off + i, 1)) | ||
304 | return -EFAULT; | ||
305 | } | ||
306 | return 0; | ||
307 | } | ||
308 | |||
309 | /* | ||
310 | * Copy lowcores info to memory, if necessary | ||
311 | * | ||
312 | * @buf: User buffer | ||
313 | * @addr: Start address of buffer in dump memory | ||
314 | * @count: Size of buffer | ||
315 | */ | ||
316 | static int zcore_add_lc(char __user *buf, unsigned long start, size_t count) | ||
317 | { | ||
318 | unsigned long end; | ||
319 | int i = 0; | ||
320 | |||
321 | if (count == 0) | ||
322 | return 0; | ||
323 | |||
324 | end = start + count; | ||
325 | while (zfcpdump_save_areas[i]) { | ||
326 | unsigned long cp_start, cp_end; /* copy range */ | ||
327 | unsigned long sa_start, sa_end; /* save area range */ | ||
328 | unsigned long prefix; | ||
329 | unsigned long sa_off, len, buf_off; | ||
330 | |||
331 | if (sys_info.arch == ARCH_S390) | ||
332 | prefix = zfcpdump_save_areas[i]->s390.pref_reg; | ||
333 | else | ||
334 | prefix = zfcpdump_save_areas[i]->s390x.pref_reg; | ||
335 | |||
336 | sa_start = prefix + sys_info.sa_base; | ||
337 | sa_end = prefix + sys_info.sa_base + sys_info.sa_size; | ||
338 | |||
339 | if ((end < sa_start) || (start > sa_end)) | ||
340 | goto next; | ||
341 | cp_start = max(start, sa_start); | ||
342 | cp_end = min(end, sa_end); | ||
343 | |||
344 | buf_off = cp_start - start; | ||
345 | sa_off = cp_start - sa_start; | ||
346 | len = cp_end - cp_start; | ||
347 | |||
348 | TRACE("copy_lc for: %lx\n", start); | ||
349 | if (copy_lc(buf + buf_off, zfcpdump_save_areas[i], sa_off, len)) | ||
350 | return -EFAULT; | ||
351 | next: | ||
352 | i++; | ||
353 | } | ||
354 | return 0; | ||
355 | } | ||
356 | |||
357 | /* | ||
358 | * Read routine for zcore character device | ||
359 | * First 4K are dump header | ||
360 | * Next 32MB are HSA Memory | ||
361 | * Rest is read from absolute Memory | ||
362 | */ | ||
363 | static ssize_t zcore_read(struct file *file, char __user *buf, size_t count, | ||
364 | loff_t *ppos) | ||
365 | { | ||
366 | unsigned long mem_start; /* Start address in memory */ | ||
367 | size_t mem_offs; /* Offset in dump memory */ | ||
368 | size_t hdr_count; /* Size of header part of output buffer */ | ||
369 | size_t size; | ||
370 | int rc; | ||
371 | |||
372 | mutex_lock(&zcore_mutex); | ||
373 | |||
374 | if (*ppos > (sys_info.mem_size + HEADER_SIZE)) { | ||
375 | rc = -EINVAL; | ||
376 | goto fail; | ||
377 | } | ||
378 | |||
379 | count = min(count, (size_t) (sys_info.mem_size + HEADER_SIZE - *ppos)); | ||
380 | |||
381 | /* Copy dump header */ | ||
382 | if (*ppos < HEADER_SIZE) { | ||
383 | size = min(count, (size_t) (HEADER_SIZE - *ppos)); | ||
384 | if (copy_to_user(buf, &zcore_header + *ppos, size)) { | ||
385 | rc = -EFAULT; | ||
386 | goto fail; | ||
387 | } | ||
388 | hdr_count = size; | ||
389 | mem_start = 0; | ||
390 | } else { | ||
391 | hdr_count = 0; | ||
392 | mem_start = *ppos - HEADER_SIZE; | ||
393 | } | ||
394 | |||
395 | mem_offs = 0; | ||
396 | |||
397 | /* Copy from HSA data */ | ||
398 | if (*ppos < (ZFCPDUMP_HSA_SIZE + HEADER_SIZE)) { | ||
399 | size = min((count - hdr_count), (size_t) (ZFCPDUMP_HSA_SIZE | ||
400 | - mem_start)); | ||
401 | rc = memcpy_hsa_user(buf + hdr_count, mem_start, size); | ||
402 | if (rc) | ||
403 | goto fail; | ||
404 | |||
405 | mem_offs += size; | ||
406 | } | ||
407 | |||
408 | /* Copy from real mem */ | ||
409 | size = count - mem_offs - hdr_count; | ||
410 | rc = memcpy_real_user(buf + hdr_count + mem_offs, mem_start + mem_offs, | ||
411 | size); | ||
412 | if (rc) | ||
413 | goto fail; | ||
414 | |||
415 | /* | ||
416 | * Since s390 dump analysis tools like lcrash or crash | ||
417 | * expect register sets in the prefix pages of the cpus, | ||
418 | * we copy them into the read buffer, if necessary. | ||
419 | * buf + hdr_count: Start of memory part of output buffer | ||
420 | * mem_start: Start memory address to copy from | ||
421 | * count - hdr_count: Size of memory area to copy | ||
422 | */ | ||
423 | if (zcore_add_lc(buf + hdr_count, mem_start, count - hdr_count)) { | ||
424 | rc = -EFAULT; | ||
425 | goto fail; | ||
426 | } | ||
427 | *ppos += count; | ||
428 | fail: | ||
429 | mutex_unlock(&zcore_mutex); | ||
430 | return (rc < 0) ? rc : count; | ||
431 | } | ||
432 | |||
433 | static int zcore_open(struct inode *inode, struct file *filp) | ||
434 | { | ||
435 | if (!hsa_available) | ||
436 | return -ENODATA; | ||
437 | else | ||
438 | return capable(CAP_SYS_RAWIO) ? 0 : -EPERM; | ||
439 | } | ||
440 | |||
441 | static int zcore_release(struct inode *inode, struct file *filep) | ||
442 | { | ||
443 | diag308(DIAG308_REL_HSA, NULL); | ||
444 | hsa_available = 0; | ||
445 | return 0; | ||
446 | } | ||
447 | |||
448 | static loff_t zcore_lseek(struct file *file, loff_t offset, int orig) | ||
449 | { | ||
450 | loff_t rc; | ||
451 | |||
452 | mutex_lock(&zcore_mutex); | ||
453 | switch (orig) { | ||
454 | case 0: | ||
455 | file->f_pos = offset; | ||
456 | rc = file->f_pos; | ||
457 | break; | ||
458 | case 1: | ||
459 | file->f_pos += offset; | ||
460 | rc = file->f_pos; | ||
461 | break; | ||
462 | default: | ||
463 | rc = -EINVAL; | ||
464 | } | ||
465 | mutex_unlock(&zcore_mutex); | ||
466 | return rc; | ||
467 | } | ||
468 | |||
469 | static struct file_operations zcore_fops = { | ||
470 | .owner = THIS_MODULE, | ||
471 | .llseek = zcore_lseek, | ||
472 | .read = zcore_read, | ||
473 | .open = zcore_open, | ||
474 | .release = zcore_release, | ||
475 | }; | ||
476 | |||
477 | |||
478 | static void __init set_s390_lc_mask(union save_area *map) | ||
479 | { | ||
480 | memset(&map->s390.ext_save, 0xff, sizeof(map->s390.ext_save)); | ||
481 | memset(&map->s390.timer, 0xff, sizeof(map->s390.timer)); | ||
482 | memset(&map->s390.clk_cmp, 0xff, sizeof(map->s390.clk_cmp)); | ||
483 | memset(&map->s390.psw, 0xff, sizeof(map->s390.psw)); | ||
484 | memset(&map->s390.pref_reg, 0xff, sizeof(map->s390.pref_reg)); | ||
485 | memset(&map->s390.acc_regs, 0xff, sizeof(map->s390.acc_regs)); | ||
486 | memset(&map->s390.fp_regs, 0xff, sizeof(map->s390.fp_regs)); | ||
487 | memset(&map->s390.gp_regs, 0xff, sizeof(map->s390.gp_regs)); | ||
488 | memset(&map->s390.ctrl_regs, 0xff, sizeof(map->s390.ctrl_regs)); | ||
489 | } | ||
490 | |||
491 | static void __init set_s390x_lc_mask(union save_area *map) | ||
492 | { | ||
493 | memset(&map->s390x.fp_regs, 0xff, sizeof(map->s390x.fp_regs)); | ||
494 | memset(&map->s390x.gp_regs, 0xff, sizeof(map->s390x.gp_regs)); | ||
495 | memset(&map->s390x.psw, 0xff, sizeof(map->s390x.psw)); | ||
496 | memset(&map->s390x.pref_reg, 0xff, sizeof(map->s390x.pref_reg)); | ||
497 | memset(&map->s390x.fp_ctrl_reg, 0xff, sizeof(map->s390x.fp_ctrl_reg)); | ||
498 | memset(&map->s390x.tod_reg, 0xff, sizeof(map->s390x.tod_reg)); | ||
499 | memset(&map->s390x.timer, 0xff, sizeof(map->s390x.timer)); | ||
500 | memset(&map->s390x.clk_cmp, 0xff, sizeof(map->s390x.clk_cmp)); | ||
501 | memset(&map->s390x.acc_regs, 0xff, sizeof(map->s390x.acc_regs)); | ||
502 | memset(&map->s390x.ctrl_regs, 0xff, sizeof(map->s390x.ctrl_regs)); | ||
503 | } | ||
504 | |||
505 | /* | ||
506 | * Initialize dump globals for a given architecture | ||
507 | */ | ||
508 | static int __init sys_info_init(enum arch_id arch) | ||
509 | { | ||
510 | switch (arch) { | ||
511 | case ARCH_S390X: | ||
512 | MSG("DETECTED 'S390X (64 bit) OS'\n"); | ||
513 | sys_info.sa_base = SAVE_AREA_BASE_S390X; | ||
514 | sys_info.sa_size = sizeof(struct save_area_s390x); | ||
515 | set_s390x_lc_mask(&sys_info.lc_mask); | ||
516 | break; | ||
517 | case ARCH_S390: | ||
518 | MSG("DETECTED 'S390 (32 bit) OS'\n"); | ||
519 | sys_info.sa_base = SAVE_AREA_BASE_S390; | ||
520 | sys_info.sa_size = sizeof(struct save_area_s390); | ||
521 | set_s390_lc_mask(&sys_info.lc_mask); | ||
522 | break; | ||
523 | default: | ||
524 | ERROR_MSG("unknown architecture 0x%x.\n",arch); | ||
525 | return -EINVAL; | ||
526 | } | ||
527 | sys_info.arch = arch; | ||
528 | if (init_cpu_info(arch)) { | ||
529 | ERROR_MSG("get cpu info failed\n"); | ||
530 | return -ENOMEM; | ||
531 | } | ||
532 | sys_info.mem_size = real_memory_size; | ||
533 | |||
534 | return 0; | ||
535 | } | ||
536 | |||
537 | static int __init check_sdias(void) | ||
538 | { | ||
539 | int rc, act_hsa_size; | ||
540 | |||
541 | rc = sclp_sdias_blk_count(); | ||
542 | if (rc < 0) { | ||
543 | ERROR_MSG("Could not determine HSA size\n"); | ||
544 | return rc; | ||
545 | } | ||
546 | act_hsa_size = (rc - 1) * PAGE_SIZE; | ||
547 | if (act_hsa_size < ZFCPDUMP_HSA_SIZE) { | ||
548 | ERROR_MSG("HSA size too small: %i\n", act_hsa_size); | ||
549 | return -EINVAL; | ||
550 | } | ||
551 | return 0; | ||
552 | } | ||
553 | |||
554 | static void __init zcore_header_init(int arch, struct zcore_header *hdr) | ||
555 | { | ||
556 | if (arch == ARCH_S390X) | ||
557 | hdr->arch_id = DUMP_ARCH_S390X; | ||
558 | else | ||
559 | hdr->arch_id = DUMP_ARCH_S390; | ||
560 | hdr->mem_size = sys_info.mem_size; | ||
561 | hdr->mem_end = sys_info.mem_size; | ||
562 | hdr->num_pages = sys_info.mem_size / PAGE_SIZE; | ||
563 | hdr->tod = get_clock(); | ||
564 | get_cpu_id(&hdr->cpu_id); | ||
565 | } | ||
566 | |||
567 | extern int sdias_init(void); | ||
568 | |||
569 | static int __init zcore_init(void) | ||
570 | { | ||
571 | unsigned char arch; | ||
572 | int rc; | ||
573 | |||
574 | if (ipl_info.type != IPL_TYPE_FCP_DUMP) | ||
575 | return -ENODATA; | ||
576 | |||
577 | zcore_dbf = debug_register("zcore", 4, 1, 4 * sizeof(long)); | ||
578 | debug_register_view(zcore_dbf, &debug_sprintf_view); | ||
579 | debug_set_level(zcore_dbf, 6); | ||
580 | |||
581 | TRACE("devno: %x\n", ipl_info.data.fcp.dev_id.devno); | ||
582 | TRACE("wwpn: %llx\n", (unsigned long long) ipl_info.data.fcp.wwpn); | ||
583 | TRACE("lun: %llx\n", (unsigned long long) ipl_info.data.fcp.lun); | ||
584 | |||
585 | rc = sdias_init(); | ||
586 | if (rc) | ||
587 | goto fail; | ||
588 | |||
589 | rc = check_sdias(); | ||
590 | if (rc) { | ||
591 | ERROR_MSG("Dump initialization failed\n"); | ||
592 | goto fail; | ||
593 | } | ||
594 | |||
595 | rc = memcpy_hsa_kernel(&arch, __LC_AR_MODE_ID, 1); | ||
596 | if (rc) { | ||
597 | ERROR_MSG("sdial memcpy for arch id failed\n"); | ||
598 | goto fail; | ||
599 | } | ||
600 | |||
601 | #ifndef __s390x__ | ||
602 | if (arch == ARCH_S390X) { | ||
603 | ERROR_MSG("32 bit dumper can't dump 64 bit system!\n"); | ||
604 | rc = -EINVAL; | ||
605 | goto fail; | ||
606 | } | ||
607 | #endif | ||
608 | |||
609 | rc = sys_info_init(arch); | ||
610 | if (rc) { | ||
611 | ERROR_MSG("arch init failed\n"); | ||
612 | goto fail; | ||
613 | } | ||
614 | |||
615 | zcore_header_init(arch, &zcore_header); | ||
616 | |||
617 | zcore_dir = debugfs_create_dir("zcore" , NULL); | ||
618 | if (!zcore_dir) { | ||
619 | rc = -ENOMEM; | ||
620 | goto fail; | ||
621 | } | ||
622 | zcore_file = debugfs_create_file("mem", S_IRUSR, zcore_dir, NULL, | ||
623 | &zcore_fops); | ||
624 | if (!zcore_file) { | ||
625 | debugfs_remove(zcore_dir); | ||
626 | rc = -ENOMEM; | ||
627 | goto fail; | ||
628 | } | ||
629 | hsa_available = 1; | ||
630 | return 0; | ||
631 | |||
632 | fail: | ||
633 | diag308(DIAG308_REL_HSA, NULL); | ||
634 | return rc; | ||
635 | } | ||
636 | |||
637 | extern void sdias_exit(void); | ||
638 | |||
639 | static void __exit zcore_exit(void) | ||
640 | { | ||
641 | debug_unregister(zcore_dbf); | ||
642 | sdias_exit(); | ||
643 | diag308(DIAG308_REL_HSA, NULL); | ||
644 | } | ||
645 | |||
646 | MODULE_AUTHOR("Copyright IBM Corp. 2003,2007"); | ||
647 | MODULE_DESCRIPTION("zcore module for zfcpdump support"); | ||
648 | MODULE_LICENSE("GPL"); | ||
649 | |||
650 | subsys_initcall(zcore_init); | ||
651 | module_exit(zcore_exit); | ||