SlideShare a Scribd company logo
www.puffinbrowser.com
Identifying and Supporting"X-
compatible" Hardware Blocks
Chen-Yu Tsai / wens@csie.org
Chen-Yu Tsai
• Software engineer at CloudMosa, Inc. in Taipei
– Manages Linux servers
– Write tooling for management
• Embedded Linux hobbyist since 2011
– Co-maintainer of kernel support for Allwinner SoC
Overview
• Introduction
• Identifying hardware
• Driver implementations
• Examples
Ancient PC history
• VGA
• 8250 UART
• NE2000
• Sound Blaster
Duck Test
• Looks like a duck
• Swims like a duck
• Quacks like a duck
Compatible How?
• Looks like a duck
– Has the same interface
• Swims like a duck
– Has the same logic
• Quacks like a duck
– Gives the same response
Examples
• Standard controller interfaces
– AHCI, EHCI, OHCI, xHCI
• Licensed IP cores
• Clones
AHCI, EHCI, OHCI, xHCI
• Standard interface to access the core
– Performance varies
• Vendor specific glue layer
– Clocks, resets, PHYs
IP Vendors
• Synopsys (DesignWare)
• Mentor Graphics
• Cadence
Licensed IP Cores
• Core IP block
– May even be for HCIs
• Glue layer
• PHYs
Clones
• Same logic
• Missing registers
• Rearranged registers
• Obfuscated registers
Identifying Hardware
Resources
• Datasheets
• Vendor Kernels
Good Public Datasheets
• NXP i.MX6 Reference Manual
• TI KeyStone II User Guide Library
• Zynq UltraScale+ MPSoC Register Reference
Identifiers
• Register layout
– Register names
• DMA engine
– Logic
– Descriptor format
Experience & Luck
• Needle in a sea of needles
– One can only recognize something they’ve seen before
• Senior members of the community may help
• Might only be recognizable after driver is finished
• YMMV
Implementing Drivers
Driver Libraries
• Core logic as a library
• Platform driver
– Extra resource management
– Extra setup
– Presents parameters and callbacks to library
drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
static int sun7i_gmac_probe(struct platform_device *pdev)
{
stmmac_get_platform_resources(pdev, &stmmac_res);
stmmac_probe_config_dt(pdev, &stmmac_res.mac);
/* platform specific stuff ... */
plat_dat->init = sun7i_gmac_init;
plat_dat->exit = sun7i_gmac_exit;
stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
}
Dealing with Register Changes
• Register offset table
• regmap & regmap_field
• Custom I/O callbacks
Register Offset Table
drivers/i2c/busses/i2c-mv64xxx.c:
struct mv64xxx_i2c_regs {
u8 addr;
u8 ext_addr;
u8 data;
u8 control;
u8 status;
u8 clock;
u8 soft_reset;
};
writel(0, drv_data->reg_base + drv_data->reg_offsets.soft_reset);
regmap_field
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c:
static const struct sun4i_hdmi_variant sun6i_variant = {
…
.field_ddc_en = REG_FIELD(SUN4I_HDMI_DDC_CTRL_REG, 31, 31),
.field_ddc_start = REG_FIELD(SUN4I_HDMI_DDC_CTRL_REG, 30, 30),
.field_ddc_reset = REG_FIELD(SUN4I_HDMI_DDC_CTRL_REG, 0, 0),
.field_ddc_addr_reg = REG_FIELD(SUN4I_HDMI_DDC_ADDR_REG, 0, 31),
.field_ddc_slave_addr = REG_FIELD(SUN4I_HDMI_DDC_ADDR_REG, 0, 6),
…
};
regmap_field
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c:
static const struct sun4i_hdmi_variant {
…
/* Regmap fields for I2C adapter */
struct regmap_field *field_ddc_en;
struct regmap_field *field_ddc_start;
struct regmap_field *field_ddc_reset;
struct regmap_field *field_ddc_addr_reg;
struct regmap_field *field_ddc_slave_addr;
…
};
regmap_field
regmap_field_write(hdmi->field_ddc_fifo_tx_thres,
hdmi->variant->ddc_fifo_thres_incl ? 0 : 1);
regmap_field_write(hdmi->field_ddc_fifo_rx_thres, RX_THRESHOLD);
regmap_field_write(hdmi->field_ddc_fifo_clear, 1);
if (regmap_field_read_poll_timeout(hdmi->field_ddc_fifo_clear,
reg, !reg, 100, 2000))
return -EIO;
Custom I/O Functions
drivers/usb/musb/musb_io.h:
/**
* struct musb_io - IO functions for MUSB
* @quirks: platform specific flags
* @ep_offset: platform specific function to get end point offset
* @ep_select: platform specific function to select end point
* @fifo_offset: platform specific function to get fifo offset
* @read_fifo: platform specific function to read fifo
* @write_fifo: platform specific function to write fifo
* @busctl_offset: platform specific function to get busctl offset
*/
Examples
8250 UART
• De-facto standard
– 8250 driver library
• Platform specifics
– Extra features
– Quirks or bugs
Synopsys DesignWare APB UART
• Extra “busy” interrupt
– Fires on attempts to write to LCR when UART
is busy
– “irq XX: nobody cared”
• Extra “UART status register”
• 8250_dw driver wraps 8250 library
AHCI
• libahci & libahci_platform
– Driver library
– Handles PHYs, clocks, regulators
• Platform specific ahci_*
• Generic ahci_platform
Mentor Graphics MUSB
• USB On-The-Go IP core
– Seen on a few platforms
– Has all related signals (ID & VBUS detect)
• Separate USB PHY
Allwinner USB OTG
• MUSB with rearranged registers
– Custom I/O functions
• Very weird USB PHY interface
– Generic PHY framework
• ID & VBUS detect lines not routed outside
– Controlled through custom register
– Use GPIO lines externally
– extcon framework
DesignWare MAC
• Many hardware revisions
– Later ones have feature register
• Found on 12+ platforms
• Called “stmmac” in the kernel
– Driver library
– Platform provides config and callbacks
A20 GMAC
• Old revision of DWMAC
• No DMA feature register
– Dug out feature set from vendor kernel
• Simple glue layer
A64/H3 EMAC
• DWMAC with rearranged registers
– MDC bitfield meaning is different
– Chained DMA descriptors only
• DMA descriptor format is the same
– A few fields are marked as “reserved”
DesignWare HDMI
• Found on 3+ platforms
– With either DW-HDMI-PHY or 3rd party PHY
• “dw-hdmi” in the kernel
– Library-ish driver
– Platform provides config and callbacks
A64/H3 HDMI
• Obfuscated register addresses
– Obfuscation can be turned off :)
• Found in some vendor kernel release
• Custom PHY
– Reverse engineered init code
• Limited to certain resolutions
Questions?

