2022年4月17日 星期日

Chocolatey - Windows 軟體套件管理工具


官方網址
https://chocolatey.org

Chocolatey 可以讓 Windows以 command line的形式來安裝及管理軟體套件,類似
Linux使用的 APT。

使用Powershell 安裝


1. 以系統管理員權限執行 Powershell。

2. 在 PowerShell執行以下命令
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient). DownloadString('https://community.chocolatey.org/install.ps1'))

3. 重新開機。

4. 在 Powershell執行 choco,確認是否安裝成功。
choco

Chocolatey v1.1.0

Chocolately 操作


安裝套件,以 jq為例:
choco install jq

2022年4月15日 星期五

Legacy PCI IRQ Routing (PIC)

PCI Configuration Space Header

PCI Local Bus spec中定義了兩個 register,Interrupt Line (0x3C)及 Interrupt Pin (0x3D)

Interrupt Line (0x3C)

BIOS會負責填入此 PCI device的 interrupt pin在系統上所使用的 IRQ number。
這個 register不會被 device本身使用,而是給 driver或 OS看的。

Interrupt Pin (0x3D)

PCI device透過 Interrupt Pin來發出中斷的信號,分別為INTA#、INTB#、INTC#及 INTD#。
可從此 register的值來判斷這 device或 device function所使用的 Interrupt Pin是哪一個,
在出廠時就固定了。(1=INTA# 2=INTB# 3=INTC# 4=INTD#)

PCI IRQ Router

Intel 南橋提供8個 PIRQn#來讓 BIOS決定PCI device的 interrupt pin要 route
到哪個 IRQ。

透過 LPC register 0x60-0x63 (PIRQA#-PIRQD#)及 0x68-0x6B (PIRQ#E-PIRQ#H)
來設定所使用的 IRQ number。

PCI IRQ Routing Specification

BIOS要負責提供 PCI routing的資訊,例如PCI Slot的 interrupt pin是接到Pci IRQ Router 的哪
個pin,藉此讓 OS能夠判斷 IRQ是由哪個 PCI device所觸發的。

Legacy BIOS時代便是由 Microsoft所規範的 PCI IRQ Routing Specification中的 PCI IRQ
Table來實現。

PCI IRQ table會以 16-byte boundary形式存放在系統記憶體 F0000h - FFFFFh(F segment)中,
其開頭為 $PIR。

Byte OffsetSize in BytesName
04Signature
42Version
62Table Size
81PCI Interrupt Router's Bus
91PCI Interrupt Router's DevFunc
102PCI Exclusive IRQs
124Compatible PCI Interrupt Router
164Miniport Data
2011Reserved (Zero)
311Checksum
3216First Slot Entry
4816Second Slot Entry
N+1*1616Nth Slot Entry

Slot Entry
Byte OffsetSize in BytesName
0BytePCI Bus Number
1BytePCI Device Number (in upper five bits)
2ByteLink Value for INTA#
3WordIRQ Bitmap for INTA#
5ByteLink Value for INTB#
6WordIRQ Bitmap for INTB#
8ByteLink Value for INTC#
9WordIRQ Bitmap for INTC#
11ByteLink Value for INTD#
12WordIRQ Bitmap for INTD#
14ByteSlot Number
15ByteReserved

Link Value for INTn#

代表此 INTn#所連接到的Interrupt Router's Pin (PIRQm#),若為 0則代表沒有連到
任何 PIRQm#。

IRQ Bitmap for INTn#

代表此 INTn#能使用的 IRQ。Bit0代表 IRQ0,Bit1代表 IRQ1以此類推。

2022年4月6日 星期三

Hello CMake


Source

CMake
https://cmake.org/

Visual Studio Community 2019
https://visualstudio.microsoft.com

以建立一個名為HelloCMake的專案為例,在 HelloCMake的目錄新增 CMakeLists.txt
檔案及放入專案程式碼 HelloCMake.cpp,如下:

HelloCmake
├ ─ ─ ─ CMakeLists.txt
└ ─ ─ ─ HelloCMake.cpp


CMakeLists.txt
cmake_minimum_required(VERSION 3.23)

# set the project name
project(HelloCMake)

# add the executable
add_executable(HelloCMake HelloCMake.cpp)

cmake_minimum_required

指定 CMake最低版本需求。

project

設定專案名稱。

add_executable

從指定的 source來產生執行檔。

Build CMake


在 HelloCMake的目錄下建立名為 build的目錄。
mkdir build


切換到 build,執行 cmake命令並指定 CMakeLists.txt所在的目錄。
cd build
cmake ../

在產生完 CMake檔案的 build下開始編譯
cmake --build .