SlideShare a Scribd company logo
X Window / Direct Rendering
                                        Architectural Diagram
       Xclient (w/GL)
                        OpenGL I/F
Xlib I/F                                                               Filesystem
                                       libdrm I/F      IOCTL / mmap
                                                                       Driver I/F


                        Mesa                 libdrm
                                                                                               PCI
                                                                                   Direct
 Xlib       Xlib I/F
                                                                                               Driver
                                                                                 Rendering
                                                                                               I/F
                                                                                  Manager
                                                             Filesystem
                                             sockets         Abstraction
                                                                                  AGP GART
                                                                                  Manager
              X protocol                                               Filesystem I/F
                                                                       Driver I/F                          Hard-
                                                              Kernel
                                             sockets
  X Server (device-independent tier)                                                                       ware
                                                                                 AGP GART
                                       libdrm I/F
                XFree86 Tier
                                                                                  Manager
 DIX                                                    IOCTL / Memory
                                             libdrm
 I/F             DGA           DRI                      mmap Manager    MM
                                                                                           PCI
                                                              Subsystem I/F
                                                                                           Driver
              vidmode
                                                                                           I/F
                             Video
           XFree86                           IOCTL /
                                                                IRQ
                 XAA
                                                                              PCI Device
           Extension                         mmap
                             Driver                          Abstraction IRQM
  MI       I/F
                                                                                    Manager
                                                                           I/F
                  Xv
                                                                         2007 © Moriyoshi Koizumi. All Rights Reserved.
X Window / Indirect Rendering
                           Architectural Diagram
       Xclient (w/GL)
                        OpenGL I/F
Xlib I/F                                                             Filesystem
                                                                     Driver I/F


                        Mesa
                                                                                              PCI
                                                                                  Direct
 Xlib       Xlib I/F
                                                                                              Driver
                                                                                Rendering
                                                                                              I/F
                                                                                 Manager
                                                           Filesystem
                                             sockets       Abstraction
                                                                                AGP GART
                                                                                Manager
              X protocol                                             Filesystem I/F
                                                                     Driver I/F                           Hard-
                                                            Kernel
                                             sockets
  X Server (DIX)                                                                                          ware
                        GLX     Mesa
                                                                                AGP GART
       XFree86 Tier                    libdrm I/F
                                                                                 Manager
 DIX                                                   IOCTL / Memory
                                             libdrm
 I/F             DGA           DRI                     mmap Manager   MM
                                                                                          PCI
                                                            Subsystem I/F
                                                                                          Driver
              vidmode
                                                                                          I/F
                              Video
           XFree86                           IOCTL /
                                                              IRQ
                 XAA
                                                                            PCI Device
           Extension                         mmap
                              Driver                       Abstraction IRQM
  MI       I/F
                                                                                   Manager
                                                                          I/F
                  Xv
                                                                        2007 © Moriyoshi Koizumi. All Rights Reserved.
Address Space Layout

                                      Kernel Space
                    Graphics
           MMIO     Aperture
           Space




Physical
                                      User Space
Address
Space
           Actual
           RAM
           Space
                     GART




                                     2007 © Moriyoshi Koizumi. All Rights Reserved.
Direct Memory Access
                            1. Queueing
              Kernel Space               Graphic Controller
               Instruction
                 Buffer          DMA                                FIFO
                                 Transfer



 Marked
Consistent   IOCTL (BLIT etc.)
              User Space

                  Some
                 Process




                                    2007 © Moriyoshi Koizumi. All Rights Reserved.
Direct Memory Access
         2. Bitmap Block Transfer (Blit)
               Kernel Space          Graphic Controller
                                         Active Entry
                              FIFO




                                                   Parse &
               User Space                          Dispatch

                  Some
 Marked
                 Process                Blit Engine
Consistent

                              DMA Transfer
                 Another
                 Process

                               2007 © Moriyoshi Koizumi. All Rights Reserved.
DRM IOCTL I/F

    AUTH (GET_MAGIC / AUTH_MAGIC)
●


    VERSION (GET / SET)
●


    BUSID (GET / SET)
●


    MAP (ADD / RM)
●


    CTX (ADD / RM / GET / SWITCH / NEW /
●


    RESERVE)
    LOCK (LOCK / UNLOCK)
●


    AGP operations
●


    Device-specific operations
●
                                 2007 © Moriyoshi Koizumi. All Rights Reserved.