More Related Content

What's hot

Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
shimosawa
 
ACPI Debugging from Linux Kernel
ACPI Debugging from Linux KernelACPI Debugging from Linux Kernel
ACPI Debugging from Linux Kernel
SUSE Labs Taipei
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
Sherif Mousa
 
Profiling the ACPICA Namespace and Event Handing
Profiling the ACPICA Namespace and Event HandingProfiling the ACPICA Namespace and Event Handing
Profiling the ACPICA Namespace and Event Handing
SUSE Labs Taipei
 
Linux Kernel Platform Development: Challenges and Insights
 Linux Kernel Platform Development: Challenges and Insights Linux Kernel Platform Development: Challenges and Insights
Linux Kernel Platform Development: Challenges and Insights
GlobalLogic Ukraine
 
Qemu Introduction
Qemu IntroductionQemu Introduction
Qemu Introduction
Chiawei Wang
 
Ironic
IronicIronic
Ironic
Haomeng Wang
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
linuxlab_conf
 
Linux Kernel Debugging
Linux Kernel DebuggingLinux Kernel Debugging
Linux Kernel Debugging
GlobalLogic Ukraine
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
Anil Kumar Pugalia
 
Kernel Recipes 2017 - HDMI CEC: Status Report - Hans Verkuil
Kernel Recipes 2017 - HDMI CEC: Status Report - Hans VerkuilKernel Recipes 2017 - HDMI CEC: Status Report - Hans Verkuil
Kernel Recipes 2017 - HDMI CEC: Status Report - Hans Verkuil
Anne Nicolas
 
