📄 libfbx-gen.c
字号:
/* * libfbx-gen.c -- Generic routines for libfbx modules * (C)opyright 2001 U4X Labs * * Written by: Paul Mundt <lethal@u4xlabs.com> * * $Id: libfbx-gen.c,v 1.1 2001/03/03 01:34:43 lethal Exp $ * * This is the place for all the generic routines for hardware * specific optimizations for the libfbx system to go. * * See ChangeLog for modifications, CREDITS for credits. * * All source herein is copyright U4X Labs and its original author. * Any code modifications or additions are (C)opyright the original * author and U4X Labs respectively. * * libfbx is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * libfbx is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with libfbx; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */#include <libfbx/libfbx-drivers.h>#include <libfbx/libfbx.h>#include <sys/mman.h>/* * Function: fb_map_mmio_region() * Arguments: None. * Returns: 0 on success, -1 on failure. * Description: Maps the MMIO region if it's available. */int fb_map_mmio_region(){ if (fb_screen == NULL) return -1; if (fb_screen->driver == NULL) return -1; fb_screen->driver->mmio_ctl = mmap(0, fb_screen->finfo->mmio_len, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, fb_screen->finfo->smem_len); if (fb_screen->driver->mmio_ctl == MAP_FAILED) { perror("mmap mmio"); return -1; } return 0;}/* * Function: fb_unmap_mmio_region() * Arguments: None. * Returns: None. * Description: Unmaps the MMIO region if it's available. */void fb_unmap_mmio_region(){ if (fb_screen == NULL) return; if (fb_screen->driver == NULL) return; if (fb_screen->driver->mmio_ctl == MAP_FAILED) return; munmap((void *)fb_screen->driver->mmio_ctl, fb_screen->finfo->mmio_len);}inline void fb_outb(__u32 idx, __u8 val){ *((volatile __u8 *)(fb_screen->driver->mmio_ctl + idx)) = val;}inline __u8 fb_inb(__u32 idx){ return *((volatile __u8 *)(fb_screen->driver->mmio_ctl + idx));}inline void fb_outl(__u32 idx, __u32 val){ *((volatile __u32 *)((__u32)fb_screen->driver->mmio_ctl + idx)) = val;}inline __u32 fb_inl(__u32 idx){ return *((volatile __u32 *)((__u32)fb_screen->driver->mmio_ctl + idx));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -