mac的内核_Mac编程

mac的内核_Mac编程MAC内核编程指南-综述等

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

综述
为什么想起写这个类似于读书笔记的翻译呢,主要是MAC内核开发的资料基本都是en文的,中文的几乎没有(反正我没找到,你要有麻烦给一个,不甚感谢),而读en的资料对初学者来说又比较费时间,所以时间够的话我会把觉得重要的东西记下来,以飨读者。
一、Why You Should Avoid Programming in the Kernel
  一个内核bug可能导致整个系统Crash,所以应尽可能避免内核编程,而选择在用户空间编码。
二、The Early Boot Process
  和普通PC的BIOS类似,苹果机使用Boot ROM来引导和加载系统,大体流程如下:
Boot ROM
When the power to a Macintosh computer is turned on, the BootROM firmware is activated. BootROM (which is part of the computer’s hardware) has two primary responsibilities: it initializes system hardware and it selects an operating system to run. BootROM has two components to help it carry out these functions:
    •    POST (Power-On Self Test) initializes some hardware interfaces and verifies that sufficient memory is available and in a good state.
    •    EFI does basic hardware initialization and selects which operating system to use.
If multiple installations of Mac OS X are available, BootROM chooses the one that was last selected by the Startup Disk System Preference. The user can override this choice by holding down the Option key while the computer boots, which causes EFI to display a screen for choosing the boot volume.

The Boot Loader
Once BootROM is finished and a Mac OS X partition has been selected, control passes to the boot.efi boot loader. The principal job of this boot loader is to load the kernel environment. As it does this, the boot loader draws the “booting” image on the screen.
If full-disk encryption is enabled, the boot loader is responsible for drawing the login UI and prompting for the user’s password, which needed to access the encrypted disk to boot from it. (This UI is drawn by loginwindow otherwise.)
In the simplest case, the boot loader can be found in the /System/Library/CoreServices directory on the root partition, in a file named boot.efi .
Note:  Booting from a UFS volume is deprecated as of Mac OS X v10.5.
In order to speed up boot time, the boot loader uses several caches. The contents and location of these caches varies between versions of Mac OS X, but knowing some details about the caching may be helpful when debugging kernel extensions.
After you install or modify a kernel extension, touch the /System/Library/Extensions directory; the system rebuilds the caches automatically.
Important:  You should not depend on the implementation details of the kernel caches in your software.
In Mac OS X v10.7, the boot loader looks for the unified prelinked kernel. This cache contains all kernel extensions that may be needed to boot a Mac with any hardware configuration, with the extensions already linked against the kernel. It is located at /System/Library/Caches/com.apple.kext.caches/Startup/kernelcache .
In Mac OS X v10.6 and earlier, the boot loader first looks for the prelinked kernel (also called the kernel cache). This cache contains exactly the set of kernel extensions that were needed during the previous system startup, already linked against the kernel. If the prelinked kernel is missing or unusable (for example, because a hardware configuration has changed), the booter looks for the mkext cache, which contains all kernel extensions that may be needed to boot the system. Using the mkext cache is much slower because the linker must be run. On Mac OS X v10.5 and v10.6, these caches are located in /System/Library/Caches/com.apple.kext.caches/Startup/ ; on previous versions of Mac OS X, it was located at /System/Library/Caches/com.apple.kernelcaches/ .
Finally, if the caches cannot be used, the boot loader searches /System/Library/Extensions for drivers and other kernel extensions whose OSBundleRequired property is set to a value appropriate to the type of boot (for example, local or network boot). This process is very slow, because the Info.plist file of every kernel extension must be parsed, and then the linker must be run.
For more information on how drivers are loaded, see I/O Kit Fundamentals , the manual page for kextcache , and Kernel Extension Programming Topics .

Rooting
Once the kernel and all drivers necessary for booting are loaded, the boot loader starts the kernel’s initialization procedure. At this point, enough drivers are loaded for the kernel to find the root device.
The kernel initializes the Mach and BSD data structures and then initializes the I/O Kit . The I/O Kit links the loaded drivers into the kernel, using the device tree to determine which drivers to link. Once the kernel finds the root device, it roots(*) BSD off of it.
Note:  As a terminology aside, the term “boot” was historically reserved for loading a bootstrap loader and kernel off of a disk or partition. In more recent years, the usage has evolved to allow a second meaning: the entire process from initial bootstrap until the OS is generally usable by an end user. In this case, the term is used according to the former meaning.
As used here, the term “root” refers to mounting a partition as the root, or top-level, filesystem. Thus, while the OS boots off of the root partition, the kernel roots the OS off of the partition before executing startup scripts from it.
Boot≠Root is a technology that allows the system to boot from a partition other than the root partition. This is used to boot systems where the root partition is encrypted using full-disk encryption, or where the root partition is located on a device which requires additional drivers (such as a RAID array). Boot≠Root uses a helper partition to store the files needed to boot, such as the kernel cache. For more information on how to set up the property in a filter-scheme driver, see “Developing a Filter Scheme” in Mass Storage Device Driver Programming Guide .
三、参考资料
Information on the Web
Apple maintains several websites where developers can go for general and technical information on Mac OS X.
    •    Apple Developer Connection: Developer Documentation (http://developer.apple.com/documentation/ ). Features the same documentation that is installed on Mac OS X, except that often the documentation is more up-to-date. Also includes legacy documentation.
    •    Apple Developer Connection: Mac OS X (http://developer.apple.com/devcenter/macosx/ ). Offers SDKs, release notes, product notes and news, and other resources and information related to Mac OS X.
    •    AppleCare Tech Info Library (http://www.apple.com/support/ ). Contains technical articles, tutorials, FAQs, technical notes, and other information.
Next

原书地址:http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/KernelProgramming/About/About.htm

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/184550.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • Java中containsKey()方法[通俗易懂]

    Java中containsKey()方法[通俗易懂]containsKey方法——判断是否包含指定的键名在HashMap中经常用到containsKey()来判断键(key)是否存在。HashMap中允许值对象(value)为null,并且没有个数限制,所以当get()方法的返回值为null时,可能有两种情况:一种是在HashMap中没有该键对象,另一种是该键对象没有映射任何值对象,即值对象为null。因此,在HashMap中不应该利用get()方法来判断是否存在某个键,而应该利用containsKey()方法来判断。例如:HashMap&l

  • Android入门学习教程PDF免费下载

    Android入门学习教程PDF免费下载场景Android(安卓)是一种以Linux为基础的开放源码操作系统,主要使用于便携设备。2005年由Google收购注资,并拉拢多家制造商组成开放手机联盟开发改良,逐渐扩展到到平板电脑及其他领域上。实现关注公众号:霸道的程序猿回复:Android书籍免费下载。…

  • 使用Nginx实现负载均衡[通俗易懂]

    使用Nginx实现负载均衡[通俗易懂]负载均衡的作用负载均衡:分摊到多个操作单元上进行执行,和它的英文名称很匹配。就是我们需要一个调度者,保证所有后端服务器都将性能充分发挥,从而保持服务器集群的整体性能最优,这就是负载均衡。负载均衡这里面涉及的东西相对也是比较多的,理论就不说太多了,网上,书上很多,今天我们就利用Nginx服务器来实现一个简单的负载均衡负载均衡算法源地址哈希法:根据获取客户端的IP地址,通过哈…

  • java 还原中文utf-8格式编码的字符

    java 还原中文utf-8格式编码的字符java 还原中文utf-8格式编码的字符

  • 什么是UDP攻击_机器人打电话营销效果

    什么是UDP攻击_机器人打电话营销效果UDP协议UDP是一个简单的面向数据报的运输层协议,也是最常见的作为流量攻击最多的一种协议,需要用到UDP的主要都是视频通讯,枪战类实时通讯的游戏类。UDP不提供可靠性,它只是把应用程序传给IP层的数据报发送出去,但并不保证它们能到达目的地。由于UDP传输数据前传输数据之前源端和终端不建立连接,且没有超时重发等机制,故而传输速度很快。UDP攻击UDP攻击是DDoS攻击的一种,是典型的流量型攻击。就好比学校中午放学时的食堂,学生大量飞奔食堂,但食堂窗口就那么多,学生数量太多,就只能挤在窗口前等待。

  • Web漏洞扫描神器:xray

    Web漏洞扫描神器:xray一.Xray简介:xray是从长亭洞鉴核心引擎中提取出的社区版漏洞扫描神器,支持主动、被动多种扫描方式,自备盲打平台、可以灵活定义POC,功能丰富,调用简单,支持Windows/macOS/Linux多种操作系统,可以满足广大安全从业者的自动化Web漏洞探测需求二.下载地址:GitHub项目地址:https://github.com/chaitin/xray下载地址:https://download.xray.cool/xray/1.7.0三.版本说明:..

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号