U-Boot - An universal bootloader
U-Boot - An universal bootloader U-Boot - An universal bootloader
U-Boot - An universal bootloader
Emertxe Information Technologies Pvt Ltd
 
Kernel Recipes 2017 - Build farm again - Willy Tarreau
Kernel Recipes 2017 - Build farm again - Willy TarreauKernel Recipes 2017 - Build farm again - Willy Tarreau
Kernel Recipes 2017 - Build farm again - Willy Tarreau
Anne Nicolas
 
Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64
Samsung Open Source Group
 
OSDC 2017 - Werner Fischer - Open power for the data center
OSDC 2017 - Werner Fischer - Open power for the data centerOSDC 2017 - Werner Fischer - Open power for the data center
OSDC 2017 - Werner Fischer - Open power for the data center
NETWAYS
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
Anil Kumar Pugalia
 
Tech Days 2015: Embedded Product Update
Tech Days 2015: Embedded Product UpdateTech Days 2015: Embedded Product Update
Tech Days 2015: Embedded Product Update
AdaCore
 
Signature verification of kernel module and kexec
Signature verification of kernel module and kexecSignature verification of kernel module and kexec
Signature verification of kernel module and kexec
joeylikernel
 

What's hot (18)

Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
ACPI Debugging from Linux Kernel
ACPI Debugging from Linux KernelACPI Debugging from Linux Kernel
ACPI Debugging from Linux Kernel
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
 
Profiling the ACPICA Namespace and Event Handing
Profiling the ACPICA Namespace and Event HandingProfiling the ACPICA Namespace and Event Handing
Profiling the ACPICA Namespace and Event Handing
 
Linux Kernel Platform Development: Challenges and Insights
 Linux Kernel Platform Development: Challenges and Insights Linux Kernel Platform Development: Challenges and Insights
Linux Kernel Platform Development: Challenges and Insights
 
Qemu Introduction
Qemu IntroductionQemu Introduction
Qemu Introduction
 
Ironic
IronicIronic
Ironic
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
 
Linux Kernel Debugging
Linux Kernel DebuggingLinux Kernel Debugging
Linux Kernel Debugging
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
 
Kernel Recipes 2017 - HDMI CEC: Status Report - Hans Verkuil
Kernel Recipes 2017 - HDMI CEC: Status Report - Hans VerkuilKernel Recipes 2017 - HDMI CEC: Status Report - Hans Verkuil
Kernel Recipes 2017 - HDMI CEC: Status Report - Hans Verkuil
 
U-Boot - An universal bootloader
U-Boot - An universal bootloader U-Boot - An universal bootloader
U-Boot - An universal bootloader
 
Kernel Recipes 2017 - Build farm again - Willy Tarreau
Kernel Recipes 2017 - Build farm again - Willy TarreauKernel Recipes 2017 - Build farm again - Willy Tarreau
Kernel Recipes 2017 - Build farm again - Willy Tarreau
 
Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64
 
OSDC 2017 - Werner Fischer - Open power for the data center
OSDC 2017 - Werner Fischer - Open power for the data centerOSDC 2017 - Werner Fischer - Open power for the data center
OSDC 2017 - Werner Fischer - Open power for the data center
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Tech Days 2015: Embedded Product Update
Tech Days 2015: Embedded Product UpdateTech Days 2015: Embedded Product Update
Tech Days 2015: Embedded Product Update
 
Signature verification of kernel module and kexec
Signature verification of kernel module and kexecSignature verification of kernel module and kexec
Signature verification of kernel module and kexec
 

Similar to Identifying and Supporting 'X-compatible' Hardware Blocks

Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02
Narender Kumar
 
Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02
Narender Kumar
 
#WeSpeakLinux Session
#WeSpeakLinux Session#WeSpeakLinux Session
#WeSpeakLinux Session
Kellyn Pot'Vin-Gorman
 
Operating Systems 1 (5/12) - Architectures (Unix)
Operating Systems 1 (5/12) - Architectures (Unix)Operating Systems 1 (5/12) - Architectures (Unix)
Operating Systems 1 (5/12) - Architectures (Unix)
Peter Tröger
 
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
Stefano Stabellini
 
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
DefconRussia
 
