Skip to content

Commit

Permalink
s390/sclp_early: Add function to detect sclp console capabilities
Browse files Browse the repository at this point in the history
Add SCLP console detect functions to encapsulate detection of SCLP console
capabilities, for example, VT220 support.  Reuse the sclp_send/receive masks
that were stored by the most recent sclp_set_event_mask() call to prevent
unnecessary SCLP calls.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
  • Loading branch information
Hendrik Brueckner authored and Martin Schwidefsky committed Dec 16, 2013
1 parent 5d5de1a commit 52733e0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
4 changes: 2 additions & 2 deletions arch/s390/include/asm/sclp.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ int sclp_chp_configure(struct chp_id chpid);
int sclp_chp_deconfigure(struct chp_id chpid);
int sclp_chp_read_info(struct sclp_chp_info *info);
void sclp_get_ipl_info(struct sclp_ipl_info *info);
bool sclp_has_linemode(void);
bool sclp_has_vt220(void);
bool __init sclp_has_linemode(void);
bool __init sclp_has_vt220(void);
int sclp_pci_configure(u32 fid);
int sclp_pci_deconfigure(u32 fid);
int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode);
Expand Down
46 changes: 30 additions & 16 deletions drivers/s390/char/sclp_early.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ struct read_info_sccb {
} __packed __aligned(PAGE_SIZE);

static char sccb_early[PAGE_SIZE] __aligned(PAGE_SIZE) __initdata;
static unsigned int sclp_con_has_vt220 __initdata;
static unsigned int sclp_con_has_linemode __initdata;
static unsigned long sclp_hsa_size;
static struct sclp_ipl_info sclp_ipl_info;

Expand Down Expand Up @@ -109,26 +111,12 @@ static void __init sclp_facilities_detect(struct read_info_sccb *sccb)

bool __init sclp_has_linemode(void)
{
struct init_sccb *sccb = (void *) &sccb_early;

if (sccb->header.response_code != 0x20)
return 0;
if (!(sccb->sclp_send_mask & (EVTYP_OPCMD_MASK | EVTYP_PMSGCMD_MASK)))
return 0;
if (!(sccb->sclp_receive_mask & (EVTYP_MSG_MASK | EVTYP_PMSGCMD_MASK)))
return 0;
return 1;
return !!sclp_con_has_linemode;
}

bool __init sclp_has_vt220(void)
{
struct init_sccb *sccb = (void *) &sccb_early;

if (sccb->header.response_code != 0x20)
return 0;
if (sccb->sclp_send_mask & EVTYP_VT220MSG_MASK)
return 1;
return 0;
return !!sclp_con_has_vt220;
}

unsigned long long sclp_get_rnmax(void)
Expand Down Expand Up @@ -240,11 +228,37 @@ static void __init sclp_hsa_size_detect(void *sccb)
sclp_hsa_size = size;
}

static unsigned int __init sclp_con_check_linemode(struct init_sccb *sccb)
{
if (!(sccb->sclp_send_mask & (EVTYP_OPCMD_MASK | EVTYP_PMSGCMD_MASK)))
return 0;
if (!(sccb->sclp_receive_mask & (EVTYP_MSG_MASK | EVTYP_PMSGCMD_MASK)))
return 0;
return 1;
}

static void __init sclp_console_detect(struct init_sccb *sccb)
{
if (sccb->header.response_code != 0x20)
return;

if (sccb->sclp_send_mask & EVTYP_VT220MSG_MASK)
sclp_con_has_vt220 = 1;

if (sclp_con_check_linemode(sccb))
sclp_con_has_linemode = 1;
}

void __init sclp_early_detect(void)
{
void *sccb = &sccb_early;

sclp_facilities_detect(sccb);
sclp_hsa_size_detect(sccb);

/* Turn off SCLP event notifications. Also save remote masks in the
* sccb. These are sufficient to detect sclp console capabilities.
*/
sclp_set_event_mask(sccb, 0, 0);
sclp_console_detect(sccb);
}

0 comments on commit 52733e0

Please sign in to comment.