# Tìm hiểu quá trình cài đặt

{% hint style="warning" %}
Một trong những khó khăn lớn nhất đối với hackintosh đó là đọc lỗi

> Bởi lẽ từ khoá mà bạn đang tìm kiếm có thể khác hoàn toàn với các từ khoá trên google
>
> > Điều này sẽ gây ra một khó khăn cực lớn

Đối với bài hướng dẫn này chúng tôi hy vọng sẽ giúp được bạn

> Giúp bạn hiểu rõ từng gia đoạn trong quá trình boot
>
> > Từ đó giúp bạn biết được mình đang ở đâu, dễ dàng phán đoán lỗi
> > {% endhint %}

## OpenCore Booting

{% hint style="info" %}
Phần này khá đơn giản

> Chủ yếu đến từ người dùng
> {% endhint %}

{% hint style="success" %}
Ban đầu khi bạn ấn nút nguồn hệ thống sẽ mở lên và bios tiến hành tìm kiếm thiết bị boot

> Có thể là tự động hoặc chọn thủ công thông qua menu boot
> {% endhint %}

{% hint style="success" %}
Hệ thống sẽ tiến hành xác định file bootx64.efi ở thiết bị boot dưới thứ mục EFI/Boot

> Hoặc file opencore.efi ở dưới thư mục EFI/OC
> {% endhint %}

{% hint style="success" %}
Sau đó file bootx64.efi sẽ call tới opencore.efi ở folder EFI/OC

> Bước này sẽ được bỏ qua nếu như ở giai đoạn 2 bạn boot vào file opencore.efi
> {% endhint %}

{% hint style="success" %}
Tiếp theo các dữ liệu ở NVRAM sẽ được load lên&#x20;

> Bao gồm toàn bộ những gì được lưu ở NVRAM như tình trạng sip, boot-args,....
> {% endhint %}

{% hint style="success" %}
Tiếp đến drivers sẽ được load lên từ EFI/OC/Drivers
{% endhint %}

{% hint style="success" %}
Graphics Output Protocol(GOP) sẽ được load