HiPEAC-Keynote.pptx
HiPEAC-Keynote.pptxHiPEAC-Keynote.pptx
HiPEAC-Keynote.pptx
Behzad Salami
 
1184 Quayle
1184 Quayle1184 Quayle
1184 Quayle
Stanley F. Quayle
 
XPDS14: Xen 4.5 Roadmap - Konrad Wilk, Oracle
XPDS14: Xen 4.5 Roadmap - Konrad Wilk, OracleXPDS14: Xen 4.5 Roadmap - Konrad Wilk, Oracle
XPDS14: Xen 4.5 Roadmap - Konrad Wilk, Oracle
The Linux Foundation
 
Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest
Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest
Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest
Lenz Grimmer
 
ONIE: Open Network Install Environment @ OSDC 2014 Netways, Berlin
ONIE: Open Network Install Environment @ OSDC 2014 Netways, BerlinONIE: Open Network Install Environment @ OSDC 2014 Netways, Berlin
ONIE: Open Network Install Environment @ OSDC 2014 Netways, Berlin
Nat Morris
 
the windows opereting system
the windows opereting systemthe windows opereting system
the windows opereting system
Юсуф Сатторов
 
Earhart
EarhartEarhart
Earhart
siam hossain
 
Adding Support for Networking and Web Technologies to an Embedded System
Adding Support for Networking and Web Technologies to an Embedded SystemAdding Support for Networking and Web Technologies to an Embedded System
Adding Support for Networking and Web Technologies to an Embedded System
John Efstathiades
 
Hyper-V: Best Practices
Hyper-V: Best PracticesHyper-V: Best Practices
Hyper-V: Best Practices
Tomica Kaniski
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
Rayed Alrashed
 
OSDC 2014 ONIE by Nat Morris
OSDC 2014 ONIE by Nat MorrisOSDC 2014 ONIE by Nat Morris
OSDC 2014 ONIE by Nat Morris
Cumulus Networks
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
Kris Buytaert
 
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniquesLarson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Scott K. Larson
 
Nano Server (ATD 11)
Nano Server (ATD 11)Nano Server (ATD 11)
Nano Server (ATD 11)
Tomica Kaniski
 

Similar to Identifying and Supporting 'X-compatible' Hardware Blocks (20)

Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02
 
Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02
 
#WeSpeakLinux Session
#WeSpeakLinux Session#WeSpeakLinux Session
#WeSpeakLinux Session
 
Operating Systems 1 (5/12) - Architectures (Unix)
Operating Systems 1 (5/12) - Architectures (Unix)Operating Systems 1 (5/12) - Architectures (Unix)
Operating Systems 1 (5/12) - Architectures (Unix)
 
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
 
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
 
HiPEAC-Keynote.pptx
HiPEAC-Keynote.pptxHiPEAC-Keynote.pptx
HiPEAC-Keynote.pptx
 
1184 Quayle
1184 Quayle1184 Quayle
1184 Quayle
 
XPDS14: Xen 4.5 Roadmap - Konrad Wilk, Oracle
XPDS14: Xen 4.5 Roadmap - Konrad Wilk, OracleXPDS14: Xen 4.5 Roadmap - Konrad Wilk, Oracle
XPDS14: Xen 4.5 Roadmap - Konrad Wilk, Oracle
 
Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest
Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest
Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest
 
ONIE: Open Network Install Environment @ OSDC 2014 Netways, Berlin
ONIE: Open Network Install Environment @ OSDC 2014 Netways, BerlinONIE: Open Network Install Environment @ OSDC 2014 Netways, Berlin
ONIE: Open Network Install Environment @ OSDC 2014 Netways, Berlin
 
the windows opereting system
the windows opereting systemthe windows opereting system
the windows opereting system
 
Earhart
EarhartEarhart
Earhart
 
Adding Support for Networking and Web Technologies to an Embedded System
Adding Support for Networking and Web Technologies to an Embedded SystemAdding Support for Networking and Web Technologies to an Embedded System
Adding Support for Networking and Web Technologies to an Embedded System
 
Hyper-V: Best Practices
Hyper-V: Best PracticesHyper-V: Best Practices
Hyper-V: Best Practices
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
OSDC 2014 ONIE by Nat Morris
OSDC 2014 ONIE by Nat MorrisOSDC 2014 ONIE by Nat Morris
OSDC 2014 ONIE by Nat Morris
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniquesLarson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
 