DRM Authentication

                               1. Retrieve Magic Cookie (drmGetMagic())

                                                              Cookie Manager
                Mesa             libdrm
                                                                              2. Generate
                                                              Direct
Xlib
                                                                              Magic
                                                            Rendering
                                                             Manager          Cookie

                        3. Send Magic
       X protocol       (XF86DRIAuthConnection())     4. Authenticate Cookie
                                                      (drmAuthMagic())
                                             Kernel
       X Server

         XFree86 Tier
                                 libdrm
                        DRI




                                                      2007 © Moriyoshi Koizumi. All Rights Reserved.
DRM Authentication
                                                                (Userland Wrappers)

libdrm/xf86drm.c:
(formally: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c)
int drmGetMagic(int fd, drm_magic_t * magic)
{
     drm_auth_t auth;


    *magic = 0;
    if (ioctl(fd, DRM_IOCTL_GET_MAGIC, &auth)) return -errno;
    *magic = auth.magic;
    return 0;
}




                                                          2007 © Moriyoshi Koizumi. All Rights Reserved.
DRM Authentication
                                                             (Userland Wrappers)

xc/programs/Xserver/hw/xfree86/dri/dri.c:
Bool
DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic)
{
     DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);


    if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
    return TRUE;
}


libdrm/xf86drm.c:
(formally: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c)
  int drmAuthMagic(int fd, drm_magic_t magic)
  {
      drm_auth_t auth;
      auth.magic = magic;
      if (ioctl(fd, DRM_IOCTL_AUTH_MAGIC, &auth)) return -errno;
      return 0;
  }



                                                       2007 © Moriyoshi Koizumi. All Rights Reserved.
DRM Authentication
       (linux/drivers/char/drm/drm_drv.c: IOCTL Dispatch Table)

