Commit 0e8625c7 authored by Linus Torvalds's avatar Linus Torvalds

Import 1.3.53

parent 6caf23d5
...@@ -372,6 +372,14 @@ S: 25360 Georgia Tech Station ...@@ -372,6 +372,14 @@ S: 25360 Georgia Tech Station
S: Atlanta, Georgia 30332 S: Atlanta, Georgia 30332
S: USA S: USA
N: Kai Harrekilde-Petersen
E: khp@pip.dknet.dk
W: http://www.pip.dknet.dk/~pip93
D: ftape-HOWTO, i82078 fdc detection code, various ftape related stuff.
S: Studsgade 40, 2tv
S: DK-8000 Aarhus C
S: Denmark
N: Andrew Haylett N: Andrew Haylett
E: ajh@primag.co.uk E: ajh@primag.co.uk
D: Selection mechanism D: Selection mechanism
......
Linux kernel coding style
This is a short document describing the preferred coding style for the
linux kernel. Coding style is very personal, and I won't _force_ my
views on anybody, but this is what goes for anything that I have to be
able to maintain, and I'd prefer it for most other things too. Please
at least consider the points made here.
First off, I'd suggest printing out a copy of the GNU coding standards,
and NOT read it. Burn them, it's a great symbolic gesture.
Anyway, here goes:
Chapter 1: Indentation
Tabs are 8 characters, and thus indentations are also 8 characters.
There are heretic movements that try to make indentations 4 (or even 2!)
characters deep, and that is akin to trying to define the value of PI to
be 3.
Rationale: The whole idea behind indentation is to clearly define where
a block of control starts and ends. Especially when you've been looking
at your screen for 20 straight hours, you'll find it a lot easier to see
how the indentation works if you have large indentations.
Now, some people will claim that having 8-character indentations makes
the code move too far to the right, and makes it hard to read on a
80-character terminal screen. The answer to that is that if you need
more than 3 levels of indentation, you're screwed anyway, and should fix
your program.
In short, 8-char indents make things easier to read, and have the added
benefit of warning you when you're nesting your functions too deep.
Heed that warning.
Chapter 2: Placing Braces
The other issue that always comes up in C styling is the placement of
braces. Unlike the indent size, there are few technical reasons to
choose one placement strategy over the other, but the preferred way, as
shown to us by the prophets Kernighan and Ritchie, is to put the opening
brace last on the line, and put the closing brace first, thusly:
if (x is true) {
we do y
}
However, there is one special case, namely functions: they have the
opening brace at the beginning of the next line, thus:
int function(int x)
{
body of function
}
Heretic people all over the world have claimed that this inconsistency
is ... well ... inconsistent, but all right-thinking people know that
(a) K&R are _right_ and (b) K&R are right. Besides, functions are
special anyway (you can't nest them in C).
Note that the closing brace is empty on a line of its own, _except_ in
the cases where it is followed by a continuation of the same statement,
ie a "while" in a do-statement or an "else" in an if-statement, like
this:
do {
body of do-loop
} while (condition);
and
if (x == y) {
..
} else if (x > y) {
...
} else {
....
}
Rationale: K&R.
Also, note that this brace-placement also minimizes the number of empty
(or almost empty) lines, without any loss of readability. Thus, as the
supply of new-lines on your screen is not a renewable resource (think
25-line terminal screens here), you have more empty lines to put
comments on.
Chapter 3: Naming
C is a Spartan language, and so should your naming be. Unlike Modula-2
and Pascal programmers, C programmers do not use cute names like
ThisVariableIsATemporaryCounter. A C programmer would call that
variable "tmp", which is much easier to write, and not the least more
difficult to understand.
HOWEVER, while mixed-case names are frowned upon, descriptive names for
global variables are a must. To call a global function "foo" is a
shooting offense.
GLOBAL variables (to be used only if you _really_ need them) need to
have descriptive names, as do global functions. If you have a function
that counts the number of active users, you should call that
"count_active_users()" or similar, you should _not_ call it "cntusr()".
Encoding the type of a function into the name (so-called Hungarian
notation) is brain damaged - the compiler knows the types anyway and can
check those, and it only confuses the programmer. No wonder MicroSoft
makes buggy programs.
LOCAL variable names should be short, and to the point. If you have
some random integer loop counter, it should probably be called "i".
Calling it "loop_counter" is non-productive, if there is no chance of it
being mis-understood. Similarly, "tmp" can be just about any type of
variable that is used to hold a temporary value.
If you are afraid to mix up your local variable names, you have another
problem, which is called the function-growth-hormone-imbalance syndrome.
See next chapter.
Chapter 4: Functions
Functions should be short and sweet, and do just one thing. They should
fit on one or two screenfuls of text (the ISO/ANSI screen size is 80x24,
as we all know), and do one thing and do that well.
The maximum length of a function is inversely proportional to the
complexity and indentation level of that function. So, if you have a
conceptually simple function that is just one long (but simple)
case-statement, where you have to do lots of small things for a lot of
different cases, it's ok to have a longer function.
However, if you have a complex function, and you suspect that a
less-than-gifted first-year high-school student might not even
understand what the function is all about, you should adhere to the
maximum limits all the more closely. Use helper functions with
descriptive names (you can ask the compiler to in-line them if you think
it's performance-critical, and it will probably do a better job of it
that you would have done).
Another measure of the function is the number of local variables. They
shouldn't exceed 5-10, or you're doing something wrong. Re-think the
function, and split it into smaller pieces. A human brain can
generally easily keep track of about 7 different things, anything more
and it gets confused. You know you're brilliant, but maybe you'd like
to understand what you did 2 weeks from now.
Chapter 5: Commenting
Comments are good, but there is also a danger of over-commenting. NEVER
try to explain HOW your code works in a comment: it's much better to
write the code so that the _working_ is obvious, and it's a waste of
time to explain badly written code.
Generally, you want your comments to tell WHAT your code does, not HOW.
Also, try to avoid putting comments inside a function body: if the
function is so complex that you need to separately comment parts of it,
you should probably go back to chapter 4 for a while. You can make
small comments to note or warn about something particularly clever (or
ugly), but try to avoid excess. Instead, put the comments at the head
of the function, telling people what it does, and possibly WHY it does
it.
Chapter 6: You've made a mess of it
That's ok, we all do. You've probably been told by your long-time unix
user helper that "GNU emacs" automatically formats the C sources for
you, and you've noticed that yes, it does do that, but the defaults it
uses are less than desirable (in fact, they are worse than random
typing - a infinite number of monkeys typing into GNU emacs would never
make a good program).
So, you can either get rid of GNU emacs, or change it to use saner
values. I did the first, so don't ask me how to do the latter. But
even if you fail in getting emacs to do sane formatting, not everything
is lost: use "indent".
Now, again, GNU indent has the same brain dead settings that GNU emacs
has, which is why you need to give it a few command line options.
However, that's not too bad, because even the makers of GNU indent
recognize the authority of K&R (the GNU people aren't evil, they are
just severely misguided in this matter), so you just give indent the
options "-kr -i8" (stands for "K&R, 8 character indents").
"indent" has a lot of options, and especially when it comes to comment
re-formatting you may want to take a look at the manual page. But
remember: "indent" is not a fix for bad programming.
...@@ -317,6 +317,14 @@ CONFIG_M486 ...@@ -317,6 +317,14 @@ CONFIG_M486
not sure, say N; This option will make the kernel use some not sure, say N; This option will make the kernel use some
instructions that are only available on 486+ machines. instructions that are only available on 486+ machines.
Use Pentium optimizations
CONFIG_M586
If you have a 586 or better, as opposed to a 486, or if you have a
486 and are very short on memory, say Y here.
Things will be slightly faster for a 586, and your kernel will be
smaller. A kernel with this option enabled will still run on a 486,
although slightly slower.
Enable loadable module support Enable loadable module support
CONFIG_MODULES CONFIG_MODULES
Kernel modules are small pieces of compiled code which can be Kernel modules are small pieces of compiled code which can be
...@@ -568,11 +576,12 @@ CONFIG_SKB_LARGE ...@@ -568,11 +576,12 @@ CONFIG_SKB_LARGE
The IPX protocol The IPX protocol
CONFIG_IPX CONFIG_IPX
This is support for the Novell networking protocol, IPX. You need it This is support for the Novell networking protocol, IPX. You need it
if you want to access Novell Netware servers from within the Linux if you want to access Novell Netware servers by using ncpfs or from
DOS emulator dosemu (read the DOSEMU-HOWTO, available via ftp (user: within the Linux DOS emulator dosemu (read the DOSEMU-HOWTO,
anonymous) in sunsite.unc.edu:/pub/Linux/docs/HOWTO). To available via ftp (user: anonymous) in
turn your Linux box into a fully featured Netware file server and sunsite.unc.edu:/pub/Linux/docs/HOWTO). To turn your Linux box into
IPX router, say Y here and fetch lwared from a fully featured Netware file server and IPX router, say Y here and
fetch lwared from
sunsite.unc.edu:/pub/Linux/system/Networking/daemons/. General sunsite.unc.edu:/pub/Linux/system/Networking/daemons/. General
information about how to connect Linux, Windows machines and Macs is information about how to connect Linux, Windows machines and Macs is
on the WWW at http://eats.com/linux_mac_win.html (to browse the WWW, on the WWW at http://eats.com/linux_mac_win.html (to browse the WWW,
...@@ -2003,7 +2012,7 @@ CONFIG_SYSV_FS ...@@ -2003,7 +2012,7 @@ CONFIG_SYSV_FS
Documentation/modules.txt. If you haven't heard about all of this Documentation/modules.txt. If you haven't heard about all of this
before, it's safe to say N. before, it's safe to say N.
SMB filesystem (to mount WfW shares etc..) support SMB filesystem support (to mount WfW shares etc..)
CONFIG_SMB_FS CONFIG_SMB_FS
SMB (Server Message Buffer) is the protocol Windows for Workgroups SMB (Server Message Buffer) is the protocol Windows for Workgroups
(WfW), Windows NT and Lan Manager use to talk to each other over an (WfW), Windows NT and Lan Manager use to talk to each other over an
...@@ -2023,6 +2032,18 @@ CONFIG_SMB_FS ...@@ -2023,6 +2032,18 @@ CONFIG_SMB_FS
running kernel whenever you want), say M here and read running kernel whenever you want), say M here and read
Documentation/modules.txt. Most people say N, however. Documentation/modules.txt. Most people say N, however.
NCP filesystem support (to mount NetWare volumes)
CONFIG_NCP_FS
NCP (NetWare Core Protocol) is a protocol that runs over IPX and is
used by NetWare clients to talk to file servers. Enabling this
allows you to mount NetWare file server volumes and access them just
like any other directory. To actually mount the filesystem, you need
a special mount program, available on sunsite.unc.edu via anonymous
ftp in /pub/Linux/system/Filesystem/ncpfs-xx.tgz. If you want to
compile this as a module ( = code which can be inserted in and
removed from the running kernel whenever you want), say M here and
read Documentation/modules.txt.
Cyclades async mux support Cyclades async mux support
CONFIG_CYCLADES CONFIG_CYCLADES
This is a card which gives you many serial ports. You would need This is a card which gives you many serial ports. You would need
......
VERSION = 1 VERSION = 1
PATCHLEVEL = 3 PATCHLEVEL = 3
SUBLEVEL = 52 SUBLEVEL = 53
ARCH = i386 ARCH = i386
...@@ -266,6 +266,7 @@ modules_install: ...@@ -266,6 +266,7 @@ modules_install:
if [ -f IPV4_MODULES ]; then inst_mod IPV4_MODULES ipv4; fi; \ if [ -f IPV4_MODULES ]; then inst_mod IPV4_MODULES ipv4; fi; \
if [ -f SCSI_MODULES ]; then inst_mod SCSI_MODULES scsi; fi; \ if [ -f SCSI_MODULES ]; then inst_mod SCSI_MODULES scsi; fi; \
if [ -f FS_MODULES ]; then inst_mod FS_MODULES fs; fi; \ if [ -f FS_MODULES ]; then inst_mod FS_MODULES fs; fi; \
if [ -f CDROM_MODULES ]; then inst_mod CDROM_MODULES cdrom; fi; \
\ \
ls *.o > .allmods; \ ls *.o > .allmods; \
echo $$MODULES | tr ' ' '\n' | sort | comm -23 .allmods - > .misc; \ echo $$MODULES | tr ' ' '\n' | sort | comm -23 .allmods - > .misc; \
......
...@@ -22,6 +22,7 @@ CONFIG_ALPHA_CABRIOLET=y ...@@ -22,6 +22,7 @@ CONFIG_ALPHA_CABRIOLET=y
# CONFIG_ALPHA_SRM is not set # CONFIG_ALPHA_SRM is not set
CONFIG_PCI=y CONFIG_PCI=y
CONFIG_ALPHA_APECS=y CONFIG_ALPHA_APECS=y
CONFIG_ALPHA_NEED_ROUNDING_EMULATION=y
# CONFIG_SERIAL_ECHO is not set # CONFIG_SERIAL_ECHO is not set
# CONFIG_TGA_CONSOLE is not set # CONFIG_TGA_CONSOLE is not set
CONFIG_PCI_OPTIMIZE=y CONFIG_PCI_OPTIMIZE=y
...@@ -33,6 +34,7 @@ CONFIG_SYSVIPC=y ...@@ -33,6 +34,7 @@ CONFIG_SYSVIPC=y
# block devices # block devices
# #
CONFIG_BLK_DEV_FD=y CONFIG_BLK_DEV_FD=y
# CONFIG_BLK_DEV_RAM is not set
CONFIG_ST506=y CONFIG_ST506=y
# #
...@@ -142,6 +144,7 @@ CONFIG_DE4X5=y ...@@ -142,6 +144,7 @@ CONFIG_DE4X5=y
# #
# Filesystems # Filesystems
# #
# CONFIG_QUOTA is not set
# CONFIG_MINIX_FS is not set # CONFIG_MINIX_FS is not set
# CONFIG_EXT_FS is not set # CONFIG_EXT_FS is not set
CONFIG_EXT2_FS=y CONFIG_EXT2_FS=y
...@@ -168,6 +171,7 @@ CONFIG_PSMOUSE=y ...@@ -168,6 +171,7 @@ CONFIG_PSMOUSE=y
# CONFIG_ATIXL_BUSMOUSE is not set # CONFIG_ATIXL_BUSMOUSE is not set
# CONFIG_QIC02_TAPE is not set # CONFIG_QIC02_TAPE is not set
# CONFIG_APM is not set # CONFIG_APM is not set
# CONFIG_WATCHDOG is not set
# #
# Sound # Sound
......
...@@ -46,14 +46,16 @@ LINKFLAGS =-qmagic -Ttext 0xfffe0 ...@@ -46,14 +46,16 @@ LINKFLAGS =-qmagic -Ttext 0xfffe0
endif endif
CFLAGS := $(CFLAGS) -pipe CFLAGS := $(CFLAGS) -pipe
ifdef CONFIG_M386
CFLAGS := $(CFLAGS) -m386
endif
ifdef CONFIG_M486 ifdef CONFIG_M486
CFLAGS := $(CFLAGS) -m486 CFLAGS := $(CFLAGS) -m486
else
ifdef CONFIG_M586
CFLAGS := $(CFLAGS) -mpentium
else
CFLAGS := $(CFLAGS) -m386
endif endif
ifdef CONFIG_M586
CFLAGS := $(CFLAGS) -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2
endif endif
ifdef SMP ifdef SMP
......
...@@ -27,10 +27,10 @@ tristate 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF ...@@ -27,10 +27,10 @@ tristate 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF
if [ "$CONFIG_BINFMT_ELF" = "y" ]; then if [ "$CONFIG_BINFMT_ELF" = "y" ]; then
bool 'Compile kernel as ELF - if your GCC is ELF-GCC' CONFIG_KERNEL_ELF bool 'Compile kernel as ELF - if your GCC is ELF-GCC' CONFIG_KERNEL_ELF
fi fi
#bool 'Use Pentium-specific optimizations (does NOT work on i386)' CONFIG_M586 choice 'Processor type' \
#if [ "$CONFIG_M586" = "n" ]; then "386 CONFIG_M386 \
bool 'Use 486-specific optimizations (does NOT work on i386)' CONFIG_M486 486 CONFIG_M486 \
#fi Pentium CONFIG_M586" Pentium
source drivers/block/Config.in source drivers/block/Config.in
......
...@@ -19,7 +19,9 @@ CONFIG_PCI_OPTIMIZE=y ...@@ -19,7 +19,9 @@ CONFIG_PCI_OPTIMIZE=y
CONFIG_SYSVIPC=y CONFIG_SYSVIPC=y
CONFIG_BINFMT_ELF=y CONFIG_BINFMT_ELF=y
CONFIG_KERNEL_ELF=y CONFIG_KERNEL_ELF=y
CONFIG_M486=y # CONFIG_M386 is not set
# CONFIG_M486 is not set
CONFIG_M586=y
# #
# block devices # block devices
...@@ -109,10 +111,10 @@ CONFIG_MSDOS_FS=y ...@@ -109,10 +111,10 @@ CONFIG_MSDOS_FS=y
CONFIG_PROC_FS=y CONFIG_PROC_FS=y
CONFIG_NFS_FS=y CONFIG_NFS_FS=y
# CONFIG_ROOT_NFS is not set # CONFIG_ROOT_NFS is not set
# CONFIG_SMB_FS is not set
CONFIG_ISO9660_FS=y CONFIG_ISO9660_FS=y
# CONFIG_HPFS_FS is not set # CONFIG_HPFS_FS is not set
# CONFIG_SYSV_FS is not set # CONFIG_SYSV_FS is not set
# CONFIG_SMB_FS is not set
# #
# character devices # character devices
......
...@@ -12,16 +12,16 @@ ...@@ -12,16 +12,16 @@
# #
# Copyright (C) 1994 by Linus Torvalds # Copyright (C) 1994 by Linus Torvalds
# Changes for PPC by Gary Thomas # Changes for PPC by Gary Thomas
# Modified by Cort Dougan
# #
# PowerPC (cross) tools # PowerPC (cross) tools
AS = as.ppc AS = /usr/local/bin/as.ppc
ASFLAGS = ASFLAGS =
LD = ld.ppc LD = /u/cort/ppc-gcc/bin/ld.ppc
#LINKFLAGS = -T arch/ppc/ld.script -Ttext 0x90000000 -Map vmlinux.map #LINKFLAGS = -T arch/ppc/ld.script -Ttext 0x90000000 -Map vmlinux.map
LINKFLAGS = -T arch/ppc/ld.script -Ttext 0x90000000 LINKFLAGS = -T arch/ppc/ld.script -Ttext 0x90000000
HOSTCC = gcc HOSTCC = gcc
CC = gcc.ppc CC = /usr/local/bin/gcc.ppc
CFLAGS = -D__KERNEL__ -I$(TOPDIR)/include \ CFLAGS = -D__KERNEL__ -I$(TOPDIR)/include \
-Wstrict-prototypes \ -Wstrict-prototypes \
-fomit-frame-pointer \ -fomit-frame-pointer \
...@@ -30,10 +30,10 @@ CFLAGS = -D__KERNEL__ -I$(TOPDIR)/include \ ...@@ -30,10 +30,10 @@ CFLAGS = -D__KERNEL__ -I$(TOPDIR)/include \
-O2 -pipe -O2 -pipe
#-Wall #-Wall
CPP = $(CC) -E $(CFLAGS) CPP = $(CC) -E $(CFLAGS)
AR = ar.ppc AR = /u/cort/ppc-gcc/bin/ar.ppc
RANLIB = ranlib.ppc RANLIB = /u/cort/ppc-gcc/bin/ranlib.ppc
STRIP = strip.ppc STRIP = /u/cort/ppc-gcc/bin/strip.ppc
NM = nm.ppc NM = /u/cort/ppc-gcc/bin/nm.ppc
# #
# Set these to indicate how to link it.. # Set these to indicate how to link it..
...@@ -99,6 +99,8 @@ arch/ppc/mm: dummy ...@@ -99,6 +99,8 @@ arch/ppc/mm: dummy
archclean: archclean:
# @$(MAKEBOOT) clean # @$(MAKEBOOT) clean
/bin/rm -f arch/ppc/kernel/*.o arch/ppc/kernel/mk_defs arch/ppc/kernel/ppc_defs.h mm/*.o
/bin/rm -f arch/ppc/kernel/*~ arch/ppc/kernel/*~
archdep: archdep:
# @$(MAKEBOOT) dep # @$(MAKEBOOT) dep
......
...@@ -24,8 +24,11 @@ OBJECTS = head.o main.o ...@@ -24,8 +24,11 @@ OBJECTS = head.o main.o
all: linux.boot all: linux.boot
linux.boot: $(TOPDIR)/vmlinux linux.boot: $(TOPDIR)/vmlinux mkboot
mkboot $(TOPDIR)/vmlinux $@ 0 mkboot $(TOPDIR)/vmlinux /u/cort/bootpd/vmlinux
mkboot : cortstrip.c
$(HOSTCC) -o mkboot cortstrip.c
clean: clean:
rm -f linux.boot rm -f linux.boot
......
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
/* amount to skip */
#define PLACE 65536
/* size of read buffer */
#define SIZE 0x200000
/* crude program to strip the elf header to make a bootable
image via tftp
*/
int main(int argc, char **argv )
{
int fd, fdo;
unsigned char data[SIZE];
int i, n, skip;
if ( argc != 3 )
{
fprintf(stderr,"%s infile outfile\n", argv[0]);
exit(-1);
}
fd = open(argv[1], O_RDONLY);
if ( fd == -1 )
{
fprintf(stderr,"Couldn't open %s\n", argv[1]);
perror("open()");
exit(-1);
}
fdo = open(argv[2], O_WRONLY|O_CREAT);
if ( fdo == -1 )
{
fprintf(stderr,"Couldn't open %s\n", argv[2]);
perror("open()");
exit(-1);
}
#if 0
skip = atoi(argv[3]);
#else
skip = PLACE;
#endif
i = lseek(fd, skip, SEEK_SET);
printf("lseek'd %d bytes\n", i);
if ( i == -1 )
{
perror("lseek()");
}
while ( (n = read(fd, data, SIZE)) > 0 )
{
printf("Read %d bytes\n", n);
i = write(fdo, data, n);
printf("Wrote %d bytes\n", i);
}
close(fdo);
close(fd);
return(0);
}
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
# unless it's something special (ie not a .c file). # unless it's something special (ie not a .c file).
# #
# Note 2! The CFLAGS definitions are now in the main makefile... # Note 2! The CFLAGS definitions are now in the main makefile...
#
#
# Modified by Cort Dougan
#
.c.s: .c.s:
$(CC) $(CFLAGS) -S $< $(CC) $(CFLAGS) -S $<
...@@ -26,7 +30,7 @@ HOST_CC = gcc ...@@ -26,7 +30,7 @@ HOST_CC = gcc
OBJS = misc.o setup.o port_io.o irq.o pci.o traps.o stubs.o process.o \ OBJS = misc.o setup.o port_io.o irq.o pci.o traps.o stubs.o process.o \
signal.o raw_printf.o ramdisk.o signal.o raw_printf.o ramdisk.o
all: head.o kernel.o cortstrip mkboot all: head.o kernel.o
head.o: head.s head.o: head.s
head.s: head.S $(TOPDIR)/include/linux/tasks.h ppc_defs.h head.s: head.S $(TOPDIR)/include/linux/tasks.h ppc_defs.h
......
...@@ -560,7 +560,8 @@ sys_call_table: ...@@ -560,7 +560,8 @@ sys_call_table:
.long sys_uselib .long sys_uselib
.long sys_swapon .long sys_swapon
.long sys_reboot .long sys_reboot
.long sys_readdir /* .long sys_readdir*/
.long old_readdir
.long sys_mmap /* 90 */ .long sys_mmap /* 90 */
.long sys_munmap .long sys_munmap
.long sys_truncate .long sys_truncate
......
...@@ -90,7 +90,7 @@ pcibios_read_config_word (unsigned char bus, ...@@ -90,7 +90,7 @@ pcibios_read_config_word (unsigned char bus,
#endif #endif
if ((bus != 0) || (dev < 11) || (dev > 16)) if ((bus != 0) || (dev < 11) || (dev > 16))
{ {
*val = 0xFFFFFFFF; *val =(unsigned short) 0xFFFFFFFF;
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
} else } else
{ {
...@@ -119,7 +119,7 @@ pcibios_read_config_byte (unsigned char bus, ...@@ -119,7 +119,7 @@ pcibios_read_config_byte (unsigned char bus,
#endif #endif
if ((bus != 0) || (dev < 11) || (dev > 16)) if ((bus != 0) || (dev < 11) || (dev > 16))
{ {
*val = 0xFFFFFFFF; *val = (unsigned char) 0xFFFFFFFF;
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
} else } else
{ {
...@@ -207,7 +207,7 @@ pcibios_find_device (unsigned short vendor, unsigned short device_id, ...@@ -207,7 +207,7 @@ pcibios_find_device (unsigned short vendor, unsigned short device_id,
unsigned short index, unsigned char *bus, unsigned short index, unsigned char *bus,
unsigned char *dev) unsigned char *dev)
{ {
unsigned long w, desired = (device_id << 16) | vendor; unsigned int w, desired = (device_id << 16) | vendor;
int devnr; int devnr;
if (vendor == 0xffff) { if (vendor == 0xffff) {
......
...@@ -165,4 +165,7 @@ n: ...@@ -165,4 +165,7 @@ n:
/* Missing instructions */ /* Missing instructions */
#define bdne bc 0,2, #define bdne bc 0,2,
#include "ppc_machine.h" #include <asm/ppc_machine.h>
/* * Last edited: Nov 8 12:32 1995 (cort) */ /* * Last edited: Dec 14 17:32 1995 (cort) */
/* /*
* linux/arch/ppc/kernel/process.c * linux/arch/ppc/kernel/process.c
* *
* Copyright (C) 1995 Linus Torvalds * Copyright (C) 1995 Linus Torvalds
* Adapted for PowerPC by Gary Thomas * Adapted for PowerPC by Gary Thomas
* Modified by Cort Dougan
*/ */
/* /*
...@@ -27,7 +28,7 @@ ...@@ -27,7 +28,7 @@
#include <asm/system.h> #include <asm/system.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/processor.h> #include <asm/ppc_machine.h>
int dump_fpu (struct user_i387_struct* fpu) int dump_fpu (struct user_i387_struct* fpu)
{ {
...@@ -122,10 +123,10 @@ void copy_thread(int nr, unsigned long clone_flags, unsigned long usp, ...@@ -122,10 +123,10 @@ void copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
childregs = ((struct pt_regs *) (p->kernel_stack_page + 2*PAGE_SIZE)) - 2; childregs = ((struct pt_regs *) (p->kernel_stack_page + 2*PAGE_SIZE)) - 2;
*childregs = *regs; /* STRUCT COPY */ *childregs = *regs; /* STRUCT COPY */
childregs->gpr[3] = 0; /* Result from fork() */ childregs->gpr[3] = 0; /* Result from fork() */
p->tss.ksp = childregs; p->tss.ksp = (unsigned long)childregs;
if (usp >= (unsigned long)regs) if (usp >= (unsigned long)regs)
{ /* Stack is in kernel space - must adjust */ { /* Stack is in kernel space - must adjust */
childregs->gpr[1] = childregs+1; childregs->gpr[1] = (long)(childregs+1);
} else } else
{ /* Provided stack is in user space */ { /* Provided stack is in user space */
childregs->gpr[1] = usp; childregs->gpr[1] = usp;
...@@ -166,8 +167,18 @@ asmlinkage int sys_newselect(int p1, int p2, int p3, int p4, int p5, int p6, str ...@@ -166,8 +167,18 @@ asmlinkage int sys_newselect(int p1, int p2, int p3, int p4, int p5, int p6, str
asmlinkage int sys_fork(int p1, int p2, int p3, int p4, int p5, int p6, struct pt_regs *regs) asmlinkage int sys_fork(int p1, int p2, int p3, int p4, int p5, int p6, struct pt_regs *regs)
{ {
printk("process.c: sys_fork() called\n"); int i;
return do_fork( CLONE_VM|SIGCHLD, regs->gpr[1], regs); char *a;
#if 0
for ( i = 0 ; i <= 0x400 ; i++)
{
printk("going to do kmalloc(%d)\n",i);
a = kmalloc(i,GFP_KERNEL);
a = kmalloc(i,GFP_KERNEL);
printk("a = %x\n",a);
}
#endif
return do_fork( SIGCHLD, regs->gpr[1], regs);
} }
asmlinkage int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2, asmlinkage int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2,
...@@ -176,7 +187,6 @@ asmlinkage int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2, ...@@ -176,7 +187,6 @@ asmlinkage int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2,
{ {
int error; int error;
char * filename; char * filename;
/* printk("process.c: sys_execve(a0 = %s, a1 = %x, a2 = %x)\n",a0,a1,a2);*/
#if 1 #if 1
/* paranoia check. I really don't trust head.S -- Cort */ /* paranoia check. I really don't trust head.S -- Cort */
...@@ -189,12 +199,7 @@ asmlinkage int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2, ...@@ -189,12 +199,7 @@ asmlinkage int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2,
if (error) if (error)
return error; return error;
error = do_execve(filename, (char **) a1, (char **) a2, regs); error = do_execve(filename, (char **) a1, (char **) a2, regs);
#if 0
if (error)
{
printk("EXECVE - file = '%s', error = %d\n", filename, error);
}
#endif
putname(filename); putname(filename);
return error; return error;
} }
...@@ -210,9 +215,9 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long usp, unsigned ...@@ -210,9 +215,9 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long usp, unsigned
usp = regs->gpr[1]; usp = regs->gpr[1];
i = do_fork(CLONE_VM/*clone_flags*/, /*usp*/regs->gpr[1], regs); /* I hard coded in all the arguments to clone since clone() is inlined
/* printk("sys_clone going to return %d\n", i);*/ and has trouble with its args with our gcc -- Cort*/
return i; return do_fork(/*clone_flags*/CLONE_VM, /*usp*/ regs->gpr[1], regs);
} }
...@@ -226,7 +231,7 @@ print_backtrace(void) ...@@ -226,7 +231,7 @@ print_backtrace(void)
while (*sp) while (*sp)
{ {
printk("%08X ", sp[2]); printk("%08X ", sp[2]);
sp = *sp; sp = (unsigned long *)*sp;
if (++cnt == 8) if (++cnt == 8)
{ {
printk("\n"); printk("\n");
......
...@@ -3,9 +3,65 @@ ...@@ -3,9 +3,65 @@
#include <stdarg.h> #include <stdarg.h>
extern void cnputc(char c); extern void cnputc(char c);
char cngetc(void);
int cntstc(void);
void _cnpause(void);
void cnpause(void);
void video_on(void);
int CRT_init(void);
int kbd(int noblock);
int scankbd(void);
static char *_sprintk_ptr; static char *_sprintk_ptr;
void kbdreset(void);
int CRT_test(void);
int CRT_putc(int , unsigned char );
/*int CRT_putc(int port, u_char c)*/
int CRT_getc(void);
int _vprintk( int (*putc)(), const char *fmt0, va_list ap);
static _cvt(unsigned long val, char *buf, long radix, char *digits);
static void cursor(void);
static void initscreen(void );
/*
* COM1 NS16550 support
*/
struct NS16550
{
unsigned char rbr; /* 0 */
unsigned char ier; /* 1 */
unsigned char fcr; /* 2 */
unsigned char lcr; /* 3 */
unsigned char mcr; /* 4 */
unsigned char lsr; /* 5 */
unsigned char msr; /* 6 */
unsigned char scr; /* 7 */
};
#define thr rbr
#define iir fcr
#define dll rbr
#define dlm ier
#define LSR_DR 0x01 /* Data ready */
#define LSR_OE 0x02 /* Overrun */
#define LSR_PE 0x04 /* Parity error */
#define LSR_FE 0x08 /* Framing error */
#define LSR_BI 0x10 /* Break */
#define LSR_THRE 0x20 /* Xmit holding register empty */
#define LSR_TEMT 0x40 /* Xmitter empty */
#define LSR_ERR 0x80 /* Error */
#define COM1 0x800003F8
#define COM2 0x800002F8
typedef struct NS16550 *NS16550_t;
const NS16550_t COM_PORTS[] = { COM1,COM2};
volatile struct NS16550 *NS16550_init(int chan);
void NS16550_putc(volatile struct NS16550 *com_port, unsigned char c);
unsigned char NS16550_getc(volatile struct NS16550 *com_port);
static _sputc(char c) static _sputc(char c)
{ {
*_sprintk_ptr++ = c; *_sprintk_ptr++ = c;
...@@ -46,11 +102,7 @@ _printk(char const *fmt, ...) ...@@ -46,11 +102,7 @@ _printk(char const *fmt, ...)
#define is_digit(c) ((c >= '0') && (c <= '9')) #define is_digit(c) ((c >= '0') && (c <= '9'))
int int _vprintk( int (*putc)(), const char *fmt0, va_list ap)
_vprintk(putc, fmt0, ap)
int (*putc)();
const char *fmt0;
va_list ap;
{ {
char c, sign, *cp; char c, sign, *cp;
int left_prec, right_prec, zero_fill, length, pad, pad_on_right; int left_prec, right_prec, zero_fill, length, pad, pad_on_right;
...@@ -210,7 +262,6 @@ static _cvt(unsigned long val, char *buf, long radix, char *digits) ...@@ -210,7 +262,6 @@ static _cvt(unsigned long val, char *buf, long radix, char *digits)
/* /*
* Console I/O interface * Console I/O interface
*/ */
typedef const (*proc)(); typedef const (*proc)();
typedef int dev_t; typedef int dev_t;
...@@ -225,24 +276,24 @@ static int port = 0; ...@@ -225,24 +276,24 @@ static int port = 0;
static int line_num = 0; static int line_num = 0;
#define MAX_LINES 24 #define MAX_LINES 24
char char cngetc(void)
cngetc()
{ {
int s = _disable_interrupts(); int s = _disable_interrupts();
char c = '\0'; char c = '\0';
if (port == CRT_PORT) if (port == CRT_PORT)
{ {
c = CRT_getc(port); /* c = CRT_getc(port);*/
c = CRT_getc();
} else } else
if (port) if (port)
{ {
c = NS16550_getc(port); c = NS16550_getc((struct NS16550 *)port);
} }
_enable_interrupts(s); _enable_interrupts(s);
return (c); return (c);
} }
cntstc() int cntstc(void)
{ {
return (0); return (0);
} }
...@@ -268,7 +319,7 @@ cnputc(char c) ...@@ -268,7 +319,7 @@ cnputc(char c)
port = CRT_PORT; port = CRT_PORT;
} else } else
{ {
port = NS16550_init(0); port =(int) NS16550_init(0);
} }
init = TRUE; init = TRUE;
} }
...@@ -278,7 +329,7 @@ cnputc(char c) ...@@ -278,7 +329,7 @@ cnputc(char c)
} else } else
if (port) if (port)
{ {
NS16550_putc(port, c); NS16550_putc((struct NS16550 *)port, c);
} }
if (c == '\n') if (c == '\n')
{ {
...@@ -294,7 +345,7 @@ cnputc(char c) ...@@ -294,7 +345,7 @@ cnputc(char c)
} }
} }
_cnpause() void _cnpause(void)
{ {
int c; int c;
int s = _disable_interrupts(); int s = _disable_interrupts();
...@@ -323,7 +374,7 @@ _cnpause() ...@@ -323,7 +374,7 @@ _cnpause()
_enable_interrupts(s); _enable_interrupts(s);
} }
cnpause() void cnpause(void)
{ {
int c; int c;
int s = _disable_interrupts(); int s = _disable_interrupts();
...@@ -333,45 +384,7 @@ cnpause() ...@@ -333,45 +384,7 @@ cnpause()
_enable_interrupts(s); _enable_interrupts(s);
} }
/* volatile struct NS16550 *NS16550_init(int chan)
* COM1 NS16550 support
*/
struct NS16550
{
unsigned char rbr; /* 0 */
unsigned char ier; /* 1 */
unsigned char fcr; /* 2 */
unsigned char lcr; /* 3 */
unsigned char mcr; /* 4 */
unsigned char lsr; /* 5 */
unsigned char msr; /* 6 */
unsigned char scr; /* 7 */
};
#define thr rbr
#define iir fcr
#define dll rbr
#define dlm ier
#define LSR_DR 0x01 /* Data ready */
#define LSR_OE 0x02 /* Overrun */
#define LSR_PE 0x04 /* Parity error */
#define LSR_FE 0x08 /* Framing error */
#define LSR_BI 0x10 /* Break */
#define LSR_THRE 0x20 /* Xmit holding register empty */
#define LSR_TEMT 0x40 /* Xmitter empty */
#define LSR_ERR 0x80 /* Error */
#define COM1 0x800003F8
#define COM2 0x800002F8
typedef struct NS16550 *NS16550_t;
const NS16550_t COM_PORTS[] = { COM1, COM2};
volatile struct NS16550 *
NS16550_init(int chan)
{ {
volatile struct NS16550 *com_port; volatile struct NS16550 *com_port;
volatile unsigned char xx; volatile unsigned char xx;
...@@ -393,13 +406,14 @@ NS16550_init(int chan) ...@@ -393,13 +406,14 @@ NS16550_init(int chan)
} }
NS16550_putc(volatile struct NS16550 *com_port, unsigned char c) void NS16550_putc(volatile struct NS16550 *com_port, unsigned char c)
{ {
volatile int i; volatile int i;
while ((com_port->lsr & LSR_THRE) == 0) ; while ((com_port->lsr & LSR_THRE) == 0) ;
com_port->thr = c; com_port->thr = c;
} }
unsigned char NS16550_getc(volatile struct NS16550 *com_port) unsigned char NS16550_getc(volatile struct NS16550 *com_port)
{ {
while ((com_port->lsr & LSR_DR) == 0) ; while ((com_port->lsr & LSR_DR) == 0) ;
...@@ -481,8 +495,7 @@ unsigned short pccolor_so; /* color/attributes, standout mode */ ...@@ -481,8 +495,7 @@ unsigned short pccolor_so; /* color/attributes, standout mode */
/* /*
* cursor() sets an offset (0-1999) into the 80x25 text area * cursor() sets an offset (0-1999) into the 80x25 text area
*/ */
static void static void cursor(void)
cursor()
{ {
int pos = screen.cp - Crtat; int pos = screen.cp - Crtat;
...@@ -495,8 +508,7 @@ cursor() ...@@ -495,8 +508,7 @@ cursor()
} }
} }
static void static void initscreen(void )
initscreen()
{ {
struct screen *d = &screen; struct screen *d = &screen;
...@@ -533,8 +545,7 @@ fillw(unsigned short val, unsigned short *buf, int num) ...@@ -533,8 +545,7 @@ fillw(unsigned short val, unsigned short *buf, int num)
* "ca" is the color/attributes value (left-shifted by 8) * "ca" is the color/attributes value (left-shifted by 8)
* or 0 if the current regular color for that screen is to be used. * or 0 if the current regular color for that screen is to be used.
*/ */
void int CRT_putc(int port, unsigned char c)
CRT_putc(int port, u_char c)
{ {
struct screen *d = &screen; struct screen *d = &screen;
u_short *base; u_short *base;
...@@ -779,13 +790,13 @@ CRT_putc(int port, u_char c) ...@@ -779,13 +790,13 @@ CRT_putc(int port, u_char c)
cursor(); cursor();
} }
video_on() void video_on(void)
{ /* Enable video */ { /* Enable video */
outb(0x3C4, 0x01); outb(0x3C4, 0x01);
outb(0x3C5, inb(0x3C5)&~20); outb(0x3C5, inb(0x3C5)&~20);
} }
CRT_init() int CRT_init(void)
{ {
unsigned long *PCI_base = (unsigned long *)0x80808010; /* Magic */ unsigned long *PCI_base = (unsigned long *)0x80808010; /* Magic */
struct screen *d = &screen; struct screen *d = &screen;
...@@ -964,9 +975,7 @@ const unsigned char keycode[] = { ...@@ -964,9 +975,7 @@ const unsigned char keycode[] = {
_x__, 0x4E, 0x51, 0x4A, _x__, 0x49, 0x46, 0x54, /* 0x78-0x7F */ _x__, 0x4E, 0x51, 0x4A, _x__, 0x49, 0x46, 0x54, /* 0x78-0x7F */
}; };
int int kbd(int noblock)
kbd(noblock)
int noblock;
{ {
unsigned char dt, brk, act; unsigned char dt, brk, act;
int first = 1; int first = 1;
...@@ -1041,11 +1050,12 @@ kbd(noblock) ...@@ -1041,11 +1050,12 @@ kbd(noblock)
goto loop; goto loop;
} }
scankbd() { int scankbd(void)
{
return (kbd(1) != -1); return (kbd(1) != -1);
} }
kbdreset() void kbdreset(void)
{ {
unsigned char c; unsigned char c;
...@@ -1066,14 +1076,14 @@ kbdreset() ...@@ -1066,14 +1076,14 @@ kbdreset()
; ;
} }
CRT_getc() int CRT_getc(void)
{ {
int c; int c;
while ((c = kbd(0)) == 0) ; while ((c = kbd(0)) == 0) ;
return(c); return(c);
} }
CRT_test() int CRT_test(void)
{ {
return ((inb(KBSTATP) & KBINRDY) != 0); return ((inb(KBSTATP) & KBINRDY) != 0);
} }
......
...@@ -134,9 +134,6 @@ int size_memory; ...@@ -134,9 +134,6 @@ int size_memory;
#define DEFAULT_ROOT_DEVICE 0x0200 /* fd0 */ #define DEFAULT_ROOT_DEVICE 0x0200 /* fd0 */
#define COMMAND_LINE_SIZE 512 /* Should match head.S */
char saved_command_line[COMMAND_LINE_SIZE];
void setup_arch(char **cmdline_p, void setup_arch(char **cmdline_p,
unsigned long * memory_start_p, unsigned long * memory_end_p) unsigned long * memory_start_p, unsigned long * memory_end_p)
{ {
...@@ -146,7 +143,6 @@ void setup_arch(char **cmdline_p, ...@@ -146,7 +143,6 @@ void setup_arch(char **cmdline_p,
ROOT_DEV = DEFAULT_ROOT_DEVICE; ROOT_DEV = DEFAULT_ROOT_DEVICE;
aux_device_present = 0xaa; aux_device_present = 0xaa;
strcpy(saved_command_line, cmd_line);
*cmdline_p = cmd_line; *cmdline_p = cmd_line;
*memory_start_p = (unsigned long) &_end; *memory_start_p = (unsigned long) &_end;
*memory_end_p = (unsigned long *)Hash; *memory_end_p = (unsigned long *)Hash;
......
#include <linux/in.h> #include <linux/in.h>
unsigned int csum_tcpudp_magic(void);
void halt(void);
void _do_bottom_half(void);
void sys_ptrace(void) { _panic("sys_ptrace"); } void sys_ptrace(void) { _panic("sys_ptrace"); }
void sys_iopl(void) { _panic("sys_iopl"); } void sys_iopl(void) { _panic("sys_iopl"); }
void sys_vm86(void) { _panic("sys_vm86"); } void sys_vm86(void) { _panic("sys_vm86"); }
...@@ -9,10 +13,11 @@ void sys_quotactl(void) { _panic("sys_quotactl"); } ...@@ -9,10 +13,11 @@ void sys_quotactl(void) { _panic("sys_quotactl"); }
void sys_pipe(void) {_panic("sys_pipe"); } void sys_pipe(void) {_panic("sys_pipe"); }
void sys_ipc(void) {_panic("sys_ipc"); } void sys_ipc(void) {_panic("sys_ipc"); }
void sys_mmap(void) {_panic("sys_mmap"); } void sys_mmap(void) {_panic("sys_mmap"); }
void sys_readdir(void) {_panic("sys_readdir"); } /* unneeded
void sys_readdir(void) {panic("sys_readdir"); }
*/
halt() void halt(void)
{ {
_printk("\n...Halt!\n"); _printk("\n...Halt!\n");
abort(); abort();
...@@ -91,7 +96,8 @@ tcp_check(unsigned char *buf, int len, int saddr, int daddr) ...@@ -91,7 +96,8 @@ tcp_check(unsigned char *buf, int len, int saddr, int daddr)
return (_val); return (_val);
} }
#endif #endif
_do_bottom_half()
void _do_bottom_half(void)
{ {
_enable_interrupts(1); _enable_interrupts(1);
do_bottom_half(); do_bottom_half();
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <asm/system.h> #include <asm/system.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/processor.h> #include <asm/ppc_machine.h>
/* /*
* Trap & Exception support * Trap & Exception support
...@@ -68,6 +68,7 @@ MachineCheckException(struct pt_regs *regs) ...@@ -68,6 +68,7 @@ MachineCheckException(struct pt_regs *regs)
ProgramCheckException(struct pt_regs *regs) ProgramCheckException(struct pt_regs *regs)
{ {
printk("Program check at PC: %x[%x], SR: %x\n", regs->nip, va_to_phys(regs->nip), regs->msr); printk("Program check at PC: %x[%x], SR: %x\n", regs->nip, va_to_phys(regs->nip), regs->msr);
while(1) ;
_exception(SIGILL, regs); _exception(SIGILL, regs);
} }
......
...@@ -24,6 +24,9 @@ modules: ...@@ -24,6 +24,9 @@ modules:
dep: dep:
$(CPP) -M *.c > .depend $(CPP) -M *.c > .depend
fastdep:
$(CPP) -M *.c > .depend
# #
# include a dependency file if one exists # include a dependency file if one exists
# #
......
/* * Last edited: Nov 29 18:14 1995 (cort) */
/* /*
* ARCH/ppc/mm/fault.c * ARCH/ppc/mm/fault.c
* *
...@@ -5,6 +6,9 @@ ...@@ -5,6 +6,9 @@
* Ported to PPC by Gary Thomas * Ported to PPC by Gary Thomas
*/ */
/*#define NOISY_DATAFAULT*/
/*#define NOISY_INSTRFAULT*/
#include <linux/config.h> #include <linux/config.h>
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/sched.h> #include <linux/sched.h>
...@@ -37,19 +41,24 @@ DataAccessException(struct pt_regs *regs) ...@@ -37,19 +41,24 @@ DataAccessException(struct pt_regs *regs)
if (user_mode(regs)) mode |= 0x04; if (user_mode(regs)) mode |= 0x04;
if (regs->dsisr & 0x02000000) mode |= 0x02; /* Load/store */ if (regs->dsisr & 0x02000000) mode |= 0x02; /* Load/store */
if (regs->dsisr & 0x08000000) mode |= 0x01; /* Protection violation */ if (regs->dsisr & 0x08000000) mode |= 0x01; /* Protection violation */
#if 0 #ifdef NOISY_DATAFAULT
/*#ifdef SHOW_FAULTS*/ printk("Data fault on %x\n",regs->dar);
printk("Data Access Fault - Loc: %x, DSISR: %x, PC: %x", regs->dar, regs->dsisr, regs->nip);
printk(" PR: %d\n", regs->msr &&(1<<14));
#endif #endif
if (mode & 0x01) if (mode & 0x01)
{ {
#if 0 #if 0
printk("Write Protect Fault - Loc: %x, DSISR: %x, PC: %x\n", regs->dar, regs->dsisr, regs->nip); printk("Write Protect Fault - Loc: %x, DSISR: %x, PC: %x\n", regs->dar, regs->dsisr, regs->nip);
#endif
#ifdef NOISY_DATAFAULT
printk("Write Protect fault\n ");
#endif #endif
do_page_fault(regs, regs->dar, mode); do_page_fault(regs, regs->dar, mode);
#ifdef NOISY_DATAFAULT
printk("Write Protect fault handled\n");
#endif
return; return;
} }
/* printk("trying\n"); */
for (tries = 0; tries < 1; tries++) for (tries = 0; tries < 1; tries++)
{ {
dir = pgd_offset(current->mm, regs->dar & PAGE_MASK); dir = pgd_offset(current->mm, regs->dar & PAGE_MASK);
...@@ -72,7 +81,15 @@ DataAccessException(struct pt_regs *regs) ...@@ -72,7 +81,15 @@ DataAccessException(struct pt_regs *regs)
{ {
printk("No PGD\n"); printk("No PGD\n");
} }
#ifdef NOISY_DATAFAULT
printk("fall through page fault addr=%x; ip=%x\n",
regs->dar,regs->nip);
printk("beforefault: pgd[0] = %x[%x]\n",current->mm->pgd,*(current->mm->pgd));
#endif
do_page_fault(regs, regs->dar, mode); do_page_fault(regs, regs->dar, mode);
#ifdef NOISY_DATAFAULT
printk("handled: pgd[0] = %x[%x]\n",current->mm->pgd,*(current->mm->pgd));
#endif
} }
} }
...@@ -83,12 +100,14 @@ InstructionAccessException(struct pt_regs *regs) ...@@ -83,12 +100,14 @@ InstructionAccessException(struct pt_regs *regs)
pmd_t *pmd; pmd_t *pmd;
pte_t *pte; pte_t *pte;
int tries, mode = 0; int tries, mode = 0;
#if 0
panic("Instruction Access Fault - Loc: %x, DSISR: %x, PC: %x\n", regs->dar, regs->dsisr, regs->nip); #if NOISY_INSTRFAULT
printk("Instr fault on %x\n",regs->dar);
#endif #endif
if (user_mode(regs)) mode |= 0x04; if (user_mode(regs)) mode |= 0x04;
if (regs->dsisr & 0x02000000) mode |= 0x02; /* Load/store */ if (regs->dsisr & 0x02000000) mode |= 0x02; /* Load/store */
if (regs->dsisr & 0x08000000) mode |= 0x01; /* Protection violation */ if (regs->dsisr & 0x08000000) mode |= 0x01; /* Protection violation */
if (mode & 0x01) if (mode & 0x01)
{ {
do_page_fault(regs, regs->dar, mode); do_page_fault(regs, regs->dar, mode);
...@@ -96,29 +115,56 @@ InstructionAccessException(struct pt_regs *regs) ...@@ -96,29 +115,56 @@ InstructionAccessException(struct pt_regs *regs)
} }
for (tries = 0; tries < 1; tries++) for (tries = 0; tries < 1; tries++)
{ {
/* dir = pgd_offset(current->mm, regs->nip & PAGE_MASK); */
dir = pgd_offset(current->mm, regs->dar & PAGE_MASK); dir = pgd_offset(current->mm, regs->dar & PAGE_MASK);
#ifdef NOISY_INSTRFAULT
/* printk("regs->dar=%x current=%x current->mm=%x current->mm->pgd=%x current->tss.pg_tables=%x\n",
regs->dar,current,current->mm,current->mm->pgd,current->tss.pg_tables);*/
#endif
if (dir) if (dir)
{ {
pmd = pmd_offset(dir, regs->dar & PAGE_MASK); pmd = pmd_offset(dir, regs->dar & PAGE_MASK);
if (pmd && pmd_present(*pmd)) if (pmd && pmd_present(*pmd))
{ {
pte = pte_offset(pmd, regs->dar & PAGE_MASK); pte = pte_offset(pmd, regs->dar & PAGE_MASK);
if (pte && pte_present(*pte))
{ #ifdef NOISY_INSTRFAULT
/* printk("dir %x(%x) pmd %x(%x) pte %x\n",dir,*dir,pmd,*pmd,pte);*/
#if 0 #if 0
printk("Page mapped - PTE: %x[%x]\n", pte, *(long *)pte); printk("pgd_offset mm=%x mm->pgd=%x dirshouldbe=%x\n",
current->mm, current->mm->pgd,
current->mm->pgd+((regs->dar&PAGE_MASK) >> PGDIR_SHIFT));
printk("dir is %x\n", dir);
/* printk("got pte\n"); */
if (pte) {
printk("pgd=%x; dir=%x->%x; pmd=%x->%x; pte=%x; \n",
current->mm->pgd,dir,*dir,pmd,*pmd,pte);
if (pte_present(*pte)) {
printk("pte present\n");
} else {
printk("pte not present\n");
}
} else {
printk("pte false\n");
}
#endif #endif
#endif
if (pte && pte_present(*pte))
{
/* MMU_hash_page(&current->tss, regs->nip & PAGE_MASK, pte); */
MMU_hash_page(&current->tss, regs->dar & PAGE_MASK, pte); MMU_hash_page(&current->tss, regs->dar & PAGE_MASK, pte);
return; return;
} }
} }
} else } else
{ {
#if 1 #ifdef NOISY_INSTRFAULT
panic("No PGD Instruction Access Fault - Loc: %x, DSISR: %x, PC: %x\n", regs->dar, regs->dsisr, regs->nip); panic("No PGD Instruction Access Fault - Loc: %x, DSISR: %x, PC: %x current->mm\n",
regs->dar, regs->dsisr, regs->nip, current->mm);
#endif #endif
printk("No PGD\n");
} }
/* do_page_fault(regs, regs->nip, mode); */
do_page_fault(regs, regs->dar, mode); do_page_fault(regs, regs->dar, mode);
} }
} }
...@@ -138,24 +184,15 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, unsigned long er ...@@ -138,24 +184,15 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, unsigned long er
{ {
struct vm_area_struct * vma; struct vm_area_struct * vma;
unsigned long page; unsigned long page;
/* printk("\ndo_page_fault()\n");*/
/* printk("In do_page_fault()\n"); */
#if 1 #if 1
for (vma = current->mm->mmap ; ; vma = vma->vm_next) for (vma = current->mm->mmap ; ; vma = vma->vm_next)
{ {
if (!vma) if (!vma)
{ {
#if 0 /* mfisk */ panic("!vma: ip = %x; current=%x[%d]; mm=%x; mmap=%x; address = %x error_code = %x\n",
{ struct vm_area_struct * mmp; regs->nip, current,current->pid,current->mm,current->mm->mmap, address, error_code);
for(mmp=current->mm->mmap; mmp; mmp=mmp->vm_next) {
printk("notinmap: current: %x; mm: %x; mmap: %x; vma: %x to %x flags: %x\n",
current, current->mm, mmp, mmp->vm_start, mmp->vm_end, mmp->vm_flags);
}
}
#endif
panic("do_page_fault() !vma \n");
panic("not in map: ip = %x; current=%x; mm=%x; mmap=%x; address = %x error_code = %x\n",
regs->nip, current, current->mm, current->mm->mmap, address, error_code);
goto bad_area; goto bad_area;
} }
if (vma->vm_end > address) if (vma->vm_end > address)
...@@ -164,6 +201,8 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, unsigned long er ...@@ -164,6 +201,8 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, unsigned long er
#else #else
vma = find_vma(current, address); vma = find_vma(current, address);
if (!vma) if (!vma)
{
}
goto bad_area; goto bad_area;
#endif #endif
if (vma->vm_start <= address){ if (vma->vm_start <= address){
...@@ -171,11 +210,17 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, unsigned long er ...@@ -171,11 +210,17 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, unsigned long er
} }
if (!(vma->vm_flags & VM_GROWSDOWN)) if (!(vma->vm_flags & VM_GROWSDOWN))
{ {
printk("stack: gpr[1]=%x ip = %x; current=%x[%d]; mm=%x; mmap=%x; address = %x error_code = %x\n",regs->gpr[1],regs->nip, current,current->pid,current->mm,current->mm->mmap, address, error_code);
panic("stack\n"); panic("stack\n");
goto bad_area; goto bad_area;
} }
if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur) if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur)
{ panic("stack 2\n"); {
printk("stack2: vma->vm_end-addres %x rlim %x\n", vma->vm_end - address,
current->rlim[RLIMIT_STACK].rlim_cur);
printk("stack2: vm_end %x address = %x\n", vma->vm_end,address);
printk("stack2: gpr[1]=%x ip = %x; current=%x[%d]; mm=%x; mmap=%x; address = %x error_code = %x\n",regs->gpr[1],regs->nip, current,current->pid,current->mm,current->mm->mmap, address, error_code);
panic("stack2\n");
goto bad_area; goto bad_area;
} }
vma->vm_offset -= vma->vm_start - (address & PAGE_MASK); vma->vm_offset -= vma->vm_start - (address & PAGE_MASK);
...@@ -192,8 +237,8 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, unsigned long er ...@@ -192,8 +237,8 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, unsigned long er
if (error_code & 2) { if (error_code & 2) {
if (!(vma->vm_flags & VM_WRITE)) if (!(vma->vm_flags & VM_WRITE))
{ {
panic("\ndo_page_fault() write\n"); panic("do_page_fault() write\n");
panic("\ndo_page_fault() write! current: %x, address:%x, vm_flags: %x, mm: %x; vma(%x) %x to %x\n", panic("do_page_fault() write! current: %x, address:%x, vm_flags: %x, mm: %x; vma(%x) %x to %x\n",
current,address,vma->vm_flags,current->mm,vma,vma->vm_start,vma->vm_end); current,address,vma->vm_flags,current->mm,vma,vma->vm_start,vma->vm_end);
goto bad_area; goto bad_area;
} }
...@@ -224,7 +269,10 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, unsigned long er ...@@ -224,7 +269,10 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, unsigned long er
goto bad_area; goto bad_area;
} }
} }
/* printk("premm: pgd[0] = %x[%x]\n",current->mm->pgd,*(current->mm->pgd)); */
handle_mm_fault(vma, address, error_code & 2); handle_mm_fault(vma, address, error_code & 2);
/* printk("handled fault for %x in %x to %x flags %x\n", */
/* address,vma->vm_start,vma->vm_end,vma->vm_flags); */
return; return;
/* /*
...@@ -233,16 +281,21 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, unsigned long er ...@@ -233,16 +281,21 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, unsigned long er
*/ */
bad_area: bad_area:
if (user_mode(regs)) { if (user_mode(regs)) {
panic("Task: %x, PC: %x, bad area! - Addr: %x\n", current, regs->nip, address); printk("Task: %x, PC: %x, bad area! - Addr: %x\n", current, regs->nip, address);
send_sig(SIGSEGV, current, 1); send_sig(SIGSEGV, current, 1);
return; return;
} }
#if 0 #if 0
panic("\nKERNEL! Task: %x, PC: %x, bad area! - Addr: %x, PGDIR: %x\n", panic("KERNEL! Task: %x, PC: %x, bad area! - Addr: %x, PGDIR: %x\n",
current, regs->nip, address, current->tss.pg_tables); current, regs->nip, address, current->tss.pg_tables);
#else #else
panic("\nKERNELmm! current: %x, address:%x, vm_flags: %x, mm: %x; vma(%x) %x to %x\n", /* panic("KERNEL mm! current: %x, address:%x, vm_flags: %x, mm: %x; \nvma(%x) %x to %x swapper_pg_dir %x\n",
current,address,vma->vm_flags,current->mm,vma,vma->vm_start,vma->vm_end,
swapper_pg_dir);*/
printk("KERNEL mm! current: %x, address:%x, vm_flags: %x, mm: %x; vma(%x) %x to %x\n",
current,address,vma->vm_flags,current->mm,vma,vma->vm_start,vma->vm_end); current,address,vma->vm_flags,current->mm,vma,vma->vm_start,vma->vm_end);
panic("Kernel access of bad area\n");
#endif #endif
while (1) ; while (1) ;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* Ported to PPC by Gary Thomas * Ported to PPC by Gary Thomas
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/sched.h> #include <linux/sched.h>
...@@ -27,7 +28,7 @@ ...@@ -27,7 +28,7 @@
making it 8k for now. will change later. making it 8k for now. will change later.
-- Cort -- Cort
*/ */
pgd_t swapper_pg_dir[1024*8]; pgd_t swapper_pg_dir[1024];
/*pgd_t *swapper_pg_dir;*/ /*pgd_t *swapper_pg_dir;*/
pte *MMU_get_page(void); pte *MMU_get_page(void);
...@@ -331,6 +332,7 @@ BAT BAT1 = ...@@ -331,6 +332,7 @@ BAT BAT1 =
}; };
BAT BAT2 = BAT BAT2 =
{ {
/* map kernel with bats 0 = yes */
#if 1 #if 1
{ {
0x00000000>>17, /* bepi */ 0x00000000>>17, /* bepi */
...@@ -468,9 +470,9 @@ void MMU_init(void) ...@@ -468,9 +470,9 @@ void MMU_init(void)
{ {
int i, p; int i, p;
SEGREG *segs; SEGREG *segs;
_printk("MMU init - started\n"); /* _printk("MMU init - started\n");*/
find_end_of_memory(); find_end_of_memory();
_printk(" Start at 0x%08X, End at 0x%08X, Hash at 0x%08X\n", _start, _end, Hash); /* _printk(" Start at 0x%08X, End at 0x%08X, Hash at 0x%08X\n", _start, _end, Hash);*/
_SDR1 = ((unsigned long)Hash & 0x00FFFFFF) | Hash_mask; _SDR1 = ((unsigned long)Hash & 0x00FFFFFF) | Hash_mask;
p = (int)mmu_pages; p = (int)mmu_pages;
p = (p + (MMU_PAGE_SIZE-1)) & ~(MMU_PAGE_SIZE-1); p = (p + (MMU_PAGE_SIZE-1)) & ~(MMU_PAGE_SIZE-1);
...@@ -507,7 +509,7 @@ void MMU_init(void) ...@@ -507,7 +509,7 @@ void MMU_init(void)
{ {
MMU_map_page(&init_task.tss, i, i & 0x00FFFFFF, PAGE_KERNEL); MMU_map_page(&init_task.tss, i, i & 0x00FFFFFF, PAGE_KERNEL);
} }
_printk("MMU init - done!\n"); /* _printk("MMU init - done!\n");*/
} }
pte * pte *
...@@ -518,7 +520,7 @@ MMU_get_page(void) ...@@ -518,7 +520,7 @@ MMU_get_page(void)
{ {
bzero((char *)pg, MMU_PAGE_SIZE); bzero((char *)pg, MMU_PAGE_SIZE);
} }
_printk("MMU Allocate Page at %08X\n", pg); /* _printk("MMU Allocate Page at %08X\n", pg);*/
return(pg); return(pg);
} }
......
...@@ -5,7 +5,7 @@ mainmenu_option next_comment ...@@ -5,7 +5,7 @@ mainmenu_option next_comment
comment 'block devices' comment 'block devices'
tristate 'Normal floppy disk support' CONFIG_BLK_DEV_FD tristate 'Normal floppy disk support' CONFIG_BLK_DEV_FD
bool 'RAM disk support' CONFIG_BLK_DEV_RAM tristate 'RAM disk support' CONFIG_BLK_DEV_RAM
bool 'Normal (MFM/RLL) disk and IDE disk/cdrom support' CONFIG_ST506 bool 'Normal (MFM/RLL) disk and IDE disk/cdrom support' CONFIG_ST506
if [ "$CONFIG_ST506" = "y" ]; then if [ "$CONFIG_ST506" = "y" ]; then
comment 'Please see drivers/block/README.ide for help/info on IDE drives' comment 'Please see drivers/block/README.ide for help/info on IDE drives'
......
...@@ -30,6 +30,10 @@ endif ...@@ -30,6 +30,10 @@ endif
ifeq ($(CONFIG_BLK_DEV_RAM),y) ifeq ($(CONFIG_BLK_DEV_RAM),y)
L_OBJS += rd.o L_OBJS += rd.o
else
ifeq ($(CONFIG_BLK_DEV_RAM),m)
M_OBJS += rd.o
endif
endif endif
ifeq ($(CONFIG_BLK_DEV_HD),y) ifeq ($(CONFIG_BLK_DEV_HD),y)
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
* loader now also loads into a dynamic (buffer cache based) ramdisk, * loader now also loads into a dynamic (buffer cache based) ramdisk,
* not the old static ramdisk. Support for the old static ramdisk has * not the old static ramdisk. Support for the old static ramdisk has
* been completely removed. * been completely removed.
*
* Loadable module support added by Tom Dyas.
*/ */
#include <linux/sched.h> #include <linux/sched.h>
...@@ -35,6 +37,7 @@ ...@@ -35,6 +37,7 @@
#include <linux/mman.h> #include <linux/mman.h>
#include <linux/malloc.h> #include <linux/malloc.h>
#include <linux/ioctl.h> #include <linux/ioctl.h>
#include <linux/module.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/segment.h> #include <asm/segment.h>
...@@ -52,8 +55,10 @@ extern void wait_for_keypress(void); ...@@ -52,8 +55,10 @@ extern void wait_for_keypress(void);
#define BUILD_CRAMDISK #define BUILD_CRAMDISK
#define NUM_RAMDISKS 8 #define NUM_RAMDISKS 8
#ifndef MODULE
void rd_load(void); void rd_load(void);
static int crd_load(struct file *fp, struct file *outfp); static int crd_load(struct file *fp, struct file *outfp);
#endif
/* Various static variables go here... mostly used within the ramdisk code only. */ /* Various static variables go here... mostly used within the ramdisk code only. */
...@@ -66,9 +71,11 @@ static int rd_blocksizes[NUM_RAMDISKS]; ...@@ -66,9 +71,11 @@ static int rd_blocksizes[NUM_RAMDISKS];
* architecture-specific setup routine (from the stored bootsector * architecture-specific setup routine (from the stored bootsector
* information). * information).
*/ */
#ifndef MODULE
int rd_doload = 0; /* 1 = load ramdisk, 0 = don't load */ int rd_doload = 0; /* 1 = load ramdisk, 0 = don't load */
int rd_prompt = 1; /* 1 = prompt for ramdisk, 0 = don't prompt */ int rd_prompt = 1; /* 1 = prompt for ramdisk, 0 = don't prompt */
int rd_image_start = 0; /* starting block # of image */ int rd_image_start = 0; /* starting block # of image */
#endif
/* /*
* Basically, my strategy here is to set up a buffer-head which can't be * Basically, my strategy here is to set up a buffer-head which can't be
...@@ -143,9 +150,18 @@ static int rd_open(struct inode * inode, struct file * filp) ...@@ -143,9 +150,18 @@ static int rd_open(struct inode * inode, struct file * filp)
if (DEVICE_NR(inode->i_rdev) >= NUM_RAMDISKS) if (DEVICE_NR(inode->i_rdev) >= NUM_RAMDISKS)
return -ENODEV; return -ENODEV;
MOD_INC_USE_COUNT;
return 0; return 0;
} }
#ifdef MODULE
static void rd_release(struct inode * inode, struct file * filp)
{
MOD_DEC_USE_COUNT;
}
#endif
static struct file_operations fd_fops = { static struct file_operations fd_fops = {
NULL, /* lseek - default */ NULL, /* lseek - default */
block_read, /* read - block dev write */ block_read, /* read - block dev write */
...@@ -155,7 +171,11 @@ static struct file_operations fd_fops = { ...@@ -155,7 +171,11 @@ static struct file_operations fd_fops = {
rd_ioctl, /* ioctl */ rd_ioctl, /* ioctl */
NULL, /* mmap */ NULL, /* mmap */
rd_open, /* open */ rd_open, /* open */
#ifndef MODULE
NULL, /* no special release code... */ NULL, /* no special release code... */
#else
rd_release, /* module needs to decrement use count */
#endif
block_fsync /* fsync */ block_fsync /* fsync */
}; };
...@@ -165,7 +185,7 @@ int rd_init(void) ...@@ -165,7 +185,7 @@ int rd_init(void)
int i; int i;
if (register_blkdev(MAJOR_NR, "ramdisk", &fd_fops)) { if (register_blkdev(MAJOR_NR, "ramdisk", &fd_fops)) {
printk("RAMDISK2 : Could not get major %d", MAJOR_NR); printk("RAMDISK: Could not get major %d", MAJOR_NR);
return -EIO; return -EIO;
} }
...@@ -181,6 +201,7 @@ int rd_init(void) ...@@ -181,6 +201,7 @@ int rd_init(void)
return 0; return 0;
} }
#ifndef MODULE
/* /*
* This routine tries to a ramdisk image to load, and returns the * This routine tries to a ramdisk image to load, and returns the
* number of blocks to read for a non-compressed image, 0 if the image * number of blocks to read for a non-compressed image, 0 if the image
...@@ -523,7 +544,27 @@ crd_load(struct file * fp, struct file *outfp) ...@@ -523,7 +544,27 @@ crd_load(struct file * fp, struct file *outfp)
return result; return result;
} }
#endif #endif /* BUILD_CRAMDISK */
#endif /* MODULE */
/* loadable module support */
#ifdef MODULE
int init_module(void)
{
int error = rd_init();
if (!error)
printk(KERN_INFO "RAMDISK: Loaded as module.\n");
return error;
}
void cleanup_module(void)
{
unregister_blkdev( MAJOR_NR, "ramdisk" );
blk_dev[MAJOR_NR].request_fn = 0;
}
#endif /* MODULE */
...@@ -286,7 +286,8 @@ static inline void ...@@ -286,7 +286,8 @@ static inline void
enable_interrupts(void) enable_interrupts(void)
{ {
#ifdef USE_IRQ #ifdef USE_IRQ
/* this code snarfed from cdu31a.c; it will not /*
* This code was taken from cdu31a.c; it will not
* directly work for the cdu535 as written... * directly work for the cdu535 as written...
*/ */
curr_control_reg |= ( SONY_ATTN_INT_EN_BIT curr_control_reg |= ( SONY_ATTN_INT_EN_BIT
...@@ -300,7 +301,8 @@ static inline void ...@@ -300,7 +301,8 @@ static inline void
disable_interrupts(void) disable_interrupts(void)
{ {
#ifdef USE_IRQ #ifdef USE_IRQ
/* this code snarfed from cdu31a.c; it will not /*
* This code was taken from cdu31a.c; it will not
* directly work for the cdu535 as written... * directly work for the cdu535 as written...
*/ */
curr_control_reg &= ~(SONY_ATTN_INT_EN_BIT curr_control_reg &= ~(SONY_ATTN_INT_EN_BIT
......
...@@ -158,7 +158,7 @@ static int ac_probe1(int ioaddr, struct device *dev) ...@@ -158,7 +158,7 @@ static int ac_probe1(int ioaddr, struct device *dev)
inb(ioaddr + AC_ID_PORT + 2), inb(ioaddr + AC_ID_PORT + 3)); inb(ioaddr + AC_ID_PORT + 2), inb(ioaddr + AC_ID_PORT + 3));
#endif #endif
/* Assign and snarf the interrupt now. */ /* Assign and allocate the interrupt now. */
if (dev->irq == 0) if (dev->irq == 0)
dev->irq = config2irq(inb(ioaddr + AC_CONFIG)); dev->irq = config2irq(inb(ioaddr + AC_CONFIG));
else if (dev->irq == 2) else if (dev->irq == 2)
......
This diff is collapsed.
This diff is collapsed.
...@@ -61,43 +61,43 @@ ...@@ -61,43 +61,43 @@
/* /*
** Control and Status Register bit definitions (EWRK3_CSR) ** Control and Status Register bit definitions (EWRK3_CSR)
*/ */
#define RA 0x80 /* Runt Accept */ #define CSR_RA 0x80 /* Runt Accept */
#define PME 0x40 /* Promiscuous Mode Enable */ #define CSR_PME 0x40 /* Promiscuous Mode Enable */
#define MCE 0x20 /* Multicast Enable */ #define CSR_MCE 0x20 /* Multicast Enable */
#define TNE 0x08 /* TX Done Queue Not Empty */ #define CSR_TNE 0x08 /* TX Done Queue Not Empty */
#define RNE 0x04 /* RX Queue Not Empty */ #define CSR_RNE 0x04 /* RX Queue Not Empty */
#define TXD 0x02 /* TX Disable */ #define CSR_TXD 0x02 /* TX Disable */
#define RXD 0x01 /* RX Disable */ #define CSR_RXD 0x01 /* RX Disable */
/* /*
** Control Register bit definitions (EWRK3_CR) ** Control Register bit definitions (EWRK3_CR)
*/ */
#define APD 0x80 /* Auto Port Disable */ #define CR_APD 0x80 /* Auto Port Disable */
#define PSEL 0x40 /* Port Select (0->TP port) */ #define CR_PSEL 0x40 /* Port Select (0->TP port) */
#define LBCK 0x20 /* LoopBaCK enable */ #define CR_LBCK 0x20 /* LoopBaCK enable */
#define FDUP 0x10 /* Full DUPlex enable */ #define CR_FDUP 0x10 /* Full DUPlex enable */
#define FBUS 0x08 /* Fast BUS enable (ISA clk > 8.33MHz) */ #define CR_FBUS 0x08 /* Fast BUS enable (ISA clk > 8.33MHz) */
#define EN_16 0x04 /* ENable 16 bit memory accesses */ #define CR_EN_16 0x04 /* ENable 16 bit memory accesses */
#define LED 0x02 /* LED (1-> turn on) */ #define CR_LED 0x02 /* LED (1-> turn on) */
/* /*
** Interrupt Control Register bit definitions (EWRK3_ICR) ** Interrupt Control Register bit definitions (EWRK3_ICR)
*/ */
#define IE 0x80 /* Interrupt Enable */ #define ICR_IE 0x80 /* Interrupt Enable */
#define IS 0x60 /* Interrupt Selected */ #define ICR_IS 0x60 /* Interrupt Selected */
#define TNEM 0x08 /* TNE Mask (0->mask) */ #define ICR_TNEM 0x08 /* TNE Mask (0->mask) */
#define RNEM 0x04 /* RNE Mask (0->mask) */ #define ICR_RNEM 0x04 /* RNE Mask (0->mask) */
#define TXDM 0x02 /* TXD Mask (0->mask) */ #define ICR_TXDM 0x02 /* TXD Mask (0->mask) */
#define RXDM 0x01 /* RXD Mask (0->mask) */ #define ICR_RXDM 0x01 /* RXD Mask (0->mask) */
/* /*
** Transmit Status Register bit definitions (EWRK3_TSR) ** Transmit Status Register bit definitions (EWRK3_TSR)
*/ */
#define NCL 0x80 /* No Carrier Loopback */ #define TSR_NCL 0x80 /* No Carrier Loopback */
#define ID 0x40 /* Initially Deferred */ #define TSR_ID 0x40 /* Initially Deferred */
#define LCL 0x20 /* Late CoLlision */ #define TSR_LCL 0x20 /* Late CoLlision */
#define ECL 0x10 /* Excessive CoLlisions */ #define TSR_ECL 0x10 /* Excessive CoLlisions */
#define RCNTR 0x0f /* Retries CouNTeR */ #define TSR_RCNTR 0x0f /* Retries CouNTeR */
/* /*
** I/O Page Register bit definitions (EWRK3_IOPR) ** I/O Page Register bit definitions (EWRK3_IOPR)
...@@ -111,67 +111,68 @@ ...@@ -111,67 +111,68 @@
/* /*
** I/O Base Register bit definitions (EWRK3_IOBR) ** I/O Base Register bit definitions (EWRK3_IOBR)
*/ */
#define EISA 0x20 /* Enable EISA ID and Control Registers */ #define EISA_REGS_EN 0x20 /* Enable EISA ID and Control Registers */
#define IOB 0x1f /* Compare bits for I/O Base Address */ #define EISA_IOB 0x1f /* Compare bits for I/O Base Address */
/* /*
** I/O Configuration/Management Register bit definitions (EWRK3_CMR) ** I/O Congiguration/Management Register bit definitions (EWRK3_CMR)
*/ */
#define RA 0x80 /* Read Ahead */ #define CMR_RA 0x80 /* Read Ahead */
#define WB 0x40 /* Write Behind */ #define CMR_WB 0x40 /* Write Behind */
#define LINK 0x20 /* 0->TP */ #define CMR_LINK 0x20 /* 0->TP */
#define POLARITY 0x10 /* Informational */ #define CMR_POLARITY 0x10 /* Informational */
#define NO_EEPROM 0x0c /* NO_EEPROM<1:0> pin status */ #define CMR_NO_EEPROM 0x0c /* NO_EEPROM<1:0> pin status */
#define HS 0x08 /* Hard Strapped pin status (LeMAC2) */ #define CMR_HS 0x08 /* Hard Strapped pin status (LeMAC2) */
#define PNP 0x04 /* Plug 'n Play */ #define CMR_PNP 0x04 /* Plug 'n Play */
#define DRAM 0x02 /* 0-> 1DRAM, 1-> 2 DRAM on board */ #define CMR_DRAM 0x02 /* 0-> 1DRAM, 1-> 2 DRAM on board */
#define _0WS 0x01 /* Zero Wait State */ #define CMR_0WS 0x01 /* Zero Wait State */
/* /*
** MAC Receive Status Register bit definitions ** MAC Receive Status Register bit definitions
*/ */
#define ROK 0x80 /* Receive OK summary */ #define R_ROK 0x80 /* Receive OK summary */
#define IAM 0x10 /* Individual Address Match */ #define R_IAM 0x10 /* Individual Address Match */
#define MCM 0x08 /* MultiCast Match */ #define R_MCM 0x08 /* MultiCast Match */
#define DBE 0x04 /* Dribble Bit Error */ #define R_DBE 0x04 /* Dribble Bit Error */
#define CRC 0x02 /* CRC error */ #define R_CRC 0x02 /* CRC error */
#define PLL 0x01 /* Phase Lock Lost */ #define R_PLL 0x01 /* Phase Lock Lost */
/* /*
** MAC Transmit Control Register bit definitions ** MAC Transmit Control Register bit definitions
*/ */
#define SQEE 0x40 /* SQE Enable - look for heartbeat */ #define TCR_SQEE 0x40 /* SQE Enable - look for heartbeat */
#define SED 0x20 /* Stop when Error Detected */ #define TCR_SED 0x20 /* Stop when Error Detected */
#define QMODE 0x10 /* Q_MODE */ #define TCR_QMODE 0x10 /* Q_MODE */
#define LAB 0x08 /* Less Aggressive Backoff */ #define TCR_LAB 0x08 /* Less Aggressive Backoff */
#define PAD 0x04 /* PAD Runt Packets */ #define TCR_PAD 0x04 /* PAD Runt Packets */
#define IFC 0x02 /* Insert Frame Check */ #define TCR_IFC 0x02 /* Insert Frame Check */
#define ISA 0x01 /* Insert Source Address */ #define TCR_ISA 0x01 /* Insert Source Address */
/* /*
** MAC Transmit Status Register bit definitions ** MAC Transmit Status Register bit definitions
*/ */
#define VSTS 0x80 /* Valid STatuS */ #define T_VSTS 0x80 /* Valid STatuS */
#define MAC_CTU 0x40 /* Cut Through Used */ #define T_CTU 0x40 /* Cut Through Used */
#define MAC_SQE 0x20 /* Signal Quality Error */ #define T_SQE 0x20 /* Signal Quality Error */
#define MAC_NCL 0x10 /* No Carrier Loopback */ #define T_NCL 0x10 /* No Carrier Loopback */
#define MAC_LCL 0x08 /* Late Collision */ #define T_LCL 0x08 /* Late Collision */
#define MAC_ID 0x04 /* Initially Deferred */ #define T_ID 0x04 /* Initially Deferred */
#define MAC_COLL 0x03 /* COLLision status */ #define T_COLL 0x03 /* COLLision status */
#define MAC_XCOLL 0x03 /* Excessive Collisions */ #define T_XCOLL 0x03 /* Excessive Collisions */
#define MAC_MCOLL 0x02 /* Multiple Collisions */ #define T_MCOLL 0x02 /* Multiple Collisions */
#define MAC_OCOLL 0x01 /* One Collision */ #define T_OCOLL 0x01 /* One Collision */
#define MAC_NOCOLL 0x00 /* No Collisions */ #define T_NOCOLL 0x00 /* No Collisions */
#define MAC_XUR 0x03 /* Excessive Underruns */ #define T_XUR 0x03 /* Excessive Underruns */
#define MAC_TXE 0x7f /* TX Errors */ #define T_TXE 0x7f /* TX Errors */
/* /*
** EISA Configuration Register bit definitions ** EISA Configuration Register bit definitions
*/ */
#define EISA_ID iobase + 0x0c80 /* EISA ID Registers */
#define EISA_ID0 iobase + 0x0c80 /* EISA ID Register 0 */ #define EISA_ID0 iobase + 0x0c80 /* EISA ID Register 0 */
#define EISA_ID1 iobase + 0x0c81 /* EISA ID Register 1 */ #define EISA_ID1 iobase + 0x0c81 /* EISA ID Register 1 */
#define EISA_ID2 iobase + 0x0c82 /* EISA ID Register 2 */ #define EISA_ID2 iobase + 0x0c82 /* EISA ID Register 2 */
...@@ -283,6 +284,8 @@ ...@@ -283,6 +284,8 @@
#define MASK_INTERRUPTS 1 #define MASK_INTERRUPTS 1
#define UNMASK_INTERRUPTS 0 #define UNMASK_INTERRUPTS 0
#define EEPROM_OFFSET(a) ((u_short)((u_long)(a)))
/* /*
** Include the IOCTL stuff ** Include the IOCTL stuff
*/ */
......
...@@ -569,7 +569,7 @@ lance_open(struct device *dev) ...@@ -569,7 +569,7 @@ lance_open(struct device *dev)
} }
/* We used to allocate DMA here, but that was silly. /* We used to allocate DMA here, but that was silly.
DMA lines can't be shared! We now permanently snarf them. */ DMA lines can't be shared! We now permanently allocate them. */
irq2dev_map[dev->irq] = dev; irq2dev_map[dev->irq] = dev;
......
...@@ -237,7 +237,6 @@ int ether_config(struct device *dev, struct ifmap *map) ...@@ -237,7 +237,6 @@ int ether_config(struct device *dev, struct ifmap *map)
return 0; return 0;
} }
#ifdef CONFIG_MODULES
int register_netdev(struct device *dev) int register_netdev(struct device *dev)
{ {
struct device *d = dev_base; struct device *d = dev_base;
...@@ -357,8 +356,6 @@ void unregister_netdev(struct device *dev) ...@@ -357,8 +356,6 @@ void unregister_netdev(struct device *dev)
restore_flags(flags); restore_flags(flags);
} }
#endif /* CONFIG_MODULES */
/* /*
......
...@@ -1407,7 +1407,7 @@ static int pi_probe(struct device *dev, int card_type) ...@@ -1407,7 +1407,7 @@ static int pi_probe(struct device *dev, int card_type)
} }
/* Grab the region */ /* Grab the region */
snarf_region(ioaddr & 0x3f0, PI_TOTAL_SIZE); request_region(ioaddr & 0x3f0, PI_TOTAL_SIZE, "pi2" );
} /* Only for A port */ } /* Only for A port */
......
...@@ -877,7 +877,7 @@ static int pt_probe(struct device *dev) ...@@ -877,7 +877,7 @@ static int pt_probe(struct device *dev)
} }
/* Grab the region */ /* Grab the region */
snarf_region(ioaddr & 0x3f0, PT_TOTAL_SIZE); request_region(ioaddr & 0x3f0, PT_TOTAL_SIZE, "pt" );
} /* A port */ } /* A port */
dev->open = pt_open; dev->open = pt_open;
dev->stop = pt_close; dev->stop = pt_close;
......
This diff is collapsed.
...@@ -448,11 +448,11 @@ int aha1740_detect(Scsi_Host_Template * tpnt) ...@@ -448,11 +448,11 @@ int aha1740_detect(Scsi_Host_Template * tpnt)
for ( slot=MINEISA; slot <= MAXEISA; slot++ ) for ( slot=MINEISA; slot <= MAXEISA; slot++ )
{ {
base = SLOTBASE(slot); base = SLOTBASE(slot);
/*
/* The ioports for eisa boards are generally beyond that used in the * The ioports for eisa boards are generally beyond that used in the
check,snarf_region code, but this may change at some point, so we * check/allocate region code, but this may change at some point,
go through the motions. */ * so we go through the motions.
*/
if(check_region(base, 0x5c)) continue; /* See if in use */ if(check_region(base, 0x5c)) continue; /* See if in use */
if ( aha1740_test_port()) break; if ( aha1740_test_port()) break;
} }
......
...@@ -58,6 +58,21 @@ const unsigned char scsi_command_size[8] = { 6, 10, 10, 12, 12, 12, 10, 10 }; ...@@ -58,6 +58,21 @@ const unsigned char scsi_command_size[8] = { 6, 10, 10, 12, 12, 12, 10, 10 };
#define INTERNAL_ERROR (panic ("Internal error in file %s, line %d.\n", __FILE__, __LINE__)) #define INTERNAL_ERROR (panic ("Internal error in file %s, line %d.\n", __FILE__, __LINE__))
/*
* PAGE_SIZE must be a multiple of the sector size (512). True
* for all reasonably recent architectures (even the VAX...).
*/
#define SECTOR_SIZE 512
#define SECTORS_PER_PAGE (PAGE_SIZE/SECTOR_SIZE)
#if SECTORS_PER_PAGE <= 8
typedef unsigned char FreeSectorBitmap;
#elif SECTORS_PER_PAGE <= 32
typedef unsigned int FreeSectorBitmap;
#else
# error You lose.
#endif
static void scsi_done (Scsi_Cmnd *SCpnt); static void scsi_done (Scsi_Cmnd *SCpnt);
static int update_timeout (Scsi_Cmnd *, int); static int update_timeout (Scsi_Cmnd *, int);
static void print_inquiry(unsigned char *data); static void print_inquiry(unsigned char *data);
...@@ -68,7 +83,7 @@ static int scan_scsis_single (int channel,int dev,int lun,int * max_scsi_dev , ...@@ -68,7 +83,7 @@ static int scan_scsis_single (int channel,int dev,int lun,int * max_scsi_dev ,
void scsi_build_commandblocks(Scsi_Device * SDpnt); void scsi_build_commandblocks(Scsi_Device * SDpnt);
static unsigned char * dma_malloc_freelist = NULL; static FreeSectorBitmap * dma_malloc_freelist = NULL;
static int scsi_need_isa_bounce_buffers; static int scsi_need_isa_bounce_buffers;
static unsigned int dma_sectors = 0; static unsigned int dma_sectors = 0;
unsigned int dma_free_sectors = 0; unsigned int dma_free_sectors = 0;
...@@ -2145,8 +2160,6 @@ static int update_timeout(Scsi_Cmnd * SCset, int timeout) ...@@ -2145,8 +2160,6 @@ static int update_timeout(Scsi_Cmnd * SCset, int timeout)
return oldto; return oldto;
} }
#define MALLOC_PAGEBITS 12
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES
static int scsi_register_host(Scsi_Host_Template *); static int scsi_register_host(Scsi_Host_Template *);
static void scsi_unregister_host(Scsi_Host_Template *); static void scsi_unregister_host(Scsi_Host_Template *);
...@@ -2157,7 +2170,7 @@ void *scsi_malloc(unsigned int len) ...@@ -2157,7 +2170,7 @@ void *scsi_malloc(unsigned int len)
unsigned int nbits, mask; unsigned int nbits, mask;
unsigned long flags; unsigned long flags;
int i, j; int i, j;
if((len & 0x1ff) || len > (1<<MALLOC_PAGEBITS)) if(len % SECTOR_SIZE != 0 || len > PAGE_SIZE)
return NULL; return NULL;
save_flags(flags); save_flags(flags);
...@@ -2165,8 +2178,8 @@ void *scsi_malloc(unsigned int len) ...@@ -2165,8 +2178,8 @@ void *scsi_malloc(unsigned int len)
nbits = len >> 9; nbits = len >> 9;
mask = (1 << nbits) - 1; mask = (1 << nbits) - 1;
for(i=0;i < (dma_sectors >> (MALLOC_PAGEBITS - 9)); i++) for(i=0;i < dma_sectors / SECTORS_PER_PAGE; i++)
for(j=0; j<=(sizeof(*dma_malloc_freelist) * 8) - nbits; j++){ for(j=0; j<=SECTORS_PER_PAGE - nbits; j++){
if ((dma_malloc_freelist[i] & (mask << j)) == 0){ if ((dma_malloc_freelist[i] & (mask << j)) == 0){
dma_malloc_freelist[i] |= (mask << j); dma_malloc_freelist[i] |= (mask << j);
restore_flags(flags); restore_flags(flags);
...@@ -2183,33 +2196,25 @@ void *scsi_malloc(unsigned int len) ...@@ -2183,33 +2196,25 @@ void *scsi_malloc(unsigned int len)
int scsi_free(void *obj, unsigned int len) int scsi_free(void *obj, unsigned int len)
{ {
int page, sector, nbits, mask; unsigned int page, sector, nbits, mask;
long offset;
unsigned long flags; unsigned long flags;
#ifdef DEBUG #ifdef DEBUG
printk("scsi_free %p %d\n",obj, len); printk("scsi_free %p %d\n",obj, len);
#endif #endif
offset = -1; for (page = 0; page < dma_sectors / SECTORS_PER_PAGE; page++) {
for (page = 0; page < (dma_sectors >> 3); page++) unsigned long page_addr = (unsigned long) dma_malloc_pages[page];
if ((unsigned long) obj >= (unsigned long) dma_malloc_pages[page] && if ((unsigned long) obj >= page_addr &&
(unsigned long) obj < (unsigned long) dma_malloc_pages[page] (unsigned long) obj < page_addr + PAGE_SIZE)
+ (1 << MALLOC_PAGEBITS))
{ {
offset = ((unsigned long) obj) - ((unsigned long)dma_malloc_pages[page]); sector = (((unsigned long) obj) - page_addr) >> 9;
break;
}
if (page == (dma_sectors >> 3)) panic("scsi_free:Bad offset");
sector = offset >> 9;
if(sector >= dma_sectors) panic ("scsi_free:Bad page");
sector = (offset >> 9) & (sizeof(*dma_malloc_freelist) * 8 - 1);
nbits = len >> 9; nbits = len >> 9;
mask = (1 << nbits) - 1; mask = (1 << nbits) - 1;
if ((mask << sector) > 0xffff) panic ("scsi_free:Bad memory alignment"); if ((mask << sector) >= (1 << SECTORS_PER_PAGE))
panic ("scsi_free:Bad memory alignment");
save_flags(flags); save_flags(flags);
cli(); cli();
...@@ -2220,6 +2225,9 @@ int scsi_free(void *obj, unsigned int len) ...@@ -2220,6 +2225,9 @@ int scsi_free(void *obj, unsigned int len)
dma_malloc_freelist[page] &= ~(mask << sector); dma_malloc_freelist[page] &= ~(mask << sector);
restore_flags(flags); restore_flags(flags);
return 0; return 0;
}
}
panic("scsi_free:Bad offset");
} }
...@@ -2521,11 +2529,12 @@ int scsi_proc_info(char *buffer, char **start, off_t offset, int length, ...@@ -2521,11 +2529,12 @@ int scsi_proc_info(char *buffer, char **start, off_t offset, int length,
static void resize_dma_pool(void) static void resize_dma_pool(void)
{ {
int i; int i;
unsigned long size;
struct Scsi_Host * shpnt; struct Scsi_Host * shpnt;
struct Scsi_Host * host = NULL; struct Scsi_Host * host = NULL;
Scsi_Device * SDpnt; Scsi_Device * SDpnt;
unsigned long flags; unsigned long flags;
unsigned char * new_dma_malloc_freelist = NULL; FreeSectorBitmap * new_dma_malloc_freelist = NULL;
unsigned int new_dma_sectors = 0; unsigned int new_dma_sectors = 0;
unsigned int new_need_isa_buffer = 0; unsigned int new_need_isa_buffer = 0;
unsigned char ** new_dma_malloc_pages = NULL; unsigned char ** new_dma_malloc_pages = NULL;
...@@ -2538,14 +2547,15 @@ static void resize_dma_pool(void) ...@@ -2538,14 +2547,15 @@ static void resize_dma_pool(void)
if( dma_free_sectors != dma_sectors ) if( dma_free_sectors != dma_sectors )
panic("SCSI DMA pool memory leak %d %d\n",dma_free_sectors,dma_sectors); panic("SCSI DMA pool memory leak %d %d\n",dma_free_sectors,dma_sectors);
for(i=0; i < dma_sectors >> 3; i++) for(i=0; i < dma_sectors / SECTORS_PER_PAGE; i++)
scsi_init_free(dma_malloc_pages[i], PAGE_SIZE); scsi_init_free(dma_malloc_pages[i], PAGE_SIZE);
if (dma_malloc_pages) if (dma_malloc_pages)
scsi_init_free((char *) dma_malloc_pages, scsi_init_free((char *) dma_malloc_pages,
(dma_sectors>>3)*sizeof(*dma_malloc_pages)); (dma_sectors / SECTORS_PER_PAGE)*sizeof(*dma_malloc_pages));
dma_malloc_pages = NULL; dma_malloc_pages = NULL;
if (dma_malloc_freelist) if (dma_malloc_freelist)
scsi_init_free(dma_malloc_freelist, dma_sectors>>3); scsi_init_free((char *) dma_malloc_freelist,
(dma_sectors / SECTORS_PER_PAGE)*sizeof(*dma_malloc_freelist));
dma_malloc_freelist = NULL; dma_malloc_freelist = NULL;
dma_sectors = 0; dma_sectors = 0;
dma_free_sectors = 0; dma_free_sectors = 0;
...@@ -2553,7 +2563,7 @@ static void resize_dma_pool(void) ...@@ -2553,7 +2563,7 @@ static void resize_dma_pool(void)
} }
/* Next, check to see if we need to extend the DMA buffer pool */ /* Next, check to see if we need to extend the DMA buffer pool */
new_dma_sectors = 16; /* Base value we use */ new_dma_sectors = 2*SECTORS_PER_PAGE; /* Base value we use */
if (high_memory-1 > ISA_DMA_THRESHOLD) if (high_memory-1 > ISA_DMA_THRESHOLD)
scsi_need_isa_bounce_buffers = 1; scsi_need_isa_bounce_buffers = 1;
...@@ -2562,7 +2572,7 @@ static void resize_dma_pool(void) ...@@ -2562,7 +2572,7 @@ static void resize_dma_pool(void)
if (scsi_devicelist) if (scsi_devicelist)
for(shpnt=scsi_hostlist; shpnt; shpnt = shpnt->next) for(shpnt=scsi_hostlist; shpnt; shpnt = shpnt->next)
new_dma_sectors += 8; /* Increment for each host */ new_dma_sectors += SECTORS_PER_PAGE; /* Increment for each host */
for (SDpnt=scsi_devices; SDpnt; SDpnt = SDpnt->next) { for (SDpnt=scsi_devices; SDpnt; SDpnt = SDpnt->next) {
host = SDpnt->host; host = SDpnt->host;
...@@ -2581,6 +2591,7 @@ static void resize_dma_pool(void) ...@@ -2581,6 +2591,7 @@ static void resize_dma_pool(void)
} }
} }
/* limit DMA memory to 32MB: */
new_dma_sectors = (new_dma_sectors + 15) & 0xfff0; new_dma_sectors = (new_dma_sectors + 15) & 0xfff0;
/* /*
...@@ -2593,22 +2604,20 @@ static void resize_dma_pool(void) ...@@ -2593,22 +2604,20 @@ static void resize_dma_pool(void)
if (new_dma_sectors) if (new_dma_sectors)
{ {
new_dma_malloc_freelist = (unsigned char *) size = (new_dma_sectors / SECTORS_PER_PAGE)*sizeof(FreeSectorBitmap);
scsi_init_malloc(new_dma_sectors >> 3, GFP_ATOMIC); new_dma_malloc_freelist = (FreeSectorBitmap *) scsi_init_malloc(size, GFP_ATOMIC);
memset(new_dma_malloc_freelist, 0, new_dma_sectors >> 3); memset(new_dma_malloc_freelist, 0, size);
new_dma_malloc_pages = (unsigned char **) size = (new_dma_sectors / SECTORS_PER_PAGE)*sizeof(*new_dma_malloc_pages);
scsi_init_malloc((new_dma_sectors>>3)*sizeof(*new_dma_malloc_pages), new_dma_malloc_pages = (unsigned char **) scsi_init_malloc(size, GFP_ATOMIC);
GFP_ATOMIC); memset(new_dma_malloc_pages, 0, size);
memset(new_dma_malloc_pages, 0,
(new_dma_sectors>>3)*sizeof(*new_dma_malloc_pages));
} }
/* /*
* If we need more buffers, expand the list. * If we need more buffers, expand the list.
*/ */
if( new_dma_sectors > dma_sectors ) { if( new_dma_sectors > dma_sectors ) {
for(i=dma_sectors >> 3; i< new_dma_sectors >> 3; i++) for(i=dma_sectors / SECTORS_PER_PAGE; i< new_dma_sectors / SECTORS_PER_PAGE; i++)
new_dma_malloc_pages[i] = (unsigned char *) new_dma_malloc_pages[i] = (unsigned char *)
scsi_init_malloc(PAGE_SIZE, GFP_ATOMIC | GFP_DMA); scsi_init_malloc(PAGE_SIZE, GFP_ATOMIC | GFP_DMA);
} }
...@@ -2620,17 +2629,17 @@ static void resize_dma_pool(void) ...@@ -2620,17 +2629,17 @@ static void resize_dma_pool(void)
cli(); cli();
if (dma_malloc_freelist) if (dma_malloc_freelist)
{ {
memcpy(new_dma_malloc_freelist, dma_malloc_freelist, dma_sectors >> 3); size = (dma_sectors / SECTORS_PER_PAGE)*sizeof(FreeSectorBitmap);
scsi_init_free(dma_malloc_freelist, dma_sectors>>3); memcpy(new_dma_malloc_freelist, dma_malloc_freelist, size);
scsi_init_free((char *) dma_malloc_freelist, size);
} }
dma_malloc_freelist = new_dma_malloc_freelist; dma_malloc_freelist = new_dma_malloc_freelist;
if (dma_malloc_pages) if (dma_malloc_pages)
{ {
memcpy(new_dma_malloc_pages, dma_malloc_pages, size = (dma_sectors / SECTORS_PER_PAGE)*sizeof(*dma_malloc_pages);
(dma_sectors>>3)*sizeof(*dma_malloc_pages)); memcpy(new_dma_malloc_pages, dma_malloc_pages, size);
scsi_init_free((char *) dma_malloc_pages, scsi_init_free((char *) dma_malloc_pages, size);
(dma_sectors>>3)*sizeof(*dma_malloc_pages));
} }
dma_free_sectors += new_dma_sectors - dma_sectors; dma_free_sectors += new_dma_sectors - dma_sectors;
...@@ -3111,6 +3120,8 @@ scsi_dump_status(void) ...@@ -3111,6 +3120,8 @@ scsi_dump_status(void)
extern struct symbol_table scsi_symbol_table; extern struct symbol_table scsi_symbol_table;
int init_module(void) { int init_module(void) {
unsigned long size;
/* /*
* This makes /proc/scsi visible. * This makes /proc/scsi visible.
*/ */
...@@ -3127,7 +3138,7 @@ int init_module(void) { ...@@ -3127,7 +3138,7 @@ int init_module(void) {
#endif #endif
dma_sectors = PAGE_SIZE / 512; dma_sectors = PAGE_SIZE / SECTOR_SIZE;
dma_free_sectors= dma_sectors; dma_free_sectors= dma_sectors;
/* /*
* Set up a minimal DMA buffer list - this will be used during scan_scsis * Set up a minimal DMA buffer list - this will be used during scan_scsis
...@@ -3135,13 +3146,13 @@ int init_module(void) { ...@@ -3135,13 +3146,13 @@ int init_module(void) {
*/ */
/* One bit per sector to indicate free/busy */ /* One bit per sector to indicate free/busy */
dma_malloc_freelist = (unsigned char *) size = (dma_sectors / SECTORS_PER_PAGE)*sizeof(FreeSectorBitmap);
scsi_init_malloc(dma_sectors >> 3, GFP_ATOMIC); dma_malloc_freelist = (unsigned char *) scsi_init_malloc(size, GFP_ATOMIC);
memset(dma_malloc_freelist, 0, dma_sectors >> 3); memset(dma_malloc_freelist, 0, size);
/* One pointer per page for the page list */ /* One pointer per page for the page list */
dma_malloc_pages = (unsigned char **) dma_malloc_pages = (unsigned char **)
scsi_init_malloc((dma_sectors >> 3)*sizeof(*dma_malloc_pages), GFP_ATOMIC); scsi_init_malloc((dma_sectors / SECTORS_PER_PAGE)*sizeof(*dma_malloc_pages), GFP_ATOMIC);
dma_malloc_pages[0] = (unsigned char *) dma_malloc_pages[0] = (unsigned char *)
scsi_init_malloc(PAGE_SIZE, GFP_ATOMIC | GFP_DMA); scsi_init_malloc(PAGE_SIZE, GFP_ATOMIC | GFP_DMA);
return 0; return 0;
......
...@@ -124,14 +124,14 @@ static int ioctl_internal_command(Scsi_Device *dev, char * cmd) ...@@ -124,14 +124,14 @@ static int ioctl_internal_command(Scsi_Device *dev, char * cmd)
break; break;
case NOT_READY: /* This happens if there is no disc in drive */ case NOT_READY: /* This happens if there is no disc in drive */
if(dev->removable){ if(dev->removable){
printk("Device not ready. Make sure there is a disc in the drive.\n"); printk(KERN_INFO "Device not ready. Make sure there is a disc in the drive.\n");
break; break;
}; };
case UNIT_ATTENTION: case UNIT_ATTENTION:
if (dev->removable){ if (dev->removable){
dev->changed = 1; dev->changed = 1;
SCpnt->result = 0; /* This is no longer considered an error */ SCpnt->result = 0; /* This is no longer considered an error */
printk("Disc change detected.\n"); printk(KERN_INFO "Disc change detected.\n");
break; break;
}; };
default: /* Fall through for non-removable media */ default: /* Fall through for non-removable media */
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* the status register flipped, I'll fix this "RSN" * the status register flipped, I'll fix this "RSN"
* *
* This card does all the I/O via memory mapped I/O, so there is no need * This card does all the I/O via memory mapped I/O, so there is no need
* to check or snarf a region of the I/O address space. * to check or allocate a region of the I/O address space.
*/ */
/* /*
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
* the 24F, cause the SCSI bus to do odd things and generally lead to * the 24F, cause the SCSI bus to do odd things and generally lead to
* kernel panics and machine hangs. This is like the Adaptec code. * kernel panics and machine hangs. This is like the Adaptec code.
* *
* Use check/snarf_region for 14f, 34f to avoid I/O space address conflicts. * Check I/O ports 14f, and 34f before allocating them to avoid conflicts.
*/ */
/* Changes from version 1.8 to version 1.9 /* Changes from version 1.8 to version 1.9
......
...@@ -19,10 +19,11 @@ if [ "$CONFIG_INET" = "y" ]; then ...@@ -19,10 +19,11 @@ if [ "$CONFIG_INET" = "y" ]; then
if [ "$CONFIG_NFS_FS" = "y" ]; then if [ "$CONFIG_NFS_FS" = "y" ]; then
bool 'Root file system on NFS' CONFIG_ROOT_NFS bool 'Root file system on NFS' CONFIG_ROOT_NFS
fi fi
tristate 'SMB filesystem support (to mount WfW shares etc..)' CONFIG_SMB_FS
fi
if [ "$CONFIG_IPX" = "y" ]; then
tristate 'NCP filesystem support (to mount NetWare volumes)' CONFIG_NCP_FS
fi fi
tristate 'ISO9660 cdrom filesystem support' CONFIG_ISO9660_FS tristate 'ISO9660 cdrom filesystem support' CONFIG_ISO9660_FS
tristate 'OS/2 HPFS filesystem support (read only)' CONFIG_HPFS_FS tristate 'OS/2 HPFS filesystem support (read only)' CONFIG_HPFS_FS
tristate 'System V and Coherent filesystem support' CONFIG_SYSV_FS tristate 'System V and Coherent filesystem support' CONFIG_SYSV_FS
if [ "$CONFIG_INET" = "y" ]; then
tristate 'SMB filesystem (to mount WfW shares etc..) support' CONFIG_SMB_FS
fi
...@@ -16,7 +16,8 @@ O_OBJS = open.o read_write.o inode.o devices.o file_table.o buffer.o \ ...@@ -16,7 +16,8 @@ O_OBJS = open.o read_write.o inode.o devices.o file_table.o buffer.o \
dcache.o $(BINFMTS) dcache.o $(BINFMTS)
MOD_LIST_NAME := FS_MODULES MOD_LIST_NAME := FS_MODULES
ALL_SUB_DIRS = minix ext ext2 msdos proc isofs nfs xiafs umsdos hpfs sysv smbfs ALL_SUB_DIRS = minix ext ext2 msdos proc isofs nfs xiafs umsdos hpfs sysv \
smbfs ncpfs
ifeq ($(CONFIG_QUOTA),y) ifeq ($(CONFIG_QUOTA),y)
O_OBJS += dquot.o O_OBJS += dquot.o
...@@ -108,6 +109,14 @@ else ...@@ -108,6 +109,14 @@ else
endif endif
endif endif
ifeq ($(CONFIG_NCP_FS),y)
SUB_DIRS += ncpfs
else
ifeq ($(CONFIG_NCP_FS),m)
MOD_SUB_DIRS += ncpfs
endif
endif
ifeq ($(CONFIG_HPFS_FS),y) ifeq ($(CONFIG_HPFS_FS),y)
SUB_DIRS += hpfs SUB_DIRS += hpfs
else else
......
This diff is collapsed.
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/sysv_fs.h> #include <linux/sysv_fs.h>
#include <linux/hpfs_fs.h> #include <linux/hpfs_fs.h>
#include <linux/smb_fs.h> #include <linux/smb_fs.h>
#include <linux/ncp_fs.h>
#include <linux/major.h> #include <linux/major.h>
extern void device_setup(void); extern void device_setup(void);
...@@ -87,6 +88,11 @@ asmlinkage int sys_setup(void) ...@@ -87,6 +88,11 @@ asmlinkage int sys_setup(void)
{smb_read_super, "smbfs", 0, NULL}); {smb_read_super, "smbfs", 0, NULL});
#endif #endif
#ifdef CONFIG_NCP_FS
register_filesystem(&(struct file_system_type)
{ncp_read_super, "ncpfs", 0, NULL});
#endif
#ifdef CONFIG_ISO9660_FS #ifdef CONFIG_ISO9660_FS
register_filesystem(&(struct file_system_type) register_filesystem(&(struct file_system_type)
{isofs_read_super, "iso9660", 1, NULL}); {isofs_read_super, "iso9660", 1, NULL});
......
...@@ -86,13 +86,13 @@ static inline void put_last_free(struct inode *inode) ...@@ -86,13 +86,13 @@ static inline void put_last_free(struct inode *inode)
inode->i_next->i_prev = inode; inode->i_next->i_prev = inode;
} }
void grow_inodes(void) int grow_inodes(void)
{ {
struct inode * inode; struct inode * inode;
int i; int i;
if (!(inode = (struct inode*) get_free_page(GFP_KERNEL))) if (!(inode = (struct inode*) get_free_page(GFP_KERNEL)))
return; return -ENOMEM;
i=PAGE_SIZE / sizeof(struct inode); i=PAGE_SIZE / sizeof(struct inode);
nr_inodes += i; nr_inodes += i;
...@@ -103,6 +103,7 @@ void grow_inodes(void) ...@@ -103,6 +103,7 @@ void grow_inodes(void)
for ( ; i ; i-- ) for ( ; i ; i-- )
insert_inode_free(inode++); insert_inode_free(inode++);
return 0;
} }
unsigned long inode_init(unsigned long start, unsigned long end) unsigned long inode_init(unsigned long start, unsigned long end)
...@@ -443,7 +444,7 @@ struct inode * get_empty_inode(void) ...@@ -443,7 +444,7 @@ struct inode * get_empty_inode(void)
{ {
static int ino = 0; static int ino = 0;
struct inode * inode, * best; struct inode * inode, * best;
unsigned long badness = ~0UL; unsigned long badness = 1000;
int i; int i;
if (nr_inodes < NR_INODE && nr_free_inodes < (nr_inodes >> 1)) if (nr_inodes < NR_INODE && nr_free_inodes < (nr_inodes >> 1))
...@@ -461,9 +462,9 @@ struct inode * get_empty_inode(void) ...@@ -461,9 +462,9 @@ struct inode * get_empty_inode(void)
} }
} }
} }
if (badness > 20) if (badness)
if (nr_inodes < NR_INODE) { if (nr_inodes < NR_INODE) {
grow_inodes(); if (grow_inodes() == 0)
goto repeat; goto repeat;
} }
inode = best; inode = best;
......
#
# Makefile for the linux ncp-filesystem routines.
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (ie not a .c file).
#
# Note 2! The CFLAGS definitions are now in the main makefile...
O_TARGET := ncpfs.o
O_OBJS := dir.o file.o inode.o ioctl.o mmap.o ncplib_kernel.o sock.o
M_OBJS := $(O_TARGET)
include $(TOPDIR)/Rules.make
ncplib_kernel.o: ncplib_kernel.c ncplib_kernel.h
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -finline-functions -c -o $@ $<
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* ioctl.c
*
* Copyright (C) 1995 by Volker Lendecke
*
*/
#include <asm/segment.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/ncp_fs.h>
#include <linux/ioctl.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/ncp.h>
int
ncp_ioctl (struct inode * inode, struct file * filp,
unsigned int cmd, unsigned long arg)
{
int result;
struct ncp_ioctl_request request;
struct ncp_server *server;
switch(cmd) {
case NCP_IOC_NCPREQUEST:
if (!suser())
{
return -EPERM;
}
if ((result = verify_area(VERIFY_READ, (char *)arg,
sizeof(request))) != 0)
{
return result;
}
memcpy_fromfs(&request, (struct ncp_ioctl_request *)arg,
sizeof(request));
if ( (request.function > 255)
|| (request.size >
NCP_PACKET_SIZE - sizeof(struct ncp_request_header)))
{
return -EINVAL;
}
if ((result = verify_area(VERIFY_WRITE, (char *)request.data,
NCP_PACKET_SIZE)) != 0)
{
return result;
}
server = NCP_SERVER(inode);
ncp_lock_server(server);
/* FIXME: We hack around in the server's structures
here to be able to use ncp_request */
server->has_subfunction = 0;
server->current_size =
request.size + sizeof(struct ncp_request_header);
memcpy_fromfs(server->packet, request.data,
request.size+sizeof(struct ncp_request_header));
ncp_request(server, request.function);
DPRINTK("ncp_ioctl: copy %d bytes\n",
server->reply_size);
memcpy_tofs(request.data, server->packet,
server->reply_size);
ncp_unlock_server(server);
return server->reply_size;
case NCP_IOC_GETMOUNTUID:
if ((result = verify_area(VERIFY_WRITE, (uid_t*) arg,
sizeof(uid_t))) != 0)
{
return result;
}
put_fs_word(NCP_SERVER(inode)->m.mounted_uid, (uid_t*) arg);
return 0;
default:
return -EINVAL;
}
return -EINVAL;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/config.h> #include <linux/config.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/pagemap.h>
#ifdef CONFIG_APM #ifdef CONFIG_APM
#include <linux/apm_bios.h> #include <linux/apm_bios.h>
#endif #endif
...@@ -276,10 +277,10 @@ static int get_meminfo(char * buffer) ...@@ -276,10 +277,10 @@ static int get_meminfo(char * buffer)
si_meminfo(&i); si_meminfo(&i);
si_swapinfo(&i); si_swapinfo(&i);
return sprintf(buffer, " total: used: free: shared: buffers:\n" return sprintf(buffer, " total: used: free: shared: buffers: cached:\n"
"Mem: %8lu %8lu %8lu %8lu %8lu\n" "Mem: %8lu %8lu %8lu %8lu %8lu %8lu\n"
"Swap: %8lu %8lu %8lu\n", "Swap: %8lu %8lu %8lu\n",
i.totalram, i.totalram-i.freeram, i.freeram, i.sharedram, i.bufferram, i.totalram, i.totalram-i.freeram, i.freeram, i.sharedram, i.bufferram, page_cache_size*PAGE_SIZE,
i.totalswap, i.totalswap-i.freeswap, i.freeswap); i.totalswap, i.totalswap-i.freeswap, i.freeswap);
} }
......
...@@ -263,6 +263,7 @@ asmlinkage int sys_readv(unsigned long fd, const struct iovec * vector, long cou ...@@ -263,6 +263,7 @@ asmlinkage int sys_readv(unsigned long fd, const struct iovec * vector, long cou
asmlinkage int sys_writev(unsigned long fd, const struct iovec * vector, long count) asmlinkage int sys_writev(unsigned long fd, const struct iovec * vector, long count)
{ {
int error;
struct file * file; struct file * file;
struct inode * inode; struct inode * inode;
...@@ -270,5 +271,8 @@ asmlinkage int sys_writev(unsigned long fd, const struct iovec * vector, long co ...@@ -270,5 +271,8 @@ asmlinkage int sys_writev(unsigned long fd, const struct iovec * vector, long co
return -EBADF; return -EBADF;
if (!(file->f_mode & 2)) if (!(file->f_mode & 2))
return -EBADF; return -EBADF;
return do_readv_writev(VERIFY_READ, inode, file, vector, count); down(&inode->i_sem);
error = do_readv_writev(VERIFY_READ, inode, file, vector, count);
up(&inode->i_sem);
return error;
} }
...@@ -501,7 +501,7 @@ smb_iget(struct inode *dir, char *path, struct smb_dirent *finfo) ...@@ -501,7 +501,7 @@ smb_iget(struct inode *dir, char *path, struct smb_dirent *finfo)
return NULL; return NULL;
} }
new_inode_info->state = INODE_LOOKED_UP; new_inode_info->state = SMB_INODE_LOOKED_UP;
new_inode_info->nused = 0; new_inode_info->nused = 0;
new_inode_info->dir = SMB_INOP(dir); new_inode_info->dir = SMB_INOP(dir);
...@@ -539,8 +539,8 @@ smb_free_inode_info(struct smb_inode_info *i) ...@@ -539,8 +539,8 @@ smb_free_inode_info(struct smb_inode_info *i)
return; return;
} }
i->state = INODE_CACHED; i->state = SMB_INODE_CACHED;
while ((i->nused == 0) && (i->state == INODE_CACHED)) { while ((i->nused == 0) && (i->state == SMB_INODE_CACHED)) {
struct smb_inode_info *dir = i->dir; struct smb_inode_info *dir = i->dir;
i->next->prev = i->prev; i->next->prev = i->prev;
...@@ -565,7 +565,7 @@ smb_init_root(struct smb_server *server) ...@@ -565,7 +565,7 @@ smb_init_root(struct smb_server *server)
root->finfo.len = strlen(root->finfo.path); root->finfo.len = strlen(root->finfo.path);
root->finfo.opened = 0; root->finfo.opened = 0;
root->state = INODE_LOOKED_UP; root->state = SMB_INODE_LOOKED_UP;
root->nused = 1; root->nused = 1;
root->dir = NULL; root->dir = NULL;
root->next = root->prev = root; root->next = root->prev = root;
...@@ -690,8 +690,8 @@ smb_lookup(struct inode *dir, const char *__name, int len, ...@@ -690,8 +690,8 @@ smb_lookup(struct inode *dir, const char *__name, int len,
if (result_info != 0) { if (result_info != 0) {
if (result_info->state == INODE_CACHED) if (result_info->state == SMB_INODE_CACHED)
result_info->state = INODE_LOOKED_UP; result_info->state = SMB_INODE_LOOKED_UP;
put_pname(name); put_pname(name);
......
...@@ -17,6 +17,11 @@ ...@@ -17,6 +17,11 @@
#include <linux/smb_fs.h> #include <linux/smb_fs.h>
#include <linux/malloc.h> #include <linux/malloc.h>
static inline int min(int a, int b)
{
return a<b ? a : b;
}
static int static int
smb_fsync(struct inode *inode, struct file *file) smb_fsync(struct inode *inode, struct file *file)
{ {
......
This diff is collapsed.
...@@ -32,6 +32,11 @@ ...@@ -32,6 +32,11 @@
void smb_printerr(int class, int num); void smb_printerr(int class, int num);
static int smb_request_ok(struct smb_server *s, int command, int wct, int bcc); static int smb_request_ok(struct smb_server *s, int command, int wct, int bcc);
static inline int min(int a, int b)
{
return a<b ? a : b;
}
/*****************************************************************************/ /*****************************************************************************/
/* */ /* */
/* Encoding/Decoding section */ /* Encoding/Decoding section */
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment