License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 21:07:57 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
2009-06-16 15:30:47 +07:00
|
|
|
* IBM/3270 Driver - console view.
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
2009-06-16 15:30:47 +07:00
|
|
|
* Author(s):
|
|
|
|
* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global)
|
|
|
|
* Rewritten for 2.5 by Martin Schwidefsky <schwidefsky@de.ibm.com>
|
|
|
|
* Copyright IBM Corp. 2003, 2009
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
|
2014-03-21 15:25:24 +07:00
|
|
|
#include <linux/module.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/console.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/types.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2006-02-01 18:06:35 +07:00
|
|
|
#include <linux/err.h>
|
2008-10-11 02:33:27 +07:00
|
|
|
#include <linux/reboot.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#include <asm/ccwdev.h>
|
|
|
|
#include <asm/cio.h>
|
|
|
|
#include <asm/cpcmd.h>
|
|
|
|
#include <asm/ebcdic.h>
|
|
|
|
|
|
|
|
#include "raw3270.h"
|
2007-10-12 21:11:35 +07:00
|
|
|
#include "tty3270.h"
|
2005-04-17 05:20:36 +07:00
|
|
|
#include "ctrlchar.h"
|
|
|
|
|
|
|
|
#define CON3270_OUTPUT_BUFFER_SIZE 1024
|
|
|
|
#define CON3270_STRING_PAGES 4
|
|
|
|
|
|
|
|
static struct raw3270_fn con3270_fn;
|
|
|
|
|
2017-01-02 15:59:40 +07:00
|
|
|
static bool auto_update = true;
|
2014-03-21 15:25:24 +07:00
|
|
|
module_param(auto_update, bool, 0);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Main 3270 console view data structure.
|
|
|
|
*/
|
|
|
|
struct con3270 {
|
|
|
|
struct raw3270_view view;
|
|
|
|
struct list_head freemem; /* list of free memory for strings. */
|
|
|
|
|
|
|
|
/* Output stuff. */
|
|
|
|
struct list_head lines; /* list of lines. */
|
|
|
|
struct list_head update; /* list of lines to update. */
|
|
|
|
int line_nr; /* line number for next update. */
|
|
|
|
int nr_lines; /* # lines in list. */
|
|
|
|
int nr_up; /* # lines up in history. */
|
|
|
|
unsigned long update_flags; /* Update indication bits. */
|
|
|
|
struct string *cline; /* current output line. */
|
|
|
|
struct string *status; /* last line of display. */
|
|
|
|
struct raw3270_request *write; /* single write request. */
|
|
|
|
struct timer_list timer;
|
|
|
|
|
|
|
|
/* Input stuff. */
|
|
|
|
struct string *input; /* input string for read request. */
|
|
|
|
struct raw3270_request *read; /* single read request. */
|
|
|
|
struct raw3270_request *kreset; /* single keyboard reset request. */
|
|
|
|
struct tasklet_struct readlet; /* tasklet to issue read request. */
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct con3270 *condev;
|
|
|
|
|
|
|
|
/* con3270->update_flags. See con3270_update for details. */
|
|
|
|
#define CON_UPDATE_ERASE 1 /* Use EWRITEA instead of WRITE. */
|
|
|
|
#define CON_UPDATE_LIST 2 /* Update lines in tty3270->update. */
|
|
|
|
#define CON_UPDATE_STATUS 4 /* Update status line. */
|
2009-06-12 15:26:31 +07:00
|
|
|
#define CON_UPDATE_ALL 8 /* Recreate screen. */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2017-10-17 06:44:30 +07:00
|
|
|
static void con3270_update(struct timer_list *);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup timeout for a device. On timeout trigger an update.
|
|
|
|
*/
|
2007-02-06 03:16:47 +07:00
|
|
|
static void con3270_set_timer(struct con3270 *cp, int expires)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2009-06-12 15:26:31 +07:00
|
|
|
if (expires == 0)
|
|
|
|
del_timer(&cp->timer);
|
|
|
|
else
|
|
|
|
mod_timer(&cp->timer, jiffies + expires);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The status line is the last line of the screen. It shows the string
|
|
|
|
* "console view" in the lower left corner and "Running"/"More..."/"Holding"
|
|
|
|
* in the lower right corner of the screen.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
con3270_update_status(struct con3270 *cp)
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
str = (cp->nr_up != 0) ? "History" : "Running";
|
|
|
|
memcpy(cp->status->string + 24, str, 7);
|
|
|
|
codepage_convert(cp->view.ascebc, cp->status->string + 24, 7);
|
|
|
|
cp->update_flags |= CON_UPDATE_STATUS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
con3270_create_status(struct con3270 *cp)
|
|
|
|
{
|
|
|
|
static const unsigned char blueprint[] =
|
|
|
|
{ TO_SBA, 0, 0, TO_SF,TF_LOG,TO_SA,TAT_COLOR, TAC_GREEN,
|
|
|
|
'c','o','n','s','o','l','e',' ','v','i','e','w',
|
|
|
|
TO_RA,0,0,0,'R','u','n','n','i','n','g',TO_SF,TF_LOG };
|
|
|
|
|
|
|
|
cp->status = alloc_string(&cp->freemem, sizeof(blueprint));
|
|
|
|
/* Copy blueprint to status line */
|
|
|
|
memcpy(cp->status->string, blueprint, sizeof(blueprint));
|
|
|
|
/* Set TO_RA addresses. */
|
|
|
|
raw3270_buffer_address(cp->view.dev, cp->status->string + 1,
|
|
|
|
cp->view.cols * (cp->view.rows - 1));
|
|
|
|
raw3270_buffer_address(cp->view.dev, cp->status->string + 21,
|
|
|
|
cp->view.cols * cp->view.rows - 8);
|
|
|
|
/* Convert strings to ebcdic. */
|
|
|
|
codepage_convert(cp->view.ascebc, cp->status->string + 8, 12);
|
|
|
|
codepage_convert(cp->view.ascebc, cp->status->string + 24, 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set output offsets to 3270 datastream fragment of a console string.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
con3270_update_string(struct con3270 *cp, struct string *s, int nr)
|
|
|
|
{
|
2016-09-21 00:09:07 +07:00
|
|
|
if (s->len < 4) {
|
|
|
|
/* This indicates a bug, but printing a warning would
|
|
|
|
* cause a deadlock. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (s->string[s->len - 4] != TO_RA)
|
2005-04-17 05:20:36 +07:00
|
|
|
return;
|
|
|
|
raw3270_buffer_address(cp->view.dev, s->string + s->len - 3,
|
|
|
|
cp->view.cols * (nr + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Rebuild update list to print all lines.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
con3270_rebuild_update(struct con3270 *cp)
|
|
|
|
{
|
|
|
|
struct string *s, *n;
|
|
|
|
int nr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Throw away update list and create a new one,
|
|
|
|
* containing all lines that will fit on the screen.
|
|
|
|
*/
|
|
|
|
list_for_each_entry_safe(s, n, &cp->update, update)
|
|
|
|
list_del_init(&s->update);
|
|
|
|
nr = cp->view.rows - 2 + cp->nr_up;
|
|
|
|
list_for_each_entry_reverse(s, &cp->lines, list) {
|
|
|
|
if (nr < cp->view.rows - 1)
|
|
|
|
list_add(&s->update, &cp->update);
|
|
|
|
if (--nr < 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cp->line_nr = 0;
|
|
|
|
cp->update_flags |= CON_UPDATE_LIST;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Alloc string for size bytes. Free strings from history if necessary.
|
|
|
|
*/
|
|
|
|
static struct string *
|
|
|
|
con3270_alloc_string(struct con3270 *cp, size_t size)
|
|
|
|
{
|
|
|
|
struct string *s, *n;
|
|
|
|
|
|
|
|
s = alloc_string(&cp->freemem, size);
|
|
|
|
if (s)
|
|
|
|
return s;
|
|
|
|
list_for_each_entry_safe(s, n, &cp->lines, list) {
|
|
|
|
list_del(&s->list);
|
|
|
|
if (!list_empty(&s->update))
|
|
|
|
list_del(&s->update);
|
|
|
|
cp->nr_lines--;
|
|
|
|
if (free_string(&cp->freemem, s) >= size)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
s = alloc_string(&cp->freemem, size);
|
|
|
|
BUG_ON(!s);
|
|
|
|
if (cp->nr_up != 0 && cp->nr_up + cp->view.rows > cp->nr_lines) {
|
|
|
|
cp->nr_up = cp->nr_lines - cp->view.rows + 1;
|
|
|
|
con3270_rebuild_update(cp);
|
|
|
|
con3270_update_status(cp);
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write completion callback.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
con3270_write_callback(struct raw3270_request *rq, void *data)
|
|
|
|
{
|
|
|
|
raw3270_request_reset(rq);
|
|
|
|
xchg(&((struct con3270 *) rq->view)->write, rq);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update console display.
|
|
|
|
*/
|
|
|
|
static void
|
2017-10-17 06:44:30 +07:00
|
|
|
con3270_update(struct timer_list *t)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-10-17 06:44:30 +07:00
|
|
|
struct con3270 *cp = from_timer(cp, t, timer);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct raw3270_request *wrq;
|
|
|
|
char wcc, prolog[6];
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned long updated;
|
|
|
|
struct string *s, *n;
|
|
|
|
int rc;
|
|
|
|
|
2014-03-21 15:25:24 +07:00
|
|
|
if (!auto_update && !raw3270_view_active(&cp->view))
|
|
|
|
return;
|
2005-10-31 06:00:10 +07:00
|
|
|
if (cp->view.dev)
|
|
|
|
raw3270_activate_view(&cp->view);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
wrq = xchg(&cp->write, 0);
|
|
|
|
if (!wrq) {
|
|
|
|
con3270_set_timer(cp, 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&cp->view.lock, flags);
|
|
|
|
updated = 0;
|
2009-06-12 15:26:31 +07:00
|
|
|
if (cp->update_flags & CON_UPDATE_ALL) {
|
|
|
|
con3270_rebuild_update(cp);
|
|
|
|
con3270_update_status(cp);
|
|
|
|
cp->update_flags = CON_UPDATE_ERASE | CON_UPDATE_LIST |
|
|
|
|
CON_UPDATE_STATUS;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
if (cp->update_flags & CON_UPDATE_ERASE) {
|
|
|
|
/* Use erase write alternate to initialize display. */
|
|
|
|
raw3270_request_set_cmd(wrq, TC_EWRITEA);
|
|
|
|
updated |= CON_UPDATE_ERASE;
|
|
|
|
} else
|
|
|
|
raw3270_request_set_cmd(wrq, TC_WRITE);
|
|
|
|
|
|
|
|
wcc = TW_NONE;
|
|
|
|
raw3270_request_add_data(wrq, &wcc, 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update status line.
|
|
|
|
*/
|
|
|
|
if (cp->update_flags & CON_UPDATE_STATUS)
|
|
|
|
if (raw3270_request_add_data(wrq, cp->status->string,
|
|
|
|
cp->status->len) == 0)
|
|
|
|
updated |= CON_UPDATE_STATUS;
|
|
|
|
|
|
|
|
if (cp->update_flags & CON_UPDATE_LIST) {
|
|
|
|
prolog[0] = TO_SBA;
|
|
|
|
prolog[3] = TO_SA;
|
|
|
|
prolog[4] = TAT_COLOR;
|
|
|
|
prolog[5] = TAC_TURQ;
|
|
|
|
raw3270_buffer_address(cp->view.dev, prolog + 1,
|
|
|
|
cp->view.cols * cp->line_nr);
|
|
|
|
raw3270_request_add_data(wrq, prolog, 6);
|
|
|
|
/* Write strings in the update list to the screen. */
|
|
|
|
list_for_each_entry_safe(s, n, &cp->update, update) {
|
|
|
|
if (s != cp->cline)
|
|
|
|
con3270_update_string(cp, s, cp->line_nr);
|
|
|
|
if (raw3270_request_add_data(wrq, s->string,
|
|
|
|
s->len) != 0)
|
|
|
|
break;
|
|
|
|
list_del_init(&s->update);
|
|
|
|
if (s != cp->cline)
|
|
|
|
cp->line_nr++;
|
|
|
|
}
|
|
|
|
if (list_empty(&cp->update))
|
|
|
|
updated |= CON_UPDATE_LIST;
|
|
|
|
}
|
|
|
|
wrq->callback = con3270_write_callback;
|
|
|
|
rc = raw3270_start(&cp->view, wrq);
|
|
|
|
if (rc == 0) {
|
|
|
|
cp->update_flags &= ~updated;
|
|
|
|
if (cp->update_flags)
|
|
|
|
con3270_set_timer(cp, 1);
|
|
|
|
} else {
|
|
|
|
raw3270_request_reset(wrq);
|
|
|
|
xchg(&cp->write, wrq);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&cp->view.lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read tasklet.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
con3270_read_tasklet(struct raw3270_request *rrq)
|
|
|
|
{
|
|
|
|
static char kreset_data = TW_KR;
|
|
|
|
struct con3270 *cp;
|
|
|
|
unsigned long flags;
|
|
|
|
int nr_up, deactivate;
|
|
|
|
|
|
|
|
cp = (struct con3270 *) rrq->view;
|
|
|
|
spin_lock_irqsave(&cp->view.lock, flags);
|
|
|
|
nr_up = cp->nr_up;
|
|
|
|
deactivate = 0;
|
|
|
|
/* Check aid byte. */
|
|
|
|
switch (cp->input->string[0]) {
|
|
|
|
case 0x7d: /* enter: jump to bottom. */
|
|
|
|
nr_up = 0;
|
|
|
|
break;
|
|
|
|
case 0xf3: /* PF3: deactivate the console view. */
|
|
|
|
deactivate = 1;
|
|
|
|
break;
|
|
|
|
case 0x6d: /* clear: start from scratch. */
|
|
|
|
cp->update_flags = CON_UPDATE_ALL;
|
|
|
|
con3270_set_timer(cp, 1);
|
|
|
|
break;
|
|
|
|
case 0xf7: /* PF7: do a page up in the console log. */
|
|
|
|
nr_up += cp->view.rows - 2;
|
|
|
|
if (nr_up + cp->view.rows - 1 > cp->nr_lines) {
|
|
|
|
nr_up = cp->nr_lines - cp->view.rows + 1;
|
|
|
|
if (nr_up < 0)
|
|
|
|
nr_up = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xf8: /* PF8: do a page down in the console log. */
|
|
|
|
nr_up -= cp->view.rows - 2;
|
|
|
|
if (nr_up < 0)
|
|
|
|
nr_up = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (nr_up != cp->nr_up) {
|
|
|
|
cp->nr_up = nr_up;
|
|
|
|
con3270_rebuild_update(cp);
|
|
|
|
con3270_update_status(cp);
|
|
|
|
con3270_set_timer(cp, 1);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&cp->view.lock, flags);
|
|
|
|
|
|
|
|
/* Start keyboard reset command. */
|
|
|
|
raw3270_request_reset(cp->kreset);
|
|
|
|
raw3270_request_set_cmd(cp->kreset, TC_WRITE);
|
|
|
|
raw3270_request_add_data(cp->kreset, &kreset_data, 1);
|
|
|
|
raw3270_start(&cp->view, cp->kreset);
|
|
|
|
|
|
|
|
if (deactivate)
|
|
|
|
raw3270_deactivate_view(&cp->view);
|
|
|
|
|
|
|
|
raw3270_request_reset(rrq);
|
|
|
|
xchg(&cp->read, rrq);
|
|
|
|
raw3270_put_view(&cp->view);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read request completion callback.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
con3270_read_callback(struct raw3270_request *rq, void *data)
|
|
|
|
{
|
|
|
|
raw3270_get_view(rq->view);
|
|
|
|
/* Schedule tasklet to pass input to tty. */
|
|
|
|
tasklet_schedule(&((struct con3270 *) rq->view)->readlet);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Issue a read request. Called only from interrupt function.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
con3270_issue_read(struct con3270 *cp)
|
|
|
|
{
|
|
|
|
struct raw3270_request *rrq;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rrq = xchg(&cp->read, 0);
|
|
|
|
if (!rrq)
|
|
|
|
/* Read already scheduled. */
|
|
|
|
return;
|
|
|
|
rrq->callback = con3270_read_callback;
|
|
|
|
rrq->callback_data = cp;
|
|
|
|
raw3270_request_set_cmd(rrq, TC_READMOD);
|
|
|
|
raw3270_request_set_data(rrq, cp->input->string, cp->input->len);
|
|
|
|
/* Issue the read modified request. */
|
|
|
|
rc = raw3270_start_irq(&cp->view, rrq);
|
|
|
|
if (rc)
|
|
|
|
raw3270_request_reset(rrq);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Switch to the console view.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
con3270_activate(struct raw3270_view *view)
|
|
|
|
{
|
|
|
|
struct con3270 *cp;
|
|
|
|
|
|
|
|
cp = (struct con3270 *) view;
|
|
|
|
cp->update_flags = CON_UPDATE_ALL;
|
|
|
|
con3270_set_timer(cp, 1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
con3270_deactivate(struct raw3270_view *view)
|
|
|
|
{
|
|
|
|
struct con3270 *cp;
|
|
|
|
|
|
|
|
cp = (struct con3270 *) view;
|
|
|
|
del_timer(&cp->timer);
|
|
|
|
}
|
|
|
|
|
2016-05-02 19:53:29 +07:00
|
|
|
static void
|
2005-04-17 05:20:36 +07:00
|
|
|
con3270_irq(struct con3270 *cp, struct raw3270_request *rq, struct irb *irb)
|
|
|
|
{
|
|
|
|
/* Handle ATTN. Schedule tasklet to read aid. */
|
2008-07-14 14:58:50 +07:00
|
|
|
if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION)
|
2005-04-17 05:20:36 +07:00
|
|
|
con3270_issue_read(cp);
|
|
|
|
|
|
|
|
if (rq) {
|
2008-07-14 14:58:50 +07:00
|
|
|
if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK)
|
2005-04-17 05:20:36 +07:00
|
|
|
rq->rc = -EIO;
|
|
|
|
else
|
|
|
|
/* Normal end. Copy residual count. */
|
2008-07-14 14:58:50 +07:00
|
|
|
rq->rescnt = irb->scsw.cmd.count;
|
2015-08-19 21:50:10 +07:00
|
|
|
} else if (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) {
|
|
|
|
/* Interrupt without an outstanding request -> update all */
|
|
|
|
cp->update_flags = CON_UPDATE_ALL;
|
|
|
|
con3270_set_timer(cp, 1);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Console view to a 3270 device. */
|
|
|
|
static struct raw3270_fn con3270_fn = {
|
|
|
|
.activate = con3270_activate,
|
|
|
|
.deactivate = con3270_deactivate,
|
|
|
|
.intv = (void *) con3270_irq
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
con3270_cline_add(struct con3270 *cp)
|
|
|
|
{
|
|
|
|
if (!list_empty(&cp->cline->list))
|
|
|
|
/* Already added. */
|
|
|
|
return;
|
|
|
|
list_add_tail(&cp->cline->list, &cp->lines);
|
|
|
|
cp->nr_lines++;
|
|
|
|
con3270_rebuild_update(cp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
con3270_cline_insert(struct con3270 *cp, unsigned char c)
|
|
|
|
{
|
|
|
|
cp->cline->string[cp->cline->len++] =
|
|
|
|
cp->view.ascebc[(c < ' ') ? ' ' : c];
|
|
|
|
if (list_empty(&cp->cline->update)) {
|
|
|
|
list_add_tail(&cp->cline->update, &cp->update);
|
|
|
|
cp->update_flags |= CON_UPDATE_LIST;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
con3270_cline_end(struct con3270 *cp)
|
|
|
|
{
|
|
|
|
struct string *s;
|
|
|
|
unsigned int size;
|
|
|
|
|
|
|
|
/* Copy cline. */
|
|
|
|
size = (cp->cline->len < cp->view.cols - 5) ?
|
|
|
|
cp->cline->len + 4 : cp->view.cols;
|
|
|
|
s = con3270_alloc_string(cp, size);
|
|
|
|
memcpy(s->string, cp->cline->string, cp->cline->len);
|
2016-09-21 00:09:07 +07:00
|
|
|
if (cp->cline->len < cp->view.cols - 5) {
|
2005-04-17 05:20:36 +07:00
|
|
|
s->string[s->len - 4] = TO_RA;
|
|
|
|
s->string[s->len - 1] = 0;
|
|
|
|
} else {
|
2016-08-12 02:34:54 +07:00
|
|
|
while (--size >= cp->cline->len)
|
2005-04-17 05:20:36 +07:00
|
|
|
s->string[size] = cp->view.ascebc[' '];
|
|
|
|
}
|
|
|
|
/* Replace cline with allocated line s and reset cline. */
|
|
|
|
list_add(&s->list, &cp->cline->list);
|
|
|
|
list_del_init(&cp->cline->list);
|
|
|
|
if (!list_empty(&cp->cline->update)) {
|
|
|
|
list_add(&s->update, &cp->cline->update);
|
|
|
|
list_del_init(&cp->cline->update);
|
|
|
|
}
|
|
|
|
cp->cline->len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a string to the 3270 console
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
con3270_write(struct console *co, const char *str, unsigned int count)
|
|
|
|
{
|
|
|
|
struct con3270 *cp;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned char c;
|
|
|
|
|
|
|
|
cp = condev;
|
|
|
|
spin_lock_irqsave(&cp->view.lock, flags);
|
|
|
|
while (count-- > 0) {
|
|
|
|
c = *str++;
|
|
|
|
if (cp->cline->len == 0)
|
|
|
|
con3270_cline_add(cp);
|
|
|
|
if (c != '\n')
|
|
|
|
con3270_cline_insert(cp, c);
|
|
|
|
if (c == '\n' || cp->cline->len >= cp->view.cols)
|
|
|
|
con3270_cline_end(cp);
|
|
|
|
}
|
|
|
|
/* Setup timer to output current console buffer after 1/10 second */
|
2009-06-12 15:26:31 +07:00
|
|
|
cp->nr_up = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
if (cp->view.dev && !timer_pending(&cp->timer))
|
|
|
|
con3270_set_timer(cp, HZ/10);
|
|
|
|
spin_unlock_irqrestore(&cp->view.lock,flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct tty_driver *
|
|
|
|
con3270_device(struct console *c, int *index)
|
|
|
|
{
|
|
|
|
*index = c->index;
|
|
|
|
return tty3270_driver;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait for end of write request.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
con3270_wait_write(struct con3270 *cp)
|
|
|
|
{
|
|
|
|
while (!cp->write) {
|
|
|
|
raw3270_wait_cons_dev(cp->view.dev);
|
|
|
|
barrier();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-10-11 02:33:27 +07:00
|
|
|
* panic() calls con3270_flush through a panic_notifier
|
|
|
|
* before the system enters a disabled, endless loop.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
static void
|
2008-10-11 02:33:27 +07:00
|
|
|
con3270_flush(void)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct con3270 *cp;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
cp = condev;
|
|
|
|
if (!cp->view.dev)
|
|
|
|
return;
|
2009-06-16 15:30:47 +07:00
|
|
|
raw3270_pm_unfreeze(&cp->view);
|
2014-03-21 15:25:24 +07:00
|
|
|
raw3270_activate_view(&cp->view);
|
2005-04-17 05:20:36 +07:00
|
|
|
spin_lock_irqsave(&cp->view.lock, flags);
|
|
|
|
con3270_wait_write(cp);
|
|
|
|
cp->nr_up = 0;
|
|
|
|
con3270_rebuild_update(cp);
|
|
|
|
con3270_update_status(cp);
|
|
|
|
while (cp->update_flags != 0) {
|
|
|
|
spin_unlock_irqrestore(&cp->view.lock, flags);
|
2017-10-17 06:44:30 +07:00
|
|
|
con3270_update(&cp->timer);
|
2005-04-17 05:20:36 +07:00
|
|
|
spin_lock_irqsave(&cp->view.lock, flags);
|
|
|
|
con3270_wait_write(cp);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&cp->view.lock, flags);
|
|
|
|
}
|
|
|
|
|
2008-10-11 02:33:27 +07:00
|
|
|
static int con3270_notify(struct notifier_block *self,
|
|
|
|
unsigned long event, void *data)
|
|
|
|
{
|
|
|
|
con3270_flush();
|
|
|
|
return NOTIFY_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct notifier_block on_panic_nb = {
|
|
|
|
.notifier_call = con3270_notify,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct notifier_block on_reboot_nb = {
|
|
|
|
.notifier_call = con3270_notify,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* The console structure for the 3270 console
|
|
|
|
*/
|
|
|
|
static struct console con3270 = {
|
|
|
|
.name = "tty3270",
|
|
|
|
.write = con3270_write,
|
|
|
|
.device = con3270_device,
|
|
|
|
.flags = CON_PRINTBUFFER,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 3270 console initialization code called from console_init().
|
|
|
|
*/
|
|
|
|
static int __init
|
|
|
|
con3270_init(void)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
void *cbuf;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Check if 3270 is to be the console */
|
|
|
|
if (!CONSOLE_IS_3270)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* Set the console mode for VM */
|
|
|
|
if (MACHINE_IS_VM) {
|
2005-06-26 04:55:32 +07:00
|
|
|
cpcmd("TERM CONMODE 3270", NULL, 0, NULL);
|
|
|
|
cpcmd("TERM AUTOCR OFF", NULL, 0, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2014-01-27 19:26:10 +07:00
|
|
|
rp = raw3270_setup_console();
|
2005-04-17 05:20:36 +07:00
|
|
|
if (IS_ERR(rp))
|
|
|
|
return PTR_ERR(rp);
|
|
|
|
|
2009-06-22 17:08:05 +07:00
|
|
|
condev = kzalloc(sizeof(struct con3270), GFP_KERNEL | GFP_DMA);
|
2015-12-21 21:31:06 +07:00
|
|
|
if (!condev)
|
|
|
|
return -ENOMEM;
|
2005-04-17 05:20:36 +07:00
|
|
|
condev->view.dev = rp;
|
|
|
|
|
2009-06-22 17:08:05 +07:00
|
|
|
condev->read = raw3270_request_alloc(0);
|
2005-04-17 05:20:36 +07:00
|
|
|
condev->read->callback = con3270_read_callback;
|
|
|
|
condev->read->callback_data = condev;
|
2009-06-22 17:08:05 +07:00
|
|
|
condev->write = raw3270_request_alloc(CON3270_OUTPUT_BUFFER_SIZE);
|
|
|
|
condev->kreset = raw3270_request_alloc(1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
INIT_LIST_HEAD(&condev->lines);
|
|
|
|
INIT_LIST_HEAD(&condev->update);
|
2017-10-17 06:44:30 +07:00
|
|
|
timer_setup(&condev->timer, con3270_update, 0);
|
2005-04-17 05:20:36 +07:00
|
|
|
tasklet_init(&condev->readlet,
|
|
|
|
(void (*)(unsigned long)) con3270_read_tasklet,
|
|
|
|
(unsigned long) condev->read);
|
|
|
|
|
2005-10-31 06:00:10 +07:00
|
|
|
raw3270_add_view(&condev->view, &con3270_fn, 1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
INIT_LIST_HEAD(&condev->freemem);
|
|
|
|
for (i = 0; i < CON3270_STRING_PAGES; i++) {
|
2009-06-22 17:08:05 +07:00
|
|
|
cbuf = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
|
2005-04-17 05:20:36 +07:00
|
|
|
add_string_memory(&condev->freemem, cbuf, PAGE_SIZE);
|
|
|
|
}
|
|
|
|
condev->cline = alloc_string(&condev->freemem, condev->view.cols);
|
|
|
|
condev->cline->len = 0;
|
|
|
|
con3270_create_status(condev);
|
|
|
|
condev->input = alloc_string(&condev->freemem, 80);
|
2008-10-11 02:33:27 +07:00
|
|
|
atomic_notifier_chain_register(&panic_notifier_list, &on_panic_nb);
|
|
|
|
register_reboot_notifier(&on_reboot_nb);
|
2005-04-17 05:20:36 +07:00
|
|
|
register_console(&con3270);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
console_initcall(con3270_init);
|