Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to initialize APM in Linux

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article to share with you is about how to initialize APM in Linux, Xiaobian think it is very practical, so share it with you to learn, I hope you can gain something after reading this article, not much to say, follow Xiaobian to see it.

The misc device's primary device number is 10, and Linux APM_bios as a misc device has a secondary device number of 134. Linux 2.6.30.10 kernel/drivers/char/apm-emulation.c provides the Linux APM_bios driver model, that is, the system to enter sleep entry function, earlier versions of the interface file: arch/arm/kernel/apm.c

In Linux APM-emulation.c:

/* * The apm_bios device is one of the misc char devices. * This is its minor number. */ #define Linux APM_MINOR_DEV 134

The Linux APM_bios device communicates with user space via the ioctl system call, i.e. when a user process issues a suspend command via ioctl, it passes it to the kernel, putting the system into the suspend state.

1, Initialize

static int __init apm_init(void) { int ret; if (apm_disabled) { printk(KERN_NOTICE "apm: disabled on user request.\ n"); return -ENODEV; }

//Create a thread to process the event queue, the worker function is kapmd

kapmd_tsk = kthread_create(kapmd, NULL, "kapmd"); if (IS_ERR(kapmd_tsk)) { ret = PTR_ERR(kapmd_tsk); kapmd_tsk = NULL; goto out; } wake_up_process(kapmd_tsk);

//Output Linux APM information to user space via proc

#ifdef CONFIG_PROC_FS proc_create("apm", 0, NULL, &apm_proc_fops); #endif

//Register misc device

ret = misc_register (&apm_device); if (ret) goto out_stop; ret = register_pm_notifier (&apm_notif_block); if (ret) goto out_unregister; return 0; out_unregister: misc_deregister (&apm_device); out_stop: remove_proc_entry ("apm", NULL); kthread_stop(kapmd_tsk); out: return ret; } The above is how to initialize APM in Linux. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report