> Tìm hiểu GOP là gì chi tiết [tại đây](https://wiki.osdev.org/GOP#:~:text=Graphics%20Output%20Protocol,-It%20has%20basically\&text=GOP%20is%20an%20EFI%20Boot,UEFI%20uses%20its%20own%20ABI.)
> {% endhint %}

{% hint style="success" %}
Tiếp theo ACPI sẽ được load từ EFI/OC/ACPI
{% endhint %}

{% hint style="success" %}
Tiếp đó SMBIOS sẽ được áp dụng vào từ config
{% endhint %}

{% hint style="success" %}
Bây giờ thì opencore picker sẽ được load&#x20;

> Opencore picker tức là giao diện chọn các option boot của opencore
> {% endhint %}

{% hint style="success" %}
Bây giờ chỉ việc chọn bộ cài của bạn mà thôi
{% endhint %}

{% hint style="warning" %}
Ở mục này thường sẽ có mọt số vấn đề thường gặp như sau:

* [`Stuck on no vault provided!`](/issue/boot-issue.md#stuck-on-no-vault-provided)
* [Can't see macOS partitions](/issue/boot-issue.md#can-t-see-macos-partitions)
* [Booting OpenCore reboots to BIOS](/issue/boot-issue.md#booting-opencore-reboots-to-bios)

Và về những lỗi khác có thể tham khảo chi tiết [tại đây](/issue/boot-issue.md)
{% endhint %}

## boot.efi Handoff <a href="#boot-efi-handoff" id="boot-efi-handoff"></a>

{% hint style="info" %}
Đây là gia đoạn bắt đầu đi vào MacOS bootloader (boot.efi)&#x20;

> Cụ thể nó sẽ tiến hành chuẩn bị để tiến vào quá trình load kernel và load các kext được liệu kê trong config.plist
>
> > Nếu bạn gặp lỗi ở phần này có thì có thể tham khảo ở [kernel issue](/issue/kernel-issue.md)
> >
> > > Một vài lỗi thường gặp:
> > >
> > > * [Stuck on EndRandomSeed](/issue/kernel-issue.md#stuck-on-endrandomseed)
> > > * [Stuck on `[EB|#LOG:EXITBS:START]`](/issue/eb-or-log-exitbs-start.md)
> > > * [`Couldn't allocate runtime area` errors](/issue/kernel-issue.md#couldnt-allocate-runtime-area-errors)
> > >   {% endhint %}

{% hint style="warning" %}
Chú ý ở phiên bản MacOS 10.15.4 apple có tiến hành thay đổi boot.efi debugging protocol

> Hiểu nôm na là phương thức gỡ lỗi của boot.efi

Do đó mọi thứ có thể sẽ hơi khác nhưng cơ bản những quy tắc chung vẫn áp dụng được
{% endhint %}

## XNU/Kernel Handoff <a href="#xnu-kernel-handoff" id="xnu-kernel-handoff"></a>

{% hint style="info" %}
Sau khi boot.efi đã hoàn thành các công đoạn chuẩn bị bây giờ nó sẽ tiến hành boot vào kernel giai đoạn này thường được gọi là Rooting phase

> Xem chi tiết nó [tại đây](https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/booting/booting.html)
> {% endhint %}

<figure><img src="/files/3y38eShpsv5lrbQQ8aw5" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Đây cũng là phần mà SMBIOS được kiểm tra lại và maocs sẽ cố gắng sắp xếp lại các ACPI, Kext đã được load trước đó theo thứ tự

> Một số lỗi phổ biến thường diễn ra ở phần này là&#x20;
>
> * SSDT load lỗi
>
> * Kext load lỗi
>
> * memory map load lỗi
>
> > Một số lỗi phổ biến ở giai đoạn này là&#x20;
> >
> > * [Kernel Panic `Cannot perform kext summary`](/issue/kernel-issue.md#kernel-panic-cannot-perform-kext-summary)
> > * [Kernel Panic on `Invalid frame pointer`](/issue/kernel-issue.md#kernel-panic-on-invalid-frame-pointer)
> >   {% endhint %}

<figure><img src="/files/0YsSaxrE5On7gtGXfTGo" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Sau giai đoạn này chúng ta đến giai đoạn `[ PCI configurations begin ]`Phần này sẽ kiểm tra các phần cứng hệ thống, kext ACPI&#x20;

> Đồng thời nó cũng là giai đoạn IOKit kết nối các phần cứng thích hợp với các bản vá device
>
> > Một số lỗi thường gặp&#x20;
> >
> > * Embedded Controllers (EC)
> >
> > * Storage(NVMe, SATA,...)
> >
> > * PCI/e
> >
> > * NVRAM
> >
> > * RTC
> >
> > * PS2 and I2C
> >
> > > Để tìm hiểu rõ về phần này hãy xem bài viết:
> > >
> > > * [Stuck on `RTC...`, `PCI Configuration Begins`, `Previous Shutdown...`, `HPET`, `HID: Legacy...`](https://install.heavietnam.com/issue/pages/38Kcownp64KZwXr0s1p3#stuck-on-rtc...-pci-configuration-begins-previous-shutdown...-hpet-hid-legacy)
> > >   {% endhint %}

<figure><img src="/files/0qDLQAEwvww859xPzem6" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Đây là phần load USB

> Giới hạn 15 port
>
> Các ánh xạ công usb
>
> > Ánh xạ là thuật ngữ toán học và khoa học
>
> Nó cũng là nay xuất hiện lỗi `Waiting for Root Device`

Xem chi tiết các fix tại [đây](/issue/kernel-issue.md#waiting-for-root-device-or-prohibited-sign-error)
{% endhint %}

<figure><img src="/files/6uAlGkcIrwvqA6QSXKKU" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Đây là nơi mà fakeSMC và VirtualSMC toả sáng&#x20;

> Trước hết ta cần biến đây là nơi load kext tên DSMOS
>
> Nhiệm vụ của kext này là xác minh hệ thống của bạn có SMC hay không nếu không nó sẽ ngưng giải nén các mã nhị phân và làm bạn mắc kẹt tại đây hoặc khiến bạn kẹt tại AppleACPICPU
>
> > Một số lỗi thường gặp:
> >
> > * [kextd stall\[0\]: AppleACPICPU](/issue/kernel-issue.md#kextd-stall-0-appleacpicpu)
> >   {% endhint %}

```
Your karma check for today:
There once was a user that whined
his existing OS was so blind,
he'd do better to pirate an OS that ran great
but found his hardware declined.
Please don't steal Mac OS!
Really, that's way uncool.
(C) Apple Computer, Inc.
```

Source: Dont Steal Mac OS X.kext

<figure><img src="/files/yDR1R8rCOApSiENl1jby" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Đây là nơi load trình điều khiển âm thanh của apple&#x20;

> Tức là nơi appleALC được phát huy công dụng&#x20;

Nếu có bất cứ lỗi nào xảy ra ở đây thì hãy tắt appleALC đi

> Khá hiếm gặp lỗi
>
> > Với các kext âm thanh khác cũng tương tự
> > {% endhint %}

<figure><img src="/files/GsWGmcapCB3pjYEyczyX" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Đây là nơi load GPU và cũng là lúc whatvergreen thực hiện nhiệm vụ của mình

> Nếu bị lỗi ở đây thì là do GPU của bạn chứ không phải do whatvergreen
>
> > Một số lỗi thường gặp:
> >
> > * [Stuck on or near `IOConsoleUsers: gIOScreenLock...`](https://install.heavietnam.com/issue/pages/38Kcownp64KZwXr0s1p3#stuck-on-or-near-ioconsoleusers-gioscreenlock...-giolockstate-3)
> > * [Black screen after `IOConsoleUsers: gIOScreenLock...` on Navi](https://install.heavietnam.com/issue/pages/38Kcownp64KZwXr0s1p3#black-screen-after-ioconsoleusers-gioscreenlock...-on-navi)
> >   {% endhint %}

## macOS Handoff <a href="#macos-handoff" id="macos-handoff"></a>

<figure><img src="/files/cm77N5egC9Ip9p4QcZei" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Sau một đoạn hành trình khó khăn mà bạn đã vượt qua thì sắp tới rồi hãy cố thêm một chút

> Nếu như bạn gặp khó khăn ở logo apple thì hãy check một vài đều sau:
>
> * [macOS frozen right before login](/issue/kernel-issue.md#macos-frozen-right-before-login)
> * [Black screen after `IOConsoleUsers: gIOScreenLock...` on Navi](https://install.heavietnam.com/issue/pages/38Kcownp64KZwXr0s1p3#black-screen-after-ioconsoleusers-gioscreenlock...-on-navi)
> * [Frozen in the macOS installer after 30 seconds](/issue/userspace-issue.md#do-man-hinh-o-installer-sau-30-giay)
>   {% endhint %}

{% hint style="warning" %}
Source tham khảo: <https://dortania.github.io/OpenCore-Install-Guide/troubleshooting/boot.html#macos-handoff>
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://install.heavietnam.com/issue/tim-hieu-qua-trinh-cai-dat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