static drm_ioctl_desc_t drm_ioctls[] = {
   [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = {drm_version, 0},
   [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = {drm_getunique,
0},
   [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = {drm_getmagic, 0},
   [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = {drm_irq_by_busid,
DRM_MASTER|DRM_ROOT_ONLY},
   [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = {drm_getmap, 0},
   [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = {drm_getclient,
0},
   [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = {drm_setversion,
DRM_MASTER|DRM_ROOT_ONLY},
   [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = {drm_authmagic,
DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
   [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = {drm_addctx,
DRM_AUTH|DRM_ROOT_ONLY},
   [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = {drm_getctx,
DRM_AUTH},
...

                                       2007 © Moriyoshi Koizumi. All Rights Reserved.
DRM Authentication
             (linux/drivers/char/drm/drm_drv.c: IOCTL Dispatcher)
if (nr < DRIVER_IOCTL_COUNT)
    ioctl = &drm_ioctls[nr];
else if ((nr >= DRM_COMMAND_BASE)
           && (nr < DRM_COMMAND_BASE + dev->driver->num_ioctls))
    ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE];
else
    goto err_i1;


func = ioctl->func;


/* is there a local override? */
if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl)
        func = dev->driver->dma_ioctl;
if (!func) {
    DRM_DEBUG(quot;no functionnquot;);
    retcode = -EINVAL;
} else if (((ioctl->flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)) ||
       ((ioctl->flags & DRM_AUTH) && !priv->authenticated) ||
       ((ioctl->flags & DRM_MASTER) && !priv->master)) {
    retcode = -EACCES;
} else {
    retcode = func(inode, filp, cmd, arg);
}

                                               2007 © Moriyoshi Koizumi. All Rights Reserved.
DRM Authentication
                (linux/drivers/char/drm/drm_auth.c: Cookie Issuer)

int drm_getmagic(struct inode *inode, struct file *filp,
            unsigned int cmd, unsigned long arg)
{
       ...
                                        typedef unsigned int drm_magic_t;
       /* Find unique magic */
       if (priv->magic) {
                                        typedef struct drm_auth {
           auth.magic = priv->magic;
                                           drm_magic_t magic;
       } else {
           do {                         } drm_auth_t;
               spin_lock(&lock);
               if (!sequence)
                   ++sequence;/* reserve 0 */
               auth.magic = sequence++;
               spin_unlock(&lock);
           } while (drm_find_file(dev, auth.magic));
           priv->magic = auth.magic;
           drm_add_magic(dev, priv, auth.magic);
       }


       DRM_DEBUG(quot;%unquot;, auth.magic);
       if (copy_to_user((drm_auth_t __user *) arg, &auth, sizeof(auth)))
           return -EFAULT;
       return 0;
}

                                               2007 © Moriyoshi Koizumi. All Rights Reserved.
DRM Authentication
                (linux/drivers/char/drm/drm_auth.c: Cookie Verifier)


int drm_authmagic(struct inode *inode, struct file *filp,
          unsigned int cmd, unsigned long arg)
{
    drm_file_t *priv = filp->private_data;
    drm_device_t *dev = priv->head->dev;
    drm_auth_t auth;
    drm_file_t *file;


    if (copy_from_user(&auth, (drm_auth_t __user *) arg, sizeof(auth)))
        return -EFAULT;
    DRM_DEBUG(quot;%unquot;, auth.magic);
    if ((file = drm_find_file(dev, auth.magic))) {
        file->authenticated = 1;
        drm_remove_magic(dev, auth.magic);
        return 0;
    }
    return -EINVAL;
}




                                                2007 © Moriyoshi Koizumi. All Rights Reserved.
DRM Authentication
                (linux/drivers/char/drm/drm_auth.c: Cookie Keeper)



static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
{
    drm_file_t *retval = NULL;
    drm_magic_entry_t *pt;
    int hash = drm_hash_magic(magic);


    mutex_lock(&dev->struct_mutex);
    for (pt = dev->magiclist[hash].head; pt; pt = pt->next) {
        if (pt->magic == magic) {
            retval = pt->priv;
            break;
        }
    }
    mutex_unlock(&dev->struct_mutex);
    return retval;
}




                                                2007 © Moriyoshi Koizumi. All Rights Reserved.
Graphic Address Remapping Table
                          (GART)
   SAREA
  Frame Buffer       Phy-Phy Address Translation
 Texture Buffer                                    Process #1
                         (by AGP controller)
                       Graphics
            MMIO       Aperture                                               Virtual
            Space                                                             Memory
                                                                              Space


Physical
                                                   Process #2
Address
Space
            Actual                                                            Virtual
            RAM                                                               Memory
            Space                                                             Space
                         GART


                                              Phy-Virt Address
                                              Translation (by MMU)

                                                   2007 © Moriyoshi Koizumi. All Rights Reserved.
AGPGART IOCTL I/F

    ACQUIRE
●



    SETUP
●



    RESERVE
●



    PROTECT
●



    ALLOCATE / DEALLOCATE
●



    BIND / UNBIND
●




                            2007 © Moriyoshi Koizumi. All Rights Reserved.

More Related Content

What's hot

Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
Emertxe Information Technologies Pvt Ltd
 
BKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateBKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack Update
Linaro
 
ARM Trusted FirmwareのBL31を単体で使う!
ARM Trusted FirmwareのBL31を単体で使う!ARM Trusted FirmwareのBL31を単体で使う!
ARM Trusted FirmwareのBL31を単体で使う!
Mr. Vengineer
 
Linux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use CasesLinux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use Cases
Kernel TLV
 
05.2 virtio introduction
05.2 virtio introduction05.2 virtio introduction
05.2 virtio introduction
zenixls2
 
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
The Linux Foundation
 
Linux Network Stack
Linux Network StackLinux Network Stack
Linux Network Stack
Adrien Mahieux
 
Power Management from Linux Kernel to Android
Power Management from Linux Kernel to AndroidPower Management from Linux Kernel to Android
Power Management from Linux Kernel to Android
National Cheng Kung University
 
Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)
Brendan Gregg
 
eBPF Perf Tools 2019
eBPF Perf Tools 2019eBPF Perf Tools 2019
eBPF Perf Tools 2019
Brendan Gregg
 
20221021_JP5.0.2-Webinar-JP_Final.pdf
20221021_JP5.0.2-Webinar-JP_Final.pdf20221021_JP5.0.2-Webinar-JP_Final.pdf
20221021_JP5.0.2-Webinar-JP_Final.pdf
NVIDIA Japan
 
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
Mr. Vengineer
 
Linux dma engine
Linux dma engineLinux dma engine
Linux dma engine
pradeep_tewani
 
Xen in Safety-Critical Systems - Critical Summit 2022
Xen in Safety-Critical Systems - Critical Summit 2022Xen in Safety-Critical Systems - Critical Summit 2022
Xen in Safety-Critical Systems - Critical Summit 2022
Stefano Stabellini
 
Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)
Thomas Petazzoni
 
twlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsotwlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdso
Viller Hsiao
 
Hands-on ethernet driver
Hands-on ethernet driverHands-on ethernet driver
Hands-on ethernet driver
SUSE Labs Taipei
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Jian-Hong Pan
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDB
Linaro
 
いまさら聞けないarmを使ったNEONの基礎と活用事例
いまさら聞けないarmを使ったNEONの基礎と活用事例いまさら聞けないarmを使ったNEONの基礎と活用事例
いまさら聞けないarmを使ったNEONの基礎と活用事例
Fixstars Corporation
 

What's hot (20)

Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
BKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateBKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack Update
 
ARM Trusted FirmwareのBL31を単体で使う!
ARM Trusted FirmwareのBL31を単体で使う!ARM Trusted FirmwareのBL31を単体で使う!
ARM Trusted FirmwareのBL31を単体で使う!
 
Linux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use CasesLinux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use Cases
 
05.2 virtio introduction
05.2 virtio introduction05.2 virtio introduction
05.2 virtio introduction
 
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
 
Linux Network Stack
Linux Network StackLinux Network Stack
Linux Network Stack
 
Power Management from Linux Kernel to Android
Power Management from Linux Kernel to AndroidPower Management from Linux Kernel to Android
Power Management from Linux Kernel to Android
 
Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)
 
eBPF Perf Tools 2019
eBPF Perf Tools 2019eBPF Perf Tools 2019
eBPF Perf Tools 2019
 
20221021_JP5.0.2-Webinar-JP_Final.pdf
20221021_JP5.0.2-Webinar-JP_Final.pdf20221021_JP5.0.2-Webinar-JP_Final.pdf
20221021_JP5.0.2-Webinar-JP_Final.pdf
 
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
 
Linux dma engine
Linux dma engineLinux dma engine
Linux dma engine
 
Xen in Safety-Critical Systems - Critical Summit 2022
Xen in Safety-Critical Systems - Critical Summit 2022Xen in Safety-Critical Systems - Critical Summit 2022
Xen in Safety-Critical Systems - Critical Summit 2022
 
Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)
 
twlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsotwlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdso
 
Hands-on ethernet driver
Hands-on ethernet driverHands-on ethernet driver
Hands-on ethernet driver
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDB
 
いまさら聞けないarmを使ったNEONの基礎と活用事例
いまさら聞けないarmを使ったNEONの基礎と活用事例いまさら聞けないarmを使ったNEONの基礎と活用事例
いまさら聞けないarmを使ったNEONの基礎と活用事例
 

Similar to X / DRM (Direct Rendering Manager) Architectural Overview

20111130 hardware-monitoring-with-the-new-ipmi-plugin-v2
20111130 hardware-monitoring-with-the-new-ipmi-plugin-v220111130 hardware-monitoring-with-the-new-ipmi-plugin-v2
20111130 hardware-monitoring-with-the-new-ipmi-plugin-v2Werner Fischer
 
Raise your Uptime - How to monitor heterogeneous server environments with Linux
Raise your Uptime - How to monitor heterogeneous server environments with LinuxRaise your Uptime - How to monitor heterogeneous server environments with Linux
Raise your Uptime - How to monitor heterogeneous server environments with LinuxWerner Fischer
 
Hybrid Programmable Forwarding Planes: BoF Session
Hybrid Programmable Forwarding Planes: BoF SessionHybrid Programmable Forwarding Planes: BoF Session
Hybrid Programmable Forwarding Planes: BoF Session
Juniper Developer Resources Cooney
 
z/VM Platform Update
z/VM Platform Updatez/VM Platform Update
z/VM Platform Update
IBM India Smarter Computing
 
Open Storage Sun Intel European Business Technology Tour
Open Storage Sun Intel European Business Technology TourOpen Storage Sun Intel European Business Technology Tour
Open Storage Sun Intel European Business Technology TourWalter Moriconi
 
Benefits of Using FPGAs for Embedded Processing: Embedded World 2010
Benefits of Using FPGAs for Embedded Processing: Embedded World 2010Benefits of Using FPGAs for Embedded Processing: Embedded World 2010
Benefits of Using FPGAs for Embedded Processing: Embedded World 2010Altera Corporation
 
FPGA Camp - Intellitech Presentation
FPGA Camp - Intellitech PresentationFPGA Camp - Intellitech Presentation
FPGA Camp - Intellitech PresentationFPGA Central
 
Unified workflow review (gen)
Unified workflow review (gen)Unified workflow review (gen)
Unified workflow review (gen)Baiju Gujarathi
 
Jaguar x86 Core Functional Verification
Jaguar x86 Core Functional VerificationJaguar x86 Core Functional Verification
Jaguar x86 Core Functional VerificationDVClub
 
Sears Point Racetrack
Sears Point RacetrackSears Point Racetrack
Sears Point RacetrackDino, llc
 
Lte Latam 2012 Alberto Boaventura V6
Lte Latam 2012 Alberto Boaventura V6Lte Latam 2012 Alberto Boaventura V6
Lte Latam 2012 Alberto Boaventura V6
Alberto Boaventura
 
Mpc5121 econfs
Mpc5121 econfsMpc5121 econfs
Mpc5121 econfsDino, llc
 
Ap nr5000 pt file
Ap nr5000 pt fileAp nr5000 pt file
Ap nr5000 pt file
AddPac1999
 
Linux-without-a-bootloader
Linux-without-a-bootloaderLinux-without-a-bootloader
Linux-without-a-bootloader
Nishanth Menon
 
Презентация команды "Обыватели"
Презентация команды "Обыватели"Презентация команды "Обыватели"
Презентация команды "Обыватели"
Tatyana Savchyk
 
Linux on System z disk I/O performance
Linux on System z disk I/O performanceLinux on System z disk I/O performance
Linux on System z disk I/O performance
IBM India Smarter Computing
 
9800301 04 8080-8085_assembly_language_programming_manual_may81
9800301 04 8080-8085_assembly_language_programming_manual_may819800301 04 8080-8085_assembly_language_programming_manual_may81
9800301 04 8080-8085_assembly_language_programming_manual_may81
satolina
 
PA Develops an LTE PHY for Catapult
PA Develops an LTE PHY for CatapultPA Develops an LTE PHY for Catapult
PA Develops an LTE PHY for Catapult
grahambell
 
LF_DPDK17_mediated devices: better userland IO
LF_DPDK17_mediated devices: better userland IOLF_DPDK17_mediated devices: better userland IO
LF_DPDK17_mediated devices: better userland IO
LF_DPDK
 

Similar to X / DRM (Direct Rendering Manager) Architectural Overview (20)

20111130 hardware-monitoring-with-the-new-ipmi-plugin-v2
20111130 hardware-monitoring-with-the-new-ipmi-plugin-v220111130 hardware-monitoring-with-the-new-ipmi-plugin-v2
20111130 hardware-monitoring-with-the-new-ipmi-plugin-v2
 
Raise your Uptime - How to monitor heterogeneous server environments with Linux
Raise your Uptime - How to monitor heterogeneous server environments with LinuxRaise your Uptime - How to monitor heterogeneous server environments with Linux
Raise your Uptime - How to monitor heterogeneous server environments with Linux
 
Thesis Donato Slides EN
Thesis Donato Slides ENThesis Donato Slides EN
Thesis Donato Slides EN
 
Hybrid Programmable Forwarding Planes: BoF Session
Hybrid Programmable Forwarding Planes: BoF SessionHybrid Programmable Forwarding Planes: BoF Session
Hybrid Programmable Forwarding Planes: BoF Session
 
z/VM Platform Update
z/VM Platform Updatez/VM Platform Update
z/VM Platform Update
 
Open Storage Sun Intel European Business Technology Tour
Open Storage Sun Intel European Business Technology TourOpen Storage Sun Intel European Business Technology Tour
Open Storage Sun Intel European Business Technology Tour
 
Benefits of Using FPGAs for Embedded Processing: Embedded World 2010
Benefits of Using FPGAs for Embedded Processing: Embedded World 2010Benefits of Using FPGAs for Embedded Processing: Embedded World 2010
Benefits of Using FPGAs for Embedded Processing: Embedded World 2010
 
FPGA Camp - Intellitech Presentation
FPGA Camp - Intellitech PresentationFPGA Camp - Intellitech Presentation
FPGA Camp - Intellitech Presentation
 
Unified workflow review (gen)
Unified workflow review (gen)Unified workflow review (gen)
Unified workflow review (gen)
 
Jaguar x86 Core Functional Verification
Jaguar x86 Core Functional VerificationJaguar x86 Core Functional Verification
Jaguar x86 Core Functional Verification
 
Sears Point Racetrack
Sears Point RacetrackSears Point Racetrack
Sears Point Racetrack
 
Lte Latam 2012 Alberto Boaventura V6
Lte Latam 2012 Alberto Boaventura V6Lte Latam 2012 Alberto Boaventura V6
Lte Latam 2012 Alberto Boaventura V6
 
Mpc5121 econfs
Mpc5121 econfsMpc5121 econfs
Mpc5121 econfs
 
Ap nr5000 pt file
Ap nr5000 pt fileAp nr5000 pt file
Ap nr5000 pt file
 
Linux-without-a-bootloader
Linux-without-a-bootloaderLinux-without-a-bootloader
Linux-without-a-bootloader
 
Презентация команды "Обыватели"
Презентация команды "Обыватели"Презентация команды "Обыватели"
Презентация команды "Обыватели"
 
Linux on System z disk I/O performance
Linux on System z disk I/O performanceLinux on System z disk I/O performance
Linux on System z disk I/O performance
 
9800301 04 8080-8085_assembly_language_programming_manual_may81
9800301 04 8080-8085_assembly_language_programming_manual_may819800301 04 8080-8085_assembly_language_programming_manual_may81
9800301 04 8080-8085_assembly_language_programming_manual_may81
 
PA Develops an LTE PHY for Catapult
PA Develops an LTE PHY for CatapultPA Develops an LTE PHY for Catapult
PA Develops an LTE PHY for Catapult
 
LF_DPDK17_mediated devices: better userland IO
LF_DPDK17_mediated devices: better userland IOLF_DPDK17_mediated devices: better userland IO
LF_DPDK17_mediated devices: better userland IO
 

More from Moriyoshi Koizumi

Goをカンストさせる話
Goをカンストさせる話Goをカンストさせる話
Goをカンストさせる話
Moriyoshi Koizumi
 
PHP7を魔改造した話
PHP7を魔改造した話PHP7を魔改造した話
PHP7を魔改造した話
Moriyoshi Koizumi
 
Authentication, Authorization, OAuth, OpenID Connect and Pyramid
Authentication, Authorization, OAuth, OpenID Connect and PyramidAuthentication, Authorization, OAuth, OpenID Connect and Pyramid
Authentication, Authorization, OAuth, OpenID Connect and Pyramid
Moriyoshi Koizumi
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
HLSについて知っていることを話します
HLSについて知っていることを話しますHLSについて知っていることを話します
HLSについて知っていることを話します
Moriyoshi Koizumi
 
Pyramidのrendererをカスタマイズする
PyramidのrendererをカスタマイズするPyramidのrendererをカスタマイズする
Pyramidのrendererをカスタマイズする
Moriyoshi Koizumi
 
Hacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 AutumnHacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 Autumn
Moriyoshi Koizumi
 
Uguisudani
UguisudaniUguisudani
Uguisudani
Moriyoshi Koizumi
 
よいことも悪いこともぜんぶPHPが教えてくれた
よいことも悪いこともぜんぶPHPが教えてくれたよいことも悪いこともぜんぶPHPが教えてくれた
よいことも悪いこともぜんぶPHPが教えてくれたMoriyoshi Koizumi
 
mod_himoteからはじめよう
mod_himoteからはじめようmod_himoteからはじめよう
mod_himoteからはじめよう
Moriyoshi Koizumi
 
HPHPは約束の地なのか
HPHPは約束の地なのかHPHPは約束の地なのか
HPHPは約束の地なのかMoriyoshi Koizumi
 
Phjosh(仮)プロジェクト
Phjosh(仮)プロジェクトPhjosh(仮)プロジェクト
Phjosh(仮)プロジェクトMoriyoshi Koizumi
 

More from Moriyoshi Koizumi (20)

Goをカンストさせる話
Goをカンストさせる話Goをカンストさせる話
Goをカンストさせる話
 
PHP7を魔改造した話
PHP7を魔改造した話PHP7を魔改造した話
PHP7を魔改造した話
 
Authentication, Authorization, OAuth, OpenID Connect and Pyramid
Authentication, Authorization, OAuth, OpenID Connect and PyramidAuthentication, Authorization, OAuth, OpenID Connect and Pyramid
Authentication, Authorization, OAuth, OpenID Connect and Pyramid
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
HLSについて知っていることを話します
HLSについて知っていることを話しますHLSについて知っていることを話します
HLSについて知っていることを話します
 
Pyramidのrendererをカスタマイズする
PyramidのrendererをカスタマイズするPyramidのrendererをカスタマイズする
Pyramidのrendererをカスタマイズする
 
Hacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 AutumnHacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 Autumn
 
Uguisudani
UguisudaniUguisudani
Uguisudani
 
よいことも悪いこともぜんぶPHPが教えてくれた
よいことも悪いこともぜんぶPHPが教えてくれたよいことも悪いこともぜんぶPHPが教えてくれた
よいことも悪いこともぜんぶPHPが教えてくれた
 
Ik in action
Ik in actionIk in action
Ik in action
 
Nginx lua
Nginx luaNginx lua
Nginx lua
 
Haxeについて
HaxeについてHaxeについて
Haxeについて
 
Gocon2013
Gocon2013Gocon2013
Gocon2013
 
PHP language update 201211
PHP language update 201211PHP language update 201211
PHP language update 201211
 
mod_himoteからはじめよう
mod_himoteからはじめようmod_himoteからはじめよう
mod_himoteからはじめよう
 
HPHPは約束の地なのか
HPHPは約束の地なのかHPHPは約束の地なのか
HPHPは約束の地なのか
 
Pyfes201110
Pyfes201110Pyfes201110
Pyfes201110
 
Phjosh(仮)プロジェクト
Phjosh(仮)プロジェクトPhjosh(仮)プロジェクト
Phjosh(仮)プロジェクト
 
Aaなゲームをjsで
AaなゲームをjsでAaなゲームをjsで
Aaなゲームをjsで
 
Aaなゲームをjsで
AaなゲームをjsでAaなゲームをjsで
Aaなゲームをjsで
 

Recently uploaded

Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 

Recently uploaded (20)

Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 

X / DRM (Direct Rendering Manager) Architectural Overview

  • 1. X Window / Direct Rendering Architectural Diagram Xclient (w/GL) OpenGL I/F Xlib I/F Filesystem libdrm I/F IOCTL / mmap Driver I/F Mesa libdrm PCI Direct Xlib Xlib I/F Driver Rendering I/F Manager Filesystem sockets Abstraction AGP GART Manager X protocol Filesystem I/F Driver I/F Hard- Kernel sockets X Server (device-independent tier) ware AGP GART libdrm I/F XFree86 Tier Manager DIX IOCTL / Memory libdrm I/F DGA DRI mmap Manager MM PCI Subsystem I/F Driver vidmode I/F Video XFree86 IOCTL / IRQ XAA PCI Device Extension mmap Driver Abstraction IRQM MI I/F Manager I/F Xv 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 2. X Window / Indirect Rendering Architectural Diagram Xclient (w/GL) OpenGL I/F Xlib I/F Filesystem Driver I/F Mesa PCI Direct Xlib Xlib I/F Driver Rendering I/F Manager Filesystem sockets Abstraction AGP GART Manager X protocol Filesystem I/F Driver I/F Hard- Kernel sockets X Server (DIX) ware GLX Mesa AGP GART XFree86 Tier libdrm I/F Manager DIX IOCTL / Memory libdrm I/F DGA DRI mmap Manager MM PCI Subsystem I/F Driver vidmode I/F Video XFree86 IOCTL / IRQ XAA PCI Device Extension mmap Driver Abstraction IRQM MI I/F Manager I/F Xv 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 3. Address Space Layout Kernel Space Graphics MMIO Aperture Space Physical User Space Address Space Actual RAM Space GART 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 4. Direct Memory Access 1. Queueing Kernel Space Graphic Controller Instruction Buffer DMA FIFO Transfer Marked Consistent IOCTL (BLIT etc.) User Space Some Process 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 5. Direct Memory Access 2. Bitmap Block Transfer (Blit) Kernel Space Graphic Controller Active Entry FIFO Parse & User Space Dispatch Some Marked Process Blit Engine Consistent DMA Transfer Another Process 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 6. DRM IOCTL I/F AUTH (GET_MAGIC / AUTH_MAGIC) ● VERSION (GET / SET) ● BUSID (GET / SET) ● MAP (ADD / RM) ● CTX (ADD / RM / GET / SWITCH / NEW / ● RESERVE) LOCK (LOCK / UNLOCK) ● AGP operations ● Device-specific operations ● 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 7. DRM Authentication 1. Retrieve Magic Cookie (drmGetMagic()) Cookie Manager Mesa libdrm 2. Generate Direct Xlib Magic Rendering Manager Cookie 3. Send Magic X protocol (XF86DRIAuthConnection()) 4. Authenticate Cookie (drmAuthMagic()) Kernel X Server XFree86 Tier libdrm DRI 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 8. DRM Authentication (Userland Wrappers) libdrm/xf86drm.c: (formally: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c) int drmGetMagic(int fd, drm_magic_t * magic) { drm_auth_t auth; *magic = 0; if (ioctl(fd, DRM_IOCTL_GET_MAGIC, &auth)) return -errno; *magic = auth.magic; return 0; } 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 9. DRM Authentication (Userland Wrappers) xc/programs/Xserver/hw/xfree86/dri/dri.c: Bool DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE; return TRUE; } libdrm/xf86drm.c: (formally: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c) int drmAuthMagic(int fd, drm_magic_t magic) { drm_auth_t auth; auth.magic = magic; if (ioctl(fd, DRM_IOCTL_AUTH_MAGIC, &auth)) return -errno; return 0; } 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 10. DRM Authentication (linux/drivers/char/drm/drm_drv.c: IOCTL Dispatch Table) static drm_ioctl_desc_t drm_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = {drm_version, 0}, [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = {drm_getunique, 0}, [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = {drm_getmagic, 0}, [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = {drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY}, [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = {drm_getmap, 0}, [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = {drm_getclient, 0}, [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = {drm_setversion, DRM_MASTER|DRM_ROOT_ONLY}, [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = {drm_authmagic, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = {drm_addctx, DRM_AUTH|DRM_ROOT_ONLY}, [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = {drm_getctx, DRM_AUTH}, ... 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 11. DRM Authentication (linux/drivers/char/drm/drm_drv.c: IOCTL Dispatcher) if (nr < DRIVER_IOCTL_COUNT) ioctl = &drm_ioctls[nr]; else if ((nr >= DRM_COMMAND_BASE) && (nr < DRM_COMMAND_BASE + dev->driver->num_ioctls)) ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE]; else goto err_i1; func = ioctl->func; /* is there a local override? */ if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl) func = dev->driver->dma_ioctl; if (!func) { DRM_DEBUG(quot;no functionnquot;); retcode = -EINVAL; } else if (((ioctl->flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)) || ((ioctl->flags & DRM_AUTH) && !priv->authenticated) || ((ioctl->flags & DRM_MASTER) && !priv->master)) { retcode = -EACCES; } else { retcode = func(inode, filp, cmd, arg); } 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 12. DRM Authentication (linux/drivers/char/drm/drm_auth.c: Cookie Issuer) int drm_getmagic(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { ... typedef unsigned int drm_magic_t; /* Find unique magic */ if (priv->magic) { typedef struct drm_auth { auth.magic = priv->magic; drm_magic_t magic; } else { do { } drm_auth_t; spin_lock(&lock); if (!sequence) ++sequence;/* reserve 0 */ auth.magic = sequence++; spin_unlock(&lock); } while (drm_find_file(dev, auth.magic)); priv->magic = auth.magic; drm_add_magic(dev, priv, auth.magic); } DRM_DEBUG(quot;%unquot;, auth.magic); if (copy_to_user((drm_auth_t __user *) arg, &auth, sizeof(auth))) return -EFAULT; return 0; } 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 13. DRM Authentication (linux/drivers/char/drm/drm_auth.c: Cookie Verifier) int drm_authmagic(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->head->dev; drm_auth_t auth; drm_file_t *file; if (copy_from_user(&auth, (drm_auth_t __user *) arg, sizeof(auth))) return -EFAULT; DRM_DEBUG(quot;%unquot;, auth.magic); if ((file = drm_find_file(dev, auth.magic))) { file->authenticated = 1; drm_remove_magic(dev, auth.magic); return 0; } return -EINVAL; } 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 14. DRM Authentication (linux/drivers/char/drm/drm_auth.c: Cookie Keeper) static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic) { drm_file_t *retval = NULL; drm_magic_entry_t *pt; int hash = drm_hash_magic(magic); mutex_lock(&dev->struct_mutex); for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { if (pt->magic == magic) { retval = pt->priv; break; } } mutex_unlock(&dev->struct_mutex); return retval; } 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 15. Graphic Address Remapping Table (GART) SAREA Frame Buffer Phy-Phy Address Translation Texture Buffer Process #1 (by AGP controller) Graphics MMIO Aperture Virtual Space Memory Space Physical Process #2 Address Space Actual Virtual RAM Memory Space Space GART Phy-Virt Address Translation (by MMU) 2007 © Moriyoshi Koizumi. All Rights Reserved.
  • 16. AGPGART IOCTL I/F ACQUIRE ● SETUP ● RESERVE ● PROTECT ● ALLOCATE / DEALLOCATE ● BIND / UNBIND ● 2007 © Moriyoshi Koizumi. All Rights Reserved.