Nano Server (ATD 11)
Nano Server (ATD 11)Nano Server (ATD 11)
Nano Server (ATD 11)
 

More from Chen-Yu Tsai

Putting Taiwan on the kernel.org Keysigning Map
Putting Taiwan on the kernel.org Keysigning MapPutting Taiwan on the kernel.org Keysigning Map
Putting Taiwan on the kernel.org Keysigning Map
Chen-Yu Tsai
 
Linux Kernel Patch Submission Tips
Linux Kernel Patch Submission TipsLinux Kernel Patch Submission Tips
Linux Kernel Patch Submission Tips
Chen-Yu Tsai
 
Allwinner Kernel Upstreaming Experiences
Allwinner Kernel Upstreaming ExperiencesAllwinner Kernel Upstreaming Experiences
Allwinner Kernel Upstreaming Experiences
Chen-Yu Tsai
 
Upstream Allwinner ARM SoC (sunxi) Support
Upstream Allwinner ARM SoC (sunxi) SupportUpstream Allwinner ARM SoC (sunxi) Support
Upstream Allwinner ARM SoC (sunxi) Support
Chen-Yu Tsai
 
linux-sunxi - OSDC.tw 2014 Lightning Talk
linux-sunxi - OSDC.tw 2014 Lightning Talklinux-sunxi - OSDC.tw 2014 Lightning Talk
linux-sunxi - OSDC.tw 2014 Lightning Talk
Chen-Yu Tsai
 
Open Standards and Open Source in Datacenter Management - OSDC.tw 2014
Open Standards and Open Source in Datacenter Management - OSDC.tw 2014Open Standards and Open Source in Datacenter Management - OSDC.tw 2014
Open Standards and Open Source in Datacenter Management - OSDC.tw 2014
Chen-Yu Tsai
 

More from Chen-Yu Tsai (6)

Putting Taiwan on the kernel.org Keysigning Map
Putting Taiwan on the kernel.org Keysigning MapPutting Taiwan on the kernel.org Keysigning Map
Putting Taiwan on the kernel.org Keysigning Map
 
Linux Kernel Patch Submission Tips
Linux Kernel Patch Submission TipsLinux Kernel Patch Submission Tips
Linux Kernel Patch Submission Tips
 
Allwinner Kernel Upstreaming Experiences
Allwinner Kernel Upstreaming ExperiencesAllwinner Kernel Upstreaming Experiences
Allwinner Kernel Upstreaming Experiences
 
Upstream Allwinner ARM SoC (sunxi) Support
Upstream Allwinner ARM SoC (sunxi) SupportUpstream Allwinner ARM SoC (sunxi) Support
Upstream Allwinner ARM SoC (sunxi) Support
 
linux-sunxi - OSDC.tw 2014 Lightning Talk
linux-sunxi - OSDC.tw 2014 Lightning Talklinux-sunxi - OSDC.tw 2014 Lightning Talk
linux-sunxi - OSDC.tw 2014 Lightning Talk
 
Open Standards and Open Source in Datacenter Management - OSDC.tw 2014
Open Standards and Open Source in Datacenter Management - OSDC.tw 2014Open Standards and Open Source in Datacenter Management - OSDC.tw 2014
Open Standards and Open Source in Datacenter Management - OSDC.tw 2014
 

Recently uploaded

IoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdf
IoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdfIoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdf
IoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdf
mohitd6
 
Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...
Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...
Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...
confluent
 
