drivers/tty/vt/consolemap.c

Source file repositories/reference/linux-study-clean/drivers/tty/vt/consolemap.c

File Facts

System
Linux kernel
Corpus path
drivers/tty/vt/consolemap.c
Extension
.c
Size
26450 bytes
Lines
901
Domain
Driver Families
Bucket
drivers/tty
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct uni_pagedict {
	u16		**uni_pgdir[UNI_DIRS];
	unsigned long	refcount;
	unsigned long	sum;
	unsigned char	*inverse_translations[LAST_MAP + 1];
	u16		*inverse_trans_unicode;
};

static struct uni_pagedict *dflt;

static void set_inverse_transl(struct vc_data *conp, struct uni_pagedict *dict,
	       enum translation_map m)
{
	unsigned short *t = translations[m];
	unsigned char *inv;

	if (!dict)
		return;
	inv = dict->inverse_translations[m];

	if (!inv) {
		inv = dict->inverse_translations[m] = kmalloc(MAX_GLYPH,
				GFP_KERNEL);
		if (!inv)
			return;
	}
	memset(inv, 0, MAX_GLYPH);

	for (unsigned int ch = 0; ch < ARRAY_SIZE(translations[m]); ch++) {
		int glyph = conv_uni_to_pc(conp, t[ch]);
		if (glyph >= 0 && glyph < MAX_GLYPH && inv[glyph] < 32) {
			/* prefer '-' above SHY etc. */
			inv[glyph] = ch;
		}
	}
}

static void set_inverse_trans_unicode(struct uni_pagedict *dict)
{
	unsigned int d, r, g;
	u16 *inv;

	if (!dict)
		return;

	inv = dict->inverse_trans_unicode;
	if (!inv) {
		inv = dict->inverse_trans_unicode = kmalloc_array(MAX_GLYPH,
				sizeof(*inv), GFP_KERNEL);
		if (!inv)
			return;
	}
	memset(inv, 0, MAX_GLYPH * sizeof(*inv));

	for (d = 0; d < UNI_DIRS; d++) {
		u16 **dir = dict->uni_pgdir[d];
		if (!dir)
			continue;
		for (r = 0; r < UNI_DIR_ROWS; r++) {
			u16 *row = dir[r];
			if (!row)
				continue;
			for (g = 0; g < UNI_ROW_GLYPHS; g++) {
				u16 glyph = row[g];
				if (glyph < MAX_GLYPH && inv[glyph] < 32)
					inv[glyph] = UNI(d, r, g);
			}
		}
	}
}

unsigned short *set_translate(enum translation_map m, struct vc_data *vc)
{
	inv_translate[vc->vc_num] = m;
	return translations[m];
}

/*
 * Inverse translation is impossible for several reasons:
 * 1. The font<->character maps are not 1-1.
 * 2. The text may have been written while a different translation map
 *    was active.
 * Still, it is now possible to a certain extent to cut and paste non-ASCII.
 */
u16 inverse_translate(const struct vc_data *conp, u16 glyph, bool use_unicode)
{
	struct uni_pagedict *p;
	enum translation_map m;

	if (glyph >= MAX_GLYPH)

Annotation

Implementation Notes