Please wait until the page is fully downloaded and then press the "Expand" button or the blue line numbers.
0118000 /*
0118001 * down.c
0118002 *
0118003 * This file is used to Power down pc card socket 0.
0118004 *
0118005 * Created: Oct 2004 by Wangzhi <quakewang@mail.whut.edu.cn>
0118006 * Referenced: enable.c, ibmeth.c created by Philip Homburg
0118007 *
0118008 */
0118009
0118010 #include <sys/types.h>
0118011 #include <errno.h>
0118012 #include <fcntl.h>
0118013 #include <stdio.h>
0118014 #include <stdlib.h>
0118015 #include <string.h>
0118016 #include <unistd.h>
0118017 #include <sys/ioctl.h>
0118018 #include <ibm/portio.h>
0118019
0118020 #include "i82365.h"
0118021
0118022 /* Declare vals and functions */
0118023 char *prog_name;
0118024 int socket= 0;
0118025 u16_t index_port;
0118026 void out_reg(int socket, u8_t index, u8_t value);
0118027
0118028 int main(int argc, char *argv[])
0118029 {
0118030 u8_t c, g, gc, p, s;
0118031 int i;
0118032
0118033 int result;
0118034 u8_t byte;
0118035
0118036 /* put this process' name into prog_name */
0118037 (prog_name=strrchr(argv[0],'/')) ? prog_name++ : (prog_name=argv[0]);
0118038
0118039 /* A normal user can not control hardware, but if you open the /dev/mem *
0118040 * device, you can control the hardware . *
0118041 * Try to get I/O privileges! */
0118042 if ((mem_fd= open("/dev/mem", O_RDWR)) == -1)
0118043 {
0118044 fprintf(stderr, "%s: unable to open '/dev/mem': %s
",
0118045 prog_name, strerror(errno));
0118046 exit(1);
0118047 }
0118048
0118049 /* The following power down the PCMCIA socket 0 *
0118050 * If you want to know the detail, you must reference the PCMCIA *
0118051 * specification. This is for intel82365 compatible PCMCIA controller, *
0118052 * most of the PCMCIA controllers are intel82365 compatible, And there *
0118053 * another PCMCIA controllers. */
0118054
0118055 printf("Power down the pc card socket 0 ...
");
0118056
0118057 /* The start address of the registers in PCMCIA controller */
0118058 index_port=I365_INDEX;
0118059
0118060 /* Now do with socket 0, maybe your laptop have socket 1,2,3 ... */
0118061 socket= 0;
0118062
0118063 /* power down the socket 0 */
0118064 out_reg(socket, I365_PWR_CTL, 0x00);
0118065
0118066 /* The above action use a little time, wait a moment! */
0118067 sleep(1);
0118068
0118069 /* All are down! */
0118070 exit(0);
0118071 }
0118072
0118073 /* write a 8 bits data to a PCMCIA controller's register */
0118074 void out_reg(int socket, u8_t index, u8_t value)
0118075 {
0118076 index += socket * 0x40;
0118077 outb(index_port, index);
0118078 outb(index_port+1, value);
0118079 }
0118080