SlideShare a Scribd company logo
1 of 16
Download to read offline
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

OSC2011 Tokyo/Fall 濃いバナ(virtio)
OSC2011 Tokyo/Fall 濃いバナ(virtio)OSC2011 Tokyo/Fall 濃いバナ(virtio)
OSC2011 Tokyo/Fall 濃いバナ(virtio)Takeshi HASEGAWA
 
GPU Virtualization in Embedded Automotive Solutions
GPU Virtualization in Embedded Automotive SolutionsGPU Virtualization in Embedded Automotive Solutions
GPU Virtualization in Embedded Automotive SolutionsGlobalLogic Ukraine
 
SR-IOV+KVM on Debian/Stable
SR-IOV+KVM on Debian/StableSR-IOV+KVM on Debian/Stable
SR-IOV+KVM on Debian/Stablejuet-y
 
YOW2021 Computing Performance
YOW2021 Computing PerformanceYOW2021 Computing Performance
YOW2021 Computing PerformanceBrendan Gregg
 
Architecture Of The Linux Kernel
Architecture Of The Linux KernelArchitecture Of The Linux Kernel
Architecture Of The Linux Kernelguest547d74
 
OpenStackを使用したGPU仮想化IaaS環境 事例紹介
OpenStackを使用したGPU仮想化IaaS環境 事例紹介OpenStackを使用したGPU仮想化IaaS環境 事例紹介
OpenStackを使用したGPU仮想化IaaS環境 事例紹介VirtualTech Japan Inc.
 
FPGA+SoC+Linux実践勉強会資料
FPGA+SoC+Linux実践勉強会資料FPGA+SoC+Linux実践勉強会資料
FPGA+SoC+Linux実践勉強会資料一路 川染
 
Presentation systemc
Presentation systemcPresentation systemc
Presentation systemcSUBRAHMANYA S
 
Understanding Open vSwitch
Understanding Open vSwitch Understanding Open vSwitch
Understanding Open vSwitch YongKi Kim
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringScyllaDB
 
Linux-HA Japanプロジェクトのこれまでとこれから
Linux-HA JapanプロジェクトのこれまでとこれからLinux-HA Japanプロジェクトのこれまでとこれから
Linux-HA Japanプロジェクトのこれまでとこれからksk_ha
 
Linux MMAP & Ioremap introduction
Linux MMAP & Ioremap introductionLinux MMAP & Ioremap introduction
Linux MMAP & Ioremap introductionGene Chang
 
Project ACRN hypervisor introduction
Project ACRN hypervisor introduction Project ACRN hypervisor introduction
Project ACRN hypervisor introduction Project ACRN
 
Introduction to open_sbi
Introduction to open_sbiIntroduction to open_sbi
Introduction to open_sbiNylon
 
Performance Wins with BPF: Getting Started
Performance Wins with BPF: Getting StartedPerformance Wins with BPF: Getting Started
Performance Wins with BPF: Getting StartedBrendan Gregg
 
Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?Chris Simmonds
 
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...Adrian Huang
 

What's hot (20)

OSC2011 Tokyo/Fall 濃いバナ(virtio)
OSC2011 Tokyo/Fall 濃いバナ(virtio)OSC2011 Tokyo/Fall 濃いバナ(virtio)
OSC2011 Tokyo/Fall 濃いバナ(virtio)
 
GPU Virtualization in Embedded Automotive Solutions
GPU Virtualization in Embedded Automotive SolutionsGPU Virtualization in Embedded Automotive Solutions
GPU Virtualization in Embedded Automotive Solutions
 
SR-IOV+KVM on Debian/Stable
SR-IOV+KVM on Debian/StableSR-IOV+KVM on Debian/Stable
SR-IOV+KVM on Debian/Stable
 
YOW2021 Computing Performance
YOW2021 Computing PerformanceYOW2021 Computing Performance
YOW2021 Computing Performance
 
Architecture Of The Linux Kernel
Architecture Of The Linux KernelArchitecture Of The Linux Kernel
Architecture Of The Linux Kernel
 
OpenStackを使用したGPU仮想化IaaS環境 事例紹介
OpenStackを使用したGPU仮想化IaaS環境 事例紹介OpenStackを使用したGPU仮想化IaaS環境 事例紹介
OpenStackを使用したGPU仮想化IaaS環境 事例紹介
 
FPGA+SoC+Linux実践勉強会資料
FPGA+SoC+Linux実践勉強会資料FPGA+SoC+Linux実践勉強会資料
FPGA+SoC+Linux実践勉強会資料
 
Presentation systemc
Presentation systemcPresentation systemc
Presentation systemc
 
Understanding Open vSwitch
Understanding Open vSwitch Understanding Open vSwitch
Understanding Open vSwitch
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uring
 
Linux-HA Japanプロジェクトのこれまでとこれから
Linux-HA JapanプロジェクトのこれまでとこれからLinux-HA Japanプロジェクトのこれまでとこれから
Linux-HA Japanプロジェクトのこれまでとこれから
 
ZynqMPのQEMU
ZynqMPのQEMUZynqMPのQEMU
ZynqMPのQEMU
 
Linux MMAP & Ioremap introduction
Linux MMAP & Ioremap introductionLinux MMAP & Ioremap introduction
Linux MMAP & Ioremap introduction
 
Project ACRN hypervisor introduction
Project ACRN hypervisor introduction Project ACRN hypervisor introduction
Project ACRN hypervisor introduction
 
Introduction to open_sbi
Introduction to open_sbiIntroduction to open_sbi
Introduction to open_sbi
 
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)
 
Performance Wins with BPF: Getting Started
Performance Wins with BPF: Getting StartedPerformance Wins with BPF: Getting Started
Performance Wins with BPF: Getting Started
 
Linux systems - Getting started with setting up and embedded platform
Linux systems - Getting started with setting up and embedded platformLinux systems - Getting started with setting up and embedded platform
Linux systems - Getting started with setting up and embedded platform
 
Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?
 
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
 

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
 
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 V6Alberto Boaventura
 
Mpc5121 econfs
Mpc5121 econfsMpc5121 econfs
Mpc5121 econfsDino, llc
 
Ap nr5000 pt file
Ap nr5000 pt fileAp nr5000 pt file
Ap nr5000 pt fileAddPac1999
 
Linux-without-a-bootloader
Linux-without-a-bootloaderLinux-without-a-bootloader
Linux-without-a-bootloaderNishanth Menon
 
Презентация команды "Обыватели"
Презентация команды "Обыватели"Презентация команды "Обыватели"
Презентация команды "Обыватели"Tatyana Savchyk
 
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_may81satolina
 
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 Catapultgrahambell
 
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 IOLF_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
 
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 PyramidMoriyoshi 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 AutumnMoriyoshi 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

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....rightmanforbloodline
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governanceWSO2
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformWSO2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuidePixlogix Infotech
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaWSO2
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 

Recently uploaded (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

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.