drivers/char/toshiba.c
Source file repositories/reference/linux-study-clean/drivers/char/toshiba.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/toshiba.c- Extension
.c- Size
- 12740 bytes
- Lines
- 521
- Domain
- Driver Families
- Bucket
- drivers/char
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/types.hlinux/fcntl.hlinux/miscdevice.hlinux/ioport.hasm/io.hlinux/uaccess.hlinux/init.hlinux/stat.hlinux/proc_fs.hlinux/seq_file.hlinux/mutex.hlinux/toshiba.h
Detected Declarations
function tosh_fn_statusfunction tosh_emulate_fanfunction tosh_smmfunction tosh_ioctlfunction proc_toshiba_showfunction tosh_set_fn_portfunction tosh_get_machine_idfunction tosh_probefunction toshiba_initfunction toshiba_exitmodule init toshiba_initexport tosh_smm
Annotated Snippet
static const struct file_operations tosh_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = tosh_ioctl,
.llseek = noop_llseek,
};
static struct miscdevice tosh_device = {
TOSH_MINOR_DEV,
"toshiba",
&tosh_fops
};
/*
* Read the Fn key status
*/
#ifdef CONFIG_PROC_FS
static int tosh_fn_status(void)
{
unsigned char scan;
unsigned long flags;
if (tosh_fn!=0) {
scan = inb(tosh_fn);
} else {
local_irq_save(flags);
outb(0x8e, 0xe4);
scan = inb(0xe5);
local_irq_restore(flags);
}
return (int) scan;
}
#endif
/*
* For the Portage 610CT and the Tecra 700CS/700CDT emulate the HCI fan function
*/
static int tosh_emulate_fan(SMMRegisters *regs)
{
unsigned long eax,ecx,flags;
unsigned char al;
eax = regs->eax & 0xff00;
ecx = regs->ecx & 0xffff;
/* Portage 610CT */
if (tosh_id==0xfccb) {
if (eax==0xfe00) {
/* fan status */
local_irq_save(flags);
outb(0xbe, 0xe4);
al = inb(0xe5);
local_irq_restore(flags);
regs->eax = 0x00;
regs->ecx = (unsigned int) (al & 0x01);
}
if ((eax==0xff00) && (ecx==0x0000)) {
/* fan off */
local_irq_save(flags);
outb(0xbe, 0xe4);
al = inb(0xe5);
outb(0xbe, 0xe4);
outb (al | 0x01, 0xe5);
local_irq_restore(flags);
regs->eax = 0x00;
regs->ecx = 0x00;
}
if ((eax==0xff00) && (ecx==0x0001)) {
/* fan on */
local_irq_save(flags);
outb(0xbe, 0xe4);
al = inb(0xe5);
outb(0xbe, 0xe4);
outb(al & 0xfe, 0xe5);
local_irq_restore(flags);
regs->eax = 0x00;
regs->ecx = 0x01;
}
}
/* Tecra 700CS/CDT */
if (tosh_id==0xfccc) {
if (eax==0xfe00) {
/* fan status */
local_irq_save(flags);
outb(0xe0, 0xe4);
al = inb(0xe5);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/types.h`, `linux/fcntl.h`, `linux/miscdevice.h`, `linux/ioport.h`, `asm/io.h`, `linux/uaccess.h`.
- Detected declarations: `function tosh_fn_status`, `function tosh_emulate_fan`, `function tosh_smm`, `function tosh_ioctl`, `function proc_toshiba_show`, `function tosh_set_fn_port`, `function tosh_get_machine_id`, `function tosh_probe`, `function toshiba_init`, `function toshiba_exit`.
- Atlas domain: Driver Families / drivers/char.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.