linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: jason@openinformatics.com (Jason E. Stewart)
To: debian-powerpc@lists.debian.org, stewart.sadler@roke.co.uk,
	linuxppc-dev@lists.linuxppc.org
Subject: External Monitor under Pismo
Date: 02 Apr 2001 13:18:34 -0700	[thread overview]
Message-ID: <87vgonhx7p.fsf@amadeus.openinformatics.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 806 bytes --]

Hey All,

So after 7 months of flailing I finally got my Pismo to run it's
external monitor port, yeah!!!

3 days before I had a talk to give about our OpenSource project, I
realized I was going to be using OpenOffice under linux, and I
couldn't actually drive a projector... So after I got done panicing I
hit google. I find a link on the YDL lists about the 'mirror' program
that appears to have been originally written by Paul Mackeras.

It gives me the functionality I need, but unfortunately it doesn't
seem to work with 2.4 kernels, only 2.2. The program is doing some
pretty low-level memory mojo which I am clueless about.

Could someone slightly wiser point out what would change between 2.2
and 2.4 that would cause this to break? Is it the base memory offset
for the framebuffer?

Cheers!
jas.


[-- Attachment #2: mirror2.c --]
[-- Type: application/octet-stream, Size: 3644 bytes --]

/*
*  Copyright (C) 1996 Paul Mackerras (paulus@linuxcare.com.au)
*
*  This program is free software; you can redistribute it and/or
*  modify it under the terms of the GNU General Public License
*  as published by the Free Software Foundation; either version
*  2 of the License, or (at your option) any later version.
*
*  Minor changes made by Stewart J Sadler (stewart.sadler@roke.co.uk) Oct 2000 
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/mman.h>

/* SJS apparently not used 
static inline void eieio()
{
   asm volatile("eieio" : :);
} */

unsigned long regs;

/************************************************************************/
static inline unsigned int ld(int regno)
{
    unsigned int x;

    asm volatile ("lwbrx %0,0,%1; eieio" : "=r" (x) : "r" (regs + regno));
    return x;
}

/************************************************************************/
static inline void st(int regno, unsigned int x)
{
    asm volatile ("stwbrx %0,0,%1; eieio" : : "r" (x), "r" (regs + regno));
}

/************************************************************************/
static void print_usage(void)
{
  printf("Usage = mirror2 [-h ][-o mirror_level ][-m offset]\n");
  printf("  -h Help/ print usage\n");
  printf("  -o Set mirroring to mirror_level (0=off 1=on ?)\n");
  printf("  -m PCI offset for device as a Hex number\n");
}


/************************************************************************/
static void get_arguments(int ac, char **av,int *on,unsigned long *offset)
{
  int arg;
  char *thisArg;
  
  /* defaults */
  *on=1;
  *offset=0xa0000000;
  
  if(ac==1)
  {
     print_usage();
  }
  for(arg=1;arg<ac;arg++)
  {
     thisArg=av[arg];
     if(thisArg[0]=='-')
     {
        switch(tolower(thisArg[1]))
        {
        case 'o':
           *on=1;
           if(arg+1<ac)
           {
                arg++;
                *on=atoi(av[arg]);
                printf("Mirroring level = %d\n",*on);
           }
           break;
        case 'm':
           if(arg+1<ac)
           {
                arg++;
                sscanf(av[arg],"%lx",offset);
                printf("Mirror Offset = %lX\n",*offset);
           }
           break;
        case 'h':
           print_usage();
           break;
        }
     }
  }
}

/************************************************************************/
int main(int ac, char **av)
{
    int fd, on;
    int a, x;
    unsigned long memoryOffset=0x81000000;
    
    if ((fd = open("/dev/mem", O_RDWR)) < 0) {
         perror("/dev/mem");
         exit(1);
    }

    get_arguments(ac,av,&on,&memoryOffset);

    regs = (unsigned long)
        mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, fd, memoryOffset);
    if (regs == -1) {
         perror("mmap");
         exit(1);
    }

    st(0x300, ld(0x200));
    st(0x304, ld(0x204));
    st(0x308, ld(0x208));
    st(0x30c, ld(0x20c));
    st(0x324, ld(0x224));
    st(0x32c, ld(0x22c));

    st(0x3f8, on? ((ld(0x50) & 0x700) | 0x2210000): 0x4000000);

    st(0x3e0, ld(0x2e0));
    st(0x3e4, ld(0x2e4));

    x = ld(0x8) & ~0xff;
    st(0x8, x | 2);
    a = ld(0x9);
    st(0x8, x | 0xaa);
    st(0x9, a & ~0x20000);

    st(0x8, x | 3);
    a = ld(0x9);
    st(0x8, x | 0xab);
    st(0x9, a);

    st(0x8, x | 4);
    a = ld(0x9);
    st(0x8, 0xac);
    st(0x9, a);

    st(0x58, (ld(0x58) & ~0x10));

    st(0x54, on? (ld(0x54) | 0x8000): (ld(0x54) & ~0x8000));

    exit(0);
}

[-- Attachment #3: Type: text/plain, Size: 1 bytes --]



             reply	other threads:[~2001-04-02 20:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-02 20:18 Jason E. Stewart [this message]
2001-04-03 11:24 ` External Monitor under Pismo Andrew Sharp
2001-04-03 15:15   ` Tuomas Kuosmanen
2001-04-04  1:12     ` Steven Hanley
2001-04-04  2:03     ` Jason E. Stewart
2001-04-04  8:38       ` Tuomas Kuosmanen
2001-04-03 18:08   ` Jason E. Stewart
  -- strict thread matches above, loose matches on Subject: below --
2001-04-04  9:21 Iain Sandoe
2001-04-04 17:01 ` Andrew Sharp
2001-04-04 18:43   ` Jason E. Stewart
2001-04-04 18:01     ` Michel Dänzer
2001-04-04 19:28       ` Jason E. Stewart
2001-04-04 21:45         ` Michel Dänzer
2001-04-04 23:19           ` Jason E. Stewart
2001-04-04 22:22             ` Michel Dänzer
2001-04-05 19:55               ` Jason E. Stewart
2001-04-05 19:48                 ` Michel Dänzer
2001-04-05 21:49                   ` Jason E. Stewart
2001-04-05 23:46               ` Jason E. Stewart
2001-04-05 23:28                 ` Michel Dänzer
2001-04-06  3:04                   ` Steven Hanley
2001-04-04 17:29 Iain Sandoe
2001-04-05  1:58 ` Andrew Sharp
2001-04-05  5:55   ` Jason E. Stewart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vgonhx7p.fsf@amadeus.openinformatics.com \
    --to=jason@openinformatics.com \
    --cc=debian-powerpc@lists.debian.org \
    --cc=linuxppc-dev@lists.linuxppc.org \
    --cc=stewart.sadler@roke.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).