Software development... for all? (keynote at ICSOFT'2024)
Software development... for all? (keynote at ICSOFT'2024)Software development... for all? (keynote at ICSOFT'2024)
Software development... for all? (keynote at ICSOFT'2024)
miso_uam
 
NYGGS 360: A Complete ERP for Construction Innovation
NYGGS 360: A Complete ERP for Construction InnovationNYGGS 360: A Complete ERP for Construction Innovation
NYGGS 360: A Complete ERP for Construction Innovation
NYGGS Construction ERP Software
 
Mobile App Development Company in Noida - Drona Infotech.
Mobile App Development Company in Noida - Drona Infotech.Mobile App Development Company in Noida - Drona Infotech.
Mobile App Development Company in Noida - Drona Infotech.
Mobile App Development Company in Noida - Drona Infotech
 
Authentication Review-June -2024 AP & TS.pptx
Authentication Review-June -2024 AP & TS.pptxAuthentication Review-June -2024 AP & TS.pptx
Authentication Review-June -2024 AP & TS.pptx
DEMONDUOS
 
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
rachitkumar09887
 
ERP Software Solutions Provider in Coimbatore
ERP Software Solutions Provider in CoimbatoreERP Software Solutions Provider in Coimbatore
ERP Software Solutions Provider in Coimbatore
Nextskill Technologies
 
Top Chinese Government-backed APT Groups
Top Chinese Government-backed APT GroupsTop Chinese Government-backed APT Groups
Top Chinese Government-backed APT Groups
SOCRadar
 
TEQnation 2024: Sustainable Software: May the Green Code Be with You
TEQnation 2024: Sustainable Software: May the Green Code Be with YouTEQnation 2024: Sustainable Software: May the Green Code Be with You
TEQnation 2024: Sustainable Software: May the Green Code Be with You
marcofolio
 
Il Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazioneIl Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazione
confluent
 
HIRE A HACKER FOR CHEATING HUSBAND/WIFE)
HIRE A HACKER FOR CHEATING HUSBAND/WIFE)HIRE A HACKER FOR CHEATING HUSBAND/WIFE)
HIRE A HACKER FOR CHEATING HUSBAND/WIFE)
josephinedrea942
 
Artificial intelligence in customer services or chatbots
Artificial intelligence  in customer services or chatbotsArtificial intelligence  in customer services or chatbots
Artificial intelligence in customer services or chatbots
kayash1656
 
Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …
908dutch
 
Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...
Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...
Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...
norina2645
 
UMiami degree offer diploma Transcript
UMiami degree offer diploma TranscriptUMiami degree offer diploma Transcript
UMiami degree offer diploma Transcript
attueb
 
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
bhumivarma35300
 
Introduction to Cloud computing for Internet of Things
Introduction to Cloud computing for Internet of ThingsIntroduction to Cloud computing for Internet of Things
Introduction to Cloud computing for Internet of Things
NachuSubramanian1
 
Google ML-Kit - Understanding on-device machine learning
Google ML-Kit - Understanding on-device machine learningGoogle ML-Kit - Understanding on-device machine learning
Google ML-Kit - Understanding on-device machine learning
VishrutGoyani1
 
How To Fill Timesheet in TaskSprint: Quick Guide 2024
How To Fill Timesheet in TaskSprint: Quick Guide 2024How To Fill Timesheet in TaskSprint: Quick Guide 2024
How To Fill Timesheet in TaskSprint: Quick Guide 2024
TaskSprint | Employee Efficiency Software
 

Recently uploaded (20)

IoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdf
IoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdfIoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdf
IoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdf
 
Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...
Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...
Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...
 
Software development... for all? (keynote at ICSOFT'2024)
Software development... for all? (keynote at ICSOFT'2024)Software development... for all? (keynote at ICSOFT'2024)
Software development... for all? (keynote at ICSOFT'2024)
 
NYGGS 360: A Complete ERP for Construction Innovation
NYGGS 360: A Complete ERP for Construction InnovationNYGGS 360: A Complete ERP for Construction Innovation
NYGGS 360: A Complete ERP for Construction Innovation
 
Mobile App Development Company in Noida - Drona Infotech.
Mobile App Development Company in Noida - Drona Infotech.Mobile App Development Company in Noida - Drona Infotech.
Mobile App Development Company in Noida - Drona Infotech.
 
Authentication Review-June -2024 AP & TS.pptx
Authentication Review-June -2024 AP & TS.pptxAuthentication Review-June -2024 AP & TS.pptx
Authentication Review-June -2024 AP & TS.pptx
 
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
 
ERP Software Solutions Provider in Coimbatore
ERP Software Solutions Provider in CoimbatoreERP Software Solutions Provider in Coimbatore
ERP Software Solutions Provider in Coimbatore
 
Top Chinese Government-backed APT Groups
Top Chinese Government-backed APT GroupsTop Chinese Government-backed APT Groups
Top Chinese Government-backed APT Groups
 
TEQnation 2024: Sustainable Software: May the Green Code Be with You
TEQnation 2024: Sustainable Software: May the Green Code Be with YouTEQnation 2024: Sustainable Software: May the Green Code Be with You
TEQnation 2024: Sustainable Software: May the Green Code Be with You
 
Il Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazioneIl Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazione
 
HIRE A HACKER FOR CHEATING HUSBAND/WIFE)
HIRE A HACKER FOR CHEATING HUSBAND/WIFE)HIRE A HACKER FOR CHEATING HUSBAND/WIFE)
HIRE A HACKER FOR CHEATING HUSBAND/WIFE)
 
