wiki:jazz/09-02-01

Version 8 (modified by jazz, 16 years ago) (diff)

--

2009-02-01

CGDB

BUGFIX: jfbterm (5)

#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>       // include frame buffer header files
#include <sys/ioctl.h>

int main(void)
{
  int fbfd = 0 ;            // frame buffer file description

  /* Get device independent unchangeable information about a frame buffer
   * device and a specific video mode by FBIOGET_FSCREENINFO ioctl. */
  struct  fb_fix_screeninfo finfo;

  fbfd = open( "/dev/fb0" , O_RDWR );
  if ( !fbfd )
  {
    printf( "Error: cannot open framebuffer device.\n" );
    exit(1);
  }
  printf("The framebuffer device was opened successfully.\n");

  /* Get fixed screen information */
  if ( ioctl ( fbfd ,  FBIOGET_FSCREENINFO , &finfo )  )
  {
    printf("Error reading fixed screen information.\n");
    exit(2);
  } else {
    printf("Succesfully Read the Fixed Screen Information\n");
  }

  printf("fb_fix_screeninfo.smem_len = %d\n", finfo.smem_len);
  printf("fb_fix_screeninfo.mmio_len = %d\n", finfo.mmio_len);
}
  • 在 Ubuntu Intrepid 上執行結果
    root@intrepid:~# uname -a
    Linux intrepid 2.6.27-7-server #1 SMP Tue Nov 4 20:16:57 UTC 2008 x86_64 GNU/Linux
    root@intrepid:~# ./fbinfo
    The framebuffer device was opened successfully.
    Succesfully Read the Fixed Screen Information
    fb_fix_screeninfo.smem_len = 16777216
    fb_fix_screeninfo.mmio_len = 0
    
  • 以下是在 Debian Sarge 上執行結果,值得一提的是 jfbterm 在 2.6.8 核心上可以正常執行。(不過還有字型問題需要調整)
    root@wsu-admin:~# uname -a
    Linux wsu-admin 2.6.8-2-386 #1 Tue Aug 16 12:46:35 UTC 2005 i686 GNU/Linux
    root@wsu-admin:~# ./fbinfo
    The framebuffer device was opened successfully.
    Succesfully Read the Fixed Screen Information
    fb_fix_screeninfo.smem_len = 65536
    fb_fix_screeninfo.mmio_len = 0
    
    root@wsu-admin:~# jfbterm
    jfbterm - Kanji on framebuffer console Version 0.4.7
           Copyright (C) 2003 Fumitoshi UKAI
            Copyright (C) 1999-2000 Noritoshi Masuichi
    This program is based on KON2
            Copyright (C) 1992-1996 Takashi MANABE
    
    (**) : Configuration file `/etc/jfbterm.conf'
    .... 略 ....
    exec : /bin/bash ioctl FBIOGET_CON2FBMAP: Invalid argument
    color 0 : 0, 0
    color 1 : 2a, 2a
    color 2 : 2a, 2a
    color 3 : 2a, 2a
    color 4 : 2a, 2a
    color 5 : 2a, 2a
    color 6 : 2a, 2a
    color 7 : 2a, 2a
    color 8 : 15, 15
    color 9 : 3f, 3f
    color 10 : 3f, 3f
    color 11 : 3f, 3f
    color 12 : 3f, 3f
    color 13 : 3f, 3f
    color 14 : 3f, 3f
    color 15 : 3f, 3f
    
  • 以下是在 Debian Etch 上執行結果,有趣的是 jfbterm 0.4.7-7 在 2.6.18 上執行,縱使有 cannot mmap(mmio) : Invalid argument 的錯誤訊息,但仍舊可以正常進入 jfbterm 的環境。
    root@etch:~# uname -a
    Linux etch 2.6.18-4-686 #1 SMP Wed May 9 23:03:12 UTC 2007 i686 GNU/Linux
    root@etch:~# ./fbinfo
    The framebuffer device was opened successfully.
    Succesfully Read the Fixed Screen Information
    fb_fix_screeninfo.smem_len = 1920000
    fb_fix_screeninfo.mmio_len = 0
    
    root@etch:~# jfbterm
    jfbterm - Kanji on framebuffer console Version 0.4.7
           Copyright (C) 2003 Fumitoshi UKAI
            Copyright (C) 1999-2000 Noritoshi Masuichi
    This program is based on KON2
            Copyright (C) 1992-1996 Takashi MANABE
    
    (**) : Configuration file `/etc/jfbterm.conf'
    ... 略 ...
    exec : /bin/bash color 0 : 0, 0
    color 1 : 15, 15
    color 2 : 540, 540
    color 3 : 555, 555
    color 4 : a800, a800
    color 5 : a815, a815
    color 6 : ad40, ad40
    color 7 : ad55, ad55
    color 8 : 52aa, 52aa
    color 9 : 52bf, 52bf
    color 10 : 57ea, 57ea
    color 11 : 57ff, 57ff
    color 12 : faaa, faaa
    color 13 : fabf, fabf
    color 14 : ffea, ffea
    color 15 : ffff, ffff
    cannot mmap(mmio) : Invalid argument
    
  • file jfbterm
    set args -e ls
    show args
    break fbcommon.c:500
    break fbcommon.c:557
    break fbcommon.c:566
    break term.c:103
    break term.c:284
    r
    c
    c
    c
    bt
    c
    bt
    p utp->ut_time
    
    Breakpoint 4, tterm_final (p=0x6147c0) at term.c:103
    (gdb) bt
    #0  tterm_final (p=0x6147c0) at term.c:103
    #1  0x0000000000408adf in sigchld (sig=<value optimized out>) at term.c:82
    #2  <signal handler called>
    #3  0x00007f5dfc00f433 in select () from /lib/libc.so.6
    #4  0x0000000000408873 in tterm_start (p=0x6147c0, tn=<value optimized out>, en=<value optimized out>) at term.c:192
    #5  0x0000000000402cf2 in main (argc=<value optimized out>, argv=0x7fff049477f8) at main.c:438
    (gdb) c
    Continuing.
    
    Breakpoint 5, tterm_reset_utmp (p=<value optimized out>) at term.c:284
    (gdb) bt
    #0  tterm_reset_utmp (p=<value optimized out>) at term.c:284
    #1  0x0000000000408a50 in tterm_final (p=0xe) at term.c:103
    #2  0x0000000000408adf in sigchld (sig=<value optimized out>) at term.c:82
    #3  <signal handler called>
    #4  0x00007fa268131433 in select () from /lib/libc.so.6
    #5  0x0000000000408873 in tterm_start (p=0x6147c0, tn=<value optimized out>, en=<value optimized out>) at term.c:192
    #6  0x0000000000402cf2 in main (argc=<value optimized out>, argv=0x7fff70a69328) at main.c:438
    (gdb) p utp->ut_time
    There is no member named ut_time.