loader: remove shouting from ORB's variable name
[hvf.git] / cp / nucleus / sclp.c
blob013759de6c2301a2e626f05b3b979046805341ed
1 /*
2 * (C) Copyright 2007-2011 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
5 * details.
6 */
8 #include <ebcdic.h>
9 #include <vsprintf.h>
10 #include <stdarg.h>
11 #include <sclp.h>
13 struct sccb_header {
14 u16 len;
15 u8 flags;
16 u8 __reserved[2];
17 u8 type;
18 u8 reason;
19 u8 response;
20 } __attribute__((packed));
22 struct sccb_evd_header {
23 u16 len;
24 u8 type;
25 u8 flags;
26 u16 __reserved;
27 } __attribute__((packed));
29 struct sccb_mcd_header {
30 u16 len;
31 u16 type;
32 u32 tag;
33 u32 code;
34 } __attribute__((packed));
36 struct sccb_obj_header {
37 u16 len;
38 u16 type;
39 } __attribute__((packed));
41 struct sccb_mto_header {
42 u8 ltflags[2];
43 u8 present[4];
44 } __attribute__((packed));
46 struct sccb {
47 struct sccb_header hdr;
48 struct sccb_evd_header evd;
49 struct sccb_mcd_header mcd;
50 struct sccb_obj_header obj;
51 struct sccb_mto_header mto;
52 char txt[256];
53 } __attribute__((aligned(8)));
55 void sclp_msg(const char *fmt, ...)
57 struct sccb sccb;
58 va_list args;
59 int ret;
61 memset(&sccb, 0, sizeof(sccb));
63 va_start(args, fmt);
64 ret = vsnprintf(sccb.txt, sizeof(sccb.txt), fmt, args);
65 va_end(args);
67 if (!ret)
68 return;
70 ascii2ebcdic((u8*) sccb.txt, ret);
72 /* Note: sccb.mto is ok all zeroed out */
73 #define SCCB_OBJ_TYPE_MESSAGE 0x0004
74 sccb.obj.len = ret + sizeof(struct sccb_mto_header) +
75 sizeof(struct sccb_obj_header);
76 sccb.obj.type = SCCB_OBJ_TYPE_MESSAGE;
78 sccb.mcd.len = sccb.obj.len + sizeof(struct sccb_mcd_header);
79 sccb.mcd.type = 0x0001;
80 sccb.mcd.tag = 0xd4c4c240;
81 sccb.mcd.code = 0x00000001;
83 #define SCCB_EVD_TYPE_PRIOR 0x09
84 sccb.evd.len = sccb.mcd.len + sizeof(struct sccb_evd_header);
85 sccb.evd.type = SCCB_EVD_TYPE_PRIOR;
87 #define SCCB_FLAGS_SYNC 0x80
88 #define SCCB_WRITE_EVENT_DATA 0x00760005
89 sccb.hdr.len = sccb.evd.len + sizeof(struct sccb_header);
90 sccb.hdr.flags = SCCB_FLAGS_SYNC;
93 * SERVC r1,r2
94 * r1 = command
95 * r2 = real addr of control block
97 int cc;
98 int cmd = SCCB_WRITE_EVENT_DATA;
99 asm volatile(
100 " .insn rre,0xb2200000,%1,%2\n" /* servc %1,%2 */
101 " ipm %0\n"
102 " srl %0,28"
103 : "=&d" (cc) : "d" (cmd), "a" (&sccb)
104 : "cc", "memory");