Artificial intelligence in customer services or chatbots
Artificial intelligence  in customer services or chatbotsArtificial intelligence  in customer services or chatbots
Artificial intelligence in customer services or chatbots
 
Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …
 
Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...
Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...
Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...
 
UMiami degree offer diploma Transcript
UMiami degree offer diploma TranscriptUMiami degree offer diploma Transcript
UMiami degree offer diploma Transcript
 
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
 
Introduction to Cloud computing for Internet of Things
Introduction to Cloud computing for Internet of ThingsIntroduction to Cloud computing for Internet of Things
Introduction to Cloud computing for Internet of Things
 
Google ML-Kit - Understanding on-device machine learning
Google ML-Kit - Understanding on-device machine learningGoogle ML-Kit - Understanding on-device machine learning
Google ML-Kit - Understanding on-device machine learning
 
How To Fill Timesheet in TaskSprint: Quick Guide 2024
How To Fill Timesheet in TaskSprint: Quick Guide 2024How To Fill Timesheet in TaskSprint: Quick Guide 2024
How To Fill Timesheet in TaskSprint: Quick Guide 2024
 

Identifying and Supporting 'X-compatible' Hardware Blocks

  • 1. www.puffinbrowser.com Identifying and Supporting"X- compatible" Hardware Blocks Chen-Yu Tsai / wens@csie.org
  • 2. Chen-Yu Tsai • Software engineer at CloudMosa, Inc. in Taipei – Manages Linux servers – Write tooling for management • Embedded Linux hobbyist since 2011 – Co-maintainer of kernel support for Allwinner SoC
  • 3. Overview • Introduction • Identifying hardware • Driver implementations • Examples
  • 4. Ancient PC history • VGA • 8250 UART • NE2000 • Sound Blaster
  • 5. Duck Test • Looks like a duck • Swims like a duck • Quacks like a duck
  • 6. Compatible How? • Looks like a duck – Has the same interface • Swims like a duck – Has the same logic • Quacks like a duck – Gives the same response
  • 7. Examples • Standard controller interfaces – AHCI, EHCI, OHCI, xHCI • Licensed IP cores • Clones
  • 8. AHCI, EHCI, OHCI, xHCI • Standard interface to access the core – Performance varies • Vendor specific glue layer – Clocks, resets, PHYs
  • 9. IP Vendors • Synopsys (DesignWare) • Mentor Graphics • Cadence
  • 10. Licensed IP Cores • Core IP block – May even be for HCIs • Glue layer • PHYs
  • 11. Clones • Same logic • Missing registers • Rearranged registers • Obfuscated registers
  • 14. Good Public Datasheets • NXP i.MX6 Reference Manual • TI KeyStone II User Guide Library • Zynq UltraScale+ MPSoC Register Reference
  • 15. Identifiers • Register layout – Register names • DMA engine – Logic – Descriptor format
  • 16. Experience & Luck • Needle in a sea of needles – One can only recognize something they’ve seen before • Senior members of the community may help • Might only be recognizable after driver is finished • YMMV
  • 18. Driver Libraries • Core logic as a library • Platform driver – Extra resource management – Extra setup – Presents parameters and callbacks to library
  • 19. drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c static int sun7i_gmac_probe(struct platform_device *pdev) { stmmac_get_platform_resources(pdev, &stmmac_res); stmmac_probe_config_dt(pdev, &stmmac_res.mac); /* platform specific stuff ... */ plat_dat->init = sun7i_gmac_init; plat_dat->exit = sun7i_gmac_exit; stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); }
  • 20. Dealing with Register Changes • Register offset table • regmap & regmap_field • Custom I/O callbacks
  • 21. Register Offset Table drivers/i2c/busses/i2c-mv64xxx.c: struct mv64xxx_i2c_regs { u8 addr; u8 ext_addr; u8 data; u8 control; u8 status; u8 clock; u8 soft_reset; }; writel(0, drv_data->reg_base + drv_data->reg_offsets.soft_reset);
  • 22. regmap_field drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c: static const struct sun4i_hdmi_variant sun6i_variant = { … .field_ddc_en = REG_FIELD(SUN4I_HDMI_DDC_CTRL_REG, 31, 31), .field_ddc_start = REG_FIELD(SUN4I_HDMI_DDC_CTRL_REG, 30, 30), .field_ddc_reset = REG_FIELD(SUN4I_HDMI_DDC_CTRL_REG, 0, 0), .field_ddc_addr_reg = REG_FIELD(SUN4I_HDMI_DDC_ADDR_REG, 0, 31), .field_ddc_slave_addr = REG_FIELD(SUN4I_HDMI_DDC_ADDR_REG, 0, 6), … };
  • 23. regmap_field drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c: static const struct sun4i_hdmi_variant { … /* Regmap fields for I2C adapter */ struct regmap_field *field_ddc_en; struct regmap_field *field_ddc_start; struct regmap_field *field_ddc_reset; struct regmap_field *field_ddc_addr_reg; struct regmap_field *field_ddc_slave_addr; … };
  • 24. regmap_field regmap_field_write(hdmi->field_ddc_fifo_tx_thres, hdmi->variant->ddc_fifo_thres_incl ? 0 : 1); regmap_field_write(hdmi->field_ddc_fifo_rx_thres, RX_THRESHOLD); regmap_field_write(hdmi->field_ddc_fifo_clear, 1); if (regmap_field_read_poll_timeout(hdmi->field_ddc_fifo_clear, reg, !reg, 100, 2000)) return -EIO;
  • 25. Custom I/O Functions drivers/usb/musb/musb_io.h: /** * struct musb_io - IO functions for MUSB * @quirks: platform specific flags * @ep_offset: platform specific function to get end point offset * @ep_select: platform specific function to select end point * @fifo_offset: platform specific function to get fifo offset * @read_fifo: platform specific function to read fifo * @write_fifo: platform specific function to write fifo * @busctl_offset: platform specific function to get busctl offset */
  • 27. 8250 UART • De-facto standard – 8250 driver library • Platform specifics – Extra features – Quirks or bugs
  • 28. Synopsys DesignWare APB UART • Extra “busy” interrupt – Fires on attempts to write to LCR when UART is busy – “irq XX: nobody cared” • Extra “UART status register” • 8250_dw driver wraps 8250 library
  • 29. AHCI • libahci & libahci_platform – Driver library – Handles PHYs, clocks, regulators • Platform specific ahci_* • Generic ahci_platform
  • 30. Mentor Graphics MUSB • USB On-The-Go IP core – Seen on a few platforms – Has all related signals (ID & VBUS detect) • Separate USB PHY
  • 31. Allwinner USB OTG • MUSB with rearranged registers – Custom I/O functions • Very weird USB PHY interface – Generic PHY framework • ID & VBUS detect lines not routed outside – Controlled through custom register – Use GPIO lines externally – extcon framework
  • 32. DesignWare MAC • Many hardware revisions – Later ones have feature register • Found on 12+ platforms • Called “stmmac” in the kernel – Driver library – Platform provides config and callbacks
  • 33. A20 GMAC • Old revision of DWMAC • No DMA feature register – Dug out feature set from vendor kernel • Simple glue layer
  • 34. A64/H3 EMAC • DWMAC with rearranged registers – MDC bitfield meaning is different – Chained DMA descriptors only • DMA descriptor format is the same – A few fields are marked as “reserved”
  • 35. DesignWare HDMI • Found on 3+ platforms – With either DW-HDMI-PHY or 3rd party PHY • “dw-hdmi” in the kernel – Library-ish driver – Platform provides config and callbacks
  • 36. A64/H3 HDMI • Obfuscated register addresses – Obfuscation can be turned off :) • Found in some vendor kernel release • Custom PHY – Reverse engineered init code • Limited to certain resolutions