diff --git a/.project b/.project new file mode 100644 index 0000000..164d965 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + Scratch + + + + + + + + diff --git a/aibot/Makefile b/aibot/Makefile new file mode 100644 index 0000000..8a745c1 --- /dev/null +++ b/aibot/Makefile @@ -0,0 +1,11 @@ +all: aibot mods + +aibot: src + (cd src;make) + +mods: modules + (cd modules;make) + +clean: + (cd src;make clean) + (cd modules;make clean) diff --git a/aibot/include/aibot.h b/aibot/include/aibot.h new file mode 100644 index 0000000..a717c77 --- /dev/null +++ b/aibot/include/aibot.h @@ -0,0 +1,25 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +char *GetField(char *newline,int); + +#define VERSION "v0.1" diff --git a/aibot/include/irc.h b/aibot/include/irc.h new file mode 100644 index 0000000..3de256e --- /dev/null +++ b/aibot/include/irc.h @@ -0,0 +1,8 @@ +typedef struct ircStruct { + int socket; + char command[256]; + char data[1024]; + } IRCNode; + + +typedef struct ircStruct *IRC; diff --git a/aibot/include/socket.h b/aibot/include/socket.h new file mode 100644 index 0000000..dbf0b42 --- /dev/null +++ b/aibot/include/socket.h @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +#define MAXBUFLENGTH 4096 +#define BUFFER_SIZE 1024 + +int Connect(char *,int); +int ReadSock(int,char *); +int SendSock(int,const char *fmt, ...); diff --git a/aibot/modules/Makefile b/aibot/modules/Makefile new file mode 100644 index 0000000..80663dc --- /dev/null +++ b/aibot/modules/Makefile @@ -0,0 +1,12 @@ +CC=gcc +CFLAGS=-I./include + +all: example + +example: example.c + $(CC) -fPIC -c example.c + ld -Bshareable -o example.so example.o + +clean: + rm -fr *.so + rm -fr *.o diff --git a/aibot/modules/example.c b/aibot/modules/example.c new file mode 100644 index 0000000..5e57756 --- /dev/null +++ b/aibot/modules/example.c @@ -0,0 +1,7 @@ +#include + +char *Description(char *tmp) { + char description[512]; + sprintf(description,"This is an example modules and this was passwd to it: [%s]",tmp); + return(description); + } diff --git a/aibot/src/Makefile b/aibot/src/Makefile new file mode 100644 index 0000000..c7f76aa --- /dev/null +++ b/aibot/src/Makefile @@ -0,0 +1,22 @@ +CC=gcc +CFLAGS=-I../include + +MODS=main.o socket.o irc.o + +all: aibot + +aibot: $(MODS) + $(CC) -o ../bot $(MODS) + +main.o: main.c + $(CC) $(CFLAGS) -c main.c + +socket.o: socket.c + $(CC) $(CFLAGS) -c socket.c + +irc.o: irc.c + $(CC) $(CFLAGS) -c irc.c +clean: + rm -f *.o + rm -f ../*core + rm -f ../bot diff --git a/aibot/src/main.c b/aibot/src/main.c new file mode 100644 index 0000000..fa38978 --- /dev/null +++ b/aibot/src/main.c @@ -0,0 +1,45 @@ +#include "aibot.h" +#include "socket.h" +#include "irc.h" + +int main(int argc,char *argv[]) { + int s; + char *output; + IRC irc; + irc = (IRC) malloc (sizeof(IRCNode)); + printf("Starting AI Bot\n"); + irc->socket = Connect("irc.undernet.org",6667); + printf("Test: [%i]\n",s); + SendSock(irc->socket,"NICK PenisEnvy\nUSER PenisEnvy 0 0 UbieDubie\n"); + SendSock(irc->socket,"JOIN #UbixOS\n"); + while (1) { + if (ReadSock(irc->socket,output)) { + printf("%s\n",output); + IRCParse(output,irc); + if (!strcasecmp(irc->command,"PRIVMSG")) { + IRCPrivmsg(irc); + } + } + } + return(0); + } + +char *GetField(char *newline,int ch) { + static char *line = NULL; + char *end, *field; + + if (newline) + line = newline; + if (line == NULL) + return(NULL); + field = line; + if ((end = (char *)index(line,ch)) == NULL) { + line = NULL; + if ((end = (char *)index(field,'\n')) == NULL) + end = field + strlen(field); + } + else + line = end + 1; *end = '\0'; + + return(field); + } diff --git a/aibot/src/socket.c b/aibot/src/socket.c new file mode 100644 index 0000000..cb390f4 --- /dev/null +++ b/aibot/src/socket.c @@ -0,0 +1,76 @@ +#include "aibot.h" +#include "socket.h" + +int Connect(char *server,int port) { + char buf[1024]; + struct hostent *hp; + struct sockaddr_in sin; + int s; + if ((hp=gethostbyname(server))==NULL) { + printf("conn() -- ERROR: Unknown hostname (%s)\n", server); + exit(1); + } + if ((s=socket(AF_INET, SOCK_STREAM, 0)) < 0) { + printf("conn() -- ERROR: Client: Socket\n"); + } + sin.sin_family = AF_INET; + sin.sin_port = htons(port); + bcopy(hp->h_addr, &sin.sin_addr, hp->h_length); + if (connect(s,(struct sockaddr *)&sin, sizeof(sin)) < 0) { + printf("conn() -- ERROR: Client: Connect\n"); + exit(1); + } + return s; + } + +int SendSock(int socket, const char *fmt, ...) { + char *string; + va_list args; + string = malloc(MAXBUFLENGTH); + va_start(args, fmt); + vsnprintf(string, MAXBUFLENGTH, fmt, args); + va_end(args); + send(socket, string, strlen(string), 0); + return(strlen(string)); +} + +int ReadSock(int s,char *buf) { + char inc; + int bufnum, n; + fd_set fds; + struct timeval wait; + u_long btx = 0, brx = 0; + + bufnum = 0; + + if (s==-1) + { + return(-1); + } + wait.tv_sec = 0L; + wait.tv_usec = 2500L; + FD_ZERO(&fds); + FD_SET(s, &fds); + if (select(s+1, &fds, NULL, 0, &wait) > 0) + { + do + { + n = read(s, &inc, 1); + if (n == 0) + { + return -1; + } + if (bufnum < BUFFER_SIZE - 1 ) + { + buf[bufnum++] = inc; + } + } + while (inc != '\n'); + { + buf[bufnum] = '\0'; + } + brx += bufnum; + return bufnum; + } + return 0; +} diff --git a/lockwasher/Makefile b/lockwasher/Makefile new file mode 100644 index 0000000..8ac14b2 --- /dev/null +++ b/lockwasher/Makefile @@ -0,0 +1,36 @@ +# $Id: Makefile,v 1.2 2003/04/02 18:56:04 reddawg Exp $ +# The System Makefile (C) 2002 The UbixOS Project + +all: libc views libcpp depend bin kernel tools + +libc: src + (cd src/lib/libc;make) + +views: src + (cd src/lib/views;make) + +libcpp: src + (cd src/lib/libcpp;make) + +depend: src + (cd src/lib/ubix;make) + +bin: src + (cd src/bin;make) + +kernel: src + (cd src/sys;make) + +tools: src + (cd src/tools;make) + +install: + (cd src/sys;make install) + +clean: + (cd src/sys;make clean) + (cd src/lib/libc;make clean) + (cd src/bin;make clean) + (cd src/lib/ubix;make clean) + (cd src/lib/views;make clean) + (cd src/lib/libcpp;make clean) diff --git a/lockwasher/README b/lockwasher/README new file mode 100644 index 0000000..40ac8fd --- /dev/null +++ b/lockwasher/README @@ -0,0 +1 @@ +This is the top level of the UbixOS CVS repository. Please see the file LICENSE for copyright information. The source tree map is as follows: doc - contains most UbixOS documentation. examples - example files help - CLI Help Files developer - developers handbook FAQ - UbixOS FAQ manual - user manual src - contains all source files for UnixOS bin grayspace-misc(temporary) lib sys tools For information on source tree syncing please refer to: \ No newline at end of file diff --git a/lockwasher/UbixOS-Team b/lockwasher/UbixOS-Team new file mode 100644 index 0000000..4a69c4d --- /dev/null +++ b/lockwasher/UbixOS-Team @@ -0,0 +1,7 @@ +$Id: UbixOS-Team,v 1.2 2003/03/13 16:19:09 apwillia Exp $ + + +Christopher Olsen AKA Ubu Project Founder +Patrick Williams AKA Patrick_W Design Architect +Mark Iuzzolino AKA TCA Lead Gui Developer +Jeff Leveille AKA grayspace Lead Multimedia Developer diff --git a/lockwasher/lockwasher.kdevprj b/lockwasher/lockwasher.kdevprj new file mode 100644 index 0000000..df1d368 --- /dev/null +++ b/lockwasher/lockwasher.kdevprj @@ -0,0 +1,1910 @@ +[./Authors] +dist=true +install=false +install_location= +type=DATA + +[./LICENSE] +dist=true +install=false +install_location= +type=DATA + +[./Makefile.am] +files=./Authors,./LICENSE,./README,./UbixOS-Team,./lockwasher.kdevprj, +sub_dirs=docs,src, +type=normal + +[./README] +dist=true +install=false +install_location= +type=DATA + +[./UbixOS-Team] +dist=true +install=false +install_location= +type=DATA + +[./lockwasher.kdevprj] +dist=true +install=false +install_location= +type=DATA + +[Config for BinMakefileAm] +addcxxflags= +bin_program=lockwasher +cflags= +cppflags= +cxxflags=\s-O0 +ldadd= +ldflags=\s +libtool_dir= +path_to_bin_program=. + +[General] +AMChanged=false +author=reddawg +configure_args=\s--build=i386-linux --host=i386-linux --target=i386-linux\s +dir_where_make_will_be_called=./ +email=reddawg@Laptop.DomainAtlantic.Com +kdevprj_version=1.3 +lfv_open_groups= +make_options=\s-j1 all install clean\s +makefiles=./Makefile.am,docs/Makefile.am,docs/arch/Makefile.am,src/Makefile.am,src/bin/Makefile.am,src/bin/cat/Makefile.am,src/bin/ls/Makefile.am,src/bin/init/Makefile.am,src/bin/ld-dyn/Makefile.am,src/bin/login/Makefile.am,src/bin/pwd/Makefile.am,src/bin/shell/Makefile.am,src/bin/test/Makefile.am,src/grayspace-misc/Makefile.am,src/lib/Makefile.am,src/lib/libc/Makefile.am,src/lib/libc/generic/Makefile.am,src/lib/libc/include/Makefile.am,src/lib/libc/include/sys/Makefile.am,src/lib/libc/stdio/Makefile.am,src/lib/libc/stdlib/Makefile.am,src/lib/libc/string/Makefile.am,src/lib/libc/sys/Makefile.am,src/lib/ubix/Makefile.am,src/sys/Makefile.am,src/sys/boot/Makefile.am,src/sys/boot/boot2/Makefile.am,src/sys/boot/btx/Makefile.am,src/sys/boot/btx/btx/Makefile.am,src/sys/boot/btx/lib/Makefile.am,src/sys/boot/btx/btxldr/Makefile.am,src/sys/compile/Makefile.am,src/sys/deviceman/Makefile.am,src/sys/drivers/Makefile.am,src/sys/graphics/Makefile.am,src/sys/include/Makefile.am,src/sys/include/deviceman/Makefile.am,src/sys/include/drivers/Makefile.am,src/sys/include/misc/Makefile.am,src/sys/include/ubixfs/Makefile.am,src/sys/include/ubixos/Makefile.am,src/sys/include/version/Makefile.am,src/sys/include/vmm/Makefile.am,src/sys/init/Makefile.am,src/sys/kernel/Makefile.am,src/sys/misc/Makefile.am,src/sys/ubixfs/Makefile.am,src/sys/vmm/Makefile.am,src/tools/Makefile.am,Makefile.am,src/sys/sys/Makefile.am,src/sys/lib/Makefile.am,src/sys/include/lib/Makefile.am,src/sys/pci/Makefile.am,src/sys/include/sde/Makefile.am,src/sys/sde/Makefile.am,src/sys/isa/Makefile.am,src/sys/include/pci/Makefile.am,src/sys/ld/Makefile.am,src/sys/include/ld/Makefile.am +modifyMakefiles=true +project_name=lockwasher +project_type=normal_empty +short_info= +sub_dir= +version= +version_control=CVS +workspace=1 + +[LFV Groups] +GNU=AUTHORS,COPYING,ChangeLog,INSTALL,README,TODO,NEWS, +Headers=*.h,*.hxx,*.hpp,*.H, +Others=*, +Sources=*.cpp,*.c,*.cc,*.C,*.cxx,*.ec,*.ecpp,*.lxx,*.l++,*.ll,*.l, +Translations=*.ts,*.po, +User Interface=*.ui,*.kdevdlg,*.rc, +groups=Headers,Sources,GNU,Translations,User Interface,Others + +[LICENSE] +dist=true +install=false +install_location= +type=DATA + +[Makefile] +dist=true +install=false +install_location= +type=DATA + +[Makefile.am] +files=LICENSE,Makefile,README,UbixOS-Team,snapshot.txt +sub_dirs=src +type=normal + +[README] +dist=true +install=false +install_location= +type=DATA + +[UbixOS-Team] +dist=true +install=false +install_location= +type=DATA + +[docs/FAQ] +dist=true +install=false +install_location= +type=DATA + +[docs/Makefile.am] +files=docs/FAQ,docs/mailing-lists, +sub_dirs=arch, +type=normal + +[docs/arch/Makefile.am] +files=docs/arch/scheduler, +sub_dirs= +type=normal + +[docs/arch/scheduler] +dist=true +install=false +install_location= +type=DATA + +[docs/mailing-lists] +dist=true +install=false +install_location= +type=DATA + +[snapshot.txt] +dist=true +install=false +install_location= +type=DATA + +[src/Makefile.am] +sub_dirs=bin,grayspace-misc,lib,sys,tools, +type=normal + +[src/bin/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/bin/Makefile.am] +files=src/bin/Makefile +sub_dirs=cat,ls,init,ld-dyn,login,pwd,shell,test, +type=normal + +[src/bin/cat/Makefile.am] +files=src/bin/cat/cat,src/bin/cat/main.c, +sub_dirs= +type=normal + +[src/bin/cat/cat] +dist=true +install=false +install_location= +type=DATA + +[src/bin/cat/main.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/init/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/bin/init/Makefile.am] +files=src/bin/init/init,src/bin/init/main.c,src/bin/init/Makefile +sub_dirs= +type=normal + +[src/bin/init/init] +dist=true +install=false +install_location= +type=DATA + +[src/bin/init/main.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/ld-dyn/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/bin/ld-dyn/Makefile.am] +files=src/bin/ld-dyn/ld-dyn,src/bin/ld-dyn/main.c,src/bin/ld-dyn/Makefile +sub_dirs= +type=normal + +[src/bin/ld-dyn/ld-dyn] +dist=true +install=false +install_location= +type=DATA + +[src/bin/ld-dyn/main.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/login/Makefile.am] +files=src/bin/login/login,src/bin/login/main.c, +sub_dirs= +type=normal + +[src/bin/login/login] +dist=true +install=false +install_location= +type=DATA + +[src/bin/login/main.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/ls/Makefile.am] +files=src/bin/ls/ls,src/bin/ls/main.c, +sub_dirs= +type=normal + +[src/bin/ls/ls] +dist=true +install=false +install_location= +type=DATA + +[src/bin/ls/main.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/pwd/Makefile.am] +files=src/bin/pwd/main.c,src/bin/pwd/pwd, +sub_dirs= +type=normal + +[src/bin/pwd/main.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/pwd/pwd] +dist=true +install=false +install_location= +type=DATA + +[src/bin/shell/Makefile.am] +files=src/bin/shell/commands.c,src/bin/shell/error.c,src/bin/shell/exec.c,src/bin/shell/input.c,src/bin/shell/main.c,src/bin/shell/shell,src/bin/shell/shell.h, +sub_dirs= +type=normal + +[src/bin/shell/commands.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/shell/error.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/shell/exec.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/shell/input.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/shell/main.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/shell/shell] +dist=true +install=false +install_location= +type=DATA + +[src/bin/shell/shell.h] +dist=true +install=false +install_location= +type=HEADER + +[src/bin/test/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/bin/test/Makefile.am] +files=src/bin/test/main.c,src/bin/test/test,src/bin/test/Makefile +sub_dirs= +type=normal + +[src/bin/test/main.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/test/test] +dist=true +install=false +install_location= +type=DATA + +[src/grayspace-misc/Makefile.am] +files=src/grayspace-misc/gsdefines.h, +sub_dirs= +type=normal + +[src/grayspace-misc/gsdefines.h] +dist=true +install=false +install_location= +type=HEADER + +[src/lib/Makefile.am] +sub_dirs=libc,ubix, +type=normal + +[src/lib/libc/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/lib/libc/Makefile.am] +files=src/lib/libc/Makefile +sub_dirs=generic,include,stdio,stdlib,string,sys, +type=normal + +[src/lib/libc/generic/Makefile.am] +files=src/lib/libc/generic/getcwd.c, +sub_dirs= +type=normal + +[src/lib/libc/generic/getcwd.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/include/Makefile.am] +files=src/lib/libc/include/stdarg.h,src/lib/libc/include/stdio.h,src/lib/libc/include/stdlib.h,src/lib/libc/include/string.h,src/lib/libc/include/unistd.h, +sub_dirs=sys, +type=normal + +[src/lib/libc/include/stdarg.h] +dist=true +install=false +install_location= +type=HEADER + +[src/lib/libc/include/stdio.h] +dist=true +install=false +install_location= +type=HEADER + +[src/lib/libc/include/stdlib.h] +dist=true +install=false +install_location= +type=HEADER + +[src/lib/libc/include/string.h] +dist=true +install=false +install_location= +type=HEADER + +[src/lib/libc/include/sys/Makefile.am] +files=src/lib/libc/include/sys/types.h,src/lib/libc/include/sys/sys.h, +sub_dirs= +type=normal + +[src/lib/libc/include/sys/sys.h] +dist=true +install=false +install_location= +type=HEADER + +[src/lib/libc/include/sys/types.h] +dist=true +install=false +install_location= +type=HEADER + +[src/lib/libc/include/unistd.h] +dist=true +install=false +install_location= +type=HEADER + +[src/lib/libc/stdio/Makefile.am] +files=src/lib/libc/stdio/fclose.c,src/lib/libc/stdio/fd.c,src/lib/libc/stdio/fgetc.c,src/lib/libc/stdio/fopen.c,src/lib/libc/stdio/fprintf.c,src/lib/libc/stdio/fread.c,src/lib/libc/stdio/fwrite.c,src/lib/libc/stdio/gets.c,src/lib/libc/stdio/printf.c,src/lib/libc/stdio/sprintf.c,src/lib/libc/stdio/vfprintf.c,src/lib/libc/stdio/vsprintf.c, +sub_dirs= +type=normal + +[src/lib/libc/stdio/fclose.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdio/fd.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdio/fgetc.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdio/fopen.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdio/fprintf.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdio/fread.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdio/fwrite.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdio/gets.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdio/printf.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdio/sprintf.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdio/vfprintf.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdio/vsprintf.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdlib/Makefile.am] +files=src/lib/libc/stdlib/exit.c,src/lib/libc/stdlib/malloc.c, +sub_dirs= +type=normal + +[src/lib/libc/stdlib/exit.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/stdlib/malloc.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/string/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/lib/libc/string/Makefile.am] +files=src/lib/libc/string/memcmp.c,src/lib/libc/string/memcpy.c,src/lib/libc/string/memset.c,src/lib/libc/string/strlen.c,src/lib/libc/string/strtok.c,src/lib/libc/string/Makefile +sub_dirs= +type=static_library + +[src/lib/libc/string/memcmp.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/string/memcpy.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/string/memset.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/string/strlen.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/string/strtok.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/sys/Makefile.am] +files=src/lib/libc/sys/exec.c,src/lib/libc/sys/fork.c,src/lib/libc/sys/getpage.c,src/lib/libc/sys/getpid.c,src/lib/libc/sys/pidstatus.c,src/lib/libc/sys/setuid.c,src/lib/libc/sys/setgid.c,src/lib/libc/sys/getuid.c,src/lib/libc/sys/getgid.c,src/lib/libc/sys/getdrives.c +sub_dirs= +type=static_library + +[src/lib/libc/sys/exec.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/sys/fork.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/sys/getdrives.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/sys/getgid.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/sys/getpage.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/sys/getpid.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/sys/getuid.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/sys/pidstatus.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/sys/setgid.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/libc/sys/setuid.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/lib/ubix/Makefile.am] +files=src/lib/ubix/startup.c, +sub_dirs= +type=normal + +[src/lib/ubix/startup.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/sys/Makefile.am] +files=src/sys/Makefile +sub_dirs=boot,compile,deviceman,drivers,graphics,include,init,kernel,misc,ubixfs,vmm,sys,lib,pci,sde,isa,ld +type=normal + +[src/sys/boot/Makefile.am] +sub_dirs=boot2,btx, +type=normal + +[src/sys/boot/boot2/Makefile.am] +files=src/sys/boot/boot2/boot1.s,src/sys/boot/boot2/boot2.c,src/sys/boot/boot2/lib.h,src/sys/boot/boot2/sio.s,src/sys/boot/boot2/test.c,src/sys/boot/boot2/ubixfs.h, +sub_dirs= +type=normal + +[src/sys/boot/boot2/boot1.s] +dist=true +install=false +install_location= +type=DATA + +[src/sys/boot/boot2/boot2.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/boot/boot2/lib.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/boot/boot2/sio.s] +dist=true +install=false +install_location= +type=DATA + +[src/sys/boot/boot2/test.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/boot/boot2/ubixfs.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/boot/btx/Makefile.am] +sub_dirs=btx,lib,btxldr, +type=normal + +[src/sys/boot/btx/btx/Makefile.am] +files=src/sys/boot/btx/btx/btx.s, +sub_dirs= +type=normal + +[src/sys/boot/btx/btx/btx.s] +dist=true +install=false +install_location= +type=DATA + +[src/sys/boot/btx/btxldr/Makefile.am] +files=src/sys/boot/btx/btxldr/btxldr.s, +sub_dirs= +type=normal + +[src/sys/boot/btx/btxldr/btxldr.s] +dist=true +install=false +install_location= +type=DATA + +[src/sys/boot/btx/lib/Makefile.am] +files=src/sys/boot/btx/lib/btxcsu.s,src/sys/boot/btx/lib/btxsys.s,src/sys/boot/btx/lib/btxv86.h,src/sys/boot/btx/lib/btxv86.s, +sub_dirs= +type=normal + +[src/sys/boot/btx/lib/btxcsu.s] +dist=true +install=false +install_location= +type=DATA + +[src/sys/boot/btx/lib/btxsys.s] +dist=true +install=false +install_location= +type=DATA + +[src/sys/boot/btx/lib/btxv86.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/boot/btx/lib/btxv86.s] +dist=true +install=false +install_location= +type=DATA + +[src/sys/compile/Makefile.am] +files=src/sys/compile/null.c,src/sys/compile/ubix.elf, +sub_dirs= +type=normal + +[src/sys/compile/null.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/compile/ubix.elf] +dist=true +install=false +install_location= +type=DATA + +[src/sys/deviceman/Makefile.am] +files=src/sys/deviceman/bus_resources_portio.c, +sub_dirs= +type=normal + +[src/sys/deviceman/bus_resources_portio.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/drivers/8259.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/drivers/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/sys/drivers/Makefile.am] +files=src/sys/drivers/8259.c,src/sys/drivers/keyboard.c,src/sys/drivers/fdc.c,src/sys/drivers/pci_pio.c,src/sys/drivers/pit.c,src/sys/drivers/video.c,src/sys/drivers/hd.c,src/sys/drivers/drives.c,src/sys/drivers/lnc.c,src/sys/drivers/Makefile +sub_dirs= +type=static_library + +[src/sys/drivers/drives.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/drivers/fdc.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/drivers/hd.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/drivers/keyboard.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/drivers/lnc.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/drivers/pci_pio.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/drivers/pit.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/drivers/video.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/graphics/1.DPF] +dist=true +install=false +install_location= +type=DATA + +[src/sys/graphics/6X6.DPF] +dist=true +install=false +install_location= +type=DATA + +[src/sys/graphics/BLOCK.DPF] +dist=true +install=false +install_location= +type=DATA + +[src/sys/graphics/BOLD.DPF] +dist=true +install=false +install_location= +type=DATA + +[src/sys/graphics/Makefile.am] +files=src/sys/graphics/6X6.DPF,src/sys/graphics/1.DPF,src/sys/graphics/BLOCK.DPF,src/sys/graphics/BOLD.DPF,src/sys/graphics/OLDENG.DPF,src/sys/graphics/PACMAN.DPF,src/sys/graphics/ROM8X8.DPF,src/sys/graphics/main.cpp,src/sys/graphics/objfont.cpp,src/sys/graphics/objfont.h,src/sys/graphics/objgfx,src/sys/graphics/objgfx30.cpp,src/sys/graphics/objgfx30.h,src/sys/graphics/testprog.cpp, +sub_dirs= +type=normal + +[src/sys/graphics/OLDENG.DPF] +dist=true +install=false +install_location= +type=DATA + +[src/sys/graphics/PACMAN.DPF] +dist=true +install=false +install_location= +type=DATA + +[src/sys/graphics/ROM8X8.DPF] +dist=true +install=false +install_location= +type=DATA + +[src/sys/graphics/main.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/graphics/objfont.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/graphics/objfont.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/graphics/objgfx] +dist=true +install=false +install_location= +type=DATA + +[src/sys/graphics/objgfx30.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/graphics/objgfx30.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/graphics/testprog.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/include/Makefile.am] +files=src/sys/include/types.h,src/sys/include/config.h,src/sys/include/math.h,src/sys/include/stdarg.h +sub_dirs=deviceman,drivers,misc,ubixfs,ubixos,version,vmm,lib,sde,pci,ld +type=normal + +[src/sys/include/config.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/deviceman/Makefile.am] +files=src/sys/include/deviceman/device.h,src/sys/include/deviceman/bus.h,src/sys/include/deviceman/bus_resources.h,src/sys/include/deviceman/bus_resources_portio.h,src/sys/include/deviceman/isapnp.h, +sub_dirs= +type=normal + +[src/sys/include/deviceman/bus.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/deviceman/bus_resources.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/deviceman/bus_resources_portio.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/deviceman/device.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/deviceman/isapnp.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/drivers/8259.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/drivers/Makefile.am] +files=src/sys/include/drivers/keyboard.h,src/sys/include/drivers/8259.h,src/sys/include/drivers/fdc.h,src/sys/include/drivers/pci_pio.h,src/sys/include/drivers/video.h,src/sys/include/drivers/hd.h,src/sys/include/drivers/drives.h,src/sys/include/drivers/lnc.h,src/sys/include/drivers/pit.h +sub_dirs= +type=normal + +[src/sys/include/drivers/drives.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/drivers/fdc.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/drivers/hd.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/drivers/keyboard.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/drivers/lnc.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/drivers/pci_pio.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/drivers/pit.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/drivers/video.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ld/Makefile.am] +files=src/sys/include/ld/ld.h +sub_dirs= +type=normal + +[src/sys/include/ld/ld.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/lib/Makefile.am] +files=src/sys/include/lib/string.h,src/sys/include/lib/kmalloc.h,src/sys/include/lib/bioscall.h +sub_dirs= +type=normal + +[src/sys/include/lib/bioscall.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/lib/kmalloc.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/lib/string.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/math.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/misc/Makefile.am] +files=src/sys/include/misc/kernel_string_pool.h,src/sys/include/misc/misc_bit_array.h,src/sys/include/misc/misc_string_conv.h, +sub_dirs= +type=normal + +[src/sys/include/misc/kernel_string_pool.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/misc/misc_bit_array.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/misc/misc_string_conv.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/pci/Makefile.am] +files=src/sys/include/pci/pci.h +sub_dirs= +type=normal + +[src/sys/include/pci/pci.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/sde/Makefile.am] +files=src/sys/include/sde/sde.h +sub_dirs= +type=normal + +[src/sys/include/sde/sde.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/stdarg.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/types.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixfs/Makefile.am] +files=src/sys/include/ubixfs/ubixfs.h,src/sys/include/ubixfs/file.h, +sub_dirs= +type=normal + +[src/sys/include/ubixfs/file.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixfs/ubixfs.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/Makefile.am] +files=src/sys/include/ubixos/a.out.h,src/sys/include/ubixos/bios32.h,src/sys/include/ubixos/dma.h,src/sys/include/ubixos/elf.h,src/sys/include/ubixos/exec.h,src/sys/include/ubixos/fork.h,src/sys/include/ubixos/gdt.h,src/sys/include/ubixos/idlethread.h,src/sys/include/ubixos/idt.h,src/sys/include/ubixos/io.h,src/sys/include/ubixos/kmalloc.h,src/sys/include/ubixos/panic.h,src/sys/include/ubixos/schedule.h,src/sys/include/ubixos/spinlock.h,src/sys/include/ubixos/syscall.h,src/sys/include/ubixos/syscalls.h,src/sys/include/ubixos/types.h,src/sys/include/ubixos/vitals.h,src/sys/include/ubixos/mount.h,src/sys/include/ubixos/fs.h,src/sys/include/ubixos/file.h,src/sys/include/ubixos/kpanic.h,src/sys/include/ubixos/libcpp.h,src/sys/include/ubixos/message.h,src/sys/include/ubixos/version.h,src/sys/include/ubixos/syserr.h +sub_dirs= +type=normal + +[src/sys/include/ubixos/a.out.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/bios32.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/dma.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/elf.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/exec.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/file.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/fork.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/fs.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/gdt.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/idlethread.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/idt.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/io.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/kmalloc.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/kpanic.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/libcpp.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/message.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/mount.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/panic.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/schedule.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/spinlock.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/syscall.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/syscalls.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/syserr.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/types.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/version.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/vitals.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/version/Makefile.am] +files=src/sys/include/version/version.h, +sub_dirs= +type=normal + +[src/sys/include/version/version.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/vmm/Makefile.am] +files=src/sys/include/vmm/memory.h,src/sys/include/vmm/paging.h, +sub_dirs= +type=normal + +[src/sys/include/vmm/memory.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/vmm/paging.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/init/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/sys/init/Makefile.am] +files=src/sys/init/main.c,src/sys/init/Makefile +sub_dirs= +type=normal + +[src/sys/init/main.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/isa/8259.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/isa/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/sys/isa/Makefile.am] +files=src/sys/isa/8259.c,src/sys/isa/atkbd.c,src/sys/isa/Makefile,src/sys/isa/fdc.c,src/sys/isa/pit.c +sharedlib_LDFLAGS=-version-info 0:0:0 +sharedlib_rootname=isa +sub_dirs= +type=static_library + +[src/sys/isa/atkbd.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/isa/fdc.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/isa/pit.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/sys/kernel/Makefile.am] +files=src/sys/kernel/bios32.c,src/sys/kernel/dma.c,src/sys/kernel/exec.c,src/sys/kernel/fork.c,src/sys/kernel/idlethread.c,src/sys/kernel/idt.c,src/sys/kernel/io.c,src/sys/kernel/kmalloc.c,src/sys/kernel/kprintf.c,src/sys/kernel/panic.c,src/sys/kernel/schedule.c,src/sys/kernel/spinlock.c,src/sys/kernel/syscall.c,src/sys/kernel/version.c,src/sys/kernel/vitals.c,src/sys/kernel/vsprintf.c,src/sys/kernel/kpanic.c,src/sys/kernel/Makefile,src/sys/kernel/mount.c,src/sys/kernel/fs.c,src/sys/kernel/file.c,src/sys/kernel/bioscall.c,src/sys/kernel/message.cc,src/sys/kernel/schedule.cc,src/sys/kernel/endtask.c,src/sys/kernel/syserr.c,src/sys/kernel/elf.c +sub_dirs= +type=static_library + +[src/sys/kernel/bios32.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/bioscall.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/dma.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/elf.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/endtask.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/exec.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/file.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/fork.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/fs.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/idlethread.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/idt.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/io.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/kmalloc.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/kpanic.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/kprintf.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/message.cc] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/mount.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/panic.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/schedule.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/schedule.cc] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/spinlock.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/syscall.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/syserr.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/version.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/vitals.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/kernel/vsprintf.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/ld/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/sys/ld/Makefile.am] +files=src/sys/ld/Makefile,src/sys/ld/ld.c,src/sys/ld/loadlibrary.c +sub_dirs= +type=static_library + +[src/sys/ld/ld.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/ld/loadlibrary.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/lib/Makefile.am] +files=src/sys/lib/string.c,src/sys/lib/strtok.c +sharedlib_LDFLAGS=-version-info 0:0:0 +sharedlib_rootname=lib +sub_dirs= +type=static_library + +[src/sys/lib/string.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/lib/strtok.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/misc/Makefile.am] +files=src/sys/misc/kernel_string_pool.c,src/sys/misc/misc_bit_array.c,src/sys/misc/misc_string_conv.c, +sub_dirs= +type=normal + +[src/sys/misc/kernel_string_pool.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/misc/misc_bit_array.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/misc/misc_string_conv.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/pci/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/sys/pci/Makefile.am] +files=src/sys/pci/hd.c,src/sys/pci/lnc.c,src/sys/pci/Makefile,src/sys/pci/pci.c +sharedlib_LDFLAGS=-version-info 0:0:0 +sharedlib_rootname=pci +sub_dirs= +type=static_library + +[src/sys/pci/hd.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/pci/lnc.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/pci/pci.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/sde/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/sys/sde/Makefile.am] +files=src/sys/sde/main.c,src/sys/sde/sde.cc,src/sys/sde/Makefile,src/sys/sde/ogDisplay_UbixOS.cc,src/sys/sde/main.cc +sharedlib_LDFLAGS=-version-info 0:0:0 +sharedlib_rootname=sde +sub_dirs= +type=static_library + +[src/sys/sde/main.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/sde/main.cc] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/sde/ogDisplay_UbixOS.cc] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/sde/sde.cc] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/sys/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/sys/sys/Makefile.am] +files=src/sys/sys/dma.c,src/sys/sys/drives.c,src/sys/sys/idt.c,src/sys/sys/io.c,src/sys/sys/Makefile,src/sys/sys/video.c +sharedlib_LDFLAGS=-version-info 0:0:0 +sharedlib_rootname=sys +sub_dirs= +type=static_library + +[src/sys/sys/dma.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/sys/drives.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/sys/idt.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/sys/io.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/sys/video.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/ubixfs/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/sys/ubixfs/Makefile.am] +files=src/sys/ubixfs/file.c,src/sys/ubixfs/ubixfs.c,src/sys/ubixfs/Makefile +sub_dirs= +type=normal + +[src/sys/ubixfs/file.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/ubixfs/ubixfs.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/sys/vmm/Makefile.am] +files=src/sys/vmm/memory.c,src/sys/vmm/paging.c,src/sys/vmm/Makefile,src/sys/vmm/clearvirtualpage.c,src/sys/vmm/doublefault.c,src/sys/vmm/getphysicaladdr.c,src/sys/vmm/freepage.c,src/sys/vmm/unmappage.c,src/sys/vmm/createvirtualspace.c,src/sys/vmm/copyvirtualspace.c,src/sys/vmm/setpageattributes.c,src/sys/vmm/getfreevirtualpage.c,src/sys/vmm/getfreekernelpage.c,src/sys/vmm/remappage.c,src/sys/vmm/getfreepage.c,src/sys/vmm/pagefault.c +sub_dirs= +type=static_library + +[src/sys/vmm/clearvirtualpage.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/copyvirtualspace.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/createvirtualspace.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/doublefault.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/freepage.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/getfreekernelpage.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/getfreepage.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/getfreevirtualpage.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/getphysicaladdr.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/memory.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/pagefault.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/paging.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/remappage.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/setpageattributes.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/sys/vmm/unmappage.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/tools/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/tools/Makefile.am] +files=src/tools/format,src/tools/format.c,src/tools/ubixfs.h,src/tools/userdb,src/tools/Makefile,src/tools/OLDENG.DPF,src/tools/PACMAN.DPF,src/tools/ROM8X14.DPF +sub_dirs= +type=normal + +[src/tools/OLDENG.DPF] +dist=true +install=false +install_location= +type=DATA + +[src/tools/PACMAN.DPF] +dist=true +install=false +install_location= +type=DATA + +[src/tools/ROM8X14.DPF] +dist=true +install=false +install_location= +type=DATA + +[src/tools/format] +dist=true +install=false +install_location= +type=DATA + +[src/tools/format.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/tools/ubixfs.h] +dist=true +install=false +install_location= +type=HEADER + +[src/tools/userdb] +dist=true +install=false +install_location= +type=DATA diff --git a/lockwasher/lockwasher.kdevses b/lockwasher/lockwasher.kdevses new file mode 100644 index 0000000..1c293a9 --- /dev/null +++ b/lockwasher/lockwasher.kdevses @@ -0,0 +1,7 @@ + + + + (Default) + + + diff --git a/lockwasher/snapshot.txt b/lockwasher/snapshot.txt new file mode 100644 index 0000000..1729d34 --- /dev/null +++ b/lockwasher/snapshot.txt @@ -0,0 +1,25 @@ +Free Pages: [3505] +Initializing System. +Starting Login Daemon. + +UbixOS/IA-32 (devel.ubixos.com) (console) + +Login: root +Password: **** +Welcome to UbixOS +This is an experimental kernel so it WILL crash and when +it does please send us some info so we can fix it or +if you have access to the source fix it and commit the +changes. + +All reports can be sent to chris@domainatlantic.com + +� +UbixOS: pwd@sys +[0x8049354][0x804823A] +[0x8049358][0x804824A] +[0x804935C][0x804825A] +memAddr: [0x8048264] +[][0x0][printf][0x34][_DYNAMIC][0x9][__bss_start][0x42][getcwd][0x2D][_edata][0x +3B][_GLOBAL_OFFSET_TABLE_][0x12][_end][0x4E][exit][0x28]Need To Code This +UbixOS: diff --git a/lockwasher/src/bin/Makefile b/lockwasher/src/bin/Makefile new file mode 100644 index 0000000..da183ee --- /dev/null +++ b/lockwasher/src/bin/Makefile @@ -0,0 +1,50 @@ +# $Id: Makefile,v 1.4 2003/04/27 00:45:15 reddawg Exp $ +# The System Makefile (C) 2002 The UbixOS Project + +all: init-bin login-bin shell-bin test-bin ls-bin pwd-bin cat-bin ld-dyn-bin de-bin muffin-bin goofball-bin + +init-bin: init + (cd init;make) + +login-bin: login + (cd login;make) + +shell-bin: shell + (cd shell;make) + +test-bin: test + (cd test;make) + +ls-bin: ls + (cd ls;make) + +pwd-bin: pwd + (cd pwd;make) + +cat-bin: cat + (cd cat;make) + +ld-dyn-bin: ld-dyn + (cd ld-dyn;make) + +de-bin: de + (cd de;make) + +muffin-bin: muffin + (cd muffin;make) + +goofball-bin: goofball + (cd goofball;make) + +clean: + (cd init;make clean) + (cd shell;make clean) + (cd test;make clean) + (cd ls;make clean) + (cd pwd;make clean) + (cd login;make clean) + (cd cat;make clean) + (cd ld-dyn;make clean) + (cd de;make clean) + (cd muffin;make clean) + (cd goofball;make clean) diff --git a/lockwasher/src/bin/cat/Makefile b/lockwasher/src/bin/cat/Makefile new file mode 100644 index 0000000..bfcb411 --- /dev/null +++ b/lockwasher/src/bin/cat/Makefile @@ -0,0 +1,53 @@ +# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:57 reddawg Exp $ +# Application Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Compiler Flags +CFLAGS = -I../../lib/libc/include -fno-builtin + +#Linker +LD = ld + +#Binary File Name +BINARY = cat + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +#Libraries +LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o ../../lib/libc/generic/*.o + +#Startup File +STARTUP = ../../lib/ubix/startup.o + +# Link The Binary +$(BINARY) : $(OBJS) +# $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + ld -o $@ $(STARTUP) ../../lib/libc/libc.so $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.c.o: + $(GCC) -Wall -O $(CFLAGS) -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/lockwasher/src/bin/cat/main.c b/lockwasher/src/bin/cat/main.c new file mode 100644 index 0000000..8bf7637 --- /dev/null +++ b/lockwasher/src/bin/cat/main.c @@ -0,0 +1,40 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: main.c,v 1.1.1.1 2003/01/12 00:19:57 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include + +int main(int argc,char **argv) { + int i = 0x0; + FILE *fd; + fd = fopen("userdb","r"); + for (i=0;i +#include +#include + +#define MAXPARTITIONS 4 + + +struct partStruct { + char active; + char startHd; + char startSec; + char startCyl; + char pType; + char endHd; + char endSec; + char endCyl; + long startLba; + long size; + }; + + +struct mbrStruct { + char code[446]; + struct partStruct *parts; + char sig[2]; + }; + +struct driveInfo { + char hdSector[512]; + char hdEnable; + char hdDev; + char hdFlags; + char hdShift; + long hdMask; + long hdMulti; + long hdPort; + long hdSize; + long hdCalc; + }; + +struct driveDiskLabel { + uInt32 magicNum; + uInt32 magicNum2; + uInt16 driveType; + uInt16 numPartitions; + struct drivePartitions { //the partition table + uInt32 pSize; //number of sectors in partition + uInt32 pOffset; //starting sector + uInt32 pFsSize; //filesystem basic fragment size + uInt32 pBatSize; //BAT size + uInt8 pFsType; //filesystem type, see below + uInt8 pFrag; //filesystem fragments per block + } partitions[MAXPARTITIONS]; + }; + +struct driveDriver { + struct driveDriver *prev; + struct driveDriver *next; + struct driveDiskLabel *diskLabel; + int id; + struct driveInfo *driveInfoStruct; + char driveType; + void (*read)(void *,long,long,void *); + void (*write)(void *,long,long,void *); + void (*reset)(void *); + }; + +int main(int argc,char **argv) { + int i = 0x0; + char *data = (char *)malloc(512); + char drive[32]; + struct driveDriver *drives = 0x0,*tmpDrives = 0x0; + struct partStruct *parts = (struct partStruct *)malloc(64); + FILE *mbr,*hdDrive; + printf("UbixOS Disk Editor\n(C) 2003 Ubix Corp\n\n"); + drives = getDrives(); + while (1) { + printf("0) Show Disks\n"); + printf("1) Quit\n"); + gets(data); + switch (data[0]) { + case '0': + printf("Please Choose A Disk\n"); + for (tmpDrives=drives;tmpDrives;tmpDrives=tmpDrives->next) { + printf("[%i][0x%X][%i]\n",tmpDrives->id,tmpDrives->driveType,((tmpDrives->driveInfoStruct->hdSize*512)/1024)); + } + gets(data); + sprintf(drive,"drive%c@devfs",data[0]); + driveOpts: + printf("0) Install MBR\n"); + printf("1) Show Partitions\n"); + printf("3) Delete Partition\n"); + printf("4) Add Partition\n"); + gets(data); + switch (data[0]) { + case '0': + printf("Installing MBR\n"); + mbr = fopen("mbr.img@sys","rb"); + printf("[%s]\n",drive); + hdDrive = fopen(drive,"rb"); + printf("[0x%X]\n",hdDrive); + fread(data,512,1,mbr); + fwrite(data,512,1,hdDrive); + fclose(mbr); + fclose(hdDrive); + break; + case '1': + hdDrive = fopen(drive,"rb"); + printf("Going To Seek\n"); + fseek(hdDrive,446,0); + printf("Done Seeking\n"); + fread(parts,64,1,hdDrive); + for (i=0;i<4;i++) { + printf("Active Type Start C/H/S End C/H/S Start LBA Size\n"); + printf("%i 0x%X %i/%i/%i %i/%i/%i 0x%X 0x%X\n",parts->active,(uInt8)parts->pType,parts->startCyl,parts->startHd,parts->startSec,parts->endCyl,parts->endHd,parts->endSec,parts->startLba,parts->size); + parts++; + } + fclose(hdDrive); + break; + default: + printf("Invalid Option\n"); + goto driveOpts; + break; + } + break; + case '1': + return(0); + break; + default: + break; + } + } + return(0); + } diff --git a/lockwasher/src/bin/goofball/Makefile b/lockwasher/src/bin/goofball/Makefile new file mode 100644 index 0000000..bd14fba --- /dev/null +++ b/lockwasher/src/bin/goofball/Makefile @@ -0,0 +1,52 @@ +# $Id: Makefile,v 1.1 2003/04/27 00:45:15 reddawg Exp $ +# Application Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Compiler Flags +CFLAGS = -I../../lib/libc/include -fno-builtin + +#Linker +LD = ld + +#Binary File Name +BINARY = goofball + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +#Libraries +LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o ../../lib/libc/generic/*.o + +#Startup File +STARTUP = ../../lib/ubix/startup.o + +# Link The Binary +$(BINARY) : $(OBJS) + $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.c.o: + $(GCC) -Wall -O $(CFLAGS) -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/lockwasher/src/bin/goofball/main.c b/lockwasher/src/bin/goofball/main.c new file mode 100644 index 0000000..92a7e91 --- /dev/null +++ b/lockwasher/src/bin/goofball/main.c @@ -0,0 +1,34 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: main.c,v 1.1 2003/04/27 12:37:25 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include + +int main() { + printf("Goofy Ball\n"); + while (1) { + printf("GoofBall: [0x%X]\n",getpid()); + } + return(0); + } diff --git a/lockwasher/src/bin/init/Makefile b/lockwasher/src/bin/init/Makefile new file mode 100644 index 0000000..e0cad8a --- /dev/null +++ b/lockwasher/src/bin/init/Makefile @@ -0,0 +1,52 @@ +# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:57 reddawg Exp $ +# Application Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Compiler Flags +CFLAGS = -I../../lib/libc/include -fno-builtin + +#Linker +LD = ld + +#Binary File Name +BINARY = init + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +#Libraries +LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o + +#Startup File +STARTUP = ../../lib/ubix/startup.o + +# Link The Binary +$(BINARY) : $(OBJS) + $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.c.o: + $(GCC) -Wall -O $(CFLAGS) -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o ${CFLAGS} $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/lockwasher/src/bin/init/main.c b/lockwasher/src/bin/init/main.c new file mode 100644 index 0000000..161bd47 --- /dev/null +++ b/lockwasher/src/bin/init/main.c @@ -0,0 +1,57 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: main.c,v 1.11 2003/04/24 05:16:28 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include + +int main(int argc,char **argv) { + int i=0; + if (getpid() != 1) { + printf("Sorry This Program Must Be Started By The Kernel!!!!\n"); + exit(1); + } + if ((getuid() != 0) && (getgid() != 0)) { + printf("Sorry The System Must Start This As Root.\n"); + exit(1); + } + printf("Initializing System.\n"); + startup: + i = fork(); + if (0 == i) { + printf("Starting Login Daemon.\n"); + exec("login@sys",0x0,0x0); + printf("Error Starting System\n"); + exit(0); + } + else { + while (pidStatus(i)) { + sched_yield(); + //asm("nop"); + } + goto startup; + } + return(0); + } diff --git a/lockwasher/src/bin/ld-dyn/Makefile b/lockwasher/src/bin/ld-dyn/Makefile new file mode 100644 index 0000000..163656c --- /dev/null +++ b/lockwasher/src/bin/ld-dyn/Makefile @@ -0,0 +1,52 @@ +# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:59 reddawg Exp $ +# Application Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Compiler Flags +CFLAGS = -I../../lib/libc/include -fno-builtin + +#Linker +LD = ld + +#Binary File Name +BINARY = ld-dyn + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +#Libraries +LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o ../../lib/libc/generic/*.o + +#Startup File +STARTUP = ../../lib/ubix/startup.o + +# Link The Binary +$(BINARY) : $(OBJS) + $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.c.o: + $(GCC) -Wall -O $(CFLAGS) -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/lockwasher/src/bin/ld-dyn/main.c b/lockwasher/src/bin/ld-dyn/main.c new file mode 100644 index 0000000..1fe24c2 --- /dev/null +++ b/lockwasher/src/bin/ld-dyn/main.c @@ -0,0 +1,38 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: main.c,v 1.1.1.1 2003/01/12 00:19:59 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +//#include "../../sys/include/ubixos/elf.h" + +int main(int argc,char **argv) { + /* + elfHeader *eHeader = 0x0; + elfProgramheader *ePheader = 0x0; + elfSectionheader *eSheader = 0x0; + elfPltInfo *pltInfo = 0x0; + elfDynsym *dynSym = 0x0; + */ + return(0); + } diff --git a/lockwasher/src/bin/login/Makefile b/lockwasher/src/bin/login/Makefile new file mode 100644 index 0000000..c2be029 --- /dev/null +++ b/lockwasher/src/bin/login/Makefile @@ -0,0 +1,52 @@ +# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:59 reddawg Exp $ +# Application Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Compiler Flags +CFLAGS = -I../../lib/libc/include -fno-builtin + +#Linker +LD = ld + +#Binary File Name +BINARY = login + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +#Libraries +LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o + +#Startup File +STARTUP = ../../lib/ubix/startup.o + +# Link The Binary +$(BINARY) : $(OBJS) + $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.c.o: + $(GCC) -Wall -O $(CFLAGS) -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/lockwasher/src/bin/login/main.c b/lockwasher/src/bin/login/main.c new file mode 100644 index 0000000..927d208 --- /dev/null +++ b/lockwasher/src/bin/login/main.c @@ -0,0 +1,119 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: main.c,v 1.19 2003/04/24 05:16:28 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include + +struct passwd { + char username[32]; + char password[32]; + int uid; + int gid; + char shell[128]; + char realname[256]; + }; + +static char *pgets(char *string) { + int count=0,ch=0; + while (1) { + ch = fgetc(stdin); + if(ch == 10) { + printf("\n"); + break; + } + else if(ch == 8 && count > 0) count-=2; + else if(ch == 0) count--; + else string[count] = ch; + if (ch != 8) printf("*"); + count ++; + } + string[count] = '\0'; + return(string); + } + +int main() { + FILE *fd; + int shellPid = 0,i = 0x0; + char userName[32]; + char passWord[32]; + char *data2 = 0x0; + struct passwd *data = 0x0; + if ((getuid() != 0) && (getgid() != 0)) { + printf("This Application Must Be Run As Root.\n"); + exit(1); + } + data = (struct passwd *)malloc(4096); + if (!(fd = fopen("userdb@sys","r"))) { + printf("Error Opening File"); + memcpy(data[0].username,"root",4); + memcpy(data[0].password,"user",4); + memcpy(data[0].shell,"shell@sys", 10); + } + else { + fread(data,4096,1,fd); + fclose(fd); + } + data2 = (char *)malloc(256); + printf("\nUbixOS/IA-32 (devel.ubixos.com) (console)\n\n"); + login: + printf("Login: "); + gets((char *)&userName); + printf("Password: "); + pgets((char *)&passWord); + for (i=0x0;i<(4096/sizeof(struct passwd));i++) { + if (0x0 == memcmp(userName,data[i].username,4)) { + if (0x0 == memcmp(passWord,data[i].password,4)) { + shellPid = fork(); + if (!shellPid) { + if (setuid(data[i].uid) != 0x0) { + printf("Set UID Failed\n"); + } + if (setgid(data[i].gid) != 0x0) { + printf("Set GID Failed\n"); + } + if ((fd = fopen("motd@sys","r")) == 0x0) { + printf("No MOTD"); + } + else { + fread(data2,256,1,fd); + printf("%s\n",data2); + } + fclose(fd); + exec(data[i].shell,0x0,0x0); + } + else { + while (pidStatus(shellPid)) sched_yield(); + goto login; + } + } + } + } + printf("Login Incorrect!\n"); + goto login; + exit(1); + } + diff --git a/lockwasher/src/bin/ls/Makefile b/lockwasher/src/bin/ls/Makefile new file mode 100644 index 0000000..ab9a7ce --- /dev/null +++ b/lockwasher/src/bin/ls/Makefile @@ -0,0 +1,52 @@ +# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:57 reddawg Exp $ +# Application Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Compiler Flags +CFLAGS = -I../../lib/libc/include -fno-builtin + +#Linker +LD = ld + +#Binary File Name +BINARY = ls + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +#Libraries +LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o + +#Startup File +STARTUP = ../../lib/ubix/startup.o + +# Link The Binary +$(BINARY) : $(OBJS) + $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.c.o: + $(GCC) -Wall -O $(CFLAGS) -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/lockwasher/src/bin/ls/main.c b/lockwasher/src/bin/ls/main.c new file mode 100644 index 0000000..50219d5 --- /dev/null +++ b/lockwasher/src/bin/ls/main.c @@ -0,0 +1,103 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: main.c,v 1.4 2003/04/24 05:16:28 reddawg Exp $ + +**************************************************************************************/ + +#include +#include + +#define permRead 0x8 +#define permWrite 0x4 +#define permExecute 0x2 +#define permHidden 0x1 + + +//UbixFS Directory Entry +struct directoryEntry { + uLong startCluster; //Starting Cluster Of File + uLong size; //Size Of File + uLong creationDate; //Date Created + uLong lastModified; //Date Last Modified + uLong uid; //UID Of Owner + uLong gid; //GID Of Owner + uShort attributes; //Files Attributes + uShort permissions; //Files Permissions + char fileName[256]; //File Name + }; + +int main(int argc,char **argv) { + int i = 0x0,x = 0x0,tmpPerms = 0x0; + char *pwd = (char *)malloc(256); + char *permsData = (char *)malloc(13); + FILE *fd; + struct directoryEntry *dirEntry = 0x0; + if (argv[1] == 0x0) { + if ((fd = fopen(":","rb")) == 0x0) { + printf("Error Reading Directory\n"); + exit(1); + } + } + else { + if ((fd = fopen(argv[1],"rb")) == 0x0) { + printf("Error Reading Directory\n"); + exit(1); + } + } + dirEntry = (struct directoryEntry *)malloc(fd->size); + fread(dirEntry,fd->size,1,fd); + if (!fclose(fd)) { + printf("Error Closing Directory\n"); + } + pwd[0] = '/'; + for (i=0;i<(fd->size/sizeof(struct directoryEntry));i++) { + if ((dirEntry[i].fileName[0] > 0) && (dirEntry[i].fileName[0] != ':')) { + for (x=0;x<12;x++) { + permsData[x] = '-'; + } + if (dirEntry[i].attributes == 0x800) { + permsData[0] = 'F'; + } + if (dirEntry[i].attributes == 0x8000) { + permsData[0] = 'D'; + } + tmpPerms = ((dirEntry[i].permissions & 0xF00) >> 8); + if ((tmpPerms & permRead) == permRead) permsData[1] = 'R'; + if ((tmpPerms & permWrite) == permWrite) permsData[2] = 'W'; + if ((tmpPerms & permExecute) == permExecute) permsData[3] = 'E'; + if ((tmpPerms & permHidden) == permHidden) permsData[4] = 'H'; + tmpPerms = ((dirEntry[i].permissions & 0x0F0) >> 4); + if ((tmpPerms & permRead) == permRead) permsData[5] = 'R'; + if ((tmpPerms & permWrite) == permWrite) permsData[6] = 'W'; + if ((tmpPerms & permExecute) == permExecute) permsData[7] = 'E'; + if ((tmpPerms & permHidden) == permHidden) permsData[8] = 'H'; + tmpPerms = ((dirEntry[i].permissions & 0x00F) >> 0); + if ((tmpPerms & permRead) == permRead) permsData[9] = 'R'; + if ((tmpPerms & permWrite) == permWrite) permsData[10] = 'W'; + if ((tmpPerms & permExecute) == permExecute) permsData[11] = 'E'; + if ((tmpPerms & permHidden) == permHidden) permsData[12] = 'H'; + printf("%s %i %i %i %s\n",permsData,(int)dirEntry[i].uid,(int)dirEntry[i].gid,(int)dirEntry[i].size,dirEntry[i].fileName); + } + } + for (i=0;i +#include +#include +extern "C" { +#include +#include +} + +int main() { + bool result; + ogBitFont * font = new ogBitFont(); + vWindow * window = new vWindow(); + printf("[%i]\n",window->vCreate()); + window->ogClear(window->ogRGB(0,0,255)); + if (window->ogGetPixel(0,0) == window->ogRGB(0,0,255)) + printf("ogClear worked\n"); + if (window->ogGetPixel(-1,-1) == window->ogRGB(0,0,255)) + printf("problem with ogRGB!!!!!\n"); + + result = font->load("PACMAN.DPF"); + printf("Font Loaded: [0x%X]\n",(int)result); + font->setFGColor(0,255,0); + font->setBGColor(255,0,0); + + printf("Muffin!\n"); + printf("Command 1\n"); + window->vSDECommand(1); + printf("Command 3\n"); + window->vSDECommand(3); + printf("Load Font\n"); + font->putString(*window,0x0,0x0,"this is a test"); + window->vSDECommand(3); + window->vSDECommand(4); + return(0); + } diff --git a/lockwasher/src/bin/pwd/Makefile b/lockwasher/src/bin/pwd/Makefile new file mode 100644 index 0000000..df6d3b8 --- /dev/null +++ b/lockwasher/src/bin/pwd/Makefile @@ -0,0 +1,53 @@ +# $Id: Makefile,v 1.2 2003/05/04 13:20:15 reddawg Exp $ +# Application Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Compiler Flags +CFLAGS = -I../../lib/libc/include -fno-builtin + +#Linker +LD = ld + +#Binary File Name +BINARY = pwd + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +#Libraries +#LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o ../../lib/libc/generic/*.o +LIBRARIES = ../../lib/libc/libc.so + +#Startup File +STARTUP = ../../lib/ubix/startup.o + +# Link The Binary +$(BINARY) : $(OBJS) + $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.c.o: + $(GCC) -Wall -O $(CFLAGS) -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/lockwasher/src/bin/pwd/main.c b/lockwasher/src/bin/pwd/main.c new file mode 100644 index 0000000..74e24c1 --- /dev/null +++ b/lockwasher/src/bin/pwd/main.c @@ -0,0 +1,32 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: main.c,v 1.2 2003/04/20 12:11:29 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include + +int main() { + char cwd[1024]; + exit(printf("%s\n",getcwd(cwd,1024))); + return(0); + } diff --git a/lockwasher/src/bin/shell/Makefile b/lockwasher/src/bin/shell/Makefile new file mode 100644 index 0000000..a317ea0 --- /dev/null +++ b/lockwasher/src/bin/shell/Makefile @@ -0,0 +1,52 @@ +# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:58 reddawg Exp $ +# Application Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Compiler Flags +CFLAGS = -I../../lib/libc/include -fno-builtin + +#Linker +LD = ld + +#Binary File Name +BINARY = shell + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o error.o commands.o exec.o input.o + +#Libraries +LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o + +#Startup File +STARTUP = ../../lib/ubix/startup.o + +# Link The Binary +$(BINARY) : $(OBJS) + $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.c.o: + $(GCC) -Wall -O $(CFLAGS) -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/lockwasher/src/bin/shell/commands.c b/lockwasher/src/bin/shell/commands.c new file mode 100644 index 0000000..68468ff --- /dev/null +++ b/lockwasher/src/bin/shell/commands.c @@ -0,0 +1,72 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: commands.c,v 1.4 2003/05/11 23:37:07 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include "shell.h" + +int commands(inputBuffer *data) { + int cPid = 0x0,i = 0x0; + if (0 == memcmp(data->args->arg, "uname", 5)) { + printf("UbixOS v0.87 " __DATE__" " __TIME__ " \n"); + return(1); + } + else if (0 == memcmp(data->args->arg, "exit", 4)) { + exit(1); + } + else if (0 == memcmp(data->args->arg, "mypid", 5)) { + printf("My Pid: [%i]\n",getpid()); + return(1); + } + else if (memcmp(data->args->arg,"stress", 6) == 0) { + while (1) { + cPid = fork(); + printf("Pid: [%i]\n",cPid); + if (!cPid) { + exec("test",data->argc,data->argv); + exit(1); + } + else { + while (pidStatus(cPid)); + } + + } + } + else if (memcmp(data->args->arg,"echo",4) == 0) { + for (i=1;iargc;i++) { + printf("%s ",data->argv[i]); + } + printf("\n"); + } + else if (memcmp(data->args->arg,"about",5) == 0) { + printf("UbixOS Shell v0.99 (C) 2002\n"); + printf("Base Command Line Interface\n"); + } + else { + return(0); + } + return(1); + } diff --git a/lockwasher/src/bin/shell/error.c b/lockwasher/src/bin/shell/error.c new file mode 100644 index 0000000..1a1355c --- /dev/null +++ b/lockwasher/src/bin/shell/error.c @@ -0,0 +1,30 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: error.c,v 1.1.1.1 2003/01/12 00:19:58 reddawg Exp $ + +**************************************************************************************/ + +#include +#include + +void error(int errorCode,char *errorMsg) { + printf("ERROR: #%i Message: %s\n", errorCode, errorMsg); + exit(errorCode); + } diff --git a/lockwasher/src/bin/shell/exec.c b/lockwasher/src/bin/shell/exec.c new file mode 100644 index 0000000..b0557aa --- /dev/null +++ b/lockwasher/src/bin/shell/exec.c @@ -0,0 +1,47 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: exec.c,v 1.4 2003/04/23 21:42:34 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include "shell.h" + +void sched_yield(); + +void execProgram(inputBuffer *data) { + int cPid = 0x0; + cPid = fork(); + if (!cPid) { + if (exec(data->argv[0],data->argc,data->argv) == 0) { + printf("%s: Command Not Found.\n",data->argv[0]); + } + exit(1); + } + else { + if (data->bg == 0x0) { + while (pidStatus(cPid)) + sched_yield(); + } + } + } diff --git a/lockwasher/src/bin/shell/input.c b/lockwasher/src/bin/shell/input.c new file mode 100644 index 0000000..53568a0 --- /dev/null +++ b/lockwasher/src/bin/shell/input.c @@ -0,0 +1,58 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: input.c,v 1.3 2003/04/23 21:42:34 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include "shell.h" + +void parseInput(inputBuffer *buffer,char *data) { + int i = 0x0; + struct argsStruct *tmpArgs = 0x0; + + while (data[0] == ' ') { + data++; + } + buffer->args = (struct argsStruct *)malloc(sizeof(struct argsStruct)); + tmpArgs = buffer->args; + while(data != 0x0) { + tmpArgs->arg = strtok(data," "); + data = strtok(NULL,"\n"); + if (tmpArgs->arg[0] == '&') { + buffer->bg = 0x1; + } + else { + buffer->argc++; + if (data != 0x0) { + tmpArgs->next = (struct argsStruct *)malloc(sizeof(struct argsStruct)); + } + tmpArgs = tmpArgs->next; + } + } + buffer->argv = (char *)malloc(4*buffer->argc); + tmpArgs = buffer->args; + for (i=0;iargc;i++) { + buffer->argv[i] = tmpArgs->arg; + tmpArgs = tmpArgs->next; + } + } diff --git a/lockwasher/src/bin/shell/main.c b/lockwasher/src/bin/shell/main.c new file mode 100644 index 0000000..4afec69 --- /dev/null +++ b/lockwasher/src/bin/shell/main.c @@ -0,0 +1,47 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: main.c,v 1.2 2003/04/23 21:42:34 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include "shell.h" + +int main() { + unsigned char buffer[256],*data; + inputBuffer *inBuf = (inputBuffer *)malloc(sizeof(inputBuffer)); + while (1) { + printf("UbixOS: "); + gets((char *)&buffer); + data = (uChar *)&buffer; + parseInput(inBuf,data); + if (inBuf->args->arg != 0x0) { + if (!commands(inBuf)) execProgram(inBuf); + } + inBuf->argc = 0x0; + inBuf->args = 0x0; + inBuf->bg = 0x0; + } + exit(0); + } diff --git a/lockwasher/src/bin/shell/shell.h b/lockwasher/src/bin/shell/shell.h new file mode 100644 index 0000000..c07a0e8 --- /dev/null +++ b/lockwasher/src/bin/shell/shell.h @@ -0,0 +1,17 @@ +#include + +struct argsStruct { + struct argsStruct *next; + char *arg; + }; + +typedef struct { + int argc; + char **argv; + uInt8 bg; + struct argsStruct *args; + } inputBuffer; + +void parseInput(inputBuffer *,char *); +int commands(inputBuffer *); +void execProgram(inputBuffer *); diff --git a/lockwasher/src/bin/test/Makefile b/lockwasher/src/bin/test/Makefile new file mode 100644 index 0000000..3eb6538 --- /dev/null +++ b/lockwasher/src/bin/test/Makefile @@ -0,0 +1,52 @@ +# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:58 reddawg Exp $ +# Application Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Compiler Flags +CFLAGS = -I../../lib/libc/include -fno-builtin + +#Linker +LD = ld + +#Binary File Name +BINARY = test + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +#Libraries +LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o + +#Startup File +STARTUP = ../../lib/ubix/startup.o + +# Link The Binary +$(BINARY) : $(OBJS) + $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.c.o: + $(GCC) -Wall -O $(CFLAGS) -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/lockwasher/src/bin/test/main.c b/lockwasher/src/bin/test/main.c new file mode 100644 index 0000000..e3f404f --- /dev/null +++ b/lockwasher/src/bin/test/main.c @@ -0,0 +1,55 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: main.c,v 1.12 2003/05/11 23:37:07 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include + +void sched_yield(); + +int main() { + int i = 0,x = 0,cPid = 0; + printf("This Is A Test Program\n"); + printf("My PID Is : [%i]\n",getpid()); + printf("I'm Now Going To Fork Myself And See If This Causes A Memory Leak\n"); + for (i=0;i<=100;i++) { + cPid = fork(); + if (!cPid) { + printf("Child Pid: [%i]\n",getpid()); + for (x=0;x<=5;x++) { + printf("[%i]",x); + } + printf("\n"); + while (malloc(4096*100000) != 0x0); + exit(1); + } + else { + printf("Parent Pid: [%i]\n",getpid()); + while (pidStatus(cPid)) sched_yield(); + } + } + printf("Testing Complete\n"); + exit(0); //OK HERE IS THE BUG MUST CHECK STACK POINTERS + return(0); + } diff --git a/lockwasher/src/lib/libc/Makefile b/lockwasher/src/lib/libc/Makefile new file mode 100644 index 0000000..f1a591d --- /dev/null +++ b/lockwasher/src/lib/libc/Makefile @@ -0,0 +1,61 @@ +# $Id: Makefile,v 1.6 2003/05/04 13:20:15 reddawg Exp $ +# The System Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Linker +LD = ld -Bshareable +AR = ar + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = + +#Sub Sections +SUBS = ./stdio/*.o ./sys/*.o ./string/*.o ./stdlib/*.o ./math/*.o ./quad/*.o ./generic/*.o + +#Output +OUTPUT = libc.so + +lib.so: $(OBJS) + (cd stdio;make) + (cd stdlib;make) + (cd math;make) + (cd quad;make) + (cd sys;make) + (cd string;make) + (cd generic;make) +# $(LD) -o $(OUTPUT) $(OBJS) ./stdio/*.o ./sys/*.o ./string/*.o ./stdlib/*.o + $(GCC) -nostdlib -shared -Wl,-soname,libc.so -o $(OUTPUT) $(OBJS) $(SUBS) + +# Compile the source files +.cc.o: + $(G++) -Wall -nostdinc -O -I./include -c -o $@ $< + +.cc.s: + $(G++) -Wall -nostdinc -O -I./include -S -o $@ $< + +.c.o: + $(GCC) -Wall -nostdinc -O -I./include -c $< + +.c.s: + $(GCC) -Wall -nostdinc -O -I./include -S -o $@ $< + +.S.o: + $(GCC) -Wall -nostdinc -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(OUTPUT) + (cd stdio;make clean) + (cd sys;make clean) + (cd stdlib;make clean) + (cd generic;make clean) + (cd string;make clean) + (cd math;make clean) + (cd quad;make clean) diff --git a/lockwasher/src/lib/libc/generic/Makefile b/lockwasher/src/lib/libc/generic/Makefile new file mode 100644 index 0000000..f86df45 --- /dev/null +++ b/lockwasher/src/lib/libc/generic/Makefile @@ -0,0 +1,42 @@ +# $Id: Makefile,v 1.2 2003/03/13 02:02:33 apwillia Exp $ +# The System Makefile (C) 2002 The UbixOS Project + +CFLAGS = -fno-builtin + +#Compiler +GCC = gcc +G++ = gcc + +#Linker +LD = ld -Bshareable +AR = ar + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = getcwd.o +#Output +OUTPUT = libc.so + +$(OUTPUT): $(OBJS) + +# Compile the source files +.cc.o: + $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -c -o $@ $< + +.cc.s: + $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $< + +.c.o: + $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -c $< + +.c.s: + $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $< + +.S.o: + $(GCC) $(CFLAGS) -Wall -nostdlib -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(OUTPUT) diff --git a/lockwasher/src/lib/libc/generic/getcwd.c b/lockwasher/src/lib/libc/generic/getcwd.c new file mode 100644 index 0000000..599b7e1 --- /dev/null +++ b/lockwasher/src/lib/libc/generic/getcwd.c @@ -0,0 +1,30 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: getcwd.c,v 1.2 2003/04/20 12:11:30 reddawg Exp $ + +**************************************************************************************/ + +char *getcwd(char *cwd) { + asm( + "int %0\n" + : : "i" (0x80),"a" (26),"b" (cwd) + ); + return(cwd); + } \ No newline at end of file diff --git a/lockwasher/src/lib/libc/include/math.h b/lockwasher/src/lib/libc/include/math.h new file mode 100644 index 0000000..2435391 --- /dev/null +++ b/lockwasher/src/lib/libc/include/math.h @@ -0,0 +1,2 @@ +double sqrt(double val); +double atan(double val); diff --git a/lockwasher/src/lib/libc/include/quad.h b/lockwasher/src/lib/libc/include/quad.h new file mode 100644 index 0000000..4f65864 --- /dev/null +++ b/lockwasher/src/lib/libc/include/quad.h @@ -0,0 +1,4 @@ +#include + +quad_t __divdi3(quad_t a,quad_t b); +u_quad_t __udivdi3(u_quad_t a,u_quad_t b); diff --git a/lockwasher/src/lib/libc/include/stdarg.h b/lockwasher/src/lib/libc/include/stdarg.h new file mode 100644 index 0000000..4d76835 --- /dev/null +++ b/lockwasher/src/lib/libc/include/stdarg.h @@ -0,0 +1,34 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: stdarg.h,v 1.1.1.1 2003/01/12 00:20:01 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _STDARG_H +#define _STDARG_H + +typedef char *vaList; + +#define _vaSize(TYPE) (((sizeof(TYPE) + sizeof(int) -1) / sizeof(int)) * sizeof(int)) +#define vaStart(AP, LASTARG) (AP=((vaList)&(LASTARG) + _vaSize(LASTARG))) +#define vaEnd(AP) +#define vaArg(AP, TYPE) (AP += _vaSize(TYPE), *((TYPE *)(AP - _vaSize(TYPE)))) + +#endif diff --git a/lockwasher/src/lib/libc/include/stdio.h b/lockwasher/src/lib/libc/include/stdio.h new file mode 100644 index 0000000..5dc9ab2 --- /dev/null +++ b/lockwasher/src/lib/libc/include/stdio.h @@ -0,0 +1,65 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: stdio.h,v 1.4 2003/04/24 05:16:28 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _STDIO_H +#define _STDIO_H + +#include +#include + +/* Type Definitions */ + +typedef struct fileDescriptor { + uLong fd; + uInt32 size; + } FILE; + +/* Definitions */ + +extern FILE fdTable[]; + +#define stdin (&fdTable[0]) +#define stdout (&fdTable[1]) +#define stderr (&fdTable[2]) + +#define SEEK_SET 0 + +/* Functions Definitions */ + +int fprintf(FILE *, const char *,...); +int printf(const char *,...); +int vfprintf(FILE *,const char *,vaList args); +int vsprintf(char *buf,const char *fmt,vaList args); +FILE *fopen(const char *,const char *); +int fwrite(const void *ptr,int size,int nmemb,FILE *fd); +int fgetc(FILE *fd); + +//New Functions Listed From Here On Till I'm Done Writing A libc +int sprintf(char *string, const char *format, ...); +char *gets(char *string); +size_t fread(void *pointer,size_t size,size_t count, FILE *stream); +int fclose(FILE *fp); +int fseek(FILE *,long offset,int whence); + +#endif + diff --git a/lockwasher/src/lib/libc/include/stdlib.h b/lockwasher/src/lib/libc/include/stdlib.h new file mode 100644 index 0000000..5992cf5 --- /dev/null +++ b/lockwasher/src/lib/libc/include/stdlib.h @@ -0,0 +1,34 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: stdlib.h,v 1.3 2003/04/02 20:27:47 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _STDLIB_H +#define _STDLIB_H + +#include + +void exit(int); +void *malloc(uInt len); +void free(void *); +int abs(int val); + +#endif diff --git a/lockwasher/src/lib/libc/include/string.h b/lockwasher/src/lib/libc/include/string.h new file mode 100644 index 0000000..5e8827d --- /dev/null +++ b/lockwasher/src/lib/libc/include/string.h @@ -0,0 +1,38 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: string.h,v 1.2 2003/04/23 21:42:34 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _STRING_H +#define _STRING_H + +#include + +extern void * memcpy(void *, const void *, size_t); +extern void * memset(void *, int, size_t); +extern int memcmp(const void *, const void *, size_t); + +extern int strlen(const char *); + +char *strtok(char *str, const char *sep); +char *strtok_r(char *str, const char *sep, char **last); + +#endif diff --git a/lockwasher/src/lib/libc/include/sys/sched.h b/lockwasher/src/lib/libc/include/sys/sched.h new file mode 100644 index 0000000..5e85737 --- /dev/null +++ b/lockwasher/src/lib/libc/include/sys/sched.h @@ -0,0 +1,7 @@ +#ifndef _SCHED_H +#define _SCHED_H + +int sched_yield(); + +#endif + diff --git a/lockwasher/src/lib/libc/include/sys/sys.h b/lockwasher/src/lib/libc/include/sys/sys.h new file mode 100644 index 0000000..4f3c0dd --- /dev/null +++ b/lockwasher/src/lib/libc/include/sys/sys.h @@ -0,0 +1,32 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: sys.h,v 1.4 2003/04/23 21:42:34 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _SYS_H +#define _SYS_H + +int exec(char *,int argc,char **argv); +int pidStatus(int pid); +void *getPage(int count); +void *getDrives(); + +#endif diff --git a/lockwasher/src/lib/libc/include/sys/types.h b/lockwasher/src/lib/libc/include/sys/types.h new file mode 100644 index 0000000..7d673ce --- /dev/null +++ b/lockwasher/src/lib/libc/include/sys/types.h @@ -0,0 +1,49 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: types.h,v 1.4 2003/04/02 20:27:47 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _TYPES_H +#define _TYPES_H + +typedef unsigned short uShort; +typedef unsigned long uLong; +typedef unsigned char uChar; +typedef unsigned int uInt; +typedef unsigned long size_t; +typedef int pid_t; + +typedef unsigned char uInt8; +typedef unsigned short uInt16; +typedef unsigned long uInt32; + +typedef long long int quad_t; +typedef unsigned long long int u_quad_t; + +#ifndef NULL +#define NULL 0x0 +#endif + +#ifndef NOBOOL +typedef enum { FALSE=0,TRUE=1 } bool; +#endif + +#endif diff --git a/lockwasher/src/lib/libc/include/unistd.h b/lockwasher/src/lib/libc/include/unistd.h new file mode 100644 index 0000000..19f7c57 --- /dev/null +++ b/lockwasher/src/lib/libc/include/unistd.h @@ -0,0 +1,39 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: unistd.h,v 1.2 2003/03/31 15:23:07 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _UNISTD_H +#define _UNISTD_H + +#include + +uShort getpid(void); +pid_t fork(); + +//New Functions Added Belong Under Here +char *getcwd(char *buffer,uLong size); +int setuid(int); +int setgid(int); +int getuid(void); +int getgid(void); + +#endif diff --git a/lockwasher/src/lib/libc/math/Makefile b/lockwasher/src/lib/libc/math/Makefile new file mode 100644 index 0000000..a6bcb13 --- /dev/null +++ b/lockwasher/src/lib/libc/math/Makefile @@ -0,0 +1,42 @@ +# $Id: Makefile,v 1.1 2003/04/02 20:27:47 reddawg Exp $ +# The System Makefile (C) 2002 The UbixOS Project + +CFLAGS = -fno-builtin + +#Compiler +GCC = gcc +G++ = gcc + +#Linker +LD = ld -Bshareable +AR = ar + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = atan.o sqrt.o +#Output +OUTPUT = libc.so + +$(OUTPUT): $(OBJS) + +# Compile the source files +.cc.o: + $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -c -o $@ $< + +.cc.s: + $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $< + +.c.o: + $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -c $< + +.c.s: + $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $< + +.S.o: + $(GCC) $(CFLAGS) -Wall -nostdlib -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(OUTPUT) diff --git a/lockwasher/src/lib/libc/math/atan.c b/lockwasher/src/lib/libc/math/atan.c new file mode 100644 index 0000000..ee59158 --- /dev/null +++ b/lockwasher/src/lib/libc/math/atan.c @@ -0,0 +1,5 @@ +#include + +double atan(double val) { + return(val); + } diff --git a/lockwasher/src/lib/libc/math/sqrt.c b/lockwasher/src/lib/libc/math/sqrt.c new file mode 100644 index 0000000..581e032 --- /dev/null +++ b/lockwasher/src/lib/libc/math/sqrt.c @@ -0,0 +1,5 @@ +#include + +double sqrt(double val) { + return(val); + } diff --git a/lockwasher/src/lib/libc/quad/Makefile b/lockwasher/src/lib/libc/quad/Makefile new file mode 100644 index 0000000..cdf9ba8 --- /dev/null +++ b/lockwasher/src/lib/libc/quad/Makefile @@ -0,0 +1,42 @@ +# $Id: Makefile,v 1.1 2003/04/02 20:28:25 reddawg Exp $ +# The System Makefile (C) 2002 The UbixOS Project + +CFLAGS = -fno-builtin + +#Compiler +GCC = gcc +G++ = gcc + +#Linker +LD = ld -Bshareable +AR = ar + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = udivdi3.o divdi3.o +#Output +OUTPUT = libc.so + +$(OUTPUT): $(OBJS) + +# Compile the source files +.cc.o: + $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -c -o $@ $< + +.cc.s: + $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $< + +.c.o: + $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -c $< + +.c.s: + $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $< + +.S.o: + $(GCC) $(CFLAGS) -Wall -nostdlib -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(OUTPUT) diff --git a/lockwasher/src/lib/libc/quad/divdi3.c b/lockwasher/src/lib/libc/quad/divdi3.c new file mode 100644 index 0000000..914b0be --- /dev/null +++ b/lockwasher/src/lib/libc/quad/divdi3.c @@ -0,0 +1,17 @@ +#include + +quad_t __divdi3(quad_t a,quad_t b) { + u_quad_t ua = 0x0, ub = 0x0, uq = 0x0; + int neg; + + if (a < 0) + ua = -(u_quad_t)a, neg = 1; + else + ua = a, neg = 0; + if (b < 0) + ub = -(u_quad_t)b, neg ^= 1; + else + ub = b; +// uq = __qdivrem(ua, ub, (u_quad_t *)0); + return (neg ? -uq : uq); +} diff --git a/lockwasher/src/lib/libc/quad/qdivrem.c b/lockwasher/src/lib/libc/quad/qdivrem.c new file mode 100644 index 0000000..0fa5cb8 --- /dev/null +++ b/lockwasher/src/lib/libc/quad/qdivrem.c @@ -0,0 +1,199 @@ +#include + +u_quad_t +__qdivrem(uq, vq, arq) + u_quad_t uq, vq, *arq; +{ + union uu tmp; + digit *u, *v, *q; + register digit v1, v2; + u_long qhat, rhat, t; + int m, n, d, j, i; + digit uspace[5], vspace[5], qspace[5]; + + /* + * Take care of special cases: divide by zero, and u < v. + */ + if (vq == 0) { + /* divide by zero. */ + static volatile const unsigned int zero = 0; + + tmp.ul[H] = tmp.ul[L] = 1 / zero; + if (arq) + *arq = uq; + return (tmp.q); + } + if (uq < vq) { + if (arq) + *arq = uq; + return (0); + } + u = &uspace[0]; + v = &vspace[0]; + q = &qspace[0]; + + /* + * Break dividend and divisor into digits in base B, then + * count leading zeros to determine m and n. When done, we + * will have: + * u = (u[1]u[2]...u[m+n]) sub B + * v = (v[1]v[2]...v[n]) sub B + * v[1] != 0 + * 1 < n <= 4 (if n = 1, we use a different division algorithm) + * m >= 0 (otherwise u < v, which we already checked) + * m + n = 4 + * and thus + * m = 4 - n <= 2 + */ + tmp.uq = uq; + u[0] = 0; + u[1] = HHALF(tmp.ul[H]); + u[2] = LHALF(tmp.ul[H]); + u[3] = HHALF(tmp.ul[L]); + u[4] = LHALF(tmp.ul[L]); + tmp.uq = vq; + v[1] = HHALF(tmp.ul[H]); + v[2] = LHALF(tmp.ul[H]); + v[3] = HHALF(tmp.ul[L]); + v[4] = LHALF(tmp.ul[L]); + for (n = 4; v[1] == 0; v++) { + if (--n == 1) { + u_long rbj; /* r*B+u[j] (not root boy jim) */ + digit q1, q2, q3, q4; + + /* + * Change of plan, per exercise 16. + * r = 0; + * for j = 1..4: + * q[j] = floor((r*B + u[j]) / v), + * r = (r*B + u[j]) % v; + * We unroll this completely here. + */ + t = v[2]; /* nonzero, by definition */ + q1 = u[1] / t; + rbj = COMBINE(u[1] % t, u[2]); + q2 = rbj / t; + rbj = COMBINE(rbj % t, u[3]); + q3 = rbj / t; + rbj = COMBINE(rbj % t, u[4]); + q4 = rbj / t; + if (arq) + *arq = rbj % t; + tmp.ul[H] = COMBINE(q1, q2); + tmp.ul[L] = COMBINE(q3, q4); + return (tmp.q); + } + } + + /* + * By adjusting q once we determine m, we can guarantee that + * there is a complete four-digit quotient at &qspace[1] when + * we finally stop. + */ + for (m = 4 - n; u[1] == 0; u++) + m--; + for (i = 4 - m; --i >= 0;) + q[i] = 0; + q += 4 - m; + + /* + * Here we run Program D, translated from MIX to C and acquiring + * a few minor changes. + * + * D1: choose multiplier 1 << d to ensure v[1] >= B/2. + */ + d = 0; + for (t = v[1]; t < B / 2; t <<= 1) + d++; + if (d > 0) { + shl(&u[0], m + n, d); /* u <<= d */ + shl(&v[1], n - 1, d); /* v <<= d */ + } + /* + * D2: j = 0. + */ + j = 0; + v1 = v[1]; /* for D3 -- note that v[1..n] are constant */ + v2 = v[2]; /* for D3 */ + do { + register digit uj0, uj1, uj2; + + /* + * D3: Calculate qhat (\^q, in TeX notation). + * Let qhat = min((u[j]*B + u[j+1])/v[1], B-1), and + * let rhat = (u[j]*B + u[j+1]) mod v[1]. + * While rhat < B and v[2]*qhat > rhat*B+u[j+2], + * decrement qhat and increase rhat correspondingly. + * Note that if rhat >= B, v[2]*qhat < rhat*B. + */ + uj0 = u[j + 0]; /* for D3 only -- note that u[j+...] change */ + uj1 = u[j + 1]; /* for D3 only */ + uj2 = u[j + 2]; /* for D3 only */ + if (uj0 == v1) { + qhat = B; + rhat = uj1; + goto qhat_too_big; + } else { + u_long n = COMBINE(uj0, uj1); + qhat = n / v1; + rhat = n % v1; + } + while (v2 * qhat > COMBINE(rhat, uj2)) { + qhat_too_big: + qhat--; + if ((rhat += v1) >= B) + break; + } + /* + * D4: Multiply and subtract. + * The variable `t' holds any borrows across the loop. + * We split this up so that we do not require v[0] = 0, + * and to eliminate a final special case. + */ + for (t = 0, i = n; i > 0; i--) { + t = u[i + j] - v[i] * qhat - t; + u[i + j] = LHALF(t); + t = (B - HHALF(t)) & (B - 1); + } + t = u[j] - t; + u[j] = LHALF(t); + /* + * D5: test remainder. + * There is a borrow if and only if HHALF(t) is nonzero; + * in that (rare) case, qhat was too large (by exactly 1). + * Fix it by adding v[1..n] to u[j..j+n]. + */ + if (HHALF(t)) { + qhat--; + for (t = 0, i = n; i > 0; i--) { /* D6: add back. */ + t += u[i + j] + v[i]; + u[i + j] = LHALF(t); + t = HHALF(t); + } + u[j] = LHALF(u[j] + t); + } + q[j] = qhat; + } while (++j <= m); /* D7: loop on j. */ + + /* + * If caller wants the remainder, we have to calculate it as + * u[m..m+n] >> d (this is at most n digits and thus fits in + * u[m+1..m+n], but we may need more source digits). + */ + if (arq) { + if (d) { + for (i = m + n; i > m; --i) + u[i] = (u[i] >> d) | + LHALF(u[i - 1] << (HALF_BITS - d)); + u[i] = 0; + } + tmp.ul[H] = COMBINE(uspace[1], uspace[2]); + tmp.ul[L] = COMBINE(uspace[3], uspace[4]); + *arq = tmp.q; + } + + tmp.ul[H] = COMBINE(qspace[1], qspace[2]); + tmp.ul[L] = COMBINE(qspace[3], qspace[4]); + return (tmp.q); +} + diff --git a/lockwasher/src/lib/libc/quad/udivdi3.c b/lockwasher/src/lib/libc/quad/udivdi3.c new file mode 100644 index 0000000..4c9908d --- /dev/null +++ b/lockwasher/src/lib/libc/quad/udivdi3.c @@ -0,0 +1,7 @@ +#include + +u_quad_t __udivdi3(u_quad_t a,u_quad_t b) { + + //return (__qdivrem(a, b, (u_quad_t *)0)); + return(0); +} diff --git a/lockwasher/src/lib/libc/stdio/Makefile b/lockwasher/src/lib/libc/stdio/Makefile new file mode 100644 index 0000000..8670aca --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/Makefile @@ -0,0 +1,42 @@ +# $Id: Makefile,v 1.2 2003/04/02 19:42:50 reddawg Exp $ +# The System Makefile (C) 2002 The UbixOS Project + +CFLAGS = -fno-builtin + +#Compiler +GCC = gcc +G++ = gcc + +#Linker +LD = ld -Bshareable +AR = ar + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = fseek.o printf.o vsprintf.o fd.o vfprintf.o fopen.o fread.o fwrite.o fgetc.o sprintf.o gets.o fclose.o +#Output +OUTPUT = libc.so + +$(OUTPUT): $(OBJS) + +# Compile the source files +.cc.o: + $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -c -o $@ $< + +.cc.s: + $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $< + +.c.o: + $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -c $< + +.c.s: + $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $< + +.S.o: + $(GCC) $(CFLAGS) -Wall -nostdlib -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(OUTPUT) diff --git a/lockwasher/src/lib/libc/stdio/fclose.c b/lockwasher/src/lib/libc/stdio/fclose.c new file mode 100644 index 0000000..6519b05 --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/fclose.c @@ -0,0 +1,35 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fclose.c,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#include +#include + +int fclose(FILE *fp) { + int status = 0x0; + asm( + "int %0\n" + : : "i" (0x80),"a" (10),"b" (fp),"c" (&status) + ); + return(status); + } + diff --git a/lockwasher/src/lib/libc/stdio/fd.c b/lockwasher/src/lib/libc/stdio/fd.c new file mode 100644 index 0000000..6b2c4bb --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/fd.c @@ -0,0 +1,32 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fd.c,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#include + +FILE fdTable[3] = { + {0}, /* stdin */ + {1}, /* stdout */ + {2} /* stderr */ + }; + + diff --git a/lockwasher/src/lib/libc/stdio/fgetc.c b/lockwasher/src/lib/libc/stdio/fgetc.c new file mode 100644 index 0000000..84f9872 --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/fgetc.c @@ -0,0 +1,34 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fgetc.c,v 1.1.1.1 2003/01/12 00:20:01 reddawg Exp $ + +**************************************************************************************/ + +#include + +int fgetc(FILE *fd) { + volatile int ch = 0; + asm( + "int %0" + : + : "i" (0x80),"a" (5),"b" (&ch),"c" (fd) + ); + return(ch); + } diff --git a/lockwasher/src/lib/libc/stdio/fopen.c b/lockwasher/src/lib/libc/stdio/fopen.c new file mode 100644 index 0000000..72042b5 --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/fopen.c @@ -0,0 +1,36 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fopen.c,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#include +#include + +FILE *fopen(const char *file,const char *mode) { + FILE *fp = malloc(sizeof(FILE)); + fp->fd = -1; + asm( + "int %0\n" + : : "i" (0x80),"a" (8),"b" (file),"c" (mode),"d" (fp) + ); + //printf("\0",fp->fd); + return((FILE *)fp); + } diff --git a/lockwasher/src/lib/libc/stdio/fprintf.c b/lockwasher/src/lib/libc/stdio/fprintf.c new file mode 100644 index 0000000..233046d --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/fprintf.c @@ -0,0 +1,31 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fprintf.c,v 1.1.1.1 2003/01/12 00:20:01 reddawg Exp $ + +**************************************************************************************/ + +int fprintf(FILE *fp, const char *fmt, ...) { + int retVal; + vaList ap; + vaStart(ap, fmt); + retVal = vfprintf(fp, fmt, ap); + vaEnd(ap); + return(retVal); + } \ No newline at end of file diff --git a/lockwasher/src/lib/libc/stdio/fread.c b/lockwasher/src/lib/libc/stdio/fread.c new file mode 100644 index 0000000..6a15a8b --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/fread.c @@ -0,0 +1,33 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fread.c,v 1.4 2003/03/27 13:30:43 reddawg Exp $ + +**************************************************************************************/ + +#include + +size_t fread(void *pointer,size_t size,size_t count, FILE *stream) { + asm( + "int %0\n" + : : "i" (0x80),"a" (22),"b" (pointer),"c" (size * count),"d" (stream) + ); + return(count); + } + diff --git a/lockwasher/src/lib/libc/stdio/fseek.c b/lockwasher/src/lib/libc/stdio/fseek.c new file mode 100644 index 0000000..e4b5ad2 --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/fseek.c @@ -0,0 +1,32 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fseek.c,v 1.2 2003/05/01 12:30:02 reddawg Exp $ + +**************************************************************************************/ + +#include + +int fseek(FILE *fd,long offset,int whence) { + asm( + "int %0\n" + : : "i" (0x80),"a" (27),"b" (fd),"c" (offset),"d" (whence) + ); + return(offset+whence); + } diff --git a/lockwasher/src/lib/libc/stdio/fwrite.c b/lockwasher/src/lib/libc/stdio/fwrite.c new file mode 100644 index 0000000..f537f6a --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/fwrite.c @@ -0,0 +1,35 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fwrite.c,v 1.5 2003/05/01 12:30:02 reddawg Exp $ + +**************************************************************************************/ + +#include + +int fwrite(const void *ptr,int size,int nmemb,FILE *fd) { + int retVal = size; + asm( + "int %0" + : + : "i" (0x80),"a" (23),"b" (ptr),"c" (size*nmemb),"d" (fd) + ); + return(retVal); + } + diff --git a/lockwasher/src/lib/libc/stdio/gets.c b/lockwasher/src/lib/libc/stdio/gets.c new file mode 100644 index 0000000..9f8d35c --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/gets.c @@ -0,0 +1,43 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: gets.c,v 1.3 2003/04/23 21:42:34 reddawg Exp $ + +**************************************************************************************/ + +#include + +char *gets(char *string) { + int count=0,ch=0; + while (1) { + ch = fgetc(stdin); + if(ch == 10) { + printf("\n"); + break; + } + else if(ch == 8 && count > 0) count-=2; + else if(ch == 0) count--; + else string[count] = ch; + if (ch != 8) printf("%c",ch); + count ++; + } + string[count] = '\0'; + return(string); + } + diff --git a/lockwasher/src/lib/libc/stdio/printf.c b/lockwasher/src/lib/libc/stdio/printf.c new file mode 100644 index 0000000..dd85c7e --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/printf.c @@ -0,0 +1,36 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: printf.c,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#include +#include + +int printf(char const *fmt, ...) { + int retVal; + vaList ap; + vaStart(ap, fmt); + retVal = vfprintf(stdin, fmt, ap); + vaEnd(ap); + return(retVal); + } + + diff --git a/lockwasher/src/lib/libc/stdio/sprintf.c b/lockwasher/src/lib/libc/stdio/sprintf.c new file mode 100644 index 0000000..9f5c969 --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/sprintf.c @@ -0,0 +1,34 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: sprintf.c,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#include + +int sprintf(char *string, const char *format, ...) { + vaList args; + int retVal = 0x0; + vaStart(args, format); + retVal = vsprintf(string,format,args); + vaEnd(args) + return(retVal); + } + diff --git a/lockwasher/src/lib/libc/stdio/vfprintf.c b/lockwasher/src/lib/libc/stdio/vfprintf.c new file mode 100644 index 0000000..193694e --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/vfprintf.c @@ -0,0 +1,37 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: vfprintf.c,v 1.3 2003/05/01 12:30:02 reddawg Exp $ + +**************************************************************************************/ + +#include +#include + +int vfprintf(FILE *fd,const char *fmt,vaList args) { + int retVal = 0; + char data[1024]; + retVal = vsprintf(data,fmt,args); + asm( + "int %0" + : + : "i" (0x80),"a" (23),"b" (data),"c" (sizeof(data)),"d" (fd) + ); + return(retVal); + } diff --git a/lockwasher/src/lib/libc/stdio/vsprintf.c b/lockwasher/src/lib/libc/stdio/vsprintf.c new file mode 100644 index 0000000..8754780 --- /dev/null +++ b/lockwasher/src/lib/libc/stdio/vsprintf.c @@ -0,0 +1,241 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are prohibited. + + $Id: vsprintf.c,v 1.1.1.1 2003/01/12 00:20:02 reddawg Exp $ + +**************************************************************************************/ + +/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ +/* + * Wirzenius wrote this portably, Torvalds fucked it up :-) + */ + +#include +#include + +/* we use this so that we can do without the ctype library */ +#define is_digit(c) ((c) >= '0' && (c) <= '9') + +static int skip_atoi(const char **s) +{ + int i=0; + + while (is_digit(**s)) + i = i*10 + *((*s)++) - '0'; + return i; +} + +#define ZEROPAD 1 /* pad with zero */ +#define SIGN 2 /* unsigned/signed long */ +#define PLUS 4 /* show plus */ +#define SPACE 8 /* space if plus */ +#define LEFT 16 /* left justified */ +#define SPECIAL 32 /* 0x */ +#define SMALL 64 /* use 'abcdef' instead of 'ABCDEF' */ + +#define do_div(n,base) ({ \ +int __res; \ +__asm__("divl %4":"=a" (n),"=d" (__res):"0" (n),"1" (0),"r" (base)); \ +__res; }) + +static char * number(char * str, int num, int base, int size, int precision + ,int type) +{ + char c,sign,tmp[36]; + const char *digits="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + int i; + + if (type&SMALL) digits="0123456789abcdefghijklmnopqrstuvwxyz"; + if (type&LEFT) type &= ~ZEROPAD; + if (base<2 || base>36) + return 0; + c = (type & ZEROPAD) ? '0' : ' ' ; + if (type&SIGN && num<0) { + sign='-'; + num = -num; + } else + sign=(type&PLUS) ? '+' : ((type&SPACE) ? ' ' : 0); + if (sign) size--; + if (type&SPECIAL) { + if (base==16) { size -= 2; } + else if (base==8) { size--; } + } + i=0; + if (num==0) + tmp[i++]='0'; + else while (num!=0) + tmp[i++]=digits[do_div(num,base)]; + if (i>precision) precision=i; + size -= precision; + if (!(type&(ZEROPAD+LEFT))) + while(size-->0) + *str++ = ' '; + if (sign) + *str++ = sign; + if (type&SPECIAL) { + if (base==8) { + *str++ = '0'; + } + else if (base==16) { + *str++ = '0'; + *str++ = digits[33]; + } + } + if (!(type&LEFT)) + while(size-->0) + *str++ = c; + while(i0) + *str++ = tmp[i]; + while(size-->0) + *str++ = ' '; + return str; +} + +int vsprintf(char *buf, const char *fmt, vaList args) +{ + int len; + int i; + char * str; + char *s; + int *ip; + + int flags; /* flags to number() */ + + int field_width; /* width of output field */ + int precision; /* min. # of digits for integers; max + number of chars for from string */ + int qualifier; /* 'h', 'l', or 'L' for integer fields */ + + for (str=buf ; *fmt ; ++fmt) { + if (*fmt != '%') { + *str++ = *fmt; + continue; + } + + /* process flags */ + flags = 0; + repeat: + ++fmt; /* this also skips first '%' */ + switch (*fmt) { + case '-': flags |= LEFT; goto repeat; + case '+': flags |= PLUS; goto repeat; + case ' ': flags |= SPACE; goto repeat; + case '#': flags |= SPECIAL; goto repeat; + case '0': flags |= ZEROPAD; goto repeat; + } + + /* get field width */ + field_width = -1; + if (is_digit(*fmt)) + field_width = skip_atoi(&fmt); + else if (*fmt == '*') { + /* it's the next argument */ + field_width = vaArg(args, int); + if (field_width < 0) { + field_width = -field_width; + flags |= LEFT; + } + } + + /* get the precision */ + precision = -1; + if (*fmt == '.') { + ++fmt; + if (is_digit(*fmt)) + precision = skip_atoi(&fmt); + else if (*fmt == '*') { + /* it's the next argument */ + precision = vaArg(args, int); + } + if (precision < 0) + precision = 0; + } + + /* get the conversion qualifier */ + qualifier = -1; + if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') { + qualifier = *fmt; + ++fmt; + } + + switch (*fmt) { + case 'c': + if (!(flags & LEFT)) + while (--field_width > 0) + *str++ = ' '; + *str++ = (unsigned char) vaArg(args, int); + while (--field_width > 0) + *str++ = ' '; + break; + + case 's': + s = vaArg(args, char *); + len = strlen(s); + if (precision < 0) + precision = len; + else if (len > precision) + len = precision; + + if (!(flags & LEFT)) + while (len < field_width--) + *str++ = ' '; + for (i = 0; i < len; ++i) + *str++ = *s++; + while (len < field_width--) + *str++ = ' '; + break; + + case 'o': + str = number(str, vaArg(args, unsigned long), 8, + field_width, precision, flags); + break; + + case 'p': + if (field_width == -1) { + field_width = 8; + flags |= ZEROPAD; + } + str = number(str, + (unsigned long) vaArg(args, void *), 16, + field_width, precision, flags); + break; + + case 'x': + flags |= SMALL; + case 'X': + str = number(str, vaArg(args, unsigned long), 16, + field_width, precision, flags); + break; + + case 'd': + case 'i': + flags |= SIGN; + case 'u': + str = number(str, vaArg(args, unsigned long), 10, + field_width, precision, flags); + break; + + case 'n': + ip = vaArg(args, int *); + *ip = (str - buf); + break; + + default: + if (*fmt != '%') + *str++ = '%'; + if (*fmt) + *str++ = *fmt; + else + --fmt; + break; + } + } + *str = '\0'; + return str-buf; +} diff --git a/lockwasher/src/lib/libc/stdlib/Makefile b/lockwasher/src/lib/libc/stdlib/Makefile new file mode 100644 index 0000000..81b47bb --- /dev/null +++ b/lockwasher/src/lib/libc/stdlib/Makefile @@ -0,0 +1,43 @@ +# $Id: Makefile,v 1.2 2003/04/02 20:27:47 reddawg Exp $ +# The System Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +CFLAGS = -fno-builtin + +#Linker +LD = ld -Bshareable +AR = ar + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = abs.o exit.o malloc.o +#Output +OUTPUT = libc.so + +$(OUTPUT): $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall ${CFLAGS} -nostdinc -O -I../include -c -o $@ $< + +.cc.s: + $(G++) -Wall ${CFLAGS} -nostdinc -O -I../include -S -o $@ $< + +.c.o: + $(GCC) -Wall ${CFLAGS} -nostdinc -O -I../include -c $< + +.c.s: + $(GCC) -Wall ${CFLAGS} -nostdinc -O -I../include -S -o $@ $< + +.S.o: + $(GCC) -Wall ${CFLAGS} -nostdinc -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(OUTPUT) diff --git a/lockwasher/src/lib/libc/stdlib/abs.c b/lockwasher/src/lib/libc/stdlib/abs.c new file mode 100644 index 0000000..a008c42 --- /dev/null +++ b/lockwasher/src/lib/libc/stdlib/abs.c @@ -0,0 +1,5 @@ +#include + +int abs(int val) { + return(val>0?val:-val); + } diff --git a/lockwasher/src/lib/libc/stdlib/exit.c b/lockwasher/src/lib/libc/stdlib/exit.c new file mode 100644 index 0000000..3dcb83b --- /dev/null +++ b/lockwasher/src/lib/libc/stdlib/exit.c @@ -0,0 +1,31 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: exit.c,v 1.1.1.1 2003/01/12 00:20:01 reddawg Exp $ + +**************************************************************************************/ + +#include + +void exit(int status) { + asm( + "int %0\n" + : : "i" (0x80),"a" (2),"b" (status) + ); + } diff --git a/lockwasher/src/lib/libc/stdlib/malloc.c b/lockwasher/src/lib/libc/stdlib/malloc.c new file mode 100644 index 0000000..c0f0621 --- /dev/null +++ b/lockwasher/src/lib/libc/stdlib/malloc.c @@ -0,0 +1,203 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: malloc.c,v 1.8 2003/04/16 07:21:11 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include + +struct memDescriptor { + struct memDescriptor *prev; //4 + struct memDescriptor *next; //4 + void *baseAddr; //4 + unsigned long limit; //4 + unsigned char status; //1 + char reserved[15]; //15 + }; + +struct memDescriptor *kernDesc = 0x0; +struct memDescriptor *freeKernDesc = 0x0; +struct memDescriptor *emptyKernDesc = 0x0; + +void insertFreeDesc(struct memDescriptor *freeDesc); + +void initMalloc() { + int i=0; + struct memDescriptor *tmpDesc1 = 0x0; + struct memDescriptor *tmpDesc2 = 0x0; + emptyKernDesc = (struct memDescriptor *)getPage(1); + tmpDesc1 = emptyKernDesc; + tmpDesc1->prev = 0x0; + for (i=1;i<((4096/sizeof(struct memDescriptor)));i++) { + tmpDesc2 = &emptyKernDesc[i]; + tmpDesc2->prev = tmpDesc1; + tmpDesc1->next = tmpDesc2; + tmpDesc1 = tmpDesc2; + } + tmpDesc1->next = 0x0; + //Return + return; + } + +void *getEmptyDesc() { + struct memDescriptor *tmpDesc = emptyKernDesc; + if (tmpDesc != 0x0) { + emptyKernDesc = tmpDesc->next; + emptyKernDesc->prev = 0x0; + tmpDesc->next = 0x0; + tmpDesc->prev = 0x0; + return(tmpDesc); + } + printf("Error Finding Empty Descriptor!\n"); + return(0x0); + } + +void *malloc(uInt len) { + struct memDescriptor *tmpDesc1 = 0x0; + struct memDescriptor *tmpDesc2 = 0x0; + //If Kernel Descriptor Is NULL Initialize Malloc + if (emptyKernDesc == 0x0) { + initMalloc(); + } + len = (len + 15) & 0xFFFFFFF0; + for (tmpDesc1 = freeKernDesc;tmpDesc1;tmpDesc1=tmpDesc1->next) { + if (tmpDesc1->limit >= len) { + tmpDesc1->status = 0x1; + if (tmpDesc1->prev != 0x0) { + tmpDesc1->prev->next = tmpDesc1->next; + tmpDesc1->next->prev = tmpDesc1->prev; + } + else { + freeKernDesc = tmpDesc1->next; + freeKernDesc->prev = 0x0; + } + tmpDesc1->prev = 0x0; + tmpDesc1->next = kernDesc; + kernDesc->prev = tmpDesc1; + kernDesc = tmpDesc1; + if (tmpDesc1->limit > (len + 16)) { + tmpDesc2 = getEmptyDesc(); + tmpDesc2->limit = tmpDesc1->limit - len; + tmpDesc1->limit = len; + tmpDesc2->baseAddr = tmpDesc1->baseAddr + len; + tmpDesc2->status = 0x0; + insertFreeDesc(tmpDesc2); + } + return(tmpDesc1->baseAddr); + } + } + tmpDesc1 = getEmptyDesc(); + if (tmpDesc1 != 0x0) { + tmpDesc1->baseAddr = (struct memDescriptor *)getPage((len+4095)/4096); + tmpDesc1->limit = len; + tmpDesc1->status = 0x1; + tmpDesc1->next = kernDesc; + tmpDesc1->prev = 0x0; + if (kernDesc != 0x0) { + kernDesc->prev = tmpDesc1; + } + kernDesc = tmpDesc1; + if ((len/4096) > 0) { + tmpDesc2 = getEmptyDesc(); + tmpDesc2->status = 0x0; + tmpDesc2->baseAddr = tmpDesc1->baseAddr + tmpDesc1->limit; + tmpDesc2->limit = ((len + 4095)/4096)*4096 - tmpDesc1->limit; + insertFreeDesc(tmpDesc2); + } + /* + printf("[0x"); + printf("%X",tmpDesc1->baseAddr); + printf("]\n"); + */ + return(tmpDesc1->baseAddr); + } + //Return Null If Unable To Malloc + return(0x0); + } + +void free(void *baseAddr) { + long *data = 0x0; + long i = 0x0; + struct memDescriptor *tmpDesc1 = 0x0; + struct memDescriptor *tmpDesc2 = 0x0; + + if (baseAddr == 0x0) { + return; + } + for (tmpDesc1=kernDesc;tmpDesc1;tmpDesc1=tmpDesc1->next) { + if (tmpDesc1->baseAddr == baseAddr) { + tmpDesc1->status = 0x0; + if (tmpDesc1->prev) { + tmpDesc2 = tmpDesc1->prev; + tmpDesc2->next = tmpDesc1->next; + } + if (tmpDesc1->next) { + tmpDesc2 = tmpDesc1->next; + if (tmpDesc2) { + tmpDesc2->prev = tmpDesc1->prev; + } + } + if ((kernDesc == tmpDesc1) && (tmpDesc1->prev)) { + kernDesc = tmpDesc1->prev; + } + else { + kernDesc = tmpDesc1->next; + } + insertFreeDesc(tmpDesc1); + data = baseAddr; + for (i=0;i < (tmpDesc1->limit/4);i++) { + data[i] = 0x0; + } + return; + } + } + printf("Error Freeing User Descriptor! [0x%X]\n",(unsigned int) baseAddr); + return; + } + +void insertFreeDesc(struct memDescriptor *freeDesc) { + struct memDescriptor *tmpDesc; + freeDesc->status = 0x0; + if (freeKernDesc != 0x0) { + for (tmpDesc=freeKernDesc;tmpDesc;tmpDesc=tmpDesc->next) { + if ((freeDesc->limit >= tmpDesc->limit) && (!tmpDesc->next)) { + tmpDesc->next = freeDesc; + freeDesc->prev = tmpDesc; + freeDesc->next = 0x0; + return; + } + else if ((freeDesc->limit >= tmpDesc->limit) && (freeDesc->limit <= tmpDesc->next->limit)) { + freeDesc->next = tmpDesc->next; + freeDesc->prev = tmpDesc; + tmpDesc->next->prev = freeDesc; + tmpDesc->next = freeDesc; + return; + } + } + } + else { + freeDesc->prev = 0x0; + freeDesc->next = 0x0; + freeKernDesc = freeDesc; + } + return; + } \ No newline at end of file diff --git a/lockwasher/src/lib/libc/string/Makefile b/lockwasher/src/lib/libc/string/Makefile new file mode 100644 index 0000000..baced8c --- /dev/null +++ b/lockwasher/src/lib/libc/string/Makefile @@ -0,0 +1,42 @@ +# $Id: Makefile,v 1.2 2003/04/23 21:42:34 reddawg Exp $ +# The System Makefile (C) 2002 The UbixOS Project + +CFLAGS = -fno-builtin + +#Compiler +GCC = gcc +G++ = gcc + +#Linker +LD = ld -Bshareable +AR = ar + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = strtok.o memcpy.o memset.o memcmp.o strlen.o +#Output +OUTPUT = libc.so + +$(OUTPUT): $(OBJS) + +# Compile the source files +.cc.o: + $(G++) $(CFLAGS) -Wall -nostdinc -O -I../include -c -o $@ $< + +.cc.s: + $(G++) $(CFLAGS) -Wall -nostdinc -O -I../include -S -o $@ $< + +.c.o: + $(GCC) $(CFLAGS) -Wall -nostdinc -O -I../include -c $< + +.c.s: + $(GCC) $(CFLAGS) -Wall -nostdinc -O -I../include -S -o $@ $< + +.S.o: + $(GCC) $(CFLAGS) -Wall -nostdinc -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(OUTPUT) diff --git a/lockwasher/src/lib/libc/string/memcmp.c b/lockwasher/src/lib/libc/string/memcmp.c new file mode 100644 index 0000000..266e2c2 --- /dev/null +++ b/lockwasher/src/lib/libc/string/memcmp.c @@ -0,0 +1,28 @@ +#include +#include + +int memcmp(const void * dst, const void * src, size_t length) +{ + size_t x = length >> 2; + size_t y = length & 0xf; + size_t i; + + for (i = 0; i < x; i++) + { + if (((unsigned long *)dst)[i] > ((unsigned long *)src)[i]) + return 1; + if (((unsigned long *)dst)[i] < ((unsigned long *)src)[i]) + return -1; + } + + for (i = 0; i < y; i++) + { + if (((char *) dst)[length-y+i] > ((char *) src)[length-y+i]) + return 1; + if (((char *) dst)[length-y+i] < ((char *) src)[length-y+i]) + return -1; + } + + return 0; +} + diff --git a/lockwasher/src/lib/libc/string/memcpy.c b/lockwasher/src/lib/libc/string/memcpy.c new file mode 100644 index 0000000..e57ba1b --- /dev/null +++ b/lockwasher/src/lib/libc/string/memcpy.c @@ -0,0 +1,18 @@ +#include +#include + +void * memcpy(void * dst, const void * src, size_t length) +{ + size_t x = length >> 2; + size_t y = length & 0xf; + size_t i; + + for (i = 0; i < x; i++) + ((unsigned long *)dst)[i] = ((unsigned long *)src)[i]; + + for (i = 0; i < y; i++) + ((char *) dst)[length-y+i] = ((char *) src)[length-y+i]; + + return dst; +} + diff --git a/lockwasher/src/lib/libc/string/memset.c b/lockwasher/src/lib/libc/string/memset.c new file mode 100644 index 0000000..1acfbd6 --- /dev/null +++ b/lockwasher/src/lib/libc/string/memset.c @@ -0,0 +1,20 @@ +#include +#include + +void * memset(void * dst, int c, size_t length) +{ + size_t x = length >> 2; + size_t y = length & 0xf; + size_t i; + + unsigned int newC = (c << 24) | (c << 16) | (c << 8) | (c); + + for (i = 0; i < x; i++) + ((unsigned long *)dst)[i] = newC; + + for (i = 0; i < y; i++) + ((char *) dst)[length-y+i] = c; + + return dst; +} + diff --git a/lockwasher/src/lib/libc/string/strlen.c b/lockwasher/src/lib/libc/string/strlen.c new file mode 100644 index 0000000..4febfa7 --- /dev/null +++ b/lockwasher/src/lib/libc/string/strlen.c @@ -0,0 +1,16 @@ +#include +#include + +int strlen(const char * string) +{ + int i = 0; + + while (1) + { + if (string[i] == '\0') + return i; + i++; + } + + return 0; +} diff --git a/lockwasher/src/lib/libc/string/strtok.c b/lockwasher/src/lib/libc/string/strtok.c new file mode 100644 index 0000000..da83be4 --- /dev/null +++ b/lockwasher/src/lib/libc/string/strtok.c @@ -0,0 +1,71 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: strtok.c,v 1.1 2003/04/23 21:42:34 reddawg Exp $ + +**************************************************************************************/ + +#include +#include + +char *strtok_r(char *s, const char *delim, char **last) { + char *spanp; + int c, sc; + char *tok; + + if ((s == NULL) && ((s = *last) == NULL)) { + return(NULL); + } + +cont: + c = *s++; + for (spanp = (char *)delim; (sc = *spanp++) != 0; ) { + if (c == sc) { + goto cont; + } + } + if (c == 0) { + *last = NULL; + return(NULL); + } + tok = s - 1; + + for (;;) { + c = *s++; + spanp = (char *)delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) { + s = NULL; + } + else { + char *w = s - 1; + *w = '\0'; + } + *last = s; + return(tok); + } + } while (sc != 0); + } + } + +char *strtok(char *s, const char *delim) { + static char *last; + return (strtok_r(s, delim, &last)); + } \ No newline at end of file diff --git a/lockwasher/src/lib/libc/sys/Makefile b/lockwasher/src/lib/libc/sys/Makefile new file mode 100644 index 0000000..76a955c --- /dev/null +++ b/lockwasher/src/lib/libc/sys/Makefile @@ -0,0 +1,43 @@ +# $Id: Makefile,v 1.5 2003/04/18 05:35:24 reddawg Exp $ +# The System Makefile (C) 2002 The UbixOS Project + +CFLAGS = -fno-builtin + +#Compiler +GCC = gcc +G++ = gcc + +#Linker +LD = ld -Bshareable +AR = ar + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = getdrives.o setuid.o setgid.o getuid.o getgid.o exec.o getpid.o fork.o pidstatus.o getpage.o sched.o + +#Output +OUTPUT = sys.so + +$(OUTPUT): $(OBJS) + +# Compile the source files +.cc.o: + $(G++) ${CFLAGS} -Wall -nostdinc -O -I../include -c -o $@ $< + +.cc.s: + $(G++) ${CFLAGS} -Wall -nostdinc -O -I../include -S -o $@ $< + +.c.o: + $(GCC) ${CFLAGS} -Wall -nostdinc -O -I../include -c $< + +.c.s: + $(GCC) ${CFLAGS} -Wall -nostdinc -O -I../include -S -o $@ $< + +.S.o: + $(GCC) ${CFLAGS} -Wall -nostdinc -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(OUTPUT) diff --git a/lockwasher/src/lib/libc/sys/exec.c b/lockwasher/src/lib/libc/sys/exec.c new file mode 100644 index 0000000..9ed33e5 --- /dev/null +++ b/lockwasher/src/lib/libc/sys/exec.c @@ -0,0 +1,31 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: exec.c,v 1.5 2003/04/24 05:19:30 reddawg Exp $ + +**************************************************************************************/ + +int exec(char *file,int argc,char **argv) { + int status = 0x1; + asm( + "int %0 \n" + : : "i" (0x80),"a" (3),"b" (argc),"c" (argv),"d" (file) + ); + return(status); + } diff --git a/lockwasher/src/lib/libc/sys/fork.c b/lockwasher/src/lib/libc/sys/fork.c new file mode 100644 index 0000000..55ef7a8 --- /dev/null +++ b/lockwasher/src/lib/libc/sys/fork.c @@ -0,0 +1,46 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fork.c,v 1.4 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#include + +pid_t fork() { + pid_t pid = 0x0; + asm( + "pushl %%eax\n" + "pushl %%ecx\n" + "movl $4,%%eax\n" + "push %%ss\n" + "movl %%esp,%%ecx\n" + "sub $4,%%ecx\n" + "pushl %%ecx\n" + "int $0x80 \n" + "popl %%esp\n" + "pop %%ax\n" + "popl %%ecx\n" + "popl %%eax\n" + : + : "b" (&pid) + ); + return(pid); + } + diff --git a/lockwasher/src/lib/libc/sys/getdrives.c b/lockwasher/src/lib/libc/sys/getdrives.c new file mode 100644 index 0000000..76ed8e4 --- /dev/null +++ b/lockwasher/src/lib/libc/sys/getdrives.c @@ -0,0 +1,11 @@ +#include + + +void *getDrives() { + uInt32 ptr = 0x0; + asm( + "int %0\n" + : : "i" (0x80),"a" (45),"b" (&ptr) + ); + return((void *)ptr); + } \ No newline at end of file diff --git a/lockwasher/src/lib/libc/sys/getgid.c b/lockwasher/src/lib/libc/sys/getgid.c new file mode 100644 index 0000000..b98f8e3 --- /dev/null +++ b/lockwasher/src/lib/libc/sys/getgid.c @@ -0,0 +1,33 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: getgid.c,v 1.1 2003/03/31 15:23:08 reddawg Exp $ + +**************************************************************************************/ + +#include + +int getgid(void) { + int gid = 0x0; + asm( + "int %0\n" + : : "i" (0x80),"a" (32),"b" (&gid) + ); + return(gid); + } \ No newline at end of file diff --git a/lockwasher/src/lib/libc/sys/getpage.c b/lockwasher/src/lib/libc/sys/getpage.c new file mode 100644 index 0000000..b5c87bd --- /dev/null +++ b/lockwasher/src/lib/libc/sys/getpage.c @@ -0,0 +1,31 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: getpage.c,v 1.2 2003/04/02 21:45:44 reddawg Exp $ + +**************************************************************************************/ + +void *getPage(int count) { + long pageAddr = 0x0; + asm( + "int %0\n" + : : "i" (0x80),"a" (7),"b" (&pageAddr),"c" (count) + ); + return((void *)pageAddr); + } diff --git a/lockwasher/src/lib/libc/sys/getpid.c b/lockwasher/src/lib/libc/sys/getpid.c new file mode 100644 index 0000000..2e13bdc --- /dev/null +++ b/lockwasher/src/lib/libc/sys/getpid.c @@ -0,0 +1,34 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: getpid.c,v 1.3 2003/03/20 02:45:13 reddawg Exp $ + +**************************************************************************************/ + +#include + +int getpid(void) { + int pid = 0x0; + asm( + "int %0\n" + : : "i" (0x80),"a" (1),"b" (&pid) + ); + return(pid); + } + diff --git a/lockwasher/src/lib/libc/sys/getuid.c b/lockwasher/src/lib/libc/sys/getuid.c new file mode 100644 index 0000000..3ff64c9 --- /dev/null +++ b/lockwasher/src/lib/libc/sys/getuid.c @@ -0,0 +1,33 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: getuid.c,v 1.1 2003/03/31 15:23:08 reddawg Exp $ + +**************************************************************************************/ + +#include + +int getuid(void) { + int uid = 0x0; + asm( + "int %0\n" + : : "i" (0x80),"a" (31),"b" (&uid) + ); + return(uid); + } \ No newline at end of file diff --git a/lockwasher/src/lib/libc/sys/pidstatus.c b/lockwasher/src/lib/libc/sys/pidstatus.c new file mode 100644 index 0000000..3835e85 --- /dev/null +++ b/lockwasher/src/lib/libc/sys/pidstatus.c @@ -0,0 +1,32 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: pidstatus.c,v 1.1.1.1 2003/01/12 00:20:00 reddawg Exp $ + +**************************************************************************************/ + +#include + +int pidStatus(int pid) { + asm( + "int %0\n" + : : "i" (0x80),"a" (6),"b" (&pid) + ); + return(pid); + } diff --git a/lockwasher/src/lib/libc/sys/sched.c b/lockwasher/src/lib/libc/sys/sched.c new file mode 100644 index 0000000..7e53359 --- /dev/null +++ b/lockwasher/src/lib/libc/sys/sched.c @@ -0,0 +1,13 @@ + +#include + +int sched_yield(void) +{ + int return_val = 0; + asm( + "int %0\n" + : : "i" (0x80),"a" (11) + ); + return return_val; +} + diff --git a/lockwasher/src/lib/libc/sys/setgid.c b/lockwasher/src/lib/libc/sys/setgid.c new file mode 100644 index 0000000..555e6af --- /dev/null +++ b/lockwasher/src/lib/libc/sys/setgid.c @@ -0,0 +1,33 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: setgid.c,v 1.1 2003/03/31 15:23:08 reddawg Exp $ + +**************************************************************************************/ + +#include + +int setgid(int gid) { + int status = 0x0; + asm( + "int %0\n" + : : "i" (0x80),"a" (34),"b" (gid),"c" (&status) + ); + return(status); + } \ No newline at end of file diff --git a/lockwasher/src/lib/libc/sys/setuid.c b/lockwasher/src/lib/libc/sys/setuid.c new file mode 100644 index 0000000..27f9168 --- /dev/null +++ b/lockwasher/src/lib/libc/sys/setuid.c @@ -0,0 +1,33 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: setuid.c,v 1.1 2003/03/31 15:23:08 reddawg Exp $ + +**************************************************************************************/ + +#include + +int setuid(int uid) { + int status = 0x0; + asm( + "int %0\n" + : : "i" (0x80),"a" (33),"b" (uid),"c" (&status) + ); + return(status); + } \ No newline at end of file diff --git a/lockwasher/src/lib/libcpp/Makefile b/lockwasher/src/lib/libcpp/Makefile new file mode 100644 index 0000000..8e8007b --- /dev/null +++ b/lockwasher/src/lib/libcpp/Makefile @@ -0,0 +1,42 @@ +# (C) 2002 The UbixOS Project +# $Id: Makefile,v 1.1 2003/04/02 18:56:04 reddawg Exp $ + +CFLAGS = -fno-builtin + +# Compiler +CC = gcc +CPP = g++ + + +# Linker +LINKER = ld + +# Remove +REMOVE = rm -fr + +# Objects +OBJS = libcpp.o + +#Include + +INCLUDE = -I./include -I../libc/include + +all: $(OBJS) + +# Compile Types +.cpp.o: + $(CPP) ${CFLAGS} -Wall -DNOBOOL -fno-rtti -fno-exceptions -g -c $(INCLUDE) -o $@ $< +.cc.o: + $(CPP) ${CFLAGS} -Wall -DNOBOOL -fno-rtti -fno-exceptions -fomit-frame-pointer -O $(INCLUDE) -c -o $@ $< +.cc.s: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O $(INCLUDE) -S -o $@ $< +.c.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O $(INCLUDE) -c -o $@ $< +.c.s: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O $(INCLUDE) -S -o $@ $< +.S.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) diff --git a/lockwasher/src/lib/libcpp/include/libcpp.h b/lockwasher/src/lib/libcpp/include/libcpp.h new file mode 100644 index 0000000..78f02c8 --- /dev/null +++ b/lockwasher/src/lib/libcpp/include/libcpp.h @@ -0,0 +1,9 @@ +#ifndef __LIBCPP_H +#define __LIBCPP_H + +void * operator new(unsigned size); +void operator delete(void * ptr); +void * operator new[](unsigned size); +void operator delete[](void * ptr); + +#endif diff --git a/lockwasher/src/lib/libcpp/libcpp.cc b/lockwasher/src/lib/libcpp/libcpp.cc new file mode 100644 index 0000000..b5084a9 --- /dev/null +++ b/lockwasher/src/lib/libcpp/libcpp.cc @@ -0,0 +1,33 @@ +extern "C" +{ +#include +void __pure_virtual() { while(1); } +void __cxa_pure_virtual() { while(1); } +} + +#include + +void * operator new[](unsigned size) +{ + return malloc(size); +} + +void operator delete[](void * ptr) +{ + free(ptr); + + return; +} + +void * operator new(unsigned size) +{ + return malloc(size); +} + +void operator delete(void * ptr) +{ + free(ptr); + + return; +} + diff --git a/lockwasher/src/lib/ubix/Makefile b/lockwasher/src/lib/ubix/Makefile new file mode 100644 index 0000000..f559a68 --- /dev/null +++ b/lockwasher/src/lib/ubix/Makefile @@ -0,0 +1,42 @@ +# $Id: Makefile,v 1.1.1.1 2003/01/12 00:20:02 reddawg Exp $ +# Kernel Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Linker +LD = ld + +#Binary File Name +BINARY = none + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = startup.o + +# Make the Binary +$(BINARY) : $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O -I../libc/include -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O -I../libc/include -S -o $@ $< + +.c.o: + $(GCC) -Wall -O -I../libc/include -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O -I../libc/include -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/lockwasher/src/lib/ubix/startup.c b/lockwasher/src/lib/ubix/startup.c new file mode 100644 index 0000000..c47bb0a --- /dev/null +++ b/lockwasher/src/lib/ubix/startup.c @@ -0,0 +1,35 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: startup.c,v 1.3 2003/04/23 21:42:34 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include + +extern int main(); + +void _start(int argc,char **argv) { + //int argc = args[0]; + //char **argv = args[1]; + char **env = 0x0; + exit(main(argc,argv,env)); + } diff --git a/lockwasher/src/lib/views/1.DPF b/lockwasher/src/lib/views/1.DPF new file mode 100644 index 0000000..a02b207 --- /dev/null +++ b/lockwasher/src/lib/views/1.DPF Binary files differ diff --git a/lockwasher/src/lib/views/6X6.DPF b/lockwasher/src/lib/views/6X6.DPF new file mode 100644 index 0000000..bf94b27 --- /dev/null +++ b/lockwasher/src/lib/views/6X6.DPF Binary files differ diff --git a/lockwasher/src/lib/views/8X14.DPF b/lockwasher/src/lib/views/8X14.DPF new file mode 100644 index 0000000..63690a6 --- /dev/null +++ b/lockwasher/src/lib/views/8X14.DPF Binary files differ diff --git a/lockwasher/src/lib/views/BLOCK.DPF b/lockwasher/src/lib/views/BLOCK.DPF new file mode 100644 index 0000000..12f39f7 --- /dev/null +++ b/lockwasher/src/lib/views/BLOCK.DPF Binary files differ diff --git a/lockwasher/src/lib/views/BOLD.DPF b/lockwasher/src/lib/views/BOLD.DPF new file mode 100644 index 0000000..20800b5 --- /dev/null +++ b/lockwasher/src/lib/views/BOLD.DPF Binary files differ diff --git a/lockwasher/src/lib/views/BOLD1.DPF b/lockwasher/src/lib/views/BOLD1.DPF new file mode 100644 index 0000000..fa3e96e --- /dev/null +++ b/lockwasher/src/lib/views/BOLD1.DPF Binary files differ diff --git a/lockwasher/src/lib/views/BROADWAY.DPF b/lockwasher/src/lib/views/BROADWAY.DPF new file mode 100644 index 0000000..5a524b4 --- /dev/null +++ b/lockwasher/src/lib/views/BROADWAY.DPF Binary files differ diff --git a/lockwasher/src/lib/views/COURIER.DPF b/lockwasher/src/lib/views/COURIER.DPF new file mode 100644 index 0000000..00058b2 --- /dev/null +++ b/lockwasher/src/lib/views/COURIER.DPF Binary files differ diff --git a/lockwasher/src/lib/views/CYBER.DPF b/lockwasher/src/lib/views/CYBER.DPF new file mode 100644 index 0000000..3c4c755 --- /dev/null +++ b/lockwasher/src/lib/views/CYBER.DPF Binary files differ diff --git a/lockwasher/src/lib/views/DOTTIE.DPF b/lockwasher/src/lib/views/DOTTIE.DPF new file mode 100644 index 0000000..2a1828e --- /dev/null +++ b/lockwasher/src/lib/views/DOTTIE.DPF Binary files differ diff --git a/lockwasher/src/lib/views/DP.DPF b/lockwasher/src/lib/views/DP.DPF new file mode 100644 index 0000000..c3efc73 --- /dev/null +++ b/lockwasher/src/lib/views/DP.DPF Binary files differ diff --git a/lockwasher/src/lib/views/FUTURE.DPF b/lockwasher/src/lib/views/FUTURE.DPF new file mode 100644 index 0000000..baf934d --- /dev/null +++ b/lockwasher/src/lib/views/FUTURE.DPF Binary files differ diff --git a/lockwasher/src/lib/views/ITALIC.DPF b/lockwasher/src/lib/views/ITALIC.DPF new file mode 100644 index 0000000..3f853c6 --- /dev/null +++ b/lockwasher/src/lib/views/ITALIC.DPF Binary files differ diff --git a/lockwasher/src/lib/views/KAP.DPF b/lockwasher/src/lib/views/KAP.DPF new file mode 100644 index 0000000..5913c19 --- /dev/null +++ b/lockwasher/src/lib/views/KAP.DPF Binary files differ diff --git a/lockwasher/src/lib/views/LCD.DPF b/lockwasher/src/lib/views/LCD.DPF new file mode 100644 index 0000000..acfa45c --- /dev/null +++ b/lockwasher/src/lib/views/LCD.DPF Binary files differ diff --git a/lockwasher/src/lib/views/Makefile b/lockwasher/src/lib/views/Makefile new file mode 100644 index 0000000..e86bc56 --- /dev/null +++ b/lockwasher/src/lib/views/Makefile @@ -0,0 +1,46 @@ +# $Id: Makefile,v 1.9 2003/04/13 14:25:19 flameshadow Exp $ +# Kernel Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = g++ + +#Linker +LD = ld + +#Binary File Name +BINARY = objgfx + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = objgfx30.o ogFont.o ogSprite.o ogBlit.o vWidget.o vWindow.o + +#Include +INCLUDE = -I./include -I../../lib/libc/include -I../../lib/libcpp/include + +# Link the binary +$(BINARY) : $(OBJS) +# $(G++) -o $@ $(OBJS) + +# Compile the source files +.cpp.o: + $(G++) -Wall -g -fno-builtin -fno-rtti -fno-exceptions -DNOBOOL $(INCLUDE) -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O $(INCLUDE) -S -o $@ $< + +.c.o: + $(GCC) -Wall -O $(INCLUDE) -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O $(INCLUDE) -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(BINARY) *.core diff --git a/lockwasher/src/lib/views/NORMAL.DPF b/lockwasher/src/lib/views/NORMAL.DPF new file mode 100644 index 0000000..9284622 --- /dev/null +++ b/lockwasher/src/lib/views/NORMAL.DPF Binary files differ diff --git a/lockwasher/src/lib/views/NORMAL1.DPF b/lockwasher/src/lib/views/NORMAL1.DPF new file mode 100644 index 0000000..c7c1829 --- /dev/null +++ b/lockwasher/src/lib/views/NORMAL1.DPF Binary files differ diff --git a/lockwasher/src/lib/views/OLDENG.DPF b/lockwasher/src/lib/views/OLDENG.DPF new file mode 100644 index 0000000..e542aca --- /dev/null +++ b/lockwasher/src/lib/views/OLDENG.DPF Binary files differ diff --git a/lockwasher/src/lib/views/PACMAN.DPF b/lockwasher/src/lib/views/PACMAN.DPF new file mode 100644 index 0000000..4db8522 --- /dev/null +++ b/lockwasher/src/lib/views/PACMAN.DPF Binary files differ diff --git a/lockwasher/src/lib/views/PIGFONT.DPF b/lockwasher/src/lib/views/PIGFONT.DPF new file mode 100644 index 0000000..8a75a62 --- /dev/null +++ b/lockwasher/src/lib/views/PIGFONT.DPF Binary files differ diff --git a/lockwasher/src/lib/views/ROM8X14.DPF b/lockwasher/src/lib/views/ROM8X14.DPF new file mode 100644 index 0000000..376a5ef --- /dev/null +++ b/lockwasher/src/lib/views/ROM8X14.DPF Binary files differ diff --git a/lockwasher/src/lib/views/ROM8X16.DPF b/lockwasher/src/lib/views/ROM8X16.DPF new file mode 100644 index 0000000..dfb28b2 --- /dev/null +++ b/lockwasher/src/lib/views/ROM8X16.DPF Binary files differ diff --git a/lockwasher/src/lib/views/ROM8X8.DPF b/lockwasher/src/lib/views/ROM8X8.DPF new file mode 100644 index 0000000..b65b08d --- /dev/null +++ b/lockwasher/src/lib/views/ROM8X8.DPF Binary files differ diff --git a/lockwasher/src/lib/views/ROMAN.DPF b/lockwasher/src/lib/views/ROMAN.DPF new file mode 100644 index 0000000..85dcd69 --- /dev/null +++ b/lockwasher/src/lib/views/ROMAN.DPF Binary files differ diff --git a/lockwasher/src/lib/views/ROMAN1.DPF b/lockwasher/src/lib/views/ROMAN1.DPF new file mode 100644 index 0000000..19dc135 --- /dev/null +++ b/lockwasher/src/lib/views/ROMAN1.DPF Binary files differ diff --git a/lockwasher/src/lib/views/ROMAN2.DPF b/lockwasher/src/lib/views/ROMAN2.DPF new file mode 100644 index 0000000..81ac9d3 --- /dev/null +++ b/lockwasher/src/lib/views/ROMAN2.DPF Binary files differ diff --git a/lockwasher/src/lib/views/SCRIPT.DPF b/lockwasher/src/lib/views/SCRIPT.DPF new file mode 100644 index 0000000..8adf710 --- /dev/null +++ b/lockwasher/src/lib/views/SCRIPT.DPF Binary files differ diff --git a/lockwasher/src/lib/views/SPECIAL.DPF b/lockwasher/src/lib/views/SPECIAL.DPF new file mode 100644 index 0000000..7c34d5e --- /dev/null +++ b/lockwasher/src/lib/views/SPECIAL.DPF Binary files differ diff --git a/lockwasher/src/lib/views/SPECIAL1.DPF b/lockwasher/src/lib/views/SPECIAL1.DPF new file mode 100644 index 0000000..fdb0f86 --- /dev/null +++ b/lockwasher/src/lib/views/SPECIAL1.DPF Binary files differ diff --git a/lockwasher/src/lib/views/defpal.inc b/lockwasher/src/lib/views/defpal.inc new file mode 100644 index 0000000..fdddf0e --- /dev/null +++ b/lockwasher/src/lib/views/defpal.inc @@ -0,0 +1,259 @@ +const + ogRGBA DEFAULT_PALETTE[256] = + {{0,0,0,0}, // 0 + {0,0,170,0}, + {0,170,0,0}, + {0,170,170,0}, // 3 + {170,0,0,0}, + {170,0,170,0}, + {170,85,0,0}, + {170,170,170,0}, // 7 + {85,85,85,0}, + {85,85,255,0}, + {85,255,85,0}, + {85,255,255,0}, // 11 + {255,85,85,0}, + {255,85,255,0}, + {255,255,85,0}, + {255,255,255,0}, //15 + {16,16,16,0}, // 16 + {32,32,32,0}, + {48,48,48,0}, + {64,64,64,0}, + {80,80,80,0}, + {96,96,96,0}, + {112,112,112,0}, + {128,128,128,0}, + {144,144,144,0}, + {160,160,160,0}, + {176,176,176,0}, + {192,192,192,0}, + {208,208,208,0}, + {224,224,224,0}, + {240,240,240,0}, + {255,255,255,0}, //31 + {59,0,0,0}, // 32 + {79,0,0,0}, + {103,0,0,0}, + {123,0,0,0}, + {143,7,7,0}, + {167,7,7,0}, + {187,11,11,0}, + {211,15,15,0}, + {231,19,19,0}, + {255,27,27,0}, + {255,59,59,0}, + {255,91,91,0}, + {255,119,119,0}, + {255,151,151,0}, + {255,183,183,0}, + {255,215,215,0}, + {55,55,0,0}, // 48 + {71,71,0,0}, + {87,87,0,0}, + {103,103,7,0}, + {119,119,7,0}, + {135,135,11,0}, + {155,155,19,0}, + {171,171,23,0}, + {187,187,31,0}, + {203,203,35,0}, + {219,219,43,0}, + {239,239,59,0}, + {255,255,63,0}, + {255,255,127,0}, + {255,255,187,0}, + {255,255,255,0}, + {0,43,0,0}, // 64 + {0,63,0,0}, + {0,83,0,0}, + {0,103,0,0}, + {7,127,7,0}, + {7,147,7,0}, + {11,167,11,0}, + {15,187,15,0}, + {19,211,19,0}, + {27,231,27,0}, + {59,235,59,0}, + {91,239,91,0}, + {127,239,127,0}, + {159,243,159,0}, + {195,247,195,0}, + {231,251,231,0}, + {0,55,55,0}, // 80 + {0,71,71,0}, + {0,87,87,0}, + {7,103,103,0}, + {7,119,119,0}, + {11,135,135,0}, + {19,155,155,0}, + {23,171,171,0}, + {31,187,187,0}, + {35,203,203,0}, + {43,219,219,0}, + {51,235,235,0}, + {63,255,255,0}, + {127,255,255,0}, + {187,255,255,0}, + {255,255,255,0}, + {15,15,55,0}, // 96 + {19,19,79,0}, + {27,27,103,0}, + {31,31,127,0}, + {35,35,155,0}, + {39,39,179,0}, + {43,43,203,0}, + {47,47,227,0}, + {51,51,255,0}, + {71,71,255,0}, + {91,91,255,0}, + {111,111,255,0}, + {131,131,255,0}, + {151,151,255,0}, + {175,175,255,0}, + {195,195,255,0}, + {59,51,59,0}, // 112 + {79,63,79,0}, + {103,71,103,0}, + {123,75,123,0}, + {143,75,143,0}, + {167,71,167,0}, + {187,67,187,0}, + {211,55,211,0}, + {231,43,231,0}, + {255,27,255,0}, + {255,59,255,0}, + {255,91,255,0}, + {255,119,255,0}, + {255,151,255,0}, + {255,183,255,0}, + {255,215,255,0}, + {59,51,59,0}, // 128 + {71,59,71,0}, + {83,71,83,0}, + {95,83,95,0}, + {111,95,111,0}, + {123,103,123,0}, + {135,115,135,0}, + {147,127,147,0}, + {163,139,163,0}, + {175,151,175,0}, + {187,159,187,0}, + {203,171,203,0}, + {215,183,215,0}, + {227,191,227,0}, + {239,203,239,0}, + {255,215,255,0}, + {55,27,27,0}, // 144 + {71,35,35,0}, + {91,43,43,0}, + {107,55,55,0}, + {127,67,67,0}, + {143,75,75,0}, + {163,87,87,0}, + {179,99,99,0}, + {199,111,111,0}, + {203,127,127,0}, + {211,139,139,0}, + {219,159,159,0}, + {223,175,175,0}, + {231,191,191,0}, + {239,211,211,0}, + {247,231,231,0}, + {91,63,27,0}, // 160 + {111,75,31,0}, + {127,87,39,0}, + {147,103,43,0}, + {167,115,51,0}, + {187,127,55,0}, + {207,139,63,0}, + {227,155,67,0}, + {247,167,75,0}, + {247,175,95,0}, + {247,183,119,0}, + {247,195,139,0}, + {247,203,159,0}, + {247,215,183,0}, + {247,227,203,0}, + {251,239,227,0}, + {63,63,31,0}, // 176 + {75,75,35,0}, + {87,87,43,0}, + {99,99,51,0}, + {115,115,55,0}, + {127,127,63,0}, + {139,139,67,0}, + {151,151,75,0}, + {167,167,83,0}, + {175,175,95,0}, + {183,183,107,0}, + {191,191,123,0}, + {203,203,139,0}, + {211,211,159,0}, + {219,219,175,0}, + {231,231,195,0}, + {27,59,47,0}, // 192 + {31,75,59,0}, + {39,87,67,0}, + {47,103,79,0}, + {55,119,91,0}, + {59,135,99,0}, + {67,151,111,0}, + {71,167,119,0}, + {79,183,127,0}, + {87,199,139,0}, + {91,215,147,0}, + {99,231,155,0}, + {127,235,183,0}, + {163,239,211,0}, + {195,243,231,0}, + {231,251,247,0}, + {23,55,55,0}, // 208 + {31,71,71,0}, + {39,87,87,0}, + {47,103,103,0}, + {55,119,119,0}, + {67,139,139,0}, + {75,155,155,0}, + {87,171,171,0}, + {99,187,187,0}, + {111,203,203,0}, + {123,223,223,0}, + {143,227,227,0}, + {163,231,231,0}, + {183,235,235,0}, + {203,239,239,0}, + {227,247,247,0}, + {39,39,79,0}, // 224 + {47,47,91,0}, + {55,55,107,0}, + {63,63,123,0}, + {71,71,139,0}, + {79,79,151,0}, + {87,87,167,0}, + {99,99,183,0}, + {107,107,199,0}, + {123,123,203,0}, + {139,139,211,0}, + {155,155,219,0}, + {171,171,223,0}, + {187,187,231,0}, + {207,207,239,0}, + {227,227,247,0}, + {63,27,63,0}, // 240 + {75,31,75,0}, + {91,39,91,0}, + {103,47,103,0}, + {119,51,119,0}, + {131,59,131,0}, + {147,67,147,0}, + {163,75,163,0}, + {175,83,175,0}, + {191,91,191,0}, + {199,107,199,0}, + {207,127,207,0}, + {215,147,215,0}, + {223,171,223,0}, + {231,195,231,0}, + {243,219,243,0}}; + diff --git a/lockwasher/src/lib/views/include/objgfx30.h b/lockwasher/src/lib/views/include/objgfx30.h new file mode 100644 index 0000000..2d13c63 --- /dev/null +++ b/lockwasher/src/lib/views/include/objgfx30.h @@ -0,0 +1,148 @@ +/************************************************************** +$Id: objgfx30.h,v 1.7 2003/04/09 05:54:02 flameshadow Exp $ +**************************************************************/ + +#ifndef OBJGFX30_H +#define OBJGFX30_H + +#include // for NULL, true, false + +#define ogVERSION 3.0; + +typedef signed char int8; +typedef signed short int int16; +typedef signed long int int32; +typedef signed long long int int64; +typedef unsigned char uInt8; +typedef unsigned short int uInt16; +typedef unsigned long int uInt32; +typedef unsigned long long int uInt64; + +enum ogDataState { ogNONE, ogOWNER, ogALIASING }; + +struct ogRGB { + uInt8 red; + uInt8 green; + uInt8 blue; +}; + +struct ogRGBA { + uInt8 red; + uInt8 green; + uInt8 blue; + uInt8 alpha; +}; + +struct ogPoint { + int32 x; + int32 y; +}; + +typedef + struct ogPixelFmt { + uInt8 BPP; + uInt8 redFieldPosition; + uInt8 greenFieldPosition; + uInt8 blueFieldPosition; + uInt8 alphaFieldPosition; + uInt8 redMaskSize; + uInt8 greenMaskSize; + uInt8 blueMaskSize; + uInt8 alphaMaskSize; + }; + +// Default pixel formats + +const ogPixelFmt OG_NULL_PIXFMT = { 0, 0,0,0,0,0,0,0,0}; +const ogPixelFmt OG_PIXFMT_8BPP = { 8, 0,0,0,0,0,0,0,0}; +const ogPixelFmt OG_PIXFMT_15BPP = {15, 10,5,0,15,5,5,5,1}; +const ogPixelFmt OG_PIXFMT_16BPP = {16, 11,5,0,0,5,6,5,0}; +const ogPixelFmt OG_PIXFMT_24BPP = {24, 16,8,0,0,8,8,8,0}; +const ogPixelFmt OG_PIXFMT_32BPP = {32, 16,8,0,24,8,8,8,8}; +const ogPixelFmt OG_MAC_PIXFMT_16BPP = {16, 8,4,0,12,4,4,4,4}; + +class ogSurface { + protected: + float version; + void* buffer; + uInt32* lineOfs; + ogRGBA* pal; + ogSurface* owner; + uInt32 xRes, yRes; + uInt32 maxX, maxY; + uInt32 bSize; // buffer size (in bytes) + uInt32 lSize; // LineOfs size (in bytes) + uInt32 transparentColor; + ogDataState dataState; + uInt32 BPP; // bits per pixel + uInt32 redFieldPosition; + uInt32 greenFieldPosition; + uInt32 blueFieldPosition; + uInt32 alphaFieldPosition; + uInt32 redShifter; + uInt32 greenShifter; + uInt32 blueShifter; + uInt32 alphaShifter; + bool antiAlias; + bool clipLine(int32&, int32&, int32&, int32&); + virtual void rawLine(uInt32, uInt32, uInt32, uInt32, uInt32); + virtual uInt32 rawGetPixel(uInt32, uInt32); + virtual void rawSetPixel(uInt32, uInt32, uInt32); + void aaRawLine(uInt32, uInt32, uInt32, uInt32, uInt32); + public: + ogSurface(void); + virtual bool ogAlias(ogSurface&, uInt32, uInt32, uInt32, uInt32); + virtual bool ogAvail(void); + void ogArc(int32, int32, uInt32, uInt32, uInt32, uInt32); + void ogBSpline(uInt32, ogPoint*, uInt32, uInt32); + void ogCircle(int32, int32, uInt32, uInt32); + virtual void ogClear(uInt32); + virtual bool ogClone(ogSurface&); + void ogCopy(ogSurface&); + void ogCopyBuf(int32, int32, + ogSurface&, int32, int32, int32, int32); + virtual void ogCopyLineTo(uInt32, uInt32, const void *, uInt32); + virtual void ogCopyLineFrom(uInt32, uInt32, void *, uInt32); + void ogCopyPal(ogSurface&); + virtual bool ogCreate(uInt32, uInt32, ogPixelFmt); + void ogCubicBezierCurve(int32, int32, int32, int32, + int32, int32, int32, int32, uInt32, uInt32); + void ogCurve(int32,int32, int32,int32, int32,int32, uInt32, uInt32); + void ogFillCircle(int32, int32, uInt32, uInt32); +// void ogFillConvexPolygon(uInt32, ogPoint*, uInt32); + void ogFillPolygon(uInt32, ogPoint*, uInt32); + void ogFillRect(int32, int32, int32, int32, uInt32); + void ogFillTriangle(int32,int32, int32,int32, int32,int32, uInt32); + bool ogGetAntiAlias(void) const { return antiAlias; } + uInt8 ogGetBPP(void) const { return BPP; } + ogDataState ogGetDataState(void) const { return dataState; } + uInt32 ogGetMaxX(void) const { return maxX; } + uInt32 ogGetMaxY(void) const { return maxY; } + void ogGetPixFmt(ogPixelFmt&); + virtual uInt32 ogGetPixel(int32, int32); + virtual void * ogGetPtr(uInt32, uInt32); + uInt32 ogGetTransparentColor(void) { return transparentColor; } + void ogHFlip(void); + virtual void ogHLine(int32, int32, int32, uInt32); + void ogLine(int32, int32, int32, int32, uInt32); + virtual bool ogLoadPal(const char *); + void ogPolygon(uInt32, ogPoint*, uInt32); + void ogRect(int32, int32, int32, int32, uInt32); + uInt32 ogRGB(uInt8, uInt8, uInt8); + bool ogSavePal(const char *); + void ogScale(ogSurface&); + void ogScaleBuf(int32, int32, int32, int32, + ogSurface&, int32, int32, int32, int32); + bool ogSetAntiAlias(bool); + virtual void ogSetPixel(int32, int32, uInt32); + virtual void ogSetRGBPalette(uInt8, uInt8, uInt8, uInt8); + uInt32 ogSetTransparentColor(uInt32); + void ogSpline(uInt32, ogPoint*, uInt32, uInt32); + void ogTriangle(int32, int32, int32, int32, int32, int32, uInt32); + void ogUnpackRGB(uInt32, uInt8&, uInt8&, uInt8&); + virtual void ogVFlip(void); + virtual void ogVLine(int32, int32, int32, uInt32); + virtual ~ogSurface(void); +}; // ogSurface + +#endif diff --git a/lockwasher/src/lib/views/include/ogBlit.h b/lockwasher/src/lib/views/include/ogBlit.h new file mode 100644 index 0000000..7788ae0 --- /dev/null +++ b/lockwasher/src/lib/views/include/ogBlit.h @@ -0,0 +1,28 @@ +#ifndef OGBLIT_H +#define OGBLIT_H + +#include "ogSprite.h" + +class ogBlit: public ogSprite { + protected: + uInt8 * blitMask; + uInt32 blitMaskSize; + uInt32 totalPixCount; + int32 startX, startY; + int32 endX, endY; + + void blitSize(ogSurface&, int32, int32, int32, int32); + void getBlitMask(ogSurface&, int32, int32); + public: + ogBlit(void); + virtual void get(ogSurface&, int32, int32, int32, int32); + void getBlitWithMask(ogSurface&, int32, int32); + uInt32 getBlitMaskSize(void) { return blitMaskSize; } + virtual uInt32 getSize(void); + virtual bool loadFrom(const char *, uInt32); + virtual void put(ogSurface&, int32, int32); + virtual bool saveTo(const char *, int32); + virtual ~ogBlit(void); +}; // ogBlit + +#endif diff --git a/lockwasher/src/lib/views/include/ogDisplay_UbixOS.h b/lockwasher/src/lib/views/include/ogDisplay_UbixOS.h new file mode 100644 index 0000000..4e301de --- /dev/null +++ b/lockwasher/src/lib/views/include/ogDisplay_UbixOS.h @@ -0,0 +1,80 @@ +#ifndef OGDISPLAY_UBIXOS_H +#define OGDISPLAY_UBIXOS_H + +#include "objgfx30.h" + +struct ogMode_Rec { + uInt16 ModeAttributes __attribute__((packed)); + uInt8 WindowAFlags __attribute__((packed)); + uInt8 WindowBFlags __attribute__((packed)); + uInt16 Granularity __attribute__((packed)); + uInt16 WindowSize __attribute__((packed)); + uInt16 WindowASeg __attribute__((packed)); + uInt16 WindowBSeg __attribute__((packed)); + void* BankSwitch __attribute__((packed)); + uInt16 BytesPerLine __attribute__((packed)); + uInt16 xRes __attribute__((packed)); + uInt16 yRes __attribute__((packed)); + uInt8 CharWidth __attribute__((packed)); + uInt8 CharHeight __attribute__((packed)); + uInt8 NumBitPlanes __attribute__((packed)); + uInt8 BitsPerPixel __attribute__((packed)); + uInt8 NumberOfBanks __attribute__((packed)); + uInt8 MemoryModel __attribute__((packed)); + uInt8 BankSize __attribute__((packed)); + uInt8 NumOfImagePages __attribute__((packed)); + uInt8 Reserved __attribute__((packed)); + // Direct colour fields (required for Direct/6 and YUV/7 memory models + uInt8 RedMaskSize __attribute__((packed)); + uInt8 RedFieldPosition __attribute__((packed)); + uInt8 GreenMaskSize __attribute__((packed)); + uInt8 GreenFieldPosition __attribute__((packed)); + uInt8 BlueMaskSize __attribute__((packed)); + uInt8 BlueFieldPosition __attribute__((packed)); + uInt8 AlphaMaskSize __attribute__((packed)); + uInt8 AlphaFieldPosition __attribute__((packed)); + uInt8 DirectColourMode __attribute__((packed)); + // VESA 2.0 specific fields + uInt32 physBasePtr __attribute__((packed)); + void* OffScreenMemOffset __attribute__((packed)); + uInt16 OffScreenMemSize __attribute__((packed)); + uInt8 paddington[461] __attribute__((packed)); +}; + +struct ogVESA_Rec { + char VBESignature[4] __attribute__((packed)); + uInt8 minVersion __attribute__((packed)); + uInt8 majVersion __attribute__((packed)); + uInt32 OEMStringPtr __attribute__((packed)); + uInt32 Capabilities __attribute__((packed)); + uInt32 VideoModePtr __attribute__((packed)); + uInt16 TotalMemory __attribute__((packed)); + // VESA 2.0 specific fields + uInt16 OEMSoftwareRev __attribute__((packed)); + uInt32 OEMVendorNamePtr __attribute__((packed)); + uInt32 OEMProductNamePtr __attribute__((packed)); + uInt32 OEMProductRevPtr __attribute__((packed)); + uInt8 paddington[474] __attribute__((packed)); +}; + +class ogDisplay_UbixOS : public ogSurface { + protected: + ogVESA_Rec* VESARec; + ogMode_Rec* modeRec; + uInt16 findMode(uInt32, uInt32, uInt32); + void getModeInfo(uInt16); + void getVESAInfo(void); + void setMode(uInt16); + void setPal(void); + public: + ogDisplay_UbixOS(void); + virtual bool ogAlias(ogSurface&, uInt32, uInt32, uInt32, uInt32); + virtual bool ogClone(ogSurface&); + virtual void ogCopyPal(ogSurface&); + virtual bool ogCreate(uInt32, uInt32, ogPixelFmt); + virtual bool ogLoadPal(const char *); + virtual void ogSetRGBPalette(uInt8, uInt8, uInt8, uInt8); + virtual ~ogDisplay_UbixOS(void); +}; // ogDisplay_UbixOS + +#endif diff --git a/lockwasher/src/lib/views/include/ogDisplay_VESA.h b/lockwasher/src/lib/views/include/ogDisplay_VESA.h new file mode 100644 index 0000000..69c8de3 --- /dev/null +++ b/lockwasher/src/lib/views/include/ogDisplay_VESA.h @@ -0,0 +1,95 @@ +#ifndef OGDISPLAY_VESA_H +#define OGDISPLAY_VESA_H + +#include "objgfx30.h" + +struct ogMode_Rec { + uInt16 ModeAttributes __attribute__((packed)); + uInt8 WindowAFlags __attribute__((packed)); + uInt8 WindowBFlags __attribute__((packed)); + uInt16 Granularity __attribute__((packed)); + uInt16 WindowSize __attribute__((packed)); + uInt16 WindowASeg __attribute__((packed)); + uInt16 WindowBSeg __attribute__((packed)); + void* BankSwitch __attribute__((packed)); + uInt16 BytesPerLine __attribute__((packed)); + uInt16 xRes __attribute__((packed)); + uInt16 yRes __attribute__((packed)); + uInt8 CharWidth __attribute__((packed)); + uInt8 CharHeight __attribute__((packed)); + uInt8 NumBitPlanes __attribute__((packed)); + uInt8 BitsPerPixel __attribute__((packed)); + uInt8 NumberOfBanks __attribute__((packed)); + uInt8 MemoryModel __attribute__((packed)); + uInt8 BankSize __attribute__((packed)); + uInt8 NumOfImagePages __attribute__((packed)); + uInt8 Reserved __attribute__((packed)); + // Direct colour fields (required for Direct/6 and YUV/7 memory models + uInt8 RedMaskSize __attribute__((packed)); + uInt8 RedFieldPosition __attribute__((packed)); + uInt8 GreenMaskSize __attribute__((packed)); + uInt8 GreenFieldPosition __attribute__((packed)); + uInt8 BlueMaskSize __attribute__((packed)); + uInt8 BlueFieldPosition __attribute__((packed)); + uInt8 AlphaMaskSize __attribute__((packed)); + uInt8 AlphaFieldPosition __attribute__((packed)); + uInt8 DirectColourMode __attribute__((packed)); + // VESA 2.0 specific fields + uInt32 physBasePtr __attribute__((packed)); + void* OffScreenMemOffset __attribute__((packed)); + uInt16 OffScreenMemSize __attribute__((packed)); + uInt8 paddington[461] __attribute__((packed)); +}; + +struct ogVESA_Rec { + char VBESignature[4] __attribute__((packed)); + uInt8 minVersion __attribute__((packed)); + uInt8 majVersion __attribute__((packed)); + uInt32 OEMStringPtr __attribute__((packed)); + uInt32 Capabilities __attribute__((packed)); + uInt32 VideoModePtr __attribute__((packed)); + uInt16 TotalMemory __attribute__((packed)); + // VESA 2.0 specific fields + uInt16 OEMSoftwareRev __attribute__((packed)); + uInt32 OEMVendorNamePtr __attribute__((packed)); + uInt32 OEMProductNamePtr __attribute__((packed)); + uInt32 OEMProductRevPtr __attribute__((packed)); + uInt8 paddington[474] __attribute__((packed)); +}; + +class ogDisplay_VESA : public ogSurface { + protected: + uInt16 ScreenSelector; + ogVESA_Rec* VESARec; + ogMode_Rec* modeRec; + bool InGraphics; + uInt16 findMode(uInt32, uInt32, uInt32); + void getModeInfo(uInt16); + void getVESAInfo(void); + void setMode(uInt16); + virtual uInt32 rawGetPixel(uInt32, uInt32); + virtual void rawSetPixel(uInt32, uInt32, uInt32); + virtual void rawLine(uInt32, uInt32, uInt32, uInt32, uInt32); + void setPal(void); + public: + ogDisplay_VESA(void); + virtual bool ogAvail(void); + virtual bool ogAlias(ogSurface&, uInt32, uInt32, uInt32, uInt32); + virtual void ogClear(uInt32); + virtual bool ogClone(ogSurface&); + virtual void ogCopyLineTo(uInt32, uInt32, const void *, uInt32); + virtual void ogCopyLineFrom(uInt32, uInt32, void *, uInt32); + virtual void ogCopyPal(ogSurface&); + virtual bool ogCreate(uInt32, uInt32, ogPixelFmt); + virtual uInt32 ogGetPixel(int32, int32); + virtual void * ogGetPtr(uInt32, uInt32); + virtual void ogHLine(int32, int32, int32, uInt32); + virtual bool ogLoadPal(const char *); + virtual void ogSetPixel(int32, int32, uInt32); + virtual void ogSetRGBPalette(uInt8, uInt8, uInt8, uInt8); + virtual void ogVFlip(void); + virtual void ogVLine(int32, int32, int32, uInt32); + virtual ~ogDisplay_VESA(void); +}; // ogDisplay_VESA + +#endif diff --git a/lockwasher/src/lib/views/include/ogFont.h b/lockwasher/src/lib/views/include/ogFont.h new file mode 100644 index 0000000..d060b33 --- /dev/null +++ b/lockwasher/src/lib/views/include/ogFont.h @@ -0,0 +1,55 @@ +#ifndef OGFONT_H +#define OGFONT_H + +#include "objgfx30.h" + +#define LeftText 0 +#define CenterText 1 +#define RightText 2 +#define BottomText 0 +#define TopText 2 + +typedef + struct { + char ID[3]; + uInt8 version; + uInt8 width, height; + uInt8 numOfChars; + uInt8 startingChar; + uInt8 colourType; + uInt8 paddington[7]; + } ogDPFHeader; + +class ogBitFont { + protected: + uInt32 fontDataIdx[256]; + uInt32 charWidthTable[256]; + uInt32 charHeightTable[256]; + void * fontData; + uInt32 fontDataSize; + ogRGB BGColour; + ogRGB FGColour; + uInt8 width, height; + uInt16 numOfChars; + uInt8 startingChar; + + public: + ogBitFont(); + void putChar(ogSurface&, int32, int32, const char); + void putString(ogSurface&, int32, int32, const char *); + void setBGColor(uInt8, uInt8, uInt8); + void setFGColor(uInt8, uInt8, uInt8); + uInt32 getWidth(void) const { return width; }; + uInt32 getHeight(void) const { return height; }; + bool loadFrom(const char *, uInt32); + bool saveTo(const char *, int32); + void centerTextX(ogSurface&, int32, const char *); + void justifyText(ogSurface&, uInt8, uInt8, const char *); + bool load(const char *); + bool save(const char *); + uInt32 textHeight(const char *) const { return height; }; + uInt32 textWidth(const char *); + ~ogBitFont(void); +}; // ogBitFont + +#endif diff --git a/lockwasher/src/lib/views/include/ogSprite.h b/lockwasher/src/lib/views/include/ogSprite.h new file mode 100644 index 0000000..3e3315f --- /dev/null +++ b/lockwasher/src/lib/views/include/ogSprite.h @@ -0,0 +1,39 @@ +#ifndef OGSPRITE_H +#define OGSPRITE_H + +#include "objgfx30.h" + +class ogSprite { + protected: + void * image; + uInt32 imageSize; + ogRGBA* pal; + uInt32 width, height; + uInt32 bitDepth; // make this 32-bit just for alignment purposes + uInt32 RFP; + uInt32 GFP; + uInt32 BFP; + uInt32 AFP; + uInt32 RShift; + uInt32 GShift; + uInt32 BShift; + uInt32 AShift; + uInt32 tColour; // original transparent colour + uInt32 getPixel(void *); + void setPixel(void *, uInt32); + void unpackRGB(uInt32, uInt8&, uInt8&, uInt8&); + public: + ogSprite(void); + void get(ogSurface&, int32, int32, int32, int32); + uInt32 getHeight(void) { return height; } + uInt32 getSize(void); + uInt32 getWidth(void) { return width; } + bool load(const char *); + virtual bool loadFrom(const char *, uInt32); + virtual void put(ogSurface&, int32, int32); + bool save(const char *); + virtual bool saveTo(const char *, int32); + virtual ~ogSprite(void); + +}; // ogSprite +#endif diff --git a/lockwasher/src/lib/views/include/vWidget.h b/lockwasher/src/lib/views/include/vWidget.h new file mode 100644 index 0000000..7a15dc5 --- /dev/null +++ b/lockwasher/src/lib/views/include/vWidget.h @@ -0,0 +1,17 @@ +#ifndef VWIDGET_H +#define VWIDGET_H + +#include "objgfx30.h" + +class vWidget : public ogSurface { + protected: + bool active; + public: + vWidget(void) { active = true; } + virtual void vDraw(void) = 0; + virtual bool vGetActive(void) const { return active; } + virtual bool vSetActive(bool); + virtual bool vCreate(void) = 0; +}; + +#endif diff --git a/lockwasher/src/lib/views/include/vWindow.h b/lockwasher/src/lib/views/include/vWindow.h new file mode 100644 index 0000000..3218261 --- /dev/null +++ b/lockwasher/src/lib/views/include/vWindow.h @@ -0,0 +1,19 @@ +#ifndef VWINDOW_H +#define VWINDOW_H + +#include +#include +#include "vWidget.h" + +class vWindow : public vWidget { + protected: + ogSurface * realWindow; + ogBitFont * titleFont; + public: + vWindow(void); + virtual void vDraw(void) { return; } + virtual bool vCreate(void); + void vSDECommand(uInt32); + virtual ~vWindow(void); +}; +#endif diff --git a/lockwasher/src/lib/views/main.cpp b/lockwasher/src/lib/views/main.cpp new file mode 100644 index 0000000..5bca6db --- /dev/null +++ b/lockwasher/src/lib/views/main.cpp @@ -0,0 +1,483 @@ +/********************************************************************** +will add copyright bs later + +$Id: main.cpp,v 1.2 2003/04/02 19:23:21 flameshadow Exp $ +**********************************************************************/ + +#include "objgfx30.h" +#include "ogFont.h" +#include "ogSprite.h" +#include "ogBlit.h" +// #include "ogDisplay_VESA.h" +#include +#include +#include +#include + +using namespace std; + +void testSetPixel(ogSurface& buf) { + uInt32 xx,yy; + buf.ogClear(buf.ogRGB(0,255,0)); + for (yy = 0; yy<=buf.ogGetMaxY(); yy++) + for (xx = 0; xx<=buf.ogGetMaxX(); xx++) + buf.ogSetPixel(xx,yy,xx*yy); + getc(stdin); + return; +} // testSetPixel + +void testRect(ogSurface& buf) { + uInt32 count; + if (buf.ogGetBPP()==8) + for (count=0; count<1000; count++) + buf.ogRect(buf.ogGetMaxX() / 2 - count, buf.ogGetMaxY() / 2 - count, + buf.ogGetMaxX() / 2 + count, buf.ogGetMaxY() / 2 + count, + count); + else + for (count=0; count<1000; count++) + buf.ogRect(buf.ogGetMaxX() / 2 - count, buf.ogGetMaxY() / 2 - count, + buf.ogGetMaxX() / 2 + count, buf.ogGetMaxY() / 2 + count, + buf.ogRGB(count,count,count)); + getc(stdin); + return; +} // testRect + +void testLine(ogSurface & buf) { + uInt32 count; + uInt32 colour; + buf.ogClear(0); + if (buf.ogGetBPP()==8) + for (count=0; count<(buf.ogGetMaxX()+1); count+=2) { + buf.ogLine(count,0,buf.ogGetMaxX()-count,buf.ogGetMaxY(),count); + } // for + else { + colour = 255; + for (count = 0; count < (buf.ogGetMaxX()+1)/2; count+=4) { + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + buf.ogGetMaxX()/2-count,buf.ogGetMaxY(), + buf.ogRGB(colour,colour,colour)); + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + buf.ogGetMaxX()/2+count,buf.ogGetMaxY(), + buf.ogRGB(colour,colour,colour)); + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + buf.ogGetMaxX()/2-count,0, + buf.ogRGB(0,colour,0)); + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + buf.ogGetMaxX()/2+count,0, + buf.ogRGB(0,colour,0)); + + --colour; + } // for + + colour = 255; + for (count = 0; count < (buf.ogGetMaxY()+1)/2; count+=4) { + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + 0, buf.ogGetMaxY()/2-count, + buf.ogRGB(colour,0,0)); + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + 0, buf.ogGetMaxY()/2+count, + buf.ogRGB(colour,0,0)); + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + buf.ogGetMaxX(), buf.ogGetMaxY()/2-count, + buf.ogRGB(0,0,colour)); + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + buf.ogGetMaxX(), buf.ogGetMaxY()/2+count, + buf.ogRGB(0,0,colour)); + --colour; + } // for + } // else + getc(stdin); + return; +} // testLine + +void testClear(ogSurface & buf) { + uInt32 count; + if (buf.ogGetBPP()==8) + for (count=0; count<256; count++) + buf.ogClear(count); + else { + for (count=0; count<256; count+=8) + buf.ogClear(buf.ogRGB(count,0,0)); + for (count=0; count<256; count+=8) + buf.ogClear(buf.ogRGB(0,count,0)); + for (count=0; count<256; count+=8) + buf.ogClear(buf.ogRGB(0,0,count)); + for (count=0; count<256; count+=8) + buf.ogClear(buf.ogRGB(count,count,count)); + } // else + getc(stdin); + return; +} // testClear + +void testCircle(ogSurface & buf) { + uInt32 count; + if (buf.ogGetBPP()==8) + for (count=0; count<1000; count++) + buf.ogCircle(buf.ogGetMaxX()/2,buf.ogGetMaxY()/2, count, count); + else + for (count=0; count<1000; count++) + buf.ogCircle(buf.ogGetMaxX()/2,buf.ogGetMaxY()/2,count,buf.ogRGB(count,0,count)); + getc(stdin); +} // testCircle + +void testVFlip(ogSurface & buf) { + buf.ogVFlip(); + getc(stdin); + return; +} // testVFlip + +void testHFlip(ogSurface & buf) { + buf.ogHFlip(); + getc(stdin); + return; +} // testHFlip + +void testArc(ogSurface & buf) { + uInt32 radius; + uInt32 mid_x, mid_y; + mid_x = buf.ogGetMaxX()/2; + mid_y = buf.ogGetMaxY()/2; + if (buf.ogGetBPP()==8) { + for (radius = 1; radius <9; radius++) { + buf.ogArc(mid_x, mid_y, radius*10, 0, 90, radius*15); + buf.ogArc(mid_x, mid_y, radius*10, 180,270, 249-(radius-1)*16); + } // for + } else { + for (radius = 1; radius <255; radius++) { + buf.ogArc(mid_x, mid_y, radius, 0, 90, buf.ogRGB(radius,radius,0)); + buf.ogArc(mid_x, mid_y, radius, 180,270,buf.ogRGB(0,255-radius,255-radius)); + } // for + } // else + getchar(); + return; +} // testArc + +void testCubicBezierCurve(ogSurface & buf) { + buf.ogCubicBezierCurve(100, 100, + 300,50, + 400,120, + 350,300, + 25, buf.ogRGB(255,255,255)); + getchar(); + return; +} // testCubicBezierCurve + +void testCurve(ogSurface & buf) { + buf.ogCurve(10,10,100,30,35,160,20,buf.ogRGB(255,255,255)); + getchar(); + return; +} // testCurve +void testSprite(ogSurface & buf) { + uInt32 count; + uInt32 w,h; + ogSprite * sprite = NULL; + sprite = new ogSprite(); + + buf.ogClear(0); + testLine(buf); + if (buf.ogGetBPP()==8) + sprite->get(buf, + buf.ogGetMaxX()/2-80,buf.ogGetMaxY()/2-80, + buf.ogGetMaxX()/2+80,buf.ogGetMaxY()/2+80); + else + sprite->get(buf, + buf.ogGetMaxX()/2-150,buf.ogGetMaxY()/2-150, + buf.ogGetMaxX()/2+150,buf.ogGetMaxY()/2+150); + + sprite->save("test.spr"); + delete sprite; + sprite = new ogSprite(); + sprite->load("test.spr"); + w = sprite->getWidth()/2; + h = sprite->getHeight()/2; + buf.ogClear(0); + sprite->put(buf,-10000,-10000); // test *really* off the screen + sprite->put(buf,10000,10000); // test *really* off the screen + + sprite->put(buf,buf.ogGetMaxX()/2-w,buf.ogGetMaxY()/2-h); + sprite->put(buf,-w,-h); + sprite->put(buf,buf.ogGetMaxX()/2-w,-h); + sprite->put(buf,buf.ogGetMaxX()-w,-h); + sprite->put(buf,-w,buf.ogGetMaxY()/2-h); + sprite->put(buf,buf.ogGetMaxX()-w,buf.ogGetMaxY()/2-h); + sprite->put(buf,-w,buf.ogGetMaxY()-h); + sprite->put(buf,buf.ogGetMaxX()/2-w,buf.ogGetMaxY()-h); + sprite->put(buf,buf.ogGetMaxX()-w,buf.ogGetMaxY()-h); + getc(stdin); + for (count = 0; count < 256; count++) { + sprite->put(buf,random() % (buf.ogGetMaxX()+sprite->getWidth()) - sprite->getWidth(), + random() % (buf.ogGetMaxY()+sprite->getHeight()) - sprite->getHeight()); + } // for + delete sprite; + getc(stdin); + return; +} // testSprite + +void testBlit(ogSurface & buf) { + int32 xx, yy, count; + ogBlit * blit = NULL; + blit = new ogBlit(); + buf.ogClear(0); + for (xx= 0; xx<= 20; xx++) { + buf.ogLine(128,0,128-xx*6,255,buf.ogRGB(255,255,255)); + buf.ogLine(128,0,128+xx*6,255,buf.ogRGB(255,255,255)); + buf.ogLine(128,255,128-xx*6,0,buf.ogRGB(255,255,255)); + buf.ogLine(128,255,128+xx*6,0,buf.ogRGB(255,255,255)); + } // for + + buf.ogFillCircle(128,128,60,buf.ogRGB(255,255,255)); + blit->get(buf,0,0,255,255); + for (yy = 0; yy<=(int32)buf.ogGetMaxY(); yy++) + for (xx = 0; xx<=(int32)buf.ogGetMaxX(); xx++) + buf.ogSetPixel(xx,yy,xx*yy); + blit->save("test.blt"); + delete blit; + blit = new ogBlit(); + blit->load("test.blt"); + + blit->put(buf,-10000,-10000); // test *really* off the screen + blit->put(buf,10000,10000); // test *really* off the screen + + blit->put(buf,-128,-128); + blit->put(buf,buf.ogGetMaxX()/2-128,-128); + blit->put(buf,buf.ogGetMaxX()-128,-128); + blit->put(buf,-128,buf.ogGetMaxY()/2-128); + blit->put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()/2-128); + blit->put(buf,buf.ogGetMaxX()-128,buf.ogGetMaxY()/2-128); + blit->put(buf,-128,buf.ogGetMaxY()-128); + blit->put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()-128); + blit->put(buf,buf.ogGetMaxX()-128,buf.ogGetMaxY()-128); + + getc(stdin); + buf.ogClear(0); + for (yy = 0; yy<=(int32)buf.ogGetMaxY(); yy++) + for (xx = 0; xx<=(int32)buf.ogGetMaxX(); xx++) + buf.ogSetPixel(xx,yy,xx*yy); + blit->getBlitWithMask(buf, + buf.ogGetMaxX()/2-blit->getWidth(), + buf.ogGetMaxY()/2-blit->getHeight()); + buf.ogClear(0); + blit->put(buf,-10000,-10000); // test *really* off the screen + blit->put(buf,10000,10000); // test *really* off the screen + + blit->put(buf,-128,-128); + blit->put(buf,buf.ogGetMaxX()/2-128,-128); + blit->put(buf,buf.ogGetMaxX()-128,-128); + blit->put(buf,-128,buf.ogGetMaxY()/2-128); + blit->put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()/2-128); + blit->put(buf,buf.ogGetMaxX()-128,buf.ogGetMaxY()/2-128); + blit->put(buf,-128,buf.ogGetMaxY()-128); + blit->put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()-128); + blit->put(buf,buf.ogGetMaxX()-128,buf.ogGetMaxY()-128); + + getc(stdin); + for (count = 0; count < 1000; count++) { + blit->put(buf,random() % (buf.ogGetMaxX()+blit->getWidth()) - blit->getWidth(), + random() % (buf.ogGetMaxY()+blit->getHeight()) - blit->getHeight()); + } // for + getc(stdin); + for (yy = 0; yy<=(int32)buf.ogGetMaxY(); yy++) + for (xx = 0; xx<=(int32)buf.ogGetMaxX(); xx++) + buf.ogSetPixel(xx,yy,xx*yy); + + blit->getBlitWithMask(buf,buf.ogGetMaxX()/2,buf.ogGetMaxY()-128); + buf.ogClear(buf.ogRGB(128,128,128)); + blit->put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()/2-128); + getc(stdin); + delete blit; + + return; +} // testBlit + +void +testBlit2(ogSurface & buf) { + ogBlit * blit = new ogBlit(); + ogSurface * buf2 = new ogSurface(); + ogSurface * blitsource = new ogSurface(); + uInt32 xx,yy,count,colour; + buf.ogClear(0); + buf2->ogClone(buf); + blitsource->ogClone(buf); + + colour = 255; + for (count = 0; count < (buf2->ogGetMaxX()+1)/2; count+=4) { + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + buf2->ogGetMaxX()/2-count,buf2->ogGetMaxY(), + buf2->ogRGB(colour,colour,colour)); + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + buf2->ogGetMaxX()/2+count,buf2->ogGetMaxY(), + buf2->ogRGB(colour,colour,colour)); + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + buf2->ogGetMaxX()/2-count,0, + buf2->ogRGB(0,colour,0)); + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + buf2->ogGetMaxX()/2+count,0, + buf2->ogRGB(0,colour,0)); + --colour; + } // for + + colour = 255; + for (count = 0; count < (buf.ogGetMaxY()+1)/2; count+=4) { + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + 0, buf2->ogGetMaxY()/2-count, + buf2->ogRGB(colour,0,0)); + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + 0, buf2->ogGetMaxY()/2+count, + buf2->ogRGB(colour,0,0)); + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + buf2->ogGetMaxX(), buf2->ogGetMaxY()/2-count, + buf2->ogRGB(0,0,colour)); + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + buf2->ogGetMaxX(), buf2->ogGetMaxY()/2+count, + buf2->ogRGB(0,0,colour)); + --colour; + } // for + for (yy = 0; yy<=buf2->ogGetMaxY(); yy++) + for (xx = 0; xx<=buf2->ogGetMaxX(); xx++) + buf2->ogSetPixel(xx,yy,xx*yy); + for (count = 0; count<200; count++) + blitsource->ogFillCircle(random() % blitsource->ogGetMaxX(), random() % blitsource->ogGetMaxY(), + random() % 35+1,blitsource->ogRGB(255,255,255)); + + blit->get(*blitsource,0,0,blitsource->ogGetMaxX(),blitsource->ogGetMaxY()); + blit->save("bigblit.blt"); + delete blit; + blit = new ogBlit; + blit->load("bigblit.blt"); + for (count = 0; count<=256; count+=4) { + for (yy = 0; yy<=buf2->ogGetMaxY(); yy++) + for (xx = 0; xx<=buf2->ogGetMaxX(); xx++) + buf2->ogSetPixel(xx,yy,xx*yy*count); + + blit->getBlitWithMask(*buf2,0,0); + blit->put(buf,0,0); + } // for + + getc(stdin); + delete blitsource; + delete buf2; + delete blit; + return; +} // testBlit2 + +void +testBlit3(ogSurface & buf) { + int32 count; + ogBlit * blit = NULL; + ogSurface * buf2 = NULL; + buf2 = new ogSurface(); + blit = new ogBlit(); + buf.ogClear(0); + buf.ogFillCircle(buf.ogGetMaxX()/2,buf.ogGetMaxY()/2,14,buf.ogRGB(255,255,255)); + blit->get(buf,buf.ogGetMaxX()/2-20,buf.ogGetMaxY()/2-20, + buf.ogGetMaxX()/2+20,buf.ogGetMaxY()/2+20); + blit->put(buf,0,0); + for (count=0; count<(int32)buf.ogGetMaxX(); count++) + buf.ogLine(count,0,count,buf.ogGetMaxY(),count); + buf2->ogClone(buf); + blit->getBlitWithMask(*buf2,10,10); + buf.ogClear(buf.ogRGB(63,63,63)); + for (count=-40; count<(int32)buf.ogGetMaxX()+10; count++) { + blit->getBlitWithMask(*buf2,count,buf2->ogGetMaxY()/2-20); + blit->put(buf,count,buf.ogGetMaxY()/2-20); + blit->getBlitWithMask(*buf2,buf2->ogGetMaxX()/2-20,count); + blit->put(buf,buf.ogGetMaxX()/2-20,count); + } + getc(stdin); + delete blit; + return; +} // testBlit3 + +void +testSaveLoadPal(ogSurface & buf) { + uInt32 count; + testRect(buf); + for (count=0; count<256; count++) + buf.ogSetRGBPalette(count,count,count,count); + if (buf.ogSavePal("test.pal")==false) cout << "ogSavePal() failed" << endl; + for (count=0; count<256; count++) + buf.ogSetRGBPalette(count,0,0,0); + if (buf.ogLoadPal("test.pal")==false) cout << "ogLoadPal() failed" << endl; + testRect(buf); +} // testSaveLoadPal + +void +testPolygon(ogSurface & buf) { + ogPoint points[16]; + uInt32 count; + buf.ogClear(0); + for (count=0; count<16; count++) { + points[count].x = random() % buf.ogGetMaxX(); + points[count].y = random() % buf.ogGetMaxY(); + } // for + buf.ogFillPolygon(16, points, buf.ogRGB(random() & 255,random() & 255,random() & 255)); + getc(stdin); + return; +} // testPolygon + +void +testSpline(ogSurface & buf) { + ogPoint points[8]; + uInt32 i; + for (i=0; i<8; i++) { + points[i].x = random() % buf.ogGetMaxX(); + points[i].y = random() % buf.ogGetMaxY(); + } // for + buf.ogClear(0); + buf.ogPolygon(8, points, buf.ogRGB(22,229,52)); + buf.ogSpline(8, points, 24, buf.ogRGB(64,64,255)); + buf.ogBSpline(8, points, 24, buf.ogRGB(255,128,128)); + getchar(); + return; +} // testSpline + +void +testFont(ogSurface &buf) { + ogBitFont* font = NULL; + int32 xx, yy; + unsigned char ch; + font = new ogBitFont(); + font->load("script.DPF"); + ch = '\0'; + for (yy = 0; yy < 16; yy++) + for (xx = 0; xx < 16; xx++) + font->putChar(buf,xx*font->getWidth(),yy*font->getHeight(),ch++); + + font->justifyText(buf,CenterText,CenterText,"Hello world"); + getchar(); + delete font; +} // testFont + +int main() { + ogSurface* buf = NULL; + ogSurface* screen = NULL; + buf = new ogSurface(); +// screen = new ogDisplay_VESA(); + screen = new ogSurface(); +// buf->ogCreate(640,480,OG_PIXFMT_32BPP); + screen->ogCreate(800,600,OG_PIXFMT_32BPP); + srandom(time(NULL)); + + testFont(*screen); +/* testRect(*screen); + testCircle(*screen); + testLine(*screen); + testVFlip(*screen); + testHFlip(*screen); + testArc(*screen); + testSetPixel(*screen); + testClear(*screen); + testSprite(*screen); + testBlit(*screen); + */ +// testBlit2(*screen); +// testBlit3(*screen); // special test for 320x200x8bpp +// testSaveLoadPal(*screen); // use an 8bpp mode +/* testPolygon(*screen); + testCurve(*screen); + testSpline(*screen); + */ + delete buf; +// delete screen; + return(0); +} diff --git a/lockwasher/src/lib/views/objgfx30.cpp b/lockwasher/src/lib/views/objgfx30.cpp new file mode 100644 index 0000000..7153df0 --- /dev/null +++ b/lockwasher/src/lib/views/objgfx30.cpp @@ -0,0 +1,2847 @@ +/******************************************************* +$Id: objgfx30.cpp,v 1.9 2003/04/16 06:07:49 flameshadow Exp $ +*******************************************************/ + +extern "C" { + #include + #include + #include // for stuff in fileExists + #include + } + +#include +#include "defpal.inc" + +using namespace std; +// #include "../ubixos-home/src/sys/include/ubixos/types.h" + +#define ROUND(f) (int)((f) + ((f) > 0 ? 0.5 : -0.5)) + +struct ogHLine { + int32 xStart; + int32 xEnd; +}; + +struct ogHLineList { + int32 length; + int32 yStart; + int32 * xLeft; + int32 * xRight; +}; + +struct ogPointListHeader { + int32 length; + ogPoint * PointPtr; +}; + +struct ogEdgeState { + ogEdgeState* nextEdge; + int32 x; + int32 startY; + int32 wholePixelXMove; + int32 xDirection; + int32 errorTerm; + int32 errorTermAdjUp; + int32 errorTermAdjDown; + int32 count; +}; + +class ogEdgeTable { + public: + ogEdgeState * globalEdges; + ogEdgeState * activeEdges; + ogEdgeTable(void) { globalEdges = activeEdges = NULL; return; } + void advanceAET(void); + void buildGET(uInt32 numPoints, ogPoint * polyPoints); + void moveXSortedToAET(int32 yToMove); + void scanOutAET(ogSurface & destObject, int32 yToScan, uInt32 colour); + void xSortAET(void); + ~ogEdgeTable(void); +}; // ogEdgeState + +void +ogEdgeTable::advanceAET(void) { + ogEdgeState * currentEdge; + ogEdgeState ** currentEdgePtr; + + currentEdgePtr = &activeEdges; + currentEdge = activeEdges; + while (currentEdge!=NULL) { + currentEdge->count--; + if (currentEdge->count==0) { + // this edge is finished, so remove it from the AET + *currentEdgePtr = currentEdge->nextEdge; + } else { + // advance the edge's x coord by minimum move + currentEdge->x += currentEdge->wholePixelXMove; + // determine whether it's time for X to advance one extra + currentEdge->errorTerm += currentEdge->errorTermAdjUp; + if (currentEdge->errorTerm>0) { + currentEdge->x += currentEdge->xDirection; + currentEdge->errorTerm -= currentEdge->errorTermAdjDown; + } // if + currentEdgePtr = ¤tEdge->nextEdge; + } // else + currentEdge = *currentEdgePtr; + } // while + return; +} // ogEdgeTable::advanceAET + +void +ogEdgeTable::buildGET(uInt32 numPoints, ogPoint * polyPoints) { + int32 i, x1, y1, x2, y2, deltaX, deltaY, width, tmp; + ogEdgeState * newEdgePtr; + ogEdgeState * followingEdge; + ogEdgeState ** followingEdgeLink; + + /* Creates a GET in the buffer pointed to by NextFreeEdgeStruc from + * the vertex list. Edge endpoints are flipped, if necessary, to + * guarantee all edges go top to bottom. The GET is sorted primarily + * by ascending Y start coordinate, and secondarily by ascending X + * start coordinate within edges with common Y coordinates } + */ + + // Scan through the vertex list and put all non-0-height edges into + // the GET, sorted by increasing Y start coordinate} + for (i = 0; i<(int32)numPoints; i++) { + // calculate the edge height and width + x1 = polyPoints[i].x; + y1 = polyPoints[i].y; + if (i==0) { + // wrap back around to the end of the list + x2 = polyPoints[numPoints-1].x; + y2 = polyPoints[numPoints-1].y; + } else { + x2 = polyPoints[i-1].x; + y2 = polyPoints[i-1].y; + } // else i!=0 + if (y1>y2) { + tmp = x1; + x1 = x2; + x2 = tmp; + tmp = y1; + y1 = y2; + y2 = tmp; + } // if y1>y2 + // skip if this can't ever be an active edge (has 0 height) + deltaY = y2-y1; + if (deltaY!=0) { + newEdgePtr = new ogEdgeState; + newEdgePtr->xDirection = ((deltaX = x2-x1) > 0) ? 1 : -1; + width = abs(deltaX); + newEdgePtr->x = x1; + newEdgePtr->startY = y1; + newEdgePtr->count = newEdgePtr->errorTermAdjDown = deltaY; + newEdgePtr->errorTerm = (deltaX >= 0) ? 0 : 1-deltaY; + if (deltaY>=width) { + newEdgePtr->wholePixelXMove = 0; + newEdgePtr->errorTermAdjUp = width; + } else { + newEdgePtr->wholePixelXMove = (width / deltaY) * newEdgePtr->xDirection; + newEdgePtr->errorTermAdjUp = width % deltaY; + } // else + followingEdgeLink = &globalEdges; + while (true) { + followingEdge = *followingEdgeLink; + if ((followingEdge == NULL) || + (followingEdge->startY >= y1) || + ((followingEdge->startY == y1) && + (followingEdge->x>=x1))) { + newEdgePtr->nextEdge = followingEdge; + *followingEdgeLink = newEdgePtr; + break; + } // if + followingEdgeLink = &followingEdge->nextEdge; + } // while + } // if deltaY!=0) + } // for + return; +} // ogEdgeTable::buildGET + +void +ogEdgeTable::moveXSortedToAET(int32 yToMove) { + ogEdgeState * AETEdge; + ogEdgeState * tempEdge; + ogEdgeState ** AETEdgePtr; + int32 currentX; + + /* The GET is Y sorted. Any edges that start at the desired Y + * coordinate will be first in the GET, so we'll move edges from + * the GET to AET until the first edge left in the GET is no + * longer at the desired Y coordinate. Also, the GET is X sorted + * within each Y cordinate, so each successive edge we add to the + * AET is guaranteed to belong later in the AET than the one just + * added. + */ + AETEdgePtr = &activeEdges; + while ((globalEdges!=NULL) && (globalEdges->startY==yToMove)) { + currentX = globalEdges->x; + // link the new edge into the AET so that the AET is still + // sorted by X coordinate + while (true) { + AETEdge = *AETEdgePtr; + if ((AETEdge==NULL) || (AETEdge->x>=currentX)) { + tempEdge = globalEdges->nextEdge; + *AETEdgePtr = globalEdges; + globalEdges->nextEdge = AETEdge; + AETEdgePtr = &globalEdges->nextEdge; + globalEdges = tempEdge; + break; + } else AETEdgePtr = &AETEdge->nextEdge; + } // while true + } // while globalEdges!=NULL and globalEdges->startY==yToMove + return; +} // ogEdgeTable::moveXSortedToAET + +void +ogEdgeTable::scanOutAET(ogSurface & destObject, int32 yToScan, uInt32 colour) { + ogEdgeState * currentEdge; + int32 leftX; + + /* Scan through the AET, drawing line segments as each pair of edge + * crossings is encountered. The nearest pixel on or to the right + * of the left edges is drawn, and the nearest pixel to the left + * of but not on right edges is drawn + */ + currentEdge = activeEdges; + while (currentEdge!=NULL) { + leftX = currentEdge->x; + currentEdge = currentEdge->nextEdge; + if (currentEdge!=NULL) { + if (leftX!=currentEdge->x) + destObject.ogHLine(leftX, currentEdge->x-1, yToScan, colour); + currentEdge = currentEdge->nextEdge; + } // if currentEdge != NULL + } // while + return; +} // ogEdgeTable::scanOutAET + +void +ogEdgeTable::xSortAET(void) { + ogEdgeState * currentEdge; + ogEdgeState * tempEdge; + ogEdgeState ** currentEdgePtr; + bool swapOccurred; + if (activeEdges==NULL) return; + do { + swapOccurred = false; + currentEdgePtr = &activeEdges; + currentEdge = activeEdges; + while (currentEdge->nextEdge!=NULL) { + if (currentEdge->x > currentEdge->nextEdge->x) { + // the second edge has a lower x than the first + // swap them in the AET + tempEdge = currentEdge->nextEdge->nextEdge; + *currentEdgePtr = currentEdge->nextEdge; + currentEdge->nextEdge->nextEdge = currentEdge; + currentEdge->nextEdge = tempEdge; + swapOccurred = true; + } // if + currentEdgePtr = &((*currentEdgePtr)->nextEdge); + currentEdge = *currentEdgePtr; + } // while + } while (swapOccurred); + return; +} // ogEdgeTable::xSortAET + +ogEdgeTable::~ogEdgeTable(void) { + ogEdgeState * edge; + ogEdgeState * tmpEdge; + tmpEdge = globalEdges; + // first walk the global edges and delete any non-null nodes + while (tmpEdge!=NULL) { + edge = tmpEdge; + tmpEdge = edge->nextEdge; + delete edge; + } // while + tmpEdge = activeEdges; + // next walk the activeEdges and delete any non-null nodes. Note that this should + // always be null + while (tmpEdge!=NULL) { + edge = tmpEdge; + tmpEdge = edge->nextEdge; + delete edge; + } // while + return; +} // ogEdgeTable::~ogEdgeTable + +static bool +fileExists(const char *file) +{ + FILE *f = fopen(file, "r"); + if (!f) + return false; + fclose(f); + return true; +} + +static int32 calculate(float mu, int32 p0, int32 p1, int32 p2, int32 p3); + +// ogSurface constructor +ogSurface::ogSurface(void) { + version = ogVERSION; + dataState = ogNONE; + buffer = NULL; + lineOfs = NULL; + pal = NULL; + xRes = 0; + yRes = 0; + maxX = 0; + maxY = 0; + bSize = 0; + lSize = 0; + transparentColor = 0; + BPP = 0; + redShifter = 0; + greenShifter = 0; + blueShifter = 0; + alphaShifter = 0; + redFieldPosition = 0; + greenFieldPosition = 0; + blueFieldPosition = 0; + alphaFieldPosition = 0; + antiAlias = true; + return; +} // ogSurface::ogSurface + +void +ogSurface::aaRawLine(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2, uInt32 colour) { + /* + * aaRawLine + * + * private method + * + * draws an unclipped anti-aliased line from (x1,y1) to (x2,y2) using colour + * + */ + uInt32 erradj, erracc; + uInt32 erracctmp, intshift, wgt, wgtcompmask; + int32 dx, dy, tmp, xDir, i; + uInt32 ct[32]; + uInt8 r,g,b; + uInt8 orig_r, orig_g, orig_b; + + if (y1 > y2) { + tmp= y1; + y1 = y2; + y2 = tmp; + + tmp= x1; + x1 = x2; + x2 = tmp; + } // if + + ogUnpackRGB(colour, orig_r, orig_g, orig_b); + + for (i=0; i<32; i++) { + r = (i*orig_r) / 31; + g = (i*orig_g) / 31; + b = (i*orig_b) / 31; + ct[31-i] = ogRGB(r,g,b); + } // for + + ogSetPixel(x1,y1,colour); + + dx = (x2-x1); + if (dx>=0) xDir=1; else xDir=-1; + dx = abs(dx); + dy = (y2 - y1); + + if (dy==0) { + ogHLine(x1,x2,y1,colour); + return; + } + + if (dx==0) { + ogVLine(x1,y1,y2,colour); + return; + } + + // this is incomplete.. diagonal lines don't travel through the + // center of pixels exactly + if (dx==dy) { + for (; dy != 0; dy--) { + x1+=xDir; + y1++; + ogSetPixel(x1,y1,colour); + } // for + return; + } // if dx==dy + + erracc = 0; + intshift = 32-5; + wgtcompmask = 31; + if (dy>dx) { + /* y-major. Calculate 32-bit fixed point fractional part of a pixel that + * X advances every time Y advances 1 pixel, truncating the result so that + * we won't overrun the endpoint along the X axis + */ + erradj = ((unsigned long long) dx << 32) / (unsigned long long)dy; + while (--dy) { + erracctmp = erracc; + erracc += erradj; + if (erracc <= erracctmp) x1 += xDir; + y1++; // y-major so always advance Y + /* the nbits most significant bits of erracc give us the intensity + * weighting for this pixel, and the complement of the weighting for + * the paired pixel. + */ + wgt = erracc >> intshift; + ogSetPixel(x1, y1, ct[wgt]); + ogSetPixel(x1+xDir, y1, ct[wgt^wgtcompmask]); + } // while + } else { + /* x-major line. Calculate 32-bit fixed-point fractional part of a pixel + * that Y advances each time X advances 1 pixel, truncating the result so + * that we won't overrun the endpoint along the X axis. + */ + erradj = ((unsigned long long)dy << 32) / (unsigned long long)dx; + // draw all pixels other than the first and last + while (--dx) { + erracctmp = erracc; + erracc += erradj; + if (erracc <= erracctmp) y1++; + x1 += xDir; // x-major so always advance X + /* the nbits most significant bits of erracc give us the intensity + * weighting for this pixel, and the complement of the weighting for + * the paired pixel. + */ + wgt = erracc >> intshift; + ogSetPixel(x1, y1, ct[wgt]); + ogSetPixel(x1, y1+1, ct[wgt^wgtcompmask]); + } // while + } // else + ogSetPixel(x2,y2,colour); + return; +} // ogSurface::aaRawLine + +uInt32 +ogSurface::rawGetPixel(uInt32 x, uInt32 y) { + uInt32 result; + switch (BPP) { + case 8: + __asm__ __volatile__( + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi] + " mov %%eax, %3 \n" // mov result, eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (result) // %2, %3 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] + " mov %%eax, %0 \n" // mov result, eax + : "=m" (result) + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x) // , "m" (result) // %2, %3 + ); + break; + case 24: + __asm__ __volatile__( + " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size + " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size + " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // edx,word ptr [edi] + " xor %%eax, %%eax \n" + " mov 2(%%edi), %%al \n" // mov al, [edi+2] + " shl $16, %%eax \n" // shl eax, 16 + " mov (%%edi), %%ax \n" // mov ax, [edi] + " mov %%eax, %3 \n" // mov result, eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (result) // %2, %3 + ); + break; + case 32: + __asm__ __volatile__( + " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " mov (%%edi),%%eax \n" // eax,word ptr [edi] + " mov %%eax, %3 \n" // mov result, eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (result) // %2, %3 + ); + } // switch + return result; +} // ogSurface::rawGetPixel + +void +ogSurface::rawSetPixel(uInt32 x, uInt32 y, uInt32 colour) { + switch (BPP) { + case 8: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%al, (%%edi) \n" // mov [edi], al + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], al + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + break; + case 24: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + break; + case 32: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%eax, (%%edi) \n" // mov [edi], eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + } // switch + return; +} // ogSurface::rawSetPixel + +bool +ogSurface::clipLine(int32& x1, int32& y1, int32& x2, int32& y2) { + /* + * clipLine() + * + * private method + * + * clips a line to (0,0),(maxX,maxY); returns true if + * the line segment is in bounds, false if none of the line segment is + * on the screen. Uses HJI's line clipping algorithm. + */ + + int32 tx1, ty1, tx2, ty2; + int32 OutCode; + uInt32 AndResult, OrResult; + AndResult = 15; + OrResult = 0; + OutCode = 0; + if (x1<0) OutCode+=8; + if (x1>(int32)maxX) OutCode+=4; + if (y1<0) OutCode+=2; + if (y1>(int32)maxY) OutCode++; + + AndResult &= OutCode; + OrResult |= OutCode; + OutCode = 0; + + if (x2<0) OutCode+=8; + if (x2>(int32)maxX) OutCode+=4; + if (y2<0) OutCode+=2; + if (y2>(int32)maxY) OutCode++; + + AndResult &= OutCode; + OrResult |= OutCode; + + if (AndResult>0) return false; + if (OrResult==0) return true; + + // some clipping is required here. + + tx1 = x1; + ty1 = y1; + tx2 = x2; + ty2 = y2; + + if (x1<0) { + ty1 = (x2*y1-x1*y2) / (x2-x1); + tx1 = 0; + } // if + else + if (x2<0) { + ty2 = (x2*y1-x1*y2) / (x2-x1); + tx2 = 0; + } // elseif + + if (x1>(int32)maxX) { + ty1 = (y1*(x2-maxX)+y2*(maxX-x1)) / (x2-x1); + tx1 = maxX; + } // if + else + if (x2>(int32)maxX) { + ty2 = (y1*(x2-maxX)+y2*(maxX-x1)) / (x2-x1); + tx2 = maxX; + } // elseif + + if (((ty1<0) && (ty2<0)) || + ((ty1>(int32)maxY) && (ty2>(int32)maxY))) return false; + + if (ty1<0) { + tx1 = (x1*y2-x2*y1) / (y2-y1); + ty1 = 0; + } // if + else + if (ty2<0) { + tx2 = (x1*y2-x2*y1) / (y2-y1); + ty2 = 0; + } // elseif + + if (ty1>(int32)maxY) { + tx1 = (x1*(y2-maxY)+x2*(maxY-y1)) / (y2-y1); + ty1 = maxY; + } // if + else + if (ty2>(int32)maxY) { + tx2 = (x1*(y2-maxY)+x2*(maxY-y1)) / (y2-y1); + ty2 = maxY; + } // elseif + + if (((uInt32)tx1>maxX) || ((uInt32)tx2>maxX)) return false; + + x1 = tx1; + y1 = ty1; + x2 = tx2; + y2 = ty2; + + return true; +} // ogSurface::clipLine + +void +ogSurface::rawLine(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2, uInt32 colour) { + /* + * ogSurface::rawLine() + * + * private method; draws an unclipped line from (x1,y1) to (x2,y2) + * + */ + int32 tc; + if (!ogAvail()) return; + switch (BPP) { + case 8: + __asm__ __volatile__( + " mov $1, %%ecx \n" // mov ecx, 1 + " bt $15, %%eax \n" // bt eax, 15 + " jnc rlxPositive8 \n" + " or $-1, %%ecx \n" // or ecx, -1 + " neg %%eax \n" // neg eax +"rlxPositive8: \n" + " add %%eax, %%eax \n" // add eax, eax + " bt $15, %%ebx \n" // bt ebx, 15 + " jnc rlyPositive8 \n" + " neg %%edx \n" // neg edx + " neg %%ebx \n" // neg ebx +"rlyPositive8: \n" + " add %%ebx, %%ebx \n" // add ebx, ebx + + " cmp %%ebx, %%eax \n" // cmp eax, ebx + " jle rlyGreater8 \n" + " push %%ecx \n" // push ecx + " mov %%eax, %%ecx \n" // mov ecx, eax + " mov %%ebx, %6 \n" // mov tc, ebx + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" // pop ecx +"rlxTop8: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%al, (%%edi) \n" // mov [edi], al + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone8 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddY8 \n" + " add %%edx, %%edi \n" // add edi, edx + " sub %%eax, %6 \n" // sub tc, eax +"rlNoAddY8: \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ebx, %6 \n" // add tc, ebx + " jmp rlxTop8 \n" + +"rlyGreater8: \n" + " push %%ecx \n" // push ecx + " mov %%ebx, %%ecx \n" // mov ecx, ebx + " mov %%eax, %6 \n" // mov tc, eax + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" +"rlyTop8: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%al, (%%edi) \n" // mov [edi], al + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone8 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddX8 \n" + " add %%ecx, %%edi \n" // add edi, ecx + " sub %%ebx, %6 \n" // sub tc, ebx +"rlNoAddX8: \n" + " add %%edx, %%edi \n" // add edi, edx + " add %%eax, %6 \n" // add tc, eax + " jmp rlyTop8 \n" +"rlDone8: \n" + : + : "D" ((uInt8 *)buffer+lineOfs[y1]+x1), // %0 + "S" ((uInt8 *)buffer+lineOfs[y2]+x2), // %1 + "a" (x2-x1), "b" (y2-y1), // %2, %3 + "d" (xRes), "m" (colour), // %4, %5 + "m" (tc) // %6 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " mov $1, %%ecx \n" // mov ecx, 1 + " bt $15, %%eax \n" // bt eax, 15 + " jnc rlxPositive16 \n" + " or $-1, %%ecx \n" // or ecx, -1 + " neg %%eax \n" // neg eax +"rlxPositive16: \n" + " add %%eax, %%eax \n" // add eax, eax + " bt $15, %%ebx \n" // bt ebx, 15 + " jnc rlyPositive16 \n" + " neg %%edx \n" // neg edx + " neg %%ebx \n" // neg ebx +"rlyPositive16: \n" + " add %%ebx, %%ebx \n" // add ebx, ebx + + " cmp %%ebx, %%eax \n" // cmp eax, ebx + " jle rlyGreater16 \n" + " push %%ecx \n" // push ecx + " mov %%eax, %%ecx \n" // mov ecx, eax + " mov %%ebx, %6 \n" // mov tc, ebx + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" // pop ecx +"rlxTop16: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%ax, (%%edi) \n" // mov [edi], ax + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone16 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddY16 \n" + " add %%edx, %%edi \n" // add edi, edx + " sub %%eax, %6 \n" // sub tc, eax +"rlNoAddY16: \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ebx, %6 \n" // add tc, ebx + " jmp rlxTop16 \n" + +"rlyGreater16: \n" + " push %%ecx \n" // push ecx + " mov %%ebx, %%ecx \n" // mov ecx, ebx + " mov %%eax, %6 \n" // mov tc, eax + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" +"rlyTop16: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%ax, (%%edi) \n" // mov [edi], ax + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone16 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddX16 \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " sub %%ebx, %6 \n" // sub tc, ebx +"rlNoAddX16: \n" + " add %%edx, %%edi \n" // add edi, edx + " add %%eax, %6 \n" // add tc, eax + " jmp rlyTop16 \n" +"rlDone16: \n" + : + : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1 << 1)), // %0 + "S" ((uInt8 *)buffer+lineOfs[y2]+(x2 << 1)), // %1 + "a" (x2-x1), "b" (y2-y1), // %2, %3 + "d" (xRes), "m" (colour), // %4, %5 + "m" (tc) // %6 + ); + break; + case 24: + __asm__ __volatile__( + " mov $1, %%ecx \n" // mov ecx, 1 + " bt $15, %%eax \n" // bt eax, 15 + " jnc rlxPositive24 \n" + " or $-1, %%ecx \n" // or ecx, -1 + " neg %%eax \n" // neg eax +"rlxPositive24: \n" + " add %%eax, %%eax \n" // add eax, eax + " bt $15, %%ebx \n" // bt ebx, 15 + " jnc rlyPositive24 \n" + " neg %%edx \n" // neg edx + " neg %%ebx \n" // neg ebx +"rlyPositive24: \n" + " add %%ebx, %%ebx \n" // add ebx, ebx + + " cmp %%ebx, %%eax \n" // cmp eax, ebx + " jle rlyGreater24 \n" + " push %%ecx \n" // push ecx + " mov %%eax, %%ecx \n" // mov ecx, eax + " mov %%ebx, %6 \n" // mov tc, ebx + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" // pop ecx +"rlxTop24: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone24 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddY24 \n" + " add %%edx, %%edi \n" // add edi, edx + " sub %%eax, %6 \n" // sub tc, eax +"rlNoAddY24: \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ebx, %6 \n" // add tc, ebx + " jmp rlxTop24 \n" + +"rlyGreater24: \n" + " push %%ecx \n" // push ecx + " mov %%ebx, %%ecx \n" // mov ecx, ebx + " mov %%eax, %6 \n" // mov tc, eax + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" +"rlyTop24: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone24 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddX24 \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " sub %%ebx, %6 \n" // sub tc, ebx +"rlNoAddX24: \n" + " add %%edx, %%edi \n" // add edi, edx + " add %%eax, %6 \n" // add tc, eax + " jmp rlyTop24 \n" +"rlDone24: \n" + : + : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1*3)), // %0 + "S" ((uInt8 *)buffer+lineOfs[y2]+(x2*3)), // %1 + "a" (x2-x1), "b" (y2-y1), // %2, %3 + "d" (xRes), "m" (colour), // %4, %5 + "m" (tc) // %6 + ); + break; + case 32: + __asm__ __volatile__( + " mov $1, %%ecx \n" // mov ecx, 1 + " bt $15, %%eax \n" // bt eax, 15 + " jnc rlxPositive32 \n" + " or $-1, %%ecx \n" // or ecx, -1 + " neg %%eax \n" // neg eax +"rlxPositive32: \n" + " add %%eax, %%eax \n" // add eax, eax + " bt $15, %%ebx \n" // bt ebx, 15 + " jnc rlyPositive32 \n" + " neg %%edx \n" // neg edx + " neg %%ebx \n" // neg ebx +"rlyPositive32: \n" + " add %%ebx, %%ebx \n" // add ebx, ebx + + " cmp %%ebx, %%eax \n" // cmp eax, ebx + " jle rlyGreater32 \n" + " push %%ecx \n" // push ecx + " mov %%eax, %%ecx \n" // mov ecx, eax + " mov %%ebx, %6 \n" // mov tc, ebx + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" // pop ecx +"rlxTop32: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%eax, (%%edi)\n" // mov [edi], eax + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone32 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddY32 \n" + " add %%edx, %%edi \n" // add edi, edx + " sub %%eax, %6 \n" // sub tc, eax +"rlNoAddY32: \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ebx, %6 \n" // add tc, ebx + " jmp rlxTop32 \n" + +"rlyGreater32: \n" + " push %%ecx \n" // push ecx + " mov %%ebx, %%ecx \n" // mov ecx, ebx + " mov %%eax, %6 \n" // mov tc, eax + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" +"rlyTop32: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%eax, (%%edi)\n" // mov [edi], eax + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone32 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddX32 \n" + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " sub %%ebx, %6 \n" // sub tc, ebx +"rlNoAddX32: \n" + " add %%edx, %%edi \n" // add edi, edx + " add %%eax, %6 \n" // add tc, eax + " jmp rlyTop32 \n" +"rlDone32: \n" + : + : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1 << 2)), // %0 + "S" ((uInt8 *)buffer+lineOfs[y2]+(x2 << 2)), // %1 + "a" (x2-x1), "b" (y2-y1), // %2, %3 + "d" (xRes), "m" (colour), // %4, %5 + "m" (tc) // %6 + ); + break; + } // switch + return; +} // ogSurface::rawLine + +bool +ogSurface::ogAlias(ogSurface& SrcObject, uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) { + uInt32 tmp; + if (dataState==ogOWNER) return false; + + if (x2> 3)); + lineOfs=((uInt32 *)SrcObject.lineOfs)+y1; + pal = SrcObject.pal; + xRes = SrcObject.xRes; + yRes = SrcObject.yRes; + maxX = (x2-x1); + maxY = (y2-y1); + bSize = 0; + lSize = 0; + transparentColor = SrcObject.transparentColor; + dataState = ogALIASING; + BPP = SrcObject.BPP; + // For 8bpp modes the next part doesn't matter + redFieldPosition = SrcObject.redFieldPosition; + greenFieldPosition = SrcObject.greenFieldPosition; + blueFieldPosition = SrcObject.blueFieldPosition; + alphaFieldPosition = SrcObject.alphaFieldPosition; + // The next part is only used by 15/16bpp + redShifter = SrcObject.redShifter; + greenShifter = SrcObject.greenShifter; + blueShifter = SrcObject.blueShifter; + alphaShifter = SrcObject.alphaShifter; + + antiAlias = SrcObject.antiAlias; + + return true; +} // ogSurface::ogAlias + +void +ogSurface::ogArc(int32 x_center, int32 y_center, uInt32 radius, + uInt32 s_angle, uInt32 e_angle, uInt32 colour) { + int32 p; + uInt32 x, y, tmp; + double alpha; + + if (radius==0) { + ogSetPixel(x_center, y_center, colour); + return; + } // if + + s_angle%=361; + e_angle%=361; + + if (s_angle>e_angle) { + tmp = s_angle; + s_angle = e_angle; + e_angle = tmp; + } // if + + x = 0; + y = radius; + p = 3-2*radius; + + while (x<=y) { + alpha = (180.0/3.14159265358979)*atan((double)x/(double)y); + if ((alpha>=s_angle) && (alpha<=e_angle)) + ogSetPixel(x_center-x, y_center-y, colour); + if ((90-alpha>=s_angle) && (90-alpha<=e_angle)) + ogSetPixel(x_center-y, y_center-x, colour); + if ((90+alpha>=s_angle) && (90+alpha<=e_angle)) + ogSetPixel(x_center-y, y_center+x,colour); + if ((180-alpha>=s_angle) && (180-alpha<=e_angle)) + ogSetPixel(x_center-x, y_center+y,colour); + if ((180+alpha>=s_angle) && (180+alpha<=e_angle)) + ogSetPixel(x_center+x, y_center+y,colour); + if ((270-alpha>=s_angle) && (270-alpha<=e_angle)) + ogSetPixel(x_center+y, y_center+x,colour); + if ((270+alpha>=s_angle) && (270+alpha<=e_angle)) + ogSetPixel(x_center+y, y_center-x,colour); + if ((360-alpha>=s_angle) && (360-alpha<=e_angle)) + ogSetPixel(x_center+x, y_center-y,colour); + if (p<0) + p+=4*x+6; + else { + p+=4*(x-y)+10; + --y; + } + ++x; + } // while + return; +} // ogSurface::ogArc + +bool +ogSurface::ogAvail(void) { + return ((buffer!=NULL) && (lineOfs!=NULL)); +} // ogSurface::ogAvail + +static int32 +calculate(float mu, int32 p0, int32 p1, int32 p2, int32 p3) { + float mu2, mu3; + mu2 = mu*mu; + mu3 = mu2*mu; + return (int32)(0.5f+(1.0/6.0)*(mu3*(-p0+3.0*p1-3.0*p2+p3)+ + mu2*(3.0*p0-6.0*p1+3.0*p2)+ + mu*(-3.0*p0+3.0*p2)+(p0+4.0*p1+p2))); +} // calculate + + +void +ogSurface::ogBSpline(uInt32 numPoints, ogPoint* points, uInt32 segments, + uInt32 colour) { + float mu, mudelta; + int32 x1,y1,x2,y2; + uInt32 n,h; + if (points==NULL) return; + if ((numPoints<4) || (numPoints>4096) || (segments==0)) return; + mudelta = 1.0/segments; + for (n=3; n=0) { + ogSetPixel(x_center+x,y_center+y,colour); + ogSetPixel(x_center+x,y_center-y,colour); + ogSetPixel(x_center-x,y_center+y,colour); + ogSetPixel(x_center-x,y_center-y,colour); + if (d + y > 0) { + y--; + d -= 2*y+1; + } // if + if (x > d) { + x++; + d += 2*x+1; + } // if + } // while + return; +} // ogSurface::ogCircle + +void +ogSurface::ogClear(uInt32 colour) { + uInt32 height = 0; + if (!ogAvail()) return; + __asm__ __volatile__("cld\n"); + switch (BPP) { + case 8: + __asm__ __volatile__( + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxY) + " inc %%ebx \n" // inc ebx (maxX) + " sub %%edx, %%esi \n" // sub esi, edx + " mov %%al, %%ah \n" // mov ah, al + " mov %%ax, %%cx \n" // mov cx, ax + " shl $16, %%eax \n" // shl eax, 16 + " mov %%cx, %%ax \n" // mov ax, cx + "loop8: \n" + " push %%edx \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " and $3, %%edx \n" // and edx, 3 + " shr $2, %%ecx \n" // shr ecx, 2 + " rep \n" + " stosl \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " rep \n" + " stosb \n" + " pop %%edx \n" + " add %%esi, %%edi \n" // add edi, esi + " dec %%ebx \n" + " jnz loop8 \n" + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "a" (colour), "b" (maxY), // %2, %3 + "c" (xRes), "d" (maxX) // %4, %5 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxX) + " inc %%ebx \n" // inc ebx (maxY) + " sub %%edx, %%esi \n" // sub esi, edx + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " mov %%ax, %%cx \n" // mov cx, ax + " shl $16, %%eax \n" // shl eax, 16 + " mov %%cx, %%ax \n" // mov ax, cx + "loop16: \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " shr $1, %%ecx \n" // shr ecx, 1 + " rep \n" + " stosl \n" + " jnc noc16 \n" + " stosw \n" + "noc16: \n" + " add %%esi, %%edi \n" // add edi, esi + " dec %%ebx \n" + " jnz loop16 \n" + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "a" (colour), "b" (maxY), // %2, %3 + "c" (xRes), "d" (maxX) // %4, %5 + ); + break; + case 24: + __asm__ __volatile__( + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxX) + " inc %%ebx \n" // inc ebx (maxY) + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " mov %%ebx, %6 \n" // mov height, ebx + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " mov %%eax, %%ebx \n" // mov ebx, eax + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " shr $16, %%ebx \n" // shr ebx, 16 + "oloop24: \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + "iloop24: \n" + " mov %%ax,(%%edi) \n" // mov [edi],ax + " movb %%bl,2(%%edi) \n" // mov [edi+2],bl + " add $3, %%edi \n" // add edi, 3 + " dec %%ecx \n" // dec ecx + " jnz iloop24 \n" + " add %%esi, %%edi \n" // add edi, esi + " decl %6 \n" // dec height + " jnz oloop24 \n" + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "a" (colour), "b" (maxY), // %2, %3 + "c" (xRes), "d" (maxX), // %4, %5 + "m" (height) // %6 + ); + break; + case 32: + __asm__ __volatile__( + + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxX) + " inc %%ebx \n" // inc ebx (maxY) + " mov %%edx, %%ecx \n" // mov ecx, edx + " shl $2, %%ecx \n" // shl ecx, 2 + " sub %%ecx, %%esi \n" // sub esi, ecx // adjust for pix size + "loop32: \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " rep \n" + " stosl \n" + " add %%esi, %%edi \n" // add edi, esi + " dec %%ebx \n" + " jnz loop32 \n" + + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "a" (colour), "b" (maxY), // %2, %3 + "c" (xRes), "d" (maxX) // %4, %5 + ); + } // switch + return; +} // ogSurface::ogClear + +bool +ogSurface::ogClone(ogSurface& SrcObject) { + bool created; + ogPixelFmt pixfmt; + if (SrcObject.dataState==ogNONE) return false; + SrcObject.ogGetPixFmt(pixfmt); + created = ogCreate(SrcObject.maxX+1,SrcObject.maxY+1,pixfmt); + if (!created) return false; + transparentColor = SrcObject.transparentColor; + antiAlias = SrcObject.antiAlias; + ogCopyPal(SrcObject); + ogCopy(SrcObject); + return true; +} // ogSurface::ogClone + +void +ogSurface::ogCopy(ogSurface& SrcObject) { + uInt32 count, xCount, yCount; + uInt32 xx, yy; + uInt8 r, g, b; + void * srcPtr; + + if (!ogAvail()) return; + if (!SrcObject.ogAvail()) return; + + xCount = SrcObject.maxX+1; + if (xCount>maxX+1) xCount=maxX+1; + yCount = SrcObject.maxY+1; + if (yCount>maxY+1) yCount=maxY+1; + if ((BPP!=SrcObject.BPP) || (redShifter!=SrcObject.redShifter) || + (blueShifter!=SrcObject.blueShifter) || + (greenShifter!=SrcObject.greenShifter)) { + for (yy=0; yy> 3); // adjust for bpp + for (count=0; count(int32)maxX) || (dY1>(int32)maxY)) return; + + // if any of the source buffer is out of bounds then do nothing + if (( (uInt32)sX1>SrcObject.maxX) || ((uInt32)sX2>SrcObject.maxX) || + ( (uInt32)sY1>SrcObject.maxY) || ((uInt32)sY2>SrcObject.maxY)) return; + + if (sX1>sX2) { + xx = sX1; + sX1= sX2; + sX2= xx; + } // if + + if (sY1>sY2) { + yy = sY1; + sY1= sY2; + sY2= yy; + } // if + + xCount = abs(sX2-sX1)+1; + yCount = abs(sY2-sY1)+1; + + if (dX1+xCount>(int32)maxX+1) xCount=maxX-dX1+1; + if (dY1+yCount>(int32)maxY+1) yCount=maxY-dY1+1; + + if (dX1<0) { + xCount += dX1; + sX1 -= dX1; + dX1 = 0; + } // if + + if (dY1<0) { + yCount += dY1; + sY1 -= dY1; + dY1 = 0; + } // if + + if ((dX1+xCount<0) || (dY1+yCount<0)) return; + + if ((BPP!=SrcObject.BPP) || (redShifter!=SrcObject.redShifter) || + (blueShifter!=SrcObject.blueShifter) || + (greenShifter!=SrcObject.greenShifter)) { + if (SrcObject.BPP==8) { + for (xx=0; xx<256; xx++) + pixmap[xx] = ogRGB(SrcObject.pal[xx].red, + SrcObject.pal[xx].green, + SrcObject.pal[xx].blue); + for (yy=0; yy<=yCount-1; yy++) + for (xx=0; xx<=xCount-1; xx++) + rawSetPixel(dX1+xx,dY1+yy, + pixmap[SrcObject.ogGetPixel(sX1+xx,sY1+yy)]); + } // if SrcObject->bpp + else + { + for (yy=0; yy<=yCount-1; yy++) + for (xx=0; xx<=xCount-1; xx++) { + SrcObject.ogUnpackRGB(SrcObject.ogGetPixel(sX1+xx,sY1+yy),r,g,b); + rawSetPixel(dX1+xx,dY1+yy,ogRGB(r,g,b)); + } // for + } // else + } // if + else + { + xCount *= (BPP+7) >> 3; + for (count=0; count> 3), // dest + src, // src + size); // size + + return; +} // ogSurface::ogCopyLineTo + +void +ogSurface::ogCopyLineFrom(uInt32 sx, uInt32 sy, void * dst, uInt32 size) { + /* + * ogCopyLineFrom() + * + * Inputs: + * + * sx - Source X of the target buffer + * sy - Source Y of the target buffer + * dest - where to put it + * size - size in bytes *NOT* pixels + * + * Copies a run of pixels (of the same format) to (x,y) of a buffer + * + * This method is required because of the different implementations of + * copying a run of pixels to a buffer + * + * WARNING!!! This does *NO* error checking. It is assumed that you've + * done all of that. ogCopyLineTo and ogCopyLineFrom are the only + * methods that don't check to make sure you're hosing things. Don't + * use this method unless YOU KNOW WHAT YOU'RE DOING!!!!!!!!! + */ + memcpy( dst, // dest + (uInt8*)buffer+lineOfs[sy]+sx*((BPP+7) >> 3), // src + size); // size + + return; +} // ogSurface::ogCopyLineFrom + +void +ogSurface::ogCopyPal(ogSurface& SrcObject) { + if (SrcObject.pal==NULL) return; + if (pal==NULL) pal = new ogRGBA[256]; + if (pal==NULL) return; + memcpy(pal, SrcObject.pal, sizeof(ogRGBA)*256); + return; +} // ogSurface::ogCopyPal + +bool +ogSurface::ogCreate(uInt32 _xRes, uInt32 _yRes,ogPixelFmt _pixformat) { + /* + * ogSurface::ogCreate() + * Allocates memory for a buffer of size _xRes by _yRes with + * the pixel format defined in _pixformat. Allocates memory + * for pal and lineOfs. + */ + uInt32 yy; + if (dataState==ogOWNER) { + free(buffer); + delete [] lineOfs; + delete [] pal; + } // if datastate + BPP = _pixformat.BPP; + bSize=_xRes*_yRes*((BPP+7) >> 3); + buffer = malloc(bSize); + if (buffer==NULL) return false; + memset(buffer,0,bSize); + lSize = _yRes*sizeof(uInt32); + lineOfs = new uInt32[_yRes]; + if (lineOfs == NULL) return false; + pal = new ogRGBA[256]; + if (pal == NULL) return false; + // copy the default palette into the buffer + memcpy(pal,DEFAULT_PALETTE,sizeof(ogRGBA)*256); + maxX=_xRes-1; + xRes=_xRes*((BPP+7) >> 3); + maxY=_yRes-1; + yRes=_yRes; + lineOfs[0]=0; + for (yy=1; yy<=maxY; yy++) + lineOfs[yy]=lineOfs[yy-1]+xRes; + dataState = ogOWNER; + // For 8bpp modes the next part doesn't matter + redFieldPosition=_pixformat.redFieldPosition; + greenFieldPosition=_pixformat.greenFieldPosition; + blueFieldPosition=_pixformat.blueFieldPosition; + alphaFieldPosition=_pixformat.alphaFieldPosition; + // The next part is only used by 15/16hpp + redShifter=8-_pixformat.redMaskSize; + greenShifter=8-_pixformat.greenMaskSize; + blueShifter=8-_pixformat.blueMaskSize; + alphaShifter=8-_pixformat.alphaMaskSize; + + // Turn anti aliasing off by default for 8bpp modes + antiAlias = (BPP>8); + owner = this; + return true; +} // ogSurface::ogCreate + +void +ogSurface::ogCubicBezierCurve(int32 x1, int32 y1, int32 x2, int32 y2, + int32 x3, int32 y3, int32 x4, int32 y4, + uInt32 segments, uInt32 colour) { + float tX1, tY1, tX2, tY2, tX3, tY3, mu, mu2, mu3, mudelta; + int32 xStart, yStart, xEnd, yEnd; + uInt32 n; + if (segments<1) return; + if (segments>128) segments=128; + + mudelta = 1.0/segments; + mu = mudelta; + tX1 =-x1+3*x2-3*x3+x4; + tY1 =-y1+3*y2-3*y3+y4; + tX2 =3*x1-6*x2+3*x3; + tY2 =3*y1-6*y2+3*y3; + tX3 =-3*x1+3*x2; + tY3 =-3*y1+3*y2; + + xStart = x1; + yStart = y1; + + for (n=1; n128) segments=128; + x2 = (x2*2)-((x1+x3)/2); + y2 = (y2*2)-((y1+y3)/2); + + ex = ((int64)(x2-x1) << 17) / segments; + ey = ((int64)(y2-y1) << 17) / (long long)segments; + fx = ((int64)(x3-(2*x2)+x1) << 16) / (segments*segments); + fy = ((int64)(y3-(2*y2)+y1) << 16) / (long long)(segments*segments); + + while (--segments>0) { + t1=x3; + t2=y3; + x3=((int64)((fx*segments+ex)*segments) / 65536L)+x1; + y3=((int64)((fy*segments+ey)*segments) / 65536L)+y1; + ogLine(t1, t2, x3, y3, colour); + } // while + ogLine(x3,y3,x1,y1,colour); + return; + +} // ogSurface::ogCurve + +void +ogSurface::ogFillCircle(int32 x_center, int32 y_center, + uInt32 radius, uInt32 colour) { + int32 x, y, d; + x = 0; + y = radius; + d = 2*(1-radius); + while (y>=0) { + ogHLine(x_center-x, x_center+x, y_center-y, colour); + ogHLine(x_center-x, x_center+x, y_center+y, colour); + if (d+y>0) { + y--; + d-=2*y+1; + } + if (x>d) { + x++; + d+=2*x+1; + } + } // while + return; +} // ogSurface::ogFillCircle + +#if 0 +!-/* Scan converts an edge from (X1,Y1) to (X2,Y2), not including the +!- * point at (X2,Y2). This avoids overlapping the end of one line with +!- * the start of the next, and causes the bottom scan line of the +!- * polygon not to be drawn. If SkipFirst != 0, the point at (X1,Y1) +!- * isn't drawn. For each scan line, the pixel closest to the scanned +!- * line without being to the left of the scanned line is chosen +!- */ +!-static void index_forward(int32 & index, uInt32 numPoints) { +!- index = (index + 1) % numPoints; +!- return; +!-} // index_forward +!- +!-static void index_backward(int32 & index, uInt32 numPoints) { +!- index = (index - 1 + numPoints) % numPoints; +!- return; +!-} // index_forward +!- +!-static void index_move(int32 & index, uInt32 numPoints, int32 direction) { +!- if (direction > 0) +!- index_forward(index, numPoints); +!- else +!- index_backward(index, numPoints); +!- return; +!-} // index_move +!- +!-static void scanEdge(int32 x1, int32 y1, int32 x2, int32 y2, +!- uInt32 & eIdx, int32 * xList) { +!- int32 y, deltaX, deltaY; +!- float inverseSlope; +!- +!- deltaX = x2 - x1; +!- deltaY = y2 - y1; +!- if (deltaY <= 0) return; +!- inverseSlope = deltaX / deltaY; +!- +!- // Store the X coordinate of the pixel closest to but not to the +!- // left of the line for each Y coordinate between Y1 and Y2, not +!- // including Y2 +!- y = y1; +!- do { +!- xList[eIdx] = x1+ (int32)(0.5f+((y-y1)*inverseSlope)); +!- y++; +!- eIdx++; +!- } while (y maxPointY) { +!- maxIndex = i; +!- maxPointY = polyPoints[i].y; // new bottom +!- } // else if +!- } // for +!- +!- if (minPointY == maxPointY) return; +!- +!- // scan in ascending order to find the last top-edge point +!- minIndexR = minIndexL; +!- while (polyPoints[minIndexR].y == minPointY) index_forward(minIndexR, numPoints); +!- index_backward(minIndexR, numPoints); // back up to last top-edge point +!- +!- // now scan in descending order to find the first top-edge point +!- while (polyPoints[minIndexL].y == minPointY) index_backward(minIndexL, numPoints); +!- index_forward(minIndexL, numPoints); +!- +!- // figure out which direction through the vertex list from the top +!- // vertex is the left edge and which is the right +!- leftEdgeDir = -1; +!- +!- topIsFlat = (polyPoints[minIndexL].x==polyPoints[minIndexR].x) ? 0 : 1; +!- if (topIsFlat==1) { +!- if (polyPoints[minIndexL].x > polyPoints[minIndexR].x) { +!- leftEdgeDir = 1; +!- temp = minIndexL; +!- minIndexL = minIndexR; +!- minIndexR = temp; +!- } +!- } else { +!- // Point to the downward end of the first line of each of the +!- // two edges down from the top +!- nextIndex = minIndexR; +!- index_forward(nextIndex, numPoints); +!- prevIndex = minIndexL; +!- index_forward(prevIndex, numPoints); +!- +!- deltaXN = polyPoints[nextIndex].x - polyPoints[minIndexL].x; +!- deltaYN = polyPoints[nextIndex].y - polyPoints[minIndexL].y; +!- deltaXP = polyPoints[prevIndex].x - polyPoints[minIndexL].x; +!- deltaYP = polyPoints[prevIndex].y - polyPoints[minIndexL].y; +!- if (deltaXN * deltaYP - deltaYN * deltaXP < 0) { +!- leftEdgeDir = 1; +!- temp = minIndexL; +!- minIndexL = minIndexR; +!- minIndexR = temp; +!- } // if +!- } // else +!- +!- /* Set the # of scan lines in the polygon, skipping the bottom edge +!- * and also skipping the top vertex if the top isn't flat because +!- * in that case the top vertex has a right edge component, and set +!- * the top scan line to draw, which is likewise the second line of +!- * the polygon unles the top if flat +!- */ +!- +!- workingHLineList.length = maxPointY - minPointY; +!- if (workingHLineList.length <= 0) return; +!- workingHLineList.yStart = minPointY; +!- +!- // get memory in which to srote the line list we generate +!- workingHLineList.xLeft = workingHLineList.xRight = NULL; +!- if ((workingHLineList.xLeft = new int32[workingHLineList.length]) == NULL) return; +!- if ((workingHLineList.xRight = new int32[workingHLineList.length]) == NULL) { +!- delete workingHLineList.xLeft; +!- return; +!- } +!- memset(workingHLineList.xLeft,0,workingHLineList.length*sizeof(int32)); +!- memset(workingHLineList.xRight,0,workingHLineList.length*sizeof(int32)); +!- +!- // scan the left edge and store the boundary points int he list +!- // Initial pointer for storing scan converted left-edge coords +!- edgePointIdx = 0; +!- +!- // start from the top of the left edge +!- curIndex = prevIndex = minIndexL; +!- +!- do { +!- index_move(curIndex, numPoints, leftEdgeDir); +!- scanEdge(polyPoints[prevIndex].x, +!- polyPoints[prevIndex].y, +!- polyPoints[curIndex].x, +!- polyPoints[curIndex].y, +!- edgePointIdx, +!- workingHLineList.xLeft); +!- prevIndex = curIndex; +!- } while (curIndex != maxIndex); +!- +!- edgePointIdx = 0; +!- curIndex = prevIndex = minIndexR; +!- // Scan convert the right edge, top to bottom. X coordinates are +!- // adjusted 1 to the left, effectively causing scan conversion of +!- // the nearest points to the left of but not exactly on the edge } +!- do { +!- index_move(curIndex, numPoints, -leftEdgeDir); +!- scanEdge(polyPoints[prevIndex].x, +!- polyPoints[prevIndex].y, +!- polyPoints[curIndex].x, +!- polyPoints[curIndex].y, +!- edgePointIdx, +!- workingHLineList.xRight); +!- prevIndex = curIndex; +!- } while (curIndex != maxIndex); +!- +!- ogPolygon(numPoints, polyPoints, colour); +!- +!- for (i = 0; i < workingHLineList.length; i++) { +!- ogHLine(workingHLineList.xLeft[i], workingHLineList.xRight[i], +!- workingHLineList.yStart+i, colour); +!- } // for +!- +!- ogPolygon(numPoints, polyPoints, colour); +!- +!- delete workingHLineList.xLeft; +!- delete workingHLineList.xRight; +!- +!- return; +!-} // ogSurface::ogFillConvexPolygon +#endif + +void +ogSurface::ogFillPolygon(uInt32 numPoints, ogPoint* polyPoints, uInt32 colour) { + ogEdgeTable * edges; + int32 currentY; + + if (numPoints<3) return; +/* if (numPoints==3) { + * ogFillConvexPolygon(numPoints, polyPoints, colour); + * return; + * } // if + */ + ogPolygon(numPoints, polyPoints, colour); + edges = new ogEdgeTable(); + edges->buildGET(numPoints, polyPoints); + currentY = edges->globalEdges->startY; + while ((edges->globalEdges!=NULL) || (edges->activeEdges!=NULL)) { + edges->moveXSortedToAET(currentY); + edges->scanOutAET(*this, currentY, colour); + edges->advanceAET(); + edges->xSortAET(); + currentY++; + if (currentY>(int32)maxY) break; // if we've gone past the bottom, stop + } // while + delete edges; + return; +} // ogSurface::ogFillPolygon + +void +ogSurface::ogFillRect(int32 x1, int32 y1, int32 x2, int32 y2, uInt32 colour) { + int32 yy,tmp; + + if (x2(int32)maxY)) return; + if (y1<0) y1=0; + if (y2>(int32)maxY) y2=maxY; + for (yy=y1; yy<=y2; yy++) + ogHLine(x1,x2,yy,colour); +} // ogSurface::ogFillRect + +void ogSurface::ogFillTriangle(int32 x1, int32 y1, int32 x2, int32 y2, + int32 x3, int32 y3, uInt32 colour) { + ogPoint Points[3]; + Points[0].x = x1; + Points[0].y = y1; + Points[1].x = x2; + Points[1].y = y2; + Points[2].x = x3; + Points[2].y = y3; +// ogFillConvexPolygon(3,Points,colour); + ogFillPolygon(3,Points,colour); + return; +} // ogSurface::ogFillTriangle + +void +ogSurface::ogGetPixFmt(ogPixelFmt& pixfmt) { + pixfmt.BPP=BPP; + pixfmt.redFieldPosition=redFieldPosition; + pixfmt.greenFieldPosition=greenFieldPosition; + pixfmt.blueFieldPosition=blueFieldPosition; + pixfmt.alphaFieldPosition=alphaFieldPosition; + pixfmt.redMaskSize=8-redShifter; + pixfmt.greenMaskSize=8-greenShifter; + pixfmt.blueMaskSize=8-blueShifter; + pixfmt.alphaMaskSize=8-alphaShifter; + return; +} // ogSurface::ogGetPixFmt + +uInt32 +ogSurface::ogGetPixel(int32 x, int32 y) { + uInt32 result; + if (!ogAvail()) return transparentColor; + + if (((uInt32)x>maxX) || ((uInt32)y>maxY)) return transparentColor; + + switch (BPP) { + case 8: + __asm__ __volatile__( + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi] + " mov %%eax, %3 \n" // mov result, eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (result) // %2, %3 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] + " mov %%eax, %0 \n" // mov result, eax + : "=m" (result) + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x) // , "m" (result) // %2, %3 + ); + break; + case 24: + __asm__ __volatile__( + " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size + " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size + " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // edx,word ptr [edi] + " xor %%eax, %%eax \n" + " mov 2(%%edi), %%al \n" // mov al, [edi+2] + " shl $16, %%eax \n" // shl eax, 16 + " mov (%%edi), %%ax \n" // mov ax, [edi] + " mov %%eax, %3 \n" // mov result, eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (result) // %2, %3 + ); + break; + case 32: + __asm__ __volatile__( + " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " mov (%%edi),%%eax \n" // eax,word ptr [edi] + " mov %%eax, %3 \n" // mov result, eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (result) // %2, %3 + ); + } // switch + return result; +} // ogSurface::ogGetPixel + +void * +ogSurface::ogGetPtr(uInt32 x, uInt32 y) { +// return (ogAvail() ? ( (uInt8*)buffer+(lineOfs[y]+x*((BPP+7) >> 3)) ) : NULL ); + return ((uInt8*)buffer+(lineOfs[y]+x*((BPP+7) >> 3))); +} // ogSurface::ogGetPtr + +void +ogSurface::ogHFlip(void) { + void * tmpBuf1; + void * tmpBuf2; + uInt32 xWidth, count; + if (!ogAvail()) return; + xWidth = (maxX+1)*((BPP+7) >> 3); + tmpBuf1 = malloc(xWidth); + tmpBuf2 = malloc(xWidth); + if ((tmpBuf1!=NULL) && (tmpBuf2!=NULL)) + for (count=0; count<=(maxY/2); count++) { + ogCopyLineFrom(0,count,tmpBuf1,xWidth); + ogCopyLineFrom(0,maxY-count,tmpBuf2,xWidth); + ogCopyLineTo(0,maxY-count,tmpBuf1,xWidth); + ogCopyLineTo(0,count,tmpBuf2,xWidth); +// memcpy(tmpBuf,((uInt8*)buffer+lineOfs[count]),xWidth); +// memcpy(((uInt8*)buffer+lineOfs[count]), +// ((uInt8*)buffer+lineOfs[maxY-count]), +// xWidth); +// memcpy(((uInt8*)buffer+lineOfs[maxY-count]),tmpBuf,xWidth); + } // for + free(tmpBuf2); + free(tmpBuf1); + return; +} // ogSurface::ogHFlip + +void +ogSurface::ogHLine(int32 x1, int32 x2, int32 y, uInt32 colour) { + int32 tmp; + + if (!ogAvail()) return; + if ((uInt32)y>maxY) return; + if (x1>x2) { + tmp= x1; + x1 = x2; + x2 = tmp; + } // if + if (x1<0) x1 = 0; + if (x2>(int32)maxX) x2=maxX; + if (x2> redShifter) << redFieldPosition | + (green >> greenShifter) << greenFieldPosition | + (blue >> blueShifter) << blueFieldPosition; + break; + case 24: + case 32: + colour = ( (red << redFieldPosition) | + (green << greenFieldPosition) | + (blue << blueFieldPosition) ); + } // switch + //asm("": "=a" (lastclr)); + return colour; +} // ogSurface::ogRGB + +bool +ogSurface::ogSavePal(const char *palfile) { + FILE * f; + uInt32 lresult; + if (pal==NULL) return false; + if ((f = fopen(palfile, "wb"))==NULL) return false; + lresult = fwrite(pal,sizeof(ogRGBA),256,f); + fclose(f); + return (lresult == 256); +} // ogSurface::ogSavePal + +void +ogSurface::ogScale(ogSurface& SrcObject) { + ogScaleBuf(0,0,maxX,maxY,SrcObject,0,0,SrcObject.maxX,SrcObject.maxY); + return; +} // ogSurface::ogScale + +void +ogSurface::ogScaleBuf(int32 dX1, int32 dY1, int32 dX2, int32 dY2, + ogSurface& SrcObject, + int32 sX1, int32 sY1, int32 sX2, int32 sY2) { + + uInt32 sWidth, dWidth; + uInt32 sHeight, dHeight; + int32 sx, sy, xx, yy; + uInt32 xInc, yInc; + uInt32 origdX1, origdY1; + ogPixelFmt pixFmt; + ogSurface * tmpBuf; + ogSurface * sBuf; + ogSurface * dBuf; + bool doCopyBuf; + uInt8 scaleBPP; + + origdX1 = origdY1 = 0; // to keep the compiler from generating a warning + + if (!ogAvail()) return; + if (!SrcObject.ogAvail()) return; + + if (sX1>sX2) { + xx = sX1; + sX1= sX2; + sX2= xx; + } + + if (sY1>sY2) { + yy = sY1; + sY1= sY2; + sY2= yy; + } + + // if any part of the source falls outside the buffer then don't do anything + + if (((uInt32)sX1>SrcObject.maxX) || ((uInt32)sX2>SrcObject.maxX) || + ((uInt32)sY1>SrcObject.maxY) || ((uInt32)sY2>SrcObject.maxY)) return; + + if (dX1>dX2) { + xx = dX1; + dX1= dX1; + dX2= xx; + } + + if (dY1>dY2) { + yy = dY1; + dY1= dY2; + dY2= yy; + } + + dWidth = (dX2-dX1)+1; + if (dWidth<=0) return; + + dHeight = (dY2-dY1)+1; + if (dHeight<=0) return; + + sWidth = (sX2-sX1)+1; + sHeight = (sY2-sY1)+1; + + // convert into 16:16 fixed point ratio + xInc = (sWidth << 16) / dWidth; + yInc = (sHeight << 16) / dHeight; + + if (dX2>(int32)maxX) { + xx = (xInc*(dX1-maxX)) >> 16; + sX1 -= xx; + sWidth -= xx; + dWidth -= (dX1-maxX); + dX1 = maxX; + } + + if (dY2>(int32)maxY) { + yy = (yInc*(dY2-maxY)) >> 16; + sY2 -= yy; + sHeight -= yy; + dHeight -= (dY2-maxY); + dY2 = maxY; + } + + if (dX1<0) { + xx = (xInc*(-dX1)) >> 16; + sX1 += xx; + sWidth -= xx; + dWidth += dX1; + dX1 = 0; + } + + if (dY1<0) { + yy = (yInc*(-dY1)) >> 16; + sY1 += yy; + sHeight -= yy; + dHeight += dY1; + dY1 = 0; + } + + if ((dWidth<=0) || (dHeight<=0)) return; + if ((sWidth<=0) || (sHeight<=0)) return; + + // Do a quick check to see if the scale is 1:1 .. in that case just copy + // the image + + if ((dWidth==sWidth) && (dHeight==sHeight)) { + ogCopyBuf(dX1,dY1,SrcObject,sX1,sY1,sX2,sY2); + return; + } + + tmpBuf = NULL; + + /* + * Alright.. this is how we're going to optimize the case of different + * pixel formats. We are going to use copyBuf() to automagically do + * the conversion for us using tmpBuf. Here's how it works: + * If the source buffer is smaller than the dest buffer (ie, we're making + * something bigger) we will convert the source buffer first into the dest + * buffer's pixel format. Then we do the scaling. + * If the source buffer is larger than the dest buffer (ie, we're making + * something smaller) we will scale first and then use copyBuf to do + * the conversion. + * This method puts the onus of conversion on the copyBuf() function which, + * while not excessively fast, does the job. + * The case in which the source and dest are the same size is handled above. + * + */ + + if ( (BPP!=SrcObject.BPP) || (redShifter!=SrcObject.redShifter) || + (blueShifter!=SrcObject.blueShifter) || + (greenShifter!=SrcObject.greenShifter)) { + tmpBuf = new ogSurface(); + if (tmpBuf==NULL) return; + if (sWidth*sHeight*((SrcObject.BPP+7)>>3)<=dWidth*dHeight*((BPP+7)>>3)) { + // if the number of pixels in the source buffer is less than the + // number of pixels in the dest buffer then... + ogGetPixFmt(pixFmt); + if (tmpBuf->ogCreate(sWidth,sHeight,pixFmt)==false) return; + tmpBuf->ogCopyPal(SrcObject); + tmpBuf->ogCopyBuf(0,0,SrcObject,sX1,sY1,sX2,sY2); + sX2 -= sX1; + sY2 -= sY1; + sX1 = 0; + sY1 = 0; + sBuf = tmpBuf; + dBuf = this; + doCopyBuf = false; // do we do a copyBuf later? + scaleBPP = BPP; + } else { + SrcObject.ogGetPixFmt(pixFmt); + if (tmpBuf->ogCreate(dWidth,dHeight,pixFmt)==false) return; +// tmpBuf->ogCopyPal(&this); + origdX1 = dX1; + origdY1 = dY1; + dX1 = 0; + dY1 = 0; + dX2 = tmpBuf->maxX; + dY2 = tmpBuf->maxY; + sBuf = &SrcObject; + dBuf = tmpBuf; + doCopyBuf = true; + scaleBPP = SrcObject.BPP; + } // else + } else { + // pixel formats are identical + sBuf = &SrcObject; + dBuf = this; + doCopyBuf = false; + scaleBPP = BPP; + } // else + + sy = sY1 << 16; + + for (yy = dY1; yy <=dY2; yy++) { + sx = 0; + for (xx = dX1; xx <= dX2; xx++) { + dBuf->rawSetPixel(xx,yy,sBuf->rawGetPixel(sX1+(sx >> 16),(sy>>16))); + sx+=xInc; + } // for xx + sy += yInc; + } // for yy + + if ((doCopyBuf) && (tmpBuf!=NULL)) + ogCopyBuf(origdX1,origdY1,*tmpBuf,0,0,tmpBuf->maxX,tmpBuf->maxY); + delete tmpBuf; + return; +} // ogSurface::ogScaleBuf + +bool +ogSurface::ogSetAntiAlias(bool _AntiAlias) { + bool tmp; + tmp = antiAlias; + antiAlias = _AntiAlias; + return tmp; +} // ogSurface::ogSetAntiAlias + +void +ogSurface::ogSetPixel(int32 x, int32 y, uInt32 colour) { + if (!ogAvail()) return; +// if ((buffer==NULL) || (lineOfs==NULL)) return; + if (((uInt32)x>maxX) || ((uInt32)y>maxY)) return; + switch (BPP) { + case 8: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx * 4] + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%al, (%%edi) \n" // mov [edi], al + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " mov %3, %%eax \n" // mov eax, colour + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], al + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (colour) // %2, %3 + ); + break; + case 24: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + break; + case 32: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%eax, (%%edi) \n" // mov [edi], eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + } // switch + return; +} // ogSurface::ogSetPixel + +void +ogSurface::ogSetRGBPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) { + if (pal==NULL) return; + pal[colour].red = red; + pal[colour].green = green; + pal[colour].blue = blue; + return; +} // ogSurface::ogSetRGBPalette + +uInt32 +ogSurface::ogSetTransparentColor(uInt32 colour) { + uInt32 tmp; + tmp = transparentColor; + transparentColor = colour; + return tmp; +} // ogSurface::ogSetTransparentColor + +static double f(double g) { return g*g*g-g; } + +void +ogSurface::ogSpline(uInt32 numPoints, ogPoint* points, uInt32 segments, + uInt32 colour) { + int32 i, oldY, oldX, x, y, j; + float part, t, xx, yy, tmp; + float * zc; + float * dx; + float * dy; + float * u; + float * wndX1; + float * wndY1; + float * px; + float * py; + + bool runOnce; + if ((numPoints<2) || (points==NULL)) return; + zc = new float[numPoints]; + dx = new float[numPoints]; + dy = new float[numPoints]; + u = new float[numPoints]; + wndX1 = new float[numPoints]; + wndY1 = new float[numPoints]; + px = new float[numPoints]; + py = new float[numPoints]; + if ((zc==NULL) || (dx==NULL) || (dy==NULL) || (wndX1==NULL) || + (wndY1==NULL) || (px==NULL) || (py==NULL)) goto safeexit; + + for (i = 0; (uInt32)i0; i--) { + py[i] = (wndY1[i]-u[i]*py[i+1])/dy[i]; + px[i] = (wndX1[i]-u[i]*px[i+1])/dx[i]; + } // for + + for (i = 0; (uInt32)i < numPoints-1; i++) { + for (j = 0; (uInt32)j <= segments; j++) { + part = zc[i]-(((zc[i]-zc[i+1])/segments)*j); + t = (part-zc[i])/u[i]; + part = t * points[i+1].y + + (1.0-t)*points[i].y + + u[i] * u[i] * ( f(t) * py[i+1] + f(1.0-t) * py[i]) /6.0; +// y = Round(part); + y = ROUND(part+0.5f); + part = zc[i]-(((zc[i]-zc[i+1])/segments)*j); + t = (part-zc[i])/u[i]; + part = t*points[i+1].x+(1.0-t)*points[i].x+u[i]*u[i]*(f(t)*px[i+1]+ + f(1.0-t)*px[i])/6.0; + +// x = Round(part); + x = ROUND(part+0.5f); + if (runOnce) ogLine(oldX, oldY, x, y, colour); else runOnce = true; + oldX = x; + oldY = y; + } // for j + } // for i +safeexit: + delete [] py; + delete [] px; + delete [] wndY1; + delete [] wndX1; + delete [] u; + delete [] dy; + delete [] dx; + delete [] zc; + + return; +} // ogSurface::ogSpline + + +void +ogSurface::ogTriangle(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, + uInt32 colour) { + ogLine(x1,y1,x2,y2,colour); + ogLine(x2,y2,x3,y3,colour); + ogLine(x3,y3,x1,y1,colour); + return; +} // ogSurface::ogTriangle + +void +ogSurface::ogUnpackRGB(uInt32 colour, uInt8& red, uInt8& green, uInt8& blue) { + switch (BPP) { + case 8: + if (pal==NULL) { + red = 0; + green = 0; + blue = 0; + return; + } + if (colour>255) colour &= 255; + red = pal[colour].red; + green = pal[colour].green; + blue = pal[colour].blue; + break; + case 15: + case 16: + red = ((colour >> redFieldPosition) << redShifter); + green = ((colour >> greenFieldPosition) << greenShifter); + blue = ((colour >> blueFieldPosition) << blueShifter); + if ((red) && (redShifter)) red+=(1 << redShifter)-1; + if ((green) && (greenShifter)) green+=(1 << greenShifter)-1; + if ((blue) && (blueShifter)) blue+=(1 << blueShifter)-1; + break; + case 24: + case 32: + red = colour >> redFieldPosition; + green = colour >> greenFieldPosition; + blue = colour >> blueFieldPosition; + break; + default: + red = 0; + green = 0; + blue = 0; + } + return; +} // ogSurface::ogUnpackRGB + +void +ogSurface::ogVFlip(void) { + if (!ogAvail()) return; +// if ((buffer==NULL) || (lineOfs==NULL)) return; + switch (BPP) { + case 8: + __asm__ __volatile__( + " add %%edi, %%esi \n" // add esi, edi + "vf8lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf8lop2: \n" + " mov (%%edi),%%al \n" // mov al, [edi] + " mov (%%esi),%%ah \n" // mov ah, [esi] + " mov %%al,(%%esi) \n" // mov [esi], al + " mov %%ah,(%%edi) \n" // mov [edi], ah + " inc %%edi \n" // inc edi + " dec %%esi \n" // dec esi + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf8lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " dec %%edx \n" + " jnz vf8lop \n" + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX), // %0, %1 + "b" (xRes), "d" (maxY+1) // %2, %3 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " add %%edi, %%esi \n" // add esi, edi + "vf16lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf16lop2: \n" + " mov (%%edi),%%ax \n" // mov ax, [edi] + " mov (%%esi),%%cx \n" // mov cx, [esi] + " mov %%ax,(%%esi) \n" // mov [esi], ax + " mov %%cx,(%%edi) \n" // mov [edi], cx + " add $2, %%edi \n" // add edi, 2 + " sub $2, %%esi \n" // sub esi, 2 + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf16lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " dec %%edx \n" + " jnz vf16lop \n" + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*2), // %0, %1 + "b" (xRes), "d" (maxY+1) // %2, %3 + ); + break; + case 24: + __asm__ __volatile__( + " add %%edi, %%esi \n" // add esi, edi + "vf24lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf24lop2: \n" + " mov (%%edi),%%ax \n" // mov ax, [edi] + " mov 2(%%edi),%%dl \n" // mov dl, [edi+2] + " mov (%%esi),%%cx \n" // mov cx, [esi] + " mov 2(%%esi),%%dh \n" // mov dh, [esi+2] + " mov %%ax,(%%esi) \n" // mov [esi], ax + " mov %%dl,2(%%esi) \n" // mov [esi+2], dl + " mov %%cx,(%%edi) \n" // mov [edi], cx + " mov %%dh,2(%%edi) \n" // mov [edi+2], dh + " add $3, %%edi \n" // add edi, 3 + " sub $3, %%esi \n" // sub esi, 3 + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf24lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " decl %3 \n" // dec height + " jnz vf24lop \n" + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*3), // %0, %1 + "b" (xRes), "m" (maxY+1) // %2, %3 + ); + break; + + case 32: + __asm__ __volatile__( + " add %%edi, %%esi \n" // add esi, edi + "vf32lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf32lop2: \n" + " mov (%%edi),%%eax \n" // mov eax, [edi] + " mov (%%esi),%%ecx \n" // mov ecx, [esi] + " mov %%eax,(%%esi) \n" // mov [esi], eax + " mov %%ecx,(%%edi) \n" // mov [edi], ecx + " add $4, %%edi \n" // add edi, 4 + " sub $4, %%esi \n" // sub esi, 4 + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf32lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " dec %%edx \n" + " jnz vf32lop \n" + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*4), // %0, %1 + "b" (xRes), "d" (maxY+1) // %2, %3 + ); + + } // switch + return; +} // ogSurface::ogVFlip + +void +ogSurface::ogVLine(int32 x, int32 y1, int32 y2, uInt32 colour) { + int32 tmp; + if (!ogAvail()) return; + if ((uInt32)x>maxX) return; + if (y1>y2) { + tmp= y1; + y1 = y2; + y2 = tmp; + } // if + if (y1<0) y1 = 0; + if (y2>(int32)maxY) y2 = maxY; + if (y2 +#include + #include + } +#include "objgfx30.h" +#include "ogBlit.h" + +static bool +fileExists(const char *file) +{ + FILE *f = fopen(file, "r"); + if (!f) + return false; + fclose(f); + return true; +} + +ogBlit::ogBlit(void) { + blitMask = NULL; + blitMaskSize = 0; + totalPixCount = 0; + startX = 0; + startY = 0; + endX = 0; + endY = 0; + return; +} // ogBlit::ogBlit + +void +ogBlit::blitSize(ogSurface& SrcObject, int32 x1, int32 y1, int32 x2, int32 y2) { + int32 x,y; + uInt8 zerocount; + uInt8 pixcount; + uInt32 bm; + bool inZeros; + bool found; + + // first free the image data or the blitMask data if we already have some + + free(image); + delete [] blitMask; + image = NULL; + blitMask = NULL; + imageSize = 0; + blitMaskSize = 0; + bm = (bitDepth+7) >> 3; + tColour = SrcObject.ogGetTransparentColor(); + + startX = x1; + startY = y1; + endX = x2; + endY = y2; + + // start by locating the left-most non-transparent pixel in the region defined + // by (x1,y1) to (x2,y2) + found = false; + while ((!found) && (startX<=x2)) { + for (y=y1; y<=y2; y++) + found |= (SrcObject.ogGetPixel(startX,y)!=tColour); + if (!found) startX++; + } // while + // now we look for the top-most non-transparent pixel in the regsion defined by + // (StartX,y1) to (x2,y2) + found = false; + while ((!found) && (startY<=y2)) { + for (x=startX; x<=x2; x++) + found |= (SrcObject.ogGetPixel(x,startY)!=tColour); + if (!found) startY++; + } // while + found = false; + while ((!found) && (endX>=startX)) { + for (y=startY; y<=y2; y++) + found |= (SrcObject.ogGetPixel(endX,y)!=tColour); + if (!found) endX--; + } // while + found = false; + while ((!found) && (endY>=startY)) { + for (x=startX; x<=endX; x++) + found |= (SrcObject.ogGetPixel(x,endY)!=tColour); + if (!found) endY--; + } // while + + for (y = startY; y <= endY; y++) { + zerocount = 0; + blitMaskSize++; // save room for xlcount + x = startX; + inZeros = (SrcObject.ogGetPixel(x,y)==tColour); + while (x<=endX) { + switch (inZeros) { + case true: + zerocount = 0; // How many zeros? + while ((x<=endX) && (SrcObject.ogGetPixel(x,y)==tColour)) { + x++; + if (zerocount == 255) { + zerocount = 0; + blitMaskSize += 2; + } else zerocount++; + } // while + inZeros = false; + break; // case true + case false: + pixcount = 0; + blitMaskSize += 2; + do { + x++; + if (pixcount == 255) { + blitMaskSize += 2; + pixcount = 0; + } else pixcount++; + totalPixCount++; + imageSize += bm; + } while ((x<=endX) && (SrcObject.ogGetPixel(x,y)!=tColour)); + inZeros = true; + break; // case false + } // switch + } // while + } // for + + startX -= x1; + startY -= y1; + endX -= x1; + endY -= y1; + + blitMask = new uInt8[blitMaskSize]; //(uInt8 *)malloc(blitMaskSize); +// memset(blitMask,0,blitMaskSize); + return; +} // ogBlit::blitSize + +void +ogBlit::getBlitMask(ogSurface& SrcObject, int32 x1, int32 y1) { + uInt8 * blitMaskPtr; + uInt8 * lineCountPtr; + uInt32 bm; + int32 x,y; + bool inZeros; + uInt8 pixCount, zeroCount; + + if (blitMask==NULL) return; + blitMaskPtr = blitMask; + bm = (bitDepth+7) >> 3; +// This is done elsewhere tColour = SrcObject.ogGetTransparentColor(); + + for (y = y1+startY; y <= y1+endY; y++) { + zeroCount = 0; + lineCountPtr = blitMaskPtr; + *lineCountPtr = 0; + blitMaskPtr++; + x = x1+startX; + inZeros = (SrcObject.ogGetPixel(x,y)==tColour); + while (x<=x1+endX) { + switch (inZeros) { + case true: + zeroCount = 0; + while ((x<=x1+endX) && (SrcObject.ogGetPixel(x,y)==tColour)) { + x++; + if (zeroCount == 255) { + (*lineCountPtr)++; + *blitMaskPtr = 255; // offset + blitMaskPtr++; // increment to next byte + *blitMaskPtr = 0; // runcount + blitMaskPtr++; // increment to next byte + *blitMaskPtr = 0; // offset + zeroCount = 0; + } else zeroCount++; + } // while + inZeros = false; // we are no longer in zeros} + break; // case true + case false: + (*lineCountPtr)++; + *blitMaskPtr = zeroCount; + blitMaskPtr++; + *blitMaskPtr = 0; + pixCount = 0; + do { + x++; + if (pixCount == 255) { + (*lineCountPtr)++; + *blitMaskPtr = 255; // runcount + blitMaskPtr++; // advance pointer + *blitMaskPtr = 0; // offset to next run + blitMaskPtr++; // advance pointer + *blitMaskPtr = 0; // next run count (incremented below) + pixCount = 0; + } else pixCount++; + (*blitMaskPtr)++; + } while ((x<=(x1+endX)) && + (SrcObject.ogGetPixel(x,y)!=tColour)); + blitMaskPtr++; + inZeros = true; // set inZeros to true to toggle + break; // case false + } // switch + } // while + } // for + return; +} // ogBlit::getBlitMask + +void +ogBlit::get(ogSurface& SrcObject, int32 x1, int32 y1, int32 x2, int32 y2) { + int32 tmp; + ogPixelFmt pixfmt; + + if (x1 > x2) { + tmp = x1; + x1 = x2; + x2 = tmp; + } // if + + if (y1 > y2) { + tmp = y1; + y1 = y2; + y2 = tmp; + } // if + + width = (x2-x1)+1; + height = (y2-y1)+1; + + SrcObject.ogGetPixFmt(pixfmt); + + bitDepth = pixfmt.BPP; + RFP = pixfmt.redFieldPosition; + GFP = pixfmt.greenFieldPosition; + BFP = pixfmt.blueFieldPosition; + AFP = pixfmt.alphaFieldPosition; + RShift = 8-pixfmt.redMaskSize; + GShift = 8-pixfmt.greenMaskSize; + BShift = 8-pixfmt.blueMaskSize; + AShift = 8-pixfmt.alphaMaskSize; + + if (bitDepth == 8) { + if (pal==NULL) pal = new ogRGBA[256]; + for (tmp=0; tmp<256; tmp++) + SrcObject.ogUnpackRGB(tmp,pal[tmp].red, pal[tmp].green, pal[tmp].blue); +// memcpy(pal, SrcObject.pal, sizeof(ogRGBA)*256); + } // if + + blitSize(SrcObject, x1, y1, x2, y2); + getBlitMask(SrcObject, x1, y1); + getBlitWithMask(SrcObject, x1, y1); + return; +} // ogBlit::get() + +void +ogBlit::getBlitWithMask(ogSurface& SrcObject, int32 x, int32 y) { + /* + * getBlitWithMask + * + * Retrieves the data portion of a blit using a predefined mask and + * stores the data in the Image pointer. If the source buffer is + * a different pixel format, we will adjust the image pointer + * to accommodate the new data and update the pixel format. The put() + * function will adjust the pixels to the dest buffer as needed. + * Before calling this routine, you must call getBlitMask. + */ + + int32 sx, sy; + uInt8 lineCount, offset, pixCount; + uInt32 nsy, ney; // new start y, new end y + uInt8 * blitMaskPtr; + void * imagePtr; + uInt32 distToEdge, bm, xRight, count; + ogPixelFmt pixfmt; + + // can we draw anything? + if (blitMask==NULL) return; + // see if the blit is outside the buffer + if ( (x+startX > (int32)SrcObject.ogGetMaxX()) || (x+endX<0) || + (y+startY > (int32)SrcObject.ogGetMaxY()) || (y+endY<0)) return; + blitMaskPtr = blitMask; + + // first check to see if the pixel format we get the blitmask from is + // different than what we're dealing with now. + SrcObject.ogGetPixFmt(pixfmt); + if ( (bitDepth!=pixfmt.BPP) || + (RFP!=pixfmt.redFieldPosition) || + (GFP!=pixfmt.greenFieldPosition) || + (BFP!=pixfmt.blueFieldPosition) ) { + if (image!=NULL) free(image); + image = NULL; + imageSize = 0; + bitDepth = pixfmt.BPP; + RFP = pixfmt.redFieldPosition; + GFP = pixfmt.greenFieldPosition; + BFP = pixfmt.blueFieldPosition; + AFP = pixfmt.alphaFieldPosition; + RShift = 8-pixfmt.redMaskSize; + GShift = 8-pixfmt.greenMaskSize; + BShift = 8-pixfmt.blueMaskSize; + AShift = 8-pixfmt.alphaMaskSize; + } // if + + bm = (bitDepth+7) >> 3; // bit multiplier + + if (image==NULL) { + imageSize = totalPixCount*bm; + image = malloc(imageSize); + } // if + imagePtr = image; + + // If any part of the blit data is out of bounds, we need to fill it with the + // transparent colour + if ((x+startX<0) || (x+endX>(int32)SrcObject.ogGetMaxX()) || + (y+startY<0) || (y+endY>(int32)SrcObject.ogGetMaxY())) { + for (count=0; count0) { + blitMaskPtr++; + pixCount = *blitMaskPtr; + blitMaskPtr++; + if (pixCount>0) (uInt8 *)imagePtr+=pixCount*bm; + lineCount--; + } // while + } // for sy + } // if + + // Now do clipping on the bottom edge. This is easy. + if (y+endY>(int32)SrcObject.ogGetMaxY()) + ney = (SrcObject.ogGetMaxY()-y); + else + ney = endY; + + for (sy = nsy; (uInt32)sy <= ney; sy++) { + sx = x+startX; + lineCount = *blitMaskPtr; + blitMaskPtr++; + while (lineCount>0) { + offset = *blitMaskPtr; + blitMaskPtr++; + sx += offset; + pixCount = *blitMaskPtr; + blitMaskPtr++; + if (pixCount>0) { + if (sx<=(int32)SrcObject.ogGetMaxX()) { + if ((sx<0) && (sx+pixCount>0)) { + pixCount += sx; // remember, sx is negative + (uInt8*)imagePtr -= sx*bm; // remember, sx is negative + sx=0; + } // if sx<0 && sx+pixcount>0 + + if (sx+pixCount>(int32)SrcObject.ogGetMaxX()+1) { + distToEdge = (SrcObject.ogGetMaxX()-sx)+1; + xRight = (pixCount - distToEdge)*bm; + pixCount = distToEdge; + } else xRight = 0; // if sx+pixCount>MaxX + + if (sx>=0) + SrcObject.ogCopyLineFrom(sx,y+sy,imagePtr,pixCount*bm); +// memcpy(imagePtr, // dest +// ((uInt8*)SrcObject.Buffer+SrcObject.LineOfs[y+sy]+sx*bm), +// pixCount*bm); + (uInt8*)imagePtr += xRight; + } // if sx <= MaxX + sx += pixCount; + (uInt8*)imagePtr += pixCount*bm; + } // if pixCount>0 + lineCount--; + } // while + } // for + + return; +} // ogBlit::getBlitWithMask + +uInt32 +ogBlit::getSize(void) { + return ogSprite::getSize() + + sizeof(totalPixCount) + + sizeof(blitMaskSize) + + blitMaskSize + + sizeof(startX) + + sizeof(startY) + + sizeof(endX) + + sizeof(endY); +} // ogBlit::getSize + +bool +ogBlit::loadFrom(const char * filename, uInt32 offset) { + FILE * infile; + uInt32 lresult, tresult, totSize; + uInt32 tmpSize; + char header_ident[4]; + + if (fileExists(filename)==false) return false; + if ((infile = fopen(filename,"rb"))==NULL) return false; + fseek(infile, offset, SEEK_SET); + + // for now just free up the previous image. This will be changed + // later so it doesn't affect the current image (if any) if there + // is a failure loading + + free(image); + delete [] pal; + delete [] blitMask; + imageSize = 0; + blitMaskSize = 0; + + tresult = 0; // total bytes we've read in so far + + lresult = fread(header_ident, sizeof(header_ident), 1, infile); + tresult += lresult*sizeof(header_ident); + if ((header_ident[0]!='B') || + (header_ident[1]!='L') || + (header_ident[2]!='T') || + (header_ident[3]!=(char)0x1A)) { + fclose(infile); + return false; + } + lresult = fread(&totSize, sizeof(totSize), 1, infile); + tresult += lresult*sizeof(totSize); + + lresult = fread(&width, sizeof(width), 1, infile); + tresult += lresult*sizeof(width); + + lresult = fread(&height, sizeof(height), 1, infile); + tresult += lresult*sizeof(height); + + lresult = fread(&bitDepth, sizeof(bitDepth), 1, infile); + tresult += lresult*sizeof(bitDepth); + + lresult = fread(&RFP, sizeof(RFP), 1, infile); + tresult += lresult*sizeof(RFP); + + lresult = fread(&GFP, sizeof(GFP), 1, infile); + tresult += lresult*sizeof(GFP); + + lresult = fread(&BFP, sizeof(BFP), 1, infile); + tresult += lresult*sizeof(BFP); + + lresult = fread(&AFP, sizeof(AFP), 1, infile); + tresult += lresult*sizeof(AFP); + + lresult = fread(&RShift, sizeof(RShift), 1, infile); + tresult += lresult*sizeof(RShift); + + lresult = fread(&GShift, sizeof(GShift), 1, infile); + tresult += lresult*sizeof(GShift); + + lresult = fread(&BShift, sizeof(BShift), 1, infile); + tresult += lresult*sizeof(BShift); + + lresult = fread(&AShift, sizeof(AShift), 1, infile); + tresult += lresult*sizeof(AShift); + + lresult = fread(&tColour, sizeof(tColour), 1, infile); + tresult += lresult*sizeof(tColour); + + lresult = fread(&totalPixCount, sizeof(totalPixCount), 1, infile); + tresult += lresult*sizeof(totalPixCount); + + lresult = fread(&startX, sizeof(startX), 1, infile); + tresult += lresult*sizeof(startX); + + lresult = fread(&startY, sizeof(startY), 1, infile); + tresult += lresult*sizeof(startY); + + lresult = fread(&endX, sizeof(endX), 1, infile); + tresult += lresult*sizeof(endX); + + lresult = fread(&endY, sizeof(endY), 1, infile); + tresult += lresult*sizeof(endY); + + lresult = fread(&blitMaskSize, sizeof(blitMaskSize), 1, infile); + tresult += lresult*sizeof(blitMaskSize); + + lresult = fread(&imageSize, sizeof(imageSize), 1, infile); + tresult += lresult*sizeof(imageSize); + + blitMask = new uInt8[blitMaskSize]; + if (blitMask == NULL) { + fclose(infile); + return false; + } + + image = malloc(imageSize); + if (image == NULL) { + fclose(infile); + return false; + } + + // read in the blit mask + lresult = fread(blitMask, blitMaskSize, 1, infile); + tresult += lresult*blitMaskSize; + + // read in the image data + // it's possible that if we start saving only blit masks this section will be + // blank + lresult = fread(image, 1, imageSize, infile); + tresult += lresult; + + if (bitDepth==8) { + // 8bpp sprites have palettes + if (pal==NULL) pal = new ogRGBA[256]; + if (pal==NULL) { + fclose(infile); + return false; + } // if pal==NULL + lresult = fread(&tmpSize, sizeof(tmpSize), 1, infile); + tresult += lresult*sizeof(tmpSize); + if (tmpSize>sizeof(ogRGBA)*256) { + fclose(infile); + return false; + } + lresult = fread(pal, tmpSize, 1, infile); + tresult += lresult*tmpSize; + } // if bitDepth == 8 + + fclose(infile); + return (tresult == totSize); +} // ogBlit::loadFrom + +void +ogBlit::put(ogSurface& DestObject, int32 x, int32 y) { + int32 sx, sy; + uInt32 nsy, ney; + uInt8 lineCount, offset, pixCount; + uInt8* blitMaskPtr; + void * imagePtr; + uInt32 distToEdge, bm, xRight, xx; + uInt8 r, g, b; + ogPixelFmt pixfmt; + + // can we draw anything? + if ((blitMask==NULL) || (image==NULL)) return; + if (DestObject.ogAvail()==false) return; + // see if the blit is oustide the buffer + if ( ((x+startX)>(int32)DestObject.ogGetMaxX()) || + ((y+startY)>(int32)DestObject.ogGetMaxY()) || + ((x+endX)<0) || ((y+endY)<0) ) return; + + blitMaskPtr = blitMask; + imagePtr = image; + + bm = (bitDepth+7) >> 3; + + // first do clipping on the top edge + nsy = startY; + if (y+startY<0) { + /* + * If we're here then part of the blit is above the top edge of the + * buffer. The distance to the top of the buffer is abs(y+startY). + * So, we need to loop through the blit geometry and advance the + * relative pointers (BlitMaskPtr and ImagePtr) + */ + for (sy = (y+startY); sy<0; sy++) { + nsy++; + lineCount = *blitMaskPtr; + blitMaskPtr++; + while (lineCount>0) { + blitMaskPtr++; + pixCount = *blitMaskPtr; + blitMaskPtr++; + if (pixCount>0) (uInt8 *)imagePtr+=pixCount*bm; + lineCount--; + } // while + } // for sy + } // if + + // Now do clipping on the bottom edge. This is easy + // y is guaranteed to be >=0 + if (y+endY>(int32)DestObject.ogGetMaxY()) + ney = (DestObject.ogGetMaxY()-y); + else + ney = endY; + + DestObject.ogGetPixFmt(pixfmt); + + if ( (pixfmt.BPP != bitDepth) || + (pixfmt.redFieldPosition != RFP) || + (pixfmt.greenFieldPosition != GFP) || + (pixfmt.blueFieldPosition != BFP)) { + for (sy = nsy; (uInt32)sy <= ney; sy++) { + sx = x+startX; + lineCount = *blitMaskPtr; + blitMaskPtr++; + while (lineCount>0) { + offset = *blitMaskPtr; + blitMaskPtr++; + sx += offset; + pixCount = *blitMaskPtr; + blitMaskPtr++; + if (pixCount>0) { + if (sx<=(int32)DestObject.ogGetMaxX()) { + if ((sx<0) && (sx+(int32)pixCount>0)) { + pixCount += sx; // remember, sx is negative + (uInt8*)imagePtr -= sx*bm; // remember, sx is negative + sx = 0; + } // if sx<0 && sx+pixCount>0 + if (sx+pixCount>(int32)DestObject.ogGetMaxX()) { + distToEdge = (DestObject.ogGetMaxX()-sx)+1; + xRight = (pixCount-distToEdge)*bm; + pixCount = distToEdge; + } else xRight = 0; // if sx+pixCount>MaxX + if (sx>=0) + for (xx=0; xx0) { + offset = *blitMaskPtr; + blitMaskPtr++; + sx += offset; + pixCount = *blitMaskPtr; + blitMaskPtr++; + if (pixCount>0) { + if (sx<=(int32)DestObject.ogGetMaxX()) { + if ((sx<0) && (sx+pixCount>0)) { + pixCount += sx; // remember, sx is negative + (uInt8*)imagePtr -= sx*bm; // remember, sx is negative + sx = 0; + } // if sx<0 && sx+pixCount>0 + + if (sx+pixCount>(int32)DestObject.ogGetMaxX()+1) { + distToEdge = (DestObject.ogGetMaxX()-sx)+1; + xRight = (pixCount - distToEdge)*bm; + pixCount = distToEdge; + } else xRight = 0; // if sx+pixCount>MaxX + + if (sx>=0) + DestObject.ogCopyLineTo(sx,y+sy,imagePtr,pixCount*bm); +// memcpy( ((uInt8*)DestObject.Buffer+DestObject.LineOfs[y+sy]+sx*bm), +// imagePtr, +// pixCount*bm); + (uInt8*)imagePtr += xRight; + } // if sx <= MaxX + sx += pixCount; + (uInt8*)imagePtr += pixCount*bm; + } // if pixCount>0 + lineCount--; + } // while + } // for + } // else + + return; +} // ogBlit::put +bool +ogBlit::saveTo(const char * filename, int32 offset) { + /* + * saveTo + * + * saves a blit to disk. If the file doesn't exit then we will create + * a new one (doing this will ignore any specified offset). If the file + * exists, we will seek to the specified offset and place the bitmap there. + * If offset is -1, then we seek to the end of the file. + * + * This function will fail on files larger than 2GB. + * + */ + FILE * outfile = NULL; + char header_ident[4]; + uInt32 tmpSize; + + if (image==NULL) return false; + if ((bitDepth==8) && (pal==NULL)) return false; + + if (fileExists(filename)==false) { // file doesn't exist + if ((outfile = fopen(filename,"wb")) == NULL) return false; + } else { + // file exists. Now we check to see where we put it + if (offset==-1) { + if ((outfile = fopen(filename, "ab")) == NULL) return false; + } else { + // we have an existing file and an offset to place the data + if ((outfile = fopen(filename, "wb")) == NULL) return false; + if (offset!=0) fseek(outfile, offset, SEEK_SET); + } // else + } // else + + tmpSize = getSize(); + + header_ident[0] = 'B'; + header_ident[1] = 'L'; + header_ident[2] = 'T'; + header_ident[3] = (char)0x1A; // EOF marker + + // we store exactly how bit this sucker is inside the header. This includes + // the header information before it, and the size itself + fwrite(header_ident, sizeof(header_ident), 1, outfile); + + fwrite(&tmpSize, sizeof(tmpSize), 1, outfile); + fwrite(&width, sizeof(width), 1, outfile); + fwrite(&height, sizeof(height), 1, outfile); + fwrite(&bitDepth, sizeof(bitDepth), 1, outfile); + + fwrite(&RFP, sizeof(RFP), 1, outfile); + fwrite(&GFP, sizeof(GFP), 1, outfile); + fwrite(&BFP, sizeof(BFP), 1, outfile); + fwrite(&AFP, sizeof(AFP), 1, outfile); + + fwrite(&RShift, sizeof(RShift), 1, outfile); + fwrite(&GShift, sizeof(GShift), 1, outfile); + fwrite(&BShift, sizeof(BShift), 1, outfile); + fwrite(&AShift, sizeof(AShift), 1, outfile); + + fwrite(&tColour, sizeof(tColour), 1, outfile); + fwrite(&totalPixCount, sizeof(totalPixCount), 1, outfile); + + fwrite(&startX, sizeof(startX), 1, outfile); + fwrite(&startY, sizeof(startY), 1, outfile); + fwrite(&endX, sizeof(endX), 1, outfile); + fwrite(&endY, sizeof(endY), 1, outfile); + + fwrite(&blitMaskSize, sizeof(blitMaskSize), 1, outfile); + fwrite(&imageSize, sizeof(imageSize), 1, outfile); + + fwrite(blitMask, blitMaskSize, 1, outfile); + fwrite(image, 1, imageSize, outfile); + + if (bitDepth == 8) { + tmpSize = sizeof(ogRGBA)*256; + fwrite(&tmpSize, sizeof(tmpSize), 1, outfile); + fwrite(pal, sizeof(ogRGBA), 256, outfile); + } // if bitDepth == 8 + + fclose(outfile); + return true; +} // ogBlit::saveTo + +ogBlit::~ogBlit(void) { + delete [] blitMask; + blitMask = NULL; + blitMaskSize = 0; + return; +} // ogBlit::~ogBlit + diff --git a/lockwasher/src/lib/views/ogDisplay_VESA.cpp b/lockwasher/src/lib/views/ogDisplay_VESA.cpp new file mode 100644 index 0000000..5ea4a53 --- /dev/null +++ b/lockwasher/src/lib/views/ogDisplay_VESA.cpp @@ -0,0 +1,1531 @@ +#include "objgfx30.h" +#include "defpal.inc" +#include "ogDisplay_VESA.h" +#include // for __tb +#include +#include +#include +#include +#include + +/* + * + * ogDisplay methods + * + */ + +void InitVESAMode(uInt16 mode) { + __dpmi_regs regs; + regs.x.ax=0x4f02; + regs.x.bx=mode; + __dpmi_int(0x10, ®s); + return; +} + +ogDisplay_VESA::ogDisplay_VESA(void) { + InGraphics = false; + VESARec = new ogVESA_Rec; + modeRec = new ogMode_Rec; + getVESAInfo(); + + ScreenSelector = __dpmi_allocate_ldt_descriptors(1); + + return; +} // ogDisplay_VESA::ogDisplay_VESA + +uInt32 +ogDisplay_VESA::rawGetPixel(uInt32 x, uInt32 y) { + uInt32 result; + switch (BPP) { + case 8: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector) + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector) + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + case 24: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector) + " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size + " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size + " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size + " add %%esi, %%edi \n" // add edi, esi + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4] + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] + " xor %%eax, %%eax \n" + " mov 2(%%edi), %%al \n" // mov al, [edi+2] + " shl $16, %%eax \n" // shl eax, 16 + " mov (%%edi), %%ax \n" // mov ax, [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + case 32: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector) + " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size} + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4] + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " mov (%%edi),%%eax \n" // eax,word ptr [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + } // switch + return result; +} // TScreen::rawGetPixel + +void +ogDisplay_VESA::rawSetPixel(uInt32 x, uInt32 y, uInt32 colour) { + switch (BPP) { + case 8: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx * 4] + " push %%ds \n" // push ds + " mov %%dx, %%ds \n" // mov ds, dx + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%al, (%%edi) \n" // mov [edi], al + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), // %2, %3 + "d" (ScreenSelector) // %4 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" // push ds + " mov %%dx, %%ds \n" // mov ds, dx + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], al + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), // %2, %3 + "d" (ScreenSelector) // %4 + ); + break; + case 24: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + // " add (%%esi,%%ebx,4),%%edi \n" // add edi, [esi + ebx * 4] + " push %%ds \n" // push ds + " mov %%dx, %%ds \n" // mov ds, dx + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), // %2, %3 + "d" (ScreenSelector) // %4 + ); + break; + case 32: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" // push ds + " mov %%dx, %%ds \n" // mov ds, dx + + " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%eax, (%%edi) \n" // mov [edi], eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), // %2, %3 + "d" (ScreenSelector) // %4 + ); + } // switch + return; +} // ogDisplay_VESA::rawSetPixel + +void +ogDisplay_VESA::rawLine(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2, uInt32 colour) { + /* + * ogDisplay_VESA::rawLine() + * + * private method; draws an unclipped line from (x1,y1) to (x2,y2) + * + */ + int32 tc; + if (!ogAvail()) return; + switch (BPP) { + case 8: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%cx, %%ds \n" // mov ds, cx + " mov $1, %%ecx \n" // mov ecx, 1 + " bt $15, %%eax \n" // bt eax, 15 + " jnc rlxPositive8 \n" + " or $-1, %%ecx \n" // or ecx, -1 + " neg %%eax \n" // neg eax +"rlxPositive8: \n" + " add %%eax, %%eax \n" // add eax, eax + " bt $15, %%ebx \n" // bt ebx, 15 + " jnc rlyPositive8 \n" + " neg %%edx \n" // neg edx + " neg %%ebx \n" // neg ebx +"rlyPositive8: \n" + " add %%ebx, %%ebx \n" // add ebx, ebx + + " cmp %%ebx, %%eax \n" // cmp eax, ebx + " jle rlyGreater8 \n" + " push %%ecx \n" // push ecx + " mov %%eax, %%ecx \n" // mov ecx, eax + " mov %%ebx, %6 \n" // mov tc, ebx + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" // pop ecx +"rlxTop8: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%al, (%%edi) \n" // mov [edi], al + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone8 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddY8 \n" + " add %%edx, %%edi \n" // add edi, edx + " sub %%eax, %6 \n" // sub tc, eax +"rlNoAddY8: \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ebx, %6 \n" // add tc, ebx + " jmp rlxTop8 \n" + +"rlyGreater8: \n" + " push %%ecx \n" // push ecx + " mov %%ebx, %%ecx \n" // mov ecx, ebx + " mov %%eax, %6 \n" // mov tc, eax + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" +"rlyTop8: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%al, (%%edi) \n" // mov [edi], al + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone8 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddX8 \n" + " add %%ecx, %%edi \n" // add edi, ecx + " sub %%ebx, %6 \n" // sub tc, ebx +"rlNoAddX8: \n" + " add %%edx, %%edi \n" // add edi, edx + " add %%eax, %6 \n" // add tc, eax + " jmp rlyTop8 \n" +"rlDone8: \n" + " pop %%ds \n" // pop ds + : + : "D" ((uInt8 *)buffer+lineOfs[y1]+x1), // %0 + "S" ((uInt8 *)buffer+lineOfs[y2]+x2), // %1 + "a" (x2-x1), "b" (y2-y1), // %2, %3 + "d" (xRes), "m" (colour), // %4, %5 + "m" (tc), "c" (ScreenSelector) // %6, %7 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%cx, %%ds \n" // mov ds, cx + " mov $1, %%ecx \n" // mov ecx, 1 + " bt $15, %%eax \n" // bt eax, 15 + " jnc rlxPositive16 \n" + " or $-1, %%ecx \n" // or ecx, -1 + " neg %%eax \n" // neg eax +"rlxPositive16: \n" + " add %%eax, %%eax \n" // add eax, eax + " bt $15, %%ebx \n" // bt ebx, 15 + " jnc rlyPositive16 \n" + " neg %%edx \n" // neg edx + " neg %%ebx \n" // neg ebx +"rlyPositive16: \n" + " add %%ebx, %%ebx \n" // add ebx, ebx + + " cmp %%ebx, %%eax \n" // cmp eax, ebx + " jle rlyGreater16 \n" + " push %%ecx \n" // push ecx + " mov %%eax, %%ecx \n" // mov ecx, eax + " mov %%ebx, %6 \n" // mov tc, ebx + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" // pop ecx +"rlxTop16: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%ax, (%%edi) \n" // mov [edi], ax + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone16 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddY16 \n" + " add %%edx, %%edi \n" // add edi, edx + " sub %%eax, %6 \n" // sub tc, eax +"rlNoAddY16: \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ebx, %6 \n" // add tc, ebx + " jmp rlxTop16 \n" + +"rlyGreater16: \n" + " push %%ecx \n" // push ecx + " mov %%ebx, %%ecx \n" // mov ecx, ebx + " mov %%eax, %6 \n" // mov tc, eax + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" +"rlyTop16: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%ax, (%%edi) \n" // mov [edi], ax + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone16 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddX16 \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " sub %%ebx, %6 \n" // sub tc, ebx +"rlNoAddX16: \n" + " add %%edx, %%edi \n" // add edi, edx + " add %%eax, %6 \n" // add tc, eax + " jmp rlyTop16 \n" +"rlDone16: \n" + " pop %%ds \n" // pop ds + + : + : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1 << 1)), // %0 + "S" ((uInt8 *)buffer+lineOfs[y2]+(x2 << 1)), // %1 + "a" (x2-x1), "b" (y2-y1), // %2, %3 + "d" (xRes), "m" (colour), // %4, %5 + "m" (tc), "c" (ScreenSelector) // %6, %7 + ); + break; + case 24: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%cx, %%ds \n" // mov ds, cx + " mov $1, %%ecx \n" // mov ecx, 1 + " bt $15, %%eax \n" // bt eax, 15 + " jnc rlxPositive24 \n" + " or $-1, %%ecx \n" // or ecx, -1 + " neg %%eax \n" // neg eax +"rlxPositive24: \n" + " add %%eax, %%eax \n" // add eax, eax + " bt $15, %%ebx \n" // bt ebx, 15 + " jnc rlyPositive24 \n" + " neg %%edx \n" // neg edx + " neg %%ebx \n" // neg ebx +"rlyPositive24: \n" + " add %%ebx, %%ebx \n" // add ebx, ebx + + " cmp %%ebx, %%eax \n" // cmp eax, ebx + " jle rlyGreater24 \n" + " push %%ecx \n" // push ecx + " mov %%eax, %%ecx \n" // mov ecx, eax + " mov %%ebx, %6 \n" // mov tc, ebx + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" // pop ecx +"rlxTop24: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone24 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddY24 \n" + " add %%edx, %%edi \n" // add edi, edx + " sub %%eax, %6 \n" // sub tc, eax +"rlNoAddY24: \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ebx, %6 \n" // add tc, ebx + " jmp rlxTop24 \n" + +"rlyGreater24: \n" + " push %%ecx \n" // push ecx + " mov %%ebx, %%ecx \n" // mov ecx, ebx + " mov %%eax, %6 \n" // mov tc, eax + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" +"rlyTop24: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone24 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddX24 \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " sub %%ebx, %6 \n" // sub tc, ebx +"rlNoAddX24: \n" + " add %%edx, %%edi \n" // add edi, edx + " add %%eax, %6 \n" // add tc, eax + " jmp rlyTop24 \n" +"rlDone24: \n" + " pop %%ds \n" // pop ds + + : + : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1*3)), // %0 + "S" ((uInt8 *)buffer+lineOfs[y2]+(x2*3)), // %1 + "a" (x2-x1), "b" (y2-y1), // %2, %3 + "d" (xRes), "m" (colour), // %4, %5 + "m" (tc), "c" (ScreenSelector) // %6, %7 + ); + break; + case 32: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%cx, %%ds \n" // mov ds, cx + " mov $1, %%ecx \n" // mov ecx, 1 + " bt $15, %%eax \n" // bt eax, 15 + " jnc rlxPositive32 \n" + " or $-1, %%ecx \n" // or ecx, -1 + " neg %%eax \n" // neg eax +"rlxPositive32: \n" + " add %%eax, %%eax \n" // add eax, eax + " bt $15, %%ebx \n" // bt ebx, 15 + " jnc rlyPositive32 \n" + " neg %%edx \n" // neg edx + " neg %%ebx \n" // neg ebx +"rlyPositive32: \n" + " add %%ebx, %%ebx \n" // add ebx, ebx + + " cmp %%ebx, %%eax \n" // cmp eax, ebx + " jle rlyGreater32 \n" + " push %%ecx \n" // push ecx + " mov %%eax, %%ecx \n" // mov ecx, eax + " mov %%ebx, %6 \n" // mov tc, ebx + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" // pop ecx +"rlxTop32: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%eax, (%%edi)\n" // mov [edi], eax + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone32 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddY32 \n" + " add %%edx, %%edi \n" // add edi, edx + " sub %%eax, %6 \n" // sub tc, eax +"rlNoAddY32: \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ebx, %6 \n" // add tc, ebx + " jmp rlxTop32 \n" + +"rlyGreater32: \n" + " push %%ecx \n" // push ecx + " mov %%ebx, %%ecx \n" // mov ecx, ebx + " mov %%eax, %6 \n" // mov tc, eax + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" +"rlyTop32: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%eax, (%%edi)\n" // mov [edi], eax + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone32 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddX32 \n" + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " sub %%ebx, %6 \n" // sub tc, ebx +"rlNoAddX32: \n" + " add %%edx, %%edi \n" // add edi, edx + " add %%eax, %6 \n" // add tc, eax + " jmp rlyTop32 \n" +"rlDone32: \n" + " pop %%ds \n" // pop ds + : + : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1 << 2)), // %0 + "S" ((uInt8 *)buffer+lineOfs[y2]+(x2 << 2)), // %1 + "a" (x2-x1), "b" (y2-y1), // %2, %3 + "d" (xRes), "m" (colour), // %4, %5 + "m" (tc), "c" (ScreenSelector) // %6, %7 + ); + break; + } // switch + return; +} // ogDisplay_VESA::rawLine + +bool +ogDisplay_VESA::ogAvail(void) { + return ( ((ScreenSelector!=0) || (buffer!=NULL)) && (lineOfs!=NULL)); +} // ogDisplay_VESA::ogAvail + +void +ogDisplay_VESA::getModeInfo(uInt16 mode) { + __dpmi_regs regs; + memset(modeRec, 0,sizeof(struct ogMode_Rec)); + memset(®s, 0, sizeof(regs)); + dosmemput(modeRec, sizeof(struct ogMode_Rec), __tb); + + int ofs, seg; + + seg = __tb; // __tb is a buffer located in "dos memory". This buffer + ofs = __tb; // is used because the vesa driver cannot acces memory + // above 1 MB (your program is most likely to be located above 1MB). + + ofs &= 0xffff; // Make a real pointer (segment:offse = 16:16) + seg &= 0xffff0000; // from the address of the buffer. + seg >>= 4; + + regs.x.ax = 0x4f01; // Get the modeinfo of a certain vesa video mode, + // this is a structure which contains. + regs.x.cx = mode; // information needed by other functions below. + regs.x.es = seg; + regs.x.di = ofs; + __dpmi_int(0x10, ®s); + + dosmemget(__tb,sizeof(struct ogMode_Rec),modeRec); // This info is located in dos memory, so + // it has to be moved to your program's + // addres space. + return; + +} // ogDisplay_VESA::getModeInfo + +void +ogDisplay_VESA::getVESAInfo(void) { + unsigned int seg, ofs; + __dpmi_regs regs; + if (VESARec==NULL) VESARec = new ogVESA_Rec; + if (VESARec==NULL) return; + + memset(VESARec,0,sizeof(struct ogVESA_Rec)); + memset(®s, 0, sizeof(regs)); + VESARec->VBESignature[0] = 'V'; // First off initialize the structure. + VESARec->VBESignature[1] = 'B'; + VESARec->VBESignature[2] = 'E'; + VESARec->VBESignature[3] = '2'; + + /* + + Because VBE funtions operate in real mode, we first have to move the + initialized structure to real-mode address space, so the structure can + be filled by the vesa function in real mode. + + */ + dosmemput(VESARec, sizeof(struct ogVESA_Rec), __tb); + + + seg = __tb; // Calculate real mode addres of the buffer. + ofs = __tb; + ofs &= 0xffff; + seg &= 0xffff0000; + seg >>= 4; + + regs.x.ax = 0x4F00; + regs.x.es = seg; + regs.x.di = ofs; + + __dpmi_int(0x10, ®s); // Get vesa info. + + dosmemget(__tb, sizeof(struct ogVESA_Rec), VESARec); // Move the structure back to + + VESARec->OEMStringPtr = (VESARec->OEMStringPtr & 0xFFFF) + + ((VESARec->OEMStringPtr & 0xFFFF0000) >> 12); + VESARec->OEMVendorNamePtr= (VESARec->OEMVendorNamePtr& 0xFFFF) + + ((VESARec->OEMVendorNamePtr& 0xFFFF0000) >> 12); + VESARec->OEMProductNamePtr= (VESARec->OEMProductNamePtr& 0xFFFF) + + ((VESARec->OEMProductNamePtr& 0xFFFF0000) >> 12); + VESARec->OEMProductRevPtr= (VESARec->OEMProductRevPtr& 0xFFFF) + + ((VESARec->OEMProductRevPtr& 0xFFFF0000) >> 12); + VESARec->VideoModePtr = ((VESARec->VideoModePtr & 0xFFFF0000) >> 12) + + (VESARec->VideoModePtr & 0xFFFF); + + return; +} // ogDisplay_VESA::getVESAInfo + +uInt16 +ogDisplay_VESA::findMode(uInt32 _xRes, uInt32 _yRes, uInt32 _BPP) { + uInt16 mode; + + if ((_xRes==320) && (_yRes==200) && (_BPP==8)) return 0x13; + +// if ((VESARec==NULL) || (VESARec->VideoModePtr==NULL)) return 0; + if (modeRec==NULL) return 0; + for (mode = 0x100; mode < 0x1FF; mode++) { + getModeInfo(mode); + if ((modeRec->xRes>=_xRes) && (modeRec->yRes>=_yRes) && + (modeRec->BitsPerPixel==_BPP)) + return mode; + } + + return 0; +} // ogDisplay_VESA::findMode + +void +ogDisplay_VESA::setMode(uInt16 mode) { + uInt32 size, count; + __dpmi_meminfo mem_info; + + if (mode==0x13) { + + xRes = 320; + yRes = 200; + maxX = 319; + maxY = 199; + BPP = 8; + + redFieldPosition = 0; + greenFieldPosition = 0; + blueFieldPosition = 0; + alphaFieldPosition = 0; + + redShifter = 0; + greenShifter = 0; + blueShifter = 0; + alphaFieldPosition = 0; + + mem_info.address = 0xA0000; + mem_info.size = 64000; + size = 63999; + buffer = NULL; + __dpmi_physical_address_mapping(&mem_info); + __dpmi_set_segment_base_address(ScreenSelector, mem_info.address); + __dpmi_set_segment_limit(ScreenSelector,size); + __dpmi_set_descriptor_access_rights(ScreenSelector, 0x40F3); + + } else { + buffer = NULL; + mode |= 0x4000; // attempt lfb + getModeInfo(mode); + if (modeRec->physBasePtr == 0) return; + size = modeRec->yRes*modeRec->BytesPerLine; + + xRes = modeRec->BytesPerLine; + yRes = modeRec->yRes; + maxX = modeRec->xRes-1; + maxY = yRes-1; + + redFieldPosition = modeRec->RedFieldPosition; + greenFieldPosition = modeRec->GreenFieldPosition; + blueFieldPosition = modeRec->BlueFieldPosition; + + redShifter = 8-modeRec->RedMaskSize; + greenShifter = 8-modeRec->GreenMaskSize; + blueShifter = 8-modeRec->BlueMaskSize; + + BPP = modeRec->BitsPerPixel; + + mem_info.address = modeRec->physBasePtr; + mem_info.size = size; + size = ((size+4095) >> 12); + __dpmi_physical_address_mapping(&mem_info); + __dpmi_set_segment_base_address(ScreenSelector, mem_info.address); + __dpmi_set_segment_limit(ScreenSelector,size); + __dpmi_set_descriptor_access_rights(ScreenSelector, 0xC0F3); + } // else + + owner = this; + dataState = ogALIASING; + InGraphics = true; + + if ((lineOfs!=NULL) && (lSize!=0)) delete [] lineOfs; + lSize = yRes*sizeof(uInt32); + lineOfs = new uInt32[yRes];; + if (lineOfs == NULL) return; + lineOfs[0] = 0; + for (count=1; count8); + if (BPP==8) setPal(); + ogClear(0); + return; +} // ogDisplay_VESA::setMode + +void +ogDisplay_VESA::setPal(void) { + uInt32 c; + if (BPP!=8) return; + outportb(0x3c8,0); + for (c=0; c<256; c++) { + outportb(0x3c9,pal[c].red >> 2); + outportb(0x3c9,pal[c].green >> 2); + outportb(0x3c9,pal[c].blue >> 2); + } // for + return; +} // ogDisplay_VESA::setPal + +bool +ogDisplay_VESA::ogAlias(ogSurface& SrcObject, uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) { + return false; +} // ogDisplay_VESA::ogAlias + +void +ogDisplay_VESA::ogClear(uInt32 colour) { + uInt32 height; + if (!ogAvail()) return; + __asm__ __volatile__("cld\n"); + switch (BPP) { + case 8: + __asm__ __volatile__( + " push %%es \n" // push es + " mov %6, %%ax \n" // mov ax, ScreenSelector + " mov %%ax, %%es \n" // mov es, ax + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxY) + " inc %%ebx \n" // inc ebx (maxX) + " mov %5, %%eax \n" // mov eax, colour + " sub %%edx, %%esi \n" // sub esi, edx + " mov %%al, %%ah \n" // mov ah, al + " mov %%ax, %%cx \n" // mov cx, ax + " shl $16, %%eax \n" // shl eax, 16 + " mov %%cx, %%ax \n" // mov ax, cx + "loop8: \n" + " push %%edx \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " and $3, %%edx \n" // and edx, 3 + " shr $2, %%ecx \n" // shr ecx, 2 + " rep \n" + " stosl \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " rep \n" + " stosb \n" + " pop %%edx \n" + " add %%esi, %%edi \n" // add edi, esi + " dec %%ebx \n" + " jnz loop8 \n" + " pop %%es \n" // pop es + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4 + "m" (colour), "m" (ScreenSelector) // %5, %6 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " push %%es \n" // push es + " mov %6, %%ax \n" // mov ax, ScreenSelector + " mov %%ax, %%es \n" // mov es, ax + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxX) + " inc %%ebx \n" // inc ebx (maxY) + " sub %%edx, %%esi \n" // sub esi, edx + " mov %5, %%eax \n" // mov eax, colour + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " mov %%ax, %%cx \n" // mov cx, ax + " shl $16, %%eax \n" // shl eax, 16 + " mov %%cx, %%ax \n" // mov ax, cx + "loop16: \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " shr $1, %%ecx \n" // shr ecx, 1 + " rep \n" + " stosl \n" + " jnc noc16 \n" + " stosw \n" + "noc16: \n" + " add %%esi, %%edi \n" // add edi, esi + " dec %%ebx \n" + " jnz loop16 \n" + " pop %%es \n" + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4 + "m" (colour), "m" (ScreenSelector) // %5, %6 + ); + break; + case 24: + __asm__ __volatile__( + " push %%es \n" // push es + " mov %7, %%ax \n" // mov ax, ScreenSelector + " mov %%ax, %%es \n" // mov es, ax + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxX) + " inc %%ebx \n" // inc ebx (maxY) + " mov %5, %%eax \n" // mov eax, colour + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " mov %%ebx, %6 \n" // mov height, ebx + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " mov %%eax, %%ebx \n" // mov ebx, eax + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " shr $16, %%ebx \n" // shr ebx, 16 + "oloop24: \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + "iloop24: \n" + " mov %%ax,(%%edi) \n" // mov [edi],ax + " movb %%bl,2(%%edi) \n" // mov [edi+2],bl + " add $3, %%edi \n" // add edi, 3 + " dec %%ecx \n" // dec ecx + " jnz iloop24 \n" + " add %%esi, %%edi \n" // add edi, esi + " decl %6 \n" // dec height + " jnz oloop24 \n" + " pop %%es \n" // pop es + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4 + "m" (colour), "m" (height), // %5, %6 + "m" (ScreenSelector) // %7 + ); + break; + case 32: + __asm__ __volatile__( + " push %%es \n" // push es + " mov %6, %%ax \n" // mov ax, ScreenSelector + " mov %%ax, %%es \n" // mov es, ax + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxX) + " inc %%ebx \n" // inc ebx (maxY) + " mov %5, %%eax \n" // mov eax, colour + " mov %%edx, %%ecx \n" // mov ecx, edx + " shl $2, %%ecx \n" // shl ecx, 2 + " sub %%ecx, %%esi \n" // sub esi, ecx // adjust for pix size + "loop32: \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " rep \n" + " stosl \n" + " add %%esi, %%edi \n" // add edi, esi + " dec %%ebx \n" + " jnz loop32 \n" + " pop %%es \n" // pop es + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4 + "m" (colour), "m" (ScreenSelector) // %5, %6 + ); + break; + } // switch + return; +} // ogDisplay_VESA::ogClear + +void +ogDisplay_VESA::ogCopyLineTo(uInt32 dx, uInt32 dy, const void * src, + uInt32 size) { + /* + * ogCopyLineTo() + * + * Inputs: + * + * dx - Destination X of the target buffer + * dy - Destination Y of the target buffer + * src - buffer to copy + * size - size in bytes *NOT* pixels + * + * Copies a run of pixels (of the same format) to (x,y) of a buffer + * + * This method is required because of the different implementations of + * copying a run of pixels to a buffer + * + * WARNING!!! This does *NO* error checking. It is assumed that you've + * done all of that. ogCopyLineTo and ogCopyLineFrom are the only + * methods that don't check to make sure you're hosing things. Don't + * use this method unless YOU KNOW WHAT YOU'RE DOING!!!!!!!!! + */ + movedata(_my_ds(),(uInt32)src, + ScreenSelector,(uInt32)((uInt8*)buffer+(lineOfs[dy]+dx*( (BPP+7) >> 3) ) ), + size); + + return; +} // ogSurface::ogCopyLineTo + +void +ogDisplay_VESA::ogCopyLineFrom(uInt32 sx, uInt32 sy, void * dest, uInt32 size) { + /* + * ogCopyLineFrom() + * + * Inputs: + * + * sx - Source X of the target buffer + * sy - Source Y of the target buffer + * dest - where to put it + * size - size in bytes *NOT* pixels + * + * Copies a run of pixels (of the same format) to (x,y) of a buffer + * + * This method is required because of the different implementations of + * copying a run of pixels to a buffer + * + * WARNING!!! This does *NO* error checking. It is assumed that you've + * done all of that. ogCopyLineTo and ogCopyLineFrom are the only + * methods that don't check to make sure you're hosing things. Don't + * use this method unless YOU KNOW WHAT YOU'RE DOING!!!!!!!!! + */ + movedata(ScreenSelector,(uInt32)((uInt8*)buffer+(lineOfs[sy]+sx*( (BPP+7) >> 3) ) ), + _my_ds(),(uInt32)dest, + size); + + return; +} // ogDisplay_VESA::ogCopyLineFrom + +bool +ogDisplay_VESA::ogCreate(uInt32 _xRes, uInt32 _yRes,ogPixelFmt _pixFormat) { + uInt16 mode; + mode = findMode(_xRes, _yRes, _pixFormat.BPP); + if ((mode == 0) && ((_pixFormat.BPP==24) || (_pixFormat.BPP==32))) { + if (_pixFormat.BPP==24) _pixFormat.BPP=32; else _pixFormat.BPP=24; + mode=findMode(_xRes,_yRes,_pixFormat.BPP); + } // if + if (mode!=0) setMode(mode); + return (mode!=0); +} // ogDisplay_VESA::ogCreate + +bool +ogDisplay_VESA::ogClone(ogSurface& SrcObject) { + return false; +} // ogDisplay_VESA::ogClone + +void +ogDisplay_VESA::ogCopyPal(ogSurface& SrcObject) { + ogSurface::ogCopyPal(SrcObject); + setPal(); + return; +} // ogDisplay_VESA::ogCopyPal + +uInt32 +ogDisplay_VESA::ogGetPixel(int32 x, int32 y) { + uInt32 result; + if (!ogAvail()) return transparentColor; + if (((uInt32)x>maxX) || ((uInt32)y>maxY)) + return transparentColor; + switch (BPP) { + case 8: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector) + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector) + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + case 24: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector) + " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size + " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size + " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size + " add %%esi, %%edi \n" // add edi, esi + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4] + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] + " xor %%eax, %%eax \n" + " mov 2(%%edi), %%al \n" // mov al, [edi+2] + " shl $16, %%eax \n" // shl eax, 16 + " mov (%%edi), %%ax \n" // mov ax, [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + case 32: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector) + " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size} + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4] + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " mov (%%edi),%%eax \n" // eax,word ptr [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + } // switch + return result; +} // TScreen::ogGetPixel + +void * +ogDisplay_VESA::ogGetPtr(uInt32 x, uInt32 y) { + return NULL; +} // ogDisplay_VESA::ogGetPtr + +void +ogDisplay_VESA::ogHLine(int32 x1, int32 x2, int32 y, uInt32 colour) { + int32 tmp; + + if (!ogAvail()) return; + if ((uInt32)y>maxY) return; + if (x1>x2) { + tmp= x1; + x1 = x2; + x2 = tmp; + } // if + if (x1<0) x1 = 0; + if (x2>(int32)maxX) x2=maxX; + if (x2maxX) || ((uInt32)y>maxY)) return; + switch (BPP) { + case 8: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" + " mov %4, %%dx \n" + " mov %%dx, %%ds \n" + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%al, (%%edi) \n" // mov [edi], al + " pop %%ds\n" + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), "m" (ScreenSelector) // %2, %3, %4 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" + " mov %4, %%dx \n" + " mov %%dx, %%ds \n" + + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " mov %3, %%eax \n" // mov eax, colour + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], al + " pop %%ds\n" + + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), "m" (ScreenSelector) // %2, %3, %4 + ); + break; + case 24: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" // push ds + " mov %4, %%dx \n" // mov dx, ScreenSelector + " mov %%dx, %%ds \n" // mov ds, dx + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), "m" (ScreenSelector) // %2, %3, %4 + ); + break; + case 32: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" // push ds + " mov %4, %%dx \n" // mov dx, ScreenSelector + " mov %%dx, %%ds \n" // mov ds, dx + " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%eax, (%%edi)\n" // mov [edi], eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), "m" (ScreenSelector) // %2, %3, %4 + ); + } // switch + return; +} // ogDisplay_VESA::ogSetPixel + +void +ogDisplay_VESA::ogSetRGBPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) { + if (pal==NULL) return; + ogSurface::ogSetRGBPalette(colour,red,green,blue); + outportb(0x3c8,colour); + outportb(0x3c9,red >> 2); + outportb(0x3c9,green >> 2); + outportb(0x3c9,blue >> 2); + + return; +} // ogDisplay_VESA::ogSetRGBPalette + +void +ogDisplay_VESA::ogVFlip(void) { + if (!ogAvail()) return; + switch (BPP) { + case 8: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax + " add %%edi, %%esi \n" // add esi, edi + "vf8lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf8lop2: \n" + " mov (%%edi),%%al \n" // mov al, [edi] + " mov (%%esi),%%ah \n" // mov ah, [esi] + " mov %%al,(%%esi) \n" // mov [esi], al + " mov %%ah,(%%edi) \n" // mov [edi], ah + " inc %%edi \n" // inc edi + " dec %%esi \n" // dec esi + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf8lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " dec %%edx \n" + " jnz vf8lop \n" + " pop %%ds \n" // pop ds + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX), // %0, %1 + "b" (xRes), "d" (maxY+1), "a" (ScreenSelector) // %2, %3, %4 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax + " add %%edi, %%esi \n" // add esi, edi + "vf16lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf16lop2: \n" + " mov (%%edi),%%ax \n" // mov ax, [edi] + " mov (%%esi),%%cx \n" // mov cx, [esi] + " mov %%ax,(%%esi) \n" // mov [esi], ax + " mov %%cx,(%%edi) \n" // mov [edi], cx + " add $2, %%edi \n" // add edi, 2 + " sub $2, %%esi \n" // sub esi, 2 + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf16lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " dec %%edx \n" + " jnz vf16lop \n" + " pop %%ds \n" // pop ds + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*2), // %0, %1 + "b" (xRes), "d" (maxY+1), "a" (ScreenSelector) // %2, %3, %4 + ); + break; + case 24: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax + " add %%edi, %%esi \n" // add esi, edi + "vf24lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf24lop2: \n" + " mov (%%edi),%%ax \n" // mov ax, [edi] + " mov 2(%%edi),%%dl \n" // mov dl, [edi+2] + " mov (%%esi),%%cx \n" // mov cx, [esi] + " mov 2(%%esi),%%dh \n" // mov dh, [esi+2] + " mov %%ax,(%%esi) \n" // mov [esi], ax + " mov %%dl,2(%%esi) \n" // mov [esi+2], dl + " mov %%cx,(%%edi) \n" // mov [edi], cx + " mov %%dh,2(%%edi) \n" // mov [edi+2], dh + " add $3, %%edi \n" // add edi, 3 + " sub $3, %%esi \n" // sub esi, 3 + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf24lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " decl %3 \n" // dec height + " jnz vf24lop \n" + " pop %%ds \n" // pop ds + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*3), // %0, %1 + "b" (xRes), "d" (maxY+1), "a" (ScreenSelector) // %2, %3, %4 + ); + break; + + case 32: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax + " add %%edi, %%esi \n" // add esi, edi + "vf32lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf32lop2: \n" + " mov (%%edi),%%eax \n" // mov eax, [edi] + " mov (%%esi),%%ecx \n" // mov ecx, [esi] + " mov %%eax,(%%esi) \n" // mov [esi], eax + " mov %%ecx,(%%edi) \n" // mov [edi], ecx + " add $4, %%edi \n" // add edi, 4 + " sub $4, %%esi \n" // sub esi, 4 + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf32lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " dec %%edx \n" + " jnz vf32lop \n" + " pop %%ds \n" // pop ds + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*4), // %0, %1 + "b" (xRes), "d" (maxY+1), "a" (ScreenSelector) // %2, %3, %4 + ); + + } // switch + return; +} // ogDisplay_VESA::ogVFlip + +void +ogDisplay_VESA::ogVLine(int32 x, int32 y1, int32 y2, uInt32 colour) { + int32 tmp; + if (!ogAvail()) return; + if ((uInt32)x>maxX) return; + if (y1>y2) { + tmp= y1; + y1 = y2; + y2 = tmp; + } // if + if (y1<0) y1 = 0; + if (y2>(int32)maxY) y2 = maxY; + if (y2 + #include + #include + } +#include "ogFont.h" +#include "objgfx30.h" + +ogBitFont::ogBitFont(void) { + memset(fontDataIdx,0,sizeof(fontDataIdx)); + memset(charWidthTable,0,sizeof(charWidthTable)); + memset(charHeightTable,0,sizeof(charHeightTable)); + fontData = NULL; + fontDataSize = 0; + width = 0; + height = 0; + numOfChars = 0; + startingChar = 0; + BGColour.red = 0; + BGColour.green = 0; + BGColour.blue = 0; + FGColour.red = 255; + FGColour.green = 255; + FGColour.blue = 255; + return; +} // ogBitFont::ogBitFont + +void +ogBitFont::centerTextX(ogSurface& buf, int32 y, const char * TextString ) { + int32 x; + x = ((buf.ogGetMaxX()+1)-textWidth(TextString)) / 2; + putString(buf,x,y,TextString); + return; +} // ogBitFont::centerTextX + +void +ogBitFont::justifyText(ogSurface& buf, uInt8 horiz, uInt8 vert, const char * textString) { + uInt32 x,y; + if (textString==NULL) return; + switch (horiz) { + case LeftText: + x = 0; + break; + case CenterText: + x = ((buf.ogGetMaxX())-textWidth(textString)) / 2; + break; + case RightText: + x = (buf.ogGetMaxX())-textWidth(textString); + break; + default: + return; + } // switch + + switch (vert) { + case TopText: + y = 0; + break; + case CenterText: + y = ((buf.ogGetMaxY())-height) / 2; + break; + case BottomText: + y = (buf.ogGetMaxY())-height; + default: + return; + } // switch + putString(buf,x,y,textString); + return; +} // ogBitFont::justifyText + +bool +ogBitFont::load(const char* fontFile) { + return loadFrom(fontFile,0); +} // ogBitFont::Load + +bool +ogBitFont::save(const char* fontFile) { + return saveTo(fontFile,0); +} // ogBitFont::save + +uInt32 +ogBitFont::textWidth(const char * textString) { + uInt32 size=0; + if (textString==NULL) return 0; + while (*textString) + size+=charWidthTable[(uInt8)*(textString++)]; + return size; +} // ogBitFont::textWidth + +void +ogBitFont::setBGColor(uInt8 r, uInt8 g, uInt8 b) { + BGColour.red = r; + BGColour.green = g; + BGColour.blue = b; + return; +} // ogBitFont::setBGColor + +void +ogBitFont::setFGColor(uInt8 r, uInt8 g, uInt8 b) { + FGColour.red = r; + FGColour.green = g; + FGColour.blue = b; + return; +} // ogBitFont::setFGColor + +void +ogBitFont::putString(ogSurface& buf, int32 x, int32 y, const char * textString) { + char ch; + if (fontData==NULL) return; + if (textString==NULL) return; + if (buf.ogAvail()==false) return; + buf.ogFillRect(x,y,x+textWidth(textString)-1,y+textHeight(textString)-1, + buf.ogRGB(BGColour.red, BGColour.green, BGColour.blue)); + while (*textString) { + ch = *textString++; + putChar(buf, x, y, ch); + x+=charWidthTable[(uInt8)ch]; + } // while +} // ogBitFont::putString + +void +ogBitFont::putChar(ogSurface& buf, int32 x, int32 y, const char ch) { + uInt32 xx, xcount, ycount; + uInt8 * offset; + uInt8 bits = 0; + uInt32 colour; + if (fontData==NULL) return; + if (buf.ogAvail()==false) return; + if (charWidthTable[(uInt8)ch]!=0) { + colour = buf.ogRGB(FGColour.red,FGColour.green,FGColour.blue); + offset=(uInt8 *)(fontData); + offset+=fontDataIdx[(uInt8)ch]; + for (ycount = 0; ycount<=(uInt32)(height-1); ycount++) { + xcount = charWidthTable[(uInt8)ch]; + xx = 0; + do { + if ((xx & 7)==0) bits = *(offset++); + if (bits & 128) + buf.ogSetPixel(x+xx,y+ycount,colour); + bits+=bits; + xx++; + } while (--xcount); + } // for + } // if +} // ogBitFont::putChar + +bool +ogBitFont::loadFrom(const char * fontFile, uInt32 offset) { + FILE * infile; + ogDPFHeader header; + uInt32 lresult, size; + free(fontData); + infile = fopen(fontFile,"rb"); + fseek(infile,offset,SEEK_SET); + lresult = fread(&header,sizeof(header),1,infile); + width = header.width; + height = header.height; + numOfChars = header.numOfChars; + if (numOfChars==0) numOfChars = 256; + startingChar = header.startingChar; + + memset(fontDataIdx,0,sizeof(fontDataIdx)); + memset(charWidthTable,0,sizeof(charWidthTable)); + memset(charHeightTable,0,sizeof(charHeightTable)); + + size = ((width+7) / 8)*height; + fontDataSize = size*numOfChars; + + for (int tmp=startingChar; tmp<=startingChar+numOfChars-1; tmp++) { + charWidthTable[tmp]=width; + charHeightTable[tmp]=height; + fontDataIdx[tmp]=(size*(tmp-startingChar)); + } // for + fontData = malloc(fontDataSize); + lresult = fread(fontData,1,fontDataSize,infile); + fclose(infile); + return true; +} // ogBitFont::loadFrom + +bool +ogBitFont::saveTo(const char *, int32) { + return false; +} // ogBitFont::saveTo + +ogBitFont::~ogBitFont(void) { + if (fontDataSize) free(fontData); + return; +} // ogBitFont::~ogBitFont + + diff --git a/lockwasher/src/lib/views/ogSprite.cpp b/lockwasher/src/lib/views/ogSprite.cpp new file mode 100644 index 0000000..42e87a6 --- /dev/null +++ b/lockwasher/src/lib/views/ogSprite.cpp @@ -0,0 +1,552 @@ +extern "C" { +#include +#include +#include + } +#include "objgfx30.h" +#include "ogSprite.h" + +static bool +fileExists(const char *file) +{ + FILE *f = fopen(file, "r"); + if (!f) + return false; + fclose(f); + return true; +} + +ogSprite::ogSprite(void) { + image = NULL; + pal = NULL; + imageSize = 0; + width = 0; + height = 0; + bitDepth = 0; + RFP = 0; + GFP = 0; + BFP = 0; + AFP = 0; + RShift = 0; + GShift = 0; + BShift = 0; + AShift = 0; + tColour = 0; + return; +} // ogSprite + +void +ogSprite::get(ogSurface& SrcObject, int32 x1, int32 y1, int32 x2, int32 y2) { + ogPixelFmt pixfmt; + uInt32 xx,yy,xOfs,yOfs; + uInt32 rx1, ry1, rx2, ry2; + uInt32 xCount, yCount, count; + void *p; + uInt32 bm; // bit multiplier + uInt32 MaxX, MaxY; + + if (SrcObject.ogAvail()==false) return; + + free(image); + free(pal); + + MaxX = SrcObject.ogGetMaxX(); + MaxY = SrcObject.ogGetMaxY(); + tColour = SrcObject.ogGetTransparentColor(); + + SrcObject.ogGetPixFmt(pixfmt); + + bitDepth = pixfmt.BPP; + RFP = pixfmt.redFieldPosition; + GFP = pixfmt.greenFieldPosition; + BFP = pixfmt.blueFieldPosition; + AFP = pixfmt.alphaFieldPosition; + RShift = 8-pixfmt.redMaskSize; + GShift = 8-pixfmt.greenMaskSize; + BShift = 8-pixfmt.blueMaskSize; + AShift = 8-pixfmt.alphaMaskSize; + + if (bitDepth==8) { + if (pal==NULL) pal = new ogRGBA[256]; + if (pal==NULL) return; + for (count=0; count<256; count++) + SrcObject.ogUnpackRGB(count,pal[count].red, pal[count].green, pal[count].blue); +// memcpy(pal, SrcObject.pal, sizeof(ogRGBA)*256); + } // if + + bm = ((bitDepth+7) >> 3); + + if (x1>x2) { + xx = x1; + x1 = x2; + x2 = xx; + } // if + + if (y1>y2) { + yy = y1; + y1 = y2; + y2 = yy; + } // if + + xCount = abs(x2-x1)+1; + yCount = abs(y2-y1)+1; + width = xCount; + height = yCount; + imageSize = xCount*yCount*bm; + image = malloc(imageSize); + p = image; + + if ( ((uInt32)x1>MaxX) || ((uInt32)y1>MaxY) || + ((uInt32)x2>MaxX) || ((uInt32)y2>MaxY) ) { + for (count=0; count(int32)MaxX) { + xCount -= MaxX-x2+1; + rx2 = MaxX; + } else rx2 = x2; + + if (y2>(int32)MaxY) { + yCount -= MaxY-y2+1; + ry2=MaxY; + } else ry2 = y2; + + xCount *= bm; +// rx1 *= bm; + for (yy=0; yysizeof(ogRGBA)*256) { + fclose(infile); + return false; + } + lresult = fread(pal, tmpSize, 1, infile); + tresult += lresult*tmpSize; + } // if bitDepth == 8 + + fclose(infile); + return (tresult == totSize); +} // ogSprite::loadFrom; + +void +ogSprite::put(ogSurface& DestObject, int32 x, int32 y) { + uInt32 xx, yy, bm; + int32 xCount, yCount; + uInt32 yOfs; + uInt32 xLeft, xRight; + int32 MaxX, MaxY; + void * p; + uInt8 r,g,b; + ogPixelFmt pixfmt; + + if (image==NULL) return; + if (DestObject.ogAvail()==false) return; + + MaxX = DestObject.ogGetMaxX(); + MaxY = DestObject.ogGetMaxY(); + + xCount = width; + yCount = height; + bm = (bitDepth+7) >> 3; + + // check to see if the image is totally off the screen + if ((x+xCount<0) || (y+yCount<0) || (x>(int32)MaxX) || (y>(int32)MaxY)) return; + + p = image; + if (y<0) { + yOfs = abs(y)*xCount*bm; + yCount+=y; + y=0; + } else yOfs=0; + + if (x<0) { + xLeft = abs(x)*bm; + xCount += x; + x = 0; + } else xLeft = 0; + + if (x+xCount > MaxX) { + xRight = (xCount - (MaxX-x+1))*bm; + xCount = (MaxX-x)+1; + } else xRight = 0; + + if ((y+yCount)>MaxY) yCount = (MaxY-y)+1; + + DestObject.ogGetPixFmt(pixfmt); + + (uInt8 *)p += yOfs; + + if ((pixfmt.BPP!=bitDepth) || + (pixfmt.redFieldPosition!=RFP) || + (pixfmt.greenFieldPosition!=GFP) || + (pixfmt.blueFieldPosition!=BFP)) { + for (yy=0; yy<(uInt32)yCount; yy++) { + (uInt8 *)p += xLeft; + for (xx=0; xx<(uInt32)xCount; xx++) { + unpackRGB(getPixel(p),r,g,b); + (uInt8 *)p += bm; + DestObject.ogSetPixel(x+xx,y+yy,DestObject.ogRGB(r,g,b)); + } // for + (uInt8 *)p += xRight; + } // for + } // if + else { // pixel formats match + xCount *= bm; +// x *= (pixfmt.BPP+7) >> 3; + for (yy=0; yy<(uInt32)yCount; yy++) { + (uInt8 *)p += xLeft; + DestObject.ogCopyLineTo(x,y+yy,p,xCount); +// memcpy((uInt8 *)DestObject.Buffer+DestObject.LineOfs[y+yy]+x,p,xCount); + (uInt8 *)p += xCount; + (uInt8 *)p += xRight; + } // for + } // else + return; +} // ogSurface::put + +bool +ogSprite::save(const char * filename) { + return saveTo(filename,0); +} // ogSprite::save + +bool +ogSprite::saveTo(const char * filename, int32 offset) { + /* + * saveTo + * + * saves a bitmap to disk. If the file doesn't exit then we will create + * a new one (doing this will ignore any specified offset). If the file + * exists, we will seek to the specified offset and place the bitmap there. + * If offset is -1, then we seek to the end of the file. + * + * This function will fail on files larger than 2GB. + * + */ + FILE * outfile = NULL; + char header_ident[4]; + uInt32 tmpSize; + + if (image==NULL) return false; + if ((bitDepth==8) && (pal==NULL)) return false; + + if (fileExists(filename)==false) { // file doesn't exist + if ((outfile = fopen(filename,"wb")) == NULL) return false; + } else { + // file exists. Now we check to see where we put it + if (offset==-1) { + if ((outfile = fopen(filename, "ab")) == NULL) return false; + } else { + // we have an existing file and an offset to place the data + if ((outfile = fopen(filename, "wb")) == NULL) return false; + if (offset!=0) fseek(outfile, offset, SEEK_SET); + } // else + } // else + header_ident[0] = 'S'; + header_ident[1] = 'P'; + header_ident[2] = 'R'; + header_ident[3] = (char)0x1A; // EOF marker + + // we store exactly how bit this sucker is inside the header. This includes + // the header information before it, and the size itself + tmpSize = getSize(); + fwrite(header_ident, sizeof(header_ident), 1, outfile); + + fwrite(&tmpSize, sizeof(tmpSize), 1, outfile); + fwrite(&width, sizeof(width), 1, outfile); + fwrite(&height, sizeof(height), 1, outfile); + fwrite(&bitDepth, sizeof(bitDepth), 1, outfile); + + fwrite(&RFP, sizeof(RFP), 1, outfile); + fwrite(&GFP, sizeof(GFP), 1, outfile); + fwrite(&BFP, sizeof(BFP), 1, outfile); + fwrite(&AFP, sizeof(AFP), 1, outfile); + + fwrite(&RShift, sizeof(RShift), 1, outfile); + fwrite(&GShift, sizeof(GShift), 1, outfile); + fwrite(&BShift, sizeof(BShift), 1, outfile); + fwrite(&AShift, sizeof(AShift), 1, outfile); + + fwrite(&imageSize, sizeof(imageSize), 1, outfile); + fwrite(image, imageSize, 1, outfile); + + if (bitDepth == 8) { + tmpSize = sizeof(ogRGBA)*256; + fwrite(&tmpSize, sizeof(tmpSize), 1, outfile); + fwrite(pal, sizeof(ogRGBA), 256, outfile); + } // if bitDepth == 8 + + fclose(outfile); + return true; +} // ogSprite::saveTo + +void +ogSprite::unpackRGB(uInt32 colour, uInt8& red, uInt8& green, uInt8& blue) { + switch (bitDepth) { + case 8: + if (colour>255) colour&=255; + if (pal==NULL) return; + red=pal[colour].red; + green=pal[colour].green; + blue=pal[colour].blue; + break; + case 15: + case 16: + red = (uInt8)(colour >> RFP) << RShift; + green = (uInt8)(colour >> GFP) << GShift; + blue = (uInt8)(colour >> BFP) << BShift; + if ((red!=0) && (RShift!=0)) red+=(1 << RShift)-1; + if ((green!=0) && (GShift!=0)) green+=(1 << GShift)-1; + if ((blue!=0) && (BShift!=0)) blue+=(1 << BShift)-1; + break; + case 24: + case 32: + red = (uInt8)(colour >> RFP); + green = (uInt8)(colour >> GFP); + blue = (uInt8)(colour >> BFP); + break; + default: + red = 0; + green = 0; + blue = 0; + break; + } // switch + return; +} // ogSprite::unpackRGB + +ogSprite::~ogSprite(void) { + free(image); + delete [] pal; + image = NULL; + pal = NULL; + imageSize = 0; + width = 0; + height = 0; + bitDepth = 0; + RFP = 0; + GFP = 0; + BFP = 0; + AFP = 0; + RShift = 0; + GShift = 0; + BShift = 0; + AShift = 0; + tColour = 0; + return; +} // ogSprite::~ogSprite + + diff --git a/lockwasher/src/lib/views/rh_opt.gdt b/lockwasher/src/lib/views/rh_opt.gdt new file mode 100644 index 0000000..84e5d6a --- /dev/null +++ b/lockwasher/src/lib/views/rh_opt.gdt Binary files differ diff --git a/lockwasher/src/lib/views/rh_opt.gpr b/lockwasher/src/lib/views/rh_opt.gpr new file mode 100644 index 0000000..5353ab1 --- /dev/null +++ b/lockwasher/src/lib/views/rh_opt.gpr Binary files differ diff --git a/lockwasher/src/lib/views/rh_opt.mak b/lockwasher/src/lib/views/rh_opt.mak new file mode 100644 index 0000000..1d41e21 --- /dev/null +++ b/lockwasher/src/lib/views/rh_opt.mak @@ -0,0 +1,356 @@ +# This file is automatically generated by RHIDE 1.4.9 +# created from within RHIDE +FLAGS_FOR_SUBPROJECTS=RHIDE_OS_="$(RHIDE_OS_)" CFLAGS="$(CFLAGS)"\ + CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" CPPFLAGS="$(CPPFLAGS)" +RHIDE_OS=$(RHIDE_OS_) +ifeq ($(strip $(RHIDE_OS)),) +ifneq ($(strip $(DJDIR)),) +RHIDE_OS_:=DJGPP +else +RHIDE_OS_:=$(patsubst CYGWIN%,CYGWIN,$(shell uname)) +endif +endif + +INCLUDE_DIRS= +LIB_DIRS= +C_DEBUG_FLAGS= +C_OPT_FLAGS=-O4 +C_WARN_FLAGS=-pedantic -Wmain -Wparentheses -Wreturn-type -Wuninitialized\ + -Wall -W -Wpointer-arith -Wmissing-prototypes -Wredundant-decls +C_C_LANG_FLAGS= +C_CXX_LANG_FLAGS= +C_P_LANG_FLAGS= +C_FPC_LANG_FLAGS= +C_F_LANG_FLAGS= +C_ADA_LANG_FLAGS= +LIBS= +LD_EXTRA_FLAGS=-g +C_EXTRA_FLAGS=-Wno-long-long +LOCAL_OPT=$(subst ___~~~___, ,$(subst $(notdir $<)___,,$(filter $(notdir\ + $<)___%,$(LOCAL_OPTIONS)))) + +OBJFILES=main.o objgfx30.o ogBlit.o ogDisplay_VESA.o ogFont.o ogSprite.o +ALL_OBJFILES=main.o objgfx30.o ogBlit.o ogDisplay_VESA.o ogFont.o\ + ogSprite.o +LIBRARIES= +SOURCE_NAME=$< +OUTFILE=$@ +SPECIAL_CFLAGS= +SPECIAL_LDFLAGS= +PROG_ARGS= +SRC_DIRS= +WUC= +EDITORS= +MAIN_TARGET=objgfx.exe +PROJECT_ITEMS=main.cpp objgfx30.cpp ogBlit.cpp ogDisplay_VESA.cpp\ + ogFont.cpp ogSprite.cpp +DEFAULT_MASK=*.cpp +RHIDE_BIN_DIR=c:/djgpp/bin +PASCAL_TYPE=GPC +GET_HOME=$(HOME) +CLEAN_FILES=$(MAIN_TARGET) $(OBJFILES) +RHIDE_GCC=gcc +RHIDE_AS=gcc +RHIDE_GXX=gcc +RHIDE_GPC=gpc +RHIDE_FPC=ppc386 +RHIDE_AR=ar +RHIDE_LD=gcc +RHIDE_G77=g77 +RHIDE_NASM=nasm +RHIDE_LD_PASCAL=gpc +RHIDE_LD_FPC=$(RHIDE_FPC) -E+ +RHIDE_GNATBIND=gnatbind +RHIDE_RM=rm +RHIDE_ARFLAGS=rcs +RHIDE_TYPED_LIBS.f=g2c m +RHIDE_TYPED_LIBS.for=$(RHIDE_TYPED_LIBS.f) +RHIDE_TYPED_LIBS.F=$(RHIDE_TYPED_LIBS.f) +RHIDE_TYPED_LIBS.fpp=$(RHIDE_TYPED_LIBS.f) +RHIDE_TYPED_LIBS_GPC=gpc m +RHIDE_TYPED_LIBS_FPC=fpc +RHIDE_TYPED_LIBS.p=$(RHIDE_TYPED_LIBS_$(PASCAL_TYPE)) +RHIDE_TYPED_LIBS.pas=$(RHIDE_TYPED_LIBS.p) +RHIDE_TYPED_LIBS.pp=$(RHIDE_TYPED_LIBS_FPC) +RHIDE_TYPED_LIBS_$(RHIDE_OS).cc=stdc++ +RHIDE_TYPED_LIBS_DJGPP.cc=stdcxx m +RHIDE_TYPED_LIBS_DJGPP.cc=stdcxx m +RHIDE_TYPED_LIBS.cc=$(RHIDE_TYPED_LIBS_$(RHIDE_OS).cc) +RHIDE_TYPED_LIBS.cpp=$(RHIDE_TYPED_LIBS.cc) +RHIDE_TYPED_LIBS.cxx=$(RHIDE_TYPED_LIBS.cc) +RHIDE_TYPED_LIBS.C=$(RHIDE_TYPED_LIBS.cc) +RHIDE_TYPED_LIBS.ii=$(RHIDE_TYPED_LIBS.cc) +RHIDE_TYPED_LIBS.l=fl +RHIDE_TYPED_LIBS.m=objc +RHIDE_TYPED_LIBS.adb=gnat +RHIDE_TYPED_LIBS_SUFFIXES=$(sort $(foreach item,$(PROJECT_ITEMS),$(suffix\ + $(item)))) +RHIDE_TYPED_LIBS=$(foreach\ + suff,$(RHIDE_TYPED_LIBS_SUFFIXES),$(RHIDE_TYPED_LIBS$(suff))) +RHIDE_INCLUDES=$(SPECIAL_CFLAGS) $(addprefix -I,$(INCLUDE_DIRS)) +RHIDE_LIBDIRS=$(addprefix -L,$(LIB_DIRS)) +RHIDE_LIBS=$(addprefix -l,$(LIBS) $(RHIDE_TYPED_LIBS) $(RHIDE_OS_LIBS)) +RHIDE_LDFLAGS=$(SPECIAL_LDFLAGS) $(addprefix -Xlinker ,$(LD_EXTRA_FLAGS)) +RHIDE_NASM_TARGET_DJGPP=coff +RHIDE_NASM_TARGET_Linux=elf +RHIDE_NASM_TARGET=$(RHIDE_NASM_TARGET_$(RHIDE_OS)) +RHIDE_COMPILE_NASM=$(RHIDE_NASM) -f $(RHIDE_NASM_TARGET) $(LOCAL_OPT) -o\ + $(OUTFILE) $(SOURCE_NAME) +RHIDE_COMPILE_FORTRAN=$(RHIDE_G77) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\ + $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_F_LANG_FLAGS) $(C_EXTRA_FLAGS)\ + $(LOCAL_OPT) -c $(SOURCE_NAME) -o $(OUTFILE) +RHIDE_COMPILE_FORTRAN_FORCE=$(RHIDE_G77) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\ + $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_F_LANG_FLAGS) $(C_EXTRA_FLAGS)\ + -x f77 $(LOCAL_OPT) -c $(SOURCE_NAME) -o $(OUTFILE) +RHIDE_COMPILE_C=$(RHIDE_GCC) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\ + $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_C_LANG_FLAGS) $(C_EXTRA_FLAGS)\ + $(RHIDE_OS_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(LOCAL_OPT) -c\ + $(SOURCE_NAME) -o $(OUTFILE) +RHIDE_COMPILE_C_FORCE=$(RHIDE_GCC) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\ + $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_C_LANG_FLAGS) $(C_EXTRA_FLAGS)\ + -x c $(RHIDE_OS_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(LOCAL_OPT) -c\ + $(SOURCE_NAME) -o $(OUTFILE) +RHIDE_COMPILE_CC=$(RHIDE_GXX) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\ + $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_C_LANG_FLAGS)\ + $(C_CXX_LANG_FLAGS) $(C_EXTRA_FLAGS) $(RHIDE_OS_CXXFLAGS)\ + $(CPPFLAGS) $(CXXFLAGS) $(LOCAL_OPT) -c $(SOURCE_NAME) -o\ + $(OUTFILE) +RHIDE_COMPILE_CC_FORCE=$(RHIDE_GXX) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\ + $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_C_LANG_FLAGS)\ + $(C_CXX_LANG_FLAGS) $(C_EXTRA_FLAGS) $(RHIDE_OS_CXXFLAGS)\ + $(CPPFLAGS) $(CXXFLAGS) -x c++ $(LOCAL_OPT) -c $(SOURCE_NAME) -o\ + $(OUTFILE) +RHIDE_COMPILE_ASM=$(RHIDE_AS) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\ + $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_EXTRA_FLAGS) $(LOCAL_OPT) -c\ + $(SOURCE_NAME) -o $(OUTFILE) +RHIDE_COMPILE_ASM_FORCE=$(RHIDE_AS) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\ + $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_EXTRA_FLAGS) -x assembler\ + $(LOCAL_OPT) -c $(SOURCE_NAME) -o $(OUTFILE) +RHIDE_GPC_FLAGS=$(RHIDE_INCLUDES) $(C_DEBUG_FLAGS) $(C_OPT_FLAGS)\ + $(C_WARN_FLAGS) $(C_P_LANG_FLAGS) $(C_EXTRA_FLAGS) +RHIDE_COMPILE_GPC=$(RHIDE_GPC) $(RHIDE_GPC_FLAGS) $(LOCAL_OPT) -c\ + $(SOURCE_NAME) -o $(OUTFILE) +RHIDE_COMPILE_GPC_FORCE=$(RHIDE_GPC) $(RHIDE_GPC_FLAGS) -x pascal\ + $(LOCAL_OPT) -c $(SOURCE_NAME) -o $(OUTFILE) +RHIDE_FPC_FLAGS=$(C_FPC_LANG_FLAGS) $(LOCAL_OPT) $(addprefix\ + -Up,$(INCLUDE_DIRS)) $(C_EXTRA_FLAGS) +RHIDE_COMPILE_FPC=$(RHIDE_FPC) $(RHIDE_FPC_FLAGS) -E- $(SOURCE_NAME) +RHIDE_COMPILE_FPC_FORCE=$(RHIDE_FPC) $(RHIDE_FPC_FLAGS) -B -E-\ + $(SOURCE_NAME) +RHIDE_COMPILE_LINK=$(RHIDE_LD) $(RHIDE_LIBDIRS) $(C_EXTRA_FLAGS) -o\ + $(OUTFILE) $(OBJFILES) $(LIBRARIES) $(LDFLAGS) $(RHIDE_LDFLAGS)\ + $(RHIDE_LIBS) +RHIDE_COMPILE_LINK_GPC=$(RHIDE_LD_PASCAL) $(RHIDE_LIBDIRS) $(C_EXTRA_FLAGS)\ + -o $(OUTFILE) $(OBJFILES) $(LIBRARIES) $(RHIDE_LDFLAGS) $(LDFLAGS)\ + $(RHIDE_LIBS) +RHIDE_COMPILE_LINK_GPC_AUTOMAKE=$(RHIDE_LD_PASCAL) $(RHIDE_LIBDIRS) -o\ + $(OUTFILE) --automake $(RHIDE_GPC_FLAGS) $(SOURCE_NAME)\ + $(LIBRARIES) $(LDFLAGS) $(RHIDE_LDFLAGS) $(RHIDE_LIBS) +RHIDE_COMPILE_PASCAL=$(RHIDE_COMPILE_$(PASCAL_TYPE)) +RHIDE_COMPILE_PASCAL_FORCE=$(RHIDE_COMPILE_$(PASCAL_TYPE)_FORCE) +RHIDE_COMPILE_LINK_PASCAL_AUTOMAKE=$(RHIDE_COMPILE_LINK_$(PASCAL_TYPE)_AUTOMAKE) +RHIDE_COMPILE_LINK_PASCAL=$(RHIDE_COMPILE_LINK_$(PASCAL_TYPE)) +RHIDE_FPC_LIBDIRS_$(RHIDE_OS)=/usr/local/lib /usr/lib /lib +RHIDE_FPC_LIBDIRS_DJGPP=/usr/local/lib /usr/lib /lib +RHIDE_FPC_LIBDIRS_DJGPP=$(DJDIR)/lib +RHIDE_FPC_LIBDIRS=$(RHIDE_FPC_LIBDIRS_$(RHIDE_OS)) +RHIDE_FPC_LINK_FLAGS_$(RHIDE_OS)=$(RHIDE_LIBDIRS) $(addprefix\ + -L,$(RHIDE_FPC_LIBDIRS)) +RHIDE_FPC_LINK_FLAGS_DJGPP=$(RHIDE_LIBDIRS) $(addprefix\ + -L,$(RHIDE_FPC_LIBDIRS)) +RHIDE_FPC_LINK_FLAGS_DJGPP=-O coff-go32-exe $(RHIDE_LIBDIRS) $(addprefix\ + -L,$(RHIDE_FPC_LIBDIRS)) +RHIDE_FPC_LINK_FLAGS=$(RHIDE_FPC_LINK_FLAGS_$(RHIDE_OS)) +RHIDE_COMPILE_LINK_FPC=echo 'separate linking for FPK is not supported.\ + Please define a main source file in Project/Primary file.' 1>&2 +RHIDE_COMPILE_LINK_FPC_AUTOMAKE=$(RHIDE_FPC) -o$(OUTFILE) $(SOURCE_NAME)\ + $(RHIDE_FPC_FLAGS) -E+ +RHIDE_COMPILE_ARCHIVE=$(RHIDE_AR) $(RHIDE_ARFLAGS) $(OUTFILE)\ + $(ALL_OBJFILES) +RHIDE_COMPILE_ADA=$(RHIDE_GCC) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\ + $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_C_LANG_FLAGS) $(C_EXTRA_FLAGS)\ + $(LOCAL_OPT) $(C_ADA_LANG_FLAGS) $(RHIDE_OS_CFLAGS) $(CPPFLAGS)\ + $(CFLAGS) -c $(SOURCE_NAME) -o $(OUTFILE) +RHIDE_ADA_BIND_FILE=$(addprefix _,$(setsuffix .c,$(OUTFILE))) +RHIDE_COMPILE_LINK_ADA_BIND=$(RHIDE_GNATBIND) -o $(RHIDE_ADA_BIND_FILE)\ + $(setsuffix .ali,$(OUTFILE)) +RHIDE_COMPILE_LINK_ADA_LINK=$(RHIDE_LD) $(RHIDE_LIBDIRS) $(C_EXTRA_FLAGS) -o\ + $(OUTFILE) $(RHIDE_ADA_BIND_FILE) $(OBJFILES) $(LIBRARIES)\ + $(LDFLAGS) $(RHIDE_LDFLAGS) $(RHIDE_LIBS) +_RHIDE_COMPILE_LINK_ADA=$(RHIDE_COMPILE_LINK_ADA_BIND);\ + $(RHIDE_COMPILE_LINK_ADA_LINK); $(RHIDE_RM)\ + $(RHIDE_ADA_BIND_FILE) +RHIDE_COMPILE_LINK_ADA=gnatbl $(RHIDE_LIBDIRS) $(C_EXTRA_FLAGS) -o\ + $(OUTFILE) $(setsuffix .ali,$(OUTFILE)) $(LIBRARIES) $(LDFLAGS) \ + $(RHIDE_LDFLAGS) $(RHIDE_LIBS) +RHIDE_COMPILE.c.o=$(RHIDE_COMPILE_C) +RHIDE_COMPILE.cc.o=$(RHIDE_COMPILE_CC) +RHIDE_COMPILE.p.o=$(RHIDE_COMPILE_PASCAL) +RHIDE_COMPILE.pas.o=$(RHIDE_COMPILE.p.o) +RHIDE_COMPILE.pp.o=$(RHIDE_COMPILE_FPC) +RHIDE_COMPILE.pas.s.GPC=$(subst -c $(SOURCE_NAME),-S\ + $(SOURCE_NAME),$(RHIDE_COMPILE_GPC)) +RHIDE_COMPILE.pas.s.FPC=$(RHIDE_COMPILE_FPC) -a -s +RHIDE_COMPILE.pas.s=$(RHIDE_COMPILE.pas.s.$(PASCAL_TYPE)) +RHIDE_COMPILE.f.o=$(RHIDE_COMPILE_FORTRAN) +RHIDE_COMPILE.nsm.o=$(RHIDE_COMPILE_NASM) +RHIDE_COMPILE.s.o=$(RHIDE_COMPILE_ASM) +RHIDE_COMPILE.c.s=$(subst -c $(SOURCE_NAME),-S\ + $(SOURCE_NAME),$(RHIDE_COMPILE_C)) +RHIDE_COMPILE.c.i=$(subst -c $(SOURCE_NAME),-E\ + $(SOURCE_NAME),$(RHIDE_COMPILE_C)) +RHIDE_COMPILE.i.s=$(RHIDE_COMPILE.c.s) +RHIDE_COMPILE.cc.s=$(subst -c $(SOURCE_NAME),-S\ + $(SOURCE_NAME),$(RHIDE_COMPILE_CC)) +RHIDE_COMPILE.cc.ii=$(subst -c $(SOURCE_NAME),-E\ + $(SOURCE_NAME),$(RHIDE_COMPILE_CC)) +RHIDE_COMPILE.ii.s=$(RHIDE_COMPILE.cc.s) +RHIDE_COMPILE.cpp.o=$(RHIDE_COMPILE.cc.o) +RHIDE_COMPILE.cxx.o=$(RHIDE_COMPILE.cc.o) +RHIDE_COMPILE.C.o=$(RHIDE_COMPILE.cc.o) +RHIDE_COMPILE.pas.o=$(RHIDE_COMPILE.p.o) +RHIDE_COMPILE.for.o=$(RHIDE_COMPILE.f.o) +RHIDE_COMPILE.F.o=$(RHIDE_COMPILE.f.o) +RHIDE_COMPILE.fpp.o=$(RHIDE_COMPILE.f.o) +RHIDE_COMPILE.asm.o=$(RHIDE_COMPILE.nsm.o) +RHIDE_COMPILE.cpp.s=$(RHIDE_COMPILE.cc.s) +RHIDE_COMPILE.cxx.s=$(RHIDE_COMPILE.cc.s) +RHIDE_COMPILE.C.s=$(RHIDE_COMPILE.cc.s) +RHIDE_COMPILE.cpp.ii=$(RHIDE_COMPILE.cc.ii) +RHIDE_COMPILE.cxx.ii=$(RHIDE_COMPILE.cc.ii) +RHIDE_COMPILE.C.ii=$(RHIDE_COMPILE.cc.ii) +RHIDE_COMPILE.adb.o=$(RHIDE_COMPILE_ADA) +RHIDE_FSDB=fsdb $(OUTFILE) $(addprefix -p ,$(SRC_DIRS)) $(PROG_ARGS) +RHIDE_GDB=gdb $(OUTFILE) $(addprefix -d ,$(SRC_DIRS)) +DEFAULT_GREP_MASK=*.[cfhmnps]* +RHIDE_GREP=grep -n $(prompt arguments for GREP,$(WUC) $(DEFAULT_GREP_MASK)) +RHIDE_GPROF=gprof $(OUTFILE) +RHIDE_RLOG=$(shell rlog -R $(rlog_arg)) +RHIDE_CO=$(shell co -q $(co_arg)) +RHIDE_STANDARD_INCLUDES_$(RHIDE_OS)=$(addprefix /usr/,include include/sys\ + include/g++ include/g++/std) +RHIDE_STANDARD_INCLUDES_DJGPP=$(addprefix /usr/,include include/sys\ + include/g++ include/g++/std) +RHIDE_STANDARD_INCLUDES_DJGPP=$(addprefix $(DJDIR)/,include include/sys\ + lang/cxx lang/cxx/std) +RHIDE_STANDARD_INCLUDES=$(RHIDE_STANDARD_INCLUDES_$(RHIDE_OS)) +RHIDE_CONFIG_DIRS_$(RHIDE_OS)=/usr/local/share/rhide /usr/share/rhide \ + /local/share/rhide /share/rhide +RHIDE_CONFIG_DIRS_DJGPP=/usr/local/share/rhide /usr/share/rhide \ + /local/share/rhide /share/rhide +RHIDE_CONFIG_DIRS_DJGPP=$(DJDIR)/share/rhide +RHIDE_CONFIG_DIRS_COMMON=$(RHIDE_CONFIG_DIRS_$(RHIDE_OS))\ + $(RHIDE_BIN_DIR)/../share/rhide +RHIDE_CONFIG_DIRS=. $(RHIDE_SHARE) $(GET_HOME) $(RHIDE_CONFIG_DIRS_COMMON)\ + $(addsuffix /SET,$(RHIDE_CONFIG_DIRS_COMMON)) $(SET_FILES) +RHIDE_PATH_SEPARATOR_$(RHIDE_OS)=: +RHIDE_PATH_SEPARATOR_DJGPP=: +RHIDE_PATH_SEPARATOR_DJGPP=; +RHIDE_PATH_SEPARATOR=$(RHIDE_PATH_SEPARATOR_$(RHIDE_OS)) +RHIDE_EMPTY= +RHIDE_SPACE=$(RHIDE_EMPTY) $(RHIDE_EMPTY) +RHIDE_TYPED_LIBS_DJGPP.cc=stdcxx m +RHIDE_TYPED_LIBS_DJGPP.cxx=stdcxx m +RHIDE_TYPED_LIBS_DJGPP.cpp=stdcxx m +RHIDE_TYPED_LIBS.f=g2c m +%.o: %.c + $(RHIDE_COMPILE.c.o) +%.o: %.i + $(RHIDE_COMPILE_C) +%.o: %.cc + $(RHIDE_COMPILE.cc.o) +%.o: %.cpp + $(RHIDE_COMPILE.cpp.o) +%.o: %.cxx + $(RHIDE_COMPILE.cxx.o) +%.o: %.C + $(RHIDE_COMPILE.C.o) +%.o: %.ii + $(RHIDE_COMPILE_CC) +%.o: %.s + $(RHIDE_COMPILE.s.o) +%.o: %.S + $(RHIDE_COMPILE_ASM) +%.s: %.c + $(RHIDE_COMPILE.c.s) +%.s: %.i + $(RHIDE_COMPILE.i.s) +%.s: %.cc + $(RHIDE_COMPILE.cc.s) +%.s: %.cpp + $(RHIDE_COMPILE.cpp.s) +%.s: %.cxx + $(RHIDE_COMPILE.cxx.s) +%.s: %.C + $(RHIDE_COMPILE.C.s) +%.o: %.pas + $(RHIDE_COMPILE.pas.o) +%.o: %.p + $(RHIDE_COMPILE.p.o) +%.o: %.pp + $(RHIDE_COMPILE.pp.o) +%.s: %.pas + $(RHIDE_COMPILE.pas.s) +%.o: %.m + $(RHIDE_COMPILE_OBJC) +%.o: %.f + $(RHIDE_COMPILE.f.o) +%.o: %.for + $(RHIDE_COMPILE.for.o) +%.o: %.F + $(RHIDE_COMPILE.F.o) +%.o: %.fpp + $(RHIDE_COMPILE.fpp.o) +%.o: %.asm + $(RHIDE_COMPILE.asm.o) +%.o: %.nsm + $(RHIDE_COMPILE.nsm.o) +%.o: %.adb + $(RHIDE_COMPILE.adb.o) +%.i: %.c + $(RHIDE_COMPILE.c.i) +%.s: %.c + $(RHIDE_COMPILE.c.s) +%.ii: %.cc + $(RHIDE_COMPILE.cc.ii) +%.s: %.cc + $(RHIDE_COMPILE.cc.s) +%.ii: %.cpp + $(RHIDE_COMPILE.cpp.ii) +%.s: %.cpp + $(RHIDE_COMPILE.cpp.s) +%.ii: %.cxx + $(RHIDE_COMPILE.cxx.ii) +%.s: %.cxx + $(RHIDE_COMPILE.cxx.s) +%.ii: %.C + $(RHIDE_COMPILE.C.ii) +%.s: %.C + $(RHIDE_COMPILE.C.s) +clean:: + rm -f $(CLEAN_FILES) +DEPS_0= main.o objgfx30.o ogBlit.o ogDisplay_VESA.o ogFont.o ogSprite.o +NO_LINK= +LINK_FILES=$(filter-out $(NO_LINK),$(DEPS_0)) +objgfx.exe:: $(DEPS_0) + $(RHIDE_COMPILE_LINK) +DEPS_1=main.cpp +main.o:: $(DEPS_1) + $(RHIDE_COMPILE.cpp.o) +DEPS_2=objgfx30.cpp +objgfx30.o:: $(DEPS_2) + $(RHIDE_COMPILE.cpp.o) +DEPS_3=ogBlit.cpp +ogBlit.o:: $(DEPS_3) + $(RHIDE_COMPILE.cpp.o) +DEPS_4=ogDisplay_VESA.cpp +ogDisplay_VESA.o:: $(DEPS_4) + $(RHIDE_COMPILE.cpp.o) +DEPS_5=ogFont.cpp +ogFont.o:: $(DEPS_5) + $(RHIDE_COMPILE.cpp.o) +DEPS_6=ogSprite.cpp +ogSprite.o:: $(DEPS_6) + $(RHIDE_COMPILE.cpp.o) +all:: objgfx.exe + \ No newline at end of file diff --git a/lockwasher/src/lib/views/vWidget.cpp b/lockwasher/src/lib/views/vWidget.cpp new file mode 100644 index 0000000..e285642 --- /dev/null +++ b/lockwasher/src/lib/views/vWidget.cpp @@ -0,0 +1,9 @@ +#include + +bool +vWidget::vSetActive(bool _active) { + bool result = active; + active = _active; + return result; +} // vWidget::vSetActive + diff --git a/lockwasher/src/lib/views/vWindow.cpp b/lockwasher/src/lib/views/vWindow.cpp new file mode 100644 index 0000000..894bb57 --- /dev/null +++ b/lockwasher/src/lib/views/vWindow.cpp @@ -0,0 +1,42 @@ +#include "objgfx30.h" +#include "vWindow.h" + +vWindow::vWindow(void) { + realWindow = new ogSurface(); + titleFont = new ogBitFont(); + return; +} // vWindow::vWindow + +bool +vWindow::vCreate(void) { + if (realWindow->ogCreate(400,400,OG_PIXFMT_32BPP) == false) return false; + if (ogAlias(*realWindow, // window + 0, 0, // [x1, y1] + realWindow->ogGetMaxX(), realWindow->ogGetMaxY()) // [x2, y2] + == false) return false; + return true; +} // vWindow::vCreate + +void +vWindow::vSDECommand(uInt32 command) { + asm( + "int %0" + : + : "i" (0x80),"a" (40),"b" (command),"c" (realWindow) + ); + return; +} // vWindow::vSDECommand + +vWindow::~vWindow() { + delete realWindow; + delete titleFont; + return; +} // vWindow::~vWindow + +/* +ogSurface -> vWidget -> vWindow + | \------> vButton + | + | + -- ogDisplay_UbixOS -> SDE +*/ diff --git a/lockwasher/src/sys/Makefile b/lockwasher/src/sys/Makefile new file mode 100644 index 0000000..a0181ad --- /dev/null +++ b/lockwasher/src/sys/Makefile @@ -0,0 +1,71 @@ +# $Id: Makefile,v 1.11 2003/05/04 13:20:15 reddawg Exp $ +# Kernel Makefile (C) 2002 The UbixOS Project + +all: boot-code init-code kernel-code isa-code pci-code sys-code vmm-code devfs-code ubixfs-code lib-code sde-code graphics-code ld-code kernel-img + +boot-code: boot + (cd boot;make) + +init-code: init + (cd init;make) + +kernel-code: kernel + (cd kernel;make) + +isa-code: isa + (cd isa;make) + +pci-code: pci + (cd pci;make) + +sys-code: sys + (cd sys;make) + +vmm-code: vmm + (cd vmm;make) + +ubixfs-code: ubixfs + (cd ubixfs;make) + +devfs-code: devfs + (cd devfs;make) + +graphics-code: graphics + (cd graphics;make) + +ld-code: ld + (cd ld;make) + +lib-code: lib + (cd lib;make) + +sde-code: sde + (cd sde;make) + +kernel-img: compile + (/bin/echo "/* " > ./compile/null.c) + (date >> ./compile/null.c) + (echo $user >> ./compile/null.c) + (/bin/echo " */" >> ./compile/null.c) + (cd compile;make) + +install: + (cd boot;make install) + (cd ../tools/;make format-dsk) + +clean: + (cd boot;make clean) + (cd init;make clean) + (cd isa;make clean) + (cd pci;make clean) + (cd sys;make clean) + (cd kernel;make clean) + (cd compile;make clean) + (cd vmm;make clean) + (cd devfs;make clean) + (cd ubixfs;make clean) + (cd graphics;make clean) + (cd lib;make clean) + (cd sde;make clean) + (cd ld;make clean) + (cd ../tools/;make clean) diff --git a/lockwasher/src/sys/boot/Makefile b/lockwasher/src/sys/boot/Makefile new file mode 100644 index 0000000..4252c13 --- /dev/null +++ b/lockwasher/src/sys/boot/Makefile @@ -0,0 +1,10 @@ +# $Id: Makefile,v 1.1.1.1 2003/01/12 00:20:07 reddawg Exp $ + +FDDEVICE = "/dev/fd0" +#FDDEVICE = /dev/fd1 +all: + +install: + +clean: + (rm -f writeimg format bootsec *.core boot2/test) diff --git a/lockwasher/src/sys/boot/Makefile.inc b/lockwasher/src/sys/boot/Makefile.inc new file mode 100644 index 0000000..e3011be --- /dev/null +++ b/lockwasher/src/sys/boot/Makefile.inc @@ -0,0 +1,6 @@ +# Common defines for all of /sys/boot/i386/ +# +# $FreeBSD: src/sys/boot/i386/Makefile.inc,v 1.1.2.2 2000/12/28 12:04:04 ps Exp $ + +LOADER_ADDRESS?= 0x200000 +CFLAGS+= -mpreferred-stack-boundary=2 diff --git a/lockwasher/src/sys/boot/boot2/Makefile b/lockwasher/src/sys/boot/boot2/Makefile new file mode 100644 index 0000000..cd404d1 --- /dev/null +++ b/lockwasher/src/sys/boot/boot2/Makefile @@ -0,0 +1,87 @@ +# $FreeBSD: src/sys/boot/i386/boot2/Makefile,v 1.16.2.5 2002/08/07 16:31:53 ru Exp $ + +PROG= boot2 +NOMAN= +STRIP= +BINDIR?= /boot +BINMODE= 444 +CLEANFILES+= boot1 boot1.out boot1.o \ + boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \ + sio.o + +NM?= nm + +# A value of 0x80 enables LBA support. +B1FLAGS= 0x80 + +BOOT_COMCONSOLE_PORT?= 0x3f8 +BOOT_COMCONSOLE_SPEED?= 9600 +B2SIOFMT?= 0x3 + +.if exists(${.OBJDIR}/../btx) +BTX= ${.OBJDIR}/../btx +.else +BTX= ${.CURDIR}/../btx +.endif + +ORG1= 0x7c00 +ORG2= 0x1000 + +CFLAGS= -elf -I${.CURDIR}/../btx/lib -I. \ + -Os -fno-builtin -fforce-addr -fdata-sections \ + -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \ + -mpreferred-stack-boundary=2 \ + -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ + -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ + -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings + +LDFLAGS=-nostdlib -static -N + +all: boot1 boot2 + +boot1: boot1.out + objcopy -S -O binary boot1.out ${.TARGET} + +boot1.out: boot1.o + ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o + +boot1.o: boot1.s + ${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} ${.IMPSRC} -o ${.TARGET} + +boot2.h: boot1.out + ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ + { x = $$1 - ORG1; printf("#define XREADORG 0x7%x\n", x) }' \ + ORG1=`printf "%d" ${ORG1}` > boot2.h + +boot2: boot2.ldr boot2.bin ${BTX}/btx/btx + btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \ + -o boot2.ld -P 1 boot2.bin + @ls -l boot2.ld | awk '{ x = 7680 - $$5; \ + print x " bytes available"; if (x < 0) exit 1 }' + dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null + +boot2.ldr: + dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null + +boot2.bin: boot2.out + objcopy -S -O binary boot2.out ${.TARGET} + +boot2.out: boot2.o sio.o + ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \ + ${BTX}/lib/crt0.o boot2.o sio.o + +boot2.o: boot2.h + +sio.o: sio.s + ${AS} ${AFLAGS} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \ + --defsym SIOFMT=${B2SIOFMT} \ + --defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \ + ${.IMPSRC} -o ${.TARGET} + +install: + ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + boot1 ${DESTDIR}${BINDIR}/boot1 + ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + boot2 ${DESTDIR}${BINDIR}/boot2 + +.include diff --git a/lockwasher/src/sys/boot/boot2/boot1.s b/lockwasher/src/sys/boot/boot2/boot1.s new file mode 100644 index 0000000..20d6fb0 --- /dev/null +++ b/lockwasher/src/sys/boot/boot2/boot1.s @@ -0,0 +1,364 @@ +# +# Copyright (c) 1998 Robert Nordier +# All rights reserved. +# +# Redistribution and use in source and binary forms are freely +# permitted provided that the above copyright notice and this +# paragraph and the following disclaimer are duplicated in all +# such forms. +# +# This software is provided "AS IS" and without any express or +# implied warranties, including, without limitation, the implied +# warranties of merchantability and fitness for a particular +# purpose. +# + +# $Id: boot1.s,v 1.3 2003/03/05 02:55:45 reddawg Exp $ + +# Memory Locations + .set MEM_REL,0x700 # Relocation address + .set MEM_ARG,0x900 # Arguments + .set MEM_ORG,0x7c00 # Origin + .set MEM_BUF,0x8c00 # Load area + .set MEM_BTX,0x9000 # BTX start + .set MEM_JMP,0x9010 # BTX entry point + .set MEM_USR,0xa000 # Client start + .set BDA_BOOT,0x472 # Boot howto flag + +# Partition Constants + .set PRT_OFF,0x1be # Partition offset + .set PRT_NUM,0x4 # Partitions + .set PRT_UBX,0x2A # Partition type + +# Flag Bits + .set FL_PACKET,0x80 # Packet mode + +# Misc. Constants + .set SIZ_PAG,0x1000 # Page size + .set SIZ_SEC,0x200 # Sector size + + .globl start + .globl xread + .code16 + +start: jmp main # Start recognizably + +# This is the start of a standard BIOS Parameter Block (BPB). Most bootable +# FAT disks have this at the start of their MBR. While normal BIOS's will +# work fine without this section, IBM's El Torito emulation "fixes" up the +# BPB by writing into the memory copy of the MBR. Rather than have data +# written into our xread routine, we'll define a BPB to work around it. +# The data marked with (T) indicates a field required for a ThinkPad to +# recognize the disk and (W) indicates fields written from IBM BIOS code. +# The use of the BPB is based on what OpenBSD and NetBSD implemented in +# their boot code but the required fields were determined by trial and error. +# +# Note: If additional space is needed in boot1, one solution would be to +# move the "prompt" message data (below) to replace the OEM ID. + + .org 0x03, 0x00 +oemid: .space 0x08, 0x00 # OEM ID + + .org 0x0b, 0x00 +bpb: .word 512 # sector size (T) + .byte 0 # sectors/clustor + .word 0 # reserved sectors + .byte 0 # number of FATs + .word 0 # root entries + .word 0 # small sectors + .byte 0 # media type (W) + .word 0 # sectors/fat + .word 18 # sectors per track (T) + .word 2 # number of heads (T) + .long 0 # hidden sectors (W) + .long 0 # large sectors + + .org 0x24, 0x00 +ebpb: .byte 0 # BIOS physical drive number (W) + + .org 0x25,0x90 +# +# Trampoline used by boot2 to call read to read data from the disk via +# the BIOS. Call with: +# +# %cx:%ax - long - LBA to read in +# %es:(%bx) - caddr_t - buffer to read data into +# %dl - byte - drive to read from +# %dh - byte - num sectors to read +# + +xread: push %ss # Address + pop %ds # data +# +# Setup an EDD disk packet and pass it to read +# +xread.1: # Starting + pushl $0x0 # absolute + push %cx # block + push %ax # number + push %es # Address of + push %bx # transfer buffer + xor %ax,%ax # Number of + movb %dh,%al # blocks to + push %ax # transfer + push $0x10 # Size of packet + mov %sp,%bp # Packet pointer + callw read # Read from disk + lea 0x10(%bp),%sp # Clear stack + lret # To far caller +# +# Load the rest of boot2 and BTX up, copy the parts to the right locations, +# and start it all up. +# + +# +# Setup the segment registers to flat addressing (segment 0) and setup the +# stack to end just below the start of our code. +# +main: +#mov $0x4f02,%ax +#mov $0x4103,%bx +#int $0x10 + cld # String ops inc + xor %cx,%cx # Zero + mov %cx,%es # Address + mov %cx,%ds # data + mov %cx,%ss # Set up + mov $start,%sp # stack +# +# Relocate ourself to MEM_REL. Since %cx == 0, the inc %ch sets +# %cx == 0x100. +# + mov %sp,%si # Source + mov $MEM_REL,%di # Destination + incb %ch # Word count + rep # Copy + movsw # code +# +# If we are on a hard drive, then load the MBR and look for the first +# UbixOS slice. We use the fake partition entry below that points to +# the MBR when we call nread. The first pass looks for the first active +# UbixOS slice. The second pass looks for the first non-active UbixOS +# slice if the first one fails. +# + mov $part4,%si # Partition + cmpb $0x80,%dl # Hard drive? + jb main.4 # No + movb $0x1,%dh # Block count + callw nread # Read MBR + mov $0x1,%cx # Two passes +main.1: mov $MEM_BUF+PRT_OFF,%si # Partition table + movb $0x1,%dh # Partition +main.2: cmpb $PRT_UBX,0x4(%si) # Our partition type? + jne main.3 # No + jcxz main.5 # If second pass + testb $0x80,(%si) # Active? + jnz main.5 # Yes +main.3: add $0x10,%si # Next entry + incb %dh # Partition + cmpb $0x1+PRT_NUM,%dh # In table? + jb main.2 # Yes + dec %cx # Do two + jcxz main.1 # passes +# +# If we get here, we didn't find any UbixOS slices at all, so print an +# error message and die. +# +#Ubu mov $msg_part,%si # Message + jmp error # Error +# +# Floppies use partition 0 of drive 0. +# +main.4: xor %dx,%dx # Partition:drive +# +# Ok, we have a slice and drive in %dx now, so use that to locate and load +# boot2. %si references the start of the slice we are looking for, so go +# ahead and load up the first 16 sectors (boot1 + boot2) from that. When +# we read it in, we conveniently use 0x8c00 as our transfer buffer. Thus, +# boot1 ends up at 0x8c00, and boot2 starts at 0x8c00 + 0x200 = 0x8e00. +# The first part of boot2 is the disklabel, which is 0x200 bytes long. +# The second part is BTX, which is thus loaded into 0x9000, which is where +# it also runs from. The boot2.bin binary starts right after the end of +# BTX, so we have to figure out where the start of it is and then move the +# binary to 0xb000. Normally, BTX clients start at MEM_USR, or 0xa000, but +# when we use btxld create boot2, we use an entry point of 0x1000. That +# entry point is relative to MEM_USR; thus boot2.bin starts at 0xb000. +# +main.5: mov %dx,MEM_ARG # Save args + movb $0x10,%dh # Sector count + callw nread # Read disk + mov $MEM_BTX,%bx # BTX + mov 0xa(%bx),%si # Get BTX length and set + add %bx,%si # %si to start of boot2.bin + mov $MEM_USR+SIZ_PAG,%di # Client page 1 + mov $MEM_BTX+0xe*SIZ_SEC,%cx # Byte + sub %si,%cx # count + rep # Relocate + movsb # client + sub %di,%cx # Byte count + xorb %al,%al # Zero assumed bss from + rep # the end of boot2.bin + stosb # up to 0x10000 + callw seta20 # Enable A20 + jmp start+MEM_JMP-MEM_ORG # Start BTX +# +# Enable A20 so we can access memory above 1 meg. +# +seta20: cli # Disable interrupts +seta20.1: inb $0x64,%al # Get status + testb $0x2,%al # Busy? + jnz seta20.1 # Yes + movb $0xd1,%al # Command: Write + outb %al,$0x64 # output port +seta20.2: inb $0x64,%al # Get status + testb $0x2,%al # Busy? + jnz seta20.2 # Yes + movb $0xdf,%al # Enable + outb %al,$0x60 # A20 + sti # Enable interrupts + retw # To caller +# +# Trampoline used to call read from within boot1. +# +nread: mov $MEM_BUF,%bx # Transfer buffer + mov 0x8(%si),%ax # Get + mov 0xa(%si),%cx # LBA + push %cs # Read from + callw xread.1 # disk + jnc return # If success, return + mov $msg_read,%si # Otherwise, set the error + # message and fall through to + # the error routine +# +# Print out the error message pointed to by %ds:(%si) followed +# by a prompt, wait for a keypress, and then reboot the machine. +# +error: callw putstr # Display message +# UBU mov $prompt,%si # Display + callw putstr # prompt + xorb %ah,%ah # BIOS: Get + int $0x16 # keypress + movw $0x1234, BDA_BOOT # Do a warm boot + ljmp $0xffff,$0x0 # reboot the machine +# +# Display a null-terminated string using the BIOS output. +# +putstr.0: mov $0x7,%bx # Page:attribute + movb $0xe,%ah # BIOS: Display + int $0x10 # character +putstr: lodsb # Get char + testb %al,%al # End of string? + jne putstr.0 # No + +# +# Overused return code. ereturn is used to return an error from the +# read function. Since we assume putstr succeeds, we (ab)use the +# same code when we return from putstr. +# +ereturn: movb $0x1,%ah # Invalid + stc # argument +return: retw # To caller +# +# Reads sectors from the disk. If EDD is enabled, then check if it is +# installed and use it if it is. If it is not installed or not enabled, then +# fall back to using CHS. Since we use a LBA, if we are using CHS, we have to +# fetch the drive parameters from the BIOS and divide it out ourselves. +# Call with: +# +# %dl - byte - drive number +# stack - 10 bytes - EDD Packet +# +read: push %dx # Save + movb $0x8,%ah # BIOS: Get drive + int $0x13 # parameters + movb %dh,%ch # Max head number + pop %dx # Restore + jc return # If error + andb $0x3f,%cl # Sectors per track + jz ereturn # If zero + cli # Disable interrupts + mov 0x8(%bp),%eax # Get LBA + push %dx # Save + movzbl %cl,%ebx # Divide by + xor %edx,%edx # sectors + div %ebx # per track + movb %ch,%bl # Max head number + movb %dl,%ch # Sector number + inc %bx # Divide by + xorb %dl,%dl # number + div %ebx # of heads + movb %dl,%bh # Head number + pop %dx # Restore + cmpl $0x3ff,%eax # Cylinder number supportable? + sti # Enable interrupts + ja read.7 # No, try EDD + xchgb %al,%ah # Set up cylinder + rorb $0x2,%al # number + orb %ch,%al # Merge + inc %ax # sector + xchg %ax,%cx # number + movb %bh,%dh # Head number + subb %ah,%al # Sectors this track + mov 0x2(%bp),%ah # Blocks to read + cmpb %ah,%al # To read + jb read.2 # this + movb %ah,%al # track +read.2: mov $0x5,%di # Try count +read.3: les 0x4(%bp),%bx # Transfer buffer + push %ax # Save + movb $0x2,%ah # BIOS: Read + int $0x13 # from disk + pop %bx # Restore + jnc read.4 # If success + dec %di # Retry? + jz read.6 # No + xorb %ah,%ah # BIOS: Reset + int $0x13 # disk system + xchg %bx,%ax # Block count + jmp read.3 # Continue +read.4: movzbw %bl,%ax # Sectors read + add %ax,0x8(%bp) # Adjust + jnc read.5 # LBA, + incw 0xa(%bp) # transfer +read.5: shlb %bl # buffer + add %bl,0x5(%bp) # pointer, + sub %al,0x2(%bp) # block count + ja read # If not done +read.6: retw # To caller +read.7: testb $FL_PACKET,%cs:MEM_REL+flags-start # LBA support enabled? + jz ereturn # No, so return an error + mov $0xbeba,%bx # Magic + push %dx # Save + movb $0x41,%ah # BIOS: Check + int $0x13 # extensions present + pop %dx # Restore + jc return # If error, return an error + cmp $0xbabe,%bx # Magic? + jne ereturn # No, so return an error + testb $0x1,%cl # Packet interface? + jz ereturn # No, so return an error + mov %bp,%si # Disk packet + movb $0x42,%ah # BIOS: Extended + int $0x13 # read + retw # To caller + +# Messages + +msg_read: .asciz "Read" +msg_part: .asciz "Boot" + +prompt: .asciz " error\r\n" + +flags: .byte FLAGS # Flags + + .org PRT_OFF,0x90 + +# Partition table + + .fill 0x30,0x1,0x0 +part4: .byte 0x80, 0x00, 0x01, 0x00 + .byte 0x2A, 0xff, 0xff, 0xff + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x50, 0xc3, 0x00, 0x00 # 50000 sectors long, bleh + + .word 0xbabe # Magic number diff --git a/lockwasher/src/sys/boot/boot2/boot2.c b/lockwasher/src/sys/boot/boot2/boot2.c new file mode 100644 index 0000000..013b416 --- /dev/null +++ b/lockwasher/src/sys/boot/boot2/boot2.c @@ -0,0 +1,878 @@ +/* + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + */ + +/* + * $ID: src/sys/boot/i386/boot2/boot2.c,v 1.28.2.6 2002/03/31 18:12:50 pb Exp $ + */ + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#include + +#include "boot2.h" +#include "lib.h" +#include "ubixfs.h" + +#define RBX_ASKNAME 0x0 /* -a */ +#define RBX_SINGLE 0x1 /* -s */ +#define RBX_DFLTROOT 0x5 /* -r */ +#define RBX_KDB 0x6 /* -d */ +#define RBX_CONFIG 0xa /* -c */ +#define RBX_VERBOSE 0xb /* -v */ +#define RBX_SERIAL 0xc /* -h */ +#define RBX_CDROM 0xd /* -C */ +#define RBX_GDB 0xf /* -g */ +#define RBX_DUAL 0x1d /* -D */ +#define RBX_PROBEKBD 0x1e /* -P */ +#define RBX_NOINTR 0x1f /* -n */ + +#define RBX_MASK 0xffff + +#define PATH_CONFIG "/boot.config" +#define PATH_BOOT3 "/boot/loader" +#define PATH_KERNEL "/ubix.elf" + +#define ARGS 0x900 +#define NOPT 12 +#define BSIZEMAX 16384 +#define NDEV 5 +#define MEM_BASE 0x12 +#define MEM_EXT 0x15 +#define V86_CY(x) ((x) & 1) +#define V86_ZR(x) ((x) & 0x40) + +#define DRV_HARD 0x80 +#define DRV_MASK 0x7f + +#define TYPE_AD 0 +#define TYPE_WD 1 +#define TYPE_WFD 2 +#define TYPE_FD 3 +#define TYPE_DA 4 + +extern uint32_t _end; + +struct blockAllocationTableEntry *BAT = 0x0; +struct directoryEntry *rootDir = 0x0; + +static const char optstr[NOPT] = "DhaCcdgnPrsv"; +static const unsigned char flags[NOPT] = { + RBX_DUAL, + RBX_SERIAL, + RBX_ASKNAME, + RBX_CDROM, + RBX_CONFIG, + RBX_KDB, + RBX_GDB, + RBX_NOINTR, + RBX_PROBEKBD, + RBX_DFLTROOT, + RBX_SINGLE, + RBX_VERBOSE +}; + +static const char *const dev_nm[] = {"ad", "wd", " ", "fd", "da"}; +static const unsigned dev_maj[] = {30, 0, 1, 2, 4}; + +static struct dsk { + unsigned drive; + unsigned type; + unsigned unit; + unsigned slice; + unsigned part; + unsigned start; + int init; + int meta; +} dsk; +static char cmd[512]; +static char kname[1024]; +static uint32_t opts; +static struct bootinfo bootinfo; +static int ls; +static uint32_t fs_off; +static uint8_t ioctrl = 0x1; + +void exit(int); +static void load(const char *); +static int parse(char *); +static ino_t lookup(const char *); +static int xfsread(const char *, void *, size_t); +static ssize_t fsread(const char *, void *, size_t); +static int dskread(void *, unsigned, unsigned); +static int printf(const char *,...); +static int putchar(int); +static void *memcpy(void *, const void *, size_t); +static void *malloc(size_t); +static uint32_t memsize(int); +static int drvread(void *, unsigned, unsigned); +static int keyhit(unsigned); +static int xputc(int); +static int xgetc(int); +static int getc(int); + +//My Functions +static void initUbixFS(void); + +static inline void readfile(const char *fname, void *buf, size_t size) { + fs_off = 0; + fsread(fname,buf,size); + /* + ino_t ino; + if ((ino = lookup(fname))) + fsread(ino, buf, size); + */ + } + +static inline int +strcmp(const char *s1, const char *s2) +{ + for (; *s1 == *s2 && *s1; s1++, s2++); + return (u_char)*s1 - (u_char)*s2; +} + +static inline int +fsfind(const char *name, ino_t * ino) +{ + char buf[DEV_BSIZE]; + struct dirent *d; + char *s; + ssize_t n; + fs_off = 0; + while ((n = fsread(name, buf, DEV_BSIZE)) > 0) + for (s = buf; s < buf + DEV_BSIZE;) { + d = (void *)s; + if (ls) + printf("%s ", d->d_name); + else if (!strcmp(name, d->d_name)) { + *ino = d->d_fileno; + return d->d_type; + } + s += d->d_reclen; + } + if (n != -1 && ls) + putchar('\n'); + return 0; +} + +static inline int +getchar(void) +{ + int c; + + c = xgetc(0); + if (c == '\r') + c = '\n'; + return c; +} + +static inline void +getstr(char *str, int size) +{ + char *s; + int c; + + s = str; + do { + switch (c = getchar()) { + case 0: + break; + case '\b': + case '\177': + if (s > str) { + s--; + putchar('\b'); + putchar(' '); + } else + c = 0; + break; + case '\n': + *s = 0; + break; + default: + if (s - str < size - 1) + *s++ = c; + } + if (c) + putchar(c); + } while (c != '\n'); +} + +static inline uint32_t +drvinfo(int drive) +{ + v86.addr = 0x13; + v86.eax = 0x800; + v86.edx = DRV_HARD + drive; + v86int(); + if (V86_CY(v86.efl)) + return 0x4f010f; + return ((v86.ecx & 0xc0) << 18) | ((v86.ecx & 0xff00) << 8) | + (v86.edx & 0xff00) | (v86.ecx & 0x3f); +} + +static inline void +putc(int c) +{ + v86.addr = 0x10; + v86.eax = 0xe00 | (c & 0xff); + v86.ebx = 0x7; + v86int(); +} + +static void initUbixFS() { + BAT = (struct blockAllocationTableEntry *)malloc(4096); + rootDir = (struct directoryEntry *)malloc(4096); + dskread(BAT,0,8); + dskread(rootDir,8,8); + } + +int +main(void) +{ + int autoboot, i; + + v86.ctl = V86_FLAGS; + dsk.drive = *(uint8_t *)PTOV(ARGS); + dsk.type = dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD; + dsk.unit = dsk.drive & DRV_MASK; + dsk.slice = *(uint8_t *)PTOV(ARGS + 1) + 1; + bootinfo.bi_version = BOOTINFO_VERSION; + bootinfo.bi_size = sizeof(bootinfo); + bootinfo.bi_basemem = memsize(MEM_BASE); + bootinfo.bi_extmem = memsize(MEM_EXT); + bootinfo.bi_memsizes_valid++; + for (i = 0; i < N_BIOS_GEOM; i++) + bootinfo.bi_bios_geom[i] = drvinfo(i); + autoboot = 2; + + //Initialize UbixFS + initUbixFS(); + + readfile(PATH_CONFIG, cmd, sizeof(cmd)); + if (*cmd) { + printf("%s: %s", PATH_CONFIG, cmd); + if (parse(cmd)) + autoboot = 0; + *cmd = 0; + } + if (autoboot && !*kname) { + if (autoboot == 2) { + memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3)); + if (!keyhit(0x37)) { + load(kname); + autoboot = 1; + } + } + if (autoboot == 1) + memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL)); + } + for (;;) { + printf(" \n>> UbixOS/i386 BOOT\n" + "Default: %u:%s(%u,%c)%s\n" + "boot: ", + dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit, + 'a' + dsk.part, kname); + if (ioctrl & 0x2) + sio_flush(); + if (!autoboot || keyhit(0x5a)) + getstr(cmd, sizeof(cmd)); + else + putchar('\n'); + autoboot = 0; + if (parse(cmd)) + putchar('\a'); + else + load(kname); + } +} + +/* XXX - Needed for btxld to link the boot2 binary; do not remove. */ +void +exit(int x) +{ +} + +static void +load(const char *fname) +{ + union { + struct exec ex; + Elf32_Ehdr eh; + } hdr; + Elf32_Phdr ep[2]; + Elf32_Shdr es[2]; + caddr_t p; + ino_t ino; + uint32_t addr, x; + int fmt, i, j; + fs_off = 0; + /* + if (!(ino = lookup(fname))) { + if (!ls) + printf("No %s\n", fname); + return; + } + */ + if (xfsread(fname, &hdr, sizeof(hdr))) + return; + if (N_GETMAGIC(hdr.ex) == ZMAGIC) + fmt = 0; + else if (IS_ELF(hdr.eh)) + fmt = 1; + else { + printf("Invalid %s\n", "format"); + return; + } + if (fmt == 0) { + addr = hdr.ex.a_entry & 0xffffff; + p = PTOV(addr); + fs_off = PAGE_SIZE; + if (xfsread(fname, p, hdr.ex.a_text)) + return; + p += roundup2(hdr.ex.a_text, PAGE_SIZE); + if (xfsread(fname, p, hdr.ex.a_data)) + return; + p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE); + bootinfo.bi_symtab = VTOP(p); + memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms)); + p += sizeof(hdr.ex.a_syms); + if (hdr.ex.a_syms) { + if (xfsread(fname, p, hdr.ex.a_syms)) + return; + p += hdr.ex.a_syms; + if (xfsread(fname, p, sizeof(int))) + return; + x = *(uint32_t *)p; + p += sizeof(int); + x -= sizeof(int); + if (xfsread(fname, p, x)) + return; + p += x; + } + } else { + fs_off = hdr.eh.e_phoff; + for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) { + if (xfsread(fname, ep + j, sizeof(ep[0]))) + return; + if (ep[j].p_type == PT_LOAD) + j++; + } + for (i = 0; i < 2; i++) { + p = PTOV(ep[i].p_paddr & 0xffffff); + fs_off = ep[i].p_offset; + if (xfsread(fname, p, ep[i].p_filesz)) + return; + } + p += roundup2(ep[1].p_memsz, PAGE_SIZE); + bootinfo.bi_symtab = VTOP(p); + if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) { + fs_off = hdr.eh.e_shoff + sizeof(es[0]) * + (hdr.eh.e_shstrndx + 1); + if (xfsread(fname, &es, sizeof(es))) + return; + for (i = 0; i < 2; i++) { + memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size)); + p += sizeof(es[i].sh_size); + fs_off = es[i].sh_offset; + if (xfsread(fname, p, es[i].sh_size)) + return; + p += es[i].sh_size; + } + } + addr = hdr.eh.e_entry & 0xffffff; + } + bootinfo.bi_esymtab = VTOP(p); + bootinfo.bi_kernelname = VTOP(fname); + bootinfo.bi_bios_dev = dsk.drive; + __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), + MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part), + 0, 0, 0, VTOP(&bootinfo)); +} + +static int +parse(char *arg) +{ + char *p, *q; + int drv, c, i; + + while ((c = *arg++)) { + if (c == ' ' || c == '\t' || c == '\n') + continue; + for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); + if (*p) + *p++ = 0; + if (c == '-') { + while ((c = *arg++)) { + for (i = 0; c != optstr[i]; i++) + if (i == NOPT - 1) + return -1; + opts ^= 1 << flags[i]; + } + if (opts & 1 << RBX_PROBEKBD) { + i = *(uint8_t *)PTOV(0x496) & 0x10; + printf("Keyboard: %s\n", i ? "yes" : "no"); + if (!i) + opts |= 1 << RBX_DUAL | 1 << RBX_SERIAL; + opts &= ~(1 << RBX_PROBEKBD); + } + ioctrl = opts & 1 << RBX_DUAL ? 0x3 : + opts & 1 << RBX_SERIAL ? 0x2 : 0x1; + if (ioctrl & 0x2) + sio_init(); + } else { + for (q = arg--; *q && *q != '('; q++); + if (*q) { + drv = -1; + if (arg[1] == ':') { + if (*arg < '0' || *arg > '9') + return -1; + drv = *arg - '0'; + arg += 2; + } + if (q - arg != 2) + return -1; + for (i = 0; arg[0] != dev_nm[i][0] || + arg[1] != dev_nm[i][1]; i++) + if (i == NDEV - 1) + return -1; + dsk.type = i; + arg += 3; + if (arg[1] != ',' || *arg < '0' || *arg > '9') + return -1; + dsk.unit = *arg - '0'; + arg += 2; + dsk.slice = WHOLE_DISK_SLICE; + if (arg[1] == ',') { + if (*arg < '0' || *arg > '0' + NDOSPART) + return -1; + if ((dsk.slice = *arg - '0')) + dsk.slice++; + arg += 2; + } + if (arg[1] != ')' || *arg < 'a' || *arg > 'p') + return -1; + dsk.part = *arg - 'a'; + arg += 2; + if (drv == -1) + drv = dsk.unit; + dsk.drive = (dsk.type == TYPE_WD || + dsk.type == TYPE_AD || + dsk.type == TYPE_DA ? DRV_HARD : 0) + drv; + dsk.meta = 0; + fsread(0, NULL, 0); + } + if ((i = p - arg - !*(p - 1))) { + if (i >= sizeof(kname)) + return -1; + memcpy(kname, arg, i + 1); + } + } + arg = p; + } + return 0; +} + +static ino_t +lookup(const char *path) +{ + char name[MAXNAMLEN + 1]; + const char *s; + ino_t ino; + ssize_t n; + int dt; + + ino = ROOTINO; + dt = DT_DIR; + for (;;) { + if (*path == '/') + path++; + if (!*path) + break; + for (s = path; *s && *s != '/'; s++); + if ((n = s - path) > MAXNAMLEN) + return 0; + ls = *path == '?' && n == 1 && !*s; + memcpy(name, path, n); + name[n] = 0; + if ((dt = fsfind(name, &ino)) <= 0) + break; + path = s; + } + return dt == DT_REG ? ino : 0; +} +static int +xfsread(const char *fname, void *buf, size_t nbyte) +{ + if (fsread(fname, buf, nbyte) != nbyte) { +// printf("Invalid %s\n", "format"); + return -1; + } + return 0; +} + +/* FSREAD */ +static ssize_t fsread(const char *fname, void *buf, size_t nbyte) { + int i = 0x0,x = 0x0,block = 0x0,bOffset = 0x0,offset = 0x0,lb = -1; + int fBlock = -1; + char *buffer = 0x0; + char *buffer2 = 0x0; + struct directoryEntry *tmpDir = 0x0; + tmpDir = rootDir; + if (*fname == '/') { fname++; } + for (i=0;i<=(4096/sizeof(struct directoryEntry));i++) { + if (!strcmp(tmpDir[i].fileName,fname)) { + fBlock = tmpDir[i].startCluster; + break; + } + } + if (fBlock == -1) { + nbyte = 0; + return(nbyte); + } + buffer = malloc(4096); + buffer2 = buf; + offset = fs_off; + if (offset < 0) { + printf("Error!!!\n"); + offset = 0; + } + for (i=0;i> DEV_BSHIFT; + dsk.meta++; + } + if (!inode) + return 0; + if (inomap != inode) { + if (dskread(blkbuf, fsbtodb(&fs, ino_to_fsba(&fs, inode)), + fsblks)) + return -1; + din = ((struct dinode *)blkbuf)[inode % INOPB(&fs)]; + inomap = inode; + fs_off = 0; + blkmap = indmap = 0; + } + s = buf; + if (nbyte > (n = din.di_size - fs_off)) + nbyte = n; + nb = nbyte; + while (nb) { + lbn = lblkno(&fs, fs_off); + if (lbn < NDADDR) + addr = din.di_db[lbn]; + else { + if (indmap != din.di_ib[0]) { + if (!indbuf) + indbuf = malloc(BSIZEMAX); + if (dskread(indbuf, fsbtodb(&fs, din.di_ib[0]), + fsblks)) + return -1; + indmap = din.di_ib[0]; + } + addr = indbuf[(lbn - NDADDR) % NINDIR(&fs)]; + } + n = dblksize(&fs, &din, lbn); + if (blkmap != addr) { + if (dskread(blkbuf, fsbtodb(&fs, addr), n >> DEV_BSHIFT)) + return -1; + blkmap = addr; + } + off = blkoff(&fs, fs_off); + n -= off; + if (n > nb) + n = nb; + memcpy(s, blkbuf + off, n); + s += n; + fs_off += n; + nb -= n; + } + return nbyte; +} +*/ + +static int +dskread(void *buf, unsigned lba, unsigned nblk) +{ + static char *sec; + struct dos_partition *dp; + struct ubixDiskLabel *d; + unsigned sl, i; + + if (!dsk.meta) { + if (!sec) + sec = malloc(DEV_BSIZE); + dsk.start = 0; + if (drvread(sec, DOSBBSECTOR, 1)) + return -1; + dp = (void *)(sec + DOSPARTOFF); + sl = dsk.slice; + if (sl < BASE_SLICE) { + for (i = 0; i < NDOSPART; i++) + if (dp[i].dp_typ == DOSPTYP_UBX && + (dp[i].dp_flag & 0x80 || sl < BASE_SLICE)) { + sl = BASE_SLICE + i; + if (dp[i].dp_flag & 0x80 || + dsk.slice == COMPATIBILITY_SLICE) + break; + } + if (dsk.slice == WHOLE_DISK_SLICE) + dsk.slice = sl; + } + if (sl != WHOLE_DISK_SLICE) { + if (sl != COMPATIBILITY_SLICE) + dp += sl - BASE_SLICE; + if (dp->dp_typ != DOSPTYP_UBX) { + printf("Invalid %s\n", "slice"); + return -1; + } + dsk.start = dp->dp_start; + } + if (drvread(sec, dsk.start + LABELSECTOR, 1)) + return -1; + d = (void *)(sec + LABELOFFSET); + if (d->magicNum != UBIXDISKMAGIC || d->magicNum2 != UBIXDISKMAGIC) { + if (dsk.part != RAW_PART) { + printf("Invalid %s\n", "label"); + return -1; + } + } else { + if (!dsk.init) { + if (d->driveType == DTYPE_SCSI) + dsk.type = TYPE_DA; + dsk.init++; + } + if (dsk.part >= d->numPartitions || + !d->partitions[dsk.part].p_size) { + printf("Invalid %s\n", "partition"); + return -1; + } + dsk.start = d->partitions[dsk.part].p_offset; + } + } + return drvread(buf, dsk.start + lba, nblk); +} + +static int +printf(const char *fmt,...) +{ + static const char digits[16] = "0123456789abcdef"; + va_list ap; + char buf[10]; + char *s; + unsigned r, u; + int c; + + va_start(ap, fmt); + while ((c = *fmt++)) { + if (c == '%') { + c = *fmt++; + switch (c) { + case 'c': + putchar(va_arg(ap, int)); + continue; + case 's': + for (s = va_arg(ap, char *); *s; s++) + putchar(*s); + continue; + case 'u': + case 'x': + r = c == 'u' ? 10U : 16U; + u = va_arg(ap, unsigned); + s = buf; + do + *s++ = digits[u % r]; + while (u /= r); + while (--s >= buf) + putchar(*s); + continue; + } + } + putchar(c); + } + va_end(ap); + return 0; +} + +static int +putchar(int c) +{ + if (c == '\n') + xputc('\r'); + return xputc(c); +} + +static void * +memcpy(void *dst, const void *src, size_t size) +{ + const char *s; + char *d; + + for (d = dst, s = src; size; size--) + *d++ = *s++; + return dst; +} + +static void * +malloc(size_t size) +{ + static uint32_t next; + void *p; + + if (!next) + next = roundup2(__base + _end, 0x10000) - __base; + p = (void *)next; + next += size; + return p; +} + +static uint32_t +memsize(int type) +{ + v86.addr = type; + v86.eax = 0x8800; + v86int(); + return v86.eax; +} + +static int +drvread(void *buf, unsigned lba, unsigned nblk) +{ + static unsigned c = 0x2d5c7c2f; + + printf("%c\b", c = c << 8 | c >> 24); + v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; + v86.addr = XREADORG; /* call to xread in boot1 */ + v86.es = VTOPSEG(buf); + v86.eax = lba; + v86.ebx = VTOPOFF(buf); + v86.ecx = lba >> 16; + v86.edx = nblk << 8 | dsk.drive; + v86int(); + v86.ctl = V86_FLAGS; + if (V86_CY(v86.efl)) { + printf("Disk error 0x%x (lba=0x%x)\n", v86.eax >> 8 & 0xff, + lba); + return -1; + } + return 0; +} + +static int +keyhit(unsigned ticks) +{ + uint32_t t0, t1; + + if (opts & 1 << RBX_NOINTR) + return 0; + t0 = 0; + for (;;) { + if (xgetc(1)) + return 1; + t1 = *(uint32_t *)PTOV(0x46c); + if (!t0) + t0 = t1; + if (t1 < t0 || t1 >= t0 + ticks) + return 0; + } +} + +static int +xputc(int c) +{ + if (ioctrl & 0x1) + putc(c); + if (ioctrl & 0x2) + sio_putc(c); + return c; +} + +static int +xgetc(int fn) +{ + if (opts & 1 << RBX_NOINTR) + return 0; + for (;;) { + if (ioctrl & 0x1 && getc(1)) + return fn ? 1 : getc(0); + if (ioctrl & 0x2 && sio_ischar()) + return fn ? 1 : sio_getc(); + if (fn) + return 0; + } +} + +static int +getc(int fn) +{ + v86.addr = 0x16; + v86.eax = fn << 8; + v86int(); + return fn == 0 ? v86.eax & 0xff : !V86_ZR(v86.efl); +} diff --git a/lockwasher/src/sys/boot/boot2/lib.h b/lockwasher/src/sys/boot/boot2/lib.h new file mode 100644 index 0000000..44d1f10 --- /dev/null +++ b/lockwasher/src/sys/boot/boot2/lib.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + */ + +/* + * $FreeBSD: src/sys/boot/i386/boot2/lib.h,v 1.2 1999/08/28 00:40:02 peter Exp $ + */ + +void sio_init(void); +void sio_flush(void); +void sio_putc(int); +int sio_getc(void); +int sio_ischar(void); diff --git a/lockwasher/src/sys/boot/boot2/sio.s b/lockwasher/src/sys/boot/boot2/sio.s new file mode 100644 index 0000000..1e8da20 --- /dev/null +++ b/lockwasher/src/sys/boot/boot2/sio.s @@ -0,0 +1,80 @@ +# +# Copyright (c) 1998 Robert Nordier +# All rights reserved. +# +# Redistribution and use in source and binary forms are freely +# permitted provided that the above copyright notice and this +# paragraph and the following disclaimer are duplicated in all +# such forms. +# +# This software is provided "AS IS" and without any express or +# implied warranties, including, without limitation, the implied +# warranties of merchantability and fitness for a particular +# purpose. +# + +# $FreeBSD: src/sys/boot/i386/boot2/sio.s,v 1.4 1999/08/28 00:40:02 peter Exp $ + + .set SIO_PRT,SIOPRT # Base port + .set SIO_FMT,SIOFMT # 8N1 + .set SIO_DIV,(115200/SIOSPD) # 115200 / SPD + + .globl sio_init + .globl sio_flush + .globl sio_putc + .globl sio_getc + .globl sio_ischar + +# void sio_init(void) + +sio_init: movw $SIO_PRT+0x3,%dx # Data format reg + movb $SIO_FMT|0x80,%al # Set format + outb %al,(%dx) # and DLAB + pushl %edx # Save + subb $0x3,%dl # Divisor latch reg + movw $SIO_DIV,%ax # Set + outw %ax,(%dx) # BPS + popl %edx # Restore + movb $SIO_FMT,%al # Clear + outb %al,(%dx) # DLAB + incl %edx # Modem control reg + movb $0x3,%al # Set RTS, + outb %al,(%dx) # DTR + incl %edx # Line status reg + +# void sio_flush(void) + +sio_flush.0: call sio_getc.1 # Get character +sio_flush: call sio_ischar # Check for character + jnz sio_flush.0 # Till none + ret # To caller + +# void sio_putc(int c) + +sio_putc: movw $SIO_PRT+0x5,%dx # Line status reg + xor %ecx,%ecx # Timeout + movb $0x40,%ch # counter +sio_putc.1: inb (%dx),%al # Transmitter + testb $0x20,%al # buffer empty? + loopz sio_putc.1 # No + jz sio_putc.2 # If timeout + movb 0x4(%esp,1),%al # Get character + subb $0x5,%dl # Transmitter hold reg + outb %al,(%dx) # Write character +sio_putc.2: ret $0x4 # To caller + +# int sio_getc(void) + +sio_getc: call sio_ischar # Character available? + jz sio_getc # No +sio_getc.1: subb $0x5,%dl # Receiver buffer reg + inb (%dx),%al # Read character + ret # To caller + +# int sio_ischar(void) + +sio_ischar: movw $SIO_PRT+0x5,%dx # Line status register + xorl %eax,%eax # Zero + inb (%dx),%al # Received data + andb $0x1,%al # ready? + ret # To caller diff --git a/lockwasher/src/sys/boot/boot2/test.c b/lockwasher/src/sys/boot/boot2/test.c new file mode 100644 index 0000000..3cb1c85 --- /dev/null +++ b/lockwasher/src/sys/boot/boot2/test.c @@ -0,0 +1,24 @@ +#include +#include + +#include "ubixfs.h" + +int main() { + FILE *fd; + struct ubixDiskLabel *d = (struct ubixDiskLabel *)malloc(512); + printf("Building Disk Label\n"); + d->magicNum = UBIXDISKMAGIC; + d->magicNum2 = UBIXDISKMAGIC; + d->numPartitions = 2; + d->partitions[0].p_size = 2000; + d->partitions[0].p_offset = 50; + d->partitions[0].p_fstype = 0x24; + d->partitions[0].p_bsize = 0x8; + d->partitions[1].p_size = 2000; + d->partitions[1].p_offset = 1000; + d->partitions[1].p_fstype = 0x24; + d->partitions[1].p_bsize = 0x8; + fd = fopen("/dev/fd0","wb"); + fseek(fd,512,0); + fwrite(d,512,1,fd); + } diff --git a/lockwasher/src/sys/boot/boot2/ubixfs.h b/lockwasher/src/sys/boot/boot2/ubixfs.h new file mode 100644 index 0000000..4c558d1 --- /dev/null +++ b/lockwasher/src/sys/boot/boot2/ubixfs.h @@ -0,0 +1,44 @@ +#define DOSPTYP_UBX 0x2A /* UbixFS partition type */ +#define UBIXDISKMAGIC ((u_int32_t)0x45) /* The disk magic number */ +#define MAXUBIXPARTITIONS 16 +#define UBIXFSMAGIC ((u_int32_t)0x69) /* The File System Magic Number */ + +typedef unsigned long uLong; +typedef unsigned short uShort; + + +struct ubixDiskLabel { + u_int32_t magicNum; + u_int32_t magicNum2; + u_int16_t driveType; + u_int16_t numPartitions; + struct ubixPartitions { /* the partition table */ + u_int32_t p_size; /* number of sectors in partition */ + u_int32_t p_offset; /* starting sector */ + u_int32_t p_fsize; /* filesystem basic fragment size */ + u_int32_t p_bsize; /* BAT size */ + u_int8_t p_fstype; /* filesystem type, see below */ + u_int8_t p_frag; /* filesystem fragments per block */ + } partitions[MAXUBIXPARTITIONS]; + }; + +//Block Allocation Table Entry +struct blockAllocationTableEntry { + long attributes; //Block Attributes + long realSector; //Real Sector + long nextBlock; //Sector Of Next Block + long reserved; //Reserved + }; + + +struct directoryEntry { + uLong startCluster; //Starting Cluster Of File + uLong size; //Size Of File + uLong creationDate; //Date Created + uLong lastModified; //Date Last Modified + uLong uid; //UID Of Owner + uLong gid; //GID Of Owner + uShort attributes; //Files Attributes + uShort permissions; //Files Permissions + char fileName[256]; //File Name + }; diff --git a/lockwasher/src/sys/boot/btx/Makefile b/lockwasher/src/sys/boot/btx/Makefile new file mode 100644 index 0000000..9a65f19 --- /dev/null +++ b/lockwasher/src/sys/boot/btx/Makefile @@ -0,0 +1,5 @@ +# $FreeBSD: src/sys/boot/i386/btx/Makefile,v 1.6 1999/08/28 00:40:03 peter Exp $ + +SUBDIR= btx btxldr lib + +.include diff --git a/lockwasher/src/sys/boot/btx/btx/Makefile b/lockwasher/src/sys/boot/btx/btx/Makefile new file mode 100644 index 0000000..cdefb50 --- /dev/null +++ b/lockwasher/src/sys/boot/btx/btx/Makefile @@ -0,0 +1,36 @@ +# $FreeBSD: src/sys/boot/i386/btx/btx/Makefile,v 1.7.2.2 2000/12/28 12:08:22 ps Exp $ + +M4?= m4 + +.if defined(PAGING) +M4FLAGS+= -DPAGING +.endif + +.if defined(BOOT_BTX_NOHANG) +BOOT_BTX_FLAGS=0x1 +.else +BOOT_BTX_FLAGS=0x0 +.endif + +AFLAGS+= --defsym BTX_FLAGS=${BOOT_BTX_FLAGS} + +ORG= 0x9000 + +all: btx + +btx: btx.o +.if ${OBJFORMAT} == aout + ${LD} -nostdlib -N -s -T ${ORG} -o btx.out btx.o + dd if=btx.out of=${.TARGET} ibs=32 skip=1 +.else + ${LD} -N -e start -Ttext ${ORG} -o btx.out btx.o + objcopy -S -O binary btx.out ${.TARGET} +.endif + +btx.o: btx.s + (cd ${.CURDIR}; ${M4} ${M4FLAGS} btx.s) | \ + ${AS} ${AFLAGS} -o ${.TARGET} + +CLEANFILES+= btx btx.out btx.o + +.include diff --git a/lockwasher/src/sys/boot/btx/btx/btx.s b/lockwasher/src/sys/boot/btx/btx/btx.s new file mode 100644 index 0000000..0bcf0a9 --- /dev/null +++ b/lockwasher/src/sys/boot/btx/btx/btx.s @@ -0,0 +1,1080 @@ +# +# Copyright (c) 1998 Robert Nordier +# All rights reserved. +# +# Redistribution and use in source and binary forms are freely +# permitted provided that the above copyright notice and this +# paragraph and the following disclaimer are duplicated in all +# such forms. +# +# This software is provided "AS IS" and without any express or +# implied warranties, including, without limitation, the implied +# warranties of merchantability and fitness for a particular +# purpose. +# + +# $FreeBSD: src/sys/boot/i386/btx/btx/btx.s,v 1.15.2.4 2000/12/28 12:08:22 ps Exp $ + +# +# Memory layout. +# + .set MEM_BTX,0x1000 # Start of BTX memory + .set MEM_ESP0,0x1800 # Supervisor stack + .set MEM_BUF,0x1800 # Scratch buffer + .set MEM_ESP1,0x1e00 # Link stack + .set MEM_IDT,0x1e00 # IDT + .set MEM_TSS,0x1f98 # TSS + .set MEM_MAP,0x2000 # I/O bit map + .set MEM_DIR,0x4000 # Page directory + .set MEM_TBL,0x5000 # Page tables + .set MEM_ORG,0x9000 # BTX code + .set MEM_USR,0xa000 # Start of user memory +# +# Paging control. +# + .set PAG_SIZ,0x1000 # Page size + .set PAG_CNT,0x1000 # Pages to map +# +# Segment selectors. +# + .set SEL_SCODE,0x8 # Supervisor code + .set SEL_SDATA,0x10 # Supervisor data + .set SEL_RCODE,0x18 # Real mode code + .set SEL_RDATA,0x20 # Real mode data + .set SEL_UCODE,0x28|3 # User code + .set SEL_UDATA,0x30|3 # User data + .set SEL_TSS,0x38 # TSS +# +# Task state segment fields. +# + .set TSS_ESP0,0x4 # PL 0 ESP + .set TSS_SS0,0x8 # PL 0 SS + .set TSS_ESP1,0xc # PL 1 ESP + .set TSS_MAP,0x66 # I/O bit map base +# +# System calls. +# + .set SYS_EXIT,0x0 # Exit + .set SYS_EXEC,0x1 # Exec +# +# V86 constants. +# + .set V86_FLG,0x208eff # V86 flag mask + .set V86_STK,0x400 # V86 stack allowance +# +# Dump format control bytes. +# + .set DMP_X16,0x1 # Word + .set DMP_X32,0x2 # Long + .set DMP_MEM,0x4 # Memory + .set DMP_EOL,0x8 # End of line +# +# Screen defaults and assumptions. +# + .set SCR_MAT,0x7 # Mode/attribute + .set SCR_COL,0x50 # Columns per row + .set SCR_ROW,0x19 # Rows per screen +# +# BIOS Data Area locations. +# + .set BDA_MEM,0x413 # Free memory + .set BDA_KEYFLAGS,0x417 # Keyboard shift-state flags + .set BDA_SCR,0x449 # Video mode + .set BDA_POS,0x450 # Cursor position + .set BDA_BOOT,0x472 # Boot howto flag +# +# Derivations, for brevity. +# + .set _ESP0H,MEM_ESP0>>0x8 # Byte 1 of ESP0 + .set _ESP1H,MEM_ESP1>>0x8 # Byte 1 of ESP1 + .set _TSSIO,MEM_MAP-MEM_TSS # TSS I/O base + .set _TSSLM,MEM_DIR-MEM_TSS-1 # TSS limit + .set _IDTLM,MEM_TSS-MEM_IDT-1 # IDT limit +# +# Code segment. +# + .globl start + .code16 +start: # Start of code +# +# BTX header. +# +btx_hdr: .byte 0xeb # Machine ID + .byte 0xe # Header size + .ascii "BTX" # Magic + .byte 0x1 # Major version + .byte 0x1 # Minor version + .byte BTX_FLAGS # Flags + .word PAG_CNT-MEM_ORG>>0xc # Paging control + .word break-start # Text size + .long 0x0 # Entry address +# +# Initialization routine. +# +init: cli # Disable interrupts + xor %ax,%ax # Zero/segment + mov %ax,%ss # Set up + mov $MEM_ESP0,%sp # stack + mov %ax,%es # Address + mov %ax,%ds # data + pushl $0x2 # Clear + popfl # flags +# +# Initialize memory. +# + mov $MEM_IDT,%di # Memory to initialize + mov $(MEM_ORG-MEM_IDT)/2,%cx # Words to zero + push %di # Save + rep # Zero-fill + stosw # memory + pop %di # Restore +# +# Create IDT. +# + mov $idtctl,%si # Control string +init.1: lodsb # Get entry + cbw # count + xchg %ax,%cx # as word + jcxz init.4 # If done + lodsb # Get segment + xchg %ax,%dx # P:DPL:type + lodsw # Get control + xchg %ax,%bx # set + lodsw # Get handler offset + mov $SEL_SCODE,%dh # Segment selector +init.2: shr %bx # Handle this int? + jnc init.3 # No + mov %ax,(%di) # Set handler offset + mov %dh,0x2(%di) # and selector + mov %dl,0x5(%di) # Set P:DPL:type + add $0x4,%ax # Next handler +init.3: lea 0x8(%di),%di # Next entry + loop init.2 # Till set done + jmp init.1 # Continue +# +# Initialize TSS. +# +init.4: movb $_ESP0H,TSS_ESP0+1(%di) # Set ESP0 + movb $SEL_SDATA,TSS_SS0(%di) # Set SS0 + movb $_ESP1H,TSS_ESP1+1(%di) # Set ESP1 + movb $_TSSIO,TSS_MAP(%di) # Set I/O bit map base +ifdef(`PAGING',` +# +# Create page directory. +# + xor %edx,%edx # Page + mov $PAG_SIZ>>0x8,%dh # size + xor %eax,%eax # Zero + mov $MEM_DIR,%di # Page directory + mov $PAG_CNT>>0xa,%cl # Entries + mov $MEM_TBL|0x7,%ax # First entry +init.5: stosl # Write entry + add %dx,%ax # To next + loop init.5 # Till done +# +# Create page tables. +# + mov $MEM_TBL,%di # Page table + mov $PAG_CNT>>0x8,%ch # Entries + xor %ax,%ax # Start address +init.6: mov $0x7,%al # Set U:W:P flags + cmp btx_hdr+0x8,%cx # Standard user page? + jb init.7 # Yes + cmp $PAG_CNT-MEM_BTX>>0xc,%cx # BTX memory? + jae init.7 # No or first page + and $~0x2,%al # Clear W flag + cmp $PAG_CNT-MEM_USR>>0xc,%cx # User page zero? + jne init.7 # No + testb $0x80,btx_hdr+0x7 # Unmap it? + jz init.7 # No + and $~0x1,%al # Clear P flag +init.7: stosl # Set entry + add %edx,%eax # Next address + loop init.6 # Till done +') +# +# Bring up the system. +# + mov $0x2820,%bx # Set protected mode + callw setpic # IRQ offsets + lidt idtdesc # Set IDT +ifdef(`PAGING',` + xor %eax,%eax # Set base + mov $MEM_DIR>>0x8,%ah # of page + mov %eax,%cr3 # directory +') + lgdt gdtdesc # Set GDT + mov %cr0,%eax # Switch to protected +ifdef(`PAGING',` + or $0x80000001,%eax # mode and enable paging +',` + or $0x01,%eax # mode +') + mov %eax,%cr0 # + ljmp $SEL_SCODE,$init.8 # To 32-bit code + .code32 +init.8: xorl %ecx,%ecx # Zero + movb $SEL_SDATA,%cl # To 32-bit + movw %cx,%ss # stack +# +# Launch user task. +# + movb $SEL_TSS,%cl # Set task + ltr %cx # register + movl $MEM_USR,%edx # User base address + movzwl %ss:BDA_MEM,%eax # Get free memory + shll $0xa,%eax # To bytes + subl $0x1000,%eax # Less arg space + subl %edx,%eax # Less base + movb $SEL_UDATA,%cl # User data selector + pushl %ecx # Set SS + pushl %eax # Set ESP + push $0x202 # Set flags (IF set) + push $SEL_UCODE # Set CS + pushl btx_hdr+0xc # Set EIP + pushl %ecx # Set GS + pushl %ecx # Set FS + pushl %ecx # Set DS + pushl %ecx # Set ES + pushl %edx # Set EAX + movb $0x7,%cl # Set remaining +init.9: push $0x0 # general + loop init.9 # registers + popa # and initialize + popl %es # Initialize + popl %ds # user + popl %fs # segment + popl %gs # registers + iret # To user mode +# +# Exit routine. +# +exit: cli # Disable interrupts + movl $MEM_ESP0,%esp # Clear stack +# +# Turn off paging. +# + movl %cr0,%eax # Get CR0 +ifdef(`PAGING',` + andl $~0x80000000,%eax # Disable + movl %eax,%cr0 # paging +') + xorl %ecx,%ecx # Zero +ifdef(`PAGING',` + movl %ecx,%cr3 # Flush TLB +') +# +# To 16 bits. +# + ljmpw $SEL_RCODE,$exit.1 # Reload CS + .code16 +exit.1: mov $SEL_RDATA,%cl # 16-bit selector + mov %cx,%ss # Reload SS + mov %cx,%ds # Load + mov %cx,%es # remaining + mov %cx,%fs # segment + mov %cx,%gs # registers +# +# To real-address mode. +# + dec %ax # Switch to + mov %eax,%cr0 # real mode + ljmp $0x0,$exit.2 # Reload CS +exit.2: xor %ax,%ax # Real mode segment + mov %ax,%ss # Reload SS + mov %ax,%ds # Address data + mov $0x7008,%bx # Set real mode + callw setpic # IRQ offsets + lidt ivtdesc # Set IVT +# +# Reboot or await reset. +# + sti # Enable interrupts + testb $0x1,btx_hdr+0x7 # Reboot? +exit.3: jz exit.3 # No + movw $0x1234, BDA_BOOT # Do a warm boot + ljmp $0xffff,$0x0 # reboot the machine +# +# Set IRQ offsets by reprogramming 8259A PICs. +# +setpic: in $0x21,%al # Save master + push %ax # IMR + in $0xa1,%al # Save slave + push %ax # IMR + movb $0x11,%al # ICW1 to + outb %al,$0x20 # master, + outb %al,$0xa0 # slave + movb %bl,%al # ICW2 to + outb %al,$0x21 # master + movb %bh,%al # ICW2 to + outb %al,$0xa1 # slave + movb $0x4,%al # ICW3 to + outb %al,$0x21 # master + movb $0x2,%al # ICW3 to + outb %al,$0xa1 # slave + movb $0x1,%al # ICW4 to + outb %al,$0x21 # master, + outb %al,$0xa1 # slave + pop %ax # Restore slave + outb %al,$0xa1 # IMR + pop %ax # Restore master + outb %al,$0x21 # IMR + retw # To caller + .code32 +# +# Initiate return from V86 mode to user mode. +# +inthlt: hlt # To supervisor mode +# +# Exception jump table. +# +intx00: push $0x0 # Int 0x0: #DE + jmp ex_noc # Divide error + push $0x1 # Int 0x1: #DB + jmp ex_noc # Debug + push $0x3 # Int 0x3: #BP + jmp ex_noc # Breakpoint + push $0x4 # Int 0x4: #OF + jmp ex_noc # Overflow + push $0x5 # Int 0x5: #BR + jmp ex_noc # BOUND range exceeded + push $0x6 # Int 0x6: #UD + jmp ex_noc # Invalid opcode + push $0x7 # Int 0x7: #NM + jmp ex_noc # Device not available + push $0x8 # Int 0x8: #DF + jmp except # Double fault + push $0xa # Int 0xa: #TS + jmp except # Invalid TSS + push $0xb # Int 0xb: #NP + jmp except # Segment not present + push $0xc # Int 0xc: #SS + jmp except # Stack segment fault + push $0xd # Int 0xd: #GP + jmp ex_v86 # General protection + push $0xe # Int 0xe: #PF + jmp except # Page fault +intx10: push $0x10 # Int 0x10: #MF + jmp ex_noc # Floating-point error +# +# Handle #GP exception. +# +ex_v86: testb $0x2,0x12(%esp,1) # V86 mode? + jz except # No + jmp v86mon # To monitor +# +# Save a zero error code. +# +ex_noc: pushl (%esp,1) # Duplicate int no + movb $0x0,0x4(%esp,1) # Fake error code +# +# Handle exception. +# +except: cld # String ops inc + pushl %ds # Save + pushl %es # most + pusha # registers + movb $0x6,%al # Push loop count + testb $0x2,0x3a(%esp,1) # V86 mode? + jnz except.1 # Yes + pushl %gs # Set GS + pushl %fs # Set FS + pushl %ds # Set DS + pushl %es # Set ES + movb $0x2,%al # Push loop count + cmpw $SEL_SCODE,0x44(%esp,1) # Supervisor mode? + jne except.1 # No + pushl %ss # Set SS + leal 0x50(%esp,1),%eax # Set + pushl %eax # ESP + jmp except.2 # Join common code +except.1: pushl 0x50(%esp,1) # Set GS, FS, DS, ES + decb %al # (if V86 mode), and + jne except.1 # SS, ESP +except.2: push $SEL_SDATA # Set up + popl %ds # to + pushl %ds # address + popl %es # data + movl %esp,%ebx # Stack frame + movl $dmpfmt,%esi # Dump format string + movl $MEM_BUF,%edi # Buffer + pushl %edi # Dump to + call dump # buffer + popl %esi # and + call putstr # display + leal 0x18(%esp,1),%esp # Discard frame + popa # Restore + popl %es # registers + popl %ds # saved + cmpb $0x3,(%esp,1) # Breakpoint? + je except.3 # Yes + jmp exit # Exit +except.3: leal 0x8(%esp,1),%esp # Discard err, int no + iret # From interrupt +# +# Return to user mode from V86 mode. +# +intrtn: cld # String ops inc + pushl %ds # Address + popl %es # data + leal 0x3c(%ebp),%edx # V86 Segment registers + movl MEM_TSS+TSS_ESP1,%esi # Link stack pointer + lodsl # INT_V86 args pointer + movl %esi,%ebx # Saved exception frame + testl %eax,%eax # INT_V86 args? + jz intrtn.2 # No + movl $MEM_USR,%edi # User base + movl 0x1c(%esi),%ebx # User ESP + movl %eax,(%edi,%ebx,1) # Restore to user stack + leal 0x8(%edi,%eax,1),%edi # Arg segment registers + testb $0x4,-0x6(%edi) # Return flags? + jz intrtn.1 # No + movl 0x30(%ebp),%eax # Get V86 flags + movw %ax,0x18(%esi) # Set user flags +intrtn.1: leal 0x10(%esi),%ebx # Saved exception frame + xchgl %edx,%esi # Segment registers + movb $0x4,%cl # Update seg regs + rep # in INT_V86 + movsl # args +intrtn.2: movl %edx,%esi # Segment registers + leal 0x28(%ebp),%edi # Set up seg + movb $0x4,%cl # regs for + rep # later + movsl # pop + movl %ebx,%esi # Restore exception + movb $0x5,%cl # frame to + rep # supervisor + movsl # stack + movl %esi,MEM_TSS+TSS_ESP1 # Link stack pointer + popa # Restore + leal 0x8(%esp,1),%esp # Discard err, int no + popl %es # Restore + popl %ds # user + popl %fs # segment + popl %gs # registers + iret # To user mode +# +# V86 monitor. +# +v86mon: cld # String ops inc + pushl $SEL_SDATA # Set up for + popl %ds # flat addressing + pusha # Save registers + movl %esp,%ebp # Address stack frame + movzwl 0x2c(%ebp),%edi # Load V86 CS + shll $0x4,%edi # To linear + movl 0x28(%ebp),%esi # Load V86 IP + addl %edi,%esi # Code pointer + xorl %ecx,%ecx # Zero + movb $0x2,%cl # 16-bit operands + xorl %eax,%eax # Zero +v86mon.1: lodsb # Get opcode + cmpb $0x66,%al # Operand size prefix? + jne v86mon.2 # No + movb $0x4,%cl # 32-bit operands + jmp v86mon.1 # Continue +v86mon.2: cmpb $0xf4,%al # HLT? + jne v86mon.3 # No + cmpl $inthlt+0x1,%esi # Is inthlt? + jne v86mon.7 # No (ignore) + jmp intrtn # Return to user mode +v86mon.3: cmpb $0xf,%al # Prefixed instruction? + jne v86mon.4 # No + cmpb $0x09,(%esi) # Is it a WBINVD? + je v86wbinvd # Yes + cmpb $0x30,(%esi) # Is it a WRMSR? + je v86wrmsr # Yes + cmpb $0x32,(%esi) # Is it a RDMSR? + je v86rdmsr # Yes + cmpb $0x20,(%esi) # Is this a + jne v86mon.4 # MOV EAX,CR0 + cmpb $0xc0,0x1(%esi) # instruction? + je v86mov # Yes +v86mon.4: cmpb $0xfa,%al # CLI? + je v86cli # Yes + cmpb $0xfb,%al # STI? + je v86sti # Yes + movzwl 0x38(%ebp),%ebx # Load V86 SS + shll $0x4,%ebx # To offset + pushl %ebx # Save + addl 0x34(%ebp),%ebx # Add V86 SP + movl 0x30(%ebp),%edx # Load V86 flags + cmpb $0x9c,%al # PUSHF/PUSHFD? + je v86pushf # Yes + cmpb $0x9d,%al # POPF/POPFD? + je v86popf # Yes + cmpb $0xcd,%al # INT imm8? + je v86intn # Yes + cmpb $0xcf,%al # IRET/IRETD? + je v86iret # Yes + popl %ebx # Restore + popa # Restore + jmp except # Handle exception +v86mon.5: movl %edx,0x30(%ebp) # Save V86 flags +v86mon.6: popl %edx # V86 SS adjustment + subl %edx,%ebx # Save V86 + movl %ebx,0x34(%ebp) # SP +v86mon.7: subl %edi,%esi # From linear + movl %esi,0x28(%ebp) # Save V86 IP + popa # Restore + leal 0x8(%esp,1),%esp # Discard int no, error + iret # To V86 mode +# +# Emulate MOV EAX,CR0. +# +v86mov: movl %cr0,%eax # CR0 to + movl %eax,0x1c(%ebp) # saved EAX + incl %esi # Adjust IP +# +# Return from emulating a 0x0f prefixed instruction +# +v86preret: incl %esi # Adjust IP + jmp v86mon.7 # Finish up +# +# Emulate WBINVD +# +v86wbinvd: wbinvd # Write back and invalidate + # cache + jmp v86preret # Finish up +# +# Emulate WRMSR +# +v86wrmsr: movl 0x18(%ebp),%ecx # Get user's %ecx (MSR to write) + movl 0x14(%ebp),%edx # Load the value + movl 0x1c(%ebp),%eax # to write + wrmsr # Write MSR + jmp v86preret # Finish up +# +# Emulate RDMSR +# +v86rdmsr: movl 0x18(%ebp),%ecx # MSR to read + rdmsr # Read the MSR + movl %eax,0x1c(%ebp) # Return the value of + movl %edx,0x14(%ebp) # the MSR to the user + jmp v86preret # Finish up +# +# Emulate CLI. +# +v86cli: andb $~0x2,0x31(%ebp) # Clear IF + jmp v86mon.7 # Finish up +# +# Emulate STI. +# +v86sti: orb $0x2,0x31(%ebp) # Set IF + jmp v86mon.7 # Finish up +# +# Emulate PUSHF/PUSHFD. +# +v86pushf: subl %ecx,%ebx # Adjust SP + cmpb $0x4,%cl # 32-bit + je v86pushf.1 # Yes + data16 # 16-bit +v86pushf.1: movl %edx,(%ebx) # Save flags + jmp v86mon.6 # Finish up +# +# Emulate IRET/IRETD. +# +v86iret: movzwl (%ebx),%esi # Load V86 IP + movzwl 0x2(%ebx),%edi # Load V86 CS + leal 0x4(%ebx),%ebx # Adjust SP + movl %edi,0x2c(%ebp) # Save V86 CS + xorl %edi,%edi # No ESI adjustment +# +# Emulate POPF/POPFD (and remainder of IRET/IRETD). +# +v86popf: cmpb $0x4,%cl # 32-bit? + je v86popf.1 # Yes + movl %edx,%eax # Initialize + data16 # 16-bit +v86popf.1: movl (%ebx),%eax # Load flags + addl %ecx,%ebx # Adjust SP + andl $V86_FLG,%eax # Merge + andl $~V86_FLG,%edx # the + orl %eax,%edx # flags + jmp v86mon.5 # Finish up +# +# trap int 15, function 87 +# reads %es:%si from saved registers on stack to find a GDT containing +# source and destination locations +# reads count of words from saved %cx +# returns success by setting %ah to 0 +# +int15_87: pushl %eax # Save + pushl %ebx # some information + pushl %esi # onto the stack. + pushl %edi + xorl %eax,%eax # clean EAX + xorl %ebx,%ebx # clean EBX + movl 0x4(%ebp),%esi # Get user's ESI + movl 0x3C(%ebp),%ebx # store ES + movw %si,%ax # store SI + shll $0x4,%ebx # Make it a seg. + addl %eax,%ebx # ebx=(es<<4)+si + movb 0x14(%ebx),%al # Grab the + movb 0x17(%ebx),%ah # necessary + shll $0x10,%eax # information + movw 0x12(%ebx),%ax # from + movl %eax,%esi # the + movb 0x1c(%ebx),%al # GDT in order to + movb 0x1f(%ebx),%ah # have %esi offset + shll $0x10,%eax # of source and %edi + movw 0x1a(%ebx),%ax # of destination. + movl %eax,%edi + pushl %ds # Make: + popl %es # es = ds + pushl %ecx # stash ECX + xorl %ecx,%ecx # highw of ECX is clear + movw 0x18(%ebp),%cx # Get user's ECX + shll $0x1,%ecx # Convert from num words to num + # bytes + rep # repeat... + movsb # perform copy. + popl %ecx # Restore + popl %edi + popl %esi # previous + popl %ebx # register + popl %eax # values. + movb $0x0,0x1d(%ebp) # set ah = 0 to indicate + # success + andb $0xfe,%dl # clear CF + jmp v86mon.5 # Finish up + +# +# Reboot the machine by setting the reboot flag and exiting +# +reboot: orb $0x1,btx_hdr+0x7 # Set the reboot flag + jmp exit # Terminate BTX and reboot + +# +# Emulate INT imm8... also make sure to check if it's int 15/87 +# +v86intn: lodsb # Get int no + cmpb $0x19,%al # is it int 19? + je reboot # yes, reboot the machine + cmpb $0x15,%al # is it int 15? + jne v86intn.3 # no, skip parse + pushl %eax # stash EAX + movl 0x1c(%ebp),%eax # user's saved EAX + cmpb $0x87,%ah # is it the memcpy subfunction? + jne v86intn.1 # no, keep checking + popl %eax # get the stack straight + jmp int15_87 # it's our cue +v86intn.1: cmpw $0x4f53,%ax # is it the delete key callout? + jne v86intn.2 # no, handle the int normally + movb BDA_KEYFLAGS,%al # get the shift key state + andb $0xc,%al # mask off just Ctrl and Alt + cmpb $0xc,%al # are both Ctrl and Alt down? + jne v86intn.2 # no, handle the int normally + popl %eax # restore EAX + jmp reboot # reboot the machine +v86intn.2: popl %eax # restore EAX +v86intn.3: subl %edi,%esi # From + shrl $0x4,%edi # linear + movw %dx,-0x2(%ebx) # Save flags + movw %di,-0x4(%ebx) # Save CS + leal -0x6(%ebx),%ebx # Adjust SP + movw %si,(%ebx) # Save IP + shll $0x2,%eax # Scale + movzwl (%eax),%esi # Load IP + movzwl 0x2(%eax),%edi # Load CS + movl %edi,0x2c(%ebp) # Save CS + xorl %edi,%edi # No ESI adjustment + andb $~0x1,%dh # Clear TF + jmp v86mon.5 # Finish up +# +# Hardware interrupt jump table. +# +intx20: push $0x8 # Int 0x20: IRQ0 + jmp int_hw # V86 int 0x8 + push $0x9 # Int 0x21: IRQ1 + jmp int_hw # V86 int 0x9 + push $0xa # Int 0x22: IRQ2 + jmp int_hw # V86 int 0xa + push $0xb # Int 0x23: IRQ3 + jmp int_hw # V86 int 0xb + push $0xc # Int 0x24: IRQ4 + jmp int_hw # V86 int 0xc + push $0xd # Int 0x25: IRQ5 + jmp int_hw # V86 int 0xd + push $0xe # Int 0x26: IRQ6 + jmp int_hw # V86 int 0xe + push $0xf # Int 0x27: IRQ7 + jmp int_hw # V86 int 0xf + push $0x70 # Int 0x28: IRQ8 + jmp int_hw # V86 int 0x70 + push $0x71 # Int 0x29: IRQ9 + jmp int_hw # V86 int 0x71 + push $0x72 # Int 0x2a: IRQ10 + jmp int_hw # V86 int 0x72 + push $0x73 # Int 0x2b: IRQ11 + jmp int_hw # V86 int 0x73 + push $0x74 # Int 0x2c: IRQ12 + jmp int_hw # V86 int 0x74 + push $0x75 # Int 0x2d: IRQ13 + jmp int_hw # V86 int 0x75 + push $0x76 # Int 0x2e: IRQ14 + jmp int_hw # V86 int 0x76 + push $0x77 # Int 0x2f: IRQ15 + jmp int_hw # V86 int 0x77 +# +# Reflect hardware interrupts. +# +int_hw: testb $0x2,0xe(%esp,1) # V86 mode? + jz intusr # No + pushl $SEL_SDATA # Address + popl %ds # data + xchgl %eax,(%esp,1) # Swap EAX, int no + pushl %ebp # Address + movl %esp,%ebp # stack frame + pushl %ebx # Save + shll $0x2,%eax # Get int + movl (%eax),%eax # vector + subl $0x6,0x14(%ebp) # Adjust V86 ESP + movzwl 0x18(%ebp),%ebx # V86 SS + shll $0x4,%ebx # * 0x10 + addl 0x14(%ebp),%ebx # + V86 ESP + xchgw %ax,0x8(%ebp) # Swap V86 IP + rorl $0x10,%eax # Swap words + xchgw %ax,0xc(%ebp) # Swap V86 CS + roll $0x10,%eax # Swap words + movl %eax,(%ebx) # CS:IP for IRET + movl 0x10(%ebp),%eax # V86 flags + movw %ax,0x4(%ebx) # Flags for IRET + andb $~0x3,0x11(%ebp) # Clear IF, TF + popl %ebx # Restore + popl %ebp # saved + popl %eax # registers + iret # To V86 mode +# +# Invoke V86 interrupt from user mode, with arguments. +# +intx31: stc # Have btx_v86 + pushl %eax # Missing int no +# +# Invoke V86 interrupt from user mode. +# +intusr: std # String ops dec + pushl %eax # Expand + pushl %eax # stack + pushl %eax # frame + pusha # Save + pushl %gs # Save + movl %esp,%eax # seg regs + pushl %fs # and + pushl %ds # point + pushl %es # to them + push $SEL_SDATA # Set up + popl %ds # to + pushl %ds # address + popl %es # data + movl $MEM_USR,%ebx # User base + movl %ebx,%edx # address + jc intusr.1 # If btx_v86 + xorl %edx,%edx # Control flags + xorl %ebp,%ebp # btx_v86 pointer +intusr.1: leal 0x50(%esp,1),%esi # Base of frame + pushl %esi # Save + addl -0x4(%esi),%ebx # User ESP + movl MEM_TSS+TSS_ESP1,%edi # Link stack pointer + leal -0x4(%edi),%edi # Adjust for push + xorl %ecx,%ecx # Zero + movb $0x5,%cl # Push exception + rep # frame on + movsl # link stack + xchgl %eax,%esi # Saved seg regs + movl 0x40(%esp,1),%eax # Get int no + testl %edx,%edx # Have btx_v86? + jz intusr.2 # No + movl (%ebx),%ebp # btx_v86 pointer + movb $0x4,%cl # Count + addl %ecx,%ebx # Adjust for pop + rep # Push saved seg regs + movsl # on link stack + addl %ebp,%edx # Flatten btx_v86 ptr + leal 0x14(%edx),%esi # Seg regs pointer + movl 0x4(%edx),%eax # Get int no/address + movzwl 0x2(%edx),%edx # Get control flags +intusr.2: movl %ebp,(%edi) # Push btx_v86 and + movl %edi,MEM_TSS+TSS_ESP1 # save link stack ptr + popl %edi # Base of frame + xchgl %eax,%ebp # Save intno/address + movl 0x48(%esp,1),%eax # Get flags + testb $0x2,%dl # Simulate CALLF? + jnz intusr.3 # Yes + decl %ebx # Push flags + decl %ebx # on V86 + movw %ax,(%ebx) # stack +intusr.3: movb $0x4,%cl # Count + subl %ecx,%ebx # Push return address + movl $inthlt,(%ebx) # on V86 stack + rep # Copy seg regs to + movsl # exception frame + xchgl %eax,%ecx # Save flags + movl %ebx,%eax # User ESP + subl $V86_STK,%eax # Less bytes + ja intusr.4 # to + xorl %eax,%eax # keep +intusr.4: shrl $0x4,%eax # Gives segment + stosl # Set SS + shll $0x4,%eax # To bytes + xchgl %eax,%ebx # Swap + subl %ebx,%eax # Gives offset + stosl # Set ESP + xchgl %eax,%ecx # Get flags + btsl $0x11,%eax # Set VM + andb $~0x1,%ah # Clear TF + stosl # Set EFL + xchgl %eax,%ebp # Get int no/address + testb $0x1,%dl # Address? + jnz intusr.5 # Yes + shll $0x2,%eax # Scale + movl (%eax),%eax # Load int vector +intusr.5: movl %eax,%ecx # Save + shrl $0x10,%eax # Gives segment + stosl # Set CS + movw %cx,%ax # Restore + stosl # Set EIP + leal 0x10(%esp,1),%esp # Discard seg regs + popa # Restore + iret # To V86 mode +# +# System Call. +# +intx30: cmpl $SYS_EXEC,%eax # Exec system call? + jne intx30.1 # No + pushl %ss # Set up + popl %es # all + pushl %es # segment + popl %ds # registers + pushl %ds # for the + popl %fs # program + pushl %fs # we're + popl %gs # invoking + movl $MEM_USR,%eax # User base address + addl 0xc(%esp,1),%eax # Change to user + leal 0x4(%eax),%esp # stack +ifdef(`PAGING',` + movl %cr0,%eax # Turn + andl $~0x80000000,%eax # off + movl %eax,%cr0 # paging + xorl %eax,%eax # Flush + movl %eax,%cr3 # TLB +') + popl %eax # Call + call *%eax # program +intx30.1: incb %ss:btx_hdr+0x7 # Flag reboot + jmp exit # Exit +# +# Dump structure [EBX] to [EDI], using format string [ESI]. +# +dump.0: stosb # Save char +dump: lodsb # Load char + testb %al,%al # End of string? + jz dump.10 # Yes + testb $0x80,%al # Control? + jz dump.0 # No + movb %al,%ch # Save control + movb $'=',%al # Append + stosb # '=' + lodsb # Get offset + pushl %esi # Save + movsbl %al,%esi # To + addl %ebx,%esi # pointer + testb $DMP_X16,%ch # Dump word? + jz dump.1 # No + lodsw # Get and + call hex16 # dump it +dump.1: testb $DMP_X32,%ch # Dump long? + jz dump.2 # No + lodsl # Get and + call hex32 # dump it +dump.2: testb $DMP_MEM,%ch # Dump memory? + jz dump.8 # No + pushl %ds # Save + testb $0x2,0x52(%ebx) # V86 mode? + jnz dump.3 # Yes + verr 0x4(%esi) # Readable selector? + jnz dump.3 # No + ldsl (%esi),%esi # Load pointer + jmp dump.4 # Join common code +dump.3: lodsl # Set offset + xchgl %eax,%edx # Save + lodsl # Get segment + shll $0x4,%eax # * 0x10 + addl %edx,%eax # + offset + xchgl %eax,%esi # Set pointer +dump.4: movb $0x10,%cl # Bytes to dump +dump.5: lodsb # Get byte and + call hex8 # dump it + decb %cl # Keep count + jz dump.7 # If done + movb $'-',%al # Separator + cmpb $0x8,%cl # Half way? + je dump.6 # Yes + movb $' ',%al # Use space +dump.6: stosb # Save separator + jmp dump.5 # Continue +dump.7: popl %ds # Restore +dump.8: popl %esi # Restore + movb $0xa,%al # Line feed + testb $DMP_EOL,%ch # End of line? + jnz dump.9 # Yes + movb $' ',%al # Use spaces + stosb # Save one +dump.9: jmp dump.0 # Continue +dump.10: stosb # Terminate string + ret # To caller +# +# Convert EAX, AX, or AL to hex, saving the result to [EDI]. +# +hex32: pushl %eax # Save + shrl $0x10,%eax # Do upper + call hex16 # 16 + popl %eax # Restore +hex16: call hex16.1 # Do upper 8 +hex16.1: xchgb %ah,%al # Save/restore +hex8: pushl %eax # Save + shrb $0x4,%al # Do upper + call hex8.1 # 4 + popl %eax # Restore +hex8.1: andb $0xf,%al # Get lower 4 + cmpb $0xa,%al # Convert + sbbb $0x69,%al # to hex + das # digit + orb $0x20,%al # To lower case + stosb # Save char + ret # (Recursive) +# +# Output zero-terminated string [ESI] to the console. +# +putstr.0: call putchr # Output char +putstr: lodsb # Load char + testb %al,%al # End of string? + jnz putstr.0 # No + ret # To caller +# +# Output character AL to the console. +# +putchr: pusha # Save + xorl %ecx,%ecx # Zero for loops + movb $SCR_MAT,%ah # Mode/attribute + movl $BDA_POS,%ebx # BDA pointer + movw (%ebx),%dx # Cursor position + movl $0xb8000,%edi # Regen buffer (color) + cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode? + jne putchr.1 # No + xorw %di,%di # Regen buffer (mono) +putchr.1: cmpb $0xa,%al # New line? + je putchr.2 # Yes + xchgl %eax,%ecx # Save char + movb $SCR_COL,%al # Columns per row + mulb %dh # * row position + addb %dl,%al # + column + adcb $0x0,%ah # position + shll %eax # * 2 + xchgl %eax,%ecx # Swap char, offset + movw %ax,(%edi,%ecx,1) # Write attr:char + incl %edx # Bump cursor + cmpb $SCR_COL,%dl # Beyond row? + jb putchr.3 # No +putchr.2: xorb %dl,%dl # Zero column + incb %dh # Bump row +putchr.3: cmpb $SCR_ROW,%dh # Beyond screen? + jb putchr.4 # No + leal 2*SCR_COL(%edi),%esi # New top line + movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move + rep # Scroll + movsl # screen + movb $' ',%al # Space + movb $SCR_COL,%cl # Columns to clear + rep # Clear + stosw # line + movb $SCR_ROW-1,%dh # Bottom line +putchr.4: movw %dx,(%ebx) # Update position + popa # Restore + ret # To caller + + .p2align 4 +# +# Global descriptor table. +# +gdt: .word 0x0,0x0,0x0,0x0 # Null entry + .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE + .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA + .word 0xffff,0x0,0x9a00,0x0 # SEL_RCODE + .word 0xffff,0x0,0x9200,0x0 # SEL_RDATA + .word 0xffff,MEM_USR,0xfa00,0xcf# SEL_UCODE + .word 0xffff,MEM_USR,0xf200,0xcf# SEL_UDATA + .word _TSSLM,MEM_TSS,0x8900,0x0 # SEL_TSS +gdt.1: +# +# Pseudo-descriptors. +# +gdtdesc: .word gdt.1-gdt-1,gdt,0x0 # GDT +idtdesc: .word _IDTLM,MEM_IDT,0x0 # IDT +ivtdesc: .word 0x400-0x0-1,0x0,0x0 # IVT +# +# IDT construction control string. +# +idtctl: .byte 0x10, 0x8e # Int 0x0-0xf + .word 0x7dfb,intx00 # (exceptions) + .byte 0x10, 0x8e # Int 0x10 + .word 0x1, intx10 # (exception) + .byte 0x10, 0x8e # Int 0x20-0x2f + .word 0xffff,intx20 # (hardware) + .byte 0x1, 0xee # int 0x30 + .word 0x1, intx30 # (system call) + .byte 0x2, 0xee # Int 0x31-0x32 + .word 0x1, intx31 # (V86, null) + .byte 0x0 # End of string +# +# Dump format string. +# +dmpfmt: .byte '\n' # "\n" + .ascii "int" # "int=" + .byte 0x80|DMP_X32, 0x40 # "00000000 " + .ascii "err" # "err=" + .byte 0x80|DMP_X32, 0x44 # "00000000 " + .ascii "efl" # "efl=" + .byte 0x80|DMP_X32, 0x50 # "00000000 " + .ascii "eip" # "eip=" + .byte 0x80|DMP_X32|DMP_EOL,0x48 # "00000000\n" + .ascii "eax" # "eax=" + .byte 0x80|DMP_X32, 0x34 # "00000000 " + .ascii "ebx" # "ebx=" + .byte 0x80|DMP_X32, 0x28 # "00000000 " + .ascii "ecx" # "ecx=" + .byte 0x80|DMP_X32, 0x30 # "00000000 " + .ascii "edx" # "edx=" + .byte 0x80|DMP_X32|DMP_EOL,0x2c # "00000000\n" + .ascii "esi" # "esi=" + .byte 0x80|DMP_X32, 0x1c # "00000000 " + .ascii "edi" # "edi=" + .byte 0x80|DMP_X32, 0x18 # "00000000 " + .ascii "ebp" # "ebp=" + .byte 0x80|DMP_X32, 0x20 # "00000000 " + .ascii "esp" # "esp=" + .byte 0x80|DMP_X32|DMP_EOL,0x0 # "00000000\n" + .ascii "cs" # "cs=" + .byte 0x80|DMP_X16, 0x4c # "0000 " + .ascii "ds" # "ds=" + .byte 0x80|DMP_X16, 0xc # "0000 " + .ascii "es" # "es=" + .byte 0x80|DMP_X16, 0x8 # "0000 " + .ascii " " # " " + .ascii "fs" # "fs=" + .byte 0x80|DMP_X16, 0x10 # "0000 " + .ascii "gs" # "gs=" + .byte 0x80|DMP_X16, 0x14 # "0000 " + .ascii "ss" # "ss=" + .byte 0x80|DMP_X16|DMP_EOL,0x4 # "0000\n" + .ascii "cs:eip" # "cs:eip=" + .byte 0x80|DMP_MEM|DMP_EOL,0x48 # "00 00 ... 00 00\n" + .ascii "ss:esp" # "ss:esp=" + .byte 0x80|DMP_MEM|DMP_EOL,0x0 # "00 00 ... 00 00\n" + .asciz "BTX halted" # End +# +# End of BTX memory. +# + .p2align 4 +break: diff --git a/lockwasher/src/sys/boot/btx/btxldr/Makefile b/lockwasher/src/sys/boot/btx/btxldr/Makefile new file mode 100644 index 0000000..d421cd5 --- /dev/null +++ b/lockwasher/src/sys/boot/btx/btxldr/Makefile @@ -0,0 +1,28 @@ +# $FreeBSD: src/sys/boot/i386/btx/btxldr/Makefile,v 1.7.2.1 2000/04/15 03:09:41 ps Exp $ + +M4?= m4 +M4FLAGS+= -DLOADER_ADDRESS=${LOADER_ADDRESS} + +.if defined(BTXLDR_VERBOSE) +M4FLAGS+= -DBTXLDR_VERBOSE +.endif + +all: btxldr + +btxldr: btxldr.o +.if ${OBJFORMAT} == aout + ${LD} -nostdlib -N -s -T ${LOADER_ADDRESS} -o btxldr.out btxldr.o + dd if=btxldr.out of=${.TARGET} ibs=32 skip=1 +.else + ${LD} -N -e start -Ttext ${LOADER_ADDRESS} -o btxldr.out btxldr.o + objcopy -S -O binary btxldr.out ${.TARGET} +.endif + +btxldr.o: btxldr.s + (cd ${.CURDIR}; ${M4} ${M4FLAGS} btxldr.s ) | \ + ${AS} ${AFLAGS} -o ${.TARGET} + +CLEANFILES+= btxldr btxldr.out btxldr.o + +.include <${.CURDIR}/../../Makefile.inc> +.include diff --git a/lockwasher/src/sys/boot/btx/btxldr/btxldr.s b/lockwasher/src/sys/boot/btx/btxldr/btxldr.s new file mode 100644 index 0000000..3604c5d --- /dev/null +++ b/lockwasher/src/sys/boot/btx/btxldr/btxldr.s @@ -0,0 +1,396 @@ +# +# Copyright (c) 1998 Robert Nordier +# All rights reserved. +# +# Redistribution and use in source and binary forms are freely +# permitted provided that the above copyright notice and this +# paragraph and the following disclaimer are duplicated in all +# such forms. +# +# This software is provided "AS IS" and without any express or +# implied warranties, including, without limitation, the implied +# warranties of merchantability and fitness for a particular +# purpose. +# + +# $FreeBSD: src/sys/boot/i386/btx/btxldr/btxldr.s,v 1.8.2.2 2000/07/06 23:04:29 obrien Exp $ + +# +# Prototype BTX loader program, written in a couple of hours. The +# real thing should probably be more flexible, and in C. +# + +# +# Memory locations. +# + .set MEM_STUB,0x600 # Real mode stub + .set MEM_ESP,0x1000 # New stack pointer + .set MEM_TBL,0x5000 # BTX page tables + .set MEM_ENTRY,0x9010 # BTX entry point + .set MEM_DATA,start+0x1000 # Data segment +# +# Segment selectors. +# + .set SEL_SCODE,0x8 # 4GB code + .set SEL_SDATA,0x10 # 4GB data + .set SEL_RCODE,0x18 # 64K code + .set SEL_RDATA,0x20 # 64K data +# +# Paging constants. +# + .set PAG_SIZ,0x1000 # Page size + .set PAG_ENT,0x4 # Page entry size +# +# Screen constants. +# + .set SCR_MAT,0x7 # Mode/attribute + .set SCR_COL,0x50 # Columns per row + .set SCR_ROW,0x19 # Rows per screen +# +# BIOS Data Area locations. +# + .set BDA_MEM,0x413 # Free memory + .set BDA_SCR,0x449 # Video mode + .set BDA_POS,0x450 # Cursor position +# +# Required by aout gas inadequacy. +# + .set SIZ_STUB,0x1a # Size of stub +# +# We expect to be loaded by boot2 at the origin defined in ./Makefile. +# + .globl start +# +# BTX program loader for ELF clients. +# +start: cld # String ops inc + movl $m_logo,%esi # Identify + call putstr # ourselves + movzwl BDA_MEM,%eax # Get base memory + shll $0xa,%eax # in bytes + movl %eax,%ebp # Base of user stack +ifdef(`BTXLDR_VERBOSE',` + movl $m_mem,%esi # Display + call hexout # amount of + call putstr # base memory +') + lgdt gdtdesc # Load new GDT +# +# Relocate caller's arguments. +# +ifdef('BTXLDR_VERBOSE',` + movl $m_esp,%esi # Display + movl %esp,%eax # caller + call hexout # stack + call putstr # pointer + movl $m_args,%esi # Format string + leal 0x4(%esp,1),%ebx # First argument + movl $0x6,%ecx # Count +start.1: movl (%ebx),%eax # Get argument and + addl $0x4,%ebx # bump pointer + call hexout # Display it + loop start.1 # Till done + call putstr # End message +') + movl $0x48,%ecx # Allocate space + subl %ecx,%ebp # for bootinfo + movl 0x18(%esp,1),%esi # Source: bootinfo + cmpl $0x0, %esi # If the bootinfo pointer + je start_null_bi # is null, don't copy it + movl %ebp,%edi # Destination + rep # Copy + movsb # it + movl %ebp,0x18(%esp,1) # Update pointer +ifdef(`BTXLDR_VERBOSE',` + movl $m_rel_bi,%esi # Display + movl %ebp,%eax # bootinfo + call hexout # relocation + call putstr # message +') +start_null_bi: movl $0x18,%ecx # Allocate space + subl %ecx,%ebp # for arguments + leal 0x4(%esp,1),%esi # Source + movl %ebp,%edi # Destination + rep # Copy + movsb # them +ifdef(`BTXLDR_VERBOSE',` + movl $m_rel_args,%esi # Display + movl %ebp,%eax # argument + call hexout # relocation + call putstr # message +') +# +# Set up BTX kernel. +# + movl $MEM_ESP,%esp # Set up new stack + movl $MEM_DATA,%ebx # Data segment + movl $m_vers,%esi # Display BTX + call putstr # version message + movb 0x5(%ebx),%al # Get major version + addb $'0',%al # Display + call putchr # it + movb $'.',%al # And a + call putchr # dot + movb 0x6(%ebx),%al # Get minor + xorb %ah,%ah # version + movb $0xa,%dl # Divide + divb %dl,%al # by 10 + addb $'0',%al # Display + call putchr # tens + movb %ah,%al # Get units + addb $'0',%al # Display + call putchr # units + call putstr # End message + movl %ebx,%esi # BTX image + movzwl 0x8(%ebx),%edi # Compute + orl $PAG_SIZ/PAG_ENT-1,%edi # the + incl %edi # BTX + shll $0x2,%edi # load + addl $MEM_TBL,%edi # address + pushl %edi # Save load address + movzwl 0xa(%ebx),%ecx # Image size +ifdef(`BTXLDR_VERBOSE',` + pushl %ecx # Save image size +') + rep # Relocate + movsb # BTX + movl %esi,%ebx # Keep place +ifdef(`BTXLDR_VERBOSE',` + movl $m_rel_btx,%esi # Restore + popl %eax # parameters + call hexout # and +') + popl %ebp # display +ifdef(`BTXLDR_VERBOSE',` + movl %ebp,%eax # the + call hexout # relocation + call putstr # message +') + addl $PAG_SIZ,%ebp # Display +ifdef(`BTXLDR_VERBOSE',` + movl $m_base,%esi # the + movl %ebp,%eax # user + call hexout # base + call putstr # address +') +# +# Set up ELF-format client program. +# + cmpl $0x464c457f,(%ebx) # ELF magic number? + je start.3 # Yes + movl $e_fmt,%esi # Display error + call putstr # message +start.2: jmp start.2 # Hang +start.3: +ifdef(`BTXLDR_VERBOSE',` + movl $m_elf,%esi # Display ELF + call putstr # message + movl $m_segs,%esi # Format string +') + movl $0x2,%edi # Segment count + movl 0x1c(%ebx),%edx # Get e_phoff + addl %ebx,%edx # To pointer + movzwl 0x2c(%ebx),%ecx # Get e_phnum +start.4: cmpl $0x1,(%edx) # Is p_type PT_LOAD? + jne start.6 # No +ifdef(`BTXLDR_VERBOSE',` + movl 0x4(%edx),%eax # Display + call hexout # p_offset + movl 0x8(%edx),%eax # Display + call hexout # p_vaddr + movl 0x10(%edx),%eax # Display + call hexout # p_filesz + movl 0x14(%edx),%eax # Display + call hexout # p_memsz + call putstr # End message +') + pushl %esi # Save + pushl %edi # working + pushl %ecx # registers + movl 0x4(%edx),%esi # Get p_offset + addl %ebx,%esi # as pointer + movl 0x8(%edx),%edi # Get p_vaddr + addl %ebp,%edi # as pointer + movl 0x10(%edx),%ecx # Get p_filesz + rep # Set up + movsb # segment + movl 0x14(%edx),%ecx # Any bytes + subl 0x10(%edx),%ecx # to zero? + jz start.5 # No + xorb %al,%al # Then + rep # zero + stosb # them +start.5: popl %ecx # Restore + popl %edi # working + popl %esi # registers + decl %edi # Segments to do + je start.7 # If none +start.6: addl $0x20,%edx # To next entry + loop start.4 # Till done +start.7: +ifdef(`BTXLDR_VERBOSE',` + movl $m_done,%esi # Display done + call putstr # message +') + movl $start.8,%esi # Real mode stub + movl $MEM_STUB,%edi # Destination + movl $start.9-start.8,%ecx # Size + rep # Relocate + movsb # it + ljmp $SEL_RCODE,$MEM_STUB # To 16-bit code + .code16 +start.8: xorw %ax,%ax # Data + movb $SEL_RDATA,%al # selector + movw %ax,%ss # Reload SS + movw %ax,%ds # Reset + movw %ax,%es # other + movw %ax,%fs # segment + movw %ax,%gs # limits + movl %cr0,%eax # Switch to + decw %ax # real + movl %eax,%cr0 # mode + ljmp $0,$MEM_ENTRY # Jump to BTX entry point +start.9: + .code32 +# +# Output message [ESI] followed by EAX in hex. +# +hexout: pushl %eax # Save + call putstr # Display message + popl %eax # Restore + pushl %esi # Save + pushl %edi # caller's + movl $buf,%edi # Buffer + pushl %edi # Save + call hex32 # To hex + xorb %al,%al # Terminate + stosb # string + popl %esi # Restore +hexout.1: lodsb # Get a char + cmpb $'0',%al # Leading zero? + je hexout.1 # Yes + testb %al,%al # End of string? + jne hexout.2 # No + decl %esi # Undo +hexout.2: decl %esi # Adjust for inc + call putstr # Display hex + popl %edi # Restore + popl %esi # caller's + ret # To caller +# +# Output zero-terminated string [ESI] to the console. +# +putstr.0: call putchr # Output char +putstr: lodsb # Load char + testb %al,%al # End of string? + jne putstr.0 # No + ret # To caller +# +# Output character AL to the console. +# +putchr: pusha # Save + xorl %ecx,%ecx # Zero for loops + movb $SCR_MAT,%ah # Mode/attribute + movl $BDA_POS,%ebx # BDA pointer + movw (%ebx),%dx # Cursor position + movl $0xb8000,%edi # Regen buffer (color) + cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode? + jne putchr.1 # No + xorw %di,%di # Regen buffer (mono) +putchr.1: cmpb $0xa,%al # New line? + je putchr.2 # Yes + xchgl %eax,%ecx # Save char + movb $SCR_COL,%al # Columns per row + mulb %dh # * row position + addb %dl,%al # + column + adcb $0x0,%ah # position + shll %eax # * 2 + xchgl %eax,%ecx # Swap char, offset + movw %ax,(%edi,%ecx,1) # Write attr:char + incl %edx # Bump cursor + cmpb $SCR_COL,%dl # Beyond row? + jb putchr.3 # No +putchr.2: xorb %dl,%dl # Zero column + incb %dh # Bump row +putchr.3: cmpb $SCR_ROW,%dh # Beyond screen? + jb putchr.4 # No + leal 2*SCR_COL(%edi),%esi # New top line + movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move + rep # Scroll + movsl # screen + movb $' ',%al # Space + movb $SCR_COL,%cl # Columns to clear + rep # Clear + stosw # line + movb $SCR_ROW-1,%dh # Bottom line +putchr.4: movw %dx,(%ebx) # Update position + popa # Restore + ret # To caller +# +# Convert EAX, AX, or AL to hex, saving the result to [EDI]. +# +hex32: pushl %eax # Save + shrl $0x10,%eax # Do upper + call hex16 # 16 + popl %eax # Restore +hex16: call hex16.1 # Do upper 8 +hex16.1: xchgb %ah,%al # Save/restore +hex8: pushl %eax # Save + shrb $0x4,%al # Do upper + call hex8.1 # 4 + popl %eax # Restore +hex8.1: andb $0xf,%al # Get lower 4 + cmpb $0xa,%al # Convert + sbbb $0x69,%al # to hex + das # digit + orb $0x20,%al # To lower case + stosb # Save char + ret # (Recursive) + + .data + .p2align 4 +# +# Global descriptor table. +# +gdt: .word 0x0,0x0,0x0,0x0 # Null entry + .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE + .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA + .word 0xffff,0x0,0x9a00,0x0 # SEL_RCODE + .word 0xffff,0x0,0x9200,0x0 # SEL_RDATA +gdt.1: +gdtdesc: .word gdt.1-gdt-1 # Limit + .long gdt # Base +# +# Messages. +# +m_logo: .asciz " \nBTX loader 1.00 " +m_vers: .asciz "BTX version is \0\n" +e_fmt: .asciz "Error: Client format not supported\n" +ifdef(`BTXLDR_VERBOSE',` +m_mem: .asciz "Starting in protected mode (base mem=\0)\n" +m_esp: .asciz "Arguments passed (esp=\0):\n" +m_args: .asciz"\n" +m_rel_bi: .asciz "Relocated bootinfo (size=48) to \0\n" +m_rel_args: .asciz "Relocated arguments (size=18) to \0\n" +m_rel_btx: .asciz "Relocated kernel (size=\0) to \0\n" +m_base: .asciz "Client base address is \0\n" +m_elf: .asciz "Client format is ELF\n" +m_segs: .asciz "text segment: offset=" + .asciz " vaddr=" + .asciz " filesz=" + .asciz " memsz=\0\n" + .asciz "data segment: offset=" + .asciz " vaddr=" + .asciz " filesz=" + .asciz " memsz=\0\n" +m_done: .asciz "Loading complete\n" +') +# +# Uninitialized data area. +# +buf: # Scratch buffer diff --git a/lockwasher/src/sys/boot/btx/lib/Makefile b/lockwasher/src/sys/boot/btx/lib/Makefile new file mode 100644 index 0000000..c993e57 --- /dev/null +++ b/lockwasher/src/sys/boot/btx/lib/Makefile @@ -0,0 +1,16 @@ +# $FreeBSD: src/sys/boot/i386/btx/lib/Makefile,v 1.3.2.1 2002/07/19 18:46:28 ru Exp $ + +OBJS= btxcsu.o btxsys.o btxv86.o +AFLAGS+= -elf +LDFLAGS+= -elf +CLEANFILES+= crt0.o ${OBJS} + +all: crt0.o + +crt0.o: ${OBJS} + ${LD} ${LDFLAGS} -i -o ${.TARGET} ${OBJS} + +.include + +.s.o: + ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} diff --git a/lockwasher/src/sys/boot/btx/lib/btxcsu.s b/lockwasher/src/sys/boot/btx/lib/btxcsu.s new file mode 100644 index 0000000..119fda6 --- /dev/null +++ b/lockwasher/src/sys/boot/btx/lib/btxcsu.s @@ -0,0 +1,43 @@ +# +# Copyright (c) 1998 Robert Nordier +# All rights reserved. +# +# Redistribution and use in source and binary forms are freely +# permitted provided that the above copyright notice and this +# paragraph and the following disclaimer are duplicated in all +# such forms. +# +# This software is provided "AS IS" and without any express or +# implied warranties, including, without limitation, the implied +# warranties of merchantability and fitness for a particular +# purpose. +# + +# $FreeBSD: src/sys/boot/i386/btx/lib/btxcsu.s,v 1.3 1999/08/28 00:40:07 peter Exp $ + +# +# BTX C startup code (ELF). +# + +# +# Globals. +# + .global _start +# +# Constants. +# + .set ARGADJ,0xfa0 # Argument adjustment +# +# Client entry point. +# +_start: movl %eax,__base # Set base address + movl %esp,%eax # Set + addl $ARGADJ,%eax # argument + movl %eax,__args # pointer + call main # Invoke client main() + call exit # Invoke client exit() +# +# Data. +# + .comm __base,4 # Client base address + .comm __args,4 # Client arguments diff --git a/lockwasher/src/sys/boot/btx/lib/btxsys.s b/lockwasher/src/sys/boot/btx/lib/btxsys.s new file mode 100644 index 0000000..6bca740 --- /dev/null +++ b/lockwasher/src/sys/boot/btx/lib/btxsys.s @@ -0,0 +1,40 @@ +# +# Copyright (c) 1998 Robert Nordier +# All rights reserved. +# +# Redistribution and use in source and binary forms are freely +# permitted provided that the above copyright notice and this +# paragraph and the following disclaimer are duplicated in all +# such forms. +# +# This software is provided "AS IS" and without any express or +# implied warranties, including, without limitation, the implied +# warranties of merchantability and fitness for a particular +# purpose. +# + +# $FreeBSD: src/sys/boot/i386/btx/lib/btxsys.s,v 1.2 1999/08/28 00:40:07 peter Exp $ + +# +# BTX system calls. +# + +# +# Globals. +# + .global __exit + .global __exec +# +# Constants. +# + .set INT_SYS,0x30 # Interrupt number +# +# System call: exit +# +__exit: xorl %eax,%eax # BTX system + int $INT_SYS # call 0x0 +# +# System call: exec +# +__exec: movl $0x1,%eax # BTX system + int $INT_SYS # call 0x1 diff --git a/lockwasher/src/sys/boot/btx/lib/btxv86.h b/lockwasher/src/sys/boot/btx/lib/btxv86.h new file mode 100644 index 0000000..1ef0712 --- /dev/null +++ b/lockwasher/src/sys/boot/btx/lib/btxv86.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + */ + +/* + * $FreeBSD: src/sys/boot/i386/btx/lib/btxv86.h,v 1.5 1999/08/28 00:40:08 peter Exp $ + */ + +#ifndef _BTXV86_H_ +#define _BTXV86_H_ + +#include + +#define V86_ADDR 0x10000 /* Segment:offset address */ +#define V86_CALLF 0x20000 /* Emulate far call */ +#define V86_FLAGS 0x40000 /* Return flags */ + +struct __v86 { + uint32_t ctl; /* Control flags */ + uint32_t addr; /* Interrupt number or address */ + uint32_t es; /* V86 ES register */ + uint32_t ds; /* V86 DS register */ + uint32_t fs; /* V86 FS register */ + uint32_t gs; /* V86 GS register */ + uint32_t eax; /* V86 EAX register */ + uint32_t ecx; /* V86 ECX register */ + uint32_t edx; /* V86 EDX register */ + uint32_t ebx; /* V86 EBX register */ + uint32_t efl; /* V86 eflags register */ + uint32_t ebp; /* V86 EBP register */ + uint32_t esi; /* V86 ESI register */ + uint32_t edi; /* V86 EDI register */ +}; + +extern struct __v86 __v86; /* V86 interface structure */ +void __v86int(void); + +#define v86 __v86 +#define v86int __v86int + +extern u_int32_t __base; +extern u_int32_t __args; + +#define PTOV(pa) ((caddr_t)(pa) - __base) +#define VTOP(va) ((vm_offset_t)(va) + __base) +#define VTOPSEG(va) (u_int16_t)(VTOP((caddr_t)va) >> 4) +#define VTOPOFF(va) (u_int16_t)(VTOP((caddr_t)va) & 0xf) + +void __exit(int) __attribute__((__noreturn__)); +void __exec(caddr_t, ...); + +#endif /* !_BTXV86_H_ */ diff --git a/lockwasher/src/sys/boot/btx/lib/btxv86.s b/lockwasher/src/sys/boot/btx/lib/btxv86.s new file mode 100644 index 0000000..6d6af19 --- /dev/null +++ b/lockwasher/src/sys/boot/btx/lib/btxv86.s @@ -0,0 +1,85 @@ +# +# Copyright (c) 1998 Robert Nordier +# All rights reserved. +# +# Redistribution and use in source and binary forms are freely +# permitted provided that the above copyright notice and this +# paragraph and the following disclaimer are duplicated in all +# such forms. +# +# This software is provided "AS IS" and without any express or +# implied warranties, including, without limitation, the implied +# warranties of merchantability and fitness for a particular +# purpose. +# + +# $FreeBSD: src/sys/boot/i386/btx/lib/btxv86.s,v 1.3 1999/08/28 00:40:08 peter Exp $ + +# +# BTX V86 interface. +# + +# +# Globals. +# + .global __v86int +# +# Fields in V86 interface structure. +# + .set V86_CTL,0x0 # Control flags + .set V86_ADDR,0x4 # Int number/address + .set V86_ES,0x8 # V86 ES + .set V86_DS,0xc # V86 DS + .set V86_FS,0x10 # V86 FS + .set V86_GS,0x14 # V86 GS + .set V86_EAX,0x18 # V86 EAX + .set V86_ECX,0x1c # V86 ECX + .set V86_EDX,0x20 # V86 EDX + .set V86_EBX,0x24 # V86 EBX + .set V86_EFL,0x28 # V86 eflags + .set V86_EBP,0x2c # V86 EBP + .set V86_ESI,0x30 # V86 ESI + .set V86_EDI,0x34 # V86 EDI +# +# Other constants. +# + .set INT_V86,0x31 # Interrupt number + .set SIZ_V86,0x38 # Size of V86 structure +# +# V86 interface function. +# +__v86int: popl __v86ret # Save return address + pushl $__v86 # Push pointer + call __v86_swap # Load V86 registers + int $INT_V86 # To BTX + call __v86_swap # Load user registers + addl $0x4,%esp # Discard pointer + pushl __v86ret # Restore return address + ret # To user +# +# Swap V86 and user registers. +# +__v86_swap: xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP + xchgl %eax,V86_EAX(%ebp) # Swap EAX + xchgl %ecx,V86_ECX(%ebp) # Swap ECX + xchgl %edx,V86_EDX(%ebp) # Swap EDX + xchgl %ebx,V86_EBX(%ebp) # Swap EBX + pushl %eax # Save + pushf # Put eflags + popl %eax # in EAX + xchgl %eax,V86_EFL(%ebp) # Swap + pushl %eax # Put EAX + popf # in eflags + movl 0x8(%esp,1),%eax # Load EBP + xchgl %eax,V86_EBP(%ebp) # Swap + movl %eax,0x8(%esp,1) # Save EBP + popl %eax # Restore + xchgl %esi,V86_ESI(%ebp) # Swap ESI + xchgl %edi,V86_EDI(%ebp) # Swap EDI + xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP + ret # To caller +# +# V86 interface structure. +# + .comm __v86,SIZ_V86 + .comm __v86ret,4 diff --git a/lockwasher/src/sys/compile/Makefile b/lockwasher/src/sys/compile/Makefile new file mode 100644 index 0000000..e0499c3 --- /dev/null +++ b/lockwasher/src/sys/compile/Makefile @@ -0,0 +1,45 @@ +# $Id: Makefile,v 1.10 2003/05/04 13:20:15 reddawg Exp $ +# Kernel Makefile (C) 2002 The UbixOS Project + +CFLAGS = -fno-builtin + +#Compiler +GCC = gcc +G++ = gcc + +#Linker +LD = ld + +#Kernel File Name +KERNEL = ubix.elf + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = null.o + +# Link the kernel statically with fixed text+data address @1M +$(KERNEL) : $(OBJS) + $(LD) -nobuiltin -o $@ $(OBJS) ../init/*.o ../kernel/*.o ../isa/*.o ../pci/*.o ../sys/*.o ../vmm/*.o ../ubixfs/*.o ../devfs/*.o ../lib/*.o ../sde/*.o ../graphics/*.o ../ld/*.o -Ttext 0x30000 + /usr/bin/strip $@ + +# Compile the source files +.cc.o: + $(G++) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< + +.cc.s: + $(G++) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< + +.c.o: + $(GCC) ${CFLAGS} -Wall -O -I../include -c -o $@ $< + +.c.s: + $(GCC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< + +.S.o: + $(GCC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(KERNEL) null.c diff --git a/lockwasher/src/sys/devfs/Makefile b/lockwasher/src/sys/devfs/Makefile new file mode 100644 index 0000000..777f242 --- /dev/null +++ b/lockwasher/src/sys/devfs/Makefile @@ -0,0 +1,36 @@ +# (C) 2002 The UbixOS Project +# $Id: Makefile,v 1.1 2003/04/27 12:37:25 reddawg Exp $ + +CFLAGS = -fno-builtin + +# Compiler +CC = gcc +CPP = g++ + + +# Linker +LINKER = ld + +# Remove +REMOVE = rm -fr + +# Objects +OBJS = devfs.o + +all: $(OBJS) + +# Compile Types +.cc.o: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.cc.s: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.c.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.c.s: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.S.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) diff --git a/lockwasher/src/sys/devfs/devfs.c b/lockwasher/src/sys/devfs/devfs.c new file mode 100644 index 0000000..bbc12cd --- /dev/null +++ b/lockwasher/src/sys/devfs/devfs.c @@ -0,0 +1,185 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: devfs.c,v 1.3 2003/05/04 13:20:15 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int sprintf(char *buf,const char *fmt, ...); //TEMP + +int enableDevFS() { + //Add DevFS i will + if (!addFs(1,initDevFS,readDevFS,writeDevFS,openFileDevFS,0x0,0x0,0x0,0x0)) { + sysErr(systemErr,"Unable To Enable DevFS"); + return(0); + } + //Return + mount(0x0,0x0,0x1,"devfs","rw"); // Mount Device File System + return(1); + } + +void initDevFS(struct mountPoints *mp) { + struct devFsInfo *fsInfo = 0x0; + mp->fsInfo = (struct devFsInfo *)kmalloc(sizeof(struct devFsInfo),-2); + + fsInfo = mp->fsInfo; + fsInfo->deviceList = 0x0; + + kprintf("DevFS Initialized\n"); + //Return + return; + } + +int openFileDevFS(char *file,fileDescriptor *fd) { + struct devFsInfo *fsInfo = fd->mp->fsInfo; + struct devFsDevices *tmpDev = 0x0; + kprintf("Opening DevFS File [0x%X]\n",fsInfo->deviceList); + for (tmpDev = fsInfo->deviceList;tmpDev != 0x0;tmpDev = tmpDev->next) { + kprintf("[%s][%s]\n",tmpDev->devName,file); + if (kstrcmp(tmpDev->devName,file) == 0x0) { + switch (fd->mode) { + case 0: + case 1: + kprintf("Opened Device: [%s]\n",tmpDev->devName); + (void *)fd->start = tmpDev; + break; + default: + kprintf("Invalid File Mode\n"); + return(0x0); + break; + } + return(0x1); + } + } + return(0x0); + } + +/************************************************************************ + +Function: int readDevFS(fileDescriptor *fd,char *data,long offset,long size) +Description: Read File Into Data +Notes: + +************************************************************************/ +int readDevFS(fileDescriptor *fd,char *data,long offset,long size) { + int i = 0x0,x = 0x0; + uInt32 sectors = 0x0; + uInt16 diff = 0x0; + struct driveDriver *drive = 0x0; + struct devFsDevices *tmpDev = (void *)fd->start; + + kprintf("[0x%X]\n",tmpDev->devMajor); + drive = findDrive(tmpDev->devMajor); + kprintf("[0x%X][0x%X]\n",drive,drive->driveInfoStruct); + + + kprintf("Reading From Device: [%s]\n",fd->fileName); + + sectors = ((size+511)/512); + diff = (offset - ((offset/512)*512)); + + for (i=0x0;iread(drive->driveInfoStruct,i + (offset/512),1,fd->buffer); + for (x=0x0;x<(size - (i*512));x++) { + if (diff > 0) { + data[x] = fd->buffer[x + diff]; + } + else { + data[x] = fd->buffer[x]; + } + } + diff = 0x0; + data += 512; + } + + return(size); + } + +/************************************************************************ + +Function: int writeDevFS(fileDescriptor *fd,char *data,long offset,long size) +Description: Write Data Into File +Notes: + +************************************************************************/ +int writeDevFS(fileDescriptor *fd,char *data,long offset,long size) { + int i = 0x0,x = 0x0; + struct driveDriver *drive = 0x0; + struct devFsDevices *tmpDev = (void *)fd->start; + + kprintf("[0x%X]\n",tmpDev->devMajor); + drive = findDrive(tmpDev->devMajor); + kprintf("[0x%X][0x%X]\n",drive,drive->driveInfoStruct); + + kprintf("Writing To Device: [%s]\n",fd->fileName); + for (i=0x0;i<((size+511)/512);i++) { + drive->read(drive->driveInfoStruct,i + (offset/512),1,fd->buffer); + for (x=0x0;((x < 512) && ((x + (i * 512)) < size));x++) { + fd->buffer[x] = data[x]; + } + drive->write(drive->driveInfoStruct,i + (offset/512),1,fd->buffer); + data += 512; + } + return(size); + } + + +int devFsMkNod(char *name,uInt8 type,uInt16 major,uInt16 minor) { + struct mountPoints *mp = 0x0; + struct devFsInfo *fsInfo = 0x0; + struct devFsDevices *tmpDev = 0x0; + + mp = findMount("devfs"); + + if (mp == 0x0) { + kprintf("Error\n"); + return(0x0); + } + + fsInfo = mp->fsInfo; + + tmpDev = (struct devFsDevices *)kmalloc(sizeof(struct devFsDevices),-2); + + tmpDev->devType = type; + tmpDev->devMajor = major; + tmpDev->devMinor = minor; + sprintf(tmpDev->devName,name); + kprintf("tmpDev->devName: [%s]\n",tmpDev->devName); + + tmpDev->next = fsInfo->deviceList; + tmpDev->prev = 0x0; + if (fsInfo->deviceList != 0x0) { + fsInfo->deviceList->prev = tmpDev; + } + + fsInfo->deviceList = tmpDev; + + return(0x1); + } \ No newline at end of file diff --git a/lockwasher/src/sys/graphics/Makefile b/lockwasher/src/sys/graphics/Makefile new file mode 100644 index 0000000..459eba0 --- /dev/null +++ b/lockwasher/src/sys/graphics/Makefile @@ -0,0 +1,43 @@ +# $Id: Makefile,v 1.6 2003/04/03 01:26:33 reddawg Exp $ +# Kernel Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = g++ + +#Linker +LD = ld + +#Binary File Name +BINARY = objgfx + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = objgfx30.o #objfont.o ogSprite.o ogBlit.o + +# Link the binary +$(BINARY) : $(OBJS) +# $(G++) -o $@ $(OBJS) + +# Compile the source files +.cpp.o: + $(G++) -Wall -DNOBOOL -fno-rtti -fno-exceptions -g -c -I../include -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< + +.c.o: + $(GCC) -Wall -O -I../include -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(BINARY) *.core diff --git a/lockwasher/src/sys/graphics/objgfx30.cpp b/lockwasher/src/sys/graphics/objgfx30.cpp new file mode 100644 index 0000000..fda1d83 --- /dev/null +++ b/lockwasher/src/sys/graphics/objgfx30.cpp @@ -0,0 +1,2858 @@ +/******************************************************* +$Id: objgfx30.cpp,v 1.15 2003/04/16 06:07:22 flameshadow Exp $ +*******************************************************/ + +extern "C" { + #include + #include + #include + #include + #include + } + +#include +#include + +using namespace std; +// #include "../ubixos-home/src/sys/include/ubixos/types.h" + +#define ROUND(f) (int)((f) + ((f) > 0 ? 0.5 : -0.5)) + +struct ogHLine { + int32 xStart; + int32 xEnd; +}; + +struct ogHLineList { + int32 length; + int32 yStart; + int32 * xLeft; + int32 * xRight; +}; + +struct ogPointListHeader { + int32 length; + ogPoint * PointPtr; +}; + +struct ogEdgeState { + ogEdgeState* nextEdge; + int32 x; + int32 startY; + int32 wholePixelXMove; + int32 xDirection; + int32 errorTerm; + int32 errorTermAdjUp; + int32 errorTermAdjDown; + int32 count; +}; + +class ogEdgeTable { + public: + ogEdgeState * globalEdges; + ogEdgeState * activeEdges; + ogEdgeTable(void) { globalEdges = activeEdges = NULL; return; } + void advanceAET(void); + void buildGET(uInt32 numPoints, ogPoint * polyPoints); + void moveXSortedToAET(int32 yToMove); + void scanOutAET(ogSurface & destObject, int32 yToScan, uInt32 colour); + void xSortAET(void); + ~ogEdgeTable(void); +}; // ogEdgeState + +void +ogEdgeTable::advanceAET(void) { + ogEdgeState * currentEdge; + ogEdgeState ** currentEdgePtr; + + currentEdgePtr = &activeEdges; + currentEdge = activeEdges; + while (currentEdge!=NULL) { + currentEdge->count--; + if (currentEdge->count==0) { + // this edge is finished, so remove it from the AET + *currentEdgePtr = currentEdge->nextEdge; + } else { + // advance the edge's x coord by minimum move + currentEdge->x += currentEdge->wholePixelXMove; + // determine whether it's time for X to advance one extra + currentEdge->errorTerm += currentEdge->errorTermAdjUp; + if (currentEdge->errorTerm>0) { + currentEdge->x += currentEdge->xDirection; + currentEdge->errorTerm -= currentEdge->errorTermAdjDown; + } // if + currentEdgePtr = ¤tEdge->nextEdge; + } // else + currentEdge = *currentEdgePtr; + } // while + return; +} // ogEdgeTable::advanceAET + +void +ogEdgeTable::buildGET(uInt32 numPoints, ogPoint * polyPoints) { + int32 i, x1, y1, x2, y2, deltaX, deltaY, width, tmp; + ogEdgeState * newEdgePtr; + ogEdgeState * followingEdge; + ogEdgeState ** followingEdgeLink; + + /* Creates a GET in the buffer pointed to by NextFreeEdgeStruc from + * the vertex list. Edge endpoints are flipped, if necessary, to + * guarantee all edges go top to bottom. The GET is sorted primarily + * by ascending Y start coordinate, and secondarily by ascending X + * start coordinate within edges with common Y coordinates } + */ + + // Scan through the vertex list and put all non-0-height edges into + // the GET, sorted by increasing Y start coordinate} + for (i = 0; i<(int32)numPoints; i++) { + // calculate the edge height and width + x1 = polyPoints[i].x; + y1 = polyPoints[i].y; + if (i==0) { + // wrap back around to the end of the list + x2 = polyPoints[numPoints-1].x; + y2 = polyPoints[numPoints-1].y; + } else { + x2 = polyPoints[i-1].x; + y2 = polyPoints[i-1].y; + } // else i!=0 + if (y1>y2) { + tmp = x1; + x1 = x2; + x2 = tmp; + tmp = y1; + y1 = y2; + y2 = tmp; + } // if y1>y2 + // skip if this can't ever be an active edge (has 0 height) + deltaY = y2-y1; + if (deltaY!=0) { + newEdgePtr = new ogEdgeState; + newEdgePtr->xDirection = ((deltaX = x2-x1) > 0) ? 1 : -1; + width = abs(deltaX); + newEdgePtr->x = x1; + newEdgePtr->startY = y1; + newEdgePtr->count = newEdgePtr->errorTermAdjDown = deltaY; + newEdgePtr->errorTerm = (deltaX >= 0) ? 0 : 1-deltaY; + if (deltaY>=width) { + newEdgePtr->wholePixelXMove = 0; + newEdgePtr->errorTermAdjUp = width; + } else { + newEdgePtr->wholePixelXMove = (width / deltaY) * newEdgePtr->xDirection; + newEdgePtr->errorTermAdjUp = width % deltaY; + } // else + followingEdgeLink = &globalEdges; + while (true) { + followingEdge = *followingEdgeLink; + if ((followingEdge == NULL) || + (followingEdge->startY >= y1) || + ((followingEdge->startY == y1) && + (followingEdge->x>=x1))) { + newEdgePtr->nextEdge = followingEdge; + *followingEdgeLink = newEdgePtr; + break; + } // if + followingEdgeLink = &followingEdge->nextEdge; + } // while + } // if deltaY!=0) + } // for + return; +} // ogEdgeTable::buildGET + +void +ogEdgeTable::moveXSortedToAET(int32 yToMove) { + ogEdgeState * AETEdge; + ogEdgeState * tempEdge; + ogEdgeState ** AETEdgePtr; + int32 currentX; + + /* The GET is Y sorted. Any edges that start at the desired Y + * coordinate will be first in the GET, so we'll move edges from + * the GET to AET until the first edge left in the GET is no + * longer at the desired Y coordinate. Also, the GET is X sorted + * within each Y cordinate, so each successive edge we add to the + * AET is guaranteed to belong later in the AET than the one just + * added. + */ + AETEdgePtr = &activeEdges; + while ((globalEdges!=NULL) && (globalEdges->startY==yToMove)) { + currentX = globalEdges->x; + // link the new edge into the AET so that the AET is still + // sorted by X coordinate + while (true) { + AETEdge = *AETEdgePtr; + if ((AETEdge==NULL) || (AETEdge->x>=currentX)) { + tempEdge = globalEdges->nextEdge; + *AETEdgePtr = globalEdges; + globalEdges->nextEdge = AETEdge; + AETEdgePtr = &globalEdges->nextEdge; + globalEdges = tempEdge; + break; + } else AETEdgePtr = &AETEdge->nextEdge; + } // while true + } // while globalEdges!=NULL and globalEdges->startY==yToMove + return; +} // ogEdgeTable::moveXSortedToAET + +void +ogEdgeTable::scanOutAET(ogSurface & destObject, int32 yToScan, uInt32 colour) { + ogEdgeState * currentEdge; + int32 leftX; + + /* Scan through the AET, drawing line segments as each pair of edge + * crossings is encountered. The nearest pixel on or to the right + * of the left edges is drawn, and the nearest pixel to the left + * of but not on right edges is drawn + */ + currentEdge = activeEdges; + while (currentEdge!=NULL) { + leftX = currentEdge->x; + currentEdge = currentEdge->nextEdge; + if (currentEdge!=NULL) { + if (leftX!=currentEdge->x) + destObject.ogHLine(leftX, currentEdge->x-1, yToScan, colour); + currentEdge = currentEdge->nextEdge; + } // if currentEdge != NULL + } // while + return; +} // ogEdgeTable::scanOutAET + +void +ogEdgeTable::xSortAET(void) { + ogEdgeState * currentEdge; + ogEdgeState * tempEdge; + ogEdgeState ** currentEdgePtr; + bool swapOccurred; + if (activeEdges==NULL) return; + do { + swapOccurred = false; + currentEdgePtr = &activeEdges; + currentEdge = activeEdges; + while (currentEdge->nextEdge!=NULL) { + if (currentEdge->x > currentEdge->nextEdge->x) { + // the second edge has a lower x than the first + // swap them in the AET + tempEdge = currentEdge->nextEdge->nextEdge; + *currentEdgePtr = currentEdge->nextEdge; + currentEdge->nextEdge->nextEdge = currentEdge; + currentEdge->nextEdge = tempEdge; + swapOccurred = true; + } // if + currentEdgePtr = &((*currentEdgePtr)->nextEdge); + currentEdge = *currentEdgePtr; + } // while + } while (swapOccurred); + return; +} // ogEdgeTable::xSortAET + +ogEdgeTable::~ogEdgeTable(void) { + ogEdgeState * edge; + ogEdgeState * tmpEdge; + tmpEdge = globalEdges; + // first walk the global edges and delete any non-null nodes + while (tmpEdge!=NULL) { + edge = tmpEdge; + tmpEdge = edge->nextEdge; + delete edge; + } // while + tmpEdge = activeEdges; + // next walk the activeEdges and delete any non-null nodes. Note that this should + // always be null + while (tmpEdge!=NULL) { + edge = tmpEdge; + tmpEdge = edge->nextEdge; + delete edge; + } // while + return; +} // ogEdgeTable::~ogEdgeTable + +static bool +fileExists(const char *file) +{ + fileDescriptor *f = fopen(file, "r"); + if (!f) + return false; + fclose(f); + return true; +} + +static int32 calculate(float mu, int32 p0, int32 p1, int32 p2, int32 p3); + +// ogSurface constructor +ogSurface::ogSurface(void) { + version = ogVERSION; + dataState = ogNONE; + buffer = NULL; + lineOfs = NULL; + pal = NULL; + xRes = 0; + yRes = 0; + maxX = 0; + maxY = 0; + bSize = 0; + lSize = 0; + transparentColor = 0; + BPP = 0; + redShifter = 0; + greenShifter = 0; + blueShifter = 0; + alphaShifter = 0; + redFieldPosition = 0; + greenFieldPosition = 0; + blueFieldPosition = 0; + alphaFieldPosition = 0; + antiAlias = true; + return; +} // ogSurface::ogSurface + +void +ogSurface::aaRawLine(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2, uInt32 colour) { + /* + * aaRawLine + * + * private method + * + * draws an unclipped anti-aliased line from (x1,y1) to (x2,y2) using colour + * + */ + uInt32 erradj, erracc; + uInt32 erracctmp, intshift, wgt, wgtcompmask; + int32 dx, dy, tmp, xDir, i; + uInt32 ct[32]; + uInt8 r,g,b; + uInt8 orig_r, orig_g, orig_b; + + if (y1 > y2) { + tmp= y1; + y1 = y2; + y2 = tmp; + + tmp= x1; + x1 = x2; + x2 = tmp; + } // if + + ogUnpackRGB(colour, orig_r, orig_g, orig_b); + + for (i=0; i<32; i++) { + r = (i*orig_r) / 31; + g = (i*orig_g) / 31; + b = (i*orig_b) / 31; + ct[31-i] = ogRGB(r,g,b); + } // for + + ogSetPixel(x1,y1,colour); + + dx = (x2-x1); + if (dx>=0) xDir=1; else xDir=-1; + dx = abs(dx); + dy = (y2 - y1); + + if (dy==0) { + ogHLine(x1,x2,y1,colour); + return; + } + + if (dx==0) { + ogVLine(x1,y1,y2,colour); + return; + } + + // this is incomplete.. diagonal lines don't travel through the + // center of pixels exactly + if (dx==dy) { + for (; dy != 0; dy--) { + x1+=xDir; + y1++; + ogSetPixel(x1,y1,colour); + } // for + return; + } // if dx==dy + + erracc = 0; + intshift = 32-5; + wgtcompmask = 31; + if (dy>dx) { + /* y-major. Calculate 32-bit fixed point fractional part of a pixel that + * X advances every time Y advances 1 pixel, truncating the result so that + * we won't overrun the endpoint along the X axis + */ + erradj = ((unsigned long long) dx << 32) / (unsigned long long)dy; + while (--dy) { + erracctmp = erracc; + erracc += erradj; + if (erracc <= erracctmp) x1 += xDir; + y1++; // y-major so always advance Y + /* the nbits most significant bits of erracc give us the intensity + * weighting for this pixel, and the complement of the weighting for + * the paired pixel. + */ + wgt = erracc >> intshift; + ogSetPixel(x1, y1, ct[wgt]); + ogSetPixel(x1+xDir, y1, ct[wgt^wgtcompmask]); + } // while + } else { + /* x-major line. Calculate 32-bit fixed-point fractional part of a pixel + * that Y advances each time X advances 1 pixel, truncating the result so + * that we won't overrun the endpoint along the X axis. + */ + erradj = ((unsigned long long)dy << 32) / (unsigned long long)dx; + // draw all pixels other than the first and last + while (--dx) { + erracctmp = erracc; + erracc += erradj; + if (erracc <= erracctmp) y1++; + x1 += xDir; // x-major so always advance X + /* the nbits most significant bits of erracc give us the intensity + * weighting for this pixel, and the complement of the weighting for + * the paired pixel. + */ + wgt = erracc >> intshift; + ogSetPixel(x1, y1, ct[wgt]); + ogSetPixel(x1, y1+1, ct[wgt^wgtcompmask]); + } // while + } // else + ogSetPixel(x2,y2,colour); + return; +} // ogSurface::aaRawLine + +uInt32 +ogSurface::rawGetPixel(uInt32 x, uInt32 y) { + uInt32 result; + switch (BPP) { + case 8: + __asm__ __volatile__( + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi] + " mov %%eax, %3 \n" // mov result, eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (result) // %2, %3 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] + " mov %%eax, %0 \n" // mov result, eax + : "=m" (result) + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x) // , "m" (result) // %2, %3 + ); + break; + case 24: + __asm__ __volatile__( + " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size + " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size + " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // edx,word ptr [edi] + " xor %%eax, %%eax \n" + " mov 2(%%edi), %%al \n" // mov al, [edi+2] + " shl $16, %%eax \n" // shl eax, 16 + " mov (%%edi), %%ax \n" // mov ax, [edi] + " mov %%eax, %3 \n" // mov result, eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (result) // %2, %3 + ); + break; + case 32: + __asm__ __volatile__( + " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " mov (%%edi),%%eax \n" // eax,word ptr [edi] + " mov %%eax, %3 \n" // mov result, eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (result) // %2, %3 + ); + } // switch + return result; +} // ogSurface::rawGetPixel + +void +ogSurface::rawSetPixel(uInt32 x, uInt32 y, uInt32 colour) { + switch (BPP) { + case 8: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%al, (%%edi) \n" // mov [edi], al + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], al + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + break; + case 24: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + break; + case 32: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%eax, (%%edi) \n" // mov [edi], eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + } // switch + return; +} // ogSurface::rawSetPixel + +bool +ogSurface::clipLine(int32& x1, int32& y1, int32& x2, int32& y2) { + /* + * clipLine() + * + * private method + * + * clips a line to (0,0),(maxX,maxY); returns true if + * the line segment is in bounds, false if none of the line segment is + * on the screen. Uses HJI's line clipping algorithm. + */ + + int32 tx1, ty1, tx2, ty2; + int32 OutCode; + uInt32 AndResult, OrResult; + AndResult = 15; + OrResult = 0; + OutCode = 0; + if (x1<0) OutCode+=8; + if (x1>(int32)maxX) OutCode+=4; + if (y1<0) OutCode+=2; + if (y1>(int32)maxY) OutCode++; + + AndResult &= OutCode; + OrResult |= OutCode; + OutCode = 0; + + if (x2<0) OutCode+=8; + if (x2>(int32)maxX) OutCode+=4; + if (y2<0) OutCode+=2; + if (y2>(int32)maxY) OutCode++; + + AndResult &= OutCode; + OrResult |= OutCode; + + if (AndResult>0) return false; + if (OrResult==0) return true; + + // some clipping is required here. + + tx1 = x1; + ty1 = y1; + tx2 = x2; + ty2 = y2; + + if (x1<0) { + ty1 = (x2*y1-x1*y2) / (x2-x1); + tx1 = 0; + } // if + else + if (x2<0) { + ty2 = (x2*y1-x1*y2) / (x2-x1); + tx2 = 0; + } // elseif + + if (x1>(int32)maxX) { + ty1 = (y1*(x2-maxX)+y2*(maxX-x1)) / (x2-x1); + tx1 = maxX; + } // if + else + if (x2>(int32)maxX) { + ty2 = (y1*(x2-maxX)+y2*(maxX-x1)) / (x2-x1); + tx2 = maxX; + } // elseif + + if (((ty1<0) && (ty2<0)) || + ((ty1>(int32)maxY) && (ty2>(int32)maxY))) return false; + + if (ty1<0) { + tx1 = (x1*y2-x2*y1) / (y2-y1); + ty1 = 0; + } // if + else + if (ty2<0) { + tx2 = (x1*y2-x2*y1) / (y2-y1); + ty2 = 0; + } // elseif + + if (ty1>(int32)maxY) { + tx1 = (x1*(y2-maxY)+x2*(maxY-y1)) / (y2-y1); + ty1 = maxY; + } // if + else + if (ty2>(int32)maxY) { + tx2 = (x1*(y2-maxY)+x2*(maxY-y1)) / (y2-y1); + ty2 = maxY; + } // elseif + + if (((uInt32)tx1>maxX) || ((uInt32)tx2>maxX)) return false; + + x1 = tx1; + y1 = ty1; + x2 = tx2; + y2 = ty2; + + return true; +} // ogSurface::clipLine + +void +ogSurface::rawLine(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2, uInt32 colour) { + /* + * ogSurface::rawLine() + * + * private method; draws an unclipped line from (x1,y1) to (x2,y2) + * + */ + int32 tc; + if (!ogAvail()) return; + switch (BPP) { + case 8: + __asm__ __volatile__( + " mov $1, %%ecx \n" // mov ecx, 1 + " bt $15, %%eax \n" // bt eax, 15 + " jnc rlxPositive8 \n" + " or $-1, %%ecx \n" // or ecx, -1 + " neg %%eax \n" // neg eax +"rlxPositive8: \n" + " add %%eax, %%eax \n" // add eax, eax + " bt $15, %%ebx \n" // bt ebx, 15 + " jnc rlyPositive8 \n" + " neg %%edx \n" // neg edx + " neg %%ebx \n" // neg ebx +"rlyPositive8: \n" + " add %%ebx, %%ebx \n" // add ebx, ebx + + " cmp %%ebx, %%eax \n" // cmp eax, ebx + " jle rlyGreater8 \n" + " push %%ecx \n" // push ecx + " mov %%eax, %%ecx \n" // mov ecx, eax + " mov %%ebx, %6 \n" // mov tc, ebx + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" // pop ecx +"rlxTop8: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%al, (%%edi) \n" // mov [edi], al + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone8 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddY8 \n" + " add %%edx, %%edi \n" // add edi, edx + " sub %%eax, %6 \n" // sub tc, eax +"rlNoAddY8: \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ebx, %6 \n" // add tc, ebx + " jmp rlxTop8 \n" + +"rlyGreater8: \n" + " push %%ecx \n" // push ecx + " mov %%ebx, %%ecx \n" // mov ecx, ebx + " mov %%eax, %6 \n" // mov tc, eax + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" +"rlyTop8: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%al, (%%edi) \n" // mov [edi], al + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone8 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddX8 \n" + " add %%ecx, %%edi \n" // add edi, ecx + " sub %%ebx, %6 \n" // sub tc, ebx +"rlNoAddX8: \n" + " add %%edx, %%edi \n" // add edi, edx + " add %%eax, %6 \n" // add tc, eax + " jmp rlyTop8 \n" +"rlDone8: \n" + : + : "D" ((uInt8 *)buffer+lineOfs[y1]+x1), // %0 + "S" ((uInt8 *)buffer+lineOfs[y2]+x2), // %1 + "a" (x2-x1), "b" (y2-y1), // %2, %3 + "d" (xRes), "m" (colour), // %4, %5 + "m" (tc) // %6 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " mov $1, %%ecx \n" // mov ecx, 1 + " bt $15, %%eax \n" // bt eax, 15 + " jnc rlxPositive16 \n" + " or $-1, %%ecx \n" // or ecx, -1 + " neg %%eax \n" // neg eax +"rlxPositive16: \n" + " add %%eax, %%eax \n" // add eax, eax + " bt $15, %%ebx \n" // bt ebx, 15 + " jnc rlyPositive16 \n" + " neg %%edx \n" // neg edx + " neg %%ebx \n" // neg ebx +"rlyPositive16: \n" + " add %%ebx, %%ebx \n" // add ebx, ebx + + " cmp %%ebx, %%eax \n" // cmp eax, ebx + " jle rlyGreater16 \n" + " push %%ecx \n" // push ecx + " mov %%eax, %%ecx \n" // mov ecx, eax + " mov %%ebx, %6 \n" // mov tc, ebx + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" // pop ecx +"rlxTop16: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%ax, (%%edi) \n" // mov [edi], ax + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone16 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddY16 \n" + " add %%edx, %%edi \n" // add edi, edx + " sub %%eax, %6 \n" // sub tc, eax +"rlNoAddY16: \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ebx, %6 \n" // add tc, ebx + " jmp rlxTop16 \n" + +"rlyGreater16: \n" + " push %%ecx \n" // push ecx + " mov %%ebx, %%ecx \n" // mov ecx, ebx + " mov %%eax, %6 \n" // mov tc, eax + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" +"rlyTop16: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%ax, (%%edi) \n" // mov [edi], ax + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone16 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddX16 \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " sub %%ebx, %6 \n" // sub tc, ebx +"rlNoAddX16: \n" + " add %%edx, %%edi \n" // add edi, edx + " add %%eax, %6 \n" // add tc, eax + " jmp rlyTop16 \n" +"rlDone16: \n" + : + : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1 << 1)), // %0 + "S" ((uInt8 *)buffer+lineOfs[y2]+(x2 << 1)), // %1 + "a" (x2-x1), "b" (y2-y1), // %2, %3 + "d" (xRes), "m" (colour), // %4, %5 + "m" (tc) // %6 + ); + break; + case 24: + __asm__ __volatile__( + " mov $1, %%ecx \n" // mov ecx, 1 + " bt $15, %%eax \n" // bt eax, 15 + " jnc rlxPositive24 \n" + " or $-1, %%ecx \n" // or ecx, -1 + " neg %%eax \n" // neg eax +"rlxPositive24: \n" + " add %%eax, %%eax \n" // add eax, eax + " bt $15, %%ebx \n" // bt ebx, 15 + " jnc rlyPositive24 \n" + " neg %%edx \n" // neg edx + " neg %%ebx \n" // neg ebx +"rlyPositive24: \n" + " add %%ebx, %%ebx \n" // add ebx, ebx + + " cmp %%ebx, %%eax \n" // cmp eax, ebx + " jle rlyGreater24 \n" + " push %%ecx \n" // push ecx + " mov %%eax, %%ecx \n" // mov ecx, eax + " mov %%ebx, %6 \n" // mov tc, ebx + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" // pop ecx +"rlxTop24: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone24 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddY24 \n" + " add %%edx, %%edi \n" // add edi, edx + " sub %%eax, %6 \n" // sub tc, eax +"rlNoAddY24: \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ebx, %6 \n" // add tc, ebx + " jmp rlxTop24 \n" + +"rlyGreater24: \n" + " push %%ecx \n" // push ecx + " mov %%ebx, %%ecx \n" // mov ecx, ebx + " mov %%eax, %6 \n" // mov tc, eax + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" +"rlyTop24: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone24 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddX24 \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " sub %%ebx, %6 \n" // sub tc, ebx +"rlNoAddX24: \n" + " add %%edx, %%edi \n" // add edi, edx + " add %%eax, %6 \n" // add tc, eax + " jmp rlyTop24 \n" +"rlDone24: \n" + : + : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1*3)), // %0 + "S" ((uInt8 *)buffer+lineOfs[y2]+(x2*3)), // %1 + "a" (x2-x1), "b" (y2-y1), // %2, %3 + "d" (xRes), "m" (colour), // %4, %5 + "m" (tc) // %6 + ); + break; + case 32: + __asm__ __volatile__( + " mov $1, %%ecx \n" // mov ecx, 1 + " bt $15, %%eax \n" // bt eax, 15 + " jnc rlxPositive32 \n" + " or $-1, %%ecx \n" // or ecx, -1 + " neg %%eax \n" // neg eax +"rlxPositive32: \n" + " add %%eax, %%eax \n" // add eax, eax + " bt $15, %%ebx \n" // bt ebx, 15 + " jnc rlyPositive32 \n" + " neg %%edx \n" // neg edx + " neg %%ebx \n" // neg ebx +"rlyPositive32: \n" + " add %%ebx, %%ebx \n" // add ebx, ebx + + " cmp %%ebx, %%eax \n" // cmp eax, ebx + " jle rlyGreater32 \n" + " push %%ecx \n" // push ecx + " mov %%eax, %%ecx \n" // mov ecx, eax + " mov %%ebx, %6 \n" // mov tc, ebx + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" // pop ecx +"rlxTop32: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%eax, (%%edi)\n" // mov [edi], eax + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone32 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddY32 \n" + " add %%edx, %%edi \n" // add edi, edx + " sub %%eax, %6 \n" // sub tc, eax +"rlNoAddY32: \n" + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ebx, %6 \n" // add tc, ebx + " jmp rlxTop32 \n" + +"rlyGreater32: \n" + " push %%ecx \n" // push ecx + " mov %%ebx, %%ecx \n" // mov ecx, ebx + " mov %%eax, %6 \n" // mov tc, eax + " shr $1, %%ecx \n" // shr ecx, 1 + " sub %%ecx, %6 \n" // sub tc, ecx + " pop %%ecx \n" +"rlyTop32: \n" + " push %%eax \n" // push eax + " mov %5, %%eax \n" // mov eax, colour + " mov %%eax, (%%edi)\n" // mov [edi], eax + " pop %%eax \n" // pop eax + " cmp %%edi, %%esi \n" // cmp esi, edi + " je rlDone32 \n" + " cmp $0, %6 \n" // cmp tc, 0 + " jl rlNoAddX32 \n" + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx - pix size + " add %%ecx, %%edi \n" // add edi, ecx + " sub %%ebx, %6 \n" // sub tc, ebx +"rlNoAddX32: \n" + " add %%edx, %%edi \n" // add edi, edx + " add %%eax, %6 \n" // add tc, eax + " jmp rlyTop32 \n" +"rlDone32: \n" + : + : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1 << 2)), // %0 + "S" ((uInt8 *)buffer+lineOfs[y2]+(x2 << 2)), // %1 + "a" (x2-x1), "b" (y2-y1), // %2, %3 + "d" (xRes), "m" (colour), // %4, %5 + "m" (tc) // %6 + ); + break; + } // switch + return; +} // ogSurface::rawLine + +bool +ogSurface::ogAlias(ogSurface& SrcObject, uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) { + uInt32 tmp; + if (dataState==ogOWNER) return false; + + if (x2> 3)); + lineOfs=((uInt32 *)SrcObject.lineOfs)+y1; + pal = SrcObject.pal; + xRes = SrcObject.xRes; + yRes = SrcObject.yRes; + maxX = (x2-x1); + maxY = (y2-y1); + bSize = 0; + lSize = 0; + transparentColor = SrcObject.transparentColor; + dataState = ogALIASING; + BPP = SrcObject.BPP; + // For 8bpp modes the next part doesn't matter + redFieldPosition = SrcObject.redFieldPosition; + greenFieldPosition = SrcObject.greenFieldPosition; + blueFieldPosition = SrcObject.blueFieldPosition; + alphaFieldPosition = SrcObject.alphaFieldPosition; + // The next part is only used by 15/16bpp + redShifter = SrcObject.redShifter; + greenShifter = SrcObject.greenShifter; + blueShifter = SrcObject.blueShifter; + alphaShifter = SrcObject.alphaShifter; + + antiAlias = SrcObject.antiAlias; + + return true; +} // ogSurface::ogAlias + +void +ogSurface::ogArc(int32 x_center, int32 y_center, uInt32 radius, + uInt32 s_angle, uInt32 e_angle, uInt32 colour) { + int32 p; + uInt32 x, y, tmp; + double alpha; + + if (radius==0) { + ogSetPixel(x_center, y_center, colour); + return; + } // if + + s_angle%=361; + e_angle%=361; + + if (s_angle>e_angle) { + tmp = s_angle; + s_angle = e_angle; + e_angle = tmp; + } // if + + x = 0; + y = radius; + p = 3-2*radius; + + while (x<=y) { + alpha = (180.0/3.14159265358979)*atan((double)x/(double)y); + if ((alpha>=s_angle) && (alpha<=e_angle)) + ogSetPixel(x_center-x, y_center-y, colour); + if ((90-alpha>=s_angle) && (90-alpha<=e_angle)) + ogSetPixel(x_center-y, y_center-x, colour); + if ((90+alpha>=s_angle) && (90+alpha<=e_angle)) + ogSetPixel(x_center-y, y_center+x,colour); + if ((180-alpha>=s_angle) && (180-alpha<=e_angle)) + ogSetPixel(x_center-x, y_center+y,colour); + if ((180+alpha>=s_angle) && (180+alpha<=e_angle)) + ogSetPixel(x_center+x, y_center+y,colour); + if ((270-alpha>=s_angle) && (270-alpha<=e_angle)) + ogSetPixel(x_center+y, y_center+x,colour); + if ((270+alpha>=s_angle) && (270+alpha<=e_angle)) + ogSetPixel(x_center+y, y_center-x,colour); + if ((360-alpha>=s_angle) && (360-alpha<=e_angle)) + ogSetPixel(x_center+x, y_center-y,colour); + if (p<0) + p+=4*x+6; + else { + p+=4*(x-y)+10; + --y; + } + ++x; + } // while + return; +} // ogSurface::ogArc + +bool +ogSurface::ogAvail(void) { + return ((buffer!=NULL) && (lineOfs!=NULL)); +} // ogSurface::ogAvail + +static int32 +calculate(float mu, int32 p0, int32 p1, int32 p2, int32 p3) { + float mu2, mu3; + mu2 = mu*mu; + mu3 = mu2*mu; + return (int32)(0.5f+(1.0/6.0)*(mu3*(-p0+3.0*p1-3.0*p2+p3)+ + mu2*(3.0*p0-6.0*p1+3.0*p2)+ + mu*(-3.0*p0+3.0*p2)+(p0+4.0*p1+p2))); +} // calculate + + +void +ogSurface::ogBSpline(uInt32 numPoints, ogPoint* points, uInt32 segments, + uInt32 colour) { + float mu, mudelta; + int32 x1,y1,x2,y2; + uInt32 n,h; + if (points==NULL) return; + if ((numPoints<4) || (numPoints>4096) || (segments==0)) return; + mudelta = 1.0/segments; + for (n=3; n=0) { + ogSetPixel(x_center+x,y_center+y,colour); + ogSetPixel(x_center+x,y_center-y,colour); + ogSetPixel(x_center-x,y_center+y,colour); + ogSetPixel(x_center-x,y_center-y,colour); + if (d + y > 0) { + y--; + d -= 2*y+1; + } // if + if (x > d) { + x++; + d += 2*x+1; + } // if + } // while + return; +} // ogSurface::ogCircle + +void +ogSurface::ogClear(uInt32 colour) { + uInt32 height = 0; + if (!ogAvail()) return; + __asm__ __volatile__("cld\n"); + switch (BPP) { + case 8: + __asm__ __volatile__( + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxY) + " inc %%ebx \n" // inc ebx (maxX) + " sub %%edx, %%esi \n" // sub esi, edx + " mov %%al, %%ah \n" // mov ah, al + " mov %%ax, %%cx \n" // mov cx, ax + " shl $16, %%eax \n" // shl eax, 16 + " mov %%cx, %%ax \n" // mov ax, cx + "loop8: \n" + " push %%edx \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " and $3, %%edx \n" // and edx, 3 + " shr $2, %%ecx \n" // shr ecx, 2 + " rep \n" + " stosl \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " rep \n" + " stosb \n" + " pop %%edx \n" + " add %%esi, %%edi \n" // add edi, esi + " dec %%ebx \n" + " jnz loop8 \n" + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "a" (colour), "b" (maxY), // %2, %3 + "c" (xRes), "d" (maxX) // %4, %5 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxX) + " inc %%ebx \n" // inc ebx (maxY) + " sub %%edx, %%esi \n" // sub esi, edx + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " mov %%ax, %%cx \n" // mov cx, ax + " shl $16, %%eax \n" // shl eax, 16 + " mov %%cx, %%ax \n" // mov ax, cx + "loop16: \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " shr $1, %%ecx \n" // shr ecx, 1 + " rep \n" + " stosl \n" + " jnc noc16 \n" + " stosw \n" + "noc16: \n" + " add %%esi, %%edi \n" // add edi, esi + " dec %%ebx \n" + " jnz loop16 \n" + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "a" (colour), "b" (maxY), // %2, %3 + "c" (xRes), "d" (maxX) // %4, %5 + ); + break; + case 24: + __asm__ __volatile__( + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxX) + " inc %%ebx \n" // inc ebx (maxY) + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " mov %%ebx, %6 \n" // mov height, ebx + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " mov %%eax, %%ebx \n" // mov ebx, eax + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " shr $16, %%ebx \n" // shr ebx, 16 + "oloop24: \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + "iloop24: \n" + " mov %%ax,(%%edi) \n" // mov [edi],ax + " movb %%bl,2(%%edi) \n" // mov [edi+2],bl + " add $3, %%edi \n" // add edi, 3 + " dec %%ecx \n" // dec ecx + " jnz iloop24 \n" + " add %%esi, %%edi \n" // add edi, esi + " decl %6 \n" // dec height + " jnz oloop24 \n" + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "a" (colour), "b" (maxY), // %2, %3 + "c" (xRes), "d" (maxX), // %4, %5 + "m" (height) // %6 + ); + break; + case 32: + __asm__ __volatile__( + + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxX) + " inc %%ebx \n" // inc ebx (maxY) + " mov %%edx, %%ecx \n" // mov ecx, edx + " shl $2, %%ecx \n" // shl ecx, 2 + " sub %%ecx, %%esi \n" // sub esi, ecx // adjust for pix size + "loop32: \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " rep \n" + " stosl \n" + " add %%esi, %%edi \n" // add edi, esi + " dec %%ebx \n" + " jnz loop32 \n" + + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "a" (colour), "b" (maxY), // %2, %3 + "c" (xRes), "d" (maxX) // %4, %5 + ); + } // switch + return; +} // ogSurface::ogClear + +bool +ogSurface::ogClone(ogSurface& SrcObject) { + bool created; + ogPixelFmt pixfmt; + if (SrcObject.dataState==ogNONE) return false; + SrcObject.ogGetPixFmt(pixfmt); + created = ogCreate(SrcObject.maxX+1,SrcObject.maxY+1,pixfmt); + if (!created) return false; + transparentColor = SrcObject.transparentColor; + antiAlias = SrcObject.antiAlias; + ogCopyPal(SrcObject); + ogCopy(SrcObject); + return true; +} // ogSurface::ogClone + +void +ogSurface::ogCopy(ogSurface& SrcObject) { + uInt32 count, xCount, yCount; + uInt32 xx, yy; + uInt8 r, g, b; + void * srcPtr; + + if (!ogAvail()) return; + if (!SrcObject.ogAvail()) return; + + xCount = SrcObject.maxX+1; + if (xCount>maxX+1) xCount=maxX+1; + yCount = SrcObject.maxY+1; + if (yCount>maxY+1) yCount=maxY+1; + if ((BPP!=SrcObject.BPP) || (redShifter!=SrcObject.redShifter) || + (blueShifter!=SrcObject.blueShifter) || + (greenShifter!=SrcObject.greenShifter)) { + for (yy=0; yy> 3); // adjust for bpp + for (count=0; count(int32)maxX) || (dY1>(int32)maxY)) return; + + // if any of the source buffer is out of bounds then do nothing + if (( (uInt32)sX1>SrcObject.maxX) || ((uInt32)sX2>SrcObject.maxX) || + ( (uInt32)sY1>SrcObject.maxY) || ((uInt32)sY2>SrcObject.maxY)) return; + + if (sX1>sX2) { + xx = sX1; + sX1= sX2; + sX2= xx; + } // if + + if (sY1>sY2) { + yy = sY1; + sY1= sY2; + sY2= yy; + } // if + + xCount = abs(sX2-sX1)+1; + yCount = abs(sY2-sY1)+1; + + if (dX1+xCount>(int32)maxX+1) xCount=maxX-dX1+1; + if (dY1+yCount>(int32)maxY+1) yCount=maxY-dY1+1; + + if (dX1<0) { + xCount += dX1; + sX1 -= dX1; + dX1 = 0; + } // if + + if (dY1<0) { + yCount += dY1; + sY1 -= dY1; + dY1 = 0; + } // if + + if ((dX1+xCount<0) || (dY1+yCount<0)) return; + + if ((BPP!=SrcObject.BPP) || (redShifter!=SrcObject.redShifter) || + (blueShifter!=SrcObject.blueShifter) || + (greenShifter!=SrcObject.greenShifter)) { + if (SrcObject.BPP==8) { + for (xx=0; xx<256; xx++) + pixmap[xx] = ogRGB(SrcObject.pal[xx].red, + SrcObject.pal[xx].green, + SrcObject.pal[xx].blue); + for (yy=0; yy<=yCount-1; yy++) + for (xx=0; xx<=xCount-1; xx++) + rawSetPixel(dX1+xx,dY1+yy, + pixmap[SrcObject.ogGetPixel(sX1+xx,sY1+yy)]); + } // if SrcObject->bpp + else + { + for (yy=0; yy<=yCount-1; yy++) + for (xx=0; xx<=xCount-1; xx++) { + SrcObject.ogUnpackRGB(SrcObject.ogGetPixel(sX1+xx,sY1+yy),r,g,b); + rawSetPixel(dX1+xx,dY1+yy,ogRGB(r,g,b)); + } // for + } // else + } // if + else + { + xCount *= (BPP+7) >> 3; + for (count=0; count> 3), // dest + src, // src + size); // size + + return; +} // ogSurface::ogCopyLineTo + +void +ogSurface::ogCopyLineFrom(uInt32 sx, uInt32 sy, void * dst, uInt32 size) { + /* + * ogCopyLineFrom() + * + * Inputs: + * + * sx - Source X of the target buffer + * sy - Source Y of the target buffer + * dest - where to put it + * size - size in bytes *NOT* pixels + * + * Copies a run of pixels (of the same format) to (x,y) of a buffer + * + * This method is required because of the different implementations of + * copying a run of pixels to a buffer + * + * WARNING!!! This does *NO* error checking. It is assumed that you've + * done all of that. ogCopyLineTo and ogCopyLineFrom are the only + * methods that don't check to make sure you're hosing things. Don't + * use this method unless YOU KNOW WHAT YOU'RE DOING!!!!!!!!! + */ + kmemcpy( dst, // dest + (uInt8*)buffer+lineOfs[sy]+sx*((BPP+7) >> 3), // src + size); // size + + return; +} // ogSurface::ogCopyLineFrom + +void +ogSurface::ogCopyPal(ogSurface& SrcObject) { + if (SrcObject.pal==NULL) return; + if (pal==NULL) pal = new ogRGBA[256]; + if (pal==NULL) return; + kmemcpy(pal, SrcObject.pal, sizeof(ogRGBA)*256); + return; +} // ogSurface::ogCopyPal + +bool +ogSurface::ogCreate(uInt32 _xRes, uInt32 _yRes,ogPixelFmt _pixformat) { + /* + * ogSurface::ogCreate() + * Allocates memory for a buffer of size _xRes by _yRes with + * the pixel format defined in _pixformat. Allocates memory + * for pal and lineOfs. + */ + uInt32 yy; + if (dataState==ogOWNER) { + kfree(buffer); + delete [] lineOfs; + delete [] pal; + } // if datastate + BPP = _pixformat.BPP; + bSize=_xRes*_yRes*((BPP+7) >> 3); + buffer = kmalloc(bSize,-2); + if (buffer==NULL) return false; + kmemset(buffer,0,bSize); + lSize = _yRes*sizeof(uInt32); + lineOfs = new uInt32[_yRes]; + if (lineOfs == NULL) return false; + pal = new ogRGBA[256]; + if (pal == NULL) return false; + // copy the default palette into the buffer + kmemcpy(pal,DEFAULT_PALETTE,sizeof(ogRGBA)*256); + maxX=_xRes-1; + xRes=_xRes*((BPP+7) >> 3); + maxY=_yRes-1; + yRes=_yRes; + lineOfs[0]=0; + for (yy=1; yy<=maxY; yy++) + lineOfs[yy]=lineOfs[yy-1]+xRes; + dataState = ogOWNER; + // For 8bpp modes the next part doesn't matter + redFieldPosition=_pixformat.redFieldPosition; + greenFieldPosition=_pixformat.greenFieldPosition; + blueFieldPosition=_pixformat.blueFieldPosition; + alphaFieldPosition=_pixformat.alphaFieldPosition; + // The next part is only used by 15/16hpp + redShifter=8-_pixformat.redMaskSize; + greenShifter=8-_pixformat.greenMaskSize; + blueShifter=8-_pixformat.blueMaskSize; + alphaShifter=8-_pixformat.alphaMaskSize; + + // Turn anti aliasing off by default for 8bpp modes + antiAlias = (BPP>8); + owner = this; + return true; +} // ogSurface::ogCreate + +void +ogSurface::ogCubicBezierCurve(int32 x1, int32 y1, int32 x2, int32 y2, + int32 x3, int32 y3, int32 x4, int32 y4, + uInt32 segments, uInt32 colour) { + float tX1, tY1, tX2, tY2, tX3, tY3, mu, mu2, mu3, mudelta; + int32 xStart, yStart, xEnd, yEnd; + uInt32 n; + if (segments<1) return; + if (segments>128) segments=128; + + mudelta = 1.0/segments; + mu = mudelta; + tX1 =-x1+3*x2-3*x3+x4; + tY1 =-y1+3*y2-3*y3+y4; + tX2 =3*x1-6*x2+3*x3; + tY2 =3*y1-6*y2+3*y3; + tX3 =-3*x1+3*x2; + tY3 =-3*y1+3*y2; + + xStart = x1; + yStart = y1; + + for (n=1; n128) segments=128; + x2 = (x2*2)-((x1+x3)/2); + y2 = (y2*2)-((y1+y3)/2); + + ex = ((int64)(x2-x1) << 17) / segments; + ey = ((int64)(y2-y1) << 17) / (long long)segments; + fx = ((int64)(x3-(2*x2)+x1) << 16) / (segments*segments); + fy = ((int64)(y3-(2*y2)+y1) << 16) / (long long)(segments*segments); + + while (--segments>0) { + t1=x3; + t2=y3; + x3=((int64)((fx*segments+ex)*segments) / 65536L)+x1; + y3=((int64)((fy*segments+ey)*segments) / 65536L)+y1; + ogLine(t1, t2, x3, y3, colour); + } // while + ogLine(x3,y3,x1,y1,colour); + return; + +} // ogSurface::ogCurve + +void +ogSurface::ogFillCircle(int32 x_center, int32 y_center, + uInt32 radius, uInt32 colour) { + int32 x, y, d; + x = 0; + y = radius; + d = 2*(1-radius); + while (y>=0) { + ogHLine(x_center-x, x_center+x, y_center-y, colour); + ogHLine(x_center-x, x_center+x, y_center+y, colour); + if (d+y>0) { + y--; + d-=2*y+1; + } + if (x>d) { + x++; + d+=2*x+1; + } + } // while + return; +} // ogSurface::ogFillCircle + +#if 0 +!-/* Scan converts an edge from (X1,Y1) to (X2,Y2), not including the +!- * point at (X2,Y2). This avoids overlapping the end of one line with +!- * the start of the next, and causes the bottom scan line of the +!- * polygon not to be drawn. If SkipFirst != 0, the point at (X1,Y1) +!- * isn't drawn. For each scan line, the pixel closest to the scanned +!- * line without being to the left of the scanned line is chosen +!- */ +!-static void index_forward(int32 & index, uInt32 numPoints) { +!- index = (index + 1) % numPoints; +!- return; +!-} // index_forward +!- +!-static void index_backward(int32 & index, uInt32 numPoints) { +!- index = (index - 1 + numPoints) % numPoints; +!- return; +!-} // index_forward +!- +!-static void index_move(int32 & index, uInt32 numPoints, int32 direction) { +!- if (direction > 0) +!- index_forward(index, numPoints); +!- else +!- index_backward(index, numPoints); +!- return; +!-} // index_move +!- +!-static void scanEdge(int32 x1, int32 y1, int32 x2, int32 y2, +!- uInt32 & eIdx, int32 * xList) { +!- int32 y, deltaX, deltaY; +!- float inverseSlope; +!- +!- deltaX = x2 - x1; +!- deltaY = y2 - y1; +!- if (deltaY <= 0) return; +!- inverseSlope = deltaX / deltaY; +!- +!- // Store the X coordinate of the pixel closest to but not to the +!- // left of the line for each Y coordinate between Y1 and Y2, not +!- // including Y2 +!- y = y1; +!- do { +!- xList[eIdx] = x1+ (int32)(0.5f+((y-y1)*inverseSlope)); +!- y++; +!- eIdx++; +!- } while (y maxPointY) { +!- maxIndex = i; +!- maxPointY = polyPoints[i].y; // new bottom +!- } // else if +!- } // for +!- +!- if (minPointY == maxPointY) return; +!- +!- // scan in ascending order to find the last top-edge point +!- minIndexR = minIndexL; +!- while (polyPoints[minIndexR].y == minPointY) index_forward(minIndexR, numPoints); +!- index_backward(minIndexR, numPoints); // back up to last top-edge point +!- +!- // now scan in descending order to find the first top-edge point +!- while (polyPoints[minIndexL].y == minPointY) index_backward(minIndexL, numPoints); +!- index_forward(minIndexL, numPoints); +!- +!- // figure out which direction through the vertex list from the top +!- // vertex is the left edge and which is the right +!- leftEdgeDir = -1; +!- +!- topIsFlat = (polyPoints[minIndexL].x==polyPoints[minIndexR].x) ? 0 : 1; +!- if (topIsFlat==1) { +!- if (polyPoints[minIndexL].x > polyPoints[minIndexR].x) { +!- leftEdgeDir = 1; +!- temp = minIndexL; +!- minIndexL = minIndexR; +!- minIndexR = temp; +!- } +!- } else { +!- // Point to the downward end of the first line of each of the +!- // two edges down from the top +!- nextIndex = minIndexR; +!- index_forward(nextIndex, numPoints); +!- prevIndex = minIndexL; +!- index_forward(prevIndex, numPoints); +!- +!- deltaXN = polyPoints[nextIndex].x - polyPoints[minIndexL].x; +!- deltaYN = polyPoints[nextIndex].y - polyPoints[minIndexL].y; +!- deltaXP = polyPoints[prevIndex].x - polyPoints[minIndexL].x; +!- deltaYP = polyPoints[prevIndex].y - polyPoints[minIndexL].y; +!- if (deltaXN * deltaYP - deltaYN * deltaXP < 0) { +!- leftEdgeDir = 1; +!- temp = minIndexL; +!- minIndexL = minIndexR; +!- minIndexR = temp; +!- } // if +!- } // else +!- +!- /* Set the # of scan lines in the polygon, skipping the bottom edge +!- * and also skipping the top vertex if the top isn't flat because +!- * in that case the top vertex has a right edge component, and set +!- * the top scan line to draw, which is likewise the second line of +!- * the polygon unles the top if flat +!- */ +!- +!- workingHLineList.length = maxPointY - minPointY; +!- if (workingHLineList.length <= 0) return; +!- workingHLineList.yStart = minPointY; +!- +!- // get memory in which to srote the line list we generate +!- workingHLineList.xLeft = workingHLineList.xRight = NULL; +!- if ((workingHLineList.xLeft = new int32[workingHLineList.length]) == NULL) return; +!- if ((workingHLineList.xRight = new int32[workingHLineList.length]) == NULL) { +!- delete workingHLineList.xLeft; +!- return; +!- } +!- kmemset(workingHLineList.xLeft,0,workingHLineList.length*sizeof(int32)); +!- kmemset(workingHLineList.xRight,0,workingHLineList.length*sizeof(int32)); +!- +!- // scan the left edge and store the boundary points int he list +!- // Initial pointer for storing scan converted left-edge coords +!- edgePointIdx = 0; +!- +!- // start from the top of the left edge +!- curIndex = prevIndex = minIndexL; +!- +!- do { +!- index_move(curIndex, numPoints, leftEdgeDir); +!- scanEdge(polyPoints[prevIndex].x, +!- polyPoints[prevIndex].y, +!- polyPoints[curIndex].x, +!- polyPoints[curIndex].y, +!- edgePointIdx, +!- workingHLineList.xLeft); +!- prevIndex = curIndex; +!- } while (curIndex != maxIndex); +!- +!- edgePointIdx = 0; +!- curIndex = prevIndex = minIndexR; +!- // Scan convert the right edge, top to bottom. X coordinates are +!- // adjusted 1 to the left, effectively causing scan conversion of +!- // the nearest points to the left of but not exactly on the edge } +!- do { +!- index_move(curIndex, numPoints, -leftEdgeDir); +!- scanEdge(polyPoints[prevIndex].x, +!- polyPoints[prevIndex].y, +!- polyPoints[curIndex].x, +!- polyPoints[curIndex].y, +!- edgePointIdx, +!- workingHLineList.xRight); +!- prevIndex = curIndex; +!- } while (curIndex != maxIndex); +!- +!- ogPolygon(numPoints, polyPoints, colour); +!- +!- for (i = 0; i < workingHLineList.length; i++) { +!- ogHLine(workingHLineList.xLeft[i], workingHLineList.xRight[i], +!- workingHLineList.yStart+i, colour); +!- } // for +!- +!- ogPolygon(numPoints, polyPoints, colour); +!- +!- delete workingHLineList.xLeft; +!- delete workingHLineList.xRight; +!- +!- return; +!-} // ogSurface::ogFillConvexPolygon +#endif + +void +ogSurface::ogFillPolygon(uInt32 numPoints, ogPoint* polyPoints, uInt32 colour) { + ogEdgeTable * edges; + int32 currentY; + + if (numPoints<3) return; +/* if (numPoints==3) { + * ogFillConvexPolygon(numPoints, polyPoints, colour); + * return; + * } // if + */ + ogPolygon(numPoints, polyPoints, colour); + edges = new ogEdgeTable(); + edges->buildGET(numPoints, polyPoints); + currentY = edges->globalEdges->startY; + while ((edges->globalEdges!=NULL) || (edges->activeEdges!=NULL)) { + edges->moveXSortedToAET(currentY); + edges->scanOutAET(*this, currentY, colour); + edges->advanceAET(); + edges->xSortAET(); + currentY++; + if (currentY>(int32)maxY) break; // if we've gone past the bottom, stop + } // while + delete edges; + return; +} // ogSurface::ogFillPolygon + +void +ogSurface::ogFillRect(int32 x1, int32 y1, int32 x2, int32 y2, uInt32 colour) { + int32 yy,tmp; + + if (x2(int32)maxY)) return; + if (y1<0) y1=0; + if (y2>(int32)maxY) y2=maxY; + for (yy=y1; yy<=y2; yy++) + ogHLine(x1,x2,yy,colour); +} // ogSurface::ogFillRect + +void ogSurface::ogFillTriangle(int32 x1, int32 y1, int32 x2, int32 y2, + int32 x3, int32 y3, uInt32 colour) { + ogPoint Points[3]; + Points[0].x = x1; + Points[0].y = y1; + Points[1].x = x2; + Points[1].y = y2; + Points[2].x = x3; + Points[2].y = y3; +// ogFillConvexPolygon(3,Points,colour); + ogFillPolygon(3,Points,colour); + return; +} // ogSurface::ogFillTriangle + +void +ogSurface::ogGetPixFmt(ogPixelFmt& pixfmt) { + pixfmt.BPP=BPP; + pixfmt.redFieldPosition=redFieldPosition; + pixfmt.greenFieldPosition=greenFieldPosition; + pixfmt.blueFieldPosition=blueFieldPosition; + pixfmt.alphaFieldPosition=alphaFieldPosition; + pixfmt.redMaskSize=8-redShifter; + pixfmt.greenMaskSize=8-greenShifter; + pixfmt.blueMaskSize=8-blueShifter; + pixfmt.alphaMaskSize=8-alphaShifter; + return; +} // ogSurface::ogGetPixFmt + +uInt32 +ogSurface::ogGetPixel(int32 x, int32 y) { + uInt32 result; + if (!ogAvail()) return transparentColor; + + if (((uInt32)x>maxX) || ((uInt32)y>maxY)) return transparentColor; + + switch (BPP) { + case 8: + __asm__ __volatile__( + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi] + " mov %%eax, %3 \n" // mov result, eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (result) // %2, %3 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] + " mov %%eax, %0 \n" // mov result, eax + : "=m" (result) + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x) // , "m" (result) // %2, %3 + ); + break; + case 24: + __asm__ __volatile__( + " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size + " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size + " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // edx,word ptr [edi] + " xor %%eax, %%eax \n" + " mov 2(%%edi), %%al \n" // mov al, [edi+2] + " shl $16, %%eax \n" // shl eax, 16 + " mov (%%edi), %%ax \n" // mov ax, [edi] + " mov %%eax, %3 \n" // mov result, eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (result) // %2, %3 + ); + break; + case 32: + __asm__ __volatile__( + " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " mov (%%edi),%%eax \n" // eax,word ptr [edi] + " mov %%eax, %3 \n" // mov result, eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (result) // %2, %3 + ); + } // switch + return result; +} // ogSurface::ogGetPixel + +void * +ogSurface::ogGetPtr(uInt32 x, uInt32 y) { +// return (ogAvail() ? ( (uInt8*)buffer+(lineOfs[y]+x*((BPP+7) >> 3)) ) : NULL ); + return ((uInt8*)buffer+(lineOfs[y]+x*((BPP+7) >> 3))); +} // ogSurface::ogGetPtr + +void +ogSurface::ogHFlip(void) { + void * tmpBuf1; + void * tmpBuf2; + uInt32 xWidth, count; + if (!ogAvail()) return; + xWidth = (maxX+1)*((BPP+7) >> 3); + tmpBuf1 = kmalloc(xWidth,-2); + tmpBuf2 = kmalloc(xWidth,-2); + if ((tmpBuf1!=NULL) && (tmpBuf2!=NULL)) + for (count=0; count<=(maxY/2); count++) { + ogCopyLineFrom(0,count,tmpBuf1,xWidth); + ogCopyLineFrom(0,maxY-count,tmpBuf2,xWidth); + ogCopyLineTo(0,maxY-count,tmpBuf1,xWidth); + ogCopyLineTo(0,count,tmpBuf2,xWidth); +// kmemcpy(tmpBuf,((uInt8*)buffer+lineOfs[count]),xWidth); +// kmemcpy(((uInt8*)buffer+lineOfs[count]), +// ((uInt8*)buffer+lineOfs[maxY-count]), +// xWidth); +// kmemcpy(((uInt8*)buffer+lineOfs[maxY-count]),tmpBuf,xWidth); + } // for + kfree(tmpBuf2); + kfree(tmpBuf1); + return; +} // ogSurface::ogHFlip + +void +ogSurface::ogHLine(int32 x1, int32 x2, int32 y, uInt32 colour) { + int32 tmp; + + if (!ogAvail()) return; + if ((uInt32)y>maxY) return; + if (x1>x2) { + tmp= x1; + x1 = x2; + x2 = tmp; + } // if + if (x1<0) x1 = 0; + if (x2>(int32)maxX) x2=maxX; + if (x2> redShifter) << redFieldPosition | + (green >> greenShifter) << greenFieldPosition | + (blue >> blueShifter) << blueFieldPosition; + break; + case 24: + case 32: + colour = ( (red << redFieldPosition) | + (green << greenFieldPosition) | + (blue << blueFieldPosition) ); + } // switch + //asm("": "=a" (lastclr)); + return colour; +} // ogSurface::ogRGB + +bool +ogSurface::ogSavePal(const char *palfile) { + fileDescriptor * f; + uInt32 lresult; + if (pal==NULL) return false; + if ((f = fopen(palfile, "wb"))==NULL) return false; + lresult = fwrite(pal,sizeof(ogRGBA),256,f); + fclose(f); + return (lresult == 256); +} // ogSurface::ogSavePal + +void +ogSurface::ogScale(ogSurface& SrcObject) { + ogScaleBuf(0,0,maxX,maxY,SrcObject,0,0,SrcObject.maxX,SrcObject.maxY); + return; +} // ogSurface::ogScale + +void +ogSurface::ogScaleBuf(int32 dX1, int32 dY1, int32 dX2, int32 dY2, + ogSurface& SrcObject, + int32 sX1, int32 sY1, int32 sX2, int32 sY2) { + + uInt32 sWidth, dWidth; + uInt32 sHeight, dHeight; + int32 sx, sy, xx, yy; + uInt32 xInc, yInc; + uInt32 origdX1, origdY1; + ogPixelFmt pixFmt; + ogSurface * tmpBuf; + ogSurface * sBuf; + ogSurface * dBuf; + bool doCopyBuf; + uInt8 scaleBPP; + + origdX1 = origdY1 = 0; // to keep the compiler from generating a warning + + if (!ogAvail()) return; + if (!SrcObject.ogAvail()) return; + + if (sX1>sX2) { + xx = sX1; + sX1= sX2; + sX2= xx; + } + + if (sY1>sY2) { + yy = sY1; + sY1= sY2; + sY2= yy; + } + + // if any part of the source falls outside the buffer then don't do anything + + if (((uInt32)sX1>SrcObject.maxX) || ((uInt32)sX2>SrcObject.maxX) || + ((uInt32)sY1>SrcObject.maxY) || ((uInt32)sY2>SrcObject.maxY)) return; + + if (dX1>dX2) { + xx = dX1; + dX1= dX1; + dX2= xx; + } + + if (dY1>dY2) { + yy = dY1; + dY1= dY2; + dY2= yy; + } + + dWidth = (dX2-dX1)+1; + if (dWidth<=0) return; + + dHeight = (dY2-dY1)+1; + if (dHeight<=0) return; + + sWidth = (sX2-sX1)+1; + sHeight = (sY2-sY1)+1; + + // convert into 16:16 fixed point ratio + xInc = (sWidth << 16) / dWidth; + yInc = (sHeight << 16) / dHeight; + + if (dX2>(int32)maxX) { + xx = (xInc*(dX1-maxX)) >> 16; + sX1 -= xx; + sWidth -= xx; + dWidth -= (dX1-maxX); + dX1 = maxX; + } + + if (dY2>(int32)maxY) { + yy = (yInc*(dY2-maxY)) >> 16; + sY2 -= yy; + sHeight -= yy; + dHeight -= (dY2-maxY); + dY2 = maxY; + } + + if (dX1<0) { + xx = (xInc*(-dX1)) >> 16; + sX1 += xx; + sWidth -= xx; + dWidth += dX1; + dX1 = 0; + } + + if (dY1<0) { + yy = (yInc*(-dY1)) >> 16; + sY1 += yy; + sHeight -= yy; + dHeight += dY1; + dY1 = 0; + } + + if ((dWidth<=0) || (dHeight<=0)) return; + if ((sWidth<=0) || (sHeight<=0)) return; + + // Do a quick check to see if the scale is 1:1 .. in that case just copy + // the image + + if ((dWidth==sWidth) && (dHeight==sHeight)) { + ogCopyBuf(dX1,dY1,SrcObject,sX1,sY1,sX2,sY2); + return; + } + + tmpBuf = NULL; + + /* + * Alright.. this is how we're going to optimize the case of different + * pixel formats. We are going to use copyBuf() to automagically do + * the conversion for us using tmpBuf. Here's how it works: + * If the source buffer is smaller than the dest buffer (ie, we're making + * something bigger) we will convert the source buffer first into the dest + * buffer's pixel format. Then we do the scaling. + * If the source buffer is larger than the dest buffer (ie, we're making + * something smaller) we will scale first and then use copyBuf to do + * the conversion. + * This method puts the onus of conversion on the copyBuf() function which, + * while not excessively fast, does the job. + * The case in which the source and dest are the same size is handled above. + * + */ + + if ( (BPP!=SrcObject.BPP) || (redShifter!=SrcObject.redShifter) || + (blueShifter!=SrcObject.blueShifter) || + (greenShifter!=SrcObject.greenShifter)) { + tmpBuf = new ogSurface(); + if (tmpBuf==NULL) return; + if (sWidth*sHeight*((SrcObject.BPP+7)>>3)<=dWidth*dHeight*((BPP+7)>>3)) { + // if the number of pixels in the source buffer is less than the + // number of pixels in the dest buffer then... + ogGetPixFmt(pixFmt); + if (tmpBuf->ogCreate(sWidth,sHeight,pixFmt)==false) return; + tmpBuf->ogCopyPal(SrcObject); + tmpBuf->ogCopyBuf(0,0,SrcObject,sX1,sY1,sX2,sY2); + sX2 -= sX1; + sY2 -= sY1; + sX1 = 0; + sY1 = 0; + sBuf = tmpBuf; + dBuf = this; + doCopyBuf = false; // do we do a copyBuf later? + scaleBPP = BPP; + } else { + SrcObject.ogGetPixFmt(pixFmt); + if (tmpBuf->ogCreate(dWidth,dHeight,pixFmt)==false) return; +// tmpBuf->ogCopyPal(&this); + origdX1 = dX1; + origdY1 = dY1; + dX1 = 0; + dY1 = 0; + dX2 = tmpBuf->maxX; + dY2 = tmpBuf->maxY; + sBuf = &SrcObject; + dBuf = tmpBuf; + doCopyBuf = true; + scaleBPP = SrcObject.BPP; + } // else + } else { + // pixel formats are identical + sBuf = &SrcObject; + dBuf = this; + doCopyBuf = false; + scaleBPP = BPP; + } // else + + sy = sY1 << 16; + + for (yy = dY1; yy <=dY2; yy++) { + sx = 0; + for (xx = dX1; xx <= dX2; xx++) { + dBuf->rawSetPixel(xx,yy,sBuf->rawGetPixel(sX1+(sx >> 16),(sy>>16))); + sx+=xInc; + } // for xx + sy += yInc; + } // for yy + + if ((doCopyBuf) && (tmpBuf!=NULL)) + ogCopyBuf(origdX1,origdY1,*tmpBuf,0,0,tmpBuf->maxX,tmpBuf->maxY); + delete tmpBuf; + return; +} // ogSurface::ogScaleBuf + +void +ogSurface::ogSendSDE(uInt32 command) { + asm( + "int %0" + : + : "i" (0x80),"a" (40),"b" (command),"c" (this) + ); + return; +} // ogSurface::ogSendSDE + +bool +ogSurface::ogSetAntiAlias(bool _AntiAlias) { + bool tmp; + tmp = antiAlias; + antiAlias = _AntiAlias; + return tmp; +} // ogSurface::ogSetAntiAlias + +void +ogSurface::ogSetPixel(int32 x, int32 y, uInt32 colour) { + if (!ogAvail()) return; +// if ((buffer==NULL) || (lineOfs==NULL)) return; + if (((uInt32)x>maxX) || ((uInt32)y>maxY)) return; + switch (BPP) { + case 8: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx * 4] + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%al, (%%edi) \n" // mov [edi], al + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " mov %3, %%eax \n" // mov eax, colour + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], al + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "m" (colour) // %2, %3 + ); + break; + case 24: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + break; + case 32: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%eax, (%%edi) \n" // mov [edi], eax + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour) // %2, %3 + ); + } // switch + return; +} // ogSurface::ogSetPixel + +void +ogSurface::ogSetRGBPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) { + if (pal==NULL) return; + pal[colour].red = red; + pal[colour].green = green; + pal[colour].blue = blue; + return; +} // ogSurface::ogSetRGBPalette + +uInt32 +ogSurface::ogSetTransparentColor(uInt32 colour) { + uInt32 tmp; + tmp = transparentColor; + transparentColor = colour; + return tmp; +} // ogSurface::ogSetTransparentColor + +static double f(double g) { return g*g*g-g; } + +void +ogSurface::ogSpline(uInt32 numPoints, ogPoint* points, uInt32 segments, + uInt32 colour) { + int32 i, oldY, oldX, x, y, j; + float part, t, xx, yy, tmp; + float * zc; + float * dx; + float * dy; + float * u; + float * wndX1; + float * wndY1; + float * px; + float * py; + + bool runOnce; + if ((numPoints<2) || (points==NULL)) return; + zc = new float[numPoints]; + dx = new float[numPoints]; + dy = new float[numPoints]; + u = new float[numPoints]; + wndX1 = new float[numPoints]; + wndY1 = new float[numPoints]; + px = new float[numPoints]; + py = new float[numPoints]; + if ((zc==NULL) || (dx==NULL) || (dy==NULL) || (wndX1==NULL) || + (wndY1==NULL) || (px==NULL) || (py==NULL)) goto safeexit; + + for (i = 0; (uInt32)i0; i--) { + py[i] = (wndY1[i]-u[i]*py[i+1])/dy[i]; + px[i] = (wndX1[i]-u[i]*px[i+1])/dx[i]; + } // for + + for (i = 0; (uInt32)i < numPoints-1; i++) { + for (j = 0; (uInt32)j <= segments; j++) { + part = zc[i]-(((zc[i]-zc[i+1])/segments)*j); + t = (part-zc[i])/u[i]; + part = t * points[i+1].y + + (1.0-t)*points[i].y + + u[i] * u[i] * ( f(t) * py[i+1] + f(1.0-t) * py[i]) /6.0; +// y = Round(part); + y = ROUND(part+0.5f); + part = zc[i]-(((zc[i]-zc[i+1])/segments)*j); + t = (part-zc[i])/u[i]; + part = t*points[i+1].x+(1.0-t)*points[i].x+u[i]*u[i]*(f(t)*px[i+1]+ + f(1.0-t)*px[i])/6.0; + +// x = Round(part); + x = ROUND(part+0.5f); + if (runOnce) ogLine(oldX, oldY, x, y, colour); else runOnce = true; + oldX = x; + oldY = y; + } // for j + } // for i +safeexit: + delete [] py; + delete [] px; + delete [] wndY1; + delete [] wndX1; + delete [] u; + delete [] dy; + delete [] dx; + delete [] zc; + + return; +} // ogSurface::ogSpline + + +void +ogSurface::ogTriangle(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, + uInt32 colour) { + ogLine(x1,y1,x2,y2,colour); + ogLine(x2,y2,x3,y3,colour); + ogLine(x3,y3,x1,y1,colour); + return; +} // ogSurface::ogTriangle + +void +ogSurface::ogUnpackRGB(uInt32 colour, uInt8& red, uInt8& green, uInt8& blue) { + switch (BPP) { + case 8: + if (pal==NULL) { + red = 0; + green = 0; + blue = 0; + return; + } + if (colour>255) colour &= 255; + red = pal[colour].red; + green = pal[colour].green; + blue = pal[colour].blue; + break; + case 15: + case 16: + red = ((colour >> redFieldPosition) << redShifter); + green = ((colour >> greenFieldPosition) << greenShifter); + blue = ((colour >> blueFieldPosition) << blueShifter); + if ((red) && (redShifter)) red+=(1 << redShifter)-1; + if ((green) && (greenShifter)) green+=(1 << greenShifter)-1; + if ((blue) && (blueShifter)) blue+=(1 << blueShifter)-1; + break; + case 24: + case 32: + red = colour >> redFieldPosition; + green = colour >> greenFieldPosition; + blue = colour >> blueFieldPosition; + break; + default: + red = 0; + green = 0; + blue = 0; + } + return; +} // ogSurface::ogUnpackRGB + +void +ogSurface::ogVFlip(void) { + if (!ogAvail()) return; +// if ((buffer==NULL) || (lineOfs==NULL)) return; + switch (BPP) { + case 8: + __asm__ __volatile__( + " add %%edi, %%esi \n" // add esi, edi + "vf8lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf8lop2: \n" + " mov (%%edi),%%al \n" // mov al, [edi] + " mov (%%esi),%%ah \n" // mov ah, [esi] + " mov %%al,(%%esi) \n" // mov [esi], al + " mov %%ah,(%%edi) \n" // mov [edi], ah + " inc %%edi \n" // inc edi + " dec %%esi \n" // dec esi + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf8lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " dec %%edx \n" + " jnz vf8lop \n" + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX), // %0, %1 + "b" (xRes), "d" (maxY+1) // %2, %3 + ); + break; + case 15: + case 16: + __asm__ __volatile__( + " add %%edi, %%esi \n" // add esi, edi + "vf16lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf16lop2: \n" + " mov (%%edi),%%ax \n" // mov ax, [edi] + " mov (%%esi),%%cx \n" // mov cx, [esi] + " mov %%ax,(%%esi) \n" // mov [esi], ax + " mov %%cx,(%%edi) \n" // mov [edi], cx + " add $2, %%edi \n" // add edi, 2 + " sub $2, %%esi \n" // sub esi, 2 + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf16lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " dec %%edx \n" + " jnz vf16lop \n" + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*2), // %0, %1 + "b" (xRes), "d" (maxY+1) // %2, %3 + ); + break; + case 24: + __asm__ __volatile__( + " add %%edi, %%esi \n" // add esi, edi + "vf24lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf24lop2: \n" + " mov (%%edi),%%ax \n" // mov ax, [edi] + " mov 2(%%edi),%%dl \n" // mov dl, [edi+2] + " mov (%%esi),%%cx \n" // mov cx, [esi] + " mov 2(%%esi),%%dh \n" // mov dh, [esi+2] + " mov %%ax,(%%esi) \n" // mov [esi], ax + " mov %%dl,2(%%esi) \n" // mov [esi+2], dl + " mov %%cx,(%%edi) \n" // mov [edi], cx + " mov %%dh,2(%%edi) \n" // mov [edi+2], dh + " add $3, %%edi \n" // add edi, 3 + " sub $3, %%esi \n" // sub esi, 3 + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf24lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " decl %3 \n" // dec height + " jnz vf24lop \n" + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*3), // %0, %1 + "b" (xRes), "m" (maxY+1) // %2, %3 + ); + break; + + case 32: + __asm__ __volatile__( + " add %%edi, %%esi \n" // add esi, edi + "vf32lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf32lop2: \n" + " mov (%%edi),%%eax \n" // mov eax, [edi] + " mov (%%esi),%%ecx \n" // mov ecx, [esi] + " mov %%eax,(%%esi) \n" // mov [esi], eax + " mov %%ecx,(%%edi) \n" // mov [edi], ecx + " add $4, %%edi \n" // add edi, 4 + " sub $4, %%esi \n" // sub esi, 4 + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf32lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " dec %%edx \n" + " jnz vf32lop \n" + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*4), // %0, %1 + "b" (xRes), "d" (maxY+1) // %2, %3 + ); + + } // switch + return; +} // ogSurface::ogVFlip + +void +ogSurface::ogVLine(int32 x, int32 y1, int32 y2, uInt32 colour) { + int32 tmp; + if (!ogAvail()) return; + if ((uInt32)x>maxX) return; + if (y1>y2) { + tmp= y1; + y1 = y2; + y2 = tmp; + } // if + if (y1<0) y1 = 0; + if (y2>(int32)maxY) y2 = maxY; + if (y2 +#include +#include + +struct devFsDevices { + struct devFsDevices *next; + struct devFsDevices *prev; + uInt8 devType; + uInt16 devMajor; + uInt16 devMinor; + char devName[32]; + }; + +struct devFsInfo { + struct devFsDevices *deviceList; + }; + +int openFileDevFS(char *file,fileDescriptor *fd); +void initDevFS(struct mountPoints *mp); +int enableDevFS(); +int readDevFS(fileDescriptor *fd,char *data,long offset,long size); +int writeDevFS(fileDescriptor *fd,char *data,long offset,long size); +int devFsMkNod(char *name,uInt8 type,uInt16 major,uInt16 minor); + +#endif diff --git a/lockwasher/src/sys/include/deviceman/bus.h b/lockwasher/src/sys/include/deviceman/bus.h new file mode 100644 index 0000000..b5384dd --- /dev/null +++ b/lockwasher/src/sys/include/deviceman/bus.h @@ -0,0 +1,20 @@ +/* + "bus.h" + + created by: grayspace aka J. Leveille + for: UbixOS Project + date: May 11, 2002 + + purpose: master header file for all things BUS related + + $Id: bus.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $ +*/ + +#ifndef _BUS_H +#define _BUS_H + +#include "bus_resources.h" + + + +#endif /* _BUS_H */ \ No newline at end of file diff --git a/lockwasher/src/sys/include/deviceman/bus_resources.h b/lockwasher/src/sys/include/deviceman/bus_resources.h new file mode 100644 index 0000000..9485941 --- /dev/null +++ b/lockwasher/src/sys/include/deviceman/bus_resources.h @@ -0,0 +1,266 @@ +/* + "bus_resources.h" + + created by: grayspace aka J. Leveille + for: UbixOS Project + date: May 12, 2002 + + purpose: master header file for bus resource management + + $Id: bus_resources.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $ +*/ + +#ifndef _BUS_RESOURCES_H +#define _BUS_RESOURCES_H + +/* Intel 32-bit architecture */ +#if TCPU_IA32 + +/* DMA channels */ +#define MIN_DMA_CHANNEL (0) +#define MAX_DMA_CHANNEL (7) +#define NUM_DMA_CHANNELS (MAX_DMA_CHANNEL - MIN_DMA_CHANNEL - 1) + +/* IRQs */ +#define MIN_IRQ (0) +#define MAX_IRQ (15) +#define NUM_IRQS (MAX_IRQ - MIN_IRQ - 1) + +/* Port IO Range */ +#define MIN_PORTIO_ADDR (0) +#define MAX_PORTIO_ADDR (1023) +#define MAXBITS_PORTIO_ADDR (10) + +/* Memory Range */ +#define MIN_MEMIO_ADDR (0) +#define MAX_MEMIO_ADDR (0xFFFFFFFF) +#define MAXBITS_MEMIO_ADDR (32) + +/* NOTE: 'BI_' denotes roughly something related to BUS info */ + +/* for building/use-with device-info/bus-resource-info structures */ +#define BI_NUMBITS_IRQS (4) +#define BI_NUMBITS_DMA_CHANNELS (3) +#define BI_IRQ_BIT (0) +#define BI_DMA_CHANNEL_BIT (BI_IRQ_BIT + BI_NUMBITS_IRQS) + +#define BI_IRQ_MASK\ + MAKEMASK_GS( BI_NUMBITS_IRQS, BI_IRQ_BIT ) +#define BI_DMA_CHANNEL_MASK\ + MAKEMASK_GS( BI_NUMBITS_DMA_CHANNELS, BI_DMA_CHANNEL_BIT ) + +#define BI_NUMBITS_PORTIO_BASEADDR (16) +#define BI_NUMBITS_PORTIO_OVERADDR (16) +#define BI_PORTIO_BASEADDR_BIT (0) +#define BI_PORTIO_OVERADDR_BIT ( BI_PORTIO_BASEADDR_BIT\ + + BI_NUMBITS_PORTIO_BASEADDR ) +#define BI_PORTIO_BASEADDR_MASK\ + MAKEMASK_GS( BI_NUMBITS_PORTIO_BASEADDR, BI_PORTIO_BASEADDR_BIT ) +#define BI_PORTIO_OVERADDR_MASK\ + MAKEMASK_GS( BI_NUMBITS_PORTIO_OVERADDR, BI_PORTIO_OVERADDR_BIT ) + +/* maximum number of DMAs and IRQs a device can use + NOTE: *must* be same */ +#define BI_MAX_DMAANDIRQS (2) +#define BI_MAX_DMAS (BI_MAX_DMAANDIRQS) +#define BI_MAX_IRQS (BI_MAX_DMAANDIRQS) + +/* maximum number of Port IO ranges a device can use */ +#define BI_MAX_PORTIO_RANGES (4) + +/* maximum number of Memory IO ranges a device can use */ +#define BI_MAX_MEMIO_RANGES (4) + +/* structure for storing a device's bus resources */ +typedef struct tagBUS_RESOURCES +{ + /* DMA and IRQ info */ + BYTEg a_dmairq[BI_MAX_DMAANDIRQS]; + + /* + bits [0,1] number of IRQs used + bits [2,3] number of DMA channels used + bits [4,7] number of port IO ranges used + */ + BYTEg resource_counts1; + + /* + bits [0,3] number of memory ranges used + bits [4,7] ??? + */ + BYTEg resource_counts2; + + /* Port IO Ranges */ + DWORDg a_portiorange[BI_MAX_PORTIO_RANGES]; + + /* Memory IO Ranges */ + DWORDg a_memiorange_base[BI_MAX_MEMIO_RANGES]; + DWORDg a_memiorange_last[BI_MAX_MEMIO_RANGES]; +} +BUS_RESOURCES; + +/* NOTE: 'BUS_RES' denotes interface functions/macros on + the 'BUS_RESOURCES' structure */ + +#if (BI_IRQ_BIT == 0) + /* get IRQ 'idx' from resource description 'br' */ + #define BUS_RES_GETIRQ( br, idx ) ((br).a_dmairq[(idx)]&BI_IRQ_MASK) + + /* set IRQ 'idx' in resource description 'br' to 'irq' */ + #define BUS_RES_SETIRQ( br, idx, irq )\ + (br).a_dmairq[(idx)] &= BI_IRQ_MASK;\ + (br).a_dmairq[(idx)] |= (irq) +#else + /* get IRQ 'idx' from resource description 'br' */ + #define BUS_RES_GETIRQ( br, idx )\ + GETBITVAL_GS( (br).a_dmairq[(idx)], BI_IRQ_MASK, BI_IRQ_BIT ) + + /* set IRQ 'idx' in resource description 'br' to 'irq' */ + #define BUS_RES_SETIRQ( br, idx, irq )\ + SETBITVAL_FAST_GS( (br).a_dmairq[(idx)],\ + BI_IRQ_MASK,\ + BI_IRQ_BIT,\ + (irq) ) +#endif + +/* get DMA 'idx' from resource description 'br' */ +#define BUS_RES_GETDMA( br, idx )\ + GETBITVAL_GS( (br).a_dmairq[(idx)], BI_DMA_MASK, BI_DMA_BIT ) + +/* set DMA 'idx' in resource description 'br' to 'dma' */ +#define BUS_RES_SETDMA( br, idx, dma )\ + SETBITVAL_FAST_GS( (br).a_dmairq[(idx)],\ + BI_DMA_MASK,\ + BI_DMA_BIT,\ + (dma) ) + +#if (BI_PORTIO_BASEADDR_BIT == 0) && (BI_PORTIO_OVERADDR_BIT == BI_NUMBITS_PORTIO_BASEADDR ) + /* get port IO base address 'idx' from resource description 'br' */ + #define BUS_RES_GETPORTIOBASE( br, idx )\ + ((br).a_portiorange[(idx)]&BI_PORTIO_BASEADDR_MASK) + + /* get port IO 'over' address 'idx' from resource description 'br' */ + #define BUS_RES_GETPORTIOOVER( br, idx )\ + ((br).a_portiorange[(idx)]>>BI_PORTIO_OVERADDR_BIT) + + /* get port IO range 'idx' from resource description 'br' + into 'baseaddr_o' and 'overaddr_o' */ + #define BUS_RES_GETPORTIORANGE( br, idx, baseaddr_o, overaddr_o )\ + (baseaddr_o)\ + = ((br).a_portiorange[(idx)] & BI_PORTIO_BASEADDR_MASK);\ + (overaddr_o)\ + = ((br).a_portiorange[(idx)] >> BI_PORTIO_OVERADDR_BIT) + + /* set port IO range 'idx' in resource description 'br' + to 'baseaddr' and 'overaddr' */ + #define BUS_RES_SETPORTIORANGE( br, idx, baseaddr, overaddr )\ + ((br).a_portiorange[(idx)]\ + = ((overaddr)<>2) +/* set number of IRQs used/assigned-to device */ +#define BUS_RES_SETIRQSUSED( br, irqsused )\ + (br).resource_counts1 &= ~0x0C;\ + (br).resource_counts1 |= ((irqsused)<<2) + +/* get number of DMAs used/assigned-to device */ +#define BUS_RES_GETDMASUSED( br )\ + ((br).resource_counts1 & 3) +/* set number of DMAs used/assigned-to device */ +#define BUS_RES_SETDMASUSED( br, dmasused )\ + (br).resource_counts1 &= ~3;\ + (br).resource_counts1 |= (dmasused) + +/* get number of port IO ranges used/assigned-to device */ +#define BUS_RES_GETPORTIORANGESUSED( br )\ + (((br).resource_counts1)>>4) +/* get number of port IO ranges used/assigned-to device */ +#define BUS_RES_SETPORTIORANGESUSED( br, rangesused )\ + (br).resource_counts1 &= 0x0F;\ + (br).resource_counts1 |= ((rangesused)<<4) + +/* get number of port IO ranges used/assigned-to device */ +#define BUS_RES_GETMEMIORANGESUSED( br )\ + (((br).resource_counts2) & 0x0F) +/* get number of port IO ranges used/assigned-to device */ +#define BUS_RES_SETMEMIORANGESUSED( br, rangesused )\ + (br).resource_counts2 &= 0xF0;\ + (br).resource_counts2 |= (rangesused) + +#else /* #if TCPU_IA32 */ + +#error unknown target CPU!!! + +#endif /* #if TCPU_??? */ + +#include "bus_resources_portio.h" + +#endif /* _BUS_RESOURCES_H */ \ No newline at end of file diff --git a/lockwasher/src/sys/include/deviceman/bus_resources_portio.h b/lockwasher/src/sys/include/deviceman/bus_resources_portio.h new file mode 100644 index 0000000..82d417d --- /dev/null +++ b/lockwasher/src/sys/include/deviceman/bus_resources_portio.h @@ -0,0 +1,47 @@ +/* + "bus_resources_portio.h" + + created by: grayspace aka J. Leveille + for: UbixOS Project + date: May 12, 2002 + + purpose: for port IO resource management + + $Id: bus_resources_portio.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $ +*/ + +#ifndef _BUS_RESOURCES_PORTIO_H +#define _BUS_RESOURCES_PORTIO_H + +/* for managing port IO ranges */ +typedef struct tagBUS_PORTIO_POOL +{ + DWORDg a_addrs[(1<<(MAXBITS_PORTIO_ADDR-5))]; +} +BUS_PORTIO_POOL; + +/* checks a range of port addresses + returns: + - 1 if the range is comptetely empty + - 0 otherwise */ +int BUS_PORTIO_CheckRange( BUS_PORTIO_POOL * p_bpp, + DWORDg baseaddr, + DWORDg overaddr ); + +/* allocates a range of port addresses + returns: + - 1 on success + - 0 on failure */ +int BUS_PORTIO_AllocateRange( BUS_PORTIO_POOL * p_bpp, + DWORDg baseaddr, + DWORDg overaddr ); + +/* frees a range of port addresses + returns: + - 1 if any port addresses in the range were allocated + - 0 otherwise */ +int BUS_PORTIO_FreeRange( BUS_PORTIO_POOL * p_bpp, + DWORDg baseaddr, + DWORDg overaddr ); + +#endif /* _BUS_RESOURCES_PORTIO_H */ \ No newline at end of file diff --git a/lockwasher/src/sys/include/deviceman/device.h b/lockwasher/src/sys/include/deviceman/device.h new file mode 100644 index 0000000..19dd403 --- /dev/null +++ b/lockwasher/src/sys/include/deviceman/device.h @@ -0,0 +1,114 @@ +/* + "device.h" + + created by: grayspace aka J. Leveille + for: UbixOS Project + date: May 11, 2002 + + purpose: master header file for all things device related + + $Id: device.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $ +*/ + +#ifndef _DEVICE_H +#define _DEVICE_H + +// maximum length of a device's name +#define MAX_DEVICE_NAMELEN (16) + +// maximum number of bus devices allowed +#define MAX_BUS_DEVICES (16) + +/* device types (for now, only bus devices allowed) */ +#define DEVICE_TYPE_UNKNOWN (0) +#define DEVICE_TYPE_BUS_ISA (1) +#define DEVICE_TYPE_BUS_PCI (2) + +/* device classes */ +#define DEVICE_CLASS_GENERIC (0) +#define DEVICE_CLASS_SOUND_DAC (1) +#define DEVICE_CLASS_VIDEO (2) +#define DEVICE_CLASS_NIC (3) +#define DEVICE_CLASS_DISK_CTLR (4) +#define DEVICE_CLASS_DISK (5) + +/* string names for devices classes + (for use in device list configuration files) */ +#define DEVICE_CLASS_GENERIC_IDSTR "GENERIC" +#define DEVICE_CLASS_SOUND_DAC_IDSTR "SOUND_DAC" +#define DEVICE_CLASS_VIDEO_IDSTR "VIDEO" +#define DEVICE_CLASS_NIC_IDSTR "NIC" +#define DEVICE_CLASS_DISK_CTLR_IDSTR "DISK_CTLR" +#define DEVICE_CLASS_DISK_IDSTR "DISK" + +/* string names for devices classes + (for display to the user) */ +#define DEVICE_CLASS_GENERIC_NAME "Generic Device" +#define DEVICE_CLASS_SOUND_DAC_NAME "Sound (Digital-Ananlog Output)" +#define DEVICE_CLASS_VIDEO_NAME "Video Card" +#define DEVICE_CLASS_NIC_NAME "Network Card" +#define DEVICE_CLASS_DISK_CTLR_NAME "Disk Controller" +#define DEVICE_CLASS_DISK_NAME "Disk Device" + +/* device ISR or pseudo ISR */ +typedef int (* DEVICE_ISR)( void * p ); + +/* device IO routine */ +typedef int (* DEVICE_IO_RTN)( void * p ); + +/* device control routine */ +typedef int (* DEVICE_CTRL_RTN)( void * p ); + +/* ISA bus device structure */ +typedef struct tagDEVICE_ISA +{ + /* bus resources assigned to device */ + BUS_RESOURCES br; + + /* ISRs for device */ + DEVICE_ISR * apfn_isr[BI_MAX_IRQS]; + + /* device IO routine (kernel/driver use only) */ + DEVICE_IO_RTN pfn_io; + + /* device control routine (kernel/driver use only) */ + DEVICE_CTRL_RTN pfn_ctrl; +} +DEVICE_BUS_ISA; + +/* PCI bus device structure */ +/* TODO */ +typedef struct tagDEVICE_BUS_PCI +{ + int dummy; +} +DEVICE_BUS_PCI; + +/* bus device structure */ +typedef union tagDEVICE_BUS +{ + DEVICE_BUS_ISA isa; + DEVICE_BUS_PCI pci; +} +DEVICE_BUS; + +/* device structure */ +typedef struct tagDEVICE +{ + /* type of device */ + BYTEg type; + + /* pointer to actual device specific structure */ + void * p; +} +DEVICE; + +/* global kernel structure for device information */ +typedef struct tagDEVICES +{ + /* bus devices */ + DEVICE a_isa[MAX_BUS_DEVICES]; +} +DEVICES; + +#endif /* _DEVICE_H */ \ No newline at end of file diff --git a/lockwasher/src/sys/include/deviceman/isapnp.h b/lockwasher/src/sys/include/deviceman/isapnp.h new file mode 100644 index 0000000..a1fea0f --- /dev/null +++ b/lockwasher/src/sys/include/deviceman/isapnp.h @@ -0,0 +1,86 @@ +/* + "isapnp.h" + + created by: grayspace aka J. Leveille + for: UbixOS Project + date: May 12, 2002 + + Purpose: ISA PNP support + + $Id: isapnp.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $ +*/ + +#ifndef _ISAPNP_H +#define _ISAPNP_H + +#include "misc_string_conv.h" + +/* structure for holding an ISA-PNP device ID */ +typedef struct tagISAPNP_ID +{ + WORDg text; + BYTEg a_hex[2]; +} +ISAPNP_ID; + +/* structure for holding configuration file info about a + particular ISA-PNP device */ +typedef struct tagISAPNP_DEV_INFO +{ + /* 'class' of device */ + BYTEg devclass; + + /* device ID */ + ISAPNP_ID id; + + /* kernal string ID of description */ + DWORDg descID; +} +ISAPNP_DEV_INFO; + +/* structure for holding device info database + NOTE: should be sorted by 'id' */ +typedef struct tagISAPNP_DEV_INFO_DB +{ + // pointer to infos + ISAPNP_DEV_INFO * p_infos; + + // number of infos + int numinfos; +} +ISAPNP_DEV_INFO_DB; + +/* fill a 'ISAPNP_ID' struct from four bytes assumed to be in little endian + format */ +#define ISAPNP_ID_FROMBYTES( dst_id, p_bytes )\ + (dst_id).text = (WORDg) (((DWORDg) (p_bytes)[1])<<8);\ + (dst_id).text |= (WORDg) (p_bytes)[1] + +/* + NOTE: + - in 'id.text' + - bits [10,14] are first character - 64 + - bits [5,9] are second character - 64 + - bits [0,4] are third character - 64 +*/ +#define ISAPNP_ID_GETSTRING( p_dststr, id )\ + (p_dststr)[0] = (((id).text >> 10)&0x1F) + 64;\ + (p_dststr)[1] = (((id).text >> 5)&0x1F) + 64;\ + (p_dststr)[2] = ((id).text&0x1F) + 64;\ + HEX_GETSTRING_BYTE_NONULL( p_dst_str + 3, (id).a_hex[1] );\ + HEX_GETSTRING_BYTE( p_dst_str + 5, (id).a_hex[0] ) + +#define ACCESS_FUNC_PORT "movl %edx, $0x279\n\t" +#define ACCESS_DATA_PORT "movl %edx, $0x2A9\n\t" +#define FUNC_SETREADPORT "movb $0x00, %al\n\toutb %dx, %al\n\t" +#define FUNC_ISOLATION "movb $0x01, %al\n\toutb %dx, %al\n\t" +#define FUNC_CONFIGCONTROL "movb $0x02, %al\n\toutb %dx, %al\n\t" +#define FUNC_WAKEUP "movb $0x03, %al\n\toutb %dx, %al\n\t" +#define FUNC_RESOURCEDATA "movb $0x04, %al\n\toutb %dx, %al\n\t" +#define FUNC_STATUS "movb $0x05, %al\n\toutb %dx, %al\n\t" +#define FUNC_SETCARDNUM "movb $0x06, %al\n\toutb %dx, %al\n\t" +#define FUNC_SETDEVICENUM "movb $0x07, %al\n\toutb %dx, %al\n\t" +#define FUNC_ACTIVATEADDR "movb $0x1E, %al\n\toutb %dx, %al\n\t" +#define FUNC_IORANGECHECK "movb $0x1F, %al\n\toutb %dx, %al\n\t" + +#endif // _ISAPNP_H \ No newline at end of file diff --git a/lockwasher/src/sys/include/isa/8259.h b/lockwasher/src/sys/include/isa/8259.h new file mode 100644 index 0000000..8ee2ae5 --- /dev/null +++ b/lockwasher/src/sys/include/isa/8259.h @@ -0,0 +1,44 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: 8259.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#ifndef _8259_H +#define _8259_H + +#define mPic 0x20 /* I/O for master PIC */ +#define mImr 0x21 /* I/O for master IMR */ +#define sPic 0xA0 /* I/O for slave PIC */ +#define sImr 0xA1 /* I/O for slace IMR */ +#define eoi 0x20 /* EOI command */ +#define icw1 0x11 /* Cascade, Edge triggered */ +#define icw4 0x01 /* 8088 mode */ +#define mVec 0x68 /* Vector for master */ +#define sVec 0x70 /* Vector for slave */ +#define ocw3Irr 0x0A /* Read IRR */ +#define ocw3Isr 0x0B /* Read ISR */ + +void init8259(); +void enableIrq(unsigned short irqNo); +void disableIrq(unsigned short irqNo); + +#endif + diff --git a/lockwasher/src/sys/include/isa/atkbd.h b/lockwasher/src/sys/include/isa/atkbd.h new file mode 100644 index 0000000..ceeda4e --- /dev/null +++ b/lockwasher/src/sys/include/isa/atkbd.h @@ -0,0 +1,40 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: atkbd.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#ifndef _KEYBOARD_H +#define _KEYBOARD_H + +#define shiftKey 1 +#define controlKey 2 +#define altKey 4 +#define ledNumlock 2 +#define ledScrolllock 1 +#define ledCapslock 4 + +void initKeyboard(); +void keyboardIsr(); +void keyboardHandler(); +void setLeds(); + +#endif + diff --git a/lockwasher/src/sys/include/isa/fdc.h b/lockwasher/src/sys/include/isa/fdc.h new file mode 100644 index 0000000..58e34cf --- /dev/null +++ b/lockwasher/src/sys/include/isa/fdc.h @@ -0,0 +1,79 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fdc.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#ifndef _FDC_H +#define _FDC_H + +#include + +typedef struct DrvGeom { + byte heads; + byte tracks; + byte spt; +} drvGeom; + + +#define fdcMsr (0x3f4) +#define fdcData (0x3f5) +#define fdcDir (0x3f7) +#define fdcCcr (0x3f7) +#define fdcDor (0x3f2) +#define fdcDrs (0x3f4) + +#define cmdWrite (0xc5) +#define cmdRead (0xe6) +#define cmdSeek (0x0f) +#define cmdSensei (0x08) +#define cmdRecal (0x07) +#define cmdSpecify (0x03) + +#define dg144Heads 2 /* heads per drive (1.44M) */ +#define dg144Tracks 80 +#define dg144Spt 18 +#define dg144Gap3rw 0x1b +#define dg168Gap3rw 0x1c + + + +void initFloppy(); +void floppyIsr(); +void floppyIsrhndlr(); +void sendByte(int byte); +int getByte(); +bool fdcRw(int block,byte *blockBuffer,bool read,unsigned long numSectors); +void block2Hts(int block,int *head,int *track,int *sector); +void motorOn(void); +void motorOff(void); +bool seek(int track); +bool waitFdc(bool sensei); +int getByte(); +void sendByte(int byte); +void recalibrate(void); +void reset(void); +bool writeBlock(int block,byte *blockBuffer, unsigned long numSectors); +bool readBlock(int block,byte *blockBuffer, unsigned long numSectors); +void fdcWrite(void *info,long startSector,long sectorCount,void *baseAddr); +void fdcRead(void *info,long startSector,long sectorCount,void *baseAddr); + +#endif + diff --git a/lockwasher/src/sys/include/isa/pit.h b/lockwasher/src/sys/include/isa/pit.h new file mode 100644 index 0000000..13e5158 --- /dev/null +++ b/lockwasher/src/sys/include/isa/pit.h @@ -0,0 +1 @@ +void initPIT(int); diff --git a/lockwasher/src/sys/include/ld/ld.h b/lockwasher/src/sys/include/ld/ld.h new file mode 100644 index 0000000..d6d65c5 --- /dev/null +++ b/lockwasher/src/sys/include/ld/ld.h @@ -0,0 +1,38 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: ld.h,v 1.2 2003/05/07 05:03:37 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _LD_H +#define _LD_H + +#include + +typedef struct sharedLibS { + struct sharedLibS *next; + struct sharedLibS *prev; + void *baseAddr; + } sharedLib; + +void ld(); +void loadLibrary(char *); + +#endif \ No newline at end of file diff --git a/lockwasher/src/sys/include/lib/Alloc.h b/lockwasher/src/sys/include/lib/Alloc.h new file mode 100644 index 0000000..de924dc --- /dev/null +++ b/lockwasher/src/sys/include/lib/Alloc.h @@ -0,0 +1,65 @@ +#ifndef __CPP_ALLOC_H +#define __CPP_ALLOC_H + +#ifdef __cplusplus + +#include + +class Alloc +{ + protected: + int alloc_size; + + uint8_t flags; + void * chunks[8]; + + public: + Alloc(); + Alloc(int); + ~Alloc(); + + void setSize(int); + void * allocate(); + void deallocate(void *); + + private: + void clear(); + +}; + +/* +Alloc::Alloc() { + alloc_size = 0; + flags = 0x0; + for (int i = 0; i < 8; i++) + chunks[i] = (void *) 0x0; + }; + +Alloc::Alloc(int size) { + Alloc(); + alloc_size = size; + }; + +Alloc::~Alloc() { clear(); } +void Alloc::setSize(int size) { clear(); alloc_size = size; } + +void * Alloc::allocate() { + if (0 == alloc_size) + return NULL; + return kmalloc(alloc_size,-2); +}; + +void Alloc::deallocate(void * ptr) { + kfree(ptr); +}; + +void Alloc::clear() { return; }; +*/ + + + + + +#endif + +#endif diff --git a/lockwasher/src/sys/include/lib/Pair.h b/lockwasher/src/sys/include/lib/Pair.h new file mode 100644 index 0000000..389d783 --- /dev/null +++ b/lockwasher/src/sys/include/lib/Pair.h @@ -0,0 +1,40 @@ +#ifndef __CPP_PAIR_H +#define __CPP_PAIR_H + +#ifdef __cplusplus + +#include + +template class Pair +{ + protected: + A a; + B b; + + public: + Pair() : a(), b() { }; + Pair(const A & _a, const B & _b) : a(_a), b(_b) { }; + + ~Pair() { }; + + inline A & first() { return a; }; + inline B & second() { return b; }; + + Pair & operator= (const Pair & right) { + this->first() = right.a; + this->second() = right.b; + + return *this; + } + + operator B() const + { + return b; + } +}; + + + +#endif + +#endif diff --git a/lockwasher/src/sys/include/lib/Queue.h b/lockwasher/src/sys/include/lib/Queue.h new file mode 100644 index 0000000..c6285b0 --- /dev/null +++ b/lockwasher/src/sys/include/lib/Queue.h @@ -0,0 +1,221 @@ +#ifndef __CPP_QUEUE_H +#define __CPP_QUEUE_H + +#ifdef __cplusplus + +#include +#include +#include + +template class Queue +{ + public: + + class Pair; + + Queue(); + ~Queue(); + + void insert(const int, const T &); + void insert(Pair & a) { insert(a.first(), a.second()); }; + const Pair find(const int) const; + const T remove(const int); + const T remove(); + const T top(); + const Pair pop(); + void empty(); + int size(); + + + + private: + class Node + { + public: + Node() : index(-1), prev(NULL), next(NULL), data() {}; + + int index; + Node * prev; + Node * next; + T data; + }; + + Node * first; + Node * last; + int sz; + + Alloc allocator; + +}; + +template Queue::Queue() : first(NULL), last(NULL), sz(0) + { allocator.setSize(sizeof(Node)); }; +template Queue::~Queue() { while(first != NULL) this->pop(); }; + +template +void Queue::insert(const int a, const T & b) +{ + Node * temp = (Node *) allocator.allocate(); + temp->index = a; + temp->data = b; + + temp->next = first; + + if (NULL == last) + this->last = temp; + else + this->first->prev = temp; + + this->first = temp; + + sz++; + +} + +template +const Pair Queue::find(const int a) const { + + T item = T(); + bool found = false; + Node * temp = first; + + while ((NULL != temp) && !found) + { + if (a == temp->index) + { + item = temp->data; + found = true; + } + + temp = temp->next; + } + + if (found) + return Pair(a,item); + else + return Pair(-1,item); +} + +template +const T Queue::remove(const int a) { + + T item = T(); + bool found = false; + Node * temp = first; + + while ((NULL != temp) && !found) + { + if (a == temp->index) + { + item = temp->data; + found = true; + + if (NULL != temp->prev) + temp->prev->next = temp->next; + if (NULL != temp->next) + temp->next->prev = temp->prev; + if (temp == first) + first = temp->next; + if (temp == last) + last = temp->prev; + + allocator.deallocate(temp); + temp = NULL; + + sz--; + } + + temp = temp->next; + } + + return item; +} + +template +const T Queue::remove() +{ + T item = T(); + Node * temp; + + if (NULL != last) + { + item = last->data; + + if (NULL != last->prev) + { + last->prev->next = NULL; + temp = last; + last = last->prev; + + delete temp; + } + else + { + temp = last; + first = last = NULL; + delete temp; + } + sz--; + } + + return item; +} + +template +const T Queue::top() +{ + T item = T(); + if (NULL != last) + { + item = last->data; + } + return item; +} + +template +const Pair Queue::pop() +{ + T item = T(); + int index; + bool found = false; + Node * temp; + + if (NULL != first) + { + item = first->data; + index = first->index; + found = true; + + if (NULL != first->next) + { + temp = first; + first = first->next; + first->prev = NULL; + + delete temp; + } + else + { + temp = last; + first = last = NULL; + delete temp; + } + sz--; + } + + + if (found) + return Pair(index, item); + else + return Pair(-1, item); +} + + +template +void Queue::empty() { while (last != NULL) pop(); } + +template +int Queue::size() { return sz; } +#endif + +#endif // __QUEUE_H diff --git a/lockwasher/src/sys/include/lib/bioscall.h b/lockwasher/src/sys/include/lib/bioscall.h new file mode 100644 index 0000000..d85f5d2 --- /dev/null +++ b/lockwasher/src/sys/include/lib/bioscall.h @@ -0,0 +1,9 @@ +#include + +#define EFLAG_TF 0x100 +#define EFLAG_IF 0x200 +#define EFLAG_IOPL3 0x3000 +#define EFLAG_VM 0x20000 + +int biosCall(int biosInt,int eax,int ebx,int ecx,int edx,int esi,int edi,int es,int ds); +void bios16Code(); \ No newline at end of file diff --git a/lockwasher/src/sys/include/lib/kmalloc.h b/lockwasher/src/sys/include/lib/kmalloc.h new file mode 100644 index 0000000..0cec0df --- /dev/null +++ b/lockwasher/src/sys/include/lib/kmalloc.h @@ -0,0 +1,62 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: kmalloc.h,v 1.11 2003/04/23 23:08:19 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _KMALLOC_H +#define _KMALLOC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct memDescriptor { + struct memDescriptor *prev; //4 + struct memDescriptor *next; //4 + void *baseAddr; //4 + uInt32 limit; //4 + uInt8 status; //1 + pidType pid; //4 + char reserved[11]; //11 + }; + +void kfree(void *baseAddr); +void *kmalloc(uInt32 len,pidType pid); +void initMalloc(pidType pid); +void *getEmptyDesc(); +void insertFreeDesc(struct memDescriptor *freeDesc); +void mergeMemBlocks(); +void kfreeProcess(pidType pid); + +extern struct memDescriptor *kernDesc; +extern struct memDescriptor *freeKernDesc; +extern struct memDescriptor *emptyKernDesc; + +extern int mallocLock; + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/lockwasher/src/sys/include/lib/string.h b/lockwasher/src/sys/include/lib/string.h new file mode 100644 index 0000000..7491c2e --- /dev/null +++ b/lockwasher/src/sys/include/lib/string.h @@ -0,0 +1,49 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: string.h,v 1.7 2003/04/23 23:08:19 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _STRING_H +#define _STRING_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int kstrcmp(char *str1, char *str2); +int kstrncmp(const char * a, const char * b, size_t c); +void *kmemcpy(void * dst, const void * src, size_t length); +void *kmemset(void * dst, int c, size_t length); +int kstrlen(const char * string); +int kmemcmp(const void * dst, const void * src, size_t length); +void kstrncpy(char * dest, const char * src, size_t size); +char *strtok(char *str, const char *sep); +char *strtok_r(char *str, const char *sep, char **last); + +int sprintf(char *buf,const char *fmt, ...); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lockwasher/src/sys/include/math.h b/lockwasher/src/sys/include/math.h new file mode 100644 index 0000000..49afd00 --- /dev/null +++ b/lockwasher/src/sys/include/math.h @@ -0,0 +1,12 @@ +#ifndef __MATH_H +#define __MATH_H + +typedef long long int quad_t; +typedef unsigned long long int u_quad_t; + +double atan(double x); +double sqrt(double x); +u_quad_t __udivdi3(u_quad_t a,u_quad_t b); +quad_t __divdi3(quad_t a,quad_t b); + +#endif diff --git a/lockwasher/src/sys/include/misc/kernel_string_pool.h b/lockwasher/src/sys/include/misc/kernel_string_pool.h new file mode 100644 index 0000000..29585af --- /dev/null +++ b/lockwasher/src/sys/include/misc/kernel_string_pool.h @@ -0,0 +1,113 @@ +/* + "kernel_string_pool.h" + + created by: grayspace aka J. Leveille + for: UbixOS Project + date: May 11, 2002 + + purpose: to provide a mechanism for maintaining a pool of strings + for use by the kernel without unnecessary waste of memory + + NOTEs: + - for now only ASCII is supported + - done quickly, pretty hacky + + TODO: + - expand to support unicode + - use huffman encoding instead + + $Id: kernel_string_pool.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $ +*/ + +#ifndef _KERNEL_STRING_POOL_H +#define _KERNEL_STRING_POOL_H + +/* memory FORMAT of a 'KRNSTR': (quick and dirty for now) + + an 'ID' is used to indicate a string within the pool + ---------------------------------------------------- + + 'ID' - [DWORD]: + - BYTE offset inside pool where the 'KRNSTR' + (kernel string) is stored + + 'KRNSTR's (kernel strings) are specified as an array of continuous BYTEs + ------------------------------------------------------------------------ + + 'KRNSTR': + - 'num-bytes' - [BYTE] + - total number of bytes in kernel string + - [KRNWORD] x ??? + - 'KRNWORD's follow for 'num-bytes' bytes + + 'KRNWORD': + - [BYTE] 'key1' + + - if key1 == [0,63]: + - key1 is the index of the 'sub-string' in the pool + + - otherwise + - if key1 has bit 7 set + - [BYTE] 'key2' + - [BYTE] 'key3' + - the index of the 'sub-string' in the pool is: + (key1&0x7F) * 65536 + + key2 * 256 + + key3 + - (index is in [16384,(2^23-1)] + + - otherwise + - [BYTE] 'key2' + - the index of the 'sub-string' in the pool is: + (key1&0x3F) * 256 + + key2 + - (index is in [64,16383]) + + - NOTE: the reason for using only extra 8-bit keys + is in case we port to platform with data alignment exceptions + and this stuff is left dormant and never changed + + - NOTE: a 'space' (0x20) is implied between each 'KRNWORD', therefore + it is not currently possible to break encode string AB into substrings + A & B if AB does not contain any spaces + + - a 'sub-string' is found by using the the index of the + 'sub-string' and scanning through the whole + substring pool (a little slow) + (lookup table was ditched to save memory) + + 'sub-string's are specified as an array of continuous BYTEs + ----------------------------------------------------------- + + - a 'sub-string' is as follows: + + - [BYTE] 'numchars' [0,255] -> [1,256] + - [BYTE] x 'numchars' (the chars themselves) + + - WARNING: empty 'sub-string's are not allowed + +*/ + +/* WARNING: it is *assumed* any 'ID' given to a kernel + string pool function will be valid!! */ + +/* structure for kernel string pool */ +typedef struct tagKSTR_POOL +{ + /* pointer to where the kernel strings are stored */ + const BYTEg * p_krnstrs; + + /* pointer to where the sub strings are stored */ + const BYTEg * p_substrs; +} +KSTR_POOL; + +/* the reason for this structure format is so that a tool + can be written which can generate a 'KSTR_POOL' from a configuration + file and place it into a 'C' source and header file pair as static data */ + +// gets the substring indicated by 'id' from the pool 'p_ksp' into 'p_dst' +// - returns pointer to 'p_dst' +char * KSTR_POOL_GetString( KSTR_POOL * p_ksp, char * p_dst, DWORDg id ); + +#endif /* _KERNEL_STRING_POOL_H */ \ No newline at end of file diff --git a/lockwasher/src/sys/include/misc/misc_bit_array.h b/lockwasher/src/sys/include/misc/misc_bit_array.h new file mode 100644 index 0000000..7c41701 --- /dev/null +++ b/lockwasher/src/sys/include/misc/misc_bit_array.h @@ -0,0 +1,46 @@ +/* + "misc_bit_array.h" + + created by: grayspace aka J. Leveille + for: UbixOS Project + date: May 12, 2002 + + purpose: functions for dealing with bit arrays + + $Id: misc_bit_array.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $ +*/ + +#ifndef _MISC_BIT_ARRAY_H +#define _MISC_BIT_ARRAY_H + +typedef struct tagBIT_ARRAY_RANGE_PARAMS +{ + DWORDg * p_curdw; + DWORDg * p_firstdw; + DWORDg * p_overdw; + DWORDg premask; + DWORDg postmask; +} +BIT_ARRAY_RANGE_PARAMS; + +// returns: +// - 1 if the given range of bits is empty +// - 0 otherwise +int BIT_ARRAY_IsRangeEmpty( BIT_ARRAY_RANGE_PARAMS * p_rp ); + +// set the given range of bits to all 1s +void BIT_ARRAY_SetRange( BIT_ARRAY_RANGE_PARAMS * p_rp ); + +// set the given range of bits to all 0s +void BIT_ARRAY_ResetRange( BIT_ARRAY_RANGE_PARAMS * p_rp ); + +// builds a structure for use with the other functions +#define BIT_ARRAY_MAKERANGEPARAMS( rp, p_basedw, firstbit, overbit )\ + (rp).premask = ((32-(firstbit))&31);\ + (rp).p_firstdw = (p_basedw) + ((firstbit)>>5);\ + (rp).postmask = ((overbit)&31);\ + (rp).p_overdw = (p_basedw) + ((overbit)>>5);\ + (rp).premask = MAKEMASK_GS( (rp).premask, (32 - (rp).premask) );\ + (rp).postmask = MAKEMASK_GS( (rp).postmask, 0 ) + +#endif // _MISC_BIT_ARRAY_H \ No newline at end of file diff --git a/lockwasher/src/sys/include/misc/misc_string_conv.h b/lockwasher/src/sys/include/misc/misc_string_conv.h new file mode 100644 index 0000000..944cca5 --- /dev/null +++ b/lockwasher/src/sys/include/misc/misc_string_conv.h @@ -0,0 +1,29 @@ +/* + "misc_string_conv.h" + + created by: grayspace aka J. Leveille + for: UbixOS Project + date: July 7, 2002 + + purpose: functions/macro for dealing with misc string conversion + + $Id: misc_string_conv.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $ +*/ + +#ifndef _MISC_STRING_CONV_H +#define _MISC_STRING_CONV_H + +extern const char a_hexvals[]; + +/* gets a hex value specified by a byte into a string + but does *not* null terminate */ +#define HEX_GETSTRING_BYTE_NONULL( p_dst_str, hexval_byte )\ + (p_dst_str)[0] = a_hexvals[((hexval_byte)>>4)];\ + (p_dst_str)[1] = a_hexvals[((hexval_byte)&0x0F)] + +/* gets a hex value specified by a byte into a string */ +#define HEX_GETSTRING_BYTE( p_dst_str, hexval_byte )\ + HEX_GETSTRING_BYTE_NONULL( p_dst_str, hexval_byte );\ + (p_dst_str)[2] = 0 + +#endif // _MISC_STRING_CONV_H \ No newline at end of file diff --git a/lockwasher/src/sys/include/objgfx/defpal.inc b/lockwasher/src/sys/include/objgfx/defpal.inc new file mode 100644 index 0000000..fdddf0e --- /dev/null +++ b/lockwasher/src/sys/include/objgfx/defpal.inc @@ -0,0 +1,259 @@ +const + ogRGBA DEFAULT_PALETTE[256] = + {{0,0,0,0}, // 0 + {0,0,170,0}, + {0,170,0,0}, + {0,170,170,0}, // 3 + {170,0,0,0}, + {170,0,170,0}, + {170,85,0,0}, + {170,170,170,0}, // 7 + {85,85,85,0}, + {85,85,255,0}, + {85,255,85,0}, + {85,255,255,0}, // 11 + {255,85,85,0}, + {255,85,255,0}, + {255,255,85,0}, + {255,255,255,0}, //15 + {16,16,16,0}, // 16 + {32,32,32,0}, + {48,48,48,0}, + {64,64,64,0}, + {80,80,80,0}, + {96,96,96,0}, + {112,112,112,0}, + {128,128,128,0}, + {144,144,144,0}, + {160,160,160,0}, + {176,176,176,0}, + {192,192,192,0}, + {208,208,208,0}, + {224,224,224,0}, + {240,240,240,0}, + {255,255,255,0}, //31 + {59,0,0,0}, // 32 + {79,0,0,0}, + {103,0,0,0}, + {123,0,0,0}, + {143,7,7,0}, + {167,7,7,0}, + {187,11,11,0}, + {211,15,15,0}, + {231,19,19,0}, + {255,27,27,0}, + {255,59,59,0}, + {255,91,91,0}, + {255,119,119,0}, + {255,151,151,0}, + {255,183,183,0}, + {255,215,215,0}, + {55,55,0,0}, // 48 + {71,71,0,0}, + {87,87,0,0}, + {103,103,7,0}, + {119,119,7,0}, + {135,135,11,0}, + {155,155,19,0}, + {171,171,23,0}, + {187,187,31,0}, + {203,203,35,0}, + {219,219,43,0}, + {239,239,59,0}, + {255,255,63,0}, + {255,255,127,0}, + {255,255,187,0}, + {255,255,255,0}, + {0,43,0,0}, // 64 + {0,63,0,0}, + {0,83,0,0}, + {0,103,0,0}, + {7,127,7,0}, + {7,147,7,0}, + {11,167,11,0}, + {15,187,15,0}, + {19,211,19,0}, + {27,231,27,0}, + {59,235,59,0}, + {91,239,91,0}, + {127,239,127,0}, + {159,243,159,0}, + {195,247,195,0}, + {231,251,231,0}, + {0,55,55,0}, // 80 + {0,71,71,0}, + {0,87,87,0}, + {7,103,103,0}, + {7,119,119,0}, + {11,135,135,0}, + {19,155,155,0}, + {23,171,171,0}, + {31,187,187,0}, + {35,203,203,0}, + {43,219,219,0}, + {51,235,235,0}, + {63,255,255,0}, + {127,255,255,0}, + {187,255,255,0}, + {255,255,255,0}, + {15,15,55,0}, // 96 + {19,19,79,0}, + {27,27,103,0}, + {31,31,127,0}, + {35,35,155,0}, + {39,39,179,0}, + {43,43,203,0}, + {47,47,227,0}, + {51,51,255,0}, + {71,71,255,0}, + {91,91,255,0}, + {111,111,255,0}, + {131,131,255,0}, + {151,151,255,0}, + {175,175,255,0}, + {195,195,255,0}, + {59,51,59,0}, // 112 + {79,63,79,0}, + {103,71,103,0}, + {123,75,123,0}, + {143,75,143,0}, + {167,71,167,0}, + {187,67,187,0}, + {211,55,211,0}, + {231,43,231,0}, + {255,27,255,0}, + {255,59,255,0}, + {255,91,255,0}, + {255,119,255,0}, + {255,151,255,0}, + {255,183,255,0}, + {255,215,255,0}, + {59,51,59,0}, // 128 + {71,59,71,0}, + {83,71,83,0}, + {95,83,95,0}, + {111,95,111,0}, + {123,103,123,0}, + {135,115,135,0}, + {147,127,147,0}, + {163,139,163,0}, + {175,151,175,0}, + {187,159,187,0}, + {203,171,203,0}, + {215,183,215,0}, + {227,191,227,0}, + {239,203,239,0}, + {255,215,255,0}, + {55,27,27,0}, // 144 + {71,35,35,0}, + {91,43,43,0}, + {107,55,55,0}, + {127,67,67,0}, + {143,75,75,0}, + {163,87,87,0}, + {179,99,99,0}, + {199,111,111,0}, + {203,127,127,0}, + {211,139,139,0}, + {219,159,159,0}, + {223,175,175,0}, + {231,191,191,0}, + {239,211,211,0}, + {247,231,231,0}, + {91,63,27,0}, // 160 + {111,75,31,0}, + {127,87,39,0}, + {147,103,43,0}, + {167,115,51,0}, + {187,127,55,0}, + {207,139,63,0}, + {227,155,67,0}, + {247,167,75,0}, + {247,175,95,0}, + {247,183,119,0}, + {247,195,139,0}, + {247,203,159,0}, + {247,215,183,0}, + {247,227,203,0}, + {251,239,227,0}, + {63,63,31,0}, // 176 + {75,75,35,0}, + {87,87,43,0}, + {99,99,51,0}, + {115,115,55,0}, + {127,127,63,0}, + {139,139,67,0}, + {151,151,75,0}, + {167,167,83,0}, + {175,175,95,0}, + {183,183,107,0}, + {191,191,123,0}, + {203,203,139,0}, + {211,211,159,0}, + {219,219,175,0}, + {231,231,195,0}, + {27,59,47,0}, // 192 + {31,75,59,0}, + {39,87,67,0}, + {47,103,79,0}, + {55,119,91,0}, + {59,135,99,0}, + {67,151,111,0}, + {71,167,119,0}, + {79,183,127,0}, + {87,199,139,0}, + {91,215,147,0}, + {99,231,155,0}, + {127,235,183,0}, + {163,239,211,0}, + {195,243,231,0}, + {231,251,247,0}, + {23,55,55,0}, // 208 + {31,71,71,0}, + {39,87,87,0}, + {47,103,103,0}, + {55,119,119,0}, + {67,139,139,0}, + {75,155,155,0}, + {87,171,171,0}, + {99,187,187,0}, + {111,203,203,0}, + {123,223,223,0}, + {143,227,227,0}, + {163,231,231,0}, + {183,235,235,0}, + {203,239,239,0}, + {227,247,247,0}, + {39,39,79,0}, // 224 + {47,47,91,0}, + {55,55,107,0}, + {63,63,123,0}, + {71,71,139,0}, + {79,79,151,0}, + {87,87,167,0}, + {99,99,183,0}, + {107,107,199,0}, + {123,123,203,0}, + {139,139,211,0}, + {155,155,219,0}, + {171,171,223,0}, + {187,187,231,0}, + {207,207,239,0}, + {227,227,247,0}, + {63,27,63,0}, // 240 + {75,31,75,0}, + {91,39,91,0}, + {103,47,103,0}, + {119,51,119,0}, + {131,59,131,0}, + {147,67,147,0}, + {163,75,163,0}, + {175,83,175,0}, + {191,91,191,0}, + {199,107,199,0}, + {207,127,207,0}, + {215,147,215,0}, + {223,171,223,0}, + {231,195,231,0}, + {243,219,243,0}}; + diff --git a/lockwasher/src/sys/include/objgfx/objgfx30.h b/lockwasher/src/sys/include/objgfx/objgfx30.h new file mode 100644 index 0000000..f1ee3a0 --- /dev/null +++ b/lockwasher/src/sys/include/objgfx/objgfx30.h @@ -0,0 +1,151 @@ +/************************************************************** +$Id: objgfx30.h,v 1.6 2003/04/03 04:39:18 reddawg Exp $ +**************************************************************/ + +#ifndef OBJGFX30_H +#define OBJGFX30_H + +//#include // for NULL, true, false + +#define ogVERSION 3.0; + + +typedef signed char int8; +typedef signed short int int16; +typedef signed long int int32; +typedef signed long long int int64; +typedef unsigned char uInt8; +typedef unsigned short int uInt16; +typedef unsigned long int uInt32; +typedef unsigned long long int uInt64; + +enum ogDataState { ogNONE, ogOWNER, ogALIASING }; + +struct ogRGB { + uInt8 red; + uInt8 green; + uInt8 blue; +}; + +struct ogRGBA { + uInt8 red; + uInt8 green; + uInt8 blue; + uInt8 alpha; +}; + +struct ogPoint { + int32 x; + int32 y; +}; + +typedef + struct ogPixelFmt { + uInt8 BPP; + uInt8 redFieldPosition; + uInt8 greenFieldPosition; + uInt8 blueFieldPosition; + uInt8 alphaFieldPosition; + uInt8 redMaskSize; + uInt8 greenMaskSize; + uInt8 blueMaskSize; + uInt8 alphaMaskSize; + }; + +// Default pixel formats + +const ogPixelFmt OG_NULL_PIXFMT = { 0, 0,0,0,0,0,0,0,0}; +const ogPixelFmt OG_PIXFMT_8BPP = { 8, 0,0,0,0,0,0,0,0}; +const ogPixelFmt OG_PIXFMT_15BPP = {15, 10,5,0,15,5,5,5,1}; +const ogPixelFmt OG_PIXFMT_16BPP = {16, 11,5,0,0,5,6,5,0}; +const ogPixelFmt OG_PIXFMT_24BPP = {24, 16,8,0,0,8,8,8,0}; +const ogPixelFmt OG_PIXFMT_32BPP = {32, 16,8,0,24,8,8,8,8}; +const ogPixelFmt OG_MAC_PIXFMT_16BPP = {16, 8,4,0,12,4,4,4,4}; + +class ogSurface { +//protected: +public: + float version; + void* buffer; + uInt32* lineOfs; + ogRGBA* pal; + ogSurface* owner; + uInt32 xRes, yRes; + uInt32 maxX, maxY; + uInt32 bSize; // buffer size (in bytes) + uInt32 lSize; // LineOfs size (in bytes) + uInt32 transparentColor; + ogDataState dataState; + uInt32 BPP; // bits per pixel + uInt32 redFieldPosition; + uInt32 greenFieldPosition; + uInt32 blueFieldPosition; + uInt32 alphaFieldPosition; + uInt32 redShifter; + uInt32 greenShifter; + uInt32 blueShifter; + uInt32 alphaShifter; + bool antiAlias; + bool clipLine(int32&, int32&, int32&, int32&); + virtual void rawLine(uInt32, uInt32, uInt32, uInt32, uInt32); + virtual uInt32 rawGetPixel(uInt32, uInt32); + virtual void rawSetPixel(uInt32, uInt32, uInt32); + void aaRawLine(uInt32, uInt32, uInt32, uInt32, uInt32); +// public: + ogSurface(void); + virtual bool ogAlias(ogSurface&, uInt32, uInt32, uInt32, uInt32); + virtual bool ogAvail(void); + void ogArc(int32, int32, uInt32, uInt32, uInt32, uInt32); + void ogBSpline(uInt32, ogPoint*, uInt32, uInt32); + void ogCircle(int32, int32, uInt32, uInt32); + virtual void ogClear(uInt32); + virtual bool ogClone(ogSurface&); + void ogCopy(ogSurface&); + void ogCopyBuf(int32, int32, + ogSurface&, int32, int32, int32, int32); + virtual void ogCopyLineTo(uInt32, uInt32, const void *, uInt32); + virtual void ogCopyLineFrom(uInt32, uInt32, void *, uInt32); + void ogCopyPal(ogSurface&); + virtual bool ogCreate(uInt32, uInt32, ogPixelFmt); + void ogCubicBezierCurve(int32, int32, int32, int32, + int32, int32, int32, int32, uInt32, uInt32); + void ogCurve(int32,int32, int32,int32, int32,int32, uInt32, uInt32); + void ogFillCircle(int32, int32, uInt32, uInt32); +// void ogFillConvexPolygon(uInt32, ogPoint*, uInt32); + void ogFillPolygon(uInt32, ogPoint*, uInt32); + void ogFillRect(int32, int32, int32, int32, uInt32); + void ogFillTriangle(int32,int32, int32,int32, int32,int32, uInt32); + bool ogGetAntiAlias(void) const { return antiAlias; } + uInt8 ogGetBPP(void) const { return BPP; } + ogDataState ogGetDataState(void) const { return dataState; } + uInt32 ogGetMaxX(void) const { return maxX; } + uInt32 ogGetMaxY(void) const { return maxY; } + void ogGetPixFmt(ogPixelFmt&); + virtual uInt32 ogGetPixel(int32, int32); + virtual void * ogGetPtr(uInt32, uInt32); + uInt32 ogGetTransparentColor(void) { return transparentColor; } + void ogHFlip(void); + virtual void ogHLine(int32, int32, int32, uInt32); + void ogLine(int32, int32, int32, int32, uInt32); + virtual bool ogLoadPal(const char *); + void ogPolygon(uInt32, ogPoint*, uInt32); + void ogRect(int32, int32, int32, int32, uInt32); + uInt32 ogRGB(uInt8, uInt8, uInt8); + bool ogSavePal(const char *); + void ogScale(ogSurface&); + void ogScaleBuf(int32, int32, int32, int32, + ogSurface&, int32, int32, int32, int32); +void ogSendSDE(uInt32); + bool ogSetAntiAlias(bool); + virtual void ogSetPixel(int32, int32, uInt32); + virtual void ogSetRGBPalette(uInt8, uInt8, uInt8, uInt8); + uInt32 ogSetTransparentColor(uInt32); + void ogSpline(uInt32, ogPoint*, uInt32, uInt32); + void ogTriangle(int32, int32, int32, int32, int32, int32, uInt32); + void ogUnpackRGB(uInt32, uInt8&, uInt8&, uInt8&); + virtual void ogVFlip(void); + virtual void ogVLine(int32, int32, int32, uInt32); + virtual ~ogSurface(void); +}; // ogSurface + +#endif diff --git a/lockwasher/src/sys/include/objgfx/ogBlit.h b/lockwasher/src/sys/include/objgfx/ogBlit.h new file mode 100644 index 0000000..7788ae0 --- /dev/null +++ b/lockwasher/src/sys/include/objgfx/ogBlit.h @@ -0,0 +1,28 @@ +#ifndef OGBLIT_H +#define OGBLIT_H + +#include "ogSprite.h" + +class ogBlit: public ogSprite { + protected: + uInt8 * blitMask; + uInt32 blitMaskSize; + uInt32 totalPixCount; + int32 startX, startY; + int32 endX, endY; + + void blitSize(ogSurface&, int32, int32, int32, int32); + void getBlitMask(ogSurface&, int32, int32); + public: + ogBlit(void); + virtual void get(ogSurface&, int32, int32, int32, int32); + void getBlitWithMask(ogSurface&, int32, int32); + uInt32 getBlitMaskSize(void) { return blitMaskSize; } + virtual uInt32 getSize(void); + virtual bool loadFrom(const char *, uInt32); + virtual void put(ogSurface&, int32, int32); + virtual bool saveTo(const char *, int32); + virtual ~ogBlit(void); +}; // ogBlit + +#endif diff --git a/lockwasher/src/sys/include/objgfx/ogDisplay_VESA.h b/lockwasher/src/sys/include/objgfx/ogDisplay_VESA.h new file mode 100644 index 0000000..69c8de3 --- /dev/null +++ b/lockwasher/src/sys/include/objgfx/ogDisplay_VESA.h @@ -0,0 +1,95 @@ +#ifndef OGDISPLAY_VESA_H +#define OGDISPLAY_VESA_H + +#include "objgfx30.h" + +struct ogMode_Rec { + uInt16 ModeAttributes __attribute__((packed)); + uInt8 WindowAFlags __attribute__((packed)); + uInt8 WindowBFlags __attribute__((packed)); + uInt16 Granularity __attribute__((packed)); + uInt16 WindowSize __attribute__((packed)); + uInt16 WindowASeg __attribute__((packed)); + uInt16 WindowBSeg __attribute__((packed)); + void* BankSwitch __attribute__((packed)); + uInt16 BytesPerLine __attribute__((packed)); + uInt16 xRes __attribute__((packed)); + uInt16 yRes __attribute__((packed)); + uInt8 CharWidth __attribute__((packed)); + uInt8 CharHeight __attribute__((packed)); + uInt8 NumBitPlanes __attribute__((packed)); + uInt8 BitsPerPixel __attribute__((packed)); + uInt8 NumberOfBanks __attribute__((packed)); + uInt8 MemoryModel __attribute__((packed)); + uInt8 BankSize __attribute__((packed)); + uInt8 NumOfImagePages __attribute__((packed)); + uInt8 Reserved __attribute__((packed)); + // Direct colour fields (required for Direct/6 and YUV/7 memory models + uInt8 RedMaskSize __attribute__((packed)); + uInt8 RedFieldPosition __attribute__((packed)); + uInt8 GreenMaskSize __attribute__((packed)); + uInt8 GreenFieldPosition __attribute__((packed)); + uInt8 BlueMaskSize __attribute__((packed)); + uInt8 BlueFieldPosition __attribute__((packed)); + uInt8 AlphaMaskSize __attribute__((packed)); + uInt8 AlphaFieldPosition __attribute__((packed)); + uInt8 DirectColourMode __attribute__((packed)); + // VESA 2.0 specific fields + uInt32 physBasePtr __attribute__((packed)); + void* OffScreenMemOffset __attribute__((packed)); + uInt16 OffScreenMemSize __attribute__((packed)); + uInt8 paddington[461] __attribute__((packed)); +}; + +struct ogVESA_Rec { + char VBESignature[4] __attribute__((packed)); + uInt8 minVersion __attribute__((packed)); + uInt8 majVersion __attribute__((packed)); + uInt32 OEMStringPtr __attribute__((packed)); + uInt32 Capabilities __attribute__((packed)); + uInt32 VideoModePtr __attribute__((packed)); + uInt16 TotalMemory __attribute__((packed)); + // VESA 2.0 specific fields + uInt16 OEMSoftwareRev __attribute__((packed)); + uInt32 OEMVendorNamePtr __attribute__((packed)); + uInt32 OEMProductNamePtr __attribute__((packed)); + uInt32 OEMProductRevPtr __attribute__((packed)); + uInt8 paddington[474] __attribute__((packed)); +}; + +class ogDisplay_VESA : public ogSurface { + protected: + uInt16 ScreenSelector; + ogVESA_Rec* VESARec; + ogMode_Rec* modeRec; + bool InGraphics; + uInt16 findMode(uInt32, uInt32, uInt32); + void getModeInfo(uInt16); + void getVESAInfo(void); + void setMode(uInt16); + virtual uInt32 rawGetPixel(uInt32, uInt32); + virtual void rawSetPixel(uInt32, uInt32, uInt32); + virtual void rawLine(uInt32, uInt32, uInt32, uInt32, uInt32); + void setPal(void); + public: + ogDisplay_VESA(void); + virtual bool ogAvail(void); + virtual bool ogAlias(ogSurface&, uInt32, uInt32, uInt32, uInt32); + virtual void ogClear(uInt32); + virtual bool ogClone(ogSurface&); + virtual void ogCopyLineTo(uInt32, uInt32, const void *, uInt32); + virtual void ogCopyLineFrom(uInt32, uInt32, void *, uInt32); + virtual void ogCopyPal(ogSurface&); + virtual bool ogCreate(uInt32, uInt32, ogPixelFmt); + virtual uInt32 ogGetPixel(int32, int32); + virtual void * ogGetPtr(uInt32, uInt32); + virtual void ogHLine(int32, int32, int32, uInt32); + virtual bool ogLoadPal(const char *); + virtual void ogSetPixel(int32, int32, uInt32); + virtual void ogSetRGBPalette(uInt8, uInt8, uInt8, uInt8); + virtual void ogVFlip(void); + virtual void ogVLine(int32, int32, int32, uInt32); + virtual ~ogDisplay_VESA(void); +}; // ogDisplay_VESA + +#endif diff --git a/lockwasher/src/sys/include/objgfx/ogFont.h b/lockwasher/src/sys/include/objgfx/ogFont.h new file mode 100644 index 0000000..d060b33 --- /dev/null +++ b/lockwasher/src/sys/include/objgfx/ogFont.h @@ -0,0 +1,55 @@ +#ifndef OGFONT_H +#define OGFONT_H + +#include "objgfx30.h" + +#define LeftText 0 +#define CenterText 1 +#define RightText 2 +#define BottomText 0 +#define TopText 2 + +typedef + struct { + char ID[3]; + uInt8 version; + uInt8 width, height; + uInt8 numOfChars; + uInt8 startingChar; + uInt8 colourType; + uInt8 paddington[7]; + } ogDPFHeader; + +class ogBitFont { + protected: + uInt32 fontDataIdx[256]; + uInt32 charWidthTable[256]; + uInt32 charHeightTable[256]; + void * fontData; + uInt32 fontDataSize; + ogRGB BGColour; + ogRGB FGColour; + uInt8 width, height; + uInt16 numOfChars; + uInt8 startingChar; + + public: + ogBitFont(); + void putChar(ogSurface&, int32, int32, const char); + void putString(ogSurface&, int32, int32, const char *); + void setBGColor(uInt8, uInt8, uInt8); + void setFGColor(uInt8, uInt8, uInt8); + uInt32 getWidth(void) const { return width; }; + uInt32 getHeight(void) const { return height; }; + bool loadFrom(const char *, uInt32); + bool saveTo(const char *, int32); + void centerTextX(ogSurface&, int32, const char *); + void justifyText(ogSurface&, uInt8, uInt8, const char *); + bool load(const char *); + bool save(const char *); + uInt32 textHeight(const char *) const { return height; }; + uInt32 textWidth(const char *); + ~ogBitFont(void); +}; // ogBitFont + +#endif diff --git a/lockwasher/src/sys/include/objgfx/ogSprite.h b/lockwasher/src/sys/include/objgfx/ogSprite.h new file mode 100644 index 0000000..3e3315f --- /dev/null +++ b/lockwasher/src/sys/include/objgfx/ogSprite.h @@ -0,0 +1,39 @@ +#ifndef OGSPRITE_H +#define OGSPRITE_H + +#include "objgfx30.h" + +class ogSprite { + protected: + void * image; + uInt32 imageSize; + ogRGBA* pal; + uInt32 width, height; + uInt32 bitDepth; // make this 32-bit just for alignment purposes + uInt32 RFP; + uInt32 GFP; + uInt32 BFP; + uInt32 AFP; + uInt32 RShift; + uInt32 GShift; + uInt32 BShift; + uInt32 AShift; + uInt32 tColour; // original transparent colour + uInt32 getPixel(void *); + void setPixel(void *, uInt32); + void unpackRGB(uInt32, uInt8&, uInt8&, uInt8&); + public: + ogSprite(void); + void get(ogSurface&, int32, int32, int32, int32); + uInt32 getHeight(void) { return height; } + uInt32 getSize(void); + uInt32 getWidth(void) { return width; } + bool load(const char *); + virtual bool loadFrom(const char *, uInt32); + virtual void put(ogSurface&, int32, int32); + bool save(const char *); + virtual bool saveTo(const char *, int32); + virtual ~ogSprite(void); + +}; // ogSprite +#endif diff --git a/lockwasher/src/sys/include/pci/hd.h b/lockwasher/src/sys/include/pci/hd.h new file mode 100644 index 0000000..5587e39 --- /dev/null +++ b/lockwasher/src/sys/include/pci/hd.h @@ -0,0 +1,28 @@ +#ifndef _HD_H +#define _HD_H + +struct driveInfo { + char hdSector[512]; + char hdEnable; + char hdDev; + char hdFlags; + char hdShift; + long hdMask; + long hdMulti; + long hdPort; + long hdSize; + long hdCalc; + }; + +void initHardDisk(); +int initDrive(struct driveInfo *); +void hdWrite(struct driveInfo *hdd,long startSector,long sectorCount,void *baseAddr); +void hdRead(struct driveInfo *hdd,long startSector,long sectorCount,void *baseAddr); + +extern struct driveInfo *hdd0; +extern struct driveInfo *hdd1; +extern struct driveInfo *hdd2; +extern struct driveInfo *hdd3; + +#endif + diff --git a/lockwasher/src/sys/include/pci/lnc.h b/lockwasher/src/sys/include/pci/lnc.h new file mode 100644 index 0000000..ec867f4 --- /dev/null +++ b/lockwasher/src/sys/include/pci/lnc.h @@ -0,0 +1,157 @@ +#ifndef _LNC_H +#define _LNC_H + +#include + +#define NDESC(len2) (1 << len2) +#define NORMAL 0 +#define MEM_SLEW 8 +#define TRANSBUFSIZE 1518 +#define RECVBUFSIZE 1518 +#define NRDRE 3 +#define NTDRE 3 +#define ETHER_ADDR_LEN 6 +#define NE2100_IOSIZE 24 +#define PCNET_RDP 0x10 /* Register Data Port */ +#define PCNET_RAP 0x12 /* Register Address Port */ +#define PCNET_RESET 0x14 +#define PCNET_BDP 0x16 +#define PCNET_VSW 0x18 +#define NE2100 2 + +/* mem_mode values */ +#define DMA_FIXED 1 +#define DMA_MBUF 2 +#define SHMEM 4 + + +/********** Chip Types **********/ +#define UNKNOWN 0 /* Unknown */ +#define LANCE 1 /* Am7990 */ +#define C_LANCE 2 /* Am79C90 */ +#define PCnet_ISA 3 /* Am79C960 */ +#define PCnet_ISAplus 4 /* Am79C961 */ +#define PCnet_ISA_II 5 /* Am79C961A */ +#define PCnet_32 6 /* Am79C965 */ +#define PCnet_PCI 7 /* Am79C970 */ +#define PCnet_PCI_II 8 /* Am79C970A */ +#define PCnet_FAST 9 /* Am79C971 */ +#define PCnet_FASTplus 10 /* Am79C972 */ +#define PCnet_Home 11 /* Am79C978 */ + +/******** AM7990 Specifics **************/ +#define CSR0 0x0000 +#define CSR1 1 +#define CSR2 2 +#define CSR3 3 +#define CSR88 88 +#define CSR89 89 + +#define ERR 0x8000 +#define BABL 0x4000 +#define CERR 0x2000 +#define MISS 0x1000 +#define MERR 0x0800 +#define RINT 0x0400 +#define TINT 0x0200 +#define IDON 0x0100 +#define INTR 0x0080 +#define INEA 0x0040 +#define RXON 0x0020 +#define TXON 0x0010 +#define TDMD 0x0008 +#define STOP 0x0004 +#define STRT 0x0002 +#define INIT 0x0001 + + +/* CSR88-89: Chip ID masks */ +#define AMD_MASK 0x003 +#define PART_MASK 0xffff +#define Am79C960 0x0003 +#define Am79C961 0x2260 +#define Am79C961A 0x2261 +#define Am79C965 0x2430 +#define Am79C970 0x0242 +#define Am79C970A 0x2621 +#define Am79C971 0x2623 +#define Am79C972 0x2624 +#define Am79C973 0x2625 +#define Am79C978 0x2626 + +/********** Structs **********/ + + + + +struct initBlock { + uInt16 mode; /* Mode register */ + uInt8 padr[6]; /* Ethernet address */ + uInt8 ladrf[8]; /* Logical address filter (multicast) */ + uInt16 rdra; /* Low order pointer to receive ring */ + uInt16 rlen; /* High order pointer and no. rings */ + uInt16 tdra; /* Low order pointer to transmit ring */ + uInt16 tlen; /* High order pointer and no rings */ + }; + +struct mds { + uInt16 md0; + uInt16 md1; + short md2; + uInt16 md3; + }; + +struct hostRingEntry { + struct mds *md; + union { + //struct mbuf *mbuf; + char *data; + }buff; + }; + +struct arpcom { + //struct ifnet ac_if; /* network-visible interface */ + uInt8 ac_enaddr[6]; /* ethernet hardware address */ + int ac_multicnt; /* length of ac_multiaddrs list */ + void *ac_netgraph; /* ng_ether(4) netgraph node info */ + }; + +struct nicInfo { + int ident; /* Type of card */ + int ic; /* Type of ic, Am7990, Am79C960 etc. */ + int memMode; + int iobase; + int mode; /* Mode setting at initialization */ + }; + +struct lncInfo { + struct arpcom arpcom; + struct nicInfo nic; + struct hostRingEntry *recvRing; + struct hostRingEntry *transRings; + struct initBlock *initBloack; + int rap; + int rdp; + int bdp; + int nrdre; + int ntdre; + }; + +extern struct lncInfo *lnc; + +void writeCsr(struct lncInfo *lnc, uInt16 port, uInt16 val); +uInt16 readCsr(struct lncInfo *lnc, uInt16 port); +void writeBcr(struct lncInfo *lnc, uInt16 port, uInt16 val); +uInt16 readBcr(struct lncInfo *lnc, uInt16 port); + +void initLNC(); +int probe(struct lncInfo *lnc); +int lanceProbe(struct lncInfo *lnc); +int lncAttach(struct lncInfo *lnc,int unit); + + +void lncInt(); +void _lncInt(); + +#endif + diff --git a/lockwasher/src/sys/include/pci/pci.h b/lockwasher/src/sys/include/pci/pci.h new file mode 100644 index 0000000..5a371ae --- /dev/null +++ b/lockwasher/src/sys/include/pci/pci.h @@ -0,0 +1,78 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: pci.h,v 1.1 2003/05/01 12:30:02 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _PCI_H +#define _PCI_H + +#include + + +struct pciConfig { + uInt16 vendorId; + uInt16 deviceId; + + uInt16 command; + uInt16 status; + + uInt8 revisionId; + uInt8 interface; + uInt8 subClass; + uInt8 baseClass; + + uInt8 cacheLineSize; + uInt8 latencyTimer; + uInt8 headerType; + uInt8 bist; + + /* device info */ + uInt8 bus; + uInt8 dev; + uInt8 func; + uInt8 irq; + + /* base registers */ + uInt32 base[6]; + uInt32 size[6]; + + uInt16 subsysVendor; + uInt16 subsys; + + }; + +struct confadd { + uInt8 reg:8; + uInt8 func:3; + uInt8 dev:5; + uInt8 bus:8; + uInt8 rsvd:7; + uInt8 enable:1; + }; + +#define countof(a) (sizeof(a) / sizeof(a[0])) + +void initPci(); +bool pciProbe(int bus,int dev,int func,struct pciConfig *cfg); +uInt32 pciRead(int bus, int dev, int func, int reg, int bytes); +void pciWrite(int bus,int dev,int func,int reg,uInt32 v,int bytes); + +#endif \ No newline at end of file diff --git a/lockwasher/src/sys/include/sde/ogDisplay_UbixOS.h b/lockwasher/src/sys/include/sde/ogDisplay_UbixOS.h new file mode 100644 index 0000000..5159ceb --- /dev/null +++ b/lockwasher/src/sys/include/sde/ogDisplay_UbixOS.h @@ -0,0 +1,80 @@ +#ifndef OGDISPLAY_UBIXOS_H +#define OGDISPLAY_UBIXOS_H + +#include + +struct ogMode_Rec { + uInt16 ModeAttributes __attribute__((packed)); + uInt8 WindowAFlags __attribute__((packed)); + uInt8 WindowBFlags __attribute__((packed)); + uInt16 Granularity __attribute__((packed)); + uInt16 WindowSize __attribute__((packed)); + uInt16 WindowASeg __attribute__((packed)); + uInt16 WindowBSeg __attribute__((packed)); + void* BankSwitch __attribute__((packed)); + uInt16 BytesPerLine __attribute__((packed)); + uInt16 xRes __attribute__((packed)); + uInt16 yRes __attribute__((packed)); + uInt8 CharWidth __attribute__((packed)); + uInt8 CharHeight __attribute__((packed)); + uInt8 NumBitPlanes __attribute__((packed)); + uInt8 BitsPerPixel __attribute__((packed)); + uInt8 NumberOfBanks __attribute__((packed)); + uInt8 MemoryModel __attribute__((packed)); + uInt8 BankSize __attribute__((packed)); + uInt8 NumOfImagePages __attribute__((packed)); + uInt8 Reserved __attribute__((packed)); + // Direct colour fields (required for Direct/6 and YUV/7 memory models + uInt8 RedMaskSize __attribute__((packed)); + uInt8 RedFieldPosition __attribute__((packed)); + uInt8 GreenMaskSize __attribute__((packed)); + uInt8 GreenFieldPosition __attribute__((packed)); + uInt8 BlueMaskSize __attribute__((packed)); + uInt8 BlueFieldPosition __attribute__((packed)); + uInt8 AlphaMaskSize __attribute__((packed)); + uInt8 AlphaFieldPosition __attribute__((packed)); + uInt8 DirectColourMode __attribute__((packed)); + // VESA 2.0 specific fields + uInt32 physBasePtr __attribute__((packed)); + void* OffScreenMemOffset __attribute__((packed)); + uInt16 OffScreenMemSize __attribute__((packed)); + uInt8 paddington[461] __attribute__((packed)); +}; + +struct ogVESA_Rec { + char VBESignature[4] __attribute__((packed)); + uInt8 minVersion __attribute__((packed)); + uInt8 majVersion __attribute__((packed)); + uInt32 OEMStringPtr __attribute__((packed)); + uInt32 Capabilities __attribute__((packed)); + uInt32 VideoModePtr __attribute__((packed)); + uInt16 TotalMemory __attribute__((packed)); + // VESA 2.0 specific fields + uInt16 OEMSoftwareRev __attribute__((packed)); + uInt32 OEMVendorNamePtr __attribute__((packed)); + uInt32 OEMProductNamePtr __attribute__((packed)); + uInt32 OEMProductRevPtr __attribute__((packed)); + uInt8 paddington[474] __attribute__((packed)); +}; + +class ogDisplay_UbixOS : public ogSurface { + protected: + ogVESA_Rec* VESARec; + ogMode_Rec* modeRec; + uInt16 findMode(uInt32, uInt32, uInt32); + void getModeInfo(uInt16); + void getVESAInfo(void); + void setMode(uInt16); + void setPal(void); + public: + ogDisplay_UbixOS(void); + virtual bool ogAlias(ogSurface&, uInt32, uInt32, uInt32, uInt32); + virtual bool ogClone(ogSurface&); + virtual void ogCopyPal(ogSurface&); + virtual bool ogCreate(uInt32, uInt32, ogPixelFmt); + virtual bool ogLoadPal(const char *); + virtual void ogSetRGBPalette(uInt8, uInt8, uInt8, uInt8); + virtual ~ogDisplay_UbixOS(void); +}; // ogDisplay_UbixOS + +#endif diff --git a/lockwasher/src/sys/include/sde/sde.h b/lockwasher/src/sys/include/sde/sde.h new file mode 100644 index 0000000..37c3ce5 --- /dev/null +++ b/lockwasher/src/sys/include/sde/sde.h @@ -0,0 +1,48 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: sde.h,v 1.4 2003/04/03 23:29:50 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _SDE_H +#define _SDE_H + +#include + +#define registerWindow 1 +#define windowReady 2 +#define drawWindow 3 +#define killWindow 4 + +void sdeThread(); +void sysSDE(); + +struct sdeWindows { + struct sdeWindows *next; + struct sdeWindows *prev; + void *buf; + Int32 pid; + uInt8 status; + }; + +extern struct sdeWindows *windows; + +#endif + diff --git a/lockwasher/src/sys/include/stdarg.h b/lockwasher/src/sys/include/stdarg.h new file mode 100644 index 0000000..4dc0db9 --- /dev/null +++ b/lockwasher/src/sys/include/stdarg.h @@ -0,0 +1,35 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: stdarg.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#ifndef _STDARG_H +#define _STDARG_H + +typedef char *vaList; + +#define _vaSize(TYPE) (((sizeof(TYPE) + sizeof(int) -1) / sizeof(int)) * sizeof(int)) +#define vaStart(AP, LASTARG) (AP=((vaList)&(LASTARG) + _vaSize(LASTARG))) +#define vaEnd(AP) +#define vaArg(AP, TYPE) (AP += _vaSize(TYPE), *((TYPE *)(AP - _vaSize(TYPE)))) + +#endif + diff --git a/lockwasher/src/sys/include/sys/dma.h b/lockwasher/src/sys/include/sys/dma.h new file mode 100644 index 0000000..b86d52b --- /dev/null +++ b/lockwasher/src/sys/include/sys/dma.h @@ -0,0 +1,33 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: dma.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#ifndef _DMA_H +#define _DMA_H + +#include + +void dmaXfer(uChar channel,uLong address,uInt length,uChar read); +void _dmaXfer(uChar dmaChannel,uChar page,uInt offset,uInt length,uChar mode); + +#endif + diff --git a/lockwasher/src/sys/include/sys/drives.h b/lockwasher/src/sys/include/sys/drives.h new file mode 100644 index 0000000..3465dc9 --- /dev/null +++ b/lockwasher/src/sys/include/sys/drives.h @@ -0,0 +1,66 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: drives.h,v 1.4 2003/03/20 02:45:13 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _DRIVES_H +#define _DRIVES_H + +#include + +#define MAXPARTITIONS 4 + +struct driveDiskLabel { + uInt32 magicNum; + uInt32 magicNum2; + uInt16 driveType; + uInt16 numPartitions; + struct drivePartitions { //the partition table + uInt32 pSize; //number of sectors in partition + uInt32 pOffset; //starting sector + uInt32 pFsSize; //filesystem basic fragment size + uInt32 pBatSize; //BAT size + uInt8 pFsType; //filesystem type, see below + uInt8 pFrag; //filesystem fragments per block + } partitions[MAXPARTITIONS]; + }; + +struct driveDriver { + struct driveDriver *prev; + struct driveDriver *next; + struct driveDiskLabel *diskLabel; + int id; + void *driveInfoStruct; + char driveType; + void (*read)(void *,long,long,void *); + void (*write)(void *,long,long,void *); + void (*reset)(void *); + }; + + +extern struct driveDriver *drives; +extern int currentDrive; + +void addDrive(int id,char type,void *driveInfoStruct,void *read,void *write,void *reset); +struct driveDriver *findDrive(int id); + +#endif + diff --git a/lockwasher/src/sys/include/sys/gdt.h b/lockwasher/src/sys/include/sys/gdt.h new file mode 100644 index 0000000..eb15add --- /dev/null +++ b/lockwasher/src/sys/include/sys/gdt.h @@ -0,0 +1,88 @@ + + + +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: gdt.h,v 1.3 2003/04/05 04:21:07 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _GDT_H +#define _GDT_H + +/* Descriptor Definitions */ +#define dCall 0x0C00 /* 386 Call Gate */ +#define dCode 0x1800 /* Code Segment */ +#define dData 0x1000 /* Data Segment */ +#define dInt 0x0E00 /* 386 Interrupt Gate */ +#define dLdt 0x200 /* Local Descriptor Table (LDT) */ +#define dTask 0x500 /* Task gate */ +#define dTrap 0x0F00 /* 386 Trap Gate */ +#define dTss 0x900 /* Task State Segment (TSS) */ + +/* Descriptor Options */ +#define dDpl3 0x6000 /* DPL3 or mask for DPL */ +#define dDpl2 0x4000 /* DPL2 or mask for DPL */ +#define dDpl1 0x2000 /* DPL1 or mask for DPL */ +#define dPresent 0x8000 /* Present */ +#define dNpresent 0x8000 /* Not Present */ +#define dAcc 0x100 /* Accessed (Data or Code) */ +#define dWrite 0x200 /* Writable (Data segments only) */ +#define dRead 0x200 /* Readable (Code segments only) */ +#define dBusy 0xB00 /* Busy (TSS only) was 200 */ +#define dEexdown 0x400 /* Expand down (Data segments only) */ +#define dConform 0x400 /* Conforming (Code segments only) */ +#define dBig 0x40 /* Default to 32 bit mode */ +#define dBiglim 0x80 /* Limit is in 4K units */ + +/* GDT Descriptor */ +struct gdtDescriptor { + unsigned short limitLow; /* Limit 0..15 */ + unsigned short baseLow; /* Base 0..15 */ + unsigned char baseMed; /* Base 16..23 */ + unsigned char access; /* Access Byte */ + unsigned int limitHigh:4; /* Limit 16..19 */ + unsigned int granularity:4; /* Granularity */ + unsigned char baseHigh; /* Base 24..31 */ + } __attribute__ ((packed)); + +struct gdtGate { + unsigned short offsetLow; /* Offset 0..15 */ + unsigned short selector; /* Selector */ + unsigned short access; /* Access Flags */ + unsigned short offsetHigh; /* Offset 16..31 */ + } __attribute__ ((packed)); + +union descriptorTableunion { + struct gdtDescriptor descriptor; /* Normal descriptor */ + struct gdtGate gate; /* Gate descriptor */ + unsigned long dummy; /* Any other info */ + }; + + +#define descriptorTable(name,length) union descriptorTableunion name[length] = +#define standardDescriptor(base, limit, control) {descriptor: {(limit & 0xffff), (base & 0xffff), ((base >> 16) & 0xff), \ + ((control+dPresent) >> 8), (limit >> 16), \ + ((control & 0xff) >> 4), (base >> 24)}} +#define gateDescriptor(offset, selector, control) {gate: {(offset & 0xffff), selector, \ + (control+dPresent), (offset >> 16) }} + +#endif + diff --git a/lockwasher/src/sys/include/sys/idt.h b/lockwasher/src/sys/include/sys/idt.h new file mode 100644 index 0000000..e4aae5f --- /dev/null +++ b/lockwasher/src/sys/include/sys/idt.h @@ -0,0 +1,56 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: idt.h,v 1.5 2003/04/10 06:35:43 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _IDT_H +#define _IDT_H + +#include + +#define EFLAG_TF 0x100 +#define EFLAG_IF 0x200 +#define EFLAG_IOPL3 0x3000 +#define EFLAG_VM 0x20000 + +void initIdt(); +void setVector(void *handler, unsigned char interrupt, unsigned short controlMajor); +void setTaskVector(uInt8 interrupt,uInt16 controlMajor,uInt8 selector); +void intNull(); + +void _int0(); +void _int1(); +void _int2(); +void _int3(); +void _int4(); +void _int5(); +void _int6(); +void _int7(); +void _int8(); +void _int9(); +void _int10(); +void _int11(); +void _int12(); +void _int13(); +void timerInt(); + +#endif + diff --git a/lockwasher/src/sys/include/sys/io.h b/lockwasher/src/sys/include/sys/io.h new file mode 100644 index 0000000..e0f9521 --- /dev/null +++ b/lockwasher/src/sys/include/sys/io.h @@ -0,0 +1,36 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: io.h,v 1.3 2003/05/01 12:30:02 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _IO_H +#define _IO_H + +inline unsigned char inportByte(unsigned int); +inline unsigned short inportWord(unsigned int); +inline unsigned long inportDWord(unsigned int); +inline void outportByte(unsigned int,unsigned char); +inline void outportByteP(unsigned int port,unsigned char value); +inline void outportWord(unsigned int,unsigned short); +inline void outportDWord(unsigned int port,unsigned long value); + +#endif + diff --git a/lockwasher/src/sys/include/sys/tss.h b/lockwasher/src/sys/include/sys/tss.h new file mode 100644 index 0000000..b5ae0d9 --- /dev/null +++ b/lockwasher/src/sys/include/sys/tss.h @@ -0,0 +1,79 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: tss.h,v 1.6 2003/04/20 12:11:30 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _TSS_H +#define _TSS_H + +struct tssStruct { + short back_link; + short back_link_reserved; + long esp0; + short ss0; + short ss0_reserved; + long esp1; + short ss1; + short ss1_reserved; + long esp2; + short ss2; + short ss2_reserved; + long cr3; + long eip; + long eflags; + long eax,ecx,edx,ebx; + long esp; + long ebp; + long esi; + long edi; + short es; + short es_reserved; + short cs; + short cs_reserved; + short ss; + short ss_reserved; + short ds; + short ds_reserved; + short fs; + short fs_reserved; + short gs; + short gs_reserved; + short ldt; + short ldt_reserved; + //long trace_bitmap; /* bits: trace 0, bitmap 16-31 */ + short trace_bitmap; + short io_map; +// char io_space[8192]; + }; + +struct i387Struct { + long cwd; + long swd; + long twd; + long fip; + long fcs; + long foo; + long fos; + long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ + }; + +#endif + diff --git a/lockwasher/src/sys/include/sys/video.h b/lockwasher/src/sys/include/sys/video.h new file mode 100644 index 0000000..90087cf --- /dev/null +++ b/lockwasher/src/sys/include/sys/video.h @@ -0,0 +1,37 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: video.h,v 1.3 2003/04/08 15:39:16 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _VIDEO_H +#define _VIDEO_H + +#define defaultColor 0x0F + +extern int printColor; +extern int printfOff; + +void kprint(char *string); +int kprintf(const char *fmt, ...); +void clearScreen(); + +#endif + diff --git a/lockwasher/src/sys/include/types.h b/lockwasher/src/sys/include/types.h new file mode 100644 index 0000000..d50a2cf --- /dev/null +++ b/lockwasher/src/sys/include/types.h @@ -0,0 +1,2 @@ +/* $Id: types.h,v 1.1.1.1 2003/01/12 00:20:17 reddawg Exp $ */ + diff --git a/lockwasher/src/sys/include/ubixfs/ubixfs.h b/lockwasher/src/sys/include/ubixfs/ubixfs.h new file mode 100644 index 0000000..cd3da39 --- /dev/null +++ b/lockwasher/src/sys/include/ubixfs/ubixfs.h @@ -0,0 +1,111 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: ubixfs.h,v 1.11 2003/04/24 05:16:28 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _UBIXFS_H +#define _UBIXFS_H + +#include +#include +#include + +#define UBIXDISKMAGIC ((uInt32)0x45) /* The disk magic number */ +#define MAXUBIXPARTITIONS 16 +#define blockSize 8 + +//Partition Information +struct ubixDiskLabel { + uLong magicNum; + uLong magicNum2; + uShort driveType; + uShort numPartitions; + struct ubixPartitions { //the partition table + uLong pSize; //number of sectors in partition + uLong pOffset; //starting sector + uLong pFsSize; //filesystem basic fragment size + uLong pBatSize; //BAT size + uChar pFsType; //filesystem type, see below + uChar pFrag; //filesystem fragments per block + } partitions[MAXUBIXPARTITIONS]; + }; + + +struct partitionInformation { + uLong size; //Size In Sectors + uLong startSector; //Base Sector Of Partition + uLong blockAllocationTable; //Base Sector Of BAT + uLong rootDirectory; //Base Sector Of Root Directory + }; + +//Block Allocation Table Entry +struct blockAllocationTableEntry { + long attributes; //Block Attributes + long realSector; //Real Sector + long nextBlock; //Sector Of Next Block + long reserved; //Reserved + }; + +//UbixFS Directory Entry +struct directoryEntry { + uLong startCluster; //Starting Cluster Of File + uLong size; //Size Of File + uLong creationDate; //Date Created + uLong lastModified; //Date Last Modified + uLong uid; //UID Of Owner + uLong gid; //GID Of Owner + uShort attributes; //Files Attributes + uShort permissions; //Files Permissions + char fileName[256]; //File Name + }; + +struct bootSect { + uChar jmp[4]; + uChar id[6]; + uShort version; + uShort tmp; + uShort fsStart; + uShort tmp2; + uLong krnl_start; + uInt BytesPerSector; + uInt SectersPerTrack; + uInt TotalHeads; + uLong TotalSectors; + uChar code[479]; + }; + +struct ubixFsInfo { + struct blockAllocationTableEntry *blockAllocationTable; + uInt32 batEntries; + }; + +int readFile(char *file); +int writeFileByte(int ch,fileDescriptor *fd,long offset); +int openFileUbixFS(char *file,fileDescriptor *fd); +//extern struct ubixDiskLabel *diskLabel; + +//Good Functions +void initUbixFS(struct mountPoints *mp); +int enableUbixFS(); +int readUbixFS(fileDescriptor *fd,char *data,long offset,long size); +int writeUbixFS(fileDescriptor *fd,char *data,long offset,long size); + +#endif diff --git a/lockwasher/src/sys/include/ubixos/a.out.h b/lockwasher/src/sys/include/ubixos/a.out.h new file mode 100644 index 0000000..6df17cf --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/a.out.h @@ -0,0 +1,40 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: a.out.h,v 1.1.1.1 2003/01/12 00:20:17 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _A_OUT_H +#define _A_OUT_H + +#include + +typedef struct { + uLong aMagic; /* Use macros N_MAGIC, etc for access */ + unsigned aText; /* length of text, in bytes */ + unsigned aData; /* length of data, in bytes */ + unsigned aBss; /* length of uninitialized data area for file, in bytes */ + unsigned aSyms; /* length of symbol table data in file, in bytes */ + unsigned aEntry; /* start address */ + unsigned aTrsize; /* length of relocation info for text, in bytes */ + unsigned aDrsize; /* length of relocation info for data, in bytes */ + } aoutHeader; + +#endif \ No newline at end of file diff --git a/lockwasher/src/sys/include/ubixos/elf.h b/lockwasher/src/sys/include/ubixos/elf.h new file mode 100644 index 0000000..ccd5565 --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/elf.h @@ -0,0 +1,127 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: elf.h,v 1.4 2003/05/07 05:03:37 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _ELF_H +#define _ELF_H + +#include + +#define elfExecutable 0x002 +#define elfLibrary 0x003 + + +/* Elf Types */ +#define ET_NONE 0 // No file type +#define ET_REL 1 // Relocatable file +#define ET_EXEC 2 // Executable file +#define ET_DYN 3 // Shared object file +#define ET_CORE 4 // Core file +#define ET_LOPROC 0xff00 // Processor-specific +#define ET_HIPROC 0xffff +/* End Elf Types */ + +/* Elf Machine Types */ +#define EM_NONE 0 // No machine +#define EM_M32 1 // AT&T WE 32100 +#define EM_SPARC 2 // SPARC +#define EM_386 3 // Intel 80386 +#define EM_68K 4 // Motorola 68000 +#define EM_88K 5 // Motorola 88000 +#define EM_860 7 // Intel 80860 +#define EM_MIPS 8 // MIPS RS3000 +/* End Elf Machines Types */ + +/* Elf Version */ +#define EV_NONE 0 // Invalid version +#define EV_CURRENT 1 // Current version +/* End Elf Version */ + +/* Elf Program Header Types */ +#define PT_NULL 0 +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +/* End Elf Program Header Types */ + +typedef struct { + uChar eIdent[16]; /* File identification. */ + uShort eType; /* File type. */ + uShort eMachine; /* Machine architecture. */ + uLong eVersion; /* ELF format version. */ + uLong eEntry; /* Entry point. */ + uLong ePhoff; /* Program header file offset. */ + uLong eShoff; /* Section header file offset. */ + uLong eFlags; /* Architecture-specific flags. */ + uShort eEhsize; /* Size of ELF header in bytes. */ + uShort ePhentsize; /* Size of program header entry. */ + uShort ePhnum; /* Number of program header entries. */ + uShort eShentsize; /* Size of section header entry. */ + uShort eShnum; /* Number of section header entries. */ + uShort eShstrndx; /* Section name strings section. */ + } elfHeader; + +typedef struct { + uLong phType; /* Entry type. */ + uLong phOffset; /* File offset of contents. */ + uLong phVaddr; /* Virtual address in memory image. */ + uLong phPaddr; /* Physical address (not used). */ + uLong phFilesz; /* Size of contents in file. */ + uLong phMemsz; /* Size of contents in memory. */ + uLong phFlags; /* Access permission flags. */ + uLong phAlign; /* Alignment in memory and file. */ + } elfProgramheader; + +typedef struct { + uLong shName; /* Section name (index into the section header string table). */ + uLong shType; /* Section type. */ + uLong shFlags; /* Section flags. */ + uLong shAddr; /* Address in memory image. */ + uLong shOffset; /* Offset in file. */ + uLong shSize; /* Size in bytes. */ + uLong shLink; /* Index of a related section. */ + uLong shInfo; /* Depends on section type. */ + uLong shAddralign; /* Alignment in bytes. */ + uLong shEntsize; /* Size of each entry in section. */ + } elfSectionheader; + +typedef struct { + uLong pltOffset; + uLong pltInfo; + } elfPltInfo; + +typedef struct { + uLong dynName; + uLong dynValue; + uLong dynSize; + uLong dynInfo; + } elfDynsym; + +typedef struct { + uLong a; + uLong b; + } elfDynamic; + +char *elfGetShType(int); +char *elfGetPhType(int); + +#endif + diff --git a/lockwasher/src/sys/include/ubixos/exec.h b/lockwasher/src/sys/include/ubixos/exec.h new file mode 100644 index 0000000..8e93c55 --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/exec.h @@ -0,0 +1,31 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: exec.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#ifndef _EXEC_H +#define _EXEC_H + +void execThread(void (* tproc)(void),int stack,char *descr); +void execFile(char *file); + +#endif + diff --git a/lockwasher/src/sys/include/ubixos/file.h b/lockwasher/src/sys/include/ubixos/file.h new file mode 100644 index 0000000..eadf1a1 --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/file.h @@ -0,0 +1,70 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: file.h,v 1.10 2003/05/01 12:30:02 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _FILE_H +#define _FILE_H + +#include +#include + +#define maxFd 32 +#define fdAvail 1 +#define fdOpen 2 +#define fdRead 3 +#define fdEof 4 + +typedef struct fileDescriptorStruct { + struct fileDescriptorStruct *prev; + struct fileDescriptorStruct *next; + struct mountPoints *mp; + uInt16 status; + uInt16 mode; + uInt32 offset; + uInt32 size; + uInt16 length; + uInt32 start; + uChar fileName[22]; + char *buffer; + uInt32 dirBlock; + uInt32 perms; + } fileDescriptor; + +typedef struct userFileDescriptorStruct { + struct fileDescriptorStruct *fd; + uInt32 fdSize; + } userFileDescriptor; + +extern fileDescriptor *fdTable; +extern fileDescriptor *lastFd; + +fileDescriptor *fopen(const char *file,const char *flags); +int fclose(fileDescriptor *fd); +int feof(fileDescriptor *fd); +int fgetc(fileDescriptor *fd); +size_t fread(void *ptr, size_t size, size_t nmemb,fileDescriptor *fd); +size_t fwrite(void *ptr,int size,int nmemb,fileDescriptor *fd); +int fseek(fileDescriptor *,long,int); + +void sysFseek(userFileDescriptor *,long,int); + +#endif diff --git a/lockwasher/src/sys/include/ubixos/fork.h b/lockwasher/src/sys/include/ubixos/fork.h new file mode 100644 index 0000000..686adc4 --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/fork.h @@ -0,0 +1,32 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fork.h,v 1.1.1.1 2003/01/12 00:20:17 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _FORK_H +#define _FORK_H + +#include + +pid_t fork(); +pid_t testFork(); +void sysFork(); +#endif diff --git a/lockwasher/src/sys/include/ubixos/fs.h b/lockwasher/src/sys/include/ubixos/fs.h new file mode 100644 index 0000000..e670426 --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/fs.h @@ -0,0 +1,47 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fs.h,v 1.7 2003/04/24 05:16:28 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _FS_H +#define _FS_H + +#include + +struct fileSystem { + struct fileSystem *prev; + struct fileSystem *next; + int (*initFileSystem)(void *); + int (*read)(void *,char *,long,long); + int (*write)(void *,char *,long,long); + int (*openFile)(void *,void *); + int (*unlinkFile)(char *); + int (*mkDir)(char *,int); + int (*rmDir)(char *); + int (*sync)(void); + int fsType; + }; + +struct fileSystem *findFileSystem(int fsType); +int addFs(int fsType,void *initFileSystem,void *read,void *write,void *openFile,void *unlinkFile,void *mkDir,void *rmDir,void *sync); + +#endif + diff --git a/lockwasher/src/sys/include/ubixos/idlethread.h b/lockwasher/src/sys/include/ubixos/idlethread.h new file mode 100644 index 0000000..c3a580f --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/idlethread.h @@ -0,0 +1,30 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: idlethread.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#ifndef _IDLETHREAD_H +#define _IDLETHREAD_H + +void idleThread(); + +#endif + diff --git a/lockwasher/src/sys/include/ubixos/kpanic.h b/lockwasher/src/sys/include/ubixos/kpanic.h new file mode 100644 index 0000000..606ce81 --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/kpanic.h @@ -0,0 +1,30 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: kpanic.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#ifndef _KPANIC_H +#define _KPANIC_H + +void kPanic(char *); + +#endif + diff --git a/lockwasher/src/sys/include/ubixos/libcpp.h b/lockwasher/src/sys/include/ubixos/libcpp.h new file mode 100644 index 0000000..78f02c8 --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/libcpp.h @@ -0,0 +1,9 @@ +#ifndef __LIBCPP_H +#define __LIBCPP_H + +void * operator new(unsigned size); +void operator delete(void * ptr); +void * operator new[](unsigned size); +void operator delete[](void * ptr); + +#endif diff --git a/lockwasher/src/sys/include/ubixos/message.h b/lockwasher/src/sys/include/ubixos/message.h new file mode 100644 index 0000000..00d55df --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/message.h @@ -0,0 +1,51 @@ +#ifndef __MESSAGE_H +#define __MESSAGE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int connectionCreate(char * cname, uInt32 * cid, uInt8 flags); +int connectionOpen(char * cname, uInt32 * cid); +int messageRecv(uInt32 cid, uInt32 * sender, uInt32 * cmd, uInt32 * size, uInt8 * data); +int messageSend(uInt32 cid, uInt32 * cmd, uInt32 * size, uInt8 * data); +int messageReply(uInt32 cid, uInt32 mid, uInt32 cmd, uInt32 size, uInt8 * data); + +enum { + MSG_SEND = 0x1, + MSG_REPLY = 0x2 +}; + +#ifdef __cplusplus +} + +class message_t { + public: + uInt32 send_taskId; + uInt32 id; + uInt32 cmd; + uInt8 flags; + uInt8 size; + uInt8 data[256]; +}; + + +class connection_t { + public: + uInt32 used; + pid_t owning_pid; + Int8 unique_string[256]; + //waitQueue_t message_queue; + Queue * message_queue; + //waitQueue_t old_queue; + Queue * old_queue; +}; + + +#endif + +#endif diff --git a/lockwasher/src/sys/include/ubixos/mount.h b/lockwasher/src/sys/include/ubixos/mount.h new file mode 100644 index 0000000..c8e7997 --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/mount.h @@ -0,0 +1,45 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: mount.h,v 1.4 2003/04/24 05:16:28 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _MOUNT_H +#define _MOUNT_H + +#include + +struct mountPoints { + struct mountPoints *prev; + struct mountPoints *next; + struct fileSystem *fs; + struct driveDriver *drive; + void *fsInfo; + int partition; + char mountPoint[1024]; + char perms; + }; + +int mount(int driveId,int partition,int fsType,char *mountPoint,char *perms); +int addMount(struct mountPoints *mp); +struct mountPoints *findMount(char *mountPoint); + +#endif + diff --git a/lockwasher/src/sys/include/ubixos/panic.h b/lockwasher/src/sys/include/ubixos/panic.h new file mode 100644 index 0000000..cb126bd --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/panic.h @@ -0,0 +1,32 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: panic.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#ifndef _DMA_H +#define _DMA_H + +#include + +void panic(); + +#endif + diff --git a/lockwasher/src/sys/include/ubixos/schedule.h b/lockwasher/src/sys/include/ubixos/schedule.h new file mode 100644 index 0000000..aef2f65 --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/schedule.h @@ -0,0 +1,123 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provIded with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: schedule.h,v 2.15 2003/05/11 23:37:07 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _SCHEDULE_H +#define _SCHEDULE_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern int numTasks; + +// Possible states for tasks to be in. +enum { + STARTING = 0, READY, RUNNING, SUSPEND, SLEEP, BLOCK, + MSGREPLY, MSGWAIT, JOIN, EXITING, EMPTY +}; + +struct osInfo { + struct mountPoints *container; + elfSectionheader *sectionHeader; + uInt16 sectionCount; + uInt16 stringSection; + uInt8 timer; + uInt8 v86Task; + bool v86If; + uInt32 curDir; + uInt32 vmStart; + uInt32 stdinSize; + uInt32 controlKeys; + char *stdin; + char *shstrtab; + }; + +typedef struct taskStruct { + struct tssStruct tss; + struct i387Struct i387; + Int32 id; + uInt16 status; + uInt32 sleepTimeSec; + uInt32 sleepTimeMs; + uInt16 usedMath; + uInt32 cpuTime; + uInt32 lastExecutedTime; + Int16 uid; + Int16 gid; + struct osInfo oInfo; + } kTask_t; + +//extern kTask_t *taskList; +extern kTask_t *_current,*_usedMath; +extern int currentProc; + +void kpanic(char *); + +void initScheduler(); +kTask_t * findTask(); +kTask_t * getTask(int taskId); +void setTaskStatus(int taskId, uInt16 status); +void setTaskStatus_task(kTask_t * task, uInt16 status); +void timerInt(); +void schedule(); +void sched_yield(); +void sleep(uInt32 sec, uInt32 mSec); // sleeps current task. +void endTask(pidType); + +extern const uInt32 schedMagicNumber; + +struct waitQueueNode { + int id; + void * data; + struct waitQueueNode * next; + struct waitQueueNode * prev; + }; + +typedef struct waitQueue { + uInt32 magic_number; + uInt32 type; + struct waitQueueNode * first; + struct waitQueueNode * last; + } waitQueue_t; + +/* +waitQueue_t * waitQueueCreate(int); +void waitQueueInit(waitQueue_t *, int); +void waitQueueDelete(waitQueue_t *); +void waitQueueUnInit(waitQueue_t *); + +void waitQueueInsert(waitQueue_t *, void *, int); +void * waitQueueRemove(waitQueue_t *, int *); +void * waitQueueFind(waitQueue_t *, int); +*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lockwasher/src/sys/include/ubixos/spinlock.h b/lockwasher/src/sys/include/ubixos/spinlock.h new file mode 100644 index 0000000..e78cc6f --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/spinlock.h @@ -0,0 +1,40 @@ +#ifndef _SPINLOCK_H +#define _SPINLOCK_H + +enum spinlock_action +{ + SPIN_RETURN, + SPIN_HLT, + SPIN_SCHED, + SPIN_LOOP +}; + +typedef struct +{ + int count; // for recursion. + int owner; + + int ticket[16]; // allow up to 16 CPUs. + int choiceInProgress[16]; + + int deleteInProgress; + +} spinlock_t; + +enum spinlock_returns +{ + SPINLOCK_SUCCESS, + SPINLOCK_FAIL_DELETING +}; + +spinlock_t * spinlockCreate(); +void spinlockInit(spinlock_t *); +void spinlockDelete(spinlock_t *); + +int spinlockLock(spinlock_t *, int , int); +int spinlockUnlock(spinlock_t *, int); + +#endif + + + diff --git a/lockwasher/src/sys/include/ubixos/syscall.h b/lockwasher/src/sys/include/ubixos/syscall.h new file mode 100644 index 0000000..1df9702 --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/syscall.h @@ -0,0 +1,31 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: syscall.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#ifndef _SYSCALL_H +#define _SYSCALL_H + +void _sysCall(); +void invalidCall(); + +#endif + diff --git a/lockwasher/src/sys/include/ubixos/syscalls.h b/lockwasher/src/sys/include/ubixos/syscalls.h new file mode 100644 index 0000000..4f5d47d --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/syscalls.h @@ -0,0 +1,107 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: syscalls.h,v 1.13 2003/05/01 12:30:02 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _SYSCALLS_H +#define _SYSCALLS_H + +#include +#include + +void sysGetpid(); +void sysExit(); +void sysExec(); +void sysFork(); +void sysCheckPid(); +void sysGetFreePage(); + +void sysFwrite(); +void sysFgetc(); +void sysFopen(); +void sysFread(); +void sysFclose(); +void sysFseek(); +void sysMkDir(); +void sysRmDir(); +void sysGetUid(); +void sysGetGid(); +void sysSetUid(); +void sysSetGid(); +void sysSDE(); +void sysGetDrives(); +void sysGetCwd(); + +typedef void (*functionPTR)(); + +functionPTR systemCalls[] = { + invalidCall, /** 0 **/ + sysGetpid, /** 1 **/ + sysExit, /** 2 **/ + sysExec, /** 3 **/ + sysFork, /** 4 **/ + sysFgetc, /** 5 **/ + sysCheckPid, /** 6 **/ + sysGetFreePage, /** 7 **/ + sysFopen, /** 8 **/ + invalidCall, /** 9 **/ + sysFclose, /** 10 **/ + sched_yield, /** 11 **/ + invalidCall, /** 12 **/ + invalidCall, /** 13 **/ + invalidCall, /** 14 **/ + invalidCall, /** 15 **/ + invalidCall, /** 16 **/ + invalidCall, /** 17 **/ + invalidCall, /** 18 **/ + invalidCall, /** 19 **/ + sysFopen, /** 20 Opens A File Node **/ + sysFclose, /** 21 Closes A File Node **/ + sysFread, /** 22 File Read **/ + sysFwrite, /** 23 File Write **/ + sysMkDir, /** 24 Make Directory **/ + sysRmDir, /** 25 Remove Directory **/ + sysGetCwd, /** 26 Get Current Working Dir **/ + sysFseek, /** 27 Set FD Position **/ + invalidCall, /** 28 **/ + invalidCall, /** 29 **/ + invalidCall, /** 30 **/ + sysGetUid, /** 31 Get User Id **/ + sysGetGid, /** 32 Get Group Id **/ + sysSetUid, /** 33 Set User Id **/ + sysSetGid, /** 34 Set Group Id **/ + invalidCall, /** 35 **/ + invalidCall, /** 36 **/ + invalidCall, /** 37 **/ + invalidCall, /** 38 **/ + invalidCall, /** 39 **/ + sysSDE, /** 40 SDE Kernel Interface **/ + invalidCall, /** 41 **/ + invalidCall, /** 42 **/ + invalidCall, /** 43 **/ + invalidCall, /** 44 **/ + sysGetDrives, /** 45 Get Drives **/ + }; + +int totalCalls = sizeof(systemCalls)/sizeof(functionPTR); + +#endif + diff --git a/lockwasher/src/sys/include/ubixos/syserr.h b/lockwasher/src/sys/include/ubixos/syserr.h new file mode 100644 index 0000000..ad199b2 --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/syserr.h @@ -0,0 +1,34 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: syserr.h,v 2.2 2003/05/07 05:03:37 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _SYSERR_H +#define _SYSERR_H + +#include + +#define systemErr 0 +#define fileErr 1 + +void sysErr(uInt8,const char *,...); + +#endif \ No newline at end of file diff --git a/lockwasher/src/sys/include/ubixos/types.h b/lockwasher/src/sys/include/ubixos/types.h new file mode 100644 index 0000000..f88190a --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/types.h @@ -0,0 +1,60 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: types.h,v 1.5 2003/01/22 01:44:05 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _TYPES_H +#define _TYPES_H + +#ifndef NULL +#define NULL 0x0 +#endif + +typedef unsigned char byte; /* 8-bit byte */ +typedef unsigned short word; /* 16-bit word */ +typedef unsigned long dWord; /* 32-bit dword */ + +typedef unsigned char uChar; +typedef unsigned long uLong; +typedef unsigned short uShort; +typedef unsigned int uInt; + +typedef unsigned char uInt8; +typedef unsigned short uInt16; +typedef unsigned long uInt32; +typedef char Int8; +typedef short Int16; +typedef long Int32; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned long uint32_t; + +typedef int pidType; + +typedef int pid_t; +typedef int size_t; + +#ifndef NOBOOL +typedef enum { FALSE=0,TRUE=1 } bool; +#endif + +#endif diff --git a/lockwasher/src/sys/include/ubixos/version.h b/lockwasher/src/sys/include/ubixos/version.h new file mode 100644 index 0000000..56145f8 --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/version.h @@ -0,0 +1,32 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: version.h,v 1.4 2003/05/11 23:37:07 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _VERSION_H +#define _VERSION_H + +#define ubixosVersion "0.87" + +void outputVersion(); + +#endif + diff --git a/lockwasher/src/sys/include/ubixos/vitals.h b/lockwasher/src/sys/include/ubixos/vitals.h new file mode 100644 index 0000000..3c56e8a --- /dev/null +++ b/lockwasher/src/sys/include/ubixos/vitals.h @@ -0,0 +1,45 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: vitals.h,v 1.5 2003/05/07 05:03:37 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _VITALS_H +#define _VITALS_H + +#include +#include +#include +#include + +typedef struct vitalsStruct { + struct mountPoints *mountPoints; + struct fileSystem *fileSystems; + uInt32 openFiles; + uInt32 sysTicks; + uInt32 sysUptime; + uInt32 freePages; + sharedLib *sharedLibs; + } vitalsNode; + +extern vitalsNode *systemVitals; + +void initVitals(); +#endif diff --git a/lockwasher/src/sys/include/vmm/memory.h b/lockwasher/src/sys/include/vmm/memory.h new file mode 100644 index 0000000..a70a1ba --- /dev/null +++ b/lockwasher/src/sys/include/vmm/memory.h @@ -0,0 +1,50 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: memory.h,v 1.3 2003/03/13 00:29:44 apwillia Exp $ + +**************************************************************************************/ + +#ifndef _MEMORY_H +#define _MEMORY_H + +#include + +#define memAvail 1 +#define memNotavail 2 + +typedef struct { + uLong pageAddr; + uShort status; + pid_t pid; + int cowCounter; + } mMap; + +extern mMap *memoryMap; +extern int numPages; +extern uInt32 freePages; + +int countMemory(); +uLong findFreePage(pid_t pid); +void initMmap(); +void freeProcessPages(pid_t pid); +void adjustCowCounter(uLong baseAddr,int adjustment); + +#endif + diff --git a/lockwasher/src/sys/include/vmm/paging.h b/lockwasher/src/sys/include/vmm/paging.h new file mode 100644 index 0000000..e210b50 --- /dev/null +++ b/lockwasher/src/sys/include/vmm/paging.h @@ -0,0 +1,64 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: paging.h,v 1.6 2003/04/07 00:37:25 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _PAGING_H +#define _PAGING_H + +#include + +#define pageLength 0x00000400 +#define pageSize 4096 +#define pageEntries (pageSize/4) +#define pagePresent 0x00000001 +#define pageWrite 0x00000002 +#define pageUser 0x00000004 +#define pageCow 0x00000200 +#define pageStack 0x00000400 +#define pageDefault (pagePresent|pageWrite|pageUser) +#define kernelPageDefault (pagePresent|pageWrite) +#define tablesBaseAddress 0xBFC00000 +#define parentPageDirAddr 0x100000 + +extern uLong *kernelPageDirectory; +extern uLong *pageDirectory; +extern uLong memoryStart; + +void initPagingSystem(); +void *createVirtualSpace(pid_t pid); +void *copyVirtualSpace(pid_t pid); +void remapPage(uLong source,uLong dest); +void freePage(uLong pageAddr); +void unmapPage(uLong pageAddr,int flags); +void *getFreePage(pid_t pid); +void *getFreeVirtualPage(pid_t pid,int count); +void *getFreeKernelPage(pidType pid,uInt16 count); +void *getPhysicalAddr(uLong pageAddr); +void setPageAttribute(uLong pageAddr,int attributes); +void clearVirtualPage(uLong pageAddr); +void pageFault(); +void _pageFault(); +void *mapFromTask(pidType pid,void *ptr,uInt32 size); +void unmapPages(void *ptr,uInt32 size); +void doubleFault(); + +#endif diff --git a/lockwasher/src/sys/init/Makefile b/lockwasher/src/sys/init/Makefile new file mode 100644 index 0000000..750e817 --- /dev/null +++ b/lockwasher/src/sys/init/Makefile @@ -0,0 +1,36 @@ +# (C) 2002 The UbixOS Project +# $Id: Makefile,v 1.2 2003/03/13 02:02:33 apwillia Exp $ + +CFLAGS = -fno-builtin + +# Compiler +CC = gcc +CPP = g++ + + +# Linker +LINKER = ld + +# Remove +REMOVE = rm -fr + +# Objects +OBJS = main.o + +all: $(OBJS) + +# Compile Types +.cc.o: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.cc.s: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.c.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.c.s: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.S.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) diff --git a/lockwasher/src/sys/init/main.c b/lockwasher/src/sys/init/main.c new file mode 100644 index 0000000..0a78b40 --- /dev/null +++ b/lockwasher/src/sys/init/main.c @@ -0,0 +1,170 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: main.c,v 2.41 2003/05/07 05:03:37 reddawg Exp $ + +**************************************************************************************/ + +//Cleaned Up Here +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//Quick Desc For main() +int main(); + +/************************************************************************ + +Function: General Descriptor Table +Description: This Is Where The General Descriptor Table Is Defined The + Table Has 6 Entries They Are As Follows - + 0x00) Dummy Entry + 0x08) Ring 0 Code Segment + 0x10) Ring 0 Data Segment + 0x18) LDT Entry + 0x20) TSS Entry For Stack Faults + 0x28) TSS For Task Switch + 0x30) Ring 3 Code Segment + 0x38) Ring 3 Data Segment + 0x40) TSS For GPF +Notes: + +02/17/03 - I Will Have To Add Data/Code Segments For Rings 1,2,3 + +************************************************************************/ +descriptorTable(GDT,10) { + {dummy:0}, + standardDescriptor(0x0, 0xFFFFF, (dCode + dRead + dBig + dBiglim)), + standardDescriptor(0x0, 0xFFFFF, (dData + dWrite + dBig + dBiglim)), + standardDescriptor(0x0, 0xFFFFF, (dLdt)), + standardDescriptor(0x4000, (sizeof(struct tssStruct)-8192), (dTss)), + standardDescriptor(0x100000, sizeof(struct tssStruct), (dTss)), + standardDescriptor(0x0, 0xFFFFF, (dCode + dWrite + dBig + dBiglim + dDpl3)), + standardDescriptor(0x0, 0xFFFFF, (dData + dWrite + dBig + dBiglim + dDpl3)), + standardDescriptor(0x4200, (sizeof(struct tssStruct)-8192), (dTss)), + }; +struct { + unsigned short limit __attribute__ ((packed)); + union descriptorTableunion *gdt __attribute__ ((packed)); + } loadGdt = { (10 * sizeof(union descriptorTableunion) - 1), GDT }; + +/************************************************************************ + +Function: _start(); +Description: This Is The Main Entry Point For The Kernel We Just Re-Setup + The GDT Here And Set All The Default Register Values + +Notes: + +02/17/03 - I'm Unhappy With The Infinite Loop I Decided To Do If The Call + To Main Returns I Think I Shall Change It To A Kernel Panic + At A Later Date Then Reboot The Machine + +************************************************************************/ +void _start() { + asm("cli"); + asm( + "mov %cr0,%eax \n" + "and $0xFFFFFFFE,%eax \n" + "mov %eax,%cr0 \n" + "or $0x1,%eax \n" + "mov %eax,%cr0 \n" + "lgdtl (loadGdt) \n" + "movw $0x10,%ax \n" + "movw %ax,%ds \n" + "movw %ax,%es \n" + "movw %ax,%fs \n" + "movw %ax,%gs \n" + "movw %ax,%ss \n" + "movl $0xFFFF,%esp \n" + "mov $0x18,%ax \n" //Set up dummy LDT + "lldt %ax \n" + "mov $0x28,%ax \n" // Set up dummy TSS + "ltr %ax \n" // Loads dummy TSS + ); + main(); //Start Of Kernel Functionality + while(1); + } + +/************************************************************************ + +Function: int main(); +Description: This Is The Main Kernel Function Does All The Initialization + Then Starts The INIT Program Which Will Take Over +Notes: + +07/30/02 - I'm Considering Making The Kernel Fork Then Execute INIT + However It Seems To Be Pretty Stable As Is + +02/17/03 - Still Not Forking From Here Still Does All The Inits I'm + Going To Work Hard At Making It a Bit More Organized + +************************************************************************/ +int main() { + initMmap(); // Initialize Memory Map + initPagingSystem(); // Initialize Paging System + initVitals(); // Initialize Vitals Tracking + init8259(); // Initialize PIC + initIdt(); // Initialize IDT + enableUbixFS(); // Initialize File System + enableDevFS(); // Initialize Device File System + initPci(); // Initialize PCI Subsystem + //initLNC(); // Initialize LNC + initFloppy(); // Initialize Floppy Controller + //initHardDisk(); // Iintialize Hard Drives + mount(0x0,0x1,0x0,"sys","rw"); // Mount System File System + mount(0x0,0x0,0x0,"home","rw"); // Mount The Root File System + initKeyboard(); // Initialize Keyboard + initScheduler(); // Initialize Scheduler + //initPIT(1000); // Initialize Pit (Doesnt Work In Bochs) + //Make Nodes + devFsMkNod("drive1",'b',0x1,0x0); + loadLibrary("libc.so@sys"); + outputVersion(); // Display Version Info + execThread(idleThread,(uInt32)(kmalloc(4096,-2)+4095),"Idle Thread"); + execFile("init@sys"); + //execThread(sdeThread,(uInt32)(kmalloc(4096,-2)+4095),"SDE Thread"); + kprintf("Free Pages: [%i]\n",freePages); + enableIrq(0); + return(0); + } + + diff --git a/lockwasher/src/sys/isa/8259.c b/lockwasher/src/sys/isa/8259.c new file mode 100644 index 0000000..5e42092 --- /dev/null +++ b/lockwasher/src/sys/isa/8259.c @@ -0,0 +1,62 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: 8259.c,v 1.2 2003/02/18 00:02:10 reddawg Exp $ + +**************************************************************************************/ + +#include +#include + +unsigned int irqMask = 0xFFFF; + +/* Initializes The PIC */ +void init8259() { + outportByte(mPic, icw1); /* Initialize Master PIC */ + outportByte(sPic, icw1); /* Initialize Seconary PIC */ + outportByte(mPic+1, mVec); /* Master Interrup Vector */ + outportByte(sPic+1, sVec); /* Secondary Interrupt Vector */ + outportByte(mPic+1, 1<<2); /* Bitmask for cascade on IRQ 2 */ + outportByte(sPic+1, 2); /* Cascade on IRQ 2 */ + outportByte(mPic+1, icw4); /* Finish Primary Initialization */ + outportByte(sPic+1, icw4); /* Finish Seconary Initialization */ + outportByte(mImr, 0xff); /* Mask All Primary Interrupts */ + outportByte(sImr, 0xff); /* Mask All Seconary Interrupts */ + } + + +/* Enable IRQ # */ +void enableIrq(unsigned short irqNo) { + irqMask &= ~(1 << irqNo); + if (irqNo >= 8) { + irqMask &= ~(1 << 2); + } + outportByte(mPic+1, irqMask & 0xFF); + outportByte(sPic+1, (irqMask >> 8) & 0xFF); + } + +/* Disables IRQ # */ +void disableIrq(unsigned short irqNo) { + irqMask |= (1 << irqNo); + if ((irqMask & 0xFF00)==0xFF00) { + irqMask |= (1 << 2); + } + outportByte(mPic+1, irqMask & 0xFF); + outportByte(sPic+1, (irqMask >> 8) & 0xFF); + } diff --git a/lockwasher/src/sys/isa/Makefile b/lockwasher/src/sys/isa/Makefile new file mode 100644 index 0000000..f1df2b9 --- /dev/null +++ b/lockwasher/src/sys/isa/Makefile @@ -0,0 +1,36 @@ +# (C) 2002 The UbixOS Project +# $Id: Makefile,v 1.2 2003/03/13 02:02:33 apwillia Exp $ + +CFLAGS = -fno-builtin + +# Compiler +CC = gcc +CPP = g++ + + +# Linker +LINKER = ld + +# Remove +REMOVE = rm -fr + +# Objects +OBJS = atkbd.o 8259.o fdc.o pit.o + +all: $(OBJS) + +# Compile Types +.cc.o: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.cc.s: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.c.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.c.s: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.S.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) diff --git a/lockwasher/src/sys/isa/atkbd.c b/lockwasher/src/sys/isa/atkbd.c new file mode 100644 index 0000000..42d6805 --- /dev/null +++ b/lockwasher/src/sys/isa/atkbd.c @@ -0,0 +1,428 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: atkbd.c,v 1.10 2003/04/27 00:45:15 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +unsigned int keyMap = 0; +unsigned int ledStatus = 0; + +unsigned int keyboardMap[][8] = { +/* Ascii, Shift, Ctrl, Alt, Num, Caps, Shift Caps, Shift Num */ + { 0, 0, 0, 0, 0, 0, 0, 0}, +/* ESC */ { 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B}, +/* 1,! */ { 0x31, 0x21, 0, 0, 0x31, 0x31, 0x21, 0x21}, +/* 2,@ */ { 0x32, 0x40, 0, 0, 0x32, 0x32, 0x40, 0x40}, +/* 3,# */ { 0x33, 0x23, 0, 0, 0x33, 0x33, 0x23, 0x23}, +/* 4,$ */ { 0x34, 0x24, 0, 0, 0x34, 0x34, 0x24, 0x24}, +/* 5,% */ { 0x35, 0x25, 0, 0, 0x35, 0x35, 0x25, 0x25}, +/* 6,^ */ { 0x36, 0x5E, 0, 0, 0x36, 0x36, 0x5E, 0x5E}, +/* 7,& */ { 0x37, 0x26, 0, 0, 0x37, 0x37, 0x26, 0x26}, +/* 8,* */ { 0x38, 0x2A, 0, 0, 0x38, 0x38, 0x2A, 0x2A}, +/* 9.( */ { 0x39, 0x28, 0, 0, 0x39, 0x39, 0x28, 0x28}, +/* 0,) */ { 0x30, 0x29, 0, 0, 0x30, 0x30, 0x29, 0x29}, +/* -,_ */ { 0x2D, 0x5F, 0, 0, 0x2D, 0x2D, 0x5F, 0x5F}, +/* =,+ */ { 0x3D, 0x2B, 0, 0, 0x3D, 0x3D, 0x2B, 0x2B}, +/* 14 */ { 0x08, 0x08, 0x8, 0x8, 0x08, 0x08, 0x08, 0x08}, +/* 15 */ { 0x09, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x71, 0x51, 0, 0, 0, 0, 0, 0}, +/* */ { 0x77, 0x57, 0, 0, 0, 0, 0, 0}, +/* */ { 0x65, 0x45, 0, 0, 0, 0, 0, 0}, +/* */ { 0x72, 0x52, 0, 0, 0, 0, 0, 0}, +/* */ { 0x74, 0x54, 0, 0, 0, 0, 0, 0}, +/* */ { 0x79, 0x59, 0, 0, 0, 0, 0, 0}, +/* */ { 0x75, 0x55, 0, 0, 0, 0, 0, 0}, +/* */ { 0x69, 0x49, 0, 0, 0, 0, 0, 0}, +/* */ { 0x6F, 0x4F, 0, 0, 0, 0, 0, 0}, +/* */ { 0x70, 0x50, 0, 0, 0, 0, 0, 0}, +/* */ { 0x5B, 0x7B, 0, 0, 0, 0, 0, 0}, +/* */ { 0x5D, 0x3D, 0, 0, 0, 0, 0, 0}, +/* */ { 0x0A, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* a,A */ { 0x61, 0x41, 0x41, 0, 0, 0, 0, 0}, +/* */ { 0x73, 0x53, 0, 0, 0, 0, 0, 0}, +/* */ { 0x64, 0x44, 0, 0, 0, 0, 0, 0}, +/* */ { 0x66, 0x46, 0, 0, 0, 0, 0, 0}, +/* */ { 0x67, 0x47, 0, 0, 0, 0, 0, 0}, +/* */ { 0x68, 0x48, 0, 0, 0, 0, 0, 0}, +/* */ { 0x6A, 0x4A, 0, 0, 0, 0, 0, 0}, +/* */ { 0x6B, 0x4B, 0, 0, 0, 0, 0, 0}, +/* */ { 0x6C, 0x4C, 0, 0, 0, 0, 0, 0}, +/* */ { 0x3B, 0x3A, 0, 0, 0, 0, 0, 0}, +/* */ { 0x27, 0x07, 0, 0, 0, 0, 0, 0}, +/* */ { 0x60, 0x40, 0, 0, 0, 0, 0, 0}, +/* */ { 0x2A, 0x0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x5C, 0x3C, 0, 0, 0, 0, 0, 0}, +/* */ { 0x7A, 0x5A, 0, 0, 0, 0, 0, 0}, +/* */ { 0x78, 0x58, 0, 0, 0, 0, 0, 0}, +/* c,C */ { 0x63, 0x43, 0x3, 0, 0, 0, 0, 0}, +/* */ { 0x76, 0x56, 0, 0, 0, 0, 0, 0}, +/* */ { 0x62, 0x42, 0, 0, 0, 0, 0, 0}, +/* */ { 0x6E, 0x4E, 0, 0, 0, 0, 0, 0}, +/* */ { 0x6D, 0x4D, 0, 0, 0, 0, 0, 0}, +/* */ { 0x2C, 0x0C, 0, 0, 0, 0, 0, 0}, +/* */ { 0x2E, 0x0E, 0, 0, 0, 0, 0, 0}, +/* */ { 0x2F, 0x0F, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x20, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* F1 */ { 0x3001, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x3C00, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x3D00, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x3E00, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x3F00, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x4000, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x4100, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x4200, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x4300, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x4400, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x4700, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x4800, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x4900, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x2D, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x4B00, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x4C00, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x4D00, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x2B, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x4F00, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x5000, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x5100, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x5200, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0x5300, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 1, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0} + }; +void initKeyboard() { + setVector(keyboardIsr, mVec+1, dPresent + dInt + dDpl3); /* IRQ1 Handler */ + setLeds(); + outportByte(mPic, eoi); + enableIrq(1); + outportByte(mPic, eoi); + } + +asm( + ".globl keyboardIsr \n" + "keyboardIsr: \n" + " pusha \n" /* Save all registers */ +// " pushw %ds \n" /* Set up the data segment */ +// " pushw %es \n" +// " pushw %ss \n" /* Note that ss is always valid */ +// " pushw %ss \n" +// " popw %ds \n" +// " popw %es \n" + " call keyboardHandler \n" +// " popw %es \n" +// " popw %ds \n" /* Restore registers */ + " popa \n" + " iret \n" /* Exit interrupt */ + ); + +void keyboardHandler() { + unsigned int key = inportByte(0x60); + kTask_t *tmpTask = 0x0; + + tmpTask = getTask(0); + + if (tmpTask->oInfo.stdin == 0x0) { + tmpTask->oInfo.stdin = (char *)kmalloc(256,tmpTask->id); + } + /* Control Key */ + if (key == 0x1D && !(tmpTask->oInfo.controlKeys & controlKey)) { + tmpTask->oInfo.controlKeys |= controlKey; + } + if (key == 0x80 + 0x1D) { + tmpTask->oInfo.controlKeys &= (0xFF - controlKey); + } + /* ALT Key */ + if (key == 0x38 && !(tmpTask->oInfo.controlKeys & altKey)) { + tmpTask->oInfo.controlKeys |= altKey; + } + if (key == 0x80 + 0x38) { + tmpTask->oInfo.controlKeys &= (0xFF - altKey); + } + /* Shift Key */ + if ((key == 0x2A || key == 0x36) && !(tmpTask->oInfo.controlKeys & shiftKey)) { + tmpTask->oInfo.controlKeys |= shiftKey; + } + if ((key == 0x80 + 0x2A) || (key == 0x80 + 0x36)) { + tmpTask->oInfo.controlKeys &= (0xFF - shiftKey); + } + /* Caps Lock */ + if (key == 0x3A) { + ledStatus ^= ledCapslock; + setLeds(); + } + /* Num Lock */ + if (key == 0x45) { + ledStatus ^= ledNumlock; + setLeds(); + } + /* Scroll Lock */ + if (key == 0x46) { + ledStatus ^= ledScrolllock; + setLeds(); + } + /* Pick Which Key Map */ + if (tmpTask->oInfo.controlKeys == 0) { keyMap = 0; } + else if (tmpTask->oInfo.controlKeys == 1) { keyMap = 1; } + else if (tmpTask->oInfo.controlKeys == 2) { keyMap = 2; } + else if (tmpTask->oInfo.controlKeys == 4) { keyMap = 3; } + else { + //kprintf("controlKeys: [%i]\n",controlKeys); + } + //If Key Is Not Null Add It To Handler + if (((uInt)(keyboardMap[key][keyMap]) > 0) && ((uInt32)(keyboardMap[key][keyMap]) < 0xFF)) { + switch ((uInt32)keyboardMap[key][keyMap]) { + case 8: + //kprintf("BackSpace\n"); + backSpace(); + tmpTask->oInfo.stdin[tmpTask->oInfo.stdinSize] = keyboardMap[key][keyMap]; + tmpTask->oInfo.stdinSize++; + //kprintf("[0x%X]\n",tmpTask->oInfo.stdinSize); + //keystrokeBuffer[keystrokeBuffersize] = 0x0; + break; + case 0x3: + kprintf("End Task\n"); + //endTask(tmpTask->id); + break; + default: + tmpTask->oInfo.stdin[tmpTask->oInfo.stdinSize] = keyboardMap[key][keyMap]; + tmpTask->oInfo.stdinSize++; + break; + } + } + else { + //kprintf("Key: [%i], KeyMap: [%i],Key Char: [%i]\n",key,keyMap,keyboardMap[key][keyMap]); + } + outportByte(mPic, eoi); + //Return + return; + } + +void setLeds() { + outportByte(0x60, 0xED); + while(inportByte(0x64) & 2); + outportByte(0x60, ledStatus); + while(inportByte(0x64) & 2); + } + +//Temp +unsigned char getch() { + uInt8 retKey = 0x0; + uInt32 i = 0x0; + kTask_t *tmpTask = 0x0; + + tmpTask = getTask(0); + + while (tmpTask->oInfo.stdinSize == 0) { + sched_yield(); + } + retKey = tmpTask->oInfo.stdin[0]; + tmpTask->oInfo.stdinSize--; + + for (i=0x0;ioInfo.stdinSize;i++) { + tmpTask->oInfo.stdin[i] = tmpTask->oInfo.stdin[i+0x1]; + } + return(retKey); + } diff --git a/lockwasher/src/sys/isa/fdc.c b/lockwasher/src/sys/isa/fdc.c new file mode 100644 index 0000000..21a9490 --- /dev/null +++ b/lockwasher/src/sys/isa/fdc.c @@ -0,0 +1,284 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fdc.c,v 1.4 2003/04/05 04:21:07 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static volatile bool done = FALSE; +static drvGeom geometry = { dg144Heads,dg144Tracks,dg144Spt }; +static bool diskChange = FALSE; +static bool motor = FALSE; +static int mTick = 0; +static byte fdcTrack = 0xff; +static byte sr0 = 0; +static volatile int timeOut = 0; +static byte statSize = 0; +static byte status[7] = { 0 }; + +unsigned long tbaddr = 0x80000L; + +void initFloppy() { + setVector(floppyIsr, mVec+6, (dInt+dPresent)); + enableIrq(6); + reset(); + addDrive(0,0,0x0,fdcRead,fdcWrite,0x0); + return; + } + +asm( + ".globl floppyIsr \n" + "floppyIsr: \n" + " pusha \n" + " pushw %ds \n" + " pushw %es \n" + " pushw %ss \n" + " pushw %ss \n" + " popw %ds \n" + " popw %es \n" + " call floppyIsrhndlr \n" + " popw %es \n" + " popw %ds \n" + " popa \n" + " iret \n" + ); + +void floppyIsrhndlr() { + done = TRUE; + outportByte(0x20,0x20); + } + +void sendByte(int byte) { + volatile int msr; + int tmo; + for (tmo=0;tmo<128;tmo++) { + msr = inportByte(fdcMsr); + if ((msr & 0xc0) == 0x80) { + outportByte(fdcData,byte); + return; + } + inportByte(0x80); + } + } + +int getByte() { + volatile int msr; + int tmo; + for (tmo=0;tmo<128;tmo++) { + msr = inportByte(fdcMsr); + if ((msr & 0xd0) == 0xd0) { + return inportByte(fdcData); + } + inportByte(0x80); + } + return(-1); + } + +bool fdcRw(int block,byte *blockBuffer,bool read,unsigned long numSectors) { + int head,track,sector,tries, copyCount = 0; + unsigned char *p_tbaddr = (char *)0x80000; + unsigned char *p_blockbuff = blockBuffer; + block2Hts(block,&head,&track,§or); + motorOn(); + if (!read && blockBuffer) { + /* copy data from data buffer into track buffer */ + for (copyCount=0; copyCount<(numSectors*512); copyCount++) { + *p_tbaddr = *p_blockbuff; + p_blockbuff++; + p_tbaddr++; + } + } + for (tries = 0;tries < 3;tries++) { + if (inportByte(fdcDir) & 0x80) { + diskChange = TRUE; + seek(1); /* clear "disk change" status */ + recalibrate(); + motorOff(); + kprint("FDC: Disk change detected. Trying again.\n"); + return fdcRw(block, blockBuffer, read, numSectors); + } + if (!seek(track)) { + motorOff(); + kprintf("FDC: Error seeking to track [%i]\n",block); + return FALSE; + } + outportByte(fdcCcr,0); + if (read) { + dmaXfer(2,tbaddr,numSectors*512,FALSE); + sendByte(cmdRead); + } + else { + dmaXfer(2,tbaddr,numSectors*512,TRUE); + sendByte(cmdWrite); + } + sendByte(head << 2); + sendByte(track); + sendByte(head); + sendByte(sector); + sendByte(2); /* 512 bytes/sector */ + sendByte(geometry.spt); + if (geometry.spt == dg144Spt) { + sendByte(dg144Gap3rw); /* gap 3 size for 1.44M read/write */ + } + else { + sendByte(dg168Gap3rw); /* gap 3 size for 1.68M read/write */ + } + sendByte(0xff); /* DTL = unused */ + if (!waitFdc(TRUE)) { + kprint("Timed out, trying operation again after reset()\n"); + reset(); + return fdcRw(block, blockBuffer, read, numSectors); + } + if ((status[0] & 0xc0) == 0) break; /* worked! outta here! */ + recalibrate(); /* oops, try again... */ + } + motorOff(); + if (read && blockBuffer) { + p_blockbuff = blockBuffer; + p_tbaddr = (char *) 0x80000; + for (copyCount=0; copyCount<(numSectors*512); copyCount++) { + *p_blockbuff = *p_tbaddr; + p_blockbuff++; + p_tbaddr++; + } + } + return (tries != 3); + } + +void block2Hts(int block,int *head,int *track,int *sector) { + *head = (block % (geometry.spt * geometry.heads)) / (geometry.spt); + *track = block / (geometry.spt * geometry.heads); + *sector = block % geometry.spt + 1; + } + +void motorOn(void) { + if (!motor) { + mTick = -1; /* stop motor kill countdown */ + outportByte(fdcDor,0x1c); + motor = TRUE; + } + } + +void motorOff(void) { + if (motor) { + mTick = 13500; + } + } + +bool seek(int track) { + if (fdcTrack == track) { + return(TRUE); + } + sendByte(cmdSeek); + sendByte(0); + sendByte(track); + if (!waitFdc(TRUE)) { + return(FALSE); + } + if ((sr0 != 0x20) || (fdcTrack != track)) { + return(FALSE); + } + else { + return(TRUE); + } + } + +bool readBlock(int block,byte *blockBuffer, unsigned long numSectors) { + int track=0, sector=0, head=0, track2=0, result=0, loop=0; + block2Hts(block, &head, &track, §or); + block2Hts(block+numSectors, &head, &track2, §or); + if (track!=track2) { + for (loop=0; loop +#include + +/************************************************************************ + +Function: void initPIT() +Description: This Function Will Initialize The Programmable Timer +Notes: + +************************************************************************/ +void initPIT(int timerHz) { + outportByteP(0x43,0x3C); + outportByteP(0x40,((1193180/timerHz) & 0x00FF)); + outportByte(0x40,(((1193180/timerHz) >> 8) & 0x00FF)); + //Return + return; + } diff --git a/lockwasher/src/sys/kernel/Makefile b/lockwasher/src/sys/kernel/Makefile new file mode 100644 index 0000000..eae7291 --- /dev/null +++ b/lockwasher/src/sys/kernel/Makefile @@ -0,0 +1,36 @@ +# (C) 2002 The UbixOS Project +# $Id: Makefile,v 1.14 2003/05/04 13:20:15 reddawg Exp $ + +CFLAGS = -fno-builtin + +# Compiler +CC = gcc +CPP = g++ + + +# Linker +LINKER = ld + +# Remove +REMOVE = rm -fr + +# Objects +OBJS = syserr.o endtask.o bioscall.o file.o mount.o fs.o kpanic.o version.o schedule.o exec.o idlethread.o syscall.o fork.o spinlock.o vitals.o panic.o message.o elf.o + +all: $(OBJS) + +# Compile Types +.cc.o: + $(CPP) ${CFLAGS} -fno-exceptions -DNOBOOL -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.cc.s: + $(CPP) ${CFLAGS} -fno-exceptions -DNOBOOL -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.c.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.c.s: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.S.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) diff --git a/lockwasher/src/sys/kernel/bioscall.c b/lockwasher/src/sys/kernel/bioscall.c new file mode 100644 index 0000000..8be7bb1 --- /dev/null +++ b/lockwasher/src/sys/kernel/bioscall.c @@ -0,0 +1,62 @@ +#include +#include +#include +#include +#include +#include +#include + + +asm ( + ".globl bios16Code\n" + "bios16Code: \n" + "int $0x10 \n" + "int $0x69 \n" + ); + + +int biosCall(int biosInt,int eax,int ebx,int ecx,int edx,int esi,int edi,int es,int ds) { + short segment = 0x0,offset = 0x0; + uInt32 tmpAddr = (uInt32)&bios16Code; + kTask_t *newProcess = 0x0; + + offset = tmpAddr & 0xFFFF; + segment = (tmpAddr >> 4) & 0xF000; + + newProcess = findTask(); + + newProcess->tss.back_link = 0x0; + newProcess->tss.esp0 = (uInt32)kmalloc(4096,newProcess->id)+4096; + newProcess->tss.ss0 = 0x10; + newProcess->tss.esp1 = 0x0; + newProcess->tss.ss1 = 0x0; + newProcess->tss.esp2 = 0x0; + newProcess->tss.ss2 = 0x0; + newProcess->tss.cr3 = (uInt32)createVirtualSpace(newProcess->id); //(unsigned int)kernelPageDirectory; + newProcess->tss.eip = offset & 0xFFFF; + newProcess->tss.eflags = 2 | EFLAG_IF | EFLAG_VM; + newProcess->tss.eax = eax & 0xFFFF; + newProcess->tss.ebx = ebx & 0xFFFF; + newProcess->tss.ecx = ecx & 0xFFFF; + newProcess->tss.edx = edx & 0xFFFF; + newProcess->tss.esp = 0x1000 & 0xFFFF; + newProcess->tss.ebp = 0x1000 & 0xFFFF; + newProcess->tss.esi = esi & 0xFFFF; + newProcess->tss.edi = edi & 0xFFFF; + newProcess->tss.es = es & 0xFFFF; + newProcess->tss.cs = segment & 0xFFFF; + newProcess->tss.ss = 0x1000 & 0xFFFF; + newProcess->tss.ds = ds & 0xFFFF; + newProcess->tss.fs = 0x0 & 0xFFFF; + newProcess->tss.gs = 0x0 & 0xFFFF; + newProcess->tss.ldt = 0x0 & 0xFFFF; + newProcess->tss.trace_bitmap = 0x0 & 0xFFFF; + //newProcess->tss.io_map = sizeof(struct tssStruct)-8192; + newProcess->oInfo.v86Task = 0x1; + //kmemset(&newProcess->tss.io_space,0,8192); + setTaskStatus(newProcess->id, READY); + + while (newProcess->status != EXITING) sched_yield(); + + return(1); + } diff --git a/lockwasher/src/sys/kernel/elf.c b/lockwasher/src/sys/kernel/elf.c new file mode 100644 index 0000000..977b572 --- /dev/null +++ b/lockwasher/src/sys/kernel/elf.c @@ -0,0 +1,55 @@ +#include + +const struct { + char *elfTypeName; + uInt32 id; + } elfType[] = { + { "ET_NONE", 0 }, + { "ET_REL", 1 }, + { "ET_EXEC", 2 }, + { "ET_DYN", 3 }, + { "ET_CORE", 4 }, + { "ET_LOPROC", 0xff00 }, + { "ET_HIPROC", 0xffff }, + }; + +const struct { + char *phTypeName; + uInt32 id; + } elfPhType[] = { + { "PT_NULL", 0 }, + { "PT_LOAD", 1 }, + { "PT_DYNAMIC", 2 }, + { "PT_INTERP", 3 }, + { "PT_NOTE", 4 }, + { "PT_SHLIB", 5 }, + { "PT_PHDR", 6 }, + { "PT_LOPROC", 0x70000000 }, + { "PT_HIPROC", 0x7fffffff }, + }; + +const struct { + char *shTypeName; + uInt32 id; + } elfShType[] = { + {"SHT_NULL", 0 }, + {"SHT_PROGBITS", 1 }, + {"SHT_SYMTAB", 2 }, + {"SHT_STRTAB", 3 }, + {"SHT_RELA", 4 }, + {"SHT_HASH", 5 }, + {"SHT_DYNAMIC", 6 }, + {"SHT_NOTE", 7 }, + {"SHT_NOBITS", 8 }, + {"SHT_REL", 9 }, + {"SHT_SHLIB", 10 }, + {"SHT_DYNSYM", 11 }, + }; + +char *elfGetShType(int shType) { + return((char *)elfShType[shType].shTypeName); + } + +char *elfGetPhType(int phType) { + return((char *)elfPhType[phType].phTypeName); + } \ No newline at end of file diff --git a/lockwasher/src/sys/kernel/endtask.c b/lockwasher/src/sys/kernel/endtask.c new file mode 100644 index 0000000..8fb0323 --- /dev/null +++ b/lockwasher/src/sys/kernel/endtask.c @@ -0,0 +1,35 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: endtask.c,v 1.3 2003/04/23 23:08:19 reddawg Exp $ + +**************************************************************************************/ + + +#include +#include +#include +#include + +void endTask(pidType pid) { + kfreeProcess(pid); + freeProcessPages(pid); + setTaskStatus(pid, EXITING); + return; + } diff --git a/lockwasher/src/sys/kernel/exec.c b/lockwasher/src/sys/kernel/exec.c new file mode 100644 index 0000000..943dd3e --- /dev/null +++ b/lockwasher/src/sys/kernel/exec.c @@ -0,0 +1,379 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: exec.c,v 1.29 2003/05/11 23:37:07 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/************************************************************************ + +Function: void execFile(char *file); +Description: This Function Executes A Kile Into A New VM Space With Out + Having To Fork +Notes: + +07/30/02 - I Have Made Some Heavy Changes To This As Well As Fixed A Few + Memory Leaks The Memory Allocated To Load The Binary Into Is + Now Unmapped So It Can Be Used Again And Not Held Onto Until + The Program Exits + +07/30/02 - Now I Have To Make A Better Memory Allocator So We Can Set Up + The Freshly Allocated Pages With The Correct Permissions + +************************************************************************/ +void execFile(char *file) { + int i=0,x=0,eStart=0; + char *binarySpace = (char *)0x7C0000; + char *newLoc; + fileDescriptor *tmpFd = 0x0; + elfHeader *binaryHeader = (elfHeader *)0x7C0000; + elfProgramheader *programHeader; + //Get A New Task For This Proccess + _current = findTask(); + _current->gid = 0; + _current->uid = 0; + //Now We Must Create A Virtual Space For This Proccess To Run In + _current->tss.cr3 = (uLong)createVirtualSpace(_current->id); + //To Better Load This Application We Will Switch Over To Its VM Space + asm( + "movl %0,%%eax \n" + "movl %%eax,%%cr3 \n" + : : "d" ((uLong *)(_current->tss.cr3)) + ); + //Lets Find The File + tmpFd = fopen(file,"r"); + //If We Dont Find the File Return + if (!tmpFd) { + return; + } + //Now We Must Allocate Memory To Load The Binary Into + for (i=0;i<((tmpFd->size+4095)/4096);i++) { + remapPage(findFreePage(_current->id),(0x7C0000 + (0x1000 * i))); + } + //Load The Binary Into Memory Byte For Byte I Should Find A Faster Way + fread(binarySpace,tmpFd->size,1,tmpFd); + /* + for (i=0;feof(tmpFd) == 0;i++) { + binarySpace[i] = fgetc(tmpFd); + } + */ + //Close The File + fclose(tmpFd); + //Set programHeader To Point To Loaded Binary So We Can Gather Info + programHeader = (elfProgramheader *)(0x7C0000 + binaryHeader->ePhoff); + //Loop Through The Header And Load Sections Which Need To Be Loaded + for (i=0;iePhnum;i++) { + newLoc = (char *)programHeader[i].phVaddr; + /* + Allocate Memory Im Going To Have To Make This Load Memory With Corrent + Settings so it helps us in the future + */ + for (x=0;x<=((programHeader[i].phMemsz & 0xFFFFF000)+0x1000);x+=0x1000) { + remapPage(findFreePage(_current->id),((programHeader[i].phVaddr & 0xFFFFF000) + x)); + } + //Now Copy The Binary To Its Correct Location + for (x=0;xoInfo.vmStart = ((programHeader[i].phVaddr & 0xFFFFF000) + 0x1900000); + //Get The Starting Point + eStart = binaryHeader->eEntry; + //Now That We Relocated The Binary We Can Unmap And Free Old Pages + for (i=0;i<((tmpFd->size+4095)/4096);i++) { + unmapPage((0x7C0000 + (0x1000 * i)),0); + } + //Now Lets Make A Clean Stack + newLoc = (char *)0x5DB000; + remapPage(findFreePage(_current->id),0x5DC000); + setPageAttribute(0x5DC000,(pageDefault | pageStack)); + remapPage(findFreePage(_current->id),0x5DB000); + setPageAttribute(0x5DB000,(pageDefault | pageStack)); + remapPage(findFreePage(_current->id),0x5DA000); + setPageAttribute(0x5DA000,(pageDefault | pageStack)); + remapPage(findFreePage(_current->id),0x5D9000); + setPageAttribute(0x5D9000,(pageDefault | pageStack)); + + i = 0x5DD000; + + remapPage(findFreePage(_current->id),0x5D3000); + setPageAttribute(0x5D3000,(pageDefault | pageStack)); + remapPage(findFreePage(_current->id),0x5D2000); + setPageAttribute(0x5D2000,(pageDefault | pageStack)); + remapPage(findFreePage(_current->id),0x5D1000); + setPageAttribute(0x5D1000,(pageDefault | pageStack)); + remapPage(findFreePage(_current->id),0x5D0000); + setPageAttribute(0x5D0000,(pageDefault | pageStack)); + + //Set All The Proper Information For The Task + _current->tss.back_link = 0x0; + _current->tss.esp0 = 0x5D4000; + _current->tss.ss0 = 0x10; + _current->tss.esp1 = 0x0; + _current->tss.ss1 = 0x0; + _current->tss.esp2 = 0x0; + _current->tss.ss2 = 0x0; + _current->tss.eip = (long)eStart; + _current->tss.eflags = 0x206; + _current->tss.esp = i-16; + _current->tss.ebp = i; + _current->tss.esi = 0x0; + _current->tss.edi = 0x0; + _current->tss.es = 0x38+3; + _current->tss.cs = 0x30+3; + _current->tss.ss = 0x38+3; + _current->tss.ds = 0x38+3; + _current->tss.fs = 0x38+3; + _current->tss.gs = 0x38+3; + _current->tss.ldt = 0x18; + _current->tss.trace_bitmap = 0x0000; + _current->tss.io_map = 0x8000; + setTaskStatus(_current->id, READY); + + //_current->status = READY; + //Switch Back To The Kernels VM Space + asm( + "movl %0,%%eax \n" + "movl %%eax,%%cr3 \n" + : : "d" ((uLong *)(kernelPageDirectory)) + ); + //kprintf("Temp: [%i](%i)\n",getTask(0),getTask(0)->status); + //while(1); + //Finally Return + return; + } + +/************************************************************************ + +Function: void execThread(void (* tproc)(void),int stack,char *descr); +Description: This Function Executes A New Thread For Kernel And Does + Not Create Its Own VM Space +Notes: + +************************************************************************/ +void execThread(void (* tproc)(void),int stack,char *descr) { + kTask_t * newProcess; + //Find A New Thread + newProcess = findTask(); + //kprintf("newProcess: [%i](%i)\n",newProcess,newProcess->status); + //Set All The Correct Thread Attributes + newProcess->tss.back_link = 0x0; + newProcess->tss.esp0 = (uInt32)kmalloc(4096,newProcess->id)+4095;//0x5000; + newProcess->tss.ss0 = 0x10; + newProcess->tss.esp1 = 0x0; + newProcess->tss.ss1 = 0x0; + newProcess->tss.esp2 = 0x0; + newProcess->tss.ss2 = 0x0; + newProcess->tss.cr3 = (unsigned int)kernelPageDirectory; + newProcess->tss.eip = (unsigned int)tproc; + newProcess->tss.eflags = 0x206; + newProcess->tss.esp = stack; + newProcess->tss.ebp = stack; + newProcess->tss.esi = 0x0; + newProcess->tss.edi = 0x0; + + /* + newProcess->tss.es = 0x38+3;//0x10; + newProcess->tss.cs = 0x30+3;//0x08; + newProcess->tss.ss = 0x38+3;//0x10; + newProcess->tss.ds = 0x38+3;//0x10; + newProcess->tss.fs = 0x38+3;//0x10; + newProcess->tss.gs = 0x38+3;//0x10; + */ + + newProcess->tss.es = 0x10; + newProcess->tss.cs = 0x08; + newProcess->tss.ss = 0x10; + newProcess->tss.ds = 0x10; + newProcess->tss.fs = 0x10; + newProcess->tss.gs = 0x10; + newProcess->tss.ldt = 0x18; + + newProcess->tss.trace_bitmap = 0x0000; + newProcess->tss.io_map = 0x8000; + //newProcess->status = READY; + newProcess->oInfo.vmStart = 0x6400000; + setTaskStatus(newProcess->id, READY); + //Return + return; + } + +/************************************************************************ + +Function: void sysExec(); +Description: This Is The System Call To Execute A New Task + +Notes: + 04-22-03 - It Now Loads Sections Not The Full File + +************************************************************************/ +void sysExec(int argc,char **argv,char *file,int *status) { + int i = 0x0; + int x = 0x0; + uInt32 eStart = 0x0; + uInt32 *tmp = 0x0; + char *newLoc = 0x0; + + fileDescriptor *tmpFd = 0x0; + elfHeader *binaryHeader = 0x0; + elfProgramheader *programHeader = 0x0; + elfDynamic *elfDynamicS = 0x0; + elfSectionheader *sectionHeader = 0x0; + elfDynsym *elfDynsymS = 0x0; + elfPltInfo *elfPltInfoS = 0x0; + + asm("sti"); + + //kprintf("Status: [0x%X]\n",*status); + + tmpFd = fopen(file,"r"); + //If We Dont Find the File Return + if (tmpFd == 0x0) { + *status = 0; + return; + } + if (tmpFd->perms == 0) { + *status = -2; + kprintf("Exec Format Error: Binary File Not Executable.\n"); + fclose(tmpFd); + return; + } + + //Load ELF Header + binaryHeader = (elfHeader *)kmalloc(sizeof(elfHeader),_current->id); + fread(binaryHeader,sizeof(elfHeader),1,tmpFd); + + //Set sectionHeader To Point To Loaded Binary To We Can Gather Info + //sectionHeader = (elfSectionheader *)(0x7C0000 + binaryHeader->eShoff); + + //Check If App Is A Real Application + if ((binaryHeader->eIdent[1] != 'E') && (binaryHeader->eIdent[2] != 'L') && (binaryHeader->eIdent[3] != 'F')) { + *status = -1; + kprintf("Exec Format Error: Binary File Not Executable.\n"); + kfree(binaryHeader); + fclose(tmpFd); + return; + } + else if (binaryHeader->eType != 2) { + *status = -2; + kprintf("Exec Format Error: Binary File Not Executable.\n"); + kfree(binaryHeader); + fclose(tmpFd); + return; + } + else if (binaryHeader->eEntry == 0x300000) { + *status = -2; + kprintf("Exec Format Error: Binary File Not Executable.\n"); + kfree(binaryHeader); + fclose(tmpFd); + return; + } + + //Load The Program Header(s) + programHeader = (elfProgramheader *)kmalloc(sizeof(elfProgramheader)*binaryHeader->ePhnum,_current->id); + fseek(tmpFd,binaryHeader->ePhoff,0); + fread(programHeader,sizeof(elfProgramheader)*binaryHeader->ePhnum,1,tmpFd); + + sectionHeader = (elfSectionheader *)kmalloc(sizeof(elfSectionheader)*binaryHeader->eShnum,_current->id); + fseek(tmpFd,binaryHeader->eShoff,0); + fread(sectionHeader,sizeof(elfSectionheader)*binaryHeader->eShnum,1,tmpFd); + + //Loop Through The Header And Load Sections Which Need To Be Loaded + for (i=0;iePhnum;i++) { + if (programHeader[i].phType == 1) { + newLoc = (char *)programHeader[i].phVaddr; + /* + Allocate Memory Im Going To Have To Make This Load Memory With Corrent + Settings so it helps us in the future + */ + for (x=0;x<=((programHeader[i].phMemsz & 0xFFFFF000)+4095);x+=4096) { + remapPage(findFreePage(_current->id),((programHeader[i].phVaddr & 0xFFFFF000) + x)); + } + _current->oInfo.vmStart = ((programHeader[i].phVaddr & 0xFFFFF000) + 0x1900000); + //Now Load Section To Memory + fseek(tmpFd,programHeader[i].phOffset,0); + fread(newLoc,programHeader[i].phFilesz,1,tmpFd); + } + else if (programHeader[i].phType == 2) { + newLoc = (char *)programHeader[i].phVaddr; + fseek(tmpFd,programHeader[i].phOffset,0); + fread(newLoc,programHeader[i].phFilesz,1,tmpFd); + } + } + + _current->oInfo.shstrtab = (char *)kmalloc(sectionHeader[binaryHeader->eShstrndx].shSize,_current->id); + fseek(tmpFd,sectionHeader[binaryHeader->eShstrndx].shOffset,0); + fread(_current->oInfo.shstrtab,sectionHeader[binaryHeader->eShstrndx].shSize,0,tmpFd); + + + + kprintf("[%s]\n",_current->oInfo.shstrtab+1); + + for (i=0;ieShnum;i++) { + switch (sectionHeader[i].shType) { + case 0: + break; + case 9: + elfPltInfoS = (elfPltInfo *)sectionHeader[i].shAddr; + for (x=0x0;xoInfo.sectionHeader = sectionHeader; + _current->oInfo.sectionCount = binaryHeader->eShnum; + _current->oInfo.stringSection = binaryHeader->eShstrndx; + + //Get The Starting Point + eStart = binaryHeader->eEntry; + + //Now That We Relocated The Binary We Can Unmap And Free Header Info + kfree(binaryHeader); + kfree(programHeader); + fclose(tmpFd); + + //Jump To Start Of New Binary + asm( + + "pushl %1\n" + "pushl %1\n" + "pushl %0\n" + "jmp *%2\n" + : + : "g" (argc),"g" (argv),"g" (eStart) + ); + } diff --git a/lockwasher/src/sys/kernel/file.c b/lockwasher/src/sys/kernel/file.c new file mode 100644 index 0000000..313e510 --- /dev/null +++ b/lockwasher/src/sys/kernel/file.c @@ -0,0 +1,337 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: file.c,v 1.19 2003/05/01 12:30:02 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include + +fileDescriptor *fdTable = 0x0; + +//These Are Temporary +int sprintf(char *buf,const char *fmt, ...); +char getch(); + +/************************************************************************ + +Function: fileDescriptor *fopen(const char *file,cont char *flags) +Description: This Will Open A File And Return A File Descriptor +Notes: + +08/05/02 - Just Started A Rewrite Of This Function Should Work Out Well + +************************************************************************/ + +fileDescriptor *fopen(const char *file,const char *flags) { + int i = 0; + fileDescriptor *tmpFd = 0x0; + char *path = 0x0,*mountPoint = 0x0; + //Allocate Memory For File Descriptor + tmpFd = (fileDescriptor *)kmalloc(sizeof(fileDescriptor),-2); + + path = (char *)strtok((char *)file,"@"); + mountPoint = strtok(NULL,"\n"); + if (mountPoint == 0x0) { + tmpFd->mp = _current->oInfo.container; + } + else { + tmpFd->mp = findMount(mountPoint); + } + if (tmpFd->mp == 0x0) { + //sysErr("Mount Point Bad"); + return(0x0); + } + //This Will Set Up The Descriptor Modes + while ('\0' != flags[i]) { + switch(flags[i]) { + case 'w': + case 'W': + tmpFd->mode = 1; + break; + case 'r': + case 'R': + tmpFd->mode = 0; + break; + default: + break; + } + i++; + } + //Search For The File + if (tmpFd->mp->fs->openFile((char *)file,tmpFd) == 1) { + //If The File Is Found Then Set Up The Descriptor + tmpFd->buffer = (char *)kmalloc(4096,_current->id); + sprintf(tmpFd->fileName,"%s",file); + //Set Its Status To Open + tmpFd->status = fdOpen; + //Initial File Offset Is Zero + tmpFd->offset = 0x0; + //Pointer To Next Descriptor Is NULL + tmpFd->prev = 0x0; + //If This Is The First File Descriptor Then Set It Up To Be Starting Fd + if (fdTable == 0x0) { + fdTable = tmpFd; + tmpFd->next = 0x0; + tmpFd->prev = 0x0; + } + else { + //If There Is Already A Starting FD Set This Up As The Last One + tmpFd->next = fdTable; + fdTable->prev = tmpFd; + tmpFd->prev = 0x0; + fdTable = tmpFd; + } + systemVitals->openFiles++; + //Return The FD + return(fdTable); + } + else { + //If The File Was Not Found Free The Memory + kfree(tmpFd); + } + //Return NULL + return(0x0); + } + +/************************************************************************ + +Function: int feof(fileDescriptor *fd) +Description: Check A File Descriptor For EOF And Return Result +Notes: + +************************************************************************/ +int feof(fileDescriptor *fd) { + if (fd->status == fdEof) { + return(-1); + } + return(0); + } + +/************************************************************************ + +Function: int fclose(fileDescriptor *fd); +Description: This Will Close And Free A File Descriptor +Notes: + +************************************************************************/ +int fclose(fileDescriptor *fd) { + fileDescriptor *tmpFd = 0x0; + //Search For File Descriptor + for (tmpFd=fdTable;tmpFd;tmpFd=tmpFd->next) { + if (tmpFd == fd) { + //If Fd Is The First FD Then Reset fdTable + if (tmpFd == fdTable) { + fdTable = tmpFd->next; + if (fdTable != 0x0) { + fdTable->prev = 0x0; + } + kfree(fd->buffer); + kfree(fd); + systemVitals->openFiles--; + return(1); + } + else { + tmpFd->prev->next = tmpFd->next; + tmpFd->next->prev = tmpFd->prev; + kfree(fd->buffer); + kfree(fd); + systemVitals->openFiles--; + return(1); + } + } + } + //Return NULL If Descriptor Was Not Found + return(0x0); + } + +/************************************************************************ + +Function: int fputc(int ch,fileDescriptor *fd) +Description: This Will Write Character To FD +Notes: + +************************************************************************/ +int fputc(int ch,fileDescriptor *fd) { + fileDescriptor *tmpFd = 0x0; + //Search For File Descriptor + for (tmpFd=fdTable;tmpFd;tmpFd=tmpFd->next) { + //If Found Return Next Char + if (tmpFd == fd) { + ch = tmpFd->mp->fs->write(tmpFd,(char *)ch,tmpFd->offset,1); + tmpFd->offset++; + return(ch); + } + } + //Return NULL If FD Is Not Found + return(0x0); + } + +/************************************************************************ + +Function: int fgetc(fileDescriptor *fd) +Description: This Will Return The Next Character In A FD Stream +Notes: + +************************************************************************/ +int fgetc(fileDescriptor *fd) { + int ch = 0x0; + fileDescriptor *tmpFd = 0x0; + //Search For File Descriptor + for (tmpFd=fdTable;tmpFd;tmpFd=tmpFd->next) { + //If Found Return Next Char + if (tmpFd == fd) { + tmpFd->mp->fs->read(tmpFd,(char *)ch,tmpFd->offset,1); + tmpFd->offset++; + return(ch); + } + } + //Return NULL If FD Is Not Found + return(0x0); + } + +size_t fread(void *ptr,int size,int nmemb,fileDescriptor *fd) { + fileDescriptor *tmpFd = 0x0; + //Search For File Descriptor + for (tmpFd=fdTable;tmpFd;tmpFd=tmpFd->next) { + //If Found Return Next Char + if (tmpFd == fd) { + tmpFd->mp->fs->read(tmpFd,ptr,tmpFd->offset,size * nmemb); + tmpFd->offset += size * nmemb; + } + } + return(0x0); + } + +size_t fwrite(void *ptr,int size,int nmemb,fileDescriptor *fd) { + fileDescriptor *tmpFd = 0x0; + //Search For File Descriptor + for (tmpFd=fdTable;tmpFd;tmpFd=tmpFd->next) { + //If Found Return Next Char + if (tmpFd == fd) { + tmpFd->mp->fs->write(tmpFd,ptr,tmpFd->offset,size * nmemb); + tmpFd->offset += size * nmemb; + } + } + return(0x0); + } + +/************************************************************************ + +Function: void sysFopen(); +Description: Opens A File Descriptor For A User Task +Notes: + +************************************************************************/ +void sysFopen(char *file,char *flags,userFileDescriptor *userFd) { + asm("sti"); + userFd->fd = fopen(file,flags); + userFd->fdSize = userFd->fd->size; + //Return + return; + } + +/* +size_t fread(void *ptr, int size, int nmemb,fileDescriptor *fd) { + + // YO! what about EOF's in the middle of reading?? + + int i = 0x0; + char *data = (char *)ptr; + for (i=0;ifd); + //Return + return; + } + +void sysFwrite(char *ptr,int size,userFileDescriptor *userFd) { + char data[1024]; + int i=0; + //Temp Hack + if (userFd->fd == 0x0) { + for (i=0;ifd); + } + } +/************************************************************************ + +Function: void sysFclse(); +Description: Closes A File Descriptor For A User Task +Notes: + +************************************************************************/ +void sysFclose(userFileDescriptor *userFd,int *status) { + *status = fclose(userFd->fd); + //Return + return; + } + +void sysFgetc(int *ptr,userFileDescriptor *userFd) { + fileDescriptor *tmpFd = 0x0; + asm("sti"); + tmpFd = userFd->fd; + if (userFd->fd == 0) { + ptr[0] = (int) getch(); + } + else { + ptr[0] = (int) fgetc(tmpFd); + } + } + +void sysMkDir() { + return; + } + +void sysRmDir() { + return; + } + +int fseek(fileDescriptor *tmpFd,long offset,int whence) { + tmpFd->offset = offset+whence; + return(tmpFd->offset); + } + +void sysFseek(userFileDescriptor *userFd,long offset,int whence) { + kprintf("Word: [0x%X][0x%X]\n",userFd,userFd->fd); + userFd->fd->offset = offset+whence; + } \ No newline at end of file diff --git a/lockwasher/src/sys/kernel/fork.c b/lockwasher/src/sys/kernel/fork.c new file mode 100644 index 0000000..588be16 --- /dev/null +++ b/lockwasher/src/sys/kernel/fork.c @@ -0,0 +1,103 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fork.c,v 1.11 2003/04/22 13:51:46 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include + + +/************************************************************************ + +Function: void sysFork(); +Description: This Function Forks A Task +Notes: + +08/01/02 - This Seems To Be Working Fine However I'm Not Sure If I + Chose The Best Path To Impliment It I Guess We Will See + What The Future May Bring + +************************************************************************/ +void sysFork(); +__asm__( + ".global sysFork \n" + "sysFork: \n" + " xor %eax,%eax \n" + " call findTask \n" + " testl %eax,%eax \n" + " je 1f \n" + " push %gs \n" + " pushl %esi \n" + " pushl %edi \n" + " pushl %ebp \n" + " pushl %eax \n" + " call copyProcess \n" + " movl %eax,(%ebx) \n" + " popl %eax \n" + " popl %ebp \n" + " popl %edi \n" + " popl %esi \n" + " pop %gs \n" + "1: \n" + " ret \n" + ); + +int copyProcess(struct taskStruct *newProcess,long ebp,long edi,long esi,long gs,long none,long ebx,long ecx,long edx,long fs,long es,long ds,long eip,long cs,long eflags,long esp,long ss) { + //Set Up New Tasks Information + newProcess->uid = _current->uid; + newProcess->gid = _current->gid; + newProcess->tss.back_link = 0x0; + newProcess->tss.esp0 = _current->tss.esp0; + newProcess->tss.ss0 = 0x10; + newProcess->tss.esp1 = 0x0; + newProcess->tss.ss1 = 0x0; + newProcess->tss.esp2 = 0x0; + newProcess->tss.ss2 = 0x0; + newProcess->tss.eflags = eflags; + newProcess->tss.eax = 0x0; + newProcess->tss.ebx = ebx; + newProcess->tss.ecx = ecx; + newProcess->tss.edx = edx; + newProcess->tss.esi = esi; + newProcess->tss.edi = edi; + newProcess->tss.ebp = ebp; + newProcess->tss.esp = esp; + newProcess->tss.es = es & 0xFF; + newProcess->tss.cs = cs & 0xFF; + newProcess->tss.ss = ss & 0xFF; + newProcess->tss.ds = ds & 0xFF; + newProcess->tss.fs = fs & 0xFF; + newProcess->tss.gs = gs & 0xFF; + newProcess->tss.ldt = 0x18; + newProcess->tss.trace_bitmap = 0x0000; + newProcess->tss.io_map = 0x8000; + newProcess->tss.eip = eip; + //Create A Copy Of The VM Space For New Task + newProcess->tss.cr3 = (long)copyVirtualSpace(newProcess->id); + newProcess->oInfo.curDir = _current->oInfo.curDir; + newProcess->oInfo.container = _current->oInfo.container; + setTaskStatus(newProcess->id, READY); + //Return + return(newProcess->id); + } + diff --git a/lockwasher/src/sys/kernel/fs.c b/lockwasher/src/sys/kernel/fs.c new file mode 100644 index 0000000..22f6893 --- /dev/null +++ b/lockwasher/src/sys/kernel/fs.c @@ -0,0 +1,74 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: fs.c,v 1.4 2003/03/27 04:23:43 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include + +struct fileSystem *findFileSystem(int fsType) { + struct fileSystem *tmp = 0x0; + + //Search For File System + for (tmp=systemVitals->fileSystems;tmp;tmp=tmp->next) { + //If Found Return File System + if (tmp->fsType == fsType) { + return(tmp); + } + } + + //If FS Not Found Return NULL + return(0x0); + } + +int addFs(int fsType,void *initFileSystem,void *read,void *write,void *openFile,void *unlinkFile,void *mkDir,void *rmDir,void *sync) { + struct fileSystem *tmpFs = 0x0; + + //Allocate Memory + tmpFs = (struct fileSystem *)kmalloc(sizeof(struct fileSystem),-2); + + //Set Up FS Defaults + tmpFs->fsType = fsType; + tmpFs->initFileSystem = initFileSystem; + tmpFs->read = read; + tmpFs->write = write; + tmpFs->openFile = openFile; + tmpFs->unlinkFile = unlinkFile; + tmpFs->mkDir = mkDir; + tmpFs->rmDir = rmDir; + tmpFs->sync = sync; + + if (!systemVitals->fileSystems) { + tmpFs->prev = 0x0; + tmpFs->next = 0x0; + systemVitals->fileSystems = tmpFs; + } + else { + tmpFs->prev = 0x0; + tmpFs->next = systemVitals->fileSystems; + systemVitals->fileSystems->prev = tmpFs; + systemVitals->fileSystems = tmpFs; + } + + return(1); + } + diff --git a/lockwasher/src/sys/kernel/idlethread.c b/lockwasher/src/sys/kernel/idlethread.c new file mode 100644 index 0000000..5f50568 --- /dev/null +++ b/lockwasher/src/sys/kernel/idlethread.c @@ -0,0 +1,39 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: idlethread.c,v 1.11 2003/04/23 23:08:19 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include + +void idleThread() { + while (1==1) { + if (mallocLock != 0x0) { + if (getTask(mallocLock) == 0x0) { + mallocLock = 0x0; + } + } + asm("hlt"); + //checkTasks(); /* Looks for run away proccesses and kills thems */ + } + } diff --git a/lockwasher/src/sys/kernel/kpanic.c b/lockwasher/src/sys/kernel/kpanic.c new file mode 100644 index 0000000..435f26d --- /dev/null +++ b/lockwasher/src/sys/kernel/kpanic.c @@ -0,0 +1,38 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: kpanic.c,v 1.1 2003/01/12 19:52:16 reddawg Exp $ + +**************************************************************************************/ + +#include +//#include + +/************************************************************************ + +Function: void kPanic(); +Description: This Function Does A Kernel Panic +Notes: + +************************************************************************/ +void kPanic(char *string) { + // kprintf(string); + asm("hlt"); + return; + } diff --git a/lockwasher/src/sys/kernel/message.cc b/lockwasher/src/sys/kernel/message.cc new file mode 100644 index 0000000..4991151 --- /dev/null +++ b/lockwasher/src/sys/kernel/message.cc @@ -0,0 +1,187 @@ + +#include +#include +#include + + +static int inited = 0; +#define __MESSAGE_CONNECTION_COUNT 4 +static const unsigned int connectionCount = __MESSAGE_CONNECTION_COUNT; +static int messageCount = 0; +static connection_t * connections; + +static void messageInit() +{ + unsigned int i; + + if (inited) + return; + + connections = (connection_t *) kmalloc(connectionCount * sizeof(connection_t), -1); + + for (i = 0; i < connectionCount; i++) + { + kmemset(&connections[i], '\0', sizeof(connection_t)); + //waitQueueInit(&connections[i].message_queue, 0); + connections[i].message_queue = new Queue(); + //waitQueueInit(&connections[i].old_queue, 0); + connections[i].old_queue = new Queue(); + } + + inited = 1; +} + +int connectionCreate(char * cname, uInt32 * cid, uInt8 flags) +{ + unsigned int i; + + if (!inited) + messageInit(); + + for (i = 0; i < connectionCount; i++) + if (connections[i].used == 0) + break; + if (connections[i].used != 0) + return -1; + + connections[i].used = 1; + kstrncpy(connections[i].unique_string, cname, 256); + connections[i].owning_pid = _current->id; + + *cid = i; + + return 0; +} + +int connectionOpen(char * cname, uInt32 * cid) +{ + unsigned int i; + if (!inited) + messageInit(); + + for (i = 0; i < connectionCount; i++) + if (connections[i].used == 1) + if (0 == kstrncmp(connections[i].unique_string, cname, 256)) + break; + + if (connections[i].used == 0) + return -1; + if (0 != kstrncmp(connections[i].unique_string, cname, 256)) + return -1; + + *cid = i; + return 0; +} + +int messageRecv(uInt32 cid, uInt32 * sender, uInt32 * cmd, uInt32 * size, uInt8 * data) +{ + message_t * temp = NULL; + //int notUsed; + + if (!inited) + return -1; + + if (cid >= connectionCount) + return -1; + + //if (connections[cid].used == 0); + // return -1; + + if (connections[cid].owning_pid != _current->id) + return -1; + do + { + //temp = (message_t *) waitQueueRemove(&connections[cid].message_queue, ¬Used); + temp = connections[cid].message_queue->pop(); + + if (temp == NULL) + { + setTaskStatus_task(_current, MSGWAIT); + schedule(); + } + } + while(temp == NULL); + + kmemcpy(data, temp->data, temp->size); + *cmd = temp->cmd; + *size = temp->size; + *sender = temp->send_taskId; + + //waitQueueInsert(&connections[cid].old_queue, temp, temp->id); + connections[cid].old_queue->insert(temp->id, temp); + + return temp->id; +} + +int messageSend(uInt32 cid, uInt32 * cmd, uInt32 * size, uInt8 * data) +{ + message_t * temp; + kTask_t * task; + + if (!inited) + return -1; + + if (cid >= connectionCount) + return -1; + + if (connections[cid].used == 0) + return -1; + + temp = (message_t *) kmalloc(sizeof(message_t), -1); + + temp->cmd = *cmd; + temp->size = *size; + kmemcpy((void *) temp->data, (void *) data, *size); + temp->send_taskId = _current->id; + temp->id = messageCount; + messageCount++; + temp->flags = MSG_SEND; + + //waitQueueInsert(&connections[cid].message_queue, (void *) temp, temp->id); + connections[cid].message_queue->insert(temp->id, temp); + + task = getTask(connections[cid].owning_pid); + if (task != NULL) + { + if (task->status == MSGWAIT) + setTaskStatus_task(task, READY); + } + + while((temp->flags & MSG_REPLY) != MSG_REPLY) + { + setTaskStatus_task(_current, MSGREPLY); + schedule(); + } + + *cmd = temp->cmd; + *size= temp->size; + kmemcpy((void *) data, (void *) temp->data, *size); + + kfree((void *)temp); + + return 0; + +} + +int messageReply(uInt32 cid, uInt32 mid, uInt32 cmd, uInt32 size, uInt8 * data) +{ + message_t * temp = NULL; + if (!inited) + return -1; + if (cid >= connectionCount) + return -1; + if (connections[cid].used == 0) + return -1; + //temp = (message_t *) waitQueueFind(&connections[cid].old_queue, mid); + temp = connections[cid].old_queue->find(mid); + if (temp == NULL) + return -1; + temp->flags |= MSG_REPLY; + temp->size = size; + temp->cmd = cmd; + kmemcpy(temp->data, data, cmd); + + setTaskStatus(temp->send_taskId, READY); + + return 0; +} diff --git a/lockwasher/src/sys/kernel/mount.c b/lockwasher/src/sys/kernel/mount.c new file mode 100644 index 0000000..4423190 --- /dev/null +++ b/lockwasher/src/sys/kernel/mount.c @@ -0,0 +1,97 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: mount.c,v 1.12 2003/05/04 13:20:15 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +int mount(int driveId,int partition,int fsType,char *mountPoint,char *perms) { + struct mountPoints *mp = 0x0; + struct driveDriver *drive = 0x0; + + //Allocate Memory For Mount Point + mp = (struct mountPoints *)kmalloc(sizeof(struct mountPoints),-2); + + //Copy Mount Point Into Buffer + sprintf(mp->mountPoint,mountPoint); + + //Set Pointer To Physical Drive + drive = findDrive(driveId); + + //Set Up Mp Defaults + mp->drive = drive; + mp->fs = findFileSystem(fsType); + mp->partition = partition; + mp->perms = *perms; + if (mp->fs == 0x0) { + sysErr(systemErr,"File System Type: %i Not Found\n",fsType); + return(0x0); + } + //Add Mountpoint If It Fails Free And Return + if (addMount(mp) == 0x0) { + kfree(mp); + return(0x0); + } + //Initialize The File System If It Fails Return + if (mp->fs->initFileSystem(mp) == 0x0) { + kfree(mp); + return(0x0); + } + //Return + return(0x1); + } + +int addMount(struct mountPoints *mp) { + + //If There Are No Existing Mounts Make It The First + if (systemVitals->mountPoints == 0x0) { + mp->prev = 0x0; + mp->next = 0x0; + systemVitals->mountPoints = mp; + } + else { + mp->next = systemVitals->mountPoints; + systemVitals->mountPoints->prev = mp; + mp->prev = 0x0; + systemVitals->mountPoints = mp; + } + //Return + return(0x1); + } + +struct mountPoints *findMount(char *mountPoint) { + struct mountPoints *tmpMp = 0x0; + + for (tmpMp=systemVitals->mountPoints;tmpMp;tmpMp=tmpMp->next) { + if (kstrcmp(tmpMp->mountPoint,mountPoint) == 0x0) { + return(tmpMp); + } + } + //Return NULL If Mount Point Not Found + return(0x0); + } + diff --git a/lockwasher/src/sys/kernel/panic.c b/lockwasher/src/sys/kernel/panic.c new file mode 100644 index 0000000..1c3f615 --- /dev/null +++ b/lockwasher/src/sys/kernel/panic.c @@ -0,0 +1,34 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: panic.c,v 1.3 2003/02/18 00:02:10 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include + +void panic() { + kprintf("System Panic Occurred!\nHalting Machine!\n"); + disableIrq(0); + while (1) { + asm("hlt"); + } + } diff --git a/lockwasher/src/sys/kernel/schedule.cc b/lockwasher/src/sys/kernel/schedule.cc new file mode 100644 index 0000000..a417fc3 --- /dev/null +++ b/lockwasher/src/sys/kernel/schedule.cc @@ -0,0 +1,464 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: schedule.cc,v 1.16 2003/04/22 13:51:46 reddawg Exp $ + +**************************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +} +#endif + +#include + +#ifndef CURRENT_CPU +#define CURRENT_CPU 0 +#endif + +const uInt32 schedMagicNumber = 0x253B9CF9; +spinlock_t schedSpinlock; + +//waitQueue_t taskQueue; +Queue * taskQueue; +Queue * readyQueue; +Queue * exitQueue; +Queue * sleepQueue; + +int numTasks = 0; +int currentProc = -1; +int lastPid = -1; +kTask_t *taskList = (kTask_t *)0xE0800000; +kTask_t *_current = 0x0,*_usedMath = 0x0; + +char *tmp = 0x0; + +extern union descriptorTableunion GDT[7]; +extern int testVal; + +int switches = 0; + +void initScheduler(void) { + kTask_t * firstTask = 0x0; + + //kprintf("Initializing Scheduler......... "); + spinlockInit(&schedSpinlock); + //waitQueueInit(&taskQueue, 0); + taskQueue = new Queue(); + readyQueue = new Queue(); + sleepQueue = new Queue(); + exitQueue = new Queue(); + + // create -1 task. + firstTask = (kTask_t *) kmalloc(sizeof(kTask_t),-2); + if (firstTask == NULL) + kPanic("Scheduler Init: Couldn't allocate first task"); + firstTask->id = -1; + firstTask->status = RUNNING; + taskQueue->insert(firstTask->id, firstTask); + currentProc = -1; + _current = firstTask; + numTasks = 0; + +} + +kTask_t * findTask() { + kTask_t * newTask = 0x0; + lastPid++; + newTask = (kTask_t *) kmalloc(sizeof(kTask_t),-2); + if (newTask == NULL) + kPanic("Scheduler: Couldn't allocate memory for new task"); + + spinlockLock(&schedSpinlock, CURRENT_CPU, SPIN_SCHED); + + kmemset(newTask, '\0', sizeof(kTask_t)); + + newTask->id = (uInt32) lastPid; + newTask->status = STARTING; + newTask->usedMath=0; + newTask->cpuTime = 0; + newTask->lastExecutedTime = 0; + newTask->uid = -1; + newTask->gid = -1; + newTask->oInfo.timer = 0x0; + newTask->oInfo.v86Task = 0x1; + newTask->oInfo.curDir = 0x0; + newTask->oInfo.container = findMount("home"); + + numTasks++; + taskQueue->insert(newTask->id, newTask); + spinlockUnlock(&schedSpinlock, CURRENT_CPU); + return newTask; + } + +kTask_t * getTask(int taskId) { + // need to optimize this function a bit. + kTask_t * temp = 0x0; + spinlockLock(&schedSpinlock, CURRENT_CPU, SPIN_SCHED); + temp = taskQueue->find(taskId); + if (NULL == temp) + temp = exitQueue->find(taskId); + spinlockUnlock(&schedSpinlock, CURRENT_CPU); + return(temp); + } + +void setTaskStatus(int taskId, uInt16 status) +{ + kTask_t * temp = getTask(taskId); + + if (NULL == temp) + return; + + setTaskStatus_task(temp, status); + + return; +} + +void setTaskStatus_task(kTask_t * task, uInt16 status) +{ + if (NULL == task) + return; + spinlockLock(&schedSpinlock, CURRENT_CPU, SPIN_SCHED); + + //kprintf("Set status on task %d from %d to %d\n", + // task->id, task->status, status); + + // remove task from previous queue. + switch(task->status) + { + case SLEEP: + sleepQueue->remove(task->id); + break; + + case READY: + readyQueue->remove(task->id); + break; + + case EXITING: + taskQueue->insert(task->id, task); + exitQueue->remove(task->id); + break; + + default: + break; + } + + // set status + task->status = status; + + // insert into new queue. + switch(status) + { + case SLEEP: + sleepQueue->insert(task->id, task); + break; + + case READY: + readyQueue->insert(task->id, task); + break; + + case EXITING: + taskQueue->remove(task->id); + exitQueue->insert(task->id, task); + //kprintf("Exiting[%d].\n", exitQueue->size()); + break; + + default: + break; + } + + spinlockUnlock(&schedSpinlock, CURRENT_CPU); + return; +} + + +volatile int schedReentrLock = -1; + +void schedule() { + + volatile unsigned char jumpSet = 0; + + kTask_t * temp; + uInt32 memAddr; + struct tssStruct *gpfTSS = (struct tssStruct *)0x4200; + struct tssStruct *doubleFaultTSS = (struct tssStruct *)0x4000; + + gpfTSS->eip = (unsigned int)&_int13; + gpfTSS->esp = 0x1CFFF; + gpfTSS->ebp = 0x1CFFF; + gpfTSS->eflags = 0x206; + doubleFaultTSS->eip = (unsigned int)&doubleFault; + doubleFaultTSS->esp = 0x1BFFF; + doubleFaultTSS->ebp = 0x1BFFF; + doubleFaultTSS->eflags = 0x206; + + if (numTasks == 0) { + return; + } + + /* re-entrient lock. */ + asm volatile("mov %1, %%eax; lock incl (%%eax); setz %0" + : "=g" (jumpSet) + : "m" (&schedReentrLock) + : "eax"); + if (!jumpSet) + { + goto sched_done; + } + /* end re-entrient lock. */ + + if (systemVitals->sysTicks < _current->lastExecutedTime) + _current->cpuTime += systemVitals->sysTicks + (0xFFFFFFFF - _current->lastExecutedTime); + else + _current->cpuTime += systemVitals->sysTicks - _current->lastExecutedTime; + spinlockLock(&schedSpinlock, CURRENT_CPU, SPIN_RETURN); + + while(exitQueue->size() > 8) + kfree(exitQueue->remove()); + + if (0 == readyQueue->size()) + temp = getTask(-1); + else + temp = readyQueue->top(); + + if (NULL == temp) { + temp = _current; + } + + if (NULL == temp) { + kPanic("Scheduler: Ouch.\n"); + } + else { + if (RUNNING == _current->status) + setTaskStatus_task(_current, READY); + setTaskStatus_task(temp, RUNNING); + temp->lastExecutedTime = systemVitals->sysTicks; + memAddr = (uInt32) &(temp->tss); + + GDT[5].descriptor.access = '\x89';//0xE9;// + GDT[5].descriptor.baseLow = (memAddr & 0xFFFF); + GDT[5].descriptor.baseMed = ((memAddr >> 16) & 0xFF); + GDT[5].descriptor.baseHigh = (memAddr >> 24); + _current = temp; + spinlockUnlock(&schedSpinlock, CURRENT_CPU); + schedReentrLock = -1; + if (_current->oInfo.timer == 0x1) { + kprintf("Not Good"); + disableIrq(0); + } + + asm("ljmp $0x28,$0\n"); + return; + } + + /* + chooseTask = (currentProc + 1) % numTasks; + while ((getTask(chooseTask)->status != READY) && (getTask(chooseTask)->status != RUNNING) && (loopCount < 4)) { + if (getTask(chooseTask)->status == SLEEP) { + if (((systemVitals->sysUptime >= getTask(chooseTask)->sleepTimeSec) && (systemVitals->sysTicks >= getTask(chooseTask)->sleepTimeMs)) || (systemVitals->sysUptime == getTask(chooseTask)->sleepTimeSec)) { + setTaskStatus(chooseTask, READY); + chooseTask--; + } + } + chooseTask++; + chooseTask %= numTasks; + if (chooseTask == 0) + loopCount++; + } + if ((loopCount == 4) || (getTask(chooseTask)->status == EXITING)) + chooseTask = -1; + if (chooseTask != -1) { + if (getTask(chooseTask)->status == RUNNING) { + setTaskStatus(chooseTask, READY); + } + currentProc = chooseTask; + getTask(chooseTask)->lastExecutedTime = systemVitals->sysTicks; + setTaskStatus(chooseTask, RUNNING); + memAddr = (uInt32) &(getTask(chooseTask)->tss); + GDT[5].descriptor.access = '\x89';//0xE9;// + GDT[5].descriptor.baseLow = (memAddr & 0xFFFF); + GDT[5].descriptor.baseMed = ((memAddr >> 16) & 0xFF); + GDT[5].descriptor.baseHigh = (memAddr >> 24); + spinlockUnlock(&schedSpinlock, CURRENT_CPU); + schedReentrLock = -1; + _current = getTask(chooseTask); + asm("ljmp $0x28,$0\n"); + } + */ + + spinlockUnlock(&schedSpinlock, CURRENT_CPU); + schedReentrLock = -1; + return; + + sched_done: + return; + } + +void sched_yield() +{ + //kprintf("sched_yield"); + schedule(); +} + +void sleep(uInt32 sec, uInt32 mSec) +{ + sec += mSec / 1000; + mSec %= 1000; + + _current->sleepTimeSec = systemVitals->sysUptime + sec + ((mSec + (systemVitals->sysTicks % 1000)) / 1000); + _current->sleepTimeMs = mSec + systemVitals->sysTicks; + + setTaskStatus_task(_current, SLEEP); + + while(SLEEP == _current->status) + schedule(); + + return; +} + +/* +waitQueue_t * waitQueueCreate(int type) { + waitQueue_t * queue = (waitQueue_t *) kmalloc(sizeof(waitQueue_t),-2); + if (queue == NULL) + return NULL; + kmemset(queue, '\0', sizeof(waitQueue_t)); + queue->magic_number = schedMagicNumber; + queue->type = type; + return queue; + } + +void waitQueueInit(waitQueue_t * queue, int type) { + kmemset(queue, '\0', sizeof(*queue)); + queue->magic_number = schedMagicNumber; + queue->type = type; + queue->first = queue->last = NULL; + return; + } + +void waitQueueDelete(waitQueue_t * queue) { + struct waitQueueNode * temp; + if (queue == NULL) + return; + if (queue->magic_number != schedMagicNumber) + return; + while (queue->first != NULL) { + temp = queue->first; + queue->first = queue->first->next; + kfree(temp); + } + kmemset(queue, '\0', sizeof(waitQueue_t)); + kfree(queue); + } + +void waitQueueUnInit(waitQueue_t * queue) { + struct waitQueueNode * temp; + if (queue->magic_number != schedMagicNumber) + return; + while (queue->first != NULL) { + temp = queue->first; + queue->first = queue->first->next; + kfree(temp); + } + kmemset(queue, '\0', sizeof(waitQueue_t)); + return; + } + +void waitQueueInsert(waitQueue_t * queue, void * data, int id) { + struct waitQueueNode * temp = 0x0; + if (queue == NULL) + return; + if (queue->magic_number != schedMagicNumber) + return; + temp = (struct waitQueueNode *) kmalloc(sizeof(struct waitQueueNode),-2); + kmemset(temp, '\0', sizeof(struct waitQueueNode)); + temp->prev = temp->next = NULL; + if (queue->first == NULL) {; + queue->first = queue->last = temp; + } + else { + queue->last->next = temp; + temp->prev = queue->last; + queue->last = temp; + } + temp->data = data; + temp->id = id; + return; + } + +void * waitQueueRemove(waitQueue_t * queue, int * id) { + void * temp; + if (queue == NULL) + return NULL; + if (queue->magic_number != schedMagicNumber) + return NULL; + if (queue->first == NULL) + return NULL; + temp = queue->first->data; + *id = queue->first->id; + if (queue->first->next == NULL) { + kfree(queue->first); + queue->first = queue->last = NULL; + } + else { + queue->first = queue->first->next; + kfree(queue->first->prev); + queue->first->prev = NULL; + } + return temp; + } + +void * waitQueueFind(waitQueue_t * queue, int id) { + struct waitQueueNode * temp = 0x0; + if (queue == NULL) + return NULL; + if (queue->magic_number != schedMagicNumber) + return NULL; + if (queue->first == NULL) + return NULL; + temp = queue->first; + while ((temp->id != id) && (temp->next != NULL)) { + temp = temp->next; + } + if (temp->id == id) { + return(temp->data); + } + return(NULL); + } + +*/ diff --git a/lockwasher/src/sys/kernel/spinlock.c b/lockwasher/src/sys/kernel/spinlock.c new file mode 100644 index 0000000..c328a89 --- /dev/null +++ b/lockwasher/src/sys/kernel/spinlock.c @@ -0,0 +1,101 @@ +/************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: spinlock.c,v 1.7 2003/04/16 07:21:11 reddawg Exp $ +**************************************************************************************/ + +#include +#include +#include +#include +#include + + +spinlock_t * spinlockCreate() { + spinlock_t * lock = kmalloc(sizeof(spinlock_t),_current->id); + if (lock == NULL) + kPanic("SPINLOCK: Couldn't create spinlock\n"); + kmemset(lock, '\0', sizeof(spinlock_t)); + return(lock); + } + +void spinlockInit(spinlock_t * lock) { + kmemset(lock, '\0', sizeof(spinlock_t)); + } + +void spinlockDelete(spinlock_t * lock) { + int i; + int notComplete = 1; + + lock->deleteInProgress = 1; + + while (notComplete == 1) { + notComplete = 0; + for (i = 0; i < 16; i++) { + while(lock->choiceInProgress[i] != 0) + notComplete = 1; + while(lock->ticket[i] != 0) + notComplete = 1; + } + } + kfree(lock); + } + +int spinlockLock(spinlock_t * lock, int cpuID, int act) { + int max_ticket = 0; + int i; + + if (lock->deleteInProgress == 1) + return SPINLOCK_FAIL_DELETING; + + if (lock->owner == cpuID) { + lock->count++; + return SPINLOCK_SUCCESS; + } + + lock->choiceInProgress[cpuID] = 1; + + for (i = 0; i < 16; i++) + if (lock->ticket[i] >= max_ticket) + max_ticket = lock->ticket[i]; + + max_ticket++; + + lock->ticket[cpuID] = max_ticket; + lock->choiceInProgress[cpuID] = 0; + + for (i = 0; i < 16; i++) { + while(lock->choiceInProgress[i] == 1); + while (((lock->ticket[i] < max_ticket) || ((lock->ticket[i] == max_ticket) && (i < cpuID))) && (lock->ticket[i] != 0)); + } + lock->owner = cpuID; + return SPINLOCK_SUCCESS; + } + +int spinlockUnlock(spinlock_t * lock, int cpuID) { + if (lock->owner == cpuID) { + lock->count--; + if (lock->count != 0) { + return SPINLOCK_SUCCESS; + } + } + lock->ticket[cpuID] = 0; + lock->owner = -1; + return SPINLOCK_SUCCESS; + } \ No newline at end of file diff --git a/lockwasher/src/sys/kernel/syscall.c b/lockwasher/src/sys/kernel/syscall.c new file mode 100644 index 0000000..ebc9025 --- /dev/null +++ b/lockwasher/src/sys/kernel/syscall.c @@ -0,0 +1,144 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: syscall.c,v 1.21 2003/05/01 12:30:02 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +asm( + ".globl _sysCall \n" + "_sysCall: \n" + " cmpl totalCalls,%eax \n" + " jae invalidCall \n" + " push %ds \n" + " push %es \n" + " push %fs \n" + " pushl %edx \n" + " pushl %ecx \n" + " pushl %ebx \n" + " call *systemCalls(,%eax,4) \n" + " pushl %eax \n" + " popl %eax\n" + " popl %ebx\n" + " popl %ecx\n" + " popl %edx\n" + " pop %fs\n" + " pop %es\n" + " pop %ds\n" + " iret \n" /* Exit interrupt */ + ); + +void invalidCall() { + kprintf("Invalid Sys Call!\n"); + //_current->status = AVAILABLE; + //schedule(); + } + +void sysGetpid(int *pid) { + *pid = _current->id; + return; + } + +void sysGetUid(int *uid) { + *uid = _current->uid; + return; + } + +void sysGetGid(int *gid) { + *gid = _current->gid; + return; + } + +void sysSetUid(int uid,int *status) { + if (_current->uid == 0x0) { + _current->uid = uid; + *status = 0x0; + } + else { + *status = 1; + } + return; + } + +void sysSetGid(int gid,int *status) { + if (_current->gid == 0x0) { + _current->gid = gid; + *status = 0x0; + } + else { + *status = 1; + } + return; + } + +void sysExit(int status) { + endTask(_current->id); + sched_yield(); + } + +void sysCheckPid(int *ptr) { + //kprintf("Check status: %d[", *ptr); + if (NULL == getTask(*ptr)) { + *ptr = 0; + } + else if ((getTask(*ptr)->status != STARTING) && (getTask(*ptr)->status != EMPTY) && (getTask(*ptr)->status != EXITING)) { + *ptr = 1; + } + else { + *ptr = 0; + } + //kprintf("%d]\n", *ptr); + } + +/************************************************************************ + +Function: void sysGetFreePage(); +Description: Allocs A Page To The Users VM Space +Notes: + +************************************************************************/ +void sysGetFreePage(long *ptr,int count) { + *ptr = (long) getFreeVirtualPage(_current->id,count); + return; + } + +void sysGetDrives(uInt32 *ptr) { + *ptr = (uInt32)drives; + return; + } + + +void sysGetCwd(char *data) { + sprintf(data,":@%s",_current->oInfo.container->mountPoint); + return; + } diff --git a/lockwasher/src/sys/kernel/syserr.c b/lockwasher/src/sys/kernel/syserr.c new file mode 100644 index 0000000..e84709f --- /dev/null +++ b/lockwasher/src/sys/kernel/syserr.c @@ -0,0 +1,43 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: syserr.c,v 1.1 2003/05/04 13:20:15 reddawg Exp $ + +**************************************************************************************/ + +#include +#include + +int vsprintf(char *buf, const char *fmt, vaList args); + +void sysErr(uInt8 errType,const char *message,...) { + vaList args; + int i; + char buf[1024]; + vaStart(args, message); + i=vsprintf(buf,message,args); + vaEnd(args); + + switch (errType) { + default: + kprintf("System Error: %s\n",message); + break; + } + return; + } \ No newline at end of file diff --git a/lockwasher/src/sys/kernel/version.c b/lockwasher/src/sys/kernel/version.c new file mode 100644 index 0000000..e49163d --- /dev/null +++ b/lockwasher/src/sys/kernel/version.c @@ -0,0 +1,46 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: version.c,v 1.2 2003/02/18 00:02:10 reddawg Exp $ + +**************************************************************************************/ + +#include +#include + +void outputVersion() { + // 0x00 - Black + // 0x01 - Blue + // 0x02 - Green + // 0x03 - Teal + // 0x04 - Red + // 0x05 - Purple + // 0x06 - Brown + // 0x07 - Grey + // 0x08 - Charcole + // 0x09 - Light Blue + // 0x0A - Light Green + // 0x0B - Aqua + // 0x0C - Light Red + // 0x0D - Light Purple + // 0x0E - Yellow + // 0x0F - White + kprintf("UbixOS v%s\n",ubixosVersion); + kprintf("Copyright (c) 2002 - The UbixOS Project\n\n"); + } diff --git a/lockwasher/src/sys/kernel/vitals.c b/lockwasher/src/sys/kernel/vitals.c new file mode 100644 index 0000000..9a7fdbd --- /dev/null +++ b/lockwasher/src/sys/kernel/vitals.c @@ -0,0 +1,50 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: vitals.c,v 1.7 2003/05/07 05:03:37 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include + +vitalsNode *systemVitals = 0x0; + +/************************************************************************ + +Function: void initVitals(); +Description: This Initializes The Systems Vital Monitor +Notes: + +************************************************************************/ +void initVitals() { + //Allocate Memory For System Vitals + systemVitals = (vitalsNode *)kmalloc(sizeof(vitalsNode),-2); + //Set Up Default Information + systemVitals->openFiles = 0x0; + systemVitals->sysTicks = 0x0; + systemVitals->sysUptime = 0x0; + systemVitals->freePages = 0x0; + systemVitals->mountPoints = 0x0; + systemVitals->fileSystems = 0x0; + systemVitals->sharedLibs = 0x0; + //Return + return; + } diff --git a/lockwasher/src/sys/ld/Makefile b/lockwasher/src/sys/ld/Makefile new file mode 100644 index 0000000..ce03777 --- /dev/null +++ b/lockwasher/src/sys/ld/Makefile @@ -0,0 +1,36 @@ +# (C) 2002 The UbixOS Project +# $Id: Makefile,v 1.1 2003/05/04 13:20:15 reddawg Exp $ + + +# Compiler +CC = gcc +CPP = g++ + + +# Linker +LINKER = ld +CFLAGS = -fno-builtin + +# Remove +REMOVE = rm -fr + +# Objects +OBJS = ld.o loadlibrary.o + +all: $(OBJS) + +# Compile Types +.cc.o: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.cc.s: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.c.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.c.s: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.S.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) diff --git a/lockwasher/src/sys/ld/ld.c b/lockwasher/src/sys/ld/ld.c new file mode 100644 index 0000000..fa50cd2 --- /dev/null +++ b/lockwasher/src/sys/ld/ld.c @@ -0,0 +1,69 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: ld.c,v 1.3 2003/05/11 23:37:07 reddawg Exp $ + +**************************************************************************************/ + +#include +#include + +void ld() { + uInt16 i = 0x0,dynSize = 0x0; + uInt32 memAddr = 0x0; + uInt32 memAddr2 = 0x0; + uInt32 *tmp = 0x0; + uInt32 *tmp2 = 0x0; + char *binDynStr = 0x0; + char *libraryNeeded = 0x0; + elfDynsym *binDynSym = 0x0; + + asm( + "movl %%ebx,%0\n" + "popl %1\n" + : + : "m" (memAddr), "m" (memAddr2) + ); + tmp = memAddr; + tmp2 = memAddr2; + kprintf("memAddr: [0x%X],memAddr2: [0x%X]\n",memAddr,memAddr2); + kprintf("[0x%X][0x%X]\n",tmp[0x3],*tmp2); + for (i=0x0;i<_current->oInfo.sectionCount;i++) { + switch (_current->oInfo.sectionHeader[i].shType) { + case 3: + if (_current->oInfo.sectionHeader[i].shAddr != 0x0) { + binDynStr = _current->oInfo.sectionHeader[i].shAddr; + libraryNeeded = (char *)(binDynStr + 1); + } + break; + case 11: + binDynSym = _current->oInfo.sectionHeader[i].shAddr; + dynSize = _current->oInfo.sectionHeader[i].shSize/sizeof(elfDynsym); + break; + default: + break; + } + } + + for (i=0x0;iid); + } \ No newline at end of file diff --git a/lockwasher/src/sys/ld/loadlibrary.c b/lockwasher/src/sys/ld/loadlibrary.c new file mode 100644 index 0000000..52ac48a --- /dev/null +++ b/lockwasher/src/sys/ld/loadlibrary.c @@ -0,0 +1,97 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: loadlibrary.c,v 1.3 2003/05/11 23:37:07 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +void loadLibrary(char *libraryName) { + uInt16 i = 0x0; + void *tmp = 0x0; + fileDescriptor *fd = 0x0; + elfHeader *eHeader = 0x0; + elfProgramheader *programHeader = 0x0; + elfSectionheader *sectionHeader = 0x0; + sharedLib *tmpLib = 0x0; + + if ((fd = fopen(libraryName,"rb")) == 0x0) { + sysErr(fileErr,"Couldn't Open A System File"); + return; + } + eHeader = (elfHeader *)kmalloc(sizeof(elfHeader),-2); + + fread(eHeader,sizeof(elfHeader),1,fd); + + if ((eHeader->eIdent[1] != 'E') && (eHeader->eIdent[2] != 'L') && (eHeader->eIdent[3] != 'F')) { + sysErr(systemErr,"Format Error: Binary File Not ELF32.\n"); + kfree(eHeader); + fclose(fd); + return; + } + else if (eHeader->eType != 3) { + sysErr(systemErr,"Format Error: Binary File Not Shared Object\n"); + kfree(eHeader); + fclose(fd); + return; + } + + tmpLib = (sharedLib *)kmalloc(sizeof(sharedLib),-2); + tmpLib->baseAddr = getFreeKernelPage(-2,((fd->size+4095)/4096)); + + programHeader = (elfProgramheader *)kmalloc(sizeof(elfProgramheader)*eHeader->ePhnum,-2); + fseek(fd,eHeader->ePhoff,0); + fread(programHeader,sizeof(elfProgramheader)*eHeader->ePhnum,1,fd); + + sectionHeader = (elfSectionheader *)kmalloc(sizeof(elfSectionheader)*eHeader->eShnum,-2); + fseek(fd,eHeader->eShoff,0); + fread(sectionHeader,sizeof(elfSectionheader)*eHeader->eShnum,1,fd); + + for (i = 0x0;i < eHeader->ePhnum;i++) { + switch (programHeader[i].phType) { + case PT_LOAD: + tmp = tmpLib->baseAddr + programHeader[i].phVaddr; + kprintf("tmp: [0x%X]\n",(uInt32)tmp); + fseek(fd,programHeader[i].phOffset,0); + fread(tmp,programHeader[i].phFilesz,1,fd); + break; + case PT_DYNAMIC: + tmp = tmpLib->baseAddr + programHeader[i].phVaddr; + fseek(fd,programHeader[i].phOffset,0); + fread(tmp,programHeader[i].phFilesz,1,fd); + break; + default: + sysErr(systemErr,"Invalid Program Header Type"); + break; + } + } + + kfree(eHeader); + kfree(programHeader); + kfree(sectionHeader); + + return; + } \ No newline at end of file diff --git a/lockwasher/src/sys/lib/Alloc.cc b/lockwasher/src/sys/lib/Alloc.cc new file mode 100644 index 0000000..9fe1504 --- /dev/null +++ b/lockwasher/src/sys/lib/Alloc.cc @@ -0,0 +1,78 @@ +#include + +Alloc::Alloc() { + alloc_size = 0; + flags = 0x0; + for (int i = 0; i < 8; i++) + chunks[i] = (void *) 0x0; + }; + +Alloc::Alloc(int size) { + Alloc(); + alloc_size = size; + }; + +Alloc::~Alloc() { clear(); } +void Alloc::setSize(int size) { clear(); alloc_size = size; } + +void * Alloc::allocate() { + void * ptr; + + if (0 == alloc_size) + return NULL; + + int i = 0; + uint8_t flag_lookup = 0x1; + + while((i < 8) && ((flags & flag_lookup) == 0)) + { + flag_lookup <<= 1; + i++; + } + + if (i == 8) + ptr = kmalloc(alloc_size,-2); + else + { + flags ^= flag_lookup; + ptr = chunks[i]; + } + + return ptr; +}; + +void Alloc::deallocate(void * ptr) { + + int i = 0; + uint8_t flag_lookup = 0x1; + + while((i < 8) && ((flags & flag_lookup) != 0)) + { + flag_lookup <<= 1; + i++; + } + + if (i == 8) + kfree(ptr); + else + { + flags ^= flag_lookup; + chunks[i] = ptr; + } +}; + +void Alloc::clear() { + + uint8_t flag_lookup = 0x1; + + for (int i = 0; i < 8; i++) + { + if (flags & flag_lookup != 0) + { + flags ^= flag_lookup; + chunks[i] = NULL; + } + flag_lookup <<= 1; + } +}; + diff --git a/lockwasher/src/sys/lib/Makefile b/lockwasher/src/sys/lib/Makefile new file mode 100644 index 0000000..8bb446a --- /dev/null +++ b/lockwasher/src/sys/lib/Makefile @@ -0,0 +1,38 @@ +# (C) 2002 The UbixOS Project +# $Id: Makefile,v 1.11 2003/04/24 00:13:54 apwillia Exp $ + +CFLAGS = -fno-builtin + +# Compiler +CC = gcc +CPP = g++ + + +# Linker +LINKER = ld + +# Remove +REMOVE = rm -fr + +# Objects +OBJS = strtok.o divdi3.o sqrt.o atan.o string.o kmalloc.o kprintf.o vsprintf.o libcpp.o Alloc.o + +all: $(OBJS) + +# Compile Types +.cpp.o: + $(CPP) ${CFLAGS} -Wall -DNOBOOL -fno-rtti -fno-exceptions -g -c -I../include -o $@ $< +.cc.o: + $(CPP) ${CFLAGS} -Wall -DNOBOOL -fno-rtti -fno-exceptions -fomit-frame-pointer -O -I../include -c -o $@ $< +.cc.s: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.c.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.c.s: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.S.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) diff --git a/lockwasher/src/sys/lib/atan.c b/lockwasher/src/sys/lib/atan.c new file mode 100644 index 0000000..8778036 --- /dev/null +++ b/lockwasher/src/sys/lib/atan.c @@ -0,0 +1,5 @@ +#include + +double atan(double x) { + return(x); + } diff --git a/lockwasher/src/sys/lib/divdi3.c b/lockwasher/src/sys/lib/divdi3.c new file mode 100644 index 0000000..cd7c09a --- /dev/null +++ b/lockwasher/src/sys/lib/divdi3.c @@ -0,0 +1,9 @@ +#include + +u_quad_t __udivdi3(u_quad_t a,u_quad_t b) { + return(0); + } + +quad_t __divdi3(quad_t a,quad_t b) { + return(0); + } diff --git a/lockwasher/src/sys/lib/kmalloc.c b/lockwasher/src/sys/lib/kmalloc.c new file mode 100644 index 0000000..cda9d23 --- /dev/null +++ b/lockwasher/src/sys/lib/kmalloc.c @@ -0,0 +1,368 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: kmalloc.c,v 2.12 2003/04/24 05:16:28 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include + +struct memDescriptor *kernDesc = 0x0; +struct memDescriptor *freeKernDesc = 0x0; +struct memDescriptor *emptyKernDesc = 0x0; + +int mallocLock = 0x0; + +void initMalloc(pidType pid) { + int i=0; + struct memDescriptor *tmpDesc1 = 0x0; + struct memDescriptor *tmpDesc2 = 0x0; + emptyKernDesc = (struct memDescriptor *)getFreeKernelPage(pid,4); + tmpDesc1 = emptyKernDesc; + tmpDesc1->prev = 0x0; + for (i=1;i<((4096/sizeof(struct memDescriptor))*4);i++) { + tmpDesc2 = &emptyKernDesc[i]; + tmpDesc2->prev = tmpDesc1; + tmpDesc1->next = tmpDesc2; + tmpDesc1 = tmpDesc2; + } + tmpDesc1->next = 0x0; + //Return + return; + } + +/************************************************************************ + +Function: void *getEmptyDesc() +Description: Find An Empty Descriptor + +Notes: + +02/17/03 - Is This Efficient? + +************************************************************************/ +void *getEmptyDesc() { + struct memDescriptor *tmpDesc = emptyKernDesc; + if (tmpDesc != 0x0) { + emptyKernDesc = tmpDesc->next; + emptyKernDesc->prev = 0x0; + tmpDesc->next = 0x0; + tmpDesc->prev = 0x0; + tmpDesc->pid = 0x0; + return(tmpDesc); + } + //sysErr("Error Finding Empty Descriptor!\n"); + return(0x0); + } + +/************************************************************************ + +Function: void *kmalloc(uInt32 len,pidType pid) +Description: Allocate Kernel Memory + +Notes: + +02/17/03 - Do I Still Need To Pass In The Pid? + +************************************************************************/ +void *kmalloc(uInt32 len,pidType pid) { + struct memDescriptor *tmpDesc1 = 0x0; + struct memDescriptor *tmpDesc2 = 0x0; + + /* + while (mallocLock != 0x0) { + sched_yield(); + } + */ + + mallocLock = _current->id; + //If Kernel Descriptor Is NULL Initialize Malloc + if (emptyKernDesc == 0x0) { + initMalloc(pid); + } + len = (len + 15) & 0xFFFFFFF0; + if (len == 0x0) { + //sysErr("Malloc of Size 0 Requested\n"); + return(0x0); + } + for (tmpDesc1 = freeKernDesc;tmpDesc1;tmpDesc1=tmpDesc1->next) { + if (tmpDesc1->limit >= len) { + tmpDesc1->status = 0x1; + if (tmpDesc1->prev != 0x0) { + tmpDesc1->prev->next = tmpDesc1->next; + tmpDesc1->next->prev = tmpDesc1->prev; + } + else { + freeKernDesc = tmpDesc1->next; + freeKernDesc->prev = 0x0; + } + tmpDesc1->prev = 0x0; + tmpDesc1->next = kernDesc; + kernDesc->prev = tmpDesc1; + kernDesc = tmpDesc1; + if (tmpDesc1->limit > (len + 16)) { + tmpDesc2 = getEmptyDesc(); + tmpDesc2->limit = tmpDesc1->limit - len; + tmpDesc1->limit = len; + tmpDesc2->baseAddr = tmpDesc1->baseAddr + len; + tmpDesc2->status = 0x0; + tmpDesc2->next = 0x0; + tmpDesc2->prev = 0x0; + insertFreeDesc(tmpDesc2); + } + tmpDesc1->pid = pid; + mallocLock = 0x0; + return(tmpDesc1->baseAddr); + } + } + tmpDesc1 = getEmptyDesc(); + if (tmpDesc1 != 0x0) { + tmpDesc1->baseAddr = (struct memDescriptor *)getFreeKernelPage(pid,((len + 4095)/4096)); + tmpDesc1->limit = len; + tmpDesc1->status = 0x1; + tmpDesc1->next = kernDesc; + tmpDesc1->prev = 0x0; + kernDesc = tmpDesc1; + kernDesc->next->prev = tmpDesc1; + if ((len/4096) > 0) { + tmpDesc2 = getEmptyDesc(); + tmpDesc2->status = 0x0; + tmpDesc2->baseAddr = tmpDesc1->baseAddr + tmpDesc1->limit; + tmpDesc2->limit = ((len + 4095)/4096)*4096 - tmpDesc1->limit; + tmpDesc2->prev = 0x0; + tmpDesc2->next = 0x0; + insertFreeDesc(tmpDesc2); + } + tmpDesc1->pid = pid; + mallocLock = 0x0; + return(tmpDesc1->baseAddr); + } + //Return Null If Unable To Malloc + mallocLock = 0x0; + return(0x0); + } + +/************************************************************************ + +Function: void kfree(void *baseAddr) +Description: This Will Find The Descriptor And Free It + +Notes: + +02/17/03 - I need To Make It Join Descriptors + +************************************************************************/ +void kfree(void *baseAddr) { + long *data = 0x0; + long i = 0x0; + struct memDescriptor *tmpDesc1 = 0x0; + struct memDescriptor *tmpDesc2 = 0x0; + + /* + while (mallocLock != 0x0) { + sched_yield(); + } + */ + + mallocLock = _current->id; + for (tmpDesc1=kernDesc;tmpDesc1;tmpDesc1=tmpDesc1->next) { + //kprintf("([0x%X][0x%X])",tmpDesc1->baseAddr,baseAddr); + if (tmpDesc1->baseAddr == baseAddr) { + tmpDesc1->status = 0x0; + if (tmpDesc1->prev != 0x0) { + tmpDesc2 = tmpDesc1->prev; + tmpDesc2->next = tmpDesc1->next; + } + if (tmpDesc1->next != 0x0) { + tmpDesc2 = tmpDesc1->next; + tmpDesc2->prev = tmpDesc1->prev; + } + if (kernDesc == tmpDesc1) { + kernDesc = tmpDesc1->next; + } + tmpDesc1->next = 0x0; + tmpDesc1->prev = 0x0; + insertFreeDesc(tmpDesc1); + data = baseAddr; + for (i=0;i < (tmpDesc1->limit/4);i++) { + data[i] = 0x0; + } + mergeMemBlocks(); + mallocLock = 0x0; + return; + } + } + kprintf("Error Freeing Descriptor! [0x%X]\n",baseAddr); + mallocLock = 0x0; + return; + } + +/************************************************************************ + +Function: void insertFreeDesc(struct memDescriptor *freeDesc) +Description: This Function Inserts A Free Descriptor On The List Which Is + Kept In Size Order + +Notes: + +02/17/03 - This Was Inspired By TCA's Great Wisdom - + "[20:20:59] You should just insert it in order" + +************************************************************************/ +void insertFreeDesc(struct memDescriptor *freeDesc) { + struct memDescriptor *tmpDesc; + freeDesc->status = 0x0; + if (freeKernDesc != 0x0) { + for (tmpDesc=freeKernDesc;tmpDesc;tmpDesc=tmpDesc->next) { + if ((freeDesc->limit >= tmpDesc->limit) && (!tmpDesc->next)) { + tmpDesc->next = freeDesc; + freeDesc->prev = tmpDesc; + freeDesc->next = 0x0; + return; + } + else if ((freeDesc->limit >= tmpDesc->limit) && (freeDesc->limit <= tmpDesc->next->limit)) { + freeDesc->next = tmpDesc->next; + freeDesc->prev = tmpDesc; + tmpDesc->next->prev = freeDesc; + tmpDesc->next = freeDesc; + return; + } + } + } + else { + freeDesc->prev = 0x0; + freeDesc->next = 0x0; + freeKernDesc = freeDesc; + return; + } + //sysErr("Error With Freeing Blocks"); + return; + } + +/************************************************************************ + +Function: void mergeMemBlocks() +Description: This Function Will Merge Free Blocks And Free Pages + +Notes: + +03/05/03 - We Have A Problem It Seems The First Block Is Limit 0x0 + +************************************************************************/ +void mergeMemBlocks() { + struct memDescriptor *tmpDesc1 = 0x0; + struct memDescriptor *tmpDesc2 = 0x0; + uInt32 baseAddr = 0x0; + + //Loop The Free Descriptors See If We Can Merge Them + for (tmpDesc1=freeKernDesc;tmpDesc1;tmpDesc1=tmpDesc1->next) { + /* + Compare The Base Addr With The Other Descriptors If You Find The One + That You Are Looking For Lets Merge Them + */ + if (tmpDesc1->limit != 0x0) { + baseAddr = (uInt32)tmpDesc1->baseAddr + (uInt32)tmpDesc1->limit; + for (tmpDesc2=freeKernDesc;tmpDesc2;tmpDesc2=tmpDesc2->next) { + if ((uInt32)tmpDesc2->baseAddr == baseAddr) { + tmpDesc1->limit += tmpDesc2->limit; + tmpDesc2->baseAddr = 0x0; + tmpDesc2->limit = 0x0; + tmpDesc2->status = 0x0; + if (tmpDesc2->prev) { + tmpDesc2->prev->next = tmpDesc2->next; + } + if (tmpDesc2->next) { + tmpDesc2->next->prev = tmpDesc2->prev; + } + tmpDesc2->prev = 0x0; + tmpDesc2->next = emptyKernDesc; + emptyKernDesc->prev = tmpDesc2; + emptyKernDesc = tmpDesc2; + if (tmpDesc1->prev) { + tmpDesc1->prev->next = tmpDesc1->next; + } + if (tmpDesc1->next) { + tmpDesc1->next->prev = tmpDesc1->prev; + } + tmpDesc1->prev = 0x0; + tmpDesc1->next = 0x0; + insertFreeDesc(tmpDesc1); + tmpDesc1 = freeKernDesc; + break; + } + } + } + } + return; + } + +/************************************************************************ + +Function: void kfreeProcess(pidType pid) +Description: This Will Find The Descriptor And Free It + +Notes: + +02/17/03 - I need To Make It Join Descriptors + +************************************************************************/ +void kfreeProcess(pidType pid) { + long *data = 0x0; + long i = 0x0; + struct memDescriptor *tmpDesc1 = 0x0; + struct memDescriptor *tmpDesc2 = 0x0; + + /* + while (mallocLock != 0x0) { + sched_yield(); + } + */ + + mallocLock = _current->id; + for (tmpDesc1=kernDesc;tmpDesc1;tmpDesc1=tmpDesc1->next) { + if (tmpDesc1->pid == pid) { + tmpDesc1->status = 0x0; + if (tmpDesc1->prev != 0x0) { + tmpDesc2 = tmpDesc1->prev; + tmpDesc2->next = tmpDesc1->next; + } + if (tmpDesc1->next != 0x0) { + tmpDesc2 = tmpDesc1->next; + tmpDesc2->prev = tmpDesc1->prev; + } + if (kernDesc == tmpDesc1) { + kernDesc = tmpDesc1->next; + } + tmpDesc1->next = 0x0; + tmpDesc1->prev = 0x0; + insertFreeDesc(tmpDesc1); + data = tmpDesc1->baseAddr; + for (i=0;i < (tmpDesc1->limit/4);i++) { + data[i] = 0x0; + } + mergeMemBlocks(); + mallocLock = 0x0; + } + } + mallocLock = 0x0; + return; + } \ No newline at end of file diff --git a/lockwasher/src/sys/lib/kprintf.c b/lockwasher/src/sys/lib/kprintf.c new file mode 100644 index 0000000..b30a69f --- /dev/null +++ b/lockwasher/src/sys/lib/kprintf.c @@ -0,0 +1,53 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: kprintf.c,v 1.5 2003/04/08 15:39:16 reddawg Exp $ + +**************************************************************************************/ + +#include +#include + +int vsprintf(char *buf, const char *fmt, vaList args); + +int printfOff = 1; + +int kprintf(const char *fmt, ...) { + vaList args; + int i; + char buf[1024]; + vaStart(args, fmt); + i=vsprintf(buf,fmt,args); + vaEnd(args); + //ogPrintf(buf); + if (printfOff == 1) { + kprint(buf); + } + printColor = defaultColor; + return(i); + } + +int sprintf(char *buf,const char *fmt, ...) { + vaList args; + int i; + vaStart(args, fmt); + i=vsprintf(buf,fmt,args); + vaEnd(args); + return(i); + } diff --git a/lockwasher/src/sys/lib/libcpp.cc b/lockwasher/src/sys/lib/libcpp.cc new file mode 100644 index 0000000..b7a74df --- /dev/null +++ b/lockwasher/src/sys/lib/libcpp.cc @@ -0,0 +1,39 @@ +extern "C" +{ +#include +#include +void __pure_virtual() { while(1); } +void __cxa_pure_virtual() { while(1); } +} + +#include + +void * operator new[](unsigned size) +{ + return kmalloc(size,-2); +} + +void operator delete[](void * ptr) +{ + kfree(ptr); + + return; +} + +void * operator new(unsigned size) +{ + void * ptr = kmalloc(size, -2); + + //kprintf("Malloced: %08x\n", ptr); + + return ptr; +} + +void operator delete(void * ptr) +{ + kfree(ptr); + //kprintf("Freed: %08x\n", ptr); + + return; +} + diff --git a/lockwasher/src/sys/lib/memcmp.c b/lockwasher/src/sys/lib/memcmp.c new file mode 100644 index 0000000..52a4fa9 --- /dev/null +++ b/lockwasher/src/sys/lib/memcmp.c @@ -0,0 +1,2 @@ +#include + diff --git a/lockwasher/src/sys/lib/ogprintf.cpp b/lockwasher/src/sys/lib/ogprintf.cpp new file mode 100644 index 0000000..37ab91d --- /dev/null +++ b/lockwasher/src/sys/lib/ogprintf.cpp @@ -0,0 +1,36 @@ +#include +#include + +extern "C" { +int ogPrintf(char *s); +} + + TDPFont * font = 0x0; + TGfx0 * buf = 0x0; + int screenRow = 0x0; + +int ogPrintf(char *s) { + bool result; + + + + if (!buf) { + font = new TDPFont(); + buf = new TGfx0(); + // Creat Screen Object + buf->ogCreate(800,600,DEF_PIXFMT_8BPP); + // Set Our Font + result = font->load("ROM8X14.DPF"); + // change the buffer pointer to screen mem + buf->Buffer = (void *)0xE4000000; + // Set Font Color To White + font->setColor(255,255,255); + } + font->putText(*buf,0,screenRow,s); + screenRow += 14; + if (screenRow > 588) { + buf->ogClear(0); + screenRow = 0; + } + return 0; +} // ogPrintf diff --git a/lockwasher/src/sys/lib/sqrt.c b/lockwasher/src/sys/lib/sqrt.c new file mode 100644 index 0000000..76cbb31 --- /dev/null +++ b/lockwasher/src/sys/lib/sqrt.c @@ -0,0 +1,3 @@ +double sqrt(double x) { + return(x); + } diff --git a/lockwasher/src/sys/lib/string.c b/lockwasher/src/sys/lib/string.c new file mode 100644 index 0000000..4f71d1c --- /dev/null +++ b/lockwasher/src/sys/lib/string.c @@ -0,0 +1,137 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: string.c,v 1.4 2003/03/15 01:16:24 apwillia Exp $ + +**************************************************************************************/ + +#include + +int kstrcmp(char *str1, char *str2) { + while ((*str1 == *str2) && (*str1 != 0x0) && (*str2 != 0x0)) { + str1++; + str2++; + } + if (*str1 == *str2) { + return(0); + } + else if (*str1 > *str2) { + return(1); + } + else { + return(-1); + } + } + +int kstrncmp(const char * a, const char * b, size_t c) +{ + int i = 0; + while (i < c) + { + if ((a[i] != b[i]) || (a[i] == '\0') || (b[i] == '\0')) + return a[i] - b[i]; + i++; + } + return 0; +} + + + +void * kmemcpy(void * dst, const void * src, size_t length) { + size_t x = length >> 2; + size_t y = length & 0xf; + size_t i; + + for (i = 0; i < x; i++) { + ((unsigned long *)dst)[i] = ((unsigned long *)src)[i]; + } + + for (i = 0; i < y; i++) { + ((char *) dst)[length-y+i] = ((char *) src)[length-y+i]; + } + + return(dst); + } + + +void *kmemset(void * dst, int c, size_t length) { + size_t x = length >> 2; + size_t y = length & 0xf; + size_t i; + + unsigned int newC = (c << 24) | (c << 16) | (c << 8) | (c); + + for (i = 0; i < x; i++) + ((unsigned long *)dst)[i] = newC; + + for (i = 0; i < y; i++) + ((char *) dst)[length-y+i] = c; + + return dst; + } + +int kstrlen(const char * string) { + int i = 0; + + while (1) { + if (string[i] == '\0') + return i; + i++; + } + return 0; + } + +int kmemcmp(const void * dst, const void * src, size_t length) +{ + size_t x = length >> 2; + size_t y = length & 0xf; + size_t i; + + for (i = 0; i < x; i++) + { + if (((unsigned long *)dst)[i] > ((unsigned long *)src)[i]) + return 1; + if (((unsigned long *)dst)[i] < ((unsigned long *)src)[i]) + return -1; + } + + for (i = 0; i < y; i++) + { + if (((char *) dst)[length-y+i] > ((char *) src)[length-y+i]) + return 1; + if (((char *) dst)[length-y+i] < ((char *) src)[length-y+i]) + return -1; + } + + return 0; +} + +void kstrncpy(char * dest, const char * src, size_t size) +{ + if (size == 0) + return; + do + { + *dest = *src; + dest++; src++; + size--; + } + while(('\0' != *(src-1)) && (size)); +} + diff --git a/lockwasher/src/sys/lib/strtok.c b/lockwasher/src/sys/lib/strtok.c new file mode 100644 index 0000000..abf08bc --- /dev/null +++ b/lockwasher/src/sys/lib/strtok.c @@ -0,0 +1,71 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: strtok.c,v 1.1 2003/04/20 23:29:31 reddawg Exp $ + +**************************************************************************************/ + +#include +#include + +char *strtok_r(char *s, const char *delim, char **last) { + char *spanp; + int c, sc; + char *tok; + + if ((s == NULL) && ((s = *last) == NULL)) { + return(NULL); + } + +cont: + c = *s++; + for (spanp = (char *)delim; (sc = *spanp++) != 0; ) { + if (c == sc) { + goto cont; + } + } + if (c == 0) { + *last = NULL; + return(NULL); + } + tok = s - 1; + + for (;;) { + c = *s++; + spanp = (char *)delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) { + s = NULL; + } + else { + char *w = s - 1; + *w = '\0'; + } + *last = s; + return(tok); + } + } while (sc != 0); + } + } + +char *strtok(char *s, const char *delim) { + static char *last; + return (strtok_r(s, delim, &last)); + } diff --git a/lockwasher/src/sys/lib/ubtest.cpp b/lockwasher/src/sys/lib/ubtest.cpp new file mode 100644 index 0000000..4ee59d9 --- /dev/null +++ b/lockwasher/src/sys/lib/ubtest.cpp @@ -0,0 +1,38 @@ +#include "objgfx30.h" +#include "objfont.h" +#include "ogSprite.h" +#include "ogBlit.h" + +extern "C" { +int ogPrintf(char *s); +} + + TDPFont * font = 0x0; + TGfx0 * buf = 0x0; + int screenRow = 0x0; + +int ogPrintf(char *s) { + bool result; + + + + if (!buf) { + font = new TDPFont(); + buf = new TGfx0(); + // Creat Screen Object + buf->ogCreate(800,600,DEF_PIXFMT_8BPP); + // Set Our Font + result = font->load("ROM8X14.DPF"); + // change the buffer pointer to screen mem + buf->Buffer = (void *)0xE4000000; + // Set Font Color To White + font->setColor(255,255,255); + } + font->putText(*buf,0,screenRow,s); + screenRow += 14; + if (screenRow > 588) { + buf->ogClear(0); + screenRow = 0; + } + return 0; +} // ogPrintf diff --git a/lockwasher/src/sys/lib/vsprintf.c b/lockwasher/src/sys/lib/vsprintf.c new file mode 100644 index 0000000..014b694 --- /dev/null +++ b/lockwasher/src/sys/lib/vsprintf.c @@ -0,0 +1,241 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are prohibited. + + $Id: vsprintf.c,v 1.2 2003/03/13 00:29:45 apwillia Exp $ + +**************************************************************************************/ + +/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ +/* + * Wirzenius wrote this portably, Torvalds fucked it up :-) + */ + +#include +#include + +/* we use this so that we can do without the ctype library */ +#define is_digit(c) ((c) >= '0' && (c) <= '9') + +static int skip_atoi(const char **s) +{ + int i=0; + + while (is_digit(**s)) + i = i*10 + *((*s)++) - '0'; + return i; +} + +#define ZEROPAD 1 /* pad with zero */ +#define SIGN 2 /* unsigned/signed long */ +#define PLUS 4 /* show plus */ +#define SPACE 8 /* space if plus */ +#define LEFT 16 /* left justified */ +#define SPECIAL 32 /* 0x */ +#define SMALL 64 /* use 'abcdef' instead of 'ABCDEF' */ + +#define do_div(n,base) ({ \ +int __res; \ +__asm__("divl %4":"=a" (n),"=d" (__res):"0" (n),"1" (0),"r" (base)); \ +__res; }) + +static char * number(char * str, int num, int base, int size, int precision + ,int type) +{ + char c,sign,tmp[36]; + const char *digits="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + int i; + + if (type&SMALL) digits="0123456789abcdefghijklmnopqrstuvwxyz"; + if (type&LEFT) type &= ~ZEROPAD; + if (base<2 || base>36) + return 0; + c = (type & ZEROPAD) ? '0' : ' ' ; + if (type&SIGN && num<0) { + sign='-'; + num = -num; + } else + sign=(type&PLUS) ? '+' : ((type&SPACE) ? ' ' : 0); + if (sign) size--; + if (type&SPECIAL) { + if (base==16) { size -= 2; } + else if (base==8) { size--; } + } + i=0; + if (num==0) + tmp[i++]='0'; + else while (num!=0) + tmp[i++]=digits[do_div(num,base)]; + if (i>precision) precision=i; + size -= precision; + if (!(type&(ZEROPAD+LEFT))) + while(size-->0) + *str++ = ' '; + if (sign) + *str++ = sign; + if (type&SPECIAL) { + if (base==8) { + *str++ = '0'; + } + else if (base==16) { + *str++ = '0'; + *str++ = digits[33]; + } + } + if (!(type&LEFT)) + while(size-->0) + *str++ = c; + while(i0) + *str++ = tmp[i]; + while(size-->0) + *str++ = ' '; + return str; +} + +int vsprintf(char *buf, const char *fmt, vaList args) +{ + int len; + int i; + char * str; + char *s; + int *ip; + + int flags; /* flags to number() */ + + int field_width; /* width of output field */ + int precision; /* min. # of digits for integers; max + number of chars for from string */ + int qualifier; /* 'h', 'l', or 'L' for integer fields */ + + for (str=buf ; *fmt ; ++fmt) { + if (*fmt != '%') { + *str++ = *fmt; + continue; + } + + /* process flags */ + flags = 0; + repeat: + ++fmt; /* this also skips first '%' */ + switch (*fmt) { + case '-': flags |= LEFT; goto repeat; + case '+': flags |= PLUS; goto repeat; + case ' ': flags |= SPACE; goto repeat; + case '#': flags |= SPECIAL; goto repeat; + case '0': flags |= ZEROPAD; goto repeat; + } + + /* get field width */ + field_width = -1; + if (is_digit(*fmt)) + field_width = skip_atoi(&fmt); + else if (*fmt == '*') { + /* it's the next argument */ + field_width = vaArg(args, int); + if (field_width < 0) { + field_width = -field_width; + flags |= LEFT; + } + } + + /* get the precision */ + precision = -1; + if (*fmt == '.') { + ++fmt; + if (is_digit(*fmt)) + precision = skip_atoi(&fmt); + else if (*fmt == '*') { + /* it's the next argument */ + precision = vaArg(args, int); + } + if (precision < 0) + precision = 0; + } + + /* get the conversion qualifier */ + qualifier = -1; + if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') { + qualifier = *fmt; + ++fmt; + } + + switch (*fmt) { + case 'c': + if (!(flags & LEFT)) + while (--field_width > 0) + *str++ = ' '; + *str++ = (unsigned char) vaArg(args, int); + while (--field_width > 0) + *str++ = ' '; + break; + + case 's': + s = vaArg(args, char *); + len = kstrlen(s); + if (precision < 0) + precision = len; + else if (len > precision) + len = precision; + + if (!(flags & LEFT)) + while (len < field_width--) + *str++ = ' '; + for (i = 0; i < len; ++i) + *str++ = *s++; + while (len < field_width--) + *str++ = ' '; + break; + + case 'o': + str = number(str, vaArg(args, unsigned long), 8, + field_width, precision, flags); + break; + + case 'p': + if (field_width == -1) { + field_width = 8; + flags |= ZEROPAD; + } + str = number(str, + (unsigned long) vaArg(args, void *), 16, + field_width, precision, flags); + break; + + case 'x': + flags |= SMALL; + case 'X': + str = number(str, vaArg(args, unsigned long), 16, + field_width, precision, flags); + break; + + case 'd': + case 'i': + flags |= SIGN; + case 'u': + str = number(str, vaArg(args, unsigned long), 10, + field_width, precision, flags); + break; + + case 'n': + ip = vaArg(args, int *); + *ip = (str - buf); + break; + + default: + if (*fmt != '%') + *str++ = '%'; + if (*fmt) + *str++ = *fmt; + else + --fmt; + break; + } + } + *str = '\0'; + return str-buf; +} diff --git a/lockwasher/src/sys/pci/Makefile b/lockwasher/src/sys/pci/Makefile new file mode 100644 index 0000000..f28dbac --- /dev/null +++ b/lockwasher/src/sys/pci/Makefile @@ -0,0 +1,36 @@ +# (C) 2002 The UbixOS Project +# $Id: Makefile,v 1.3 2003/05/01 12:30:02 reddawg Exp $ + +CFLAGS = -fno-builtin + +# Compiler +CC = gcc +CPP = g++ + + +# Linker +LINKER = ld + +# Remove +REMOVE = rm -fr + +# Objects +OBJS = lnc.o hd.o pci.o + +all: $(OBJS) + +# Compile Types +.cc.o: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.cc.s: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.c.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.c.s: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.S.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) diff --git a/lockwasher/src/sys/pci/hd.c b/lockwasher/src/sys/pci/hd.c new file mode 100644 index 0000000..3a4c0e8 --- /dev/null +++ b/lockwasher/src/sys/pci/hd.c @@ -0,0 +1,249 @@ +#include +#include +#include +#include +#include + +struct driveInfo *hdd0; +struct driveInfo *hdd1; +struct driveInfo *hdd2; +struct driveInfo *hdd3; + +void initHardDisk() { + hdd0 = (struct driveInfo *)kmalloc(sizeof(struct driveInfo),-2); + hdd1 = (struct driveInfo *)kmalloc(sizeof(struct driveInfo),-2); + hdd2 = (struct driveInfo *)kmalloc(sizeof(struct driveInfo),-2); + hdd3 = (struct driveInfo *)kmalloc(sizeof(struct driveInfo),-2); + hdd0->hdPort = 0x1F7; + hdd0->hdDev = 0x40; + hdd1->hdPort = 0x1F7; + hdd1->hdDev = 0x50; + hdd2->hdPort = 0x177; + hdd2->hdDev = 0x40; + hdd3->hdPort = 0x177; + hdd3->hdDev = 0x50; + if (!initDrive(hdd0)) { + addDrive(1,1,hdd0,hdRead,hdWrite,0x0); + } + if (!initDrive(hdd1)) { + addDrive(2,1,hdd1,hdRead,hdWrite,0x0); + } + if (!initDrive(hdd2)) { + addDrive(3,1,hdd2,hdRead,hdWrite,0x0); + } + if (!initDrive(hdd3)) { + addDrive(4,1,hdd3,hdRead,hdWrite,0x0); + } + return; + } + +int initDrive(struct driveInfo *hdd) { + char retVal = 0x0; + long counter = 0x0; + short *tmp = 0x0; + for (counter = 1000000;counter >= 0;counter--) { + retVal = inportByte(hdd->hdPort) & 0x80; + if (!retVal) goto ready; + } + kprintf("Error Initializing Drive\n"); + return(1); + ready: + hdd->hdPort--; + outportByte(hdd->hdPort,hdd->hdDev); + hdd->hdPort++; + outportByte(hdd->hdPort,0xEC); + for (counter = 1000000;counter >= 0;counter--) { + retVal = inportByte(hdd->hdPort); + if ((retVal & 1) != 0x0) { + kprintf("Error Drive Not Available\n"); + return(1); + } + if ((retVal & 8) != 0x0) { + goto go; + } + } + kprintf("Time Out Waiting On Drive\n"); + return(1); + go: + hdd->hdPort -= 7; + tmp = (short *)hdd->hdSector; + for (counter = 0;counter < (512/2);counter++) { + tmp[counter] = inportWord(hdd->hdPort); + } + retVal = hdd->hdSector[0x5E] & 127; + switch (retVal) { + case 0: + hdd->hdShift = 3; + hdd->hdMulti = 8; + case 2: + hdd->hdShift = 1; + hdd->hdMulti = retVal; + break; + case 4: + hdd->hdShift = 2; + hdd->hdMulti = retVal; + break; + case 8: + hdd->hdShift = 3; + hdd->hdMulti = retVal; + break; + case 16: + hdd->hdShift = 4; + hdd->hdMulti = retVal; + break; + case 32: + hdd->hdShift = 5; + hdd->hdMulti = retVal; + break; + case 64: + hdd->hdShift = 6; + hdd->hdMulti = retVal; + break; + default: + kprintf("Error BLOCK Mode Unavailable: [%i]\n",retVal); + return(1); + } + hdd->hdPort += 2; + outportByte(hdd->hdPort,retVal); + hdd->hdPort += 4; + outportByte(hdd->hdPort,hdd->hdDev); + hdd->hdPort++; + outportByte(hdd->hdPort,0xC6); + //retVal--; //I'm Not Sure Why He Was Doing This + hdd->hdMask = retVal; + hdd->hdSize = (hdd->hdSector[0x7B] * 256 * 256 * 256) + (hdd->hdSector[0x7A] * 256 * 256) + (hdd->hdSector[0x79] * 256) + hdd->hdSector[0x78]; + hdd->hdEnable = 1; + kprintf("Drive: [0x%X/0x%X], Size: [%iSectors/%iKBytes]\n",hdd->hdPort,hdd->hdDev,hdd->hdSize,((hdd->hdSize*512)/1024)); + return(0); + } + +void hdWrite(struct driveInfo *hdd,long startSector,long sectorCount,void *baseAddr) { + long counter = 0x0; + long retVal = 0x0; + short transactionCount = 0x0; + short *tmp = (short *)baseAddr; + if (hdd->hdEnable == 0x0) { + kprintf("Invalid Drive\n"); + return; + } + if ((sectorCount >> hdd->hdShift) == 0x0) { + hdd->hdCalc = sectorCount; //hdd->hdMask; + transactionCount = 1; + } + else { + hdd->hdCalc = hdd->hdMulti; + transactionCount = sectorCount >> hdd->hdShift; + } + for (;transactionCount > 0;transactionCount--) { + for (counter = 1000000;counter >= 0;counter--) { + retVal = inportByte(hdd->hdPort) & 0x80; + if (!retVal) goto ready; + } + kprintf("Time Out Waiting On Drive\n"); + return; + ready: + hdd->hdPort -= 5; + outportByte(hdd->hdPort,hdd->hdCalc); + hdd->hdPort++; + outportByte(hdd->hdPort,(startSector & 0xFF)); + hdd->hdPort++; + retVal = startSector >> 8; + outportByte(hdd->hdPort,(retVal & 0xFF)); + hdd->hdPort++; + retVal >>= 8; + outportByte(hdd->hdPort,(retVal & 0xFF)); + hdd->hdPort++; + retVal >>= 8; + retVal &= 0x0F; + retVal |= hdd->hdDev; + outportByte(hdd->hdPort,(retVal & 0xFF)); + hdd->hdPort++; + outportByte(hdd->hdPort,0xC5); + for (counter = 1000000;counter >= 0;counter--) { + retVal = inportByte(hdd->hdPort); + if ((retVal & 1) != 0x0) { + kprintf("HD Write Error\n"); + return; + } + if ((retVal & 8) != 0x0) { + goto go; + } + } + kprintf("Time Out Waiting On Drive\n"); + return; + go: + hdd->hdPort -= 7; + for (counter = 0;counter < (hdd->hdCalc << 8);counter++) { + outportWord(hdd->hdPort,tmp[counter]); + } + hdd->hdPort += 7; + startSector += hdd->hdCalc; + } + return; + } + +void hdRead(struct driveInfo *hdd,long startSector,long sectorCount,void *baseAddr) { + long counter = 0x0; + long retVal = 0x0; + short transactionCount = 0x0; + short *tmp = (short *)baseAddr; + kprintf("Moo\n"); + if (hdd->hdEnable == 0x0) { + kprintf("Invalid Drive\n"); + return; + } + if ((sectorCount >> hdd->hdShift) == 0x0) { + hdd->hdCalc = sectorCount;//(hdd->hdMask); + transactionCount = 1; + } + else { + hdd->hdCalc = hdd->hdMulti; + transactionCount = sectorCount >> hdd->hdShift; + } + for (;transactionCount > 0;transactionCount--) { + for (counter = 1000000;counter >= 0;counter--) { + retVal = inportByte(hdd->hdPort) & 0x80; + if (!retVal) goto ready; + } + kprintf("Time Out Waiting On Drive\n"); + return; + ready: + hdd->hdPort -= 5; + outportByte(hdd->hdPort,hdd->hdCalc); + hdd->hdPort++; + outportByte(hdd->hdPort,(startSector & 0xFF)); + hdd->hdPort++; + retVal = startSector >> 8; + outportByte(hdd->hdPort,(retVal & 0xFF)); + hdd->hdPort++; + retVal >>= 8; + outportByte(hdd->hdPort,(retVal & 0xFF)); + hdd->hdPort++; + retVal >>= 8; + retVal &= 0x0F; + retVal |= hdd->hdDev; + outportByte(hdd->hdPort,(retVal & 0xFF)); + hdd->hdPort++; + outportByte(hdd->hdPort,0xC4); + for (counter = 1000000;counter >= 0;counter--) { + retVal = inportByte(hdd->hdPort); + if ((retVal & 1) != 0x0) { + kprintf("HD Write Error\n"); + return; + } + if ((retVal & 8) != 0x0) { + goto go; + } + } + kprintf("Time Out Waiting On Drive\n"); + return; + go: + hdd->hdPort -= 7; + for (counter = 0;counter < (hdd->hdCalc << 8);counter++) { + tmp[counter] = inportWord(hdd->hdPort); + } + hdd->hdPort += 7; + startSector += hdd->hdCalc; + } + return; + } diff --git a/lockwasher/src/sys/pci/lnc.c b/lockwasher/src/sys/pci/lnc.c new file mode 100644 index 0000000..f7c8860 --- /dev/null +++ b/lockwasher/src/sys/pci/lnc.c @@ -0,0 +1,259 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +struct lncInfo *lnc = 0x0; + +static char const * const nicIdent[] = { + "Unknown", + "BICC", + "NE2100", + "DEPCA", + "CNET98S", /* PC-98 */ + }; + +static char const * const icIdent[] = { + "Unknown", + "LANCE", + "C-LANCE", + "PCnet-ISA", + "PCnet-ISA+", + "PCnet-ISA II", + "PCnet-32 VL-Bus", + "PCnet-PCI", + "PCnet-PCI II", + "PCnet-FAST", + "PCnet-FAST+", + "PCnet-Home", + }; + +void writeCsr(struct lncInfo *lnc, uInt16 port, uInt16 val) { + outportWord(lnc->rap, port); + outportWord(lnc->rdp, val); + } + +uInt16 readCsr(struct lncInfo *lnc, uInt16 port) { + outportWord(lnc->rap, port); + return(inportWord(lnc->rdp)); + } + +void writeBcr(struct lncInfo *lnc, uInt16 port, uInt16 val) { + outportWord(lnc->rap, port); + outportWord(lnc->bdp, val); + } + +uInt16 readBcr(struct lncInfo *sc, uInt16 port) { + outportWord(sc->rap, port); + return (inportWord(sc->bdp)); + } + + +void initLNC() { + int i = 0x0; + lnc = kmalloc(sizeof(struct lncInfo),-2); + + lnc->rap = 0x1000 + PCNET_RAP; + lnc->rdp = 0x1000 + PCNET_RDP; + lnc->bdp = 0x1000 + PCNET_BDP; + + lnc->nic.ic = probe(lnc); + if ((lnc->nic.ic > 0) && (lnc->nic.ic >= PCnet_32)) { + lnc->nic.ident = NE2100; + lnc->nic.memMode = DMA_FIXED; + + lnc->nrdre = NRDRE; + lnc->ntdre = NTDRE; + + /* Extract MAC address from PROM */ + for (i = 0; i < ETHER_ADDR_LEN; i++) { + lnc->arpcom.ac_enaddr[i] = inportByte(0x1000 + i); + kprintf("[0x%X]",lnc->arpcom.ac_enaddr[i]); + } + } + else { + kprintf("LNC Init Error\n"); + return; + } + lncAttach(lnc,0); + writeCsr(lnc, CSR3, 0); + writeCsr(lnc, CSR0, INIT); + for (i = 0; i < 1000; i++) + if (readCsr(lnc, CSR0) & IDON) + break; + + if (readCsr(lnc, CSR0) & IDON) { + writeCsr(lnc, CSR0, STRT | INEA); + setVector(_lncInt,mVec+9, (dInt + dPresent + dDpl3)); + enableIrq(9); + //sc->arpcom.ac_if.if_flags |= IFF_RUNNING; + //sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; + //lnc_start(&sc->arpcom.ac_if); + } + else { + kprintf("LNC init Error\n"); + return; + } + return; + } + +int probe(struct lncInfo *lnc) { + uInt32 chipId = 0x0; + int type = 0x0; + + if ((type = lanceProbe(lnc))) { + chipId = readCsr(lnc, CSR89); + chipId <<= 16; + chipId |= readCsr(lnc, CSR88); + if (chipId & AMD_MASK) { + chipId >>= 12; + switch (chipId & PART_MASK) { + case Am79C960: + return(PCnet_ISA); + case Am79C961: + return (PCnet_ISAplus); + case Am79C961A: + return (PCnet_ISA_II); + case Am79C965: + return (PCnet_32); + case Am79C970: + return (PCnet_PCI); + case Am79C970A: + return (PCnet_PCI_II); + case Am79C971: + return (PCnet_FAST); + case Am79C972: + case Am79C973: + return (PCnet_FASTplus); + case Am79C978: + return (PCnet_Home); + default: + break; + } + } + } + return (type); + } + +int lanceProbe(struct lncInfo *lnc) { + writeCsr(lnc, CSR0, STOP); + if ((inportWord(lnc->rdp) & STOP) && !(readCsr(lnc, CSR3))) { + writeCsr(lnc, CSR0, INEA); + if (readCsr(lnc, CSR0) & INEA) { + return(C_LANCE); + } + else { + return(LANCE); + } + } + else { + return(UNKNOWN); + } + } + +void lncInt() { + uInt16 csr0 = 0x0; + while ((csr0 = inportWord(lnc->rdp)) & INTR) { + outportWord(lnc->rdp, csr0); + kprintf("CSR0: [0x%X]\n",csr0); + if (csr0 & ERR) { + kprintf("Error: [0x%X]\n",csr0); + } + if (csr0 & RINT) { + kprintf("RINT\n"); + } + if (csr0 & TINT) { + kprintf("TINT\n"); + } + } + kprintf("Finished!!!\n"); + outportByte(0x20,0x20); + return; + } + +asm( + ".global _lncInt \n" + "_lncInt : \n" + + " pusha \n" /* Save all registers */ + " pushw %ds \n" /* Set up the data segment */ + " pushw %es \n" + " pushw %ss \n" /* Note that ss is always valid */ + " pushw %ss \n" + " popw %ds \n" + " popw %es \n" + " call lncInt \n" + " popw %es \n" + " popw %ds \n" /* Restore registers */ + " popa \n" + " iret \n" /* Exit interrupt */ + ); + +int lncAttach(struct lncInfo *lnc,int unit) { + int lncMemSize = 0x0; + + lncMemSize = ((NDESC(lnc->nrdre) + NDESC(lnc->ntdre)) * sizeof(struct hostRingEntry)); + + if (lnc->nic.memMode != SHMEM) + lncMemSize += sizeof(struct initBlock) + (sizeof(struct mds) * (NDESC(lnc->nrdre) + NDESC(lnc->ntdre))) + MEM_SLEW; + + if (lnc->nic.memMode == DMA_FIXED) + lncMemSize += (NDESC(lnc->nrdre) * RECVBUFSIZE) + (NDESC(lnc->ntdre) * TRANSBUFSIZE); + + if (lnc->nic.memMode != SHMEM) { + if (lnc->nic.ic < PCnet_32) { + /* ISA based cards */ + kprintf("ISA Board\n"); + //sc->recv_ring = contigmalloc(lnc_mem_size, M_DEVBUF, M_NOWAIT,0ul, 0xfffffful, 4ul, 0x1000000); + } + else { + /* + * For now it still needs to be below 16MB because the + * descriptor's can only hold 16 bit addresses. + */ + //sc->recv_ring = contigmalloc(lnc_mem_size, M_DEVBUF, M_NOWAIT,0ul, 0xfffffful, 4ul, 0x1000000); + lnc->recvRing = kmalloc(lncMemSize,-2); + kprintf("PCI Board\n"); + } + } + + if (!lnc->recvRing) { + kprintf("lnc%d: Couldn't allocate memory for NIC\n", unit); + return (0); + } + + lnc->nic.mode = NORMAL; + + /* Fill in arpcom structure entries */ + /* + lnc->arpcom.ac_if.if_softc = sc; + lnc->arpcom.ac_if.if_name = lncdriver.name; + lnc->arpcom.ac_if.if_unit = unit; + lnc->arpcom.ac_if.if_mtu = ETHERMTU; + lnc->arpcom.ac_if.if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + lnc->arpcom.ac_if.if_timer = 0; + lnc->arpcom.ac_if.if_output = ether_output; + lnc->arpcom.ac_if.if_start = lnc_start; + lnc->arpcom.ac_if.if_ioctl = lnc_ioctl; + lnc->arpcom.ac_if.if_watchdog = lnc_watchdog; + lnc->arpcom.ac_if.if_init = lnc_init; + lnc->arpcom.ac_if.if_type = IFT_ETHER; + lnc->arpcom.ac_if.if_addrlen = ETHER_ADDR_LEN; + lnc->arpcom.ac_if.if_hdrlen = ETHER_HDR_LEN; + lnc->arpcom.ac_if.if_snd.ifq_maxlen = IFQ_MAXLEN; + */ + //ether_ifattach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED); + + kprintf("lnc%d: ", unit); + if (lnc->nic.ic == LANCE || lnc->nic.ic == C_LANCE) + kprintf("%s (%s)",nicIdent[lnc->nic.ident], icIdent[lnc->nic.ic]); + else + kprintf("%s", icIdent[lnc->nic.ic]); + kprintf(" address 0x%X\n", lnc->arpcom.ac_enaddr); + return(1); + } + diff --git a/lockwasher/src/sys/pci/pci.c b/lockwasher/src/sys/pci/pci.c new file mode 100644 index 0000000..1f42e8a --- /dev/null +++ b/lockwasher/src/sys/pci/pci.c @@ -0,0 +1,306 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: pci.c,v 1.2 2003/05/01 12:33:24 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include + +const struct { + uInt8 baseClass; + uInt8 subClass; + uInt8 interface; + const char* name; + } pciClasses[] = { + { 0x00, 0x00, 0x00, "Undefined" }, + { 0x00, 0x01, 0x00, "VGA" }, + + { 0x01, 0x00, 0x00, "SCSI" }, + { 0x01, 0x01, 0x00, "IDE" }, + { 0x01, 0x01, 0x8A, "IDE" }, + { 0x01, 0x02, 0x00, "Floppy" }, + { 0x01, 0x03, 0x00, "IPI" }, + { 0x01, 0x04, 0x00, "RAID" }, + { 0x01, 0x80, 0x00, "Other" }, + + { 0x02, 0x00, 0x00, "Ethernet" }, + { 0x02, 0x01, 0x00, "Token Ring" }, + { 0x02, 0x02, 0x00, "FDDI" }, + { 0x02, 0x03, 0x00, "ATM" }, + { 0x02, 0x04, 0x00, "ISDN" }, + { 0x02, 0x80, 0x00, "Other" }, + + { 0x03, 0x00, 0x00, "VGA" }, + { 0x03, 0x00, 0x01, "VGA+8514" }, + { 0x03, 0x01, 0x00, "XGA" }, + { 0x03, 0x02, 0x00, "3D" }, + { 0x03, 0x80, 0x00, "VGA Other" }, + + { 0x04, 0x00, 0x00, "Video" }, + { 0x04, 0x01, 0x00, "Audio" }, + { 0x04, 0x02, 0x00, "Telephony" }, + { 0x04, 0x80, 0x00, "Other" }, + + { 0x05, 0x00, 0x00, "RAM" }, + { 0x05, 0x01, 0x00, "Flash" }, + { 0x05, 0x80, 0x00, "Other" }, + + { 0x06, 0x00, 0x00, "PCI to HOST" }, + { 0x06, 0x01, 0x00, "PCI to ISA" }, + { 0x06, 0x02, 0x00, "PCI to EISA" }, + { 0x06, 0x03, 0x00, "PCI to MCA" }, + { 0x06, 0x04, 0x00, "PCI to PCI" }, + { 0x06, 0x04, 0x01, "PCI to PCI (Subtractive Decode)" }, + { 0x06, 0x05, 0x00, "PCI to PCMCIA" }, + { 0x06, 0x06, 0x00, "PCI to NuBUS" }, + { 0x06, 0x07, 0x00, "PCI to Cardbus" }, + { 0x06, 0x08, 0x00, "PCI to RACEway" }, + { 0x06, 0x09, 0x00, "PCI to PCI" }, + { 0x06, 0x0A, 0x00, "PCI to InfiBand" }, + { 0x06, 0x80, 0x00, "PCI to Other" }, + + { 0x07, 0x00, 0x00, "Serial" }, + { 0x07, 0x00, 0x01, "Serial - 16450" }, + { 0x07, 0x00, 0x02, "Serial - 16550" }, + { 0x07, 0x00, 0x03, "Serial - 16650" }, + { 0x07, 0x00, 0x04, "Serial - 16750" }, + { 0x07, 0x00, 0x05, "Serial - 16850" }, + { 0x07, 0x00, 0x06, "Serial - 16950" }, + { 0x07, 0x01, 0x00, "Parallel" }, + { 0x07, 0x01, 0x01, "Parallel - BiDir" }, + { 0x07, 0x01, 0x02, "Parallel - ECP" }, + { 0x07, 0x01, 0x03, "Parallel - IEEE1284" }, + { 0x07, 0x01, 0xFE, "Parallel - IEEE1284 Target" }, + { 0x07, 0x02, 0x00, "Multiport Serial" }, + { 0x07, 0x03, 0x00, "Hayes Compatible Modem" }, + { 0x07, 0x03, 0x01, "Hayes Compatible Modem, 16450" }, + { 0x07, 0x03, 0x02, "Hayes Compatible Modem, 16550" }, + { 0x07, 0x03, 0x03, "Hayes Compatible Modem, 16650" }, + { 0x07, 0x03, 0x04, "Hayes Compatible Modem, 16750" }, + { 0x07, 0x80, 0x00, "Other" }, + + { 0x08, 0x00, 0x00, "PIC" }, + { 0x08, 0x00, 0x01, "ISA PIC" }, + { 0x08, 0x00, 0x02, "EISA PIC" }, + { 0x08, 0x00, 0x10, "I/O APIC" }, + { 0x08, 0x00, 0x20, "I/O(x) APIC" }, + { 0x08, 0x01, 0x00, "DMA" }, + { 0x08, 0x01, 0x01, "ISA DMA" }, + { 0x08, 0x01, 0x02, "EISA DMA" }, + { 0x08, 0x02, 0x00, "Timer" }, + { 0x08, 0x02, 0x01, "ISA Timer" }, + { 0x08, 0x02, 0x02, "EISA Timer" }, + { 0x08, 0x03, 0x00, "RTC" }, + { 0x08, 0x03, 0x00, "ISA RTC" }, + { 0x08, 0x03, 0x00, "Hot-Plug" }, + { 0x08, 0x80, 0x00, "Other" }, + + { 0x09, 0x00, 0x00, "Keyboard" }, + { 0x09, 0x01, 0x00, "Pen" }, + { 0x09, 0x02, 0x00, "Mouse" }, + { 0x09, 0x03, 0x00, "Scanner" }, + { 0x09, 0x04, 0x00, "Game Port" }, + { 0x09, 0x80, 0x00, "Other" }, + + { 0x0a, 0x00, 0x00, "Generic" }, + { 0x0a, 0x80, 0x00, "Other" }, + + { 0x0b, 0x00, 0x00, "386" }, + { 0x0b, 0x01, 0x00, "486" }, + { 0x0b, 0x02, 0x00, "Pentium" }, + { 0x0b, 0x03, 0x00, "PentiumPro" }, + { 0x0b, 0x10, 0x00, "DEC Alpha" }, + { 0x0b, 0x20, 0x00, "PowerPC" }, + { 0x0b, 0x30, 0x00, "MIPS" }, + { 0x0b, 0x40, 0x00, "Coprocessor" }, + { 0x0b, 0x80, 0x00, "Other" }, + + { 0x0c, 0x00, 0x00, "FireWire" }, + { 0x0c, 0x00, 0x10, "OHCI FireWire" }, + { 0x0c, 0x01, 0x00, "Access.bus" }, + { 0x0c, 0x02, 0x00, "SSA" }, + { 0x0c, 0x03, 0x00, "USB (UHCI)" }, + { 0x0c, 0x03, 0x10, "USB (OHCI)" }, + { 0x0c, 0x03, 0x80, "USB" }, + { 0x0c, 0x03, 0xFE, "USB Device" }, + { 0x0c, 0x04, 0x00, "Fiber" }, + { 0x0c, 0x05, 0x00, "SMBus Controller" }, + { 0x0c, 0x06, 0x00, "InfiniBand" }, + { 0x0c, 0x80, 0x00, "Other" }, + + { 0x0d, 0x00, 0x00, "iRDA" }, + { 0x0d, 0x01, 0x00, "Consumer IR" }, + { 0x0d, 0x10, 0x00, "RF" }, + { 0x0d, 0x80, 0x00, "Other" }, + + { 0x0e, 0x00, 0x00, "I2O" }, + { 0x0e, 0x80, 0x00, "Other" }, + + { 0x0f, 0x01, 0x00, "TV" }, + { 0x0f, 0x02, 0x00, "Audio" }, + { 0x0f, 0x03, 0x00, "Voice" }, + { 0x0f, 0x04, 0x00, "Data" }, + { 0x0f, 0x80, 0x00, "Other" }, + + { 0x10, 0x00, 0x00, "Network" }, + { 0x10, 0x10, 0x00, "Entertainment" }, + { 0x10, 0x80, 0x00, "Other" }, + + { 0x11, 0x00, 0x00, "DPIO Modules" }, + { 0x11, 0x01, 0x00, "Performance Counters" }, + { 0x11, 0x10, 0x00, "Comm Sync, Time+Frequency Measurement" }, + { 0x11, 0x80, 0x00, "Other" }, + + }; + +uInt32 pciRead(int bus,int dev,int func,int reg,int bytes) { + uInt16 base; + + union { + struct confadd c; + uInt32 n; + } u; + + u.n = 0; + u.c.enable = 1; + u.c.rsvd = 0; + u.c.bus = bus; + u.c.dev = dev; + u.c.func = func; + u.c.reg = reg & 0xFC; + + outportDWord(0xCF8, u.n); + + base = 0xCFC + (reg & 0x03); + + switch(bytes){ + case 1: return(inportByte(base)); + case 2: return(inportWord(base)); + case 4: return(inportDWord(base)); + default: return 0; + } + } + +void pciWrite(int bus,int dev,int func,int reg,uInt32 v,int bytes) { + uInt16 base; + + union { + struct confadd c; + uInt32 n; + } u; + + u.n = 0; + u.c.enable = 1; + u.c.rsvd = 0; + u.c.bus = bus; + u.c.dev = dev; + u.c.func = func; + u.c.reg = reg & 0xFC; + + base = 0xCFC + (reg & 0x03); + outportDWord(0xCF8, u.n); + switch(bytes){ + case 1: outportByte(base, (uInt8) v); break; + case 2: outportWord(base, (uInt16) v); break; + case 4: outportDWord(base, v); break; + } + } + + +bool pciProbe(int bus, int dev, int func,struct pciConfig *cfg) { + uInt32 *word = (uInt16 *) cfg; + uInt32 v; + int i; + for(i=0;i<4;i++) { + word[i] = pciRead(bus,dev,func,4*i,4); + } + if(cfg->vendorId == 0xffff) return FALSE; + if(cfg->vendorId == 0x0) return FALSE; // Quick Hack + + cfg->bus = bus; + cfg->dev = dev; + cfg->func = func; + cfg->subsysVendor = pciRead(bus, dev, func, 0x2c, 2); + cfg->subsys = pciRead(bus, dev, func, 0x2e, 2); + kprintf("Device Info: /bus/pci/%d/%d/%d\n",bus,dev,func); + kprintf(" * Vendor: %X Device: %X Class/SubClass/Interface %X/%X/%X\n",cfg->vendorId,cfg->deviceId,cfg->baseClass,cfg->subClass,cfg->interface); + kprintf(" * Status: %X Command: %X BIST/Type/Lat/CLS: %X/%X/%X/%X\n",cfg->status, cfg->command, cfg->bist, cfg->headerType,cfg->latencyTimer, cfg->cacheLineSize); + switch(cfg->headerType & 0x7F){ + case 0: /* normal device */ + for(i=0;i<6;i++) { + v = pciRead(bus,dev,func,i*4 + 0x10, 4); + if(v) { + int v2; + pciWrite(bus,dev,func,i*4 + 0x10, 0xffffffff, 4); + v2 = pciRead(bus,dev,func,i*4+0x10, 4) & 0xfffffff0; + pciWrite(bus,dev,func,i*4 + 0x10, v, 4); + v2 = 1 + ~v2; + if(v & 1) { + cfg->base[i] = v & 0xffff; + cfg->size[i] = v2 & 0xffff; + } + else { + cfg->base[i] = v; + cfg->size[i] = v2; + } + } + else { + cfg->base[i] = 0; + cfg->size[i] = 0; + } + } + v = pciRead(bus,dev,func,0x3c,1); + cfg->irq = (v == 0xff ? 0 : v); + break; + case 1: + kprintf(" * PCI <-> PCI Bridge\n"); + break; + default: + kprintf(" * Unknown Header Type\n"); + break; + } + + return(TRUE); + } + +void initPci() { + uInt16 bus,dev,func; + int i = 0x0; + struct pciConfig pcfg; + for (bus = 0; bus < 255; bus++) { + for (dev = 0; dev < 32; dev++) { + for (func = 0; func < 8; func++) { + if (pciProbe(bus, dev, func, &pcfg) == TRUE) { + //kprintf(" * Vendor: %X Device: %X Class/SubClass/Interface %X/%X/%X\n",pcfg.vendorId,pcfg.deviceId,pcfg.baseClass,pcfg.subClass,pcfg.interface); + for (i=0x0;i + #include + #include + #include + #include + } + +#include +#include +#include + +extern "C" void sdeThread() { + ogSurface *screen = new ogDisplay_UbixOS(); + struct sdeWindows *tmp = 0x0; + ogSurface *buf = 0x0; + + screen->ogCreate(640,480,OG_PIXFMT_16BPP); + screen->ogClear(screen->ogRGB(63,63,63)); + + while (1) { + for (tmp = windows;tmp;tmp=tmp->next) { + switch (tmp->status) { + case registerWindow: + buf = (ogSurface *)tmp->buf; + buf->buffer = mapFromTask(tmp->pid,buf->buffer,buf->bSize); + buf->lineOfs = (uInt32 *)mapFromTask(tmp->pid,buf->lineOfs,buf->lSize); + tmp->status = windowReady; + kprintf("Window Registered!\n"); + break; + case drawWindow: + kprintf("Draw Window Routines Here\n"); + buf = (ogSurface *)tmp->buf; + screen->ogCopy(*buf); + tmp->status = windowReady; + break; + case killWindow: + kprintf("Killed Window\n"); + if (tmp->next != 0x0) { + tmp->next->prev = tmp->prev; + if (tmp->prev != 0x0) + tmp->prev->next = tmp->next; + } + else if (tmp->prev != 0x0) { + tmp->prev->next = tmp->next; + if (tmp->next != 0x0) + tmp->next->prev = tmp->prev; + } + else { + windows = 0x0; + } + unmapPages(buf->buffer,buf->bSize); + unmapPages(buf->lineOfs,buf->lSize); + // kfree(tmp->buf); + kfree(tmp); + tmp = 0x0; + break; + default: + break; + } + } + sched_yield(); + } + } \ No newline at end of file diff --git a/lockwasher/src/sys/sde/ogDisplay_UbixOS.cc b/lockwasher/src/sys/sde/ogDisplay_UbixOS.cc new file mode 100644 index 0000000..4ff47d9 --- /dev/null +++ b/lockwasher/src/sys/sde/ogDisplay_UbixOS.cc @@ -0,0 +1,201 @@ +#include +#include +#include +#include +#include + +extern "C" { + #include + #include + #include + } + +/* + * + * ogDisplay methods + * + */ + +void initVESAMode(uInt16 mode) { + kprintf("Pre-initVESAMode\n"); + biosCall(0x10,0x4F02,mode,0x0,0x0,0x0,0x0,0x0,0x0); + kprintf("Post-initVESAMode\n"); + return; + } + +ogDisplay_UbixOS::ogDisplay_UbixOS(void) { + VESARec = (ogVESA_Rec *)0x11000; + modeRec = (ogMode_Rec *)0x11200; + getVESAInfo(); + return; + } // ogDisplay_UbixOS::ogDisplay_UbixOS + +void ogDisplay_UbixOS::getModeInfo(uInt16 mode) { + kprintf("Pre-getModeInfo\n"); + biosCall(0x10,0x4F01,0x0,mode,0x0,0x0,0x0,0x1120,0x0); + kprintf("Post-getModeInfo\n"); + return; + } // ogDisplay_UbixOS::getModeInfo + +void ogDisplay_UbixOS::getVESAInfo(void) { + VESARec->VBESignature[0] = 'V'; // First off initialize the structure. + VESARec->VBESignature[1] = 'B'; + VESARec->VBESignature[2] = 'E'; + VESARec->VBESignature[3] = '2'; + kprintf("Pre-getVESAInfo\n"); + biosCall(0x10,0x4F00,0x0,0x0,0x0,0x0,0x0,0x1100,0x0); + kprintf("Post-getVESAInfo\n"); + return; + } // ogDisplay_UbixOS::getVESAInfo + +uInt16 ogDisplay_UbixOS::findMode(uInt32 _xRes, uInt32 _yRes, uInt32 _BPP) { + uInt16 mode; + + if ((_xRes==320) && (_yRes==200) && (_BPP==8)) return 0x13; + if ((VESARec==NULL) || (VESARec->VideoModePtr==NULL)) return 0; + if (modeRec==NULL) return 0; + for (mode = 0x100; mode < 0x1FF; mode++) { + getModeInfo(mode); + if ((modeRec->xRes>=_xRes) && (modeRec->yRes>=_yRes) && + (modeRec->BitsPerPixel==_BPP)) + return mode; + } + return 0; + } // ogDisplay_UbixOS::findMode + +void ogDisplay_UbixOS::setMode(uInt16 mode) { + + uInt32 size = 0x0, count = 0x0, i = 0x0; + + if (mode==0x13) { + + xRes = 320; + yRes = 200; + maxX = 319; + maxY = 199; + BPP = 8; + + redFieldPosition = 0; + greenFieldPosition = 0; + blueFieldPosition = 0; + alphaFieldPosition = 0; + + redShifter = 0; + greenShifter = 0; + blueShifter = 0; + alphaFieldPosition = 0; + + } else { + mode |= 0x4000; // attempt lfb + getModeInfo(mode); + if (modeRec->physBasePtr == 0) return; + buffer = (void *)modeRec->physBasePtr; + size = modeRec->yRes*modeRec->BytesPerLine; + + xRes = modeRec->BytesPerLine; + yRes = modeRec->yRes; + maxX = modeRec->xRes-1; + maxY = yRes-1; + + redFieldPosition = modeRec->RedFieldPosition; + greenFieldPosition = modeRec->GreenFieldPosition; + blueFieldPosition = modeRec->BlueFieldPosition; + + redShifter = 8-modeRec->RedMaskSize; + greenShifter = 8-modeRec->GreenMaskSize; + blueShifter = 8-modeRec->BlueMaskSize; + + BPP = modeRec->BitsPerPixel; + } + + owner = this; + dataState = ogALIASING; + + if ((lineOfs!=NULL) && (lSize!=0)) delete [] lineOfs; + lSize = yRes*sizeof(uInt32); + lineOfs = new uInt32[yRes];; + if (lineOfs == NULL) return; + lineOfs[0] = 0; + for (count=1; count8); + if (BPP==8) setPal(); + initVESAMode(mode); + for (i=0x0;i<((size)/4096);i++) { + remapPage(modeRec->physBasePtr + (i * 0x1000),modeRec->physBasePtr + (i * 0x1000)); + } + return; + } // ogDisplay_UbixOS::setMode + +void ogDisplay_UbixOS::setPal(void) { + uInt32 c; + if (BPP!=8) return; + // outportb(0x3c8,0); + for (c=0; c<256; c++) { + // outportb(0x3c9,pal[c].red >> 2); + // outportb(0x3c9,pal[c].green >> 2); + // outportb(0x3c9,pal[c].blue >> 2); + } // for + return; +} // ogDisplay_UbixOS::setPal + +bool +ogDisplay_UbixOS::ogAlias(ogSurface& SrcObject, uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) { + return false; +} // ogDisplay_UbixOS::ogAlias + +bool +ogDisplay_UbixOS::ogCreate(uInt32 _xRes, uInt32 _yRes,ogPixelFmt _pixFormat) { + uInt16 mode; + mode = 0x111; + setMode(mode); + /* + mode = findMode(_xRes, _yRes, _pixFormat.BPP); + if ((mode == 0) && ((_pixFormat.BPP==24) || (_pixFormat.BPP==32))) { + if (_pixFormat.BPP==24) _pixFormat.BPP=32; else _pixFormat.BPP=24; + mode=findMode(_xRes,_yRes,_pixFormat.BPP); + } // if + if (mode!=0) setMode(mode); + */ + return (mode!=0); +} // ogDisplay_UbixOS::ogCreate + +bool +ogDisplay_UbixOS::ogClone(ogSurface& SrcObject) { + return false; +} // ogDisplay_UbixOS::ogClone + +void +ogDisplay_UbixOS::ogCopyPal(ogSurface& SrcObject) { + ogSurface::ogCopyPal(SrcObject); + setPal(); + return; +} // ogDisplay_UbixOS::ogCopyPal + +bool +ogDisplay_UbixOS::ogLoadPal(const char *palfile) { + bool result; + if ((result = ogSurface::ogLoadPal(palfile))==true) setPal(); + return result; +} // ogDisplay_UbixOS::ogLoadPal + +void +ogDisplay_UbixOS::ogSetRGBPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) { + if (pal==NULL) return; + ogSurface::ogSetRGBPalette(colour,red,green,blue); +// outportb(0x3c8,colour); +// outportb(0x3c9,red >> 2); +// outportb(0x3c9,green >> 2); +// outportb(0x3c9,blue >> 2); + + return; +} // ogDisplay_UbixOS::ogSetRGBPalette + +ogDisplay_UbixOS::~ogDisplay_UbixOS(void) { +//mji delete VESARec; +//mji delete modeRec; + return; +} // ogDisplay_UbixOS::~ogDisplay_UbixOS diff --git a/lockwasher/src/sys/sde/sde.cc b/lockwasher/src/sys/sde/sde.cc new file mode 100644 index 0000000..49e38f4 --- /dev/null +++ b/lockwasher/src/sys/sde/sde.cc @@ -0,0 +1,90 @@ +#include +#include + +extern "C" { + #include + #include + #include + #include + #include + } + +struct sdeWindows *windows = 0x0; + +extern "C" void sysSDE(uInt32 cmd,void *ptr) { + ogSurface *newBuf = 0x0; + ogSurface *oldBuf = (ogSurface *)ptr; + struct sdeWindows *tmp = 0x0; + + for (tmp=windows;tmp;tmp=tmp->next) { + if (tmp->pid == _current->id) + break; + } + + if (tmp != 0x0) { + while (tmp->status != windowReady) + sched_yield(); + } + else if (tmp == 0x0 && cmd != registerWindow) { + kprintf("Invalid Window\n"); + return; + } + + switch (cmd) { + case drawWindow: + tmp->status = drawWindow; + break; + case killWindow: + tmp->status = killWindow; + break; + case registerWindow: + if (oldBuf->buffer != 0x0) { + newBuf = new ogSurface(); + newBuf->version = oldBuf->version; + newBuf->buffer = oldBuf->buffer; + newBuf->lineOfs = oldBuf->lineOfs; + newBuf->pal = oldBuf->pal; + newBuf->owner = oldBuf->owner; + newBuf->xRes = oldBuf->xRes; + newBuf->yRes = oldBuf->yRes; + newBuf->maxX = oldBuf->maxX; + newBuf->maxY = oldBuf->maxY; + newBuf->bSize = oldBuf->bSize; + newBuf->lSize = oldBuf->lSize; + newBuf->transparentColor = oldBuf->transparentColor; + newBuf->dataState = oldBuf->dataState; + newBuf->BPP = oldBuf->BPP; + newBuf->redFieldPosition = oldBuf->redFieldPosition; + newBuf->greenFieldPosition = oldBuf->greenFieldPosition; + newBuf->blueFieldPosition = oldBuf->blueFieldPosition; + newBuf->alphaFieldPosition = oldBuf->alphaFieldPosition; + newBuf->redShifter = oldBuf->redShifter; + newBuf->greenShifter = oldBuf->greenShifter; + newBuf->blueShifter = oldBuf->blueShifter; + newBuf->alphaShifter = oldBuf->alphaShifter; + newBuf->antiAlias = oldBuf->antiAlias; + tmp = (struct sdeWindows *)kmalloc(sizeof(struct sdeWindows),-2); + tmp->buf = newBuf; + tmp->status = registerWindow; + tmp->pid = _current->id; + tmp->prev = 0x0; + if (windows == 0x0) { + windows = tmp; + tmp->next = 0x0; + } + else { + tmp->next = windows; + windows->prev = tmp; + windows = tmp; + } + } + else { + kprintf("Invalid Window\n"); + } + break; + default: + kprintf("Invalid SDE Command [0x%X]\n",ptr); + break; + } + return; + } \ No newline at end of file diff --git a/lockwasher/src/sys/sys/Makefile b/lockwasher/src/sys/sys/Makefile new file mode 100644 index 0000000..49b5278 --- /dev/null +++ b/lockwasher/src/sys/sys/Makefile @@ -0,0 +1,36 @@ +# (C) 2002 The UbixOS Project +# $Id: Makefile,v 1.3 2003/03/13 02:02:33 apwillia Exp $ + +CFLAGS = -fno-builtin + +# Compiler +CC = gcc +CPP = g++ + + +# Linker +LINKER = ld + +# Remove +REMOVE = rm -fr + +# Objects +OBJS = io.o idt.o dma.o drives.o video.o + +all: $(OBJS) + +# Compile Types +.cc.o: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.cc.s: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.c.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.c.s: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.S.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) diff --git a/lockwasher/src/sys/sys/dma.c b/lockwasher/src/sys/sys/dma.c new file mode 100644 index 0000000..20015d9 --- /dev/null +++ b/lockwasher/src/sys/sys/dma.c @@ -0,0 +1,65 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: dma.c,v 1.2 2003/02/18 22:42:36 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include + +#define lowByte(x) (x & 0x00FF) +#define highByte(x) ((x & 0xFF00) >> 8) + +uChar maskReg[8] = { 0x0A, 0x0A, 0x0A, 0x0A, 0xD4, 0xD4, 0xD4, 0xD4 }; +uChar clearReg[8] = { 0x0C, 0x0C, 0x0C, 0x0C, 0xD8, 0xD8, 0xD8, 0xD8 }; +uChar modeReg[8] = { 0x0B, 0x0B, 0x0B, 0x0B, 0xD6, 0xD6, 0xD6, 0xD6 }; +uChar addrPort[8] = { 0x00, 0x02, 0x04, 0x06, 0xC0, 0xC4, 0xC8, 0xCC }; +uChar pagePort[8] = { 0x87, 0x83, 0x81, 0x82, 0x8F, 0x8B, 0x89, 0x8A }; +uChar countPort[8] = { 0x01, 0x03, 0x05, 0x07, 0xC2, 0xC6, 0xCA, 0xCE }; + +void dmaXfer(uChar channel,uLong address,uInt length,uChar read) { + unsigned char page=0, mode=0; + unsigned int offset = 0; + if (read) { + mode = 0x48 + channel; + } + else { + mode = 0x44 + channel; + } + page = address >> 16; + offset = address & 0xFFFF; + length--; + _dmaXfer(channel, page, offset, length, mode); + } + +void _dmaXfer(uChar dmaChannel,uChar page,uInt offset,uInt length,uChar mode) { + asm("cli"); + outportByte(maskReg[dmaChannel], 0x04 | dmaChannel); + outportByte(clearReg[dmaChannel], 0x00); + outportByte(modeReg[dmaChannel], mode); + outportByte(addrPort[dmaChannel], lowByte(offset)); + outportByte(addrPort[dmaChannel], highByte(offset)); + outportByte(pagePort[dmaChannel], page); + outportByte(countPort[dmaChannel], lowByte(length)); + outportByte(countPort[dmaChannel], highByte(length)); + outportByte(maskReg[dmaChannel], dmaChannel); + asm("sti"); + } diff --git a/lockwasher/src/sys/sys/drives.c b/lockwasher/src/sys/sys/drives.c new file mode 100644 index 0000000..bc50c9d --- /dev/null +++ b/lockwasher/src/sys/sys/drives.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +struct driveDriver *drives = 0x0; +int currentDrive = 0x0; + +void addDrive(int id,char type,void *driveInfoStruct,void *read,void *write,void *reset) { + struct driveDriver *tmp = 0x0; + tmp = (struct driveDriver *)kmalloc(sizeof(struct driveDriver),-2); + tmp->driveInfoStruct = driveInfoStruct; + tmp->read = read; + tmp->write = write; + tmp->reset = reset; + tmp->id = id; + tmp->driveType = type; + if (!drives) { + tmp->next = 0x0; + tmp->prev = 0x0; + drives = tmp; + } + else { + tmp->next = drives; + tmp->prev = 0x0; + drives = tmp; + } + } + +struct driveDriver *findDrive(int id) { + struct driveDriver *tmp = 0x0; + for (tmp = drives;tmp;tmp=tmp->next) { + if (tmp->id == id) return(tmp); + } + return(0x0); + } diff --git a/lockwasher/src/sys/sys/idt.c b/lockwasher/src/sys/sys/idt.c new file mode 100644 index 0000000..7b3585a --- /dev/null +++ b/lockwasher/src/sys/sys/idt.c @@ -0,0 +1,475 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: idt.c,v 1.20 2003/04/27 12:37:26 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define FP_TO_LINEAR(seg, off) ((void*) ((((uInt16) (seg)) << 4) + ((uInt16) (off)))) + +void mathStateRestore(); + +descriptorTable(IDT, 256) { + }; + +struct { + unsigned short limit __attribute__ ((packed)); + union descriptorTableunion *idt __attribute__ ((packed)); + } loadidt= { (256 * sizeof(union descriptorTableunion) - 1), IDT }; + +/* Sets Up Initial IDT Table */ +void initIdt() { + int i=0; + struct tssStruct *gpfTSS = (struct tssStruct *)0x4200; + + for (i=0;i<256;i++) { + setVector(&intNull, i, dPresent + dInt + dDpl3); + } + asm ( + "cli\n" + "lidt (%0) \n" /* Load the IDT */ + "pushfl \n" /* Clear the NT flag */ + "andl $0xffffbfff,(%%esp) \n" + "popfl \n" + "sti \n" + : + : "r" ((char *) &loadidt) + ); + setVector(&_int0,0,dPresent + dTrap + dDpl3); + setVector(&_int1,1,dPresent + dTrap + dDpl3); + setVector(&_int2,2,dPresent + dTrap + dDpl3); + setVector(&_int3,3,dPresent + dTrap + dDpl3); + setVector(&_int4,4,dPresent + dTrap + dDpl3); + setVector(&_int5,5,dPresent + dTrap + dDpl3); + setVector(&_int6,6,dPresent + dTrap + dDpl3); + setVector(&_int7,7,dPresent + dTrap + dDpl3); + //setVector(&_int8,8,dPresent + dTrap + dDpl3); + setTaskVector(8,dPresent + dTask + dDpl3,0x20); + setVector(&_int9,9,dPresent + dTrap + dDpl3); + setVector(&_int10,10,dPresent + dTrap + dDpl3); + setVector(&_int11,11,dPresent + dTrap + dDpl3); + setVector(&_int12,12,dPresent + dTrap + dDpl3); + //setVector(&_int13,13,dPresent + dTrap + dDpl3); + setTaskVector(13,dPresent + dTask + dDpl3,0x40); + setVector(&_pageFault,14,dPresent + dTrap + dDpl3); + setVector(&_sysCall,128,dPresent + dTrap + dDpl3); + setVector(timerInt,0x68, (dInt + dPresent + dDpl3)); + setVector(schedule,0x69, (dInt + dPresent + dDpl3)); + + gpfTSS->back_link = 0x0; + gpfTSS->esp0 = (uInt32)kmalloc(4096,-2)+4096; + gpfTSS->ss0 = 0x10; + gpfTSS->esp1 = 0x0; + gpfTSS->ss1 = 0x0; + gpfTSS->esp2 = 0x0; + gpfTSS->ss2 = 0x0; + gpfTSS->cr3 = (unsigned int)kernelPageDirectory; + gpfTSS->eip = (unsigned int)&_int13; + gpfTSS->eflags = 0x206; + gpfTSS->esp = 0x1CFFF; + gpfTSS->ebp = 0x1CFFF; + gpfTSS->esi = 0x0; + gpfTSS->edi = 0x0; + gpfTSS->es = 0x10; + gpfTSS->cs = 0x08; + gpfTSS->ss = 0x10; + gpfTSS->ds = 0x10; + gpfTSS->fs = 0x10; + gpfTSS->gs = 0x10; + gpfTSS->ldt = 0x0; + gpfTSS->trace_bitmap = 0x0000; + gpfTSS->io_map = 0x8000; + } + +/* Sets Up IDT Vector */ +void setVector(void *handler, unsigned char interrupt, unsigned short controlMajor) { + unsigned short codesegment = 0x08; + asm volatile("movw %%cs,%0":"=g" (codesegment)); + IDT[interrupt].gate.offsetLow = (unsigned short) (((unsigned long)handler)&0xffff); + IDT[interrupt].gate.selector = codesegment; + IDT[interrupt].gate.access = controlMajor; + IDT[interrupt].gate.offsetHigh = (unsigned short) (((unsigned long)handler) >> 16); + } + +/************************************************************************ + +Function: void setTaskVector(uInt8,uInt16,uInt8); +Description: This Function Sets Up An IDT Task Vector +Notes: + +************************************************************************/ +void setTaskVector(uInt8 interrupt,uInt16 controlMajor,uInt8 selector) { + uInt16 codesegment = 0x08; + asm volatile("movw %%cs,%0":"=g" (codesegment)); + IDT[interrupt].gate.offsetLow = 0x0; + IDT[interrupt].gate.selector = selector; + IDT[interrupt].gate.access = controlMajor; + IDT[interrupt].gate.offsetHigh = 0x0; + } + + +/* Null Intterupt Descriptor */ +void intNull() { + kprintf("Woot Invalid Interrupt\n"); + //freeProcessPages(_current->id); + //setTaskStatus(_current->id, EXITING); + //_current->status = EMPTY; + //schedule(); + //while(1); + return; + } + +void _int0() { + kprint("int0: Divide-by-Zero\n"); + freeProcessPages(_current->id); + setTaskStatus(_current->id, EXITING); + //_current->status = EMPTY; + schedule(); + while(1); + } +void _int1() { + kprint("int1: Debug exception\n"); + freeProcessPages(_current->id); + setTaskStatus(_current->id, EXITING); + //_current->status = EMPTY; + schedule(); + while(1); + } +void _int2() { + kprint("int2: unknown error\n"); + freeProcessPages(_current->id); + setTaskStatus(_current->id, EXITING); + //_current->status = EMPTY; + schedule(); + while(1); + } +void _int3() { + kprint("int3: Breakpoint\n"); + freeProcessPages(_current->id); + setTaskStatus(_current->id, EXITING); + //_current->status = EMPTY; + schedule(); + while(1); + } +void _int4() { + kprint("int4: Overflow\n"); + freeProcessPages(_current->id); + setTaskStatus(_current->id, EXITING); + //_current->status = EMPTY; + schedule(); + while(1); + } +void _int5() { + kprint("int5: Bounds check\n"); + freeProcessPages(_current->id); + setTaskStatus(_current->id, EXITING); + //_current->status = EMPTY; + schedule(); + while(1); + } +void _int6() { + kprintf("int6: Invalid opcode!\n"); + freeProcessPages(_current->id); + setTaskStatus(_current->id, EXITING); + //_current->status = EMPTY; + schedule(); + while(1); + } + +void _int7(); +__asm__ ( + ".globl _int7 \n" + "_int7: \n" + " pushl %eax \n" + " clts \n" + " movl _current,%eax \n" + " cmpl _usedMath,%eax \n" + " je mathDone \n" + " call mathStateRestore \n" + "mathDone: \n" + " popl %eax \n" + " iret \n" + ); + +void _int8() { + kprintf("int8: Double Fault!\n"); + while(1); + } + +void _int9() { + kprintf("int9: Coprocessor Segment Overrun!\n"); + while(1); + } + +void _int10() { + kprintf("int10: Invalid TSS!\n"); + while(1); + } + +void _int11() { + kprintf("int11: Segment Not Present!\n"); + while(1); + } + +void _int12() { + kprintf("int12: Stack-Segment Fault!\n"); + while(1); + } + +/* +void _int13() { + kprintf("int13: General Protection Fault!\n"); + kprintf("Task Id: [%i]\n",_current->id); + while(1); + } +*/ + +void _int13() { + uInt8 *ip = 0x0; + uInt16 *stack = 0x0, *ivt = 0x0; + uInt32 *stack32 = 0x0; + bool isOperand32 = FALSE, isAddress32 = FALSE; + + disableIrq(0); + + ip = FP_TO_LINEAR(_current->tss.cs, _current->tss.eip); + ivt = (uInt16 *) 0x0; + stack = (uInt16 *) FP_TO_LINEAR(_current->tss.ss,_current->tss.esp); + stack32 = (uInt32 *)stack; + + /* + asm( + "movl %%cr2,%%eax\n" + "movl %%eax,%0 \n" + + : "=g" (memAddr) + ); + */ + gpfStart: + /* + kprintf("General Protection Fault\n"); + kprintf("EAX: [0x%X],EBX: [0x%X]\n",_current->tss.eax,_current->tss.ebx); + kprintf("ECX: [0x%X],EDX: [0x%X]\n",_current->tss.ecx,_current->tss.edx); + kprintf("ESP: [0x%X],EPB: [0x%X]\n",_current->tss.esp,_current->tss.ebp); + kprintf("EIP: [0x%X],CR2: [0x%X]\n",_current->tss.eip,memAddr); + kprintf("CS: [0x%X],DS: [0x%X]\n",_current->tss.cs,_current->tss.ds); + kprintf("SS: [0x%X],ES: [0x%X]\n",_current->tss.ss,_current->tss.es); + kprintf("FS: [0x%X],GS: [0x%X]\n",_current->tss.gs,_current->tss.gs); + kprintf("EFLAGS: [0x%X] \n",_current->tss.eflags); + */ + //kprintf("IP: [0x%X][0x%X][0x%X][0x%X][0x%X]\n",ip,ip[0],ip[1],ip[2],ip[3]); + + switch (ip[0]) { + case 0xCD: /* INT n */ + switch (ip[1]) { + case 0x69: + //kprintf("Exit Bios [0x%X]\n",_current->id); + _current->oInfo.timer = 0x0; + setTaskStatus(_current->id,EXITING); + break; + case 0x20: + case 0x21: + //kprintf("Help!!!\n"); + while(1); + break; + default: + stack -= 3; + _current->tss.esp = ((_current->tss.esp & 0xffff) - 6) & 0xffff; + stack[0] = (uInt16) (_current->tss.eip + 2); + stack[1] = _current->tss.cs; + stack[2] = (uInt16) _current->tss.eflags; + if (_current->oInfo.v86If) + stack[2] |= EFLAG_IF; + else + stack[2] &= ~EFLAG_IF; + _current->tss.cs = ivt[ip[1] * 2 + 1] & 0xFFFF; + _current->tss.eip = ivt[ip[1] * 2] & 0xFFFF; + //kprintf("New Int [0x%X][0x%X][0x%X] [0x%X]\n",ip[1],_current->tss.cs,_current->tss.eip,_current->id); + break; + } + break; + case 0x66: + isOperand32 = TRUE; + ip++; + _current->tss.eip = (uInt16) (_current->tss.eip + 1); + goto gpfStart; + break; + case 0x67: + isAddress32 = TRUE; + ip++; + _current->tss.eip = (uInt16) (_current->tss.eip + 1); + goto gpfStart; + break; + case 0xF0: + _current->tss.eip = (uInt16) (_current->tss.eip + 1); + //kprintf("No!!!\n"); + while(1); + break; + case 0x9C: + if (isOperand32 == TRUE) { + _current->tss.esp = ((_current->tss.esp & 0xffff) - 4) & 0xffff; + stack32--; + stack32[0] = _current->tss.eflags & 0xDFF; + if (_current->oInfo.v86If == TRUE) + stack32[0] |= EFLAG_IF; + else + stack32[0] &= ~EFLAG_IF; + } + else { + _current->tss.esp = ((_current->tss.esp & 0xffff) - 2) & 0xffff; + stack--; + stack[0] = (uInt16) _current->tss.eflags; + if (_current->oInfo.v86If == TRUE) + stack[0] |= EFLAG_IF; + else + stack[0] &= ~EFLAG_IF; + _current->tss.eip = (uInt16) (_current->tss.eip + 1); + } + //kprintf("pushf [0x%X]\n",_current->id); + break; + case 0x9D: + if (isOperand32 == TRUE) { + _current->tss.eflags = EFLAG_IF | EFLAG_VM | (stack32[0] & 0xDFF); + _current->oInfo.v86If = (stack32[0] & EFLAG_IF) != 0; + _current->tss.esp = ((_current->tss.esp & 0xffff) + 4) & 0xffff; + } + else { + _current->tss.eflags = EFLAG_IF | EFLAG_VM | stack[0]; + _current->oInfo.v86If = (stack[0] & EFLAG_IF) != 0; + _current->tss.esp = ((_current->tss.esp & 0xffff) + 2) & 0xffff; + } + _current->tss.eip = (uInt16) (_current->tss.eip + 1); + //kprintf("popf [0x%X]\n",_current->id); + break; + case 0xFA: + _current->oInfo.v86If = FALSE; + _current->tss.eflags &= ~EFLAG_IF; + _current->tss.eip = (uInt16) (_current->tss.eip + 1); + _current->oInfo.timer = 0x1; + //kprintf("cli [0x%X]\n",_current->id); + break; + case 0xFB: + _current->oInfo.v86If = TRUE; + _current->tss.eflags |= EFLAG_IF; + _current->tss.eip = (uInt16) (_current->tss.eip + 1); + _current->oInfo.timer = 0x0; + //kprintf("sti [0x%X]\n",_current->id); + break; + case 0xCF: + _current->tss.eip = stack[0]; + _current->tss.cs = stack[1]; + _current->tss.eflags = EFLAG_IF | EFLAG_VM | stack[2]; + _current->oInfo.v86If = (stack[2] & EFLAG_IF) != 0; + _current->tss.esp = ((_current->tss.esp & 0xffff) + 6) & 0xffff; + //kprintf("iret [0x%X]\n",_current->id); + break; + case 0xEC: // IN AL,DX + _current->tss.eax = (_current->tss.eax & ~0xFF) | inportByte(_current->tss.edx); + _current->tss.eip = (uInt16) (_current->tss.eip + 1); + //kprintf("IN DX[0x%X],AL[0x%X] [0x%X]\n",_current->tss.edx,_current->tss.eax & 0xFF,_current->id); + break; + case 0xED: // IN AX,DX + _current->tss.eax = (_current->tss.eax & ~0xFFFF) | inportWord(_current->tss.edx); + _current->tss.eip = (uInt16) (_current->tss.eip + 1); + //kprintf("IN DX[0x%X],AX[0x%X] [0x%X]\n",_current->tss.edx,_current->tss.eax & 0xFFFF,_current->id); + break; + case 0xEE: // OUT DX,AL + outportByte(_current->tss.edx, _current->tss.eax & 0xFF); + _current->tss.eip = (uInt16) (_current->tss.eip + 1); + //kprintf("OUT DX[0x%X],AL[0x%X] [0x%X]\n",_current->tss.edx,_current->tss.eax & 0xFF,_current->id); + break; + case 0xEF: + outportWord(_current->tss.edx, _current->tss.eax); + _current->tss.eip = (uInt16) (_current->tss.eip + 1); + //kprintf("OUT DX[0x%X],AX[0x%X] [0x%X]\n",_current->tss.edx,_current->tss.eax,_current->id); + break; + case 0xF4: + _current->tss.eip = (uInt16) (_current->tss.eip + 1); + //kprintf("HLT [0x%X]\n",_current->id); + break; + default: /* something wrong */ + kprintf("Non Handled OpCode [0x%X]\n",_current->id); + setTaskStatus(_current->id,EXITING); + //Temp Reboot For Now + //while(inportByte(0x64) & 0x02); + //outportByte(0x64, 0xfe); + break; + } + enableIrq(0); + while (1); + } + +/* Timer Interupt */ +__asm__ ( + ".globl timerInt \n" + "timerInt: \n" + " pusha \n" + " movl systemVitals,%ecx \n" + " incl 12(%ecx) \n" + " mov $0x20,%dx \n" + " mov $0x20,%ax \n" + " outb %al,%dx \n" + " movl 12(%ecx),%eax \n" + " movl $1000,%ebx \n" + " xor %edx,%edx \n" + " div %ebx \n" + " test %edx,%edx \n" + " jnz next \n" + " incl 16(%ecx) \n" + "next: \n" + " movl 12(%ecx),%eax \n" + " movl $5,%ebx \n" + " xor %edx,%edx \n" + " div %ebx \n" + " test %edx,%edx \n" + " jnz done \n" + " call schedule \n" + " jmp done \n" + "done: \n" + " popa \n" +// " call blahBlah2 \n" + " iret \n" + ); + +void mathStateRestore() { + if (_usedMath != 0x0) + __asm__("fnsave %0"::"m" (_usedMath->i387)); + if (_current->usedMath != 0x0) + __asm__("frstor %0"::"m" (_current->i387)); + else { + __asm__("fninit"::); + _current->usedMath=1; + } + _usedMath=_current; + //Return + } diff --git a/lockwasher/src/sys/sys/io.c b/lockwasher/src/sys/sys/io.c new file mode 100644 index 0000000..9242429 --- /dev/null +++ b/lockwasher/src/sys/sys/io.c @@ -0,0 +1,136 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: io.c,v 1.3 2003/05/01 12:30:02 reddawg Exp $ + +**************************************************************************************/ + +/************************************************************************ + +Function: inline unsigned char inportByte(unsigned int port); +Description: This Funciton Will Input One Byte From A Port +Notes: + +************************************************************************/ +inline unsigned char inportByte(unsigned int port) { + unsigned char retVal; + asm volatile( + "inb %%dx,%%al" + : "=a" (retVal) + : "d" (port) + ); + return(retVal); + } + +/************************************************************************ + +Function: inline unsigned char inportWord(unsigned int port); +Description: This Funciton Will Input One Word From A Port +Notes: + +************************************************************************/ +inline unsigned short inportWord(unsigned int port) { + unsigned short retVal; + asm volatile( + "inw %%dx,%%ax" + : "=a" (retVal) + : "d" (port) + ); + return(retVal); + } + +/************************************************************************ + +Function: inline void outportByte(unsigned int port,unsigned char value); +Description: This Funciton Will Outputut One Byte To A Port +Notes: + +************************************************************************/ +inline void outportByte(unsigned int port,unsigned char value) { + asm volatile( + "outb %%al,%%dx" + : + : "d" (port), "a" (value) + ); + } + +/************************************************************************ + +Function: inline void outportByteP(unsigned int port,unsigned char value); +Description: This Funciton Will Outputut One Byte To A Port With A Delay +Notes: + +************************************************************************/ +inline void outportByteP(unsigned int port,unsigned char value) { + asm volatile( + "outb %%al,%%dx\n" + "jmp 1f \n" + "1: jmp 1f \n" + "1: \n" + : + : "d" (port), "a" (value) + ); + } + +/************************************************************************ + +Function: inline void outportWord(unsigned int port,unsigned char value); +Description: This Funciton Will Outputut One Word To A Port +Notes: + +************************************************************************/ +inline void outportWord(unsigned int port,unsigned short value) { + asm volatile( + "outw %%ax,%%dx" + : + : "d" (port), "a" (value) + ); + } + +/************************************************************************ + +Function: inline void outportDWord(unsigned int port,unsigned char value); +Description: This Funciton Will Outputut One DWord To A Port +Notes: + +************************************************************************/ +inline void outportDWord(unsigned int port,unsigned long value) { + asm volatile( + "outl %%eax,%%dx" + : + : "d" (port), "a" (value) + ); + } + +/************************************************************************ + +Function: inline unsigned char inportDWord(unsigned int port); +Description: This Funciton Will Input One DWord From A Port +Notes: + +************************************************************************/ +inline unsigned long inportDWord(unsigned int port) { + unsigned long retVal; + asm volatile( + "inl %%dx,%%eax" + : "=a" (retVal) + : "d" (port) + ); + return(retVal); + } \ No newline at end of file diff --git a/lockwasher/src/sys/sys/video.c b/lockwasher/src/sys/sys/video.c new file mode 100644 index 0000000..fedd301 --- /dev/null +++ b/lockwasher/src/sys/sys/video.c @@ -0,0 +1,103 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: video.c,v 1.4 2003/04/23 21:42:34 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include + +unsigned char *videoBuffer = (char *)0xB8000; +int printColor = defaultColor; + +void backSpace() { + uInt32 bufferOffset = 0x0; + outportByte(0x3d4, 0x0e); + bufferOffset = inportByte(0x3d5); + bufferOffset <<= 8; /* Shift Address Left 8 Bits */ + outportByte(0x3d4, 0x0f); + bufferOffset += inportByte(0x3d5); + bufferOffset <<= 1; /* Shift Address Left 1 Bits */ + videoBuffer[bufferOffset--] = 0x0; + videoBuffer[bufferOffset--] = 0x0; + bufferOffset >>= 1; /* Set the new cursor position */ + outportByte(0x3d4, 0x0f); + outportByte(0x3d5, bufferOffset & 0x0ff); + outportWord(0x3d4, 0x0e); + outportByte(0x3d5, bufferOffset >> 8); + return; + } + +void kprint(char *string) { + unsigned int bufferOffset = 0,character = 0,i = 0; + asm("cli"); + /* We Need To Get The Y Position */ + outportByte(0x3d4, 0x0e); + bufferOffset = inportByte(0x3d5); + bufferOffset <<= 8; /* Shift Address Left 8 Bits */ + /* Then We Need To Add The X Position */ + outportByte(0x3d4, 0x0f); + bufferOffset += inportByte(0x3d5); + bufferOffset <<= 1; /* Shift Address Left 1 Bits */ + while ((character=*string++)) { + switch(character) { + case '\n': + bufferOffset = (bufferOffset/160)*160 + 160; + break; + default: + videoBuffer[bufferOffset++] = character; + videoBuffer[bufferOffset++] = printColor; + break; + } + /* Check To See If We Are Out Of Bounds */ + if (bufferOffset >= 160*25) { + for (i = 0; i < 160*24; i++) { + videoBuffer[i] = videoBuffer[i+160]; + } + for (i = 0; i < 80; i++) { + videoBuffer[(160*24)+(i*2)] = 0x20; + videoBuffer[(160*24)+(i*2)+1] = printColor; + } + bufferOffset -= 160; + } + } + bufferOffset >>= 1; /* Set the new cursor position */ + outportByte(0x3d4, 0x0f); + outportByte(0x3d5, bufferOffset & 0x0ff); + outportWord(0x3d4, 0x0e); + outportByte(0x3d5, bufferOffset >> 8); + asm("sti"); + } + +/* Clears The Screen */ +void clearScreen() { + unsigned int i; + for (i = 0; i < (80*25); i++) { /* Fill the screen with */ + /* background Color */ + videoBuffer[i*2] = 0x20; + videoBuffer[i*2+1] = defaultColor; + } + + outportByte(0x3d4, 0x0f); /* Set the cursor to the */ + outportByte(0x3d5, 0); /* upper-left corner of the */ + outportWord(0x3d4, 0x0e); /* screen */ + outportByte(0x3d5, 0); + } diff --git a/lockwasher/src/sys/ubixfs/Makefile b/lockwasher/src/sys/ubixfs/Makefile new file mode 100644 index 0000000..55a49c9 --- /dev/null +++ b/lockwasher/src/sys/ubixfs/Makefile @@ -0,0 +1,36 @@ +# (C) 2002 The UbixOS Project +# $Id: Makefile,v 1.3 2003/03/13 02:02:33 apwillia Exp $ + +CFLAGS = -fno-builtin + +# Compiler +CC = gcc +CPP = g++ + + +# Linker +LINKER = ld + +# Remove +REMOVE = rm -fr + +# Objects +OBJS = ubixfs.o + +all: $(OBJS) + +# Compile Types +.cc.o: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.cc.s: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.c.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.c.s: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.S.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) diff --git a/lockwasher/src/sys/ubixfs/ubixfs.c b/lockwasher/src/sys/ubixfs/ubixfs.c new file mode 100644 index 0000000..1c9ce94 --- /dev/null +++ b/lockwasher/src/sys/ubixfs/ubixfs.c @@ -0,0 +1,288 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: ubixfs.c,v 1.22 2003/04/24 05:16:28 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int sprintf(char *buf,const char *fmt, ...); //TEMP + +int enableUbixFS() { + //Add UbixFS + if (!addFs(0,initUbixFS,readUbixFS,writeUbixFS,openFileUbixFS,0x0,0x0,0x0,0x0)) { + //sysErr(LOG,"Unable To Enable UbixFS"); + return(0); + } + //Return + return(1); + } + +void initUbixFS(struct mountPoints *mp) { + struct ubixFsInfo *fsInfo = 0x0; + mp->drive->diskLabel = (struct driveDiskLabel *)kmalloc(512,-2); + mp->drive->read(mp->drive->driveInfoStruct,1,1,mp->drive->diskLabel); + mp->fsInfo = (struct ubixFsInfo *)kmalloc(sizeof(struct ubixFsInfo),-2); + fsInfo = mp->fsInfo; + if ((mp->drive->diskLabel->magicNum == UBIXDISKMAGIC) && (mp->drive->diskLabel->magicNum2 == UBIXDISKMAGIC)) { + fsInfo->blockAllocationTable = (struct blockAllocationTableEntry *)kmalloc(mp->drive->diskLabel->partitions[mp->partition].pBatSize*512,-2); + //fsInfo->blockAllocationTable[0].nextBlock = 100; + fsInfo->batEntries = ((mp->drive->diskLabel->partitions[mp->partition].pBatSize*512)/sizeof(struct blockAllocationTableEntry)); + mp->drive->read(mp->drive->driveInfoStruct,mp->drive->diskLabel->partitions[mp->partition].pOffset,mp->drive->diskLabel->partitions[mp->partition].pBatSize,fsInfo->blockAllocationTable); + kprintf("UbixFS Initialized\n"); + } + else { + kprintf("Insert System Disk\n"); + initUbixFS(mp); + } + //Return + return; + } + +int openFileUbixFS(char *file,fileDescriptor *fd) { + int x=0; + struct directoryEntry *dirEntry = (struct directoryEntry *)kmalloc(4096,_current->id); + struct ubixFsInfo *fsInfo = fd->mp->fsInfo; + fd->mp->drive->read(fd->mp->drive->driveInfoStruct,(fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[0].realSector),8,dirEntry); + if (fd->mode == 0) { + for (x=0;x<(4096/sizeof(struct directoryEntry));x++) { + if ((int)!kstrcmp(dirEntry[x].fileName,file)) { + fd->start = dirEntry[x].startCluster; + fd->size = dirEntry[x].size; + fd->perms = dirEntry[x].permissions; + fd->dirBlock = 0x0; //Directory Start Sector + kfree(dirEntry); + return((int)1); + } + } + } + else if (fd->mode == 1) { + for (x=0;x<(4096/sizeof(struct directoryEntry));x++) { + if (dirEntry[x].attributes == 0x0) { + sprintf(dirEntry[x].fileName,file); + dirEntry[x].size = 0x0; + dirEntry[x].startCluster = 0x0; + fd->size = 0x0; + fd->start = 0x0; + fd->dirBlock = 0x0; + fd->mp->drive->write(fd->mp->drive->driveInfoStruct,(fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[0].realSector),8,dirEntry); + kfree(dirEntry); + return((int)1); + } + } + } + kfree(dirEntry); + return((int)0); + } + +int writeFileByte(int ch,fileDescriptor *fd,long offset) { + + int blockCount = 0x0,batIndex = 0x0,batIndexPrev = fd->start,i = 0x0; + struct directoryEntry *dirEntry = 0x0; + struct ubixFsInfo *fsInfo = fd->mp->fsInfo; + + //Find Out How Many Blocks Long This File Is + blockCount = (offset/4096); + + //Find The Block If It Doesn't Exist We Will Have To Allocate One + for (i=0x0;i<=fd->mp->drive->diskLabel->partitions[fd->mp->partition].pBatSize;i++) { + batIndex = fsInfo->blockAllocationTable[batIndexPrev].nextBlock; + if (batIndex == 0x0) { + break; + } + batIndexPrev = batIndex; + } + + if ((offset%4096 == 0) && (fd->status == fdRead)) { + fd->status = fdOpen; + } + + //If batIndex == 0x0 Then We Must Allocate A New Block + if (batIndex == 0x0) { + for (i=1;i < fsInfo->batEntries;i++) { + if (fsInfo->blockAllocationTable[i].attributes == 0x0) { + fsInfo->blockAllocationTable[batIndexPrev].nextBlock = i; + fsInfo->blockAllocationTable[batIndex].nextBlock = 0x0; + batIndex = i; + fd->start = i; + break; + } + } + //fd->mp->drive->read(fd->mp->drive->driveInfoStruct,diskLabel->partitions[0].pOffset+blockAllocationTable[batIndex].realSector,8,fd->buffer); + fd->buffer[offset-(blockCount*4096)] = ch; + fd->mp->drive->write(fd->mp->drive->driveInfoStruct,fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,8,fd->buffer); + } + else { + if (fd->status != fdRead) { + fd->mp->drive->read(fd->mp->drive->driveInfoStruct,fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,8,fd->buffer); + fd->status = fdRead; + } + fd->buffer[offset-(blockCount*4096)] = ch; + fd->mp->drive->write(fd->mp->drive->driveInfoStruct,fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,8,fd->buffer); + } + if (offset > fd->size) { + fd->size = offset; + dirEntry = (struct directoryEntry *)kmalloc(4096,-2); + fd->mp->drive->read(fd->mp->drive->driveInfoStruct,(fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[fd->dirBlock].realSector),8,dirEntry); + for (i=0x0;i<(4096/sizeof(struct directoryEntry));i++) { + if ((int)!kstrcmp(dirEntry[i].fileName,fd->fileName)) + break; + } + dirEntry[i].size = fd->size; + fd->mp->drive->write(fd->mp->drive->driveInfoStruct,(fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[fd->dirBlock].realSector),8,dirEntry); + kfree(dirEntry); + } + return(ch); + } + +//Verified Functions + +/************************************************************************ + +Function: int readUbixFS(fileDescriptor *fd,char *data,long offset,long size) +Description: Read File Into Data +Notes: + +************************************************************************/ +int readUbixFS(fileDescriptor *fd,char *data,long offset,long size) { + int blockCount = 0x0,batIndex = fd->start; + long i = 0x0; + struct ubixFsInfo *fsInfo = fd->mp->fsInfo; + blockCount = ((offset)/4096); + //Find The Starting Block + for (i=1;i<=blockCount;i++) { + batIndex = fsInfo->blockAllocationTable[batIndex].nextBlock; + if (batIndex == 0x0) { + //sysErr(log, "Invalid File Offset"); + return(0); + } + } + //If The File Size Is Greater Then The Offset Lets Goto Work + fd->mp->drive->read(fd->mp->drive->driveInfoStruct,fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,blockSize,fd->buffer); + for (i=0x0;i fd->size) { + //Set File EOF If There Is Nothing To Do + data[i] = '\0'; + fd->status = fdEof; + return(size); + } + //Copy Data From Buffer To Data + data[i] = fd->buffer[offset-(blockCount*4096)]; + offset++; + if (offset%4096 == 0) { + batIndex = fsInfo->blockAllocationTable[batIndex].nextBlock; + fd->mp->drive->read(fd->mp->drive->driveInfoStruct,fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,blockSize,fd->buffer); + blockCount++; + } + } + //Return + return(size); + } + + + +/************************************************************************ + +Function: int writeUbixFS(fileDescriptor *fd,char *data,long offset,long size) +Description: Write Data Into File +Notes: + +************************************************************************/ +int writeUbixFS(fileDescriptor *fd,char *data,long offset,long size) { + int blockCount = 0x0,batIndex = 0x0,batIndexPrev = fd->start; + long i = 0x0,x = 0x0; + struct directoryEntry *dirEntry = 0x0; + struct ubixFsInfo *fsInfo = fd->mp->fsInfo; + blockCount = ((offset)/4096); + if (fd->size != 0) { + for (i=1;i<=blockCount;i++) { + batIndex = fsInfo->blockAllocationTable[batIndexPrev].nextBlock; + if (batIndex == 0x0) { + //sysErr(log, "Invalid File Offset"); + break; + } + batIndexPrev = batIndex; + } + } + if (batIndex != 0x0) { + fd->mp->drive->read(fd->mp->drive->driveInfoStruct,fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,blockSize,fd->buffer); + } + else { + for (i=1;i < fsInfo->batEntries;i++) { + if (fsInfo->blockAllocationTable[i].attributes == 0x0) { + fsInfo->blockAllocationTable[i].nextBlock = 0x0; + fsInfo->blockAllocationTable[i].attributes = 0x1; + batIndex = i; + fd->start = i; + break; + } + } + } + for (x=0x0;xbuffer[offset-(blockCount*4096)] = data[x]; + offset++; + if (offset%4096 == 0) { + fd->mp->drive->write(fd->mp->drive->driveInfoStruct,fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,blockSize,fd->buffer); + batIndexPrev = batIndex; + if (fsInfo->blockAllocationTable[batIndex].nextBlock == 0x0) { + for (i=1;i < fsInfo->batEntries;i++) { + if (fsInfo->blockAllocationTable[i].attributes == 0x0) { + fsInfo->blockAllocationTable[batIndexPrev].nextBlock = i; + fsInfo->blockAllocationTable[i].attributes = 0x1; + fsInfo->blockAllocationTable[i].nextBlock = 0x0; + batIndex = i; + break; + } + } + } + else { + batIndex = fsInfo->blockAllocationTable[batIndex].nextBlock; + fd->mp->drive->read(fd->mp->drive->driveInfoStruct,fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,blockSize,fd->buffer); + } + blockCount++; + } + } + fd->mp->drive->write(fd->mp->drive->driveInfoStruct,fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,blockSize,fd->buffer); + if (offset > fd->size) { + fd->size = offset; + dirEntry = (struct directoryEntry *)kmalloc(4096,-2); + fd->mp->drive->read(fd->mp->drive->driveInfoStruct,(fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[fd->dirBlock].realSector),blockSize,dirEntry); + for (i=0x0;i<(4096/sizeof(struct directoryEntry));i++) { + if ((int)!kstrcmp(dirEntry[i].fileName,fd->fileName)) + break; + } + dirEntry[i].size = fd->size; + dirEntry[i].startCluster = fd->start; + fd->mp->drive->write(fd->mp->drive->driveInfoStruct,(fd->mp->drive->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[fd->dirBlock].realSector),blockSize,dirEntry); + kfree(dirEntry); + } + //Return + return(size); + } \ No newline at end of file diff --git a/lockwasher/src/sys/vmm/Makefile b/lockwasher/src/sys/vmm/Makefile new file mode 100644 index 0000000..5093084 --- /dev/null +++ b/lockwasher/src/sys/vmm/Makefile @@ -0,0 +1,36 @@ +# (C) 2002 The UbixOS Project +# $Id: Makefile,v 1.6 2003/04/20 12:11:30 reddawg Exp $ + + +# Compiler +CC = gcc +CPP = g++ + + +# Linker +LINKER = ld +CFLAGS = -fno-builtin + +# Remove +REMOVE = rm -fr + +# Objects +OBJS = pagefault.o getfreepage.o remappage.o getfreekernelpage.o getfreevirtualpage.o setpageattributes.o copyvirtualspace.o createvirtualspace.o unmappage.o freepage.o getphysicaladdr.o doublefault.o clearvirtualpage.o memory.o paging.o + +all: $(OBJS) + +# Compile Types +.cc.o: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.cc.s: + $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.c.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.c.s: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.S.o: + $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) diff --git a/lockwasher/src/sys/vmm/clearvirtualpage.c b/lockwasher/src/sys/vmm/clearvirtualpage.c new file mode 100644 index 0000000..3373be0 --- /dev/null +++ b/lockwasher/src/sys/vmm/clearvirtualpage.c @@ -0,0 +1,44 @@ +/************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: clearvirtualpage.c,v 1.1 2003/04/19 11:31:35 reddawg Exp $ +**************************************************************************************/ + +#include + + +/************************************************************************ + +Function: void clearVirtualPage(uLong pageAddr); +Description: This Will Null Out A Page Of Memory +Notes: + +************************************************************************/ +void clearVirtualPage(uLong pageAddr) { + uLong *src = 0x0; + int counter = 0x0; + //Set Source Pointer To Virtual Page Address + src = (uLong *)pageAddr; + //Clear Out The Page + for (counter=0;counter +#include + +/************************************************************************ + +Function: void *copyVirtualSpace(pid_t pid); +Description: Creates A Copy Of A Virtual Space And Set All NON Kernel + Space To COW For A Fork This Will Also Alter The Parents + VM Space To Make That COW As Well +Notes: + +08/02/02 - Added Passing Of pid_t pid So We Can Better Keep Track Of + Which Task Has Which Physical Pages + +************************************************************************/ +void *copyVirtualSpace(pid_t pid) { + void *newPageDirectoryAddress = 0x0; + uLong *parentPageDirectory = 0x0,*newPageDirectory = 0x0; + uLong *parentPageTable = 0x0,*newPageTable = 0x0; + uLong *parentStackPage = 0x0,*newStackPage = 0x0; + int x = 0,i = 0,s = 0; + //Set Address Of Parent Page Directory + parentPageDirectory = (uLong *)parentPageDirAddr; + //Allocate A New Page For The New Page Directory + newPageDirectory = (uLong *)getFreePage(pid); + //Set newPageDirectoryAddress To The Newly Created Page Directories Page + newPageDirectoryAddress = getPhysicalAddr((uLong)newPageDirectory); + //First Set Up A Flushed Page Directory + for (x=0;x + + +/************************************************************************ + +Function: void *createVirtualSpace(pid_t); +Description: Creates A Virtual Space For A New Task +Notes: + +07/30/02 - This Is Going To Create A New VM Space However Its Going To + Share The Same Top 1GB Space With The Kernels VM And Lower + 1MB Of VM Space With The Kernel + +07/30/02 - Note This Is Going To Get The Top 1Gig And Lower 1MB Region + From The Currently Loaded Page Directory This Is Safe Because + All VM Spaces Will Share These Regions + +07/30/02 - Note I Realized A Mistake The First Page Table Will Need To Be + A Copy But The Page Tables For The Top 1GB Will Not Reason For + This Is That We Just Share The First 1MB In The First Page Table + So We Will Just Share Physical Pages. + +08/02/02 - Added Passing Of pid_t pid For Better Tracking Of Who Has Which + Set Of Pages + +************************************************************************/ +void *createVirtualSpace(pid_t pid) { + void *newPageDirectoryAddress = 0x0; + uLong *parentPageDirectory = 0x0,*newPageDirectory = 0x0; + uLong *parentPageTable = 0x0,*newPageTable = 0x0; + int x = 0; + //Set Address Of Parent Page Directory + parentPageDirectory = (uLong *)parentPageDirAddr; + //Allocate A New Page For The New Page Directory + newPageDirectory = (uLong *)getFreePage(pid); + //Set newPageDirectoryAddress To The Newly Created Page Directories Page + newPageDirectoryAddress = getPhysicalAddr((uLong)newPageDirectory); + //First Set Up A Flushed Page Directory + for (x=0;x +#include +#include +#include + + +/************************************************************************ + +Function: void doubleFault(); +Description: This Function Is The Double Fault Handler +Notes: + +************************************************************************/ +void doubleFault() { + uInt32 memAddr = 0x0; + + disableIrq(0); + + asm( + "movl %%cr2,%%eax\n" + "movl %%eax,%0\n" + + : "=g" (memAddr) + ); + kprintf("DOUBLEFAULT - Task Id: %i\n",_current->id); + kprintf("EAX: [0x%X],EBX: [0x%X]\n",_current->tss.eax,_current->tss.ebx); + kprintf("ECX: [0x%X],EDX: [0x%X]\n",_current->tss.ecx,_current->tss.edx); + kprintf("ESP: [0x%X],EPB: [0x%X]\n",_current->tss.esp,_current->tss.ebp); + kprintf("EIP: [0x%X],CR2: [0x%X]\n",_current->tss.eip,memAddr); + kprintf("CS: [0x%X],DS: [0x%X]\n",_current->tss.cs,_current->tss.ds); + kprintf("EFLAGS: [0x%X] \n",_current->tss.eflags); + + setTaskStatus(_current->id,EXITING); + //enableIrq(0); + while(1); + return; + } \ No newline at end of file diff --git a/lockwasher/src/sys/vmm/freepage.c b/lockwasher/src/sys/vmm/freepage.c new file mode 100644 index 0000000..7657038 --- /dev/null +++ b/lockwasher/src/sys/vmm/freepage.c @@ -0,0 +1,53 @@ +/************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: freepage.c,v 1.1 2003/04/19 11:31:35 reddawg Exp $ +**************************************************************************************/ + +#include +#include + +/************************************************************************ + +Function: void freePage(uLong pageAddr); +Description: This Function Marks The Page As Free +Notes: + +07/30/02 - This Was Moved Out Of memory.c Into Here + +************************************************************************/ +void freePage(uLong pageAddr) { + int pageIndex = 0x0; + //Find The Page Index To The Memory Map + pageIndex = (pageAddr/4096); + //Check If Page COW Is Greater Then 0 If It Is Dec It If Not Free It + if (memoryMap[pageIndex].cowCounter == 0) { + //Set Page As Avail So It Can Be Used Again + memoryMap[pageIndex].status = memAvail; + memoryMap[pageIndex].cowCounter = 0x0; + memoryMap[pageIndex].pid = -2; + freePages++; + } + else { + //Adjust The COW Counter + adjustCowCounter(((uLong)memoryMap[pageIndex].pageAddr),-1); + } + //Return + return; + } \ No newline at end of file diff --git a/lockwasher/src/sys/vmm/getfreekernelpage.c b/lockwasher/src/sys/vmm/getfreekernelpage.c new file mode 100644 index 0000000..dfce546 --- /dev/null +++ b/lockwasher/src/sys/vmm/getfreekernelpage.c @@ -0,0 +1,74 @@ +/************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: getfreekernelpage.c,v 1.1 2003/04/20 12:11:30 reddawg Exp $ +**************************************************************************************/ + +#include +#include + +/************************************************************************ + +Function: void *getFreeKernelPage(pidType pid); +Description: Returns A Free Page Mapped To The VM Space +Notes: + +07/30/02 - This Returns A Free Page In The Top 1GB For The Kernel + +************************************************************************/ +void *getFreeKernelPage(pidType pid,uInt16 count) { + int x=0,y=0,c=0; + uInt32 *pageTableSrc = 0x0; + //Lets Search For A Free Page + for (x=768;x<1024;x++) { + //Set Page Table Address + pageTableSrc = (uInt32 *)(tablesBaseAddress + (4096*x)); + for (y=0;y<1024;y++) { + //Loop Through The Page Table Find An UnAllocated Page + if ((uInt32)pageTableSrc[y] == (uInt32)0x0) { + if (count > 1) { + for (c=0;c +#include + +/************************************************************************ + +Function: void *getFreePage(pid_t pid); +Description: Returns A Free Page Mapped To The VM Space +Notes: + +07/30/02 - This Returns A Free Page In The Top 1GB For The Kernel + +************************************************************************/ +void *getFreePage(pid_t pid) { + int x=0,y=0; + uLong *pageTableSrc = 0x0; + //Lets Search For A Free Page + for (x=768;x<1024;x++) { + //Set Page Table Address + pageTableSrc = (uLong *)(tablesBaseAddress + (4096*x)); + for (y=0;y<1024;y++) { + //Loop Through The Page Table Find An UnAllocated Page + if ((uLong)pageTableSrc[y] == (uLong)0x0) { + //Map A Physical Page To The Virtual Page + remapPage(findFreePage(pid),((x*(1024*4096))+(y*4096))); + //Clear This Page So No Garbage Is There + clearVirtualPage((uLong)((x*(1024*4096))+(y*4096))); + //Return The Address Of The Newly Allocate Page + return((void *)((x*(1024*4096))+(y*4096))); + } + } + } + //If No Free Page Was Found Return NULL + return(0x0); + } diff --git a/lockwasher/src/sys/vmm/getfreevirtualpage.c b/lockwasher/src/sys/vmm/getfreevirtualpage.c new file mode 100644 index 0000000..57a6cac --- /dev/null +++ b/lockwasher/src/sys/vmm/getfreevirtualpage.c @@ -0,0 +1,89 @@ +/************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: getfreevirtualpage.c,v 1.3 2003/04/24 00:16:30 reddawg Exp $ +**************************************************************************************/ + +#include +#include +#include + +/************************************************************************ + +Function: void *getFreeVirtualPage(pid_t pid,int count); +Description: Returns A Free Page Mapped To The VM Space +Notes: + +08/11/02 - This Will Return Next Avilable Free Page Of Tasks VM Space + +************************************************************************/ +void *getFreeVirtualPage(pid_t pid,int count) { + int x=0,y=0,c=0; + uInt32 *pageTableSrc = 0x0; + uInt32 *pageDir = (uInt32 *)parentPageDirAddr; + + //Lets Search For A Free Page + for (x=(_current->oInfo.vmStart/(1024*4096));x<1024;x++) { + //Set Page Table Address + if ((pageDir[x] & pagePresent) != pagePresent) { + //If Page Table Is Non Existant Then Set It Up + pageDir[x] = (uLong)findFreePage(_current->id) | pageDefault; + //Also Add It To Virtual Space So We Can Make Changes Later + pageTableSrc = (uLong *)(tablesBaseAddress + (4096 * 767)); + pageTableSrc[x] = pageDir[x]; + //Reload Page Directory + asm( + "movl %cr3,%eax\n" + "movl %eax,%cr3\n" + ); + } + pageTableSrc = (uInt32 *)(tablesBaseAddress + (0x1000*x)); + for (y=0;y<1024;y++) { + //Loop Through The Page Table Find An UnAllocated Page + if ((uInt32)pageTableSrc[y] == (uInt32)0x0) { + if (count > 0x1) { + for (c=0;c + +/************************************************************************ + +Function: void *getPhysicalAddr(); +Description: Returns The Physical Address Of The Virtual Page +Notes: + +************************************************************************/ +void *getPhysicalAddr(uLong pageAddr) { + int pageDirectoryIndex=0,pageTableIndex=0; + uLong *pageTable = 0x0; + //Get The Index To The Page Directory + pageDirectoryIndex = (pageAddr/(1024*4096)); + //Get The Index To The Page Table + pageTableIndex = ((pageAddr-(pageDirectoryIndex*(1024*4096)))/4096); + //Set pageTable To The Virtual Address Of Table + pageTable = (uLong *)(tablesBaseAddress + (4096 * pageDirectoryIndex)); + //Return The Physical Address Of The Page + return((void *)(pageTable[pageTableIndex] & 0xFFFFF000)); + } \ No newline at end of file diff --git a/lockwasher/src/sys/vmm/memory.c b/lockwasher/src/sys/vmm/memory.c new file mode 100644 index 0000000..bd7559f --- /dev/null +++ b/lockwasher/src/sys/vmm/memory.c @@ -0,0 +1,238 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: memory.c,v 1.8 2003/05/11 23:37:07 reddawg Exp $ + +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include + +mMap *memoryMap = (mMap *) 0x101000; +int numPages = 0; +uInt32 freePages = 0; + +int countMemory() { + register unsigned long *mem; + unsigned long memCount=-1, tempMemory; + unsigned short memKb=0; + unsigned char irq1State, irq2State; + unsigned long cr0; + /* Save States Of IRQ 1 & 2 */ + irq1State=inportByte(0x21); + irq2State=inportByte(0xA1); + + /* Shut Off Both IRQS */ + outportByte(0x21, 0xFF); + outportByte(0xA1, 0xFF); + + /* Save CR0 */ + asm( + "movl %%cr0, %%ebx\n" + : "=a"(cr0) + : + : "ebx" + ); + + asm("wbinvd"); + asm( + "movl %%ebx, %%cr0\n" + : + : "a" (cr0 | 0x00000001 | 0x40000000 | 0x20000000) + : "ebx" + ); + + while(memKb<4096 && memCount!=0) { + memKb++; + if (memCount == -1) memCount = 0; + memCount+=1024*1024; + mem=(unsigned long *)memCount; + tempMemory=*mem; + *mem=0x55AA55AA; + asm("":::"memory"); + if (*mem!=0x55AA55AA) { + memCount=0; + } + else { + *mem=0xAA55AA55; + asm("":::"memory"); + if (*mem!=0xAA55AA55) { + memCount=0; + } + } + asm("":::"memory"); + *mem=tempMemory; + } + asm( + "movl %%ebx, %%cr0\n" + : + : "a" (cr0) + : "ebx" + ); + + /* Return IRQ 1 & 2's States */ + outportByte(0x21, irq1State); + outportByte(0xA1, irq2State); + return((memKb*1024*1024)/4096); + } + +/************************************************************************ + +Function: void initMmap(); +Description: This Function Initializes The Memory Map For the System +Notes: + +************************************************************************/ +void initMmap() { + int i=0,memStart=0; + numPages = countMemory(); + //Set Memory Map To Point To First Physical Page That We Will Use + memoryMap = (mMap *) 0x101000; + //Initialize Map Make All Pages Not Available + for (i=0;ifreePages = freePages; + buf = (uInt32 *)memoryMap[i].pageAddr; + /* + for (x=0;x<0x1000;x++) { + buf[x] = 0x0; + } + */ + return(memoryMap[i].pageAddr); + } + } + //If No Free Memory Is Found Return NULL + //kprintf("Out Of Memory!!!!\n"); + return(0x0); + } + +/************************************************************************ + +Function: void adjustCowCounter(uLong baseAddr,int adjustment); +Description: This Adjust The COW Counter For Page At baseAddr It Will + Error If The Count Goes Below 0 +Notes: + +08/01/02 - I Think If Counter Gets To 0 I Should Free The Page + +************************************************************************/ +void adjustCowCounter(uLong baseAddr,int adjustment) { + int memoryMapIndex = (baseAddr/4096); + //Adjust COW Counter + //kprintf("COW (%i[%i]%x)",memoryMapIndex,memoryMap[memoryMapIndex].cowCounter,baseAddr); + memoryMap[memoryMapIndex].cowCounter += adjustment; + //kprintf("(%i[%i]%x)\n",memoryMapIndex,memoryMap[memoryMapIndex].cowCounter,baseAddr); + if (memoryMap[memoryMapIndex].cowCounter == 0) { + memoryMap[memoryMapIndex].status = memAvail; + memoryMap[memoryMapIndex].cowCounter = 0x0; + memoryMap[memoryMapIndex].pid = -3; + freePages++; + systemVitals->freePages = freePages; + } + //Return + return; + } + +/************************************************************************ + +Function: void freeProcessPages(pid_t pid); +Description: This Function Will Free Up Memory For The Exiting Process +Notes: + +08/04/02 - Added Checking For COW Pages First +************************************************************************/ +void freeProcessPages(pid_t pid) { + int i=0,x=0; + uLong *tmpPageTable = 0x0; + uLong *tmpPageDir = (uLong *)parentPageDirAddr; + //Check Page Directory For An Avail Page Table + for (i=0;i<=0x300;i++) { + if (tmpPageDir[i] != 0) { + //Set Up Page Table Pointer + tmpPageTable = (uLong *)(tablesBaseAddress + (i * 0x1000)); + //Check The Page Table For COW Pages + for (x=0;xfreePages = freePages; + } + } + } + //Return + return; + } diff --git a/lockwasher/src/sys/vmm/pagefault.c b/lockwasher/src/sys/vmm/pagefault.c new file mode 100644 index 0000000..3a016fb --- /dev/null +++ b/lockwasher/src/sys/vmm/pagefault.c @@ -0,0 +1,145 @@ +/************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: pagefault.c,v 1.1 2003/04/20 12:11:30 reddawg Exp $ +**************************************************************************************/ + +#include +#include +#include +#include +#include + +/************************************************************************ + +Function: void pageFault(); +Description: This Function Is The Second Half Of The Page Fault ISR + Currently It Handles COW However I Need To Prepar It For + Swapping +Notes: + +07/30/02 - Fixed COW However I Need To Think Of A Way To Impliment + A Paging System Also Start To Add Security Levels + +************************************************************************/ +void pageFault() { + uLong memAddr = 0,i = 0, pageTableIndex = 0,pageDirectoryIndex = 0; + uLong *pageDir,*pageTable; + uLong *src,*dst; + pageDir = (uLong *)parentPageDirAddr; + //Get Memory Address For Violation + asm( + "movl %%cr2,%%eax\n" + "movl %%eax,%0\n" + + : "=g" (memAddr) + ); + //Calculate The Page Directory Index + pageDirectoryIndex = (memAddr/(1024*4096)); + //Calculate The Page Table Index + pageTableIndex = ((memAddr-(pageDirectoryIndex*(1024*4096)))/4096); + if (pageDir[pageDirectoryIndex] == 0) { + //Creat A Routine For Non Mapped Memory + kprintf("Segfault At Address: [0x%X][0x%X][%i]\n",memAddr,_current->tss.esp,_current->id); + if ((uInt32)_current->tss.cr3 != (uInt32)kernelPageDirectory) { + freeProcessPages(_current->id); + } + setTaskStatus(_current->id,EXITING); + if (_current->id <= -1) { + //kPanic("Kernel Crashed.\n"); + } + schedule(); + while (1); + } + else { + //Set pageTable To Point To Virtual Address Of Page Table + pageTable = (uLong *)(tablesBaseAddress + (4096 * pageDirectoryIndex)); + if (((uLong)pageTable[pageTableIndex] & pageCow) == pageCow) { + //Set Src To Base Address Of Page To Copy + src = (uLong *) ((1024*4096*pageDirectoryIndex) + (4096*pageTableIndex)); + //Allocate A Free Page For Destination + dst = (uLong *) getFreePage(-1); + //Copy Memory + for (i=0;itss.esp,_current->id); + /* + kprintf("EAX: [0x%X],EBX: [0x%X]\n",_current->tss.eax,_current->tss.ebx); + kprintf("ECX: [0x%X],EDX: [0x%X]\n",_current->tss.ecx,_current->tss.edx); + kprintf("ESP: [0x%X],EPB: [0x%X]\n",_current->tss.esp,_current->tss.ebp); + kprintf("EIP: [0x%X],CR2: [0x%X]\n",_current->tss.eip,memAddr); + kprintf("CS: [0x%X],DS: [0x%X]\n",_current->tss.cs,_current->tss.ds); + kprintf("SS: [0x%X],ES: [0x%X]\n",_current->tss.ss,_current->tss.es); + kprintf("FS: [0x%X],GS: [0x%X]\n",_current->tss.gs,_current->tss.gs); + kprintf("EFLAGS: [0x%X] \n",_current->tss.eflags); + */ + + if ((uInt32)_current->tss.cr3 != (uInt32)kernelPageDirectory) { + freeProcessPages(_current->id); + } + setTaskStatus(_current->id,EXITING); + if (_current->id <= -1) { + panic(); + } + schedule(); + while(1); + } + } + asm( + "movl %cr3,%eax\n" + "movl %eax,%cr3\n" + ); + } + +/************************************************************************ + +Function: void _pageFault() +Description: This Is The ASM Code That Calls The pageFault() Function +Notes: + +************************************************************************/ +asm( + ".global _pageFault \n" + "_pageFault: \n" + "xchgl %eax,(%esp) \n" + "pushl %ecx \n" + "pushl %edx \n" + "push %ds \n" + "push %es \n" + "push %fs \n" + "call pageFault \n" + "pop %fs \n" + "pop %es \n" + "pop %ds \n" + "popl %edx \n" + "popl %ecx \n" + "popl %eax \n" + "iret \n" + ); + diff --git a/lockwasher/src/sys/vmm/paging.c b/lockwasher/src/sys/vmm/paging.c new file mode 100644 index 0000000..288ce36 --- /dev/null +++ b/lockwasher/src/sys/vmm/paging.c @@ -0,0 +1,217 @@ +/************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: paging.c,v 1.24 2003/04/24 00:16:30 reddawg Exp $ +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + + +uLong *pageDirectory = 0x0; +uLong memoryStart = 0x100000; +uLong *kernelPageDirectory = 0x0; + +/************************************************************************ + +Function: void initPageSystem() +Description: This Function Will Initialize The Ubix Paging Sytem +Notes: + +07/29/02 - I Started The Rewrite Of This Function Hopefully All Goes Well + This Is The Startup Routine To Build The Initial VM Space. + Also Note I May Switch The Page Fault To A Task Gate. + +07/30/02 - I Decided That To Save On Performance All Page Tables Will Be + Mapped In At BFC00000 So That Memory Does Not Need To Be Relocated + To Alter Page Tables. + Also Put Page Index At 0x100000 + +************************************************************************/ +void initPagingSystem() { + int i=0,x=0; + uLong *pageTable; + struct tssStruct *doubleFaultTSS = (struct tssStruct *)0x4000; + //Allocate A Page For The Kernels VM Space Page Directory + kernelPageDirectory = (uLong *)findFreePage(_current->id); + //Make Sure The Page Directory Is Clean + for (i=0;iid); + kernelPageDirectory[0] = (uLong)((uLong)(pageTable) | pagePresent|pageWrite|pageUser);//pageDefault); + //Make Sure The Page Table Is Clean + for (i=0;iback_link = 0x0; + doubleFaultTSS->esp0 = (uInt32)kmalloc(4096,-2)+4095; + doubleFaultTSS->ss0 = 0x10; + doubleFaultTSS->esp1 = 0x0; + doubleFaultTSS->ss1 = 0x0; + doubleFaultTSS->esp2 = 0x0; + doubleFaultTSS->ss2 = 0x0; + doubleFaultTSS->cr3 = (unsigned int)kernelPageDirectory; + doubleFaultTSS->eip = (unsigned int)&doubleFault; + doubleFaultTSS->eflags = 0x206; + doubleFaultTSS->esp = 0x1BFFF; + doubleFaultTSS->ebp = 0x1BFFF; + doubleFaultTSS->esi = 0x0; + doubleFaultTSS->edi = 0x0; + doubleFaultTSS->es = 0x10; + doubleFaultTSS->cs = 0x08; + doubleFaultTSS->ss = 0x10; + doubleFaultTSS->ds = 0x10; + doubleFaultTSS->fs = 0x10; + doubleFaultTSS->gs = 0x10; + doubleFaultTSS->ldt = 0x0; + doubleFaultTSS->trace_bitmap = 0x0000; + doubleFaultTSS->io_map = 0x8000; + + } + +void *mapFromTask(pidType pid,void *ptr,uInt32 size) { + kTask_t *child = 0x0; + uLong i = 0x0,x = 0x0,y = 0x0,count = ((size+4095)/0x1000),c = 0x0; + uShort dI = 0x0,tI = 0x0; + uInt32 baseAddr = 0x0,offset = 0x0; + uInt32 *childPageDir = (uInt32 *)0x5A00000; + uInt32 *childPageTable = 0x0; + uInt32 *pageTableSrc = 0x0; + offset = (uInt32)ptr & 0xFFF; + baseAddr = (uInt32)ptr & 0xFFFFF000; + child = getTask(pid); + //Calculate The Page Table Index And Page Directory Index + dI = (baseAddr/(1024*4096)); + tI = ((baseAddr-(dI*(1024*4096)))/4096); + remapPage(child->tss.cr3,0x5A00000); + for (i=0;i<0x1000;i++) { + remapPage(childPageDir[i],0x5A01000 + (i * 0x1000)); + } + for (x=(_current->oInfo.vmStart/(1024*4096));x<1024;x++) { + pageTableSrc = (uInt32 *)(tablesBaseAddress + (4096*x)); + for (y=0;y<1024;y++) { + //Loop Through The Page Table Find An UnAllocated Page + if ((uInt32)pageTableSrc[y] == (uInt32)0x0) { + if (count > 1) { + for (c=0;((c= 0x1000) { + dI++; + tI = 0-c; + } + childPageTable = (uInt32 *)(0x5A01000 + (0x1000 * dI)); + remapPage(childPageTable[tI+c],((x*(1024*4096))+((y+c)*4096))); + } + unmapPage(0x5A00000,1); + for (i=0;i<0x1000;i++) { + unmapPage((0x5A01000 + (i*0x1000)),1); + } + return((void *)((x*(1024*4096))+(y*4096)+offset)); + } + } + else { + //Map A Physical Page To The Virtual Page + childPageTable = (uInt32 *)(0x5A01000 + (0x1000 * dI)); + remapPage(childPageTable[tI],((x*(1024*4096))+(y*4096))); + //Return The Address Of The Mapped In Memory + unmapPage(0x5A00000,1); + for (i=0;i<0x1000;i++) { + unmapPage((0x5A01000 + (i*0x1000)),1); + } + return((void *)((x*(1024*4096))+(y*4096)+offset)); + } + } + } + } + return(0x0); + } + +void unmapPages(void *ptr,uInt32 size) { + uInt32 baseAddr = (uInt32)ptr & 0xFFFFF000; + uInt32 dI = 0x0,tI = 0x0; + uInt32 y = 0x0; + uInt32 *pageTable = 0x0; + + dI = (baseAddr/(1024*4096)); + tI = ((baseAddr-(dI*(1024*4096)))/4096); + pageTable = (uInt32 *)(tablesBaseAddress + (4096*dI)); + for (y=tI;y<(tI+((size+4095)/4096));y++) { + pageTable[y] = 0x0; + } + return; + } diff --git a/lockwasher/src/sys/vmm/remappage.c b/lockwasher/src/sys/vmm/remappage.c new file mode 100644 index 0000000..11f274f --- /dev/null +++ b/lockwasher/src/sys/vmm/remappage.c @@ -0,0 +1,75 @@ +/************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: remappage.c,v 1.1 2003/04/20 12:11:30 reddawg Exp $ +**************************************************************************************/ + +#include +#include +#include + +/************************************************************************ + +Function: void remapPage(Physical Source,Virtual Destination) +Description: This Function Will Remap A Physical Page Into Virtual Space +Notes: + +07/29/02 - Rewrote This To Work With Our New Paging System + +07/30/02 - Changed Address Of Page Tables And Page Directory + +************************************************************************/ +void remapPage(uLong source,uLong dest) { + uShort destPageDirectoryIndex=0,destPageTableIndex=0; + uLong *pageDir,*pageTable; + //Set Pointer pageDirectory To Point To The Virtual Mapping Of The Page Directory + pageDir = (uLong *)parentPageDirAddr; + //Check To See If Page Table Exists + destPageDirectoryIndex = (dest/(1024*4096)); + if ((pageDir[destPageDirectoryIndex] & pagePresent) != pagePresent) { + //If Page Table Is Non Existant Then Set It Up + pageDir[destPageDirectoryIndex] = (uLong)findFreePage(_current->id) | pageDefault; + //Also Add It To Virtual Space So We Can Make Changes Later + pageTable = (uLong *)(tablesBaseAddress + (4096 * 767)); + pageTable[destPageDirectoryIndex] = pageDir[destPageDirectoryIndex]; + //Reload Page Directory + asm( + "movl %cr3,%eax\n" + "movl %eax,%cr3\n" + ); + } + //Set Address To Page Table + pageTable = (uLong *)(tablesBaseAddress + (4096 * destPageDirectoryIndex)); + //Get The Index To The Page Table + destPageTableIndex = ((dest-(destPageDirectoryIndex*(1024*4096)))/4096); + //If The Page Is Mapped In Free It Before We Remap + if ((pageTable[destPageTableIndex] & pagePresent) == pagePresent) { + //Clear The Page First For Security Reasons + freePage(((uLong)pageTable[destPageTableIndex] & 0xFFFFF000)); + } + //Set The Source Address In The Destination + pageTable[destPageTableIndex] = (uLong)(source | pageDefault); + //Reload The Page Table; + asm( + "movl %cr3,%eax\n" + "movl %eax,%cr3\n" + ); + //Return + return; + } diff --git a/lockwasher/src/sys/vmm/setpageattributes.c b/lockwasher/src/sys/vmm/setpageattributes.c new file mode 100644 index 0000000..f302c24 --- /dev/null +++ b/lockwasher/src/sys/vmm/setpageattributes.c @@ -0,0 +1,53 @@ + /************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: setpageattributes.c,v 1.1 2003/04/20 12:11:30 reddawg Exp $ +**************************************************************************************/ + +#include + +/************************************************************************ + +Function: void setPageAttributes(uLong pageAddr,int attributes; +Description: This Function Will Set The Page Attributes Such As + A Read Only Page, Stack Page, COW Page, ETC. +Notes: + +************************************************************************/ +void setPageAttribute(uLong pageAddr,int attributes) { + int directoryIndex,tableIndex; + uLong *pageTable; + //Get Index To Page Directory + directoryIndex = (pageAddr/(1024*4096)); + //Get Index To Page Table + tableIndex = ((pageAddr-(directoryIndex*(1024*4096)))/4096); + //Set Table Pointer + pageTable = (uLong *)(tablesBaseAddress + (4096 * directoryIndex)); + //Set Attribute If Page Is Mapped + if (pageTable[tableIndex] != 0) { + pageTable[tableIndex] = ((pageTable[tableIndex] & 0xFFFFF000) | attributes); + } + //Reload The Page Table; + asm( + "movl %cr3,%eax\n" + "movl %eax,%cr3\n" + ); + //Return + return; + } diff --git a/lockwasher/src/sys/vmm/unmappage.c b/lockwasher/src/sys/vmm/unmappage.c new file mode 100644 index 0000000..88b076e --- /dev/null +++ b/lockwasher/src/sys/vmm/unmappage.c @@ -0,0 +1,66 @@ +/************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: unmappage.c,v 1.1 2003/04/19 11:31:35 reddawg Exp $ +**************************************************************************************/ + +#include + +/************************************************************************ + +Function: void unmapPage(uLong pageAddr,int flags); +Description: This Function Will Unmap A Page From The Kernel VM Space + The Flags Variable Decides If Its To Free The Page Or Not + A Flag Of 0 Will Free It And A Flag Of 1 Will Keep It +Notes: + +07/30/02 - I Have Decided That This Should Free The Physical Page There + Is No Reason To Keep It Marked As Not Available + +07/30/02 - Ok A Found A Reason To Keep It Marked As Available I Admit + Even I Am Not Perfect Ok The Case Where You Wouldn't Want To + Free It Would Be On Something Like Where I Allocated A Page + To Create A New Virtual Space So Now It Has A Flag + +************************************************************************/ +void unmapPage(uLong pageAddr,int flags) { + int pageDirectoryIndex=0,pageTableIndex=0; + uLong *pageTable = 0x0; + //Get The Index To The Page Directory + pageDirectoryIndex = (pageAddr/(1024*4096)); + //Get The Index To The Page Table + pageTableIndex = ((pageAddr-(pageDirectoryIndex*(1024*4096)))/4096); + //Set pageTable To The Virtual Address Of Table + pageTable = (uLong *)(tablesBaseAddress + (4096 * pageDirectoryIndex)); + //Free The Physical Page If Flags Is 0 + if (flags == 0) { + //This is temp i think its still an issue + //clearVirtualPage(pageAddr); + //freePage((uLong)(pageTable[pageTableIndex] & 0xFFFFF000)); + } + //Unmap The Page + pageTable[pageTableIndex] = 0x0; + //Rehash The Page Directory + asm( + "movl %cr3,%eax\n" + "movl %eax,%cr3\n" + ); + //Return + return; + } \ No newline at end of file diff --git a/lockwasher/src/tools/Makefile b/lockwasher/src/tools/Makefile new file mode 100644 index 0000000..558824b --- /dev/null +++ b/lockwasher/src/tools/Makefile @@ -0,0 +1,73 @@ +# $Id: Makefile,v 1.14 2003/05/04 13:20:15 reddawg Exp $ +# Kernel Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Linker +LD = ld + +#Kernel File Name +BINARY = format + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = format.o + +# Link the kernel statically with fixed text+data address @1M +$(BINARY) : $(OBJS) + $(GCC) -o $@ $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O -I../sys/include -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O -I../sys/include -S -o $@ $< + +.c.o: + $(GCC) -Wall -O -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O -I../sys/include -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(BINARY) *.core + +format-dsk: + (cp ../sys/compile/ubix.elf ./) + (cp ../bin/init/init ./) + (cp ../bin/shell/shell ./) + (cp ../bin/test/test ./) + (cp ../bin/ls/ls ./) + (cp ../bin/pwd/pwd ./) + (cp ../bin/login/login ./) + (cp ../bin/cat/cat ./) + (cp ../bin/de/de ./) + (cp ../bin/muffin/muffin ./) + (cp ../lib/libc/libc.so ./) + (cp ../bin/goofball/goofball ./) + (cp ../bin/ld-dyn/ld-dyn ./) + (./format 50 2000 ubix.elf 0 shell 3754 test 3754 muffin 3754 goofball 3754) + (./format 1000 2000 init 3754 de 3754 ls 3754 userdb 3754 login 3754 motd 0 PACMAN.DPF 3754 pwd 3754 cat 3754 mbr.img 3754 ld-dyn 3754 libc.so 3754) + (rm ubix.elf) + (rm init) + (rm shell) + (rm test) + (rm ls) + (rm pwd) + (rm cat) + (rm de) + (rm muffin) + (rm login) + (rm libc.so) + (rm goofball) + (rm ld-dyn) diff --git a/lockwasher/src/tools/OLDENG.DPF b/lockwasher/src/tools/OLDENG.DPF new file mode 100644 index 0000000..e542aca --- /dev/null +++ b/lockwasher/src/tools/OLDENG.DPF Binary files differ diff --git a/lockwasher/src/tools/PACMAN.DPF b/lockwasher/src/tools/PACMAN.DPF new file mode 100644 index 0000000..4db8522 --- /dev/null +++ b/lockwasher/src/tools/PACMAN.DPF Binary files differ diff --git a/lockwasher/src/tools/ROM8X14.DPF b/lockwasher/src/tools/ROM8X14.DPF new file mode 100644 index 0000000..376a5ef --- /dev/null +++ b/lockwasher/src/tools/ROM8X14.DPF Binary files differ diff --git a/lockwasher/src/tools/format.c b/lockwasher/src/tools/format.c new file mode 100644 index 0000000..f3aa88c --- /dev/null +++ b/lockwasher/src/tools/format.c @@ -0,0 +1,143 @@ +#include +#include +#include "./ubixfs.h" + +struct blockAllocationTableEntry *BAT = 0x0; + +int findFreeBlock(int cBlock,int size) { + int i = 0x0; + for (i=1;isize = (size/512); + partInfo->startSector = (startSector+1); + partInfo->blockAllocationTable = (startSector+1); + partInfo->rootDirectory = ((startSector+1) + (batSize/512)); + fseek(driveFd,(startSector * 512),0); + fwrite(partInfo,512,1,driveFd); + startSector++; + dirEntry[0].attributes = 0x8000; + dirEntry[0].permissions = 0xEAA; + dirEntry[0].gid = 0x0; + dirEntry[0].uid = 0x0; + dirEntry[0].startCluster = 0x0; + dirEntry[0].size = 0x4000; + sprintf(dirEntry[0].fileName,":"); + dirEntry[1].attributes = 0x8000; + dirEntry[1].permissions = 0xEAA; + dirEntry[1].gid = 0x0; + dirEntry[1].uid = 0x0; + dirEntry[1].startCluster = 0x0; + dirEntry[1].size = 0x4000; + sprintf(dirEntry[1].fileName,".."); + BAT[0].nextBlock = 0x1; + BAT[0].attributes = 1; + BAT[0].realSector = (batSize/512); + BAT[1].nextBlock = 0x2; + BAT[1].attributes = 1; + BAT[1].realSector = (batSize/512) + 1; + BAT[2].nextBlock = 0x3; + BAT[2].attributes = 1; + BAT[2].realSector = (batSize/512) + 2; + BAT[3].nextBlock = 0x0; + BAT[3].attributes = 1; + BAT[3].realSector = (batSize/512) + 3; + + for (i=4;i<(size/4096);i++) { + BAT[i].nextBlock = 0x0; + BAT[i].attributes = 0x0; + //BAT[i].realSector = (startSector + (batSize/512) + (i*8)); + BAT[i].realSector = ((batSize/512) + (i*8)); + BAT[i].reserved = 0x0; + } + file = 0x2; + while (x < argc) { + counter = 0x0; + blockCount = 0x0; + fileFd = fopen(argv[x],"rb"); + block = findFreeBlock(-1,(size/4096)); + dirEntry[file].startCluster = block; + dirEntry[file].attributes = 0x800; + dirEntry[file].permissions = atoi(argv[x+1]); + rewind(driveFd); + //fseek(driveFd,((BAT[startSector].realSector * 512) + ((batSize/512)+(BAT[block].realSector*4096))),0); + fseek(driveFd,((startSector + BAT[block].realSector) * 512),0); + while (!feof(fileFd)) { + if (4096 == (counter - (blockCount * 4096))) { + block = findFreeBlock(block,(size/4096)); + printf("Block: [%i][%s]\n",block,argv[x]); + rewind(driveFd); + //fseek(driveFd,((startSector * 512) + ((batSize/512)+(BAT[block].realSector*4096))),0); + fseek(driveFd,((startSector + BAT[block].realSector) * 512),0); + blockCount++; + } + fputc(fgetc(fileFd),driveFd); + counter++; + } + i = 0; + while((counter + i)%512) { + fputc(0x0,driveFd); + i++; + } + fclose(fileFd); + dirEntry[file].size = counter; + sprintf(dirEntry[file].fileName,"%s",argv[x]); + x += 2; + file++; + } + dirEntry[1].attributes = 0x8000; + dirEntry[1].permissions = 0xEAA; + dirEntry[1].gid = 0x0; + dirEntry[1].uid = 0x0; + dirEntry[1].startCluster = 0x0; + dirEntry[1].size = 0x4000; + sprintf(dirEntry[1].fileName,"fakeDir"); + rewind(driveFd); + fseek(driveFd,(long)((startSector * 512) + batSize),0); + fwrite(dirEntry,0x4000,1,driveFd); + rewind(driveFd); + fseek(driveFd,(startSector * 512),0); + if (fwrite(BAT,batSize,1,driveFd) >= 1) { +// printf("size [%i]\n",partInfo->size); +// printf("startSector: [%i]\n",partInfo->startSector); +// printf("bat: [%i]\n",partInfo->blockAllocationTable); +// printf("rootDir: [%i]\n",partInfo->rootDirectory); +// printf("sizeof: [%i]\n",sizeof(struct blockAllocationTableEntry)); +// printf("size: [%i]\n",(size/4096)); + printf("Formatted!\n"); + } + else { + printf("Error Formatting!!\n"); + } + fclose(driveFd); + return(0); + } diff --git a/lockwasher/src/tools/mbr.img b/lockwasher/src/tools/mbr.img new file mode 100644 index 0000000..a574013 --- /dev/null +++ b/lockwasher/src/tools/mbr.img Binary files differ diff --git a/lockwasher/src/tools/motd b/lockwasher/src/tools/motd new file mode 100644 index 0000000..d933acc --- /dev/null +++ b/lockwasher/src/tools/motd @@ -0,0 +1,8 @@ +Welcome to UbixOS +This is an experimental kernel so it WILL crash and when +it does please send us some info so we can fix it or +if you have access to the source fix it and commit the +changes. + +All reports can be sent to chris@domainatlantic.com + diff --git a/lockwasher/src/tools/ubixfs.h b/lockwasher/src/tools/ubixfs.h new file mode 100644 index 0000000..6e8f9a5 --- /dev/null +++ b/lockwasher/src/tools/ubixfs.h @@ -0,0 +1,77 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: ubixfs.h,v 1.2 2003/04/24 05:16:28 reddawg Exp $ + +**************************************************************************************/ + +#ifndef _UBIXFS_H +#define _UBIXFS_H + +typedef unsigned long uLong; +typedef unsigned short uShort; +typedef unsigned char uChar; +typedef unsigned int uInt; + +//Partition Information +struct partitionInformation { + uLong size; //Size In Sectors + uLong startSector; //Base Sector Of Partition + uLong blockAllocationTable; //Base Sector Of BAT + uLong rootDirectory; //Base Sector Of Root Directory + }; + +//Block Allocation Table Entry +struct blockAllocationTableEntry { + long attributes; //Block Attributes + long realSector; //Real Sector + long nextBlock; //Sector Of Next Block + long reserved; //Reserved + }; + +//UbixFS Directory Entry +struct directoryEntry { + uLong startCluster; //Starting Cluster Of File + uLong size; //Size Of File + uLong creationDate; //Date Created + uLong lastModified; //Date Last Modified + uLong uid; //UID Of Owner + uLong gid; //GID Of Owner + uShort attributes; //Files Attributes + uShort permissions; //Files Permissions + char fileName[256]; //File Name + }; + + +struct bootSect { + uChar jmp[4]; + uChar id[6]; + uShort version; + uShort tmp; + uShort fsStart; + uShort tmp2; + uLong krnl_start; + uInt BytesPerSector; + uInt SectersPerTrack; + uInt TotalHeads; + uLong TotalSectors; + uChar code[479]; + }; + +#endif diff --git a/lockwasher/src/tools/user.c b/lockwasher/src/tools/user.c new file mode 100644 index 0000000..3bec53a --- /dev/null +++ b/lockwasher/src/tools/user.c @@ -0,0 +1,29 @@ +#include + +struct passwd { + char username[32]; + char passwd[32]; + int uid; + int gid; + char shell[128]; + char realname[256]; + }; + +int main(int argc,char **argv) { + int i = 0x0; + struct passwd *password = 0x0; + FILE *in; + password = (struct passwd *)malloc(4096); + in = fopen("./userdb","rb"); + fread(password,4096,1,in); + fclose(in); + for (i=0;i<5;i++) { + printf("User: [%s]\n",password[i].username); + printf("Pass: [%s]\n",password[i].passwd); + printf("UID: [%i]\n",password[i].uid); + printf("GID: [%i]\n",password[i].gid); + printf("Shell: [%s]\n",password[i].shell); + printf("Name: [%s]\n",password[i].realname); + } + return(0); + } diff --git a/lockwasher/src/tools/userdb b/lockwasher/src/tools/userdb new file mode 100644 index 0000000..c0ce06c --- /dev/null +++ b/lockwasher/src/tools/userdb Binary files differ diff --git a/mobius/bin/Makefile b/mobius/bin/Makefile new file mode 100644 index 0000000..7aec844 --- /dev/null +++ b/mobius/bin/Makefile @@ -0,0 +1,39 @@ +LOADER= bootsect.com +LOADER2=mobel_pe.com +RAMDISK=ramdisk.bin +KERNEL= kernel.exe + +SYS= kernel.cfg isa.cfg drivers.cfg +#ata.drv sermouse.drv vgatext.drv cmos.drv sound.drv +FILES= $(SYS) + +SYSUSER=kernelu.dll libc.dll mgl.dll mgltest.exe \ + freetype.dll rezn000.ttf +APPS= ls.exe mount.exe fttest.exe +DEMOS= tetris.exe hello.exe guiapp.exe sertest.exe +MISC= coffbase.txt +FORTUNE=fortune.exe fortunes + +DISKFILES= $(LOADER2) $(KERNEL) $(FILES) $(SYS) +HDFILES= + +include ../src/make.actions + +all: $(RAMDISK) $(LOADER) $(LOADER2) +# mcopy.cmd -o $(DISKFILES) a: + for %i in ($(DISKFILES)) do @mcopy.cmd -o %i a: + for %i in ($(HDFILES)) do @mcopy.cmd -o %i c: + +floppy: all +# dd if=$(LOADER) of=a: + format a: /q < format.txt + rawrite -f $(LOADER) -d a: -n + cp $(DISKFILES) a: + +#$(LOADER): $(RAMDISK) $(KERNEL) + +#$(RAMDISK): $(FILES) $(KERNEL) Makefile +# $(BIN)/ramdisk -o $(RAMDISK) $(FILES) + +clean: + rm $(RAMDISK) \ No newline at end of file diff --git a/mobius/bin/ata.drv b/mobius/bin/ata.drv new file mode 100644 index 0000000..182123f --- /dev/null +++ b/mobius/bin/ata.drv Binary files differ diff --git a/mobius/bin/bootsect.com b/mobius/bin/bootsect.com new file mode 100644 index 0000000..bf4b09f --- /dev/null +++ b/mobius/bin/bootsect.com Binary files differ diff --git a/mobius/bin/coffbase.txt b/mobius/bin/coffbase.txt new file mode 100644 index 0000000..3e459de --- /dev/null +++ b/mobius/bin/coffbase.txt @@ -0,0 +1,13 @@ +kdebug 0xe0000000 0x28000 +ata 0xe0030000 0xb000 +cmos 0xe0040000 0x7000 +fat 0xe0050000 0xa000 +fdc 0xe0060000 0xa000 +isa 0xe0070000 0x7000 +keyboard 0xe0080000 0x9000 +pci 0xe0090000 +ps2mouse 0xe00a0000 +sermouse 0xe00b0000 +video 0xe00c0000 +vgatext 0xe00d0000 +sound 0xe00e0000 diff --git a/mobius/bin/console.exe b/mobius/bin/console.exe new file mode 100644 index 0000000..c074669 --- /dev/null +++ b/mobius/bin/console.exe Binary files differ diff --git a/mobius/bin/devtest.exe b/mobius/bin/devtest.exe new file mode 100644 index 0000000..d7191cd --- /dev/null +++ b/mobius/bin/devtest.exe Binary files differ diff --git a/mobius/bin/drivers.cfg b/mobius/bin/drivers.cfg new file mode 100644 index 0000000..1efdaed --- /dev/null +++ b/mobius/bin/drivers.cfg @@ -0,0 +1,12 @@ +driver=vgatext.drv mask=vgatext +driver=keyboard.drv mask=keyboard* +driver=ata.drv mask=ata* +driver=sermouse.drv mask=sermouse* +driver=ps2mouse.drv mask=ps2mouse* +driver=trio64.drv vendor=0x5333 device=0x8811 +driver=fdc.drv mask=floppy* +driver=fat.drv mask=fat +driver=video.drv mask=vga* +driver=sound.drv mask=sb* +driver=sound.drv vendor=0x125d device=0x1969 subsystem=0x125d8888 +#driver=cmos.drv vendor=0xffff device=0x1f00 diff --git a/mobius/bin/fat.drv b/mobius/bin/fat.drv new file mode 100644 index 0000000..c46ce6b --- /dev/null +++ b/mobius/bin/fat.drv Binary files differ diff --git a/mobius/bin/fdc.drv b/mobius/bin/fdc.drv new file mode 100644 index 0000000..f3f8096 --- /dev/null +++ b/mobius/bin/fdc.drv Binary files differ diff --git a/mobius/bin/floppy.img b/mobius/bin/floppy.img new file mode 100644 index 0000000..6561b0e --- /dev/null +++ b/mobius/bin/floppy.img Binary files differ diff --git a/mobius/bin/format.txt b/mobius/bin/format.txt new file mode 100644 index 0000000..4987374 --- /dev/null +++ b/mobius/bin/format.txt @@ -0,0 +1,4 @@ + + +n + diff --git a/mobius/bin/isa.cfg b/mobius/bin/isa.cfg new file mode 100644 index 0000000..c494877 --- /dev/null +++ b/mobius/bin/isa.cfg @@ -0,0 +1,33 @@ +# +# isa.cfg +# +# Configuration file for ISA (non PnP) devices under The M�bius +# + +# keyboard: I/O ports must be specified KEYB_PORT then KEYB_CTRL +name=keyboard irq=1 #io=60,1 io=64,1 + +# floppy drive controller +name=floppy0 + +# ps2mouse: shares ports 60/64 with keyboard +name=ps2mouse irq=12 + +# sermouse: set up on COM1 +#name=sermouse io=3f8,6 irq=4 + +# ide hard drive controllers +#name=ata0 io=1f0,8 irq=14 +#name=ata1 io=170,8 irq=15 + +# text-mode VGA frame buffer +#name=vgatext memory=0xb8000,0x8000 + +# CMOS, RTC +#name=clock io=70,2 vendor=ffff device=1f00 + +# VGA graphics +name=vga4 + +# SoundBlaster +#name=sb irq=5 diff --git a/mobius/bin/isa.drv b/mobius/bin/isa.drv new file mode 100644 index 0000000..7bdbf82 --- /dev/null +++ b/mobius/bin/isa.drv Binary files differ diff --git a/mobius/bin/kdebug.dll b/mobius/bin/kdebug.dll new file mode 100644 index 0000000..57c76d1 --- /dev/null +++ b/mobius/bin/kdebug.dll Binary files differ diff --git a/mobius/bin/kernel.exe b/mobius/bin/kernel.exe new file mode 100644 index 0000000..aac167f --- /dev/null +++ b/mobius/bin/kernel.exe Binary files differ diff --git a/mobius/bin/kernelu.dll b/mobius/bin/kernelu.dll new file mode 100644 index 0000000..2cfb40f --- /dev/null +++ b/mobius/bin/kernelu.dll Binary files differ diff --git a/mobius/bin/keyboard.drv b/mobius/bin/keyboard.drv new file mode 100644 index 0000000..182123f --- /dev/null +++ b/mobius/bin/keyboard.drv Binary files differ diff --git a/mobius/bin/libc.dll b/mobius/bin/libc.dll new file mode 100644 index 0000000..fd56983 --- /dev/null +++ b/mobius/bin/libc.dll Binary files differ diff --git a/mobius/bin/mobel_pe.com b/mobius/bin/mobel_pe.com new file mode 100644 index 0000000..bad5030 --- /dev/null +++ b/mobius/bin/mobel_pe.com Binary files differ diff --git a/mobius/bin/mtools.conf b/mobius/bin/mtools.conf new file mode 100644 index 0000000..40a6f30 --- /dev/null +++ b/mobius/bin/mtools.conf @@ -0,0 +1,16 @@ +# Example mtools.conf files. Uncomment the lines which correspond to +# your architecture and comment out the "SAMPLE FILE" line below +# SAMPLE FILE + +# # Uncomment these lines and edit as necessary. +# # The "partition=1" is used on the c: image because it is a hard +# # disk image. It means that the first partition inside the +# # hard disk image will be used. This is not necessary for +# # floppy disks because they don't have partitions. +drive a: file="floppy.img" +# drive c: file="harddrv.img" partition=1 +drive c: file="f:\hd.img" partition=1 + +# # uncomment the following line to display all file names in lower +# # case by default +# mtools_lower_case=1 diff --git a/mobius/bin/pci.drv b/mobius/bin/pci.drv new file mode 100644 index 0000000..bd96b03 --- /dev/null +++ b/mobius/bin/pci.drv Binary files differ diff --git a/mobius/bin/ps2mouse.drv b/mobius/bin/ps2mouse.drv new file mode 100644 index 0000000..3ae4f1c --- /dev/null +++ b/mobius/bin/ps2mouse.drv Binary files differ diff --git a/mobius/bin/ramdisk.bin b/mobius/bin/ramdisk.bin new file mode 100644 index 0000000..bc2ffb1 --- /dev/null +++ b/mobius/bin/ramdisk.bin Binary files differ diff --git a/mobius/bin/ramdisk.exe b/mobius/bin/ramdisk.exe new file mode 100644 index 0000000..f5b3b7c --- /dev/null +++ b/mobius/bin/ramdisk.exe Binary files differ diff --git a/mobius/bin/sermouse.drv b/mobius/bin/sermouse.drv new file mode 100644 index 0000000..696df51 --- /dev/null +++ b/mobius/bin/sermouse.drv Binary files differ diff --git a/mobius/bin/short.exe b/mobius/bin/short.exe new file mode 100644 index 0000000..1fc41aa --- /dev/null +++ b/mobius/bin/short.exe Binary files differ diff --git a/mobius/bin/tetris.exe b/mobius/bin/tetris.exe new file mode 100644 index 0000000..35255d1 --- /dev/null +++ b/mobius/bin/tetris.exe Binary files differ diff --git a/mobius/bin/vgatext.drv b/mobius/bin/vgatext.drv new file mode 100644 index 0000000..fdd74c2 --- /dev/null +++ b/mobius/bin/vgatext.drv Binary files differ diff --git a/mobius/doc/footer.html b/mobius/doc/footer.html new file mode 100644 index 0000000..40db26a --- /dev/null +++ b/mobius/doc/footer.html @@ -0,0 +1,7 @@ +
+Generated at $datetime for $projectname by +doxygen + $doxygenversion written by Dimitri van Heesch, + © 1997-2001
+ + diff --git a/mobius/doc/header.html b/mobius/doc/header.html new file mode 100644 index 0000000..e588612 --- /dev/null +++ b/mobius/doc/header.html @@ -0,0 +1,6 @@ + + + +$title + + diff --git a/mobius/doc/main.c b/mobius/doc/main.c new file mode 100644 index 0000000..4af80de --- /dev/null +++ b/mobius/doc/main.c @@ -0,0 +1,7 @@ +void* ps2Init(); +void ps2Delete(void*); + +int __stdcall WinMain(unsigned hinst, unsigned hprev, const char* cmdline, unsigned cmdshow) +{ + ps2Delete(ps2Init()); +} \ No newline at end of file diff --git a/mobius/doc/ps2mouse.c b/mobius/doc/ps2mouse.c new file mode 100644 index 0000000..85fac32 --- /dev/null +++ b/mobius/doc/ps2mouse.c @@ -0,0 +1,363 @@ +#include + +#ifdef _DEUB +#define TRACE0(f) printf(f) +#define TRACE1(f, a) printf(f, a) +#define TRACE2(f, a, b) printf(f, a, b) +#else +#define TRACE0(f) +#define TRACE1(f, a) +#define TRACE2(f, a, b) +#endif + +/* + * General keyboard defines -- + * needed for i8042 port (PS/2 controller) + */ + +#define KEYB_PORT 0x60 /* keyboard port */ +#define KEYB_CTRL 0x64 /* keyboard controller port */ + +#define KCTRL_ENABLE_AUX 0xA8 /* enable aux port (PS/2 mouse) */ +#define KCTRL_WRITE_CMD_BYTE 0x60 /* write to command register */ +#define KCTRL_WRITE_AUX 0xD4 /* write next byte at port 60 to aux port */ + +/* flags for KCTRL_WRITE_CMD_BYTE */ +#define KCTRL_IRQ1 0x01 +#define KCTRL_IRQ12 0x02 +#define KCTRL_SYS 0x04 +#define KCTRL_OVERRIDE_INHIBIT 0x08 +#define KCTRL_DISABLE_KEYB 0x10 +#define KCTRL_DISABLE_AUX 0x20 +#define KCTRL_TRANSLATE_XT 0x40 + +/* commands to keyboard */ +#define KEYB_SET_LEDS 0xED +#define KEYB_SET_SCANCODE_SET 0xF0 +#define KEYB_IDENTIFY 0xF2 +#define KEYB_SET_TYPEMATIC 0xF3 +#define KEYB_ENABLE 0xF4 +#define KEYB_RESET_DISABLE 0xF5 +#define KEYB_ALL_TYPM_MAKE_BRK 0xFA + +/* default ACK from keyboard following command */ +#define KEYB_ACK "\xFA" + +/* commands to aux device (PS/2 mouse) */ +#define AUX_INFORMATION 0xE9 +#define AUX_ENABLE 0xF4 +#define AUX_IDENTIFY 0xF2 +#define AUX_RESET 0xFF + +typedef unsigned char byte; +typedef unsigned short word; +typedef unsigned long dword; +typedef enum { false, true } bool; + +#define msleep thrSleep + +/* + * Ask the OS to call func() when the specified IRQ occurs. + * The parameter provided (context) will be passed to the function. + */ +void sysRegisterIrq(int irq, void (__cdecl *func)(void*, int), void* context); + +/* Pauses execution for ms milliseconds */ +void msleep(unsigned ms); + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + +#ifdef _MSC_VER + +#pragma warning(disable:4035) + +#define enable() __asm sti + +byte in(word port) +{ + __asm + { + xor eax, eax + mov dx, port + in al, dx + } +} + +void out(word port, byte data) +{ + __asm + { + movzx eax, data + mov dx, port + out dx, al + } +} + +#else + +static inline void enable() { asm("sti"); } + +static inline byte in(word port) +{ + byte ret; + asm("movw %1,%%dx ;" + "inb %%dx,%%al ;" + "movb %%al,%0" : "=r" (ret) : "r" (port) : "eax"); + return ret; +} + +#define out(port, value) \ + asm("outb %%al, %%dx" : : "d" (port), "a" (value) : "eax", "edx") + +#endif + +static word interrupts; + +typedef struct Ps2Mouse Ps2Mouse; +struct Ps2Mouse +{ + bool has_wheel; + int x, y, xmax, xmin, ymax, ymin, wheel; + dword buttons; +}; + +void kbdWrite(word port, byte data) +{ + dword timeout; + byte stat; + + for (timeout = 500000L; timeout != 0; timeout--) + { + stat = in(KEYB_CTRL); + + if ((stat & 0x02) == 0) + break; + } + + if (timeout != 0) + out(port, data); +} + +byte kbdRead() +{ + unsigned long Timeout; + byte Stat, Data; + + for (Timeout = 50000L; Timeout != 0; Timeout--) + { + Stat = in(KEYB_CTRL); + + /* loop until 8042 output buffer full */ + if ((Stat & 0x01) != 0) + { + Data = in(KEYB_PORT); + + /* loop if parity error or receive timeout */ + if((Stat & 0xC0) == 0) + return Data; + } + } + + return -1; +} + +byte kbdWriteRead(word port, byte data, const char* expect) +{ + int RetVal; + + kbdWrite(port, data); + for (; *expect; expect++) + { + RetVal = kbdRead(); + if ((byte) *expect != RetVal) + { + TRACE2("[keyboard] error: expected 0x%x, got 0x%x\n", + *expect, RetVal); + return RetVal; + } + } + + return 0; +} + +void ps2Isr(void* ctx, int irq); + +Ps2Mouse* ps2Init() +{ + /* These strings nicked from gpm (I_imps2): I don't know how they work... */ + static byte s1[] = { 0xF3, 0xC8, 0xF3, 0x64, 0xF3, 0x50, 0 }; + static byte s2[] = { 0xF6, 0xE6, 0xF4, 0xF3, 0x64, 0xE8, 0x03, 0 }; + Ps2Mouse* ctx; + const byte* ch; + byte id; + + ctx = (Ps2Mouse*) malloc(sizeof(Ps2Mouse)); + + /* enable the aux port */ + kbdWrite(KEYB_CTRL, KCTRL_ENABLE_AUX); + + for (ch = s1; *ch; ch++) + { + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, *ch, KEYB_ACK); + } + + /* Bochs doesn't like this bit... */ +#if 0 + for (ch = s2; *ch; ch++) + { + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, *ch, KEYB_ACK); + } +#endif + + msleep(10); + + /* Identify mouse -- regular PS/2 mice should return zero here. + Unfortunately, my Intellimouse PS/2 also returns zero unless it has + been given the string 's2' above. Bochs doesn't support wheeled mice + and panics when it receives the F6h above. Fix needed. */ + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, AUX_IDENTIFY, KEYB_ACK); + id = kbdRead(); + + ctx->has_wheel = id == 3; + + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, 0xF3, KEYB_ACK); + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, 0xFF, KEYB_ACK); + + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, AUX_INFORMATION, KEYB_ACK); + TRACE1(L"[mouse] status = %d\n", kbdRead()); + TRACE1(L"[mouse] resolution = %d\n", kbdRead()); + TRACE1(L"[mouse] sample rate = %d\n", kbdRead()); + + /* enable aux device (mouse) */ + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, AUX_ENABLE, KEYB_ACK); + + sysRegisterIrq(12, ps2Isr, ctx); + + ctx->xmin = ctx->ymin = 0; + ctx->xmax = 320; + ctx->ymax = 200; + ctx->x = (ctx->xmin + ctx->xmax) / 2; + ctx->y = (ctx->ymin + ctx->ymax) / 2; + + return ctx; +} + +void ps2Delete(Ps2Mouse* ctx) +{ + /* may need to shut down hardware here */ + + sysRegisterIrq(12, NULL, NULL); + free(ctx); +} + +byte ps2AuxRead() +{ + byte Stat, Data; + + enable(); + + while (true) + { + while ((interrupts & 0x1000) == 0) + ; + + interrupts &= ~0x1000; + + Stat = in(KEYB_CTRL); + if ((Stat & 0x01) != 0) + { + Data = in(KEYB_PORT); + + /* loop if parity error or receive timeout */ + if((Stat & 0xC0) == 0) + return Data; + } + } + + return (byte) -1; +} + +void ps2Packet(Ps2Mouse* ctx) +{ + int but, dx, dy, dw; + byte buf[4]; + + //putwchar(L'['); + buf[0] = ps2AuxRead(); + if (buf[0] == (byte) -1) + { + //putwchar(')'); + return; + } + + buf[1] = ps2AuxRead(); + buf[2] = ps2AuxRead(); + + if (ctx->has_wheel) + buf[3] = ps2AuxRead(); + else + buf[3] = 0; + + //putwchar(L']'); + //putwchar(L'\r'); + + /*putwchar(buf[0]); + putwchar(buf[1]); + putwchar(buf[2]); + putwchar(buf[3]);*/ + + /* Extract the data from the bytes read. + From svgalib ms.c. */ + but = (buf[0] & 0x04) >> 1 | /* Middle */ + (buf[0] & 0x02) >> 1 | /* Right */ + (buf[0] & 0x01) << 2; /* Left */ + dx = (buf[0] & 0x10) ? buf[1] - 256 : buf[1]; + dy = (buf[0] & 0x20) ? -(buf[2] - 256) : -buf[2]; + dw = (int) ((signed char) buf[3]); + + if (dx > 5 || dx < -5) + dx *= 4; + if (dy > 5 || dy < -5) + dy *= 4; + + ctx->x += dx; + ctx->y += dy; + + ctx->x = min(ctx->x, ctx->xmax); + ctx->x = max(ctx->x, ctx->xmin); + ctx->y = min(ctx->y, ctx->ymax); + ctx->y = max(ctx->y, ctx->ymin); + ctx->buttons = but; + ctx->wheel += dw; +} + +void ps2Isr(void* ctx, int irq) +{ + static int in_isr = 0; + byte stat; + + stat = in(KEYB_CTRL); + if ((stat & 0x01) != 0) + { + interrupts |= 1 << irq; + if (!in_isr) + { + in_isr++; + ps2Packet((Ps2Mouse*) ctx); + in_isr--; + } + } +} diff --git a/mobius/doc/styles.css b/mobius/doc/styles.css new file mode 100644 index 0000000..f057c30 --- /dev/null +++ b/mobius/doc/styles.css @@ -0,0 +1 @@ +H1 { text-align: center; } A.qindex {} A.qindexRef {} A.el { text-decoration: none; font-weight: bold } A.elRef { font-weight: bold } A.code { text-decoration: none; font-weight: normal; color: #4444ee } A.codeRef { font-weight: normal; color: #4444ee } DL.el { margin-left: -1cm } DIV.fragment { width: 100%; border: none; background-color: #eeeeee } DIV.ah { background-color: black; margin-bottom: 3; margin-top: 3 } TD.md { background-color: #f2f2ff } DIV.groupHeader { margin-left: 16; margin-top: 12; margin-bottom: 6; font-weight: bold } DIV.groupText { margin-left: 16; font-style: italic; font-size: smaller } FONT.keyword { color: #008000 } FONT.keywordtype { color: #604020 } FONT.keywordflow { color: #e08000 } FONT.comment { color: #800000 } FONT.preprocessor { color: #806020 } FONT.stringliteral { color: #002080 } FONT.charliteral { color: #008080 } body { font-family: Verdana; font-size: 10pt } \ No newline at end of file diff --git a/mobius/doc/txt/ACPIspec20.pdf b/mobius/doc/txt/ACPIspec20.pdf new file mode 100644 index 0000000..2ad3083 --- /dev/null +++ b/mobius/doc/txt/ACPIspec20.pdf Binary files differ diff --git a/mobius/doc/txt/PNP-ISA-v1.0a.pdf b/mobius/doc/txt/PNP-ISA-v1.0a.pdf new file mode 100644 index 0000000..edd52f2 --- /dev/null +++ b/mobius/doc/txt/PNP-ISA-v1.0a.pdf Binary files differ diff --git a/mobius/doc/txt/PNPBIOSSpecification-v1.0a.pdf b/mobius/doc/txt/PNPBIOSSpecification-v1.0a.pdf new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/mobius/doc/txt/PNPBIOSSpecification-v1.0a.pdf diff --git a/mobius/doc/txt/fat.txt b/mobius/doc/txt/fat.txt new file mode 100644 index 0000000..7cf7175 --- /dev/null +++ b/mobius/doc/txt/fat.txt @@ -0,0 +1,1973 @@ + FAT: General Overview of On-Disk Format-Page 25 +25 +� 1999 Microsoft Corporation. All rights reserved. +Hardware White Paper + +Designing Hardware for Microsoft� Operating Systems + + + +FAT: General Overview of On-Disk Format + + +Version 1.02, May 5, 1999 +Microsoft Corporation + + +The FAT (File Allocation Table) file system has its origins +in the late 1970s and early1980s and was the file system +supported by the Microsoft� MS-DOS� operating system. It was +originally developed as a simple file system suitable for +floppy disk drives less than 500K in size. Over time it has +been enhanced to support larger and larger media. Currently +there are three FAT file system types: FAT12, FAT16 and +FAT32. The basic difference in these FAT sub types, and the +reason for the names, is the size, in bits, of the entries +in the actual FAT structure on the disk. There are 12 bits +in a FAT12 FAT entry, 16 bits in a FAT16 FAT entry and 32 +bits in a FAT32 FAT entry. + +Contents +Notational Conventions in this Document 6 +General Comments (Applicable to FAT File System All Types)6 +Boot Sector and BPB 6 +FAT Data Structure 12 +FAT Type Determination 13 +FAT Volume Initialization 18 +FAT32 FSInfo Sector Structure and Backup Boot Sector 20 +FAT Directory Structure 21 +Other Notes Relating to FAT Directories 24 +Specification Compliance 25 + +Microsoft, MS_DOS, Windows, and Windows NT are trademarks or +registered trademarks of Microsoft Corporation in the United +States and/or other countries. Other product and company +names mentioned herein may be the trademarks of their +respective owners. +� 1999 Microsoft Corporation. All rights reserved. + +Disclaimer +IMPORTANT-READ CAREFULLY: This Microsoft Agreement +("Agreement") is a legal agreement between you (either an +individual or a single entity) and Microsoft Corporation +("Microsoft") for this version of the Microsoft +specification identified above ("Specification"). BY +DOWNLOADING, COPYING OR OTHERWISE USING THE SPECIFICATION, +YOU AGREE TO BE BOUND BY THE TERMS OF THIS AGREEMENT. IF YOU +DO NOT AGREE TO THE TERMS OF THIS AGREEMENT, DO NOT +DOWNLOAD, COPY, OR USE THE SPECIFICATION. + +The Specification is owned by Microsoft or its suppliers and +is protected by copyright laws and international copyright +treaties, as well as other intellectual property laws and +treaties. +1. LIMITED COVENANT NOT TO SUE. + (a) Provided that you comply with all terms and + conditions of this Agreement and subject to the + limitations in Sections 1(b) - (e) below, Microsoft grants + to you the following non-exclusive, worldwide, royalty- + free, non-transferable, non-sublicenseable, reciprocal + limited covenant not to sue: + (i) under any copyrights owned or licensable by Microsoft + without payment of consideration to unaffiliated third + parties, to reproduce the Specification solely for the + purposes of creating portions of products which comply with + the Specification in unmodified form; and + (ii) under its Necessary Claims solely to make, have + made, use, import, and directly and indirectly, + offer to sell, sell and otherwise distribute and + dispose of portions of products which comply with + the Specification in unmodified form. + For purposes of the foregoing, the Specification is + "unmodified" if there are no changes, additions or + extensions to the Specification, and "Necessary Claims" + means claims of a patent or patent application which + are (1) owned or licenseable by Microsoft without + payment of consideration to an unaffiliated third + party; and (2) have an effective filing date on or + before December 31, 2010, that must be infringed in + order to make a portion(s) of a product that complies + with the Specification. Necessary Claims does not + include claims relating to semiconductor manufacturing + technology or microprocessor circuits or claims not + required to be infringed in complying with the + Specification (even if in the same patent as Necessary + Claims). + + (b) The foregoing covenant not to sue shall not extend to + any part or function of a product which (i) is not + required to comply with the Specification in unmodified + form, or (ii) to which there was a commercially reasonable + alternative to infringing a Necessary Claim. + + (c) The covenant not to sue described above shall be + unavailable to you and shall terminate immediately if you + or any of your Affiliates (collectively "Covenantee + Party") "Initiates" any action for patent infringement + against: (x) Microsoft or any of its Affiliates + (collectively "Granting Party"), (y) any customers or + distributors of the Granting Party, or other recipients of + a covenant not to sue with respect to the Specification + from the Granting Party ("Covenantees"); or (z) any + customers or distributors of Covenantees (all parties + identified in (y) and (z) collectively referred to as + "Customers"), which action is based on a conformant + implementation of the Specification. As used herein, + "Affiliate" means any entity which directly or indirectly + controls, is controlled by, or is under common control + with a party; and control shall mean the power, whether + direct or indirect, to direct or cause the direct of the + management or policies of any entity whether through the + ownership of voting securities, by contract or otherwise. + "Initiates" means that a Covenantee Party is the first (as + between the Granting Party and the Covenantee Party) to + file or institute any legal or administrative claim or + action for patent infringement against the Granting Party + or any of the Customers. "Initiates" includes any + situation in which a Covenantee Party files or initiates a + legal or administrative claim or action for patent + infringement solely as a counterclaim or equivalent in + response to a Granting Party first filing or instituting a + legal or administrative patent infringement claim against + such Covenantee Party. + + (d) The covenant not to sue described above shall not + extend to your use of any portion of the Specification for + any purpose other than (a) to create portions of an + operating system (i) only as necessary to adapt such + operating system so that it can directly interact with a + firmware implementation of the Extensible Firmware + Initiative Specification v. 1.0 ("EFI Specification"); + (ii) only as necessary to emulate an implementation of the + EFI Specification; and (b) to create firmware, + applications, utilities and/or drivers that will be used + and/or licensed for only the following purposes: (i) to + install, repair and maintain hardware, firmware and + portions of operating system software which are utilized + in the boot process; (ii) to provide to an operating + system runtime services that are specified in the EFI + Specification; (iii) to diagnose and correct failures in + the hardware, firmware or operating system software; (iv) + to query for identification of a computer system (whether + by serial numbers, asset tags, user or otherwise); (v) to + perform inventory of a computer system; and (vi) to + manufacture, install and setup any hardware, firmware or + operating system software. + + (e) Microsoft reserves all other rights it may have in + the Specification and any intellectual property therein. + The furnishing of this document does not give you any + covenant not to sue with respect to any other Microsoft + patents, trademarks, copyrights or other intellectual + property rights; or any license with respect to any + Microsoft intellectual property rights. + +2. ADDITIONAL LIMITATIONS AND OBLIGATIONS. + (a) The foregoing covenant not to sue is applicable only to + the version of the Specification which you are about to + download. It does not apply to any additional versions of + or extensions to the Specification. + (b) Without prejudice to any other rights, Microsoft may + terminate this Agreement if you fail to comply with the + terms and conditions of this Agreement. In such event you + must destroy all copies of the Specification. +3. INTELLECTUAL PROPERTY RIGHTS. All ownership, title + and intellectual property rights in and to the + Specification are owned by Microsoft or its suppliers. +4.U.S. GOVERNMENT RIGHTS. Any Specification provided to the + U.S. Government pursuant to solicitations issued on or + after December 1, 1995 is provided with the commercial + rights and restrictions described elsewhere herein. Any + Specification provided to the U.S. Government pursuant to + solicitations issued prior to December 1, 1995 is provided + with RESTRICTED RIGHTS as provided for in FAR, 48 CFR + 52.227-14 (JUNE 1987) or DFAR, 48 CFR 252.227-7013 (OCT + 1988), as applicable. +5. EXPORT RESTRICTIONS. Export of the Specification, any + part thereof, or any process or service that is the direct + product of the Specification (the foregoing collectively + referred to as the "Restricted Components") from the United + States is regulated by the Export Administration + Regulations (EAR, 15 CFR 730-744) of the U.S. Commerce + Department, Bureau of Export Administration ("BXA"). You + agree to comply with the EAR in the export or re-export of + the Restricted Components (i) to any country to which the + U.S. has embargoed or restricted the export of goods or + services, which currently include, but are not necessarily + limited to Cuba, Iran, Iraq, Libya, North Korea, Sudan, + Syria and the Federal Republic of Yugoslavia (including + Serbia, but not Montenegro), or to any national of any such + country, wherever located, who intends to transmit or + transport the Restricted Components back to such country; + (ii) to any person or entity who you know or have reason to + know will utilize the Restricted Components in the design, + development or production of nuclear, chemical or + biological weapons; or (iii) to any person or entity who + has been prohibited from participating in U.S. export + transactions by any federal agency of the U.S. government. + You warrant and represent that neither the BXA nor any + other U.S. federal agency has suspended, revoked or denied + your export privileges. For additional information see + http://www.microsoft.com/exporting. +6. DISCLAIMER OF WARRANTIES. To the maximum extent + permitted by applicable law, Microsoft and its suppliers + provide the Specification (and all intellectual property + therein) and any (if any) support services related to the + Specification ("Support Services") AS IS AND WITH ALL + FAULTS, and hereby disclaim all warranties and conditions, + either express, implied or statutory, including, but not + limited to, any (if any) implied warranties or conditions + of merchantability, of fitness for a particular purpose, + of lack of viruses, of accuracy or completeness of + responses, of results, and of lack of negligence or lack + of workmanlike effort, all with regard to the + Specification, any intellectual property therein and the + provision of or failure to provide Support Services. + ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET + ENJOYMENT, QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION + OR NON-INFRINGEMENT, WITH REGARD TO THE SPECIFICATION AND + ANY INTELLECTUAL PROPERTY THEREIN. THE ENTIRE RISK AS TO + THE QUALITY OF OR ARISING OUT OF USE OR PERFORMANCE OF THE + SPECIFICATION, ANY INTELLECTUAL PROPERTY THEREIN, AND + SUPPORT SERVICES, IF ANY, REMAINS WITH YOU. +7. EXCLUSION OF INCIDENTAL, CONSEQUENTIAL AND CERTAIN + OTHER DAMAGES. TO THE MAXIMUM EXTENT PERMITTED BY + APPLICABLE LAW, IN NO EVENT SHALL MICROSOFT OR ITS + SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, + OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, BUT NOT + LIMITED TO, DAMAGES FOR LOSS OF PROFITS OR CONFIDENTIAL OR + OTHER INFORMATION, FOR BUSINESS INTERRUPTION, FOR PERSONAL + INJURY, FOR LOSS OF PRIVACY, FOR FAILURE TO MEET ANY DUTY + INCLUDING OF GOOD FAITH OR OF REASONABLE CARE, FOR + NEGLIGENCE, AND FOR ANY OTHER PECUNIARY OR OTHER LOSS + WHATSOEVER) ARISING OUT OF OR IN ANY WAY RELATED TO THE + USE OF OR INABILITY TO USE THE SPECIFICATION, ANY + INTELLECTUAL PROPERTY THEREIN, THE PROVISION OF OR FAILURE + TO PROVIDE SUPPORT SERVICES, OR OTHERWISE UNDER OR IN + CONNECTION WITH ANY PROVISION OF THIS AGREEMENT, EVEN IN + THE EVENT OF THE FAULT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY, BREACH OF CONTRACT OR BREACH OF WARRANTY + OF MICROSOFT OR ANY SUPPLIER, AND EVEN IF MICROSOFT OR ANY + SUPPLIER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + DAMAGES. +8. LIMITATION OF LIABILITY AND REMEDIES. Notwithstanding + any damages that you might incur for any reason whatsoever + (including, without limitation, all damages referenced + above and all direct or general damages), the entire + liability of Microsoft and any of its suppliers under any + provision of this Agreement and your exclusive remedy for + all of the foregoing shall be limited to the greater of + the amount actually paid by you for the Specification or + U.S.$5.00. The foregoing limitations, exclusions and + disclaimers shall apply to the maximum extent permitted by + applicable law, even if any remedy fails its essential + purpose. +9. APPLICABLE LAW. If you acquired this Specification in + the United States, this Agreement is governed by the laws + of the State of Washington. If you acquired this + Specification in Canada, unless expressly prohibited by + local law, this Agreement is governed by the laws in force + in the Province of Ontario, Canada; and, in respect of any + dispute which may arise hereunder, you consent to the + jurisdiction of the federal and provincial courts sitting + in Toronto, Ontario. If this Specification was acquired + outside the United States, then local law may apply. +10.QUESTIONS. Should you have any questions concerning this + Agreement, or if you desire to contact Microsoft for any + reason, please contact the Microsoft subsidiary serving + your country, or write: Microsoft Sales Information + Center/One Microsoft Way/Redmond, WA 98052-6399. +11.ENTIRE AGREEMENT. This Agreement is the entire + agreement between you and Microsoft relating to the + Specification and the Support Services (if any) and they + supersede all prior or contemporaneous oral or written + communications, proposals and representations with + respect to the Specification or any other subject matter + covered by this Agreement. To the extent the terms of any + Microsoft policies or programs for Support Services + conflict with the terms of this Agreement, the terms of + this Agreement shall control. + +Si vous avez acquis votre produit Microsoft au CANADA, la + garantie limit�e suivante vous concerne : + +RENONCIATION AUX GARANTIES. Dans toute la mesure permise par +la l�gislation en vigueur, Microsoft et ses fournisseurs +fournissent la Specification (et � toute propri�t� +intellectuelle dans celle-ci) et tous (selon le cas) les +services d'assistance li�s � la Specification ("Services +d'assistance") TELS QUELS ET AVEC TOUS LEURS D�FAUTS, et par +les pr�sentes excluent toute garantie ou condition, expresse +ou implicite, l�gale ou conventionnelle, �crite ou verbale, +y compris, mais sans limitation, toute (selon le cas) +garantie ou condition implicite ou l�gale de qualit� +marchande, de conformit� � un usage particulier, d'absence +de virus, d'exactitude et d'int�gralit� des r�ponses, de +r�sultats, d'efforts techniques et professionnels et +d'absence de n�gligence, le tout relativement � la +Specification, � toute propri�t� intellectuelle dans celle- +ci et � la prestation ou � la non-prestation des Services +d'assistance. DE PLUS, IL N'Y A AUCUNE GARANTIE ET +CONDITION DE TITRE, DE JOUISSANCE PAISIBLE, DE POSSESSION +PAISIBLE, DE SIMILARIT� � LA DESCRIPTION ET D'ABSENCE DE +CONTREFA�ON RELATIVEMENT � LA SP�CIFICATION ET � TOUTE +PROPRI�T� INTELLECTUELLE DANS CELLE-CI. VOUS SUPPORTEZ TOUS +LES RISQUES D�COULANT DE L'UTILISATION ET DE LA PERFORMANCE +DE LA SP�CIFICATION ET DE TOUTE PROPRI�T� INTELLECTUELLE +DANS CELLE-CI ET CEUX D�COULANT DES SERVICES D'ASSISTANCE +(S'IL Y A LIEU). + +EXCLUSION DES DOMMAGES INDIRECTS, ACCESSOIRES ET AUTRES. +Dans toute la mesure permise par la l�gislation en vigueur, +Microsoft et ses fournisseurs ne sont en aucun cas +responsables de tout dommage sp�cial, indirect, accessoire, +moral ou exemplaire quel qu'il soit (y compris, mais sans +limitation, les dommages entra�n�s par la perte de b�n�fices +ou la perte d'information confidentielle ou autre, +l'interruption des affaires, les pr�judices corporels, la +perte de confidentialit�, le d�faut de remplir toute +obligation y compris les obligations de bonne foi et de +diligence raisonnable, la n�gligence et toute autre perte +p�cuniaire ou autre perte de quelque nature que ce soit) +d�coulant de, ou de toute autre mani�re li� �, l'utilisation +ou l'impossibilit� d'utiliser la Sp�cification, toute +propri�t� intellectuelle dans celle-ci, la prestation ou la +non-prestation des Services d'assistance ou autrement en +vertu de ou relativement � toute disposition de cette +convention, que ce soit en cas de faute, de d�lit (y compris +la n�gligence), de responsabilit� stricte, de manquement � +un contrat ou de manquement � une garantie de Microsoft ou +de l'un de ses fournisseurs, et ce, m�me si Microsoft ou +l'un de ses fournisseurs a �t� avis� de la possibilit� de +tels dommages. + +LIMITATION DE RESPONSABILIT� ET RECOURS. Malgr� tout +dommage que vous pourriez encourir pour quelque raison que +ce soit (y compris, mais sans limitation, tous les dommages +mentionn�s ci-dessus et tous les dommages directs et +g�n�raux), la seule responsabilit� de Microsoft et de ses +fournisseurs en vertu de toute disposition de cette +convention et votre unique recours en regard de tout ce qui +pr�c�de sont limit�s au plus �lev� des montants suivants: +soit (a) le montant que vous avez pay� pour la +Sp�cification, soit (b) un montant �quivalant � cinq dollars +U.S. (5,00 $ U.S.). Les limitations, exclusions et +renonciations ci-dessus s'appliquent dans toute la mesure +permise par la l�gislation en vigueur, et ce m�me si leur +application a pour effet de priver un recours de son +essence. + +DROITS LIMIT�S DU GOUVERNEMENT AM�RICAIN +Tout Produit Logiciel fourni au gouvernement am�ricain +conform�ment � des demandes �mises le ou apr�s le 1er +d�cembre 1995 est offert avec les restrictions et droits +commerciaux d�crits ailleurs dans la pr�sente convention. +Tout Produit Logiciel fourni au gouvernement am�ricain +conform�ment � des demandes �mises avant le 1er d�cembre +1995 est offert avec des DROITS LIMIT�S tels que pr�vus dans +le FAR, 48CFR 52.227-14 (juin 1987) ou dans le FAR, 48CFR +252.227-7013 (octobre 1988), tels qu'applicables. +Sauf lorsqu'express�ment prohib� par la l�gislation locale, +la pr�sente convention est r�gie par les lois en vigueur +dans la province d'Ontario, Canada. Pour tout diff�rend qui +pourrait d�couler des pr�sentes, vous acceptez la comp�tence +des tribunaux f�d�raux et provinciaux si�geant � Toronto, +Ontario. + +Si vous avez des questions concernant cette convention ou si +vous d�sirez communiquer avec Microsoft pour quelque raison +que ce soit, veuillez contacter la succursale Microsoft +desservant votre pays, ou �crire �: Microsoft Sales +Information Center, One Microsoft Way, Redmond, +Washington 98052-6399. + + + +Notational Conventions in this Document + +Numbers that have the characters "0x" at the beginning of +them are hexadecimal (base 16) numbers. + +Any numbers that do not have the characters "0x" at the +beginning are decimal (base 10) numbers. + +The code fragments in this document are written in the 'C' +programming language. Strict typing and syntax are not +adhered to. + +There are several code fragments in this document that +freely mix 32-bit and 16-bit data elements. It is assumed +that you are a programmer who understands how to properly +type such operations so that data is not lost due to +truncation of 32-bit values to 16-bit values. Also take note +that all data types are UNSIGNED. Do not do FAT computations +with signed integer types, because the computations will be +wrong on some FAT volumes. + +General Comments (Applicable to FAT File System All Types) +All of the FAT file systems were originally developed for +the IBM PC machine architecture. The importance of this is +that FAT file system on disk data structure is all "little +endian." If we look at one 32-bit FAT entry stored on disk +as a series of four 8-bit bytes-the first being byte[0] and +the last being byte[4]-here is where the 32 bits numbered 00 +through 31 are (00 being the least significant bit): + +byte[3] 3 3 2 2 2 2 2 2 + 1 0 9 8 7 6 5 4 + +byte[2] 2 2 2 2 1 1 1 1 + 3 2 1 0 9 8 7 6 + +byte[1] 1 1 1 1 1 1 0 0 + 5 4 3 2 1 0 9 8 + +byte[0] 0 0 0 0 0 0 0 0 + 7 6 5 4 3 2 1 0 + +This is important if your machine is a "big endian" machine, +because you will have to translate between big and little +endian as you move data to and from the disk. + +A FAT file system volume is composed of four basic regions, +which are laid out in this order on the volume: + 0 - Reserved Region + 1 - FAT Region + 2 - Root Directory Region (doesn't exist on FAT32 +volumes) + 3 - File and Directory Data Region + +Boot Sector and BPB +The first important data structure on a FAT volume is called +the BPB (BIOS Parameter Block), which is located in the +first sector of the volume in the Reserved Region. This +sector is sometimes called the "boot sector" or the +"reserved sector" or the "0th sector," but the important +fact is simply that it is the first sector of the volume. + +This is the first thing about the FAT file system that +sometimes causes confusion. In MS-DOS version 1.x, there was +not a BPB in the boot sector. In this first version of the +FAT file system, there were only two different formats, the +one for single-sided and the one for double-sided 360K 5.25- +inch floppy disks. The determination of which type was on +the disk was done by looking at the first byte of the FAT +(the low 8 bits of FAT[0]). + +This type of media determination was superseded in MS-DOS +version 2.x by putting a BPB in the boot sector, and the old +style of media determination (done by looking at the first +byte of the FAT) was no longer supported. All FAT volumes +must have a BPB in the boot sector. + +This brings us to the second point of confusion relating to +FAT volume determination: What exactly does a BPB look like? +The BPB in the boot sector defined for MS-DOS 2.x only +allowed for a FAT volume with strictly less than 65,536 +sectors (32 MB worth of 512-byte sectors). This limitation +was due to the fact that the "total sectors" field was only +a 16-bit field. This limitation was addressed by MS-DOS 3.x, +where the BPB was modified to include a new 32-bit field for +the total sectors value. + +The next BPB change occurred with the Microsoft Windows 95 +operating system, where the FAT32 type was introduced. FAT16 +was limited by the maximum size of the FAT and the maximum +valid cluster size to no more than a 2 GB volume if the disk +had 512-byte sectors. FAT32 addressed this limitation on the +amount of disk space that one FAT volume could occupy so +that disks larger than 2 GB only had to have one partition +defined. + +The FAT32 BPB exactly matches the FAT12/FAT16 BPB up to and +including the BPB_TotSec32 field. They differ starting at +offset 36, depending on whether the media type is +FAT12/FAT16 or FAT32 (see discussion below for determining +FAT type). The relevant point here is that the BPB in the +boot sector of a FAT volume should always be one that has +all of the new BPB fields for either the FAT12/FAT16 or +FAT32 BPB type. Doing it this way ensures the maximum +compatibility of the FAT volume and ensures that all FAT +file system drivers will understand and support the volume +properly, because it always contains all of the currently +defined fields. + +NOTE: In the following description, all the fields whose +names start with BPB_ are part of the BPB. All the fields +whose names start with BS_ are part of the boot sector and +not really part of the BPB. The following shows the start of +sector 0 of a FAT volume, which contains the BPB: + + + Boot Sector and BPB Structure +Name Offs Size Description + et (byt + (byt es) + e) +BS_jmpBoot 0 3 Jump instruction to boot code. + This field has two allowed forms: + jmpBoot[0] = 0xEB, jmpBoot[1] = + 0x??, jmpBoot[2] = 0x90 + and + jmpBoot[0] = 0xE9, jmpBoot[1] = + 0x??, jmpBoot[2] = 0x?? + + 0x?? indicates that any 8-bit + value is allowed in that byte. + What this forms is a three-byte + Intel x86 unconditional branch + (jump) instruction that jumps to + the start of the operating system + bootstrap code. This code + typically occupies the rest of + sector 0 of the volume following + the BPB and possibly other + sectors. Either of these forms is + acceptable. JmpBoot[0] = 0xEB is + the more frequently used format. +BS_OEMName 3 8 "MSWIN4.1" There are many + misconceptions about this field. + It is only a name string. + Microsoft operating systems don't + pay any attention to this field. + Some FAT drivers do. This is the + reason that the indicated string, + "MSWIN4.1", is the recommended + setting, because it is the setting + least likely to cause + compatibility problems. If you + want to put something else in + here, that is your option, but the + result may be that some FAT + drivers might not recognize the + volume. Typically this is some + indication of what system + formatted the volume. +BPB_BytsPe 11 2 Count of bytes per sector. This +rSec value may take on only the + following values: 512, 1024, 2048 + or 4096. If maximum compatibility + is desired, only the value 512 + should be used. There is a lot of + FAT code in the world that is + basically "hard wired" to 512 + bytes per sector and doesn't + bother to check this field to make + sure it is 512. Microsoft + operating systems will properly + support 1024, 2048, and 4096, but + these values are not recommended. +BPB_SecPer 13 1 Number of sectors per allocation +Clus unit. This value must be a power + of 2 that is greater than 0. The + legal values are 1, 2, 4, 8, 16, + 32, 64, and 128. Note however, + that a value should never be used + that results in a "bytes per + cluster" value (BPB_BytsPerSec * + BPB_SecPerClus) greater than 32K + (32 * 1024). There is a + misconception that values greater + than this are OK. Values that + cause a cluster size greater than + 32K bytes do not work properly; do + not try to define one. Some + versions of some systems allow 64K + bytes per cluster value. Many + application setup programs will + not work correctly on such a FAT + volume. +BPB_RsvdSe 14 2 Number of reserved sectors in the +cCnt Reserved region of the volume + starting at the first sector of + the volume. This field must not be + 0. For FAT12 and FAT16 volumes, + this value should never be + anything other than 1. For FAT32 + volumes, this value is typically + 32. There is a lot of FAT code in + the world "hard wired" to 1 + reserved sector for FAT12 and + FAT16 volumes and that doesn't + bother to check this field to make + sure it is 1. Microsoft operating + systems will properly support any + non-zero value in this field. +BPB_NumFAT 16 1 The count of FAT data structures +s on the volume. This field should + always contain the value 2 for any + FAT volume of any type. Although + any value greater than or equal to + 1 is perfectly valid, many + software programs and a few + operating systems' FAT file system + drivers may not function properly + if the value is something other + than 2. All Microsoft file system + drivers will support a value other + than 2, but it is still highly + recommended that no value other + than 2 be used in this field. + + The reason the standard value for + this field is 2 is to provide + redundancy for the FAT data + structure so that if a sector goes + bad in one of the FATs, that data + is not lost because it is + duplicated in the other FAT. On + non-disk-based media, such as + FLASH memory cards, where such + redundancy is a useless feature, a + value of 1 may be used to save the + space that a second copy of the + FAT uses, but some FAT file system + drivers might not recognize such a + volume properly. +BPB_RootEn 17 2 For FAT12 and FAT16 volumes, this +tCnt field contains the count of 32- + byte directory entries in the root + directory. For FAT32 volumes, this + field must be set to 0. For FAT12 + and FAT16 volumes, this value + should always specify a count that + when multiplied by 32 results in + an even multiple of + BPB_BytsPerSec. For maximum + compatibility, FAT16 volumes + should use the value 512. +BPB_TotSec 19 2 This field is the old 16-bit total +16 count of sectors on the volume. + This count includes the count of + all sectors in all four regions of + the volume. This field can be 0; + if it is 0, then BPB_TotSec32 must + be non-zero. For FAT32 volumes, + this field must be 0. For FAT12 + and FAT16 volumes, this field + contains the sector count, and + BPB_TotSec32 is 0 if the total + sector count "fits" (is less than + 0x10000). +BPB_Media 21 1 0xF8 is the standard value for + "fixed" (non-removable) media. For + removable media, 0xF0 is + frequently used. The legal values + for this field are 0xF0, 0xF8, + 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, + 0xFE, and 0xFF. The only other + important point is that whatever + value is put in here must also be + put in the low byte of the FAT[0] + entry. This dates back to the old + MS-DOS 1.x media determination + noted earlier and is no longer + usually used for anything. +BPB_FATSz1 22 2 This field is the FAT12/FAT16 16- +6 bit count of sectors occupied by + ONE FAT. On FAT32 volumes this + field must be 0, and BPB_FATSz32 + contains the FAT size count. +BPB_SecPer 24 2 Sectors per track for interrupt +Trk 0x13. This field is only relevant + for media that have a geometry + (volume is broken down into tracks + by multiple heads and cylinders) + and are visible on interrupt 0x13. + This field contains the "sectors + per track" geometry value. +BPB_NumHea 26 2 Number of heads for interrupt +ds 0x13. This field is relevant as + discussed earlier for + BPB_SecPerTrk. This field contains + the one based "count of heads". + For example, on a 1.44 MB 3.5-inch + floppy drive this value is 2. +BPB_HiddSe 28 4 Count of hidden sectors preceding +c the partition that contains this + FAT volume. This field is + generally only relevant for media + visible on interrupt 0x13. This + field should always be zero on + media that are not partitioned. + Exactly what value is appropriate + is operating system specific. +BPB_TotSec 32 4 This field is the new 32-bit total +32 count of sectors on the volume. + This count includes the count of + all sectors in all four regions of + the volume. This field can be 0; + if it is 0, then BPB_TotSec16 must + be non-zero. For FAT32 volumes, + this field must be non-zero. For + FAT12/FAT16 volumes, this field + contains the sector count if + BPB_TotSec16 is 0 (count is + greater than or equal to 0x10000). + +At this point, the BPB/boot sector for FAT12 and FAT16 +differs from the BPB/boot sector for FAT32. The first table +shows the structure for FAT12 and FAT16 starting at offset +36 of the boot sector. + +Fat12 and Fat16 Structure Starting at Offset 36 +Name Offs Size Description + et (byt + (byt es) + e) +BS_DrvNum 36 1 Int 0x13 drive number (e.g. 0x80). + This field supports MS-DOS + bootstrap and is set to the INT + 0x13 drive number of the media + (0x00 for floppy disks, 0x80 for + hard disks). + NOTE: This field is actually + operating system specific. +BS_Reserve 37 1 Reserved (used by Windows NT). +d1 Code that formats FAT volumes + should always set this byte to 0. +BS_BootSig 38 1 Extended boot signature (0x29). + This is a signature byte that + indicates that the following three + fields in the boot sector are + present. +BS_VolID 39 4 Volume serial number. This field, + together with BS_VolLab, supports + volume tracking on removable + media. These values allow FAT file + system drivers to detect that the + wrong disk is inserted in a + removable drive. This ID is + usually generated by simply + combining the current date and + time into a 32-bit value. +BS_VolLab 43 11 Volume label. This field matches + the 11-byte volume label recorded + in the root directory. + NOTE: FAT file system drivers + should make sure that they update + this field when the volume label + file in the root directory has its + name changed or created. The + setting for this field when there + is no volume label is the string + "NO NAME ". +BS_FilSysT 54 8 One of the strings "FAT12 ", +ype "FAT16 ", or "FAT ". NOTE: + Many people think that the string + in this field has something to do + with the determination of what + type of FAT-FAT12, FAT16, or + FAT32-that the volume has. This is + not true. You will note from its + name that this field is not + actually part of the BPB. This + string is informational only and + is not used by Microsoft file + system drivers to determine FAT + typ,e because it is frequently not + set correctly or is not present. + See the FAT Type Determination + section of this document. This + string should be set based on the + FAT type though, because some non- + Microsoft FAT file system drivers + do look at it. + +Here is the structure for FAT32 starting at offset 36 of the +boot sector. + +FAT32 Structure Starting at Offset 36 +Name Offs Size Description + et (byt + (byt es) + e) +BPB_FATSz3 36 4 This field is only defined for +2 FAT32 media and does not exist on + FAT12 and FAT16 media. This field + is the FAT32 32-bit count of + sectors occupied by ONE FAT. + BPB_FATSz16 must be 0. +BPB_ExtFla 40 2 This field is only defined for +gs FAT32 media and does not exist on + FAT12 and FAT16 media. + Bits 0-3 -- Zero-based number of + active FAT. Only valid if + mirroring is disabled. + Bits 4-6 -- Reserved. + Bit 7 -- 0 means the FAT is + mirrored at runtime into all + FATs. + -- 1 means only one FAT is + active; it is the one + referenced in bits 0-3. + Bits 8-15 -- Reserved. +BPB_FSVer 42 2 This field is only defined for + FAT32 media and does not exist on + FAT12 and FAT16 media. High byte + is major revision number. Low byte + is minor revision number. This is + the version number of the FAT32 + volume. This supports the ability + to extend the FAT32 media type in + the future without worrying about + old FAT32 drivers mounting the + volume. This document defines the + version to 0:0. If this field is + non-zero, back-level Windows + versions will not mount the + volume. + NOTE: Disk utilities should + respect this field and not operate + on volumes with a higher major or + minor version number than that for + which they were designed. FAT32 + file system drivers must check + this field and not mount the + volume if it does not contain a + version number that was defined at + the time the driver was written. +BPB_RootCl 44 4 This field is only defined for +us FAT32 media and does not exist on + FAT12 and FAT16 media. This is set + to the cluster number of the first + cluster of the root directory, + usually 2 but not required to be + 2. + NOTE: Disk utilities that change + the location of the root directory + should make every effort to place + the first cluster of the root + directory in the first non-bad + cluster on the drive (i.e., in + cluster 2, unless it's marked + bad). This is specified so that + disk repair utilities can easily + find the root directory if this + field accidentally gets zeroed. +BPB_FSInfo 48 2 This field is only defined for + FAT32 media and does not exist on + FAT12 and FAT16 media. Sector + number of FSINFO structure in the + reserved area of the FAT32 volume. + Usually 1. + NOTE: There will be a copy of the + FSINFO structure in BackupBoot, but + only the copy pointed to by this + field will be kept up to date + (i.e., both the primary and backup + boot record will point to the same + FSINFO sector). +BPB_BkBoot 50 2 This field is only defined for +Sec FAT32 media and does not exist on + FAT12 and FAT16 media. If non- + zero, indicates the sector number + in the reserved area of the volume + of a copy of the boot record. + Usually 6. No value other than 6 + is recommended. +BPB_Reserv 52 12 This field is only defined for +ed FAT32 media and does not exist on + FAT12 and FAT16 media. Reserved + for future expansion. Code that + formats FAT32 volumes should + always set all of the bytes of + this field to 0. +BS_DrvNum 64 1 This field has the same definition + as it does for FAT12 and FAT16 + media. The only difference for + FAT32 media is that the field is + at a different offset in the boot + sector. +BS_Reserve 65 1 This field has the same definition +d1 as it does for FAT12 and FAT16 + media. The only difference for + FAT32 media is that the field is + at a different offset in the boot + sector. +BS_BootSig 66 1 This field has the same definition + as it does for FAT12 and FAT16 + media. The only difference for + FAT32 media is that the field is + at a different offset in the boot + sector. +BS_VolID 67 4 This field has the same definition + as it does for FAT12 and FAT16 + media. The only difference for + FAT32 media is that the field is + at a different offset in the boot + sector. +BS_VolLab 71 11 This field has the same definition + as it does for FAT12 and FAT16 + media. The only difference for + FAT32 media is that the field is + at a different offset in the boot + sector. +BS_FilSysT 82 8 Always set to the string "FAT32 +ype ". Please see the note for this + field in the FAT12/FAT16 section + earlier. This field has nothing to + do with FAT type determination. + +There is one other important note about Sector 0 of a FAT +volume. If we consider the contents of the sector as a byte +array, it must be true that sector[510] equals 0x55, and +sector[511] equals 0xAA. + +NOTE: Many FAT documents mistakenly say that this 0xAA55 +signature occupies the "last 2 bytes of the boot sector". +This statement is correct if - and only if - BPB_BytsPerSec +is 512. If BPB_BytsPerSec is greater than 512, the offsets +of these signature bytes do not change (although it is +perfectly OK for the last two bytes at the end of the boot +sector to also contain this signature). + +Check your assumptions about the value in the +BPB_TotSec16/32 field. Assume we have a disk or partition of +size in sectors DskSz. If the BPB TotSec field (either +BPB_TotSec16 or BPB_TotSec32 - whichever is non-zero) is +less than or equal to DskSz, there is nothing whatsoever +wrong with the FAT volume. In fact, it is not at all unusual +to have a BPB_TotSec16/32 value that is slightly smaller +than DskSz. It is also perfectly OK for the BPB_TotSec16/32 +value to be considerably smaller than DskSz. + +All this means is that disk space is being wasted. It does +not by itself mean that the FAT volume is damaged in some +way. However, if BPB_TotSec16/32 is larger than DskSz, the +volume is seriously damaged or malformed because it extends +past the end of the media or overlaps data that follows it +on the disk. Treating a volume for which the BPB_TotSec16/32 +value is "too large" for the media or partition as valid can +lead to catastrophic data loss. + +FAT Data Structure +The next data structure that is important is the FAT itself. +What this data structure does is define a singly linked list +of the "extents" (clusters) of a file. Note at this point +that a FAT directory or file container is nothing but a +regular file that has a special attribute indicating it is a +directory. The only other special thing about a directory is +that the data or contents of the "file" is a series of +32=byte FAT directory entries (see discussion below). In all +other respects, a directory is just like a file. The FAT +maps the data region of the volume by cluster number. The +first data cluster is cluster 2. + +The first sector of cluster 2 (the data region of the disk) +is computed using the BPB fields for the volume as follows. +First, we determine the count of sectors occupied by the +root directory: + +RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec - +1)) / BPB_BytsPerSec; + +Note that on a FAT32 volume the BPB_RootEntCnt value is +always 0, so on a FAT32 volume RootDirSectors is always 0. +The 32 in the above is the size of one FAT directory entry +in bytes. Note also that this computation rounds up. + +The start of the data region, the first sector of cluster 2, +is computed as follows: + +If(BPB_FATSz16 != 0) + FATSz = BPB_FATSz16; +Else + FATSz = BPB_FATSz32; + +FirstDataSector = BPB_ResvdSecCnt + (BPB_NumFATs * FATSz) + +RootDirSectors; + +NOTE: This sector number is relative to the first sector of +the volume that contains the BPB (the sector that contains +the BPB is sector number 0). This does not necessarily map +directly onto the drive, because sector 0 of the volume is +not necessarily sector 0 of the drive due to partitioning. + +Given any valid data cluster number N, the sector number of +the first sector of that cluster (again relative to sector 0 +of the FAT volume) is computed as follows: + +FirstSectorofCluster = ((N - 2) * BPB_SecPerClus) + +FirstDataSector; + +NOTE: Because BPB_SecPerClus is restricted to powers of 2 +(1,2,4,8,16,32..), this means that division and +multiplication by BPB_SecPerClus can actually be performed +via SHIFT operations on 2s complement architectures that are +usually faster instructions than MULT and DIV instructions. +On current Intel X86 processors, this is largely irrelevant +though because the MULT and DIV machine instructions are +heavily optimized for multiplication and division by powers +of 2. + +FAT Type Determination +There is considerable confusion over exactly how this works, +which leads to many "off by 1", "off by 2", "off by 10", and +"massively off" errors. It is really quite simple how this +works. The FAT type-one of FAT12, FAT16, or FAT32-is +determined by the count of clusters on the volume and +nothing else. + +Please read everything in this section carefully, all of the +words are important. For example, note that the statement +was "count of clusters." This is not the same thing as +"maximum valid cluster number," because the first data +cluster is 2 and not 0 or 1. + +To begin, let's discuss exactly how the "count of clusters" +value is determined. This is all done using the BPB fields +for the volume. First, we determine the count of sectors +occupied by the root directory as noted earlier. + +RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec - +1)) / BPB_BytsPerSec; + +Note that on a FAT32 volume, the BPB_RootEntCnt value is +always 0; so on a FAT32 volume, RootDirSectors is always 0. + +Next, we determine the count of sectors in the data region +of the volume: + +If(BPB_FATSz16 != 0) + FATSz = BPB_FATSz16; +Else + FATSz = BPB_FATSz32; + +If(BPB_TotSec16 != 0) + TotSec = BPB_TotSec16; +Else + TotSec = BPB_TotSec32; + +DataSec = TotSec - (BPB_ResvdSecCnt + (BPB_NumFATs * FATSz) ++ RootDirSectors); + +Now we determine the count of clusters: + +CountofClusters = DataSec / BPB_SecPerClus; + +Please note that this computation rounds down. + +Now we can determine the FAT type. Please note carefully or +you will commit an off-by-one error! + +In the following example, when it says <, it does not mean +<=. Note also that the numbers are correct. The first number +for FAT12 is 4085; the second number for FAT16 is 65525. +These numbers and the '<' signs are not wrong. + +If(CountofClusters < 4085) { +/* Volume is FAT12 */ +} else if(CountofClusters < 65525) { + /* Volume is FAT16 */ +} else { + /* Volume is FAT32 */ +} + +This is the one and only way that FAT type is determined. +There is no such thing as a FAT12 volume that has more than +4084 clusters. There is no such thing as a FAT16 volume that +has less than 4085 clusters or more than 65,524 clusters. +There is no such thing as a FAT32 volume that has less than +65,525 clusters. If you try to make a FAT volume that +violates this rule, Microsoft operating systems will not +handle them correctly because they will think the volume has +a different type of FAT than what you think it does. + +NOTE: As is noted numerous times earlier, the world is full +of FAT code that is wrong. There is a lot of FAT type code +that is off by 1 or 2 or 8 or 10 or 16. For this reason, it +is highly recommended that if you are formatting a FAT +volume which has maximum compatibility with all existing FAT +code, then you should you avoid making volumes of any type +that have close to 4,085 or 65,525 clusters. Stay at least +16 clusters on each side away from these cut-over cluster +counts. + +Note also that the CountofClusters value is exactly that-the +count of data clusters starting at cluster 2. The maximum +valid cluster number for the volume is CountofClusters + 1, +and the "count of clusters including the two reserved +clusters" is CountofClusters + 2. + +There is one more important computation related to the FAT. +Given any valid cluster number N, where in the FAT(s) is the +entry for that cluster number? The only FAT type for which +this is complex is FAT12. For FAT16 and FAT32, the +computation is simple: + +If(BPB_FATSz16 != 0) + FATSz = BPB_FATSz16; + Else + FATSz = BPB_FATSz32; + +If(FATType == FAT16) + FATOffset = N * 2; +Else if (FATType == FAT32) + FATOffset = N * 4; + +ThisFATSecNum = BPB_ResvdSecCnt + (FATOffset / +BPB_BytsPerSec); +ThisFATEntOffset = REM(FATOffset / BPB_BytsPerSec); + +REM(.) is the remainder operator. That means the remainder +after division of FATOffset by BPB_BytsPerSec. ThisFATSecNum +is the sector number of the FAT sector that contains the +entry for cluster N in the first FAT. If you want the sector +number in the second FAT, you add FATSz to ThisFATSecNum; +for the third FAT, you add 2*FATSz, and so on. + +You now read sector number ThisFATSecNum (remember this is a +sector number relative to sector 0 of the FAT volume). +Assume this is read into an 8-bit byte array named SecBuff. +Also assume that the type WORD is a 16-bit unsigned and that +the type DWORD is a 32-bit unsigned. + +If(FATType == FAT16) + FAT16ClusEntryVal = *((WORD *) +&SecBuff[ThisFATEntOffset]); +Else + FAT32ClusEntryVal = (*((DWORD *) +&SecBuff[ThisFATEntOffset])) & 0x0FFFFFFF; + +Fetches the contents of that cluster. To set the contents of +this same cluster you do the following: + +If(FATType == FAT16) + *((WORD *) &SecBuff[ThisFATEntOffset]) = +FAT16ClusEntryVal; +Else { + FAT32ClusEntryVal = FAT32ClusEntryVal & 0x0FFFFFFF; + *((DWORD *) &SecBuff[ThisFATEntOffset]) = + (*((DWORD *) &SecBuff[ThisFATEntOffset])) & +0xF0000000; + *((DWORD *) &SecBuff[ThisFATEntOffset]) = + (*((DWORD *) &SecBuff[ThisFATEntOffset])) | +FAT32ClusEntryVal; +} + +Note how the FAT32 code above works. A FAT32 FAT entry is +actually only a 28-bit entry. The high 4 bits of a FAT32 FAT +entry are reserved. The only time that the high 4 bits of +FAT32 FAT entries should ever be changed is when the volume +is formatted, at which time the whole 32-bit FAT entry +should be zeroed, including the high 4 bits. + +A bit more explanation is in order here, because this point +about FAT32 FAT entries seems to cause a great deal of +confusion. Basically 32-bit FAT entries are not really 32- +bit values; they are only 28-bit values. For example, all of +these 32-bit cluster entry values: 0x10000000, 0xF0000000, +and 0x00000000 all indicate that the cluster is FREE, +because you ignore the high 4 bits when you read the cluster +entry value. If the 32-bit free cluster value is currently +0x30000000 and you want to mark this cluster as bad by +storing the value 0x0FFFFFF7 in it. Then the 32-bit entry +will contain the value 0x3FFFFFF7 when you are done, because +you must preserve the high 4 bits when you write in the +0x0FFFFFF7 bad cluster mark. + +Take note that because the BPB_BytsPerSec value is always +divisible by 2 and 4, you never have to worry about a FAT16 +or FAT32 FAT entry spanning over a sector boundary (this is +not true of FAT12). + +The code for FAT12 is more complicated because there are 1.5 +bytes (12-bits) per FAT entry. + + if (FATType == FAT12) + FATOffset = N + (N / 2); +/* Multiply by 1.5 without using floating point, the divide +by 2 rounds DOWN */ + + ThisFATSecNum = BPB_ResvdSecCnt + (FATOffset / +BPB_BytsPerSec); + ThisFATEntOffset = REM(FATOffset / BPB_BytsPerSec); + +We now have to check for the sector boundary case: + +If(ThisFATEntOffset == (BPB_BytsPerSec - 1)) { + /* This cluster access spans a sector boundary in the +FAT */ + /* There are a number of strategies to handling this. +The */ + /* easiest is to always load FAT sectors into memory +*/ + /* in pairs if the volume is FAT12 (if you want to load +*/ + /* FAT sector N, you also load FAT sector N+1 +immediately */ + /* following it in memory unless sector N is the last +FAT */ + /* sector). It is assumed that this is the strategy used +here */ + /* which makes this if test for a sector boundary span +*/ + /* unnecessary. +*/ +} + +We now access the FAT entry as a WORD just as we do for +FAT16, but if the cluster number is EVEN, we only want the +low 12-bits of the 16-bits we fetch; and if the cluster +number is ODD, we only want the high 12-bits of the 16-bits +we fetch. + + FAT12ClusEntryVal = *((WORD *) &SecBuff[ThisFATEntOffset]); + If(N & 0x0001) + FAT12ClusEntryVal = FAT12ClusEntryVal >> 4; /* Cluster +number is ODD */ + Else + FAT12ClusEntryVal = FAT12ClusEntryVal & 0x0FFF; /* +Cluster number is EVEN */ + +Fetches the contents of that cluster. To set the contents of +this same cluster you do the following: + +If(N & 0x0001) { + FAT12ClusEntryVal = FAT12ClusEntryVal << 4; /* Cluster +number is ODD */ + *((WORD *) &SecBuff[ThisFATEntOffset]) = + (*((WORD *) &SecBuff[ThisFATEntOffset])) & 0x000F; +} Else { + FAT12ClusEntryVal = FAT12ClusEntryVal & 0x0FFF; /* +Cluster number is EVEN */ + *((WORD *) &SecBuff[ThisFATEntOffset]) = + (*((WORD *) &SecBuff[ThisFATEntOffset])) & 0xF000; +} +*((WORD *) &SecBuff[ThisFATEntOffset]) = + (*((WORD *) &SecBuff[ThisFATEntOffset])) | +FAT12ClusEntryVal; + +NOTE: It is assumed that the >> operator shifts a bit value +of 0 into the high 4 bits and that the << operator shifts a +bit value of 0 into the low 4 bits. + +The way the data of a file is associated with the file is as +follows. In the directory entry, the cluster number of the +first cluster of the file is recorded. The first cluster +(extent) of the file is the data associated with this first +cluster number, and the location of that data on the volume +is computed from the cluster number as described earlier +(computation of FirstSectorofCluster). + +Note that a zero-length file-a file that has no data +allocated to it-has a first cluster number of 0 placed in +its directory entry. This cluster location in the FAT (see +earlier computation of ThisFATSecNum and ThisFATEntOffset) +contains either an EOC mark (End Of Clusterchain) or the +cluster number of the next cluster of the file. The EOC +value is FAT type dependant (assume FATContent is the +contents of the cluster entry in the FAT being checked to +see whether it is an EOC mark): + +IsEOF = FALSE; +If(FATType == FAT12) { + If(FATContent >= 0x0FF8) + IsEOF = TRUE; +} else if(FATType == FAT16) { + If(FATContent >= 0xFFF8) + IsEOF = TRUE; +} else if (FATType == FAT32) { + If(FATContent >= 0x0FFFFFF8) + IsEOF = TRUE; +} + +Note that the cluster number whose cluster entry in the FAT +contains the EOC mark is allocated to the file and is also +the last cluster allocated to the file. Microsoft operating +system FAT drivers use the EOC value 0x0FFF for FAT12, +0xFFFF for FAT16, and 0x0FFFFFFF for FAT32 when they set the +contents of a cluster to the EOC mark. There are various +disk utilities for Microsoft operating systems that use a +different value, however. + +There is also a special "BAD CLUSTER" mark. Any cluster that +contains the "BAD CLUSTER" value in its FAT entry is a +cluster that should not be placed on the free list because +it is prone to disk errors. The "BAD CLUSTER" value is +0x0FF7 for FAT12, 0xFFF7 for FAT16, and 0x0FFFFFF7 for +FAT32. The other relevant note here is that these bad +clusters are also lost clusters-clusters that appear to be +allocated because they contain a non-zero value but which +are not part of any files allocation chain. Disk repair +utilities must recognize lost clusters that contain this +special value as bad clusters and not change the content of +the cluster entry. + +NOTE: It is not possible for the bad cluster mark to be an +allocatable cluster number on FAT12 and FAT16 volumes, but +it is feasible for 0x0FFFFFF7 to be an allocatable cluster +number on FAT32 volumes. To avoid possible confusion by disk +utilities, no FAT32 volume should ever be configured such +that 0x0FFFFFF7 is an allocatable cluster number. + +The list of free clusters in the FAT is nothing more than +the list of all clusters that contain the value 0 in their +FAT cluster entry. Note that this value must be fetched as +described earlier as for any other FAT entry that is not +free. This list of free clusters is not stored anywhere on +the volume; it must be computed when the volume is mounted +by scanning the FAT for entries that contain the value 0. On +FAT32 volumes, the BPB_FSInfo sector may contain a valid +count of free clusters on the volume. See the documentation +of the FAT32 FSInfo sector. + +What are the two reserved clusters at the start of the FAT +for? The first reserved cluster, FAT[0], contains the +BPB_Media byte value in its low 8 bits, and all other bits +are set to 1. For example, if the BPB_Media value is 0xF8, +for FAT12 FAT[0] = 0x0FF8, for FAT16 FAT[0] = 0xFFF8, and +for FAT32 FAT[0] = 0x0FFFFFF8. The second reserved cluster, +FAT[1], is set by FORMAT to the EOC mark. On FAT12 volumes, +it is not used and is simply always contains an EOC mark. +For FAT16 and FAT32, the file system driver may use the high +two bits of the FAT[1] entry for dirty volume flags (all +other bits, are always left set to 1). Note that the bit +location is different for FAT16 and FAT32, because they are +the high 2 bits of the entry. + +For FAT16: + ClnShutBitMask = 0x8000; + HrdErrBitMask = 0x4000; + +For FAT32: + ClnShutBitMask = 0x08000000; + HrdErrBitMask = 0x04000000; + +Bit ClnShutBitMask - If bit is 1, volume is "clean". + If bit is 0, volume is "dirty". This + indicates that the file system driver did not + Dismount the volume properly the last time it + had the volume mounted. It would be a good + idea to run a Chkdsk/Scandisk disk repair + utility on it, because it may be damaged. +Bit HrdErrBitMask - If this bit is 1, no disk read/write + errors were encountered. + If this bit is 0, the file system driver + encountered a disk I/O error on the Volume + the last time it was mounted, which is an + indicator that some sectors may have gone bad + on the volume. It would be a good idea to run + a Chkdsk/Scandisk disk repair utility that + does surface analysis on it to look for new + bad sectors. + +Here are two more important notes about the FAT region of a +FAT volume: + 1. The last sector of the FAT is not necessarily all part + of the FAT. The FAT stops at the cluster number in the last + FAT sector that corresponds to the entry for cluster number + CountofClusters + 1 (see the CountofClusters computation + earlier), and this entry is not necessarily at the end of + the last FAT sector. FAT code should not make any + assumptions about what the contents of the last FAT sector + are after the CountofClusters + 1 entry. FAT format code + should zero the bytes after this entry though. + 2. The BPB_FATSz16 (BPB_FATSz32 for FAT32 volumes) value + may be bigger than it needs to be. In other words, there may + be totally unused FAT sectors at the end of each FAT in the + FAT region of the volume. For this reason, the last sector + of the FAT is always computed using the CountofClusters + 1 + value, never from the BPB_FATSz16/32 value. FAT code should + not make any assumptions about what the contents of these + "extra" FAT sectors are. FAT format code should zero the + contents of these extra FAT sectors though. + +FAT Volume Initialization +At this point, the careful reader should have one very +interesting question. Given that the FAT type (FAT12, FAT16, +or FAT32) is dependant on the number of clusters-and that +the sectors available in the data area of a FAT volume is +dependant on the size of the FAT-when handed an unformatted +volume that does not yet have a BPB, how do you determine +all this and compute the proper values to put in +BPB_SecPerClus and either BPB_FATSz16 or BPB_FATSz32? The +way Microsoft operating systems do this is with a fixed +value, several tables, and a clever piece of arithmetic. + +Microsoft operating systems only do FAT12 on floppy disks. +Because there is a limited number of floppy formats that all +have a fixed size, this is done with a simple table: + + "If it is a floppy of this type, then the BPB looks like +this." + +There is no dynamic computation for FAT12. For the FAT12 +formats, all the computation for BPB_SecPerClus and +BPB_FATSz16 was worked out by hand on a piece of paper and +recorded in the table (being careful of course that the +resultant cluster count was always less than 4085). If your +media is larger than 4 MB, do not bother with FAT12. Use +smaller BPB_SecPerClus values so that the volume will be +FAT16. + +The rest of this section is totally specific to drives that +have 512 bytes per sector. You cannot use these tables, or +the clever arithmetic, with drives that have a different +sector size. The "fixed value" is simply a volume size that +is the "FAT16 to FAT32 cutover value". Any volume size +smaller than this is FAT16 and any volume of this size or +larger is FAT32. For Windows, this value is 512 MB. Any FAT +volume smaller than 512 MB is FAT16, and any FAT volume of +512 MB or larger is FAT32. + +Please don't draw an incorrect conclusion here. + +There are many FAT16 volumes out there that are larger than +512 MB. There are various ways to force the format to be +FAT16 rather than the default of FAT32, and there is a great +deal of code that implements different limits. All we are +talking about here is the default cutover value for MS-DOS +and Windows on volumes that have not yet been formatted. +There are two tables-one is for FAT16 and the other is for +FAT32. An entry in these tables is selected based on the +size of the volume in 512 byte sectors (the value that will +go in BPB_TotSec16 or BPB_TotSec32), and the value that this +table sets is the BPB_SecPerClus value. + + struct DSKSZTOSECPERCLUS { + DWORD DiskSize; + BYTE SecPerClusVal; + }; + + /* +*This is the table for FAT16 drives. NOTE that this table +includes +* entries for disk sizes larger than 512 MB even though +typically +* only the entries for disks < 512 MB in size are used. +* The way this table is accessed is to look for the first +entry +* in the table for which the disk size is less than or equal +* to the DiskSize field in that table entry. For this table +to +* work properly BPB_RsvdSecCnt must be 1, BPB_NumFATs +* must be 2, and BPB_RootEntCnt must be 512. Any of these +values +* being different may require the first table entries +DiskSize value +* to be changed otherwise the cluster count may be to low for FAT16. + */ + DSKSZTOSECPERCLUS DskTableFAT16 [] = { + { 8400, 0}, /* disks up to 4.1 MB, the 0 value for +SecPerClusVal trips an error */ + { 32680, 2}, /* disks up to 16 MB, 1k +cluster */ + { 262144, 4}, /* disks up to 128 MB, 2k +cluster */ + { 524288, 8}, /* disks up to 256 MB, 4k +cluster */ + { 1048576, 16}, /* disks up to 512 MB, 8k +cluster */ + /* The entries after this point are not used unless +FAT16 is forced */ + { 2097152, 32}, /* disks up to 1 GB, 16k +cluster */ + { 4194304, 64}, /* disks up to 2 GB, 32k +cluster */ + { 0xFFFFFFFF, 0} /* any disk greater than 2GB, 0 value for +SecPerClusVal trips an error */ + }; + +/* +* This is the table for FAT32 drives. NOTE that this table +includes +* entries for disk sizes smaller than 512 MB even though +typically +* only the entries for disks >= 512 MB in size are used. +* The way this table is accessed is to look for the first +entry +* in the table for which the disk size is less than or equal +* to the DiskSize field in that table entry. For this table +to +* work properly BPB_RsvdSecCnt must be 32, and BPB_NumFATs +* must be 2. Any of these values being different may require +the first +* table entries DiskSize value to be changed otherwise the +cluster count +* may be to low for FAT32. +*/ + DSKSZTOSECPERCLUS DskTableFAT32 [] = { + { 66600, 0}, /* disks up to 32.5 MB, the 0 value for +SecPerClusVal trips an error */ + { 532480, 1}, /* disks up to 260 MB, .5k +cluster */ + { 16777216, 8}, /* disks up to 8 GB, 4k +cluster */ + { 33554432, 16}, /* disks up to 16 GB, 8k +cluster */ + { 67108864, 32}, /* disks up to 32 GB, 16k +cluster */ + { 0xFFFFFFFF, 64}/* disks greater than 32GB, 32k +cluster */ + }; + +So given a disk size and a FAT type of FAT16 or FAT32, we +now have a BPB_SecPerClus value. The only thing we have left +is do is to compute how many sectors the FAT takes up so +that we can set BPB_FATSz16 or BPB_FATSz32. Note that at +this point we assume that BPB_RootEntCnt, BPB_RsvdSecCnt, +and BPB_NumFATs are appropriately set. We also assume that +DskSize is the size of the volume that we are either going +to put in BPB_TotSec32 or BPB_TotSec16. + +RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec - +1)) / BPB_BytsPerSec; +TmpVal1 = DskSize - (BPB_ResvdSecCnt + RootDirSectors); +TmpVal2 = (256 * BPB_SecPerClus) + BPB_NumFATs; +If(FATType == FAT32) + TmpVal2 = TmpVal2 / 2; +FATSz = (TMPVal1 + (TmpVal2 - 1)) / TmpVal2; +If(FATType == FAT32) { + BPB_FATSz16 = 0; + BPB_FATSz32 = FATSz; +} else { + BPB_FATSz16 = LOWORD(FATSz); + /* there is no BPB_FATSz32 in a FAT16 BPB */ +} + +Do not spend too much time trying to figure out why this +math works. The basis for the computation is complicated; +the important point is that this is how Microsoft operating +systems do it, and it works. Note, however, that this math +does not work perfectly. It will occasionally set a FATSz +that is up to 2 sectors too large for FAT16, and +occasionally up to 8 sectors too large for FAT32. It will +never compute a FATSz value that is too small, however. +Because it is OK to have a FATSz that is too large, at the +expense of wasting a few sectors, the fact that this +computation is surprisingly simple more than makes up for it +being off in a safe way in some cases. + +FAT32 FSInfo Sector Structure and Backup Boot Sector +On a FAT32 volume, the FAT can be a large data structure, +unlike on FAT16 where it is limited to a maximum of 128K +worth of sectors and FAT12 where it is limited to a maximum +of 6K worth of sectors. For this reason, a provision is made +to store the "last known" free cluster count on the FAT32 +volume so that it does not have to be computed as soon as an +API call is made to ask how much free space there is on the +volume (like at the end of a directory listing). The FSInfo +sector number is the value in the BPB_FSInfo field; for +Microsoft operating systems it is always set to 1. Here is +the structure of the FSInfo sector: + +FAT32 FSInfo Sector Structure and Backup Boot Sector +Name Offs Size Description + et (byt + (byt es) + e) +FSI_LeadSi 0 4 Value 0x41615252. This lead +g signature is used to validate that + this is in fact an FSInfo sector. +FSI_Reserv 4 480 This field is currently reserved +ed1 for future expansion. FAT32 format + code should always initialize all + bytes of this field to 0. Bytes in + this field must currently never be + used. +FSI_StrucS 484 4 Value 0x61417272. Another +ig signature that is more localized + in the sector to the location of + the fields that are used. +FSI_Free_C 488 4 Contains the last known free +ount cluster count on the volume. If + the value is 0xFFFFFFFF, then the + free count is unknown and must be + computed. Any other value can be + used, but is not necessarily + correct. It should be range + checked at least to make sure it + is <= volume cluster count. +FSI_Nxt_Fr 492 4 This is a hint for the FAT driver. +ee It indicates the cluster number at + which the driver should start + looking for free clusters. Because + a FAT32 FAT is large, it can be + rather time consuming if there are + a lot of allocated clusters at the + start of the FAT and the driver + starts looking for a free cluster + starting at cluster 2. Typically + this value is set to the last + cluster number that the driver + allocated. If the value is + 0xFFFFFFFF, then there is no hint + and the driver should start + looking at cluster 2. Any other + value can be used, but should be + checked first to make sure it is a + valid cluster number for the + volume. +FSI_Reserv 496 12 This field is currently reserved +ed2 for future expansion. FAT32 format + code should always initialize all + bytes of this field to 0. Bytes in + this field must currently never be + used. +FSI_TrailS 508 4 Value 0xAA550000. This trail +ig signature is used to validate that + this is in fact an FSInfo sector. + Note that the high 2 bytes of this + value-which go into the bytes at + offsets 510 and 511-match the + signature bytes used at the same + offsets in sector 0. + +Another feature on FAT32 volumes that is not present on +FAT16/FAT12 is the BPB_BkBootSec field. FAT16/FAT12 volumes +can be totally lost if the contents of sector 0 of the +volume are overwritten or sector 0 goes bad and cannot be +read. This is a "single point of failure" for FAT16 and +FAT12 volumes. The BPB_BkBootSec field reduces the severity +of this problem for FAT32 volumes, because starting at that +sector number on the volume-6-there is a backup copy of the +boot sector information including the volume's BPB. + +In the case where the sector 0 information has been +accidentally overwritten, all a disk repair utility has to +do is restore the boot sector(s) from the backup copy. In +the case where sector 0 goes bad, this allows the volume to +be mounted so that the user can access data before replacing +the disk. + +This second case-sector 0 goes bad-is the reason why no +value other than 6 should ever be placed in the +BPB_BkBootSec field. If sector 0 is unreadable, various +operating systems are "hard wired" to check for backup boot +sector(s) starting at sector 6 of the FAT32 volume. Note +that starting at the BPB_BkBootSec sector is a complete boot +record. The Microsoft FAT32 "boot sector" is actually three +512-byte sectors long. There is a copy of all three of these +sectors starting at the BPB_BkBootSec sector. A copy of the +FSInfo sector is also there, even though the BPB_FSInfo +field in this backup boot sector is set to the same value as +is stored in the sector 0 BPB. + +NOTE: All 3 of these sectors have the 0xAA55 signature in +sector offsets 510 and 511, just like the first boot sector +does (see the earlier discussion at the end of the BPB +structure description). + +FAT Directory Structure +This is the most simple explanation of FAT directory +entries. This document totally ignores the Long File Name +architecture and only talks about short directory entries. +For a more complete description of FAT directory structure, +see the document "FAT: Long Name On-Media Format +Specification". + +A FAT directory is nothing but a "file" composed of a linear +list of 32-byte structures. The only special directory, +which must always be present, is the root directory. For +FAT12 and FAT16 media, the root directory is located in a +fixed location on the disk immediately following the last +FAT and is of a fixed size in sectors computed from the +BPB_RootEntCnt value (see computations for RootDirSectors +earlier in this document). For FAT12 and FAT16 media, the +first sector of the root directory is sector number relative +to the first sector of the FAT volume: + +FirstRootDirSecNum = BPB_ResvdSecCnt + (BPB_NumFATs * +BPB_FATSz16); + +For FAT32, the root directory can be of variable size and is +a cluster chain, just like any other directory is. The first +cluster of the root directory on a FAT32 volume is stored in +BPB_RootClus. Unlike other directories, the root directory +itself on any FAT type does not have any date or time +stamps, does not have a file name (other than the implied +file name "\"), and does not contain "." and ".." files as +the first two directory entries in the directory. The only +other special aspect of the root directory is that it is the +only directory on the FAT volume for which it is valid to +have a file that has only the ATTR_VOLUME_ID attribute bit +set (see below). + +FAT 32 Byte Directory Entry Structure +Name Offs Size Description + et (byt + (byt es) + e) +DIR_Name 0 11 Short name. +DIR_Attr 11 1 File attributes: + ATTR_READ_ONLY 0x01 + ATTR_HIDDEN 0x02 + ATTR_SYSTEM 0x04 + ATTR_VOLUME_ID 0x08 + ATTR_DIRECTORY 0x10 + ATTR_ARCHIVE 0x20 + ATTR_LONG_NAME ATTR_READ_ON + LY | + ATTR_HIDDEN + | + ATTR_SYSTEM + | + ATTR_VOLUME_ + ID + The upper two bits of the + attribute byte are reserved and + should always be set to 0 when + a file is created and never + modified or looked at after + that. +DIR_NTRes 12 1 Reserved for use by Windows NT. + Set value to 0 when a file is + created and never modify or + look at it after that. +DIR_CrtTimeT 13 1 Millisecond stamp at file +enth creation time. This field + actually contains a count of + tenths of a second. The + granularity of the seconds part + of DIR_CrtTime is 2 seconds so + this field is a count of tenths + of a second and its valid value + range is 0-199 inclusive. +DIR_CrtTime 14 2 Time file was created. +DIR_CrtDate 16 2 Date file was created. +DIR_LstAccDa 18 2 Last access date. Note that +te there is no last access time, + only a date. This is the date + of last read or write. In the + case of a write, this should be + set to the same date as + DIR_WrtDate. +DIR_FstClusH 20 2 High word of this entry's first +I cluster number (always 0 for a + FAT12 or FAT16 volume). +DIR_WrtTime 22 2 Time of last write. Note that + file creation is considered a + write. +DIR_WrtDate 24 2 Date of last write. Note that + file creation is considered a + write. +DIR_FstClusL 26 2 Low word of this entry's first +O cluster number. +DIR_FileSize 28 4 32-bit DWORD holding this + file's size in bytes. + + +DIR_Name[0] +Special notes about the first byte (DIR_Name[0]) of a FAT +directory entry: + +� If DIR_Name[0] == 0xE5, then the directory entry is + free (there is no file or directory name in this entry). + +� If DIR_Name[0] == 0x00, then the directory entry is + free (same as for 0xE5), and there are no allocated + directory entries after this one (all of the DIR_Name[0] + bytes in all of the entries after this one are also set to + 0). + + The special 0 value, rather than the 0xE5 value, indicates + to FAT file system driver code that the rest of the + entries in this directory do not need to be examined + because they are all free. + +� If DIR_Name[0] == 0x05, then the actual file name + character for this byte is 0xE5. 0xE5 is actually a valid + KANJI lead byte value for the character set used in Japan. + The special 0x05 value is used so that this special file + name case for Japan can be handled properly and not cause + FAT file system code to think that the entry is free. + +The DIR_Name field is actually broken into two parts+ the 8- +character main part of the name, and the 3-character +extension. These two parts are "trailing space padded" with +bytes of 0x20. + +DIR_Name[0] may not equal 0x20. There is an implied '.' +character between the main part of the name and the +extension part of the name that is not present in DIR_Name. +Lower case characters are not allowed in DIR_Name (what +these characters are is country specific). + +The following characters are not legal in any bytes of +DIR_Name: +� Values less than 0x20 except for the special case of + 0x05 in DIR_Name[0] described above. +� 0x22, 0x2A, 0x2B, 0x2C, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, +0x3D, 0x3E, 0x3F, 0x5B, 0x5C, 0x5D, and 0x7C. + +Here are some examples of how a user-entered name maps into +DIR_Name: + +"foo.bar" -> "FOO BAR" +"FOO.BAR" -> "FOO BAR" +"Foo.Bar" -> "FOO BAR" +"foo" -> "FOO " +"foo." -> "FOO " +"PICKLE.A" -> "PICKLE A " +"prettybg.big" -> "PRETTYBGBIG" +".big" -> illegal, DIR_Name[0] cannot be 0x20 + +In FAT directories all names are unique. Look at the first +three examples earlier. Those different names all refer to +the same file, and there can only be one file with DIR_Name +set to "FOO BAR" in any directory. + +DIR_Attr specifies attributes of the file: + + ATTR_READ_ONLY Indicates that writes to the file should + fail. + ATTR_HIDDEN Indicates that normal directory listings + should not show this file. + ATTR_SYSTEM Indicates that this is an operating + system file. + ATTR_VOLUME_ID There should only be one "file" on the + volume that has this attribute set, and + that file must be in the root directory. + This name of this file is actually the + label for the volume. DIR_FstClusHI and + DIR_FstClusLO must always be 0 for the + volume label (no data clusters are + allocated to the volume label file). + ATTR_DIRECTORY Indicates that this file is actually a + container for other files. + ATTR_ARCHIVE This attribute supports backup + utilities. This bit is set by the FAT + file system driver when a file is + created, renamed, or written to. Backup + utilities may use this attribute to + indicate which files on the volume have + been modified since the last time that a + backup was performed. + +Note that the ATTR_LONG_NAME attribute bit combination +indicates that the "file" is actually part of the long name +entry for some other file. See the FAT Long Filename +specification for more information on this attribute +combination. + +When a directory is created, a file with the ATTR_DIRECTORY +bit set in its DIR_Attr field, you set its DIR_FileSize to +0. DIR_FileSize is not used and is always 0 on a file with +the ATTR_DIRECTORY attribute (directories are sized by +simply following their cluster chains to the EOC mark). One +cluster is allocated to the directory (unless it is the root +directory on a FAT16/FAT12 volume), and you set +DIR_FstClusLO and DIR_FstClusHI to that cluster number and +place an EOC mark in that clusters entry in the FAT. Next, +you initialize all bytes of that cluster to 0. If the +directory is the root directory, you are done (there are no +dot or dotdot entries in the root directory). If the +directory is not the root directory, you need to create two +special entries in the first two 32-byte directory entries +of the directory (the first two 32 byte entries in the data +region of the cluster you just allocated). + +The first directory entry has DIR_Name set to: +". " + +The second has DIR_Name set to: +".. " + +These are called the dot and dotdot entries. The +DIR_FileSize field on both entries is set to 0, and all of +the date and time fields in both of these entries are set to +the same values as they were in the directory entry for the +directory that you just created. You now set DIR_FstClusLO +and DIR_FstClusHI for the dot entry (the first entry) to the +same values you put in those fields for the directories +directory entry (the cluster number of the cluster that +contains the dot and dotdot entries). + +Finally, you set DIR_FstClusLO and DIR_FstClusHI for the +dotdot entry (the second entry) to the first cluster number +of the directory in which you just created the directory +(value is 0 if this directory is the root directory even for +FAT32 volumes). + +Here is the summary for the dot and dotdot entries: +� The dot entry is a directory that points to itself. +� The dotdot entry points to the starting cluster of the + parent of this directory (which is 0 if this directories + parent is the root directory). + +Date and Time Formats +Many FAT file systems do not support Date/Time other than +DIR_WrtTime and DIR_WrtDate. For this reason, +DIR_CrtTimeMil, DIR_CrtTime, DIR_CrtDate, and DIR_LstAccDate +are actually optional fields. DIR_WrtTime and DIR_WrtDate +must be supported, however. If the other date and time +fields are not supported, they should be set to 0 on file +create and ignored on other file operations. + +Date Format. A FAT directory entry date stamp is a 16-bit +field that is basically a date relative to the MS-DOS epoch +of 01/01/1980. Here is the format (bit 0 is the LSB of the +16-bit word, bit 15 is the MSB of the 16-bit word): + + Bits 0-4: Day of month, valid value range 1-31 + inclusive. + Bits 5-8: Month of year, 1 = January, valid value range + 1-12 inclusive. + Bits 9-15: Count of years from 1980, valid value range + 0-127 inclusive (1980-2107). + +Time Format. A FAT directory entry time stamp is a 16-bit +field that has a granularity of 2 seconds. Here is the +format (bit 0 is the LSB of the 16-bit word, bit 15 is the +MSB of the 16-bit word). + + Bits 0-4: 2-second count, valid value range 0-29 + inclusive (0 - 58 seconds). + Bits 5-10: Minutes, valid value range 0-59 inclusive. + Bits 11-15: Hours, valid value range 0-23 inclusive. + +The valid time range is from Midnight 00:00:00 to 23:59:58. + +Other Notes Relating to FAT Directories +� Long File Name directory entries are identical on all + FAT types. See the FAT Long File Name Specification for + details. + +� DIR_FileSize is a 32-bit field. For FAT32 volumes, your + FAT file system driver must not allow a cluster chain to be + created that is longer than 0x100000000 bytes, and the last + byte of the last cluster in a chain that long cannot be + allocated to the file. This must be done so that no file has + a file size > 0xFFFFFFFF bytes. This is a fundamental limit + of all FAT file systems. The maximum allowed file size on a + FAT volume is 0xFFFFFFFF (4,294,967,295) bytes. + +� Similarly, a FAT file system driver must not allow a + directory (a file that is actually a container for other + files) to be larger than 65,536 * 32 (2,097,152) bytes. + + NOTE: This limit does not apply to the number of files in + the directory. This limit is on the size of the directory + itself and has nothing to do with the content of the + directory. There are two reasons for this limit: + + 1. Because FAT directories are not sorted or indexed, it + is a bad idea to create huge directories; otherwise, + operations like creating a new entry (which requires every + allocated directory entry to be checked to verify that the + name doesn't already exist in the directory) become very + slow. + 2. There are many FAT file system drivers and disk + utilities, including Microsoft's, that expect to be able to + count the entries in a directory using a 16-bit WORD + variable. For this reason, directories cannot have more than + 16-bits worth of entries. + +Specification Compliance +Compliance with this specification is defined by testing on +the FAT reference operating system(s). The reference +operating systems for FAT are Microsoft Windows 98 and +Microsoft Windows 2000 (based on NT Technology). + +Your FAT volume is in compliance with this specification if +and only if both of the reference operating systems will +mount the volume, check it for errors using the operating +system supplied disk tools (Chkdsk.exe for Windows 2000 and +Scandisk.exe for Windows 98) and fail to find any errors. +The basic procedure is to manufacture a FAT volume using +your system and tools and then move the disk, or disk media +for a removable drive, to a computer running the reference +operating systems and test it. + diff --git a/mobius/doc/txt/fatFilesystem.txt b/mobius/doc/txt/fatFilesystem.txt new file mode 100644 index 0000000..32a3658 --- /dev/null +++ b/mobius/doc/txt/fatFilesystem.txt @@ -0,0 +1,169 @@ +By: Inbar Raz +-------------------------------------------------------------------- + + The FAT is a linked-list table that DOS uses to keep track of the physical + position of data on a disk and for locating free space for storing new files. + + The word at offset 1aH in a directory entry is a cluster number of the first + cluster in an allocation chain. If you locate that cell in the FAT, it will + either indicate the end of the chain or the next cell, etc. Observe: + + starting cluster number --| +Directory +-------------------+-+-------------------+---+---+-+-+-------+ + Entry -- |M Y F I L E T X T|a| |tim|dat|08 | size | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|-+-+-+-+-+ + +-------------------------+ + 00 01 02 03 04 05 06 07 |8 09 0a 0b 0c 0d 0e 0f + +--++--++--++--++--++--++--++--++-++--++--++--++--++--++--++--+ +00 |ID||ff||03-04-05-ff||00||00||09-0a-0b-15||00||00||00||00| + +--++--++--++--++--++--++--++--++--++--++--++|-++--++--++--++--+ + +-----------------------+ + +--++--++--++--++--++-++--++--++--++--++--++--++--++--++--++--+ +10 |00||00||00||00||00||16-17-19||f7||1a-1b-ff||00||00||00||00| + +--++--++--++--++--++--++--++|-++--++-++--++--++--++--++--++--+ + +-------+ +This diagram illustrates the main concepts of reading the FAT. In it: +� The file MYFILE.TXT is 10 clusters long. The first byte is in cluster 08 + and the last is in cluster 1bH. The chain is 8,9,0a,0b,15,16,17,19,1a,1b. + Each entry indicates the next entry in the chain, with a special code in + the last entry. +� Cluster 18H is marked bad and is not part of any allocation chain. +� Clusters 6,7, 0cH-14H, and 1cH-1fH are empty and available for allocation. +� Another chain starts at cluster 2 and ends at cluster 5. + ++-----------+ +| FAT Facts | The FAT normally starts at logical sector 1 in the DOS partition ++-----------+ (eg, you can read it with INT 25H with DX=1). The only way to + be sure is to read the boot sector (DX=0), and examine offset 0eH. This + tells how many boot and reserved sectors come before the FAT. Use that + number (usually 1) in DX to read the FAT via INT 25H. + + There may be more than one copy of the FAT. There are usually two complete + copies. If there are two or more, they will all be adjacent (the second FAT + directly follows the first). + + You have the following services available to help you determine information + about the FAT: + + � Use INT 25H to read the Boot Sector and examine the data fields therein + � Use DOS Fn 36H or 1cH to determine total disk sectors and clusters + � Use DOS Fn 44H (if the device driver supports Generic IOCTL) DOS 3.2 + � Use DOS Fn 32H to get all kinds of useful information. UNDOCUMENTED + + Note: The boot sector of non-booting disks (such as network block devices + and very old hard disks) may contain nothing but garbage. + ++---------------+ +| 12-bit/16-bit | The FAT can be laid out in 12-bit or 16-bit entries. 12-bit ++---------------+ entries are very efficient for media less than 384K--the + entire FAT can fit in a single 512-byte disk sector. For larger media, each + FAT entry must map to a larger and larger cluster size--to the point where a + 20M hard disk would need to allocate in units of 16 sectors in order to use + the 12-bit format (in other words, a 1-byte file would take up a full 8K + cluster of a disk). + + 16-bit FAT entries were introduced with DOS 3.0 with the necessity of + efficient handling the AT's 20-Megabyte hard disk. However, floppy disks + and 10M hard disks continue to use the 12-bit layout. You can determine if + the FAT is laid out with 12-bit or 16-bit elements: + + DOS 3.0 says: If a disk has more than 4086 (0ff6H) clusters, it uses 16 bits + (4096 is max value for a 12-bit number and >0ff6H is reserved) + DOS 3.2 says: If a disk has more than 20740 (5104H) SECTORS, it uses 16 bits + (in other words, any disk over 10 Megabytes uses a 16-bit FAT + and all others--including large RAM disks--use 12-bits). + +Note: It's a common misconception that the 16-bit FAT allows DOS to work with + disks larger than 32 Megabytes. In fact, the limiting factor is that + INT 25H/26H (through which DOS performs its disk I/O) in unable to + access a SECTOR number higher than 65535. Normally, sectors are 512 + bytes (�-K), so that sets the 32M limit. + + In DOS 4.0, INT 25H/26H supports a technique for accessing sector + numbers + higher than 65535, and thus supports trans-32M DOS partitions. This + has no effect on the layout of the FAT itself. Using 16-bit FAT + entries and 4-sector clusters, DOS now supports partitions up to 134M + (twice that for 8-sector clusters, etc.). + ++-----------------+ +| Reading the FAT | To read the value of any entry in a FAT (as when following ++-----------------+ a FAT chain), first read the entire FAT into memory and + obtain a starting cluster number from a directory. Then, for 12-bit entries: + ============== +� Multiply the cluster number by 3 =| +� Divide the result by 2 =========+= (each entry is 1.5 (3/2) bytes long) +� Read the WORD at the resulting address (as offset from the start of the FAT) +� If the cluster was even, mask the value by 0fffH (keep the low 12 bits) + If the cluster number was odd, shift the value right by 4 bits (keep the + upper 12 bits) +� The result is the entry for the next cluster in the chain (0fffH=the end). + +Note: A 12-bit entry can cross over a sector boundary, so be careful with + 1-sector FAT buffering schemes. + + 16-bit entries are simpler--each entry contains the 16-bit offset (from the + start of the FAT) of the next entry in the chain (0ffffH indicates the end). + ++-------------+ +| FAT Content | The first byte of the FAT is called the Media Descriptor or ++-------------+ FAT ID byte. The next 5 bytes (12-bit FATs) or 7 bytes + (16-bit FATs) are 0ffH. The rest of the FAT is composed of 12-bit or 16-bit + cells that each represent one disk cluster. These cells will contain one of + the following values: + + � (0)000H ................... an available cluster + � (f)ff0H through (f)ff7H ... a reserved cluster + � (f)ff7H ................... a bad cluster + � (f)ff8H through (f)fffH ... the end of an allocation chain + � (0)002H through (f)fefH ... the number of the next cluster in a chain + +Note: the high nibble of the value is used only in 16-bit FATs; eg, a bad + cluster is marked with 0ff7H in 12-bit FATs, and fff7H with 16-bit FATs. + ++------------------------------------------------+ +| Converting a Cluster Number to a Sector Number | After you obtain a file's ++------------------------------------------------+ starting cluster number + from a directory entry you will want to locate to actual disk sector that + holds the file (or subdirectory) data. + + A diskette (or a DOS partition of a hard disk) is laid out like so: + + � Boot and reserved sector(s) + � FAT #1 + � FAT #2 (optional -- not used on RAM disks) + � root directory + � data area (all file data reside here, including files for directories) + + Every section of this layout is variable and the sizes of each section must + be known in order to perform a correct cluster-to-sector conversion. The + following formulae represent the only documented method of determining a DOS + logical sector number from a cluster number: + + RootDirSectors = sectorBytes / (rootDirEntries * 32) + FatSectors = fatCount * sectorsPerFat + DataStart = reservedSectors + fatSectors + rootDirSectors + + INT 25h/26h Sector = DataStart + ((AnyClusterNumber-2) * sectorsPerCluster) + +Where the variables: + + sectorBytes sectorsPerFat fatCount + rootDirEntries reservedSectors sectorsPerCluster + + are obtained from the Boot Sector or from a BPB (if you can get access). The + resulting sector number can be used in DX for INT 25H/26H DOS absolute disk + access. + + If you are a daring sort of person, you can save trouble by using the + undocumented DOS Fn 32H (Get Disk Info) which provides a package of pre- + calculated data, including the sector number of the start of file data (it + gives you "DataStart", in the above equation). + + Author's note: The best use I've found for all this information is in + directory scanning; ie, to bypass the DOS file-searching services and read + directory sectors directly. For a program that must obtain a list of all + files and directories, direct access of directory sectors will work roughly + twice as fast as DOS Fns 4eH and 4fH. + + diff --git a/mobius/doc/txt/font.txt b/mobius/doc/txt/font.txt new file mode 100644 index 0000000..33548b5 --- /dev/null +++ b/mobius/doc/txt/font.txt @@ -0,0 +1,437 @@ +INF: Font-File Format [P_WinSDK] + +3.00 +WINDOWS +PSSONLY | Windows 3 Developer's Notes summary ENDUSER + +Summary: + +Note: This article is part of a set of seven articles, collectively +called the "Windows 3.00 Developer's Notes." More information about +the contents of the other articles, and procedures for ordering a +hard-copy set, can be found in the knowledge base article titled "INF: +The Windows 3.00 Developer's Notes" (Q65260). + +This article can be found in the Software/Data Library by searching on +the keyword FONTFMT or S12687. + +More Information: + +Formats for Microsoft Windows font files are defined for both raster +and vector fonts. These formats can be used by smart text generators +in some GDI support modules. The vector formats, in particular, are +more frequently used by GDI itself than by support modules. + + +Both raster and vector font files begin with information that is +common to both, and then continue with information that differs for +each type of file. + +For Windows 3.00, the font-file header includes six new fields: +dFlags, dfAspace, dfBspace, dfCspace, dfColorPointer, and dfReserved1. +These fields are not used in Windows 3.00. To ensure compatibility +with future versions of Windows, these fields should be set to zero. + +All device drivers support the Windows 2.x fonts. However, not all +device drivers support the Windows 3.00 version. + +Windows 3.00 font files include the glyph table in dfCharTable, which +consists of structures that describe the bits for characters in the +font file. This version enables fonts to exceed 64K in size, the size +limit of Windows 2.x fonts. This is made possible by the use of 32-bit +offsets to the character glyphs in dfCharTable. + +Because of the 32-bit offsets and their potentially large size, these +fonts are designed for use on systems that are running Windows version +3.00 in protected (standard or 386 enhanced) mode with an 80386 (or +higher) processor where the processor's 32-bit registers can access +the character glyphs. Typically, device drivers use the Windows 3.00 +version of a font only when both of these conditions are true. + +Font files are stored with an .FNT extension of the form NAME.FNT. The +information at the beginning of both raster and vector versions of +Windows 3.00 font files is shown in the following list: + +Field Description +----- ----------- + +dfVersion 2 bytes specifying the version (0200H or 0300H) of + the file. + +dfSize 4 bytes specifying the total size of the file in + bytes. + +dfCopyright 60 bytes specifying copyright information. + +dfType 2 bytes specifying the type of font file. + + The low-order byte is exclusively for GDI use. If the + low-order bit of the WORD is zero, it is a bitmap + (raster) font file. If the low-order bit is 1, it is a + vector font file. The second bit is reserved and must + be zero. If no bits follow in the file and the bits are + located in memory at a fixed address specified in + dfBitsOffset, the third bit is set to 1; otherwise, the + bit is set to 0 (zero). The high-order bit of the low + byte is set if the font was realized by a device. The + remaining bits in the low byte are reserved and set to + zero. + + The high byte is reserved for device use and will + always be set to zero for GDI-realized standard fonts. + Physical fonts with the high-order bit of the low byte + set may use this byte to describe themselves. GDI will + never inspect the high byte. + +dfPoints 2 bytes specifying the nominal point size at which + this character set looks best. + +dfVertRes 2 bytes specifying the nominal vertical resolution + (dots-per-inch) at which this character set was + digitized. + +dfHorizRes 2 bytes specifying the nominal horizontal resolution + (dots-per-inch) at which this character set was + digitized. + +dfAscent 2 bytes specifying the distance from the top of a + character definition cell to the baseline of the + typographical font. It is useful for aligning the + baselines of fonts of different heights. + +dfInternalLeading + Specifies the amount of leading inside the bounds set + by dfPixHeight. Accent marks may occur in this area. + This may be zero at the designer's option. + +dfExternalLeading + Specifies the amount of extra leading that the designer + requests the application add between rows. Since this + area is outside of the font proper, it contains no + marks and will not be altered by text output calls in + either the OPAQUE or TRANSPARENT mode. This may be zero + at the designer's option. + +dfItalic 1 (one) byte specifying whether or not the character + definition data represent an italic font. The low-order + bit is 1 if the flag is set. All the other bits are + zero. + +dfUnderline 1 byte specifying whether or not the character + definition data represent an underlined font. The + low-order bit is 1 if the flag is set. All the other + bits are 0 (zero). + +dfStrikeOut 1 byte specifying whether or not the character + definition data represent a struckout font. The low- + order bit is 1 if the flag is set. All the other bits + are zero. + +dfWeight 2 bytes specifying the weight of the characters in the + character definition data, on a scale of 1 to 1000. A + dfWeight of 400 specifies a regular weight. + +dfCharSet 1 byte specifying the character set defined by this + font. + +dfPixWidth 2 bytes. For vector fonts, specifies the width of the + grid on which the font was digitized. For raster fonts, + if dfPixWidth is nonzero, it represents the width for + all the characters in the bitmap; if it is zero, the + font has variable width characters whose widths are + specified in the dfCharTable array. + +dfPixHeight 2 bytes specifying the height of the character bitmap + (raster fonts), or the height of the grid on which a + vector font was digitized. + +dfPitchAndFamily + Specifies the pitch and font family. The low bit is set + if the font is variable pitch. The high four bits give + the family name of the font. Font families describe in + a general way the look of a font. They are intended for + specifying fonts when the exact face name desired is + not available. The families are as follows: + + Family Description + ------ ----------- + FF_DONTCARE (0<<4) Don't care or don't know. + FF_ROMAN (1<<4) Proportionally spaced fonts + with serifs. + FF_SWISS (2<<4) Proportionally spaced fonts + without serifs. + FF_MODERN (3<<4) Fixed-pitch fonts. + FF_SCRIPT (4<<4) + FF_DECORATIVE (5<<4) + + +dfAvgWidth 2 bytes specifying the width of characters in the font. + For fixed-pitch fonts, this is the same as dfPixWidth. + For variable-pitch fonts, this is the width of the + character "X." + +dfMaxWidth 2 bytes specifying the maximum pixel width of any + character in the font. For fixed-pitch fonts, this is + simply dfPixWidth. + +dfFirstChar 1 byte specifying the first character code defined by + this font. Character definitions are stored only for + the characters actually present in a font. Therefore, + use this field when calculating indexes into either + dfBits or dfCharOffset. + +dfLastChar 1 byte specifying the last character code defined by + this font. Note that all the characters with codes + between dfFirstChar and dfLastChar must be present in + the font character definitions. + +dfDefaultChar 1 byte specifying the character to substitute + whenever a string contains a character out of the + range. The character is given relative to dfFirstChar + so that dfDefaultChar is the actual value of the + character, less dfFirstChar. The dfDefaultChar should + indicate a special character that is not a space. + +dfBreakChar 1 byte specifying the character that will define word + breaks. This character defines word breaks for word + wrapping and word spacing justification. The character + is given relative to dfFirstChar so that dfBreakChar is + the actual value of the character, less that of + dfFirstChar. The dfBreakChar is normally (32 - + dfFirstChar), which is an ASCII space. + +dfWidthBytes 2 bytes specifying the number of bytes in each row of + the bitmap. This is always even, so that the rows start + on WORD boundaries. For vector fonts, this field has no + meaning. + +dfDevice 4 bytes specifying the offset in the file to the string + giving the device name. For a generic font, this value + is zero. + +dfFace 4 bytes specifying the offset in the file to the + null-terminated string that names the face. + +dfBitsPointer 4 bytes specifying the absolute machine address of + the bitmap. This is set by GDI at load time. The + dfBitsPointer is guaranteed to be even. + +dfBitsOffset 4 bytes specifying the offset in the file to the + beginning of the bitmap information. If the 04H bit in + the dfType is set, then dfBitsOffset is an absolute + address of the bitmap (probably in ROM). + + For raster fonts, dfBitsOffset points to a sequence of + bytes that make up the bitmap of the font, whose height + is the height of the font, and whose width is the sum + of the widths of the characters in the font rounded up + to the next WORD boundary. + + For vector fonts, it points to a string of bytes or + words (depending on the size of the grid on which the + font was digitized) that specify the strokes for each + character of the font. The dfBitsOffset field must be + even. + +dfReserved 1 byte, not used. + +dfFlags 4 bytes specifying the bits flags, which are additional + flags that define the format of the Glyph bitmap, as + follows: + + DFF_FIXED equ 0001h ; font is fixed pitch + DFF_PROPORTIONAL equ 0002h ; font is proportional + ; pitch + DFF_ABCFIXED equ 0004h ; font is an ABC fixed + ; font + DFF_ABCPROPORTIONAL equ 0008h ; font is an ABC pro- + ; portional font + DFF_1COLOR equ 0010h ; font is one color + DFF_16COLOR equ 0020h ; font is 16 color + DFF_256COLOR equ 0040h ; font is 256 color + DFF_RGBCOLOR equ 0080h ; font is RGB color + +dfAspace 2 bytes specifying the global A space, if any. The + dfAspace is the distance from the current position to + the left edge of the bitmap. + +dfBspace 2 bytes specifying the global B space, if any. The + dfBspace is the width of the character. + +dfCspace 2 bytes specifying the global C space, if any. The + dfCspace is the distance from the right edge of the + bitmap to the new current position. The increment of a + character is the sum of the three spaces. These apply + to all glyphs and is the case for DFF_ABCFIXED. + +dfColorPointer + 4 bytes specifying the offset to the color table for + color fonts, if any. The format of the bits is similar + to a DIB, but without the header. That is, the + characters are not split up into disjoint bytes. + Instead, they are left intact. If no color table is + needed, this entry is NULL. + [NOTE: This information is different from that in the + hard-copy Developer's Notes and reflects a correction.] + +dfReserved1 16 bytes, not used. + [NOTE: This information is different from that in the + hard-copy Developer's Notes and reflects a correction.] + +dfCharTable For raster fonts, the CharTable is an array of entries + each consisting of two 2-byte WORDs for Windows 2.x and + three 2-byte WORDs for Windows 3.00. The first WORD of + each entry is the character width. The second WORD of + each entry is the byte offset from the beginning of the + FONTINFO structure to the character bitmap. For Windows + 3.00, the second and third WORDs are used for the + offset. + + There is one extra entry at the end of this table that + describes an absolute-space character. This entry + corresponds to a character that is guaranteed to be + blank; this character is not part of the normal + character set. + + The number of entries in the table is calculated as + ((dfLastChar - dfFirstChar) + 2). This includes a + spare, the sentinel offset mentioned in the following + paragraph. + + For fixed-pitch vector fonts, each 2-byte entry in this + array specifies the offset from the start of the bitmap + to the beginning of the string of stroke specification + units for the character. The number of bytes or WORDs + to be used for a particular character is calculated by + subtracting its entry from the next one, so that there + is a sentinel at the end of the array of values. + + For proportionally spaced vector fonts, each 4-byte + entry is divided into two 2-byte fields. The first + field gives the starting offset from the start of the + bitmap of the character strokes. The second field gives + the pixel width of the character. + + An ASCII character string specifying the name of the + font face. The size of this field is the length of the + string plus a NULL terminator. + + An ASCII character string specifying the name of the + device if this font file is for a specific device. The + size of this field is the length of the string plus a + NULL terminator. + + This field contains the character bitmap definitions. + Each character is stored as a contiguous set of bytes. + (In the old font format, this was not the case.) + + The first byte contains the first 8 bits of the first + scanline (that is, the top line of the character). The + second byte contains the first 8 bits of the second + scanline. This continues until a first "column" is + completely defined. + + The following byte contains the next 8 bits of the + first scanline, padded with zeros on the right if + necessary (and so on, down through the second + "column"). If the glyph is quite narrow, each scanline + is covered by 1 byte, with bits set to zero as + necessary for padding. If the glyph is very wide, a + third or even fourth set of bytes can be present. + + Note: The character bitmaps must be stored + contiguously and arranged in ascending order. + + The following is a single-character example, in which + are given the bytes for a 12 x 14 pixel character, as + shown here schematically. + + ............ + .....**..... + ....*..*.... + ...*....*... + ..*......*.. + ..*......*.. + ..*......*.. + ..********.. + ..*......*.. + ..*......*.. + ..*......*.. + ............ + ............ + ............ + + The bytes are given here in two sets, because the + character is less than 17 pixels wide. + + 00 06 09 10 20 20 20 3F 20 20 20 00 00 00 + 00 00 00 80 40 40 40 C0 40 40 40 00 00 00 + + Note that in the second set of bytes, the second digit + of each is always zero. It would correspond to the 13th + through 16th pixels on the right side of the character, + if they were present. + + +The Windows 2.x version of dfCharTable has a GlyphEntry structure with +the following format: + +GlyphEntry struc +geWidth dw ? ; width of character bitmap in pixels +geOffset dw ? ; pointer to the bits +GlyphEntry ends + +The Windows 3.00 version of the dfCharTable is dependent on the format +of the Glyph bitmap. + + Note: The only formats supported in Windows 3.00 will be DFF_FIXED + and DFF_PROPORTIONAL. + +DFF_FIXED +DFF_PROPORTIONAL + +GlyphEntry struc +geWidth dw ? ; width of character bitmap in pixels +geOffset dd ? ; pointer to the bits +GlyphEntry ends + +DFF_ABCFIXED +DFF_ABCPROPORTIONAL + +GlyphEntry struc +geWidth dw ? ; width of character bitmap in pixels +geOffset dd ? ; pointer to the bits +geAspace dd ? ; A space in fractional pixels (16.16) +geBspace dd ? ; B space in fractional pixels (16.16) +geCspace dw ? ; C space in fractional pixels (16.16) +GlyphEntry ends + +The fractional pixels are expressed as a 32-bit signed number with an +implicit binary point between bits 15 and 16. This is referred to as a +16.16 ("sixteen dot sixteen") fixed-point number. + +The ABC spacing here is the same as that defined above. However, here +there are specific sets for each character. + +DFF_1COLOR +DFF_16COLOR +DFF_256COLOR +DFF_RGBCOLOR + +GlyphEntry struc +geWidth dw ? ; width of character bitmap in pixels +geOffset dd ? ; pointer to the bits +geHeight dw ? ; height of character bitmap in pixels +geAspace dd ? ; A space in fractional pixels (16.16) +geBspace dd ? ; B space in fractional pixels (16.16) +geCspace dd ? ; C space in fractional pixels (16.16) +GlyphEntry ends + +DFF_1COLOR means 8 pixels per byte +DFF_16COLOR means 2 pixels per byte +DFF_256COLOR means 1 pixel per byte +DFF_RGBCOLOR means RGBquads + + +Microsoft is a registered trademark and Windows is a trademark of +Microsoft Corporation. diff --git a/mobius/doc/txt/idehdc.asm b/mobius/doc/txt/idehdc.asm new file mode 100644 index 0000000..e84a7aa --- /dev/null +++ b/mobius/doc/txt/idehdc.asm @@ -0,0 +1,378 @@ +; ========================================================================== ; +; IDEHDC.asm ; +; Direct disk I/O module for IDE disk controllers. ; +; Written by Alan Martin. ; +; Note - this code doesn't use interrupts! ; +; ========================================================================== ; +idehdc segment use16 'CODE' ; Direct disk I/O code segment. + ; Initialize segment. + assume cs:idehdc ; Initial segment assumptions. + .386 ; Assume 386+ code is valid. + + ; Stack addressing equates. +_ax equ word ptr bp+001Ch ; Saved AX value. +_al equ byte ptr bp+001Ch ; Saved AL value. +_ah equ byte ptr bp+001Dh ; Saved AH value. +_bx equ word ptr bp+0010h ; Saved BX value. +_bl equ byte ptr bp+0010h ; Saved BL value. +_bh equ byte ptr bp+0011h ; Saved BH value. +_cx equ word ptr bp+0018h ; Saved CX value. +_cl equ byte ptr bp+0018h ; Saved CL value. +_ch equ byte ptr bp+0019h ; Saved CH value. +_dx equ word ptr bp+0014h ; Saved DX value. +_dl equ byte ptr bp+0014h ; Saved DL value. +_dh equ byte ptr bp+0015h ; Saved DH value. + +delay macro x ; Long delay (for 400ns transition). +local @loop ; Local labels. + push cx ; Save CX. + mov cx,x ; Get repeat count. + @loop: loop @loop ; Loop X times. + pop cx ; Restore CX. +endm ; End of DELAY macro. + +hdcwait macro ; Wait for HDC to finish commands. +local @loop,@ok,@err ; Local labels. + push ax ecx dx ; Save registers. + mov ecx,00040000h ; 1s delay on 486DX-50. + mov dx,01F7h ; HDC status register. + in al,dx ; Read status. + test al,80h ; Is the HDC busy? + jz @ok ; If not, end immediately. + @loop: in al,dx ; Read status. + delay 000Ah ; 50-100 clock delay. + test al,80h ; Is the HDC busy? + jz @ok ; If not, end loop. + loopd @loop ; Otherwise, continue. + pop dx ecx ax ; Restore registers. + stc ; Set CF. + jmp @err ; Exit with error. + @ok: pop dx ecx ax ; Restore registers. + clc ; Clear CF. + @err: +endm ; End of HDCWAIT macro. + +; ------------------------------------------ ; +; IOREAD - Read sectors through direct I/O. ; +; Input.: AX=cylinder number ; +; BH=head number; BL=sector number ; +; CH=# of sectors; CL=drive (0 or 1) ; +; DS:DX->buffer for sectors ; +; Output: CF=0 (OK) or 1 (Error) ; +; AL=error code or 0 if no error. ; +; AH=device error code if applicable.; +; Errors: AL=0 - No error. ; +; 1 - Controller busy or absent. ; +; 2 - Drive not ready. ; +; 3 - Drive not ready for read. ; +; 4 - Device error: ; +; AH, bit 0: Address mark not found. ; +; 1: Track 0 not found. ; +; 2: Write fault. ; +; 4: Sector not found. ; +; 6: Error in data. ; +; 7: Sector marked bad. ; +; Note: There may be errors if a read is ; +; across a cylinder (or sometimes even ; +; a head) boundary. ; +; ------------------------------------------ ; +ioread proc far ; Read sectors through direct I/O. + pushad ; Save all registers. + mov bp,sp ; Address the stack. + push ds es ; Save segments. + in al,0A1h ; Get PIC 2 mask. + push ax ; Save it. + or al,40h ; Disable IRQ 14. + out 0A1h,al ; Set PIC 2 mask. + hdcwait ; Wait for HDC not busy. + jnc ir_ok0 ; Continue if not busy. + mov al,01h ; Error 1: Controller busy... + mov [_al],al ; . + jmp ir_err ; ...done. + ir_ok0:mov al,[_bh] ; Get head number. + mov ah,[_cl] ; Get drive number. + and ax,010Fh ; Mask out extra bits. + shl ah,04h ; Adjust AH. + or al,ah ; Combine data. + or al,0A0h ; Set 512 bytes + ECC. + mov dx,01F6h ; Write drive/head numbers... + out dx,al ; ...done. + hdcwait ; Wait for HDC not busy. + jnc ir_ok1 ; Continue if not busy. + mov al,01h ; Error 1: Controller busy... + mov [_al],al ; . + jmp ir_err ; ...done. + ir_ok1:mov ecx,000C0000h ; 3s delay. + mov dx,01F7h ; HDC status register. + ir_l1: in al,dx ; Read status. + test al,40h ; Drive ready? + jnz ir_ok2 ; Continue if so. + loopd ir_l1 ; Loop for 3s. + mov al,02h ; Error 2: Drive not ready... + mov [_al],al ; . + jmp ir_err ; ...done. + ir_ok2:test al,10h ; Drive ready for read? + jnz ir_ok3 ; Continue if so. + loopd ir_l1 ; Loop for 3s. + mov al,03h ; Error 3: Cannot read data... + mov [_al],al ; . + jmp ir_err ; ...done. + ir_ok3:mov al,10h ; Set to >8 heads... + mov dx,03F6h ; . + out dx,ax ; ...done. + mov dx,01F2h ; Write read parameters... + mov al,[_ch] ; . + out dx,al ; . + inc dx ; . + mov al,[_bl] ; . + out dx,al ; . + inc dx ; . + mov al,[_al] ; . + out dx,al ; . + inc dx ; . + mov al,[_ah] ; . + out dx,al ; . + inc dx ; . + mov al,[_bh] ; . + mov ah,[_cl] ; . + and ax,010Fh ; . + shl ah,04h ; . + or al,ah ; . + or al,0A0h ; . + out dx,al ; ...done. + mov dx,01F1h ; Write Precompensation = 0... + xor al,al ; . + out dx,al ; ...done. + hdcwait ; Wait for HDC not busy. + jnc ir_ok4 ; Continue if not busy. + mov al,01h ; Error 1: Controller busy... + mov [_al],al ; . + jmp ir_err ; ...done. + ir_ok4:xor cx,cx ; Get sector count... + mov cl,[_ch] ; ...done. + push ds ; Put DS in ES... + pop es ; ...done. + mov di,[_dx] ; Get offset. + mov dx,01F7h ; Send read command... + mov al,20h ; . + out dx,al ; ...done. + ir_l2: mov dx,01F7h ; Get status port. + delay 000Ah ; Delay for >400ns. + in al,dx ; Get status. + test al,80h ; Busy? + jnz ir_l2 ; Loop if so. + test al,29h ; Loop if no change... + jz ir_l2 ; ...done. + test al,08h ; Ready for data? + jnz ir_rda ; If so, read it. + test al,21h ; Error in command? + jnz ir_dev ; If so, return device error. + jmp ir_l2 ; Continue loop. + ir_rda:push cx ; Save CX. + mov cx,0100h ; Repeat count. + mov dx,01F0h ; 16-bit transfer port. + rep insw ; Read data. + pop cx ; Restore CX. + loop ir_l2 ; Loop until done. + mov al,12h ; Deactivate controller... + mov dx,03F6h ; . + out dx,ax ; ...done. + mov al,00h ; No error - return 0... + mov [_al],al ; ...done. + pop ax ; Reset PIC 2 mask... + out 0A1h,al ; ...done. + clc ; No error: CF=0. + pop es ds ; Restore segments. + popad ; Restore all registers. + ret ; Return (far). + ir_dev:mov al,04h ; Error 4: Device fault... + mov [_al],al ; ...done. + mov dx,01F1h ; Get error code... + in al,dx ; . + mov [_ah],al ; ...done. + mov dx,01F6h ; Recalibrate head... + mov al,[_bh] ; . + mov ah,[_cl] ; . + and ax,010Fh ; . + shl ah,04h ; . + or al,ah ; . + or al,0A0h ; . + out dx,al ; . + inc dx ; . + mov al,10h ; . + out dx,al ; ...done. + hdcwait ; Wait for HDC not busy. + mov al,12h ; Deactivate controller... + mov dx,03F6h ; . + out dx,ax ; ...done. + ir_err:pop ax ; Reset PIC 2 mask... + out 0A1h,al ; ...done. + stc ; Error: CF=1. + pop es ds ; Restore segments. + popad ; Restore all registers. + ret ; Return (far). +ioread endp ; End of IOREAD procedure. + +; ------------------------------------------ ; +; IOWRITE - Write sectors through direct I/O.; +; Input.: AX=cylinder number ; +; BH=head number; BL=sector number ; +; CH=# of sectors; CL=drive (0 or 1) ; +; DS:DX->buffer for sectors ; +; Output: CF=0 (OK) or 1 (Error) ; +; AL=error code or 0 if no error. ; +; AH=device error code if applicable.; +; Errors: AL=0 - No error. ; +; 1 - Controller busy or absent. ; +; 2 - Drive not ready. ; +; 3 - Drive not ready for write. ; +; 4 - Device error: ; +; AH, bit 0: Address mark not found. ; +; 1: Track 0 not found. ; +; 2: Write fault. ; +; 4: Sector not found. ; +; 6: Error in data. ; +; 7: Sector marked bad. ; +; Note: There may be errors if a write is ; +; across a cylinder (or sometimes even ; +; a head) boundary. ; +; ------------------------------------------ ; +iowrite proc far ; Write sectors through direct I/O. + pushad ; Save all registers. + mov bp,sp ; Address the stack. + push ds es ; Save segments. + in al,0A1h ; Get PIC 2 mask. + push ax ; Save it. + or al,40h ; Disable IRQ 14. + out 0A1h,al ; Set PIC 2 mask. + hdcwait ; Wait for HDC not busy. + jnc iw_ok0 ; Continue if not busy. + mov al,01h ; Error 1: Controller busy... + mov [_al],al ; . + jmp iw_err ; ...done. + iw_ok0:mov al,[_bh] ; Get head number. + mov ah,[_cl] ; Get drive number. + and ax,010Fh ; Mask out extra bits. + shl ah,04h ; Adjust AH. + or al,ah ; Combine data. + or al,0A0h ; Set 512 bytes + ECC. + mov dx,01F6h ; Write drive/head numbers... + out dx,al ; ...done. + hdcwait ; Wait for HDC not busy. + jnc iw_ok1 ; Continue if not busy. + mov al,01h ; Error 1: Controller busy... + mov [_al],al ; . + jmp iw_err ; ...done. + iw_ok1:mov ecx,000C0000h ; 3s delay. + mov dx,01F7h ; HDC status register. + iw_l1: in al,dx ; Read status. + test al,40h ; Drive ready? + jnz iw_ok2 ; Continue if so. + loopd iw_l1 ; Loop for 3s. + mov al,02h ; Error 2: Drive not ready... + mov [_al],al ; . + jmp iw_err ; ...done. + iw_ok2:test al,10h ; Drive ready for write? + jnz iw_ok3 ; Continue if so. + loopd iw_l1 ; Loop for 3s. + mov al,03h ; Error 3: Cannot write... + mov [_al],al ; . + jmp iw_err ; ...done. + iw_ok3:mov al,10h ; Set to >8 heads... + mov dx,03F6h ; . + out dx,ax ; ...done. + mov dx,01F2h ; Write write parameters... + mov al,[_ch] ; . + out dx,al ; . + inc dx ; . + mov al,[_bl] ; . + out dx,al ; . + inc dx ; . + mov al,[_al] ; . + out dx,al ; . + inc dx ; . + mov al,[_ah] ; . + out dx,al ; . + inc dx ; . + mov al,[_bh] ; . + mov ah,[_cl] ; . + and ax,010Fh ; . + shl ah,04h ; . + or al,ah ; . + or al,0A0h ; . + out dx,al ; ...done. + mov dx,01F1h ; Write Precompensation = 0... + xor al,al ; . + out dx,al ; ...done. + hdcwait ; Wait for HDC not busy. + jnc iw_ok4 ; Continue if not busy. + mov al,01h ; Error 1: Controller busy... + mov [_al],al ; . + jmp iw_err ; ...done. + iw_ok4:xor cx,cx ; Get sector count... + mov cl,[_ch] ; ...done. + mov si,[_dx] ; Get offset. + mov dx,01F7h ; Send write command... + mov al,30h ; . + out dx,al ; ...done. + iw_l2: mov dx,01F7h ; Get status port. + delay 000Ah ; Delay for >400ns. + in al,dx ; Get status. + test al,80h ; Busy? + jnz iw_l2 ; Loop if so. + test al,29h ; Loop if no change... + jz iw_l2 ; ...done. + test al,08h ; Ready for data? + jnz iw_wda ; If so, write it. + test al,21h ; Error in command? + jnz iw_dev ; If so, return device error. + jmp iw_l2 ; Continue loop. + iw_wda:push cx ; Save CX. + mov cx,0100h ; Repeat count. + mov dx,01F0h ; 16-bit transfer port. + rep outsw ; Write data. + pop cx ; Restore CX. + loop iw_l2 ; Loop until done. + mov al,12h ; Deactivate controller... + mov dx,03F6h ; . + out dx,ax ; ...done. + mov al,00h ; No error - return 0... + mov [_al],al ; ...done. + pop ax ; Reset PIC 2 mask... + out 0A1h,al ; ...done. + clc ; No error: CF=0. + pop es ds ; Restore segments. + popad ; Restore all registers. + ret ; Return (far). + iw_dev:mov al,04h ; Error 4: Device fault... + mov [_al],al ; ...done. + mov dx,01F1h ; Get error code... + in al,dx ; . + mov [_ah],al ; ...done. + mov dx,01F6h ; Recalibrate head... + mov al,[_bh] ; . + mov ah,[_cl] ; . + and ax,010Fh ; . + shl ah,04h ; . + or al,ah ; . + or al,0A0h ; . + out dx,al ; . + inc dx ; . + mov al,10h ; . + out dx,al ; ...done. + hdcwait ; Wait for HDC not busy. + mov al,12h ; Deactivate controller... + mov dx,03F6h ; . + out dx,ax ; ...done. + iw_err:pop ax ; Reset PIC 2 mask... + out 0A1h,al ; ...done. + stc ; Error: CF=1. + pop es ds ; Restore segments. + popad ; Restore all registers. + ret ; Return (far). +iowrite endp ; End of IOWRITE procedure. + + ; Clean up segment. + assume nothing ; Remove segment assumptions. +idehdc ends ; End of direct I/O segment. +; ========================================================================== ; diff --git a/mobius/doc/txt/mouse.c b/mobius/doc/txt/mouse.c new file mode 100644 index 0000000..47aaa41 --- /dev/null +++ b/mobius/doc/txt/mouse.c @@ -0,0 +1,359 @@ +/***************************************************************************** +serial mouse driver +*****************************************************************************/ +#include /* kbhit(), getch() */ +#include /* printf() */ +#include /* peek() for Turbo C, inportb(), outportb(), delay() */ + +#if defined(__TURBOC__) +#define peek40(OFF) peek(0x40, OFF) + +#elif defined(__DJGPP__) +#include /* _farpeekw() */ +#include /* _dos_ds */ + +#define peek40(OFF) _farpeekw(_dos_ds, 0x400 + (OFF)) + +#else +#error Not Turbo C, not DJGPP. Sorry. +#endif + +#define BUF_SIZE 64 + +typedef struct /* circular queue */ +{ + unsigned char *data; + unsigned size, in_ptr, out_ptr; +} queue_t; + +static unsigned char _irq, _buffer[BUF_SIZE]; +static unsigned short _io_adr; +static queue_t _queue = +{ + _buffer, BUF_SIZE, 0, 0 +}; + +/* which COM port to use (1=COM1, 2=COM2, etc.) */ +unsigned char _com = 1; +/*//////////////////////////////////////////////////////////////////////////// + INTERRUPTS +////////////////////////////////////////////////////////////////////////////*/ +static const unsigned char _irq_to_vector[] = +{ + 8, 9, 10, 11, 12, 13, 14, 15, + 112, 113, 114, 115, 116, 117, 118, 119 +}; + +#if defined(__TURBOC__) +#include /* getvect(), setvect() */ + +#define INTERRUPT interrupt + +typedef void interrupt(*vector_t)(void); + +#elif defined(__DJGPP__) +#include /* _go32_dpmi_... */ +#include /* _my_cs() */ + +#define INTERRUPT /* nothing */ + +typedef _go32_dpmi_seginfo vector_t; + +#else +#error Not Turbo C, not DJGPP. Sorry. +#endif +/***************************************************************************** +*****************************************************************************/ +#if defined(__TURBOC__) +#define SAVE_VECT(num, vec) vec = getvect(num) + +#elif defined(__DJGPP__) +#define SAVE_VECT(num, vec) \ + _go32_dpmi_get_protected_mode_interrupt_vector(num, &vec) +#endif +/***************************************************************************** +*****************************************************************************/ +#if defined(__TURBOC__) +#define INSTALL_HANDLER(num, fn) setvect(num, fn) + +#elif defined(__DJGPP__) +#define INSTALL_HANDLER(num, fn) \ + { \ + _go32_dpmi_seginfo new_vector; \ + \ + new_vector.pm_selector = _my_cs(); \ + new_vector.pm_offset = (unsigned long)fn; \ + _go32_dpmi_allocate_iret_wrapper(&new_vector); \ + _go32_dpmi_set_protected_mode_interrupt_vector \ + (num, &new_vector); \ + } +#endif +/***************************************************************************** +*****************************************************************************/ +#if defined(__TURBOC__) +#define RESTORE_VECT(num, vec) setvect(num, vec) + +#elif defined(__DJGPP__) +#define RESTORE_VECT(num, vec) \ + _go32_dpmi_set_protected_mode_interrupt_vector(num, &vec) +#endif +/***************************************************************************** +*****************************************************************************/ +static void enable_irq_at_8259(unsigned short irq) +{ + unsigned char mask; + + if(irq < 8) + { + mask = 1 << irq; + outportb(0x21, inportb(0x21) & ~mask); + } + else if(irq < 16) + { + irq -= 8; + mask = 1 << irq; + outportb(0xA1, inportb(0xA1) & ~mask); + outportb(0x21, inportb(0x21) & ~0x04); + } +} +/***************************************************************************** +*****************************************************************************/ +static void disable_irq_at_8259(unsigned short irq) +{ + unsigned char mask; + + if(irq < 8) + { + mask = 1 << irq; + outportb(0x21, inportb(0x21) | mask); + } + else if(irq < 16) + { + irq -= 8; + mask = 1 << irq; + outportb(0xA1, inportb(0xA1) | mask); + } +} +/***************************************************************************** +*****************************************************************************/ +#if defined(__TURBOC__) +static unsigned crit_begin(void) +{ + unsigned ret_val; + + asm pushf; + asm pop [ret_val]; + return ret_val; +} +/***************************************************************************** +*****************************************************************************/ +static void crit_end(unsigned flags) +{ + asm push [flags]; + asm popf; +} +#elif defined(__DJGPP__) +/***************************************************************************** +*****************************************************************************/ +static __inline__ unsigned crit_begin(void) +{ + unsigned ret_val; + + __asm__ __volatile__("pushfl\n" + "popl %0\n" + "cli" + : "=a"(ret_val) + :); + return ret_val; +} +/***************************************************************************** +*****************************************************************************/ +static __inline__ void crit_end(unsigned flags) +{ + __asm__ __volatile__("pushl %0\n" + "popfl" + : + : "m"(flags) + ); +} +#endif +/***************************************************************************** +*****************************************************************************/ +static int inq(queue_t *q, unsigned char data) +{ + unsigned flags, temp; + + flags = crit_begin(); + temp = q->in_ptr + 1; + if(temp >= q->size) + temp = 0; +/* if in_ptr reaches out_ptr, the queue is full */ + if(temp == q->out_ptr) + { + crit_end(flags); + return -1; + } + q->data[q->in_ptr] = data; + q->in_ptr = temp; + crit_end(flags); + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static int deq(queue_t *q, unsigned char *data) +{ + unsigned flags; + + flags = crit_begin(); +/* if in_ptr == out_ptr, the queue is empty */ + if(q->in_ptr == q->out_ptr) + { + crit_end(flags); + return -1; + } + *data = q->data[q->out_ptr]; + q->out_ptr++; + if(q->out_ptr >= q->size) + q->out_ptr = 0; + crit_end(flags); + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static void INTERRUPT com_irq(void) +{ + unsigned char temp; + +#if defined(__TURBOC__) +pokeb(0xB800, 0, peekb(0xB800, 0) + 1); +#endif + temp = inportb(_io_adr + 5); + if(temp & 0x01) + { + temp = inportb(_io_adr + 0); + (void)inq(&_queue, temp); + } + (void)inportb(_io_adr + 2); +/* acknowledge interrupt at 8259s */ + outportb(0x20, 0x20); + if(_irq >= 8) + outportb(0xA0, 0x20); +} +/***************************************************************************** +*****************************************************************************/ +#define MAX_ID 16 + +int main(void) +{ + static const unsigned char com_to_irq[] = + { + 4, 3, 4, 3 + }; +/**/ + unsigned char vect_num, byte, id[MAX_ID], *ptr; + vector_t old_vector; + unsigned temp; + + if(_com < 1 || _com > 4) + { + printf("Invalid COM port %u (must be 1-4)\n", _com); + return 1; + } +/* get COM port I/O address from BIOS data segment */ + _io_adr = peek40(0 + (_com - 1) * 2); + if(_io_adr == 0) + { + printf("Sorry, no COM%u serial port on this PC\n", _com); + return 2; + } + printf("activating mouse on COM%u...\n", _com); + _irq = com_to_irq[_com - 1]; + vect_num = _irq_to_vector[_irq]; +/* install handler */ + SAVE_VECT(vect_num, old_vector); + INSTALL_HANDLER(vect_num, com_irq); +/* set up serial chip +turn off handshaking lines to power-down mouse, then delay */ + outportb(_io_adr + 4, 0); + delay(500); + outportb(_io_adr + 3, 0x80); /* set DLAB to access baud divisor */ + outportb(_io_adr + 1, 0); /* 1200 baud */ + outportb(_io_adr + 0, 96); + outportb(_io_adr + 3, 0x02); /* clear DLAB bit, set 7N1 format */ + outportb(_io_adr + 2, 0); /* turn off FIFO, if any */ +/* activate Out2, RTS, and DTR to power the mouse */ + outportb(_io_adr + 4, 0x0B); +/* enable receiver interrupts */ + outportb(_io_adr + 1, 0x01); +/* enable interrupts at 8259s */ + enable_irq_at_8259(_irq); +/* wait a moment to get ID bytes from mouse. Microsoft mice just return +a single 'M' byte, some 3-button mice return "M3", my Logitech mouse +returns a string of bytes. I could find no documentation on these, +but I figured out some of it on my own. */ + ptr = id; + for(temp = 750; temp != 0; temp--) + { + while(deq(&_queue, &byte) == 0) + { + printf("%02X ", byte); + *ptr = byte; + ptr++; + if(ptr >= id + MAX_ID) + goto FOO; + } + delay(1); + } + printf("\n"); +FOO: + if(ptr >= id + 11) + { +/* find the 'M' */ + for(ptr = id; ptr < id + MAX_ID - 7; ptr++) + { + if(*ptr == 'M') + break; + } + if(ptr < id + MAX_ID) + { +/* four bytes that each encode 4 bits of the numeric portion +of the PnP ID. Each byte has b4 set (i.e. ORed with 0x10) */ + temp = (ptr[8] & 0x0F); + temp <<= 4; + temp |= (ptr[9] & 0x0F); + temp <<= 4; + temp |= (ptr[10] & 0x0F); + temp <<= 4; + temp |= (ptr[11] & 0x0F); +/* three bytes that each encode one character of the character portion +of the PnP ID. Each byte has b5 set (i.e. ORed with 0x20) */ + printf("mouse PnP ID: %c%c%c%04X\n", + '@' + (ptr[5] & 0x1F), + '@' + (ptr[6] & 0x1F), + '@' + (ptr[7] & 0x1F), temp); + } +/* example: Logitech serial mouse LGI8001 +('L' - '@') | 0x20 == 0x2C +('G' - '@') | 0x20 == 0x27 +('I' - '@') | 0x20 == 0x29 +('8' - '0') | 0x10 == 0x18 +('0' - '0') | 0x10 == 0x10 +('0' - '0') | 0x10 == 0x10 +('1' - '0') | 0x10 == 0x11 */ + } + printf("Press a key to quit\n"); + while(!kbhit()) + { + if(deq(&_queue, &byte) == 0) + printf("%02X ", byte); + } + if(getch() == 0) + (void)getch(); +/* disable interrupts at serial chip */ + outportb(_io_adr + 1, 0); +/* disable interrupts at 8259s */ + disable_irq_at_8259(_irq); +/* restore old vector */ + RESTORE_VECT(vect_num, old_vector); + return 0; +} diff --git a/mobius/doc/txt/pcidevs.txt b/mobius/doc/txt/pcidevs.txt new file mode 100644 index 0000000..71fd241 --- /dev/null +++ b/mobius/doc/txt/pcidevs.txt @@ -0,0 +1,6774 @@ +; PCI and AGP Vendors, Devices and Subsystems identification file. +; +; This is version 208 of this file; 10-05-2001 (D-M-Y). +; +; This file is maintained by YOU! If you find an error or omission in this +; file, PLEASE email me with your updates! Without your input, this file will +; soon become out of date and next to worthless. +; +; Too many people have already contributed to this list to name here; thanks to +; each and every one of you! Please keep the updates coming as your work is +; very much appreciated. +; +; The list now contains 6,737 lines of info!!! +; +; Please email your additions/corrections to chart@hyperlink.net.au +; +; The latest version of this list (+more PCI info) is always available from: +; http://members.hyperlink.net.au/~chart +; +; This file is part of my PCI info-program PCI.ZIP which is available from +; http://members.hyperlink.net.au/~chart/download.htm Full documentation on +; the file's format and a can be found in this package. + +V 0000 Gammagraphx, Inc +V 001A Ascend Communications, Inc +V 0033 Paradyne Corp +V 003D Real 3D (Lockheed Martin-Marietta Corp) +V 0070 Hauppauge Computer Works Inc +V 0100 Ncipher Corp Ltd +V 0123 General Dynamics +V 0675 Dynalink +D 1700 IS64PH ISDN Adapter +D 1702 IS64PH ISDN Adapter +V 0815 LinTech GmbH +D 0002 ELKA SO-PCI +V 0A89 BREA Technologies Inc +V 0E11 Compaq +D 0001 PCI to EISA Bridge +D 0002 PCI to ISA Bridge +D 0508 Netelligent 4/16 TR PCI UTP/STP Controller +D 1000 Triflex/Pentium Bridge, Model 1000 +D 2000 Triflex/Pentium Bridge, Model 2000 +D 3032 Qvision 1280/p Rev 0 +D 3033 Qvision 1280/p Rev 1 +D 3034 QVision 1280/p Rev 2 +D 4000 Triflex CPU to PCI Bridge +D 6010 HotPlug PCI Bridge 6010 +D 7020 USB Controller +D A0EC Fibre Channel Host Controller /P +D A0F0 Advanced System Management Controller +D A0F3 Triflex PCI to ISA PnP Bridge +D A0F7 PCI Hot Plug Controller +O 0E11 PCI Hot Plug Controller +S A2F8 Proliant DL580 hot Plug Controller (CPQPHP Installed) +D A0F8 USB Open Host Controller +O 0E11 USB Open Host Controller +S A0F8 USB Open Host Controller +D AE10 Smart-2 Array Controller +O 0E11 Smart-2 Array Controller +S 4030 Smart-2/P Array Controller +S 4031 Smart-2SL Array Controller +S 4032 Smart Array Controller +S 4033 Smart 3100ES Array Controller +D AE29 MIS-L PCI to ISA Bridge +D AE2A MPC CPU to PCI Bridge +D AE2B MIS-E PCI to ISA-PnP Bridge +D AE31 System Management Controller +D AE32 Netelligent 10/100 TX +D AE33 Triflex Dual EIDE Controller +D AE34 Netelligent 10 T +D AE35 Integrated NetFlex 3/P +D AE40 Dual-port Netelligent 10/100 TX +D AE43 Proliant Integrated Netelligent 10/100 +D AE69 CETUS-L PCI to ISA Bridge +D AE6C DRACO PCI Bridge +D AE6D NorthStar CPU to PCI Bridge +D B011 Dual-port Netelligent 10/100 TX +D B012 Netelligent 10 T/2 +D B030 Netelligent 10/100 TX UTP/Coax +D B04A 10/100TX WOL UTP Controller +D B0C6 10/100TX Embedded WOL UTP Controller +D B0D7 NC3121 (Rev A & B) +D F130 ThunderLAN / NetFlex-3/P +D F150 NetFlex-3/P with BNC +V 1000 Symbios Logic (NCR) (LSI Logic) +D 0001 53C810 8100S Fast-SCSI Adapter +O 1000 8100S Fast-SCSI Adapter +S 1000 8100S Fast-SCSI Adapter +D 0002 53C820 820 Fast-Wide-SCSI Adapter +D 0003 53C825 825XS/D Fast-Wide-SCSI Adapter +D 0004 53C815 815X Fast-SCSI Adapter +D 0005 53C875 8100ASP, 2081X Ultra-Wide-SCSI Adapter +D 0006 53C860 8600SP Ultra-SCSI Adapter +D 000A 53C1510 +D 000B 53C896 896, 22910 SCSI Adapter +D 000C 53C895 8951U SCSI Adapter +O DC93 DC-2980U2W SCSI3 Host Adapter +S 2980 DC-2980U2W SCSI3 Host Adapter +D 000D 53C885 23800 SCSI Adapter +D 000F 53C875/6, 875XS/D, 2280X Ultra-Wide-SCSI Adapter +O 0E11 Embedded Ultra Wide SCSI Controller +S 7004 Embedded Ultra Wide SCSI Controller +O 1092 FirePort 40 Dual PCI SCSI Controller +S 8760 FirePort 40 Dual PCI SCSI Controller +O 1DE1 DC390F Ultra Wide SCSI Controller +S 3904 DC390F Ultra Wide SCSI Controller +D 0010 SCSI Array Controller +O 0E11 Integrated Array Controller +S 4040 Proliant DL580 Integrated Array Controller +D 0012 53C895A Ultra2 SCSI Controller +D 0013 53C875A Ultra SCSI Controller +D 0020 53C1010-33 Dual Channel Ultra3 SCSI Adapter +X 10001000 Dual Channel Ultra160 SCSI Multifunction Controller +D 0021 53C1000R/1010R PCI U160 SCSI Controller +X 10001000 Dual Channel Ultra160 SCSI Multifunction Controller +D 008F 53C875J SCSI Controller +O 1092 FirePort 40 PCI SCSI Controller +S 8000 FirePort 40 PCI SCSI Controller +S 8760 FirePort 40 Dual PCI SCSI Host Adapter +D 0621 LSIFC909 Fibre Channel I/O Processor +D 0701 53C885 Ethernet Adapter +D 0702 Gigabit Ethernet Adapter +O 1318 PEI100X Gigabit Ethernet Adapter +S 0000 PEI100X Gigabit Ethernet Adapter +D 0901 61C102 USB Controller +D 1000 63C815 Fast-SCSI +V 1001 Kolter Electronic Germany +D 0010 PCI1616 Measurement card with 32 digital I/O lines +D 0011 OPTO-PCI Opto-Isolated digital I/O board +D 0012 PCI-AD/DA Analogue I/O board +D 0013 PCI-OPTO-RELAIS Digital I/O board with relay outputs +D 0014 PCI-Counter/Timer Counter Timer board +D 0015 PCI-DAC416 Analogue output board +D 0016 PCI-MFB Analogue I/O board +D 0017 PROTO-3 PCI Prototyping board +V 1002 ATI Technologies +D 4158 Mach32 (68800AX) +D 4354 Mach64 CT (215CT222) +D 4358 Mach64 CX (210888) +D 4554 Mach64 ET +D 4654 Mach64 VT +D 4742 Rage 3D Pro AGP 2x (BGA Package) +O 1002 Rage 3D Pro AGP 2x +S 0040 XPERT@PLAY 98 +S 0044 Rage 3D Pro AGP 2x +S 0048 Rage 3D Pro AGP 2x +S 0061 All-in-Wonder Pro NTSC +S 0063 All-in-Wonder Pro NTSC +S 0080 XPERT@WORK +S 0084 XPERT 98 +S 0088 XPERT XL +S 00F3 Rage 3D Pro AGP 2x Onboard Display Adapter +S 4742 Rage 3D Pro AGP 2x (BGA Package) +S 4744 Rage 3D Pro AGP 2x (BGA Package) +O 1028 Optiplex GX1 Onboard Display Adapter +S 4082 Optiplex GX1 Onboard Display Adapter +O 8086 Rage 3D Pro AGP +S 4152 Rage 3D Pro AGP +D 4744 Rage 3D Pro AGP 1x (BGA Package) +X 00840000 Rage 3D Pro AGP 1x (BGA Package) +O 1002 Rage 3D Pro AGP 1x +S 0040 Rage 3D Pro AGP 1x +S 0048 Rage 3D Pro AGP 1x +S 0080 Rage 3D Pro AGP 1x +S 0088 Rage 3D Pro AGP 1x +S 4744 Rage 3D Pro AGP 1x +D 4747 Rage 3D Pro +D 4749 Rage 3D Pro PCI (BGA Package) +O 1002 Rage 3D Pro PCI +S 0061 All-in-Wonder PRO NTSC +S 0063 All-in-Wonder PRO NTSC +O 1028 Poweredge Integrated Video +S 007F 6300 Poweredge Integrated Video +D 474C Rage XC PCI-66 +D 474D Rage XL AGP 2x +D 474E Rage XC AGP 2x +D 474F Rage XL PCI-66 +D 4750 Rage 3D Pro PCI (PQFP Package) +O 1002 Rage 3D Pro PCI (PQFP Package) +S 0040 XPERT@PLAY 98 +S 0080 XPERT 98 +S 0088 XPERT XL +D 4751 Rage 3D Pro PCI (PQFP Package, Limited 3D) +D 4752 Rage XL PCI +D 4753 Rage XC PCI +D 4754 Rage 3D II Mach64 GT, Limited 3D +D 4755 Rage 3D II+ +D 4756 Rage 3D IIC PCI (PQFP Package) +D 4757 Rage 3D IIC AGP (BGA Package) +O 1028 Rage 3D IIC +S 0089 Rage 3D IIC +S 4082 Rage 3D IIC +S 8082 Rage 3D IIC +S C082 Rage 3D IIC +D 4758 Mach64 GX (21088) +D 4759 Rage 3D IIC +O 1028 Rage 3D IIC +S 00A2 Rage 3D IIC +D 475A Rage 3D IIC AGP (PQFP Package) +O 1002 Rage 3D IIC +S 0087 Rage 3D IIC +D 4C42 Rage 3D LT Pro AGP 133MHz (BGA-312 Package) +O 0E11 Rage 3D LT Pro +S B0E8 Rage 3D LT Pro +S B10E Rage 3D LT Pro (Compaq Aramada 1750) +O 1028 Rage 3D LT Pro +S 0085 Rage 3D LT Pro +D 4C44 Rage 3D LT Pro AGP 66MHz (BGA-312 Package) +D 4C46 Mobility M3 AGP 2x +D 4C47 Rage 3D LT-G +D 4C49 Rage 3D LT Pro PCI (BGA-312 Package) +D 4C4D Rage P/M Mobility AGP 2x +O 0E11 Rage P/M Mobility AGP 2x +S B160 Armada V300 Laptop integrated video +O 1509 Rage P/M Mobility AGP 2x +S 4230 Rage P/M Mobility AGP 2x on FIC A450 Notebook +D 4C4E Rage L Mobility AGP 2x +D 4C50 Rage 3D LT Pro PCI (BGA-256 Package) +D 4C51 Rage 3D LT Pro PCI (BGA-256 Package, Limited 3D) +D 4C52 Rage P/M Mobility PCI +D 4C53 Rage L Mobility PCI +D 4C54 Mach64 LT +D 4D46 Rage Mobility 128 AGP 4x +O 1028 Rage Mobility 128 AGP 4x +S 00A4 Rage Mobility 128 AGP 4x in Dell Inspiron 8000 Laptop +D 5041 Rage 128 Pro PCI +D 5042 Rage 128 Pro AGP 2x +D 5043 Rage 128 Pro AGP 4x +D 5044 Rage 128 Pro PCI (TMDS) +O 1002 Rage 128 Pro PCI +S 0028 All-in-Wonder 128 Pro PCI +S 0029 All-in-Wonder 128 Pro PCI +D 5045 Rage 128 Pro AGP 2x (TMDS) +D 5046 Rage 128 Pro AGP 4x (TMDS) +O 1002 Rage 128 Pro AGP 4x (TMDS) +S 0004 Rage Fury Pro +S 0008 Rage Fury Pro/Xpert 2000 Pro +S 0014 Rage Fury Pro +S 0018 Rage Fury Pro/Xpert 2000 Pro +S 0028 All-in-Wonder 128 Pro AGP +S 002A All-in-Wonder 128 Pro AGP +S 0048 Rage Fury Pro +S 2000 Rage Fury MAXX AGP 4x (TMDS) (VGA device) +S 2001 Rage Fury MAXX AGP 4x (TMDS) (Extra device?!) +D 5047 Rage 128 Pro PCI +D 5048 Rage 128 Pro AGP 2x +D 5049 Rage 128 Pro AGP 4x +D 504A Rage 128 Pro PCI (TMDS) +D 504B Rage 128 Pro AGP 2x (TMDS) +D 504C Rage 128 Pro AGP 4x (TMDS) +D 504D Rage 128 Pro PCI +D 504E Rage 128 Pro AGP 2x +D 504F Rage 128 Pro AGP 4x +D 5050 Rage 128 Pro PCI (TMDS) +D 5051 Rage 128 Pro AGP 2x (TMDS) +D 5052 Rage 128 Pro AGP 4x (TMDS) +D 5053 Rage 128 Pro PCI +D 5054 Rage 128 Pro AGP 2x +D 5055 Rage 128 Pro AGP 4x +D 5056 Rage 128 Pro PCI (TMDS) +D 5057 Rage 128 Pro AGP 2x (TMDS) +D 5058 Rage 128 Pro AGP 4x (TMDS) +D 5144 Radeon DDR/SDR +O 1002 Radeon DDR +S 0008 Radeon SDR +S 0009 Radeon SDR PCI +S 000A Radeon DDR +S 001A Radeon DDR +S 0028 All-in-Wonder Radeon SDR AGP +S 0029 All-in-Wonder Radeon PCI +S 0038 Radeon SDR +S 0039 Radeon SDR PCI +S 008A Radeon DDR +S 009A Radeon DDR +S 00BA Radeon DDR +S 0108 Radeon SDR +S 010A Radeon DDR +S 0138 Radeon SDR +S 0139 Radeon SDR PCI +S 018A Radeon DDR +S 01BA Radeon DDR +S 020A Radeon DDR +S 028A Radeon DDR +S 02AA All-in-Wonder Radeon AGP +S 0508 Radeon SDR +S 050A Radeon DDR +S 0538 Radeon SDR +S 053A Radeon DDR +S 0908 Radeon SDR +S 110A Radeon DDR +O 104A PowerVR KYRO Graphics Accelerator +S 0010 PowerVR KYRO Graphics Accelerator +D 5159 Radeon VE +O 1002 Radeon VE +S 031A Radeon VE +D 5245 Rage 128 GL PCI +O 1002 Rage 128 GL PCI +S 0008 Xpert 128 +S 0028 All-in-Wonder 128 PCI +S 0029 All-in-Wonder 128 PCI +S 0068 All-in-Wonder 128 PCI +D 5246 Rage 128 GL AGP 2x +O 1002 Rage 128 GL AGP 2x +S 0004 Magnum/Xpert 128/Xpert 99 +S 0008 Magnum/Xpert 128/Xpert 99/Xpert 2000 +S 0028 All-in-Wonder 128 AGP +S 0044 Rage Fury/Xpert 128/Xpert 2000 +S 0048 Rage Fury/Xpert 128/Xpert 2000 +S 0068 All-in-Wonder 128 AGP +S 0448 Rage Fury +D 524B Rage 128 VR PCI +D 524C Rage 128 VR AGP 2x +O 1002 Rage 128 VR AGP 2x +S 0008 Xpert 99/Xpert 2000 +S 0088 Xpert 99 +D 5345 Rage 128 4x PCI +D 5346 Rage 128 4x AGP 2x +D 5347 Rage 128 4x AGP 4x +D 5348 Rage 128 4x +D 534B Rage 128 4x PCI +D 534C Rage 128 4x AGP 2x +D 534D Rage 128 4x AGP 4x +O 1002 Rage 128 4x AGP 4x +S 0008 Xpert 99/Xpert 2000 +S 0018 Xpert 2000 +D 534E Rage 128 4x +D 5354 Mach64 ST +O 1002 Mach64 ST Reference +S 5354 Mach64 ST Reference +D 5446 Rage 128 Pro AGP 4x +O 1002 Rage 128 Pro AGP 4x +S 0004 Rage Fury Pro +S 0008 Rage Fury Pro/Xpert 2000 Pro +S 0028 All-In-Wonder 128 Pro Ultra AGP +S 0029 All-In-Wonder 128 Pro Ultra AGP +S 002A All-In-Wonder 128 Pro Ultra AGP +S 002B All-In-Wonder 128 Pro Ultra AGP +D 5654 Mach64 VT (215VT22200) +O 1002 Mach64VT Reference +S 5654 Mach64VT Reference +D 5655 Mach64 VT3 +D 5656 Mach64 VT4 PCI (PQFP Package) +V 1003 ULSI Systems +D 0201 US201 GUI Accelerator +V 1004 VLSI Technology +D 0005 82C591/2-FC1 Bridge +D 0006 82C593-FC1 Bridge +D 0007 82C594-AFC2 Wildcat Controller +D 0008 82C596/7 Wildcat PCI to ISA Bridge +D 0009 82C597-AFC2 +D 000C 82C541 +D 000D 82C543 +D 0100 CPU to PCI Bridge for notebook +D 0101 82C532 Peripheral Controller +D 0102 82C534 PCI to PCI Bridge +D 0103 82C538 PCI to ISA Bridge +D 0104 82C535 CPU to PCI Bridge +D 0105 82C147 IrDA Controller +D 0200 82C975 RISC GUI Accelerator +D 0280 82C925 RISC GUI Accelerator +D 0304 QSound ThunderBird PCI Audio +R 19 QSound ThunderBird PCI Audio Q3D,Q3D+ +R 38 QSound ThunderBird PCI Audio SD 2Ch, 4Ch, 4Ch+256 Voice +O 1004 QSound ThunderBird PCI Audio +S 0304 QSound ThunderBird PCI Audio +O 122D DSP368 Audio +S 1206 DSP368 Audio +O 1483 XWave Thunder 3D Audio +S 5020 XWave Thunder 3D Audio +D 0305 QSound ThunderBird PCI Audio Gameport +O 1004 QSound ThunderBird PCI Audio Gameport +S 0305 QSound ThunderBird PCI Audio Gameport +O 122D DSP368 Audio Gameport +S 1207 DSP368 Audio Gameport +O 1483 XWave Thunder 3D Audio Gameport +S 5021 XWave Thunder 3D Audio Gameport +D 0306 QSound ThunderBird PCI Audio Support Registers +O 1004 QSound ThunderBird PCI Audio Support Registers +S 0306 QSound ThunderBird PCI Audio Support Registers +O 122D DSP368 Audio Support Registers +S 1208 DSP368 Audio Support Registers +O 1483 XWave Thunder 3D Audio Support Registers +S 5022 XWave Thunder 3D Audio Support Registers +D 0702 VAS96011 Golden Gate II +V 1005 Advance Logic (ADL) Inc +D 2064 ALG2032/2064 +D 2128 ALG2364A +D 2301 AVL2301 GUI Accelerator +D 2302 ALG2302 GUI Accelerator +D 2364 ALG2364 GUI Accelerator +D 2464 ALG2364A +D 2501 ALG2564A/25128A +V 1006 Reply Group +V 1007 Netframe Systems Inc +V 1008 Epson +V 100A Phoenix Technologies +V 100B National Semiconductor +D 0001 DP83810 10/100 Fast Ethernet Adapter +D 0002 PC87415 IDE DMA-Master Mode +D 000E PC87560 Legacy I/O Controller +D 000F CS4210 OHCI Compliant FireWire Controller +D 0011 National PCI System I/O +D 0012 USB Controller +D 001B LM4560 Advanced Audio Accelerator +O 100B LM4560 Advanced Audio Accelerator +S 001B LM4560 Advanced Audio Accelerator +D 0020 DP83815 10/100 Fast Ethernet Adapter (MacPhyter) +D 0021 PC87200 PCI to ISA Bridge +D D001 PC87410 PCI EIDE Controller (Single FIFO) +V 100C TSENG LABS Inc +D 3202 ET4000W32P Rev A +D 3205 ET4000W32P Rev B +D 3206 ET4000W32P Rev C +D 3207 ET4000W32P Rev D +D 3208 ET6000/ET6100 +D 4702 ET6300 +V 100D AST Computer +V 100E Weitek +D 9000 WeitekPower P9000 +D 9001 WeitekPower P9000 +D 9100 WeitekPower P9100 +V 1010 Video Logic Ltd +V 1011 Digital Equipment Corp (DEC) +D 0001 DecChip 21050 PCI to PCI Bridge +D 0002 DecChip 21040 "Tulip" Ethernet Adapter +D 0004 DecChip 21030 "TGA" +D 0007 Zephyr NV-RAM +D 0008 KZPSA SCSI to SCSI Adapter +D 0009 DecChip 21140 Fast Ethernet Adapter +O 1025 21140 Fast Ethernet Adapter +S 0310 21140 Fast Ethernet Adapter +O 10B8 SMC9332BDT EtherPower 10/100 +S 2001 SMC9332BDT EtherPower 10/100 +S 2002 SMC9332BVT EtherPower T4 10/100 +S 2003 SMC9334BDT EtherPower 10/100 (1-port) +O 1109 ANA-6944A/TX Fast Ethernet +S 2400 ANA-6944A/TX Fast Ethernet +O 1112 RNS23xx Fast Ethernet +S 2300 RNS2300 Fast Ethernet +S 2320 RNS2320 Fast Ethernet +S 2340 RNS2340 Fast Ethernet +O 1113 EN-1207-TX Fast Ethernet +S 1207 EN-1207-TX Fast Ethernet +O 1186 DFE-500TX Fast Ethernet +S 1100 DFE-500TX Fast Ethernet +S 1112 DFE-570TX Fast Ethernet +O 1282 AEF-380TXD Fast Ethernet +S 9100 AEF-380TXD Fast Ethernet +O 1385 FA310TX Fast Ethernet +S 1100 FA310TX Fast Ethernet +O 2646 KNE100TX Fast Ethernet +S 0001 KNE100TX Fast Ethernet +D 000A DecChip 21230 Video Codec +D 000C DecChip 21130 Integrated GUI Accelerator +D 000D DecChip TGA2 +D 000F FDDI "DEFPA" +D 0014 DecChip 21041 "Tulip Plus" Ethernet Adapter +R 21 DecChip 21041-PB "Tulip Plus" Ethernet Adapter +O 1186 DE-530+ Ethernet Adapter +S 0100 DE-530+ Ethernet Adapter +D 0016 ATM-Controller "DGLPB" +D 0019 DecChip 21142/3 10/100 Fast Ethernet Adapter +O 1011 DE500 Fast Ethernet Adapter +S 500A DE500 Fast Ethernet Adapter +S 500B DE500 Fast Ethernet Adapter +O 1014 10/100 EtherJet Cardbus Adapter +S 0001 10/100 EtherJet Cardbus Adapter +O 1025 ALN315 Fast Ethernet Adapter +S 0315 ALN315 Fast Ethernet Adapter +O 1033 PC-9821NR-B06 +S 800C 21143 Based Fast Ethernet Adapter +S 800D PC-9821NR-B06 +O 108D Rapidfire/GoCard Fast Ethernet Adapter +S 0016 Rapidfire OC-2327 10/100 Ethernet Adapter +S 0017 GoCard OC-2250 Ethernet 10/100 CardBus PC Card +O 10B8 SMC8032/4 Series Fast Ethernet Adapter +S 2005 SMC8032DT Extreme Fast Ethernet Adapter +S 8034 SMC8034 EZ CardBus Fast Ethernet Adapter +O 10EF Cardbus Fast Ethernet Adapter +S 8169 Cardbus Fast Ethernet Adapter +O 1109 ANA-6911A/TX Fast Ethernet Adapter +S 2A00 ANA-6911A/TX Fast Ethernet Adapter +S 2B00 ANA-6911A/TXC Fast Ethernet Adapter +S 3000 ANA-6922/TX Fast Ethernet Adapter +O 1113 Cheetah Fast Ethernet Adapter +S 1207 Cheetah Fast Ethernet Adapter +S 2220 Cardbus Fast Ethernet Adapter +O 115D Cardbus Ethernet 10/100 Adapter +S 0002 Cardbus Ethernet 10/100 Adapter +O 1179 Fast Ethernet Adapter +S 0203 Fast Ethernet Adapter +S 0204 Cardbus Fast Ethernet Adapter +O 1186 DFE-500TX Fast Ethernet Adapter +S 1100 DFE-500TX Fast Ethernet Adapter +S 1101 DFE-500TX Fast Ethernet Adapter +S 1102 DFE-500TX Fast Ethernet Adapter +O 11F6 FreedomLINE Fast Ethernet Adapter +S 0503 FreedomLINE Fast Ethernet Adapter +O 1259 AT-2800Tx Fast Ethernet Adapter +S 2800 AT-2800Tx Fast Ethernet Adapter +O 1266 Eagle Fast EtherMAX +S 0004 Eagle Fast EtherMAX +O 12AF NetFlyer Cardbus Fast Ethernet Adapter +S 0019 NetFlyer Cardbus Fast Ethernet Adapter +O 1374 FastEthernet CardBus PC Card 10/100 +S 0001 FastEthernet CardBus PC Card 10/100 +S 0002 FastEthernet CardBus PC Card 10/100 +S 0007 FastEthernet CardBus PC Card 10/100 +S 0008 FastEthernet CardBus PC Card 10/100 +O 1395 10/100 Ethernet Cardbus PC Card +S 0001 10/100 Ethernet Cardbus PC Card +O 13D1 PCMPC200 EtherFast 10/100 Cardbus PC Card +S AB01 PCMPC200 EtherFast 10/100 Cardbus PC Card +O 8086 EtherExpress PRO/100 Mobile Cardbus 32 Adapter +S 0001 EtherExpress PRO/100 Mobile Cardbus 32 Adapter +D 0021 21052 PCI to PCI Bridge +D 0022 21150-AA PCI to PCI Bridge +D 0023 21150 PCI to PCI Bridge +R 04 21150-AB (Intel DC1030G) PCI to PCI Bridge +R 05 21150-BC (Intel DC1111C) PCI to PCI Bridge +R 06 21150-AC,BC (Intel DC1111D) PCI to PCI Bridge +D 0024 21151/2 PCI to PCI Bridge +D 0025 21153 PCI to PCI Bridge +D 0026 21154 PCI to PCI Bridge +D 0034 Modem56 CardBus +O 1374 Modem56 CardBus +S 0003 Modem56 CardBus +D 0045 21553 PCI to PCI Bridge +D 0046 21554 PCI to PCI Bridge +O 9005 PERC 2, 2/Si, 3/Si, 3/Di RAID Controllers +S 1364 PERC 2/Si Quad Channel RAID Controller +D 1065 21285 SA-110 Microprocessor (RAID Controller) +O 1069 DAC1160P Disk Array +S 0020 DAC1160P Disk Array +V 1012 Micronics Computers Inc +V 1013 Cirrus Logic +D 0038 CL-GD7548 +D 0040 CL-GD7555 Flat Panel GUI Accelerator +D 004C CL-GD7556 Video/Graphics LCD/CRT Ctrlr +D 00A0 CL-GD5430/40 +D 00A2 CL-GD5432 (Alpine) +D 00A4 CL-GD5434-A +D 00A8 CL-GD5434-HC-B +D 00AC CL-GD5436 +D 00B0 CL-GD5440 +D 00B8 CL-GD5446 PCI +D 00BC CL-GD5480 +O 1013 CL-GD5480 +S 00BC CL-GD5480 +D 00D0 CL-GD5460/62 +D 00D2 CL-GD5462 (Laguna I) +D 00D4 CL-GD5464 (Laguna 3D) +D 00D5 Laguna 5464 BD +D 00D6 CL-GD546X AGP/PCI +O 13CE Metheus 2 Megapixel, dual head display +S 8031 Metheus 2 Megapixel, dual head display +D 00E8 CL-GD5436U +D 1100 CL-PD6729 PCI to PCMCIA Bridge +D 1110 CL-PD6832 PCMCIA/Cardbus Ctrlr +D 1112 CL-PD6834 PCMCIA/Cardbus Ctrlr +D 1113 CL-PD6833 PCMCIA/Cardbus Ctrlr +D 1200 CL-GD7542 (nordic) +D 1202 CL-GD7543 (Viking) +D 1204 CL-GD7541 (Nordic-lite) +D 4400 CL-CD4400 Communications Controller +D 6001 CS4610/11 CrystalClear SoundFusion Audio Accelerator +O 1014 CS4610 SoundFusion Audio Accelerator +S 1010 CS4610 SoundFusion Audio Accelerator +D 6003 CS4614/22/24 CrystalClear SoundFusion Audio Accelerator +O 1013 Crystal SoundFusion(tm) PCI Audio Accelerator +S 4280 Crystal SoundFusion(tm) PCI Audio Accelerator +O 1014 Thinkpad T Series Integrated Sound +S 0153 Thinkpad T Series model 2647 Integrated Sound +O 153B DMX XFire 1024 PCI Audio Accelerator +S 112E DMX XFire 1024 PCI Audio Accelerator +D 6005 Crystal CS4281 PCI Audio +O 1013 Crystal CS4281 PCI Audio +S 4281 Crystal CS4281 PCI Audio +O 10CF Crystal CS4281 PCI Audio +S 10A8 Crystal CS4281 PCI Audio +S 10A9 Crystal CS4281 PCI Audio +S 10AA Crystal CS4281 PCI Audio +S 10AB Crystal CS4281 PCI Audio +S 10AC Crystal CS4281 PCI Audio +S 10AD Crystal CS4281 PCI Audio +S 10B4 Crystal CS4281 PCI Audio +O 1179 Crystal CS4281 PCI Audio +S 0001 Crystal CS4281 PCI Audio +O 14C0 Crystal CS4281 PCI Audio +S 000C Crystal CS4281 PCI Audio +V 1014 IBM +D 0002 PCI to MCA Bridge +D 0005 Alta Lite CPU Bridge +D 0007 Alta MP CPU Bridge +D 000A PCI to ISA Bridge with PnP Port +D 0017 CPU to PCI Bridge +D 0018 Auto LANStreamer +D 001B GXT-150P GUI Accelerator +D 001D 82G2675 +D 0020 PCI to MCA Bridge +D 0022 82351/2 PCI to PCI Bridge +D 002D Python +D 002E ServeRAID SCSI Adapter +D 0036 Miami/PCI 32-bit LocalBus Bridge +D 003A CPU to PCI Bridge +D 003E 85H9533 16/4 Token Ring Controller UTP/STP +O 1014 Token-Ring Adapter +S 003E Token-Ring Adapter +S 00CD Token-Ring Adapter + Wake-On-LAN +S 00CE 16/4 Token-Ring Adapter 2 +S 00CF 16/4 Token-Ring Adapter Special +S 00E4 High-Speed 100/16/4 Token-Ring Adapter +S 00E5 16/4 Token-Ring Adapter 2 + Wake-On-LAN +D 0045 SSA Adapter +D 0046 MPIC Interrupt Controller +D 0047 PCI to PCI Bridge +D 0048 PCI to PCI Bridge +D 004E ATM Controller (14104E00) +D 004F ATM Controller (14104F00) +D 0050 ATM Controller (14105000) +D 0053 25 MBit ATM Controller +D 0057 MPEG PCI Bridge +D 005C i82557B 10/100 PCI Ethernet Adapter +D 005D 05J3506 TCP/IP Networking Device +D 007C ATM Controller (14107C00) +D 007D MPEG 2 Decoder +D 0090 GXT 3000P +O 1014 GXT-3000P +S 008E GXT-3000P +D 0095 20H2999 PCI Docking Bridge +D 00A5 ATM Controller (1410A500) +D 00A6 ATM 155MBPS MM Controller (1410A600) +D 00B7 256-bit Graphics Rasterizer (Fire GL1) +O 1902 Fire GL1 +S 00B8 Fire GL1 +D 00BE ATM 622MBPS Controller (1410be00) +D 00CE 02LI537 Adapter 2 Token Ring Adapter +D 0142 Yotta Video Compositor Input +D 0144 Yotta Video Compositor Output +D 0156 405GP PLB to PCI Bridge +V 1015 LSI Logic Corp of Canada +V 1016 Fujitsu ICL Personal Systems +V 1017 Spea Software AG +D 5343 SPEA 3D Acccelerator +V 1018 Unisys Corporation +V 1019 Elitegroup Computer Sys +V 101A NCR (AT&T GIS) +D 0005 8156 100VG/AnyLAN Adapter +D 0009 Altera FLEX RAID Controller(??) +V 101B Vitesse Semiconductor +V 101C Western Digital +D 0193 WD33C193A PCI-SCSI Bridge +D 0196 WD33C196A PCI-SCSI Bridge +D 0197 WD33C197A PCI-Wide SCSI Bridge +D 0296 WD33C296A PCI-Wide SCSI Bridge +D 3193 WD7193 Fast SCSI II Host Adapter +D 3197 WD7197 Fast Wide SCSI II Host Adapter +D 3296 WD7296a Fast Wide SCSI II Host Adapter +D 4296 WD34C294 Wide Fast-20 SCSI Host Adapter +D 9710 Pipeline 9710 +D 9712 Pipeline 9712 +D C24A 90C ?? +V 101E American Megatrends Inc +D 1960 80960RP i960RP Microprocessor +O 101E MegaRaid RAID Controller +S 0493 MegaRaid 493 RAID Controller +D 9010 MegaRAID Fast Wide SCSI RAID-Adapter +D 9030 EIDE Controller +D 9031 EIDE Controller +D 9032 EIDE & SCSI Controller +D 9033 SCSI Controller +D 9040 Multimedia card +D 9060 MegaRaid RAID Controller +V 101F PictureTel Corp +V 1020 Hitachi Computer Electronics +V 1021 Oki Electric Industry +V 1022 Advanced Micro Devices (AMD) +D 2000 AM79C970/1/2/3/5 Ethernet Adapter +O 1014 Netfinity Fault Tolerance PCI Adapter +S 2000 Netfinity Fault Tolerance PCI Adapter +O 103C Ethernet with LAN remote power Adapter +S 104C Ethernet with LAN remote power Adapter +S 1064 Ethernet with LAN remote power Adapter +S 1065 Ethernet with LAN remote power Adapter +S 106C Ethernet with LAN remote power Adapter +S 106E Ethernet with LAN remote power Adapter +S 10EA Ethernet with LAN remote power Adapter +O 1113 EN1220 10/100 Fast Ethernet +S 1220 EN1220 10/100 Fast Ethernet +O 1259 AT-2450 10/100 Fast Ethernet +S 2450 AT-2450 10/100 Fast Ethernet +S 2454 AT-2450v4 10Mb Ethernet Adapter +S 2700 AT-2700TX 10/100 Fast Ethernet +S 2701 AT-2700FX 100Mb Ethernet Adapter +D 2001 AM79C978 PCnet Single Chip Home Networking Controller 1/10Mbps +O 1092 Home Network Adapter +S 0A78 Home Network Adapter +O 1668 ActionLink Home Network Adapter +S 0299 ActionLink Home Network Adapter +D 2020 AM53C974 SCSI Bridge (AKA Qlogic Fast!SCSI Basic, Tekram DC-390) +D 2040 AM79C974 Ethernet & SCSI Bridge +D 7004 AMD-751 CPU to PCI Bridge (SMP Chipset) +D 7006 AMD-751 CPU to PCI Bridge +D 7007 AMD-751 PCI to AGP Bridge +D 700C AMD-762 CPU to PCI Bridge (SMP Chipset) +D 700D AMD-762 CPU to AGP Bridge (AGP 4x) +D 700E AMD-761 CPU to PCI Bridge +D 700F AMD-761 CPU to AGP Bridge (AGP 4x) +D 7400 AMD-755 PCI to ISA Bridge +D 7401 AMD-755 (Cobra) Bus Master IDE Controller +D 7403 AMD-755 Power Management Controller +D 7404 AMD-755 USB Open Host Controller +D 7408 AMD-756 PCI to ISA Bridge +O 1022 AMD-756 PCI to ISA Bridge +S 7408 AMD-756 PCI to ISA Bridge +D 7409 AMD-756 (Viper) Bus Master IDE Controller +D 740B AMD-756 Power Management Controller +D 740C AMD-756 USB Open Host Controller +D 7410 AMD-766 PCI to ISA/LPC Bridge +D 7411 AMD-766 EIDE Controller +D 7412 AMD-766 USB Controller +D 7413 AMD-766 Power Management Controller +D 7414 AMD-766 USB Host Controller +V 1023 Trident Microsystems +D 0194 82c194 Cardbus Controller +D 2000 4DWave(DX) PCI Audio +D 2001 4DWave(NX) PCI Audio +D 8400 CyberBlade i7 +O 1023 CyberBlade i7 +S 8400 CyberBlade i7 AGP +D 8420 CyberBlade i7 +O 0E11 CyberBlade i7 +S B15A CyberBlade i7 AGP +D 8500 CyberBlade/i1 +O 107B VT8361/VT8601 Graphics Controller +S 0106 VT8361/VT8601 Graphics Controller +O 1458 VT8361/VT8601 Graphics Controller +S D000 VT8361/VT8601 Graphics Controller +O 1462 VT8361/VT8601 Graphics Controller +S 3688 VT8361/VT8601 Graphics Controller +O 147A VT8361/VT8601 Graphics Controller +S D078 VT8361/VT8601 Graphics Controller +O 14A4 VT8361/VT8601 Graphics Controller +S 2139 VT8361/VT8601 Graphics Controller +O 1509 VT8361/VT8601 Graphics Controller +S 8914 VT8361/VT8601 Graphics Controller +O 1695 VT8361/VT8601 Graphics Controller +S 8500 VT8361/VT8601 Graphics Controller +O 1DE1 VT8361/VT8601 Graphics Controller +S 8630 VT8361/VT8601 Graphics Controller +O 270F VT8361/VT8601 Graphics Controller +S 7170 VT8361/VT8601 Graphics Controller +D 8520 CyberBlade i1 +O 0E11 CyberBlade i1 +S B16E CyberBlade i1 AGP +O 1023 CyberBlade i1 +S 8520 CyberBlade i1 AGP +D 9320 TGUI9320 GUI Accelerator +D 9350 GUI Accelerator +D 9360 Flat panel GUI Accelerator +D 9382 Cyber9382 Reference Design +D 9383 Cyber9383 Reference Design +D 9385 Cyber9385 Reference Design +D 9386 Cyber9386 Video Accelerator +D 9388 Cyber9388 Video Accelerator +O 13BD Cyber9388 Video Accelerator on Sharp Notebook +S 100A Cyber9388 Video Accelerator on sharp PC-A520 Notebook +D 9397 Cyber9397 Video Accelerator +D 939A Cyber9397DVD Video Accelerator +D 9420 TGUI9420 DGi GUI Accelerator +D 9430 TGUI9430 GUI Accelerator +D 9440 TGUI9440 DGi GUI Accelerator +D 9460 TGUI9460 GUI Accelerator +D 9470 TGUI9470 +D 9520 Cyber9520 Video Accelerator +D 9525 Cyber9525 Video Accelerator +D 9540 Cyber9540 Video Accelerator +D 9660 TGUI9660XGi/968x/938x GUI Accelerator +D 9680 TGUI9680 GUI Accelerator +D 9682 TGUI9682 Multimedia Accelerator +D 9683 TGUI9683 DUI Accelerator +D 9685 ProVIDIA 9685 +D 9750 3DImage 9750 PCI/AGP +O 1014 3DImage 9750 +S 9750 3DImage 9750 +O 1023 3DImage 9750 +S 9750 3DImage 9750 +D 9753 TGUI9753 Video Accelerator +D 9754 TGUI9753 Wave Video Accelerator +D 9759 TGUI975 Image GUI Accelerator +D 9783 TGUI9783 +D 9785 TGUI9785 +D 9850 3DImage 9850 AGP +O 1023 3DImage 9850 AGP +S 9850 3DImage 9850 AGP +D 9880 Blade 3D PCI/AGP +O 1023 Blade 3D +S 9880 Blade 3D +V 1024 Zenith Data Systems +V 1025 Acer Inc +D 1435 ALI M1435 VL to PCI Bridge +D 1445 ALI M1445 VL to PCI Bridge & Enhanced IDE Adapter +D 1449 ALI M1449 PCI to ISA Bridge +D 1451 ALI M1451 Pentium Chipset +D 1461 ALI M1461 P54C Chipset +D 1489 ALI M1489 486 Chipset +D 1511 ALI M1511 Aladdin +D 1512 ALI M1512 Aladdin +D 1513 ALI M1513 Aladdin +D 1521 ALI M1521 Aladdin III CPU Bridge +O 10B9 ALI M1521 Aladdin III CPU Bridge +S 1521 ALI M1521 Aladdin III CPU Bridge +D 1523 ALI M1523 ISA Bridge +O 10B9 ALI M1523 ISA Bridge +S 1523 ALI M1523 ISA Bridge +D 1531 ALI M1531 Aladdin IV/IV+ North Bridge +D 1533 ALI M1533 Aladdin IV/V ISA South Bridge +O 10B9 ALI M1533 Aladdin IV/V ISA South Bridge +S 1533 ALI M1533 Aladdin IV/V ISA South Bridge +D 1535 ALI M1535 Aladdin V+ PCI South Bridge +D 1541 ALI M1541 Aladdin V/V+ AGP+PCI North Bridge +O 10B9 ALI M1541 Aladdin V/V+ AGP+PCI North Bridge +S 1541 ALI M1541 Aladdin V/V+ AGP+PCI North Bridge +D 1542 ALI M1542 Aladdin V/V+ AGP+PCI North Bridge +D 1543 ALI M1543 Aladdin IV+/V South Bridge +D 1561 ALI M1561 Northbridge [Aladdin 7] +D 1621 ALI M1621 Aladdin Pro II PCI North Bridge +D 1631 ALI M1631 Aladdin Pro III PCI North Bridge +D 1641 ALI M1641 Aladdin Pro IV PCI North Bridge +D 3141 ALI M3141 GUI Accelerator, 2 MB Video-RAM +D 3143 ALI M3143 GUI Accelerator, 2 MB Video-RAM with DAC +D 3145 ALI M3145 GUI Accelerator, 2 MB Video-RAM +D 3147 ALI M3147 GUI Accelerator, 2 MB Video-RAM with DAC +D 3149 ALI M3149 GUI Accelerator, 4 MB Video-RAM +D 3151 ALI M3151 GUI Accelerator, 8 MB Video-RAM +D 3307 ALI M3307 MPEG-1 Decoder +D 3309 ALI M3309 MPEG Decoder +D 3321 ALI M3321 MPEG-II Decoder +D 5212 ALI M4803 +D 5215 ALI EIDE Controller +D 5217 ALI M5217 I/O Controller +D 5219 ALI M5219 I/O Controller +D 5225 ALI M5225 EIDE Controller +D 5229 ALI M5229 EIDE Controller +D 5235 ALI M5235 I/O Controller +D 5237 ALI M5237 USB Controller +D 5240 EIDE Controller +D 5241 PCMCIA Bridge +D 5242 General Purpose Controller +D 5243 PCI to PCI Bridge Controller +D 5244 Floppy Disk Controller +D 5247 ALI M1541 PCI to PCI Bridge +D 5251 ALI M5251 P1394 OHCI Controller +D 5427 ALI PCI to AGP Bridge +D 5451 ALI M5451 PCI AC-Link Controller Audio Device +D 5453 ALI M5453 PCI AC-Link Controller Modem Device +D 7101 ALI M7101 PCI PMU Power Management Controller +O 10B9 ALI M7101 PCI PMU Power Management Controller +S 7101 ALI M7101 PCI PMU Power Management Controller +V 1028 Dell Computer Corp +D 0001 PowerEdge Expandable RAID Controller 2/Si +D 0002 PowerEdge Expandable RAID Controller 3/Di +D 0003 PowerEdge Expandable RAID Controller 3/Si +D 0004 PowerEdge Expandable RAID Controller 3/Si +D 0005 PowerEdge Expandable RAID Controller 3/Di +D 0006 PowerEdge Expandable RAID Controller 3/Di +D 0008 PowerEdge Expandable RAID Controller 3/Di +V 1029 Siemens Nixdorf AG +V 102A LSI Logic, Headland Division +D 0000 HYDRA Pentium PCI Chipset (MPI) +D 0010 ASPEN 486 PCI Chipset +D 0310 L64364 ATMizer r II+ ATM-SAR Chip +V 102B Matrox Graphics Inc +D 0010 MGA-I (Impression??) +D 0518 MGA-PX2085 Ultima/Atlas +D 0519 MGA-2064W Millennium +D 051A MGA-1064SG Mystique +O 102B MGA-1084SG Mystique +S 1100 MGA-1084SG Mystique +S 1200 MGA-1084SG Mystique +O 110A Scenic Pro +S 0018 Scenic Pro C5 (D1025) +D 051B MGA-2164W Millennium II PCI +O 102B MGA-2164W Millennium II +S 051B MGA-2164W Millennium II +S 1100 MGA-2164W Millennium II +S 1200 MGA-2164W Millennium II +D 051E MGA-1164SG Mystique 220 AGP +D 051F MGA-2164WA Millennium II AGP +O 102B MGA-2164WA Millennium II AGP +S 1000 MGA-2164WA-B Millennium II AGP +S 2007 MGA-2164WA-B Millennium II AGP +D 0520 MGA-G200B Chipset (PCI) +O 102B MGA-G200 Chipset +S DBC2 G200 Multi-Monitor +S DBC8 G200 Multi-Monitor +S DBE2 G200 Multi-Monitor +S DBE8 G200 Multi-Monitor +S FF03 Millennium G200 SD PCI +S FF04 Marvel G200 PCI +D 0521 MGA-G200B Chipset (AGP) +O 1014 Millennium G200 AGP +S FF03 Millennium G200 AGP +O 102B MGA-G200 AGP +S 48E9 Mystique G200 AGP +S 48F8 Millennium G200 SD AGP +S 4A60 Millennium G200 LE AGP +S 4A64 Millennium G200 AGP +S C93C Millennium G200 AGP +S C9B0 Millennium G200 AGP +S C9BC Millennium G200 AGP +S CA60 Millennium G250 LE AGP +S CA6C Millennium G250 AGP +S DBBC Millennium G200 AGP +S DBC2 Millennium G200 MMS (Dual G200) +S DBC3 Millennium G200 MMS (Dual G200) +S DBC8 Millennium G200 MMS (Dual G200) +S DBD2 Millennium G200 MMS (Dual G200) +S DBD3 Millennium G200 MMS (Dual G200) +S DBD4 Millennium G200 MMS (Dual G200) +S DBD5 Millennium G200 MMS (Dual G200) +S DBD8 Millennium G200 MMS (Dual G200) +S DBD9 Millennium G200 MMS (Dual G200) +S DBE2 Millennium G200 MMS (Quad G200) +S DBE3 Millennium G200 MMS (Quad G200) +S DBE8 Millennium G200 MMS (Quad G200) +S DBF2 Millennium G200 MMS (Quad G200) +S DBF3 Millennium G200 MMS (Quad G200) +S DBF4 Millennium G200 MMS (Quad G200) +S DBF5 Millennium G200 MMS (Quad G200) +S DBF8 Millennium G200 MMS (Quad G200) +S DBF9 Millennium G200 MMS (Quad G200) +S F806 Mystique G200 Video AGP +S FF00 MGA-G200 AGP +S FF02 Mystique G200 AGP +S FF03 Millennium G200 AGP +S FF04 Marvel G200 AGP +O 110A MGA-G200 AGP +S 0032 MGA-G200 AGP +D 0525 MGA-G400 Chipset +R 80 MGA-G450 Chipset +O 0E11 MGA-G400 AGP +S B16F MGA-G400 AGP +O 102B Millennium G400/G450 Chipset +S 0328 Millennium G400 SDRAM +S 0338 Millennium G400 SDRAM +S 0378 Millennium G400 Single Head +S 0540 Millennium G450 AGP +S 0541 Millennium G450 AGP +S 0640 Millennium G450 AGP +S 0641 Millennium G450 AGP +S 07C0 Millennium G450 DualHead LE AGP +S 07C1 Millennium G450 DualHead LE AGP +S 0D40 Millennium G450 PCI +S 0D41 Millennium G450 PCI +S 19D8 Millennium G400 +S 19F8 Millennium G400 +S 2159 Millennium G400 Dual Head +S 2179 Millennium G400 Dual Head +S 217D Millennium G400 Max +S 2F58 Millennium G400 +S 2F78 Millennium G400 +S 3693 Marvel G400 AGP +S 5A80 Orion G400 AGP +S 5EB0 Orion G400 PCI +O 1458 MGA-G400 +S 0400 MGA-G400 +O B16F Matrox MGA-G400 AGP +S 0E11 Matrox MGA-G400 AGP +D 0D10 MGA-I Ultima/Impression +D 1000 MGA-G100 Chipset PCI +O 102B Productiva G100 PCI +S FF01 Productiva G100 PCI +S FF05 Productiva G100 Multi-Monitor PCI +D 1001 MGA-G100 Chipset AGP +O 102B MGA-G100 AGP +S 1001 MGA-G100 AGP +S FF00 MGA-G100 AGP +S FF01 MGA-G100 Productiva AGP +S FF03 Millennium G100 AGP +S FF04 MGA-G100 AGP +S FF05 MGA-G100 Productiva AGP Multi-Monitor +O 110A MGA-G100 AGP +S 001E MGA-G100 AGP +D 1525 Fusion G450 AGP +D 1527 Fusion Plus G800 AGP +D 2007 Mistral GUI+3D Accelerator +D 2527 MGA-G800 Chipset +D 4536 Meteor 2/MC Video Capture Card +D 6573 Shark 10/100 Multiport SwitchNIC +V 102C Chips And Technologies +D 00B8 CT64310 Wingine DGX DRAM GUI Accelerator +D 00C0 F69000 HiQVideo GUI Accelerator +D 00D0 F65545 Flat Panel GUI Accelerator +D 00D8 F65545 Flat Panel GUI Accelerator +D 00DC F65548 Flat Panel GUI Accelerator +D 00E0 F65550 HiQV32 GUI Accelerator +D 00E4 F65554 HiQV64 GUI Accelerator +D 00E5 F65555 HiQVPro GUI Accelerator +O 0E11 Armada 1700 Laptop Display Controller +S B049 Armada 1700 Laptop Display Controller +O 1179 Satellite notebooks +S 0001 Satellite 300CDS Notebook +D 00F0 F68554 +D 00F4 F68554 HiQVision GUI Controller +D 00F5 F68555 +D 01E0 65560 PCI +D 0C30 69030 AGP/PCI GUI Accelerator +V 102D Wyse Technologies +D 50DC 3328 Audio +V 102E Olivetti Advanced Technology +V 102F Toshiba America +D 0009 r4x00 CPU Bridge +D 0020 ATM Meteor 155 PCI Adapter +V 1030 TMC Research +V 1031 Miro Computer Products AG +D 5601 MiroVIDEO DC20 Video I/O & JPEG +D 5607 Video I/O & motion JPEG compressor +D 5631 Media 3D +D 6057 MiroVIDEO DC10/DC30 (plus) +V 1032 Compaq +V 1033 NEC Electronics Hong Kong +D 0001 PCI to 486-like bus Bridge +D 0002 PCI to VL98 Bridge +D 0003 ATM Controller +D 0004 R4000 PCI Bridge +D 0005 PCI to 486-like bus Bridge +D 0006 GUI Accelerator +D 0007 PCI to UX-Bus Bridge +D 0008 GUI Accelerator +D 0009 GUI Accelerator for 98 +D 001A [Nile II] +D 001D uPD98405 NEASCOT-S20 ATM Integrated SAR Controller +D 0021 Vrc4373 [Nile I] +D 0029 PowerVR PCX1 3D Accelerator +D 002A PowerVR 3D Accelerator +D 0035 uPD9210 USB Open Host Controller +O 1179 Satellite Notebooks +S 0001 Satellite 300CDS notebook +D 003E uPD66369 NAPCCARD Cardbus Controller +D 0046 PowerVR PCX2 3D Accelerator +D 005A Vrc5074 [Nile 4] +D 0063 uPD72862 Firewarden OHCI Compliant FireWire Controller +O 1033 uPD72862 Firewarden OHCI Compliant FireWire Controller +S 0063 uPD72862 Firewarden OHCI Compliant FireWire Controller +D 0067 PowerVR Neon 250 Chipset +O 1010 PowerVR Neon 250 +S 0020 PowerVR Neon 250 AGP +S 0080 PowerVR Neon 250 AGP +S 0088 PowerVR Neon 250 PCI +S 0090 PowerVR Neon 250 AGP +S 0098 PowerVR Neon 250 PCI +S 00A0 PowerVR Neon 250 AGP +S 00A8 PowerVR Neon 250 PCI +S 0120 PowerVR Neon 250 AGP +D 0074 56k Voice Modem +O 1033 RCV56ACF 56k Voice Modem +S 8014 RCV56ACF 56k Voice Modem +D 009B Vrc5476 +D 00CD uPD72870 FireWire OHCI Host Controller +O 1033 uPD72870 FireWire OHCI Host Controller +S 00CD uPD72870 FireWire OHCI Host Controller +D 00CE uPD72871 FireWire OHCI Host Controller +O 1033 uPD72871 FireWire OHCI Host Controller +S 00CE uPD72871 FireWire OHCI Host Controller +V 1034 Burndy/Framatome Connectors USA Ltd +V 1035 Industrial Technology Research +V 1036 Future Domain Corp +D 0000 TMC-18XX/TMC-3260 SCSI-2 Controller (36c70) +V 1037 Hitachi Micro Systems Inc +V 1038 AMP Incorporated +V 1039 Silicon Integrated Systems (SiS) +D 0001 Virtual PCI to PCI Bridge +D 0002 SiS86C6262 GUI Accelerator +D 0005 Pentium Chipset +D 0006 SiS85C501/2/3 Pentium PCI Chipset +D 0008 SiS85C503/5513 PCI to ISA Bridge (LPC Bridge) +D 0009 SiS600 Power Management Controller +D 0018 SiS85C503/5513 PCI to ISA Bridge (LPC Bridge) +D 0200 SiS5597/8 GUI Accelerator (SuperTX) +O 1039 SiS5597 SVGA (Shared RAM) +S 0000 SiS5597 SVGA (Shared RAM) +D 0204 82C204 +D 0205 SiS6205 GUI Accelerator with RAM-DAC, UMA-Support +D 0300 SiS300/SiS305 GUI Accelerator+3D +O 107D WinFast VR300 +S 2720 WinFast VR300 +D 0305 SiS305 2D/3D/DVD Accelerator +D 0315 SiS315 +D 0406 SiS85C501/2 Pentium PCI Chipset +D 0496 SiS85C496/497 486 PCI Chipset +D 0530 SiS530 CPU to PCI Bridge +D 0540 SiS540 CPU to PCI Bridge +D 0596 SiS596 Pentium PCI Chipset with IDE +D 0597 SiS5513 EIDE Controller (C step) +D 0601 SiS83C601 PCI Enhanced IDE Controller +D 0620 SiS620 CPU to PCI Bridge +D 0630 SiS630 CPU to PCI Bridge +D 0635 SiS635 +D 0730 SiS730x +D 0735 SiS735 +D 0900 SiS900 10/100 Ethernet Adapter +O 1039 SiS900 10/100 Ethernet Adapter +S 0900 SiS900 10/100 Ethernet Adapter +D 3602 SiS83C602 EIDE Controller +D 5107 SiS5107 Hot Docking Controller +D 5300 SiS540 PCI Display Adapter +D 5401 SiS5401 486 PCI Chipset +D 5511 SiS5511/5512 Pentium PCI Chipset +D 5513 SiS5513 EIDE Controller (A,B step) +O 1039 SiS5513 EIDE Controller (A,B step) +S 5513 SiS5513 EIDE Controller (A,B step) +D 5517 SiS5517 Pentium Chipset, CPU to PCI Bridge +D 5571 SiS5571 Pentium Chipset, CPU to PCI Bridge +D 5581 SiS5581 Pentium Chipset +D 5582 SiS5582 PCI to ISA Bridge +D 5591 SiS5591/2 CPU to PCI Bridge +D 5596 SiS5596 Pentium Chipset +D 5597 SiS5597 CPU to PCI Bridge +D 5600 SiS600 CPU to PCI Bridge +D 6204 SiS6204 Video decoder & MPEG interface +D 6205 SiS6205 VGA Controller +D 6225 SiS6225 GUI Accelerator +D 6236 SiS6236 AGP GUI Accelerator+3D +D 6300 SiS630 GUI Accelerator+3D +D 6306 SiS530,620 GUI Accelerator+3D +O 1039 SiS530,620 GUI Accelerator+3D +S 6306 SiS530,620 GUI Accelerator+3D +D 6326 SiS86C326 GUI Accelerator +O 1039 SiS6326 GUI Accelerator +S 6326 SiS6326 GUI Accelerator +O 1092 SpeedStar +S 0A50 SpeedStar A50 +S 0A70 SpeedStar A70 +S 4910 SpeedStar A70 +S 4920 SpeedStar A70 +O 1569 SiS6326 GUI Accelerator +S 6326 SiS6326 GUI Accelerator +D 7001 SiS5597/8 Universal Serial Bus Controller +D 7007 SiS OHCI Compliant FireWire Controller +D 7013 SiS7013 56k Modem +O 1043 SiS7013 56k Modem +S E010 SiS7013 56k Modem on CUSC Motherboard +D 7016 SiS7016 10/100 Ethernet Adapter +O 1039 SiS7016 10/100 Ethernet Adapter +S 7016 SiS7016 10/100 Ethernet Adapter +D 7018 SiS7018 PCI Audio Accelerator +O 1014 SiS7018 PCI Audio Accelerator +S 01B6 SiS7018 PCI Audio Accelerator +S 01B7 SiS7018 PCI Audio Accelerator +O 1019 SiS7018 PCI Audio Accelerator +S 7018 SiS7018 PCI Audio Accelerator +O 1025 SiS7018 PCI Audio Accelerator +S 000E SiS7018 PCI Audio Accelerator +S 0018 SiS7018 PCI Audio Accelerator +O 1039 SiS7018 PCI Audio Accelerator +S 7018 SiS7018 PCI Audio Accelerator +O 1043 SiS7018 PCI Audio Accelerator +S 800B SiS7018 PCI Audio Accelerator +O 1054 SiS7018 PCI Audio Accelerator +S 7018 SiS7018 PCI Audio Accelerator +O 107D SiS7018 PCI Audio Accelerator +S 5330 SiS7018 PCI Audio Accelerator +S 5350 SiS7018 PCI Audio Accelerator +O 1170 SiS7018 PCI Audio Accelerator +S 3209 SiS7018 PCI Audio Accelerator +O 1462 SiS7018 PCI Audio Accelerator +S 400A SiS7018 PCI Audio Accelerator +O 14A4 SiS7018 PCI Audio Accelerator +S 2089 SiS7018 PCI Audio Accelerator +O 14CD SiS7018 PCI Audio Accelerator +S 2194 SiS7018 PCI Audio Accelerator +O 14FF SiS7018 PCI Audio Accelerator +S 1100 SiS7018 PCI Audio Accelerator +O 152D SiS7018 PCI Audio Accelerator +S 8808 SiS7018 PCI Audio Accelerator +O 1558 SiS7018 PCI Audio Accelerator +S 1103 SiS7018 PCI Audio Accelerator +S 2200 SiS7018 PCI Audio Accelerator +O 1563 SiS7018 PCI Audio Accelerator +S 7018 SiS7018 PCI Audio Accelerator +O 15C5 SiS7018 PCI Audio Accelerator +S 0111 SiS7018 PCI Audio Accelerator +O 270F SiS7018 PCI Audio Accelerator +S A171 SiS7018 PCI Audio Accelerator +O A0A0 SiS7018 PCI Audio Accelerator +S 0022 SiS7018 PCI Audio Accelerator +V 103A Seiko Epson Corp +V 103B Tatung Corp Of America +V 103C Hewlett-Packard Company +D 1030 J2585A DeskDirect 10/100VG NIC +D 1031 DeskDirect 10/100 NIC +O 103C DeskDirect 10/100 NIC +S 1040 J2973A DeskDirect 10BaseT NIC +S 1041 J2585B DeskDirect 10/100VG NIC +S 1042 J2970A DeskDirect 10BaseT/2 NIC +D 1064 79C970 PCNet Ethernet Controller +D 10C1 NetServer Smart IRQ Router +D 10ED TopTools Remote Control +D 1200 82557B 10/100 NIC +D 1219 NetServer PCI Hot-Plug Controller +D 121A NetServer SMIC Controller +D 121B NetServer Legacy COM Port Decoder +D 121C NetServer PCI COM Port Decoder +D 2910 E2910A PCI Bus Exerciser +D 2920 Fast Host Interface +D 2924 W2924A PCI Host Interface Adapter +D 2925 E2925A PCI Bus Exerciser +D 2926 E2926A 64-bit PCI Bus Exerciser +D 2927 E2927A 64-bit 66/50MHz PCI Bus Exerciser +D 2940 E2940A 64-bit 66/50MHz CompactPCI Bus Exerciser +V 103E Solliday Engineering +V 103F Logic Modeling (Synopsys) +V 1040 AccelGraphics Inc (Kubota Pacific) +V 1041 Computrend +V 1042 PC Technology Inc +D 1000 RZ1000 FDC 37c665 EIDE +D 1001 RZ1001 / 37c922 +D 3000 Samurai 0 CPU to PCI Bridge +D 3010 Samurai 1 CPU to PCI Bridge +D 3020 Samurai IDE Controller +V 1043 Asustek Computer Inc +V 1044 Adaptec (Formerly: Distributed Processing Technology (DPT)) +D 1012 Domino RAID Egine +D A400 DPT 2124/9X SmartCache III/RAID SCSI Controller +D A500 PCI Bridge +D A501 SmartRAID V Controller +O 1044 I2O SmartRAID V Controller +S C001 I2O RAID PM1554U2 Ultra2 Single Channel +S C002 I2O RAID PM1654U2 Ultra2 Single Channel +S C003 I2O RAID PM1564U3 Ultra3 Single Channel +S C004 I2O RAID PM1564U3 Ultra3 Dual Channel +S C005 I2O RAID PM1554U2 Ultra2 Single Channel (NON ACPI) +S C00A I2O RAID PM2554U2 Ultra2 Single Channel +S C00B I2O RAID PM2654U2 Ultra2 Single Channel +S C00C I2O RAID PM2664U3 Ultra3 Single Channel +S C00D I2O RAID PM2664U3 Ultra3 Dual Channel +S C00E I2O RAID PM2554U2 Ultra2 Single Channel (NON ACPI) +S C00F I2O RAID PM2654U2 Ultra2 Single Channel (NON ACPI) +S C014 I2O RAID PM3754U2 Ultra2 Single Channel (NON ACPI) +S C015 I2O RAID PM3755U2B Ultra2 Single Channel (NON ACPI) +S C016 I2O RAID PM3755F Fibre Channel (NON ACPI) +S C01E I2O RAID PM3757U2 Ultra2 Single Channel +S C01F I2O RAID PM3757U2 Ultra2 Dual Channel +S C020 I2O RAID PM3767U3 Ultra3 Dual Channel +S C021 I2O RAID PM3767U3 Ultra3 Quad Channel +S C028 I2O RAID PM2865U3 Ultra3 Single Channel +S C029 I2O RAID PM2865U3 Ultra3 Dual Channel +S C02A I2O RAID PM2865F Fibre Channel +S C03C I2O RAID 2000S Ultra3 Single Channel +S C03D I2O RAID 2000S Ultra3 Dual Channel +S C03E I2O RAID 2000F Fibre Channel +S C046 I2O RAID 3000S Ultra3 Single Channel +S C047 I2O RAID 3000S Ultra3 Dual Channel +S C048 I2O RAID 3000F Fibre Channel +S C050 I2O RAID 5000S Ultra3 Single Channel +S C051 I2O RAID 5000S Ultra3 Dual Channel +S C052 I2O RAID 5000F Fibre Channel +S C05A I2O RAID 1000UDMA Ultra DMA +S C05B I2O RAID 1000UDMA Ultra DMA DAC +V 1045 OPTi Inc +D A0F8 82C750 Vendetta Chipset USB Controller +D C101 92C264 +D C178 82C178 LCD GUI Accelerator +D C556 82X556 Viper +D C557 82C557/8 Viper-M Pentium Bridge +D C558 82C558 Viper PCI to ISA Bridge with PnP +D C567 82C750 Vendetta Chipset (Viper Max) CPU to PCI Bridge +D C568 82C750 Vendetta Chipset (Viper Max) PCI to ISA Bridge +D C569 82C579 Viper XPress+ Chipset, Pentium to PCI Bridge +D C621 82C621 IDE Controller (Single FIFO) +D C700 82C700 FireStar PCI to ISA Bridge +O 03F4 Compaq Armarda +S 0E11 Compaq Armarda +D C701 82C701 FireStar Plus CPU to PCI Bridge +O 03F4 Compaq Armarda +S 0E11 Compaq Armarda +D C814 82C814 FireBridge I +D C822 82C822 VLB to CPU Bridge +D C824 82C824 FireFox PC-Card Cardbus Controller +D C825 82C825 FireBridge II +D C832 82C832 CPU to PCI Bridge and PCI to ISA Bridge +D C861 82C861 USB Controller +D C895 82C895 +D C935 EV1935 ECTIVA MachOne PCI Audio +D D568 82C825 FireBridge II PCI EIDE Controller +O 03F4 Compaq Armada +S 0E11 Compaq Armada +D D768 82C750 Vendetta Chipset UDMA EIDE Controller +V 1046 IPC Corp Ltd +V 1047 Genoa Systems Corp +V 1048 ELSA GmbH +D 1000 PCI to SCSI Bridge +D 3000 QuickStep 3000 +V 1049 Fountain Technology +V 104A SGS Thomson Microelectric +D 0008 STG 2000X +D 0009 STG 1764X +D 1746 STG 1764X +D 3520 MPEG-II decoder card +V 104B Buslogic +D 0140 BT-946C PCI-SCSI-2 MultiMaster +D 1040 BA80c30 PCI-SCSI MultiMaster +D 8130 BT-930/932/950/952 FlashPoint LT/DL/LW/DW Ultra(wide) SCSI +V 104C Texas Instruments (TI) +D 0500 100 MBit LAN Controller +D 0508 TMS380C2X Compressor Interface +D 1000 Eagle i/f AS +D 3D04 TVP4010 Permedia +D 3D07 TVP4020 Permedia 2 +O 1011 Comet +S 4D10 Comet +O 1040 AccelSTAR II +S 000F AccelSTAR II +O 1048 Winner 2000 +S 0A31 Winner 2000 +S 0A32 GLoria Synergy +O 107D WinFast 3D L2300 +S 2633 WinFast 3D L2300 +O 1092 FIRE GL 1000 PRO +S 0127 FIRE GL 1000 PRO +S 0136 FIRE GL 1000 PRO +S 0141 FIRE GL 1000 PRO +S 0146 FIRE GL 1000 PRO +S 0148 FIRE GL 1000 PRO +S 0149 FIRE GL 1000 PRO +S 0152 FIRE GL 1000 PRO +S 0154 FIRE GL 1000 PRO +S 0155 FIRE GL 1000 PRO +S 0156 FIRE GL 1000 PRO +S 0157 FIRE GL 1000 PRO +O 1097 Jeronimo Pro +S 3D01 Jeronimo Pro +O 1102 Graphics Blaster Extreme +S 100F Graphics Blaster Extreme +O 3D3D Reference Permedia 2 3D +S 0100 Reference Permedia 2 3D +D 8000 LYNX FireWire Host Controller +O E4BF EKF SNARE Series +S 1010 CF1-1-SNARE +S 1020 CF1-2-SNARE +D 8009 TSB12LV22 OHCI-Lynx Compliant FireWire Controller +O 104D 8032 OHCI i.LINK(IEEE 1394) PCI Host Controller +S 8032 8032 OHCI i.LINK(IEEE 1394) PCI Host Controller +D 8019 TSB12LV23 OHCI Compliant FireWire Controller +O 11BD Studio DVxxx Series +S 000A Studio DV500-1394 +S 000E Studio DV +S 000F Studio DV500-1394 +O E4BF EKF CYMBAL Series +S 1010 CF2-1-CYMBAL +D 8020 OHCI Compliant FireWire Controller +O 11BD Studio DV +S 000E Studio DV +D 8027 IEEE-1394 FireWire Adapter +O 1028 IEEE-1394 FireWire Adapter +S 00A4 IEEE-1394 FireWire Adapter in Dell Inspiron 8000 Laptop +D A001 TDC1570 64-Bit PCI ATM Interface +D A100 TDC1561 32-Bit PCI ATM Interface +D AC10 PCI1050 PC card Controller +D AC11 PCI1030 PC card Controller +D AC12 PCI1130 PC card Cardbus Controller +D AC13 PCI1031 PC card Cardbus Controller +D AC15 PCI1131 PC card Cardbus Controller +D AC16 PCI1250 PC card Cardbus Controller +D AC17 PCI1220 PC card Cardbus Controller +D AC18 PCI1260 PC card Cardbus Controller +D AC19 PCI1221 PC card Cardbus Controller +D AC1A PCI1210 PC card Cardbus Controller +D AC1B PCI1450 PC card Cardbus Controller +D AC1C PCI1225 PC card Cardbus Controller +D AC1D PCI1251 PC card Cardbus Controller +D AC1E PCI1211 PC card Cardbus Controller +D AC1F PCI1251B PC card Cardbus Controller +D AC20 PCI2030 PCI to PCI Bridge +D AC21 PCI2031 PCI to PCI Bridge +D AC22 PCI2032 PCI Docking Bridge +D AC30 PCI1260 PC card Cardbus Controller +D AC40 PCI4450 PC card Cardbus Controller +D AC41 PCI4410 PC card Cardbus Controller +D AC42 PCI4451 PC card Cardbus Controller +D AC50 PCI1410 PC card Cardbus Controller +D AC51 PCI1420 PC card Cardbus Controller +D AC52 PCI1451 PC card Cardbus Controller +D AC53 PCI1421 PC card Cardbus Controller +D AC60 PCI2040 PCI to DSP Bridge Controller +D FE00 FireWire Host Controller +D FE03 12C01A FireWire Host Controller +V 104D Sony Corp +D 8009 CXD1947A FireWire link layer/PCI Bridge +D 8039 CXD3222 OHCI i.LINK (IEEE 1394) PCI Host Controller +D 8056 Rockwell HCF 56K modem +D 808A Memory Stick Controller +V 104E Oak Technology Inc +D 0017 OTI-64017 +D 0107 OTI-107 Spitfire VGA +D 0109 Video Adapter +D 0111 OTI-64111 Spitfire +D 0217 OTI-64217 +D 0317 OTI-64317 +V 104F Co-Time Computer Ltd +V 1050 Winbond Electronics Corp +D 0000 NE2000 Ethernet Adapter +D 0001 W83769F Ethernet Adapter +D 0105 W82C105 Ethernet Adapter +D 0840 W89C840 Ethernet Adapter +O 1050 W89C840 Ethernet Adapter +S 0001 W89C840 Ethernet Adapter +S 0840 W89C840 Ethernet Adapter +D 0940 W89C940 NE2000-Compatible Ethernet Adapter +D 5A5A W89C940F NE2000-compatible Ethernet Adapter +D 6692 W6692CF ISDN Adapter +D 9970 W9970CF +V 1051 Anigma Corp +V 1052 ?Young Micro Systems +V 1053 ?Young Micro systems +V 1054 Hitachi Ltd +D 0001 PCI Bridge +D 0002 PCI Bus Controller +V 1055 SMSC (Was EFAR Microsystems; bought out in 1996) +D 0810 EFAR 486 Host Bridge +D 0922 EFAR Pentium Host Bridge +D 0926 EFAR PCI to ISA Bridge +D 9130 SLC90E66 Victory66 UDMA66 EIDE Controller (??) +D 9460 SLC90E66 Victory66 PCI to ISA Bridge +D 9461 SLC90E66 Victory66 UDMA66 EIDE Controller +D 9462 SLC90E66 Victory66 USB Host Controller +D 9463 SLC90E66 Victory66 Power Management Controller +V 1056 ICL +V 1057 Motorola +D 0001 MPC105 Eagle PowerPC Chipset +D 0002 MPC106 Grackle PowerPC Chipset +D 0100 MC145575 (HCF-PCI) +D 0431 KTI829c 100VG Ethernet Controller +D 1801 56301 Audio I/O Controller (MIDI) +O ECC0 Layla +S 0030 Layla +D 4801 Raven PowerPC Chipset +D 4802 Falcon +D 4803 Hawk +D 4806 CPX8216 +D 4809 CPX8216T HotSwap Controller +D 5600 SM56 PCI Modem +O 1057 SM56 PCI Modem +S 0300 SM56 PCI Speakerphone Modem +S 0301 SM56 PCI Voice Modem +S 0302 SM56 PCI Fax Modem +S 5600 SM56 PCI Voice modem +O 13D2 SM56 PCI Modem +S 0300 SM56 PCI Speakerphone Modem +S 0301 SM56 PCI Voice modem +S 0302 SM56 PCI Fax Modem +O 1436 SM56 PCI Modem +S 0300 SM56 PCI Speakerphone Modem +S 0301 SM56 PCI Voice modem +S 0302 SM56 PCI Fax Modem +O 144F SM56 PCI Modem +S 100C SM56 PCI Fax Modem +O 1494 SM56 PCI Modem +S 0300 SM56 PCI Speakerphone Modem +S 0301 SM56 PCI Voice modem +O 14C8 SM56 PCI Modem +S 0300 SM56 PCI Speakerphone Modem +S 0302 SM56 PCI Fax Modem +O 1668 SM56 PCI Modem +S 0300 SM56 PCI Speakerphone Modem +S 0302 SM56 PCI Fax Modem +V 1058 Electronics Telecommunication Research Inc (ETRI) +V 1059 Teknor Microsystems +V 105A Promise Technology +D 0D30 PDC20265 Ultra100 EIDE Controller +O 105A PDC20265 Ultra100 EIDE Controller +S 4D33 PDC20265 Ultra100 EIDE Controller +D 4D30 Ulta100 EIDE Controller +D 4D33 PDC20246 UltraATA Controller +D 4D38 PDC20262 UltraDMA66 EIDE Controller +D 5300 DC5030 EIDE Controller +V 105B Foxconn International +V 105C Wipro Infotech Limited +V 105D Number 9 Computer Company +D 2309 Imagine 128 v1 +D 2339 Imagine 128 v2 +O 105D Imagine 128 series 2 +S 0000 Imagine 128 series 2 4Mb VRAM +S 0001 Imagine 128 series 2 4Mb VRAM +S 0002 Imagine 128 series 2 4Mb VRAM +S 0003 Imagine 128 series 2 4Mb VRAM +S 0004 Imagine 128 series 2 4Mb VRAM +S 0005 Imagine 128 series 2 4Mb VRAM +S 0006 Imagine 128 series 2 4Mb VRAM +S 0007 Imagine 128 series 2 4Mb VRAM +S 0008 Imagine 128 series 2e 4Mb DRAM +S 0009 Imagine 128 series 2e 4Mb DRAM +S 000A Imagine 128 series 2 8Mb VRAM +S 000B Imagine 128 series 2 8Mb H-VRAM +O 13CC Metheus 5 Megapixel +S 0000 Metheus 5 Megapixel +D 493D Revolution 3D (T2R) +O 13CC Metheus 4/5 Megapixel (DualHead) +S 0002 Metheus 4 Megapixel (DualHead) +S 0003 Metheus 5 Megapixel (DualHead) +D 5348 Revolution 4 +V 105E Vtech Engineering Canada Ltd +V 105F Infotronic America Inc +V 1060 United Microelectronics (UMC) +D 0001 UM82C881 486 PCI Chipset +D 0002 UM82C886 PCI to ISA Bridge +D 0101 UM8673F PCI Enhanced IDE Controller +D 0881 UM8881 HB4 486 PCI Chipset +D 0886 UM8886 PCI to ISA Bridge +D 0891 UM82C891 Pentium Chipset +D 1001 UM886A Enhanced IDE Controller +D 673A UM8886 Enhanced IDE Controller +D 673B EIDE Master/DMA +D 8710 UM8710 GUI Accelerator +D 8821 CPU to PCI Bridge +D 8822 PCI to ISA Bridge +D 8851 Pentium CPU to PCI Bridge +D 8852 Pentium CPU to ISA Bridge +D 886A UM8886 PCI to ISA Bridge with EIDE +D 8881 UM8881 HB4 486 PCI Chipset +D 8886 UM8886 PCI to ISA Bridge +D 888A UM8886A +D 8891 UM8891 586 PCI Chipset +D 9017 UM9017F Ethernet +D 9018 UM9018 Ethernet +D 9026 UM9026 Fast Ethernet +D E881 UM8881 486 Chipset (Notebook) +D E886 UM8886 PCI to ISA Bridge with EIDE (Notebook) +D E88A UM8886N +D E891 UM8891 Pentium Chipset (Notebook) +V 1061 I.T.T. (X Tech) +D 0001 ITT AGX013/16 GUI Accelerator +D 0002 ITT 3204/3501 MPEG Decoder +V 1062 Maspar Computer Corp +V 1063 Ocean Office Automation +V 1064 Alcatel CIT +V 1065 Texas Microsystems +V 1066 Picopower Technology (National) +D 0000 PT80C826 VL Bridge +D 0001 PT86C521 Vesuvius V1-LS System Controller +D 0002 PT86C523 Vesuvius V3-LS ISA Bridge +D 0004 ISA Bridge +D 0005 National PC87550 System Controller +D 8002 PT86C523 Vesuvius V3-LS ISA Bridge +V 1067 Mitsubishi Electronics +D 1002 VG500 [VolumePro Volume Rendering Accelerator] +V 1068 Diversified Technology +V 1069 Mylex Corp +D 0001 DAC960P Wide-SCSI RAID Controller +D 0002 DAC960PD RAID Controller +D 0010 DAC960PG/PJ/PR/PT/PTL1/PRL RAID Controller +O 1069 DAC960PG/PJ/PR/PT/PTL1/PRL RAID Controller +S 0010 DAC960PG/PJ/PR/PT/PTL1/PRL RAID Controller +D 0050 AcceleRAID Disk Array +O 1069 AcceleRAID Disk Array +S 0050 AcceleRAID 352 Disk Array +S 0052 AcceleRAID 170 Disk Array +D BA55 eXtremeRAID support Device +D BA56 eXtremeRAID Disk Array +O 1069 eXtremeRAID Disk Array +S 0030 eXtremeRAID 3000 Disk Array +S 0040 eXtremeRAID 2000 Disk Array +V 106A Aten Research Inc +V 106B Apple Computer Inc +D 0001 Bandit +D 0002 Grand Central +D 0003 Control Video +D 0004 PlanB Video-In +D 0007 O'Hare I/O +D 000E Hydra +D 0010 Heathrow Mac I/O +D 0017 Paddington Mac I/O +V 106C Hyundai Electronics America +D 8801 Dual Pentium ISA/PCI Motherboard +D 8802 PowerPC ISA/PCI Motherboard +D 8803 Dual Window Graphics Accelerator +D 8804 PCI LAN Controller +D 8805 100-BaseT LAN Controller +V 106D Sequent Computer systems +V 106E DFI Inc +V 106F City Gate Development Ltd +V 1070 Daewoo Telecom Ltd +V 1071 Mitac +V 1072 GIT Co Ltd +V 1073 YAMAHA Corp +D 0001 3D GUI Accelerator +D 0002 YGV615 RPA3 3D-Graphics Controller +D 0003 YMF-740 +D 0004 YMF724 PCI Audio Controller +O 1073 YMF724-Based PCI Audio Adapter +S 0004 YMF724-Based PCI Audio Adapter +D 0005 DS1 Audio +O 1073 DS-XG PCI Audio CODEC +S 0005 DS-XG PCI Audio CODEC +D 0006 DS1 Audio +D 0008 DS1 Audio +O 1073 DS-XG PCI Audio CODEC +S 0008 DS-XG PCI Audio CODEC +D 000A DS1L Audio +O 1073 DS-XG PCI Audio CODEC +S 0004 DS-XG PCI Audio CODEC +S 000A DS-XG PCI Audio CODEC +D 000C YMF740C DS-1L Audio +O 107A DS-XG PCI Audio CODEC +S 000C DS-XG PCI Audio CODEC +D 000D YF724F DS-1 Audio +O 1073 DS-XG PCI Audio CODEC +S 000D DS-XG PCI Audio CODEC +D 0010 YMF744B DS-1S Audio +O 1073 DS-XG PCI Audio CODEC +S 0006 DS-XG PCI Audio CODEC +S 0010 DS-XG PCI Audio CODEC +D 0012 YMF754B DS-1S Audio +O 1073 DS-XG PCI Audio Codec +S 0012 DS-XG PCI Audio Codec +D 0020 DS-1 Audio +V 1074 Nexgen Microsystems +D 4E78 82C500/1 Nx586 Chipset +V 1075 Advanced Integration Research +V 1076 Chaintech Computer Co Ltd +V 1077 Qlogic +D 1020 ISP1020A Fast-Wide-SCSI "Fast!SCSI IQ" +D 1022 ISP1022A Fast-Wide-SCSI +D 1080 ISP1080 SCSI Host Adapter +D 1240 ISP1240 SCSI Host Adapter +D 1280 ISP1280 +D 2100 QLA2100 64bit Fibre Channel Adapter +O 1077 QLA2100 64bit Fibre Channel Adapter +S 0001 QLA2100 64bit Fibre Channel Adapter +D 2200 ISP2200 +V 1078 Cyrix Corp +D 0000 Cx5520 ISA Bridge Rev.0 +D 0001 MediaGX CPU PCI Master +D 0002 Cx5520 ISA Bridge Rev.1 +D 0100 5530 Kahula Legacy +D 0101 5530 Kahula SMI +D 0102 5530 Kahula IDE +D 0103 5530 Kahula Audio +D 0104 5530 Kahula Video +V 1079 I-Bus +V 107A Networth +V 107B Gateway 2000 +V 107C LG Electronics / Goldstar Co Ltd +V 107D Leadtek Research +D 0000 S3-805/P86C850 GUI Accelerator +V 107E Interphase Corp +D 0001 ATM Interface card +D 0002 100 VG amylan Controller +D 0004 5526 +D 0005 55x6 +D 0008 155 Mbit ATM Controller +V 107F Data Technology Corp (DTC) +D 0802 SL82c105 PCI EIDE Controller +D 0803 EIDE Bus Master Controller +D 0806 EIDE Controller +D 1138 High Speed Parallel Port +D 2015 EIDE Controller +V 1080 Contaq Corp +D 0600 82C596/9 PCI to VLB Bridge +D C691 Cypress CY82C691 +D C693 82C693 PCI to ISA Bridge +V 1081 Radius Inc/Supermac Technology Inc +D 0D47 Radius PCI to NuBUS Bridge +V 1082 EFA Corp Of America +V 1083 Forex Computer Corp +D 0001 FR710 PCI Enhanced IDE Adapter +D 0613 Host Bridge ?? +V 1084 Parador +V 1085 Tulip Computers Int'l BV +V 1086 J. Bond Computer Systems +V 1087 Cache Computer +V 1088 Microcomputer Systems (M) Son +V 1089 Data General Corp +V 108A Bit3 Computer +D 0001 VME Bridge Model 617 +D 0010 VME Bridge Model 618 +D 3000 VME Bridge Model 2706 +V 108C Oakleigh Systems Inc (Elonex PLC) +V 108D Olicom +D 0001 OC-3136/3137 16/4 PCI Adapter +R 01 OC-3136 16/4 PCI Adapter (Mk1) +R 02 OC-3136 16/4 PCI Adapter (Mk2) +R 03 OC-3137 16/4 PCI/II Adapter +D 0002 OC-3139f Fastload 16/4 PCI/III Token-Ring Adapter +D 0004 OC-3139/3140 RapidFire Token-Ring 16/4 Adapter +R 02 OC-3139 RapidFire Token-Ring 16/4 Adapter +R 03 OC-3140 RapidFire Token-Ring 16/4 Adapter +O 108D OC-3139/3140 RapidFire Token-Ring 16/4 Adapter +S 0004 OC-3139/3140 RapidFire Token-Ring 16/4 Adapter +D 0005 OC-3250 GoCard Token-Ring 16/4 Adapter +D 0006 OC-3530 RapidFire Token-Ring 100 Adapter +D 0007 OC-3141 RapidFire Token-Ring 16/4 Adapter +O 108D OC-3141 RapidFire Token-Ring 16/4 Adapter +S 0007 OC-3141 RapidFire Token-Ring 16/4 Adapter +D 0008 OC-3540 RapidFire HSTR 100/16/4 Adapter +O 108D OC-3540 RapidFire HSTR 100/16/4 Adapter +S 0008 OC-3540 RapidFire HSTR 100/16/4 Adapter +D 0011 OC-2805 Ethernet Controller +D 0012 OC-2325 Ethernet PCI/II 10/100 Controller +D 0013 OC-2183/2185 PCI/II Ethernet Controller +D 0014 OC-2326 Ethernet PCI/II 10/100 Controller +D 0021 OC-6151/6152 ATM Adapter +D 0022 ATM Adapter +V 108E Sun Microsystems +D 0001 SPARC EBUS +D 1000 EBUS +D 1001 Happy Meal Ethernet +D 5000 Simba PCI Bridge +D 5043 SunPCI Co-processor +D 8000 PCI Bus Module +D A000 UltraSPARC IIi PCI +V 108F Systemsoft Corp +V 1090 Encore Computer Corp +V 1091 Intergraph Corp +D 0020 3D Graphics Processor +D 0021 3D Graphics Processor w/Texturing +D 0040 3D Graphics Frame Buffer +D 0041 3D Graphics Frame Buffer +D 0060 Proprietary Bus Bridge +D 00E4 Powerstorm 4D50T +D 0720 Motion JPEG Codec +V 1092 Diamond Multimedia Systems +D 00A0 SpeedStar Pro SE GUI Accelerator +D 00A8 SpeedStar 64 GUI Accelerator +D 08D4 Supra 2260 Modem +D 1092 Viper V330 +D 6120 Maximum DVD +D 8810 Stealth SE GUI Accelerator +D 8811 Stealth 64/SE GUI Accelerator +D 8880 Stealth Video GUI Accelerator +D 8881 Stealth Video GUI Accelerator +D 88B0 Stealth 64 Video GUI Accelerator +D 88B1 Stealth 64 Video GUI Accelerator +D 88C0 Stealth 64 GUI Accelerator +D 88C1 Stealth 64 GUI Accelerator +D 88D0 Stealth 64 GUI Accelerator +D 88D1 Stealth 64 GUI Accelerator +D 88F0 Stealth 64 Video GUI Accelerator +D 88F1 Stealth 64 Video GUI Accelerator +D 9999 Monster Sound +V 1093 National Instruments +D 0160 PCI-DIO-96 +D 0162 PCI-MIO-16XE-50 +D 1150 PCI-DIO-32HS High Speed Digital I/O Board +D 1170 PCI-MIO-16XE-10 +D 1180 PCI-MIO-16E-1 +D 1190 PCI-MIO-16E-4 +D 1270 PCI-6032E Data Aquisition Card +D 1330 PCI-6031E +D 1340 PCI-6033E Data Aquisition Card +D 1350 PCI-6071E +D 2A60 PCI-6023E +D 2A70 PCI-6024E Data Aquisition Card +D 2A80 PCI-6025E Data Aquisition Card +D B001 IMAQ-PCI-1408 +D B011 IMAQ-PXI-1408 +D B021 IMAQ-PCI-1424 +D B031 IMAQ-PCI-1413 +D B041 IMAQ-PCI-1407 +D B051 IMAQ-PXI-1407 +D B061 IMAQ-PCI-1411 +D B071 IMAQ-PCI-1422 +D B081 IMAQ-PXI-1422 +D B091 IMAQ-PXI-1411 +D C801 PCI-GPIB Interface Board +V 1094 First International Computers +V 1095 CMD Technology Inc +D 0640 PCI-0640 EIDE Adapter (Single FIFO) +D 0641 PCI-0640 EIDE Adapter with RAID 1 +D 0642 PCI-0642 EIDE Adapter with RAID 1 +D 0643 PCI-0643 DMA IDE Controller +R 06 PCI-643U UltraDMA IDE Controller +D 0646 PCI-0646 EIDE Adapter (Single FIFO) +R 03 PCI-0646U UltraDMA IDE Controller +R 05 PCI-0646U2 UltraDMA IDE Controller +R 07 PCI-0646U2 UltraDMA IDE Controller +D 0647 PCI-0647 +D 0648 PCI-0648 UDMA66 EIDE Controller +O 1043 Dual UltraDMA/66 EIDE Controller +S 8025 CUBX Dual UltraDMA/66 EIDE Controller +D 0649 PCI-0649 UltraDMA/100 EIDE Controller +D 0650 PBC-0650A PCI Fast SCSI II Host Adapter +D 0670 USB0670 USB Controller +D 0673 USB0673 USB Controller +V 1096 Alacron +V 1097 Appian Technology (ETMA) +D 0038 EIDE Controller (Single FIFO) +V 1098 Quantum Designs H.K. Ltd +D 0001 QD8500 EIDE Controller +D 0002 QD8580 EIDE Controller +V 1099 Samsung Electronics Co Ltd +V 109A Packard Bell +V 109B Gemlight Computer Ltd +V 109C Megachips Corp +V 109D Zida Technologies Ltd +V 109E Brooktree Corp +D 0350 Bt848 Mediastream Controller +D 0351 Bt849 Video Capture +D 036C Bt879(??) Video Capture +O 13E9 Win/TV (Video Section) +S 0070 Win/TV (Video Section) +D 036E Bt878 Mediastream Controller +X 1200BD11 Miro PCTV (Video) +O 0070 WinTV +S 13EB WinTV PAL B-G +O 1002 ATI-TV Wonder +S 0001 ATI-TV Wonder +S 0002 ATI-TV Wonder FM +O 127A Bt878 Mediastream Controller +S 0001 Bt878 Mediastream Controller NTSC +S 0002 Bt878 Mediastream Controller PAL BG +S 0003 Bt878a Mediastream Controller PAL BG +S 0048 Bt878/832 Mediastream Controller +O 144F MagicTView CPH060 - Video +S 3000 MagicTView CPH060 - Video +O 1461 AverMedia TV Series +S 0001 AverMedia TV98(878) +S 0002 AverMedia TV98(878) +O 14F1 Bt878 Mediastream Controller +S 0001 Bt878 Mediastream Controller NTSC +S 0002 Bt878 Mediastream Controller PAL BG +S 0003 Bt878a Mediastream Controller PAL BG +S 0048 Bt878/832 Mediastream Controller +O 1851 FlyVideo'98 +S 1850 FlyVideo'98 - Video +S 1851 FlyVideo II +O 1852 FlyVideo'98 - Video (with FM Tuner) +S 1852 FlyVideo'98 - Video (with FM Tuner) +D 036F Bt879 Video Capture +O 127A Bt879 Video Capture +S 0044 Bt879 Video Capture NTSC +S 0122 Bt879 Video Capture PAL I +S 0144 Bt879 Video Capture NTSC +S 0222 Bt879 Video Capture PAL BG +S 0244 Bt879a Video Capture NTSC +S 0322 Bt879 Video Capture NTSC +S 0422 Bt879 Video Capture NTSC +S 1122 Bt879 Video Capture PAL I +S 1222 Bt879 Video Capture PAL BG +S 1322 Bt879 Video Capture NTSC +S 1522 Bt879a Video Capture PAL I +S 1622 Bt879a Video Capture PAL BG +S 1722 Bt879a Video Capture NTSC +O 1461 AverMedia TV Series +S 0001 AverMedia TV98 (879) +S 0002 AverMedia TV98 (879) +O 14F1 Bt879 Video Capture +S 0044 Bt879 Video Capture NTSC +S 0122 Bt879 Video Capture PAL I +S 0144 Bt879 Video Capture NTSC +S 0222 Bt879 Video Capture PAL BG +S 0244 Bt879a Video Capture NTSC +S 0322 Bt879 Video Capture NTSC +S 0422 Bt879 Video Capture NTSC +S 1122 Bt879 Video Capture PAL I +S 1222 Bt879 Video Capture PAL BG +S 1322 Bt879 Video Capture NTSC +S 1522 Bt879a Video Capture PAL I +S 1622 Bt879a Video Capture PAL BG +S 1722 Bt879a Video Capture NTSC +O 1851 FlyVideo'98 +S 1850 FlyVideo'98 - Video +S 1851 FlyVideo II +O 1852 FlyVideo'98 - Video (with FM Tuner) +S 1852 FlyVideo'98 - Video (with FM Tuner) +D 0370 Bt880 Video Capture +O 1461 AverMedia TV Series +S 0001 AverMedia TV98 (880) +S 0002 AverMedia TV98 (880) +O 1851 FlyVideo'98 +S 1850 FlyVideo'98 - Video +S 1851 FlyVideo'98 EZ - video +O 1852 FlyVideo'98 - Video (with FM Tuner) +S 1852 FlyVideo'98 - Video (with FM Tuner) +D 0878 Bt878 Video Capture (Audio Section) +X 1200BD11 Miro PCTV (Audio) +O 0070 WinTV +S 13EB WinTV PAL B-G +O 1002 ATI-TV Wonder +S 0001 ATI-TV Wonder Bt878 +S 0002 ATI-TV Wonder Bt878 +O 127A Bt878 Video Capture (Audio Section) +S 0001 Bt878 Video Capture (Audio Section) +S 0002 Bt878 Video Capture (Audio Section) +S 0003 Bt878 Video Capture (Audio Section) +S 0048 Bt878 Video Capture (Audio Section) +O 13E9 Win/TV (Audio Section) +S 0070 Win/TV (Audio Section) +O 144F MagicTView CPH060 - Audio +S 3000 MagicTView CPH060 - Audio +O 1461 AverMedia TV Series +S 0001 AverMedia TV98 (878 Audio Section) +S 0002 AverMedia TV98 (878 Audio Section) +O 14F1 Bt878 Video Capture (Audio Section) +S 0001 Bt878 Video Capture (Audio Section) +S 0002 Bt878 Video Capture (Audio Section) +S 0003 Bt878 Video Capture (Audio Section) +S 0048 Bt878 Video Capture (Audio Section) +D 0879 Bt879 Video Capture (Audio Section) +O 1002 ATI-TV Wonder +S 0001 ATI-TV Wonder Bt879 +S 0002 ATI-TV Wonder Bt879 +O 127A Bt879 Video Capture (Audio Section) +S 0044 Bt879 Video Capture (Audio Section) +S 0122 Bt879 Video Capture (Audio Section) +S 0144 Bt879 Video Capture (Audio Section) +S 0222 Bt879 Video Capture (Audio Section) +S 0244 Bt879 Video Capture (Audio Section) +S 0322 Bt879 Video Capture (Audio Section) +S 0422 Bt879 Video Capture (Audio Section) +S 1122 Bt879 Video Capture (Audio Section) +S 1222 Bt879 Video Capture (Audio Section) +S 1322 Bt879 Video Capture (Audio Section) +S 1522 Bt879 Video Capture (Audio Section) +S 1622 Bt879 Video Capture (Audio Section) +S 1722 Bt879 Video Capture (Audio Section) +O 1461 AverMedia TV Series +S 0001 AverMedia TV98 (879 Audio Section) +S 0002 AverMedia TV98 (879 Audio Section) +O 14F1 Bt879 Video Capture (Audio Section) +S 0044 Bt879 Video Capture (Audio Section) +S 0122 Bt879 Video Capture (Audio Section) +S 0144 Bt879 Video Capture (Audio Section) +S 0222 Bt879 Video Capture (Audio Section) +S 0244 Bt879 Video Capture (Audio Section) +S 0322 Bt879 Video Capture (Audio Section) +S 0422 Bt879 Video Capture (Audio Section) +S 1122 Bt879 Video Capture (Audio Section) +S 1222 Bt879 Video Capture (Audio Section) +S 1322 Bt879 Video Capture (Audio Section) +S 1522 Bt879 Video Capture (Audio Section) +S 1622 Bt879 Video Capture (Audio Section) +S 1722 Bt879 Video Capture (Audio Section) +D 0880 Bt880 Video Capture (Audio Section) +O 1461 AverMedia TV Series +S 0001 AverMedia TV98 (880 Audio Section) +S 0002 AverMedia TV98 (880 Audio Section +D 2115 BtV 2115 Mediastream Controller +D 2125 BtV 2125 Mediastream Controller +D 2164 BtV 2164 Display Adapter +D 2165 BtV 2165 Mediastream Controller +D 8230 BtV 8230 ATM Segment/Reassembly Ctrlr (SRC) +D 8471 Bt8471 32 Channel HDLC Controller +D 8472 Bt8471/2 32/64 Channel HDLC Contoller +D 8474 Bt8474 128 Channel HDLC Controller +V 109F Trigem Computer Inc +V 10A0 Meidensha Corp +V 10A1 Juko Electronics Inc Ltd +V 10A2 Quantum Corp +V 10A3 Everex Systems Inc +V 10A4 Globe Manufacturing Sales +V 10A5 Racal Interlan +V 10A6 Informtech Industrial +V 10A7 Benchmarq +V 10A8 Sierra Semiconductor +D 0000 STB Horizon 64 +V 10A9 Silicon Graphics +D 0001 Crosstalk to PCI Bridge +D 0002 Linc I/O Controller +D 0003 IOC3 I/O Controller +D 0004 O2 MACE +D 0005 RAD Audio +D 0006 HPCEX +D 0007 RPCEX +D 0008 DiVO VIP +D 0009 Alteon Gigabit Ethernet +D 0010 AMP Video I/O +D 0011 GRIP +D 0012 SGH PSHAC GSN +D 1001 Magic Carpet +D 1002 Lithium +D 1003 Dual JPEG 1 +D 1004 Dual JPEG 2 +D 1005 Dual JPEG 3 +D 1006 Dual JPEG 4 +D 1007 Dual JPEG 5 +D 1008 Cesium +D 2001 Fibre Channel +D 2002 ASDE +D 8001 O2 1394 +D 8002 G-net NT +V 10AA ACC Microelectronics +D 0000 ACC 2056/2188 CPU to PCI Bridge +D 2051 Laptop Chipset CPU Bridge +D 5842 Laptop Chipset ISA Bridge +V 10AB Digicom +V 10AC Honeywell IAC +V 10AD Symphony Labs +D 0001 W83769F PCI EIDE Controller (Signle FIFO) +D 0003 SL82C103 EIDE Controller +D 0005 SL82C105 EIDE Busmaster Controller +D 0103 SL82C103 EIDE Controller +D 0105 SL82C105 EIDE Busmaster Controller +D 0150 EIDE Controller +D 0565 W83C553 PCI EIDE Controller? +V 10AE Cornerstone Technology +D 0002 Graphics Controller +V 10AF Microcomputer Systems +D 0001 IDE Controller +V 10B0 Gainward (Cardexpert Technology?) +V 10B1 Cabletron Systems Inc +V 10B2 Raytheon Company +V 10B3 Databook Inc +D 3106 DB87144 Cardbus Controller +D B106 DB87144 +V 10B4 STB Systems +D 1B1D Velocity 128 3D +O 10B4 Velocity 4400 +S 237E Velocity 4400 +V 10B5 PLX Technology +D 0401 PCI9080RDK-401B PCI Reference Design Kit for PCI 9080 +D 0480 IOP 480 Integrated PowerPC I/O Processor +O 10B5 IOP 480 Integrated PowerPC I/O Processor +S 0480 IOP 480 Integrated PowerPC I/O Processor +D 0860 PCI9080RDK-860 PCI Reference Design Kit for PCI 9080 +D 0960 PCI9080RDK-960 PCI Reference Design Kit for PCI 9080 +D 1076 VScom 800 8 port serial adaptor +D 1077 VScom 400 4 port serial adaptor +D 1860 PCI9054RDK-860 PCI Reference Design Kit for PCI 9054 +D 2021 PCI9080 used in Daktronics VMax Quad Tansmitter Card +D 2288 Chrislin Industries Memory +O 10B5 Chrislin Industries Memory +S 9054 Chrislin Industries Memory +D 3001 PCI9030RDK-LITE PCI Reference Design Kit for PCI 9030 +D 30C1 cPCI 9030RDK-LITE CompactPCI Reference Design Kit for PCI 9030 +D 5406 PCI9054RDK-LITE PCI Bus Master Prototyping Kit for PCI 9054 +D 6466 GBP32 PCI Adaptive Switch Fabric Generator +D 9030 PCI9030 PCI SMARTagent I/O Accelerator +D 9036 PCI9036 PCI Interface Chip +D 9050 PCI9050 Target PCI Interface Chip +O 10B5 PCI9050 Target PCI Interface Chip +S 1150 Pickering Interfaces PXI +S 2273 SH-ARC SoHard ARCnet Card +O 1522 RockForce V.90 Modem +S 0001 RockForce 4 port V.90 Modem +S 0002 RockForce 2 port V.90 Modem +S 0003 RockForce 6 port V.90 Modem +S 0004 RockForce 8 port V.90 Modem +S 0010 RockForce 2000 4 port v.90 Modem +S 0020 RockForce 2000 2 port v.90 Modem +D 9052 PCI9052 Target PCI Interface Chip +O D84D EX-Series +S 4006 EX-4006 1P +S 4008 EX-4008 1P EPP/ECP +S 4014 EX-4014 2P +S 4018 EX-4018 3P EPP/ECP +S 4025 EX-4025 1S(16C550) RS-232 +S 4027 EX-4027 1S(16C650) RS-232 +S 4028 EX-4028 1S(16C850) RS-232 +S 4036 EX-4036 2S(16C650) RS-232 +S 4037 EX-4037 2S(16C650) RS-232 +S 4038 EX-4038 2S(16C850) RS-232 +S 4052 EX-4052 1S(16C550) RS-422/485 +S 4053 EX-4053 2S(16C550) RS-422/485 +S 4055 EX-4055 4S(16C550) RS-232 +S 4058 EX-4055 4S(16C650) RS-232 +S 4065 EX-4065 8S(16C550) RS-232 +S 4068 EX-4068 8S(16C650) RS-232 +S 4078 EX-4078 2S(16C552) RS-232+1P +D 9054 PCI9054 PCI Interface Chip +O 10B5 PCI9054 PCI Interface Chip +S 9054 PCI9054 PCI Interface Chip +D 9056 PCI9056 66MHz PCI I/O Accelerator +O 10B5 PCI9056 66MHz PCI I/O Accelerator +S 9056 PCI9056 66MHz PCI I/O Accelerator +D 9060 PCI9060 PCI Bus Interface Chip +D 906D PCI9060SD PCI Bus Interface Chip +O 125C Aries 16000P +S 0640 Aries 16000P +D 906E PCI9060ES PCI Bus Interface Chip +D 9080 PCI9080 PCI to Local Bus Chip +O 10B5 PCI9080 PCI to Local Bus Chip +S 9080 PCI9080 PCI to Local Bus Chip +D 9610 PCI9610 64 bit 66MHz PCI Master I/O Accelerator +D 9656 PCI9656 64 bit 66MHz PCI I/O Accelerator +D C860 cPCI 9054RDK-860 CompactPCI Reference Design Kit for PCI 9054 +V 10B6 Madge Networks +D 0001 Smart 16/4 Ringnode (PCI1b) +D 0002 Smart 16/4 Ringnode (PCIBM2/Cardbus) +O 10B6 Smart 16/4 Ringnode (PCIBM2/Cardbus) +S 0002 Smart 16/4 Ringnode Mk2 (PCIBM2) +S 0006 16/4 Cardbus Adapter (Eric) +D 0003 Smart 16/4 Ringnode (Knossos Series) +R 01 Presto PCI Plus Smart 16/4 Ringnode (Knossos Series) +R 02 Presto PCI 2000 Smart 16/4 Ringnode (Knossos Series) +O 0E11 NC4621 4/16 Token-Ring Adapter + WOL +S B0FD NC4621 4/16 Token-Ring Adapter + WOL +O 10B6 Smart 16/4 Ringnode (Knossos Series) +S 0003 Smart 16/4 Ringnode Mk3 +S 0007 Presto PCI Plus/2000 +D 0004 Smart 16/4 Ringnode Mk1 (PCIBM1) +D 0006 16/4 Cardbus Adapter (Eric 2) +O 10B6 16/4 Cardbus Adapter (Eric 2) +S 0006 16/4 Cardbus Adapter (Eric 2) +D 0007 Presto PCI +O 10B6 Presto PCI +S 0007 Presto PCI +D 0009 Smart 100/16/4 PCI-HS Ringnode +O 10B6 Smart 100/16/4 PCI-HS Ringnode +S 0009 Smart 100/16/4 PCI-HS Ringnode +D 000A Smart 100/16/4 PCI Ringnode +O 10B6 Smart 100/16/4 PCI Ringnode +S 000A Smart 100/16/4 PCI Ringnode +D 000B 16/4 Cardbus Adapter Mk2 +O 10B6 16/4 Cardbus Adapter Mk2 +S 0008 16/4 Cardbus Adapter Mk2 +S 000B 16/4 Cardbus Adapter Mk2 +D 1000 Collage 25 ATM Adapter +D 1001 Collage 155 ATM Adapter +V 10B7 3COM Corp, Networking Division +D 0001 3C985 1000BaseSX +D 1007 3C556 V.90 Mini-PCI Modem +O 10B7 3C556 V.90 Mini-PCI Modem +S 6137 3C556 V.90 Mini-PCI Modem in Dell Inspiron 8000 Laptop +S 615B 3C556 V.90 Mini-PCI Modem in Dell Laptop +D 3390 Token Link Velocity +D 3590 3C359 TokenLink Velocity XL Adapter +O 10B7 TokenLink Velocity XL Adapter +S 3590 TokenLink Velocity XL Adapter +D 4500 3c450 Cyclone/unknown +D 5055 3c555 Laptop Hurricane +D 5057 3C575 Megahertz 10/100 LAN Cardbus PC Card +O 10B7 3C575 Megahertz 10/100 LAN Cardbus PC Card +S 5A57 3C575 Megahertz 10/100 LAN Cardbus PC Card +D 5157 3C575 Megahertz 10/100 LAN Cardbus PC Card +O 10B7 3C575 Megahertz 10/100 LAN Cardbus PC Card +S 5B57 3C575 Megahertz 10/100 LAN Cardbus PC Card +D 5257 3CCFE575CT Cyclone Fast Ethernet CardBus PC Card +O 10B7 FE575C 10/100 CardBus Fast Ethernet PC Card +S 5C57 FE575C 10/100 CardBus Fast Ethernet PC Card +D 5900 3C590 PCI Ethernet Adapter 10bT +D 5920 3c592 PCI/EISA 10Mb Demon/Vortex +D 5950 3C595 PCI Ethernet Adapter 100bTX +D 5951 3C595 PCI Ethernet Adapter 100bT4 +D 5952 3C595 PCI Ethernet Adapter 100b-MII +D 5970 3C597 PCI/EISA 10/100 Demon/Vortex +D 5B57 3C595 Megahertz 10/100 LAN CardBus +O 10B7 3C575 Megahertz 10/100 LAN Cardbus PC Card +S 5B57 3C575 Megahertz 10/100 LAN Cardbus PC Card +D 6055 3C556 10/100 Mini PCI Fast Ethernet Adapter +O 10B7 3C556 10/100 Mini PCI Fast Ethernet Adapter +S 6456 3C556 10/100 Mini PCI Fast Ethernet Adapter +D 6056 3C556 10/100 Mini PCI Fast Ethernet Adapter +O 10B7 3C556 10/100 Mini PCI Fast Ethernet Adapter +S 6356 3C556 10/100 Mini PCI Fast Ethernet Adapter +D 6560 3CCFE656 Cyclone Ethernet+56k Modem CardBus PC Card +O 10B7 FEM656 10/100 LAN+56K Modem CardBus PC Card +S 656A FEM656 10/100 LAN+56K Modem CardBus PC Card +D 6561 FEM656 10/100 LAN+56K Modem CardBus PC Card +O 10B7 FEM656 10/100 LAN+56K Modem CardBus PC Card +S 656B FEM656 10/100 LAN+56K Modem CardBus PC Card +D 6562 3CCFEM656 [id 6562] Cyclone CardBus PC Card +O 10B7 FEM656B 10/100 LAN+56K Modem CardBus PC Card +S 656B FEM656B 10/100 LAN+56K Modem CardBus PC Card +D 6563 FEM656B 10/100 LAN+56K Modem CardBus PC Card +O 10B7 FEM656B 10/100 LAN+56K Modem CardBus PC Card +S 656B FEM656B 10/100 LAN+56K Modem CardBus PC Card +D 6564 3CCFEM656 [id 6564] Cyclone CardBus PC Card +D 6565 3CCFEM656C Global 10/10 Fast Ethernet+56K Modem CardBus PC Card +D 7646 3CSOHO100-TX Hurricane +D 8811 Token Ring Adapter +D 9000 3C900-TPO Fast Ethernet +D 9001 3C900-Combo Fast Etherlink +D 9004 3C900B-TPO Etherlink XL TPO 10Mb +O 10B7 3C900B-TPO Etherlink XL TPO 10Mb +S 9004 3C900B-TPO Etherlink XL TPO 10Mb +D 9005 3C900B-Combo Etherlink XL Combo +O 10B7 3C900B-Combo Etherlink XL Combo +S 9005 3C900B-Combo Etherlink XL Combo +D 9006 3C900B-TPC Etherlink XL TPC +D 900A 3C900B-FL Etherlink XL FL +D 9050 3C905-TX Fast Etherlink 10/100 +X FFFF0082 3C905-TX Fast Etherlink 10/100 +X FFFF008D 3C905-TX Fast Etherlink 10/100 +D 9051 3C905-T4 Fast Etherlink XL 10/100 +D 9055 3C905B Fast Etherlink XL 10/100 +O 1028 3C905B Fast Etherlink XL 10/100 +S 0080 3C905B Fast Etherlink XL 10/100 +S 0081 3C905B Fast Etherlink XL 10/100 +S 0082 3C905B Fast Etherlink XL 10/100 +S 0083 3C905B Fast Etherlink XL 10/100 +S 0084 3C905B Fast Etherlink XL 10/100 +S 0085 3C905B Fast Etherlink XL 10/100 +S 0086 3C905B Fast Etherlink XL 10/100 +S 0087 3C905B Fast Etherlink XL 10/100 +S 0088 3C905B Fast Etherlink XL 10/100 +S 0089 3C905B Fast Etherlink XL 10/100 +S 0090 3C905B Fast Etherlink XL 10/100 +S 0091 3C905B Fast Etherlink XL 10/100 +S 0092 3C905B Fast Etherlink XL 10/100 +S 0093 3C905B Fast Etherlink XL 10/100 +S 0094 3C905B Fast Etherlink XL 10/100 +S 0095 3C905B Fast Etherlink XL 10/100 +S 0096 3C905B Fast Etherlink XL 10/100 +S 0097 3C905B Fast Etherlink XL 10/100 +S 0098 3C905B Fast Etherlink XL 10/100 +S 0099 3C905B Fast Etherlink XL 10/100 +O 10B7 3C905B Fast Etherlink XL 10/100 +S 9055 3C905B Fast Etherlink XL 10/100 +D 9056 3c905B-T4 Fast Etherlink XL 10/100 +D 9058 3C905B-Combo Deluxe Etherlink XL 10/100 +D 905A 3C905B-FX Fast Etherlink XL FX 10/100 +D 9200 3C905C-TX Fast Etherlink for PC Management NIC +O 103C Integrated Fast Ethernet +S 1246 Vectra VL400DT Integrated Fast Ethernet +O 10B7 3C905C-TX Fast Etherlink for PC Management NIC +S 1000 3C905C-TX Fast Etherlink for PC Management NIC +D 9800 3C980-TX Fast Etherlink XL Server Adapter +O 10B7 3C980-TX Fast Etherlink XL Server Adapter +S 9800 3C980-TX Fast Etherlink XL Server Adapter +D 9805 3C980-TX 10/100baseTX NIC [Python-T] +O 10B7 3C980 10/100baseTX NIC [Python-T] +S 9805 3C980 10/100baseTX NIC [Python-T] +D 9902 3CR990-TX-95 Etherlink 10/100 with 3XP Processor +D 9903 3CR990-TX-97 Etherlink 10/100 with 3XP Processor +D 9908 3CR990SVR95 Etherlink 10/100 Server with 3XP Processor +D 9909 3CR990SVR97 Etherlink 10/100 Server with 3XP Processor +V 10B8 Standard Microsystems Corp (SMC) +D 0005 83C170QF/171 Fast Ethernet Adapter +O 1055 LANEPIC Fast Ethernet Adapter +S E000 LANEPIC Fast Ethernet Adapter +S E002 LANEPIC Fast Ethernet Adapter +O 10B8 EtherPower II 10/100 Ethernet Adapter +S A011 EtherPower II 10/100 Ethernet Adapter +S A014 EtherPower II 10/100 Ethernet Adapter +S A015 EtherPower II 10/100 Ethernet Adapter +S A016 EtherPower II 10/100 Ethernet Adapter +S A017 EtherPower II 10/100 Ethernet Adapter +D 0006 Fast Ethernet Adapter +O 1055 LANEPIC Cardbus Fast Ethernet Adapter +S E100 LANEPIC Cardbus Fast Ethernet Adapter +S E102 LANEPIC Cardbus Fast Ethernet Adapter +S E300 LANEPIC Cardbus Fast Ethernet Adapter +S E302 LANEPIC Cardbus Fast Ethernet Adapter +O 10B8 LANEPIC Cardbus Fast Ethernet Adapter +S A012 LANEPIC Cardbus Fast Ethernet Adapter +O 13A2 LANEPIC Cardbus Fast Ethernet Adapter +S 8002 LANEPIC Cardbus Fast Ethernet Adapter +S 8006 LANEPIC Cardbus Fast Ethernet Adapter +D 1000 FDC 37C665 +D 1001 FDC 37C922 +D A011 83C170QF Fast Ethernet Controller +D B106 SMC34C90 Cardbus Controller +V 10B9 Acer Labs Incorporated (ALI) +D 0111 C-Media CMI8738/C3DX Audio Device (OEM) +O 10B9 C-Media CMI8738/C3DX Audio Device (OEM) +S 0111 C-Media CMI8738/C3DX Audio Device (OEM) +D 1435 ALI M1435 VL to PCI Bridge +D 1445 ALI M1445 VL to PCI Bridge & Enhanced IDE Adapter +D 1449 ALI M1449 PCI to ISA Bridge +D 1451 ALI M1451 Pentium PCI Chipset +D 1461 ALI M1461 Pentium PCI Chipset +D 1489 ALI M1489 486 PCI Chipset +D 1511 ALI M1511 Aladdin II +D 1512 ALI M1512 Aladdin +D 1513 ALI M1513 Aladdin +D 1521 ALI M1521 Aladdin III CPU to PCI Bridge +O 10B9 ALI M1521 Aladdin III CPU to PCI Bridge +S 1521 ALI M1521 Aladdin III CPU to PCI Bridge +D 1523 ALI M1523 ISA Bridge +O 10B9 ALI M1523 ISA Bridge +S 1523 ALI M1523 ISA Bridge +D 1531 ALI M1531 Aladdin IV/IV+ CPU to PCI Bridge +O 10B9 ALI M1531 Aladdin IV/IV+ CPU to PCI Bridge +S 1531 ALI M1531 Aladdin IV/IV+ CPU to PCI Bridge +D 1533 ALI M1533 Aladdin IV ISA Bridge +O 10B9 ALI M1533 Aladdin IV ISA Bridge +S 1533 ALI M1533 Aladdin IV ISA Bridge +D 1535 ALI M1535x ISA Bridge +D 1541 ALI M1541 Aladdin V/V+ AGP System Controller +O 10B9 ALI M1541 Aladdin V/V+ AGP System Controller +S 1541 ALI M1541 Aladdin V/V+ AGP System Controller +D 1543 ALI M1543 PCI South Bridge Aladdin IV+/V +D 1561 ALI M1561 Aladdin 7 +D 1621 ALI M1621 Aladdin Pro II CPU to PCI Bridge +D 1631 ALI M1631 Aladdin Pro III CPU to PCI Bridge +D 1632 ALI M1632 Aladdin i1 CyberBlade +D 1641 ALI M1641 Aladdin Pro IV CPU to PCI Bridge +D 1644 ALI M1644 AGP System Controller +D 1646 ALI M1646 AGP System Controller +D 1647 ALI M1647 ALiMAGiK 1 +D 1651 ALI M1651 Aladdin Pro V +D 1661 ALI M1661 AGP System Controller +D 1667 ALI M1667 AGP System Controller +D 3141 ALI M3141 GUI Accelerator 2Mb +D 3143 ALI M3143 GUI Accelerator 2Mb + DAC +D 3145 ALI M3145 GUI Accelerator 2Mb +D 3147 ALI M3147 GUI Accelerator 2Mb + DAC +D 3149 ALI M3149 GUI Accelerator 4Mb +D 3151 ALI M3151 GUI Accelerator 8Mb +D 3307 ALI M3307 MPEG-1 Decoder +D 3309 ALI M3309 MPEG Decoder +D 5212 ALI M4803 +D 5215 ALI MS4803 PCI Enhanced IDE Controller +D 5217 ALI M5217 I/O Controller +D 5219 ALI M5219 I/O Controller +D 5225 ALI M5225 EIDE Controller +D 5229 ALI M5229 EIDE Controller +D 5235 ALI M5235 I/O Controller +D 5237 ALI M5237 USB Host Controller +D 5240 EIDE Controller +D 5241 PCMCIA Bridge +D 5242 General Purpose Controller +D 5243 ALI M1541 PCI to AGP Bridge +D 5244 Floppy Disk Controller +D 5247 ALI M1621 PCI to AGP Bridge +D 5427 ALI PCI to AGP Bridge +D 5451 ALI M5451 PCI AC-Link Controller Audio Device +D 5453 ALI M5453 PCI AC-Link Controller Modem Device +D 7101 ALI M7101 Power Management Controller +O 10B9 ALI M7101 Power Management Controller +S 1533 ALI M7101 Power Management Controller on IBM Thinkpad +S 7101 ALI M7101 Power Management Controller +V 10BA Mitsubishi Electric Corp +D 0301 GUI Accelerator +X 1040001A AccelGraphics AccelECLIPSE +V 10BB Dapha Electronics Corp +V 10BC Advanced Logic Research Inc +V 10BD Surecom Technology +D 0E34 NE-34 LAN Adapter +D 5240 EIDE Controller +D 5241 PCMCIA Bridge +D 5242 General Purpose Controller +D 5243 Bus Controller +D 5244 Floppy Disk Controller +V 10BE Tsenglabs International Corp +V 10BF MOST Corp +V 10C0 Boca Research Inc +V 10C1 ICM Corp Ltd +V 10C2 Auspex Systems Inc +V 10C3 Samsung Semiconductor Inc +D 1100 SmartEther100 SC1100 LAN Adapter (i82557B) +D 8920 KS8920 Fast Ethernet Adapter +V 10C4 Award Software International Inc +V 10C5 Xerox Corp +V 10C6 Rambus Inc +V 10C7 Media Vision +V 10C8 Neomagic Corp +D 0000 Graphics Controller +D 0001 NM2070 MagicGraph 128 +D 0002 NM2090 MagicGraph 128V +D 0003 NM2093 MagicGraph 128ZV +D 0004 NM2160 MagicGraph 128XD +X 10C80004 NM2160 MagicGraph 128XD on IBM Thinkpad (2611 Series) +O 1014 NM2160 MagicGraph 128XD +S 00BA NM2160 MagicGraph 128XD +O 1025 NM2160 MagicGraph 128XD +S 1007 NM2160 MagicGraph 128XD +O 1028 NM2160 MagicGraph 128XD +S 0074 NM2160 MagicGraph 128XD +S 0075 NM2160 MagicGraph 128XD +S 007D NM2160 MagicGraph 128XD +S 007E NM2160 MagicGraph 128XD +O 1033 NM2160 MagicGraph 128XD +S 802F NM2160 MagicGraph 128XD +O 104D NM2160 MagicGraph 128XD +S 801B NM2160 MagicGraph 128XD +S 802F NM2160 MagicGraph 128XD +S 830B NM2160 MagicGraph 128XD +O 10BA NM2160 MagicGraph 128XD +S 0E00 NM2160 MagicGraph 128XD +O 10C8 NM2160 MagicGraph 128XD +S 0004 NM2160 MagicGraph 128XD +O 10CF NM2160 MagicGraph 128XD +S 1029 NM2160 MagicGraph 128XD +O 10F7 NM2160 MagicGraph 128XD +S 8308 NM2160 MagicGraph 128XD +S 8309 NM2160 MagicGraph 128XD +S 830B NM2160 MagicGraph 128XD +S 830D NM2160 MagicGraph 128XD +S 8312 NM2160 MagicGraph 128XD +D 0005 NM2200 MagicMedia 256AV +D 0006 NM2360 MagicMedia 256ZX / 256M6D +D 0016 NM2380 MagicMedia 256XL+ +D 0083 NM2097 MagicGraph 128ZV+ +D 8005 NM2200 MagicMedia 256AV Audio Device +O 0E11 NM2200 MagicMedia 256AV Audio Device +S B0D1 NM2200 MagicMedia 256AV Audio Device on Discovery +S B126 NM2200 MagicMedia 256AV Audio Device on Durango +O 1014 NM2200 MagicMedia 256AV Audio Device +S 00DD NM2200 MagicMedia 256AV Audio Device on BlackTip Thinkpad +O 1025 NM2200 MagicMedia 256AV Audio Device +S 1003 NM2200 MagicMedia 256AV Audio Device on TravelMate 720 +O 1028 NM2200 MagicMedia 256AV Audio Device +S 008F NM2200 MagicMedia 256AV Audio Device on Colorado Inspiron +O 103C NM2200 MagicMedia 256AV Audio Device +S 0007 NM2200 MagicMedia 256AV Audio Device on Voyager II +S 0008 NM2200 MagicMedia 256AV Audio Device on Voyager III +S 000D NM2200 MagicMedia 256AV Audio Device on Omnibook 900 +O 10C8 NM2200 MagicMedia 256AV Audio Device +S 8005 NM2200 MagicMedia 256AV Audio Device on FireAnt +O 110A NM2200 MagicMedia 256AV Audio Device +S 8005 NM2200 MagicMedia 256AV Audio Device +O 14C0 NM2200 MagicMedia 256AV Audio Device +S 0004 NM2200 MagicMedia 256AV Audio Device +D 8006 NM2360 MagicMedia 256ZX Audio Device +D 8016 NM2380 MagicMedia 256XL+ Audio Device +V 10C9 Dataexpert Corp +V 10CA Fujitsu Microelectronic +V 10CB Omron Corp +V 10CC Mentor Arc Inc +D 0226 PCI to ISA Bridge +D 0257 CPU to PCI Bridge +V 10CD Advanced System Products (AdvanSys) +D 1100 ASC1100 PCI SCSI Host Adapter +D 1200 ASC1200 PCI SCSI Host Adapter (Fast SCSI II) +D 1300 ASC1300 PCI SCSI Host Adapter (Fast Wide SCSI II) +O 10CD ASC1300-Based SCSI Host Adapter +S 1310 ASC1300 PCI SCSI Adapter +S 1330 ABP480 PC Card CardBus SCSI Adapter +D 2300 ASC2300 PCI SCSI Hode Adapter (Ultra-Wide SCSI II) +D 2500 ASC38c0800/1600 PCI Ultra 2/160 SCSI Controller +D 4000 ASC30c0400 FireWire OHCI Single-Chip Controller +V 10CE Radius Inc +V 10CF Fujitsu Ltd +D 2001 MB86605 PCI SCSI Host Adapter (Fast Wide SCSI II) +D 2002 MB86606 Fast Wide SCSI Controller +D 2005 MB86974 10/100 Fast Ethernet Adapter +D 200C MB86613 OHCI FireWire Controller +V 10D0 Fujitsu Ltd(??) +V 10D1 FuturePlus Systems +V 10D2 Molex Incorporated +V 10D3 Jabil Circuit Inc +V 10D4 Hualon Microelectronics +V 10D5 Autologic Inc +V 10D6 Cetia +V 10D7 BCM Advanced Research +V 10D8 Advanced Peripherals Labs +V 10D9 Macronix International Co Ltd +D 0066 MX86101P +D 0512 MX98713 Fast Ethernet Adapter (PN102TX) +D 0531 MX98715/25 Fast Ethernet Adapter +O 1186 DFE-540TX ProFAST 10/100 Adapter +S 1200 DFE-540TX ProFAST 10/100 Adapter +D 0532 MX98723 Fast Ethernet Adapter +D 8625 MX86250 +D 8626 MX86251 +D 8627 MX86251 +D 8888 MX86200 +V 10DA Thomas-Conrad Corp +D 0508 TC4048 Token Ring +D 3390 Tl3c3x9 Token Ring +V 10DB Rohm LSI Research +V 10DC CERN +D 0001 STAR/RD24 SCSI (PMC) +D 0002 STAR/RD24 SCSI (PMC) +D 0010 680-1110-150/400 PMC/PCI to S-Link Interface +D 0011 680-1110-200/450 Smiple S-Link to PMC/PCI Interface +D 0021 HIPPI destination +D 0022 HIPPI source +D 10DC ATT2C15-3 FPGA +V 10DD Evans & Sutherland +D 0001 3D Graphics Processor (?? Freedom GBbus??) +V 10DE Nvidia Corp +D 0008 NV1 EDGE 3D Accelerator +D 0009 NV1 EDGE 3D Multimedia +D 0010 Mutara V08 [NV2] +D 0018 Riva 128 Graphics Accelerator +D 0019 Riva 128ZX GUI+3D Accelerator +D 0020 Riva TNT GUI+3D Accelerator [NV4] +O 1043 AGP-V3400TNT +S 0200 AGP-V3400TNT +O 1048 Erazor II SGRAM +S 0C18 Erazor II SGRAM +O 1092 Viper V550 +S 0550 Viper V550 +S 0552 Viper V550 +S 4804 Viper V550 +S 4808 Viper V550 +S 4810 Viper V550 +S 4812 Viper V550 +S 4815 Viper V550 +S 4820 Viper V550 with TV out +S 4822 Viper V550 +S 4904 Viper V550 +S 4914 Viper V550 +S 8225 Viper V550 +O 10B4 Velocity 4400 +S 273D Velocity 4400 +O 10DE Riva TNT +S 0020 Riva TNT +O 1102 Graphics Blaster RIVA TNT +S 1015 Graphics Blaster RIVA TNT +S 1016 Graphics Blaster RIVA TNT +D 0028 RIVA TNT2 [NV5] +O 1043 AGP-V3800 +S 0200 AGP-V3800 SGRAM +S 0201 AGP-V3800 SDRAM +S 0205 PCI-V3800 +S 4000 AGP-V3800PRO +S 4025 AGP-V3800PRO SDRAM +O 1092 Viper V770 +S 4804 Viper V770 +S 4A00 Viper V770 +S 4A02 Viper V770 Ultra +S 6A02 Viper V770 Ultra +S 7A02 Viper V770 Ultra +O 10DE RIVA TNT2 +S 0005 RIVA TNT2 Pro +O 1102 3D Blaster RIVA TNT2 +S 1020 3D Blaster RIVA TNT2 +S 1026 3D Blaster RIVA TNT2 Digital +S 1032 CT6878 3D Blaster RIVA TNT2 +O 14AF Maxi Gamer +S 5008 Maxi Gamer Phoenix 2 +S 5810 Maxi Gamer Xentor +D 0029 RIVA TNT2 Ultra [NVULTRA] +O 1043 V3800 Ultra +S 0200 AGP-V3800 Ultra SGRAM +S 0201 AGP-V3800 Ultra SDRAM +S 0205 PCI-V3800 Ultra +O 1102 3D Blaster RIVA TNT2 Ultra +S 1021 3D Blaster RIVA TNT2 Ultra +S 1029 3D Blaster RIVA TNT2 Ultra +S 102F 3D Blaster RIVA TNT2 Ultra +O 1462 RIVA TNT2 +S 8806 RIVA TNT2 +O 14AF Maxi Gamer Xentor 32 +S 5820 Maxi Gamer Xentor 32 +D 002A Riva TNT2 [NV5] +D 002B Riva TNT2 [NV5] +D 002C VANTA / VANTA LT [NVVANTA] +O 1043 AGP-V3800C Combat +S 0200 AGP-V3800C Combat SDRAM +S 0201 AGP-V3800C Combat +S 4010 VANTA2000 SGRAM +S 4011 VANTA2000 +O 1092 Viper V730 +S 6820 Viper V730 +O 1102 VANTA +S 1031 CT6938 VANTA 8MB +S 1033 CT6934 VANTA +S 1034 CT6894 VANTA 16MB +S 1039 CT6954 VANTA +S 103E CT6982 VANTA +O 14AF Maxi Gamer Phoenix +S 5008 Maxi Gamer Phoenix 2 +D 002D RIVA TNT2 Model 64 [NVM64] +O 1043 AGP-V3800M +S 0200 AGP-V3800M +S 0201 AGP-V3800M SDRAM +O 1102 RIVA TNT2 Value +S 1023 CT6892 RIVA TNT2 Value +S 1024 CT6932 RIVA TNT2 Value 32Mb +S 102C CT6937 RIVA TNT2 Value +S 102D CT6931 RIVA TNT2 Value (Jumper) +S 1030 CT6931 RIVA TNT2 Value +S 103A CT6981 RIVA TNT2 Value +S 103F CT6983 RIVA TNT2 Value +S 1044 CT6984 RIVA TNT2 Value +S 1046 CT6955 RIVA TNT2 Value +O 1462 MSI-8808 +S 8808 MSI-8808 +D 002E Vanta [NV6] +D 002F Vanta [NV6] +D 00A0 RIVA TNT2 Aladdin [NVA0] +O 1043 Onboard RIVA TNT2 +S 8021 CUA Onboard RIVA TNT2 +O 14AF Maxi Gamer Xentor +S 5810 Maxi Gamer Xentor +D 0100 GeForce 256 [NV10] +O 1043 AGP-V6600 +S 0200 AGP-V6600 SGRAM +S 0201 AGP-V6600 SDRAM +S 4008 AGP-V6600 SGRAM +S 4009 AGP-V6600 PRO SDRAM +O 1048 Erazor X +O 1102 GeForce 256 +S 102D CT6941 GeForce 256 +S 1035 CT6960 GeForce 256 +S 1036 CT6961 GeForce 256 +S 1037 CT6962 GeForce 256 +S 103C CT6963 GeForce 256 +D 0101 GeForce 256 DDR +O 1043 AGP-V6800 DDR +S 0202 AGP-V6800 DDR +S 400A AGP-V6800 DDR SGRAM +S 400B AGP-V6800 DDR SDRAM +S 401E AGP-V6800 DDR SGRAM/140A +S 4022 AGP-V6800 DDR SGRAM/140H +O 1102 GeForce 256 DDR +S 102E CT6971 GeForce 256 DDR +S 1040 CT6974 GeForce 256 DDR +S 1041 CT6972 GeForce 256 DDR +S 1042 CT6975 GeForce 256 DDR +S 1043 CT6976 GeForce 256 DDR +S 1045 CT6977 GeForce 256 DDR +O 14AF Prophet 3D +S 5021 Prophet 3D +D 0102 GeForce 256 Ultra [NV10] +D 0103 Quadro (GeForce 256 GL) [NV10GL] +O 1043 V6600GL +O 1048 Gloria 2 +S 0C40 Gloria 2 +D 0110 GeForce2 MX [NV11] +O 1043 AGP-V7100 +S 4015 AGP-V7100 SDRAM +S 401D AGP-V7100 DVI SDRAM +S 4021 AGP-V7100 Deluxe Combo +O 1462 MSI-881x Starforce 881x +S 8818 MSI-8818 Starforce 8818 +D 0111 GeForce2 MX DDR [NV11DDR] +D 0112 GeForce2 MX Ultra [NV11] +D 0113 Quadro2 MXR [NV11GL] +D 0150 GeForce2 GTS [NV15] +O 1043 AGP-V7700 +S 400E AGP-V7700 DDR SGRAM +S 400F AGP-V770/64M +S 4012 AGP-V7700 DDR SDRAM +S 4013 AGP-V7700/64M +S 4016 AGP-V7700 Deluxe +S 4023 AGP-V7700Pro +O 1048 Gladiac +S 0C50 Gladiac +O 107D WinFast GeForce2 GTS with TV output +S 2840 WinFast GeForce2 GTS with TV output +O 1102 Annihilator 2 +S 1047 Annihilator 2 +O 14AF 3D Prophet 2 GTS +S 7000 3D Prophet 2 GTS +D 0151 GeForce2 GTS DDR [NV15DDR] +D 0152 GeForce2 Ultra (BladeRunner) [NV15BR] +O 1043 AGP-V7700Ultra +S 4027 AGP-V7700Ultra +D 0153 Quadro2 Pro [NV15GL] +D 01A0 Crush11 integrated graphics +D 0200 GeForce3 [NV20] +O 1043 V8200 +V 10DF Emulex Corp +D 10DF Light Pulse Fibre Channel Adapter +D 1AE5 LP6000 Fibre Channel Host Adapter +D F700 LP7000 Fibre Channel Host Adapter +D F800 LP8000 Fibre Channel host Adapter +V 10E0 Integrated Micro Solutions +D 5026 IMS5026/27/28 P54C "Diamond" PCI Chipset +D 5027 IMS5027 +D 5028 IMS5028 ISA Bridge +D 8849 IMS8849/8848 386/486 PCI Chipset +D 8853 IMS8853 ATM Network Adapter +D 9128 IMS9129 Twin Turbo 128 GUI Accelerator +V 10E1 Tekram Technology Corp Ltd +D 0391 TRM-S1040 +D 690C DC-690c +D DC29 DC-290 +V 10E2 Aptix Corp +V 10E3 Newbridge Microsystems +D 0000 CA91C042 VMEbus Bridge +D 0860 CA91C860 PCI to Motorola Processor Bridge +D 0862 CA91L826A PCI to Motorolla Processor Bridge +V 10E4 Tandem Computers +V 10E5 Micro Industries Corp +V 10E6 Gainbery Computer Products Inc +V 10E7 Vadem +V 10E8 Applied Micro Circuits Corp +D 2011 Q-Motion Video Capture/Edit board +D 4750 S5930 "Matchmaker" PCI Controller +D 5920 S5920 32-Bit PCI Bus target interface +D 8001 S5933 Daktronics VMax transmitter card +D 8033 BBK-PCI light transputer link interface +D 8043 Myrinet LANai PCI (M2-PCI-32) +D 8062 S5933_PARASTATION +D 807D S5933 PCI44 +D 8088 Kingsberg Spacetec Format Synchronizer +D 8089 Kingsberg Spacetec Serial Output Board +D 809C S5933 Traquair HEPC3 +D 80D7 PCI-9112 +D 80D9 PCI-9118 +D 80DA PCI-9812 +D 811A PCI IEEE-1355-DS-DE Interface +D 8170 S5933 "Matchmaker" PCI Chipset Development Tool +D 81B7 S5933 AJAVideo NTV ITU-R.601 video stillstore +D 82AF CQ2240 Data Aquisition Card +V 10E9 Alps Electric Corp Ltd +V 10EA InterGraphics Systems (IGS) +D 1680 IGA-1680 +D 1682 IGA-1682 +D 1683 IGA-1683 +D 2000 CyberPro 2000 +D 2010 CyberPro 20xx/2000A +D 5000 CyberPro 5000 +D 5050 CyberPro 5050 +V 10EB H+K Mebsysteme GmbH (Artists Graphics?) +D 0101 3GA 64 bit GUI Accelerator +D 8111 Twist3 Frame Grabber +V 10EC Realtek Semiconductor +D 8029 RT8029(AS) 10Mb Ethernet Adapter +O 10B8 EZ-Card Ethernet Adapter +S 2011 EZ-Card Ethernet Adapter +O 10EC RT8029(AS) Ethernet Adapter +S 8029 RT8029(AS) Ethernet Adapter +O 1113 EN1208 Ethernet Adapter +S 1208 EN1208 Ethernet Adapter +O 1186 DE-528 Ethernet Adapter +S 0300 DE-528 Ethernet Adapter +O 1259 AT-2400 Ethernet Adapter +S 2400 AT-2400 Ethernet Adapter +D 8129 RT8129 Fast Ethernet Adapter +O 10EC RT8129 Fast Ethernet Adapter +S 8129 RT8129 Fast Ethernet Adapter +D 8138 RT8139 (B/C) Cardbus Fast Ethernet Adapter +O 10EC RT8139 (B/C) Fast Ethernet Adapter +S 8138 RT8139 (B/C) Fast Ethernet Adapter +D 8139 RT8139 (A/B/C/8130) Fast Ethernet Adapter +O 1025 ALN-325 Fast Ethernet Adapter +S 8920 ALN-325 Fast Ethernet Adapter +S 8921 ALN-325 Fast Ethernet Adapter +O 10BD EP-320X-R Fast Ethernet Adapter +S 0320 EP-320X-R Fast Ethernet Adapter +O 10EC RT8139 (A/B/C/8130) Fast Ethernet Adapter +S 8139 RT8139 (A/B/C/8130) Fast Ethernet Adapter +O 1186 SN5200 Fast Ethernet Adapter +S 1320 SN5200 Fast Ethernet Adapter +O 1259 AT-2500TX Fast Ethernet Adapter +S 2500 AT-2500TX Fast Ethernet Adapter +O 1429 ND010 Fast Ethernet Adapter +S D010 ND010 Fast Ethernet Adapter +O 1432 EN-9130TX Fast Ethernet Adapter +S 9130 EN-9130TX Fast Ethernet Adapter +O 1436 RT8139 Fast Ethernet Adapter +S 8139 RT8139 Fast Ethernet Adapter +O 146C FE-1439TX Fast Ethernet Adapter +S 1439 FE-1439TX Fast Ethernet Adapter +O 1489 GF100TXRII Fast Ethernet Adapter +S 6001 GF100TXRII Fast Ethernet Adapter +S 6002 GF100TXRA Fast Ethernet Adapter +O 149C LFE-8139ATX Fast Ethernet Adapter +S 139A LFE-8139ATX Fast Ethernet Adapter +S 8139 LFE-8139TX Fast Ethernet Adapter +O 2646 EtheRx Fast Ethernet Adapter +S 0001 EtheRx Fast Ethernet Adapter +O 8E2E KF-230TX Fast Ethernet Adapter +S 7000 KF-230TX Fast Ethernet Adapter +S 7100 KF-230TX/2 Fast Ethernet Adapter +O A0A0 ALN-325C +S 0007 ALN-325C +V 10ED ASCII Corp +D 7310 V7310 VGA Video Overlay Adapter +V 10EE Xilinx Corp +D 3FC0 RME Digi96 +D 3FC1 RME Digi96/8 +D 3FC2 RME Digi96/8 Pro +D 3FC3 RME Digi96/8 Pad +V 10EF Racore Computer Products +D 8154 M815x Token Ring Adapter +V 10F0 Peritek Corp +V 10F1 Tyan Computer +D 1566 IDE/SCSI +D 1677 Multimedia +V 10F2 Achme Computer Inc +V 10F3 Alaris Inc +V 10F4 S-MOS Systems +V 10F5 NKK Corp +D A001 NDR4000 NR4600 Bridge +V 10F6 Creative Electronic Systems SA +V 10F7 Matsushita Electric Industrial Corp Ltd +V 10F8 Altos India Ltd +V 10F9 PC Direct +V 10FA TrueVision +D 0000 GUI Accelerator +D 0001 GUI Accelerator +D 0002 GUI Accelerator +D 0003 GUI Accelerator +D 0004 GUI Accelerator +D 0005 GUI Accelerator +D 0006 GUI Accelerator +D 0007 GUI Accelerator +D 0008 GUI Accelerator +D 0009 GUI Accelerator +D 000A GUI Accelerator +D 000B GUI Accelerator +D 000C Targa 1000 Video Capture & Editing card +D 000D GUI Accelerator +D 000E GUI Accelerator +D 000F GUI Accelerator +D 0010 GUI Accelerator +D 0011 GUI Accelerator +D 0012 GUI Accelerator +D 0013 GUI Accelerator +D 0014 GUI Accelerator +D 0015 GUI Accelerator +V 10FB Thesys Microelectronics +V 10FC I-O Data Device Inc +V 10FD Soyo Technology Corp Ltd +V 10FE Fast Multimedia AG +V 10FF N-Cube +V 1100 Jazz Multimedia +V 1101 Initio Corp +D 0002 Ultra SCSI Adapter +D 1060 INI-A100U2W Ultra2 SCSI Controller +D 134A Ultra SCSI Adapter +D 9100 INI-9100/9100W SCSI Controller +D 9400 INI-940 Fast Wide SCSI Controller +D 9401 INI-950 Fast Wide SCSI Controller +D 9500 INI-9100U/UW SCSI Controller +D 9700 Fast Wide SCSI Controller +V 1102 Creative Labs +D 0002 EMU10K1 Audio Chipset +O 1102 SBLive! Series +S 0020 CT4850 SBLive! Value +S 0021 CT4620 SBLive! +S 002F SBLive! Mainboard Implementation +S 4001 E-mu APS +S 8022 CT4780 SBLive! Value +S 8023 CT4790 SoundBlaster PCI512 +S 8024 CT4760 SBLive! +S 8025 SBLive! Mainboard Implementation +S 8026 CT4830 SBLive! Value +S 8027 CT4832 SBLive! Value +S 8031 CT4831 SBLive! Value +S 8040 CT4760 SBLive! +S 8051 CT4850 SBLive! Value +S 8061 SBLive! 5.1 +D 7002 PCI Gameport Joystick +O 1102 PCI Gameport Joystick +S 0020 PCI Gameport Joystick +V 1103 High Point Technologies Inc +D 0003 HPT343/345 UDMA EIDE Controller +D 0004 HPT366 UDMA66 EIDE Controller +R 03 HPT370 UDMA100 EIDE Controller +V 1104 Rasterops +V 1105 Sigma Designs Inc +D 5000 Multimedia +D 8300 REALmagic Hollywood Plus MPEG2 DVD Decoder +V 1106 VIA Technologies Inc +D 0130 VT6305 1394.A OHCI Link Layer Controller +D 0305 VT8363 KT133 System Controller +O 1043 VIA KT133 based Mainboard System Controller +S 8033 A7V Motherboard System Controller +O 147B VIA KT133 based Mainboard System Controller +S A401 KT7A Mainboard System Controller +D 0391 VT8371 KX133 System Controller +D 0501 VT8501 MVP4 System Controller +D 0505 VT82C505 VL to PCI Bridge +D 0561 VT82C570 MV IDE Controller (Single FIFO) +D 0571 VT82C586/A/B,VT82C596/A/B,VT82C686A EIDE Controller +R 06 VT82C586/B,VT82C686A EIDE Controller +R 10 VT82C596B EIDE Controller +D 0576 VT82C570 MV System Controller +D 0585 VT82C585 VP,VPX,VPX/97 System Controller +D 0586 VT82C586/A/B PCI to ISA Bridge +R 47 VT82C586B PCI to ISA Bridge +O 1106 VT82C586B PCI to ISA Bridge +S 0000 VT82C586B PCI to ISA Bridge +D 0595 VT82C595 VP2,VP2/97 System Controller +D 0596 VT82C596/A/B PCI to ISA Bridge +R 05 VT82C595 PCI to ISA Bridge +R 12 VT82C596B PCI to ISA Bridge +R 23 VT82C596B PCI to ISA Bridge +O 1043 VIA Chipset-based Mainboard PCI to ISA Bridge +S 8017 P3V4X Motherboard PCI to ISA Bridge +O 1106 VT82C596/A/B PCI to ISA Bridge +S 0000 VT82C596/A/B PCI to ISA Bridge +O 1458 VT82C596/A/B PCI to ISA Bridge +S 0596 VT82C596/A/B PCI to ISA Bridge +D 0597 VT82C597 VP3 System Controller +D 0598 VT82C598 MVP3 System Controller +D 0601 VT82C601 PM601 System Controller +D 0605 VT8605 PM133 System Controller +O 1043 VIA Chipset-based Mainboard System Controller +S 802C CUV4X Motherboard PM133 System Controller +D 0680 VT82C680 Apollo P6 +D 0686 VT82C686/A/B PCI to ISA Bridge +R 40 VT82C686B PCI to ISA Bridge +O 1043 VIA Chipset-based Mainboard PCI to ISA Bridge +S 8023 K7V Motherboard PCI to ISA Bridge +S 802C CUV4X Motherboard PCI to ISA Bridge +S 8038 CUV4X-DLS Motherboard PCI to ISA Bridge +O 1106 VT82C686/A PCI to ISA Bridge +S 0000 VT82C686/A PCI to ISA Bridge +S 0686 VT82C686/A PCI to ISA Bridge +D 0691 VT82C691/693A/694X Apollo Pro/133/133A System Controller +R 20 VT82C691 Apollo Pro System Controller +R 40 VT82C693A Apollo Pro 133 System Controller +R 44 VT82C693A Apollo Pro 133 System Controller +R C0 VT82C694X Apollo Pro 133A System Controller +O 1043 VIA Chipset-Based Mainboard System Controller +S 8017 P3V4X Motherboard System Controller +S 8023 K7V Motherboard System Controller +S 8038 CUV4X-DLS Motherboard System Controller +O 1458 VT82C691 Apollo Pro System Controller +S 0691 VT82C691 Apollo Pro System Controller +D 0692 Apollo Pro/BX Chipset +D 0693 VT82C693 Apollo Pro Plus CPU to PCI Bridge +D 0926 VT86C926 "Amazon" NE2000 Compatible Ethernet Controller +D 1000 VT82C570 MV System Controller +D 1106 VT82C570 MV IDE Controller +D 1571 VT82C416 IDE Controller +D 1595 VT82C595 VP2,VP2/97 System Controller +D 3038 VT83C572,VT82C586/A/B,VT82C596B,VT82C686A USB Controller +R 02 VT82C586B USB Controller +R 06 VT82C686A USB Controller +R 08 VT82C596B USB Controller +R 0E VT82C686A USB Controller +R 11 VT82C596B USB Controller +X 12340925 VIA USB Controller +D 3040 VT83C572, VT86C586/A/B Power Management Controller +R 10 VT86C586B Power Management Controller +D 3043 VT86C100A "Rhine" 10/100 Ethernet Adapter +O 10BD VT86C100A Fast Ethernet Adapter +S 0000 VT86C100A Fast Ethernet Adapter +O 1106 VT86C100A Fast Ethernet Adapter +S 0100 VT86C100A Fast Ethernet Adapter +O 1186 DFE-530TX Fast Ethernet Adapter (Rev A) +S 1400 DFE-530TX Fast Ethernet Adapter (Rev A) +D 3044 OHCI Compliant IEEE 1394 Host Controller +D 3050 Power Management Controller +D 3051 Power Management Controller +D 3057 VT82C686A/B ACPI Power Management Controller +R 40 VT82C686B ACPI Power Management Controller +D 3058 VT82C686A AC97 Audio Codec (Sound Card) +O 0E11 Onboard AC97 Audio Codec +S B194 Onboard AC97 Audio Codec +O 1106 Onboard AC97 Audio Codec +S 3058 Onboard AC97 Audio Codec +S 78D2 Onboard AC97 Audio Codec +O 144D Onboard AC97 Audio Codec +S 3705 Onboard AC97 Audio Codec +O 1462 Onboard AC97 Audio Codec +S 3091 MS-6309 Onboard AC97 Audio Codec +S 3300 MS-6330 K7T-Pro Onboard AC97 Audio Codec +O 14FF Onboard AC97 Audio Codec +S 0E80 Onboard AC97 Audio Codec +O 4352 Onboard AC97 Audio Codec +S 5913 Onboard AC97 Audio Codec +D 3059 AC'97 Enhanced Audio Controller +O 1106 AC'97 Enhanced Audio Controller +S 4551 AC'97 Enhanced Audio Controller +D 3065 Fast Ethernet Adapter +O 1186 DFE-530TX Fast Ethernet Adapter with WOL +S 1400 DFE-530TX Fast Ethernet Adapter with WOL (Rev A) +S 1401 DFE-530TX Fast Ethernet Adapter with WOL (Rev B) +D 3068 VT82C686A Modem Codec +D 3074 VT8233 PCI to ISA Bridge +D 3086 VT82C686 Power Management Controller (??) +D 3091 VT8633 Apollo Pro 266 CPU to PCI Bridge +D 3099 VT8366 Apollo KT266 CPU to PCI Bridge +D 3101 VT8653 CPU to PCI Bridge +D 3102 VT8362 CPU to PCI Bridge +D 3103 VT8615 CPU to PCI Bridge +D 3112 VT8361 CPU to PCI Bridge +D 3113 PCI to PCI Bridge +D 3133 VT3133 CPU to PCI Bridge +D 6100 VT86C100A 10/100 Ethernet Adapter +D 8231 VT8231 PCI to ISA Bridge +D 8235 Power Management Controller +D 8305 VT8363 KT133 PCI to AGP Bridge +D 8391 VT8371 KX133 PCI to AGP Bridge +D 8501 VT8501 MVP4 PCI to AGP Bridge +D 8597 VT82C597 VP3 PCI to AGP Bridge +D 8598 VIA PCI to AGP Bridge (All VIA AGP Chipsets) +D 8601 VT82C601 PM601 CPU to AGP Bridge +D 8605 VT8605 PM133 CPU to AGP Bridge +D 8691 VT82C691/693A/694X Apollo Pro/133/133A PCI to PCI Bridge +D 8693 VT82C693 Apollo Pro Plus PCI to PCI Bridge +D B091 VT8633 CPU to AGP Controller +D B099 VT8366 CPU to AGP Controller +D B101 VT8653 to AGP Controller +D B102 VT8362 to AGP Controller +D B103 VT8615 to AGP Controller +D B112 VT8361 to AGP Controller +D B115 CPU to AGP Controller +D B133 CPU to AGP Controller +V 1107 Stratus Computer +D 8576 PCI Host Bridge +V 1108 Proteon Inc +D 0100 P1690Plus-AA Single Port Token Ring Adapter +D 0101 P1690Plus-AB Dual Port Token Ring Adapter +D 0105 P1690Plus Token Ring Adapter +D 0108 P1690Plus Token Ring Adapter +D 0138 P1690Plus Token Ring Adapter +D 0139 P1690Plus Token Ring Adapter +D 013C P1690Plus Token Ring Adapter +D 013D P1690Plus Token Ring Adapter +V 1109 Cogent Data Technologies +D 1400 EM110TX PCI Fast Ethernet +V 110A Infineon Technologies (Was Siemens Nixdorf AG) +D 0002 Piranha PCI-EIDE-Adapter (2 Port) +D 0005 Tulip-Controller, Power-Management, Switch Extender +D 0006 PINC +D 0015 Multiprocessor Interrupt Controller (MINT) +D 0017 PCI-WAN Adapter (SiemensCard PWAN) +D 001D Copernicus Management Controller +D 113C FPGA-CPTR Hardware Tracer for CP113C/CP113D +D 113E FPGA-CPTRE Hardware Tracer for CP113E +D 2101 PEB 20321 MUNICH32X Multichannel NIC for HLC +D 2102 PEB/PEF 20534 DSCC4 Multiprotocol HDLC Controller +D 2103 PEB 20324 MUNICH128X Multichannel NIC for HDLC + Extensions +D 2104 PSB 4600/4610 PCI Interface for Telephony Applications (PITA) +D 2106 PEB 20256E Multichannel NIC for HDLC/PPP (256 Channels) +D 2108 PEB 20256M E MUNICH256FM NIC for HDLC/PPP (256 Channels) +D 3160 MCCA Pentium-PCI Host Bridge Core ASIC +D 4942 FPGA I-Bus Tracer for MBD +D 6120 SZB6120 Multimedia Adapter +V 110B CHROMATIC Research Inc / Xenon Microsystems +D 0001 Mpact Media Processor +D 0004 Mpact2 3DVD Media Processor +V 110C Mini-Max Technology Inc +V 110D ZNyX Corp +V 110E CPU Technology +V 110F Ross Technology +V 1110 Powerhouse Systems +D 6037 Firepower Powerized SMP I/O ASIC +D 6073 Firepower Powerized SMP I/O ASIC +V 1111 Santa Cruz Operation +V 1112 Rockwell International +D 2200 FDDI Adapter +D 2300 Fast Ethernet Adapter +D 2340 4 Port Fast Ethernet Adapter +D 2400 ATM Adapter +V 1113 Accton Technology Corp +D 1211 EN-1207D Fast Ethernet Adapter +O 103C EN-1207D Fast Ethernet Adapter +S 1207 EN-1207D Fast Ethernet Adapter +O 1113 EN-1207D Fast Ethernet Adapter +S 1211 EN-1207D Fast Ethernet Adapter +S 9211 EN-1207D-TX Fast Ethernet Adapter +D 1217 EN-1217 Ethernet Adapter +D 5105 10Mbps Network card +D 9211 EN-1207D Fast Ethernet Adapter +O 1113 EN-1207D Fast Ethernet Adapter +S 9211 EN-1207D Fast Ethernet Adapter +V 1114 Atmel Corp +V 1115 Dupont Pixel Systems Ltd +V 1116 Data Translation +D 0022 DT3001 +D 0023 DT3002 +D 0024 DT3003 +D 0025 DT3004 +D 0026 DT3005 +D 0027 DT3001-PGL +D 0028 DT3003-PGL +V 1117 Datacube Inc +D 9500 Max-1C SVGA card +D 9501 Max-1C image processing +V 1118 Berg Electronics +V 1119 ICP-Vortex Computersysteme GmbH +D 0000 GDT6000/6020/6050 PCI SCSI RAID-Controller +D 0001 GDT6000B/6010 PCI 1-Channel SCSI RAID-Controller +D 0002 GDT6110/6510 PCI 1-Channel SCSI RAID-Controller +D 0003 GDT6120/6520 PCI 2-Channel SCSI RAID-Controller +D 0004 GDT6530 PCI 3-Channel SCSI RAID-Controller +D 0005 GDT6550 PCI 5-Channel SCSI RAID-Controller +D 0006 GDT6117/6517 +D 0007 GDT6127/6527 +D 0008 GDT6537 +D 0009 GDT6557 +D 000A GDT6115/6515 +D 000B GDT6125/6525 +D 000C GDT6535 +D 000D GDT6555 +D 0100 GDT6117RP/6517RP +D 0101 GDT6127RP/6527RP +D 0102 GDT6537RP +D 0103 GDT6557RP +D 0104 GDT6111RP/6511RP +D 0105 GDT6127RP/6527RP +D 0110 GDT6117RP1/6517RP1 +D 0111 GDT6127RP1/6527RP1 +D 0112 GDT6537RP1 +D 0113 GDT6557RP1 +D 0114 GDT6111RP1/6511RP1 +D 0115 GDT6127RP1/6527RP1 +D 0118 GDT 6x18RD +D 0119 GDT 6x28RD +D 011A GDT 6x38RD +D 011B GDT 6x58RD +D 0120 GDT6117RP2/6517RP2 +D 0121 GDT6127RP2/6527RP2 +D 0122 GDT6537RP2 +D 0123 GDT6557RP2 +D 0124 GDT6111RP2/6511RP2 +D 0125 GDT6127RP2/6527RP2 +D 0168 GDT 7x18RN +D 0169 GDT 7x28RN +D 016A GDT 7x38RN +D 016B GDT 7x58RN +D 0210 GDT 6x19RD +D 0211 GDT 6x29RD +D 0260 GDT 7x19RN +D 0261 GDT 7x29RN +V 111A Efficient Networks Inc +D 0000 155P-MF1 (FPGA) +D 0002 155P-MF1 (ASCI) +D 0003 ENI-25P ATM Adapter +O 111A ENI-25p Miniport ATM Adapter +S 0000 ENI-25p Miniport ATM Adapter +D 0005 ENI-25P ATM Adapter +O 111A SS-3010 Miniport ATM Adapter +S 0001 SS-3010 Miniport ATM Adapter +S 0009 ENI-3060 ADSL (VPI=0) +S 0101 ENI-3010 ATM +S 0109 ENI-3060CO ADSL (VPI=0) +S 0809 ENI-3060 ADSL (VPI=0 or 8) +S 0909 ENI-3060CO ADSL (VPI=0 or 8) +S 0A09 ENI-3060 ADSL (VPI=<0..15>) +D 0007 SpeedStream ADSL +O 111A ENI-3061 ADSL [ASIC] +S 1001 ENI-3061 ADSL [ASIC] +V 111B Teledyne Electronic Systems +V 111C Tricord Systems Inc +D 0001 Powerbis Bridge +V 111D Integrated Device Technology +D 0001 IDT77211 ATM Adapter +V 111E Eldec Corp +V 111F Precision Digital Images +D 4A47 Precision MX Video engine interface +D 5243 Frame Capture Bus Interface +V 1120 EMC Corp +V 1121 Zilog +V 1122 Multi-Tech Systems Inc +V 1123 EXCELLENT DESIGN Inc +V 1124 Leutron Vision AG +V 1125 Eurocore/Vigra +V 1126 Vigra +V 1127 FORE Systems Inc +D 0200 ForeRunner PCA-200 ATM +D 0210 PCA-200PC ATM +D 0250 ATM +D 0300 PCA-200EPC ATM +D 0310 ATM +D 0400 ForeRunnerHE ATM Adapter +V 1129 Firmworks +V 112A Hermes Electronics Co Ltd +V 112B Linotype - Hell AG +V 112C ZENITH DATA Systems +V 112D Ravicad +V 112E Infomedia Microelectronics +D 0000 Enhanced IDE Controller +D 000B Enhanced IDE Controller +V 112F IMAGING TECHNLOGY Inc +D 0000 MVC IC-PCI +D 0001 Video Frame Grabber / Processor +V 1130 Computervision +V 1131 Philips Semiconductors +D 2780 TDA2780AQ TV Deflection Controller +D 5400 TriMedia TM100 Multimedia Processor +D 7145 SAA7145 +D 7146 SAA7146 Multimedia Bridge Scaler +O 114B DVRaptor Video Edit/Capture Card +S 2003 DVRaptor Video Edit/Capture Card +O 11BD DVxxx Series Overlay +S 0006 DV500 Overlay +S 000A DV500 Overlay +S 000F DV500 Overlay +V 1132 Mitel Corp +V 1133 Eicon Technology Corp +D 7901 EiconCard S90 +O 1133 EiconCard S90 +S 7901 EiconCard S90 +D 7902 EiconCard S90 +D 7911 EiconCard S91 +O 1133 EiconCard S91 +S 7911 EiconCard S91 +D 7912 EiconCard S91 +D 7941 EiconCard S94 +D 7942 EiconCard S94 +D B921 EiconCard P92 +D B922 EiconCard P92 +D E001 DIVA Pro 2.0 S/T +O 1133 DIVA Pro 2.0 S/T +S E001 DIVA Pro 2.0 S/T +D E002 DIVA 2.0 S/T +O 1133 DIVA 2.0 S/T +S E002 DIVA 2.0 S/T +D E003 DIVA Pro 2.0 U +O 1133 DIVA Pro 2.0 U +S E003 DIVA Pro 2.0 U +D E004 DIVA 2.0 U +O 1133 DIVA 2.0 U +S E004 DIVA 2.0 U +D E005 ISDN Controller +O 1133 DIVA 2.01 S/T +S E005 DIVA 2.01 S/T +D E010 DIVA Server BRI-2M +O 1133 DIVA Server BRI-2M +S E010 DIVA Server BRI-2M +D E012 DIVA Server BRI-8M +O 1133 DIVA Server BRI-8M +S E012 DIVA Server BRI-8M +D E014 DIVA Server PRI-30M +O 1133 DIVA Server PRI-30M +S E014 DIVA Server PRI-30M +V 1134 Mercury Computer Systems Inc +D 0001 Raceway Bridge +V 1135 Fuji Xerox Co Ltd +D 0001 Printer Controller +V 1136 Momentum Data Systems +V 1137 Cisco Systems Inc +V 1138 Ziatech Corp +D 8905 STD 32 Bridge +V 1139 Dynamic Pictures Inc +D 0001 VGA Compatable 3D Graphics +V 113A FWB Inc +V 113B Network computing devices +V 113C Cyclone Microsystems +D 0000 PCI9060 i960 Bridge +D 0001 PCI9060 i960 Bridge/Evaluation Platform +D 0911 PCI911 i960Jx I/O Controller +D 0912 PCI912 i960Cx I/O Controller +D 0913 PCI913 i960Hx I/O Controller +D 0914 PCI914 I/O Controller w/ secondary PCI bus +V 113D Leading Edge Products Inc +V 113E Sanyo Electric Co +V 113F Equinox Systems +D 0808 SST-64P Adapter +D 1010 SST-128P Adapter +D 80C0 SST-16P Adapter +D 80C4 SST-16P Adapter +D 80C8 SST-16P Adapter +D 8888 SST-4P Adapter +D 9090 SST-8P Adapter +V 1140 Intervoice Inc +V 1141 Crest Microsystem Inc +D 0001 EIDE +V 1142 Alliance Semiconductor +D 3210 ProMotion 3210(6410?) VGA and AVI Playback Accelerator +D 6410 GUI Accelerator +D 6412 GUI Accelerator +D 6420 GUI Accelerator +D 6422 ProVideo 6422 +D 6424 ProVideo 6424 ProMotion AT24 GUI Accelerator +D 6425 ProMotion AT25 +D 6426 GUI Accelerator +D 643D ProMotion AT3D +V 1143 Netpower Inc +V 1144 Vickers Inc/Cincinnati Milacron +D 0001 Noservo Controller +V 1145 Workbit Corp +V 1146 Force Computers +V 1147 Interface Corp +V 1148 Syskonnect (Schneider & Koch) +D 4000 FDDI Adapter +O 0E11 Netelligent 100 FDDI DAS Fibre SC +S B03B Netelligent 100 FDDI DAS Fibre SC +S B03C Netelligent 100 FDDI SAS Fibre SC +S B03D Netelligent 100 FDDI DAS UTP +S B03E Netelligent 100 FDDI SAS UTP +S B03F Netelligent 100 FDDI SAS Fibre MIC +O 1148 FDDI SK-5521 (SK-NET FDDI-UP) +S 5521 FDDI SK-5521 (SK-NET FDDI-UP) +S 5522 FDDI SK-5522 (SK-NET FDDI-UP DAS) +S 5541 FDDI SK-5541 (SK-NET FDDI-FP) +S 5543 FDDI SK-5543 (SK-NET FDDI-LP) +S 5544 FDDI SK-5544 (SK-NET FDDI-LP DAS) +S 5821 FDDI SK-5821 (SK-NET FDDI-UP64) +S 5822 FDDI SK-5822 (SK-NET FDDI-UP64 DAS) +S 5841 FDDI SK-5841 (SK-NET FDDI-FP64) +S 5843 FDDI SK-5843 (SK-NET FDDI-LP64) +S 5844 FDDI SK-5844 (SK-NET FDDI-LP64 DAS) +D 4200 Token Ring +D 4300 SK-NET SK-984x Gigabit Ethernet Adapter +O 1148 SK-NET SK-984x Gigabit Ethernet Adapter +S 9821 SK-9821 (1000Base-T single link) +S 9822 SK-9822 (1000Base-T dual link) +S 9841 SK-9841 LX +S 9842 SK-9842 LX dual link +S 9843 SK-9843 SX +S 9844 SK-9844 SX dual link +V 1149 Win System Corp +V 114A VMIC +D 7587 VMIVME-7587 +V 114B Canopus Co Ltd +V 114C Annabooks +V 114D IC Corp +V 114E Nikon Systems Inc +V 114F Digi International +D 0002 AccelePort EPC +D 0003 RightSwitch SE-6 +D 0004 AccelePort Xem +D 0005 AccelePort Xr +D 0006 AccelePort C/X +D 0009 AccelePort Xr/J +D 000A AccelePort EPC/J +D 000C DataFirePRIme T1 (1-port) +D 000D SyncPort 2-Port (x.25/FR) +D 0011 AccelePort 8r EIA-232 (IBM) +D 0012 AccelePort 8r EIA-422 +D 0013 AccelePort Xr +D 0014 AccelePort 8r EIA-422 +D 0015 AccelePort Xem +D 0016 AccelePort EPC/X +D 0017 AccelePort C/X +D 001A DataFirePRIme E1 (1-port) +D 001B AccelePort C/X (IBM) +D 001D DataFire RAS T1/E1/PRI +O 114F DataFire RAS Adapter +S 0050 DataFire RAS E1 Adapter +S 0051 DataFire RAS Dual E1 Adapter +S 0052 DataFire RAS T1 Adapter +S 0053 DataFire RAS Dual T1 Adapter +D 0023 AccelePort RAS +D 0024 DataFire RAS B4 ST/U +O 114F DataFire RAS BRI Adapter +S 0030 DataFire RAS BRI U Adapter +S 0031 DataFire RAS BRI S/T Adapter +D 0026 AccelePort 4r 920 +D 0027 AccelePort 8r 920 +D 0034 AccelePort 2r 920 +D 0035 DataFire DSP T1/E1/PRI cPCI +D 6001 Avanstar +V 1150 Thinking Machines Corp +V 1151 JAE Electronics Inc +V 1152 Megatek +V 1153 Land Win Electronic Corp +V 1154 Melco Inc +V 1155 Pine Technology Ltd +D 0810 486 CPU/PCI Bridge +D 0922 Pentium CPU/PCI Bridge +D 0926 PCI/ISA Bridge +V 1156 Periscope Engineering +V 1157 Avsys Corp +V 1158 Voarx RD Inc +D 3011 Tokenet/vg 1001/10m anylan +D 9050 Lanfleet/Truevalue +D 9051 Lanfleet/Truevalue +V 1159 MuTech Corp +D 0001 MV-1000 +V 115A Harlequin Ltd +V 115B Parallax Graphics +V 115C PHOTRON Ltd +V 115D Xircom +D 0003 Cardbus Ethernet 10/100 +O 1014 10/100 EtherJet Cardbus Adapter +S 0181 10/100 EtherJet Cardbus Adapter +S 1181 10/100 EtherJet Cardbus Adapter +S 8181 10/100 EtherJet CardBus Adapter +S 9181 10/100 EtherJet CardBus Adapter +O 115D Cardbus Ethernet 10/100 +S 0181 Cardbus Ethernet 10/100 +S 1181 Cardbus Ethernet 10/100 +O 1179 10/100 CardBus Ethernet PC Card +S 0181 10/100 CardBus Ethernet PC Card +O 8086 EtherExpress PRO/100 Mobile Cardbus 32 Adapter +S 8181 EtherExpress PRO/100 Mobile Cardbus 32 Adapter +S 9181 EtherExpress PRO/100 Mobile Cardbus 32 Adapter +D 0005 Cardbus Ethernet 10/100 +O 1014 10/100 EtherJet Cardbus Adapter +S 0182 10/100 EtherJet Cardbus Adapter +S 1182 10/100 EtherJet Cardbus Adapter +O 115D Cardbus Ethernet 10/100 +S 0182 Cardbus Ethernet 10/100 +S 1182 Cardbus Ethernet 10/100 +D 0007 Cardbus Ethernet 10/100 +O 1014 10/100 EtherJet Cardbus Adapter +S 0182 10/100 EtherJet Cardbus Adapter +S 1182 10/100 EtherJet Cardbus Adapter +O 115D Cardbus Ethernet 10/100 +S 0182 Cardbus Ethernet 10/100 +S 1182 Cardbus Ethernet 10/100 +D 000B Cardbus Ethernet 10/100 +O 1014 10/100 EtherJet Cardbus Adapter +S 0183 10/100 EtherJet Cardbus Adapter +O 115D Cardbus Ethernet 10/100 +S 0183 Cardbus Ethernet 10/100 +D 000C Mini-PCI V.90 56k Modem +O 8086 Mini-PCI V.90 56k Modem +S 2408 Mini-PCI V.90 56k Modem for COMBO IBM +D 000F Cardbus Ethernet 10/100 +O 1014 10/100 EtherJet Cardbus Adapter +S 0183 10/100 EtherJet Cardbus Adapter +O 115D Cardbus Ethernet 10/100 +S 0183 Cardbus Ethernet 10/100 +D 0101 Cardbus 56k Modem +O 115D Cardbus 56k Modem +S 1081 Cardbus 56k Modem +D 0103 Cardbus Ethernet + 56k Modem +O 1014 CardBus 56K Modem +S 9181 CardBus 56K Modem +O 115D CBEM56G-100 Ethernet + 56k Modem +S 1181 CBEM56G-100 Ethernet + 56k Modem +O 8086 PRO/100 LAN + Modem56 Cardbus +S 9181 PRO/100 LAN + Modem56 Cardbus +V 115E Peer Protocols Inc +V 115F MAXTOR Corp +V 1160 Megasoft Inc +V 1161 PFU Ltd +D 0001 Host Bridge +V 1162 OA Laboratory Co Ltd +V 1163 Rendition +D 0001 3D Blaster Verite 1000 +D 2000 Verite 2000 +O 1092 Stealth II S220 +S 2000 Stealth II S220 +O 4843 Thriller V2000 +S 0001 Thriller V2000 PCI +V 1164 Advanced Peripherals Tech +V 1165 Imagraph Corp +D 0001 Motion JPEG Recorder/Player with Audio +V 1166 Reliance Computer Corp +D 0005 CNB20-LE CPU to PCI Bridge +D 0007 CNB20-LE CPU to PCI Bridge +D 0008 CNB20-HE CPU to PCI Bridge +D 0009 CNB20-HE CPU to PCI Bridge +D 0010 CIOB30 +D 0011 CMIC-HE +D 0200 OSB4 PCI to ISA Bridge +O 1166 OSB4 PCI to ISA Bridge +S 0200 OSB4 PCI to ISA Bridge +D 0201 CSB5 +D 0211 PCI EIDE Controller +D 0220 OHCI Compliant USB Controller +O 1166 OHCI Compliant USB Controller +S 0220 OHCI Compliant USB Controller +V 1167 Mutoh Industries Inc +V 1168 Thine Electronics Inc +V 1169 Centre for Development of Advanced Computing +V 116A Polaris Communications +D 6100 BUS/Tag Channel +D 6800 Escon Channel +D 7100 Bus/Tag Channel +D 7800 Escon Channel +V 116B Connectware Inc +V 116C Intelligent resources +V 116D Martin-Marietta +V 116E Electronics for imaging +V 116F Workstation Technology +V 1170 Inventec Corp +V 1171 Loughborough Sound Images +V 1172 Altera Corp +V 1173 Adobe Systems +V 1174 Bridgeport Machines +V 1175 Mitron Computer Inc +V 1176 SBE Inc +V 1177 Silicon Engineering +V 1178 Alfa Inc +D AFA1 Fast Ethernet Adapter +V 1179 Toshiba America Info Systems +D 0404 DVD Decoder card +D 0406 Tecra Video Capture device +D 0407 DVD Decoder card (Version 2) +D 0601 Pentium Host Bridge for Notebooks +O 1179 Pentium Host Bridge for Notebooks +S 0001 Satellite 300CDS Host Bridge +D 0602 PCI to ISA Bridge for Notebooks +D 0603 ToPIC95 PCI to Cardbus Bridge for Notebooks +D 0604 PCI to PCI Bridge for Notebooks +D 0605 PCI to ISA Bridge for Notebooks +D 0606 PCI to ISA Bridge for Notebooks +D 0609 PCI to PCI Bridge for Notebooks +D 060A ToPIC95B Cardbus Controller +D 060F ToPIC97 Cardbus Controller +D 0611 PCI to ISA Bridge +D 0617 ToPIC95 PCI to Cardbus Bridge with ZV Support +D 0618 CPU to PCI and PCI to ISA Bridge +D 0701 InfraRed Controller +O 1179 Satellie notebooks +S 0001 Satellite 300CDS notebook +D 0D01 FIR Port Type-DO +O 1179 FIR Port Type-DO +S 0001 FIR Port Type-DO +V 117A A-Trend Technology +V 117B L G Electronics Inc +V 117C Atto Technology +V 117D Becton Dickinson +V 117E T/R Systems +D 0001 Printer Host +V 117F Integrated Circuit Systems +V 1180 Ricoh Co Ltd +D 0465 RL5c465 Cardbus Controller +D 0466 RL5c466 Cardbus Controller +D 0475 RL5c475 Cardbus Controller +D 0476 RL5c476 Cardbus Controller +D 0477 RL5c477 Cardbus Controller +D 0478 RL5c478 Cardbus Controller +V 1181 Telmatics International +V 1183 Fujikura Ltd +V 1184 Forks Inc +V 1185 Dataworld +D 8929 EIDE Controller +V 1186 D-Link Inc +D 0100 DC21041 Ethernet Adapter +D 1002 DFE-550TX Fast Ethernet Adapter +O 1186 DFE-550TX Fast Ethernet Adapter +S 1002 DFE-550TX Fast Ethernet Adapter +D 1100 Fast Ethernet Adapter +V 1187 Advanced Technology Laboratories +V 1188 Shima Seiki Manufacturing Ltd +V 1189 Matsushita Electronics Co +D 1592 VL/PCI Bridge +V 118A Hilevel Technology +V 118B Hypertec Pty Ltd +V 118C Corollary Inc +D 0014 PCI to C-bus II Host Bridge +D 1117 MAC-94C201B3 Memory Controller Chip +V 118D BitFlow Inc +D 0001 Raptor-PCI Framegrabber +D 0012 Model 12 Road Runner Frame Grabber +D 0014 Model 14 Road Runner Frame Grabber +D 0024 Model 24 Road Runner Frame Grabber +D 0044 Model 44 Road Runner Frame Grabber +D 0112 Model 12 Road Runner Frame Grabber +D 0114 Model 14 Road Runner Frame Grabber +D 0124 Model 24 Road Runner Frame Grabber +D 0144 Model 44 Road Runner Frame Grabber +D 0212 Model 12 Road Runner Frame Grabber +D 0214 Model 14 Road Runner Frame Grabber +D 0224 Model 24 Road Runner Frame Grabber +D 0244 Model 44 Road Runner Frame Grabber +D 0312 Model 12 Road Runner Frame Grabber +D 0314 Model 14 Road Runner Frame Grabber +D 0324 Model 24 Road Runner Frame Grabber +D 0344 Model 44 Road Runner Frame Grabber +V 118E Hermstedt GmbH +V 118F GREEN LOGIC +V 1190 Tripace +D 2550 Single Chip PCI Ultra(Wide) SCSI Processor +D C721 EIDE +D C731 TP-910/920/940 PCI Ultra(Wide) SCSI Adapter +V 1191 Acard Technology Corp +D 0001 EIDE Adapter +D 0002 ATP850UF UltraDMA33 EIDE Controller (AEC6210UF) +D 0003 SCSI Cache Host Adapter +D 0004 ATP850UF UltraDMA33 EIDE (Cache??) Controller (AEC6210UF) +D 0005 ATP850UF UltraDMA33 EIDE Controller (AEC6210UF) +D 0006 ATP860A UltraDMA66 EIDE Controller, NO-BIOS (AEC6260) +D 0007 ATP860A UltraDMA66 EIDE Controller (AEC6260) +D 8001 ATP8600 SCSI-2 RAID (Cache??) Host Adapter (AEC6820U) +D 8002 ATP850S SCSI-2 Host Adapter (AEC6710L/F) +D 8010 ATP870 Ultra Wide SCSI Contoller (AEC6712UW) +D 8020 ATP870 Ultra SCSI Controller (AEC6712U) +D 8030 ATP870 SCSI Controller (AEC6710S/6712S) +D 8040 ATP870 SCSI Controller (AEC6710D) +D 8050 AEC6712SUW SCSI +V 1192 Densan Co Ltd +V 1193 Cabletron / Zeitnet +D 0001 1221 +D 0002 1225 +V 1194 Toucan Technology +V 1195 Ratoc System Inc +V 1196 Hytec Electronics Ltd +V 1197 Gage Applied Sciences Inc +V 1198 Lambda Systems Inc +V 1199 Attachmate Corp +V 119A Mindshare Inc +V 119B Omega Micro Inc +D 1221 82C092G +V 119C Information Technology Institute +V 119D Bug Sapporo Japan +V 119E Fujitsu Microelectronics Ltd +V 119F Bull Hn Information Systems +V 11A0 Convex Computer Corp +V 11A1 Hamamatsu Photonics K.K. +V 11A2 Sierra Research and Technology +V 11A3 Deuretzbacher GmbH & Co ENG. KG +V 11A4 Barco Graphics NV +V 11A5 MicroUnity Systems Engineering Inc +V 11A6 Pure Data Ltd +V 11A7 Power Computing Corp +V 11A8 Systech Corp +V 11A9 InnoSys Inc +D 4240 AMCC S933Q Intelligent Serial Card +V 11AA Actel +V 11AB Galileo Technology Ltd +D 0146 GT-64010 System Controller for R46xx CPU +D 4620 GT-64120 System Controller for R5K & R7K w/64bit PCI +D 4801 GT-48001 8-port Switched Ethernet Controller +D 4809 GT-48300 4-port (2.4Gb each) Crossbar Switch +D F003 GT-64010 Primary Image Piranha Image Generator +D F004 GT-64120 Primary Image Barracuda Image Generator +D F006 GT-64120A Primary Image Cruncher Geometry Accelerator +V 11AC Canon Information Systems +V 11AD Lite-On Communications Inc +D 0002 LNE100TX Fast Ethernet Adapter +O 11AD LNE100TX Fast Ethernet Adapter +S 0002 LNE100TX Fast Ethernet Adapter +S 0003 LNE100TX Fast Ethernet Adapter +S F003 LNE100TX Fast Ethernet Adapter +S FFFF LNE100TX Fast Ethernet Adapter +O 128A LNE100TX Fast Ethernet Adapter +S F001 LNE100TX Fast Ethernet Adapter +O 1385 FA310TX Fast Ethernet Adapter +S F004 FA310TX Fast Ethernet Adapter +D C115 LNE100TX Fast Ethernet Adapter +V 11AE Scitex +V 11AF Pro-Log Corp/AVID Technology Inc +V 11B0 V3 Semiconductor Inc +D 0001 V3 960 PCI Bridge +O 12C4 V3 960 PCI Bridge +S 0001 Blue Heat PCI/8 RS-232 +S 0002 Blue Heat PCI/4 RS-232 +S 0003 Blue Heat PCI/2 RS-232 +D 0002 V3 350 PCI Bridge (960 rev 2) +O 12C4 V3 350 PCI Bridge +S 0001 Blue Heat PCI/8 RS-232 +S 0002 Blue Heat PCI/4 RS-232 +S 0003 Blue Heat PCI/2 RS-232 +S 0004 Blue Heat PCI/8 RS-485 +S 0005 Blue Heat PCI/4+4 RS-232/485 +S 0006 Blue Heat PCI/4 RS-485 +S 0007 Blue Heat PCI/2+2 RS-232/485 +S 0008 Blue Heat PCI/2 RS-485 +S 0009 Blue Heat PCI/2+6 RS-232/485 +S 000A Blue Heat PCI/8 RS-485 (BH081101V1) +S 000B Blue Heat PCI/4 RS-485 (BH041101V1) +D 0292 V292PBC Am29030/40 PCI Bridge +D 0960 i960 Bridge +D C960 i960 Dual PCI Bridge +V 11B1 Apricot Computers +V 11B2 Eastman Kodak +V 11B3 Barr Systems Inc +V 11B4 Leitch Technology International +V 11B5 Radstone Technology Plc +V 11B6 United Video Corp +V 11B7 Motorola +V 11B8 Xpoint Technologies Inc +D 0001 Quad PeerMaster +V 11B9 Pathlight Technology Inc +D C0ED SSA Controller +V 11BA Videotron Corp +V 11BB Pyramid Technology/DAPHA Electronics Corp +V 11BC Network Peripherals Inc +D 0001 NPI NuCard PCI FDDI +V 11BD Pinnacle Systems Inc +V 11BE International Microcircuits Inc +V 11BF Astrodesign Inc +V 11C0 Hewlett Packard +V 11C1 AT&T Microelectronics (Lucent) +D 0440 LT WinModem 56k Data+Fax+Voice+Dsvd +X 04400001 LT WinModem 56k Data+Fax+Voice+Dsvd +O 1033 LT WinModem 56k Data+Fax+Voice+Dsvd +S 8015 LT WinModem 56k Data+Fax+Voice+Dsvd +S 804F LT WinModem 56k Data+Fax+Voice+Dsvd +O 10CF LB LT Modem V.90 56k +S 102C LB LT Modem V.90 56k +S 104A BIBLO LT Modem 56k +S 105F LB2 LT Modem V.90 56k +O 1179 Internal V.90 Modem +S 0001 Internal V.90 Modem +O 11C1 LT WinModem 56k Data+Fax+Voice+Dsvd +S 0440 LT WinModem 56k Data+Fax+Voice+Dsvd +O 122D MDP7800 Series Modem +S 4101 MDP7800-U Modem +S 4102 MDP7800SP-U Modem +O 13E0 LT WinModem 56k Data+Fax+Voice+Dsvd +S 0040 LT WinModem 56k Data+Fax+Voice+Dsvd +S 0440 LT WinModem 56k Data+Fax+Voice+Dsvd +S 0441 LT WinModem 56k Data+Fax+Voice+Dsvd +S 0450 56K Voice Modem +S F100 LT WinModem 56k Data+Fax+Voice+Dsvd +S F101 LT WinModem 56k Data+Fax+Voice+Dsvd +O 144D LT56PV Modem +S 2101 LT56PV Modem +O 149F LT WinModem 56k Data+Fax+Voice+Dsvd +S 0440 LT WinModem 56k Data+Fax+Voice+Dsvd +D 0441 LT WinModem 56k Data+Fax +O 1033 LT WinModem 56k Data+Fax +S 804D LT WinModem 56k Data+Fax +S 8065 Fax Modem 56K Data+Fax(BUQD) +O 1092 Supra PCI 56i +S 0440 Supra PCI 56i +O 1179 Internal V.90 Modem +S 0001 Internal V.90 Modem +O 11C1 LT WinModem 56k Data+Fax +S 0440 LT WinModem 56k Data+Fax +S 0441 LT WinModem 56k Data+Fax +O 122D MDP7800-U Modem +S 4100 MDP7800-U Modem +O 13E0 LT WinModem 56k Data+Fax +S 0040 LT WinModem 56k Data+Fax +S 0100 LT WinModem 56k Data+Fax +S 0410 LT WinModem 56k Data+Fax +S 0420 TelePath Internet 56k WinModem +S 0443 LT WinModem 56k Data+Fax +O 1416 CommWave 56k Modem +S 9804 CommWave 56k Modem +O 141D LT WinModem 56k Data+Fax +S 0440 LT WinModem 56k Data+Fax +O 144F Lucent 56k V.90 DF Modem +S 0441 Lucent 56k V.90 DF Modem +O 1468 Presario 56k V.90 DF Modem +S 0441 Presario 56k V.90 DF Modem +D 0442 LT WinModem 56k +O 0001 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +S 0440 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +O 11C1 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +S 0440 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +S 0442 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +O 13E0 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +S 0412 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +S 0442 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +O 13FC LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +S 2471 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +O 144D LT56PT Modem +S 2104 LT56PT Modem +O 149F LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +S 0440 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +O 1668 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +S 0440 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +D 0443 LT WinModem +D 0444 LT WinModem +D 0445 LT WinModem +D 0446 LT WinModem +D 0447 LT WinModem +D 0448 LT WinModem 56k +O 13E0 LT WinModem 56k Data+Fax+Voice+Dsvd +S 0040 LT WinModem 56k Data+Fax+Voice+Dsvd +D 0449 LT WinModem 56k +O 0E11 56k V.90 Modem +S B14D 56k V.90 Modem +S B14E Armada V300 Laptopn integrated modem +O 13E0 LT WinModem 56k Data+Fax +S 0020 LT WinModem 56k Data+Fax +S 0041 TelePath Internet 56k WinModem +O 1436 Lucent Win Modem +S 0440 Lucent Win Modem +O 144F Lucent 56k V.90 DFi Modem +S 0449 Lucent 56k V.90 DFi Modem +O 1468 Presario 56k V.90 DFi Modem +S 0449 Presario 56k V.90 DFi Modem +D 044A LT WinModem 56k +O 10CF LB Global LTMODEM +S 1072 LB Global LTMODEM +O 13E0 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +S 0012 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +S 0042 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +O 144F LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +S 1005 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd +D 044B LT WinModem +D 044C LT WinModem +D 044D LT WinModem +D 044E LT WinModem +D 044F LT V.90+DSL WildFire Modem +D 0450 LT WinModem +D 0451 LT WinModem +D 0452 LT WinModem +D 0453 LT WinModem +D 0454 LT WinModem +D 0455 LT WinModem +D 0456 LT WinModem +D 0457 LT WinModem +D 0458 LT WinModem +D 0459 LT WinModem +D 045A LT WinModem +D 0480 Venus WinModem (V90, 56KFlex) +D 5801 USB Open Host Controller +O 11C1 USB Open Host Controller +S 5801 USB Open Host Controller +D 5811 IEEE1394 FireWire +O 144F IEEE1394 FireWire +S 6003 IEEE1394 FireWire +V 11C2 SAND Microelectronics +V 11C3 NEC Corp +V 11C4 Document Technologies Industries +V 11C5 Shiva Corp +V 11C6 Dainippon Screen MFG Co Ltd +V 11C7 D.C.M. Data Systems +V 11C8 Dolphin Interconnect Solutions +D 0658 PCI to SCI Bridge +D D665 PSB64 SCI-Adapter D32x +D D667 PSB66 SCI-Adapter D33x +V 11C9 MAGMA +D 0010 16-line serial port w/- DMA +D 0011 4-line serial port w/- DMA +V 11CA LSI Systems Inc +V 11CB Specialix Research Ltd +D 2000 PCI-9050 Target Interface +O 11CB SX PCI Adapter +S 0200 SX PCI Adapter +S B008 I/O8+ PCI Adapter +D 4000 SUPI-1 XIO/SIO Host +D 8000 T225 Bridge RIO Host +V 11CC Michels & Kleberhoff Computer GmbH +V 11CD HAL Computer Systems Inc +V 11CE Netaccess +V 11CF Pioneer Electronic Corp +V 11D0 Loral Frederal Systems - Manassas +V 11D1 Auravision +D 01F7 VxP524 PCI Video Processor +V 11D2 Intercom Inc +V 11D3 Trancell Systems Inc +V 11D4 Analog Devices +D 1805 Motorola SM56 PCI Speakerphone Modem +V 11D5 IKON Corp +D 0115 10115 Greensheet +D 0117 10117 Greensheet +V 11D6 Tekelec Technologies +V 11D7 Trenton Terminals Inc +V 11D8 Image Technologies Development +V 11D9 TEC Corp +V 11DA Novell +V 11DB SEGA Enterprises Ltd +V 11DC Questra Corp +V 11DD Crosfield Electronics Ltd +V 11DE Zoran Corp +D 6057 ZR36057 MotionJPEG/TV Card +O 1031 DCxx JEG Capture/TV series cards +S 7EFE DC10 Plus +S D801 MiroVIDEO DC30 Plus, Motion JPEG Capture/CODEC Board +S FC00 MiroVIDEO DC50, Motion JPEG Capture/CODEC Board +O 13CA JPEG/TV Card +S 4231 JPEG/TV Card +D 6120 ZR36120 DVD Decoder +O 1328 Cinemaster C DVD Decoder +S F001 Cinemaster C DVD Decoder +V 11DF New Wave PDG +V 11E0 Cray Communications A/S +V 11E1 Gec Plessey Semiconductors Inc +V 11E2 Samsung Information Systems America +V 11E3 Quicklogic Corp +V 11E4 Second Wave Inc +V 11E5 IIX consulting +V 11E6 Mitsui-Zosen System Research +V 11E7 Toshiba America, Electric Company +V 11E8 Digital Processing Systems Inc +V 11E9 Highwater Designs Ltd +V 11EA Elsag Bailey +V 11EB Formation Inc +V 11EC Coreco Inc +V 11ED Mediamatics +V 11EE Dome Imaging Systems Inc +V 11EF Nicolet Technologies B.V. +V 11F0 Compu-Shack GmbH +D 4231 FDDI Network Card +D 4232 FASTline UTP Quattro +D 4233 FASTline FO +D 4234 FASTline UTP +D 4235 FASTline-II UTP +D 4236 FASTline-II FO +D 4731 GIGAline +V 11F1 Symbios Logic Inc +V 11F2 Picture Tel Japan K.K. +V 11F3 Keithley Metrabyte +V 11F4 Kinetic Systems Corp +D 2915 2915 +V 11F5 Computing Devices International +V 11F6 Compex / Powermatic Data Systems Ltd +D 0112 ReadyLink ENET100-VG4 +D 1401 ReadyLink 2000 (Winbond W89C940) +D 2011 RL100-ATX 10/100 Ethernet Adapter +D 2201 ReadyLink 100TX (Winbond W89C840) +O 11F6 ReadyLink 100TX +S 2011 ReadyLink 100TX +D 9881 RL100TX Fast Ethernet Adapter +V 11F7 Scientific Atlanta +V 11F8 PMC-Sierra Inc +D 7375 PM7375 LASAR-155 ATM SAR +V 11F9 I-CUBE Inc +V 11FA Kasan Electronics Company Ltd +V 11FB Datel Inc +V 11FC Silicon Magic +V 11FD High Street Consultants +V 11FE Comtrol Corp +D 0001 RocketPort 32-port +D 0002 RocketPort 8-port +D 0003 RocketPort 16-port +D 0004 RocketPort 32-port +D 0005 RocketPort 8-port +D 0006 RocketPort 8-port +D 0008 RocketPort 8-port +D 0009 RocketPort 16-port +D 000A RocketPort 32-port +D 000B RocketPort 8-port +D 000C RocketPort 6-port +V 11FF Scion Corp +V 1200 CSS Corp +V 1201 Vista Controls Corp +V 1202 Network General Corp +V 1203 Bayer Corp, Agfa Division +V 1204 Lattice Semiconductor Corp +V 1205 Array Corp +V 1206 Amdahl Corp +V 1208 Parsytec GmbH +D 4853 HS-Link Device +V 1209 SCI Systems Inc +V 120A Synaptel +V 120B Adaptive Solutions +V 120C Technical Corp +V 120D Compression Labs Inc +V 120E Cyclades Corp +D 0100 Cyclom-Y below 1Mb Serial Card +D 0101 Cyclom-Y above 1Mb Serial Card +D 0102 Cyclom-4Y below 1Mb Serial Card +D 0103 Cyclom-4Y above 1Mb Serial Card +D 0104 Cyclom-8Y below 1Mb Serial Card +D 0105 Cyclom-8Y above 1Mb Serial Card +D 0200 Cyclom-Z below 1Mb Intelligent Serial Card +D 0201 Cyclom-Z above 1Mb Intelligent Serial Card +V 120F Essential Communications +D 0001 Roadrunner +V 1210 Hyperparallel Technologies +V 1211 Braintech Inc +V 1212 Kingston Technology Corp +V 1213 Applied Intelligent Systems Inc +V 1214 Performance Technologies Inc +V 1215 Interware Co Ltd +V 1216 Purup Prepress A/S +V 1217 O2 Micro Inc +D 6729 OZ6729 PCI to PCMCIA Bridge +D 673A OZ6730 PCI to PCMCIA Bridge +D 6832 OZ6832/3 Cardbus Controller +D 6836 OZ6836/6860 Cardbus Controller +D 6872 OZ6812 Cardbus Controller +D 6925 OZ6922 CardBus Controller +D 6933 OZ6933 Cardbus Controller +D 6972 OZ6912 CardBus Controller +V 1218 Hybricon Corp +V 1219 First Virtual Corp +V 121A 3Dfx Interactive Inc +D 0001 3Dfx Voodoo Chipset +D 0002 3Dfx Voodoo2 Chipset +D 0003 3Dfx Voodoo Banshee Chipset +X 30303030 Skywell Magic TwinPower +X FFFF1043 AGP-V3200 +O 1092 Monster Fusion +S 0003 Monster Fusion +S 4000 Monster Fusion PCI +S 4002 Monster Fusion PCI +S 4801 Monster Fusion AGP +S 4803 Monster Fusion AGP +S 8030 Monster Fusion PCI +S 8035 Monster Fusion AGP +O 10B0 Dragon 4000 +S 0001 Dragon 4000 +O 1102 3D Blaster Banshee +S 1017 CT6760 3D Blaster Banshee +O 121A Voodoo Banshee +S 0001 Voodoo Banshee AGP SDRAM +S 0002 Voodoo Banshee PCI SDRAM +S 0003 Voodoo Banshee AGP SGRAM +S 0004 Voodoo Banshee PCI SGRAM Velocity 100 +S 0011 Voodoo Banshee AGP SDRAM +S 0012 Voodoo Banshee PCI SDRAM +S 0013 Voodoo Banshee AGP SGRAM +S 0014 Voodoo Banshee PCI SGRAM +S 0021 Voodoo Banshee AGP SDRAM +S 0022 Voodoo Banshee PCI SDRAM +S 0023 Voodoo Banshee AGP SGRAM +S 0024 Voodoo Banshee PCI SGRAM +O 139C Raven +S 0016 Raven AGP +S 0017 Raven PCI +O 14AF Maxi Gamer Phoenix +S 0001 Maxi Gamer Phoenix PCI +S 0002 Maxi Gamer Phoenix AGP +D 0005 3Dfx Voodoo3 Chipset +O 121A Voodoo3 AGP +S 0004 Voodoo3 AGP +S 0030 Voodoo3 AGP +S 0031 Voodoo3 AGP +S 0034 Voodoo3 AGP +S 0036 Voodoo3 PCI +S 0037 Voodoo3 AGP +S 0038 Voodoo3 AGP +S 003A Voodoo3 AGP +S 0044 Voodoo3 PCI +S 004B Velocity 100 +S 004C Velocity 200 +S 004D Voodoo3 AGP +S 004E Voodoo3 AGP +S 0051 Voodoo3 AGP +S 0052 Voodoo3 AGP +S 0060 Voodoo3 3500 TV (NTSC) +S 0061 Voodoo3 3500 TV (PAL) +S 0062 Voodoo3 3500 TV (SECAM) +D 0009 Voodoo4/5 +O 121A Voodoo4/5 +S 0001 Voodoo5 SDRAM AGP +S 0002 Voodoo5 SDRAM/SGRAM AGP +S 0003 Voodoo5 SGRAM PCI +S 0004 Voodoo4 SDRAM+TV+LCD AGP +S 0005 Voodoo4 SDRAM+TV+LCD PCI +V 121B Advanced Telecommunications Modules +V 121C Nippon Texa Co Ltd +V 121D Lippert Automationstechnik GmbH +V 121E CSPI +V 121F Arcus Technology Inc +V 1220 Ariel Corp +D 1220 AMCC 5933 TMS320C80 DSP/Imaging Board +V 1221 Contec Co Ltd +V 1222 Ancor Communications Inc +V 1223 Heurikon/Computer Products +D 0003 PM/Link +D 0004 PM/T1 +D 0005 PM/E1 +D 0008 PM/SLS +D 0009 BajaSpan Resource Target +D 000A BajaSpan Section 0 +D 000B BajaSpan Section 1 +D 000C BajaSpan Section 2 +D 000D BajaSpan Section 3 +D 000E PM/PPC +V 1224 Interactive Images +V 1225 Power I/O Inc +V 1227 Tech-Source +V 1228 Norsk Elektro Optikk A/S +V 1229 Data Kinesis Inc +V 122A Integrated Telecom +V 122B LG Industrial Systems Co Ltd +V 122C Sican GmbH +V 122D Aztech System Ltd +D 1206 368DSP +D 50DC 3328 Audio +O 122D 3328 Audio +S 0001 3328 Audio +D 80DA 3328 Audio +O 122D 3328 Audio +S 0001 3328 Audio +V 122E Xyratex +V 122F Andrew Corp +V 1230 Fishcamp Engineering +V 1231 Woodard McCoach Inc +V 1232 GPT Limited +V 1233 Bus-tech Inc +V 1234 Technical Corp +V 1235 RISQ Modular Systems Inc +V 1236 Sigma Designs Corp +D 0000 RealMagic64/GX +D 6401 REALmagic64/GX GUI Accelerator +V 1237 Alta Technology Corp +V 1238 Adtran +V 1239 3DO Company +V 123A Visicom Labrotories Inc +V 123B SEEQ Technology Inc +V 123C Century Systems Inc +V 123D Engineering Design Team Inc +D 0000 EasyConnect 8/32 +D 0002 EasyConnect 8/64 +D 0003 EasyIO +V 123E Simutech Inc +V 123F C-Cube Microsystems +D 00E4 MPEG +D 8120 E4 +O 11BD DVxxx Series E4 +S 0006 DV500 E4 +S 000A DV500 E4 +S 000F DV500 E4 +D 8888 Cinemaster C 3.0 DVD Decoder +O 1002 Cinemaster C 3.0 DVD Decoder +S 0001 Cinemaster C 3.0 DVD Decoder +S 0002 Cinemaster C 3.0 DVD Decoder +O 1328 Cinemaster C 3.0 DVD Decoder +S 0001 Cinemaster C 3.0 DVD Decoder +V 1240 Marathon Technologies Corp +V 1241 DSC Communications +V 1242 Jaycor Networks Inc +D 4643 FCI-1063 Fibre Channel Adapter +V 1243 Delphax +V 1244 AVM Audiovisuelles MKTG & Computer GmbH +D 0700 AVM B1 ISDN Controller +D 0A00 FRITZ!Card ISDN Controller +O 1244 FRITZ!Card ISDN Controller +S 0A00 FRITZ!Card ISDN Controller +D 1200 AVM T1 ISDN Controller +V 1245 A.P.D., S.A. +V 1246 Dipix Technologies Inc +V 1247 Xylon Research Inc +V 1248 Central Data Corp +V 1249 Samsung Electronics Co Ltd +V 124A AEG Electrocom GmbH +V 124B Greenspring Computers Inc +V 124C Solitron Technologies Inc +V 124D Stallion Technologies Inc +D 0000 EasyConnect 8/32 +D 0002 EasyConnect 8/64 +O 124D EasyConnection EC8/64-PCI +S 0002 EasyConnection EC8/64-PCI +D 0003 EasyIO PCI +O 124D EasyIO-PCI +S 0002 EasyIO-PCI +D 0004 EasyConnection ECRA-PCI +O 124D EasyConnection ECRA-PCI +S 0004 EasyConnection ECRA-PCI +V 124E Cylink +V 124F Infortrend Technology Inc +D 0041 IFT-2000 Series PCI RAID Controller +V 1250 Hitachi Microcomputer System Ltd +V 1251 VLSI Solution OY +V 1253 Guzik Technical Enterprises +V 1254 Linear Systems Ltd +V 1255 Optibase Ltd +D 1110 MPEG Forge +D 1210 MPEG Fusion +D 2110 VideoPlex +D 2120 VideoPlex CC +D 2130 VideoQuest +V 1256 Perceptive Solutions Inc +D 4401 PCI-2220i Dale EIDE Adapter +D 5201 PCI-2000 IntelliCache SCSI Controller +V 1257 Vertex Networks Inc +V 1258 Gilbarco Inc +V 1259 Allied Telesyn International +D 2560 AT-2560 Fast Ethernet Adapter (i82557B) +V 125A ABB Power Systems +V 125B ASIX Electronics Corp +D 1400 AX8814X PCI Fast Ethernet Adapter +V 125C Aurora Technologies Inc +V 125D ESS Technology +D 0000 ES336H PCI Fax Modem (Early Model) +D 1948 Solo?? +D 1968 ES1968 Maestro-2 Audiodrive +O 0640 ES1968 Maestro-2 Audiodrive on VIA-Chipset Motherboard +S 0200 ES1968 Maestro-2 Audiodrive on VIA-Chipset Motherboard +O 1028 ES1968 Maestro-2 PCI +S 0085 ES1968 Maestro-2 PCI +O 1033 ES1968 Maestro-2 Audiodrive +S 8051 ES1968 Maestro-2 Audiodrive +O 125D ES1968 Maestro-2 Audiodrive +S 1968 ES1968 Maestro-2 Audiodrive +D 1969 ES1938/41/46 SOLO-1(E) AudioDrive +O 1014 ES1938/41/46 SOLO-1(E) AudioDrive +S 0166 ES1938/41/46 SOLO-1(E) AudioDrive on IBM Aptiva Mainboard +O 125D ES1938/41/46 SOLO-1(E) Audio Adapter +S 1969 ES1938/41/46 SOLO-1(E) AudioDrive +S 8888 ES1938/41/46 SOLO-1(E) Audio Adapter +O 1509 ES1938/41/46 SOLO-1(E) AudioDrive +S 4340 ES1938/41/46 SOLO-1(E) AudioDrive on FIC A450 Notebook +O 50B2 Solo-1 +S 1113 Solo-1 +O 525F ES1938/41/46 SOLO-1(E) AudioDrive +S C888 ES1938/41/46 SOLO-1(E) AudioDrive +D 1978 ES1978 Maestro-2E Audiodrive, ES1970 Canyon3D +O 0E11 ES1978 Maestro-2E Audiodrive +S B112 Armada V300 Laptop integrated sound +O 1033 ES1978 Maestro-2E Audiodrive +S 803C ES1978 Maestro-2E Audiodrive +S 8058 ES1978 Maestro-2E Audiodrive +O 1092 Monster Sound MX400 +S 4000 Monster Sound MX400 +O 1179 ES1978 Maestro-2E Audiodrive +S 0001 ES1978 Maestro-2E Audiodrive +O 125D ES1978 Maestro-2E Audiodrive +S 1978 ES1978 Maestro-2E Audiodrive +O 13BD ES1978 Maestro-2E Audiodrive on Sharp Notebook +S 100A ES1978 Maestro-2E Audiodrive on sharp PC-A520 Notebook +D 1988 ES1989 Allegro-1 Audiodrive +O 1092 Sonic Impact S100 +S 4100 Sonic Impact S100 +O 125D ES1989 Allegro-1 Audiodrive +S 1988 ES1989 Allegro-1 Audiodrive +D 1989 ES1989 Allegro-1.COMM ES56CVM-PI PCI Voice+Fax Modem +O 125D ES1989 Allegro-1.COMM ES56CVM-PI PCI Voice+Fax Modem +S 1989 ES1989 Allegro-1.COMM ES56CVM-PI PCI Voice+Fax Modem +D 1998 ES1980 Maestro-3 PCI Audio Accelerator +O 1028 ES1980 Maestro-3 PCI Audio Accelerator +S 00A4 ES1980 Maestro-3 in Dell Inspiron 8000 Laptop +O 125D ES1980 Maestro-3 PCI Audio Accelerator +S 1998 ES1980 Maestro-3 PCI Audio Accelerator +D 1999 ES1983 Maestro-3.COMM ES56CVM-PI PCI oice+Fax Modem +O 125D ES1983 Maestro-3.COMM ES56CVM-PI PCI oice+Fax Modem +S 1999 ES1983 Maestro-3.COMM ES56CVM-PI PCI oice+Fax Modem +D 199A ES1980 Maestro-3 PCI Audio Accelerator +O 125D ES1980 Maestro-3 PCI Audio Accelerator +S 199A ES1980 Maestro-3 PCI Audio Accelerator +D 199B ES1983 Maestro-3.COMM ES56CVM-PI PCI oice+Fax Modem +O 125D ES1983 Maestro-3.COMM ES56CVM-PI PCI oice+Fax Modem +S 199B ES1983 Maestro-3.COMM ES56CVM-PI PCI oice+Fax Modem +D 2808 ES336H PCI Fax Modem (Later Model) +D 2838 ES2838/2839 SuperLink Modem +D 2898 ES2898 ES56-PI Family V.90 PCI Modem +O 125D ES2898 ES56-PI Family V.90 PCI Modem +S 0424 ES56-PI Data/Fax V.90 PCI Modem +S 0425 ES56T-PI Data/Fax/TAM V.90 PCI Modem +S 0426 ES56V-PI Data/Fax/TAM/SpkrPhone V.90 PCI Modem +S 0427 ES56VW-PI Data/Fax/TAM/SpkrPhone International V.90 PCI Modem +S 0428 ES56ST-PI Data/Fax/TAM No Handset V.90 PCI Modem +S 0429 ES56V-PI Data/Fax/TAM/SpkrPhone No Handset V.90 PCI Modem +V 125E Specialvideo Engineering SRL +V 125F Concurrent Technologies Inc +V 1260 Harris Semiconductor +D 8130 HMP8130 NTSC/PAL Video Decoder +D 8131 HMP8131 NTSC/PAL Video Decoder +V 1261 Matsushita-Kotobuki Electronics Industries +V 1262 ES Computer Company Ltd +V 1263 Sonic Solutions +V 1264 AVAL NAGASAKI Corp +V 1265 Casio Computer Co Ltd +V 1266 Microdyne Corp +D 0001 NE10/100 Adapter (i82557B) +D 1910 NE2000Plus (RT8029) Ethernet Adapter +O 1266 NE2000Plus Ethernet Adapter +S 1910 NE2000Plus Ethernet Adapter +V 1267 S.A. Telecommunications +D 5352 PCR2101 +D 5A4B telsatturbo +V 1268 Tektronix +V 1269 Thomson-CSF/TTM +V 126A Lexmark International Inc +V 126B ADAX, Inc +V 126C Northern Telecom +V 126D Splash Technology Inc +V 126E Sumitomo Metal Industries Ltd +V 126F Silicon Motion Inc +D 0710 SM710 LynxEM +D 0712 SM712 LynxEM+ +D 0720 SM720 Lynx3DM +D 0810 SM810 LynxE +D 0811 SM811 LynxE +D 0820 SM820 Lynx3D +D 0910 SM910 Lynx +V 1270 Olympus Optical Co Ltd +V 1271 GW Instruments +V 1272 Telematics +V 1273 Hughes Network systems +D 0002 Direcpc +V 1274 Ensoniq (Creative) +D 1371 ES1371, ES1373 AudioPCI +O 0E11 ES1371, ES1373 AudioPCI +S B1A7 ES1371, ES1373 AudioPCI +O 1033 ES1371, ES1373 AudioPCI +S 80AC ES1371, ES1373 AudioPCI +O 1042 ES1371, ES1373 AudioPCI +S 1854 Tazer +O 107B ES1371, ES1373 AudioPCI +S 8054 Tabor2 +O 1274 ES1371, ES1373 AudioPCI +S 1371 Creative Sound Blaster AudioPCI64V, AudioPCI 128 +O 1462 ES1371, ES1373 AudioPCI On Motherboard +S 3180 ES1371, ES1373 AudioPCI On Motherboard +S 6470 ES1371, ES1373 AudioPCI On Motherboard MS-6147 1.1A +S 6560 ES1371, ES1373 AudioPCI On Motherboard MS-6156 1.10 +S 6630 ES1371, ES1373 AudioPCI On Motherboard MS-6163BX 1.0A +S 6631 ES1371, ES1373 AudioPCI On Motherboard MS-6163VIA 1.0A +S 6632 ES1371, ES1373 AudioPCI On Motherboard MS-6163BX 2.0A +S 6633 ES1371, ES1373 AudioPCI On Motherboard MS-6163VIA 2.0A +S 6820 ES1371, ES1373 AudioPCI On Motherboard MS-6182 1.00 +S 6822 ES1371, ES1373 AudioPCI On Motherboard MS-6182 1.00A +S 6830 ES1371, ES1373 AudioPCI On Motherboard MS-6183 1.00 +S 6880 ES1371, ES1373 AudioPCI On Motherboard MS-6188 1.00 +S 6900 ES1371, ES1373 AudioPCI On Motherboard MS-6190 1.00 +S 6910 ES1371, ES1373 AudioPCI On Motherboard MS-6191 +S 6930 ES1371, ES1373 AudioPCI On Motherboard MS-6193 +S 6990 ES1371, ES1373 AudioPCI On Motherboard MS-6199BX 2.0A +S 6991 ES1371, ES1373 AudioPCI On Motherboard MS-6199VIA 2.0A +O 14A4 ES1371, ES1373 AudioPCI On Motherboard +S 2077 ES1371, ES1373 AudioPCI On Motherboard KR639 +S 2105 ES1371, ES1373 AudioPCI On Motherboard MR800 +S 2107 ES1371, ES1373 AudioPCI On Motherboard MR801 +S 2172 ES1371, ES1373 AudioPCI On Motherboard DR739 +O 1509 ES1371, ES1373 AudioPCI On Motherboard +S 9902 ES1371, ES1373 AudioPCI On Motherboard KW11 +S 9903 ES1371, ES1373 AudioPCI On Motherboard KW31 +S 9904 ES1371, ES1373 AudioPCI On Motherboard KA11 +S 9905 ES1371, ES1373 AudioPCI On Motherboard KC13 +O 152D ES1371, ES1373 AudioPCI On Motherboard +S 8801 ES1371, ES1373 AudioPCI On Motherboard CP810E +S 8802 ES1371, ES1373 AudioPCI On Motherboard CP810 +S 8803 ES1371, ES1373 AudioPCI On Motherboard P3810E +S 8804 ES1371, ES1373 AudioPCI On Motherboard P3810-S +S 8805 ES1371, ES1373 AudioPCI On Motherboard P3820-S +O 270F ES1371, ES1373 AudioPCI On Motherboard +S 2001 ES1371, ES1373 AudioPCI On Motherboard 6CTR +S 2200 ES1371, ES1373 AudioPCI On Motherboard 6WTX +S 3000 ES1371, ES1373 AudioPCI On Motherboard 6WSV +S 3100 ES1371, ES1373 AudioPCI On Motherboard 6WIV2 +S 3102 ES1371, ES1373 AudioPCI On Motherboard 6WIV +S 7060 ES1371, ES1373 AudioPCI On Motherboard 6ASA2 +O 8086 ES1371, ES1373 AudioPCI On Motherboard +S 4249 ES1371, ES1373 AudioPCI On Motherboard BI440ZX +S 424C ES1371, ES1373 AudioPCI On Motherboard BL440ZX +S 425A ES1371, ES1373 AudioPCI On Motherboard BZ440ZX +S 4341 ES1371, ES1373 AudioPCI On Motherboard Cayman +S 4343 ES1371, ES1373 AudioPCI On Motherboard Cape Cod +S 4649 ES1371, ES1373 AudioPCI On Motherboard Fire Island +S 464A ES1371, ES1373 AudioPCI On Motherboard FJ440ZX +S 4D4F ES1371, ES1373 AudioPCI On Motherboard Montreal +S 4F43 ES1371, ES1373 AudioPCI On Motherboard OC440LX +S 5243 ES1371, ES1373 AudioPCI On Motherboard RC440BX +S 5352 ES1371, ES1373 AudioPCI On Motherboard SunRiver +S 5643 ES1371, ES1373 AudioPCI On Motherboard Vancouver +S 5753 ES1371, ES1373 AudioPCI On Motherboard WS440BX +D 5000 ES1370 AudioPCI +X 4C4C4942 Creative Sound Blaster AudioPCI 64 +D 5880 5880 AudioPCI +O 1274 5880 AudioPCI +S 2000 Creative Sound Blaster AudioPCI 128 +S 2003 Creative Sound Blaster AudioPCI 128 +S 5880 Creative Sound Blaster AudioPCI 128 +O 1462 5880 AudioPCI On Motherboard +S 6880 5880 AudioPCI On Motherboard MS-6188 1.00 +O 270F 5880 AudioPCI On Motherboard +S 2001 5880 AudioPCI On Motherboard 6CTR +S 2200 5880 AudioPCI On Motherboard 6WTX +S 7040 5880 AudioPCI On Motherboard 6ATA4 +V 1275 Network Appliance Corp +V 1276 Switched Network Technologies Inc +V 1277 Comstream +V 1278 Transtech Parallel Systems Ltd +V 1279 Transmeta Corp +D 0295 Virtual Northbridge +D 0395 LongRun Northbridge +D 0396 SDRAM Controller +D 0397 BIOS scratchpad +V 127A Rockwell Semiconductor Systems (Also Conexant) +D 1002 HCF 56k V90 Modem +O 1092 SupraExpress 56i PRO +S 094C SupraExpress 56i PRO +O 122D MDP3858-U Data Fax Modem +S 4002 MDP3858-U Data Fax Modem +S 4007 MDP3858-U Data Fax Modem +S 4017 MDP3858-U Data Fax Modem +O 127A HCF 56k V90 Modem +S 1002 HCF 56k V90 Modem +D 1003 HCF 56k V90 Modem +O 127A PCI56RX Modem +S 1003 PCI56RX Modem +O 13DF PCI56RX Modem +S 1003 PCI56RX Modem +O 13E0 1156IV+ International series V.90 Modem +S 0147 1156IV+ International series V.90 Modem +D 1004 HCF 56k V90 Modem +O 1048 MicroLink 56K PCI Modem +S 1500 MicroLink 56K PCI Modem +D 1005 HCF 56k V90 Speakerphone Modem +O 122D MDP3858 Series Modem +S 4006 MDP3858V-U Data Fax Modem +S 4008 MDP3858SP-A SVD Modem +S 4010 MDP3858V-U Data Fax Modem +S 4015 MDP3858V-U Data Fax Modem +S 4016 MDP3858V-U Data Fax Modem +O 127A PCI56RVP Modem +S 1005 PCI56RVP Modem +O 13DF PCI56RVP Modem +S 1005 PCI56RVP Modem +O 1436 WS-5614PS3G +S 1005 WS-5614PS3G +D 1023 V.90 Modem +O 1436 5614 International series V.90 Modem +S 1303 5614 International series V.90 Modem +D 1024 HCF 56k PCI Modem +O 144F HCF 56k PCI Modem +S 1008 HCF 56k PCI Modem +D 1025 HCF 56k PCI Modem +O 127A HCF 56k PCI Modem +S 1025 HCF 56k PCI Modem +D 1026 HCF 56k PCI Speakerphone Modem +O 127A HCF 56k PCI Speakerphone Modem +S 1026 HCF 56k PCI Speakerphone Modem +D 1035 HCF 56k PCI Speakerphone Modem +O 127A HCF 56k PCI Speakerphone Modem +S 1035 HCF 56k PCI Speakerphone Modem +D 1085 Volcano HCF 56k PCI Modem +O 127A Volcano HCF 56k PCI Modem +S 1085 Volcano HCF 56k PCI Modem +D 2005 Conexant SoftK56 Speakerphone Modem +O 104D HCF 56K PCI Modem +S 8044 HCF 56K PCI Modem +O 127A Conexant SoftK56 Speakerphone Modem +S 2005 Conexant SoftK56 Speakerphone Modem +D 2015 Conexant SoftK56 Speakerphone Modem +O 127A Conexant SoftK56 Speakerphone Modem +S 2015 Conexant SoftK56 Speakerphone Modem +O 14C8 Conexant SoftK56 Speakerphone Modem +S 2115 Conexant SoftK56 Speakerphone Modem +D 4310 Master Riptide PCI Audio Device +D 4311 Conexant PCI Modem Enumerator +D 4312 Riptide PCI Game Controller +D 4320 Riptide PCI Audio Controller +O 1235 Riptide PCI Audio Controller +S 4320 Riptide PCI Audio Controller +D 4321 Riptide HCF 56k PCI Modem +O 1235 Riptide HCF 56k PCI Modem +S 4321 Riptide HCF 56k PCI Modem +D 4322 Riptide PCI Game Controller +O 1235 Riptide PCI Game Controller +S 4322 Riptide PCI Game Controller +D 5278 Harmonic DVB Network Adapter +D 8234 RapidFire 616X ATM155 Adapter +O 108D RapidFire 616X ATM155 Adapter +S 0027 RapidFire 616X ATM155 Adapter +V 127B PIXERA Corp +V 127C Crosspoint Solutions Inc +V 127D VELA Research +V 127E Winnou, L.P. +V 127F Fujifilm +V 1280 Photoscript Group Ltd +V 1281 Yokogawa Electric Corp +V 1282 Davicom Semiconductor Inc +D 9102 DM9102/A/AF,DM9801 Fast Ethernet Adapter +O 3030 C-Net CN200 Pro Fast Ethernet Adapter +S 5032 C-Net CN200 Pro Fast Ethernet Adapter +V 1283 Integrated Technology Express Inc +D 673A IT8330G PCI EIDE Controller +D 8172 IT8172 Ultra RISC (MIPS,SH4) Companion Chip +D 8330 IT8330G PCI Host Bridge +D 8872 IT8871/72 PCI to ISA I/O chip with SMB, Parallel Port & GPIO +D 8888 IT8888F PCI to ISA Bridge with SMB +D 8889 IT8889F PCI to ISA Bridge +D E886 IT8330G PCI to ISA Bridge +V 1284 Sahara Networks Inc +V 1285 Platform Technologies Inc +D 0100 ES1948 Maestro-1 AudioDrive +O 1285 ES1948 Maestro-1 AudioDrive +S 0100 ES1948 Maestro-1 AudioDrive +V 1286 Mazet GmbH +V 1287 M-Pact Inc +D 001E LS220D DVD Decoder +D 001F LS220C DVD Decoder +V 1288 Timestep Corp +V 1289 AVC Technology Inc +V 128A Asante Technologies Inc +V 128B Transwitch Corporation +V 128C Retix Corp +V 128D G2 Networks Inc +D 0021 ATM155 Adapter +V 128E Hoon Tech co Ltd/Samho Multi Tech Ltd +D 0008 ST128 WSS/SB +D 0009 ST128 SAM9407 +D 000A ST128 Game Port +D 000B ST128 MPU Port +D 000C ST128 Ctrl Port +V 128F Tateno Dennou Inc +V 1290 Sord Computer Corporation +V 1291 NCS Computer Italia +V 1292 Tritech Microelectronics +V 1293 Media Reality Technology +V 1294 Rhetorex Inc +V 1295 Imagenation Corp +V 1296 Kofax Image Products +V 1297 Holco Ent Co Ltd/Shuttle Computer +V 1298 Spellcaster Telecommunications Inc +V 1299 Knowledge Technology Lab +V 129A Vmetro Inc +V 129B Image Access +V 129C Xantel Corp/Jaycor +V 129D Compcore Multimedia Inc +V 129E Victor Company of Japan Ltd +V 129F OEC Medical Systems Inc +V 12A0 Allen-Bradley Company +V 12A1 Simpact Associates Inc +V 12A2 Newgen systems Corp +V 12A3 Lucent Technologies +V 12A4 NTT Electronics Technology Company +V 12A5 Vision Dynamics Ltd +V 12A6 Scalable Networks Inc +V 12A7 AMO GmbH +V 12A8 News Datacom +V 12A9 Xiotech Corp +V 12AA SDL Communications Inc +V 12AB Yuan Yuan Enterprise Co Ltd +D 3000 TUN-200/MPG-200C PCI TV (and possibly DVD Decoder??) Card +V 12AC Measurex Corp +V 12AD Multidata GmbH +V 12AE Alteon Networks Inc +D 0001 ACENIC +O 12AE Gigabit Ethernet Adapter +S 0001 Gigabit Ethernet Adapter +O 1410 Gigabit Ethernet-SX PCI Adapter +S 0104 Gigabit Ethernet-SX PCI Adapter +V 12AF TDK USA Corp +V 12B0 Jorge Scientific Corp +V 12B1 GammaLink +V 12B2 General Signal Networks +D 0209 SNA Link/9000 PCI to ESCON Controller +V 12B3 Inter-Face Co Ltd +V 12B4 FutureTel Inc +V 12B5 Granite Systems Inc +V 12B6 Natural Microsystems +V 12B7 ACCUMEN/Cognex Modular Vision Systems +V 12B8 Korg +V 12B9 3COM Corp, Modem Division (Formerly US Robotics) +D 1006 USR 56k Internal WinModem +O 12B9 USR 56k Internal WinModem +S 005C USR 56k Internal Voice WinModem (Model 3472) +S 005E USR 56k Internal WinModem (Model 662975) +S 0062 USR 56k Internal Voice WinModem (Model 662978) +S 0068 USR 56k Internal Voice WinModem (Model 5690) +S 007A USR 56k Internal Voice WinModem (Model 662974) +S 007F USR 56k Internal WinModem (Models 5698, 5699) +S 0080 USR 56k Internal WinModem (Models 2975, 3528) +S 0081 USR 56k Internal Voice WinModem (Models 2974, 3529) +S 0091 USR 56k Internal Voice WinModem (Model 2978) +D 1007 USR 56k Internal WinModem +O 12B9 USR 56k Internal WinModem +S 00A3 USR 56k Internal WinModem (Model 3595) +S 00A6 USR 56k Internal Voice Winmodem (Model 3594) +D 1008 USR 56k Internal Modem +O 12B9 USR 56k Internal Modem +S 00A2 USR 56k Internal FAX Modem (Model 2977) +S 00AA USR 56k Internal Voice Modem (Model 2976) +S 00AB USR 56k Internal Voice Modem (Model 5609) +S 00AC USR 56k Internal Voice Modem (Model 3298) +S 00AD USR 56k Internal FAX Modem (Model 5610) +S 00B7 USR 56k Internal Gaming Modem (Model 5613) +V 12BA Bittware Research/PMC Sierra +V 12BB Nippon Unisoft Corp +V 12BC Array Microsystems +V 12BD Computerm Corp +V 12BE Anchor Chips Inc +D 3041 AN3041Q CO-MEM PCI Bus Interface/Cache +D 3042 AN3042Q CO-MEM Lite PCI Generic Host Bridge/Shared Memory +O 12BE Anchor Chips Lite Evaluation Board +S 3042 Anchor Chips Lite Evaluation Board +V 12BF Fujifilm Microdevices +V 12C0 Infimed +V 12C1 GMM Research Corp +V 12C2 Mentec Ltd +V 12C3 Holtek Microelectronics Inc +V 12C4 Connect Tech Inc +D 0001 Blue Heat PCI/8 RS-232 +D 0002 Blue Heat PCI/4 RS-232 +D 0003 Blue Heat PCI/2 RS-232 +D 0004 Blue Heat PCI/8 RS-485 +D 0005 Blue Heat PCI/4+4 RS-232/485 +D 0006 Blue Heat PCI/4 RS-485 +D 0007 Blue Heat PCI/2+2 RS-232/485 +D 0008 Blue Heat PCI/2 RS-485 +D 0009 Blue Heat PCI/2+6 RS-232/485 +D 000A Blue Heat PCI/8 RS-485 (BH081101V1) +D 000B Blue Heat PCI/4 RS-485 (BH041101V1) +V 12C5 Picture Elements Inc +D 007F PCIISE Imaging Subsystem Engine +D 0081 PCIVST PCI Thresholding Engine +D 0085 Video Simulator/Sender +D 0086 THR2 Multi-scale Thresholder +V 12C6 Mitani Corp +V 12C7 Dialogic Corp +V 12C8 G Force Co Ltd +V 12C9 Gigi Operations +V 12CA Integrated Computing Engines +V 12CB Antex Electronics Corp +V 12CC Pluto Technologies International +V 12CD Aims Lab +V 12CE Netspeed Inc +V 12CF Prophet Systems Inc +V 12D0 GDE Systems Inc +V 12D1 PSITECH +V 12D2 STB/Nvidia/SGS Thompson +D 0008 NV1 +D 0009 DAC64 +D 0018 RIVA 128 2D/3D GUI Accelerator +O 1048 Victory Erazor +S 0C10 Victory Erazor +O 107B STB Velocity 128 +S 8030 STB Velocity 128 +O 1092 Viper V330 +S 0350 Viper V330 +S 1092 Viper V330 +O 10B4 STB Velocity 128 +S 1B1B STB Velocity 128 +S 1B20 STB Velocity 128 +S 1B21 STB Velocity 128 +S 1B22 STB Velocity 128 AGP, NTSC TV-Out +S 1B23 STB Velocity 128 AGP, PAL TV-Out +S 1B27 STB Velocity 128 DVD +S 1B88 MVP PRO 128 +S 222A STB Velocity 128 AGP +S 2230 STB Velocity 128 PCI +S 2235 STB Velocity 128 AGP +O 2A15 3DVision-SAGP +S 54A3 3DVision-SAGP +D 0019 RIVA 128ZX 2D/3D GUI Accelerator +D 0020 TNT +D 0028 TNT2 +D 0029 UTNT2 +D 002C VTNT2 +D 00A0 ITNT2 +V 12D3 Vingmed Sound A/S +V 12D4 DGM&S +V 12D5 Equator Technologies +V 12D6 Analogic Corp +V 12D7 Biotonic SRL +V 12D8 Pericom Semiconductor +V 12D9 Acculab PLC +V 12DA True Time +V 12DB Annapolis Micro systems Inc +V 12DC Symicron Computer Communication Ltd +V 12DD Management Graphics +V 12DE Rainbow Technologies +V 12DF SBS Technologies Inc +V 12E0 Chase Research +D 0010 ST16C654 Quad UART +D 0020 ST16C654 Quad UART +D 0021 8x UART +D 0030 ST16C654 Quad UART +V 12E1 Nintendo co Ltd +V 12E2 Datum Inc Bancomm-Timing Division +V 12E3 Imation Corp - Medical Imaging Systems +V 12E4 Brooktrout Technology Inc +V 12E5 XCD Inc/Apex Inc +V 12E6 Cirel Systems +V 12E7 Sunsgroup Corp +V 12E8 CRISC Corp +V 12E9 GE Spacenet +V 12EA Zuken +V 12EB Aureal Inc +D 0001 AU8820 Vortex Digital Audio Processor +X 03000000 IntreSource TeraSound A3D +O 104D AU8820 Vortex Digital Audio Processor +S 8036 AU8820 Vortex Digital Audio Processor +O 1092 Sonic Impact A3D +S 2000 Sonic Impact A3D +S 2100 Sonic Impact A3D +S 2110 Sonic Impact A3D +S 2200 Sonic Impact A3D +O 12EB AU8820 Vortex Digital Audio Processor +S 0001 AU8820 Vortex Digital Audio Processor +O 5053 Montego +S 3355 Montego +D 0002 AU8830 Vortex 3D Digital Audio Processor +O 104D AU8830 Vortex 3D Digital Audio Processor +S 8049 AU8830 Vortex 3D Digital Audio Processor +S 807B AU8830 Vortex 3D Digital Audio Processor +O 1092 Monster Sound II +S 3000 Monster Sound II +S 3001 Monster Sound II +S 3002 Monster Sound II +S 3003 Monster Sound II +S 3004 Monster Sound II +O 12EB AU8830 Vortex 3D Digital Audio Processor +S 0001 AU8830 Vortex 3D Digital Audio Processor +S 0002 AU8830 Vortex 3D Digital Audio Processor +S 0088 AU8830 Vortex 3D Digital Audio Processor +O 144D AU8830 Vortex 3D Digital Audio Processor +S 3510 AU8830 Vortex 3D Digital Audio Processor +O 5053 Montego II +S 3356 Montego II +D 0003 AU8810 Vortex Digital Audio Processor +O 104D AU8810 Vortex Digital Audio Processor +S 8049 AU8810 Vortex Digital Audio Processor +S 8077 AU8810 Vortex Digital Audio Processor +O 109F AU8810 Vortex Digital Audio Processor +S 1000 AU8810 Vortex Digital Audio Processor +O 12EB AU8810 Vortex Digital Audio Processor +S 0003 AU8810 Vortex Digital Audio Processor +O 1462 AU8810 Vortex Digital Audio Processor +S 6780 AU8810 Vortex Digital Audio Processor +O 14A4 AU8810 Vortex Digital Audio Processor +S 2073 AU8810 Vortex Digital Audio Processor +S 2091 AU8810 Vortex Digital Audio Processor +S 2104 AU8810 Vortex Digital Audio Processor +S 2106 AU8810 Vortex Digital Audio Processor +D 8803 Vortex 56k Software Modem +R 01 Vortex 56k Software Modem +R 02 Vortex 56k Software Modem +O 12EB Vortex 56k Software Modem +S 8803 Vortex 56k Software Modem +V 12EC 3A International Inc +V 12ED Optivision Inc +V 12EE Orange Micro +V 12EF Vienna Systems +V 12F0 Pentek +V 12F1 Sorensen Vision Inc +V 12F2 Gammagraphix Inc +V 12F3 Radstone Technology / XING Inc +V 12F4 Megatel +V 12F5 Forks Inc +V 12F6 Dawson France +V 12F7 Cognex +V 12F8 Electronic-Design GmbH +D 0002 VideoMaker +V 12F9 FourFold Technologies +V 12FB Spectrum Signal Processing +V 12FC Capital Equipment Corp +V 12FD i2S +V 12FE ESD Electronic System Design GmbH +V 12FF Lexicon +V 1300 Harman International Industries Inc +V 1302 Computer Sciences Corp +V 1303 Innovative Integration +V 1304 Juniper Networks +V 1305 NetPhone Inc +V 1306 Duet Technologies +V 1307 ComputerBoards Inc +D 0001 PCI-DAS1602/16 +D 0006 PCI-GPIB +D 000B PCI-DIO48H +D 000C PCI-PDISO8 +D 000D PCI-PDISO16 +D 000F PCI-DAS1200 +D 0010 PCI-DAS1602/12 +D 0014 PCI-DIO24H +D 0015 PCI-DIO24H/CTR3 +D 0016 PCI-DIO24H/CTR15 +D 0017 PCI-DIO96H +D 0018 PCI-CTR05 +D 0019 PCI-DAS1200/JR +D 001A PCI-DAS1001 +D 001B PCI-DAS1002 +D 001C PCI-DAS1602JR/16 +D 001D PCI-DAS6402/16 +D 001E PCI-DAS6402/12 +D 001F PCI-DAS16/M1 +D 0020 PCI-DDA02/12 +D 0021 PCI-DDA04/12 +D 0022 PCI-DDA08/12 +D 0023 PCI-DDA02/16 +D 0024 PCI-DDA04/16 +D 0025 PCI-DDA08/16 +D 0026 PCI-DAC04/12-HS +D 0027 PCI-DAC04/16-HS +D 0028 PCI-DIO24 +D 0029 PCI-DAS08 +D 002C PCI-INT32 +D 0033 PCI-DUAL-AC5 +D 0034 PCI-DAS-TC +D 0035 PCI-DAS64/M1/16 +D 0036 PCI-DAS64/M2/16 +D 0037 PCI-DAS64/M3/16 +D 004C PCI-DAS1000 +V 1308 Jato Technologies Inc +D 0001 NetCelerator Adapter +O 1308 NetCelerator Adapter +S 0001 NetCelerator Adapter +V 1309 AB Semicon Ltd +V 130A Mitsubishi Electric Microcomputer +V 130B Colorgraphic Communications Corp +V 130C AMBEX Technologies Inc +V 130D Accelerix Inc +V 130E Yamatake-Honeywell Co Ltd +V 130F Advanet Inc +V 1310 GESPAC +V 1311 VideoServer Inc +V 1312 Acuity Imaging Inc +V 1313 Yaskawa Electric Co +V 1316 Teradyne Inc +V 1317 Bridgecom Inc +D 0985 Fast Ethernet Adapter +O 1317 Fast Ethernet Adapter +S 0574 Linksys LNE100TX Fast Ethernet Adapter +V 1318 Packet Engines Inc +D 0911 PCI Ethernet Adapter +V 1319 ForteMedia Inc +D 0801 FM801 PCI Audio Device +D 0802 FM801 PCI Joystick +D 1000 FM801 PCI Audio Device +D 1001 FM801 PCI Joystick +V 131A Finisar Corp +V 131C Nippon Electro-Sensory Devices Corp +V 131D Sysmic Inc +V 131E Xinex Networks Inc +V 131F SIIG Inc +D 1000 PCI Serial Card +D 1001 CyberSerial (1-port) 16650 +D 1002 CyberSerial (1-port) 16850 +D 1010 Duet 1S(16550)+1P +D 1011 Duet 1S(16650)+1P +D 1012 Duet 1S(16850)+1P +D 1020 CyberParallel PCI Card +D 1021 CyberParallel PCI Card +D 1030 CyberSerial (2-port) 16550 +D 1031 CyberSerial (2-port) 16650 +D 1032 CyberSerial (2-port) 16850 +D 1034 Trio 2S(16550)+1P +D 1035 Trio 2S(16650)+1P +D 1036 Trio 2S(16850)+1P +D 1050 CyberSerial (4-port) 16550 +D 1051 CyberSerial (4-port) 16650 +D 1052 CyberSerial (4-port) 16850 +D 2000 CyberSerial (1-port) 16550 +D 2001 CyberSerial (1-port) 16650 +D 2002 CyberSerial (1-port) 16850 +D 2010 Duet 1S(16550)+1P +D 2011 Duet 1S(16650)+1P +D 2012 Duet 1S(16850)+1P +D 2020 CyberParallel (1-port) +D 2021 CyberParallel (2-port) +D 2030 PCI Serial Card +O 131F PCI Serial Card +S 2030 PCI Serial Card +D 2031 CyberSerial (2-port) 16650 +D 2032 CyberSerial (2-port) 16850 +D 2040 Trio 1S(16550)+2P +D 2041 Trio 1S(16650)+2P +D 2042 Trio 1S(16850)+2P +D 2050 CyberSerial (4-port) 16550 +D 2051 CyberSerial (4-port) 16650 +D 2052 CyberSerial (4-port) 16850 +D 2060 Trio 2S(16550)+1P +D 2061 Trio 2S(16650)+1P +D 2062 Trio 2S(16850)+1P +V 1320 Crypto AG +V 1321 Arcobel Graphics BV +V 1322 MTT Co Ltd +V 1323 DOME Inc +V 1324 Sphere Communications +V 1325 Salix Technologies Inc +V 1326 SeaChange International +V 1327 Voss Scientific +V 1328 Quadrant International +V 1329 Productivity Enhancement +V 132A Microcom Inc +V 132B BroadBand Technologies +V 132C Micrel Inc +V 132D Integrated Silicon Solution Inc +V 1330 MMC Networks +V 1331 RadiSys Corporation +V 1332 Micro Memory +V 1334 Redcreek Communications Inc +V 1335 Videomail Inc +V 1337 Third Planet Publishing +V 1338 BT Electronics +V 133A VTEL Corp +V 133B Softcom Microsystems +V 133C Holontech Corp +V 133D S S Technologies +V 133E Virtual Computer Corp +V 133F SCM Microsystems +V 1340 Atalla Corp +V 1341 Kyoto Microcomputer Co +V 1342 Promax Systems Inc +V 1343 Phylon Communications Inc +V 1344 Crucial Technology +V 1345 Arescom Inc +V 1347 Odetics +V 1349 Sumitomo Electric Industries Ltd +V 134A DTC Technology Corp +D 0001 Domex DMX3191 PCI SCSI Controller +D 0002 Domex DMX3194UP SCSI Adapter +V 134B Ark Research Corp +V 134C Chori Joho System Co Ltd +V 134D Pctel Inc +D 7890 HSP MicroModem 56 +D 7891 HSP MicroModem 56 +O 134D HSP MicroModem 56 +S 0001 HSP MicroModem 56 +D 7892 HSP MicroModem 56 +D 7893 HSP MicroModem 56 +D 7894 HSP MicroModem 56 +D 7895 HSP MicroModem 56 +D 7896 HSP MicroModem 56 +D 7897 HSP MicroModem 56 +V 134E CSTI +V 134F Algo System Co Ltd +V 1350 Systec Co Ltd +V 1351 Sonix Inc +V 1353 Dassault A.T. +V 1354 dWave System Inc +V 1355 Kratos Analytical Ltd +V 1356 The Logical Co +V 1359 Prisa Networks +V 135A Brain Boxes Ltd +V 135B Giganet Inc +V 135C Quatech Inc +V 135D ABB Network Partner AB +V 135E Sealevel Systems Inc +D 7101 Single Port RS-232/422/485/530 +D 7201 Dual Port RS-232/422/485 Interface +D 7202 Dual Port RS-232 Interface +D 7401 Four Port RS-232 Interface +D 7402 Four Port RS-422/485 Interface +D 7801 Eight Port RS-232 Interface +D 8001 8001 Digital I/O Adapter +V 135F I-Data International A-S +V 1360 Meinberg Funkuhren +V 1361 Soliton Systems K.K. +V 1362 Fujifacom Corp +V 1363 Phoenix Technology Ltd +V 1364 ATM Communications Inc +V 1365 Hypercope Corp +D 9050 HYSDN +O 0000 HYSDN +S 0106 HYSDN Ergo2 +S 0107 HYSDN Metro4 +V 1366 Teijin Seiki Co Ltd +V 1367 Hitachi Zosen Corp +V 1368 Skyware Corp +V 1369 Digigram +V 136A High Soft Tech +V 136B Kawasaki Steel Corp +V 136C Adtek System Science Co Ltd +V 136D Gigalabs Ltd +V 136F Applied Magic Inc +V 1370 ATL Products +V 1371 CNET Technology Inc +V 1373 Silicon Vision Inc +V 1374 Silicom Ltd +V 1375 Argosystems Inc +V 1376 LMC +V 1377 Electronic Equipment Production GmbH +V 1378 Telemann Co Ltd +V 1379 Asahi Kasei Microsystems Co Ltd +V 137A Mark Of The Unicorn Inc +V 137B PPT Vision +V 137C Iwatsu Electric Co Ltd +V 137D Dynachip Corp +V 137E Patriot Scientific Corp +V 137F Japan Satellite Systems Inc +V 1380 Sanritz Automation Co Ltd +V 1381 Brains Co Ltd +V 1382 Marian - Electronic & Software +V 1383 Controlnet Inc +V 1384 Reality Simulation Systems Inc +V 1385 Netgear +D 620A GA620 +V 1386 Video Domain Technologies +V 1387 Systran Corp +V 1388 Hitachi Information Technology Co Ltd +V 1389 Applicom International +D 0001 PCI1500PFB Intelligent fieldbus Adapter +V 138A Fusion Micromedia Corp +V 138B Tokimec Inc +V 138C Silicon Reality +V 138D Future Techno Designs Pty Ltd +V 138E Basler GmbH +V 138F Patapsco Designs Inc +V 1390 Concept Development Inc +V 1391 Development Concepts Inc +V 1392 Medialight Inc +V 1393 Moxa Technologies Co Ltd +V 1394 Level One Communications +V 1395 Ambicom Inc +V 1396 Cipher Systems Inc +V 1397 Cologne Chip Designs GmbH +D 2BD0 Billion BIPAC-PCI ISDN Card +O 1397 ISDN Board +S 2BD0 ISDN Board +O E4BF CI1-1-Harp +S 1000 CI1-1-Harp +V 1398 Clarion Co Ltd +V 1399 Rios Systems Co Ltd +V 139A Alacritech Inc +V 139B Mediasonic Multimedia Systems Ltd +V 139C Quantum 3D Inc +V 139D EPL Ltd +V 139E Media4 +V 139F Aethra S.R.L. +V 13A0 Crystal Group Inc +V 13A1 Kawasaki Heavy Industries Ltd +V 13A2 Ositech Communications Inc +V 13A3 HI-FN +V 13A4 Rascom Inc +V 13A5 Audio Digital Imaging Inc +V 13A6 Videonics Inc +V 13A7 Teles AG +V 13A8 Exar Corp +V 13A9 Ultrasound Group +V 13AA Broadband Networks Inc +V 13AB Arcom Control Systems Ltd +V 13AC Motion Media Technology Ltd +V 13AD Nexus Inc +V 13AE ALD Technology Ltd +V 13AF T.Sqware +V 13B0 Maxspeed Corp +V 13B1 Tamura Corp +V 13B2 Techno Chips Co Ltd +V 13B3 Lanart Corp +V 13B4 Wellbean Co Inc +V 13B5 ARM +V 13B6 DLoG GmbH +V 13B7 LOGIC Devices Inc +V 13B8 Nokia Telecommunications Oy +V 13B9 Elecom Co Ltd +V 13BA Oxford Instruments +V 13BB Sanyo Technosound Co Ltd +V 13BC Bitran Corp +V 13BD Sharp Corp +V 13BE Miroku Jyoho Service Co Ltd +V 13BF Sharewave Inc +V 13C0 Microgate Corp +D 0010 SyncLink PCI WAN Adapter +V 13C1 3ware Inc +D 1000 3ware ATA-RAID +V 13C2 Technotrend Systemtechnik GmbH +V 13C3 Janz Computer AG +V 13C4 Phase Metrics +V 13C5 Alphi Technology Corp +V 13C6 Condor Engineering Inc +V 13C7 Blue Chip Technology Ltd +V 13C8 Apptech Inc +V 13C9 Eaton Corp +V 13CA IOMEGA Corp +V 13CB Yano Electric Co Ltd +V 13CC Metheus Corp +V 13CD Compatible Systems Corp +V 13CE Cocom A/S +V 13CF Studio Audio & Video Ltd +V 13D0 Techsan Electronics Co Ltd +V 13D1 Abocom Systems Inc +V 13D2 Shark Multimedia Inc +V 13D3 IMC Networks +V 13D4 Graphics Microsystems Inc +V 13D5 Media 100 Inc +V 13D6 K.I. Technology Co Inc +V 13D7 Toshiba Engineering Corp +V 13D8 Phobos Corp +V 13D9 Apex PC Solutions Inc +V 13DA IntreSource Systems Pty Ltd +V 13DB Janich & Klass Computertechnik GmbH +V 13DC Netboost Corp +V 13DD Multimedia Bundle Inc +V 13DE ABB Robotics Products AB +V 13DF E-Tech Inc +D 0001 PCI56RVP Modem +O 13DF PCI56RVP Modem +S 0001 PCI56RVP Modem +V 13E0 GVC Corporation +V 13E1 Silicom Multimedia Systems Inc +V 13E2 Dynamics Research Corp +V 13E3 Nest Inc +V 13E4 Calculex Inc +V 13E5 Telesoft Design Ltd +V 13E6 Argosy Research Inc +V 13E7 NAC Inc +V 13E8 Chip Express Corp +V 13E9 Intraserver Technology Inc +V 13EA Dallas Semiconductor +V 13EB Hauppauge Computer Works Inc +V 13EC Zydacron Inc +V 13ED Raytheion E-Systems +V 13EE Hayes Microcomputer Products Inc +V 13EF Coppercom Inc +V 13F0 Sundance Technology Inc +D 0201 ST201 Fast Ethernet Adapter +V 13F1 Oce' - Technologies B.V. +V 13F2 Ford Microelectronics Inc +V 13F3 McData Corp +V 13F4 Troika Design Inc +V 13F5 Kansai Electric Co Ltd +V 13F6 C-Media Electronics Inc +D 0100 CMI8338/C3DX PCI Audio Device +O 13F6 CMI8338/C3DX PCI Audio Device +S FFFF CMI8338/C3DX PCI Audio Device +D 0101 CMI8338-031 PCI Audio Device +O 13F6 CMI8338-031 PCI Audio Device +S 0101 CMI8338-031 PCI Audio Device +D 0111 CMI8738/C3DX PCI Audio Device +O 13F6 CMI8738/C3DX PCI Audio Device +S 0111 CMI8738/C3DX PCI Audio Device +D 0211 HSP56 Audiomodem Riser +V 13F7 Wildfire Communications +V 13F8 Ad Lib Multimedia Inc +V 13F9 NTT Advanced Technology Corp +V 13FA Pentland Systems Ltd +V 13FB Aydin Corp +V 13FC Computer Peripherals International +V 13FD Micro Science Inc +V 13FE Advantech Co Ltd +V 13FF Silicon Spice Inc +V 1400 ARTX Inc +V 1401 CR-Systems A/S +V 1402 Meilhaus Electronic GmbH +V 1403 Ascor Inc +V 1404 Fundamental Software Inc +V 1405 Excalibur Systems Inc +V 1406 Oce' Printing Systems GmbH +V 1407 Lava Computer Manufacturing Inc +D 8000 Lava Parallel +D 8002 Lava Dual Parallel port A +D 8003 Lava Dual Parallel port B +D 8800 BOCA Research IOPPAR +V 1408 Aloka Co Ltd +V 1409 Timedia Technology Co Ltd +D 7168 Multi I/O card +O 1409 Timedia/Sunix Multi I/O card +S 0002 4036A, 2S, 16c550 +S 4025 4025A, 1S, 16c550 +S 4027 4027A, 1S, 16c650 +S 4028 4028D, 1S, 16c750, Remap +S 4036 4036D, 2S, 16c550, Remap +S 4037 4037A, 2S, 16c650 +S 4038 4038D, 2S, 16c750, Remap +S 4055 4055A, 4S, 16c550 +S 4056 4056A, 4S, 16c650 +S 4065 4065A, 8S, 16c550 +S 4066 4066A, 8S, 16c650 +S 4078 4078A, 2S1P, 16c550, SPP +S 4079 4079H, 2S1P, 16c550, ECP +S 4085 4085H, 2S2P, 16c550, SPP +S 4088 4088A, 2S2P, 16c550, ECP +S 4089 4089A, 2S2P, 16c650, ECP +S 4095 4095A, 4S2P, 16c550, ECP +S 4096 4096A, 4S2P, 16c650, ECP +S 5025 4025D, 1S, 16c550, Remap +S 5027 4027D, 1S, 16c650, Remap +S 5037 4037D, 2S, 16c650, Remap +S 5056 4056R, 4S, 16c550, 4*RJ45 +S 5065 4065R, 8S, 16c550, Single Bracket DB62F +S 5066 4066R, 8S, 16c550, Single Bracket DB62F +S 5078 4078U, 2S1P, 16c650, SPP +S 5079 4079A, 2S1P, 16c650, ECP +S 5085 4085U, 2S2P, 16c650, SPP +S 6079 4079R, 2S1P, 16c550, ECP, Single Bracket DB62F +S 7079 4079S, 2S1P, 16c650, ECP, Single Bracket DB62F +S 8079 4079D, 2S1P, 16c550, ECP, Remap +S 8137 8137, 2S, RS-422/485, 16c650, Mini Block +S 8138 8138, 2S, RS-422/485, 16c650, DB9M +S 8156 8156, 4S, RS-422/485, 16c650. Mini Block +S 8157 8157, 4S, RS-422/485, 16c650, 4*RJ45 +S 8166 8166, 8S, RS-422/485, 16c650, DB62F +S 8237 8237, 2S, Current Loop, 16c650, Mini Block +S 8238 8238, 2S, Current Loop, 16c650, DB9 +S 8256 8256, 4S, Current Loop, 16c650, Mini Block +S 8257 8257, 4S, Current Loop, 16c650, 2*RJ45 +S 9056 9056A, 4S, 16c550, 4*RJ45 +S 9066 9066A, 8S, 16c550, Remap, DB62F +S 9079 4079E, 2S1P, 16c650, ECP, Remap +S 9137 8137S, 2S, RS-422/485, 16c650, surge, Mini Block +S 9138 8138S, 2S, RS-422/485, 16c650, surge, DB9M +S 9156 8156S, 4S, RS-422/485, 16c650, surge, Mini Block +S 9157 8157S, 4S, RS-422/485, 16c650, surge, 4*RJ45 +S 9158 9158, 4S, RS-422/485, 16c650, Remap, 4*RJ45 +S 9159 9159, 4S, RS-422/485, 16c750, Remap, 4*RJ45 +S 9166 8166S, 8S, RS-422/485, 16c650, surge, DB62F +S 9167 9167, 8S, RS-422/485, 16c550, Remap, DB62F +S 9168 9168, 8S, RS-422/485, 16c650, Remap, DB62F +S 9237 8237S, 2S, Current Loop, 16c650, surge, Mini Block +S 9238 8238S, 2S, Current Loop, 16c650, surge, DB9 +S 9256 8256S, 4S, Current Loop, 16c650, surge, Mini Block +S 9257 8257S, 4S, Current Loop, 16c650, surge, 4*RJ45 +S A056 9056B, 4S, 16c650, 4*RJ45 +S A066 9066B, 8S, 16c650, DB62F +S A079 4079F, 2S1P, 16c750, ECP, Remap +S A157 9157, 4S, RS-422/485, 16c550, 4*RJ45 +S A158 9158S, 4S,RS-422/485, 16c650, surge, 4*RJ45 +S A159 9159S, 4S,RS-422/485, 16c750, surge, 4*RJ45 +S A167 9167S, 8S,RS-422/485, 16c550, surge, DB62F +S A168 9168S, 8S,RS-422/485, 16c650, surge, DB62F +S B056 9056C, 4S, 16c750, Remap, 4*RJ45 +S B079 9079A, 2S1P, 16c550, Remap, ECP, DB62F +S B157 9157S, 4S, 16c550, RS-422/485, surge, 4*RJ45 +S C079 9079B, 2S1P, 16c650, Remap, ECP, DB62F +S D079 9079C, 2S1P, 16c750, Remap, ECP, DB62F +D 7268 Multi I/O +O 1409 Timedia/Sunix Multi I/O +S 0101 4006A, 1P, SPP +S 0102 4014A/C, 2P, SPP +S 0103 4008A, 1P, ECP +S 0104 4018A/C, 2P, ECP +S 9018 9018A, 2P, ECP, DB62F +V 140A DSP Research Inc +V 140B Ramix Inc +V 140C Elmic Systems Inc +V 140D Matsushita Electrics Works Ltd +V 140E Goepel Electronic GmbH +V 140F Salient Systems Corp +V 1410 Midas Lab Inc +V 1411 Ikos Systems Inc +V 1412 IC Ensemble Inc +D 1712 ICE1712 Envy24 Multichannel Audio Controller +O 1412 ICE1712 Envy24 Multichannel Audio Controller +; M audio and Seasound (incorrectly!) use the IC Ensemble Vendor ID! +S D630 M Audio Delta-1010 +S D631 M Audio Delta-DiO +S D632 M Audio Delta-66 +S D633 M Audio Delta-44 +S EBA0 SeaSound Solo +O 153B EWS88 MT +S 1115 EWS88 MT +V 1413 Addonics +V 1414 Microsoft +V 1415 Oxford Semiconductor Ltd +D 8401 OX9162 PCI Bridge +D 8403 OX12PCI840 PCI Parallel Port +D 9500 PCI Function +D 9501 OX16PCI954 PCI UARTs +D 950A OX16PCI954 Dual PCI UART +D 9510 PCI Function +D 9511 OX16PCI954 PCI Bridge +D 9512 OX16PCI954 32-bit PCI Bridge +D 9513 OX16PCI954 PCI Parallel Port +V 1416 Multiwave Innovation Pte Ltd +V 1417 Convergenet Technologies Inc +V 1418 Kyushu Electronics Systems Inc +V 1419 Excel Switching Corp +V 141A Apache Micro Peripherals Inc +D 1035 PCI Modem Enumerator +V 141B Zoom Telephonics Inc +V 141D Digitan Systems Inc +V 141E Fanuc Ltd +V 141F Visiontech Ltd +V 1420 Psion Dacom PLC +V 1421 ADS Technologies Inc +V 1422 Ygrec Systems Co Ltd +V 1423 Custom 7Technology Corp +V 1424 Vidoeserver Connections +V 1425 ASIC Designers Inc +V 1426 Storage Technology Corp +V 1427 Better On-line Solutions +V 1428 EDEC Co Ltd +V 1429 UNEX Technology Corp +V 142A Kingmax Technology Inc +V 142B RadioLAN +V 142C Minton Optic Industry Co Ltd +V 142D Pix Stream Inc +V 142E Vitec Multimedia +V 142F Radicom Research Inc +V 1430 ITT Aerospace/Communications Division +V 1431 Gilat Satellite Networks +V 1432 Edimax Computer Co +V 1433 Eltec Elektronik GmbH +V 1435 Real Time Devices US Inc +V 1436 CIS Technology Inc +V 1437 Nissin Co Inc +V 1438 Atmel-Dream +V 1439 Outsource Engineering & Manufacturing Inc +V 143A Stargate Solutions Inc +V 143B Canon Research Center, America +V 143C Amlogic Inc +V 143D Tamarack Microelectronics Inc +V 143E Jones Futurex Inc +V 143F Lightwell Co Ltd - Zax Division +V 1440 Algol Corp +V 1441 AGIE Ltd +V 1442 Phoenix Contact Co GmbH +V 1443 Unibrain S.A. +V 1444 TRW +V 1445 Logical do Ltd +V 1446 Graphin Co Ltd +V 1447 AIM GmbH +V 1448 Alesis Studio +D 0001 ADAT/EDIT Audio Editing +V 1449 TUT Systems Inc +V 144A Adlink Technology +D 7250 PCI-7250 +D 7296 PCI-7296 +D 7432 PCI-7432 +D 7433 PCI-7433 +D 7434 PCI-7434 +D 7841 PCI-7841 +D 8133 PCI-8133 +D 8554 PCI-8554 +D 9111 PCI-9111 +D 9113 PCI-9113 +D 9114 PCI-9114 +V 144B Loronix Information Systems Inc +V 144C Catalina Research Inc +V 144D Samsung Electronics Co Ltd +V 144E Olitec +V 144F Askey Computer Corp +V 1450 Nexus Systems Inc +V 1451 SP3D Chip Design GmbH +V 1453 Mycom Inc +V 1454 Altiga Networks +V 1455 Logic Plus Plus Inc +V 1456 Advanced Hardware +V 1457 Nuera Communications Inc +V 1458 Giga-Byte Technology +V 1459 Dooin Electronics +V 145A Escalate Networks Inc +V 145B Praim SRL +V 145C Cryptek +V 145D Gallant Computer Inc +V 145E Aashima Technology B.V. +V 145F Baldor Electric Company +D 0001 NextMove PCI +V 1460 Dynarc Inc +V 1461 Avermedia Technologies Inc +V 1462 Micro-Star International Co Ltd (MSI) +V 1463 Fast Corp +V 1464 Interactive Circuits & Systems Ltd +V 1465 GN Nettest Telecom Division +V 1466 Designpro Inc +V 1467 Digicom SPA +V 1468 Ambit microsystem Corp +V 1469 Cleveland Motion Controls +V 146A IFR Ltd +V 146B Parascan Technologies Ltd +V 146C Ruby Tech Corp +V 146D Tachyon Inc +V 146E Williams Electronic Games Inc +V 146F Multi Dimensional Consulting Inc +V 1470 Bay Networks +V 1471 Integrated Telecom Express Inc +V 1472 Daikin Indistries Ltd +V 1473 Zapex Technologies Inc +V 1474 Doug Carson & Associates +V 1475 Picazo Communications +V 1476 Mortara Instrument Inc +V 1477 Net Insight +V 1478 Diatrend Corp +V 1479 Toray Industries Inc +V 147A Formosa Industrial Computing +V 147B Abit Computer Corp +V 147C Aware Inc +V 147D Interworks Computer Products +V 147E Matsushita Graphic Communication Systems Inc +V 147F Nihon Unisys Ltd +V 1480 SCII Telecom +V 1481 Biopac Systems Inc +V 1482 Isytec +V 1483 Labway Corp +V 1484 Logic Coporation +V 1485 ERMA - Electronic GmbH +V 1486 L3 Communications Telemetry & Instrumentation +V 1487 Marquette Medical Systems +V 1488 Kontron Electronik GmbH +V 1489 KYE Systems Corp +V 148A OPTO 22 +V 148B Innomedialogic Inc +V 148C C.P. Technology Co Ltd +V 148D Digicom Systems Inc +D 1003 Creative ModemBlaster V.90 PCI DI5635 +V 148E OSI Plus Corp +V 148F Plant Equipment Inc +V 1490 Stone Microsystems Pty Ltd +V 1491 Zeal Corp +V 1492 TIME LOGIC Corp +V 1493 Maker Communications +V 1494 Wintop Technology, Inc +V 1495 Tokai Communications Industry Co Ltd +V 1496 Joytech Computer Co, Ltd +V 1497 SMA Regelsysteme GmbH +V 1498 Tews Datentechnik GmbH +V 1499 Emtec Co, Ltd +V 149A Andor Technology Ltd +V 149B Seiko Instruments Inc +V 149C Ovislink Corp +V 149D Newtek Inc +V 149E Mapletree Networks Inc +V 149F Lectron Co Ltd +V 14A0 Softing GmbH +V 14A1 Systembase Co Ltd +V 14A2 Millennium Engineering Inc +V 14A3 Maverick Networks +V 14A4 GVC/BCM Advanced Research +V 14A5 Xionics Document Technologies Inc +V 14A6 Inova Computers GmbH & Co KG +V 14A7 Mythos Systems Inc +V 14A8 Featron Technologies Corp +V 14A9 Hivertec Inc +V 14AA Advanced MOS Technology Inc +V 14AB Mentor Graphics Corp +V 14AC Novaweb Technologies Inc +V 14AD Time Space Radio AB +V 14AE CTI, Inc +V 14AF Guillemot Corp +V 14B0 BST Communication Technology Ltd +V 14B1 Nextcom K.K. +V 14B2 Ennovate Networks Inc +V 14B3 Xpeed Inc +D 0000 DSL NIC +V 14B4 Philips Business Electronics B.V. +V 14B5 Creamware GmbH +V 14B6 Quantum Data Corp +V 14B7 Proxim Inc +D 0001 Symphony 4110 +V 14B8 Techsoft Technology Co Ltd +V 14B9 Aironet Wireless Communications +D 0001 PC4800 +V 14BA Internix Inc +V 14BB Semtech Corp +V 14BC Globespan Semiconductor Inc +V 14BD Cardio Control N.V. +V 14BE L3 Communications +V 14BF Spider Communications Inc +V 14C0 Compal Electronics Inc +V 14C1 Myricom Inc +V 14C2 DTK Computer +V 14C3 Mediatek Corp +V 14C4 Iwasaki Information Systems Co Ltd +V 14C5 ABB Automation Products AB +V 14C6 Data Race Inc +V 14C7 Modular Technoloy Holdings Ltd +V 14C8 Turbocomm Tech Inc +V 14C9 ODIN Telesystems Inc +V 14CA PE Logic Corp +V 14CB Billionton Systems Inc/Cadmus Micro Inc +V 14CC Nakayo Telecommunications Inc +V 14CD Universal Scientific Ind +V 14CE Whistle Communications +V 14CF TEK Microsystems Inc +V 14D0 Ericsson AXE R & D +V 14D1 Computer HI-TECH Co Ltd +V 14D2 Titan Electronics Inc +V 14D3 Cirtech (UK) Ltd +V 14D4 Panacom Technology Corp +V 14D5 Nitsuko Corp +V 14D6 Accusys Inc +V 14D7 Hirakawa Hewtech Corp +V 14D8 Hopf Elektronik GmbH +V 14D9 Alpha Processor Inc +V 14DA National Aerospace Laboratories +V 14DB Avlab Technology Inc +D 2100 PCI IO 1S +D 2101 PCI IO 1S-650 +D 2102 PCI IO 1S-850 +D 2110 PCI IO 1S1P +D 2111 PCI IO 1S1P-650 +D 2112 PCI IO 1S1P-850 +D 2120 PCI IO 1P, TK9902, Avlab P005 +D 2121 PCI IO 2P +D 2130 PCI IO 2S +D 2131 PCI IO 2S-650 +D 2132 PCI IO 2S-850 +D 2140 PCI IO 2P1S +D 2141 PCI IO 2P1S-650 +D 2142 PCI IO 2P1S-850 +D 2144 PCI IO 2P2S +D 2145 PCI IO 2P2S-650 +D 2146 PCI IO 2P2S-850 +D 2150 PCI IO 4S +D 2151 PCI IO 4S-654 +D 2152 PCI IO 4S-850 +D 2160 PCI IO 2S1P +D 2161 PCI IO 2S1P-650 +D 2162 PCI IO 2S1P-850 +D 2180 PCI IO 8S +D 2181 PCI IO 8S-654 +D 2182 PCI IO 8S-850 +V 14DC Amplicon Liveline Ltd +D 0000 PCI230 16-chan A/D, 2-chan D/A, 24 DIO, 3 counter timers +D 0001 PCI242H 4-port high speed RS-232 +D 0002 PCI244H 8-port high speed RS-232 +D 0003 PCI247H 2-port high speed RS-232 +D 0004 PCI248H 2-port high speed RS-422/485 +D 0005 PCI249H 2-port high speed RS-232 and RS-422/485 +D 0006 PCI260 16-channel analog input (with timers) +D 0007 PCI224 16-channel 12-bit analog output (with timers) +D 0008 PCI234 4-channel 16-bit analogue output (with timers) +D 0009 PCI236 24-channel digital I/O +D 000A PCI272 72-channel digital I/O +D 000B PCI215 48-channel digital I/O with 6 counter timers +D 000C PCI263 16-channel reed relay output +V 14DD Bolder Design Labs Inc +V 14DE Applied Integration Corp +V 14DF Basis Communications Corp +V 14E1 Invertex +V 14E2 Infolibria +V 14E3 Amtelco +V 14E4 Broadcom Corp +D 4211 BCM HPNA 10Mb/s NIC +D 4212 BCM V.90 56k Modem +V 14E5 Pixelfusion Ltd +V 14E6 Shining Technology Inc +V 14E7 3CX +V 14E8 Raycer Inc +V 14E9 Garnets System Co Ltd +V 14EA Planex Communications Inc +V 14EB Seiko Epson Corp +V 14EC Acqiris +V 14ED Datakinetics Ltd +V 14EE Maspro Kenkoh Corp +V 14EF Carry Computer Engineering Co Ltd +V 14F0 Canon Reseach Centre France +V 14F1 Conexant +D 1033 56K Winmodem +O 13E0 56K Winmodem +S 02B0 56K Winmodem +D 1035 PCI Modem Enumerator +D 1036 PCI Modem Enumerator +D 2003 SoftK56 Winmodem +O 14F1 SoftK56 Winmodem +S 2003 SoftK56 Winmodem +D 2004 SoftK56 RemoteTAM Winmodem +O 14F1 SoftK56 RemoteTAM Winmodem +S 2004 SoftK56 RemoteTAM Winmodem +D 2005 SoftK56 Speakerphone Winmodem +O 14F1 SoftK56 Speakerphone Winmodem +S 2005 SoftK56 Speakerphone Winmodem +D 2006 SoftK56 Speakerphone Winmodem +O 14F1 SoftK56 Speakerphone Winmodem +S 2006 SoftK56 Speakerphone Winmodem +D 2013 SoftK56 Winmodem +O 14F1 SoftK56 Winmodem +S 2013 SoftK56 Winmodem +D 2014 SoftK56 RemoteTAM Winmodem +O 144F SoftK56 RemoteTAM Winmodem +S 101C SoftK56 RemoteTAM Winmodem +S 2014 SoftK56 RemoteTAM Winmodem +D 2015 SoftK56 Speakerphone Winmodem +O 14C8 SoftK56 Speakerphone Winmodem +S 2115 SoftK56 Speakerphone Winmodem +O 14F1 SoftK56 Speakerphone Winmodem +S 2015 SoftK56 Speakerphone Winmodem +D 2016 SoftK56 Speakerphone Winmodem +O 14F1 SoftK56 Speakerphone Winmodem +S 2016 SoftK56 Speakerphone Winmodem +D 8237 CN8237 ATM OC2 ServiceSAR+ controller with BR Traffic Management +D 8471 CN8471A 32 Channel HDLC Controller +D 8472 CN8472A 64 Channel HDLC Controller +D 8474 CN8474A 128 Channel HDLC Controller +D 8478 CN8478 256 Channel HDLC Controller +D 8502 CX28500 676 Channel HDLC Controller +D 8503 CX28500 1024 Channel HDLC Controller +V 14F2 Mobility Electronics +V 14F3 Broadlogic +V 14F4 Tokyo Electronic Industry Co Ltd +V 14F5 Sopac Ltd +V 14F6 Coyote Technologies LLC +V 14F7 Wolf Technology Inc +V 14F8 Audiocodes Inc +V 14F9 AG Communications +V 14FA Wandel & Gochermann +V 14FB Transas Marine (UK) Ltd +V 14FC Quadrics Supercomputers World +V 14FD Japan Computer Industry Inc +V 14FE Archtek Telecom Corp +V 14FF Twinhead International Corp +V 1500 Lantech Computer Company +V 1501 Banksoft Canada Ltd +V 1502 Mitsubishi Electric Logistics Support Co Ltd +V 1503 Kawasaki LSI USA Inc +V 1504 Kaiser Electronics +V 1505 ITA Ingenieurburo Fur Testaufgaben GmbH +V 1506 Chameleon Systems Inc +V 1507 Htec Ltd +D 0001 MPC105 [Eagle] +D 0002 MPC106 [Grackle] +D 0003 MPC8240 [Kahlua] +D 0100 MC145575 [HFC-PCI] +D 0431 KTI829c 100VG +D 4801 Raven +D 4802 Falcon +D 4803 Hawk +D 4806 CPX8216 +V 1508 Honda Connectors/Mhotronics Inc +V 1509 First International Computer Inc +V 150A Forvus Research Inc +V 150B Yamashita Systems Corp +V 150C Kyopal Co Ltd +V 150D Warpspped Inc +V 150E C-Port Corp +V 150F Intec GmbH +V 1510 Behavior Tech Computer Corp +V 1511 Centillium Technology Corp +V 1512 Rosun Technologies Inc +V 1513 Raychem +V 1514 TFL LAN Inc +V 1515 Advent design +V 1516 Myson Technology Inc +V 1517 Echotek Corp +V 1518 PEP Modular Computers GmbH +V 1519 Telefon Aktiebolaget LM Ericsson +V 151A Globetek Inc +D 1002 PCI-1002 +D 1004 PCI-1004 +D 1008 PCI-1008 +V 151B Combox Ltd +V 151C Digital Audio Labs Inc +V 151D Fujitsu Computer Products Of America +V 151E Matrix Corp +V 151F Topic Semiconductor Corp +V 1520 Chaplet System Inc +V 1521 Bell Corp +V 1522 Mainpine Ltd +V 1523 Music Semiconductors +V 1524 ENE Technology Inc +V 1525 Impact Technologies +V 1526 ISS, Inc +V 1527 Solectron +V 1528 Acksys +V 1529 American Microsystems Inc +V 152A Quickturn Design Systems +V 152B Flytech Technology Co Ltd +V 152C Macraigor Systems LLC +V 152D Quanta Computer Inc +V 152E Melec Inc +V 152F Philips - Crypto +V 1530 Acqis Technology Inc +V 1531 Chryon Corp +V 1532 Echelon Corp +V 1533 Baltimore +V 1534 Road Corp +V 1535 Evergreen Technologies Inc +V 1537 Datalex Communications +V 1538 Aralion Inc +V 1539 Atelier Informatiques et Electronique Etudes S.A. +V 153A Ono Sokki +V 153B Terratec Electronic GmbH +V 153C Antal Electronic +V 153D Filanet Corp +V 153E Techwell Inc +V 153F MIPS Denmark +V 1540 Provideo Multimedia Co Ltd +V 1541 Machone Communications +V 1542 Vivid Technology Inc +V 1543 Silicon Laboratories +V 1544 DCM Data Systems +V 1545 Visiontek +V 1546 IOI Technology Corp +V 1547 Mitutoyo Corp +V 1548 Jet Propulsion Laboratory +V 1549 Interconnect Systems Solutions +V 154A Max Technologies Inc +V 154B Computex Co Ltd +V 154C Visual Technology Inc +V 154D Pan International Industrial Corp +V 154E Servotest Ltd +V 154F Stratabeam Technology +V 1550 Open Network Co Ltd +V 1551 Smart Electronic Development GmbH +V 1552 Racal Airtech Ltd +V 1553 Chicony Electronics Co Ltd +V 1554 Prolink Microsystems Corp +V 1555 Gesytec GmbH +V 1556 PLD Applications +V 1557 Mediastar Co Ltd +V 1558 Clevo/Kapok Computer +V 1559 SI Logic Ltd +V 155A Innomedia Inc +V 155B Protac International Corp +V 155C Cemax-Icon Inc +V 155D Mac System Co Ltd +V 155E LP Elektronik GmbH +V 155F Perle Systems Ltd +V 1560 Terayon Communications Systems +V 1561 Viewgraphics Inc +V 1562 Symbol Technologies +V 1563 A-Trend Technology Co Ltd +V 1564 Yamakatsu Electronics Industry Co Ltd +V 1565 Biostar Microtech Int'l Corp +V 1566 Ardent Technologies Inc +V 1567 Jungsoft +V 1568 DDK Electronics Inc +V 1569 Palit Microsystems Inc +V 156A Avtec Systems +V 156B 2wire Inc +V 156C Vidac Electronics GmbH +V 156D Alpha-Top Corp +V 156E Alfa Inc +V 156F M-Systems Flash Disk Pioneers Ltd +V 1570 Lecroy Corp +V 1571 Contemporary Controls +D A001 CCSI PCI20-485 ARCnet +D A002 CCSI PCI20-485D ARCnet +D A003 CCSI PCI20-485X ARCnet +D A004 CCSI PCI20-CXB ARCnet +D A005 CCSI PCI20-CXS ARCnet +D A006 CCSI PCI20-FOG-SMA ARCnet +D A007 CCSI PCI20-FOG-ST ARCnet +D A008 CCSI PCI20-TB5 ARCnet +D A009 CCSI PCI20-5-485 5Mbit ARCnet +D A00A CCSI PCI20-5-485D 5Mbit ARCnet +D A00B CCSI PCI20-5-485X 5Mbit ARCnet +D A00C CCSI PCI20-5-FOG-ST 5Mbit ARCnet +D A00D CCSI PCI20-5-FOG-SMA 5Mbit ARCnet +D A201 CCSI PCI22-485 10Mbit ARCnet +D A202 CCSI PCI22-485D 10Mbit ARCnet +D A203 CCSI PCI22-485X 10Mbit ARCnet +D A204 CCSI PCI22-CHB 10Mbit ARCnet +D A205 CCSI PCI22-FOG_ST 10Mbit ARCnet +D A206 CCSI PCI22-THB 10Mbit ARCnet +V 1572 Otis Elevator Company +V 1573 Lattice - Vantis +V 1574 Fairchild Semiconductor +V 1575 Voltaire Advanced Data Security Ltd +V 1576 Viewcast COM +V 1578 HITT +V 1579 Dual Technology Corp +V 157A Japan Elecronics Ind Inc +V 157B Star Multimedia Corp +V 157C Eurosoft (UK) +D 8001 Fix2000 PCI Y2K Compliance Card +V 157D Gemflex Networks +V 157E Transition Networks +V 157F PX Instruments Technology Ltd +V 1580 Primex Aerospace Co +V 1581 SEH Computertechnik GmbH +V 1582 Cytec Corp +V 1583 Inet Technologies Inc +V 1584 Uniwill Computer Corp +V 1585 Logitron +V 1586 Lancast Inc +V 1587 Konica Corp +V 1588 Solidum Systems Corp +V 1589 Atlantek Microsystems Pty Ltd +V 158A Digalog Systems Inc +V 158B Allied Data Technologies +V 158C Hitachi Semiconductor & Devices Sales Co Ltd +V 158D Point Multimedia Systems +V 158E Lara Technology Inc +V 158F Ditect Coop +V 1590 3pardata Inc +V 1591 ARN +V 1592 Syba Tech Ltd +D 0781 Multi-IO Card +D 0782 Dual Parallel Port Card (EPP) +D 0783 Multi-IO Card +D 0785 Multi-IO Card +D 0786 Multi-IO Card +D 0787 Multi-IO Card +D 0788 Multi-IO Card +D 078A Multi-IO Card +V 1593 Bops Inc +V 1594 Netgame Ltd +V 1595 Diva Systems Corp +V 1596 Folsom Research Inc +V 1597 Memec Design Services +V 1598 Granite Microsystems +V 1599 Delta Electronics Inc +V 159A General Instrument +V 159B Faraday Technology Corp +V 159C Stratus Computer Systems +V 159D Ningbo Harrison Electronics Co Ltd +V 159E A-Max Technology Co Ltd +V 159F Galea Network Security +V 15A0 Compumaster SRL +V 15A1 Geocast Network Systems +V 15A2 Catalyst Enterprises Inc +V 15A3 Italtel +V 15A4 X-Net OY +V 15A5 Toyota Macs Inc +V 15A6 Sunlight Ultrasound Technologies Ltd +V 15A7 SSE Telecom Inc +V 15A8 Shanghai Communications Technologies Center +V 15AA Moreton Bay +V 15AB Bluesteel Networks Inc +V 15AC North Atlantic Instruments +V 15AD VMWare Inc +D 0710 Virtual SVGA +V 15AE Amersham Pharmacia Biotech +V 15B0 Zoltrix International Ltd +V 15B1 Source Technology Inc +V 15B2 Mosaid Technologies Inc +V 15B3 Mellanox Technology +V 15B4 CCI/TRIAD +V 15B5 Cimetrics Inc +V 15B6 Texas Memory Systems Inc +V 15B7 Sandisk Corp +V 15B8 ADDI-DATA GmbH +V 15B9 Maestro Digital Communications +V 15BA Impacct Technology Corp +V 15BB Portwell Inc +V 15BC Agilent Technologies +V 15BD DFI Inc +V 15BE Sola Electronics +V 15BF High Tech Computer Corp (HTC) +V 15C0 BVM Ltd +V 15C1 Quantel +V 15C2 Newer Technology Inc +V 15C3 Taiwan Mycomp Co Ltd +V 15C4 EVSX Inc +V 15C5 Procomp Informatics Ltd +V 15C6 Technical University of Budapest +V 15C7 Tateyama Dystem Laboratory Co Ltd +V 15C8 Penta Media Co Ltd +V 15C9 Serome Technology Inc +V 15CA Bitboys OY +V 15CB AG Electronics Ltd +V 15CC Hotrail Inc +V 15CD Dreamtech Co Ltd +V 15CE Genrad Inc +V 15CF Hilscher GmbH +V 15D1 Infineon Technologies AG +V 15D2 First International Computer Inc (FIC) +V 15D3 NDS Technologies Israel Ltd +V 15D4 Iwill Corp +V 15D5 Tatung Co +V 15D6 Entridia Corp +V 15D7 Rockwell-Collins Inc +V 15D8 Cybernetics Technology Co Ltd +V 15D9 Super Micro Computer Inc +V 15DA Cyberfirm Inc +V 15DB Applied Computing Systems Inc +V 15DC Litronic Inc +D 0001 Argus 300 PCI Cryptography Module +V 15DD Sigmatel Inc +V 15DE Malleable Technologies Inc +V 15DF Infinilink Corp +V 15E0 Cacheflow Inc +V 15E1 Voice Technologies Group Inc +V 15E2 Quicknet Technologies Inc +V 15E3 Networth Technologies Inc +V 15E4 VSN Systemen BV +V 15E5 Valley technologies Inc +V 15E6 Agere Inc +V 15E7 Get Engineering Corp +V 15E8 National Datacomm Corp +V 15E9 Pacific Digital Corp +V 15EA Tokyo Denshi Sekei K.K. +V 15EB Drsearch GmbH +V 15EC Beckhoff GmbH +V 15ED Macrolink Inc +V 15EE In Win Development Inc +V 15EF Intelligent Paradigm Inc +V 15F0 B-Tree Systems Inc +V 15F1 Times N Systems Inc +V 15F2 Diagnostic Instruments Inc +V 15F3 Digitmedia Corp +V 15F4 Valuesoft +V 15F5 Power Micro Research +V 15F6 Extreme Packet Device Inc +V 15F7 Banctec +V 15F8 Koga Electronics Co +V 15F9 Zenith Electronics Corp +V 15FA J.P. Axzam Corp +V 15FB Zilog Inc +V 15FC Techsan Electronics Co Ltd +V 15FD N-CUBED.NET +V 15FE Kinpo Electronics Inc +V 15FF Fastpoint Technologies Inc +V 1600 Northrop Grumman - Canada Ltd +V 1601 Tenta Technology +V 1602 Prosys-tec Inc +V 1603 Nokia Wireless Communications +V 1604 Central System Research Co Ltd +V 1605 Pairgain Technologies +V 1606 Europop AG +V 1607 Lava Semiconductor Manufacturing Inc +V 1608 Automated Wagering International +V 1609 Scimetric Instruments Inc +V 162F Rohde & Schwarz GmBH & Co KG +D 1111 TS-PRL1 General Purpose Relay Card +D 1112 TS-PMA Matrix Card +V 1668 Action Tec Electronics Inc +D 0100 PCI to PCI Bridge +V 1813 Ambient Technologies Inc +D 4000 Creatix V.90 HaM Modem +V 1A08 Sierra Semiconductor +D 0000 SC15064 +V 1B13 Jaton Corp +V 1C1C DTC / Symphony / Forex Computer Corp +D 0001 FR710/82C101 EIDE +V 1D44 Distributed Processing Technology (DPT) +D A400 PM2x24/PM3224 SCSI Adapter +V 1DE1 Tekram +D 0391 TRM-S1040 +D 2020 DC-390 SCSI Controller +D 690C DC-690C IDE Cache Controller +D DC29 TRM290 Busmaster EIDE Controller +V 2001 Temporal Research Ltd +V 21C3 21st Century Computer Corp +V 2348 Racore +D 2010 8142 100VG/AnyLAN +V 2646 Kingston Technologies +V 270B Xantel Corporation +V 270F Chaintech Computer Co Ltd +V 2711 AVID Technology Inc +V 2A15 3D Vision(??) +V 3000 Hansol Electronics Inc +V 3030 C-Net +V 3142 Post Impression Systems +V 3388 Hint Corp +D 8011 VXPro II Chipset CPU to PCI Bridge +O 3388 VXPro II Chipset CPU to PCI Bridge +S 8011 VXPro II Chipset CPU to PCI Bridge +D 8012 VXPro II Chipset PCI to ISA Bridge +O 3388 VXPro II Chipset PCI to ISA Bridge +S 8012 VXPro II Chipset PCI to ISA Bridge +D 8013 VXPro II Chipset EIDE Controller +O 3388 VXPro II Chipset EIDE Controller +S 8013 VXPro II Chipset EIDE Controller +V 3411 Quantum Designs (H.K.) Inc +V 3513 ARCOM Control Systems Ltd +V 38EF 4Links +V 3D3D 3DLabs +D 0001 GLINT 300SX 3D Accelerator +D 0002 GLINT 500TX Sapphire 3D Accelerator +D 0003 GLINT Delta Geometry Processor +D 0004 3C0SX 2D+3D Accelerator +D 0005 Permedia 2D+3D Accelerator +D 0006 Glint MX 3D Accelerator +D 0007 3D Extreme Permedia II 2D+3D Accelerator +D 0008 GLINT Gamma G1 +D 0009 Permedia 3 2D+3D Accelerator +O 3D3D Permedia 3 2D+3D Accelerator +S 0100 AccelStar II 3D Accelerator +S 0111 Permedia 3:16 +S 0114 Santa Ana +S 0116 Oxygen GVX1 +S 0119 Scirocco +S 0120 Santa Ana PCL +S 0125 Oxygen VX1 +S 0127 Permedia 3 Create! +D 000A Permedia 3 +O 3D3D Permedia 3 +S 0111 Permedia3:16 +S 0114 Santa Ana Development Board +S 0116 Oxygen GVX1 +S 0119 Scirocco Development Board +S 0121 Oxygen VX1 PCI +S 0124 Permedia3:32 +S 0125 Oxygen VX1 +S 0127 Permedia3 Create! +S 0134 Oxygen GVX1 PCI +S 0136 Oxygen GVX210 +S 0800 Oxygen VX1 +D 000C Permedia 3 +O 3D3D Permedia 3 +S 0130 Oxygen VX1 +S 0140 Oxygen VX1-16 +S 0144 Oxygen VX1 +D 000E GLINT Gamma G2 +D 0100 Permedia II 2D+3D Accelerator +D 1004 Permedia 2D+3D Accelerator +D 3D04 Permedia 2D+3D Accelerator +D FFFF Glint VGA +V 4005 Avance Logic Inc +D 0300 ALS300 PCI Audio Device +D 0308 ALS300+ PCI Audio Device +D 0309 PCI Input Controller +D 1064 ALG-2064 GUI Accelerator +D 2064 ALG-2032/64i GUI Accelerator +D 2128 ALG-2364A GUI Accelerator +D 2301 AVL-2301 GUI Accelerator +D 2302 ALG-2302 GUI Accelerator +D 2303 AVG-2302 GUI Accelerator +D 2364 ALG-2364A +D 2464 ALG-2464 +D 2501 ALG-2564A/25128A +D 4000 ALS4000 Audio Chipset +O 4005 ALS4000 Audio Chipset +S 4000 ALS4000 Audio Chipset +V 4033 Delta Networks Inc (Addtron Technology Co Inc?) +V 4143 Digital Equipment Corp +V 416C Aladdin Knowledge Systems +V 4444 ICompression Inc +D 0002 iTVC12 MPEG Encoder Card +V 4468 Bridgeport Machines +V 4594 Cogetec Informatique Inc +V 45FB Baldor Electric Company +V 4680 UMAX Computer Corp +V 4843 Hercules Computer Technology Inc +V 4916 RedCreek Communications Inc +D 1960 RedCreek PCI Adapter +V 4943 Growth Networks +V 494F ICS Advent +D ACA8 PCI-AI/1216 ADC Card +O 494F PCI-AI/1216 ADC Card +S ACA0 PCI-AI/1216 ADC Card +D ACA9 PCI-AI/1216(M) ADC Card +V 4954 Integral Technologies +V 4978 Axil Computer Inc +V 4A14 NetVin +D 5000 RPTI RTL8029-Based PCI Ethernet Adapter +V 4B10 Buslogic Inc +D 3080 SCSI Host Adapter +D 4010 Wide SCSI Host Adapter +V 4C48 Lung Hwa Electronics +V 4C53 SBS-OR Industrial Computers +D 5000 NV5000 Ethernet Adapter +O 4A14 RT8029-Based Ethernet Adapter +S 5000 RT8029-Based Ethernet Adapter +V 4CA1 Seanix Technology Inc +V 4D51 Mediaq Inc +D 0200 MQ-200 +V 4D54 Microtechnica Co Ltd +V 4DDC ILC Data Device Corp +V 5053 TBS / Voyetra Technologies +D 2010 Daytona Audio Adapter +V 50B2 Terratec ?? +V 5136 S S Technologies +V 5143 Qualcomm Inc +V 5145 Ensoniq (Old ID) +D 3031 Concert AudioPCI +V 5301 Alliance Semiconductor Corp +D 0001 ProMotion aT3D +V 5333 S3 Inc +D 0551 86C551 PLATO/PX +D 5631 86C325 ViRGE +D 8800 86C866 Vision 866 +D 8801 86C964 Vision 964 +D 8810 86C732 Trio32 Rev 00 +D 8811 86C732 Trio32, 86C764 Trio64, 86C765 Trio64V+ Rev 01 +D 8812 86CM65 Aurora64V+ +D 8813 86C764 Trio64, 86C765 Trio64V+ Rev 03 +D 8814 86C767 Trio64UV+ +D 8815 86CM65 Aurora128 +D 883D 86C988 ViRGE/VX +D 8870 Fire GL +D 8880 86C868 Vision 868 VRAM Rev 00 +D 8881 86C868 Vision 868 VRAM Rev 01 +D 8882 86C868 Vision 868 VRAM Rev 02 +D 8883 86C868 Vision 868 VRAM Rev 03 +D 88B0 86C928 928 VRAM Rev 00 +D 88B1 86C928 928 VRAM Rev 01 +D 88B2 86C928 928 VRAM Rev 02 +D 88B3 86C928 928 VRAM Rev 03 +D 88C0 86C864 Vision 864 DRAM Rev 00 +D 88C1 86C864 Vision 864-P DRAM Rev 01 +D 88C2 86C864 Vision 864-P DRAM Rev 02 +D 88C3 86C864 Vision 864-P DRAM Rev 03 +D 88D0 86C964 Vision 964 VRAM Rev 00 +D 88D1 86C964 Vision 964-P VRAM Rev 01 +D 88D2 86C964 Vision 964-P VRAM Rev 02 +D 88D3 86C964 Vision 964-P VRAM Rev 03 +D 88F0 86C968 Vision 968 VRAM Rev 00 +D 88F1 86C968 Vision 968 VRAM Rev 01 +D 88F2 86C968 Vision 968 VRAM Rev 02 +D 88F3 86C968 Vision 968 VRAM Rev 03 +D 8900 86C775 Trio64V2/DX +O 5333 86C775 Trio64V2/DX +S 8900 86C775 Trio64V2/DX +D 8901 86C775 Trio64V2/DX, 86C785 Trio64V2/GX +O 5333 86C775 Trio64V2/DX, 86C785 Trio64V2/GX +S 8901 86C775 Trio64V2/DX, 86C785 Trio64V2/GX +D 8902 SMA Family +D 8903 TrioV Family +D 8904 86C365/366 Trio3D +O 1014 Integrated 86C365/366 Trio3D +S 00DB Integrated 86C365/366 Trio3D +O 5333 86C365/366 Trio3D +S 8904 86C365/366 Trio3D +D 8905 86C765 Trio64V+ Compatible +D 8906 86C765 Trio64V+ Compatible +D 8907 86C765 Trio64V+ Compatible +D 8908 86C765 Trio64V+ Compatible +D 8909 86C765 Trio64V+ Compatible +D 890A 86C765 Trio64V+ Compatible +D 890B 86C765 Trio64V+ Compatible +D 890C 86C765 Trio64V+ Compatible +D 890D 86C765 Trio64V+ Compatible +D 890E 86C765 Trio64V+ Compatible +D 890F 86C765 Trio64V+ Compatible +D 8A01 86C375 ViRGE/DX, 86C385 ViRGE/GX +O 0E11 86C385 ViRGE/GX +S B032 86C385 ViRGE/GX +O 10B4 Nitro 3D +S 1617 Nitro 3D +S 1717 Nitro 3D +O 5333 86C375 ViRGE/DX +S 8A01 86C375 ViRGE/DX +D 8A10 86C357 ViRGE/GX2, 86C359 ViRGE/GX2+ +O 1092 Stealth 3D 4000 +S 8A10 Stealth 3D 4000 +D 8A11 86C359 ViRGE/GX2+ Macrovision +D 8A12 86C359 ViRGE/GX2+ +D 8A13 86C362 Trio3D/2x, 86C368 Trio3D/2x+ +O 5333 86C362 Trio3D/2x, 86C368 Trio3D/2x+ +S 8A13 86C362 Trio3D/2x, 86C368 Trio3D/2x+ +D 8A20 86C391 Savage3D +O 5333 86C391 Savage3D +S 8A20 86C391 Savage3D +D 8A21 86C390 Savage3D/MV +O 5333 86C390 Savage3D/MV +S 8A21 86C390 Savage3D/MV +D 8A22 86C394-397 Savage4 +O 1014 Netfinity 3500 Integrated Savage4 +S 01C5 Netfinity 3500 Integrated Savage4 +O 1033 Savage4 +S 8068 Savage4 +O 1043 V3500 +S 8143 V3500 +O 105D SR9 +S 0018 SR9 8Mb SDRAM +S 002A SR9 Pro SDRAM +S 003A SR9 Pro SDRAM +S 092F SR9 Pro+ SGRAM +O 1092 Stealth III S540 +S 4207 Stealth III S540 +S 4800 Stealth III S540 +S 4807 SpeedStar A90 +S 4808 Stealth III S540 +S 4809 Stealth III S540 +S 480E Stealth III S540 +S 4904 Stealth III S520 +S 4905 SpeedStar A200 +S 4A09 Stealth III S540 +S 4A0B Stealth III S540 Xtreme +S 4A0F Stealth III S540 +S 4E01 Stealth III S540 +O 1102 3D Blaster Savage4 +S 101D 3D Blaster Savage4 +S 101E 3D Blaster Savage4 +O 5333 86C394-397 Savage4 +S 8100 86C394-397 Savage4 SDRAM 100 +S 8110 86C394-397 Savage4 SDRAM 110 +S 8125 86C394-397 Savage4 SDRAM 125 +S 8143 86C394-397 Savage4 SDRAM 143 +S 8A22 86C394-397 Savage4 +S 8A2E 86C394-397 Savage4 32bit +S 9125 86C394-397 Savage4 SGRAM 125 +S 9143 86C394-397 Savage4 SGRAM 143 +D 8A23 86C394-397 Savage4 +D 8A25 Savage4 ProSavage PM133 +O 5333 Savage4 ProSavage PM133 +S 8A25 Savage4 ProSavage PM133 +D 8A26 86C395B ProSavage +D 8C00 86C260 ViRGE/M3 (ViRGE/MX) +D 8C01 86C260 ViRGE/M5 (ViRGE/MX) +O 1179 ViRGE MX +S 0001 ViRGE MX +D 8C02 86C240 ViRGE/MXC +D 8C03 86C280 ViRGE/MX+MV +D 8C10 86C270 Savage/MX,274 Savage/IX,290 Savage/MX+MV,294 Savage/IX+MV +O 5333 86C794 Savage/MX w/MV +S 8C10 86C794 Savage/MX w/MV +D 8C12 86C270 Savage/MX,274 Savage/IX,290 Savage/MX+MV,294 Savage/IX+MV +O 1014 Thinkpad T Series Integrated Video +S 017F Thinkpad T Series Model 2647 Integrated Video +O 5333 86C792 Savage/IX w/MV +S 8C12 86C792 Savage/IX w/MV +D 8C22 86C508 SuperSavage 128/MX +D 8C2A 86C544 SuperSavage 128/IX +D 8C2B 86C553 SuperSavage 128/IX DDR +D 8C2C 86C564 SuperSavage/IX +D 8C2D 86C573 SuperSavage/IX DDR +D 8C2E 86C583 SuperSavage/IXC SDR +D 8C2F 86C594 SuperSavage/IXC DDR +D 9102 86C410 Savage 2000 +O 1092 Viper II Z200 +S 5932 Viper II Z200 +S 5934 Viper II Z200 +S 5952 Viper II Z200 +S 5954 Viper II Z200 +S 5A35 Viper II Z200 +S 5A37 Viper II Z200 +S 5A55 Viper II Z200 +S 5A57 Viper II Z200 +D CA00 86C617 SonicVibes +V 5349 ??Unknown?? (Seen on Intel 810 Motherboard AC'97 Modem Device!) +V 544C Teralogic Inc +V 5455 Technische Universit�t Berlin +D 4458 S5933 PCI to MyBus Bridge +V 5519 Cnet Technologies Inc +V 5555 Genroco Inc +D 0003 TURBOstor HFP-832 HiPPI NIC +V 5700 Netpower +V 6356 UltraStor +D 4002 ULTRA24 SCSI Host +D 4102 ULTRA24 SCSI Host +D 4202 ULTRA24 SCSI Host +D 4302 ULTRA24 SCSI Host +D 4402 ULTRA24 SCSI Host +D 4502 ULTRA24 SCSI Host +D 4602 ULTRA24 SCSI Host +D 4702 ULTRA24 SCSI Host +D 4802 ULTRA24 SCSI Host +D 4902 ULTRA24 SCSI Host +D 4A02 ULTRA24 SCSI Host +D 4B02 ULTRA24 SCSI Host +D 4C02 ULTRA24 SCSI Host +D 4D02 ULTRA24 SCSI Host +D 4E02 ULTRA24 SCSI Host +D 4F02 ULTRA24 SCSI Host +V 6374 c't Magazin f�r Computertechnik +D 6773 CT-GPPCI General Purpose PCI Interface +V 6409 Logitec Corp +V 6666 Decision Computer International Co +D 0001 PCCOM4 +D 0002 PCCOM8 +V 7604 O.N. Electric Co Ltd +V 7747 DaoGuo Technology Co Ltd +V 7BDE Midac Corporation +V 7FED PowerTV +V 8001 Beyertone AG Germany +V 8008 Quancom Electronic GmbH +D 0010 PWDOG1 Watchdog +D 0011 PWDOG2 Watchdog2 +D 0016 PROTO2 +D 0100 PREL8 +D 0102 PREL16 +D 0103 POPTOREL16 +D 0105 POPTO16IN +D 0106 PTTL24IO +D 0107 PUNIREL +D 1000 PDAC4 +D 1001 PAD12DAC4 +D 1002 PAD16DAC4 +D 1005 PAD12 +D 1006 PAD16 +D 3000 POPTOLCA +V 8086 Intel Corporation +D 0007 82379AB ?? +D 0008 Extended Express System Support Controller +D 0039 21145 ?? +D 0122 82437FX 430FX (Triton) System Controller +D 0309 80303 I/O Processor PCI to PCI Bridge +D 030D 80312 I/O Processor PCI to PCI Bridge +D 0482 82375EB/SB PCI to EISA Bridge +D 0483 82424TX/ZX (Saturn) Cache/DRAM Controller +D 0484 82378ZB/IB,82379AB PCI to ISA Bridge, System I/O +R 00 82378IB PCI to ISA Bridge, System I/O +R 03 82378ZB PCI to ISA Bridge, System I/O +R 88 82379AB PCI to ISA Bridge, System I/O + APIC +D 0486 82420EX/ZX 486 PCIset System, ISA Bridge & EIDE Controller +D 04A3 82434LX/NX (Mercury/Neptune) Cache/DRAM Controller +D 04D0 82437FX 430FX CPU to PCI Bridge +D 0960 80960RP i960 RP Microprocessor Bridge +D 0964 i960 RP Microprocessor Bridge +D 1000 82542 Gigabit Ethernet Adapter +O 0E11 NC1632 Gigabit Ethernet Adapter +S B0DF NC1632 Gigabit Ethernet Adapter +S B0E0 NC1633 Gigabit Ethernet Adapter +S B123 NC1634 Gigabit Ethernet Adapter +O 1014 Netfinity Gigabit Ethernet SX Adapter +S 0119 Netfinity Gigabit Ethernet SX Adapter +O 8086 EtherExpress PRO/1000 Gigabit Server Adapter +S 1000 EtherExpress PRO/1000 Gigabit Server Adapter +D 1002 Pro 100 LAN+Modem 56 Cardbus II +O 8086 Pro 100 LAN+Modem 56 Cardbus II +S 200E Pro 100 LAN+Modem 56 Cardbus II +D 1029 PRO/100 PCI Ethernet Adapter +O 0E11 82559 Fast Ethernet LOM with Alert on LAN* +S 3001 82559 Fast Ethernet LOM with Alert on LAN* +S 3002 82559 Fast Ethernet LOM with Alert on LAN* +S 3003 82559 Fast Ethernet LOM with Alert on LAN* +S 3004 82559 Fast Ethernet LOM with Alert on LAN* +S 3005 82559 Fast Ethernet LOM with Alert on LAN* +S 3006 82559 Fast Ethernet LOM with Alert on LAN* +S 3007 82559 Fast Ethernet LOM with Alert on LAN* +O 8086 82557/8/9-based Pro/100 Ethernet Adapter +S 000B PRO/100+ PCI Adapter +S 000C PRO/100+ Management Adapter +S 000D PRO/100+ Alert On LAN 2* Adapter +S 000E PRO/100+ Management Adapter with Alert On LAN* +S 0010 PRO/100 S Management Adapter +S 0011 PRO/100 S Management Adapter +S 0012 PRO/100 S Advanced Management Adapter (D) +S 0013 PRO/100 S Advanced Management Adapter (E) +S 100C PRO/100+ Server Adapter (PILA8470B) +S 1012 PRO/100 S Server Adapter (D) +S 1013 PRO/100 S Server Adapter (E) +S 200D PRO/100 CardBus +S 200E PRO/100 LAN+ModemV90 CardBus +S 2203 PRO/100+ MiniPCI for Compaq +S 2204 PRO/100+ MiniPCI for Compaq +S 2408 PRO/100+ MiniPCI for COMBO IBM +S 240F PRO/100+ MiniPCI for LAN Only IBM +S 2410 PRO/100+ MiniPCI for Generic LAN Only +S 2411 PRO/100+ MiniPCI for Generic Combo +S 2412 PRO/100+ MiniPCI place holder..... +S 2413 PRO/100+ MiniPCI place holder..... +S 3000 82559 Fast Ethernet LAN on Motherboard +S 3001 82559 Fast Ethernet LOM with Basic Alert on LAN* +S 3002 82559 Fast Ethernet LOM with Alert on LAN 2* +D 1030 82559 InBusiness 10/100 +D 1100 82815 815/E (Solano) Host to I/O Hub Bridge with 100MHz DRAM Controller +D 1101 82815 815/E (Solano) PCI to AGP Bridge +D 1102 82815 815/E (Solano) Internal GUI Accelerator +D 1110 82815 815/E (Solano) Host to I/O Hub Bridge, AGP Not Implemented +D 1112 82815 815/E (Solano) Internal GUI Accelerator +D 1120 82815 815/E (Solano) Host to I/O Hub Bridge, AGP Implemented +D 1121 82815 815/E (Solano) PCI to AGP Bridge +D 1130 82815/EM/EP/P 815/EM/EP/P (Solano) Host to I/O Hub Bridge +O 1043 82815/EP/EP/P (Solano) based Host to I/O Hub Bridge +S 8027 CUSL2 Host to I/O Hub Bridge +S 8028 CUSL2-M Host to I/O Hub Bridge +O 8086 82815/EM/EP/P 815/EM/EP/P (Solano) Host to I/O Hub Bridge +S 1130 82815/EM/EP/P 815/EM/EP/P (Solano) Host to I/O Hub Bridge +D 1131 82815/EM/EP/P 815/EM/EP/P (Solano) PCI to AGP Bridge +D 1132 82815/EM/EP/P 815/EM/EP/P (Solano) Interal GUI Accelerator +O 103C Vectra Series +S 1245 Vectra VL400DT +D 1161 82806AA PCI64 Hub Advanced Programmable Interrupt Controller +D 1209 82559ER Fast Ethernet Controller +D 1221 82092AA PCI to PCMCIA Bridge +D 1222 82092AA EIDE Controller +D 1223 SAA7116 Video Controller +D 1225 82452KX/GX Orion Extended Express Processor to PCI Bridge +D 1226 82596 EtherExpress PRO/10 +D 1227 82865 EtherExpress PRO/100 +D 1228 EtherExpress PRO/100 Smart +D 1229 82557/8/9 EtherExpress PRO/100(B) Ethernet Adapter +O 0E11 82557/8/9-based Ethernet Adapter +S 3001 82559 Fast Ethernet LOM with Alert on LAN* +S 3002 82559 Fast Ethernet LOM with Alert on LAN* +S 3003 82559 Fast Ethernet LOM with Alert on LAN* +S 3004 82559 Fast Ethernet LOM with Alert on LAN* +S 3005 82559 Fast Ethernet LOM with Alert on LAN* +S 3006 82559 Fast Ethernet LOM with Alert on LAN* +S 3007 82559 Fast Ethernet LOM with Alert on LAN* +S B01E Fast Ethernet NIC NC3120 +S B01F Fast Ethernet NIC NC3122 +S B02F Ethernet NIC NC1120 +S B04A Netellignet 10/100TX NIC with Wake on LAN +S B0C6 Embedded NIC NC3120 with Wake on LAN +S B0C7 Embedded NIC NC3121 +S B0D7 Fast Ethernet NIC NC3121 with Wake on LAN +S B0DD NC3131 Fast Ethernet Adapter +S B0DE NC3132 Fast Ethernet Adapter +S B0E1 NC3133 Fast Ethernet Adapter +S B134 NC3163 Fast Ethernet Adapter +S B13C NC3162 Fast Ethernet NIC +S B144 NC3123 Fast Ethernet NIC +S B163 NC3134 Fast Ethernet NIC +S B164 NC3135 Fast Ethernet Upgrade Module +O 1014 10/100 PCI Ethernet Adapter +S 005C 10/100 PCI Ethernet Adapter +S 105C Netfinity 10/100 Ethernet Adapter +S 305C 10/100 EtherJet PCI Management Adapter +O 1028 82557/8/9 EtherExpress PRO/100(B)-based Ethernet Adapter +S 009B 82557/8/9 EtherExpress PRO/100(B)-based Ethernet Adapter +O 1033 PC-9821X-B06 LAN Adapter +S 8000 PC-9821X-B06 LAN Adapter +S 8016 PK-UG-X006 Fast Ethernet +S 801F PK-UG-X006 Fast Ethernet +O 103C 10/100TX PCI LAN Adapter +S 10C0 10/100TX PCI LAN Adapter +S 10C3 10/100TX PCI LAN Adapter +S 10CA NetServer 10/100TX PCI LAN Adapter +S 10CB NetServer 10/100TX PCI LAN Adapter +S 1200 10/100TX PCI LAN Adapter +O 10C3 SmartEther100 SC1100 LAN Adapter +S 1100 SmartEther100 SC1100 LAN Adapter +O 1179 PCI FastEther LAN on Docker +S 0002 PCI FastEther LAN on Docker +O 1259 AT-2560 PCI/100 Ethernet Adapter +S 2560 AT-2560 PCI/100 Ethernet Adapter +S 2561 AT-2560 PCI/100 FX Ethernet Adapter +O 1266 NE10/100 Adapter +S 0001 NE10/100 Adapter +O 8086 EtherExpress PRO/100(B) PCI Adapter +S 0001 EtherExpress PRO/100B PCI Adapter (TX) +S 0002 EtherExpress PRO/100B PCI Adapter (T4) +S 0003 EtherExpress PRO/10+ PCI Adapter +S 0004 EtherExpress PRO/100 WfM PCI Adapter +S 0005 82557 10/100 integrated Ethernet +S 0006 82557 10/100 integrated Ethernet with Wake on LAN +S 0007 82558 10/100 integrated Ethernet +S 0008 82558 10/100 integrated Ethernet with Wake on LAN +S 0009 EtherExpress PRO/100+ Ethernet Adapter +S 000A EtherExpress PRO/100+ Management Adapter +S 000B EtherExpress PRO/100+ Ethernet Adapter +S 000C EtherExpress PRO/100+ Management Adapter +S 000D EtherExpress PRO/100+ Alert On LAN II* Adapter +S 000E EtherExpress PRO/100+ Management Adapter with Alert On LAN* +S 0010 PRO/100 S Management Adapter +S 0011 PRO/100 S Management Adapter +S 0012 PRO/100 S Advanced Management Adapter (D) +S 0013 PRO/100 S Advanced Management Adapter (E) +S 0030 PRO/100+ Management Adapter with Alert on LAN* GC +S 1009 EtherExpress PRO/100+ Server Adapter +S 100C EtherExpress PRO/100+ Server Adapter (PILA8470B) +S 1012 PRO/100 S Server Adapter (D) +S 1013 PRO/100 S Server Adapter (E) +S 1030 PRO/100+ Management Adapter with Alert on LAN* GS +S 10F0 EtherExpress PRO/100+ Dual Port Adapter +S 200D EtherExpress PRO/100 Cardbus +S 200E EtherExpress PRO/100 LAN+V90 Cardbus Modem +S 2203 PRO/100+ MiniPCI for Compaq +S 2204 PRO/100+ MiniPCI for Compaq +S 2408 PRO/100+ MiniPCI for COMBO IBM +S 240F PRO/100+ MiniPCI for LAN Only IBM +S 2410 PRO/100+ MiniPCI for Generic LAN Only +S 2411 PRO/100+ MiniPCI for Generic Combo +S 2412 PRO/100+ MiniPCI place holder..... +S 2413 PRO/100+ MiniPCI place holder..... +S 3000 82559 Fast Ethernet LAN on Motherboard +S 3001 82559 Fast Ethernet LOM with Basic Alert on LAN* +S 3002 82559 Fast Ethernet LOM with Alert on LAN II* +D 122D 82437FX 430FX (Triton) Cache/DRAM Controller +D 122E 82371FB PIIX PCI to ISA Bridge +D 1230 82338/82371FB PIIX PCI EIDE Controller +R 02 82338/82371FB PIIX PCI EIDE Controller (Faulty BusMastering!!) +D 1231 DSVD Modem +D 1234 82371MX 430MX Mobile Chipset MPIIX + EIDE + I/O +D 1235 82437MX 430MX Mobile Chipset System Controller +D 1237 82440/1FX 440FX (Natoma) System Controller +R 02 82441FX 440FX (Natoma) System Controller Rev 2 (SU053) +D 1239 82371FB 430FX PCI EIDE Controller +D 123B 82380PB PCI to PCI Docking Bridge +D 123C 82380AB 380AB Mobile Chipset ISA Bridge +D 123D 683053 Programmable Interrupt Device +D 1240 Intel752 AGP Graphics Accelerator +D 124B 82380FB 380FB Mobile Chipset PCI Bridge +D 1250 82439HX 430HX System Controller +R 01 82439HX 430HX System Controller Rev 1 - No ECC RAM Support +R 02 82439HX 430HX System Controller Rev 2 - ECC RAM Support +R 03 82439HX 430HX System Controller Rev 3 - Dual CPU Support +D 1360 82806AA PCI64 PCI Bridge +D 1361 82806AA PCI64 Hub Controller (HRes), APIC +D 1960 80960RP i960RP Microprocessor +X 11111111 MegaRaid 466 RAID Controller +O 101E MegaRaid RAID Controller +S 0438 MegaRaid 438 RAID Controller +S 0466 MegaRaid 466 RAID Controller +S 0467 MegaRAID Enterprise 1500 RAID Controller +S 0490 AMI MegaRAID Express 300 RAID Controller +O 1028 PERC series RAID Controllers +S 0467 PERC, PERC 2/Sc, 2/Dc +S 1111 PERC-2/SC RAID Controller +O 103C MegaRaid RAID Controller +S 10C6 MegaRaid 438 RAID Controller +S 10C7 MegaRaid T5 RAID Controller +S 10CD NetRAID-1Si +O 113C MegaRaid RAID Controller +S 03A2 MegaRaid RAID Controller +D 1A10 Celeron(tm) Processor to I/O Controller +D 1A11 Celeron(tm) Processor to I/O Controller +D 1A21 82840 840 (Carmel) Chipset Host to I/O Hub Bridge +D 1A23 82840 840 (Carmel) Chipset PCI to AGP Bridge +D 1A24 82840 840 (Carmel) Chipset PCI Bridge (Hub B) +D 2410 82801AA 8xx Chipset LPC Interface Bridge +D 2411 82801AA 8xx Chipset IDE Controller +O 8086 82801AA 8xx Chipset IDE Controller +S 2411 82801AA 8xx Chipset IDE Controller +D 2412 82801AA 8xx Chipset USB Controllers +O 8086 82801AA 8xx Chipset USB Controllers +S 2412 82801AA 8xx Chipset USB Controllers +D 2413 82801AA 8xx Chipset SMBus Controller +O 8086 82801AA 8xx Chipset SMBus Controller +S 2413 82801AA 8xx Chipset SMBus Controller +D 2415 82801AA 8xx Chipset AC'97 Audio Controller +O 11D4 SoundMAX Integrated Digital Audio +S 0040 SoundMAX Integrated Digital Audio +S 0048 SoundMAX Integrated Digital Audio +S 5340 SoundMAX Integrated Digital Audio +O 8086 82801AA 8xx Chipset AC'97 Audio Controller +S 2415 82801AA 8xx Chipset AC'97 Audio Controller +D 2416 82801AA 8xx Chipset AC'97 PCI Modem +O 5349 82801AA 8xx Chipset AC'97 PCI Modem +S 4C22 82801AA 8xx Chipset AC'97 PCI Modem +D 2418 82801AA 8xx Chipset Hub to PCI Bridge +D 2420 82801AB 8xx Chipset LPC Interface Bridge +D 2421 82801AB 8xx Chipset IDE Controller +D 2422 82801AB 8xx Chipset USB Controller +D 2423 82801AB 8xx Chipset SMBus Controller +D 2425 82801AB 8xx Chipset AC'97 Audio Controller +O 11D4 SoundMAX Integrated Digital Audio +S 0040 SoundMAX Integrated Digital Audio +S 0048 SoundMAX Integrated Digital Audio +D 2426 82801AB 8xx Chipset AC'97 PCI Modem +D 2428 82801AB 8xx Chipset Hub to PCI Bridge +D 2440 82801BA (ICH2) LPC Interface Controller +D 2441 82801BA Bus Master IDE Controller +D 2442 82801BA/BAM (ICH2) USB Universal Host Controller +O 8086 82801BA/BAM (ICH2) USB Universal Host Controller +S 4541 82801BA/BAM (ICH2) USB Universal Host Controller in Dell Laptop +D 2443 82801BA/BAM (ICH2) SMBus Controller +D 2444 82801BA/BAM (ICH2) USB Universal Host Controller +D 2445 82801BA/BAM (ICH2) AC'97 Audio Controller +D 2446 82801BA/BAM (ICH2) AC'97 Modem Controller +D 2448 82801BAM (ICH2) PCI to I/O Hub Bridge +D 2449 82701BA (ICH2) LAN Controller +O 8086 82701BA (ICH2) LAN Controller +S 3010 PRO/100E Adapter +S 3011 PRO/100E+ Management Adapter +S 3012 82562EH based Phoneline Network Controller +S 3013 PRO/100E Adapter +S 3014 PRO/100E+ Management Adapter +S 3015 82562EH based Phoneline Network Controller +D 244A 82801BAM (ICH2) UltraDMA/100 IDE Controller +O 8086 82801BAM (ICH2) UltraDMA/100 IDE Controller +S 4541 82801BAM (ICH2) UltraDMA/100 IDE Controller in Dell Laptop +D 244B 82801BA (ICH2) UltraDMA/100 IDE Controller +D 244C 82801BAM (ICH2) LPC Interface Controller +D 244E 82801BA (ICH2) PCI Bridge +D 2500 82820 820 (Camino) Chipset Host Bridge (MCH) +O 1043 P3C Series system chipset +S 801B P3C-E System chipset +S 801C P3C-2000 system chipset +D 2501 82820 820 (Camino) Chipset Host Bridge (MCH) +O 1043 P3C Series system chipset +S 801B P3C-E system chipset +S 801C P3C-2000 system chipset +D 250B 82820 820 (Camino) Chipset Host to I/O Bus Bridge +D 250F 82820 820 (Camino) Chipset PCI to AGP Bridge +D 2520 82805AA MTH Memory Translator Hub +D 2521 82804AA MRH-S Memory Repeater Hub for SDRAM +D 2530 82850 (850) Processor to I/O Controller (MCH) +D 2531 82860 (860) Processor to I/O Controller +D 2532 82850/82860 (850/860) Processor to AGP Bridge (MCH) +D 2533 82860 (860) PCI Bridge +D 2534 82860 (860) PCI Bridge +D 2535 82860 (860) PCI Bridge +D 2536 82860 (860) PCI Bridge +D 2537 82850/82860 (850/860) Controller +D 5001 PRO/DSL 2100 Modem - PPP +D 5200 EtherExpress PRO/100 Server PCI to PCI Bridge +D 5201 EtherExpress PRO/100 Server Ethernet Adapter +O 8086 EtherExpress PRO/100 Server Ethernet Adapter +S 0001 EtherExpress PRO/100 Server Ethernet Adapter +D 5309 80303 I/O Processor Address Translation Unit +D 530D 80312 I/O Companion Address Translation Unit +D 7000 82371SB PIIX3 ISA Bridge +D 7010 82371SB PIIX3 EIDE Controller +D 7020 82371SB PIIX3 USB Controller +R 00 82371SB PIIX3 USB Controller Rev 0 (SU052) (Unreliable!!) +R 01 82371SB PIIX3 USB Controller Rev 1 (SU093) +D 7030 82437VX 430VX System Controller +R 01 82437VX 430VX System Controller Rev 1 (Buggy Timing!!) +R 02 82437VX 430VX System Controller Rev 2 +D 7051 PB642365-003 Business Video Conferencing Card +D 7100 82439TX 430TX System Controller +D 7110 82371AB/EB/MB PIIX4 ISA Bridge +R 01 82371AB PIIX4 ISA Bridge +R 02 82371EB PIIX4E ISA Bridge +D 7111 82371AB/EB/MB PIIX4 EIDE Controller +D 7112 82371AB/EB/MB PIIX4 USB Controller +D 7113 82371AB/EB/MB PIIX4 Power Management Controller +R 01 82371AB PIIX4 Power Management Controller +R 02 82371EB PIIX4E Power Management Controller +D 7120 82810 810 Chipset Memory Controller Hub +D 7121 82810 810 Chipset Graphics Controller +D 7122 82810-DC100 810 Chipset Memory Controller Hub +O 8086 82810-DC100 810 Chipset Memory Controller Hub +S 7122 82810-DC100 810 Chipset Memory Controller Hub +D 7123 82810-DC100 810 Chipset Graphics Controller +O 8086 82810-DC100 810 Chipset Graphics Controller +S 7123 82810-DC100 810 Chipset Graphics Controller +D 7124 82810e 810e Chipset Host Bridge and Memory Controller Hub +D 7125 82810e 810e Chipset Graphics Controller +O 110A 82810e 810e Chipset Graphics Controller +S 004A 82810e 810e Chipset Graphics Controller +D 7126 82810 810 Chipset Host Bridge and Memory Controller Hub +D 7128 82810-M DC-100 System and Graphics Controller +D 712A 82810-M System and Graphics Controller +D 7180 82443LX/EX 440LX/EX CPU to PCI Bridge +D 7181 82443LX/EX 440LX/EX PCI to AGP Bridge +D 7190 82443BX/ZX 440BX/ZX CPU to PCI Bridge (AGP Implemented) +O 0E11 82443BX/ZX 440BX/ZX CPU to PCI Bridge (AGP Implemented) +S 0500 Armada 1750 Laptop System Chipset +S B110 Armada V300 Laptop System Chipset +O 1043 Intel 440BX/ZX chipset based mainboard CPU to PCI Bridge +S 8024 P3B-F CPU to PCI Bridge +S 8025 CUBX CPU to PCI Bridge +D 7191 82443BX/ZX 440BX/ZX PCI to AGP Bridge +D 7192 82443BX/ZX 440BX/ZX CPU to PCI Bridge (AGP Not Implemented) +O 0E11 Armada 1700 Laptop System Chipset +S 0460 Armada 1700 Laptop System Chipset +D 7194 82440MX CPU to I/O Controller +D 7195 82440MX(?) Chipset AC'97 Audio Controller +O 10CF QSound_SigmaTel Stac97 PCI Audio +S 1099 QSound_SigmaTel Stac97 PCI Audio +O 11D4 SoundMAX Integrated Digital Audio +S 0040 SoundMAX Integrated Digital Audio +S 0048 SoundMAX Integrated Digital Audio +D 7198 82440MX PCI to ISA Bridge +D 7199 82440MX EIDE Controller +D 719A 82440MX USB Universal Host Controller +D 719B 82440MX Power Management Controller +D 71A0 82443GX 440GX CPU to PCI Bridge (AGP Implemented) +D 71A1 82443GX 440GX PCI to AGP Bridge +D 71A2 82443GX 440GX CPU to PCI Bridge (AGP Not Implemented) +D 7600 82372FB PCI to ISA Bridge +D 7601 82372FB PCI BusMaster IDE Controller +D 7602 82372FB USB Universal Host Controller +D 7603 82372FB System Management Bus Controller +D 7605 82372FB 1394 OHCI Host Controller +D 7800 Intel740 AGP Graphics Accelerator +O 003D Real 3D Starfighter +S 0008 Real 3D Starfighter +O 1092 Stealth II G460 +S 0100 Stealth II G460 +O 10B4 Lightspeed 740 +S 201A Lightspeed 740 +O 8086 Intel740 Graphics Accelerator +S 0000 Terminator 2X/I +S 0100 Intel740 Graphics Accelerator +D 84C4 82454KX/GX 450KX/GX Orion System Controller +R 02 82454KX/GX 450KX/GX Orion System Controller Rev 2 (Bus Limit!!) +R 04 82454KX/GX 450KX/GX Orion System Controller Rev 4 +D 84C5 82453KX/GX 450KX/GX Orion Data Controller +D 84CA 82451NX 450NX Memory and I/O Controller +D 84CB 82454NX 450NX PCI Expander Bridge +D 9620 I2O RAID PCI to PCI Bridge +D 9621 SRCU21 I2O 1.5 RAID Controller +D 9622 SRCUxx I2O 1.5 RAID Controller +D 9641 SRCU31 I2O 1.5 RAID Controller +D 96A1 SRCU31L I2O 1.5 RAID Controller +D B152 PCI to PCI Bridge +D B154 S21152BA PCI to PCI Bridge +D FFFF 82450KX/GX Orion Cache/DRAM Controller (Buggy ID) +V 8800 Trigem Computer +D 2008 Video assistent component +V 8866 T-Square Design Inc +V 8888 Silicon Magic Corp +V 8E0E Computone Corp +V 8E2E KTI +D 3000 ET32/Px Ethernet Adapter +V 9004 Adaptec +D 1078 AIC-7810C RAID-Coprozessor +D 1160 AIC-1160 Family Fibre Channel Adapter +D 2178 AIC-7821 SCSI Host Adapter +D 3860 AHA-2930CU PCI SCSI Controller +D 3B78 AHA-4944W/4944UW Quad Fast-Wide/Ultra SCSI-II +D 5075 AIC-7550 SCSI Controller +D 5078 AVA-2902A/E,AVA-2904,AVA-2910 (AIC-7850P) Fast/Wide SCSI II +O 9004 AHA-2904/Integrated AIC-7850 +S 7850 AHA-2904/Integrated AIC-7850 +D 5175 AIC-755x SCSI Controller +D 5178 AIC-7850 Fast SCSI Controller +D 5275 AIC-755x SCSI Controller +D 5278 AIC-7850 Fast SCSI Controller +D 5375 AIC-755x SCSI Controller +D 5378 AIC-7850 Fast SCSI Controller +D 5475 AIC-755x SCSI Controller +D 5478 AIC-7850 Fast SCSI Controller +D 5575 AVA-2930 SCSI Host Adapter +D 5578 AIC-7855 Fast SCSI Controller +D 5675 AIC-755x SCSI Controller +D 5678 AIC-7856 Fast SCSI Controller +D 5775 AIC-755x SCSI Controller +D 5778 AIC-7850 Fast SCSI Controller +D 5800 AIC-5800 FireWire Controller +D 5900 ANA-5910/5930/5940 ATM155 & 25 LAN Adapter +D 5905 ANA-5910A/5930A/5940A ATM Adapter +D 6038 AIC-3860 SCSI Host Adapter +D 6075 APA-1480 Cardbus Ultra SCSI Controller +D 6078 AIC-7860 SCSI Controller +D 6178 AIC-7861 AHA-2940AU SCSI Controller +O 9004 AHA-2940AU Single +S 7861 AHA-2940AU Single +D 6278 AIC-7860 SCSI Controller +D 6378 AIC-7860 SCSI Controller +D 6478 AIC-786x SCSI Controller +D 6578 AIC-786x SCSI Controller +D 6678 AIC-786x SCSI Controller +D 6778 AIC-786x SCSI Controller +D 6915 ANA620xx/ANA69011A Fast Ethernet +O 9004 ANA690xx Series 10/100 Fast Ethernet +S 0008 ANA69011A/TX 10/100 Fast Ethernet +S 0009 ANA69011A/TX 10/100 Fast Ethernet +S 0010 ANA62022 2-port 10/100 Fast Ethernet +S 0018 ANA62044 4-port 10/100 Fast Ethernet +S 0020 ANA62022 2-port 10/100 Fast Ethernet +S 0028 ANA69011A/TX 10/100 Fast Ethernet +S 8008 ANA69011A/TX 64 bit 10/100 Fast Ethernet +S 8009 ANA69011A/TX 64 bit 10/100 Fast Ethernet +S 8010 ANA62022 2-port 64 bit 10/100 Fast Ethernet +S 8018 ANA62044 4-port 64 bit 10/100 Fast Ethernet +S 8020 ANA62022 2-port 64 bit 10/100 Fast Ethernet +S 8028 ANA69011A/TX 64 bit 10/100 Fast Ethernet +D 7078 AIC-7870P Fast/Wide SCSI II Chip +D 7178 AHA-2940/W Fast/Wide SCSI Host Adapter +D 7278 AHA-3940/W Dual-Channel FAST/Wide SCSI Host Adapter +D 7378 AHA-3985 4 Channel RAID SCSI Host Adapter +D 7478 AHA-2944/W SCSI Host Adapter +D 7578 AHA-3944/W Multichannel Fast/Fast-Wide Differential SCSI +D 7678 AHA-4944W/UW Quad Fast-Wide/Ultra Differential SCSI +D 7778 AIC-787x SCSI Controller +D 7810 AIC-7810 Memory Controller IC +D 7815 AIC-7815 RAID+Memory Controller IC +O 9004 AIC-7815 RAID+Memory Controller IC +S 7815 ARO-1130U2 RAID Controller +S 7840 AIC-7815 RAID+Memory Controller IC +D 7850 AIC-7850 Fast/Wide SCSI II Chip +D 7855 AHA-2930 SCSI Host Adapter +D 7860 AIC-7860 based SCSI Controller +D 7870 AIC-7870 Fast/Wide SCSI II Chip +D 7871 AHA-2940 Fast/Wide SCSI Host Adapter +D 7872 AHA-3940 Dual-Channel FAST/Wide SCSI Host Adapter +D 7873 AHA-3985 4 Channel RAID SCSI Host Adapter (AIC-7873) +D 7874 AHA-2944 SCSI Host Adapter +D 7880 AIC-7880P Ultra/Ultra Wide SCSI Chipset +D 7890 AIC-7890 SCSI Controller +D 7891 AIC-789x SCSI Controller +D 7892 AIC-789x SCSI Controller +D 7893 AIC-7895C SCSI Controller +D 7894 AIC-789x SCSI Controller +D 7895 AIC-7895 PCI SCSI Controller +O 9004 AIC-7895 PCI SCSI Controller +S 7890 AHA-2940U/UW Dual/AHA-394xAU/AUW/AUWD SCSI Controller +S 7891 AHA-2940U/UW Dual Channel PCI SCSI Controller +S 7892 AHA-3940AU/AUW/AUWD/UWD PCI SCSI Controller +S 7894 AHA-3944AUWD PCI SCSI Controller +S 7895 AHA-2940U/2940UW Dual AHA-394xAU/AUW/AUWD AIC-7895B +D 7896 AIC-789x SCSI Controller +D 7897 AIC-789x SCSI Controller +D 8078 AIC-7880P Ultra/Ultra Wide SCSI Chipset +O 9004 AIC-7880P Ultra/Ultra Wide SCSI Chipset +S 7880 AIC-7880P Ultra/Ultra Wide SCSI Chipset +D 8178 AHA-2940U/UW/2940D Ultra/Ultra Wide/Dual SCSI Host Adapter +O 9004 AHA-2940UW SCSI Host Adapter +S 7881 AHA-2940UW SCSI Host Adapter +D 8278 AHA-3940U/UW/UWD Ultra/Ultra Wide/Dual SCSI Host Adapter +D 8378 AHA-389X (AIC-7883U) +D 8478 AHA-2944UW SCSI Host Adapter +D 8578 AHA-3944U/UWD Ultra/Ultra Wide/Dual SCSI Host Adapter +D 8678 AHA-4944UW AIC-7880 SCSI Host Adapter +D 8778 AHA-2940UW Pro AIC-788x Ultra-Wide SCSI Controller +O 9004 2940UW Pro Ultra-Wide SCSI Controller +S 7887 2940UW Pro Ultra-Wide SCSI Controller +D 8878 AHA-2930UW Ultra-Wide SCSI Controller +O 9004 AHA-2930UW Ultra-Wide SCSI Controller +S 7888 AHA-2930UW Ultra-Wide SCSI Controller +D 8B78 ABA-1030 PCI +D EC78 AHA-4944W/4944UW Quad Differential SCSI Controller +V 9005 Adaptec +D 0010 AHA-2940U2W/U2B AHA-2950U2W Ultra2 SCSI Controller +O 9005 AHA-2940U2W/U2B AHA-2950U2W Ultra2 SCSI Controller +S 2180 AHA-2940U2 Ultra2 SCSI Controller +S 8100 AHA-2940U2B Ultra2 SCSI Controller +S A180 AHA-2940U2W Ultra2 SCSI Controller +S E100 AHA-2950U2B Ultra2 SCSI Controller +D 0011 AHA-2930U2 Ultra2 SCSI Host Adapter +D 0013 AIC-7890/1 SCSI Host Adapter +O 9005 AIC-7890/1 SCSI Host Adapter +S 0003 AAA-131U2 Array1000 1 Channel RAID Controller +D 001F AHA-2940U2/AHA-2940U2W AIC-7890/1 Ultra2 SCSI Controller +O 9005 2940U2W SCSI Controller +S 000F 2940U2W SCSI Controller +S A180 2940U2W SCSI Controller +D 0020 AIC-789x SCSI Controller +D 002F AIC-789x SCSI Controller +D 0030 AIC-789x SCSI Controller +D 003F AIC-789x SCSI Controller +D 0050 AHA-3940U2x/AHA-3950U2x Ultra2 SCSI Controller +O 9005 AHA-3940U2x/AHA-3950U2x Ultra2 SCSI Controller +S F500 AHA-3950U2B Ultra2 SCSI Controller +D 0051 AHA-3950U2x Ultra2 SCSI Controller +O 9005 AHA-3950U2x Ultra2 SCSI Controller +S B500 AHA-3950U2D Ultra2 SCSI Controller +D 0053 AIC-7896 SCSI Controller +O 9005 AIC-7896 SCSI Controller +S FFFF AIC-7896 SCSI Controller mainboard implementation +D 005F AIC-7896/7 Ultra2 SCSI Controller +D 0080 29160/N/LP Ultra160 (AIC-7892A) SCSI Host Adapter +O 0E11 29160 Ultra160 (AIC-7892A) SCSI Host Adapter +S E2A0 64-bit/66MHz Wide Ultra3 SCSI Adapter +O 9005 29160/N/LP Ultra160 (AIC-7892A) SCSI Host Adapter +S 62A0 29160N Ultra160 SCSI Controller +S E220 29160LP Low Profile Ultra160 SCSI Controller +S E2A0 29160 Ultra160 SCSI Controller +D 0081 19160 AIC-7892B Ultra160 SCSI Adapter +O 9005 19160 AIC-7892B Ultra160 SCSI Adapter +S 62A1 19160 AIC-7892B Ultra160 SCSI Adapter +D 0083 AIC-7892D SCSI Host Adapter +D 008F AIC-7892 Ultra160 SCSI Host Adapter +O 9005 AIC-7892 Ultra160 SCSI Host Adapter +S 008F AIC-7892 Ultra160 SCSI Host Adapter +D 00C0 39160 (AIC-7899A) Ultra160 SCSI Host Adapter +O 0E11 39160 (AIC-7899A) Ultra160 SCSI Host Adapter +S F620 64-Bit/66MHz Dulal Channel Wide Ultra3 SCSI Adapter +O 9005 39160 (AIC-7899A) Ultra160 SCSI Host Adapter +S F620 39160 (AIC-7899A) Ultra160 SCSI Host Adapter +D 00C1 AIC-7899B SCSI Host Adapter +D 00C3 AIC-7899D SCSI Host Adapter +D 00CF AIC-7899 Ultra160 SCSI Host Adapter +V 907F Atronics +D 2015 IDE-2015PL EIDE Controller +V 919A Gigapixel Corp +V 9412 Holtek +D 6565 HT6565 PCI EIDE Controller +V 9699 Omni Media Technology Inc +V 9710 Netmos +D 9705 Nm9705 Parallel Port Adapter +D 9715 Nm9715 Two Parallel Port Adapter +D 9735 Nm9735 2S 1P +D 9745 Nm9745 Dual UART and PCI-ISA Bridge +D 9755 Nm9755 Parallel Port and PCI-ISA Bridge +D 9805 Nm9805 Parallel Port Adapter +D 9815 Nm9815 Parallel Port Adapter +X 00101000 Nm9815_1P +X 00201000 Nm9815_2P +D 9835 Nm9835 1P 2S +X 00011000 Nm9835_0P1S +X 00021000 Nm9835_0P2S +X 00111000 Nm9835_1P1S +X 00121000 Nm9835_1P2S +D 9845 Nm9845 4S +X 00011000 Nm9845_0P1S +X 00021000 Nm9845_0P2S +X 00041000 Nm9845_0P4S +X 00061000 Nm9845_0P6S +X 00141000 Nm9845_1P4S +D 9855 Nm9855 1P 2S +X 00121000 Nm9855_1P2S +X 00141000 Nm9855_1P4S +X 00221000 Nm9855_2P2S +V 9902 Starbridge Technologies Inc +V A0A0 Aopen Inc +V A0F1 Unisys Corp +V A200 NEC Corp +V A259 Hewlett Packard +V A25B Hewlett Packard GmbH PL24-MKT +V A304 Sony +V A727 3Com Corp +V AA42 Scitex Digital Video +V AC1E Digital Receiver Technology Inc +V AECB Adrienne Electronics Corporation +V B00C IC Book Labs +D 001C POST Diagnostics Card +V B1B3 Shiva Europe Ltd +V B894 Brown & Sharpe Mfg Co +V C001 TSI Telsys +V C0A9 Micron/Crucial Technology +V C0DE Motorola +V C0FE Motion Engineering Inc +V C622 Hudson Soft Co Ltd +V CA50 Varian Australia Pty Ltd +V CAFE Chrysalis-ITS +V CCCC Catapult Communications +V D4D4 DY4 Systems Inc +D 0601 PCI Mezzanine Card +V D84D Exsys +V DC93 Dawicontrol +V E000 Winbond +D E000 W89C940 Ethernet Adapter +V E159 Tiger Jet Network Inc +D 0001 Tiger 300/320 128k ISDN Adapter +X 00010059 128k ISDN-S/T Adapter +X 00030059 128k ISDN-U Adapter +X 000500A7 ISDN BRI Adapter +D 0600 Tiger 600 PCI to PCI Bridge +V E4BF EKF Electronik GmbH +V EA01 Eagle Technology +V ECC0 Echo Corporation +V EDD8 ARK Logic +D A091 Stingray ARK1000PV +D A099 Stingray ARK2000PV +D A0A1 Stingray 64 ARK2000MT 64-bit GUI W/DCI Playback +D A0A9 Quadro645 ARK2000MI +D A0B1 ARK2000MIP +V F5F5 F5 Networks, Inc +V FA57 Fast Search & Transfer ASA +V FEDA Epigram Inc +V FFFE VMWare Inc (Older Product Versions) +D 0710 Virtual SVGA +; +; Well, that's the end of the list. +; +; I have deliberately omitted vendor ID FFFF which is actually "Undefined" +; deliberately by the PCI SIG. Software looks for FFFF to know if it's found a +; device or not; a vendor ID <>FFFF means you found a device, FFFF means no +; device present. +; +; The theory is that software would never look in the list for a possible +; vendor ID match when it's already knowing that there is no device there to +; get a match with! In the interest of human readability, therefore, this note +; is here and I hope it helped you! +; \ No newline at end of file diff --git a/mobius/doc/txt/pe.txt b/mobius/doc/txt/pe.txt new file mode 100644 index 0000000..d6da250 --- /dev/null +++ b/mobius/doc/txt/pe.txt @@ -0,0 +1,2043 @@ +$Id: pe.txt,v 1.1 2001/06/05 01:03:32 pavlovskii Exp $ + + + +The PE file format +================== + + + +Preface +------- + +The PE ("portable executable") file format is the format of executable +binaries (DLLs and programs) for MS windows NT, windows 95 and +win32s; in windows NT, the drivers are in this format, too. +It can also be used for object files and libraries. + +The format is designed by Microsoft and standardized by the TIS (tool +interface standard) Committee (Microsoft, Intel, Borland, Watcom, IBM +and others) in 1993, apparently based on a good knowledge of COFF, the +"common object file format" used for object files and executables on +several UNIXes and on VMS. + +The win32 SDK includes a header file containing #defines and +typedefs for the PE-format. I will mention the struct-member-names and +#defines as we go. + +You may also find the DLL "imagehelp.dll" to be helpful. It is part of +windows NT, but documentation is scarce. Some of its functions are +described in the "Developer Network". + + + +General Layout +-------------- + +At the start of a PE file we find an MS-DOS executable ("stub"); this +makes any PE file a valid MS-DOS executable. + +After the DOS-stub there is a 32-bit-signature with the magic number +0x00004550 (IMAGE_NT_SIGNATURE). + +Then there is a file header (in the COFF-format) that tells on which +machine the binary is supposed to run, how many sections are in it, the +time it was linked, whether it is an executable or a DLL and so on. (The +difference between executable and DLL in this context is: a DLL can not +be started but only be used by another binary, and a binary cannot link +to an executable). + +After that, we have an optional header (it is always there but still +called "optional" - COFF uses an "optional header" for libraries but not +for objects, that's why it is called "optional"). This tells us more +about how the binary should be loaded: The starting address, the amount +of stack to reserve, the size of the data segment etc.. + +An interesting part of the optional header is the trailing array of +'data directories'; these directories contain pointers to data in the +'sections'. If, for example, the binary has an export directory, you +will find a pointer to that directory in the array member +IMAGE_DIRECTORY_ENTRY_EXPORT, and it will point into one of the +sections. + +Following the headers we find the 'sections', introduced by the 'section +headers'. Essentially, the sections' contents is what you really need to +execute a program, and all the header and directory stuff is just there +to help you find it. +Each section has some flags about alignment, what kind of data it +contains ("initialized data" and so on), whether it can be shared etc., +and the data itself. Most, but not all, sections contain one or more +directories referenced through the entries of the optional header's +"data directory" array, like the directory of exported functions or the +directory of base relocations. Directoryless types of contents are, for +example, "executable code" or "initialized data". + + +-------------------+ + | DOS-stub | + +-------------------+ + | file-header | + +-------------------+ + | optional header | + |- - - - - - - - - -| + | | + | data directories | + | | + +-------------------+ + | | + | section headers | + | | + +-------------------+ + | | + | section 1 | + | | + +-------------------+ + | | + | section 2 | + | | + +-------------------+ + | | + | ... | + | | + +-------------------+ + | | + | section n | + | | + +-------------------+ + + + +DOS-stub and Signature +---------------------- + +The concept of a DOS-stub is well-known from the 16-bit-windows- +executables (which were in the "NE" format). The stub is used for +OS/2-executables, self-extracting archives and other applications, too. +For PE-files, it is a MS-DOS 2.0 compatible executable that almost +always consists of about 100 bytes that output an error message such as +"this program needs windows NT". +You recognize a DOS-stub by validating the DOS-header, being a +struct IMAGE_DOS_HEADER. The first 2 bytes should be the sequence "MZ" +(there is a #define IMAGE_DOS_SIGNATURE for this WORD). +You distinguish a PE binary from other stubbed binaries by the trailing +signature, which you find at the offset given by the header member +'e_lfanew' (which is 32 bits long beginning at byte offset 60). For OS/2 +and windows binaries, the signature is a 16-bit-word; for PE files, it +is a 32-bit-longword aligned at a 8-byte-boundary and having the value +IMAGE_NT_SIGNATURE #defined to be 0x00004550. + + + +File Header +----------- + +To get to the IMAGE_FILE_HEADER, validate the "MZ" of the DOS-header +(1st 2 bytes), then find the 'e_lfanew' member of the DOS-stub's header +and skip that many bytes from the beginning of the file. Verify the +signature you will find there. The file header, a struct +IMAGE_FILE_HEADER, begins immediatly after it; the members are described +top to bottom. + +The first member is the 'Machine', a 16-bit-value indicating the system +the binary is intended to run on. Known legal values are + + IMAGE_FILE_MACHINE_I386 (0x14c) + for Intel 80386 processor or better + + 0x014d + for Intel 80486 processor or better + + 0x014e + for Intel Pentium processor or better + + 0x0160 + for R3000 (MIPS) processor, big endian + + IMAGE_FILE_MACHINE_R3000 (0x162) + for R3000 (MIPS) processor, little endian + + IMAGE_FILE_MACHINE_R4000 (0x166) + for R4000 (MIPS) processor, little endian + + IMAGE_FILE_MACHINE_R10000 (0x168) + for R10000 (MIPS) processor, little endian + + IMAGE_FILE_MACHINE_ALPHA (0x184) + for DEC Alpha AXP processor + + IMAGE_FILE_MACHINE_POWERPC (0x1F0) + for IBM Power PC, little endian + +Then we have the 'NumberOfSections', a 16-bit-value. It is the number of +sections that follow the headers. We will discuss the sections later. + +Next is a timestamp 'TimeDateStamp' (32 bit), giving the time the file +was created. You can distinguish several versions of the same file by +this value, even if the "official" version number was not altered. (The +format of the timestamp is not documented except that it should be +somewhat unique among versions of the same file, but apparently it is +'seconds since January 1 1970 00:00:00' in UTC - the format used by most +C compilers for the time_t.) +This timestamp is used for the binding of import directories, which will +be discussed later. +Warning: some linkers tend to set this timestamp to absurd values which +are not the time of linking in time_t format as described. + +The members 'PointerToSymbolTable' and 'NumberOfSymbols' (both 32 bit) +are used for debugging information. I don't know how to decipher them, +and I've found the pointer to be always 0. + +'SizeOfOptionalHeader' (16 bit) is simply sizeof(IMAGE_OPTIONAL_HEADER). +You can use it to validate the correctness of the PE file's structure. + +'Characteristics' is 16 bits and consists of a collection of flags, most +of them being valid only for object files and libraries: + + Bit 0 (IMAGE_FILE_RELOCS_STRIPPED) is set if there is no relocation + information in the file. This refers to relocation information per + section in the sections themselves; it is not used for executables, + which have relocation information in the 'base relocation' directory + described below. + + Bit 1 (IMAGE_FILE_EXECUTABLE_IMAGE) is set if the file is + executable, i.e. it is not an object file or a library. This flag + may also be set if the linker attempted to create an executable but + failed for some reason, and keeps the image in order to do e.g. + incremental linking the next time. + + Bit 2 (IMAGE_FILE_LINE_NUMS_STRIPPED) is set if the line number + information is stripped; this is not used for executable files. + + Bit 3 (IMAGE_FILE_LOCAL_SYMS_STRIPPED) is set if there is no + information about local symbols in the file (this is not used + for executable files). + + Bit 4 (IMAGE_FILE_AGGRESIVE_WS_TRIM) is set if the operating system + is supposed to trim the working set of the running process (the + amount of RAM the process uses) aggressivly by paging it out. This + should be set if it is a demon-like application that waits most of + the time and only wakes up once a day, or the like. + + Bits 7 (IMAGE_FILE_BYTES_REVERSED_LO) and 15 + (IMAGE_FILE_BYTES_REVERSED_HI) are set if the endianess of the file is + not what the machine would expect, so it must swap bytes before + reading. This is unreliable for executable files (the OS expects + executables to be correctly byte-ordered). + + Bit 8 (IMAGE_FILE_32BIT_MACHINE) is set if the machine is expected + to be a 32 bit machine. This is always set for current + implementations; NT5 may work differently. + + Bit 9 (IMAGE_FILE_DEBUG_STRIPPED) is set if there is no debugging + information in the file. This is unused for executable files. + According to other information ([6]), this bit is called "fixed" and + is set if the image can only run if it is loaded at the preferred + load address (i.e. it is not relocatable). + + Bit 10 (IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP) is set if the application + may not run from a removable medium such as a floppy or a CD-ROM. In + this case, the operating system is advised to copy the file to the + swapfile and execute it from there. + + Bit 11 (IMAGE_FILE_NET_RUN_FROM_SWAP) is set if the application may + not run from the network. In this case, the operating system is + advised to copy the file to the swapfile and execute it from there. + + Bit 12 (IMAGE_FILE_SYSTEM) is set if the file is a system file such + as a driver. This is unused for executable files; it is also not + used in all the NT drivers I inspected. + + Bit 13 (IMAGE_FILE_DLL) is set if the file is a DLL. + + Bit 14 (IMAGE_FILE_UP_SYSTEM_ONLY) is set if the file is not + designed to run on multiprocessor systems (that is, it will crash + there because it relies in some way on exactly one processor). + + + +Relative Virtual Addresses +-------------------------- + +The PE format makes heavy use of so-called RVAs. An RVA, aka "relative +virtual address", is used to describe a memory address if you don't know +the base address. It is the value you need to add to the base address to +get the linear address. +The base address is the address the PE image is loaded to, and may vary +from one invocation to the next. + +Example: suppose an executable file is loaded to address 0x400000 and +execution starts at RVA 0x1560. The effective execution start will then +be at the address 0x401560. If the executable were loaded to 0x100000, +the execution start would be 0x101560. + +Things become complicated because the parts of the PE-file (the +sections) are not necessarily aligned the same way the loaded image is. +For example, the sections of the file are often aligned to +512-byte-borders, but the loaded image is perhaps aligned to +4096-byte-borders. See 'SectionAlignment' and 'FileAlignment' below. + +So to find a piece of information in a PE-file for a specific RVA, +you must calculate the offsets as if the file were loaded, but skip +according to the file-offsets. +As an example, suppose you knew the execution starts at RVA 0x1560, and +want to diassemble the code starting there. To find the address in the +file, you will have to find out that sections in RAM are aligned to 4096 +bytes and the ".code"-section starts at RVA 0x1000 in RAM and is 16384 +bytes long; then you know that RVA 0x1560 is at offset 0x560 in that +section. Find out that the sections are aligned to 512-byte-borders in +the file and that ".code" begins at offset 0x800 in the file, and you +know that the code execution start is at byte 0x800+0x560=0xd60 in the +file. + +Then you disassemble and find an access to a variable at the linear +address 0x1051d0. The linear address will be relocated upon loading the +binary and is given on the assumption that the preferred load address is +used. You find out that the preferred load address is 0x100000, so we +are dealing with RVA 0x51d0. This is in the data section which starts at +RVA 0x5000 and is 2048 bytes long. It begins at file offset 0x4800. +Hence. the veriable can be found at file offset +0x4800+0x51d0-0x5000=0x49d0. + + +Optional Header +--------------- + +Immediatly following the file header is the IMAGE_OPTIONAL_HEADER +(which, in spite of the name, is always there). It contains +information about how to treat the PE-file exactly. We'll also have the +members from top to bottom. + +The first 16-bit-word is 'Magic' and has, as far as I looked into +PE-files, always the value 0x010b. + +The next 2 bytes are the version of the linker ('MajorLinkerVersion' and +'MinorLinkerVersion') that produced the file. These values, again, are +unreliable and do not always reflect the linker version properly. +(Several linkers simply don't set this field.) +And, coming to think about it, what good is the version if you have got +no idea *which* linker was used? + +The next 3 longwords (32 bit each) are intended to be the size of the +executable code ('SizeOfCode'), the size of the initialized data +('SizeOfInitializedData', the so-called "data segment"), and the size of +the uninitialized data ('SizeOfUninitializedData', the so-called "bss +segment"). These values are, again, unreliable (e.g. the data segment +may actually be split into several segments by the compiler or linker), +and you get better sizes by inspecting the 'sections' that follow the +optional header. + +Next is a 32-bit-value that is a RVA. This RVA is the offset to the +codes's entry point ('AddressOfEntryPoint'). +Execution starts here; it is e.g. the address of a DLL's LibMain() or a +program's startup code (which will in turn call main()) or a driver's +DriverEntry(). If you dare to load the image "by hand", you call this +address to start the process after you have done all the fixups and the +relocations. + +The next 2 32-bit-values are the offsets to the executable code +('BaseOfCode') and the initialized data ('BaseOfData'), both of them +RVAs again, and both of them being of little interest because you get +more reliable information by inspecting the 'sections' that follow the +headers. +There is no offset to the uninitialized data because, being +uninitialized, there is little point in providing this data in the +image. + +The next entry is a 32-bit-value giving the preferred (linear) load +address ('ImageBase') of the entire binary, including all headers. This +is the address (always a multiple of 64 KB) the file has been relocated +to by the linker; if the binary can in fact be loaded to that address, +the loader doesn't need to relocate the file again, which is a win in +loading time. +The preferred load address can not be used if another image has already +been loaded to that address (an "address clash", which happens quite +often if you load several DLLs that are all relocated to the linker's +default), or the memory in question has been used for other purposes +(stack, malloc(), uninitialized data, whatever). In these cases, the +image must be loaded to some other address and it needs to be relocated +(see 'relocation directory' below). This has further consequences if the +image is a DLL, because then the "bound imports" are no longer valid, +and fixups have to be made to the binary that uses the DLL - see 'import +directory' below. + +The next 2 32-bit-values are the alignments of the PE-file's sections in +RAM ('SectionAlignment', when the image has been loaded) and in the file +('FileAlignment'). Usually both values are 32, or FileAlignment is 512 +and SectionAlignment is 4096. Sections will be discussed later. + +The next 2 16-bit-words are the expected operating system version +('MajorOperatingSystemVersion' and 'MinorOperatingSystemVersion' [they +_do_ like self-documenting names at MS]). This version information is +intended to be the operating system's (e.g. NT or Win95) version, as +opposed to the subsystem's version (e.g. Win32); it is often not +supplied, or wrong supplied. The loader doesn't use it, apparently. + +The next 2 16-bit-words are the binary's version, ('MajorImageVersion' and +'MinorImageVersion'). Many linkers don't set this information correctly +and many programmers don't bother to supply it, so it is better to rely +on the version-resource if one exists. + +The next 2 16-bit-words are the expected subsystem version +('MajorSubsystemVersion' and 'MinorSubsystemVersion'). This should be +the Win32 version or the POSIX version, because 16-bit-programs or +OS/2-programs won't be in PE-format, obviously. +This subsystem version should be supplied correctly, because it *is* +checked and used: +If the application is a Win32-GUI-application and runs on NT4, and the +subsystem version is *not* 4.0, the dialogs won't be 3D-style and +certain other features will also work "old-style" because the +application expects to run on NT 3.51, which had the program manager +instead of explorer and so on, and NT 4.0 will mimic that behaviour as +faithfully as possible. + +Then we have a 'Win32VersionValue' of 32 bits. I don't know what it is +good for. It has been 0 in all the PE files that I inspected. + +Next is a 32-bits-value giving the amount of memory the image will need, +in bytes ('SizeOfImage'). It is the sum of all headers' and sections' +lengths if aligned to 'SectionAlignment'. It is a hint to the loader how +many pages it will need in order to load the image. + +The next thing is a 32-bit-value giving the total length of all headers +including the data directories and the section headers +('SizeOfHeaders'). It is at the same time the offset from the beginning +of the file to the first section's raw data. + +Then we have got a 32-bit-checksum ('CheckSum'). This checksum is, for +current versions of NT, only checked if the image is a NT-driver (the +driver will fail to load if the checksum isn't correct). For other +binary types, the checksum need not be supplied and may be 0. +The algorithm to compute the checksum is property of Microsoft, and they +won't tell you. However, several tools of the Win32 SDK will compute +and/or patch a valid checksum, and the function CheckSumMappedFile() in +the imagehelp.dll will do so too. +The checksum is supposed to prevent loading of damaged binaries that +would crash anyway - and a crashing driver would result in a BSOD, so +it is better not to load it at all. + +Then there is a 16-bit-word 'Subsystem' that tells in which of the +NT-subsystems the image runs: + + IMAGE_SUBSYSTEM_NATIVE (1) + The binary doesn't need a subsystem. This is used for drivers. + + IMAGE_SUBSYSTEM_WINDOWS_GUI (2) + The image is a Win32 graphical binary. (It can still open a + console with AllocConsole() but won't get one automatically at + startup.) + + IMAGE_SUBSYSTEM_WINDOWS_CUI (3) + The binary is a Win32 console binary. (It will get a console + per default at startup, or inherit the parent's console.) + + IMAGE_SUBSYSTEM_OS2_CUI (5) + The binary is a OS/2 console binary. (OS/2 binaries will be in + OS/2 format, so this value will seldom be used in a PE file.) + + IMAGE_SUBSYSTEM_POSIX_CUI (7) + The binary uses the POSIX console subsystem. + +Windows 95 binaries will always use the Win32 subsystem, so the only +legal values for these binaries are 2 and 3; I don't know if "native" +binaries on windows 95 are possible. + +The next thing is a 16-bit-value that tells, if the image is a DLL, when +to call the DLL's entry point ('DllCharacteristics'). This seems not to +be used; apparently, the DLL is always notified about everything. + If bit 0 is set, the DLL is notified about process attachment (i.e. + DLL load). + If bit 1 is set, the DLL is notified about thread detachments (i.e. + thread terminations). + If bit 2 is set, the DLL is notified about thread attachments (i.e. + thread creations). + If bit 3 is set, the DLL is notified about process detachment (i.e. + DLL unload). + +The next 4 32-bit-values are the size of reserved stack +('SizeOfStackReserve'), the size of initially committed stack +('SizeOfStackCommit'), the size of the reserved heap +('SizeOfHeapReserve') and the size of the committed heap +('SizeOfHeapCommit'). +The 'reserved' amounts are address space (not real RAM) that is reserved +for the specific purpose; at program startup, the 'committed' amount is +actually allocated in RAM. The 'committed' value is also the amount by +which the committed stack or heap grows if necessary. (Other sources +claim that the stack will grow in pages, regardless of the +'SizeOfStackCommit' value. I didn't check this.) +So, as an example, if a program has a reserved heap of 1 MB and a +committed heap of 64 KB, the heap will start out at 64 KB and is +guaranteed to be enlargeable up to 1 MB. The heap will grow in +64-KB-chunks. +The 'heap' in this context is the primary (default) heap. A process can +create more heaps if so it wishes. +The stack is the first thread's stack (the one that starts main()). The +process can create more threads which will have their own stacks. +DLLs don't have a stack or heap of their own, so the values are ignored +for their images. I don't know if drivers have a heap or a stack of +their own, but I don't think so. + +After these stack- and heap-descriptions, we find 32 bits of +'LoaderFlags', which I didn't find a useful description of. I only found +a vague note about setting bits that automatically invoke a breakpoint +or a debugger after loading the image; however, this doesn't seem to +work. + +Then we find 32 bits of 'NumberOfRvaAndSizes', which is the number of +valid entries in the directories that follow immediatly. I've found this +value to be unreliable; you might wish use the constant +IMAGE_NUMBEROF_DIRECTORY_ENTRIES instead, or the lesser of both. + +After the 'NumberOfRvaAndSizes' there is an array of +IMAGE_NUMBEROF_DIRECTORY_ENTRIES (16) IMAGE_DATA_DIRECTORYs. +Each of these directories describes the location (32 bits RVA called +'VirtualAddress') and size (also 32 bit, called 'Size') of a particular +piece of information, which is located in one of the sections that +follow the directory entries. +For example, the security directory is found at the RVA and has the size +that are given at index 4. +The directories that I know the structure of will be discussed later. +Defined directory indexes are: + + IMAGE_DIRECTORY_ENTRY_EXPORT (0) + The directory of exported symbols; mostly used for DLLs. + Described below. + + IMAGE_DIRECTORY_ENTRY_IMPORT (1) + The directory of imported symbols; see below. + + IMAGE_DIRECTORY_ENTRY_RESOURCE (2) + Directory of resources. Described below. + + IMAGE_DIRECTORY_ENTRY_EXCEPTION (3) + Exception directory - structure and purpose unknown. + + IMAGE_DIRECTORY_ENTRY_SECURITY (4) + Security directory - structure and purpose unknown. + + IMAGE_DIRECTORY_ENTRY_BASERELOC (5) + Base relocation table - see below. + + IMAGE_DIRECTORY_ENTRY_DEBUG (6) + Debug directory - contents is compiler dependent. Moreover, many + compilers stuff the debug information into the code section and + don't create a separate section for it. + + IMAGE_DIRECTORY_ENTRY_COPYRIGHT (7) + Description string - some arbitrary copyright note or the like. + + IMAGE_DIRECTORY_ENTRY_GLOBALPTR (8) + Machine Value (MIPS GP) - structure and purpose unknown. + + IMAGE_DIRECTORY_ENTRY_TLS (9) + Thread local storage directory - structure unknown; contains + variables that are declared "__declspec(thread)", i.e. + per-thread global variables. + + IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG (10) + Load configuration directory - structure and purpose unknown. + + IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT (11) + Bound import directory - see description of import directory. + + IMAGE_DIRECTORY_ENTRY_IAT (12) + Import Address Table - see description of import directory. + +As an example, if we find at index 7 the 2 longwords 0x12000 and 33, and +the load address is 0x10000, we know that the copyright data is at +address 0x10000+0x12000 (in whatever section there may be), and the +copyright note is 33 bytes long. +If a directory of a particular type is not used in a binary, the Size +and VirtualAddress are both 0. + + + +Section directories +------------------- + +The sections consist of two major parts: first, a section description +(of type IMAGE_SECTION_HEADER) and then the raw section data. So after +the data directories we find an array of 'NumberOfSections' section +headers, ordered by the sections' RVAs. + +A section header contains: + +An array of IMAGE_SIZEOF_SHORT_NAME (8) bytes that make up the name +(ASCII) of the section. If all of the 8 bytes are used there is no 0- +terminator for the string! The name is typically something like ".data" +or ".text" or ".bss". There need not be a leading '.', the names may +also be "CODE" or "IAT" or the like. +Please note that the names are not at all related to the contents of the +section. A section named ".code" may or may not contain the executable +code; it may just as well contain the import address table; it may also +contain the code *and* the address table *and* the initialized data. +To find information in the sections, you will have to look it up via the +data directories of the optional header. Do not rely on the names, and +do not assume that the section's raw data starts at the beginning of a +section. + +The next member of the IMAGE_SECTION_HEADER is a 32-bit-union of +'PhysicalAddress' and 'VirtualSize'. In an object file, this is the +address the contents is relocated to; in an executable, it is the size of +the contents. In fact, the field seems to be unused; There are linkers +that enter the size, and there are linkers that enter the address, and +I've also found a linker that enters a 0, and all the executables run +like the gentle wind. + +The next member is 'VirtualAddress', a 32-bit-value holding the RVA to +the section's data when it is loaded in RAM. + +Then we have got 32 bits of 'SizeOfRawData', which is the size of the +secion's data rounded up to the next multiple of 'FileAlignment'. + +Next is 'PointerToRawData' (32 bits), which is incredibly useful because +it is the offset from the file's beginning to the section's data. If it +is 0, the section's data are not contained in the file and will be +arbitrary at load time. + +Then we have got 'PointerToRelocations' (32 bits) and +'PointerToLinenumbers' (also 32 bits), 'NumberOfRelocations' (16 bits) +and 'NumberOfLinenumbers' (also 16 bits). All of these are information +that's only used for object files. Executables have a special base +relocation directory, and the line number information, if present at +all, is usually contained in a special purpose debugging segment or +elsewhere. + +The last member of a section header is the 32 bits 'Characteristics', +which is a bunch of flags describing how the section's memory should be +treated: + + If bit 5 (IMAGE_SCN_CNT_CODE) is set, the section contains + executable code. + + If bit 6 (IMAGE_SCN_CNT_INITIALIZED_DATA) is set, the section + contains data that gets a defined value before execution starts. In + other words: the section's data in the file is meaningful. + + If bit 7 (IMAGE_SCN_CNT_UNINITIALIZED_DATA) is set, this section + contains uninitialized data and will be initialized to all-0-bytes + before execution starts. This is normally the BSS. + + If bit 9 (IMAGE_SCN_LNK_INFO) is set, the section doesn't contain + image data but comments, description or other documentation. This + information is part of an object file and may be information for the + linker, such as which libraries are needed. + + If bit 11 (IMAGE_SCN_LNK_REMOVE) is set, the data is part of an + object file's section that is supposed to be left out when the + executable file is linked. Often combined with bit 9. + + If bit 12 (IMAGE_SCN_LNK_COMDAT) is set, the section contains + "common block data", which are packaged functions of some sort. + + If bit 15 (IMAGE_SCN_MEM_FARDATA) is set, we have far data - + whatever that means. This bit's meaning is unsure. + + If bit 17 (IMAGE_SCN_MEM_PURGEABLE) is set, the section's data + is purgeable - but I don't think that this is the same as + "discardable", which has a bit of its own, see below. + The same bit is apparently used to indicate 16-bit-information as + there is also a define IMAGE_SCN_MEM_16BIT for it. + This bit's meaning is unsure. + + If bit 18 (IMAGE_SCN_MEM_LOCKED) is set, the section should not be + moved in memory? Perhaps it indicates there is no relocation + information? This bit's meaning is unsure. + + If bit 19 (IMAGE_SCN_MEM_PRELOAD) is set, the section should be + paged in before execution starts? This bit's meaning is unsure. + + Bits 20 to 23 specify an alignment that I have no information + about. There are #defines IMAGE_SCN_ALIGN_16BYTES and the like. The + only value I've ever seen used is 0, for the default 16-byte- + alignment. I suspect that this is the alignment of objects in a + library file or the like. + + If bit 24 (IMAGE_SCN_LNK_NRELOC_OVFL) is set, the section contains + some extended relocations that I don't know about. + + If bit 25 (IMAGE_SCN_MEM_DISCARDABLE) is set, the section's data is + not needed after the process has started. This is the case, + for example, with the relocation information. I've seen it also for + startup routines of drivers and services that are only executed + once, and for import directories. + + If bit 26 (IMAGE_SCN_MEM_NOT_CACHED) is set, the section's data + should not be cached. Don't ask my why not. Does this mean to switch + off the 2nd-level-cache? + + If bit 27 (IMAGE_SCN_MEM_NOT_PAGED) is set, the section's data + should not be paged out. This is interesting for drivers. + + If bit 28 (IMAGE_SCN_MEM_SHARED) is set, the section's data is + shared among all running instances of the image. If it is e.g. the + initialized data of a DLL, all running instances of the DLL will at + any time have the same variable contents. + Note that only the first instance's section is initialized. + Sections containing code are always shared copy-on-write (i.e. the + sharing doesn't work if relocations are necessary). + + If bit 29 (IMAGE_SCN_MEM_EXECUTE) is set, the process gets + 'execute'-access to the section's memory. + + If bit 30 (IMAGE_SCN_MEM_READ) is set, the process gets + 'read'-access to the section's memory. + + If bit 31 (IMAGE_SCN_MEM_WRITE) is set, the process gets + 'write'-access to the section's memory. + + + +After the section headers we find the sections themselves. They are, in +the file, aligned to 'FileAlignment' bytes (that is, after the optional +header and after each section's data there will be padding bytes) and +ordered by their RVAs. When loaded (in RAM), the sections are aligned to +'SectionAlignment' bytes. + +As an example, if the optional header ends at file offset 981 and +'FileAlignment' is 512, the first section will start at byte 1024. Note +that you can find the sections via the 'PointerToRawData' or the +'VirtualAddress', so there is hardly any need to actually fuss around +with the alignments. + + +I will try to make an image of it all: + + + +-------------------+ + | DOS-stub | + +-------------------+ + | file-header | + +-------------------+ + | optional header | + |- - - - - - - - - -| + | |----------------+ + | data directories | | + | | | + |(RVAs to direc- |-------------+ | + |tories in sections)| | | + | |---------+ | | + | | | | | + +-------------------+ | | | + | |-----+ | | | + | section headers | | | | | + | (RVAs to section |--+ | | | | + | borders) | | | | | | + +-------------------+<-+ | | | | + | | | <-+ | | + | section data 1 | | | | + | | | <-----+ | + +-------------------+<----+ | + | | | + | section data 2 | | + | | <--------------+ + +-------------------+ + +There is one section header for each section, and each data directory +will point to one of the sections (several data directories may point to +the same section, and there may be sections without data directory +pointing to them). + + + +Sections' raw data +------------------ + + +general +------- +All sections are aligned to 'SectionAlignment' when loaded in RAM, and +'FileAlignment' in the file. The sections are described by entries in +the section headers: You find the sections in the file via +'PointerToRawData' and in memory via 'VirtualAddress'; the length is in +'SizeOfRawData'. + +There are several kinds of sections, depending on what's contained in +them. In most cases (but not in all) there will be at least one +data directory in a section, with a pointer to it in the optional +header's data directory array. + + +code section +------------ +First, I will mention the code section. The section will have, at least, +the bits 'IMAGE_SCN_CNT_CODE', 'IMAGE_SCN_MEM_EXECUTE' and +'IMAGE_SCN_MEM_READ' set, and 'AddressOfEntryPoint' will point somewhere +into the section, to the start of the function that the developer wants +to execute first. +'BaseOfCode' will normally point to the start of this section, but may +point to somewhere later in the section if some non-code-bytes are +placed before the code in the section. +Normally, there will be nothing but executable code in this section, and +there will be only one code section, but don't rely on this. +Typical section names are ".text", ".code", "AUTO" and the like. + + +data section +------------ +The next thing we'll discuss is the initialized variables; this section +contains initialized static variables (like "static int i = 5;"). It will +have, at least, the bits 'IMAGE_SCN_CNT_INITIALIZED_DATA', +'IMAGE_SCN_MEM_READ' and 'IMAGE_SCN_MEM_WRITE' set. Some linkers may +place constant data into a section of their own that doesn't have the +writeable-bit. If part of the data is shareable, or there are other +peculiarities, there may be more sections with the apropriate section- +bits set. +The section, or sections, will be in the range 'BaseOfData' up to +'BaseOfData'+'SizeOfInitializedData'. +Typical section names are '.data', '.idata', 'DATA' and so on. + + +bss section +----------- +Then there is the uninitialized data (for static variables like "static +int k;"); this section is quite like the initialized data, but will have +a file offset ('PointerToRawData') of 0 indicating its contents is not +stored in the file, and 'IMAGE_SCN_CNT_UNINITIALIZED_DATA' is set +instead of 'IMAGE_SCN_CNT_INITIALIZED_DATA' to indicate that the +contents should be set to 0-bytes at load-time. This means, there is a +section header but no section in the file; the section will be created +by the loader and consist entirely of 0-bytes. +The length will be 'SizeOfUninitializedData'. +Typical names are '.bss', 'BSS' and the like. + +These were the section data that are *not* pointed to by data +directories. Their contents and structure is supplied by the compiler, +not by the linker. +(The stack-segment and heap-segment are not sections in the binary but +created by the loader from the stacksize- and heapsize-entries in the +optional header.) + + +copyright +--------- +To begin with a simple directory-section, let's look at the data +directory 'IMAGE_DIRECTORY_ENTRY_COPYRIGHT'. The contents is a +copyright- or description string in ASCII (not 0-terminated), like +"Gonkulator control application, copyright (c) 1848 Hugendubel & Cie". +This string is, normally, supplied to the linker with the command line +or a description file. +This string is not needed at runtime and may be discarded. It is not +writeable; in fact, the application doesn't need access at all. +So the linker will find out if there is a discardable non-writeable +section already and if not, create one (named '.descr' or the like). It +will then stuff the string into the section and let the +copyright-directory-pointer point to the string. The +'IMAGE_SCN_CNT_INITIALIZED_DATA' bit should be set. + + +exported symbols +---------------- +(Note that the description of the export directory was faulty in versions +of this text before 1999-03-12. It didn't describe forwarders, exports +by ordinal only, or exports with several names.) + +The next-simplest thing is the export directory, +'IMAGE_DIRECTORY_ENTRY_EXPORT'. This is a directory typically found +in DLLs; it contains the entry points of exported functions (and the +addresses of exported objects etc.). Executables may of course also have +exported symbols but usually they don't. +The containing section should be "initialized data" and "readable". It +should not be "discardable" because the process might call +"GetProcAddress()" to find a function's entry point at runtime. +The section is normally called '.edata' if it is a separate thing; often +enough, it is merged into some other section like "initialized data". + +The structure of the export table ('IMAGE_EXPORT_DIRECTORY') comprises a +header and the export data, that is: the symbol names, their ordinals +and the offsets to their entry points. + +First, we have 32 bits of 'Characteristics' that are unused and normally +0. Then there is a 32-bit-'TimeDateStamp', which presumably should give +the time the table was created in the time_t-format; alas, it is not +always valid (some linkers set it to 0). Then we have 2 16-bit-words of +version-info ('MajorVersion' and 'MinorVersion'), and these, too, are +often enough set to 0. + +The next thing is 32 bits of 'Name'; this is an RVA to the DLL name as a +0-terminated ASCII string. (The name is necessary in case the DLL file is +renamed - see "binding" at the import directory.) +Then, we have got a 32-bit-'Base'. We'll come to that in a moment. + +The next 32-bit-value is the total number of exported items +('NumberOfFunctions'). In addition to their ordinal number, items may be +exported by one or several names. and the next 32-bit-number is the +total number of exported names ('NumberOfNames'). +In most cases, each exported item will have exactly one corresponding +name and it will be used by that name, but an item may have several +associated names (it is then accessible by each of them), or it may have +no name, in which case it is only accessible by its ordinal number. The +use of unnamed exports (purely by ordinal) is discouraged, because all +versions of the exporting DLL would have to use the same ordinal +numbering, which is a maintainance problem. + +The next 32-bit-value 'AddressOfFunctions' is a RVA to the list of +exported items. It points to an array of 'NumberOfFunctions' +32-bit-values, each being a RVA to the exported function or variable. + +There are 2 quirks about this list: First, such an exported RVA may be 0, +in which case it is unused. Second, if the RVA points into the section +containing the export directory, this is a forwarded export. A forwarded +export is a pointer to an export in another binary; if it is used, the +pointed-to export in the other binary is used instead. The RVA in this +case points, as mentioned, into the export directory's section, to a +zero-terminated string comprising the name of the pointed-to DLL and +the export name separated by a dot, like "otherdll.exportname", or the +DLL's name and the export ordinal, like "otherdll.#19". + +Now is the time to explain the export ordinal. An export's ordinal is +the index into the AddressOfFunctions-Array (the 0-based position in +this array) plus the 'Base' mentioned above. +In most cases, the 'Base' is 1, which means the first export has an +ordinal of 1, the second has an ordinal of 2 and so on. + +After the 'AddressOfFunctions'-RVA we find a RVA to the array of +32-bit-RVAs to symbol names 'AddressOfNames', and a RVA to the array of +16-bit-ordinals 'AddressOfNameOrdinals'. Both arrays have +'NumberOfNames' elements. +The symbol names may be missing entirely, in which case the +'AddressOfNames' is 0. Otherwise, the pointed-to arrays are running +parallel, which means their elements at each index belong together. The +'AddressOfNames'-array consists of RVAs to 0-terminated export names; +the names are held in a sorted list (i.e. the first array member is the +RVA to the alphabetically smallest name; this allows efficient searching +when looking up an exported symbol by name). +According to the PE specification, the 'AddressOfNameOrdinals'-array has +the ordinal corresponding to each name; however, I've found this array +to contain the actual index into the 'AddressOfFunctions-Array instead. + +I'll draw a picture about the three tables: + + + AddressOfFunctions + | + | + | + v + exported RVA with ordinal 'Base' + exported RVA with ordinal 'Base'+1 + ... + exported RVA with ordinal 'Base'+'NumberOfFunctions'-1 + + + + AddressOfNames AddressOfNameOrdinals + | | + | | + | | + v v + RVA to first name <-> Index of export for first name + RVA to second name <-> Index of export for second name + ... ... + RVA to name 'NumberOfNames' <-> Index of export for name 'NumberOfNames' + + +Some examples are in order. + +To find an exported symbol by ordinal, subtract the 'Base' to get the +index, follow the 'AddressOfFunctions'-RVA to find the exports-array and +use the index to find the exported RVA in the array. If it does not +point into the export section, you are done. Otherwise, it points to a +string describing the exporting DLL and the name or ordinal therein, and +you have to look up the forwarded export there. + +To find an exported symbol by name, follow the 'AddressOfNames'-RVA (if +it is 0 there are no names) to find the array of RVAs to the export +names. Search your name in the list. Use the name's index in the +'AddressOfNameOrdinals'-Array and get the 16-bit-number corresponding to +the found name. According to the PE spec, it is an ordinal and you need +to subtract the 'Base' to get the export index; according to my +experiences it is the export index and you don't subtract. Using the +export index, you find the export RVA in the 'AddressOfFunctions'-Array, +being either the exported RVA itself or a RVA to a string describing a +forwarded export. + + +imported symbols +---------------- +When the compiler finds a call to a function that is in a different +executable (mostly in a DLL), it will, in the most simplistic case, not +know anything about the circumstances and simply output a normal +call-instruction to that symbol, the address of which the linker will +have to fix, like it does for any external symbol. +The linker uses an import library to look up from which DLL which symnol +is imported, and produces stubs for all the imported symbols, each of +which consists of a jump-instruction; the stubs are the actual +call-targets. These jump-instructions will actually jump to an address +that's fetched from the so-called import address table. In more +sophisticated applications (when "__declspec(dllimport)" is used), the +compiler knows the function is imported, and outputs a call to the +address that's in the import address table, bypassing the jump. + +Anyway, the address of the function in the DLL is always necessary and +will be supplied by the loader from the exporting DLL's export directory +when the application is loaded. The loader knows which symbols in what +libraries have to be looked up and their addresses fixed by searching +the import directory. + +I will better give you an example. The calls with or without +__declspec(dllimport) look like this: + + source: + int symbol(char *); + __declspec(dllimport) int symbol2(char*); + void foo(void) + { + int i=symbol("bar"); + int j=symbol2("baz"); + } + + assembly: + ... + call _symbol ; without declspec(dllimport) + ... + call [__imp__symbol2] ; with declspec(dllimport) + ... + +In the first case (without __declspec(dllimport)), the compiler didn't +know that '_symbol' was in a DLL, so the linker has to provide the +function '_symbol'. Since the function isn't there, it will supply a +stub function for the imported symbol, being an indirect jump. The +collection of all import-stubs is called the "transfer area" (also +sometimes called a "trampoline", because you jump there in order to jump +to somewhere else). +Typically this transfer area is located in the code section (it is not +part of the import directory). Each of the function stubs is a jump to +the actual function in the target DLLs. The transfer area looks like +this: + + _symbol: jmp [__imp__symbol] + _other_symbol: jmp [__imp__other__symbol] + ... + + +This means: if you use imported symbols without specifying +"__declspec(dllimport)" then the linker will generate a transfer area +for them, consisting of indirect jumps. If you do specify +"__declspec(dllimport)", the compiler will do the indirection itself and +a transfer area is not necessary. (It also means: if you import +variables or other stuff you must specify "__declspec(dllimport)", +because a stub with a jmp instruction is appropriate for functions +only.) + +In any case the adress of symbol 'x' is stored at a location '__imp_x'. +All these locations together comprise the so-called "import address +table", which is provided to the linker by the import libraries of the +various DLLs that are used. The import address table is a list of +addresses like this: + + __imp__symbol: 0xdeadbeef + __imp__symbol2: 0x40100 + __imp__symbol3: 0x300100 + ... + +This import address table is a part of the import directory, and it is +pointed to by the IMAGE_DIRECTORY_ENTRY_IAT directory pointer (although +some linkers don't set this directory entry and it works nevertheless; +apparently, the loader can resolve imports without using the directory +IMAGE_DIRECTORY_ENTRY_IAT). +The addresses in this table are unknown to the linker; the linker +inserts dummies (RVAs to the function names; see below for more +information) that are patched by the loader at load time using the +export directory of the exporting DLL. The import address table, and how +it is found by the loader, will be described in more detail later in +this chapter. + +Note that this description is C-specific; there are other application +building environments that don't use import libraries. They all need to +generate an import address table, though, which they use to let their +programs access the imported objects and functions. C compilers tend to +use import libraries because it is convenient for them - their linkers +use libraries anyway. Other environments use e.g. a description file +that lists the necessary DLL names and function names (like the "module +definition file"), or a declaration-style list in the source. + + +This is how imports are used by the program's code; now we'll look how +an import directory is made up so the loader can use it. + + +The import directory should reside in a section that's "initialized +data" and "readable". +The import directory is an array of IMAGE_IMPORT_DESCRIPTORs, one for +each used DLL. The list is terminated by a IMAGE_IMPORT_DESCRIPTOR +that's entirely filled with 0-bytes. +An IMAGE_IMPORT_DESCRIPTOR is a struct with these members: + + OriginalFirstThunk + An RVA (32 bit) pointing to a 0-terminated array of RVAs to + IMAGE_THUNK_DATAs, each describing one imported function. The + array will never change. + + TimeDateStamp + A 32-bit-timestamp that has several purposes. Let's pretend that + the timestamp is 0, and handle the advanced cases later. + + ForwarderChain + The 32-bit-index of the first forwarder in the list of imported + functions. Forwarders are also advanced stuff; set to all-bits-1 + for beginners. + + Name + A 32-bit-RVA to the name (a 0-terminated ASCII string) of the + DLL. + + FirstThunk + An RVA (32 bit) to a 0-terminated array of RVAs to + IMAGE_THUNK_DATAs, each describing one imported function. The + array is part of the import address table and will change. + +So each IMAGE_IMPORT_DESCRIPTOR in the array gives you the name of the +exporting DLL and, apart from the forwarder and timestamp, it gives you +2 RVAs to arrays of IMAGE_THUNK_DATAs, using 32 bits. (The last member +of each array is entirely filled with 0-bytes to mark the end.) +Each IMAGE_THUNK_DATA is, for now, an RVA to a IMAGE_IMPORT_BY_NAME +which describes the imported function. +The interesting point is now, the arrays run parallel, i.e.: they point +to the same IMAGE_IMPORT_BY_NAMEs. + +No need to be desparate, I will draw another picture. This is the +essential contents of one IMAGE_IMPORT_DESCRIPTOR: + + OriginalFirstThunk FirstThunk + | | + | | + | | + V V + + 0--> func1 <--0 + 1--> func2 <--1 + 2--> func3 <--2 + 3--> foo <--3 + 4--> mumpitz <--4 + 5--> knuff <--5 + 6-->0 0<--6 /* the last RVA is 0! */ + +where the names in the center are the yet to discuss +IMAGE_IMPORT_BY_NAMEs. Each of them is a 16-bit-number (a hint) followed +by an unspecified amount of bytes, being the 0-terminated ASCII name of +the imported symbol. +The hint is an index into the exporting DLL's name table (see export +directory above). The name at that index is tried, and if it doesn't +match then a binary search is done to find the name. +(Some linkers don't bother to look up correct hints and simply specify +1 all the time, or some other arbitrary number. This doesn't harm, it +just makes the first attempt to resolve the name always fail, enforcing +a binary search for each name.) + +To summarize, if you want to look up information about the imported +function "foo" from DLL "knurr", you first find the entry +IMAGE_DIRECTORY_ENTRY_IMPORT in the data directories, get an RVA, find +that address in the raw section data and now have an array of +IMAGE_IMPORT_DESCRIPTORs. Get the member of this array that relates to +the DLL "knurr" by inspecting the strings pointed to by the 'Name's. +When you have found the right IMAGE_IMPORT_DESCRIPTOR, follow its +'OriginalFirstThunk' and get hold of the pointed-to array of +IMAGE_THUNK_DATAs; inspect the RVAs and find the function "foo". + +Ok, now, why do we have *two* lists of pointers to the +IMAGE_IMPORT_BY_NAMEs? Because at runtime the application doesn't need +the imported functions' names but the addresses. This is where the +import address table comes in again. The loader will look up each +imported symbol in the export-directory of the DLL in question and +replace the IMAGE_THUNK_DATA-element in the 'FirstThunk'-list (which +until now also points to the IMAGE_IMPORT_BY_NAME) with the linear +address of the DLL's entry point. +Remember the list of addresses with labels like "__imp__symbol"; the +import address table, pointed to by the data directory +IMAGE_DIRECTORY_ENTRY_IAT, is exactly the list pointed to by +'FirstThunk'. (In case of imports from several DLLs, the import address +table comprises the 'FirstThunk'-Arrays of all the DLLs. The directory +entry IMAGE_DIRECTORY_ENTRY_IAT may be missing, the imports will still +work fine.) +The 'OriginalFirstThunk'-array remains untouched, so you can always look +up the original list of imported names via the +'OriginalFirstThunk'-list. + +The import is now patched with the correct linear addresses and looks +like this: + + OriginalFirstThunk FirstThunk + | | + | | + | | + V V + + 0--> func1 0--> exported func1 + 1--> func2 1--> exported func2 + 2--> func3 2--> exported func3 + 3--> foo 3--> exported foo + 4--> mumpitz 4--> exported mumpitz + 5--> knuff 5--> exported knuff + 6-->0 0<--6 + + +This was the basic structure, for simple cases. Now we'll learn about +tweaks in the import directories. + +First, the bit IMAGE_ORDINAL_FLAG (that is: the MSB) of the +IMAGE_THUNK_DATA in the arrays can be set, in which case there is no +symbol-name-information in the list and the symbol is imported purely by +ordinal. You get the ordinal by inspecting the lower word of the +IMAGE_THUNK_DATA. +The import by ordinals is discouraged; it is much safer to import by +name, because the export ordinals might change if the exporting DLL is +not in the expected version. + +Second, there are the so-called "bound imports". + +Think about the loader's task: when a binary that it wants to execute +needs a function from a DLL, the loader loads the DLL, finds its export +directory, looks up the function's RVA and calculates the function's +entry point. Then it patches the so-found address into the 'FirstThunk'- +list. +Given that the programmer was clever and supplied unique preferred load +addresses for the DLLs that don't clash, we can assume that the +functions' entry points will always be the same. They can be computed +and patched into the 'FirstThunk'-list at link-time, and that's what +happens with the "bound imports". (The utility "bind" does this; it is +part of the Win32 SDK.) + +Of course, one must be cautious: The user's DLL may have a different +version, or it may be necessary to relocate the DLL, thus invalidating +the pre-patched 'FirstThunk'-list; in this case, the loader will still +be able to walk the 'OriginalFirstThunk'-list, find the imported symbols +and re-patch the 'FirstThunk'-list. The loader knows that this is +necessary if a) the versions of the exporting DLL don't match or b) the +exporting DLL had to be relocated. + +To decide whether there were relocations is no problem for the loader, +but how to find out if the versions differ? This is where the +'TimeDateStamp' of the IMAGE_IMPORT_DESCRIPTOR comes in. If it is 0, the +import-list has not been bound, and the loader must fix the entry points +always. Otherwise, the imports are bound, and 'TimeDateStamp' must match +the 'TimeDateStamp' of the exporting DLL's 'FileHeader'; if it doesn't +match, the loader assumes that the binary is bound to a "wrong" DLL and +will re-patch the import list. + +There is an additional quirk about "forwarders" in the import-list. A DLL +can export a symbol that's not defined in the DLL but imported from +another DLL; such a symbol is said to be forwarded (see the export +directory description above). +Now, obviously you can't tell if the symbol's entry point is valid by +looking into the timestamp of a DLL that doesn't actually contain the +entry point. So the forwarded symbols' entry points must always be fixed +up, for safety reasons. In the import list of a binary, imports of +forwarded symbols need to be found so the loader can patch them. + +This is done via the 'ForwarderChain'. It is an index into the thunk- +lists; the import at the indexed position is a forwarded export, and the +contents of the 'FirstThunk'-list at this position is the index of the +*next* forwarded import, and so on, until the index is "-1" which +indicates there are no more forwards. If there are no forwarders at all, +'ForwarderChain' is -1 itself. + +This was the so-called "old-style" binding. + +At this point, we should sum up what we have had so far :-) + +Ok, I will assume you have found the IMAGE_DIRECTORY_ENTRY_IMPORT and you have +followed it to find the import-directory, which will be in one of the +sections. Now you're at the beginning of an array of +IMAGE_IMPORT_DESCRIPTORs the last of which will be entirely 0-bytes- +filled. +To decipher one of the IMAGE_IMPORT_DESCRIPTORs, you first look into the +'Name'-field, follow the RVA and thusly find the name of the exporting +DLL. Next you decide whether the imports are bound or not; +'TimeDateStamp' will be non-zero if the imports are bound. If they are +bound, now is a good time to check if the DLL version matches yours by +comparing the 'TimeDateStamp's. +Now you follow the 'OriginalFirstThunk'-RVA to go to the +IMAGE_THUNK_DATA-array; walk down this array (it is be 0-terminated), +and each member will be the RVA of a IMAGE_IMPORT_BY_NAME (unless the +hi-bit is set in which case you don't have a name but are left with a +mere ordinal). Follow the RVA, and skip 2 bytes (the hint), and now +you have got a 0-terminated ASCII-string that's the name of the imported +function. +To find the supplied entry point addresses in case it is a bound import, +follow the 'FirstThunk' and walk it parallel to the +'OriginalFirstThunk'-array; the array-members are the linear addresses +of the entry points (leaving aside the forwarders-topic for a moment). + +There is one thing I didn't mention until now: Apparently there are +linkers that exhibit a bug when they build the import directory (I've +found this bug being in use by a Borland C linker). These linkers set +the 'OriginalFirstThunk' in the IMAGE_IMPORT_DESCRIPTOR to 0 and create +only the 'FirstThunk'-array. Obviously, such import directories cannot +be bound (else the necessary information to re-fix the imports were +lost - you couldn't find the function names). In this case, you will +have to follow the 'FirstThunk'-array to get the imported symbol names, +and you will never have pre-patched entry point addresses. I have found +a TIS document ([6]) describing the import directory in a way that is +compatible to this bug, so that paper may be the origin of the bug. +The TIS document specifies: + IMPORT FLAGS + TIME/DATE STAMP + MAJOR VERSION - MINOR VERSION + NAME RVA + IMPORT LOOKUP TABLE RVA + IMPORT ADDRESS TABLE RVA +as opposed to the structure used elsewhere: + OriginalFirstThunk + TimeDateStamp + ForwarderChain + Name + FirstThunk + +The last tweak about the import directories is the so-called "new style" +binding (it is described in [3]), which can also be done with the +"bind"-utility. When this is used, the 'TimeDateStamp' is set to +all-bits-1 and there is no forwarderchain; all imported symbols get their +address patched, whether they are forwarded or not. Still, you need to +know the DLLs' version, and you need to distinguish forwarded symbols +from ordinary ones. For this purpose, the +IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT directory is created. This will, as +far as I could find out, *not* be in a section but in the header, after +the section headers and before the first section. (Hey, I didn't invent +this, I'm only describing it!) +This directory tells you, for each used DLL, from which other DLLs there +are forwarded exports. +The structure is an IMAGE_BOUND_IMPORT_DESCRIPTOR, comprising (in this +order): +A 32-bit number, giving you the 'TimeDateStamp' of the DLL; +a 16-bit-number 'OffsetModuleName', being the offset from the beginning +of the directory to the 0-terminated name of the DLL; +a 16-bit-number 'NumberOfModuleForwarderRefs' giving you the number of +DLLs that this DLL uses for its forwarders. + +Immediatly following this struct you find 'NumberOfModuleForwarderRefs' +structs that tell you the names and versions of the DLLs that this DLL +forwards from. These structs are 'IMAGE_BOUND_FORWARDER_REF's: +A 32-bit-number 'TimeDateStamp'; +a 16-bit-number 'OffsetModuleName', being the offset from the beginning +of the directory to the 0-terminated name of the forwarded-from DLL; +16 unused bits. + +Following the 'IMAGE_BOUND_FORWARDER_REF's is the next +'IMAGE_BOUND_IMPORT_DESCRIPTOR' and so on; the list is terminated by an +all-0-bits-IMAGE_BOUND_IMPORT_DESCRIPTOR. + + +Sorry for the inconvenience, but that's what it looks like :-) + + +Now, if you have a new-bound import directory, you load all the DLLs, +use the directory pointer IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT to find the +IMAGE_BOUND_IMPORT_DESCRIPTOR, scan through it and check if the +'TimeDateStamp's of the loaded DLLs match the ones given in this +directory. If not, fix them in the 'FirstThunk'-array of the import +directory. + + + +resources +--------- +The resources, such as dialog boxes, menus, icons and so on, are stored +in the data directory pointed to by IMAGE_DIRECTORY_ENTRY_RESOURCE. It +is in a section that has, at least, the bits +'IMAGE_SCN_CNT_INITIALIZED_DATA' and 'IMAGE_SCN_MEM_READ' set. + +A resource base is a 'IMAGE_RESOURCE_DIRECTORY'; it contains several +'IMAGE_RESOURCE_DIRECTORY_ENTRY's each of which in turn may point to a +'IMAGE_RESOURCE_DIRECTORY'. This way, you get a tree of +'IMAGE_RESOURCE_DIRECTORY's with 'IMAGE_RESOURCE_DIRECTORY_ENTRY's as +leafs; these leafs point to the actual resource data. + +In real life, the situation is somewhat relaxed. Normally you won't find +convoluted trees you can't possibly sort out. +The hierarchy is, normally, like this: one directory is the root. It +points to directories, one for each resource type. These directories +point to subdirectories, each of which will have a name or an ID and +point to a directory of the languages provided for this resource; for +each language you will find one resource entry, which will finally point +to the data. (Note that multi-language-resources don't work on +Win95, which always uses the same resource if it is available in several +languages - I didn't check which one, but I guess it's the first it +encounters. They do work on NT.) + +The tree, without the pointer to the data, may look like this: + + (root) + | + +----------------+------------------+ + | | | + menu dialog icon + | | | + +-----+-----+ +-+----+ +-+----+----+ + | | | | | | | + "main" "popup" 0x10 "maindlg" 0x100 0x110 0x120 + | | | | | | | + +---+-+ | | | | | | + | | default english default def. def. def. +german english + + +A IMAGE_RESOURCE_DIRECTORY comprises: +32 bits of unused flags called 'Characteristics'; +32 bits 'TimeDateStamp' (again in the common time_t representation), +giving you the time the resource was created (if the entry is set); +16 bits 'MajorVersion' and 16 bits 'MinorVersion', thusly allowing you +to maintain several versions of the resource; +16 bits 'NumberOfNamedEntries' and another 16 bits 'NumberOfIdEntries'. + +Immediatly following such a structure are +'NumberOfNamedEntries'+'NumberOfIdEntries' structs which are of the +format 'IMAGE_RESOURCE_DIRECTORY_ENTRY', those with the names coming first. +They may point to further 'IMAGE_RESOURCE_DIRECTORY's or they point to +the actual resource data. +A IMAGE_RESOURCE_DIRECTORY_ENTRY consists of: +32 bits giving you the id of the resource or the directory it describes; +32 bits offset to the data or offset to the next sub-directory. + +The meaning of the id depends on the level in the tree; the id may be a +number (if the hi-bit is clear) or a name (if the hi-bit is set). If it +is a name, the lower 31 bits are the offset from the beginning of the +resource section's raw data to the name (the name consists of 16 bits +length and trailing wide characters, in unicode, not 0-terminated). + +If you are in the root-directory, the id, if it is a number, is the +resource-type: + 1: cursor + 2: bitmap + 3: icon + 4: menu + 5: dialog + 6: string table + 7: font directory + 8: font + 9: accelerators + 10: unformatted resource data + 11: message table + 12: group cursor + 14: group icon + 16: version information +Any other number is user-defined. Any resource-type with a type-name is +always user-defined. + +If you are one level deeper, the id is the resource-id (or resource- +name). + +If you are another level deeper, the id must be a number, and it is the +language-id of the specific instance of the resource; for example, you +can have the same dialog in australian english, canadian french and +swiss german localized forms, and they all share the same resource-id. +The system will choose the dialog to load based on the thread's locale, +which in turn will usually reflect the user's "regional setting". +(If the resource cannot be found for the thread locale, the system will +first try to find a resource for the locale using a neutral sublanguage, +e.g. it will look for standard french instead of the user's canadian +french; if it still can't be found, the instance with the smallest +language id will be used. As noted, all this works only on NT.) +To decipher the language id, split it into the primary language id and +the sublanguage id using the macros PRIMARYLANGID() and SUBLANGID(), +giving you the bits 0 to 9 or 10 to 15, respectivly. The values are +defined in the file "winresrc.h". +Language-resources are only supported for accelerators, dialogs, menus, +rcdata or stringtables; other resource-types should be +LANG_NEUTRAL/SUBLANG_NEUTRAL. + +To find out whether the next level below a resource directory is another +directory, you inspect the hi-bit of the offset. If it is set, the +remaining 31 bits are the offset from the beginning of the resource +section's raw data to the next directory, again in the format +IMAGE_RESOURCE_DIRECTORY with trailing IMAGE_RESOURCE_DIRECTORY_ENTRYs. + +If the bit is clear, the offset is the distance from the beginning of +the resource section's raw data to the resource's raw data description, +a IMAGE_RESOURCE_DATA_ENTRY. It consists of 32 bits 'OffsetToData' (the +offset to the raw data, counting from the beginning of the resource +section's raw data), 32 bits of 'Size' of the data, 32 bits 'CodePage' +and 32 unused bits. +(The use of codepages is discouraged, you should use the 'language'- +feature to support multiple locales.) + + +The raw data format depends on the resource type; descriptions can be +found in the MS SDK documentation. Note that any string in resources is +always in UNICODE except for user defined resources, which are in the +format the developer chooses, obviously. + + +relocations +----------- +The last data directory I will describe is the base relocation +directory. It is pointed to by the IMAGE_DIRECTORY_ENTRY_BASERELOC entry +in the data directories of the optional header. It is typically +contained in a section if its own, with a name like ".reloc" and the +bits IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE and +IMAGE_SCN_MEM_READ set. + +The relocation data is needed by the loader if the image cannot be +loaded to the preferred load address 'ImageBase' mentioned in the +optional header. In this case, the fixed addresses supplied by the +linker are no longer valid, and the loader has to apply fixups for +absolute addresses used for locations of static variables, string +literals and so on. + +The relocation directory is a sequence of chunks. Each chunk contains +the relocation information for 4 KB of the image. A chunk starts with a +'IMAGE_BASE_RELOCATION' struct. It consists of 32 bits 'VirtualAddress' +and 32 bits 'SizeOfBlock'. It is followed by the chunk's actual +relocation data, being 16 bits each. +The 'VirtualAddress' is the base RVA that the relocations of this chunk +need to be applied to; the 'SizeOfBlock' is the size of the entire chunk +in bytes. +The number of trailing relocations is +('SizeOfBlock'-sizeof(IMAGE_BASE_RELOCATION))/2 +The relocation information ends when you encounter a +IMAGE_BASE_RELOCATION struct with a 'VirtualAddress' of 0. + +Each 16-bit-relocation information consists of the relocation position +in the lower 12 bits and a relocation type in the high 4 bits. To get +the relocation RVA, you need to add the IMAGE_BASE_RELOCATION's +'VirtualAddress' to the 12-bit-position. The type is one of: + IMAGE_REL_BASED_ABSOLUTE (0) + This is a no-op; it is used to align the chunk to a 32-bits- + border. The position should be 0. + IMAGE_REL_BASED_HIGH (1) + The high 16 bits of the relocation must be applied to the 16 + bits of the WORD pointed to by the offset, which is the high + word of a 32-bit-DWORD. + IMAGE_REL_BASED_LOW (2) + The low 16 bits of the relocation must be applied to the 16 + bits of the WORD pointed to by the offset, which is the low + word of a 32-bit-DWORD. + IMAGE_REL_BASED_HIGHLOW (3) + The entire 32-bit-relocation must be applied to the entire 32 + bits in question. This (and the no-op '0') is the only + relocation type I've actually found in binaries. + IMAGE_REL_BASED_HIGHADJ (4) + This is one for the tough. Read yourself (from [6]) and make + sense out of it if you can: + "Highadjust. This fixup requires a full 32-bit value. The high + 16-bits is located at Offset, and the low 16-bits is located in + the next Offset array element (this array element is included in + the Size field). The two need to be combined into a signed + variable. Add the 32-bit delta. Then add 0x8000 and store the + high 16-bits of the signed variable to the 16-bit field at + Offset." + IMAGE_REL_BASED_MIPS_JMPADDR (5) + Unknown + IMAGE_REL_BASED_SECTION (6) + Unknown + IMAGE_REL_BASED_REL32 (7) + Unknown + +As an example, if you find the relocation information to be + 0x00004000 (32 bits, starting RVA) + 0x00000010 (32 bits, size of chunk) + 0x3012 (16 bits reloc data) + 0x3080 (16 bits reloc data) + 0x30f6 (16 bits reloc data) + 0x0000 (16 bits reloc data) + 0x00000000 (next chunk's RVA) + 0xff341234 +you know the first chunk describes relocations starting at RVA 0x4000 and +is 16 bytes long. Because the header uses 8 bytes and one relocation +uses 2 bytes, there are (16-8)/2=4 relocations in the chunk. +The first relocation is to be applied to the DWORD at 0x4012, the next +to the DWORD at 0x4080, and the third to the DWORD at 0x40f6. The last +relocation is a no-op. +The next chunk has a RVA of 0 and finishes the list. + +Now, how do you do a relocation? +You know that the image *is* relocated to the preferred load address +'ImageBase' in the optional header; you also know the address you did +load the image to. If they match, you don't need to do anything. +If they don't match, you calculate the difference +actual_base-preferred_base +and add that value (signed, it may be negative) to the relocation +positions, which you will find with the method described above. + + +Acknowledgments +--------------- +Thanks go to David Binette for his debugging and proof-reading. +(The remaining errors are entirely mine.) +Also thanks to wotsit.org for letting me put the file on their site. + + +Copyright +--------- +This text is copyright 1999 by B. Luevelsmeyer. It is freeware, and you +may use it for any purpose but on your own risk. It contains errors and +it is incomplete. You have been warned. + + +Bug reports +----------- +Send any bug reports (or other comments) to +bernd.luevelsmeyer@iplan.heitec.net + + +Versions +-------- +You find the date of the current release at the top of the file. + +1998-04-06 + First public release + +1998-07-29 + Changed wrong "byte" to "word" for image version and subsystem version + Corrected error "stack is limited to 1 MB" (in fact it is not limited) + Corrected some typos + +1999-03-15 + Corrected export directory description, which was very incomplete + Reworded import directory description, which had been unclear + Corrected typos and did some rewording in other sections + + +Literature +---------- + +[1] +"Peering Inside the PE: A Tour of the Win32 Portable Executable File +Format" (M. Pietrek), in: Microsoft Systems Journal 3/1994 + +[2] +"Why to Use _declspec(dllimport) & _declspec(dllexport) In Code", MS +Knowledge Base Q132044 + +[3] +"Windows Q&A" (M. Pietrek), in: Microsoft Systems Journal 8/1995 + +[4] +"Writing Multiple-Language Resources", MS Knowledge Base Q89866 + +[5] +"The Portable Executable File Format from Top to Bottom" (Randy Kath), +in: Microsoft Developer Network + +[6] +Tool Interface Standard (TIS) Formats Specification for Windows Version +1.0 (Intel Order Number 241597, Intel Corporation 1993) + + +Appendix: hello world +--------------------- +In this appendix I will show how to make programs by hand. The example +will use Intel-assembly, because I don't speak DEC Alpha. + +The program will be the equivalent of + + #include + int main(void) + { + puts(hello,world); + return 0; + } + +First, I translate it to use Win32 functions instead of the C runtime: + + #define STD_OUTPUT_HANDLE -11UL + #define hello "hello, world\n" + + __declspec(dllimport) unsigned long __stdcall + GetStdHandle(unsigned long hdl); + + __declspec(dllimport) unsigned long __stdcall + WriteConsoleA(unsigned long hConsoleOutput, + const void *buffer, + unsigned long chrs, + unsigned long *written, + unsigned long unused + ); + + static unsigned long written; + + void startup(void) + { + WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE),hello,sizeof(hello)-1,&written,0); + return; + } + +Now I will fumble out the assembly: + startup: + ; parameters for WriteConsole(), backwards + 6A 00 push 0x00000000 + 68 ?? ?? ?? ?? push offset _written + 6A 0D push 0x0000000d + 68 ?? ?? ?? ?? push offset hello + ; parameter for GetStdHandle() + 6A F5 push 0xfffffff5 + 2E FF 15 ?? ?? ?? ?? call dword ptr cs:__imp__GetStdHandle@4 + ; result is last parameter for WriteConsole() + 50 push eax + 2E FF 15 ?? ?? ?? ?? call dword ptr cs:__imp__WriteConsoleA@20 + C3 ret + + hello: + 68 65 6C 6C 6F 2C 20 77 6F 72 6C 64 0A "hello, world\n" + _written: + 00 00 00 00 + +That was the compiler part. Anyone can do that. From now on we play +linker, which is much more interesting :-) + +I need to find the functions WriteConsoleA() and GetStdHandle(). They +happen to be in "kernel32.dll". (That was the 'import library' part.) + +Now I can start to make the executable. Question marks will take the +place of yet-to-find-out values; they will be patched afterwards. + +First the DOS-stub, starting at 0x0 and being 0x40 bytes long: + 00 | 4d 5a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 10 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 20 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 30 | 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 +As you can see, this isn't really a MS-DOS program. It's just the header +with the signature "MZ" at the beginning and the e_lfanew pointing +immediatly after the header, without any code. That's because it isn't +intended to run on MS-DOS; it's just here because the specification +requires it. + +Then the PE signature, starting at 0x40 and being 0x4 bytes long: + 50 45 00 00 + +Now the file-header, which will start at byte 0x44 and is 0x14 bytes long: + Machine 4c 01 ; i386 + NumberOfSections 02 00 ; code and data + TimeDateStamp 00 00 00 00 ; who cares? + PointerToSymbolTable 00 00 00 00 ; unused + NumberOfSymbols 00 00 00 00 ; unused + SizeOfOptionalHeader e0 00 ; constant + Characteristics 02 01 ; executable on 32-bit-machine + +And the optional header, which will start at byte 0x58 and is 0x60 bytes long: + Magic 0b 01 ; constant + MajorLinkerVersion 00 ; I'm version 0.0 :-) + MinorLinkerVersion 00 ; + SizeOfCode 20 00 00 00 ; 32 bytes of code + SizeOfInitializedData ?? ?? ?? ?? ; yet to find out + SizeOfUninitializedData 00 00 00 00 ; we don't have a BSS + AddressOfEntryPoint ?? ?? ?? ?? ; yet to find out + BaseOfCode ?? ?? ?? ?? ; yet to find out + BaseOfData ?? ?? ?? ?? ; yet to find out + ImageBase 00 00 10 00 ; 1 MB, chosen arbitrarily + SectionAlignment 20 00 00 00 ; 32-bytes-alignment + FileAlignment 20 00 00 00 ; 32-bytes-alignment + MajorOperatingSystemVersion 04 00 ; NT 4.0 + MinorOperatingSystemVersion 00 00 ; + MajorImageVersion 00 00 ; version 0.0 + MinorImageVersion 00 00 ; + MajorSubsystemVersion 04 00 ; Win32 4.0 + MinorSubsystemVersion 00 00 ; + Win32VersionValue 00 00 00 00 ; unused? + SizeOfImage ?? ?? ?? ?? ; yet to find out + SizeOfHeaders ?? ?? ?? ?? ; yet to find out + CheckSum 00 00 00 00 ; not used for non-drivers + Subsystem 03 00 ; Win32 console + DllCharacteristics 00 00 ; unused (not a DLL) + SizeOfStackReserve 00 00 10 00 ; 1 MB stack + SizeOfStackCommit 00 10 00 00 ; 4 KB to start with + SizeOfHeapReserve 00 00 10 00 ; 1 MB heap + SizeOfHeapCommit 00 10 00 00 ; 4 KB to start with + LoaderFlags 00 00 00 00 ; unknown + NumberOfRvaAndSizes 10 00 00 00 ; constant + +As you can see, I plan to have only 2 sections, one for code and one for +all the rest (data, constants and import directory). There will be no +relocations and no other stuff like resources. Also I won't have a BSS +segment and stuff the variable 'written' into the initialized data. +The section alignment is the same in the file and in RAM (32 bytes); +this helps to keep the task easy, otherwise I'd have to calculate RVAs +back and forth too much. + +Now we set up the data directories, beginning at byte 0xb8 and being 0x80 bytes long: + Address Size + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_EXPORT (0) + ?? ?? ?? ?? ?? ?? ?? ?? ; IMAGE_DIRECTORY_ENTRY_IMPORT (1) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_RESOURCE (2) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_EXCEPTION (3) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_SECURITY (4) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_BASERELOC (5) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_DEBUG (6) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_COPYRIGHT (7) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_GLOBALPTR (8) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_TLS (9) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG (10) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT (11) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_IAT (12) + 00 00 00 00 00 00 00 00 ; 13 + 00 00 00 00 00 00 00 00 ; 14 + 00 00 00 00 00 00 00 00 ; 15 +Only the import directory is in use. + +Next are the section headers. First we make the code section, which will +contain the above mentioned assembly. It is 32 bytes long, and so will +be the code section. The header begins at 0x138 and is 0x28 bytes long: + + Name 2e 63 6f 64 65 00 00 00 ; ".code" + VirtualSize 00 00 00 00 ; unused + VirtualAddress ?? ?? ?? ?? ; yet to find out + SizeOfRawData 20 00 00 00 ; size of code + PointerToRawData ?? ?? ?? ?? ; yet to find out + PointerToRelocations 00 00 00 00 ; unused + PointerToLinenumbers 00 00 00 00 ; unused + NumberOfRelocations 00 00 ; unused + NumberOfLinenumbers 00 00 ; unused + Characteristics 20 00 00 60 ; code, executable, readable + +The second section will contain the data. The header begins at 0x160 and +is 0x28 bytes long: + + Name 2e 64 61 74 61 00 00 00 ; ".data" + VirtualSize 00 00 00 00 ; unused + VirtualAddress ?? ?? ?? ?? ; yet to find out + SizeOfRawData ?? ?? ?? ?? ; yet to find out + PointerToRawData ?? ?? ?? ?? ; yet to find out + PointerToRelocations 00 00 00 00 ; unused + PointerToLinenumbers 00 00 00 00 ; unused + NumberOfRelocations 00 00 ; unused + NumberOfLinenumbers 00 00 ; unused + Characteristics 40 00 00 c0 ; initialized, readable, writeable + +The next byte is 0x188, but the sections need to be aligned to 32 bytes +(because I chose so), so we need padding bytes up to 0x1a0: + + 00 00 00 00 00 00 ; padding + 00 00 00 00 00 00 + 00 00 00 00 00 00 + 00 00 00 00 00 00 + + +Now the first section, being the code section with the above mentioned +assembly, *does* come. It begins at byte 0x1a0 and is 0x20 bytes long: + 6A 00 ; push 0x00000000 + 68 ?? ?? ?? ?? ; push offset _written + 6A 0D ; push 0x0000000d + 68 ?? ?? ?? ?? ; push offset hello_string + 6A F5 ; push 0xfffffff5 + 2E FF 15 ?? ?? ?? ?? ; call dword ptr cs:__imp__GetStdHandle@4 + 50 ; push eax + 2E FF 15 ?? ?? ?? ?? ; call dword ptr cs:__imp__WriteConsoleA@20 + C3 ; ret + +Because of the previous section's length we don't need any padding +before the next section (data), and here it comes, beginning at 0x1c0: + + 68 65 6C 6C 6F 2C 20 77 6F 72 6C 64 0A ; "hello, world\n" + 00 00 00 ; padding to align _written + 00 00 00 00 ; _written + +Now all that's left is the import directory. It will import 2 functions +from "kernel32.dll", and it's immediatly following the variables in the +same section. First we will align it to 32 bytes: + + 00 00 00 00 00 00 00 00 00 00 00 00 ; padding + +It begins at 0x1e0 with the IMAGE_IMPORT_DESCRIPTOR: + OriginalFirstThunk ?? ?? ?? ?? ; yet to find out + TimeDateStamp 00 00 00 00 ; unbound + ForwarderChain ff ff ff ff ; no forwarders + Name ?? ?? ?? ?? ; yet to find out + FirstThunk ?? ?? ?? ?? ; yet to find out + +We need to terminate the import-directory with a 0-bytes-entry (we are at 0x1f4): + OriginalFirstThunk 00 00 00 00 ; terminator + TimeDateStamp 00 00 00 00 ; + ForwarderChain 00 00 00 00 ; + Name 00 00 00 00 ; + FirstThunk 00 00 00 00 ; + +Now there's the DLL name left, and the 2 thunks, and the thunk-data, and +the function names. But we will be finished real soon now! + +The DLL name, 0-terminated, beginning at 0x208: + 6b 65 72 6e 65 6c 33 32 2e 64 6c 6c 00 ; "kernel32.dll" + 00 00 00 ; padding to 32-bit-boundary + +The original first thunk, starting at 0x218: + AddressOfData ?? ?? ?? ?? ; RVA to function name "WriteConsoleA" + AddressOfData ?? ?? ?? ?? ; RVA to function name "GetStdHandle" + 00 00 00 00 ; terminator + +The first thunk is exactly the same list and starts at 0x224: +(__imp__WriteConsoleA@20, at 0x224) + AddressOfData ?? ?? ?? ?? ; RVA to function name "WriteConsoleA" +(__imp__GetStdHandle@4, at 0x228) + AddressOfData ?? ?? ?? ?? ; RVA to function name "GetStdHandle" + 00 00 00 00 ; terminator + +Now what's left is the two function names in the shape of an +IMAGE_IMPORT_BY_NAME. We are at byte 0x230. + 01 00 ; ordinal, need not be correct + 57 72 69 74 65 43 6f 6e 73 6f 6c 65 41 00 ; "WriteConsoleA" + 02 00 ; ordinal, need not be correct + 47 65 74 53 74 64 48 61 6e 64 6c 65 00 ; "GetStdHandle" + +Ok, that's about all. The next byte, which we don't really need, is +0x24f. We need to fill the section with padding up to 0x260: + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; padding + 00 + +------------ + +We are done. Now that we know all the byte-offsets, we can apply fixups +to all those addresses and sizes that were indicated as "unknown" with +'??'-marks. +I won't force you to read that step-by-step (it's quite +straightforward), and simply present the result: + +------------ + +DOS-header, starting at 0x0: + 00 | 4d 5a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 10 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 20 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 30 | 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 + +signature, starting at 0x40: + 50 45 00 00 + +file-header, starting at 0x44: + Machine 4c 01 ; i386 + NumberOfSections 02 00 ; code and data + TimeDateStamp 00 00 00 00 ; who cares? + PointerToSymbolTable 00 00 00 00 ; unused + NumberOfSymbols 00 00 00 00 ; unused + SizeOfOptionalHeader e0 00 ; constant + Characteristics 02 01 ; executable on 32-bit-machine + +optional header, starting at 0x58: + Magic 0b 01 ; constant + MajorLinkerVersion 00 ; I'm version 0.0 :-) + MinorLinkerVersion 00 ; + SizeOfCode 20 00 00 00 ; 32 bytes of code + SizeOfInitializedData a0 00 00 00 ; data section size + SizeOfUninitializedData 00 00 00 00 ; we don't have a BSS + AddressOfEntryPoint a0 01 00 00 ; beginning of code section + BaseOfCode a0 01 00 00 ; RVA to code section + BaseOfData c0 01 00 00 ; RVA to data section + ImageBase 00 00 10 00 ; 1 MB, chosen arbitrarily + SectionAlignment 20 00 00 00 ; 32-bytes-alignment + FileAlignment 20 00 00 00 ; 32-bytes-alignment + MajorOperatingSystemVersion 04 00 ; NT 4.0 + MinorOperatingSystemVersion 00 00 ; + MajorImageVersion 00 00 ; version 0.0 + MinorImageVersion 00 00 ; + MajorSubsystemVersion 04 00 ; Win32 4.0 + MinorSubsystemVersion 00 00 ; + Win32VersionValue 00 00 00 00 ; unused? + SizeOfImage c0 00 00 00 ; sum of all section sizes + SizeOfHeaders a0 01 00 00 ; offset to 1st section + CheckSum 00 00 00 00 ; not used for non-drivers + Subsystem 03 00 ; Win32 console + DllCharacteristics 00 00 ; unused (not a DLL) + SizeOfStackReserve 00 00 10 00 ; 1 MB stack + SizeOfStackCommit 00 10 00 00 ; 4 KB to start with + SizeOfHeapReserve 00 00 10 00 ; 1 MB heap + SizeOfHeapCommit 00 10 00 00 ; 4 KB to start with + LoaderFlags 00 00 00 00 ; unknown + NumberOfRvaAndSizes 10 00 00 00 ; constant + +data directories, starting at 0xb8: + Address Size + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_EXPORT (0) + e0 01 00 00 6f 00 00 00 ; IMAGE_DIRECTORY_ENTRY_IMPORT (1) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_RESOURCE (2) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_EXCEPTION (3) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_SECURITY (4) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_BASERELOC (5) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_DEBUG (6) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_COPYRIGHT (7) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_GLOBALPTR (8) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_TLS (9) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG (10) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT (11) + 00 00 00 00 00 00 00 00 ; IMAGE_DIRECTORY_ENTRY_IAT (12) + 00 00 00 00 00 00 00 00 ; 13 + 00 00 00 00 00 00 00 00 ; 14 + 00 00 00 00 00 00 00 00 ; 15 + +section header (code), starting at 0x138: + Name 2e 63 6f 64 65 00 00 00 ; ".code" + VirtualSize 00 00 00 00 ; unused + VirtualAddress a0 01 00 00 ; RVA to code section + SizeOfRawData 20 00 00 00 ; size of code + PointerToRawData a0 01 00 00 ; file offset to code section + PointerToRelocations 00 00 00 00 ; unused + PointerToLinenumbers 00 00 00 00 ; unused + NumberOfRelocations 00 00 ; unused + NumberOfLinenumbers 00 00 ; unused + Characteristics 20 00 00 60 ; code, executable, readable + +section header (data), starting at 0x160: + Name 2e 64 61 74 61 00 00 00 ; ".data" + VirtualSize 00 00 00 00 ; unused + VirtualAddress c0 01 00 00 ; RVA to data section + SizeOfRawData a0 00 00 00 ; size of data section + PointerToRawData c0 01 00 00 ; file offset to data section + PointerToRelocations 00 00 00 00 ; unused + PointerToLinenumbers 00 00 00 00 ; unused + NumberOfRelocations 00 00 ; unused + NumberOfLinenumbers 00 00 ; unused + Characteristics 40 00 00 c0 ; initialized, readable, writeable + +(padding) + 00 00 00 00 00 00 ; padding + 00 00 00 00 00 00 + 00 00 00 00 00 00 + 00 00 00 00 00 00 + +code section, starting at 0x1a0: + 6A 00 ; push 0x00000000 + 68 d0 01 10 00 ; push offset _written + 6A 0D ; push 0x0000000d + 68 c0 01 10 00 ; push offset hello_string + 6A F5 ; push 0xfffffff5 + 2E FF 15 28 02 10 00 ; call dword ptr cs:__imp__GetStdHandle@4 + 50 ; push eax + 2E FF 15 24 02 10 00 ; call dword ptr cs:__imp__WriteConsoleA@20 + C3 ; ret + +data section, beginning at 0x1c0: + 68 65 6C 6C 6F 2C 20 77 6F 72 6C 64 0A ; "hello, world\n" + 00 00 00 ; padding to align _written + 00 00 00 00 ; _written +padding: + 00 00 00 00 00 00 00 00 00 00 00 00 ; padding +IMAGE_IMPORT_DESCRIPTOR, starting at 0x1e0: + OriginalFirstThunk 18 02 00 00 ; RVA to orig. 1st thunk + TimeDateStamp 00 00 00 00 ; unbound + ForwarderChain ff ff ff ff ; no forwarders + Name 08 02 00 00 ; RVA to DLL name + FirstThunk 24 02 00 00 ; RVA to 1st thunk +terminator (0x1f4): + OriginalFirstThunk 00 00 00 00 ; terminator + TimeDateStamp 00 00 00 00 ; + ForwarderChain 00 00 00 00 ; + Name 00 00 00 00 ; + FirstThunk 00 00 00 00 ; +The DLL name, at 0x208: + 6b 65 72 6e 65 6c 33 32 2e 64 6c 6c 00 ; "kernel32.dll" + 00 00 00 ; padding to 32-bit-boundary +original first thunk, starting at 0x218: + AddressOfData 30 02 00 00 ; RVA to function name "WriteConsoleA" + AddressOfData 40 02 00 00 ; RVA to function name "GetStdHandle" + 00 00 00 00 ; terminator +first thunk, starting at 0x224: + AddressOfData 30 02 00 00 ; RVA to function name "WriteConsoleA" + AddressOfData 40 02 00 00 ; RVA to function name "GetStdHandle" + 00 00 00 00 ; terminator +IMAGE_IMPORT_BY_NAME, at byte 0x230: + 01 00 ; ordinal, need not be correct + 57 72 69 74 65 43 6f 6e 73 6f 6c 65 41 00 ; "WriteConsoleA" +IMAGE_IMPORT_BY_NAME, at byte 0x240: + 02 00 ; ordinal, need not be correct + 47 65 74 53 74 64 48 61 6e 64 6c 65 00 ; "GetStdHandle" +(padding) + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; padding + 00 +First unused byte: 0x260 + +-------------- + +Alas, this works on NT but didn't on windows 95. windows95 can't run +applications with a section alignment of 32 bytes, it needs an +alignment of 4 KB and, apparently, a file alignment of 512 bytes. So for +windows95 you'll have to insert a large number of 0-bytes (for padding) +and adjust the RVAs. Thanks go to D. Binette for testing on windows95. + + + -- end of text -- + diff --git a/mobius/doc/txt/stack.txt b/mobius/doc/txt/stack.txt new file mode 100644 index 0000000..1a001b6 --- /dev/null +++ b/mobius/doc/txt/stack.txt @@ -0,0 +1,15 @@ +=== high address === + param2 + param1 + param0 + rtn <- esp on entry ++-> old ebp2<- esp after prologue, old ebp +| local0 +| local1 +| local2 +| bparam1 +| bparam0 +| rtn ++-- old ebp <- current ebp + local0 +=== low address === \ No newline at end of file diff --git a/mobius/doc/txt/uk-1.txt b/mobius/doc/txt/uk-1.txt new file mode 100644 index 0000000..0a9aee1 --- /dev/null +++ b/mobius/doc/txt/uk-1.txt @@ -0,0 +1,70 @@ +Set 1 scancodes for US 104-key keyboard: + +Make codes are shown in hex. +Break codes are make codes with high bit set (make code + 80h). +"Gray" keys (not on original 84-key keyboard) prefix make/break with E0h. + + ____ ___________________ ___________________ ___________________ +|Esc | | F1 | F2 | F3 | F4 | | F5 | F6 | F7 | F8 | | F9 |F10 |F11 |F12 | +| | | | | | | | | | | | | | | | | +|01 | |3B |3C |3D |3E | |3F |40 |41 |42 | |43 |44 |57 |58 | +|____| |____|____|____|____| |____|____|____|____| |____|____|____|____| + + __________________________________________________________________________ +| `~ | 1! | 2@ | 3# | 4$ | 5% | 6^ | 7& | 8* | 9( | 0) | -_ | =+ | \| | bs | +| | | | | | | | | | | | | | | | +|29 |02 |03 |04 |05 |06 |07 |08 |09 |0A |0B |0C |0D |2B |0E | +|____|____|____|____|____|____|____|____|____|____|____|____|____|____|____| +|Tab | Q | W | E | R | T | Y | U | I | O | P | [{ | ]} | | +| | | | | | | | | | | | | | | +|0F |10 |11 |12 |13 |14 |15 |16 |17 |18 |19 |1A |1B | | +|____|____|____|____|____|____|____|____|____|____|____|____|____| | +|Caps| A | S | D | F | G | H | J | K | L | ;: | '" | Enter | +| | | | | | | | | | | | | | +|3A |1E |1F |20 |21 |22 |23 |24 |25 |26 |27 |28 |1C | +|____|____|____|____|____|____|____|____|____|____|____|____|______________| +| L Shift | Z | X | C | V | B | N | M | ,< | .> | /? | R Shift | +| | | | | | | | | | | | | +|2A |2C |2D |2E |2F |30 |31 |32 |33 |34 |35 |36 | +|_________|____|____|____|____|____|____|____|____|____|____|______________| +|L Ctrl | L Win | L Alt | Space | R Alt | R Win | Menu |R Ctrl | +| | | | | | | | | +|1D |E05B |38 |39 |E038 |E05C |E05D |E01D | +|_______|_______|_______|__________________|_______|_______|_______|_______| + + +note [*] for SysReq and ScrlLock below: + Key make repeat break + --------------- ------------ ------ -------- + PrintScr/SysReq E02AE037 E037 E0B7E0AA + Pause/Break E11D45E19DC5 none none + + ____ ____ ____ +|Sys |Scrl|Brk | +| Req|Lock| | +|[*] |46 |[*] | +|____|____|____| + + ____ ____ ____ ____ ____ ____ ____ +|Ins |Home|PgUp| |Num | / | * | - | +| | | | |Lock| | | | +|E052|E047|E049| |45 |E035|37 |4A | +|____|____|____| |____|____|____|____| +|Del |End |PgDn| | 7 | 8 | 9 | | +| | | | |Home|(U) |PgUp| | +|E053|E04F|E051| |47 |48 |49 | + | +|____|____|____| |____|____|____| | + | 4 | 5 | 6 | | + |(L) | |(R) | | + |4B |4C |4D |4E | + ____ |____|____|____|____| + |(U) | | 1 | 2 | 3 | | + | | |End |(D) |PgDn| | + |E048| |4F |50 |51 |Ent | + ____|____|____ |____|____|____| | +|(L) |(D) |(R) | | 0 | . | | +| | | | |Ins |Del | | +|E04B|E050|E04D| |52 |53 |E01C| +|____|____|____| |_________|____|____| + + diff --git a/mobius/doc/txt/uk-cap.txt b/mobius/doc/txt/uk-cap.txt new file mode 100644 index 0000000..6328a77 --- /dev/null +++ b/mobius/doc/txt/uk-cap.txt @@ -0,0 +1,57 @@ +Keycaps for British 104-key keyboard: + ____ ___________________ ___________________ ___________________ +| | | | | | | | | | | | | | | | | +|Esc | | F1 | F2 | F3 | F4 | | F5 | F6 | F7 | F8 | | F9 |F10 |F11 |F12 | +| | | | | | | | | | | | | | | | | +|____| |____|____|____|____| |____|____|____|____| |____|____|____|____| + + __________________________________________________________________________ +| | | | | | | | | | | | | | | +| � | ! | @ | � | $ | % | ^ | & | * | ( | ) | _ | + |backspace| +| ` �| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | | +|____|____|____|____|____|____|____|____|____|____|____|____|____|_________| +| | | | | | | | | | | | | | | +|tab | Q | W | E | R | T | Y | U | I | O | P | { | } | | +| | | | | | | | | | | | [ | ] | | +|____|____|____|____|____|____|____|____|____|____|____|____|____| | +| | | | | | | | | | | | | | | +|caps | A | S | D | F | G | H | J | K | L | : | " | ~ | enter | +|lock | | | | | | | | | | ; | ' | # | | +|_____|____|____|____|____|____|____|____|____|____|____|____|____|________| +| | | | | | | | | | | | | | +|left| | | Z | X | C | V | B | N | M | < | > | ? | right | +|shft| \ | | | | | | | | , | . | / | shift | +|____|____|____|____|____|____|____|____|____|____|____|____|______________| +| | | | | | | | | +| left | left | left | space | right | right | menu | right | +| ctrl | win | alt | | alt | win | | ctrl | +|_______|_______|_______|__________________|_______|_______|_______|_______| + ____ ____ ____ +| | | | +|prnt|scrl| | +|scrn|lock| brk| +|____|____|____| + + ____ ____ ____ ____ ____ ____ ____ +| | | | | | | | | +|ins |home|page| |num | / | * | - | +| | | up | |lock| | | | +|____|____|____| |____|____|____|____| +| | | | | | | | | +|del |end |page| | 7 | 8 | 9 | | +| | |down| |home|(up)|pgup| | +|____|____|____| |____|____|____| | + | | | | + | + | 4 | 5 | 6 | | + |(l) | |(r) | | + ____ |____|____|____|____| + | | | | | | | + |(up)| | 1 | 2 | 3 | | + | | |end |(dn)|pgdn| | + ____|____|____ |____|____|____| | +| | | | | | |ent | +|(l) |(dn)|(r) | | 0 | . | | +| | | | | insert |del | | +|____|____|____| |_________|____|____| + + diff --git a/mobius/doc/txt/vbe.txt b/mobius/doc/txt/vbe.txt new file mode 100644 index 0000000..b28b976 --- /dev/null +++ b/mobius/doc/txt/vbe.txt @@ -0,0 +1,5083 @@ +This is the text version of the PDF file http://www.vesa.org/vbe3.pdf. +G o o g l e automatically generates text versions of PDF documents as we crawl the web. + + +Google is not affiliated with the authors of this page nor responsible for its content. + + +-------------------------------------------------------------------------------- + +VESA® +Video Electronics Standards Association +920 Hillview Court Phone: (408) 957-9270 +Milpitas, CA 95035 FAX: (408) 957-9277 + + VESA BIOS EXTENSION (VBE) + Core Functions + Standard + Version: 3.0 + + Date: September 16, 1998 + +Purpose +To standardize a modular, software interface to display and audio devices. The VBE interface is +intended to simplify and encourage the development of applications that wish to use graphics, +video, and audio devices without specific knowledge of the internal operation of the evolving +target hardware. + +Summary +The VBE standard defines a set of extensions to the VGA ROM BIOS services. These functions +can be accessed under DOS through interrupt 10h, or be called directly by high performance 32- +bit applications and operating systems other than DOS. + +These extensions also provide a hardware-independent mechanism to obtain vendor information, +and serve as an extensible foundation for OEMs and VESA to facilitate rapid software support of +emerging hardware technology without sacrificing backwards compatibility. + + + + This page is intentionally blank. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Page ii VBE CORE FUNCTIONS VERSION 3.0 + + + +Intellectual Property +Copyright © 1993-1998 - Video Electronics Standards Association. All rights reserved. + +While every precaution has been taken in the preparation of this standard, the Video Electronics +Standards Association and its contributors assume no responsibility for errors or omissions, and +make no warranties, expressed or implied, of functionality or suitability for any purpose. + +The sample code contained within this standard may be used without restriction. + +Trademarks +All trademarks used in this document are property of their respective owners. + +* VESA, VBE, VESA DDC, VBE/AI, VBE/PM, and VBE/DDC are trademarks of Video + Electronics Standards Association. +* MS-DOS and Windows are trademarks of Microsoft , Inc. +* IBM, VGA, EGA, CGA, and MDA are trademarks of International Business Machines +* RAMDAC is a trademark of Brooktree Corp. +* Hercules is a trademark of Hercules Computer Technology, Inc. + +Patents +VESA proposal and standards documents are adopted by the Video Electronics Standards +Association without regard to whether their adoption may involve patents on articles, materials, +or processes. Such adoption does not assume any liability to any patent owner, nor does it +assume any obligation whatever to parties adopting the proposal or standards document. + +Support for this Specification +Clarifications and application notes to support this standard will be published as the need arises. +To obtain the latest standard and support documentation, contact VESA. + +If you have a product which incorporates VBE, you should ask the company that manufactured +your product for assistance. If you are a display or controller manufacturer, VESA can assist you +with any clarification you may require. All comments or reported errors should be submitted in +writing to VESA, to the attention of Technical Support, using one of the following mechanisms: + +World Wide Web: www.vesa.org Mail to: +E-mail: support@vesa.org Video Electronics Standards Association +Fax: 408-957-9277 920 Hillview Court, Suite 140 +Voice: 408-957-9270 Milpitas, CA 95035 + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page iii + + + +SSC VBE/Core Workgroup Members +Any industry standard requires input from many sources. The people listed below were members +of the VBE/Core Workgroup of the Software Standards Committee (SSC) which was responsible +for combining all of the industry input into this standard: + +CHAIRMAN +Charimain, David Penley, Cirrus Logic, Inc. +past chairnam, Kevin Gillett, S-MOS Systems, Inc., +past chairman, Rod Dewell , Excalibur Solutions + +MEMBERS +Jatinder Pancar, Alliance Seminconductor +Armond Bruno, BrookTree Corporation +Rebecca Nolan, Chips and Technologies, Inc. +Andy Sobczyk, Cirrus Logic, Inc. +Brad Haakenson, Cirrus Logic, Inc. +Adrian Luff, Forte Technologies, Inc. +Steven McGowen, Intel Corporation +Jake Richter, Jon Peddie and Associates +Matt Russo, Matrox Graphics, Inc. +Todd Laney, Microsoft Corporation +Thomas Block, Number Nine Visual Technology Corporation +Mark Krueger, NVidia Corporation +Dwight Diericks, NVidia Corporation +Rex Wolfe, Phillips Semiconductor +Raluca Iovan, Phoenix Technologies Ltd. +Tim Crawford, Rendition, Inc. +Kendall Bennett, SciTech Software, Inc +Tom Ryan, SciTech Software, Inc +Don Pannell, Sierra Semiconductor +George Bystricky, S-MOS Systems, Inc. +David Milici, StereoGraphics Corporation +Tony Lin, Trident Microsystems, Inc. +Mitch Paris, Tseng Labs, Inc. +Joe Israel, Tseng Labs, Inc. +Chris Tsang, ULSI Systems +Danny Halamish, VideoLogic, Inc.. +Gregory Hamlin, VRex, Inc. +Thomas Roell, X Inside Inc. + + + + + + + + + + + + + + + + + + + + + + + + + + +Page iv VBE CORE FUNCTIONS VERSION 3.0 + + + + Table of Contents + + +INTRODUCTION................................................................................................................................................ 1 + SCOPE OF THE VBE STANDARD........................................................................................................................... 1 + BACKGROUNDER ................................................................................................................................................ 3 +VBE OVERVIEW................................................................................................................................................ 5 + VBE FEATURES ................................................................................................................................................. 5 + VBE AFFECTED DEVICES ................................................................................................................................... 5 + PROVIDING VENDOR INFORMATION..................................................................................................................... 5 +PROGRAMMING WITH VBE/CORE .............................................................................................................. 6 + ACCESSING LINEAR FRAMEBUFFER MEMORY....................................................................................................... 6 + USING REFRESH RATE CONTROL......................................................................................................................... 6 + Using VBE/DDC to obtain monitor operational limits .................................................................................. 7 + Using VM/GTF to compute CRTC values...................................................................................................... 8 + Computing the normalized pixel clock .......................................................................................................... 8 + Setting double scan modes............................................................................................................................ 8 + Setting Interlaced Modes .............................................................................................................................. 8 + USING HARDWARE TRIPLE BUFFERING ................................................................................................................ 9 + USING STEREOSCOPIC LIQUID CRYSTAL SHUTTER GLASSES.................................................................................. 9 + Automatic hardware display start address swapping (Method 1)................................................................. 10 + Automatic hardware display start address swapping (Method 2)................................................................. 11 + Software driven display start address swapping .......................................................................................... 12 + Refresh rates and stereoscopic imaging...................................................................................................... 12 + Left/right image synchronization ................................................................................................................ 13 + DEVELOPING FOR MAXIMUM COMPATIBILITY .................................................................................................... 13 + Be prepared for different Window Granularity's......................................................................................... 13 + Be prepared for both single and dual read/write Windows .......................................................................... 14 + Be prepared to support both 15 and 16 bits per pixel high color modes ...................................................... 14 + Be prepared to support both 24 and 32 bits per pixel true color modes....................................................... 14 + Some controllers can't do double scanned modes ....................................................................................... 14 + Check if VGA Compatible Before Touching Any VGA Registers ................................................................. 15 + Check if VGA Compatible Before Directly Programming the DAC ............................................................. 15 +VBE FUNCTION REFERENCE....................................................................................................................... 17 + VBE RETURN STATUS...................................................................................................................................... 17 + VBE MODE NUMBERS...................................................................................................................................... 18 + VBE FAR POINTERS ......................................................................................................................................... 20 + OBTAINING THE PROTECTED MODE ENTRY POINT ............................................................................................. 21 + CALLING THE PROTECTED MODE ENTRY POINT................................................................................................. 23 + PROTECTED MODE ENTRY POINT FUNCTIONAL RESTRICTIONS ........................................................................... 24 + FUNCTION 00H - RETURN VBE CONTROLLER INFORMATION.............................................................................. 25 + FUNCTION 01H - RETURN VBE MODE INFORMATION......................................................................................... 30 + FUNCTION 02H - SET VBE MODE..................................................................................................................... 40 + FUNCTION 03H - RETURN CURRENT VBE MODE................................................................................................ 44 + FUNCTION 04H - SAVE/RESTORE STATE............................................................................................................ 45 + FUNCTION 05H - DISPLAY WINDOW CONTROL................................................................................................... 46 + FUNCTION 06H - SET/GET LOGICAL SCAN LINE LENGTH .................................................................................... 48 + + VBE CORE FUNCTIONS VERSION 3.0 Page v + + + + FUNCTION 07H - SET/GET DISPLAY START ........................................................................................................ 50 + FUNCTION 08H - SET/GET DAC PALETTE FORMAT............................................................................................ 53 + FUNCTION 09H - SET/GET PALETTE DATA......................................................................................................... 54 + FUNCTION 0AH - RETURN VBE PROTECTED MODE INTERFACE.......................................................................... 56 + FUNCTION 0BH - GET/SET PIXEL CLOCK ............................................................................................................ 59 +VBE SUPPLEMENTAL SPECIFICATIONS................................................................................................... 60 + PURPOSE OF SUPPLEMENTAL SPECIFICATIONS .................................................................................................... 60 + OBTAINING SUPPLEMENTAL VBE FUNCTION NUMBERS ..................................................................................... 60 + REQUIRED VBE SUPPLEMENTAL SPECIFICATION COMPONENTS .......................................................................... 61 + VBE Supplemental Specification Functions ................................................................................................ 61 + Return Status.............................................................................................................................................. 61 + Subfunction 00h - Return VBE Supplemental Specification Information...................................................... 61 + LOADING SUPPLEMENTAL DRIVERS ................................................................................................................... 63 + IMPLEMENTATION QUESTIONS .......................................................................................................................... 63 + KNOWN SUPPLEMENTAL SPECIFICATIONS .......................................................................................................... 63 + Function 10h - Power Management Extensions (PM).................................................................................. 63 + Function 11h - Flat Panel Interface Extensions (FP) .................................................................................. 64 + Function 13h - Audio Interface Extensions (AI) .......................................................................................... 64 + Function 14h - OEM Extensions ................................................................................................................. 64 + Function 15h - Display Data Channel (DDC) ............................................................................................. 64 +APPENDIX 1 - VBE IMPLEMENTATION CONSIDERATIONS.................................................................. 65 + MINIMUM FUNCTIONALITY REQUIREMENTS....................................................................................................... 65 + Required VBE Services............................................................................................................................... 65 + Minimum ROM Implementation.................................................................................................................. 65 + TSR Implementations.................................................................................................................................. 65 + VGA BIOS IMPLICATIONS ............................................................................................................................... 66 + REAL MODE ROM SPACE LIMITATIONS ............................................................................................................. 67 + Data Storage .............................................................................................................................................. 67 + Removal of Unused VGA Fonts................................................................................................................... 67 + Deleting VGA Parameter Tables................................................................................................................. 68 + Increasing ROM Space............................................................................................................................... 68 + Support of VGA TTY Functions................................................................................................................... 68 + DEVELOPING DUAL-MODE BIOS CODE ............................................................................................................. 69 + Determining when in Protected Mode......................................................................................................... 69 + Things to avoid in Protected Mode ............................................................................................................. 69 + Returning pointers in info blocks ................................................................................................................ 70 + SUPPORTING MULTIPLE CONTROLLERS.............................................................................................................. 70 + Dual-Controller Designs ............................................................................................................................ 70 + Provision for Multiple Independent Controllers.......................................................................................... 70 + OEM EXTENSIONS TO VBE.............................................................................................................................. 70 +APPENDIX 2 - SAMPLE SOURCE CODE...................................................................................................... 72 + C Language Module ................................................................................................................................... 72 + Assembly Language Module ....................................................................................................................... 80 +APPENDIX 3 - DIFFERENCES BETWEEN VBE REVISIONS..................................................................... 82 + VBE 1.0...................................................................................................................................................... 82 + VBE 1.1...................................................................................................................................................... 82 + VBE 1.2...................................................................................................................................................... 82 + VBE 2.0...................................................................................................................................................... 82 + VBE 2.0, Rev. 1.1 ....................................................................................................................................... 83 + VBE 3.0...................................................................................................................................................... 85 + +Page vi VBE CORE FUNCTIONS VERSION 3.0 + + + +APPENDIX 4 - RELATED DOCUMENTS ...................................................................................................... 87 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page vii + + + + + + + Introduction + + + + + Introduction + + +This document contains the VESA BIOS Extension (VBE) specification for standard software +access to graphics display controllers which support resolutions, color depths, and frame buffer +organizations beyond the VGA hardware standard. It is intended for use by both applications +programmers and system software developers. It is also intended to provide an extended interface +to support enhanced refresh rate control for operating system utilities and drivers. + +System software developers may use this document to supplement the System and INT 10h ROM +BIOS functions to provide the VBE services. Application developers can use this document as a +guide to programming all VBE compatible devices. + +To understand the VBE specification, some knowledge of 80x86 assembly language and the VGA +hardware registers may be required. However, the services described in this specification may be +called from any high-level programming language that provides a mechanism for generating +software interrupts with the 80x86 registers set to user-specified values. + +In this specification, 'VBE' and 'VBE 3.0' are synonymous with 'VBE Core Functions version 3.0'. + +Scope of the VBE Standard + +The primary purpose of the VESA VBE is to provide standard software support for the many +unique implementations of Super VGA (SVGA) graphics controllers on the PC platform that +provide features beyond the original VGA hardware standard. This is to provide a feasible +mechanism by which application developers can take advantage of this nonstandard hardware in +graphics applications. + +The VBE specification offers an extensible software foundation which allows it to evolve as +display and audio devices evolve over time, without sacrificing backward software compatibility +with older implementations. New application software should be able to work with older +hardware, and application software that has already shipped should work correctly on new +hardware devices. + +VBE services provide standard access to all resolutions and color depths provided on the display +controller, and report the availability and details of all supported configurations to the application +as necessary. + +VBE implementations facilitate the field support of audio and display hardware by providing the +application software with the manufacturer's name and the product identification of the display +hardware. + +Since graphics controller services on the PC are typically implemented in ROM, the VBE services +are defined so that they should be implemented within the standard VGA ROM. When ROM + + VBE CORE FUNCTIONS VERSION 3.0 Page 1 + + + +Introduction + + +implementations of VBE are not possible, or when field software upgrades to the onboard ROM +are necessary, the VBE implementation may be also offered as a device driver or DOS Terminate +and Stay Resident (TSR) program. + +The standard VBE functions may be supplemented by OEM's as necessary to support custom or +proprietary functions unique to the manufacturer. This mechanism enables the OEM to establish +functions that may be standard to the product line, or provide access to special hardware +enhancements. + +Although previous VBE standards assumed that the underlying graphics architecture was a VGA +device, the display services described by VBE 3.0 can be implemented on any frame buffer +oriented graphics device. + +The majority of VBE services facilitate the setup and configuration of the hardware, allowing +applications high performance, direct access to the configured device at runtime. To further +improve the performance of flat frame buffer display devices in extended resolutions, VBE 3.0 +provides new memory models that do not require the traditional frame buffer "banking" +mechanisms. + +VBE is expected to work on all 80x86 platforms, in real and protected modes. Starting with VBE +3.0, all the VBE/Core BIOS functions can be `dual-mode', allowing them to optionally be called +as 16-bit protected mode code via a direct call to a new protected mode interface entry point. +`Dual-mode' code means that the BIOS code adheres to certain restrictions when called via the +protected mode entry point, to ensure full compatibility with fully protected mode operating +systems such as Windows NT, OS/2 and the many versions of UNIX. Note that although the +`dual-mode' code must be called as 16-bit protected mode code, this does not preclude it from +being called by 32-bit pure operating systems such as Windows NT and OS/2. Since some +modern display devices are designed without any VGA support, two or more display controllers +may be present in the system. One display controller could be used for VGA compatibility, and +the other used for graphic extensions to the basic VGA modes, resolutions, and frame buffer +models. Since it is not possible to support multiple controllers easily via the INT 10h software +interface, only the primary controller will be supported via this interface and its BIOS will be +located at C0000h. If multiple controllers are present in the system, the second controller can only +be controlled via the VBE/AF Accelerator Functions specification (contact VESA for more +information). + +Note that the VBE/Core specification does not include any support for hardware acceleration +functions such as 2D and 3D graphics primitives or video acceleration. If you wish to use such +features please refer to the VBE/AF Accelerator Functions specification (contact VESA for more +information). + + + + + + + +Page 2 VBE CORE FUNCTIONS VERSION 3.0 + + + + Introduction + + + +Backgrounder + +The IBM VGA1 has become a de facto standard in the PC graphics world. A multitude of +different VGA offerings exist in the marketplace, each one providing BIOS or register +compatibility with the IBM VGA. More and more of these VGA compatible products implement +various supersets of the VGA standard. These extensions range from higher resolutions and more +colors to improved performance and even some graphics processing capabilities. Intense +competition has dramatically improved the price/performance ratio, to the benefit of the end user. + +However, several serious problems face a software developer who intends to take advantage of +these "Super VGA"2 environments. Because there is no standard hardware implementation, the +developer is faced with widely different Super VGA hardware architecture. Lacking a common +software interface, designing applications for these environments is costly and technically difficult. +Except for applications supported by OEM-specific display drivers, very few software packages +can take advantage of the power and capabilities of Super VGA products. + +The VBE standard was originally conceived to enable the development of applications that wished +to take advantage of display resolutions and color depths beyond the VGA definition. The need +for an application or software standard was recognized by the developers of graphic hardware to +encourage the use and acceptance of their rapidly advancing product families. It became obvious +that the majority of software application developers did not have the resources to develop and +support custom device level software for the hundreds of display boards on the market. +Therefore the rich new features of these display devices were not being used outside of the +relatively small CAD market, and only then after considerable effort. + +Indeed, the need for a standard for SVGA display adapters became so important that the VESA +organization was formed to seek out a solution. The original VBE standard was devised and +agreed upon by each of the active display controller manufacturers, and has since been adopted by +DOS application developers to enable use of non-VGA extended display modes. + +As time went along VBE 1.1 was created to add more video modes and increased logical line +length/double buffering support. VBE 1.2 was created to add modes and also added high color +RAMDAC support. + +In the three years since VBE 1.2 was approved we have seen the standard become widely +accepted and many successful programs have embraced VBE. However, it has become obvious +that the need for a more robust and extensible standard exists. Early extensions to the VGA +standard continued using all of the original VGA I/O ports and frame buffer address to + + +1 IBM and VGA are trademarks of International Business Machines Corporation. + + + +2 The term "Super VGA" is used in this document for a graphics display controller implementing any superset of +the standard IBM VGA display adapter. + + + VBE CORE FUNCTIONS VERSION 3.0 Page 3 + + + +Introduction + + +communicate with the controller hardware. As we've seen, the supported resolutions and color +depths have grown, intelligent controllers with BITBLT and LineDraw Functions have become +common, and new flat frame buffer memory models have appeared along with display controllers +that are not based on VGA in any way. VBE 2.0 and future extensions will support non-VGA +based controllers with new functions for reading and writing the palette and for access to the flat +frame buffer models. + +VBE 3.0, as designed, offers the extensibility and the robustness that was lacking in the previous +specifications, while at the same time offering backwards compatibility. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Page 4 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Overview + + + + + VBE Overview + + +This chapter outlines the various features and limitations of the VBE 3.0 standard. + +VBE Features + +* Standard application interface to Graphics Controllers (SVGA Devices). +* Optional protected mode interface for OS's such as Windows NT, OS/2 and UNIX. +* Standard method of overriding the refresh rate for supported modes. +* Stereoscopic display support for liquid crystal (LC) shutter glasses. +* Standard method of identifying products and manufacturers. +* Provision for OEM extensions through Subfunction 14h. +* Extensible interface through supplemental specifications. + +VBE Affected Devices + +All frame buffer-based devices in the PC platform (with the exception of Hercules, Monochrome +(MDA), CGA and EGA devices) are suitable for use within the VBE standard to enable access to +the device by VBE-compliant applications. + +Providing Vendor Information + +The VGA specification does not provide a standard mechanism to determine what graphic device +it is running on. Only by knowing OEM-specific features can an application determine the +presence of a particular graphics controller or display board. This often involves reading and +testing registers located at I/O addresses unique to each OEM. By not knowing what hardware an +application is running on, few, if any, of the extended features of this hardware can be used. + +The VESA BIOS Extension provides several functions to return information about the graphics +environment. These functions return system level information as well as graphics mode specific +details. Function 00h returns general system level information, including an OEM identification +string. The function also returns a pointer to the supported VBE and OEM modes. Function 01h +may be used by an application to obtain additional information about each supported mode. +Function 03h returns the current VBE mode. + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 5 + + + +VBE Overview + + + + + Programming with VBE/Core + + +This section contains application and systems programming information for some of the more +advanced functions that VBE 3.0 provides. + +Accessing Linear Framebuffer Memory + +Once you have initialized the graphics hardware into a mode that supports a hardware linear +framebuffer, you need to create a pointer that your application can use to write to the linear +framebuffer memory. The first thing you should realize is that the linear framebuffer location +reported in the ModeInfoBlock for the mode you are using is a physical memory address, and +cannot be used directly from protected mode applications. Before you can use the memory you +must use the services your operating system provides to map the physical memory to a linear +memory address, and then map this linear address into your applications memory space. Under +DPMI mapping the linear memory is done with DPMI function 0x800, and equivalent functions +exist under other operating systems. + +The steps involved in mapping in a linear framebuffer region are as follows (32-bit protected +mode only): + + 1. Map the physical memory address to a linear memory address (using DPMI function + 0x800 for example). + + 2. Find the base address of the default DS selector for your operating environment. + + 3. Subtract the base address from the linear address computed in step 1 to give you a + near pointer (relative to DS) that you can use from within your code. + +Using Refresh Rate Control + +VBE 3.0 provides support for refresh rate control by allowing the calling application to pass a set +of custom CRTC timing values to the BIOS when a mode set is being performed. This provides +for maximum versatility and allows the application to program specific CRTC timing values if this +is necessary (for instance specialized display hardware such as head mounted displays or fixed +frequency monitors). + +When the calling application wishes to control the refresh rate for the mode being initialized, it +must compute a set of CRTC values and a normalized pixel clock that can be passed to function +4F02h when the mode is initialized. The VBE 3.0 interface does not provide any means to +compute these values, and the values can either be taken from discrete VESA DMT timings, or by +using the new VM/GTF Generalized Timing Formula to compute the CRTC values to be used. +Once you have these values, you must search for an available pixel clock that is the closest to + +Page 6 VBE CORE FUNCTIONS VERSION 3.0 + + + + Programming with VBE/Core + + +what you want by calling VBE function 4F0Bh (if you are using GTF to compute the CRTC +values, you should re-run the GTF calculations routines based on the pixel clock returned by +4F0Bh to get the final CRTC values). + +The steps involved in initializing a mode with a specific refresh rate are as follows: + + 1. Use VBE/DDC to obtain the operational limits of the monitor if VBE/DDC is + available and the monitor is DDC compliant. Use these values to restrict the calculated + values or modes that you can make available. + + 2. Use either the DMT timings or GTF formulas to compute a set of CRTC timings and + normalized pixel clock for the mode and refresh rate that you want to initialize. If the + mode is a double scanned mode (200, 240 or 300 lines) double the vertical resolution + used to drive the GTF CRTC calculations (i.e.: use 400 lines for the vertical number of + lines). + + 3. Call VBE function 4F0Bh to find the actual pixel clock that will be programmed for + the normalized pixel clock that you have requested. + + 4. If you are using GTF, re-run the GTF formulas using the resulting normalized pixel + clock returned by function 4F0Bh to compute the proper CRTC timings given the + exact pixel clock that will be used for the resulting mode. This is an important step to + ensure that the GTF timings will be exact for the resulting mode given the available + pixel clocks the hardware supports (and PLL resolution for programmable pixel + clocks). + + 5. If you are setting a double scanned mode (200, 240 or 300 lines vertical) set the + double scan flag in the CRTCInfoBlock. + + 6. If you are enabling an interlaced mode, set the interlace flag in the CRTCInfoBlock. + + 7. Call function 4F02h with bit D11 set in the mode number and pass in the CRTC + timings and pixel clock in the CRTCInfoBlock. + +Using VBE/DDC to obtain monitor operational limits +The VBE/DDC interface can be used to obtain the operational limits of the attached monitor, +such as the minimum and maximum horizontal and vertical frequencies as well as supported +resolutions. If the monitor and graphics card both support DDC, this information should be +obtained and used to restrict the refresh rate computation routines to ensure that the resulting +CRTC values do not produce a mode that lies outside the operational limits of the attached +monitor. + +Please refer to the VBE/DDC and EDID specifications for more information on how to obtain the +operational limits of the monitor. + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 7 + + + +VBE Overview + + +Using VM/GTF to compute CRTC values +The VESA Monitor Committee's GTF (Generalized Timing Formula) standard defines a set of +formulas that can be used to compute GTF compatible CRTC timings given a couple of input +parameters. GTF can be used to generate CRTC timings given the resolution and one of either the +vertical frequency, horizontal frequency or pixel clock. For more information please refer to the +GTF specification for the formulas and sample code for calculating GTF compliant CRTC values. + +Note that GTF can be used to generate timings that will display properly on both new GTF +compatible monitors and for existing non-GTF compliant monitors. + +Computing the normalized pixel clock +Once you have generated a set of CRTC timings from the DMT timings or using the GTF +formula, the pixel clock will be an arbitrary pixel clock which may not be directly programmable +in the hardware. Once you have the normalized pixel clock, you must then call VBE function +4F0Bh to find the exact value of the closest pixel clock that the hardware can program. Note that +when you call function 4F0Bh, you must pass it the correct value of the graphics mode that you +will be using the pixel clock for. This allows the underlying VBE implementation to make any +necessary adjustments before running the clock through the PLL calculation routines so that you +will be returned the exact pixel clock that will be programmed by the hardware. + +Setting double scan modes +If double scanning is supported by the hardware, it is possible to support modes like 320x200, +320x240 and 400x300 that scan each line twice in the vertical direction. These modes cannot be +implemented without double scanning support, and if the application is attempting to perform +refresh rate control on these modes, setting the double scan bit is required. + +When setting a double scan mode, the actual CRTC parameters calculated and passed in will be +equal to double the number of vertical lines. Hence for a 200 line mode you would actually set the +vertical CRTC parameters and pixel clock for a 400 line mode, and set the double scan bit to +convert the mode to a 200 line addressable mode. Note that if you are using double scanned +modes, you cannot enable interlaced operation. + +Setting Interlaced Modes +If interlaced mode is supported by the hardware, bit D9 will be set in the ModeAttributes field of +the ModeInfoBlock for the graphics mode in question. If this bit is set, you can enable interlaced +operation by setting bit D1 of the Flags field of the CRTCInfoBlock passed in to function 4F02h. +The CRTC timings for the interlaced mode will be identical to the non-interlaced mode. + +Note that some new hardware may not support interlaced operation, so make sure you check the +ModeInfoBlock attributes field to ensure interlaced is supported before attempting to initialize an +interlaced mode. Note that if you are using double scanned modes, you cannot enable interlaced +operation. Generally interlaced operation is only available for modes with resolutions of 640x480 +and higher, and most hardware will have a hard time enabling interlaced operation for lower +resolution modes. + +Page 8 VBE CORE FUNCTIONS VERSION 3.0 + + + + Programming with VBE/Core + + + +Using Hardware Triple Buffering + +Hardware triple buffering is supported in the VBE/Core specification by allowing the application +to schedule a display start address change, and then providing a function that can be called to +determine the status of the last scheduled display start address change. VBE Function 4F07h is +used for this, along with subfunctions 02h and 04h. To implement hardware triple buffering you +would use the following steps: + + 1. Display from the first visible buffer, and render to the second hidden buffer. + + 2. Schedule a display start address change for the second hidden buffer that you just + finished rendering (4F07h, 02h), and start rendering immediately to the third hidden + buffer. CRT controller is currently displaying from the first buffer. + + 3. Before scheduling the display start address change for the third hidden buffer, wait + until the last scheduled change has occurred (4F07h, 04h returns not 0). Schedule + display start address change for the third hidden buffer and immediately begin + rendering to the first hidden buffer. CRT controller is currently displaying from the + second buffer. + + 4. Repeat step 3 over and over cycling though each of the buffers. + +Although the above method does require a spin loop polling on Function 4F07h/04h, in most +cases when this function is called the display start address change will already have occurred and +the spin loop will time out immediately. The only time that this cannot occur is if the application is +rendering at a frame rate in excess of the current hardware refresh rate (i.e.: in excess of 60-70 +frames per second), and the resulting frame rate for the application will be pegged at the hardware +refresh rate. + +Using Stereoscopic Liquid Crystal Shutter Glasses + +Stereoscopic liquid crystal (LC) shutter glasses are a cheap, easy solution for getting real 3D +stereoscopic imaging out of a standard PC with any standard monitor. LC shutter glasses work by +constantly blanking out video information for each eye in a sequential fashion, allowing the user to +see the left image for a fraction of a second followed by the right image, followed by the left +image again etc. In order to make LC shutter glasses work effectively on PC based graphics +controllers, some mechanism for changing the displayed video information at every vertical +retrace is necessary. New hardware is available that will do this automatically, and VBE 3.0 +defines the software interface necessary to allow applications to use these new hardware features. + +There are two methods of performing hardware stereoscopic page flipping with VBE 3.0, +depending on the available underlying hardware capabilities. All VBE implementations that have +stereoscopic should support the first method, while the second method requires that the hardware +implement dual display start addresses. Please check the mode information ModeAttributes field +bit D12 to see if dual display start addressing is supported. + + + VBE CORE FUNCTIONS VERSION 3.0 Page 9 + + + +VBE Overview + + +The steps involved in enabling free running stereoscopic support are as follows (Method 1 - +consecutive left right images): + + 1. Set the mode via function 4F02h (using a high refresh rate if possible) + + 2. Enable free running stereoscopic mode with function 4F07h subfunction 05h. + + 3. Perform standard double buffered or triple buffered graphics using function 4F07h + subfunctions 02h/04h/82h, but draw both the left and right images consecutively in + memory rather than just a single image. Once both left and right eye images are + rendered, the display can be swapped as would be done for normal double/triple + buffered graphics. + + 4. Disable free running stereoscopic mode with function 4F07h subfunction 06h when + you are done with stereoscopic viewing. + +The steps involved in enabling free running stereoscopic support are as follows (Method 2 - dual +display start addresses): + + 1. Set the mode via function 4F02h (using a high refresh rate if possible) + + 2. Draw the left and right images in video memory any way you wish (see below for + some possible scenarios), and use subfunctions 03h or 83h to set the display start + addresses for the left and right images in memory. Calling subfunction 03h or 83h will + automatically enable free running stereoscopic mode for the controller. You can then + render your next frame in memory and use 03h/04h/83h to perform standard double + buffered or triple buffered graphics with both a left and right image for each buffer. + + 3. Disable free running stereoscopic mode with function 4F07h subfunction 06h when + you are done with stereoscopic viewing. + +Automatic hardware display start address swapping (Method 1) +VBE 3.0 supports hardware implementations that can be programmed to automatically swap +between the left and right images of the stereoscopic display automatically every vertical retrace. +Normally when a mode is set, stereoscopic mode will be disabled and can be enabled by the +application by calling function 4F07h, subfunction 05h (and disabled with subfunction 06h). Once +stereoscopic mode has been enabled, the hardware will display the left image from the data in +video memory defined by the current display start address, followed by the right image in the +following frame from the video memory immediately following the left image. After the right +image has been displayed the hardware will begin displaying the left image again in a continuous +cycle. + +The diagram below shows how the pages would be laid out in video memory for a triple buffered, +stereoscopic enabled graphics mode: + + + +Page 10 VBE CORE FUNCTIONS VERSION 3.0 + + + + Programming with VBE/Core + + + + Display Start 0 + Buffer 0, Left Image + + + + Buffer 0, Right Image + + Display Start 1 + + Buffer 1, Left Image + + + + Buffer 1, Right Image + + Display Start 2 + + Buffer 2, Left Image + + + + Buffer 2, Right Image + + + + +While the hardware has been programmed to display from buffer 0, it will continuously cycle +between the left and right images in buffer 0. When the application request to change to buffer 1, +it will change to continuously cycle between the left and right images for buffer 1. Note that if +display start 1 is programmed while the hardware is displaying the left image in buffer 0, the +hardware may switch to the right image in buffer 1 at the next vertical retrace or it may continue +on and display the right image buffer 0, switching to buffer 1 after the buffer 0 right image has +been displayed. + +Automatic hardware display start address swapping (Method 2) +VBE 3.0 supports hardware implementations that can be programmed to automatically swap +between the left and right images of the stereoscopic display automatically every vertical retrace. +Normally when a mode is set, stereoscopic mode will be disabled and can be enabled by the +application by calling function 4F07h, subfunctions 03h or 82h (and disabled with subfunction +06h). Once stereoscopic mode has been enabled, the hardware will display the left image from the +data in video memory defined by the current left display start address, followed by the right image +from the data in video memory defined by the current right display start address. After the right +image has been displayed the hardware will begin displaying the left image again in a continuous +cycle. + +The diagram below shows how the pages could be laid out in video memory for a triple buffered, +stereoscopic enabled graphics mode using a above/below approach: + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 11 + + + +VBE Overview + + + + Left display start 0 + Buffer 0, Left Image + + Right display start 0 + + Buffer 0, Right Image + + Left display start 1 + + Buffer 1, Left Image + + Right display start 1 + + Buffer 1, Right Image + + Left display start 2 + + Buffer 2, Left Image + + Right display start 2 + + Buffer 2, Right Image + + + + +While the hardware has been programmed to display from buffer 0, it will continuously cycle +between the left and right images in buffer 0. When the application request to change to buffer 1, +it will change to continuously cycle between the left and right images for buffer 1. Note that if +display start 1 is programmed while the hardware is displaying the left image in buffer 0, the +hardware may switch to the right image in buffer 1 at the next vertical retrace or it may continue +on and display the right image buffer 0, switching to buffer 1 after the buffer 0 right image has +been displayed. + +Software driven display start address swapping +If the hardware does not support a free running stereoscopic display mode, the application must +implement the free running display start address changes in software using a timer interrupt +handler. The application should set the timer interrupt handler to run at a rate very close to the +vertical refresh rate of the graphics mode being used, and use function 4F07h to swap the display +start address during the vertical retrace interval. + +Refresh rates and stereoscopic imaging +When the hardware is running in free running stereoscopic mode and an image or 3D scene is +being viewed through LC shutter glasses, the user will see the resulting image at half the original +refresh rate through the shutter glasses. Hence a normally acceptable display running at 60Hz +becomes a hard to view display running at 30Hz stereoscopic. For this reason when running in +stereoscopic modes it is desirable to significantly increase the refresh rate of the graphics mode to +values as high as 120Hz or 140Hz (depending on the monitors capabilities), which provides for +60Hz or 70Hz refresh per eye in stereoscopic modes. + + +Page 12 VBE CORE FUNCTIONS VERSION 3.0 + + + + Programming with VBE/Core + + +VBE 3.0 has full support for refresh rate control when setting a display mode via function 4F02h. +Stereoscopic applications can use this functionality in combination with the GTF standard to +increase the refresh rate of the stereoscopic application to acceptable levels (see the above section +on refresh rate control for more information). + +Left/right image synchronization +Signaling to the stereoscopic LC shutter glasses which image is currently being displayed is out of +the scope of this specification, however the VBE/Core specification does include capabilities bits +to let the application software know when a hardware stereoscopic synchronization signal is +available. VESA is currently working on a new hardware standard for both the standard VGA and +the new EVC connector's for signaling this synchronization information, and VBE function 4F00h +will let the application know if stereoscopic signaling is available via the EVC connector or via the +VESA stereoscopic signaling connector. Please contact VESA for more information on this new +hardware signaling standard. + +Developing for Maximum Compatibility + +This section contains information relating to developing application software with maximum +compatibility in mind, without sacrificing performance or features. Although the VBE standard +defines how the specification should work, there are many different flavors of hardware out in the +field. It is very important that you design your application with the following special cases in mind +so that your application will run on the widest variety of hardware possible. + +One of the common mistakes that many developers make when they first start developing graphics +code with VBE devices is to assume the graphics card they have in their system is a representative +sample of what exists in the field. Although the VBE interface will be identical on another +graphics card, the capabilities and attributes that card reports may be different. This section also +deals with explaining the most common pitfalls that plague developers first starting to develop +VBE code. + +This section is also very useful for the hardware vendor implementing a VBE BIOS for their +graphics hardware, as it allows the hardware vendor to understand some of the more common +pitfalls that developers will fall into, and to try and develop their BIOS code (and future +hardware) to provide for the best compatibility in the field. + +Be prepared for different Window Granularity's +One area that is of vital importance is the Windows Granularity, or the smallest increment that +you can move the bank switching window. Many controllers simply provide a 64Kb granularity, +which means that bank 0 starts at 0, bank 1 at 64Kb and bank 2 at 128Kb etc. However some +controllers may provide either a 4Kb or a 16Kb granularity. For a 4Kb granularity controller, bank +0 starts at 0 while bank 1 starts at 4Kb not 64Kb. On a 4Kb system to move the window to the +next 64Kb location you would need to program bank number 8 rather than bank number 1. + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 13 + + + +VBE Overview + + +One method of adjusting the bank numbers in your bank switching code is outlined in the sample +code in Appendix 2. This code basically finds a shift factor when the mode is initialized that +indicates how many bits to shift the bank value left to adjust from a 64Kb window to the +granularity of the hardware. In your bank switch code you simply shift the bank value left by the +specified number of bits before calling the VBE bank switch function. + +Be prepared for both single and dual read/write Windows +Another area of importance is if the controller has a single read/write window or separate read +and write window's. On a controller with a single read/write window (the most common +scenario), setting the first window will change the offset in the framebuffer where both reads and +writes occur to the same location. On a controller with dual read/write window's, you can +individually change the location in the framebuffer where read operations will occur and the +location where write operations will occur. + +To provide for maximum performance you should make sure you check the modeInfoBlock +attributes for the graphics mode you are programming. If separate read/write windows are +provided you must ensure that you set both windows to the same location with two calls to the +bank switch function. + +Be prepared to support both 15 and 16 bits per pixel high color modes +Many new games and applications have support for 15 and 16 bits per pixel high color modes. If +you wish to support these modes, don't make the mistake of assuming that all devices will +support 16 bit high color modes, or that all devices will support 15 bit high color modes. There +are devices in the field that support only 15 bit modes, and there are also devices in the field that +support only 16 bit modes. Hence it is of vital importance that your application code support both +of these color depths to ensure maximum compatibility. + +Be prepared to support both 24 and 32 bits per pixel true color modes +If you are developing code to support 24 bit true color rendering, be prepared to find controllers +in the field that have the true color modes support as either 24 bits per pixel (3 bytes per pixel) or +32 bits per pixel (4 bytes per pixel). Generally the 32 bits per pixel modes are faster because the +pixels can be written with a single CPU double word access, however 32 bits per pixel modes +require a controller that has at least 2Mb of memory. + +Hence with controllers that have 2Mb or more of memory, be prepared to find support for only +32 bits per pixel modes and no 24 bits modes. + +Some controllers can't do double scanned modes +If you are developing a game or application that wishes to support 320x200 or 320x240 modes +(in any color depth), be prepared for situations where these modes do not exist. To be able to +initialize these modes on today's hardware requires support for double scanning, and there are +some controllers in the field that do not support this. On these controllers these modes can never + + +Page 14 VBE CORE FUNCTIONS VERSION 3.0 + + + + Programming with VBE/Core + + +be supported, so you application or game must be able to deal with the situation if these modes do +not exist. + +In lieu of these modes not being available, the controller may provide support for 320x400 and +320x480 modes which do not require double scanning (this is recommended for hardware vendors +who don't have double scanning support). One neat solution is to support these modes by +rendering your frames to a system memory buffer with a resolution 320x200 or 320x240, and +then do a copy to the graphics screen with a 2x vertical stretch (just duplicate every scanline twice +in software). The end result will look identical to a real 320x200 or 320x240 mode, and you will +only lose a small amount in overall performance (and it will be much faster than rendering directly +to a 320x400 or 320x480 screen for graphics intensive games). + +Check if VGA Compatible Before Touching Any VGA Registers +Many developers find that there is an irresistible urge to push the boundaries of performance, and +they will try anything and everything they can do attain these goals. One of the things that is +commonly done is to perform weird and wonderful feats of magic using some of the standard +VGA registers. This does work, and work well on VGA compatible graphics cards, but not on all +cards! + +If the graphics controller is based on a NonVGA graphics hardware technology (and many +popular ones and many newer ones are), in the SuperVGA graphics modes the VGA registers +simply do not exist anymore, and attempting to synch to these registers will put your code into an +infinite loop. So be forewarned that doing any fiddling with the standard VGA registers is asking +for trouble on certain graphics card that use NonVGA controllers to program the SuperVGA +graphics modes (and lots more of these are coming out). + +There is however a solution for VBE 2.0 and above controllers. There is a bit in the VBE +modeInfoBlock for every graphics mode that indicates whether that mode is a NonVGA mode or +VGA compatible mode. If this bit is set indicating that a NonVGA controller is being used to +program the desired graphics mode, you must not do anything related to re-programming any of +the standard VGA registers. In these cases you must fallback onto generic code that will perform +all its graphics card interaction through the standard VBE 2.0 and above services. + +Check if VGA Compatible Before Directly Programming the DAC +Another area of concern is programming the color palette in 256 color modes. Once again the +same problem occurs when programming the palette for NonVGA controllers; the VGA palette +registers no longer exist and attempting to program the palette via these registers will simply do +nothing. Even worse attempting to synch to the vertical or horizontal retrace will also cause the +system to get into an infinite loop. + +Hence if you need to program the color palette on a NonVGA controller, you must use the +supplied VBE 2.0 and above palette programming routines rather than programming the palette +directly. Make sure you check the NonVGA attribute bit as discussed above, and if a NonVGA + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 15 + + + +VBE Overview + + +mode is detected you will have to program the palette via the standard VBE 2.0 and above +services. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Page 16 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + + + VBE Function Reference + + +This chapter describes in detail each of the functions defined by the VBE standard. VBE +functions are called from real mode using the INT 10h software interrupt vector, passing +arguments in the 80X86 registers. The INT 10h interrupt handler first determines if a VBE +function has been requested, and if so, processes that request. Otherwise control is passed to the +standard VGA BIOS for completion. Starting with VBE 3.0, VBE functions can also be called +directly from protected mode via the protected mode entry point. When called via the protected +mode entry point, the VBE functions execute as 16-bit protected mode code which can be called +directly from any 16-bit or 32-bit protected mode operating system or application. + +All VBE functions are called with the AH register set to 4Fh to distinguish them from the +standard VGA BIOS functions. The AL register is used to indicate which VBE function is to be +performed. For supplemental or extended functionality the BL register is used when appropriate +to indicate a specific subfunction. + +Functions 00h-0Fh have been reserved for Standard VBE function numbers; Functions 10h-FFh +are reserved for VBE Supplemental Specifications. + +In addition to the INT 10h interface and protected mode entry point, a simple 32-bit Protected +Mode Interface is available and is described below. In cases where there is both a standard +interface and a 32-bit protected mode interface, the register parameters for both interfaces will be +defined one after another for the function specification. + +VBE Return Status + +The AX register is used to indicate the completion status upon return from VBE functions (except +for 32 bit protected mode functions; 32 bit versions of the functions do not return any status +information or return codes). If VBE support for the specified function is available, the 4Fh value +passed in the AH register on entry is returned in the AL register. If the VBE function completed +successfully, 00h is returned in the AH register. Otherwise the AH register is set to indicate the +nature of the failure. + +VBE RETURN STATUS + + AL == 4Fh: Function is supported + AL != 4Fh: Function is not supported + AH == 00h: Function call successful + AH == 01h: Function call failed + AH == 02h: Function is not supported in the current hardware configuration + AH == 03h: Function call invalid in current video mode + + + VBE CORE FUNCTIONS VERSION 3.0 Page 17 + + + +VBE Overview + + + +Note: Applications should treat any non-zero value in the AH register as a general failure + condition as later versions of the VBE may define additional error codes. + + +VBE Mode Numbers + +Standard VGA mode numbers are 7 bits wide and presently range from 00h to 13h. OEMs have +defined extended display modes in the range 14h to 7Fh. Values from 80h to FFh cannot be used, +since VGA BIOS Function 00h (Set video mode) interprets bit 7 as a flag to clear or preserve +display memory. +Due to the limitations of 7-bit mode numbers, the optional VBE mode numbers are 14 bits wide. +To initialize a VBE mode, the mode number is passed in the BX register to VBE Function 02h +(Set VBE mode). +The format of VBE mode numbers is as follows: + + D0-D8 = Mode number + If D8 == 0, this is not a VESA defined VBE mode + If D8 == 1, this is a VESA defined VBE mode + D9-D12 = Reserved by VESA for future expansion (= 0) + D11 = Refresh Rate Control Select + If D11 == 0, Use current BIOS default refresh rate + If D11 == 1, Use user specified CRTC values for refresh rate + D12-13 = Reserved for VBE/AF (must be 0) + D14 = Linear/Flat Frame Buffer Select + If D14 == 0, Use Banked/Windowed Frame Buffer + If D14 == 1, Use Linear/Flat Frame Buffer + D15 = Preserve Display Memory Select + If D15 == 0, Clear display memory + If D15 == 1, Preserve display memory +Thus, VBE mode numbers begin at 100h. This mode numbering scheme implements standard +7-bit mode numbers for OEM-defined modes (OEM defined modes are those that can be set via +the Standard VGA BIOS). Standard VGA modes may be initialized through VBE Function 02h +(Set VBE mode) simply by placing the mode number in BL and clearing the upper byte (BH). 7- +bit OEM-defined display modes may be initialized in the same way. Note that VBE modes may +only be set if the mode exists in the VideoModeList pointed to by the VideoModePTR returned in +Function 00h, while Standard VGA modes and OEM defined 7 bit modes may be initialized +without a corresponding entry in the VideoModeList and a mode info block. The exception to +this requirement is the VBE mode number 81FFh. +To date, VESA has defined one special 7-bit mode number, 6Ah, for the 800x600, 16-color, +4-plane graphics mode. The corresponding 15-bit mode number for this mode is 102h. +The following VBE mode numbers have been previously defined by VESA: + + + +Page 18 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + +GRAPHICS TEXT +15-bit 7-bit Resolution Colors 15-bit 7-bit Columns Rows +mode mode mode mode +number number number number +100h - 640x400 256 108h - 80 60 +101h - 640x480 256 109h - 132 25 +102h 6Ah 800x600 16 10Ah - 132 43 +103h - 800x600 256 10Bh - 132 50 +104h - 1024x768 16 10Ch - 132 60 +105h - 1024x768 256 +106h - 1280x1024 16 +107h - 1280x1024 256 +10Dh - 320x200 32K (1:5:5:5) +10Eh - 320x200 64K (5:6:5) +10Fh - 320x200 16.8M (8:8:8) +110h - 640x480 32K (1:5:5:5) +111h - 640x480 64K (5:6:5) +112h - 640x480 16.8M (8:8:8) +113h - 800x600 32K (1:5:5:5) +114h - 800x600 64K (5:6:5) +115h - 800x600 16.8M (8:8:8) +116h - 1024x768 32K (1:5:5:5) +117h - 1024x768 64K (5:6:5) +118h - 1024x768 16.8M (8:8:8) +119h - 1280x1024 32K (1:5:5:5) +11Ah - 1280x1024 64K (5:6:5) +11Bh - 1280x1024 16.8M (8:8:8) +81FFh Special Mode (see below for details) + +Note: Starting with VBE version 2.0, VESA will no longer define new VESA mode numbers + and it will no longer be mandatory to support these old mode numbers. OEM's who wish + to add new VBE mode numbers to their implementations, must make sure that all new + modes are defined with mode numbers above 0x100, However, it is highly recommended + that BIOS implementations continue to support these mode numbers for compatibility + with older software and add new mode numbers after the last VESA defined mode + number). VBE 2.0-aware applications should follow the guidelines in Appendix 5 - + Application Programming Considerations - for setting a desired mode. + +Note: Mode 81FFh is a special mode designed to preserve the current memory contents and give + access to the entire video memory. This mode is especially useful for saving the entire + video memory contents before going into a state that could lose the contents (e.g., set this + mode to gain access to all video memory to save it before going into a volatile power + down state). This mode is required because the entire video memory contents are not + always accessible in every mode. It is recommended that this mode be packed pixel in + format, and a ModeInfoBlock must be defined for it. However, it should not appear in the + + VBE CORE FUNCTIONS VERSION 3.0 Page 19 + + + +VBE Overview + + + VideoModeList. Look in the ModeInfoBlock to determine if paging is required and how + paging is supported if it is. Also note that there are no implied resolutions or timings + associated with this mode. + +Note: Future display resolutions will be defined by VESA display vendors. The color depths will + not be specified and new mode numbers will not be assigned for these resolutions. For + example, if the VESA display vendors define 1600x1200 as a VESA resolution, + application developers should target their display resolution for 1600x1200 rather than + choosing an arbitrary resolution like 1550x1190. The VBE implementation should be + queried to get the available resolutions and color depths and the application should be + flexible enough to work with this list. Appendix 5 gives a detailed summary of the way an + application should go about selecting and setting modes. + + +VBE Far Pointers + +Throughout this specification references will be made to a pointer of the type `vbeFarPtr'. This is +a DWORD pointer that can have two different interpretations depending on whether the BIOS is +being called via the real mode INT 10h software interrupt, or via the protected mode entry point. +When functions are called via the real mode INT 10h software interrupt, a `vbeFarPtr' will be a +real mode segment:offset style pointer to a memory location below the 1Mb system memory +boundary. When functions are called via the protected mode entry point, a `vbeFarPtr' will be a +valid 16-bit protected mode selector:offset style pointer, the selector of which may point to the +base of the protected mode BIOS image loaded in memory, user data passed in to the protected +mode BIOS or to the information blocks passed in to the protected mode BIOS. In any case the +calling application and BIOS can simply reference the pointer as a 32-bit far pointer to access the +data, but should avoid doing any real mode specific pointer arithmetic on the selector:offset +values. + + + + + + + + + + + + + + + + + +Page 20 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + +Obtaining the Protected Mode Entry Point + +Starting with VBE/Core 3.0, all the VBE functions are optionally accessible from 16-bit and 32- +bit protected mode applications and operating systems via a new `Protected Mode Entry Point'. +The protected mode entry point defines a special location that can be used to directly call the +VBE functions as 16-bit protected mode code. The application or OS does not call the BIOS +code directly from protected mode, but first makes a copy of the BIOS image in a writeable +section of memory and then calls the code within this relocated memory block. The entry point is +located within a special `Protected Mode Information Block', which will be located somewhere +within the first 32Kb of the BIOS image (if this information block is not found, then the BIOS +does not support this new interface). The PM Info Block structure is defined as follows: + +PMInfoBlock struc +Signature db 'PMID' ; PM Info Block Signature +EntryPoint dw ? ; Offset of PM entry point within BIOS +PMInitialize dw ? ; Offset of PM initialization entry point +BIOSDataSel dw 0 ; Selector to BIOS data area emulation block +A0000Sel dw A000h ; Selector to access A0000h physical mem +B0000Sel dw B000h ; Selector to access B0000h physical mem +B8000Sel dw B800h ; Selector to access B8000h physical mem +CodeSegSel dw C000h ; Selector to access code segment as data +InProtectMode db 0 ; Set to 1 when in protected mode +Checksum db ? ; Checksum byte for structure +PMInfoBlock ends + +To find the PMInfoBlock the application must scan the BIOS image looking for the appropriate +signature. When a potential info block has been found, the application must then perform a +checksum on the PMInfoBlock by adding the byte values of all entries in the block. If the block is +valid, the sum of all bytes should be zero (the Checksum byte is used to force the result of the +sum to zero). + +Note: The protected mode entry point is optional, and may not be implemented in some VBE 3.0 + BIOS'es. Also note that the VESA VBE/AF Accelerator Functions specifications provide + an alternative protected mode environment, so application programmers looking for + protected mode support may want to take a look at the VBE/AF specification. + +Description of the PMInfoBlock structure fields: + +The Signature field contains the special signature that is used to identify the PMInfoBlock +located within the BIOS image. + +The EntryPoint field contains the offset of the Protected Mode Entry Point from the start of the +BIOS image. This offset is used to create a pointer for directly calling the protected mode entry +point from both 16-bit and 32-bit protected mode code. + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 21 + + + +VBE Overview + + +The PMInitialize field contains the offset of a function for initializing the protected mode BIOS +code. The calling application must fill in the PMInfo block with valid selectors for protected mode +operation, and then call the PMInitialize function before calling any functions via the protected +mode entry point. The PMInitialize function is responsible for initializing any internal variables in +the BIOS that may be different in protected mode such as internal pointers to font tables or other +data (using the CodeSegSel selector to address variables within the code segment). + +The BIOSDataSel field contains a protected mode selector that references a memory block of at +least 600h bytes in length that will be cleared to all zeroes. This data block is used to provide a +memory region that the BIOS can use for caching information across calls to the BIOS functions, +and essentially will be used to emulate the first 600h bytes of low DOS memory which will no +longer be present when running in protected mode. The real mode BIOS will always set this field +to 0 so that real mode code can directly access the real BIOS data area. If the BIOS relies on +certain values being present in this data block, the PMInitialize function should be used to fill in +this block with default values for protected mode operation. This selector should be a 16-bit data +selector with a minimum limit of 600h bytes with read/write permissions. + +The A0000Sel, B0000Sel and B8000Sel field's contain selectors that point to the A0000h, +B0000h and B8000h physical memory areas. These selectors are used by the protected mode +BIOS code when it needs to access these physical memory areas (for clearing the screen, or +accessing memory mapped registers etc.). The real mode BIOS will always set these fields to the +real mode segment values initially so that real mode BIOS code can directly access these memory +areas. These selectors should be 16-bit data selectors with a limit of 64Kb with read/write +permissions (32Kb for B800Sel). + +The CodeSegSel field contains a protected mode data selector that provides read/write access to +the BIOS image loaded in memory. This selector can be used by the protected mode code during +the PMInitialize function to self-modify portions of the code or internal pointers used during +protected mode operation. The real mode BIOS will always set this field to a value of C000h so +that real mode BIOS code can directly access the code segment. This selector should be a 16-bit +data selector with a limit of 64Kb with read/write permissions (it is not executable). + +The InProtectMode field is used to indicate to the BIOS code that it is running in protected +mode. By default the real mode BIOS will set this value to 0 to indicate that it is running in real +mode, and when the BIOS image has been relocated by the application, it will set this field to a +`1'. The BIOS code can then use this field to determine if it is running in real mode or protected +mode to fail functions that are not supported by the protected mode entry point. + +So to summarize, the steps involved in finding the protected mode entry point and setting up to +call the protected mode BIOS code is as follows: + + 1. Allocate a protected mode buffer large enough to hold the entire BIOS image (32Kb + normally). + + 2. Copy the BIOS image from the C0000h physical memory region to the protected + mode buffer. + + +Page 22 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + 3. Scan the BIOS image for the PMInfoBlock structure and check that the checksum for + the block is 0. + + 4. Allocate an empty (all zeros) block of memory for the BIOS data area emulation block + that is at least 600h bytes in length. Create a new data selector that points to the start + of this memory block and put the value of that selector into the BIOSDataSel field of + the PMInfoBlock. + + 5. Create selectors that point to the A0000h, B0000h and B8000h physical memory + locations (with lengths of 64Kb, 64Kb and 32Kb respectively). Put the values of these + selectors into the A0000Sel, B0000Sel and B8000Sel fields of the PMInfoBlock + respectively. + + 6. Create a read/write data selector that points to the loaded BIOS image and put the + value into the CodeSegSel field of the PMInfoBlock. + + 7. Set the InProtectMode field of the PMInfoBlock to a `1' to indicate to the BIOS code + that it is now running in protected mode. + + 8. Create a 16-bit code segment selector (execute and read permissions) that points to + the start of the protected mode BIOS buffer you have allocated. This selector and the + PMInitialize entry point from the PMInfoBlock provide a 16:16 or 16:32 (the offset + must be extended to 32-bit under a 32-bit OS) far pointer to the protected mode BIOS + initialization function. You should call this function first before calling any of the + functions via the protected mode entry point. + + 9. Create a 16-bit data segment selector that points to a region of memory at least 1024 + bytes in size that will be used as the protected mode stack for calls to the protected + mode BIOS code. This selector will have to be loaded into the SS selector before the + call, and the SP register should be cleared to zero (i.e.: SS:0 points to the start of the + 16-bit protected mode stack). The 16-bit protected mode stack is necessary so that if + the BIOS is using the stack to maintain local variables at runtime, those variables can + be correctly referenced via the 16-bit stack pointer. + + 10. Using the selector created in the above step and the protected mode entry point from + the PMInfoBlock, you now have a 16:16 or 16:32 (the offset must be extended to 32- + bit under a 32-bit OS) far pointer to the protected mode BIOS, which you can simply + call directly. Note that you do need to ensure that the stack is switched to the 16-bit + protected mode stack before the protected mode BIOS is called. + +Calling the Protected Mode Entry Point + +Calling the protected mode entry point is almost identical to calling the real mode INT 10h +functions. The only difference is that instead of issuing an INT 10h software interrupt, your code +will simply make a far call via the 16:16 or 16:32 pointer that defines the entry point for the +protected mode BIOS. A far call from 32-bit protected mode (16:32 pointer) to the protected + + VBE CORE FUNCTIONS VERSION 3.0 Page 23 + + + +VBE Overview + + +mode entry point will put the CPU into 16-bit protected mode, since the BIOS code segment is a +16-bit selector. + +Note however that any values passed in to the protected mode BIOS such as memory buffers +passed in ES:DI, will need to be valid 16:16 protected mode values. For 32-bit environments you +cannot simply pass in the 32-bit near pointers to the protected mode BIOS code, but must +translate them to 16:16 protected mode pointers. The steps to do this are relatively simple as +outlined below: + + 1. Find the linear base address of the default DS selector for your 32-bit data. + + 2. Add the above linear address to the 32-bit offset of the buffer you need to pass. + + 3. Create a new data selector that points to the linear base address calculated in step 2 + above, with a limit large enough to cover the entire buffer you are passing. + + 4. Call the VBE function with ES set to the selector created in step 3 and an offset of 0. + + 5. Destroy the selector created in step 3 (or alternatively re-use the same selector, just re- + assign the base address and length for every function call). + +Protected Mode Entry Point Functional Restrictions + +The protected mode entry point provides the capability to call and use the VBE defined functions +from 16-bit and 32-bit protected mode. However the following restrictions may apply (BIOS +vendors may implement the functionality if they feel so inclined, but it is not mandatory): + + * No support for any of the Standard VGA BIOS functions, only the VBE interface + functions. Calling the protected mode entry point for non-VBE functions may produce + unpredictable results. + + * No support for extended text modes, only graphics modes. Extended text modes + require access to VGA BIOS functionality which may not be provided via the + protected mode entry point. + + * None of the `Get' style functions such as 4F03h (Get Current Video Mode) or 4F07h + (Get Display Start) that return status information are supported by the protected mode + entry point. It is assumed this information will be cached by the operating system or + application internally. Calling these functions via the protected mode entry point may + result in undefined behavior. + + * Note that supplemental VBE services are not be restricted and BIOS implementers are + free to implement these services via the protected mode entry point. + + + + +Page 24 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + +Function 00h - Return VBE Controller Information + +Input: AX = 4F00h Return VBE Controller Information + ES:DI = Pointer to buffer in which to place + VbeInfoBlock structure + (VbeSignature should be set to 'VBE2' when + function is called to indicate VBE 3.0 information + is desired and the information block is 512 bytes in + size.) + +Output: AX = VBE Return Status + + +Note: All other registers are preserved. + +This required function returns the capabilities of the display controller, the revision level of the +VBE implementation, and vendor specific information to assist in supporting all display +controllers in the field. + +The purpose of this function is to provide information to the calling program about the general +capabilities of the installed VBE software and hardware. This function fills an information block +structure at the address specified by the caller. The VbeInfoBlock information block size is 256 +bytes for VBE 1.x, and 512 bytes for VBE 2.0+. + +The information block has the following structure: + +VbeInfoBlock struc +VbeSignature db 'VESA' ; VBE Signature +VbeVersion dw 0300h ; VBE Version +OemStringPtr dd ? ; VbeFarPtr to OEM String +Capabilities db 4 dup (?) ; Capabilities of graphics controller +VideoModePtr dd ? ; VbeFarPtr to VideoModeList +TotalMemory dw ? ; Number of 64kb memory blocks + ; Added for VBE 2.0+ +OemSoftwareRev dw ? ; VBE implementation Software revision +OemVendorNamePtr dd ? ; VbeFarPtr to Vendor Name String +OemProductNamePtr dd ? ; VbeFarPtr to Product Name String +OemProductRevPtr dd ? ; VbeFarPtr to Product Revision String +Reserved db 222 dup (?) ; Reserved for VBE implementation scratch + ; area +OemData db 256 dup (?) ; Data Area for OEM Strings +VbeInfoBlock ends + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 25 + + + +VBE Overview + + + +Note: All data in this structure is subject to change by the VBE implementation when VBE + Function 00h is called. Therefore, it should not be used by the application to store data of + any kind. + +Description of the VbeInfoBlock structure fields: + +The VbeSignature field is filled with the ASCII characters 'VESA' by the VBE implementation. +VBE 2.0+ applications should preset this field with the ASCII characters 'VBE2' to indicate to the +VBE implementation that the VBE 2.0 extended information is desired, and the VbeInfoBlock is +512 bytes in size. Upon return from VBE Function 00h, this field should always be set to 'VESA' +by the VBE implementation. + +The VbeVersion is a BCD value which specifies what level of the VBE standard is implemented +in the software. The higher byte specifies the major version number. The lower byte specifies the +minor version number. + +Note: The BCD value for VBE 3.0 is 0300h and the BCD value for VBE 1.2 is 0102h. In the + past we have had some applications misinterpreting these BCD values. For example, BCD + 0102h was interpreted as 1.02, which is incorrect. + +The OemStringPtr is a VbeFarPtr to a null terminated OEM-defined string. This string may be +used to identify the graphics controller chip or OEM product family for hardware specific display +drivers. There are no restrictions on the format of the string. This pointer may point into either +ROM or RAM, depending on the specific implementation. VBE 3.0 BIOS implementations may +place this string in the OemData area within the VbeInfoBlock if 'VBE2' is preset in the +VbeSignature field on entry to Function 00h. + +Note: The length of the OEMString is not defined, but for space considerations, we recommend + a string length of less than 256 bytes. + +The Capabilities field indicates the support of specific features in the graphics environment. +The bits are defined as follows: + +D0 = 0 DAC is fixed width, with 6 bits per primary color + = 1 DAC width is switchable to 8 bits per primary color +D1 = 0 Controller is VGA compatible + = 1 Controller is not VGA compatible +D2 = 0 Normal RAMDAC operation + = 1 When programming large blocks of information to the RAMDAC, + use the blank bit in Function 09h. +D3 = 0 No hardware stereoscopic signaling support + = 1 Hardware stereoscopic signaling supported by controller +D4 = 0 Stereo signaling supported via external VESA stereo connector + = 1 Stereo signaling supported via VESA EVC connector +D5-31 = Reserved + + +Page 26 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + +BIOS Implementation Note: The DAC must always be restored to 6 bits per primary as default +upon a mode set. If the DAC has been switched to 8 bits per primary, the mode set must restore +the DAC to 6 bits per primary to so the application developer does not have to reset it. + +Application Developer's Note: If a DAC is switchable, you can assume that the DAC will be +restored to 6 bits per primary upon a mode set. For an application to use a DAC, the application +program is responsible for setting the DAC to 8 bits per primary mode using Function 08h. + +VGA compatibility is defined as supporting all standard IBM VGA modes, fonts and I/O ports; +however, VGA compatibility doesn't guarantee that all modes which can be set are VGA +compatible, or that the 8x14 font is available. + +The need for D2 = 1 "program the RAMDAC using the blank bit in Function 09h" is for older +style RAMDACs, where programming the RAM values during display time causes a "snow-like" +effect on the screen. Some newer style RAMDACs don't have this limitation and can easily be +programmed at any time, but older RAMDACs require that they be programmed during the +vertical retrace period so as not to display the snow while values change during display time. This +bit informs the software that it should make the function call with BL=80h rather than BL=00h to +ensure the minimization of the "snow-like" effect. + +Bit D3 will be set to a 1 if the hardware supports the new VESA stereoscopic synchronization +signal either via the VESA stereo connector or via the VESA EVC connector. This bit is primarily +intended for informational purposes, so that application software can automatically use hardware +signaling when it is available, and default back to a software signaling method when one is not +available. + +Bit D4 will be set to a 1 if a VESA EVC connector is available and the stereoscopic +synchronization signal is available on this connector. Bit D4 will be set to a 0 if the VESA stereo +connector contains the synchronization information. If bit D3 is 0, this bit will be set to 0 by the +BIOS, and should be ignored by the application programmer. Note that if a VESA EVC +connector is present in the system, it is mandatory that it be used for the stereoscopic +synchronization signal. + +The VideoModePtr is a VbeFarPtr that points to a list of mode numbers for all display modes +supported by the VBE implementation. Each mode number occupies one word (16 bits). The list +of mode numbers is terminated by a -1 (0FFFFh). The mode numbers in this list represent all of +the potentially supported modes by the display controller. Refer to Chapter 3 for a description of +VESA VBE mode numbers. VBE 3.0 BIOS implementations may place this mode list in the +Reserved area of the VbeInfoBlock if 'VBE2' is preset in the VbeSignature field on entry to +Function 00h, or have it statically stored within the VBE implementation. + +Note: It is responsibility of the application to verify the actual availability of any mode returned + by this function through the Return VBE Mode Information (VBE Function 01h) call. + Some of the returned modes may not be available due to the actual amount of memory + physically installed on the display board or due to the capabilities of the attached monitor. + + + VBE CORE FUNCTIONS VERSION 3.0 Page 27 + + + +VBE Overview + + + +Note: If a VideoModeList is found to contain no entries (starts with 0FFFFh), it can be assumed + that the VBE implementation is a "stub" implementation where only Function 00h is + supported for diagnostic or "Plug and Play" reasons. These stub implementations are not + VBE 3.0 compliant and should only be implemented in cases where no space is available + to implement the entire VBE. + +Note: The VBE 3.0 protected mode entry point may not provide support for extended text + modes nor Standard VGA graphics modes. Any attempt to set one of these modes via the + protected mode entry point will have an undefined effect. + +The TotalMemory field indicates the maximum amount of memory physically installed and +available to the frame buffer in 64KB units. (e.g. 256KB = 4, 512KB = 8) Not all video modes +can address all this memory, see the ModeInfoBlock for detailed information about the +addressable memory for a given mode. + +The OemSoftwareRev field is a BCD value which specifies the OEM revision level of the VBE +software. The higher byte specifies the major version number. The lower byte specifies the minor +version number. This field can be used to identify the OEM's VBE software release. This field is +only filled in when 'VBE2' is preset in the VbeSignature field on entry to Function 00h. + +The OemVendorNamePtr is a VbeFarPtr to a null-terminated string containing the name of the +vendor which produced the display controller board product. (This string may be contained in the +VbeInfoBlock or the VBE implementation.) This field is only filled in when 'VBE2' is preset in +the VbeSignature field on entry to Function 00h. (Note: the length of the strings +OemProductRev, OemProductName and OemVendorName (including terminators) summed, +must fit within a 256 byte buffer; this is to allow for return in the OemData field if necessary.). + +The OemProductNamePtr is a VbeFarPtr to a null-terminated string containing the product +name of the display controller board. (This string may be contained in the VbeInfoBlock or the +VBE implementation.) This field is only filled in when 'VBE2' is preset in the VbeSignature field +on entry to Function 00h. (Note: the length of the strings OemProductRev, OemProductName +and OemVendorName (including terminators) summed, must fit within a 256 byte buffer; this is to +allow for return in the OemData field if necessary.). + +The OemProductRevPtr is a VbeFarPtr to a null-terminated string containing the revision or +manufacturing level of the display controller board product. (This string may be contained in the +VbeInfoBlock or the VBE implementation.) This field can be used to determine which +production revision of the display controller board is installed. This field is only filled in when +'VBE2' is preset in the VbeSignature field on entry to Function 00h. (Note: the length of the +strings OemProductRev, OemProductName and OemVendorName (including terminators) +summed, must fit within a 256 byte buffer; this is to allow for return in the OemData field if +necessary.). + +The Reserved field is a space reserved for dynamically building the VideoModeList if necessary if +the VideoModeList is not statically stored within the VBE implementation. This field should not + + +Page 28 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + +be used for anything else, and may be reassigned in the future. Application software should not +assume that information in this field is valid. + +The OemData field is a 256 byte data area that is used to return OEM information returned by +VBE Function 00h when 'VBE2' is preset in the VbeSignature field. The OemVendorName +string, OemProductName string and OemProductRev string may be copied into this area by the +VBE implementation. This area will only be used by VBE implementations 2.0 and above when +'VBE2' is preset in the VbeSignature field. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 29 + + + +VBE Overview + + + +Function 01h - Return VBE Mode Information + +Input: AX = 4F01h Return VBE mode information + CX = Mode number + ES:DI = Pointer to ModeInfoBlock structure + +Output: AX = VBE Return Status + +Note: All other registers are preserved. + +This required function returns extended information about a specific VBE display mode from the +mode list returned by VBE Function 00h. This function fills the mode information block, +ModeInfoBlock, structure with technical details on the requested mode. The ModeInfoBlock +structure is provided by the application with a fixed size of 256 bytes. + +Information can be obtained for all listed modes in the VideoModeList returned in Function 00h. +If the requested mode cannot be used or is unavailable, a bit will be set in the ModeAttributes +field to indicate that the mode is not supported in the current configuration. + +The mode information block has the following structure: + +ModeInfoBlock struc + +; Mandatory information for all VBE revisions +ModeAttributes dw ? ; mode attributes +WinAAttributes db ? ; window A attributes +WinBAttributes db ? ; window B attributes +WinGranularity dw ? ; window granularity +WinSize dw ? ; window size +WinASegment dw ? ; window A start segment +WinBSegment dw ? ; window B start segment +WinFuncPtr dd ? ; real mode pointer to window function +BytesPerScanLine dw ? ; bytes per scan line + +; Mandatory information for VBE 1.2 and above +XResolution dw ? ; horizontal resolution in pixels or characters3 +YResolution dw ? ; vertical resolution in pixels or characters +XCharSize db ? ; character cell width in pixels +YCharSize db ? ; character cell height in pixels +NumberOfPlanes db ? ; number of memory planes +BitsPerPixel db ? ; bits per pixel +NumberOfBanks db ? ; number of banks + + + +3Pixels in graphics modes, characters in text modes. + + +Page 30 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + +MemoryModel db ? ; memory model type +BankSize db ? ; bank size in KB +NumberOfImagePages db ? ; number of images +Reserved db 1 ; reserved for page function + +; Direct Color fields (required for direct/6 and YUV/7 memory models) +RedMaskSize db ? ; size of direct color red mask in bits +RedFieldPosition db ? ; bit position of lsb of red mask +GreenMaskSize db ? ; size of direct color green mask in bits +GreenFieldPosition db ? ; bit position of lsb of green mask +BlueMaskSize db ? ; size of direct color blue mask in bits +BlueFieldPosition db ? ; bit position of lsb of blue mask +RsvdMaskSize db ? ; size of direct color reserved mask in bits +RsvdFieldPosition db ? ; bit position of lsb of reserved mask +DirectColorModeInfo db ? ; direct color mode attributes + +; Mandatory information for VBE 2.0 and above +PhysBasePtr dd ? ; physical address for flat memory frame buffer +Reserved dd 0 ; Reserved - always set to 0 +Reserved dw 0 ; Reserved - always set to 0 + +; Mandatory information for VBE 3.0 and above +LinBytesPerScanLine dw ? ; bytes per scan line for linear modes +BnkNumberOfImagePages db ? ; number of images for banked modes +LinNumberOfImagePages db ? ; number of images for linear modes +LinRedMaskSize db ? ; size of direct color red mask (linear modes) +LinRedFieldPosition db ? ; bit position of lsb of red mask (linear modes) +LinGreenMaskSize db ? ; size of direct color green mask (linear modes) +LinGreenFieldPositiondb ? ; bit position of lsb of green mask (linear modes) +LinBlueMaskSize db ? ; size of direct color blue mask (linear modes) +LinBlueFieldPosition db ? ; bit position of lsb of blue mask (linear modes) +LinRsvdMaskSize db ? ; size of direct color reserved mask (linear modes) +LinRsvdFieldPosition db ? ; bit position of lsb of reserved mask (linear modes) +MaxPixelClock dd ? ; maximum pixel clock (in Hz) for graphics mode + +Reserved db 189 dup (?) ; remainder of ModeInfoBlock +ModeInfoBlock ends + + +The ModeAttributes field describes certain important characteristics of the graphics mode. + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 31 + + + +VBE Overview + + +The ModeAttributes field is defined as follows: +D0 = Mode supported by hardware configuration + 0 = Mode not supported in hardware + 1 = Mode supported in hardware +D1 = 1 (Reserved) +D2 = TTY Output functions supported by BIOS + 0 = TTY Output functions not supported by BIOS + 1 = TTY Output functions supported by BIOS +D3 = Monochrome/color mode (see note below) + 0 = Monochrome mode + 1 = Color mode +D4 = Mode type + 0 = Text mode + 1 = Graphics mode +D5 = VGA compatible mode + 0 = Yes + 1 = No +D6 = VGA compatible windowed memory mode is available + 0 = Yes + 1 = No +D7 = Linear frame buffer mode is available + 0 = No + 1 = Yes +D8 = Double scan mode is available + 0 = No + 1 = Yes +D9 = Interlaced mode is available + 0 = No + 1 = Yes +D10 = Hardware triple buffering support + 0 = No + 1 = Yes +D11 = Hardware stereoscopic display support + 0 = No + 1 = Yes +D12 = Dual display start address support + 0 = No + 1 = Yes + D13-D15 = Reserved + +Bit D0 is set to indicate that this mode can be initialized in the present hardware configuration. +This bit is reset to indicate the unavailability of a graphics mode if it requires a certain monitor +type, more memory than is physically installed, etc. + + + +Page 32 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + +Bit D1 was used by VBE 1.0 and 1.1 to indicate that the optional information following the +BytesPerScanLine field were present in the data structure. This information became mandatory +with VBE version 1.2 and above, so D1 is no longer used and should be set to 1. The Direct +Color fields are valid only if the MemoryModel field is set to a 6 (Direct Color) or 7 (YUV). + +Bit D2 indicates whether the video BIOS has support for output functions like TTY output, +scroll, etc. in this mode. TTY support is recommended but not required for all extended text and +graphic modes. If bit D2 is set to 1, then the INT 10h BIOS must support all of the standard +output functions listed below. + +All of the following TTY functions must be supported when this bit is set: + + 01 Set Cursor Size + 02 Set Cursor Position + 06 Scroll TTY window up or Blank Window + 07 Scroll TTY window down or Blank Window + 09 Write character and attribute at cursor position + 0A Write character only at cursor position + 0E Write character and advance cursor + +Bit D3 is set to indicate color modes, and cleared for monochrome modes. + +Bit D4 is set to indicate graphics modes, and cleared for text modes. + +Note: Monochrome modes map their CRTC address at 3B4h. Color modes map their CRTC + address at 3D4h. Monochrome modes have attributes in which only bit 3 (video) and bit 4 + (intensity) of the attribute controller output are significant. Therefore, monochrome text + modes have attributes of off, video, high intensity, blink, etc. Monochrome graphics + modes are two plane graphics modes and have attributes of off, video, high intensity, and + blink. Extended two color modes that have their CRTC address at 3D4h, are color modes + with one bit per pixel and one plane. The standard VGA modes, 06h and 11h, would be + classified as color modes, while the standard VGA modes 07h and 0Fh would be classified + as monochrome modes. + +Bit D5 is used to indicate if the mode is compatible with the VGA hardware registers and I/O +ports. If this bit is set, then the mode is NOT VGA compatible and no assumptions should be +made about the availability of any VGA registers. If clear, then the standard VGA I/O ports and +frame buffer address defined in WinASegment and/or WinBSegment can be assumed. + +Bit D6 is used to indicate if the mode provides Windowing or Banking of the frame buffer into +the frame buffer memory region specified by WinASegment and WinBSegment. If set, then +Windowing of the frame buffer is NOT possible. If clear, then the device is capable of mapping +the frame buffer into the segment specified in WinASegment and/or WinBSegment. (This bit is +used in conjunction with bit D7, see table following D7 for usage). + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 33 + + + +VBE Overview + + +Bit D7 indicates the presence of a Linear Frame Buffer memory model. If this bit is set, the +display controller can be put into a flat memory model by setting the mode (VBE Function 02h) +with the Flat Memory Model bit set. (This bit is used in conjunction with bit D6, see following +table for usage) + + D7 D6 + Windowed frame buffer only 0 0 + n/a 0 1 + Both Windowed and Linear4 1 0 + Linear frame buffer only 1 1 + +Bit D8 indicates if the video mode can support double scanning or not. If this bit is set, the video +mode can be initialized with the double scan flag set and the vertical resolution of the mode will +be half the value of the vertical CRTC values. Double scanning is necessary to be able to support +200, 240 and 300 scanline graphics modes on modern controllers. Note that all 200, 240 and 300 +scanline modes will have the double scan bit set. + +Bit D9 indicates if the video mode can support interlaced operation or not. If this bit is set, the +video mode can be initialized with the interlaced flag set and the controller will be initialized for +an interlaced graphics mode. Note that some controllers may not support interlaced operation, so +you must check this bit before attempting to initialize an interlaced mode. + +Bit D10 indicates if the video mode can support hardware triple buffering or not. If this bit is set, +the application program can use Function 4F07h, subfunction 04h to implement hardware triple +buffering. If hardware triple buffering is not supported, the application program may use the new +02/82h subfunctions to set the display start address, but cannot use subfunction 04h to get status +information on the scheduled display start address change. + +Bit D11 indicates if the video mode can support hardware stereoscopic displays or not (for LC +shutter glasses). If this bit is set, the application program can use Function 4F07h, subfunctions +02h/05/06h/82h to implement hardware stereoscopic display buffering. If bit D12 is also set, +applications can take advantage of dual display start address hardware when present. If bit D10 is +also set, applications can use subfunction 04h to get status information on the scheduled display +start address change. Note that it is possible for hardware to support stereoscopic display +buffering but not support hardware triple buffering. + +Bit D12 indicates if the video mode can support dual display start addresses or not (for LC shutter +glasses). If this bit is set, the application program can use Function 4F07h, subfunctions 03h/83h +to implement hardware stereoscopic display buffering using the dual display start address +capabilities, allowing the application to directly program the locations of the left and right image + + + + +4Use D14 of the Mode Number to select the Linear Buffer on a mode set (Function 02h). + + +Page 34 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + +buffers. If this bit is not set, applications will have to ensure that the left and right images are +consecutive in memory as explained in the section on using hardware stereoscopic above. + +The BytesPerScanLine field specifies how many full bytes are in each logical scanline in banked +modes. The logical scanline could be equal to or larger than the displayed scanline (the number of +physical pixels displayed). For linear modes please refer to the LinBytesPerScanLine field. + +The WinAAttributes and WinBAttributes describe the characteristics of the CPU windowing +scheme such as whether the windows exist and are read/writeable, as follows: + +D0 = Relocatable window(s) supported + 0 = Single non-relocatable window only + 1 = Relocatable window(s) are supported +D1 = Window readable + 0 = Window is not readable + 1 = Window is readable +D2 = Window writeable + 0 = Window is not writeable + 1 = Window is writeable +D3-D7 = Reserved + +Even if windowing is not supported (bit D0 = 0 for both Window A and Window B), then an +application can assume that the display memory buffer resides at the location specified by +WinASegment and/or WinBSegment. + +WinGranularity specifies the smallest boundary, in KB, on which the window can be placed in +the frame buffer memory. The value of this field is undefined if Bit D0 of the appropriate +WinAttributes field is not set. +WinSize specifies the size of the window in KB. +Note: Don't confuse the WinGranularity field with the WinSize field. Most if not all controllers + have a WinSize of 64Kb and it is a safe assumption that this will always be the case. The + WinGranularity field may however be a value other than 64Kb, and some VBE BIOS'es + may have it set to 4Kb or 16Kb. + +WinASegment and WinBSegment address specify the segment addresses where the windows +are located in the CPU address space. Note that these values are real mode segment values, so to +convert the real 32 bit physical address you need to shift the values left 4 bits (ie: segment A000h +is physical address A0000h). Also note that if the hardware has only linear framebuffer modes +available, the values listed in here will be set to 0 indicating the banked framebuffer is not +available. + +WinFuncPtr specifies the segment:offset of the VBE memory windowing function. The +windowing function can be invoked either through VBE Function 05h, or by calling the function +directly. A direct call will provide faster access to the hardware paging registers than using VBE +Function 05h, and is intended to be used by high performance applications. If this field is NULL, + + VBE CORE FUNCTIONS VERSION 3.0 Page 35 + + + +VBE Overview + + +then VBE Function 05h must be used to set the memory window when paging is supported. This +direct call method uses the same parameters as VBE Function 05h including AX and for VBE 3.0 +implementations will return the correct Return Status. VBE 1.2 implementations and earlier, did +not require the Return Status information to be returned. For more information on the direct call +method, see the notes in VBE Function 05h and the sample code in Appendix 5. When function +4F01h is called via the protected mode entry point, this pointer is undefined and is not supported. + +The XResolution and YResolution specify the width and height in pixel elements or characters +for this display mode. In graphics modes, these fields indicate the number of horizontal and +vertical pixels that may be displayed. In text modes, these fields indicate the number of horizontal +and vertical character positions. The number of pixel positions for text modes may be calculated +by multiplying the returned XResolution and YResolution values by the character cell width and +height indicated in the XCharSize and YCharSize fields described below. + +The XCharSize and YCharSize specify the size of the character cell in pixels. This value is not +zero based (e.g. XCharSize for Mode 3 using the 9 point font will have a value of 9). + +The NumberOfPlanes field specifies the number of memory planes available to software in that +mode. For standard 16-color VGA graphics, this would be set to 4. For standard packed pixel +modes, the field would be set to 1. For 256-color non-chain-4 modes, where you need to do +banking to address all pixels, this value should be set to the number of banks required to get to all +the pixels (typically this would be 4 or 8). +The BitsPerPixel field specifies the total number of bits allocated to one pixel. For example, +a standard VGA 4 Plane 16-color graphics mode would have a 4 in this field and a packed pixel +256-color graphics mode would specify 8 in this field. The number of bits per pixel per plane can +normally be derived by dividing the BitsPerPixel field by the NumberOfPlanes field. + +The MemoryModel field specifies the general type of memory organization used in this mode. +The following models have been defined: + +00h = Text mode +01h = CGA graphics +02h = Hercules graphics +03h = Planar +04h = Packed pixel +05h = Non-chain 4, 256 color +06h = Direct Color +07h = YUV +08h-0Fh = Reserved, to be defined by VESA +10h-FFh = To be defined by OEM + +Note: VBE Version 1.1 and earlier defined Direct Color graphics modes with pixel formats + 1:5:5:5, 8:8:8, and 8:8:8:8 as a Packed Pixel model with 16, 24, and 32-bits per pixel, + respectively. In VBE Version 1.2 and later, the Direct Color modes use the Direct Color + memory model and use the MaskSize and FieldPosition fields of the ModeInfoBlock to + + +Page 36 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + describe the pixel format. BitsPerPixel is always defined to be the total memory size of the + pixel, in bits. + +NumberOfBanks. This is the number of banks in which the scan lines are grouped. The quotient +from dividing the scan line number by the number of banks is the bank that contains the scan line +and the remainder is the scan line number within the bank. For example, CGA graphics modes +have two banks and Hercules graphics mode has four banks. For modes that don't have scanline +banks (such as VGA modes 0Dh-13h), this field should be set to 1. + +The BankSize field specifies the size of a bank (group of scan lines) in units of 1 KB. For CGA +and Hercules graphics modes this is 8, as each bank is 8192 bytes in length. For modes that do not +have scanline banks (such as VGA modes 0Dh-13h), this field should be set to 0. + +The NumberOfImagePages field specifies the "total number minus one (-1)"of complete display +images that will fit into the frame buffer memory. The application may load more than one image +into the frame buffer memory if this field is non-zero, and move the display window within each of +those pages. This should only be used for determining the additional display pages which are +available to the application. Note that for VBE 3.0 implementations, this value will be the +maximum number of image pages available for both banked and linear modes. To find the actual +number of image pages available for either banked or linear modes, please refer to the +BnkNumberOfImagePages and LinNumberOfImagepages. + +Note: Many applications assume the size of an image page is always rounded up to a 64Kb + boundary, so the value returned in NumberOfImagePages should be computed by + rounding the size of an image page up to the next 64Kb increment. If this is not done, + some known applications may end up writing past the end of available video memory, + causing the system to become unstable. + +Note: If the ModeInfoBlock is for an IBM Standard VGA mode and the NumberOfImagePages + field contains more pages than would be found in a 256KB implementation, the TTY + support described in the ModeAttributes must be accurate. i.e., if the TTY functions are + claimed to be supported, they must be supported in all pages, not just the pages normally + found in the 256KB implementation. + +The Reserved field has been defined to support a future VBE feature and will always be set to +one in this version. + +The RedMaskSize, LinRedMaskSize, GreenMaskSize, LinGreenMaskSize, BlueMaskSize, +LinBlueMaskSize, RsvdMaskSize and LinRsvdMaskSize fields define the size, in bits, of the +red, green, and blue components of a direct color pixel. A bit mask can be constructed from the +MaskSize fields using simple shift arithmetic. For example, the MaskSize values for a Direct +Color 5:6:5 mode would be 5, 6, 5, and 0, for the red, green, blue, and reserved fields, +respectively. Note that in the YUV MemoryModel, the red field is used for V, the green field is +used for Y, and the blue field is used for U. The MaskSize fields should be set to 0 in modes using +a memory model that does not have pixels with component fields. For VBE 3.0 implementations it + + + VBE CORE FUNCTIONS VERSION 3.0 Page 37 + + + +VBE Overview + + +is possible to have different color formats in banked framebuffer and linear framebuffer modes. +The standard values list the framebuffer format for banked framebuffer modes. For linear modes +please refer to the LinXX variants. + +The RedFieldPosition, LinRedFieldPosition, GreenFieldPosition, LinGreenFieldPosition, +BlueFieldPosition, LinBlueFieldPosition, RsvdFieldPosition and LinRsvdFieldPosition +fields define the bit position within the direct color pixel or YUV pixel of the least significant bit +of the respective color component. A color value can be aligned with its pixel field by shifting the +value left by the FieldPosition. For example, the FieldPosition values for a Direct Color 5:6:5 +mode would be 11, 5, 0, and 0, for the red, green, blue, and reserved fields, respectively. Note +that in the YUV MemoryModel, the red field is used for V, the green field is used for Y, and the +blue field is used for U. The FieldPosition fields should be set to 0 in modes using a memory +model that does not have pixels with component fields. For VBE 3.0 implementations it is +possible to have different color formats in banked framebuffer and linear framebuffer modes. The +standard values list the framebuffer format for banked framebuffer modes. For linear modes please +refer to the LinXX variants. + +The DirectColorModeInfo field describes important characteristics of direct color modes. Bit +D0 specifies whether the color ramp of the DAC is fixed or programmable. If the color ramp is +fixed, then it can not be changed. If the color ramp is programmable, it is assumed that the red, +green, and blue lookup tables can be loaded by using VBE Function 09h (it is assumed all color +ramp data is 8 bits per primary). Bit D1 specifies whether the bits in the Rsvd field of the direct +color pixel can be used by the application or are reserved, and thus unusable. + +D0 = Color ramp is fixed/programmable + 0 = Color ramp is fixed + 1 = Color ramp is programmable +D1 = Bits in Rsvd field are usable/reserved + 0 = Bits in Rsvd field are reserved + 1 = Bits in Rsvd field are usable by the application + +The PhysBasePtr is a 32-bit physical address of the start of frame buffer memory when the +controller is in flat frame buffer memory mode. If this mode is not available, then this field will be +zero. Note that the physical address cannot be used directly by the application, but must be +translated by an operating system service to a linear address that can be used directly by the +application (ie: the OS must create the page tables to map in this memory). Under a DPMI +compatible environment this is done with DPMI function 0x800. Note also that it is possible for +the linear framebuffer memory to start at different locations for different modes. + +The LinBytesPerScanLine field specifies how many full bytes are in each logical scanline for +linear framebuffer modes if the linear framebuffer modes are different to the banked modes. The +logical scanline could be equal to or larger than the displayed scanline. VBE 3.0 applications +should look at this value for linear modes, as it is possible for the linear modes to have a different +logical scanline width than the banked modes. + + + +Page 38 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + +The BnkNumberOfImagePages field specifies the "total number minus one (-1)"of complete +display images that will fit into the frame buffer memory for the banked framebuffer version of the +video mode. The application may load more than one image into the frame buffer memory if this +field is non-zero, and move the display window within each of those pages. + +The LinNumberOfImagePages field specifies the "total number minus one (-1)"of complete +display images that will fit into the frame buffer memory for the linear framebuffer version of the +video mode. This is the linear framebuffer version of the above BnkNumberOfImagePages value. + +The MaxPixelClock field is a 32-bit value that specifies the maximum possible pixel clock that +can be selected in this graphics mode when a refresh controlled mode is selected, in units of Hz. +Any attempt to select a higher pixel clock will cause the mode set to fail. This field can be used to +determine what the maximum available refresh rate for the graphics mode will be. + +Note: Version 1.1 and later VBE will zero out all unused fields in the Mode Information Block, + always returning exactly 256 bytes. This facilitates upward compatibility with future + versions of the standard, as any newly added fields will be designed such that values of + zero will indicate nominal defaults or non-implementation of optional features. (For + example, a field containing a bit-mask of extended capabilities would reflect the absence of + all such capabilities.) Applications that wish to be backwards compatible to Version 1.0 + VBE should pre-initialize the 256 byte buffer before calling the Return VBE Mode + Information function. + + + + + + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 39 + + + +VBE Overview + + + +Function 02h - Set VBE Mode + +Input: AX = 4F02h Set VBE Mode + BX = Desired Mode to set + D0-D8= Mode number + D9-D10 = Reserved (must be 0) + D11 = 0 Use current default refresh rate + = 1 Use user specified CRTC values for refresh rate + D12-13 Reserved for VBE/AF (must be 0) + D14 = 0 Use windowed frame buffer model + = 1 Use linear/flat frame buffer model + D15 = 0 Clear display memory + = 1 Don't clear display memory + ES:DI = Pointer to CRTCInfoBlock structure +Output: AX = VBE Return Status + +Note: All other registers are preserved. + +This required function initializes the controller and sets a VBE mode. The format of VESA VBE +mode numbers is described earlier in this document. If the mode cannot be set, the BIOS should +leave the graphics environment unchanged and return a failure error code. + +If the requested mode number is not available, then the call will fail, returning AH=01h to indicate +the failure to the application. + +If bit D11 is set, the mode will be using the CRTC parameters and pixel clock values passed in the +CRTCInfoBlock structure, rather than using the default values that the BIOS is currently +configured for. This allows the application program or operating system drivers to calculate a new +set of CRTC values (preferably using the VESA Generalized Timing Formula (GTF) +specification) for the mode, and allow the refresh rate to be set to any supported value for the +hardware. If bit D11 is not set, the values passed in ES:DI will be ignored. + +If bit D14 is set, the mode will be initialized for use with a flat frame buffer model. The base +address of the frame buffer can be determined from the extended mode information returned by +VBE Function 01h. If D14 is set, and a linear frame buffer model is not available then the call will +fail. + +If bit D15 is not set, all reported image pages, based on Function 00h returned information +NumberOfImagePages, will be cleared to 00h in graphics mode, and 20 07 in text mode. Memory +over and above the reported image pages will not be changed. If bit D15 is set, then the contents +of the frame buffer after the mode change is undefined. Note, the 1-byte mode numbers used in +Function 00h of an IBM VGA compatible BIOS use D7 to signify the same thing as D15 does in +this function. If bit D7 is set and the application assumes it is similar to the IBM compatible mode +set using VBE Function 02h, the implementation will fail. VBE aware applications must use the +memory clear bit in D15. + + +Page 40 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + +Note: VBE BIOS 3.0 implementations may not clear the screen if bit D15 is set. VBE + implementations should clear the screen if possible to maintain backwards compatibility, + but this is not mandatory (for some controllers this may be difficult from real mode code if + the graphics mode is linear only, as the hardware linear framebuffer will not be accessible + from real mode code). Hence VBE 3.0 aware applications should always assume that the + screen may not have been cleared, and clear it before use. + +Note: The VBE 3.0 protected mode entry point may not provide support for extended text + modes nor Standard VGA graphics modes. Any attempt to set one of these modes via the + protected mode entry point will produce undefined results. + +The CRTC information block has the following structure: + +CRTCInfoBlock struc + +HorizontalTotal dw ? ; Horizontal total in pixels +HorizontalSyncStart dw ? ; Horizontal sync start in pixels +HorizontalSyncEnd dw ? ; Horizontal sync end in pixels +VerticalTotal dw ? ; Vertical total in lines +VerticalSyncStart dw ? ; Vertical sync start in lines +VerticalSyncEnd dw ? ; Vertical sync end in lines +Flags db ? ; Flags (Interlaced, Double Scan etc) +PixelClock dd ? ; Pixel clock in units of Hz +RefreshRate dw ? ; Refresh rate in units of 0.01 Hz + +Reserved db 40 dup (?) ; remainder of ModeInfoBlock +CRTCInfoBlock ends + + +The HorizontalTotal, HorizontalSyncStart, HorizontalSyncEnd, VerticalTotal, +VerticalSyncStart and VerticalSyncEnd fields define the default normalized CRTC values that +will be programmed if bit D13 is set to a 1. Note that the CRTC values are normalized values that +are always represented in pixels and lines, rather than in the format used to actually program the +hardware. Hence for a 640x480 graphics mode the CRTC values will always be the same +regardless of color depth. It is up to the VBE implementation to convert the values from the +normalized form to hardware specific values depending on the color depth and other hardware +specific requirements. Note also that the CRTC table does not contain any information about the +horizontal and vertical blank timing positions. It is up to the VBE implementation to determine +the correct blank timings to use for the mode when it is initialized depending on the constraints of +the underlying hardware. + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 41 + + + +VBE Overview + + +The Flags field defines the following flags that modify the operation of the mode as follows: + +D0 = Double Scan Mode Enable + 0 = Graphics mode is not double scanned + 1 = Graphics mode is double scanned +D1 = Interlaced Mode Enable + 0 = Graphics mode is non-interlaced + 1 = Graphics mode is interlaced +D2 = Horizontal sync polarity + 0 = Horizontal sync polarity is positive (+) + 1 = Horizontal sync polarity is negative (-) +D3 = Vertical sync polarity + 0 = Vertical sync polarity is positive (+) + 1 = Vertical sync polarity is negative (-) + +Bit D0 is used to determine whether the mode programmed into the hardware is double scanned +or not. When double scanning is specified, the vertical CRTC values passed in will be double what +the real vertical resolution will be. Double scanning is used to implement the 200, 240 and 300 +line graphics modes on modern controllers. Note that you must check the Double Scan bit in the +mode info block to determine if double scan mode is supported before attempting to initialize a +double scanned mode. Note also that all 200, 240 and 300 scanline modes require the double scan +bit to be set. + +Bit D1 is used to determine whether the mode programmed into the hardware is interlaced or +non-interlaced. The CRTC timings passed in will be identical for both interlaced and non- +interlaced modes, and it is up to the VBE implementation to perform any necessary scaling +between the hardware values and the normalized CRTC values in interlaced modes. Note that you +must check the Interlaced bit in the mode info block to determine if interlaced mode is supported +before attempting to initialize an interlaced mode. + +Bit D2 is used to determine the horizontal sync polarity for the CRTC values programmed into +the hardware. A value of 0 indicated a positive sync polarity, while a value of 1 indicates a +negative sync polarity. + +Bit D3 is used to determine the vertical sync polarity for the CRTC values programmed into the +hardware. A value of 0 indicated a positive sync polarity, while a value of 1 indicates a negative +sync polarity. + +The PixelClock field defines the normalized pixel clock that will be programmed into the +hardware. This value is represented in a 32 bit dword in units of Hz. For example to represent a +pixel clock of 25.18Mhz one would code a value of 25,180,000. Note that this is the normalized +pixel clock that will be programmed, not a physical pixel clock and does not include any scaling +factors for the mode in question. If the hardware needs the pixel clock to be scaled from the +normalized value this will be done by the VBE implementation internally. The normalized pixel +clock is necessary in order to be able to calculate the refresh rate for the specific graphics mode +using the following formula: + +Page 42 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + PixelClock + refreshRate = HorizontalTotal ×VerticalTotal + +For example a 1024x768 mode with a HTotal of 1360, VTotal of 802, a normalized pixel clock of +75Mhz might be computed as follows: + + 65 000 + , 000 + , + refreshRate = = 59 59 + . Hz + 1360 × 802 + +The RefreshRate field defines the refresh rate that the CRTC table defines. This value may not +actually be used by the BIOS but must be calculated by the application program using the above +formulas before initializing the mode. This entry may be used by the BIOS to identify any special +cases that may need to be handled when setting the mode for specific refresh rates. The value in +this field should be represented in units if .01 Hz (ie: a value 7200 represents a refresh rate of +72.00Hz). + +Note: VBE BIOS 2.0 or later implementations should also update the BIOS Data Area 40:87 + memory clear bit so that VBE Function 03h can return this flag. VBE BIOS 1.2 and + earlier implementations ignore the memory clear bit. + +Note: This call should not set modes not listed in the list of supported modes. The exception to + this is Standard VGA modes and 7 bit mode numbers, which may be initialized regardless + of whether the mode is listed and there is a ModeInfoBlock associated with the mode. + This is in contrast to VBE/Core 2.0 which requires 7 bit modes to have a ModeInfoBlock + associated with the mode. + + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 43 + + + +VBE Overview + + + +Function 03h - Return Current VBE Mode + +Input: AX = 4F03h Return current VBE Mode + +Output: AX = VBE Return Status + BX = Current VBE mode + D0-D13 = Mode number + D14 = 0 Windowed frame buffer model + = 1 Linear/flat frame buffer model + D15 = 0 Memory cleared at last mode set + = 1 Memory not cleared at last mode set + +Note: All other registers are preserved. + +This required function returns the current VBE mode. The format of VBE mode numbers is +described earlier in this document. + +Version 1.x Note: In a standard VGA BIOS, Function 0Fh (Read current video state) returns the +current graphics mode in the AL register. In D7 of AL, it also returns the status of the memory +clear bit (D7 of 40:87). This bit is set if the mode was set without clearing memory. In this VBE +function, the memory clear bit will not be returned in BX since the purpose of the function is to +return the video mode only. If an application wants to obtain the memory clear bit, it should call +the standard VGA BIOS Function 0Fh. + +Version 2.x Note: Unlike version 1.x VBE implementations, the memory clear flag will be +returned. The application should NOT call the standard VGA BIOS Function 0Fh if the mode +was set with VBE Function 02h. + +Note: The mode number returned must be the same mode number used in the VBE Function 02h + mode set. + +Note: This function is not guaranteed to return an accurate mode value if the mode set was not + done with VBE Function 02h. + +Note: This function is not supported via the VBE 3.0 protected mode entry point, and the results + are undefined if it is called. + + + + + + + + + +Page 44 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + +Function 04h - Save/Restore State + +Input: AX = 4F04h Save/Restore State + DL = 00h Return Save/Restore State buffer size + = 01h Save state + = 02h Restore state + CX = Requested states + D0= Save/Restore controller hardware state + D1= Save/Restore BIOS data state + D2= Save/Restore DAC state + D3= Save/Restore Register state + ES:BX = Pointer to buffer (if DL <> 00h) + +Output: AX = VBE Return Status + BX = Number of 64-byte blocks to hold the state + buffer (if DL=00h) + +Note: All other registers are preserved. + +This required function provides a complete mechanism to save and restore the display controller +hardware state. The functions are a superset of the three subfunctions under the standard VGA +BIOS Function 1Ch (Save/restore state) which does not guarantee that the extended registers of +the video device are saved or restored. The complete hardware state (except frame buffer +memory) should be saveable/restorable by setting the requested states mask (in the CX register) +to 000Fh. + + + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 45 + + + +VBE Overview + + + +Function 05h - Display Window Control + +Input: AX = 4F05h VBE Display Window Control +(16-bit) BH = 00h Set memory window + = 01h Get memory window + BL = Window number + = 00h Window A + = 01h Window B + DX = Window number in video memory in window + granularity units (Set Memory Window only) + +Output: AX = VBE Return Status + DX = Window number in window granularity units + (Get Memory Window only) +Input: BH = 00h Set memory window +(32-bit) BL = Window number + = 00h Window A + = 01h Window B + DX = Window number in video memory in window + granularity units (Set Memory Window only) + ES = Selector for memory mapped registers + +This required function sets or gets the position of the specified display window or page in the +frame buffer memory by adjusting the necessary hardware paging registers. To use this function +properly, the software should first use VBE Function 01h (Return VBE Mode information) to +determine the size, location and granularity of the windows. + +For performance reasons, it may be more efficient to call this function directly, without incurring +the INT 10h overhead. VBE Function 01h returns the real mode segment:offset of this +windowing function that may be called directly for this reason (for 32-bit protected mode refer to +VBE Function 0Ah for obtaining a 32-bit protected mode version of this function). Note that a +different entry point may be returned based upon the selected mode. Therefore, it is necessary to +retrieve this segment:offset specifically for each desired mode. Note also that the direct call +version of this function is not available via the 16-bit protected mode entry point. + +Application Developer's Note: This function is not intended for use in a linear frame buffer +mode, if this function is requested, the function call will fail with the VBE Completion code +AH=03h. + +VBE BIOS Implementation Note: If this function is called while in a linear frame buffer +memory model, this function must fail with completion code AH=03h. + + + + + +Page 46 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + +Note: In VBE 1.2 implementations, the direct far call version returns no Return Status + information to the application. Also, in the far call version, the AX and DX registers will + be destroyed. Therefore if AX and/or DX must be preserved, the application must do so + prior to making the far call. The application must still load the input arguments in BH, + BL, and DX (for Set Window). In VBE 3.0 implementations, the BIOS will return the + correct Return Status, and therefore the application must assume that AX and DX will be + destroyed. + +Note: In VBE 2.0 and later implementations the 32-bit version returns no Return Status + information to the application. Also note that the ES selector only needs to be passed if + the memory location in the Ports and Memory table returned by function 4F0Ah is not + defined. + +Note: Subfunction 01h (Get Memory Window) is not supported via the VBE 3.0 protected + mode entry point, and the results are undefined if it is called. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 47 + + + +VBE Overview + + + +Function 06h - Set/Get Logical Scan Line Length + +Input: AX = 4F06h VBE Set/Get Logical Scan Line Length + BL = 00h Set Scan Line Length in Pixels + = 01h Get Scan Line Length + = 02h Set Scan Line Length in Bytes + = 03h Get Maximum Scan Line Length + CX = If BL=00h Desired Width in Pixels + If BL=02h Desired Width in Bytes + (Ignored for Get Functions) +Output: AX = VBE Return Status + BX = Bytes Per Scan Line + CX = Actual Pixels Per Scan Line + (truncated to nearest complete pixel) + DX = Maximum Number of Scan Lines + +This required function sets or gets the length of a logical scan line. This allows an application to +set up a logical display memory buffer that is wider than the displayed area. VBE Function 07h +(Set/Get Display Start) then allows the application to set the starting position that is to be +displayed. +The desired width in pixels or bytes may not be achievable because of hardware considerations. +The next larger value will be selected that will accommodate the desired number of pixels or +bytes, and the actual number of pixels will be returned in CX. BX returns a value that when added +to a pointer into display memory will point to the next scan line. For example, in VGA mode 13h +this would be 320, but in mode 12h this would be 80. DX returns the number of logical scan lines +based upon the new scan line length and the total memory installed and usable in this display +mode. + +This function is also valid in VBE supported text modes. In VBE supported text modes the +application should convert the character line length to pixel line length by getting the current +character cell width through the XCharSize field returned in ModeInfoBlock, multiplying that +times the desired number of characters per line, and passing that value in the CX register. In +addition, this function will only work if the line length is specified in character granularity. i.e. in +8 dot modes only multiples of 8 will work. Any value which is not in character granularity will +result in a function call failure. + +Note: On a failure to set scan line length by setting a CX value too large, the function will fail + with error code 02h. + +Note: The value returned when BL=03h is the lesser of either the maximum line length that the + hardware can support, or the longest scan line length that would support the number of + lines in the current video mode. This function should return both the maximum scanline + width in bytes (BX) and in pixels (CX). + + +Page 48 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + +Note: Subfunction 01h (Get Scanline Length) is not supported via the VBE 3.0 protected mode + entry point, and the results are undefined if it is called. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 49 + + + +VBE Overview + + + +Function 07h - Set/Get Display Start + +Input: AX = 4F07h VBE Set/Get Display Start Control +(16-bit) BH = 00h Reserved and must be 00h + BL = 00h Set Display Start + = 01h Get Display Start + = 02h Schedule Display Start (Alternate) + = 03h Schedule Stereoscopic Display Start + = 04h Get Scheduled Display Start Status + = 05h Enable Stereoscopic Mode + = 06h Disable Stereoscopic Mode + = 80h Set Display Start during Vertical Retrace + = 82h Set Display Start during Vertical Retrace (Alternate) + = 83h Set Stereoscopic Display Start during Vertical Retrace + ECX = If BL=02h/82h Display Start Address in bytes + If BL=03h/83h Left Image Start Address in bytes + EDX = If BL=03h/83h Right Image Start Address in bytes + CX = If BL=00h/80h First Displayed Pixel In Scan Line + DX = If BL=00h/80h First Displayed Scan Line + +Output: AX = VBE Return Status + BH = If BL=01h Reserved and will be 0 + CX = If BL=01h First Displayed Pixel In Scan Line + If BL=04h 0 if flip has not occurred, not 0 if it has + DX = If BL=01h First Displayed Scan Line + +Input: BH = 00h Reserved and must be 00h +(32-bit) BL = 00h Set Display Start + = 80h Set Display Start during Vertical Retrace + CX = Bits 0-15 of display start address + DX = Bits 16-31 of display start address + ES = Selector for memory mapped registers + +This required function selects the pixel to be displayed in the upper left corner of the display. This +function can be used to pan and scroll around logical screens that are larger than the displayed +screen. This function can also be used to rapidly switch between two different displayed screens +for double buffered animation effects. + +For the VBE 2.0 32-bit protected mode version, the value passed in DX:CX is the 32 bit offset in +display memory, aligned to a plane boundary. For planar modes this means the value is the byte +offset in memory, but in 8+ bits per pixel modes this is the offset from the start of memory divided +by 4. Hence the value passed in is identical to the value that would be programmed into the +standard VGA CRTC start address register. Note that it is up to the protected mode application +to keep track of the color depth and scan line length to calculate the new start address. If a value +that is out of range is programmed, unpredictable results will occur. For VBE 3.0 the application + + +Page 50 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + +program may optionally pass the missing two bits of information in the top two bits of DX, to +allow for pixel perfect horizontal panning. For example (32-bit protected mode interface only): + + in planar modes: + + CX[15:0] = SA[15:0] + DX[15:0] = SA[31:16] + + in 8bpp and greater modes: + + CX[15:0] = SA[17:2] + DX[13:0] = SA[31:18] + DX[15:14] = SA[1:0] + +VBE 3.0 defines seven new subfunctions (02h, 03h, 04h, 05h, 06h, 82h, 83h) to support hardware +triple buffering and stereoscopic LC shutter glasses. Functions 02h and 03h schedule a display +start address change to occur during the next vertical retrace, and returns immediately. Function +04h can then be used by the application to determine if the scheduled flip has occurred or not, +which can be used for hardware triple buffering to avoid writing to the page being displayed by +the CRT controller. Functions 04h and 05h are used to enable and disable free running hardware +stereoscopic mode. Functions 82h and 83h schedule the display start address change to occur, and +then wait until the address has changed before returning. + +Note that functions 02h, 03h, 82h and 83h take the display start address as a byte offset in video +memory, whereas the VBE 1.2 compatible functions 00h and 80h take an (x,y) pixel coordinate as +the starting address in the frame buffer. Functions 02h and 82h are preferable because they allow +for correct page flipping operation in all color depths. Functions 00h and 80h have problems in +24bpp modes where each pixel is represented as three bytes, since there are some combinations of +(x,y) starting addresses that may not map + +For stereoscopic LC shutter glasses support, the hardware must provide support for free running +stereoscopic display with the left and right images located consecutively in video memory, or +provide support for dual display start addresses that will be swapped on every vertical retrace +interval. On all VBE 3.0 implementation that support hardware stereoscopic display, applications +can enable free running stereoscopic display by calling function 05h and the hardware will remain +in free running stereoscopic display until the application calls function 06h. When function 05h is +called, free running stereoscopic display is enabled with the left buffer located first in video +memory and the right buffer located immediately following the left buffer in video memory and +the hardware will swap between the two images at each vertical retrace in a sequential fashion (ie: +left, right, left, right etc). By default when a mode is initialized, free running stereoscopic display +is turned off. + +For VBE implementations that support dual display start address hardware (VBE mode +information ModeAttributes bit 12 is set), the VBE implementation should enable the +stereoscopic display start addressing when the application calls either function 03h or function +83h and it will remain in free running stereoscopic display until the application calls function 06h + + + VBE CORE FUNCTIONS VERSION 3.0 Page 51 + + + +VBE Overview + + +to disable stereoscopic display. The main difference with this method of stereoscopic display is +that the application has complete control over where the buffers are located in video memory, and +two display starting addresses are passed into functions 03h/83h for the complete change. + +Note also that the Display Start Address passed for subfunctions 02h, 03h, 82h and 83h are +defined as a byte address in video memory rather than as a pixel coordinate. This is in contrast to +the values passed to the 32-bit version which is a byte address divided by 4, and allows for +controllers that can perform hardware scrolling to a byte boundary for pixel perfect horizontal +scrolling. + +VBE Implementation Note: If the hardware does not support free running stereoscopic page +flipping, the VBE implementation should fail functions 03h, 05h, 06h and 83h. If the hardware +does not support dual display start addressing, but does support hardware stereoscopic display +with consecutive images in video memory, the implementation should fail functions 03h and 83h +but support 05h and 06h. If the hardware does not support the returning of status information for +the scheduled display start address swap, the VBE implementation should fail function 04h, +however it should still implement functions 02h, 03h, 82h and 83h to provide support for pixel +perfect smooth scrolling. +Note: In VBE 2.0 and later implementations the 32-bit version returns no Return Status + information to the application. Also note that the ES selector only needs to be passed if + the memory location in the Ports and Memory table returned by function 4F0Ah is not + defined. + +Note: This function is also valid in text modes. To use this function in text mode, the application + should convert the character coordinates to pixel coordinates by using XCharSize and + YCharSize returned in the ModeInfoBlock. If the requested Display Start coordinates do + not allow for a full page of video memory or the hardware does not support memory + wrapping, the Function call should fail and no changes should be made. As a general case, + if a requested Display Start is not available, fail the Function call and make no changes. + +Note: CX and DX, for both input and output values are zero-based. + +Note: Subfunction 01h (Get Display Start) is not supported via the VBE 3.0 protected mode + entry point, and the results are undefined if it is called. + + + + + + + + + + +Page 52 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + +Function 08h - Set/Get DAC Palette Format + +Input: AX = 4F08h VBE Set/Get Palette Format + BL = 00h Set DAC Palette Format + = 01h Get DAC Palette Format + BH = Desired bits of color per primary + (Set DAC Palette Format only) + +Output: AX = VBE Return Status + BH = Current number of bits of color per primary + +This required function manipulates the operating mode or format of the DAC palette. Some +DACs are configurable to provide 6 bits, 8 bits, or more of color definition per red, green, and +blue primary colors. The DAC palette width is assumed to be reset to the standard VGA value of +6 bits per primary color during any mode set. + +An application can determine if DAC switching is available by querying Bit D0 of the Capabilities +field of the VbeInfoBlock structure returned by VBE Function 00h (Return Controller +Information). The application can then attempt to set the DAC palette width to the desired value. +If the display controller hardware is not capable of selecting the requested palette width, then the +next lower value that the hardware is capable of will be selected. The resulting palette width is +returned. + +This function will return failure code AH=03h if called in a direct color or YUV mode. + +Note: Subfunction 01h (Get DAC Palette Format) is not supported via the VBE 3.0 protected + mode entry point, and the results are undefined if it is called. + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 53 + + + +VBE Overview + + + +Function 09h - Set/Get Palette Data + +Input: AX = 4F09h VBE Load/Unload Palette Data +(16-bit) BL = 00h Set Palette Data + = 01h Get Palette Data + = 02h Set Secondary Palette Data + = 03h Get Secondary Palette Data + = 80h Set Palette Data during Vertical Retrace + CX = Number of palette registers to update (to a + maximum of 256) + DX = First of the palette registers to update (start) + ES:DI = Table of palette values (see below for format) + +Output: AX = VBE Return Status + +Input: BL = 00h Set Palette Data +(32-bit) = 80h Set Palette Data during Vertical Retrace + CX = Number of palette registers to update (to a + maximum of 256) + DX = First of the palette registers to update (start) + ES:EDI= Table of palette values (see below for format) + DS = Selector for memory mapped registers + +This required function is very important for NonVGA controllers which don't provide access to +the palette via the standard VGA RAMDAC registers. Applications should check the NonVGA +bit in the ModeInfoBlock for the mode they are using, and if the mode is VGA compatible then +you may program the palette directly via the standard VGA palette registers. If the mode is +NonVGA however, then this function must be used. + +Note that for VGA compatible controllers, if the palette width has been set to 8 bits per primary +rather than the default 6, applications simply need to program a full 8 bits at a time via the +standard VGA RAMDAC registers (in Standard VGA 6 bit modes only the bottom 6 bits are +used). When in 6 bit mode, the format of the 6 bits is LSB for speed reasons, as the application +can typically shift the data faster than the BIOS can. + +Setting the palette data during the vertical retrace is required on some older RAMDAC's to avoid +the onset of `snow like' effects on the screen during palette programming. Check bit D2 of the +capabilities field returned by VBE Function 00h to determine if this is required by the RAMDAC. +Many newer style RAMDAC's don't have this limitation and can easily be programmed at any +time. Note however setting the palette data during the vertical retrace is also very useful for doing +smooth palette fades and changes so that the palette data is instantly changed before the next +frame is displayed (such as done by games when moving from level to level etc). + +The palette values passed will be an array of entries with the following structure for each entry in +the array: + + +Page 54 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + +PaletteEntry struc +Blue db ? ; Blue channel value (6 or 8 bits) +Green db ? ; Green channel value (6 or 8 bits) +Red db ? ; Red channel value(6 or 8 bits) +Alignment db ? ; DWORD alignment byte (unused) +PaletteEntry ends + +Note: In VBE 2.0 and later implementations the 32-bit version returns no Return Status + information to the application. Also note that the DS selector only needs to be passed if + the memory location in the Ports and Memory table returned by function 4F0Ah is not + defined. + +Note: The need for the secondary palette is for anticipated future palette extensions, if a + secondary palette does not exist in an implementation and these calls are made, the VBE + implementation will return error code 02h. + +Note: All applications should assume the DAC is defaulted to 6 bit mode. The application is + responsible for switching the DAC to higher color modes using Function 08h. + +Note: Query VBE Function 08h to determine the RAMDAC width before loading a new palette. + +Note: Subfunctions 01h and 03h (Get Palette Data and Get Secondary Palette Data) are no + longer mandatory for VBE 3.0, and may return a failure code if called. These functions are + also not supported by the protected mode entry point and the results are undefined if they + are called. + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 55 + + + +VBE Overview + + + +Function 0Ah - Return VBE Protected Mode Interface + +Input: AX = 4F0Ah VBE 2.0 Protected Mode Interface + BL = 00h Return protected mode table + + +Output: AX = Status + ES = Real Mode Segment of Table + DI = Offset of Table + CX = Length of Table including protected mode code in bytes + (for copying purposes) + +This optional function call returns a pointer to a table that contains code for a simple 32-bit +protected mode interface that can either be copied into local 32-bit memory space or can be +executed from ROM providing the calling application sets all required selectors and I/O access +correctly. This function returns a pointer (in real mode space) with offsets to the code fragments, +and additionally returns an offset to a table which contains Non-VGA Port and Memory locations +which an Application may have to have I/O access to. This function currently includes but is not +limited to bank switching, display start address programming (for double/triple buffering) and +palette programming. + +Note: For VBE 3.0 and above this function is optional and may not be implemented. VBE 3.0 + applications primarily use the linear framebuffer for speed so 32-bit bank switching + functions are not required, and the new protected mode entry point for VBE 3.0 provides + high performance access from protected mode applications and operating systems to all + the standard VBE functions. + +The format of the table is as follows: + + ES:DI + 00h Word Offset in table of Protected mode code for + Function 5 for Set Window Call + ES:DI + 02h Word Offset in table of Protected mode code for + Function 7 for set Display Start + ES:DI + 04h Word Offset in table of Protected mode code for + Function 9 for set Primary Palette data + ES:DI + 06h Word Offset in table of Ports and Memory Locations + that the application may need I/O privileges for. + (Optional: if unsupported this must be 0000h) + (See Sub-table for format) + ES:DI + ? Variable remainder of Table including Code + + +The format of the Sub-Table (Ports and Memory locations) + + + +Page 56 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + Port, Port, ... , Port, Terminate Port List with FF FF, Memory location base addresses (4 + bytes), Limit (ie: length-1) (2 bytes), Terminate Memory Location with FF FF. + +Example 1. For Port/Index combination 3DE/Fh and Memory locations DE800-DEA00h +(length = 200h) the table would look like this: + DE 03 DF 03 FF FF 00 E8 0D 00 00 01 FF FF + +Example 2. For only the ports it would look like: + DE 03 DF 03 FF FF FF FF + +Example 3. For only the memory locations it would look like + FF FF 00 E8 0D 00 00 01 FF FF + +If the memory location is zero, then only I/O mapped ports will be used so the application does +not need to do anything special. This should be the default case for ALL cards that have I/O +mapped registers because it provides the best performance and is easier for application +programmers to deal with. + +If the memory location is nonzero (there can be only one), the application will need to create a +new 32-bit selector with the base address that points to the "physical" location specified with the +specified limit. This selector must be passed in the ES or DS segment register (depending on the +function) so that the 32-bit code can directly access its memory mapped registers as absolute +offsets into the ES selector (i.e., mov [es:10],eax to put a value into the register at base+10). For +more information on the parameters passed to the 32-bit protected mode functions, please refer to +the definitions for each of the functions in question. All the 32-bit protected mode functions that +are defined are completely relocateable and can be copied and executed anywhere in 32-bit +protected mode code space. However in order to function correctly, there are special calling +requirements that must be followed when you call these functions: + + * The CS, DS, ES and SS segment registers must be contain valid 32-bit protected + mode selectors when the functions are called, and SS:ESP must point to a valid 32-bit + stack. Generally the application can simply use the default selectors provided by the + 32-bit host environment, except as noted below. + + * There are some cases where the protected mode functions may require access to + memory mapped registers in order to complete the operation. The physical location + and length of the memory mapped register area that must be mapped will be listed in + the Sub-Table (Ports and Memory) returned by VBE Function 0Ah. If the memory + location is zero (NULL), then only I/O mapped ports will be used and the application + does not need to do anything special (which should be the default case for ALL cards + that have I/O mapped registers to provide the best performance). If however the + memory location is nonzero, the application must create a selector that points to the + memory location, and then pass this selector to the calling function in either DS or ES + (see the function definitions for the appropriate functions to determine which register + it should be passed in). It is up to the application code to save and restore the previous + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 57 + + + +VBE Overview + + + state of the DS or ES selector (depending in the function being called) if this is + necessary + + * When the VBE services are called, the current I/O permission bit map must allow + access to the I/O ports that the VBE may need to access. This can be found in the + Sub-Table (Ports and Memory) returned by VBE Function 0Ah. + + * The high order words of any registers that are used to pass parameters to the 32-bit + functions may be destroyed by the 32-bit functions. + +To summarize, it is the responsibility of the calling application to ensure to that it has the +appropriate I/O and memory privileges, and a large enough stack and appropriate selectors +allocated. It is also the responsibility of the calling application to preserve registers if necessary. + +Note: All protected mode functions should end with a near RET (as opposed to FAR RET) to + allow the application software to CALL the code from within the ROM. + +Note: The Port and Memory location Sub-table does not include the Frame Buffer Memory + location. The Frame Buffer Memory location is contained within the ModeInfoBlock + returned by VBE Function 01h. + +Note: The protected mode code is assembled for a 32-bit code segment, when copying it, the + application must copy the code to a 32-bit code segment. + +Note: Currently undefined registers may be destroyed with the exception of ESI, EBP, DS + and SS. + + + + + + + + + + + + + + + + + + +Page 58 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Function Reference + + + +Function 0Bh - Get/Set pixel clock + +Input: AX = 4F0Bh Get/Set pixel clock + BL = 00h Get closest pixel clock + ECX = Requested pixel clock in units of Hz + DX = Mode number pixel clock will be used with + + +Output: AX = Status + ECX = Closest pixel clock (BL = 00h) + +This required function allows an application to determine if a particular pixel clock is available. +When this function is called with BL set to 0, it will run the requested pixel clock through the +internal PLL programming routines and return the actual pixel clock that will be programmed into +the hardware in the ECX register. The process of running the PLL clock computation routines +may cause the returned pixel clock to be rounded slightly up or down from the requested value, +however the BIOS should implement the algorithms to attempt to find clocks that are the same as +or higher than the requested value. Note that the calling application must also pass in the VBE +mode number for the graphics mode that will be using this pixel clock to this function. The mode +number is necessary so that the underlying programming code can determine apply any necessary +scaling internally before looking for the closest physical pixel clock, and then scaling the result +back. This ensures that the application programmer only ever has to deal with normalized pixel +clocks and not have to worry about pixel clock scaling issues. + +If the BIOS implementation uses a table driven clock programming approach, it should always +attempt to find the next highest pixel clock in the table to the requested clock. The exception to +this is if there is a lower clock in the table that is within a tolerance of 1% of the requested clock +in which case this clock should be returned. + +This pixel clock can then be used by the application to compute the exact GTF timing parameters +for the mode. Note that for hardware that is not fully programmable, the returned pixel clock that +is the closest the one desired may be substantially different (ie: you could get back 25Mhz when +you request 29Mhz). It is up the calling application to determine if the clock is suitable and to +attempt to choose a different clock if not suitable. The pixel clocks passed in and returned occupy +one dword (32 bits) that represents the pixel clock in units of Hz (ie: a pixel clock of 25.18Mhz is +represented with a value of 25,180,000). + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 59 + + + +VBE Overview + + + + + VBE Supplemental Specifications + + +This chapter details VBE Supplemental Specifications. + +Purpose of Supplemental Specifications + +The VBE was originally designed to provide a device-independent interface between application +software and SVGA hardware. In the last few years, the personal computing environment has +grown much more complex and there have been numerous requests to provide interfaces similar +to the VBE to service these new requirements. The VBE supplemental specification architecture +provides a way to extend the basic VBE specification without making it too unwieldy or having to +revise the VBE specification itself. + +The supplemental specifications are implemented using VBE function numbers starting at +AL=10h. This leaves the first sixteen functions available for eventual VBE growth. Individual +calls for each supplemental specification are made through a subfunction number via the BL +register. This function/subfunction architecture is compatible with the VBE and provides each +VBE Supplemental Specification with 64 potential subfunctions. Subfunction 00h for each +supplemental specification is reserved for a 'Return VBE Supplemental Specification Information' +call. It is based on the VBE Function 00h and returns basic information on the VBE Supplemental +Specification implementation. + +Obtaining Supplemental VBE Function Numbers + +VBE Supplemental Specifications can only be created by VESA committees. Once a need for a +new software specification has been identified, the group working on it needs to contact the +VESA Software Standards Committee (SSC) to discuss the requirements. The SSC will assign a +function number and name to the supplemental specification. The name assigned to a +supplemental specification will be in the form of 'VBE/???' where the '???' is a two or three letter +acronym for its function. Two letter acronyms will be padded with FFh for the third letter. In +some cases the committee that is working on the supplemental specification may have another +name that they will use for promotional purposes, however the VBE/??? will continue to be the +signature. + +The VBE specification will be revised periodically to update the list of supplemental +specifications. To obtain the actual specifications, contact the VESA office. + + + + + + +Page 60 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Supplemental Specifications + + + +Required VBE Supplemental Specification Components + + +VBE Supplemental Specification Functions +All VBE Supplemental Specification functions are called with the AH register set to 4Fh to +identify them as VBE function calls. The AL register is used to specify which VESA function the +supplemental specification is using. The BL register will contain the subfunction number for the +call being made, BH will contain the sub-function number if necessary. + +e.g., Input: AX = 4FXXh VESA Supplemental VBE Specification + ('XX' represents the function number for the + supplemental specification) + BL = ? Subfunction + BH = ? Sub-function + +Return Status +All VBE Supplemental Specifications will use the VBE Completion codes as documented in +Section 4.1 of the VBE specification. + +Subfunction 00h - Return VBE Supplemental Specification Information +This subfunction returns the capabilities, revision level, and vendor specific information of the +supplemental specification, and is a required function for any VBE 2.x Supplemental +Specification. Note that supplementation functions provided by VBE 3.0 implementations must be +fully protected mode compatible and callable via the protected mode entry point for the VBE 3.0 +implementation. This includes the VBE/PM, VBE/DDC and other important supplemental +specifications. + +The purpose of this subfunction is to provide information to the calling program about the general +capabilities of the installed VBE software and hardware. This subfunction fills an information +block structure at the address specified by the caller. The SupVBEInfoBlock information block +size is 256 bytes. + +Input: AX = 4FXXh Return Supplemental VBE Specification Information + ('XX' represents the function number for the + supplemental specification) + BL = 00h Subfunction '0' + ES:DI = Pointer to buffer in which to place + SupVBEInfoBlock structure +Output: AX = VBE Return Status + +Other registers may be defined for input and output based upon the particular requirements of +supplemental specifications + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 61 + + + +VBE Overview + + +When writing supplemental functions, explicitly state which registers are preserved and which are +destroyed. Refrain from preserving all registers as this tends to limit expandability in the future. +An example of the note is: + +Note: Currently undefined registers may be destroyed with the exception of SI,BP,DS + and SS. + +The information block has the following structure: + +SupVbeInfoBlock struc +SupVbeSignature db 'VBE/???' ; Supplemental VBE Signature +SupVbeVersion dw ? ; Supplemental VBE Version +SupVbeSubFunc db 8 dup (?) ; Bitfield of supported subfunctions +OemSoftwareRev dw ? ; OEM Software revision +OemVendorNamePtr dd ? ; VbeFarPtr to Vendor Name String +OemProductNamePtr dd ? ; VbeFarPtr to Product Name String +OemProductRevPtr dd ? ; VbeFarPtr to Product Revision String +OemStringPtr dd ? ; VbeFarPtr to OEM String +Reserved db 221 dup (?) ; Reserved for description strings and future + ; expansion +SupVbeInfoBlock ends + +Note: All data in this structure is subject to change by the VBE implementation when any VBE + Subfunction 00h is called. Therefore it should not be used by the application to store data + of any kind. + +Description of the SupVbeInfoBlock structure fields: + +The SupVbeSignature field is filled with the ASCII characters 'VBE/' followed by the two or +three letter acronym that represents the supplemental specification. This field is filled by the +supplementary VBE implementation. In the event that the acronym is only two letters, the third +letter must be filled with FFh. + +The SupVbeVersion is a BCD value which specifies what level of the VBE supplementary +specification is implemented in the software. The higher byte specifies the major version number. +The lower byte specifies the minor version number. + +Note: The BCD value for 2.0 is 0200h and the BCD value for 1.2 is 0102h. In the past we have + had some applications misinterpreting these BCD values. For example, BCD 0102h was + interpreted as 1.02, which is incorrect. + +The SupVbeSubFunc is a bitfield that represents the subfunctions available for the +supplementary specification. If the bit representing a particular subfunction is set, then that +subfunction is supported. Subfunction '0' is represented by the LSB of the first byte and the other +subfunctions follow. Only bits for subfunctions defined in the specification need to be set. + + +Page 62 VBE CORE FUNCTIONS VERSION 3.0 + + + + VBE Supplemental Specifications + + +The OemStringPtr is a VbeFarPtr to a null-terminated OEM-defined string. This string may used +to identify the graphics controller chip or OEM product family for hardware specific display +drivers. There are no restrictions on the format of the string. This pointer may point into either +ROM or RAM, depending on the specific implementation. + +The OemSoftwareRev field is a BCD value which specifies the OEM revision level of the +Supplemental Specification software. The higher byte specifies the major version number. The +lower byte specifies the minor version number. This field can be used to identify the OEM's VBE +software release. + +The OemVendorNamePtr is a VbeFarPtr to a null-terminated OEM-defined string containing +the name of the vendor who produced the display controller board product. + +The OemProductNamePtr is a VbeFarPtr to a null-terminated OEM-defined string containing +the product name of the display controller board. + +The OemProductRevPtr is a VbeFarPtr to a null-terminated OEM-defined string containing the +revision or manufacturing level of the display controller board product. This field can be used to +determine which production revision of the display controller board is installed. + +Loading Supplemental Drivers + +VBE Supplemental Specifications can be implemented in ROM, TSR programs or as device +drivers. The specific requirements will vary depending on the individual supplementary +specification. If there are any specific requirements, they should be detailed in the supplementary +specification. + +Implementation Questions + +When developing a new supplemental specification, implementation questions whether they are +covered in this guideline or not, should be referred to the VESA Software Standards Committee +for clarification. The chairman of the SSC can be contacted through the VESA office. + +Known Supplemental Specifications + + +Function 10h - Power Management Extensions (PM) +This optional function controls the power state of the attached display device or monitor. +Refer to the VBE/PM Standard for specifics. + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 63 + + + +VBE Overview + + +Function 11h - Flat Panel Interface Extensions (FP) +This proposed optional supplemental specification allows access to the special features +incorporated in Flat Panel controllers. There is no reference specification at the time of this +standard's approval. Contact the VESA office for more information. + +Function 13h - Audio Interface Extensions (AI) +This optional function provides standard Audio services. +Refer to the VBE/AI Standard for specifics. + +Function 14h - OEM Extensions +This optional supplemental function provides OEM's with a code dispatch area that falls under the +VESA 4Fh functions. An OEM may use this area at their own risk. VESA states no warranties +or guarantees about the function calls contained within this area. + +Function 15h - Display Data Channel (DDC) +This optional function provides a mechanism to extract data from attached display devices on the +VESA communication channel. Refer to the VBE/DDC Standard for specifics. + + + + + + + + + + + + + + + + + + + + + + + + + + +Page 64 VBE CORE FUNCTIONS VERSION 3.0 + + + + Appendix 1 - VBE Implementation Considerations + + + + + Appendix 1 - VBE Implementation Considerations + + +This appendix discusses required features of VBE 3.0. implementations, and offers some +suggestions for consideration by BIOS developers. Some issues raised here apply only to adding +VBE 3.0 to an existing VGA BIOS, while other issues are more generally relevant. + +Minimum Functionality Requirements + + +Required VBE Services +VBE Functions 00h-0Ah are required; all other functions are optional. There are no absolutely +required modes, or mode capabilities, since these will vary according to the hardware and +applications. + +Note: With VBE 3.0 function 4F0Ah is optional as the new protected mode entry point provides + similar functionality with reduced BIOS space. Also function 4F09h is optional if and only + if the controller is fully VGA compatible, in which case the application can program the + palette directly using the standard VGA palette registers. For NonVGA compatible + controllers this function is required to properly support palette modes. Note also that + these functions must be implemented, but implementations may simply fail the functions if + not required. + + +Minimum ROM Implementation +For compliance certification, Functions 00-0Ah must be implemented in the ROM. In the case of +ROM space limitations that do not allow full implementations, VESA strongly recommends that +VBE Get Controller Information Function 00h be implemented in the ROM so applications will +be able to find information about the controller type and capabilities. This 'Stub' implementation +can be supplemented by a TSR which will provide full VBE Core functionality. These stub +implementations are not VBE 3.0 compliant and should only be implemented in cases where no +space is available to implement the whole VBE. In the event that a stub is implemented a TSR +must be available to complete VBE 3.0 functionality. + +In a stub implementation, the VideoModeList will contain no entries (starts with 0FFFFh). This is +the indicator to application software that the VBE Core implementation is in fact only a stub and +that other functions and modes do not exist. + +TSR Implementations +TSR based implementations of VBE must not assume that a compatible graphics controller is +present! They must first attempt to detect the presence of a compatible device before chaining +into INT 10h and completing the load process. If no compatible hardware is detected they must + + + VBE CORE FUNCTIONS VERSION 3.0 Page 65 + + + +VBE Overview + + +exit without chaining INT 10h. On failure to load, the TSR should display an appropriate +message to the screen, identifying both the installed and expected hardware and displaying the +OEM strings from Function 00h, if available. The software version number and identifying +information for the TSR should also be shown. + +TSRs which are meant to work in a variety of hardware and BIOS environments should check to +see if the ROM supports some version of VBE Function 00h, Get Controller Information. The +information which is returned from this function can then be passed on to calling applications or +displayed on the screen, reducing the burden of supporting different display hardware. If a stub or +incomplete version of VBE exists in ROM, it is the responsibility of the TSR to supplement all +missing functions and replace Function 00h. + +VESA recommends that VBE 3.0 TSRs be given names which contain some identifier for the +OEM and/or product such as ATIVBE.EXE or S3VBE.EXE. This will help users make sure they +have the correct version of software for their hardware, and may prevent a few phone calls for +software support. It is also required that a help screen be included, which can be activated by +typing "/h", "/?", or any unrecognized parameter on the command line. The help screen should +contain all pertinent information about the source and version number of the TSR and the +hardware on which it is designed to work. + +VGA BIOS Implications + +A primary design goal with the VESA VBE is to minimize the effects on the standard VGA +BIOS. Standard VGA BIOS functions should need to be modified as little as possible. However, +two standard VGA functions are affected by the VBE. These are VGA Function 00h (Set VGA +Mode) and VGA Function 0Fh (Get Current VGA Mode). + +VBE-unaware applications (such as old Pop-Up programs and other TSRs, or the CLS command +of MS-DOS), may use VGA BIOS Function 0Fh to get the current display mode and later call +VGA BIOS Function 00h to restore/reinitialize the old graphics mode. To make such +applications work, the 8-bit value returned by VGA BIOS Function 0Fh (it is up to the OEM to +define this number), must correctly reinitialize the graphics mode through VGA BIOS Function +00h. + +However, VBE-aware applications should not set the VBE mode using VGA BIOS Function 00h, +or get the current mode with VGA BIOS Function 0Fh. VBE Functions 02h (Set VBE mode) and +03h (Get VBE Mode) should be used instead. The mode number must be from the mode list +returned by VBE Function 00h, and Function 03h must return the same mode number used to set +the mode in Function 02h. + +Given these requirements, and the fact that many BIOS manufacturers will need to support at +least some of the VESA-defined 14-bit mode numbers for backwards compatibility, it is clear that +the BIOS must keep track of the last mode that was set with VBE Function 02h. There are +various ways that this could be accomplished without the use of scratch registers or non-volatile +RAM, which is not always available. One method is to use the mode number byte in the BIOS + + +Page 66 VBE CORE FUNCTIONS VERSION 3.0 + + + + Appendix 1 - VBE Implementation Considerations + + +Data Area to store the index into the mode list returned in VBE Function 00h, which is always +stored in ROM. Another method is to store a small translation table for the 14-bit mode numbers +(probably necessary for using duplicate mode numbers anyway) and to use an obsolete or unused +bit in the BIOS Data Area to indicate a 14-bit mode in effect. + +If a BIOS offers only the flat frame buffer version of one of the modes which have VESA-defined +numbers, it may be advisable to use an OEM-defined number for that mode instead. Since VBE +1.2 and earlier versions assume standard VGA windowing of the frame buffer, older VBE-aware +applications may recognize the mode number and attempt to use windowed memory without +properly checking with Function 01h. + +Real mode ROM Space Limitations + +Since standard VGA BIOS is currently confined to 32K ROM images, space is likely to be critical +in implementing even the minimum VBE 3.0 functionality. Most VGA BIOSs have already been +compressed many times as new features and modes have been added over time. Clearly, older +VGA BIOS features may have to be sacrificed to make room. + +Data Storage +To allow for ROM based execution of the VBE functions, each VBE function must be +implemented without the use of any local data. When possible, the BIOS data area, non-volatile +RAM, or OEM specific scratch registers can be used to place scratch data during execution. All +VBE data structures are allocated and provided to VBE by the calling application. + +Removal of Unused VGA Fonts +VESA strongly recommends that removal of the 8x14 VGA font become a standard way of +freeing up space for VBE 3.0 implementations. The removal of this font leaves 3.5K bytes of +ROM space for new functions, and is probably the least painful way to free up such a large +amount of space while preserving as much backwards compatibility as possible. The 8x14 font is +normally used for VGA Modes 0*, 3* and Mode 10h, which are 350-line or EGA compatible +modes. When these modes are selected the 8x16 font may be chopped and used instead. When +chopping a 16 point font to replace the 14 point, there are several characters (ones with +descenders) that should be special cased. + +Some applications which use the 8x14 font obtain a pointer to the font table through the standard +VGA functions and then use this table directly. In such cases, no workaround using the 8x16 font +is possible and a TSR with the 8x14 font is unavoidable. Some OEMs may find this situation +unacceptable because of the potential for an inexperienced user to encounter "garbage" on the +screen if the TSR is not present. However, OEMs may also find eventually that demand for VBE +3.0 services is great enough to justify the inconvenience associated with an 8x14 font TSR. To +date, no compatibility problems are known to be caused by the use of such a TSR. VESA will +make available a TSR that replaces the 8x14 font, please contact VESA for more information. + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 67 + + + +VBE Overview + + +Another option with the fonts in Turn-Key systems (such as Laptops, Notebooks etc.) is to move +the fonts to another location in the System ROM. In fact VBE functions could even be relocated. +This however is not an acceptable solution for most desktop systems, where they are expandable. + +Deleting VGA Parameter Tables +One way to create more ROM space for the VBE is to delete some of the VGA parameter tables +by deleting modes which are outdated and little used. Many of the standard VGA modes are now +almost entirely obsolete and should probably be phased out of existence. How quickly this might +happen depends on which applications are still using the older modes and on how tolerant OEMs +and users will be to using TSR programs for these modes when necessary. Some mode groups +which might be candidates for removal are modes 4, 5, and 6, all CGA modes, or all 200 line +modes. + +It must be emphasized, however, that it is absolutely necessary to preserve the size and positions +of all the standard mode VGA parameter tables! Failure to do so will cause a lot of problems +with diagnostics and older VGA applications. If a table is removed, fill the space with an equal +number of bytes of code or data. + +Increasing ROM Space +In the PC environment, VGA BIOS developers have traditionally been limited to a 32K ROM +image located at C0000h-C7FFFh. The C8000h-CBFFFh area was originally reserved for the XT +hard disk BIOS, which is of little current concern. However, SCSI CD ROM controllers have +now begun to use this area, and the possibility exists that other devices may use this area also. It +is unlikely that VBE developers will be able to expand into the C8000h-CFFFFh region without +creating potential conflicts. + +Support of VGA TTY Functions +The support of VGA TTY functions is recommended, but not mandatory, for graphic modes +beyond VGA. TTY support for all modes is desirable to allow basic text operations such as +reading and writing characters to the screen. Some operating systems will revert to using TTY +functions when a hardware error occurs, since the graphics environment may no longer be +operational. + +Support of TTY functions for all modes will, of course, increase the size of the BIOS. One +possible solution is to provide TTY function support for extended modes as part of a TSR rather +than in the ROM. + +Bit D2 in the Mode Attributes field in the ModeInfoBlock structure returned by VBE Function +01h indicates the presence of support for TTY functions for each VBE mode. Refer to the VBE +Function 01h description for details on which TTY functions must be supported when this bit +is set. + + + + +Page 68 VBE CORE FUNCTIONS VERSION 3.0 + + + + Appendix 1 - VBE Implementation Considerations + + + +Developing Dual-Mode BIOS code + +In order to support the Protected Mode Entry point for VBE 3.0 compatibility, the 16-bit BIOS +code must be crafted as `dual-mode' code. This essentially means that the code is designed to run +as either 16-bit real mode code or 16-bit protected mode code without modification. + +When the BIOS code is called from protected mode, the application or OS will have modified the +PMInfoBlock to contain valid selectors to all the important physical memory regions that the +BIOS may need to access, along with a selector to a writeable BIOS data area block. In your +BIOS code, rather than directly loading selector values to access physical memory regions or the +BIOS data area, load the selector values directly from the PMInfoBlock in the BIOS. This way +the same code will run identically as real mode code or as 16-bit protected mode code. + +For instance, instead of loading the selectors as follows: + + xor ax,ax + mov ds,ax ; DS points to BIOS data area + mov ax,A000h + mov ds,ax ; DS points to VGA framebuffer + +you can load the segment registers with the following dual-mode compatible code: + + mov ds,[cs:PMInfo.BIOSDataSel] + mov ds,[cs:PMInfo.A0000Sel] + +Determining when in Protected Mode +In some instances it may be necessary for the BIOS code to determine if it is running in real mode +or in protected mode. Before the BIOS code is called from protected mode, the application will +set the InProtectMode field of the PMInfoBlock to a `1', indicating that the code is now running +in protected mode. By default the value of this field will be set to 0 in the real mode BIOS, so the +BIOS code can simply look at this field to determine the mode it is running in. + +Things to avoid in Protected Mode +If it is necessary for the BIOS code to directly access PCI configuration space registers, access to +these registers is not possible via the INT 1Ah software interrupt that is normally used from real +mode code. In order to fully support the protected mode entry point, the BIOS implementer +cannot call the INT 1Ah software interrupt, but must access the PCI config space registers using +the standard I/O port access methods as outlined in the PCI 2.1 hardware specification. + +When writing dual-mode code you should also avoid the following real mode specific tricks: + + * Segment arithmetic, since memory is accessed via selectors not segments. + + * Hard coded segment register values. Always load segment registers from the values + stored in the PMInfoBlock structure. + + + VBE CORE FUNCTIONS VERSION 3.0 Page 69 + + + +VBE Overview + + +Returning pointers in info blocks +When called via the protected mode entry point, all pointers returned must be valid 16:16 +protected mode pointers, not real mode pointers. Hence the pointers to the OEMString, +VideoModeTable etc cannot have hard coded segment values. You can easily modify your BIOS +code to support this with the following steps: + + 1. If the data is located in the BIOS image, set the segment value to the value of the CS + register, rather than directly setting it to C000h. Under real mode CS will contain + C000h and under protected mode it will contain a read-only selector that points to the + start of the BIOS image. + + 2. If the data is located in the passed in info block, set the segment value to the ES + selector value that is passed in to the function. + +Supporting Multiple Controllers + +It is sometimes necessary for more than one display controller to be present in the system for +several reasons. For example, OEMs may choose to implement a dual-controller design with +VGA functionality provided by one controller, and SVGA or VBE functionality provided by +a second controller. In some cases, it may be desirable to install more than one display adapter in +the system for simultaneous support of multiple display monitors (to support dual monitor +debugging for example). + +Dual-Controller Designs +VBE 3.0 supports the dual-controller design by assuming that since both controllers are typically +provided by the same OEM, under control of a single BIOS ROM on the same graphics card, it is +possible to hide the fact that two controllers are indeed present from the application. This has the +limitation of preventing simultaneous use of the independent controllers, but allows applications +released before VBE 3.0 to operate normally. The VBE Function 00h (Return Controller +Information) returns the combined information of both controllers, including the combined list of +available modes. When the application selects a mode, the appropriate controller is activated. +Each of the remaining VBE functions then operates on the active controller. + +Provision for Multiple Independent Controllers +It is not possible to support multiple independent controllers via the VBE/Core interface. +However multiple independent controllers can be fully supported using the VBE/AF Accelerator +Functions specification (contact VESA for more information), and also allow the graphics +accelerator functions for all installed controllers to be programmed concurrently. + +OEM Extensions to VBE + +The VBE specification allows the OEM to extend its functionality for support of nonstandard, or +private features known only to the OEM and custom applications that are aware of these OEM +extensions. + +Page 70 VBE CORE FUNCTIONS VERSION 3.0 + + + + Appendix 1 - VBE Implementation Considerations + + +VBE Function 14h is reserved for use by OEMs wishing to add VBE subfunctions of their own. +This function number is provided so that the OEM may add custom services without fear of +conflict with other VBE services. These subfunctions must use the AX register in the same +manner as all other standard VBE functions and return the standard VBE completion codes. + +Normally, these extended functions are used by the OEM to aid in the setup and configuration of +the controller hardware. For example, during installation it may be necessary to set the physical +frame buffer address, maximum monitor refresh frequency, default graphics mode, default power +state, etc. A single setup and installation program can be used by the OEM with the entire +product line if the same OEM extensions are implemented on each product. + +A utility accessing these proprietary functions must read the VbeInfoBlock returned by VBE +Function 00h to determine if the firmware is of the proper type and revision level before making +any Function 14h calls. Failure to do so will render the calling utility incompatible with VBE 3.0 +and may cause unpredictable results. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 71 + + + +VBE Overview + + + + + Appendix 2 - Sample Source Code + + +The certification process is only for the BIOS implementations, this should be enough to ensure +that the applications fall in line with the VESA standard. If it doesn't work on a VBE Compliant +card, then the application is wrong and should be changed. To help ensure that the application +developer will work on VBE Compliant systems, sample source for application developer's will be +provided by the VESA office. + +A simple example of how to set a Video Mode, and how to use it to put something up on the +screen, is found below. This is not intended to be a complete SDK or source example, but it only +demonstrates what we are trying to achieve. + +C Language Module +(This has been compiled and tested under Microsoft C 6.0. Conversion for the direct banking +method to inline assembly may be required for Borland C.) +/**************************************************************************** +** Hello VBE! +*** Language: C (Keyword far is by definition not ANSI, therefore +* to make it true ANSI remove all far references and +* compile under MEDIUM model.) +** Environment: IBM PC (MSDOS) 16 bit Real Mode +* Original code contributed by: - Kendall Bennett, SciTech Software +* Conversion to Microsoft C by: - Rex Wolfe, Western Digital Imaging +* - George Bystricky, S-MOS Systems +** Description: Simple 'Hello World' program to initialize a user +* specified 256 color graphics mode, and display a simple +* moire pattern. Tested with VBE 1.2 and above. +** This code does not have any hard-coded VBE mode numbers, +* but will use the VBE 2.0 aware method of searching for +* available video modes, so will work with any new extended +* video modes defined by a particular OEM VBE 2.0 version. +** For brevity we don't check for failure conditions returned +* by the VBE (but we shouldn't get any). +*****************************************************************************/ +#include +#include +#include +#include + +/* Comment out the following #define to disable direct bank switching. + * The code will then use Int 10h software interrupt method for banking. */ + + +Page 72 VBE CORE FUNCTIONS VERSION 3.0 + + + + Appendix 2 - Sample Source Code + + + +#define DIRECT_BANKING + +#ifdef DIRECT_BANKING +/* only needed to setup registers BX,DX prior to the direct call.. */ +extern far setbxdx(int, int); +#endif + +/*---------------------- Macro and type definitions -----------------------*/ + +/* SuperVGA information block */ + +struct +{ char VESASignature[4]; /* 'VESA' 4 byte signature */ + short VESAVersion; /* VBE version number */ + char far *OEMStringPtr; /* Pointer to OEM string */ + long Capabilities; /* Capabilities of video card */ + unsigned far *VideoModePtr; /* Pointer to supported modes */ + short TotalMemory; /* Number of 64kb memory blocks */ + char reserved[236]; /* Pad to 256 byte block size */ +} VbeInfoBlock; + +/* SuperVGA mode information block */ + +struct +{ unsigned short ModeAttributes; /* Mode attributes */ + unsigned char WinAAttributes; /* Window A attributes */ + unsigned char WinBAttributes; /* Window B attributes */ + unsigned short WinGranularity; /* Window granularity in k */ + unsigned short WinSize; /* Window size in k */ + unsigned short WinASegment; /* Window A segment */ + unsigned short WinBSegment; /* Window B segment */ + void (far *WinFuncPtr)(void); /* Pointer to window function */ + unsigned short BytesPerScanLine; /* Bytes per scanline */ + unsigned short XResolution; /* Horizontal resolution */ + unsigned short YResolution; /* Vertical resolution */ + unsigned char XCharSize; /* Character cell width */ + unsigned char YCharSize; /* Character cell height */ + unsigned char NumberOfPlanes; /* Number of memory planes */ + unsigned char BitsPerPixel; /* Bits per pixel */ + unsigned char NumberOfBanks; /* Number of CGA style banks */ + unsigned char MemoryModel; /* Memory model type */ + unsigned char BankSize; /* Size of CGA style banks */ + unsigned char NumberOfImagePages; /* Number of images pages */ + unsigned char res1; /* Reserved */ + unsigned char RedMaskSize; /* Size of direct color red mask */ + unsigned char RedFieldPosition; /* Bit posn of lsb of red mask */ + unsigned char GreenMaskSize; /* Size of direct color green mask */ + unsigned char GreenFieldPosition; /* Bit posn of lsb of green mask */ + unsigned char BlueMaskSize; /* Size of direct color blue mask */ + unsigned char BlueFieldPosition; /* Bit posn of lsb of blue mask */ + unsigned char RsvdMaskSize; /* Size of direct color res mask */ + unsigned char RsvdFieldPosition; /* Bit posn of lsb of res mask */ + unsigned char DirectColorModeInfo; /* Direct color mode attributes */ + unsigned char res2[216]; /* Pad to 256 byte block size */ +} ModeInfoBlock; + +typedef enum + + VBE CORE FUNCTIONS VERSION 3.0 Page 73 + + + +VBE Overview + + +{ memPL = 3, /* Planar memory model */ + memPK = 4, /* Packed pixel memory model */ + memRGB = 6, /* Direct color RGB memory model */ + memYUV = 7, /* Direct color YUV memory model */ +} memModels; + +/*--------------------------- Global Variables ----------------------------*/ +char mystr[256]; +char *get_str(); + +int xres,yres; /* Resolution of video mode used */ +int bytesperline; /* Logical CRT scanline length */ +int curBank; /* Current read/write bank */ +unsigned int bankShift; /* Bank granularity adjust factor */ +int oldMode; /* Old video mode number */ +char far *screenPtr; /* Pointer to start of video memory */ +void (far *bankSwitch)(void); /* Direct bank switching function */ +/*------------------------ VBE Interface Functions ------------------------*/ + +/* Get SuperVGA information, returning true if VBE found */ + +int getVbeInfo() +{ union REGS in,out; + struct SREGS segs; + char far *VbeInfo = (char far *)&VbeInfoBlock; + in.x.ax = 0x4F00; + in.x.di = FP_OFF(VbeInfo); + segs.es = FP_SEG(VbeInfo); + int86x(0x10, &in, &out, &segs); + return (out.x.ax == 0x4F); +} + +/* Get video mode information given a VBE mode number. We return 0 if + * if the mode is not available, or if it is not a 256 color packed + * pixel mode. + */ + +int getModeInfo(int mode) +{ union REGS in,out; + struct SREGS segs; + char far *modeInfo = (char far *)&ModeInfoBlock; + if (mode < 0x100) return 0; /* Ignore non-VBE modes */ + in.x.ax = 0x4F01; + in.x.cx = mode; + in.x.di = FP_OFF(modeInfo); + segs.es = FP_SEG(modeInfo); + int86x(0x10, &in, &out, &segs); + if (out.x.ax != 0x4F) return 0; + if ((ModeInfoBlock.ModeAttributes & 0x1) + && ModeInfoBlock.MemoryModel == memPK + && ModeInfoBlock.BitsPerPixel == 8 + && ModeInfoBlock.NumberOfPlanes == 1) + return 1; + return 0; +} + +/* Set a VBE video mode */ + +Page 74 VBE CORE FUNCTIONS VERSION 3.0 + + + + Appendix 2 - Sample Source Code + + + +void setVBEMode(int mode) +{ union REGS in,out; + in.x.ax = 0x4F02; in.x.bx = mode; + int86(0x10,&in,&out); +} + +/* Return the current VBE video mode */ + +int getVBEMode(void) +{ union REGS in,out; + in.x.ax = 0x4F03; + int86(0x10,&in,&out); + return out.x.bx; +} + +/* Set new read/write bank. We must set both Window A and Window B, as + * many VBE's have these set as separately available read and write + * windows. We also use a simple (but very effective) optimization of + * checking if the requested bank is currently active. + */ + +void setBank(int bank) +{ union REGS in,out; + if (bank == curBank) return; /* Bank is already active */ + curBank = bank; /* Save current bank number */ + bank <<= bankShift; /* Adjust to window granularity */ +#ifdef DIRECT_BANKING + setbxdx(0,bank); + bankSwitch(); + setbxdx(1,bank); + bankSwitch(); +#else + in.x.ax = 0x4F05; in.x.bx = 0; in.x.dx = bank; + int86(0x10, &in, &out); + in.x.ax = 0x4F05; in.x.bx = 1; in.x.dx = bank; + int86(0x10, &in, &out); +#endif +} + +/*-------------------------- Application Functions ------------------------*/ + +/* Plot a pixel at location (x,y) in specified color (8 bit modes only) */ + +void putPixel(int x,int y,int color) +{ long addr = (long)y * bytesperline + x; + setBank((int)(addr >> 16)); + *(screenPtr + (addr & 0xFFFF)) = (char)color; +} + +/* Draw a line from (x1,y1) to (x2,y2) in specified color */ + +void line(int x1,int y1,int x2,int y2,int color) +{ int d; /* Decision variable */ + int dx,dy; /* Dx and Dy values for the line */ + + VBE CORE FUNCTIONS VERSION 3.0 Page 75 + + + +VBE Overview + + + int Eincr,NEincr; /* Decision variable increments */ + int yincr; /* Increment for y values */ + int t; /* Counters etc. */ + +#define ABS(a) ((a) >= 0 ? (a) : -(a)) + + dx = ABS(x2 - x1); + dy = ABS(y2 - y1); + if (dy <= dx) + { + /* We have a line with a slope between -1 and 1 + * + * Ensure that we are always scan converting the line from left to + * right to ensure that we produce the same line from P1 to P0 as the + * line from P0 to P1. + */ + if (x2 < x1) + { + t = x2; x2 = x1; x1 = t; /* Swap X coordinates */ + t = y2; y2 = y1; y1 = t; /* Swap Y coordinates */ + } + if (y2 > y1) + yincr = 1; + else + yincr = -1; + d = 2*dy - dx; /* Initial decision variable value */ + Eincr = 2*dy; /* Increment to move to E pixel */ + NEincr = 2*(dy - dx); /* Increment to move to NE pixel */ + putPixel(x1,y1,color); /* Draw the first point at (x1,y1) */ + + /* Incrementally determine the positions of the remaining pixels */ + for (x1++; x1 <= x2; x1++) + { + if (d < 0) + d += Eincr; /* Choose the Eastern Pixel */ + else + { + d += NEincr; /* Choose the North Eastern Pixel */ + y1 += yincr; /* (or SE pixel for dx/dy < 0!) */ + } + putPixel(x1,y1,color); /* Draw the point */ + } + } + else + { + /* We have a line with a slope between -1 and 1 (ie: includes + * vertical lines). We must swap our x and y coordinates for this. + * + * Ensure that we are always scan converting the line from left to + * right to ensure that we produce the same line from P1 to P0 as the + * line from P0 to P1. + */ + if (y2 < y1) + { + t = x2; x2 = x1; x1 = t; /* Swap X coordinates */ + t = y2; y2 = y1; y1 = t; /* Swap Y coordinates */ + } + if (x2 > x1) + yincr = 1; + else + +Page 76 VBE CORE FUNCTIONS VERSION 3.0 + + + + Appendix 2 - Sample Source Code + + + yincr = -1; + d = 2*dx - dy; /* Initial decision variable value */ + Eincr = 2*dx; /* Increment to move to E pixel */ + NEincr = 2*(dx - dy); /* Increment to move to NE pixel */ + putPixel(x1,y1,color); /* Draw the first point at (x1,y1) */ + /* Incrementally determine the positions of the remaining pixels */ + for (y1++; y1 <= y2; y1++) + { + if (d < 0) + d += Eincr; /* Choose the Eastern Pixel */ + else + { + d += NEincr; /* Choose the North Eastern Pixel */ + x1 += yincr; /* (or SE pixel for dx/dy < 0!) */ + } + putPixel(x1,y1,color); /* Draw the point */ + } + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 77 + + + +VBE Overview + + +/* Draw a simple moire pattern of lines on the display */ +void drawMoire(void) +{ int i; + for (i = 0; i < xres; i += 5) + { + line(xres/2,yres/2,i,0,i % 0xFF); + line(xres/2,yres/2,i,yres,(i+1) % 0xFF); + } + for (i = 0; i < yres; i += 5) + { + line(xres/2,yres/2,0,i,(i+2) % 0xFF); + line(xres/2,yres/2,xres,i,(i+3) % 0xFF); + } + line(0,0,xres-1,0,15); + line(0,0,0,yres-1,15); + line(xres-1,0,xres-1,yres-1,15); + line(0,yres-1,xres-1,yres-1,15); +} + +/* Return NEAR pointer to FAR string pointer*/ + +char *get_str(char far *p) +{ int i; + char *q=mystr; + + for(i=0;i<255;i++) + { + if(*p) *q++ = *p++; + else break; + } + *q = '\0'; + return(mystr); +} + +/* Display a list of available resolutions. Be careful with calls to + * function 00h to get SuperVGA mode information. Many VBE's build the + * list of video modes directly in this information block, so if you + * are using a common buffer (which we aren't here, but in protected + * mode you will), then you will need to make a local copy of this list + * of available modes. + */ + +void availableModes(void) +{ unsigned far *p; + if (!getVbeInfo()) + { + printf("No VESA VBE detected\n"); + exit(1); + } + printf("VESA VBE Version %d.%d detected (%s)\n\n", + VbeInfoBlock.VESAVersion >> 8, VbeInfoBlock.VESAVersion & 0xF, + get_str(VbeInfoBlock.OEMStringPtr)); + printf("Available 256 color video modes:\n"); + for (p = VbeInfoBlock.VideoModePtr; *p !=(unsigned)-1; p++) + + +Page 78 VBE CORE FUNCTIONS VERSION 3.0 + + + + Appendix 2 - Sample Source Code + + + { + if (getModeInfo(*p)) + { + printf(" %4d x %4d %d bits per pixel\n", + ModeInfoBlock.XResolution, ModeInfoBlock.YResolution, + ModeInfoBlock.BitsPerPixel); + } + } + printf("\nUsage: hellovbe \n"); + exit(1); +} + +/* Initialize the specified video mode. Notice how we determine a shift + * factor for adjusting the Window granularity for bank switching. This + * is much faster than doing it with a multiply (especially with direct + * banking enabled). + */ +void initGraphics(unsigned int x, unsigned int y) +{ unsigned far *p; + if (!getVbeInfo()) + { + printf("No VESA VBE detected\n"); + exit(1); + } + for (p = VbeInfoBlock.VideoModePtr; *p != (unsigned)-1; p++) + { + if (getModeInfo(*p) && ModeInfoBlock.XResolution == x + && ModeInfoBlock.YResolution == y) + { + xres = x; yres = y; + bytesperline = ModeInfoBlock.BytesPerScanLine; + bankShift = 0; + while ((unsigned)(64 >> bankShift) != ModeInfoBlock.WinGranularity) + bankShift++; + bankSwitch = ModeInfoBlock.WinFuncPtr; + curBank = -1; + screenPtr = (char far *)( ((long)0xA000)<<16 | 0); + oldMode = getVBEMode(); + setVBEMode(*p); + return; + } + } + printf("Valid video mode not found\n"); + exit(1); +} + +/* Main routine. Expects the x & y resolution of the desired video mode + * to be passed on the command line. Will print out a list of available + * video modes if no command line is present. + */ +void main(int argc,char *argv[]) +{ int x,y; + if (argc != 3) + availableModes(); /* Display list of available modes */ + x = atoi(argv[1]); /* Get requested resolution */ + + VBE CORE FUNCTIONS VERSION 3.0 Page 79 + + + +VBE Overview + + + y = atoi(argv[2]); + initGraphics(x,y); /* Start requested video mode */ + drawMoire(); /* Draw a moire pattern */ + getch(); /* Wait for keypress */ + setVBEMode(oldMode); /* Restore previous mode */ +} + +/*----------------------------------------------------------------------*/ +/* The following commented-out routines are for Planar modes */ +/* outpw() is for word output, outp() is for byte output */ +/*----------------------------------------------------------------------*/ + +/* Initialize Planar (Write mode 2) + * Should be Called from initGraphics + +void initPlanar() +{ outpw(0x3C4,0x0F02); + outpw(0x3CE,0x0003); + outpw(0x3CE,0x0205); +}*/ +/* Reset to Write Mode 0 + * for BIOS default draw text + +void setWriteMode0() +{ outpw(0x3CE,0xFF08); + outpw(0x3CE,0x0005); +}*/ +/* Plot a pixel in Planar mode + +void putPixelP(int x, int y, int color) +{ char dummy_read; + long addr = (long)y * bytesperline + (x/8); + setBank((int)(addr >> 16)); + outp(0x3CE,8); + outp(0x3CF,0x80 >> (x & 7)); + dummy_read = *(screenPtr + (addr & 0xFFFF)); + *(screenPtr + (addr & 0xFFFF)) = (char)color; +}*/ +Assembly Language Module +Below is the Assembly Language module required for the direct bank switching. In Borland C or +other C compilers, this can be converted to in-line assembly code. + +public _setbxdx +.MODEL SMALL ;whatever +.CODE +set_struc struc + dw ? ;old bp + dd ? ;return addr (always far call) + +Page 80 VBE CORE FUNCTIONS VERSION 3.0 + + + + Appendix 2 - Sample Source Code + + +p_bx dw ? ;reg bx value +p_dx dw ? ;reg dx value +set_struc ends + +_setbxdx proc far ; must be FAR + push bp + mov bp,sp + mov bx,[bp]+p_bx + mov dx,[bp]+p_dx + pop bp + ret +_setbxdx endp +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 81 + + + +VBE Overview + + + + + Appendix 3 - Differences Between VBE Revisions + + +VBE 1.0 + Initial implementation:Implemented Functions 00-05h + Defined modes 100-107h + +VBE 1.1 + Second implementation: Added Functions 06h and 07h. + Added modes 108-10Ch + Added TotalMemory to VbeInfoBlock + Added NumberOfImagePages and + Reserved fields to ModeInfoBlock + +VBE 1.2 + Third implementation: Added Function 08h + Added Hi-color modes 10D-11Bh + Added Reserved field to VbeInfoBlock + Added New Direct color fields to ModeInfoBlock + Changed optional fields to mandatory in ModeInfoBlock + Added Capabilities bit definition in VbeInfoBlock + +VBE 2.0 + Fourth implementation: Added Flat Frame Buffer support in Function 02h (D14) + Added protected mode support (Function 0Ah) + Added new DAC services for palette operations + (Function 09h) + Added new completion codes 02h and 03h + Added OEM information to VbeInfoBlock + Added two new definitions to Capabilities in VbeInfoBlock + Added new fields to ModeInfoBlock + Certification and ROM requirements for Compliance + Clarified Memory Clear bit in Function 02h (D15) + Clarified Memory Clear bit in Function 03h (D15) + Added new return field in Function 06h + Added Supplemental Functions definition and defined + Supplemental Functions 10-16h + Added new mode to access all of video memory + Added wait for vertical retrace in Function 07h + Clarified and removed ambiguities in the earlier + + +Page 82 VBE CORE FUNCTIONS VERSION 3.0 + + + + Appendix 3 - Differences Between VBE Revisions + + + specifications + Added new mode to access all video memory. + +VBE 2.0, Rev. 1.1 + Fifth implementation: Section 3 - Revised sentence to read: Note that modes may + only be set if the mode exists in the VideoModeList pointed + to by the VideoModePTR returned in Function 00h. + The exception to this requirement is the mode number + 81ffh. + + Section 4.2 - Added: If the memory location is zero, then + only I/O mapped ports will be used so the application does + not need to do anything special. This should be the default + case for ALL cards that have I/O mapped registers because + it provides the best performance. + and + If the memory location is nonzero (there can be only one), + the application will need to create a new 32-bit selector with + the base address that points to the "physical" location + specified with the specified limit. + and + When the application needs to call the 32-bit bank switch + function, it must then load the ES selector with the value of + the new selector that has been created. The bank switching + code can then directly access its memory mapped registers + as absolute offsets into the ES selector + (i.e., mov [es:10],eax to put a value into the register at + base+10). + + It is up to the application code to save and restore the + previous state of the ES selector if this is necessary (for + example in flat model code) + + Section 4.5 - Revised sentence to read: If function call D7 + is set and the application assumes it is similar to the IBM + compatible mode set using VBE Function 02h, the + implementation will fail. + + Added: Note: CX and DX, for both input and output + values, will be zero based. + + Added: If the memory location is zero, then only I/O + mapped ports will be used so the application does not need + to do anything special. This should be the default case for + + + VBE CORE FUNCTIONS VERSION 3.0 Page 83 + + + +VBE Overview + + + ALL cards that have I/O mapped registers because it + provides the best performance. + and + If the memory location is nonzero (there can be only one), + the application will need to create a new 32-bit selector with + the base address that points to the "physical" location + specified with the specified limit. + and + When the application needs to call the 32-bit bank switch + function, it must then load the ES selector with the value of + the new selector that has been created. The bank switching + code can then directly access its memory mapped registers + as absolute offsets into the ES selector (i.e., mov + [es:10],eax to put a value into the register at base+10). + + It is up to the application code to save and restore the + previous state of the ES selector if this is necessary (for + example in flat model code). + + Added to first paragraph: However, it should not appear in + the VideoModeList. Look in the ModeInfoBlock to + determine if paging is required and, if it is required, how it is + supported. + + Section A5.2.11 - Added: If the memory location is zero, + then only I/O mapped ports will be used so the application + does not need to do anything special. This should be the + default case for ALL cards that have I/O mapped registers + because it provides the best performance. + and + If the memory location is nonzero (there can be only one), + the application will need to create a new 32-bit selector with + the base address that points to the "physical" location + specified with the specified limit. + + Corrected typographical errors and style. + + Modified copyright notice; modified Support section; added + missing paragraphs regarding protected mode to function + 0Ah and section on protected mode considerations; + corrected typo in function 09h ­ 255 should have read 256; + corrected cast of 'color' in C example. + + + + + +Page 84 VBE CORE FUNCTIONS VERSION 3.0 + + + + Appendix 3 - Differences Between VBE Revisions + + +VBE 3.0 + Current implementation: Major style and formatting updated to the document to + enhance the visual appearance and readability. + + Added new `Programming with VBE/Core' section for + application programming notes. + + Added new `Protected Mode Entry Point' for compatibility + with fully protected mode operating systems such as + Windows NT, OS/2 and the many variants of UNIX. + + VBE Function 00h. Updated to include support for refresh + control. + + VBE Function 00h. Added note about extended text modes + not required to be supported via the protected mode entry + point. + + VBE Function 01h. Updated to return extended information + about the banked and linear modes, so that the hardware + implementation for banked and linear modes can be different + (such as restricted memory access in one of the modes, + different scanline widths etc). + + VBE Function 01h. Updated to return information about the + maximum pixel clock possible for the graphics mode, along + with the pixel clock scaling flags. + + VBE Function 02h. Updated to provide a `Refresh Control' + flag in bit D13 of the video mode number, and to pass in a + table of normalized CRTC values and pixel clock to the + mode set function. + + VBE Function 02h. Changed so that VBE 3.0 + implementations may not clear the screen for a mode set if + bit D15 is set. VBE 3.0 aware apps must assume screen has + not been cleared. + + VBE Function 02h. Added note about extended text modes + not required to be supported via the protected mode entry + point. + + VBE Function 07h. Updated to provide support for + hardware triple buffering and Stereo LC shutter glasses. + + + VBE CORE FUNCTIONS VERSION 3.0 Page 85 + + + +VBE Overview + + + VBE Function 09h. Updated to be optional if the controller + is VGA compatible to save on BIOS space. + + VBE Function 0Ah. Updated to be optional since the new + protected mode entry point supercedes this interface. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Page 86 VBE CORE FUNCTIONS VERSION 3.0 + + + + Related Documents + + + + + Appendix 4 - Related Documents + + +* VGA Reference Manual(s) +* Graphic Controller Data Sheets +* VESA Monitor Timings +* VBE/PM Monitor Power Management Standard +* VBE/AI VESA Audio Interface +* VBE/AF Accelerator Functions Specification +* VBE/DDC VESA Display Data Channel Software Interface Standard +* VESA DDC Hardware Specification +* VESA DPMS Hardware Specification +* VESA Generalized Timing Formula (VM/GTF) Specification +* VESA Stereo Connector (Proposal) + + + + + + + + + + + + + + + + + + + + + + + + + + + + VBE CORE FUNCTIONS VERSION 3.0 Page 87 + + + + diff --git a/mobius/doc/txt/vfat.txt b/mobius/doc/txt/vfat.txt new file mode 100644 index 0000000..edceee1 --- /dev/null +++ b/mobius/doc/txt/vfat.txt @@ -0,0 +1,426 @@ +TODO +---------------------------------------------------------------------- +* Need to get rid of the raw scanning stuff. Instead, always use + a get next directory entry approach. The only thing left that uses + raw scanning is the directory renaming code. + +* Need to make the vfat_find routine more flexible. It should be + more like the vfat_readdir routine. The vfat_readdir routine + only reads the necessary parts of the filename when trying to + find a match. + +* Need to add dcache_add code to cache directory entries. See the + ext2 code of dir.c for this. The msdos filesystem could use this + improvement as well. + + +POSSIBLE PROBLEMS +---------------------------------------------------------------------- +* vfat_valid_longname does not properly checked reserved names. + + +BUG REPORTS +---------------------------------------------------------------------- +If you have trouble with the VFAT filesystem, mail bug reports to +chaffee@bugs-bunny.cs.berkeley.edu. Please specify the filename +and the operation that gave you trouble. + + +NOTES ON THE STRUCTURE OF THE VFAT FILESYTEM +---------------------------------------------------------------------- +(This documentation was provided by Galen C. Hunt ). + +This document presents a very rough, technical overview of my +knowledge of the extended FAT file system used in Windows NT 3.5 and +Windows 95. I don't guarantee that any of the following is correct, +but it appears to be so. + +The extended FAT file system is almost identical to the FAT +file system used in DOS versions up to and including 6.223410239847 +:-). The significant change has been the addition of long file names. +Theses names support up to 255 characters including spaces and lower +case characters as opposed to the traditional 8.3 short names. + +Traditionally a file has had one directory entry described by +the following C structure: + + struct directory { // Short 8.3 names + unsigned char name[8]; // file name + unsigned char ext[3]; // file extension + unsigned char attr; // attribute byte + unsigned char reserved[10]; // reserved values (ignored) + unsigned char time[2]; // time stamp + unsigned char date[2]; // date stamp + unsigned char start[2]; // starting cluster number + unsigned char size[4]; // size of the file + }; + +Note that the "start" and "size" values are actually little +endian integer values. The descriptions of the fields in this +structure are public knowledge and can be found elsewhere. + +With the extended FAT system, Microsoft has inserted extra +directory entries for any files with extended names. (Any name which +legally fits within the old 8.3 encoding scheme does not have extra +entries.) I call these extra entries slots. Basically, a slot is a +specially formatted directory entry which holds up to 13 characters of +a files extended name. Think of slots as additional labeling for the +directory entry of the file to which they correspond. Microsoft +prefers to refer to the 8.3 entry for a file as its alias and the +extended slot directory entries as the file name. + +The C structure for a slot directory entry follows: + + struct slot { // Up to 13 characters of a long name + unsigned char id; // sequence number for slot + unsigned char name0_4[10]; // first 5 characters in name + unsigned char attr; // attribute byte + unsigned char reserved; // always 0 + unsigned char alias_checksum; // checksum for 8.3 alias + unsigned char name5_10[12]; // 6 more characters in name + unsigned char start[2]; // starting cluster number + unsigned char name11_12[4]; // last 2 characters in name + }; + +If the layout of the slots looks a little odd, it's only +because of Microsoft's efforts to maintain compatibility with old +software. The slots must be disguised to prevent old software from +panicing. To this end, a number of measures are taken: + + 1) The attribute byte for a slot directory entry is always set + to 0x0f. This corresponds to an old directory entry with + attributes of "hidden", "system", "read-only", and "volume + label". Most old software will ignore any directory + entries with the "volume label" bit set. Real volume label + entries don't have the other three bits set. + + 2) The starting cluster is always set to 0, an impossible + value for a DOS file. + +Because the extended FAT system is backward compatible, it is +possible for old software to modify directory entries. Measures must +be taken to insure the validity of slots. An extended FAT system can +verify that a slot does in fact belong to an 8.3 directory entry by +the following: + + 1) Positioning. Slots for a file always immediately proceed + their corresponding 8.3 directory entry. In addition, each + slot has an id which marks its order in the extended file + name. Here is a very abbreviated view of an 8.3 directory + entry and its corresponding long name slots for the file + "My Big File.Extension which is long": + + + + + + + + Note that the slots are stored from last to first. Slots + are numbered from 1 to N. The Nth slot is or'ed with 0x40 + to mark it as the last one. + + 2) Checksum. Each slot has an "alias_checksum" value. The + checksum is calculated from the 8.3 name using the + following algorithm: + + for (sum = i = 0; i < 11; i++) { + sum = (((sum&1)<<7)|((sum&0xfe)>>1)) + name[i] + } + + 3) If there is in the final slot, a Unicode NULL (0x0000) is stored + after the final character. After that, all unused characters in + the final slot are set to Unicode 0xFFFF. + +Finally, note that the extended name is stored in Unicode. Each Unicode +character takes two bytes. + + +NOTES ON UNICODE TRANSLATION IN VFAT FILESYTEM +---------------------------------------------------------------------- +(Information provided by Steve Searle ) + +Char used as Char(s) used Char(s) used in Entries which have +filename in shortname longname slot been corrected +0x80 (128) 0x80 0xC7 +0x81 (129) 0x9A 0xFC +0x82 (130) 0x90 0xE9 E +0x83 (131) 0xB6 0xE2 E +0x84 (132) 0x8E 0xE4 E +0x85 (133) 0xB7 0xE0 E +0x86 (134) 0x8F 0xE5 E +0x87 (135) 0x80 0xE7 E +0x88 (136) 0xD2 0xEA E +0x89 (137) 0xD3 0xEB E +0x8A (138) 0xD4 0xE8 E +0x8B (139) 0xD8 0xEF E +0x8C (140) 0xD7 0xEE E +0x8D (141) 0xDE 0xEC E +0x8E (142) 0x8E 0xC4 E +0x8F (143) 0x8F 0xC5 E +0x90 (144) 0x90 0xC9 E +0x91 (145) 0x92 0xE6 E +0x92 (146) 0x92 0xC6 E +0x93 (147) 0xE2 0xF4 E +0x94 (148) 0x99 0xF6 +0x95 (149) 0xE3 0xF2 +0x96 (150) 0xEA 0xFB +0x97 (151) 0xEB 0xF9 +0x98 (152) "_~1" 0xFF +0x99 (153) 0x99 0xD6 +0x9A (154) 0x9A 0xDC +0x9B (155) 0x9D 0xF8 +0x9C (156) 0x9C 0xA3 +0x9D (157) 0x9D 0xD8 +0x9E (158) 0x9E 0xD7 +0x9F (159) 0x9F 0x92 +0xA0 (160) 0xB5 0xE1 +0xA1 (161) 0xD6 0xE0 +0xA2 (162) 0xE0 0xF3 +0xA3 (163) 0xE9 0xFA +0xA4 (164) 0xA5 0xF1 +0xA5 (165) 0xA5 0xD1 +0xA6 (166) 0xA6 0xAA +0xA7 (167) 0xA7 0xBA +0xA8 (168) 0xA8 0xBF +0xA9 (169) 0xA9 0xAE +0xAA (170) 0xAA 0xAC +0xAB (171) 0xAB 0xBD +0xAC (172) 0xAC 0xBC +0xAD (173) 0xAD 0xA1 +0xAE (174) 0xAE 0xAB +0xAF (175) 0xAF 0xBB +0xB0 (176) 0xB0 0x91 0x25 +0xB1 (177) 0xB1 0x92 0x25 +0xB2 (178) 0xB2 0x93 0x25 +0xB3 (179) 0xB3 0x02 0x25 +0xB4 (180) 0xB4 0x24 0x25 +0xB5 (181) 0xB5 0xC1 +0xB6 (182) 0xB6 0xC2 +0xB7 (183) 0xB7 0xC0 +0xB8 (184) 0xB8 0xA9 +0xB9 (185) 0xB9 0x63 0x25 +0xBA (186) 0xBA 0x51 0x25 +0xBB (187) 0xBB 0x57 0x25 +0xBC (188) 0xBC 0x5D 0x25 +0xBD (189) 0xBD 0xA2 +0xBE (190) 0xBE 0xA5 +0xBF (191) 0xBF 0x10 0x25 +0xC0 (192) 0xC0 0x14 0x25 +0xC1 (193) 0xC1 0x34 0x25 +0xC2 (194) 0xC2 0x2C 0x25 +0xC3 (195) 0xC3 0x1C 0x25 +0xC4 (196) 0xC4 0x00 0x25 +0xC5 (197) 0xC5 0x3C 0x25 +0xC6 (198) 0xC7 0xE3 E +0xC7 (199) 0xC7 0xC3 +0xC8 (200) 0xC8 0x5A 0x25 E +0xC9 (201) 0xC9 0x54 0x25 E +0xCA (202) 0xCA 0x69 0x25 E +0xCB (203) 0xCB 0x66 0x25 E +0xCC (204) 0xCC 0x60 0x25 E +0xCD (205) 0xCD 0x50 0x25 E +0xCE (206) 0xCE 0x6C 0x25 E +0xCF (207) 0xCF 0xA4 E +0xD0 (208) 0xD1 0xF0 +0xD1 (209) 0xD1 0xD0 +0xD2 (210) 0xD2 0xCA +0xD3 (211) 0xD3 0xCB +0xD4 (212) 0xD4 0xC8 +0xD5 (213) 0x49 0x31 0x01 +0xD6 (214) 0xD6 0xCD +0xD7 (215) 0xD7 0xCE +0xD8 (216) 0xD8 0xCF +0xD9 (217) 0xD9 0x18 0x25 +0xDA (218) 0xDA 0x0C 0x25 +0xDB (219) 0xDB 0x88 0x25 +0xDC (220) 0xDC 0x84 0x25 +0xDD (221) 0xDD 0xA6 +0xDE (222) 0xDE 0xCC +0xDF (223) 0xDF 0x80 0x25 +0xE0 (224) 0xE0 0xD3 +0xE1 (225) 0xE1 0xDF +0xE2 (226) 0xE2 0xD4 +0xE3 (227) 0xE3 0xD2 +0xE4 (228) 0x05 0xF5 +0xE5 (229) 0x05 0xD5 +0xE6 (230) 0xE6 0xB5 +0xE7 (231) 0xE8 0xFE +0xE8 (232) 0xE8 0xDE +0xE9 (233) 0xE9 0xDA +0xEA (234) 0xEA 0xDB +0xEB (235) 0xEB 0xD9 +0xEC (236) 0xED 0xFD +0xED (237) 0xED 0xDD +0xEE (238) 0xEE 0xAF +0xEF (239) 0xEF 0xB4 +0xF0 (240) 0xF0 0xAD +0xF1 (241) 0xF1 0xB1 +0xF2 (242) 0xF2 0x17 0x20 +0xF3 (243) 0xF3 0xBE +0xF4 (244) 0xF4 0xB6 +0xF5 (245) 0xF5 0xA7 +0xF6 (246) 0xF6 0xF7 +0xF7 (247) 0xF7 0xB8 +0xF8 (248) 0xF8 0xB0 +0xF9 (249) 0xF9 0xA8 +0xFA (250) 0xFA 0xB7 +0xFB (251) 0xFB 0xB9 +0xFC (252) 0xFC 0xB3 +0xFD (253) 0xFD 0xB2 +0xFE (254) 0xFE 0xA0 0x25 +0xFF (255) 0xFF 0xA0 + + +Page 0 +0x80 (128) 0x00 +0x81 (129) 0x00 +0x82 (130) 0x00 +0x83 (131) 0x00 +0x84 (132) 0x00 +0x85 (133) 0x00 +0x86 (134) 0x00 +0x87 (135) 0x00 +0x88 (136) 0x00 +0x89 (137) 0x00 +0x8A (138) 0x00 +0x8B (139) 0x00 +0x8C (140) 0x00 +0x8D (141) 0x00 +0x8E (142) 0x00 +0x8F (143) 0x00 +0x90 (144) 0x00 +0x91 (145) 0x00 +0x92 (146) 0x00 +0x93 (147) 0x00 +0x94 (148) 0x00 +0x95 (149) 0x00 +0x96 (150) 0x00 +0x97 (151) 0x00 +0x98 (152) 0x00 +0x99 (153) 0x00 +0x9A (154) 0x00 +0x9B (155) 0x00 +0x9C (156) 0x00 +0x9D (157) 0x00 +0x9E (158) 0x00 +0x9F (159) 0x92 +0xA0 (160) 0xFF +0xA1 (161) 0xAD +0xA2 (162) 0xBD +0xA3 (163) 0x9C +0xA4 (164) 0xCF +0xA5 (165) 0xBE +0xA6 (166) 0xDD +0xA7 (167) 0xF5 +0xA8 (168) 0xF9 +0xA9 (169) 0xB8 +0xAA (170) 0x00 +0xAB (171) 0xAE +0xAC (172) 0xAA +0xAD (173) 0xF0 +0xAE (174) 0x00 +0xAF (175) 0xEE +0xB0 (176) 0xF8 +0xB1 (177) 0xF1 +0xB2 (178) 0xFD +0xB3 (179) 0xFC +0xB4 (180) 0xEF +0xB5 (181) 0xE6 +0xB6 (182) 0xF4 +0xB7 (183) 0xFA +0xB8 (184) 0xF7 +0xB9 (185) 0xFB +0xBA (186) 0x00 +0xBB (187) 0xAF +0xBC (188) 0xAC +0xBD (189) 0xAB +0xBE (190) 0xF3 +0xBF (191) 0x00 +0xC0 (192) 0xB7 +0xC1 (193) 0xB5 +0xC2 (194) 0xB6 +0xC3 (195) 0xC7 +0xC4 (196) 0x8E +0xC5 (197) 0x8F +0xC6 (198) 0x92 +0xC7 (199) 0x80 +0xC8 (200) 0xD4 +0xC9 (201) 0x90 +0xCA (202) 0xD2 +0xCB (203) 0xD3 +0xCC (204) 0xDE +0xCD (205) 0xD6 +0xCE (206) 0xD7 +0xCF (207) 0xD8 +0xD0 (208) 0x00 +0xD1 (209) 0xA5 +0xD2 (210) 0xE3 +0xD3 (211) 0xE0 +0xD4 (212) 0xE2 +0xD5 (213) 0xE5 +0xD6 (214) 0x99 +0xD7 (215) 0x9E +0xD8 (216) 0x9D +0xD9 (217) 0xEB +0xDA (218) 0xE9 +0xDB (219) 0xEA +0xDC (220) 0x9A +0xDD (221) 0xED +0xDE (222) 0xE8 +0xDF (223) 0xE1 +0xE0 (224) 0x85, 0xA1 +0xE1 (225) 0xA0 +0xE2 (226) 0x83 +0xE3 (227) 0xC6 +0xE4 (228) 0x84 +0xE5 (229) 0x86 +0xE6 (230) 0x91 +0xE7 (231) 0x87 +0xE8 (232) 0x8A +0xE9 (233) 0x82 +0xEA (234) 0x88 +0xEB (235) 0x89 +0xEC (236) 0x8D +0xED (237) 0x00 +0xEE (238) 0x8C +0xEF (239) 0x8B +0xF0 (240) 0xD0 +0xF1 (241) 0xA4 +0xF2 (242) 0x95 +0xF3 (243) 0xA2 +0xF4 (244) 0x93 +0xF5 (245) 0xE4 +0xF6 (246) 0x94 +0xF7 (247) 0xF6 +0xF8 (248) 0x9B +0xF9 (249) 0x97 +0xFA (250) 0xA3 +0xFB (251) 0x96 +0xFC (252) 0x81 +0xFD (253) 0xEC +0xFE (254) 0xE7 +0xFF (255) 0x98 + + +ACKNOWLEDGEMENTS +---------------------------------------------------------------------- +Thanks to Galen C. Hunt for the very useful +information he provided on creating the short filename checksum and the +structure of the long filenames. + +Thanks to Michael R. Gile for his information about +the case bits for the DOS filename entry and his excellent bug reports. + +Thanks to Gilles Vollant <100144.2636@compuserve.com> for telling me +what was broken in the 1.3.x kernels. Gilles wrote doslfn, a package +with the same functionality as vfat. We intend to work together to +create an excellent combined package. + +Thanks to Steve Searle for finding a bunch of +problems with certain filenames under Windows 95. He provided fixes +and changes to the filesystem to make it work much more like the +Windows 95 implementation. + +Additional thanks to Alain Knaff and +David C. Niemi for comments in email discussions. diff --git a/mobius/include/assert.h b/mobius/include/assert.h new file mode 100644 index 0000000..d7a95cf --- /dev/null +++ b/mobius/include/assert.h @@ -0,0 +1,4 @@ +#ifndef __ASSERT_H +#define __ASSERT_H + +#endif \ No newline at end of file diff --git a/mobius/include/conio.h b/mobius/include/conio.h new file mode 100644 index 0000000..7c051d8 --- /dev/null +++ b/mobius/include/conio.h @@ -0,0 +1,30 @@ +#ifndef __CONIO_H +#define __CONIO_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +/*! + * \ingroup libc + * \defgroup conio Console I/O + * @{ + */ + +wint_t _wgetch(); +wint_t _wgetche(); +int _kbhit(); +void delay(int ms); + +#define kbhit _kbhit + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/ctype.h b/mobius/include/ctype.h new file mode 100644 index 0000000..d3e8ab6 --- /dev/null +++ b/mobius/include/ctype.h @@ -0,0 +1,43 @@ +#ifndef __CTYPE_H +#define __CTYPE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +/*! + * \ingroup libc + * \defgroup ctype Character classification + * @{ + */ + +int iswupper(wint_t c); +int iswlower(wint_t c); +int towupper(wint_t c); +int towlower(wint_t c); + +#define iswdigit(c) ((c) >= '0' && (c) <= '9') +#define iswspace(c) ((c) == ' ' || (c) == '\n' || (c) == '\t' || (c) == '\r') +#define iswalpha(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z')) + +#define isupper(c) ((c) >= 'A' && (c) <= 'Z') +#define islower(c) ((c) >= 'a' && (c) <= 'a') +#define tolower(c) (isupper(c) ? ((c) - 'A' + 'a') : (c)) +#define toupper(c) (islower(c) ? ((c) - 'a' + 'A') : (c)) + +#define isdigit(c) ((c) >= '0' && (c) <= '9') +#define isspace(c) ((c) == ' ' || (c) == '\n' || (c) == '\t' || (c) == '\r') +#define isalpha(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z')) + +#define isalnum(c) (isalpha(c) || isdigit(c)) + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/dirent.h b/mobius/include/dirent.h new file mode 100644 index 0000000..6fe4ca1 --- /dev/null +++ b/mobius/include/dirent.h @@ -0,0 +1,14 @@ +#ifndef __DIRENT_H +#define __DIRENT_H + +typedef struct DIR DIR; +struct dirent +{ + int d_reclen; + char d_name[20]; +}; + +#define opendir(p) NULL +#define closedir(d) + +#endif \ No newline at end of file diff --git a/mobius/include/errno.h b/mobius/include/errno.h new file mode 100644 index 0000000..761e2c8 --- /dev/null +++ b/mobius/include/errno.h @@ -0,0 +1,37 @@ +#ifndef __ERRNO_H +#define __ERRNO_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! + * \ingroup libc + * \defgroup errno Error handling + * @{ + */ + +int *__errno(); + +#define errno (*__errno()) + +#define EDOM 1 +#define EILSEQ 2 +#define ERANGE 3 +#define ENOTIMPL 4 +#define EBUFFER 5 +#define ENOTFOUND 6 +#define EINVALID 7 +#define EMFILE 8 +#define ENOMEM 9 + +#define EINVAL EINVALID + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/fcntl.h b/mobius/include/fcntl.h new file mode 100644 index 0000000..a33e1be --- /dev/null +++ b/mobius/include/fcntl.h @@ -0,0 +1,14 @@ +#ifndef __FCNTL_H +#define __FCNTL_H + +#define O_RDONLY 0x0000 /* open for reading only */ +#define O_WRONLY 0x0001 /* open for writing only */ +#define O_RDWR 0x0002 /* open for reading and writing */ +#define O_APPEND 0x0008 /* writes done at eof */ + +#define O_CREAT 0x0100 /* create and open file */ +#define O_TRUNC 0x0200 /* open and truncate */ +#define O_EXCL 0x0400 /* open only if file doesn't already exist */ +#define O_BINARY 0x8000 /* file mode is binary (untranslated) */ + +#endif \ No newline at end of file diff --git a/mobius/include/gui/font.h b/mobius/include/gui/font.h new file mode 100644 index 0000000..cdabad2 --- /dev/null +++ b/mobius/include/gui/font.h @@ -0,0 +1,23 @@ +#ifndef __GUI_FONT_H +#define __GUI_FONT_H + +#include + +#undef INTERFACE +#define INTERFACE IFont +DECLARE_INTERFACE(IFont) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void ** ppvObject) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + STDMETHOD(DrawText)(THIS_ ISurface* pSurf, int x, int y, const wchar_t* str, + pixel_t pixColour) PURE; + STDMETHOD(GetTextExtent)(THIS_ const wchar_t* str, point_t* size) PURE; +}; + +// {816B7D59-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IFont, +0x816b7d59, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +#endif diff --git a/mobius/include/gui/messages.h b/mobius/include/gui/messages.h new file mode 100644 index 0000000..bfb6447 --- /dev/null +++ b/mobius/include/gui/messages.h @@ -0,0 +1,9 @@ +#ifndef __MESSAGES_H +#define __MESSAGES_H + +#define WM_QUIT 0 +#define WM_PAINT 1 +#define WM_CHAR 2 +#define WM_MOUSEMOVE 3 + +#endif \ No newline at end of file diff --git a/mobius/include/gui/surface.h b/mobius/include/gui/surface.h new file mode 100644 index 0000000..835122e --- /dev/null +++ b/mobius/include/gui/surface.h @@ -0,0 +1,185 @@ +#ifndef __GUI_SURFACE_H +#define __GUI_SURFACE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +typedef dword pixel_t; +typedef dword colour_t; + +#define RGB(r, g, b) ((byte) (b) | ((byte) (g) << 8) | ((byte) (r) << 16)) +#define GetRValue(rgb) ((dword) (rgb) & 0xff0000) +#define GetGValue(rgb) ((dword) (rgb) & 0x00ff00) +#define GetBValue(rgb) ((dword) (rgb) & 0x0000ff) + +typedef struct surface_t surface_t; +struct surface_t +{ + int nWidth, nHeight, nBpp, nPitch; + void* pMemory; +}; + +typedef struct rectangle_t rectangle_t; +struct rectangle_t +{ + int left, top, right, bottom; + +#ifdef __cplusplus + + rectangle_t() { } + + rectangle_t(int x1, int y1, int x2, int y2) + { + left = x1; + top = y1; + right = x2; + bottom = y2; + } + + operator rectangle_t*() + { + return this; + } + + void OffsetRect(int dx, int dy) + { + left += dx; + top += dy; + right += dx; + bottom += dy; + } + + void InflateRect(int dx, int dy) + { + left -= dx; + top -= dy; + right += dx; + bottom += dy; + } + + void UnionRect(const rectangle_t* rect) + { + if (!rect->IsEmpty()) + { + left = min(left, rect->left); + top = min(top, rect->top); + right = max(right, rect->right); + bottom = max(bottom, rect->bottom); + } + } + + bool IsEmpty() const + { + return left == 0 && + top == 0 && + right == 0 && + bottom == 0; + } + + void SetEmpty() + { + left = right = top = bottom = 0; + } + + int Width() const + { + return right - left; + } + + int Height() const + { + return bottom - top; + } + +#endif +}; + +typedef struct point_t point_t; +struct point_t +{ + int x, y; + +#ifdef __cplusplus + + point_t() { } + + point_t(int x1, int y1) + { + x = x1; + y = y1; + } + +#endif +}; + +typedef enum +{ + modeCopy, + modeXor, + modeNot +} DrawMode; + +#undef INTERFACE +#define INTERFACE ISurface +DECLARE_INTERFACE(ISurface) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void ** ppvObject) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + STDMETHOD(SetPalette)(THIS_ int nIndex, int red, int green, int blue) PURE; + STDMETHOD(Blt)(THIS_ ISurface* pSrc, int x, int y, int nWidth, + int nHeight, int nSrcX, int nSrcY, pixel_t pixTrans) PURE; + STDMETHOD(Lock)(THIS_ surface_t* pDesc) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ surface_t* pDesc) PURE; + STDMETHOD_(pixel_t, ColourMatch)(THIS_ colour_t clr) PURE; + + STDMETHOD(SetPixel)(THIS_ int x, int y, pixel_t pix) PURE; + STDMETHOD_(pixel_t, GetPixel)(THIS_ int x, int y) PURE; + STDMETHOD_(DrawMode, SetDrawMode)(THIS_ DrawMode mode) PURE; + STDMETHOD(FillRect)(THIS_ const rectangle_t* rect, pixel_t pix) PURE; + STDMETHOD(Rect3d)(THIS_ const rectangle_t* rect, pixel_t pixTop, + pixel_t pixBottom, int nWidth) PURE; + STDMETHOD(Rect)(THIS_ const rectangle_t* rect, pixel_t pix, int nWidth) PURE; + STDMETHOD(GetClipRect)(THIS_ rectangle_t* rect) PURE; +}; + +/* + * Some ISurface methods are currently not marshallable to the kernel: + * SetPalette + * Blt + * Rect3d + */ + +//HRESULT ISurface_SetPalette(ISurface* ptr, int nIndex, int red, int green, int blue); +//HRESULT ISurface_Blt(ISurface* ptr, ISurface* pSrc, int x, int y, int nWidth, + //int nHeight, int nSrcX, int nSrcY, pixel_t pixTrans); +HRESULT ISurface_Lock(ISurface* ptr, surface_t* pDesc); +HRESULT ISurface_Unlock(ISurface* ptr); +HRESULT ISurface_GetSurfaceDesc(ISurface* ptr, surface_t* pDesc); +pixel_t ISurface_ColourMatch(ISurface* ptr, colour_t clr); + +HRESULT ISurface_SetPixel(ISurface* ptr, int x, int y, pixel_t pix); +pixel_t ISurface_GetPixel(ISurface* ptr, int x, int y); +DrawMode ISurface_SetDrawMode(ISurface* ptr, DrawMode mode); +HRESULT ISurface_FillRect(ISurface* ptr, const rectangle_t* rect, pixel_t pix); +HRESULT ISurface_Rect3d(ISurface* ptr, const rectangle_t* rect, pixel_t pixTop, + pixel_t pixBottom, int nWidth); +HRESULT ISurface_Rect(ISurface* ptr, const rectangle_t* rect, pixel_t pix, int nWidth); +HRESULT ISurface_GetClipRect(ISurface* ptr, rectangle_t* rect); + +// {816B7D5a-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_ISurface, +0x816b7d5a, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/mobius/include/gui/winserve.h b/mobius/include/gui/winserve.h new file mode 100644 index 0000000..e0d40fe --- /dev/null +++ b/mobius/include/gui/winserve.h @@ -0,0 +1,125 @@ +#ifndef __GUI_WINSERVE_H +#define __GUI_WINSERVE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include +#include + +typedef struct msg_t msg_t; + +#undef INTERFACE +#define INTERFACE IWindow +DECLARE_INTERFACE(IWindow) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void ** ppvObject) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + STDMETHOD_(dword, GetAttrib)(THIS_ dword index) PURE; + STDMETHOD_(ISurface*, GetSurface)(THIS) PURE; + STDMETHOD(InvalidateRect)(THIS_ const rectangle_t* rect) PURE; + STDMETHOD(UpdateWindow)(THIS) PURE; + STDMETHOD(DefWndProc)(THIS_ dword message, dword param) PURE; + STDMETHOD_(IWindow*, GetFirstChild)(THIS) PURE; + STDMETHOD(ClientToScreen)(THIS_ rectangle_t* rect) PURE; +}; + +struct msg_t +{ + IWindow* wnd; + dword message; + dword params; +}; + +dword IWindow_GetAttrib(IWindow* ptr, dword index); +ISurface* IWindow_GetSurface(IWindow* ptr); +HRESULT IWindow_InvalidateRect(IWindow* ptr, const rectangle_t* rect); +HRESULT IWindow_UpdateWindow(IWindow* ptr); +HRESULT IWindow_DefWndProc(IWindow* ptr, dword message, dword param); +IWindow* IWindow_GetFirstChild(IWindow* ptr); +HRESULT IWindow_ClientToScreen(IWindow* ptr, rectangle_t* rect); + +// {816B7D58-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IWindow, +0x816b7d58, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +typedef struct windowdef_t windowdef_t; +struct windowdef_t +{ + size_t size; + dword flags; + const wchar_t* title; + size_t title_max; + int x, y, width, height; + IWindow* parent; + HRESULT (*wndproc) (IWindow*, dword, dword); +}; + +#define WIN_TITLE 0x01 +#define WIN_X 0x02 +#define WIN_Y 0x04 +#define WIN_WIDTH 0x08 +#define WIN_HEIGHT 0x10 +#define WIN_PARENT 0x20 +#define WIN_WNDPROC 0x40 + +#define ATTR_WNDPROC 0 +#define ATTR_PROCESS 1 +#define ATTR_MSGQUEUE 2 + +#undef INTERFACE +#define INTERFACE IMsgQueue +DECLARE_INTERFACE(IMsgQueue) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void ** ppvObject) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + STDMETHOD(PeekMessage)(THIS_ msg_t* msg, bool remove) PURE; + STDMETHOD(GetMessage)(THIS_ msg_t* msg) PURE; + STDMETHOD(DispatchMessage)(THIS_ const msg_t* msg) PURE; + STDMETHOD(PostMessage)(THIS_ IWindow* wnd, dword message, dword params) PURE; +}; + +// {816B7D5b-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IMsgQueue, +0x816b7d5b, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +HRESULT IMsgQueue_PeekMessage(IMsgQueue* ptr, msg_t* msg, bool remove); +HRESULT IMsgQueue_GetMessage(IMsgQueue* ptr, msg_t* msg); +HRESULT IMsgQueue_DispatchMessage(IMsgQueue* ptr, const msg_t* msg); +HRESULT IMsgQueue_PostMessage(IMsgQueue* ptr, IWindow* wnd, dword message, dword params); + +#undef INTERFACE +#define INTERFACE IWindowServer +DECLARE_INTERFACE(IWindowServer) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void ** ppvObject) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + STDMETHOD_(IWindow*, CreateWindow)(THIS_ const windowdef_t* def) PURE; + STDMETHOD_(ISurface*, GetScreen)(THIS) PURE; + STDMETHOD_(IFont*, GetFont)(THIS_ int index) PURE; +}; + +// {816B7D57-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IWindowServer, +0x816b7d57, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +IWindowServer* OpenServer(); + +IWindow* IWindowServer_CreateWindow(IWindowServer* ptr, const windowdef_t* def); +ISurface* IWindowServer_GetScreen(IWindowServer* ptr); +IFont* IWindowServer_GetFont(IWindowServer* ptr, int index); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/io.h b/mobius/include/io.h new file mode 100644 index 0000000..21f0288 --- /dev/null +++ b/mobius/include/io.h @@ -0,0 +1,21 @@ +#ifndef __IO_H +#define __IO_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +int _open(const char *filename, int oflag, ...); +int _read(int handle, void *buffer, unsigned int count); +int _close(int handle); + +#define access(p, m) 1 + +#define R_OK 0 + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/cache.h b/mobius/include/kernel/cache.h new file mode 100644 index 0000000..da7d787 --- /dev/null +++ b/mobius/include/kernel/cache.h @@ -0,0 +1,17 @@ +#ifndef __KERNEL_CACHE_H +#define __KERNEL_CACHE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +device_t* ccInstallBlockCache(device_t* dev, dword block_size); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/config.h b/mobius/include/kernel/config.h new file mode 100644 index 0000000..420995e --- /dev/null +++ b/mobius/include/kernel/config.h @@ -0,0 +1,20 @@ +#ifndef __KERNEL_CONFIG_H +#define __KERNEL_CONFIG_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +const char* cfgGetToken(const char* str, char* out, size_t max, + const char* ctrl); +hashtable_t* cfgParseStrLine(const char** line); +void cfgDeleteTable(hashtable_t* hash); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/debug.h b/mobius/include/kernel/debug.h new file mode 100644 index 0000000..55a6c93 --- /dev/null +++ b/mobius/include/kernel/debug.h @@ -0,0 +1,19 @@ +#ifndef __KERNEL_DEBUG_H +#define __KERNEL_DEBUG_H + +#ifdef DEBUG +#include +#define TRACE0(f) wprintf(L##f) +#define TRACE1(f, a) wprintf(L##f, a) +#define TRACE2(f, a, b) wprintf(L##f, a, b) +#define TRACE3(f, a, b, c) wprintf(L##f, a, b, c) +#define TRACE4(f, a, b, c, d) wprintf(L##f, a, b, c, d) +#else +#define TRACE0(f) +#define TRACE1(f, a) +#define TRACE2(f, a, b) +#define TRACE3(f, a, b, c) +#define TRACE4(f, a, b, c, d) +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/driver.h b/mobius/include/kernel/driver.h new file mode 100644 index 0000000..be9c402 --- /dev/null +++ b/mobius/include/kernel/driver.h @@ -0,0 +1,253 @@ +#ifndef __KERNEL_DRIVER_H +#define __KERNEL_DRIVER_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include +#include + +/*! + * \ingroup kernel + * \defgroup dev Device Manager + * @{ + */ + +#include + +typedef struct request_t request_t; + +//! Contains information on a request issued to a device driver +struct request_t +{ + //! Specifies the request code (one of DEV_xxx) + dword code; // in + //! Indicates the result of the request + status_t result; // out + //! Triggered when the request has completed + handle_t* event; // out when calling devRequest; + // in wrt driver + + //! Points to the next request in a driver's request list + request_t* next; + + /* Internal members */ + size_t user_length; // original user length + request_t *kernel_request; // in user mode, points to the copy made in kernel space + size_t original_request_size; // in kernel mode, the size of the original request + int queued; // is this request queued? + + union + { + //! General parameters for a buffered request + struct + { + //! The buffer used + addr_t buffer; + //! Size of the buffer in bytes + size_t length; + //! The position where the buffered operation is to start + /*! Ignored for character stream devices. */ + qword pos; + } buffered; + + //! Parameters for a DEV_OPEN request + struct + { + //! Specifies the parameters passed to devOpen() + const wchar_t* params; + } open; + + //! Parameters for a DEV_READ request + struct + { + //! Specifies the buffer into which data are read + void* buffer; // out + //! Specifies the number of bytes to read, and indicates the number + //! of bytes actually read + size_t length; // in/out + //! Specifies the offset where reading is to start + /*! Ignored for character stream devices. */ + qword pos; // in + } read; + + //! Parameters for a DEV_WRITE request + struct + { + //! Specifies the buffer from which data are written + const void* buffer; // in + //! Specifies the number of bytes to write, and indicates the number + //! of bytes actually written + size_t length; // in/out + //! Specifies the offset where writing is to start + /*! Ignored for character stream devices. */ + qword pos; // in + } write; + + //! Parameters for a DEV_IOCTL request + struct + { + //! Specifies a buffer containing ioctl parameters and data + void* buffer; // in/out + //! Specifies the size of the buffer + size_t length; // in/out + //! Specifies the IOCTL function to perform + dword code; // in + } ioctl; + + //! Parameters for a DEV_ISR request + struct + { + //! Specifies the IRQ which was triggered + byte irq; // in + } isr; + + //! Parameters for an FS_OPEN request + struct + { + const wchar_t* name; // in + size_t name_length; // in + struct file_t* fd; // out + } fs_open, fs_create; + + //! Parameters for an FS_MOUNT request + struct + { + const wchar_t* name; // in + size_t name_length; // in + struct device_t* dev; // in + } fs_mount; + + //! Parameters for FS_READ and FS_WRITE requests + struct + { + addr_t buffer; // out + size_t length; // in/out + struct file_t* fd; // in + } fs_read, fs_write, fs_getlength; + + //! Parameters for an FS_CLOSE request + struct + { + struct file_t* fd; // in + } fs_close; + + //! Parameters for a FS_IOCTL request + struct + { + //! Specifies a buffer containing ioctl parameters and data + void* buffer; // in/out + //! Specifies the size of the buffer + size_t length; // in/out + //! Specifies the IOCTL function to perform + dword code; // in + struct file_t* fd; + } fs_ioctl; + } params; +}; + +typedef struct device_t device_t; +typedef struct driver_t driver_t; + +//! The prototype of the driver's request function +typedef bool (*DEVREQ)(device_t*, request_t*); + +typedef struct device_config_t device_config_t; + +//! The kernel structure used to contain information on each device +/*! + * Since it is the device driver's responsibility to allocate memory for this + * structure, the driver author may place additional fields after this + * structure. For example, it is possible to use an instance of this structure + * as the first member of a larger one. + */ +struct device_t +{ + //! The driver that registered this device + driver_t* driver; + //! The function to be called for each device request + DEVREQ request; + //! Pointer to the device's first queued request, if any + request_t *req_first, + //! Pointer to the device's last queued request, if any + *req_last; + device_config_t *config; +}; + +typedef struct device_resource_t device_resource_t; + +enum { dresMemory, dresIo, dresIrq }; +struct device_resource_t +{ + int cls; + union + { + struct + { + addr_t base; + size_t length; + } memory; + + struct + { + addr_t base; + size_t length; + } io; + + byte irq; + } u; +}; + +struct device_config_t +{ + device_t *parent; + word vendor_id, device_id; + dword subsystem; + int num_resources; + device_resource_t *resources; +}; + +//! The kernel structure used to maintain each device driver DLL +struct driver_t +{ + //! The module used to load this driver + module_t* mod; + device_t* (*add_device)(driver_t*, const wchar_t*, device_config_t*); + device_t* (*mount_fs)(driver_t*, const wchar_t*, device_t*); +}; + +device_t* devOpen(const wchar_t* name, const wchar_t* params); +bool devClose(device_t* dev); +bool devRemove(device_t* dev); +status_t devRequest(device_t* dev, request_t* req); +status_t devRequestSync(device_t* dev, request_t* req); +bool devRegisterIrq(device_t* dev, byte irq, bool install); +driver_t* devInstallNewDevice(const wchar_t* name, device_config_t* cfg); +bool devRegister(const wchar_t* name, device_t* dev, device_config_t* cfg); +void devStartRequest(device_t* dev, request_t* req); +void devFinishRequest(device_t* dev, request_t* req); +status_t devReadSync(device_t* dev, qword pos, void* buffer, size_t* length); +status_t devWriteSync(device_t* dev, qword pos, const void* buffer, size_t* length); +status_t devUserRequest(device_t* dev, request_t* req, size_t size); +status_t devUserFinishRequest(request_t* req, bool delete_event); +dword devFindResource(const device_config_t *cfg, int cls, int index); + +#define devIsBufferedRequest(code) (((int) (code)) < 0) + +bool STDCALL drvInit(driver_t*); +void msleep(dword ms); + +//@} + +/*! + * \defgroup drivers Device Drivers + */ + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/fs.h b/mobius/include/kernel/fs.h new file mode 100644 index 0000000..bbf4d9b --- /dev/null +++ b/mobius/include/kernel/fs.h @@ -0,0 +1,29 @@ +#ifndef __KERNEL_FS_H +#define __KERNEL_FS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +typedef struct file_t file_t; +struct file_t +{ + device_t *fsd; + qword pos; +}; + +file_t* fsOpen(const wchar_t* path); +bool fsClose(file_t* fd); +size_t fsRead(file_t* fd, void* buffer, size_t length); +void fsSeek(file_t *fd, qword pos); +bool fsMount(const wchar_t* name, const wchar_t* fsd, device_t* device); +qword fsGetLength(file_t* fd); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/handle.h b/mobius/include/kernel/handle.h new file mode 100644 index 0000000..842a2c5 --- /dev/null +++ b/mobius/include/kernel/handle.h @@ -0,0 +1,38 @@ +#ifndef __KERNEL_HANDLE_H +#define __KERNEL_HANDLE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +typedef struct handle_t handle_t; +struct handle_t +{ + handle_t *next; + bool signal; + byte refs; + struct process_t* process; + const char* file; + int line; + thread_queue_t queue; +}; + +void* _hndAlloc(size_t size, struct process_t* proc, const char* file, int line); +#define hndAlloc(size, proc) _hndAlloc(size, proc, __FILE__, __LINE__); + +int hndAddRef(void* buf); +int hndFree(void* buf); +void hndSignal(void* buf, bool signal); +bool hndIsSignalled(void* buf); +void hndEnum(struct process_t* proc); + +#define hndHandle(buf) ((handle_t*) (buf) - 1) + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/hash.h b/mobius/include/kernel/hash.h new file mode 100644 index 0000000..b9e9921 --- /dev/null +++ b/mobius/include/kernel/hash.h @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////// +// Project: Redpants Kernel // +// Date: 5-12-2000 // +// Module: shell/hashtable.h // +// Purpose: This is the kernel, the main portion of the operating system, // +// that handles all the duties of a modern operating system. // +// // +// Created 2000, by Ben L. Titzer // +////////////////////////////////////////////////////////////////////////////// + +#ifndef __KERNEL_HASHTABLE_H +#define __KERNEL_HASHTABLE_H + +#include + +typedef struct hashelem_t hashelem_t; +struct hashelem_t +{ + const wchar_t* str; // string key + void *data; // the data +}; + +typedef struct hashtable_t hashtable_t; +struct hashtable_t +{ + dword size, used; + hashelem_t *table; +}; + +hashtable_t* hashCreate(dword size); +dword hashInsert(hashtable_t*, hashelem_t *); +void hashResize(hashtable_t*); +hashelem_t* hashFind(hashtable_t*, const wchar_t*); +void hashList(hashtable_t*, void (*callback)(hashelem_t *e)); + +dword hash(const wchar_t*); // hash function + +#endif diff --git a/mobius/include/kernel/i386.h b/mobius/include/kernel/i386.h new file mode 100644 index 0000000..f5a5011 --- /dev/null +++ b/mobius/include/kernel/i386.h @@ -0,0 +1,457 @@ +#ifndef __I386_H +#define __I386_H + +#include + +/* Ports */ +#define PORT_8259M 0x20 +#define PORT_8259S 0xA0 +#define PORT_KBD_A 0x60 + +#define PORT_8253_0 0x40 +#define PORT_8253_1 0x41 +#define PORT_8253_2 0x42 +#define PORT_8253_MODE 0x43 + +#define EOI 0x20 + +/* Access byte's flags */ +#define ACS_PRESENT 0x80 /* present segment */ +#define ACS_CSEG 0x18 /* code segment */ +#define ACS_DSEG 0x10 /* data segment */ +#define ACS_CONFORM 0x04 /* conforming segment */ +#define ACS_READ 0x02 /* readable segment */ +#define ACS_WRITE 0x02 /* writable segment */ +#define ACS_IDT ACS_DSEG /* segment type is the same type */ +#define ACS_INT_GATE 0x0E /* int gate for 386 */ +#define ACS_TSS_GATE 0x09 +#define ACS_DPL_0 0x00 /* descriptor privilege level #0 */ +#define ACS_DPL_1 0x20 /* descriptor privilege level #1 */ +#define ACS_DPL_2 0x40 /* descriptor privilege level #2 */ +#define ACS_DPL_3 0x60 /* descriptor privilege level #3 */ +#define ACS_LDT 0x02 /* ldt descriptor */ +#define ACS_TASK_GATE 0x05 + +/* Ready-made values */ +#define ACS_INT (ACS_PRESENT | ACS_INT_GATE) /* present int gate */ +#define ACS_TSS (ACS_PRESENT | ACS_TSS_GATE) /* present tss gate */ +#define ACS_TASK (ACS_PRESENT | ACS_TASK_GATE) /* present task gate */ +#define ACS_CODE (ACS_PRESENT | ACS_CSEG | ACS_READ) +#define ACS_DATA (ACS_PRESENT | ACS_DSEG | ACS_WRITE) +#define ACS_STACK (ACS_PRESENT | ACS_DSEG | ACS_WRITE) + +/* Attributes (in terms of size) */ +#define ATTR_GRANULARITY 0x80 /* segment limit is given in 4KB pages rather than in bytes */ +#define ATTR_BIG 0x40 /* ESP is used rather than SP */ +#define ATTR_DEFAULT 0x40 /* 32-bit code segment rather than 16-bit */ + +/* Paging */ +#define PAGE_BITS 12 +#define PAGE_SIZE (1 << PAGE_BITS) + +#define PRIV_PRES 0x001 // present +#define PRIV_RD 0x000 // read-only +#define PRIV_WR 0x002 // writable +#define PRIV_KERN 0x000 // ring 0 +#define PRIV_USER 0x004 // ring 3 +#define PRIV_ALL 0x007 + +#define PAGE_NUM(X) ((X) & -PAGE_SIZE) +#define PAGE_TABENT(X) (((X) >> 12) & 0x3FF) +#define PAGE_DIRENT(X) (((X) >> 22) & 0x3FF) + +#define EFLAG_TF 0x100 +#define EFLAG_IF 0x200 +#define EFLAG_IOPL0 0x0000 +#define EFLAG_IOPL1 0x1000 +#define EFLAG_IOPL2 0x2000 +#define EFLAG_IOPL3 0x3000 +#define EFLAG_VM 0x20000 + +#pragma pack (push, 1) /* align structures to a byte boundary */ + +/* Segment desciptor definition */ +struct descriptor_t +{ + word limit, + base_l; + byte base_m, + access, + attribs, + base_h; +}; + +typedef struct descriptor_t descriptor_t; + +struct dtr_t +{ + word limit; + dword base; +}; + +typedef struct dtr_t gdtr_t; /* GDTR register definition */ +typedef struct dtr_t idtr_t; /* IDTR register definition */ + +/* Interrupt desciptor definition */ +struct descriptor_int_t +{ + word offset_l, + selector; + + byte param_cnt, access; + word offset_h; +}; + +typedef struct descriptor_int_t descriptor_int_t; + +typedef struct pusha_t pusha_t; +struct pusha_t +{ + dword edi, esi, ebp, esp, ebx, edx, ecx, eax; +}; + +/* TSS definition */ +struct tss_t /* TSS for 386+ */ +{ + dword link, + esp0, + ss0, + esp1, + ss1, + esp2, + ss2, + cr3, + eip, + eflags, + eax, + ecx, + edx, + ebx, + esp, + ebp, + esi, + edi, + es, + cs, + ss, + ds, + fs, + gs, + ldtr; + word trace, + io_map_addr; + byte io_map[8192]; +}; + +typedef struct tss_t tss_t; + +struct tss0_t /* TSS for 386+ (no I/O bit map) */ +{ + dword link, + esp0, + ss0, + esp1, + ss1, + esp2, + ss2, + cr3, + eip, + eflags, + eax, + ecx, + edx, + ebx, + esp, + ebp, + esi, + edi; + word es, u1, + cs, u2, + ss, u3, + ds, u4, + fs, u5, + gs, u6, + ldts, u7; + word trace, + io_map_addr; +}; + +#pragma pack (pop) /* align structures to default boundary */ + +void i386_set_descriptor(descriptor_t *item, dword base, dword limit, + byte access, byte attribs); +void i386_set_descriptor_int(descriptor_int_t *item, word selector, + dword offset, byte access, byte param_cnt); + +void outs16(unsigned short Adr, unsigned short *Data, unsigned Count); + +extern dword cpuid_ecx, cpuid_edx, cpu_max_level; +dword keIdentifyCpu(); + +#ifdef _MSC_VER + +#pragma warning(disable:4035) + +/* + * Visual C++ shouldn't really be used for building the kernel, so, since all + * the following inline assembler functions are fairly priviliged, they + * aren't defined for Visual C++. + * + * xxx - bugger - I have to write these now... + */ + +#ifndef __cplusplus +#define inline +#endif + +#if 0 + +static inline void enable() { __asm sti } +static void inline disable() { __asm cli } +inline static void invalidate_page(void* page) { __asm invlpg page } + +static inline void i386_lpoke16(addr_t off, word value) +{ + __asm + { + mov ax, value + mov word ptr gs:[off], ax + } +} + +static inline word i386_lpeek16(addr_t off) +{ + __asm movzx eax, word ptr gs:[off] +} + +static inline void i386_lpoke32(addr_t off, dword value) +{ + __asm + { + mov eax, value + mov dword ptr gs:[off], eax + } +} + +static inline word i386_lpeek32(addr_t off) +{ + __asm mov eax, dword ptr gs:[off] +} + +static inline addr_t i386_lmemset32(addr_t off, dword c, size_t len) +{ + __asm + { + mov ecx, len + shr ecx, 2 + mov eax, c + mov edi, off + cld + rep stosd + } + return off; +} + +static inline addr_t i386_lmemset16(addr_t off, word c, size_t len) +{ + __asm + { + mov ecx, len + shr ecx, 1 + movzx eax, c + mov edi, off + cld + rep stosw + } + return off; +} + +static inline void out(word port, byte value) +{ + __asm + { + mov dx, port + mov al, value + out dx, al + } +} + +static inline void out16(word port, word value) +{ + __asm + { + mov dx, port + mov ax, value + out dx, ax + } +} + +static inline byte in(word port) +{ + __asm + { + xor eax, eax + mov dx, port + in al, dx + } +} + +static inline word in16(word port) +{ + __asm + { + xor eax, eax + mov dx, port + in ax, dx + } +} + +static inline void halt(dword code) +{ + __asm + { + mov eax, code + cli + hlt + } +} + +#endif + +#else + +#define inline __inline__ + +static inline void enable() { asm ("sti"); } +static inline void disable() { asm ("cli"); } +static inline void invalidate_page(void* page) { asm ("invlpg (%0)": :"r" (page)); } + +static inline void i386_lpoke8(addr_t off, byte value) +{ + asm("movb %0,%%gs:(%1)" : : "r" (value), "r" (off)); +} + +static inline word i386_lpeek8(addr_t off) +{ + byte value; + asm("movb %%gs:(%1),%0" : "=a" (value): "r" (off)); + return value; +} + +static inline void i386_lpoke16(addr_t off, word value) +{ + asm("movw %0,%%gs:(%1)" : : "r" (value), "r" (off)); +} + +static inline word i386_lpeek16(addr_t off) +{ + word value; + asm("movw %%gs:(%1),%0" : "=a" (value): "r" (off)); + return value; +} + +static inline void i386_lpoke32(addr_t off, dword value) +{ + asm("movl %0,%%gs:(%1)" : : "r" (value), "r" (off)); +} + +static inline word i386_lpeek32(addr_t off) +{ + dword value; + asm("movl %%gs:(%1),%0" : "=a" (value): "r" (off)); + return value; +} + +static inline addr_t i386_lmemset32(addr_t off, dword c, size_t len) +{ + /*asm("mov %0,%%ecx ; " + "mov %1,%%eax ; " + "mov %2,%%edi ; " + "cld ; " + "rep stosl": : "r" (len / 4), "r" (c), "r" (off): "eax", "ecx", "edi");*/ + __asm__("cld ; " + "rep stosl": : "c" (len / 4), "a" (c), "D" (off): "eax", "ecx", "edi"); + return off; +} + +static inline addr_t i386_lmemset16(addr_t off, word c, size_t len) +{ + /*asm("mov %0,%%ecx ; " + "movw %1,%%ax ; " + "mov %2,%%edi ; " + "cld ; " + "rep stosw": : "r" (len / 2), "r" (c), "r" (off): "eax", "ecx", "edi");*/ + __asm__("cld ; " + "rep stosw": : "c" (len / 2), "a" (c), "D" (off): "ax", "ecx", "edi"); + return off; +} + +static inline addr_t i386_lmemset(addr_t off, char c, int count) +{ + __asm__("cld\n\t" + "rep\n\t" + "stosb" + ::"a" (c),"D" (off),"c" (count) + :"cx","di"); + return off; +} + +addr_t i386_llmemcpy(addr_t dest, addr_t src, size_t size); + +#define out(port, value) \ + asm("outb %%al, %%dx" : : "d" (port), "a" (value) : "eax", "edx") + +static inline void out16(word port, word value) +{ + asm("outw %%ax, %%dx" : : "d" (port), "a" (value)); +} + +static inline void out32(word port, dword value) +{ + asm("outl %%eax, %%dx" : : "d" (port), "a" (value)); +} + +static inline byte in(word port) +{ + byte ret; + asm("inb %%dx,%%al" : "=a" (ret) : "d" (port)); + return ret; +} + +static inline word in16(word port) +{ + word ret; + asm("inw %%dx,%%ax" : "=a" (ret) : "d" (port)); + return ret; +} + +static inline dword in32(word port) +{ + dword ret; + asm("inl %%dx,%%eax" : "=a" (ret) : "d" (port)); + return ret; +} + +static inline void halt(dword code) +{ + asm("cli ; hlt" : : "a" (code)); +} + +static inline dword critb(void) +{ + dword flags; + asm("pushfl\n" + "pop %0\n" + "cli" : "=a" (flags)); + return flags; +} + +static inline void crite(dword flags) +{ + asm("push %0\n" + "popfl" : : "g" (flags)); +} + +#endif + +#endif diff --git a/mobius/include/kernel/kernel.h b/mobius/include/kernel/kernel.h new file mode 100644 index 0000000..174cebf --- /dev/null +++ b/mobius/include/kernel/kernel.h @@ -0,0 +1,110 @@ +#ifndef __KERNEL_H +#define __KERNEL_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifndef DLLIMPORT +#define DLLIMPORT +#endif + +#include +//#include +#include + +/*! + * \defgroup kernel Kernel + * @{ + */ + +typedef struct sysinfo_t sysinfo_t; + +//! Global system information block +struct sysinfo_t +{ + addr_t kernel_phys, ramdisk_phys; + size_t kernel_size, ramdisk_size; + addr_t memory_top; + size_t kernel_data; +}; + +typedef struct irq_t irq_t; + +//! Describes information about an IRQ handler +struct irq_t +{ + irq_t *prev, *next; + struct device_t* dev; +}; + +extern sysinfo_t DLLIMPORT _sysinfo; +extern irq_t DLLIMPORT *irq_first[16], *irq_last[16]; +volatile extern dword DLLIMPORT uptime; + +struct thread_t; +void exception(struct thread_t* thr, context_t* ctx, dword code, dword address); +int _cputws(const wchar_t* str); + +#define CHECK_L2 L"\t\04 " +void _cputws_check(const wchar_t* str); +int wprintf(const wchar_t* fmt, ...); +void syscall(context_t* ctx); +bool dbgInvoke(struct thread_t* thr, struct context_t* ctx, addr_t address); + +enum PrintfMode { modeBlue, modeConsole }; +void conSetMode(enum PrintfMode mode); + +struct textwin_t; +extern struct textwin_t spew, checks, *wprintf_window; + +//! Asserts that the specified condition is true. +/*! + * If the condition is false, the macro calls the assert_fail() function to + * alert the programmer. + * \param x The condition to test + */ +#define assert(x) if (!(x)) assert_fail(__FILE__, __LINE__, L#x); +#define CONCAT_(a, b) a##b +#define CONCAT(a, b) CONCAT_(a, b) +#define CASSERT(exp) static int CONCAT(v, __LINE__)[(exp) ? 1 : -1] = { 0 } +#define offsetof(t, f) ((addr_t) &((t*) NULL)->f) + +void assert_fail(const char* file, int line, const wchar_t* exp); + +#ifndef _MSC_VER +//#define IN_SECTION(s) __attribute__((section (s))) +#define IN_SECTION(s) +#define INIT_CODE IN_SECTION(".init") +#define INIT_DATA IN_SECTION(".init") +#endif + +typedef struct semaphore_t semaphore_t; +struct semaphore_t +{ + struct thread_t* owner; + int locks; + const char *file; + int line; +}; + +static inline void semInit(semaphore_t* sem) +{ + sem->owner = NULL; + sem->locks = 0; +} + +void semAcquire(semaphore_t* sem); +void semRelease(semaphore_t* sem); +bool semTryAcquire(semaphore_t* sem); + +#define SEMAPHORE(name) semaphore_t name = { NULL, 0, __FILE__, __LINE__ } + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/memory.h b/mobius/include/kernel/memory.h new file mode 100644 index 0000000..544097c --- /dev/null +++ b/mobius/include/kernel/memory.h @@ -0,0 +1,75 @@ +#ifndef __MEMORY_H +#define __MEMORY_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct page_pool_t page_pool_t; +struct page_pool_t +{ + //! Stack of addresses, describing each page in the pool + addr_t* pages; + //! The number of pages in memory, i.e. memory_top / PAGE_SIZE + unsigned num_pages; + //! The number of free pages in the stack + unsigned free_pages; +}; + +extern DLLIMPORT page_pool_t pool_all, pool_low; + +// pool_low contains all the pages below 1MB +#define NUM_LOW_PAGES (0x100000 >> PAGE_BITS) + +bool memInit(); +addr_t memAlloc(); +void memFree(addr_t block); +addr_t memAllocLow(); +void memFreeLow(addr_t block); +addr_t memAllocLowSpan(size_t pages); +bool memMap(dword *PageDir, dword Virt, dword Phys, dword pages, byte Privilege); +dword memTranslate(const dword* pPageDir, const void* pAddress); + +#if 0 + +#undef INTERFACE +#define INTERFACE IPager + +//! Implements a method to allow memory to be automatically paged in. +/*! + * \implement If you are writing code which causes data to be loaded by + * being paged in, as opposed to manual loading. Examples include sections + * from executable files, thread stack pages, and the ramdisk. + * \use This interface is only used from within the kernel's page fault + * handler. + */ +DECLARE_INTERFACE(IPager) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void ** ppvObject) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + //! Called by the page fault handler when a memory page was not found, + //! allowing the handler to load the page and make it available. + /*! + * \param virt The virtual address which caused the page fault. Note that + * this is not necessarily on a page boundary. + * \return S_OK if the address is now available, and program execution + * should continue; a failure code if this object does not handle this + * page, or if the page could not be made available. + */ + STDMETHOD(ValidatePage)(THIS_ const void* virt) PURE; +}; + +// {816B7D51-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IPager, +0x816b7d51, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/obj.h b/mobius/include/kernel/obj.h new file mode 100644 index 0000000..e9567c6 --- /dev/null +++ b/mobius/include/kernel/obj.h @@ -0,0 +1,37 @@ +#ifndef __KERNEL_OBJ_H +#define __KERNEL_OBJ_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +struct process_t; + +/*! + * \defgroup obj Object Services + * \ingroup kernel + * @{ + */ + +struct marshal_entry_t +{ + void* ptr; +}; + +//! Defines a marshalling handle, able to refer to any marshalled object in a +//! specific process. +typedef dword marshal_t; +typedef struct marshal_entry_t marshal_map_t; + +marshal_t objMarshal(struct process_t* proc, void* ptr); +void* objUnmarshal(struct process_t* proc, marshal_t mshl); +void objNotifyDelete(struct process_t* proc, marshal_t mshl); + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/port.h b/mobius/include/kernel/port.h new file mode 100644 index 0000000..aa334d5 --- /dev/null +++ b/mobius/include/kernel/port.h @@ -0,0 +1,55 @@ +#ifndef __KERNEL_PORT_H +#define __KERNEL_PORT_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include +#include + +#define PORT_CONNECTED 1 +#define PORT_PENDING_CONNECT 2 +#define PORT_LISTENING 4 + +typedef struct port_t port_t; +struct port_t +{ + file_t file; + port_t *prev, *next; + wchar_t* name; + process_t* owner; + + dword state; + + union + { + struct + { + port_t* remote; + size_t buffer_length; + byte buffer[128]; + } client; + + struct + { + semaphore_t connect; + port_t *connect_first, *connect_last; + int num_clients; + } server; + } u; +}; + +port_t* portCreate(process_t* owner, const wchar_t* name); +void portDelete(port_t* port); +bool portListen(port_t* port); +bool portConnect(port_t* port, const wchar_t* remote); +port_t* portAccept(port_t* server); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/proc.h b/mobius/include/kernel/proc.h new file mode 100644 index 0000000..8bf810e --- /dev/null +++ b/mobius/include/kernel/proc.h @@ -0,0 +1,77 @@ +#ifndef __KERNEL_PROC_H +#define __KERNEL_PROC_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +//#include +#include + +/*! + * \defgroup proc Process Services + * \ingroup kernel + * @{ + */ + +struct vm_area_t; + +typedef struct process_t process_t; +struct process_info_t; +struct module_info_t; +struct file_t; + +typedef struct module_t module_t; +struct module_t +{ + module_t *prev, *next; + wchar_t *name; + addr_t base; + size_t length; + addr_t entry; + //void *raw_data; + struct file_t *file; + size_t sizeof_headers; + bool imported; +}; + +struct process_t +{ + dword* page_dir; + module_t *mod_first, *mod_last; + addr_t stack_end, vmm_end; + byte level; + struct vm_area_t *first_vm_area, *last_vm_area; + struct process_info_t* info; + struct module_info_t* module_last; + marshal_map_t* marshal_map; + marshal_t last_marshal; + unsigned id; + + semaphore_t sem_vmm; +}; + +process_t* procLoad(byte level, const wchar_t* file, const wchar_t* cmdline, + unsigned priority, struct file_t* input, struct file_t* output); +void procDelete(process_t* proc); +void procTerminate(process_t* proc); +process_t* procCurrent(); +bool procPageFault(process_t* proc, addr_t virt); + +module_t* peLoad(process_t* proc, const wchar_t* file, dword base); +module_t* peLoadMemory(process_t* proc, const wchar_t* file, + struct file_t *fd, dword base); +bool pePageFault(process_t* proc, module_t* mod, addr_t addr); +addr_t peGetExport(module_t* mod, const char* name); +void peUnload(process_t* proc, module_t* mod); + +#include + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/proc.old.h b/mobius/include/kernel/proc.old.h new file mode 100644 index 0000000..91e448d --- /dev/null +++ b/mobius/include/kernel/proc.old.h @@ -0,0 +1,134 @@ +#ifndef __KERNEL_PROC_H +#define __KERNEL_PROC_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +/*! + * \defgroup proc Process Services + * \ingroup kernel + * @{ + */ + +struct IModule; +struct IPager; +struct vm_area_t; + +typedef struct process_t process_t; +struct process_info_t; +struct module_info_t; + +struct process_t +{ + dword* page_dir; + struct IModule *modules[10]; + struct IPager* stack_pager; + addr_t stack_end, vmm_end; + byte level; + int num_modules; + struct vm_area_t *first_vm_area, *last_vm_area; + struct process_info_t* info; + struct module_info_t* module_last; + marshal_map_t* marshal_map; + marshal_t last_marshal; + unsigned id; +}; + +process_t* procLoad(byte level, const wchar_t* file, const wchar_t* cmdline); +void procDelete(process_t* proc); +void procTerminate(process_t* proc); +process_t* procCurrent(); + +#undef INTERFACE +#define INTERFACE IModule + +//! Implements an executable module in the kernel. +/*! + * Modules, such as executables (EXEs) and dynamic libraries (DLLs) are + * treated transparently by the kernel by handling them as IModule + * interfaces (IPager is also used, to allow modules to load themselves + * on demand). + * + * Modules are loaded using the modLoadXXX() functions, which, given the name + * of a file, are expected to return an IModule interface to a module + * object if successful. This will then be used later by the kernel to + * import and export functions and, in the case of executables, to run + * processes. + * + * Currently only the PE (Portable Executable) format is supported. + * Theoretically any module format could be supported; to be used as a + * dynamically-linked library format, a module must be capable of + * exporting named functions. + * + * \implement If you are adding a new module format to the kernel. + * \use If you are accessing module attributes (such as exported function + * or module base addresses) from the kernel. + */ +DECLARE_INTERFACE(IModule) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void ** ppvObject) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + //! Retrieves the main entry point for the module. + /*! + * For executables this is the address where execution of the main thread + * will begin. + * + * For DLLs this is the address of the DLLMain function, which will be + * called when the module is loaded. + * \return The entry point of the module in the process's address space. + */ + STDMETHOD_(const void*, GetEntryPoint)(THIS) PURE; + + //! Retrieves the base address of the module. + /*! + * This may be different to the base originally specified if the module + * has been relocated. + * \return The base address of the module in the process's address space. + */ + STDMETHOD_(const void*, GetBase)(THIS) PURE; + + //! Retrieves the address of a named function exported by a module. + /*! + * In order to support dynamic linking, modules may support the ability to + * name functions that are accessible by other modules. This function + * allows the kernel to import functions by name. + * \param proc The name of the function, in 8-bit character format + * \return The address of the function, or NULL if the function was not + * found. + */ + STDMETHOD_(const void*, GetProcAddress)(THIS_ const char* proc) PURE; + + //! Retrieves the name of the module. + /*! + * The module name is used to identify the module within a particular + * process. + * \param name Points to a buffer which will receive the module's name + * \param max Specifies the size of the buffer, in characters + * \return S_OK if successful, or a failure code. + */ + STDMETHOD(GetName)(THIS_ wchar_t* name, size_t max) PURE; +}; + +IModule* modLoadPe(process_t* proc, const wchar_t* file, dword base); +IModule* modLoadPeMemory(process_t* proc, const wchar_t* file, const void* ptr, dword base); + +// {816B7D52-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IModule, +0x816b7d52, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +#include + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/ramdisk.h b/mobius/include/kernel/ramdisk.h new file mode 100644 index 0000000..7fe5b51 --- /dev/null +++ b/mobius/include/kernel/ramdisk.h @@ -0,0 +1,49 @@ +#ifndef __RAMDISK_H +#define __RAMDISK_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*#define RAMDISK_SIGNATURE_1 \ + ((unsigned long) 'R' | \ + ((unsigned long) 'D' << 8) | \ + ((unsigned long) 'S' << 16) | \ + ((unsigned long) 'K' << 24)) +#define RAMDISK_SIGNATURE_2 \ + ((unsigned long) 'K' | + ((unsigned long) 'S' << 8) | + ((unsigned long) 'D' << 16) | + ((unsigned long) 'R' << 24))*/ + +#define RAMDISK_SIGNATURE_1 0x5244534BUL /* RDSK */ +#define RAMDISK_SIGNATURE_2 0x5244534BUL /* KSDR */ + +typedef struct ramdisk_t ramdisk_t; +struct ramdisk_t +{ + dword signature; + dword num_files; +}; + +typedef struct ramfile_t ramfile_t; +struct ramfile_t +{ + dword offset; + dword length; + char name[16]; +}; + +#ifdef KERNEL +bool ramInit(); +void* ramOpen(const wchar_t* name); +size_t ramFileLength(const wchar_t* name); +bool ramPageFault(addr_t virt); +#endif + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/serial.h b/mobius/include/kernel/serial.h new file mode 100644 index 0000000..59e0112 --- /dev/null +++ b/mobius/include/kernel/serial.h @@ -0,0 +1,74 @@ +/* +** LL_COMM (R) Asynchronous Communication Routines +** Copyright (C) 1994 by James P. Ketrenos +** +** VERSION : 1.2 +** DATE : 7-4-94 +** CODED BY : James P. Ketrenos [ketrenoj@cs.pdx.edu] +** aka : Lord Logics (for those who care) +** +** Special thanks to all of the contributors to the Serial.FAQ +** +* +* NOTE: As of this release, these routines only allow for ONE port to be +* opened at a time. Hopefully, if all goes well, the next version will +* allow for up to 32 different ports to be opened. I have set up these +* routines to be compatible with the future format, so using the next +* version shouldn't require much, if any, change to working code. +* +* Also, you probably have noticed that the assembly listings for this code +* have not been included. If you are interested in the assembly code, +* please read the file LL_COMM.NFO, as it explains why it is not here, and +* where/how you can acquire it. +* +** +*/ + +#ifndef _LL_COMM_H_ +#define _LL_COMM_H_ +#ifdef __cplusplus +#define CEXT extern "C" +#else +#define CEXT extern +#endif + +#include + +typedef int COMM; +typedef char *PACKET; + +/* Initialization Routines ****/ +CEXT COMM ioOpenPort(int Base, int IRQ); +CEXT int ioClosePort(COMM Port); + +/* Buffer Routines ****/ +CEXT void ioClearWrite(COMM); +CEXT void ioClearRead(COMM); +CEXT int ioReadStatus(COMM); +CEXT int ioWriteStatus(COMM); + +/* I/O Routines ****/ +CEXT char ioReadByte(COMM); +CEXT int ioWriteByte(COMM, char); +CEXT int ioWriteBuffer(COMM address, const void* buf, size_t len); +CEXT int ioReadPacket(COMM, PACKET); +CEXT int ioWritePacket(COMM, PACKET); + +/* Mode Routines ****/ +CEXT int ioGetMode(COMM); +CEXT int ioSetMode(COMM, int); + +/* Port Setup Routines ****/ +CEXT int ioGetBaud(COMM); +CEXT void ioSetBaud(COMM, int); +CEXT int ioGetHandShake(COMM); +CEXT void ioSetHandShake(COMM, int); +CEXT int ioGetStatus(COMM); +CEXT int ioGetControl(COMM); +CEXT void ioSetControl(COMM, int); +CEXT int ioGetFIFO(COMM); +CEXT int ioSetFIFO(COMM, int); + +#include + +#endif diff --git a/mobius/include/kernel/sys.h b/mobius/include/kernel/sys.h new file mode 100644 index 0000000..8bc0dcd --- /dev/null +++ b/mobius/include/kernel/sys.h @@ -0,0 +1,29 @@ +#ifndef __KERNEL_SYS_H +#define __KERNEL_SYS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +struct context_t; + +void* sysOpen(const wchar_t* filespec); +void sysMount(const wchar_t* path, void* ptr); +dword sysInvoke(void* ptr, dword method, dword* params, size_t sizeof_params); +dword sysUpTime(); +void sysYield(); +bool sysV86Fault(struct context_t* ctx); +void sysInit(); + +#define SHUTDOWN_POWEROFF 0 +#define SHUTDOWN_REBOOT 1 +bool keShutdown(dword flags); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/thread.h b/mobius/include/kernel/thread.h new file mode 100644 index 0000000..a409b92 --- /dev/null +++ b/mobius/include/kernel/thread.h @@ -0,0 +1,83 @@ +#ifndef __THREAD_H +#define __THREAD_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +#define THREAD_RUNNING 0 +#define THREAD_DELETED 1 +#define THREAD_WAIT_TIMEOUT 2 +#define THREAD_WAIT_HANDLE 3 +#define THREAD_WAIT_OBJECT 4 + +struct context_t; +typedef bool (CDECL *V86HANDLER)(struct context_t*); + +typedef struct thread_t thread_t; +struct thread_t +{ + struct process_t *process; + dword kernel_esp; // must be thread_t+4 + dword id; + + thread_t *prev, *next, *prev_queue, *next_queue; + unsigned priority; + + dword *kernel_stack, *user_stack; + dword suspend; + byte state; + union + { + dword time; + + struct + { + void** handles; + unsigned num_handles; + bool wait_all; + } handle; + } wait; + + thread_info_t* info; + V86HANDLER v86handler; +}; + +typedef struct thread_queue_t thread_queue_t; +struct thread_queue_t +{ + thread_t *first, *last, *current; +}; + +//CASSERT(offsetof(thread_t, process) == 0); +//CASSERT(offsetof(thread_t, kernel_esp) == 4); + +thread_t* thrCreate(int level, process_t* proc, const void* entry_point, + unsigned priority); +thread_t* thrCreate86(process_t* proc, const byte* code, size_t code_size, + V86HANDLER handler, unsigned priority); +void thrDelete(thread_t* thr); +void thrSchedule(); +context_t* thrContext(thread_t* thr); +void thrSleep(thread_t* thr, dword ms); +bool thrWaitFinished(void** hnd, unsigned num_handles, bool wait_all); +void thrWaitHandle(thread_t* thr, void** hnd, unsigned num_handles, + bool wait_all); +void thrCall(thread_t* thr, void* addr, void* params, + size_t sizeof_params); +thread_t* thrCurrent(); +bool thrDequeue(thread_t* thr, thread_queue_t* queue); +void thrEnqueue(thread_t* thr, thread_queue_t* queue); +void thrRun(thread_t* thr); +void thrSuspend(thread_t* thr, bool suspend); + +extern thread_t DLLIMPORT *thr_first, *thr_last, *current; + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/vmm.h b/mobius/include/kernel/vmm.h new file mode 100644 index 0000000..5826ecb --- /dev/null +++ b/mobius/include/kernel/vmm.h @@ -0,0 +1,72 @@ +#ifndef __KERNEL_VMM_H +#define __KERNEL_VMM_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +typedef struct vm_area_t vm_area_t; + +#define VM_AREA_NORMAL 0 +#define VM_AREA_MAP 1 +#define VM_AREA_SHARED 2 +#define VM_AREA_FILE 3 + +//! Describes an area of memory allocated within the address space of a +//! particular process. +struct vm_area_t +{ + //! Points to the previous vm_area_t in the owning process + vm_area_t *prev; + //! Points to the next vm_area_t in the owning process + vm_area_t *next; + process_t *owner; + + //! Indicates the start of the area in the owning process's address space + void* start; + //! Specifies the number of pages spanned by the area + size_t pages; + //! Specifies the MEM_xxx flags associated with the area + dword flags; + //bool is_committed; + + //! Specifies the type of the memory area + unsigned type; + + union + { + addr_t phys_map; + vm_area_t* shared_from; + file_t *file; + } dest; +}; + +/* vmmAlloc flags are in os/os.h */ + +/* create a vm_area_t */ +void* vmmMap(process_t* proc, size_t pages, addr_t virt, void *dest, + unsigned type, dword flags); + +/* create a normal vm area */ +void* vmmAlloc(process_t* proc, size_t pages, addr_t start, dword flags); +/* create a shared vm area */ +void* vmmShare(vm_area_t* area, process_t* proc, addr_t start, dword flags); +/* create a mapped file vm area */ +void* vmmMapFile(process_t *proc, addr_t start, size_t pages, file_t *file, + dword flags); + +void vmmFree(vm_area_t* area); +bool vmmCommit(vm_area_t* area, addr_t start, size_t pages); +void vmmUncommit(vm_area_t* area); +void vmmInvalidate(vm_area_t* area, addr_t start, size_t pages); +vm_area_t* vmmArea(process_t* proc, const void* ptr); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/kernel/wrappers.h b/mobius/include/kernel/wrappers.h new file mode 100644 index 0000000..a7fa8bd --- /dev/null +++ b/mobius/include/kernel/wrappers.h @@ -0,0 +1,109 @@ +#ifndef __WRAPPERS_H +#define __WRAPPERS_H + +extern void interrupt_0(); +extern void interrupt_1(); +extern void interrupt_2(); +extern void interrupt_3(); +extern void interrupt_4(); +extern void interrupt_5(); +extern void interrupt_6(); +extern void interrupt_7(); +extern void exception_8(); +extern void interrupt_9(); +extern void exception_a(); +extern void exception_b(); +extern void exception_c(); +extern void exception_d(); +extern void exception_e(); +extern void interrupt_f(); +extern void interrupt_10(); +extern void interrupt_11(); +extern void interrupt_12(); +extern void interrupt_13(); +extern void interrupt_14(); +extern void interrupt_15(); +extern void interrupt_16(); +extern void interrupt_17(); +extern void interrupt_18(); +extern void interrupt_19(); +extern void interrupt_1a(); +extern void interrupt_1b(); +extern void interrupt_1c(); +extern void interrupt_1d(); +extern void interrupt_1e(); +extern void interrupt_1f(); +extern void irq_0(); +extern void irq_1(); +extern void irq_2(); +extern void irq_3(); +extern void irq_4(); +extern void irq_5(); +extern void irq_6(); +extern void irq_7(); +extern void irq_8(); +extern void irq_9(); +extern void irq_a(); +extern void irq_b(); +extern void irq_c(); +extern void irq_d(); +extern void irq_e(); +extern void irq_f(); +//extern void syscall_wrapper(); +extern void interrupt_30(); + +static void (*_wrappers[49]) () = +{ + interrupt_0, + interrupt_1, + interrupt_2, + interrupt_3, + interrupt_4, + interrupt_5, + interrupt_6, + interrupt_7, + exception_8, + interrupt_9, + exception_a, + exception_b, + exception_c, + exception_d, + exception_e, + interrupt_f, + interrupt_10, + interrupt_11, + interrupt_12, + interrupt_13, + interrupt_14, + interrupt_15, + interrupt_16, + interrupt_17, + interrupt_18, + interrupt_19, + interrupt_1a, + interrupt_1b, + interrupt_1c, + interrupt_1d, + interrupt_1e, + interrupt_1f, + irq_0, + irq_1, + irq_2, + irq_3, + irq_4, + irq_5, + irq_6, + irq_7, + irq_8, + irq_9, + irq_a, + irq_b, + irq_c, + irq_d, + irq_e, + irq_f, + //syscall_wrapper + interrupt_30 +}; + +#endif \ No newline at end of file diff --git a/mobius/include/limits.h b/mobius/include/limits.h new file mode 100644 index 0000000..91c2d7a --- /dev/null +++ b/mobius/include/limits.h @@ -0,0 +1,134 @@ +#ifndef _LIMITS_H___ +#ifndef _MACH_MACHLIMITS_H_ + +/* _MACH_MACHLIMITS_H_ is used on OSF/1. */ +#define _LIMITS_H___ +#define _MACH_MACHLIMITS_H_ + +/* Number of bits in a `char'. */ +#undef CHAR_BIT +#define CHAR_BIT 8 + +/* Maximum length of a multibyte character. */ +#ifndef MB_LEN_MAX +#define MB_LEN_MAX 1 +#endif + +/* Minimum and maximum values a `signed char' can hold. */ +#undef SCHAR_MIN +#define SCHAR_MIN (-128) +#undef SCHAR_MAX +#define SCHAR_MAX 127 + +/* Maximum value an `unsigned char' can hold. (Minimum is 0). */ +#undef UCHAR_MAX +#define UCHAR_MAX 255 + +/* Minimum and maximum values a `char' can hold. */ +#ifdef __CHAR_UNSIGNED__ +#undef CHAR_MIN +#define CHAR_MIN 0 +#undef CHAR_MAX +#define CHAR_MAX 255 +#else +#undef CHAR_MIN +#define CHAR_MIN (-128) +#undef CHAR_MAX +#define CHAR_MAX 127 +#endif + +/* Minimum and maximum values a `signed short int' can hold. */ +#undef SHRT_MIN +#define SHRT_MIN (-32768) +#undef SHRT_MAX +#define SHRT_MAX 32767 + +/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ +#undef USHRT_MAX +#define USHRT_MAX 65535 + +/* Minimum and maximum values a `signed int' can hold. */ +#ifndef __INT_MAX__ +#define __INT_MAX__ 2147483647 +#endif +#undef INT_MIN +#define INT_MIN (-INT_MAX-1) +#undef INT_MAX +#define INT_MAX __INT_MAX__ + +/* Maximum value an `unsigned int' can hold. (Minimum is 0). */ +#undef UINT_MAX +#define UINT_MAX (INT_MAX * 2U + 1) + +/* Minimum and maximum values a `signed long int' can hold. + (Same as `int'). */ +#ifndef __LONG_MAX__ +#ifndef __alpha__ +#define __LONG_MAX__ 2147483647L +#else +#define __LONG_MAX__ 9223372036854775807L +# endif /* __alpha__ */ +#endif +#undef LONG_MIN +#define LONG_MIN (-LONG_MAX-1) +#undef LONG_MAX +#define LONG_MAX __LONG_MAX__ + +/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ +#undef ULONG_MAX +#define ULONG_MAX (LONG_MAX * 2UL + 1) + +#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__) +/* Minimum and maximum values a `signed long long int' can hold. */ +#ifndef __LONG_LONG_MAX__ +#define __LONG_LONG_MAX__ 9223372036854775807LL +#endif +#undef LONG_LONG_MIN +#define LONG_LONG_MIN (-LONG_LONG_MAX-1) +#undef LONG_LONG_MAX +#define LONG_LONG_MAX __LONG_LONG_MAX__ + +/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ +#undef ULONG_LONG_MAX +#define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1) +#endif + +/* Maximum number of iovcnt in a writev */ +#undef IOV_MAX +#define IOV_MAX (__INT_MAX__-1) + +/* Maximum size of ssize_t */ +#undef SSIZE_MAX +#define SSIZE_MAX (__LONG_MAX__) + +/* Maximum length of a path */ +#define PATH_MAX (260 - 1 /*NUL*/) + +/* Max num groups for a user, only current GID available under Windows */ +/* Must match NGROUPS */ +#define NGROUPS_MAX 1 + +/* WaitForMultipleObjects can't handle waiting for more than 64 objects. + This limits how many children we can fork/spawn off. */ +#define CHILD_MAX 63 + +/* POSIX values */ +/* These should never vary from one system type to another */ +/* They represent the minimum values that POSIX systems must support. + POSIX-conforming apps must not require larger values. */ +#define _POSIX_ARG_MAX 4096 +#define _POSIX_CHILD_MAX 6 +#define _POSIX_LINK_MAX 8 +#define _POSIX_MAX_CANON 255 +#define _POSIX_MAX_INPUT 255 +#define _POSIX_NAME_MAX 14 +#define _POSIX_NGROUPS_MAX 0 +#define _POSIX_OPEN_MAX 16 +#define _POSIX_PATH_MAX 255 +#define _POSIX_PIPE_BUF 512 +#define _POSIX_SSIZE_MAX 32767 +#define _POSIX_STREAM_MAX 8 +#define _POSIX_TZNAME_MAX 3 + +#endif /* _MACH_MACHLIMITS_H_ */ +#endif /* _LIMITS_H___ */ diff --git a/mobius/include/malloc.h b/mobius/include/malloc.h new file mode 100644 index 0000000..2534c62 --- /dev/null +++ b/mobius/include/malloc.h @@ -0,0 +1,117 @@ +/* Author: Mark Moraes */ +/* $Id: malloc.h,v 1.2 2001/08/10 21:06:51 pavlovskii Exp $ */ +#ifndef __XMALLOC_H__ +#define __XMALLOC_H__ + +#include + +#if defined(ANSI_TYPES) || defined(__STDC__) +#define univptr_t void * +#else /* ! ANSI_TYPES */ +#define univptr_t char * +#define size_t unsigned int +#endif /* ANSI_TYPES */ + +#if defined(ANSI_TYPES) && !defined(__STDC__) +#define size_t unsigned long +#endif + +#if defined(__STDC__) +#define __proto(x) x +#else +#define __proto(x) () +#endif + +/* + * defined so users of new features of this malloc can #ifdef + * invocations of those features. + */ +#define CSRIMALLOC + +#ifdef MALLOC_TRACE +/* Tracing malloc definitions - helps find leaks */ + +extern univptr_t __malloc __proto((size_t, const char *, int)); +extern univptr_t __calloc __proto((size_t, size_t, const char *, int)); +extern univptr_t __realloc __proto((univptr_t, size_t, const char *, int)); +extern univptr_t __valloc __proto((size_t, const char *, int)); +extern univptr_t __memalign __proto((size_t, size_t, const char *, int)); +extern univptr_t __emalloc __proto((size_t, const char *, int)); +extern univptr_t __ecalloc __proto((size_t, size_t, const char *, int)); +extern univptr_t __erealloc __proto((univptr_t, size_t, const char *, int)); +extern char *__strdup __proto((const char *, const char *, int)); +extern char *__strsave __proto((const char *, const char *, int)); +extern void __free __proto((univptr_t, const char *, int)); +extern void __cfree __proto((univptr_t, const char *, int)); + +#define malloc(x) __malloc((x), __FILE__, __LINE__) +#define calloc(x, n) __calloc((x), (n), __FILE__, __LINE__) +#define realloc(p, x) __realloc((p), (x), __FILE__, __LINE__) +#define memalign(x, n) __memalign((x), (n), __FILE__, __LINE__) +#define valloc(x) __valloc((x), __FILE__, __LINE__) +#define emalloc(x) __emalloc((x), __FILE__, __LINE__) +#define ecalloc(x, n) __ecalloc((x), (n), __FILE__, __LINE__) +#define erealloc(p, x) __erealloc((p), (x), __FILE__, __LINE__) +#define strdup(p) __strdup((p), __FILE__, __LINE__) +#define strsave(p) __strsave((p), __FILE__, __LINE__) +/* cfree and free are identical */ +#define cfree(p) __free((p), __FILE__, __LINE__) +#define free(p) __free((p), __FILE__, __LINE__) + +#else /* MALLOC_TRACE */ + +extern univptr_t malloc __proto((size_t)); +extern univptr_t calloc __proto((size_t, size_t)); +extern univptr_t realloc __proto((univptr_t, size_t)); +extern univptr_t valloc __proto((size_t)); +extern univptr_t memalign __proto((size_t, size_t)); +extern univptr_t emalloc __proto((size_t)); +extern univptr_t ecalloc __proto((size_t, size_t)); +extern univptr_t erealloc __proto((univptr_t, size_t)); +extern char *strdup __proto((const char *)); +extern char *strsave __proto((const char *)); +extern void free __proto((univptr_t)); +extern void cfree __proto((univptr_t)); + +#endif /* MALLOC_TRACE */ + +#if 0 +extern void mal_debug __proto((int)); +extern void mal_dumpleaktrace __proto((FILE *)); +extern void mal_heapdump __proto((FILE *)); +extern void mal_leaktrace __proto((int)); +extern void mal_sbrkset __proto((int)); +extern void mal_slopset __proto((int)); +extern void mal_statsdump __proto(()); +extern void mal_setstatsfile __proto((FILE *)); +extern void mal_trace __proto((int)); +extern int mal_verify __proto((int)); +extern void mal_mmap __proto((char *)); +#endif + +/* + * You may or may not want this - In gcc version 1.30, on Sun3s running + * SunOS3.5, this works fine. + */ +#ifdef __GNUC__ +#define alloca(n) __builtin_alloca(n) +#endif /* __GNUC__ */ +#ifdef sparc +#define alloca(n) __builtin_alloca(n) +#endif /* sparc */ + +#ifdef ANSI_TYPES +#undef univptr_t +#else /* ! ANSI_TYPES */ +#undef univptr_t +#undef size_t +#endif /* ANSI_TYPES */ + +/* Just in case you want an ANSI malloc without an ANSI compiler */ +#if defined(ANSI_TYPES) && !defined(__STDC__) +#undef size_t +#endif + +#undef __proto + +#endif /* __XMALLOC_H__ */ /* Do not add anything after this line */ diff --git a/mobius/include/math.h b/mobius/include/math.h new file mode 100644 index 0000000..e3860cd --- /dev/null +++ b/mobius/include/math.h @@ -0,0 +1,4 @@ +#ifndef __MATH_H +#define __MATH_H + +#endif \ No newline at end of file diff --git a/mobius/include/netinet/in.h b/mobius/include/netinet/in.h new file mode 100644 index 0000000..c1e287f --- /dev/null +++ b/mobius/include/netinet/in.h @@ -0,0 +1,6 @@ +#ifndef __IN_H +#define __IN_H + +#define ntohl(l) (l) + +#endif \ No newline at end of file diff --git a/mobius/include/os/blkdev.h b/mobius/include/os/blkdev.h new file mode 100644 index 0000000..ac72f4a --- /dev/null +++ b/mobius/include/os/blkdev.h @@ -0,0 +1,13 @@ +#ifndef __OS_BLKDEV_H +#define __OS_BLKDEV_H + +#include + +typedef struct block_size_t block_size_t; +struct block_size_t +{ + size_t block_size; + size_t total_blocks; +}; + +#endif \ No newline at end of file diff --git a/mobius/include/os/coff.h b/mobius/include/os/coff.h new file mode 100644 index 0000000..32c8cf5 --- /dev/null +++ b/mobius/include/os/coff.h @@ -0,0 +1,339 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_coff_h_ +#define __dj_include_coff_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/*** coff information for Intel 386/486. */ + +/********************** FILE HEADER **********************/ + +struct external_filehdr { + unsigned short f_magic; /* magic number */ + unsigned short f_nscns; /* number of sections */ + unsigned long f_timdat; /* time & date stamp */ + unsigned long f_symptr; /* file pointer to symtab */ + unsigned long f_nsyms; /* number of symtab entries */ + unsigned short f_opthdr; /* sizeof(optional hdr) */ + unsigned short f_flags; /* flags */ +}; + + +/* Bits for f_flags: + * F_RELFLG relocation info stripped from file + * F_EXEC file is executable (no unresolved external references) + * F_LNNO line numbers stripped from file + * F_LSYMS local symbols stripped from file + * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) + */ + +#define F_RELFLG (0x0001) +#define F_EXEC (0x0002) +#define F_LNNO (0x0004) +#define F_LSYMS (0x0008) + + + +#define I386MAGIC 0x14c +#define I386AIXMAGIC 0x175 +#define I386BADMAG(x) (((x).f_magic!=I386MAGIC) && (x).f_magic!=I386AIXMAGIC) + + +#define FILHDR struct external_filehdr +#define FILHSZ sizeof(FILHDR) + + +/********************** AOUT "OPTIONAL HEADER" **********************/ + + +typedef struct +{ + unsigned short magic; /* type of file */ + unsigned short vstamp; /* version stamp */ + unsigned long tsize; /* text size in bytes, padded to FW bdry*/ + unsigned long dsize; /* initialized data " " */ + unsigned long bsize; /* uninitialized data " " */ + unsigned long entry; /* entry pt. */ + unsigned long text_start; /* base of text used for this file */ + unsigned long data_start; /* base of data used for this file */ +} +AOUTHDR; + + +typedef struct gnu_aout { + unsigned long info; + unsigned long tsize; + unsigned long dsize; + unsigned long bsize; + unsigned long symsize; + unsigned long entry; + unsigned long txrel; + unsigned long dtrel; + } GNU_AOUT; + +#define AOUTSZ (sizeof(AOUTHDR)) + +#define OMAGIC 0404 /* object files, eg as output */ +#define ZMAGIC 0413 /* demand load format, eg normal ld output */ +#define STMAGIC 0401 /* target shlib */ +#define SHMAGIC 0443 /* host shlib */ + + +/********************** SECTION HEADER **********************/ + + +struct external_scnhdr { + char s_name[8]; /* section name */ + unsigned long s_paddr; /* physical address, aliased s_nlib */ + unsigned long s_vaddr; /* virtual address */ + unsigned long s_size; /* section size */ + unsigned long s_scnptr; /* file ptr to raw data for section */ + unsigned long s_relptr; /* file ptr to relocation */ + unsigned long s_lnnoptr; /* file ptr to line numbers */ + unsigned short s_nreloc; /* number of relocation entries */ + unsigned short s_nlnno; /* number of line number entries*/ + unsigned long s_flags; /* flags */ +}; + +#define SCNHDR struct external_scnhdr +#define SCNHSZ sizeof(SCNHDR) + +/* + * names of "special" sections + */ +#define _TEXT ".text" +#define _DATA ".data" +#define _BSS ".bss" +#define _COMMENT ".comment" +#define _LIB ".lib" + +/* + * s_flags "type" + */ +#define STYP_TEXT (0x0020) /* section contains text only */ +#define STYP_DATA (0x0040) /* section contains data only */ +#define STYP_BSS (0x0080) /* section contains bss only */ + +/********************** LINE NUMBERS **********************/ + +/* 1 line number entry for every "breakpointable" source line in a section. + * Line numbers are grouped on a per function basis; first entry in a function + * grouping will have l_lnno = 0 and in place of physical address will be the + * symbol table index of the function name. + */ +struct external_lineno { + union { + unsigned long l_symndx __attribute__((packed)); /* function name symbol index, iff l_lnno == 0 */ + unsigned long l_paddr __attribute__((packed)); /* (physical) address of line number */ + } l_addr; + unsigned short l_lnno; /* line number */ +}; + + +#define LINENO struct external_lineno +#define LINESZ sizeof(LINENO) + + +/********************** SYMBOLS **********************/ + +#define E_SYMNMLEN 8 /* # characters in a symbol name */ +#define E_FILNMLEN 14 /* # characters in a file name */ +#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ + +struct external_syment +{ + union { + char e_name[E_SYMNMLEN]; + struct { + unsigned long e_zeroes __attribute__((packed)); + unsigned long e_offset __attribute__((packed)); + } e; + } e; + unsigned long e_value __attribute__((packed)); + short e_scnum; + unsigned short e_type; + unsigned char e_sclass; + unsigned char e_numaux; +}; + +#define N_BTMASK (0xf) +#define N_TMASK (0x30) +#define N_BTSHFT (4) +#define N_TSHIFT (2) + +union external_auxent { + struct { + unsigned long x_tagndx __attribute__((packed)); /* str, un, or enum tag indx */ + union { + struct { + unsigned short x_lnno; /* declaration line number */ + unsigned short x_size; /* str/union/array size */ + } x_lnsz; + unsigned long x_fsize __attribute__((packed)); /* size of function */ + } x_misc; + union { + struct { /* if ISFCN, tag, or .bb */ + unsigned long x_lnnoptr __attribute__((packed)); /* ptr to fcn line # */ + unsigned long x_endndx __attribute__((packed)); /* entry ndx past block end */ + } x_fcn; + struct { /* if ISARY, up to 4 dimen. */ + unsigned short x_dimen[E_DIMNUM]; + } x_ary; + } x_fcnary; + unsigned short x_tvndx; /* tv index */ + } x_sym; + + union { + char x_fname[E_FILNMLEN]; + struct { + unsigned long x_zeroes __attribute__((packed)); + unsigned long x_offset __attribute__((packed)); + } x_n; + } x_file; + + struct { + unsigned long x_scnlen __attribute__((packed)); /* section length */ + unsigned short x_nreloc; /* # relocation entries */ + unsigned short x_nlinno; /* # line numbers */ + } x_scn; + + struct { + unsigned long x_tvfill __attribute__((packed)); /* tv fill value */ + unsigned short x_tvlen; /* length of .tv */ + unsigned short x_tvran[2]; /* tv range */ + } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ + + +}; + +#define SYMENT struct external_syment +#define SYMESZ sizeof(SYMENT) +#define AUXENT union external_auxent +#define AUXESZ sizeof(AUXENT) + + +# define _ETEXT "etext" + + +/* Relocatable symbols have number of the section in which they are defined, + or one of the following: */ + +#define N_UNDEF ((short)0) /* undefined symbol */ +#define N_ABS ((short)-1) /* value of symbol is absolute */ +#define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */ +#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */ +#define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/ + +/* + * Type of a symbol, in low N bits of the word + */ +#define T_NULL 0 +#define T_VOID 1 /* function argument (only used by compiler) */ +#define T_CHAR 2 /* character */ +#define T_SHORT 3 /* short integer */ +#define T_INT 4 /* integer */ +#define T_LONG 5 /* long integer */ +#define T_FLOAT 6 /* floating point */ +#define T_DOUBLE 7 /* double word */ +#define T_STRUCT 8 /* structure */ +#define T_UNION 9 /* union */ +#define T_ENUM 10 /* enumeration */ +#define T_MOE 11 /* member of enumeration*/ +#define T_UCHAR 12 /* unsigned character */ +#define T_USHORT 13 /* unsigned short */ +#define T_UINT 14 /* unsigned integer */ +#define T_ULONG 15 /* unsigned long */ +#define T_LNGDBL 16 /* long double */ + +/* + * derived types, in n_type +*/ +#define DT_NON (0) /* no derived type */ +#define DT_PTR (1) /* pointer */ +#define DT_FCN (2) /* function */ +#define DT_ARY (3) /* array */ + +#define BTYPE(x) ((x) & N_BTMASK) + +#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) +#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) +#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) +#define ISTAG(x) ((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG) +#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) + +/********************** STORAGE CLASSES **********************/ + +/* This used to be defined as -1, but now n_sclass is unsigned. */ +#define C_EFCN 0xff /* physical end of function */ +#define C_NULL 0 +#define C_AUTO 1 /* automatic variable */ +#define C_EXT 2 /* external symbol */ +#define C_STAT 3 /* static */ +#define C_REG 4 /* register variable */ +#define C_EXTDEF 5 /* external definition */ +#define C_LABEL 6 /* label */ +#define C_ULABEL 7 /* undefined label */ +#define C_MOS 8 /* member of structure */ +#define C_ARG 9 /* function argument */ +#define C_STRTAG 10 /* structure tag */ +#define C_MOU 11 /* member of union */ +#define C_UNTAG 12 /* union tag */ +#define C_TPDEF 13 /* type definition */ +#define C_USTATIC 14 /* undefined static */ +#define C_ENTAG 15 /* enumeration tag */ +#define C_MOE 16 /* member of enumeration */ +#define C_REGPARM 17 /* register parameter */ +#define C_FIELD 18 /* bit field */ +#define C_AUTOARG 19 /* auto argument */ +#define C_LASTENT 20 /* dummy entry (end of block) */ +#define C_BLOCK 100 /* ".bb" or ".eb" */ +#define C_FCN 101 /* ".bf" or ".ef" */ +#define C_EOS 102 /* end of structure */ +#define C_FILE 103 /* file name */ +#define C_LINE 104 /* line # reformatted as symbol table entry */ +#define C_ALIAS 105 /* duplicate tag */ +#define C_HIDDEN 106 /* ext symbol in dmert public lib */ + +/********************** RELOCATION DIRECTIVES **********************/ + + + +struct external_reloc { + unsigned long r_vaddr __attribute__((packed)); + unsigned long r_symndx __attribute__((packed)); + unsigned short r_type; +}; + + +#define RELOC struct external_reloc +#define RELSZ sizeof(RELOC) + +#define RELOC_REL32 20 /* 32-bit PC-relative address */ +#define RELOC_ADDR32 6 /* 32-bit absolute address */ + +#define DEFAULT_DATA_SECTION_ALIGNMENT 4 +#define DEFAULT_BSS_SECTION_ALIGNMENT 4 +#define DEFAULT_TEXT_SECTION_ALIGNMENT 4 +/* For new sections we havn't heard of before */ +#define DEFAULT_SECTION_ALIGNMENT 4 + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_coff_h_ */ diff --git a/mobius/include/os/com.h b/mobius/include/os/com.h new file mode 100644 index 0000000..94fd06f --- /dev/null +++ b/mobius/include/os/com.h @@ -0,0 +1,218 @@ +#ifndef __COM_H +#define __COM_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +#ifndef callconv_defined +#ifdef _MSC_VER +#define STDCALL __stdcall +#define CDECL __cdecl +#else +#define STDCALL __attribute__((stdcall)) +#define CDECL __attribute__((cdecl)) +#endif +#define callconv_defined +#endif + +typedef unsigned long ULONG; + +#define S_OK 0 +#define S_FALSE 1 +#define E_FAIL 0x80000000 + +#define SUCCEEDED(hr) (((hr) & 0x80000000) == 0) +#define FAILED(hr) (((hr) & 0x80000000) == 0x80000000) + +#ifndef GUID_DEFINED +#define GUID_DEFINED + +typedef struct GUID GUID, IID, CLSID; +struct GUID +{ + dword Data1; + word Data2; + word Data3; + byte Data4[8]; +}; + +#endif + +#ifdef __cplusplus +typedef const IID& REFIID; +#else +typedef const IID* REFIID; +#endif + +#ifdef __cplusplus + +#define DECLARE_INTERFACE(name) struct name +#define STDMETHOD(name) virtual HRESULT STDCALL name +#define STDMETHOD_(type, name) virtual type STDCALL name +#define PURE = 0 +#define THIS +#define THIS_ +#define EXTERN_C extern "C" + +#define InlineIsEqualGUID(rguid1, rguid2) \ + (((long*) &rguid1)[0] == ((long*) &rguid2)[0] && \ + ((long*) &rguid1)[1] == ((long*) &rguid2)[1] && \ + ((long*) &rguid1)[2] == ((long*) &rguid2)[2] && \ + ((long*) &rguid1)[3] == ((long*) &rguid2)[3]) + +/* end C++ declaration */ +#else + +#define DECLARE_INTERFACE(name) \ + typedef struct name name; \ + struct name { const struct name##Vtbl* vtbl; }; \ + struct name##Vtbl \ + +#define STDMETHOD(name) HRESULT (STDCALL *name) +#define STDMETHOD_(type, name) type (STDCALL *name) +#define PURE +#define THIS_ INTERFACE* this, +#define THIS INTERFACE* this +#define EXTERN_C + +#define InlineIsEqualGUID(rguid1, rguid2) \ + (((long*) rguid1)[0] == ((long*) rguid2)[0] && \ + ((long*) rguid1)[1] == ((long*) rguid2)[1] && \ + ((long*) rguid1)[2] == ((long*) rguid2)[2] && \ + ((long*) rguid1)[3] == ((long*) rguid2)[3]) + +/* end C declarations */ +#endif + +#ifdef INITGUID +#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + EXTERN_C const GUID name \ + = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } +#else +#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + EXTERN_C extern const GUID name +#endif + +#define INTERFACE IUnknown + +//! Implements standard behaviours for a COM object. +/*! + * All COM interfaces inherit from IUnknown: they share the three IUnknown + * methods as the first three entries in their virtual method table. + * Therefore every interface can increment/decrement the object's + * reference count (AddRef()/Release()), and it is possible to access + * any interface from any other interface (QueryInterface()). + * \implement Whenever you are writing an object which implements a COM + * interface. + * \use Whenever you use a COM interface. + */ +DECLARE_INTERFACE(IUnknown) +{ + //! Queries the object for a pointer to the specified interface. + /*! + * As part of the COM standard, every interface to an object should be + * able to access every other interface. Therefore the + * QueryInterface() function is present in every interface supported + * by the object. + * + * The new interface should be independent of the old one, and must be + * Release()'d once it it no longer needed. + * + * \param iid Specifies the interface to be accessed + * \param ppvObject Points to a variable which will receive a pointer + * to the new interface. + * \return S_OK if the interface was found correctly, or a failure code. + */ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void ** ppvObject) PURE; + + //! Increments the reference count of the object. + /*! + * Every COM object maintains an internal reference count to allow + * for automatic memory management. This reference count should be + * incremented when a copy of an interface is made, and + * decremented when that interface is no longer needed. When the + * reference count reaches zero the object itself destroys itself. + * \return Returns the new reference count on the object. This may not be + * accurate and should only be used for debugging purposes. + */ + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + + //! Decrements the reference count of the object. + /*! + * The interface should be treated as no longer valid once Release() has + * been called on it, since the object may have been destroyed. + * \return Returns the new reference count on the object. This may not be + * accurate and should only be used for debugging purposes. + */ + STDMETHOD_(ULONG, Release)(THIS) PURE; +}; + +DEFINE_GUID(IID_IUnknown, 0, 0, 0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); + +HRESULT IUnknown_QueryInterface(void* ptr, REFIID iid, void** obj); +ULONG IUnknown_AddRef(void* ptr); +ULONG IUnknown_Release(void* ptr); + +#ifdef __cplusplus + +#if 0 + +extern "C" int wprintf(const wchar_t*, ...); + +#define IMPLEMENT_IUNKNOWN(cls) \ +public: \ + dword m_refs; \ +\ + STDMETHOD_(ULONG, AddRef)() \ + { \ + wprintf(L"[" L#cls L"::AddRef %d] ", m_refs); \ + return ++m_refs; \ + } \ +\ + STDMETHOD_(ULONG, Release)() \ + { \ + wprintf(L"[" L#cls L"::Release %u] ", m_refs - 1); \ + if (m_refs == 0) \ + { \ + wprintf(L"[delete " L#cls L"] "); \ + delete this; \ + return 0; \ + } \ + else \ + return m_refs--; \ + } + +#else +#define IMPLEMENT_IUNKNOWN(cls) \ +public: \ + dword m_refs; \ +\ + STDMETHOD_(ULONG, AddRef)() \ + { \ + return ++m_refs; \ + } \ +\ + STDMETHOD_(ULONG, Release)() \ + { \ + if (m_refs == 0) \ + { \ + delete this; \ + return 0; \ + } \ + else \ + return m_refs--; \ + } + +#endif + +#endif + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/os/console.h b/mobius/include/os/console.h new file mode 100644 index 0000000..25eefec --- /dev/null +++ b/mobius/include/os/console.h @@ -0,0 +1,46 @@ +#ifndef __OS_CONSOLE_H +#define __OS_CONSOLE_H + +#include + +/*! + * \defgroup kernelu_console Console I/O + * \ingroup kernelu + * @{ + */ + +//! Name of the server port created by the console server +#define CONSOLE_PORT L"console" + +//! Write a string to the console +#define CON_WRITE REQUEST_CODE(1, 0, 'c', 'w') +//! Close the console +#define CON_CLOSE REQUEST_CODE(1, 0, 'c', 'c') + +typedef struct console_request_t console_request_t; +struct console_request_t +{ + dword code; + + union + { + struct + { + size_t length; + } write; + } params; +}; + +typedef struct console_reply_t console_reply_t; +struct console_reply_t +{ + dword code; +}; + +bool conWrite(const wchar_t* str); +dword conGetKey(bool wait); +bool conKeyPressed(); + +//@} + +#endif \ No newline at end of file diff --git a/mobius/include/os/device.h b/mobius/include/os/device.h new file mode 100644 index 0000000..a77eeb3 --- /dev/null +++ b/mobius/include/os/device.h @@ -0,0 +1,169 @@ +#ifndef __OS_DEVICE_H +#define __OS_DEVICE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +/*! + * \ingroup kernelu + * \defgroup dev Device Manager + * @{ + */ + +#include + +typedef struct request_t request_t; +typedef struct request_header_t request_header_t; + +struct request_header_t +{ + //! Specifies the request code (one of DEV_xxx) + dword code; // in + //! Indicates the result of the request + status_t result; // out + //! Triggered when the request has completed + addr_t event; // out when calling devRequest; + // in wrt driver + + //! Points to the next request in a driver's request list + request_t* next; + + /* Internal members */ + size_t user_length; // original user length + request_t *kernel_request; // in user mode, points to the copy made in kernel space + size_t original_request_size; // in kernel mode, the size of the original request + int queued; // is this request queued? +}; + +union request_params_t +{ + //! General parameters for a buffered request + struct + { + //! The buffer used + addr_t buffer; + //! Size of the buffer in bytes + size_t length; + //! The position where the buffered operation is to start + /*! Ignored for character stream devices. */ + qword pos; + } buffered; + + //! Parameters for a DEV_OPEN request + struct + { + //! Specifies the parameters passed to devOpen() + const wchar_t* params; + } open; + + //! Parameters for a DEV_READ request + struct + { + //! Specifies the buffer into which data are read + void* buffer; // out + //! Specifies the number of bytes to read, and indicates the number + //! of bytes actually read + size_t length; // in/out + //! Specifies the offset where reading is to start + /*! Ignored for character stream devices. */ + qword pos; // in + } read; + + //! Parameters for a DEV_WRITE request + struct + { + //! Specifies the buffer from which data are written + const void* buffer; // in + //! Specifies the number of bytes to write, and indicates the number + //! of bytes actually written + size_t length; // in/out + //! Specifies the offset where writing is to start + /*! Ignored for character stream devices. */ + qword pos; // in + } write; + + //! Parameters for a DEV_IOCTL request + struct + { + //! Specifies a buffer containing ioctl parameters and data + void* buffer; // in/out + //! Specifies the size of the buffer + size_t length; // in/out + //! Specifies the IOCTL function to perform + dword code; // in + } ioctl; + + //! Parameters for a DEV_ISR request + struct + { + //! Specifies the IRQ which was triggered + byte irq; // in + } isr; + + //! Parameters for an FS_OPENFILE request + struct + { + const wchar_t* name; // in + size_t name_length; // in + addr_t fd; // out + } fs_open; + + struct + { + const wchar_t* name; // in + size_t name_length; // in + addr_t dev; // in + } fs_mount; + + struct + { + addr_t buffer; // out + size_t length; // in/out + addr_t fd; // in + } fs_read, fs_write; + + struct + { + addr_t fd; // in + } fs_close; + + //! Parameters for a FS_IOCTL request + struct + { + //! Specifies a buffer containing ioctl parameters and data + void* buffer; // in/out + //! Specifies the size of the buffer + size_t length; // in/out + //! Specifies the IOCTL function to perform + dword code; // in + addr_t fd; + } fs_ioctl; +}; + +//! Contains information on a request issued to a device driver +struct request_t +{ + request_header_t header; + union request_params_t params; +}; + +addr_t devOpen(const wchar_t* name, const wchar_t* params); +bool devClose(addr_t dev); +status_t devUserRequest(addr_t dev, request_t* req, size_t size); +status_t devUserFinishRequest(request_t* req, bool delete_event); +size_t devReadSync(addr_t dev, qword pos, void* buffer, size_t length); +size_t devWriteSync(addr_t dev, qword pos, void* buffer, size_t length); +status_t devUserRequestSync(addr_t dev, request_t* req, size_t size); +status_t devIoCtl(addr_t fd, dword code, void* params, size_t length); + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/os/devreq.h b/mobius/include/os/devreq.h new file mode 100644 index 0000000..69f4a8b --- /dev/null +++ b/mobius/include/os/devreq.h @@ -0,0 +1,48 @@ +#ifndef __OS_DEVREQ_H +#define __OS_DEVREQ_H + +//! Creates a device code made up of subsystem (sys) and major (maj) and +//! minor (min) codes +#define REQUEST_CODE(buff, sys, maj, min) \ + ((buff) << 31 | \ + ((sys) << 16) | \ + ((maj) << 8) | (min)) + +//! Issued when a device is being opened by the Device Manager +#define DEV_OPEN REQUEST_CODE(0, 0, 'd', 'o') +//! Issued when a device is being closed by the Device Manager +#define DEV_CLOSE REQUEST_CODE(0, 0, 'd', 'c') +//! Issued when a device is being removed from the Device Manager +#define DEV_REMOVE REQUEST_CODE(0, 0, 'd', 'R') +//! Reads from a device +#define DEV_READ REQUEST_CODE(1, 0, 'd', 'r') +//! Writes to a device +#define DEV_WRITE REQUEST_CODE(1, 0, 'd', 'w') +//! Performs general device state manipulation functions +#define DEV_IOCTL REQUEST_CODE(1, 0, 'd', 'i') +//! Issued when a device's IRQ is triggered +#define DEV_ISR REQUEST_CODE(0, 0, 'd', 'q') + +//! Opens a file on a file system device +#define FS_OPEN REQUEST_CODE(1, 0, 'f', 'o') +//! Creates a file on a file system device +#define FS_CREATE REQUEST_CODE(1, 0, 'f', 'C') +//! Closes a file +#define FS_CLOSE REQUEST_CODE(0, 0, 'f', 'c') +//! Mount a file or device in a directory +#define FS_MOUNT REQUEST_CODE(1, 0, 'f', 'm') +//! Reads from a file +#define FS_READ REQUEST_CODE(1, 0, 'f', 'r') +//! Writes to a file +#define FS_WRITE REQUEST_CODE(1, 0, 'f', 'w') +//! Performs general file state manipulation functions +#define FS_IOCTL REQUEST_CODE(1, 0, 'f', 'i') +//! Calculate the length of a file +#define FS_GETLENGTH REQUEST_CODE(0, 0, 'f', 'l') + +//! Retrieves size statistics for a block device +#define BLK_GETSIZE REQUEST_CODE(1, 0, 'b', 's') + +#define CHR_GETSIZE REQUEST_CODE(1, 0, 'c', 's') + +#endif \ No newline at end of file diff --git a/mobius/include/os/filesys.h b/mobius/include/os/filesys.h new file mode 100644 index 0000000..a5db9a3 --- /dev/null +++ b/mobius/include/os/filesys.h @@ -0,0 +1,40 @@ +#ifndef __FILESYS_H +#define __FILESYS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +#undef INTERFACE +#define INTERFACE IFolder +DECLARE_INTERFACE(IFolder) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void ** ppvObject) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + STDMETHOD(FindFirst)(THIS_ const wchar_t* spec, folderitem_t* buf) PURE; + STDMETHOD(FindNext)(THIS_ folderitem_t* buf) PURE; + STDMETHOD(FindClose)(THIS_ folderitem_t* pBuf) PURE; + STDMETHOD(Open)(THIS_ folderitem_t* item, const wchar_t* params) PURE; + STDMETHOD(Mount)(THIS_ const wchar_t* name, IUnknown* obj) PURE; +}; + +HRESULT IFolder_FindFirst(IFolder* ptr, const wchar_t* spec, folderitem_t* buf); +HRESULT IFolder_FindNext(IFolder* ptr, folderitem_t* buf); +HRESULT IFolder_FindClose(IFolder* ptr, folderitem_t* pBuf); +HRESULT IFolder_Open(IFolder* ptr, folderitem_t* item, const wchar_t* params); +HRESULT IFolder_Mount(IFolder* ptr, const wchar_t* name, IUnknown* obj); + +// {816B7D56-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IFolder, +0x816b7d56, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/os/fs.h b/mobius/include/os/fs.h new file mode 100644 index 0000000..93f37da --- /dev/null +++ b/mobius/include/os/fs.h @@ -0,0 +1,49 @@ +#ifndef __OS_FS_H +#define __OS_FS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +/*! + * \ingroup kernelu + * \defgroup fs File System + * @{ + */ + +#define ATTR_READ_ONLY 0x01 +#define ATTR_HIDDEN 0x02 +#define ATTR_SYSTEM 0x04 +#define ATTR_VOLUME_ID 0x08 +#define ATTR_DIRECTORY 0x10 +#define ATTR_ARCHIVE 0x20 +#define ATTR_DEVICE 0x1000 +#define ATTR_LINK 0x2000 + +#ifndef KERNEL + +struct request_t; + +bool fsFullPath(const wchar_t* src, wchar_t* dst); +bool fsRequest(addr_t fd, struct request_t* req, size_t size); +addr_t fsOpen(const wchar_t* path); +bool fsClose(addr_t fd); +bool fsRead(addr_t fd, void* buffer, size_t* length); +bool fsWrite(addr_t fd, const void* buffer, size_t* length); +bool fsIoCtl(addr_t fd, dword code, void* params, size_t length); +bool fsSeek(addr_t fd, qword pos); +qword fsGetPosition(addr_t fd); +qword fsGetLength(addr_t fd); + +#endif + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/os/guids.h b/mobius/include/os/guids.h new file mode 100644 index 0000000..ad8cfe6 --- /dev/null +++ b/mobius/include/os/guids.h @@ -0,0 +1,63 @@ +#ifndef __OS_GUIDS_H +#define __OS_GUIDS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +// {816B7D51-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IPager, +0x816b7d51, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +// {816B7D52-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IModule, +0x816b7d52, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +// {816B7D53-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IDevice, +0x816b7d53, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +// {816B7D54-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IStream, +0x816b7d54, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +// {816B7D55-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IBlockDevice, +0x816b7d55, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +// {816B7D56-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IFolder, +0x816b7d56, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +// {816B7D57-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IWindowServer, +0x816b7d57, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +// {816B7D58-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IWindow, +0x816b7d58, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +// {816B7D59-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IFont, +0x816b7d59, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +// {816B7D5a-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_ISurface, +0x816b7d5a, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +// {816B7D5b-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IMsgQueue, +0x816b7d5b, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +// {816B7D5c-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IVideoDriver, +0x816b7d5c, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/os/keyboard.h b/mobius/include/os/keyboard.h new file mode 100644 index 0000000..4888d4b --- /dev/null +++ b/mobius/include/os/keyboard.h @@ -0,0 +1,48 @@ +#ifndef __OS_KEYBOARD_H +#define __OS_KEYBOARD_H + +/* "bucky bits" +0x0100000 is reserved for non-ASCII keys, so start with 0x200000 */ +#define KBD_BUCKY_ALT 0x0200000 /* Alt is pressed */ +#define KBD_BUCKY_CTRL 0x0400000 /* Ctrl is pressed */ +#define KBD_BUCKY_SHIFT 0x0800000 /* Shift is pressed */ +#define KBD_BUCKY_CAPS 0x1000000 /* CapsLock is on */ +#define KBD_BUCKY_NUM 0x2000000 /* NumLock is on */ +#define KBD_BUCKY_SCRL 0x4000000 /* ScrollLock is on */ +#define KBD_BUCKY_ALTGR 0x8000000 /* AltGr is pressed */ +#define KBD_BUCKY_ANY (KBD_BUCKY_ALT | KBD_BUCKY_CTRL | KBD_BUCKY_SHIFT | KBD_BUCKY_ALTGR) + +/* "ASCII" values for non-ASCII keys. All of these are user-defined. +function keys: */ +#define KEY_F1 0x10000 +#define KEY_F2 (KEY_F1 + 1) +#define KEY_F3 (KEY_F2 + 1) +#define KEY_F4 (KEY_F3 + 1) +#define KEY_F5 (KEY_F4 + 1) +#define KEY_F6 (KEY_F5 + 1) +#define KEY_F7 (KEY_F6 + 1) +#define KEY_F8 (KEY_F7 + 1) +#define KEY_F9 (KEY_F8 + 1) +#define KEY_F10 (KEY_F9 + 1) +#define KEY_F11 (KEY_F10 + 1) +#define KEY_F12 (KEY_F11 + 1) /* 0x10B */ +/* cursor keys */ +#define KEY_INS (KEY_F12 + 1) /* 0x10C */ +#define KEY_DEL (KEY_INS + 1) +#define KEY_HOME (KEY_DEL + 1) +#define KEY_END (KEY_HOME + 1) +#define KEY_PGUP (KEY_END + 1) +#define KEY_PGDN (KEY_PGUP + 1) +#define KEY_LEFT (KEY_PGDN + 1) +#define KEY_UP (KEY_LEFT + 1) +#define KEY_DOWN (KEY_UP + 1) +#define KEY_RIGHT (KEY_DOWN + 1) /* 0x115 */ +/* print screen/sys rq and pause/break */ +#define KEY_PRTSC (KEY_RIGHT + 1) /* 0x116 */ +#define KEY_PAUSE (KEY_PRTSC + 1) /* 0x117 */ +/* these return a value but they could also act as additional bucky keys */ +#define KEY_LWIN (KEY_PAUSE + 1) /* 0x118 */ +#define KEY_RWIN (KEY_LWIN + 1) +#define KEY_MENU (KEY_RWIN + 1) /* 0x11A */ + +#endif \ No newline at end of file diff --git a/mobius/include/os/mouse.h b/mobius/include/os/mouse.h new file mode 100644 index 0000000..68c9315 --- /dev/null +++ b/mobius/include/os/mouse.h @@ -0,0 +1,17 @@ +#ifndef __OS_MOUSE_H +#define __OS_MOUSE_H + +typedef struct mouse_packet_t mouse_packet_t; +struct mouse_packet_t +{ + int dx; + int dy; + dword buttons; + int dwheel; +}; + +#define MOUSE_BUTTON_RIGHT 1 +#define MOUSE_BUTTON_MIDDLE 2 +#define MOUSE_BUTTON_LEFT 4 + +#endif \ No newline at end of file diff --git a/mobius/include/os/os.h b/mobius/include/os/os.h new file mode 100644 index 0000000..5bd5369 --- /dev/null +++ b/mobius/include/os/os.h @@ -0,0 +1,417 @@ +#ifndef __OS_H +#define __OS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +/*! + * \ingroup kernelu + * @{ + */ + +typedef struct module_info_t module_info_t; + +//! Specifies user-mode information on a specific module. +/*! + * This structure is part of the module itself (it has its own section -- + * .info). The crt0 code (crt0.c) is responsible for declaring this + * variable. When the module loader loads a section with the name ".info" + * it assumes that it comprises a structure of this format, and fills it + * in accordingly. + * + * This structure is available through the _info variable in each module. + */ +struct module_info_t +{ + //! Specifies the version number of the module loader that loaded this + //! module. + dword loader_version; + //! Points to the module loaded immediately after this one, or NULL if this + //! was the last module to be loaded. + module_info_t* next; + //! Specifies the base address of the module. + /*! + * The base address is the address where the module's headers start. + */ + dword base, + //! Specifies the overall length of the module, in bytes. + /*! + * Includes headers, all sections and alignment padding. + */ + length; + //! Specifies the name of the module. + wchar_t name[40]; +}; + +extern module_info_t _info; + +#include + +#pragma pack(push,1) + +//! The layout of the stack frame generated by the assembly-language interrupt +//! handler. +/*! + * The isr_and_switch routine (in start.asm), along with the individual + * interrupt handlers and the processor, build this structure on the stack + * before isr() is called. + */ +struct context_t +{ + /* + //! The user-mode registers pushed by pusha. + pusha_t regs; + //! The user-mode selectors pushed by isr_and_switch. + dword ds, es, fs, gs; + //! The interrupt or IRQ number pushed by the interrupt handler. + dword intr, + //! The error code pushed by the processor. + error; + //! The current context pushed by the processor. + dword eip, cs, eflags, esp, ss; + */ + + dword kernel_esp; + pusha_t regs; + dword gs, fs, es, ds; + dword intr, error; + dword eip, cs, eflags, esp, ss; +}; +typedef struct context_t context_t; +#pragma pack(pop) + +typedef enum _ExceptionDisposition { + ExceptionContinueExecution, + ExceptionContinueSearch, + ExceptionNestedException, + ExceptionCollidedUnwind +} ExceptionDisposition; + +typedef struct exception_info_t exception_info_t; +struct exception_info_t +{ + dword code; + addr_t address; + addr_t eip; +}; + +typedef ExceptionDisposition (*except_handler)( + exception_info_t *ExceptionRecord, + void * EstablisherFrame, + context_t *ContextRecord, + void * DispatcherContext); + +typedef struct exception_registration_t exception_registration_t; +struct exception_registration_t +{ + exception_registration_t* prev; + except_handler handler; +}; + +typedef struct process_info_t process_info_t; +typedef struct thread_info_t thread_info_t; + +//! Specifies user-mode thread information. +/*! + * When a thread is created, the kernel allocates space in the process's + * address space for a thread_info_t structure. This structure is freely + * readable by the process itself and includes important information about + * the thread's environment. The use of a structure like this, in user- + * accessible memory, is more efficient than a series of syscalls to query + * the relevant information. + * + * The thread_info_t structure forms each thread's FS segment. A pointer to + * the thread_info_t structure, in DS-addressable form, is provided, to + * make the structure more easily accessible from high-level languages. + */ +struct thread_info_t +{ + //! Points to a structure specifying the exception handler for the current + //! block of code. + exception_registration_t* except; + //! Points to the thread_info_t structure itself, allowing the structure to + //! be accessed without referring to the FS selector. + thread_info_t* info; + //! Specifies the thread's ID + dword tid; + //! Specifies the ID of the thread's parent process + dword pid; + //! Describes the error condition which caused the last operating system + //! call to fail, if any. Analogous to the C run-time errno variable. + dword last_error; + //! Points to the thread's parent process's information structure. + process_info_t* process; + dword queue; +}; + +#define EXCEPTION_DEBUG 1 +#define EXCEPTION_GPF 13 +#define EXCEPTION_PAGE_FAULT 14 +#define EXCEPTION_MISSING_DLL 0x80000000 +#define EXCEPTION_MISSING_IMPORT 0x80000001 +#define EXCEPTION_DLLMAIN_FAILED 0x80000002 +#define EXCEPTION_ASSERT_FAILED 0x80000003 + +//! Specifies user-mode process information. +/*! + * When a process is created, the kernel allocates space in its address space + * for a process_info_t structure. This structure is freely readable by + * the process itself and includes important information about its + * environment. The use of a structure like this, in user-accessible + * memory, is more efficient than a series of syscalls to query the + * relevant information. + * + * The process_info_t structure is accessible through the process member of + * each thread's thread_info_t structure, which forms each thread's FS + * segment. + */ +struct process_info_t +{ + //! The ID of the process; unique within the system + dword id; + //! A pointer to the process's root IFolder object + void* root; + //! Points to a buffer containing the process's initial command line + wchar_t* cmdline; + //! Points to the the module_info_t structure relating to the first module + //! loaded. Subsequent module_info_t's form a linked list through each + //! module's next member. + module_info_t* module_first; + //! Contains the process's current working directory, as a fully-qualified path + wchar_t cwd[256]; + wchar_t *environment; + addr_t base; + addr_t input, output; +}; + +#ifdef _MSC_VER + +#pragma warning(disable:4035) +__inline thread_info_t* thrGetInfo() { __asm mov eax, fs:[4] } +#pragma warning(default:4035) + +#else +//! Retrieves a pointer to the current thread's thread_info_t structure. +static inline thread_info_t* thrGetInfo() +{ + thread_info_t* ret; + asm("mov %%fs:(4), %0" : "=r" (ret)); + return ret; +} +#endif + +#ifndef callconv_defined +#ifdef _MSC_VER +#define STDCALL __stdcall +#define CDECL __cdecl +#else +#define STDCALL __attribute__((stdcall)) +#define CDECL __attribute__((cdecl)) +#endif +#define callconv_defined +#endif + +#ifndef KERNEL + +/*! + * \ingroup kernelu + * \defgroup proc Processes + * @{ + */ + +dword procLoad(const wchar_t* filespec, const wchar_t* cmdline, + unsigned priority, addr_t input, addr_t output); +void procExit(); +dword procCurrentId(); +wchar_t* procCmdLine(); +wchar_t* procCwd(); +addr_t procBase(); + +//@} + +/*! + * \ingroup kernelu + * \defgroup sys General System + * @{ + */ +addr_t sysOpen(const wchar_t* filespec); +dword sysInvoke(void* obj, dword method, ...); +void sysSetErrno(int errno); +int sysErrno(); +dword sysUpTime(); +bool sysGetErrorText(status_t stat, wchar_t* text, size_t max); + +//@} + +/*! + * \ingroup kernelu + * \defgroup thr Threads + * @{ + */ + +#define THREAD_PRIORITY_NORMAL 16 + +void thrSetTls(dword value); +dword thrGetTls(); +void thrCall(void* addr, void* params, size_t sizeof_params); +void thrSleep(dword ms); +unsigned thrWaitHandle(addr_t* hnd, unsigned num_handles, bool wait_all); +thread_info_t* thrGetInfo(); +dword thrGetId(); +addr_t thrCreate(void* entry_point, dword param, unsigned priority); +void thrExit(int code); +//@} + +typedef struct { dword unused; } *marshal_t; + +marshal_t objMarshal(void* ptr); +void* objUnmarshal(marshal_t mshl); +void objNotifyDelete(marshal_t mshl); + +/*! + * \ingroup kernelu + * \defgroup vmm Virtual Memory Manager + * @{ + */ + +void* vmmAlloc(size_t pages, addr_t start, dword flags); +//@} + + +//! Defines the entry point to a dynamic link library (DLL). +/*! + * Every DLL is notified of certain events relevant to its execution, such + * as being loaded into and unloaded from a process's address space, + * and the creation and deletion of a process's threads. The DllMain() + * function provides a way of the kernel notifying the library of such + * events. + * \param reserved1 Reserved on The M�bius; corresponds to the HINSTANCE + * parameter on Win32. + * \param reason Specifies the reason for calling DllMain + * \param reserved2 Reserved on The M�bius + * \return true if successful (e.g. if the DLL is to be allowed to load); + * false otherwise. + */ +bool STDCALL DllMain(dword reserved1, dword reason, void* reserved2); + +#endif + +/* + * All the following functions are implemented both in the kernel and in + * kernelu.dll. They may be called from either kernel or user mode. + */ + +/*! + * \defgroup res Resources + * \ingroup kernelu + * + * Because it uses the Portable Executable format, The M�bius is able to embed + * resources into executables. These can be accessed easily from user + * mode, since they are stored in their own section in the module, and are + * organised in a tree structure, by type/ID/language. + * + * The resXXX() functions will load the different resource types; resFind() + * can be used to load all resources, including ones with user-defined + * types. + * + * @{ + */ + +const void* resFind(dword base, word type, word id, word language); +bool resLoadString(dword base, word id, wchar_t* str, size_t str_max); + +/*! + * \defgroup RT Resource Type Identifiers + * + * These are the same as the standard Windows numerical resource IDs. They + * identify module resource types and can be used with the resFind() + * function. + * + * It is also possible to define new resource types. + * \note The M�bius does not currently support string resource or type IDs. + * @{ + */ + +//! Cursor +#define RT_CURSOR 1 +//! Bitmap +#define RT_BITMAP 2 +//! Icon +#define RT_ICON 3 +//! Menu +#define RT_MENU 4 +//! Dialog box +#define RT_DIALOG 5 +//! Block of 16 strings +#define RT_STRING 6 +//! Font list +#define RT_FONTDIR 7 +//! Font +#define RT_FONT 8 +//! Acclerator table +#define RT_ACCEL 9 +//! Arbitrary binary data +#define RT_RCDATA 10 +//! Table of error messages +#define RT_MSGTABLE 11 +//! Group of cursors describing the same image at different resolutions and +//! colour depths +#define RT_GROUP_CURSOR 12 +//! Group of icons describing the same image at different resolutions and +//! colour depths +#define RT_GROUP_ICON 13 +//! Module version information block +#define RT_VERSION 16 +/*! @} @} */ + +/*! + * \ingroup vmm + * @{ + */ +//! Specifies that the area can only be accessed by the kernel +#define MEM_KERNEL 0 +//! Specifies that the area can be accessed in user mode +#define MEM_USER 3 +//! Causes the area to be committed when it is allocated +#define MEM_COMMIT 0x4 +//! Allows the area to be read from +#define MEM_READ 0x8 +//! Allows the area to be written to +#define MEM_WRITE 0x10 +//! Causes the area to be zeroed when it is committed +#define MEM_ZERO 0x20 +//! Specifies that the start parameter to vmmAlloc() refers to a physical +//! address which has already been allocated in the process's address space. +#define MEM_LITERAL 0x40 +//! For memory-mapped files, specifies that the file is an executable image +//! and that the memory alignment is independent of the file alignment +#define MEM_FILE_IMAGE 0x80 +//@} + +//@} + +addr_t hndGetOwner(addr_t handle); + +#ifndef KERNEL + +typedef struct semaphore_t semaphore_t; +struct semaphore_t +{ + addr_t owner; + int locks; +}; + +void semInit(semaphore_t* sem); +void semAcquire(semaphore_t* sem); +void semRelease(semaphore_t* sem); +#endif + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/os/pe.h b/mobius/include/os/pe.h new file mode 100644 index 0000000..577ebe2 --- /dev/null +++ b/mobius/include/os/pe.h @@ -0,0 +1,419 @@ +#ifndef __OS_PE_H +#define __OS_PE_H + +/* ANSI-compliant names for un-named structs (SUx) and unions (UUx) */ +#ifdef _MSC_VER +#define SU1 +#define SU2 +#define SU3 +#define UU1 +#define UU2 +#else +#define SU1 s +#define SU2 s2 +#define SU3 s3 +#define UU1 u +#define UU2 u2 +#endif + +typedef dword DWORD; +typedef word WORD; +typedef byte BYTE; +typedef long LONG; + +#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ +#define IMAGE_OS2_SIGNATURE 0x454E // NE +#define IMAGE_OS2_SIGNATURE_LE 0x454C // LE +#define IMAGE_VXD_SIGNATURE 0x454C // LE +#define IMAGE_NT_SIGNATURE 0x00004550 // PE00 + +#pragma pack(push, 2) // 16 bit headers are 2 byte packed + +typedef struct IMAGE_DOS_HEADER { // DOS .EXE header + WORD e_magic; // Magic number + WORD e_cblp; // Bytes on last page of file + WORD e_cp; // Pages in file + WORD e_crlc; // Relocations + WORD e_cparhdr; // Size of header in paragraphs + WORD e_minalloc; // Minimum extra paragraphs needed + WORD e_maxalloc; // Maximum extra paragraphs needed + WORD e_ss; // Initial (relative) SS value + WORD e_sp; // Initial SP value + WORD e_csum; // Checksum + WORD e_ip; // Initial IP value + WORD e_cs; // Initial (relative) CS value + WORD e_lfarlc; // File address of relocation table + WORD e_ovno; // Overlay number + WORD e_res[4]; // Reserved words + WORD e_oemid; // OEM identifier (for e_oeminfo) + WORD e_oeminfo; // OEM information; e_oemid specific + WORD e_res2[10]; // Reserved words + LONG e_lfanew; // File address of new exe header + } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; + +#pragma pack(pop) + +#pragma pack(push, 1) + +typedef struct IMAGE_FILE_HEADER { + WORD Machine; + WORD NumberOfSections; + DWORD TimeDateStamp; + DWORD PointerToSymbolTable; + DWORD NumberOfSymbols; + WORD SizeOfOptionalHeader; + WORD Characteristics; +} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER; + +typedef struct IMAGE_DATA_DIRECTORY { + DWORD VirtualAddress; + DWORD Size; +} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY; + +#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16 + +typedef struct IMAGE_OPTIONAL_HEADER { + // + // Standard fields. + // + + WORD Magic; + BYTE MajorLinkerVersion; + BYTE MinorLinkerVersion; + DWORD SizeOfCode; + DWORD SizeOfInitializedData; + DWORD SizeOfUninitializedData; + DWORD AddressOfEntryPoint; + DWORD BaseOfCode; + DWORD BaseOfData; + + // + // NT additional fields. + // + + DWORD ImageBase; + DWORD SectionAlignment; + DWORD FileAlignment; + WORD MajorOperatingSystemVersion; + WORD MinorOperatingSystemVersion; + WORD MajorImageVersion; + WORD MinorImageVersion; + WORD MajorSubsystemVersion; + WORD MinorSubsystemVersion; + DWORD Win32VersionValue; + DWORD SizeOfImage; + DWORD SizeOfHeaders; + DWORD CheckSum; + WORD Subsystem; + WORD DllCharacteristics; + DWORD SizeOfStackReserve; + DWORD SizeOfStackCommit; + DWORD SizeOfHeapReserve; + DWORD SizeOfHeapCommit; + DWORD LoaderFlags; + DWORD NumberOfRvaAndSizes; + IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; +} IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER; + +#define IMAGE_SIZEOF_SHORT_NAME 8 + +typedef struct IMAGE_SECTION_HEADER { + BYTE Name[IMAGE_SIZEOF_SHORT_NAME]; + union { + DWORD PhysicalAddress; + DWORD VirtualSize; + } Misc; + DWORD VirtualAddress; + DWORD SizeOfRawData; + DWORD PointerToRawData; + DWORD PointerToRelocations; + DWORD PointerToLinenumbers; + WORD NumberOfRelocations; + WORD NumberOfLinenumbers; + DWORD Characteristics; +} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER; + +typedef struct IMAGE_BASE_RELOCATION { + DWORD VirtualAddress; + DWORD SizeOfBlock; +// WORD TypeOffset[1]; +} IMAGE_BASE_RELOCATION; + +#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file. +#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references). +#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file. +#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file. +#define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010 // Agressively trim working set +#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed. +#define IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine. +#define IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file +#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400 // If Image is on removable media, copy and run from the swap file. +#define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800 // If Image is on Net, copy and run from the swap file. +#define IMAGE_FILE_SYSTEM 0x1000 // System File. +#define IMAGE_FILE_DLL 0x2000 // File is a DLL. +#define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000 // File should only be run on a UP machine +#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed. + +#define IMAGE_FILE_MACHINE_UNKNOWN 0 +#define IMAGE_FILE_MACHINE_I386 0x14c // Intel 386. +#define IMAGE_FILE_MACHINE_R3000 0x162 // MIPS little-endian, 0x160 big-endian +#define IMAGE_FILE_MACHINE_R4000 0x166 // MIPS little-endian +#define IMAGE_FILE_MACHINE_R10000 0x168 // MIPS little-endian +#define IMAGE_FILE_MACHINE_ALPHA 0x184 // Alpha_AXP +#define IMAGE_FILE_MACHINE_POWERPC 0x1F0 // IBM PowerPC Little-Endian + +#define IMAGE_SUBSYSTEM_UNKNOWN 0 // Unknown subsystem. +#define IMAGE_SUBSYSTEM_NATIVE 1 // Image doesn't require a subsystem. +#define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 // Image runs in the Windows GUI subsystem. +#define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 // Image runs in the Windows character subsystem. +#define IMAGE_SUBSYSTEM_OS2_CUI 5 // image runs in the OS/2 character subsystem. +#define IMAGE_SUBSYSTEM_POSIX_CUI 7 // image run in the Posix character subsystem. +#define IMAGE_SUBSYSTEM_RESERVED8 8 // image run in the 8 subsystem. + +// IMAGE_SCN_TYPE_REG 0x00000000 // Reserved. +// IMAGE_SCN_TYPE_DSECT 0x00000001 // Reserved. +// IMAGE_SCN_TYPE_NOLOAD 0x00000002 // Reserved. +// IMAGE_SCN_TYPE_GROUP 0x00000004 // Reserved. +#define IMAGE_SCN_TYPE_NO_PAD 0x00000008 // Reserved. +// IMAGE_SCN_TYPE_COPY 0x00000010 // Reserved. + +#define IMAGE_SCN_CNT_CODE 0x00000020 // Section contains code. +#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 // Section contains initialized data. +#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 // Section contains uninitialized data. + +#define IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved. +#define IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information. +// IMAGE_SCN_TYPE_OVER 0x00000400 // Reserved. +#define IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image. +#define IMAGE_SCN_LNK_COMDAT 0x00001000 // Section contents comdat. +// 0x00002000 // Reserved. + +// IMAGE_SCN_MEM_PROTECTED - Obsolete 0x00004000 +#define IMAGE_SCN_MEM_FARDATA 0x00008000 +// IMAGE_SCN_MEM_SYSHEAP - Obsolete 0x00010000 +#define IMAGE_SCN_MEM_PURGEABLE 0x00020000 +#define IMAGE_SCN_MEM_16BIT 0x00020000 +#define IMAGE_SCN_MEM_LOCKED 0x00040000 +#define IMAGE_SCN_MEM_PRELOAD 0x00080000 + +#define IMAGE_SCN_ALIGN_1BYTES 0x00100000 // +#define IMAGE_SCN_ALIGN_2BYTES 0x00200000 // +#define IMAGE_SCN_ALIGN_4BYTES 0x00300000 // +#define IMAGE_SCN_ALIGN_8BYTES 0x00400000 // +#define IMAGE_SCN_ALIGN_16BYTES 0x00500000 // Default alignment if no others are specified. +#define IMAGE_SCN_ALIGN_32BYTES 0x00600000 // +#define IMAGE_SCN_ALIGN_64BYTES 0x00700000 // +// Unused 0x00800000 + +#define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000 // Section contains extended relocations. +#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 // Section can be discarded. +#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 // Section is not cachable. +#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 // Section is not pageable. +#define IMAGE_SCN_MEM_SHARED 0x10000000 // Section is shareable. +#define IMAGE_SCN_MEM_EXECUTE 0x20000000 // Section is executable. +#define IMAGE_SCN_MEM_READ 0x40000000 // Section is readable. +#define IMAGE_SCN_MEM_WRITE 0x80000000 // Section is writeable. + +// Directory Entries + +#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 // Export Directory +#define IMAGE_DIRECTORY_ENTRY_IMPORT 1 // Import Directory +#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 // Resource Directory +#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 // Exception Directory +#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 // Security Directory +#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 // Base Relocation Table +#define IMAGE_DIRECTORY_ENTRY_DEBUG 6 // Debug Directory +#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 // Description String +#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 // Machine Value (MIPS GP) +#define IMAGE_DIRECTORY_ENTRY_TLS 9 // TLS Directory +#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 // Load Configuration Directory +#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11 // Bound Import Directory in headers +#define IMAGE_DIRECTORY_ENTRY_IAT 12 // Import Address Table + +// +// Based relocation types. +// + +#define IMAGE_REL_BASED_ABSOLUTE 0 +#define IMAGE_REL_BASED_HIGH 1 +#define IMAGE_REL_BASED_LOW 2 +#define IMAGE_REL_BASED_HIGHLOW 3 +#define IMAGE_REL_BASED_HIGHADJ 4 +#define IMAGE_REL_BASED_MIPS_JMPADDR 5 +#define IMAGE_REL_BASED_SECTION 6 +#define IMAGE_REL_BASED_REL32 7 + +// +// Export Format +// + +typedef struct IMAGE_EXPORT_DIRECTORY { + DWORD Characteristics; + DWORD TimeDateStamp; + WORD MajorVersion; + WORD MinorVersion; + DWORD Name; + DWORD Base; + DWORD NumberOfFunctions; + DWORD NumberOfNames; + DWORD **AddressOfFunctions; + DWORD **AddressOfNames; + WORD **AddressOfNameOrdinals; +} IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY; + +// +// Import Format +// + +typedef struct IMAGE_IMPORT_BY_NAME { + WORD Hint; + BYTE Name[1]; +} IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME; + +typedef struct IMAGE_THUNK_DATA { + union { + BYTE* ForwarderString; + DWORD* Function; + DWORD Ordinal; + PIMAGE_IMPORT_BY_NAME AddressOfData; + } u1; +} IMAGE_THUNK_DATA; +typedef IMAGE_THUNK_DATA * PIMAGE_THUNK_DATA; + +#define IMAGE_ORDINAL_FLAG 0x80000000 +#define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0) +#define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff) + +typedef struct IMAGE_IMPORT_DESCRIPTOR { + union { + DWORD Characteristics; // 0 for terminating null import descriptor + PIMAGE_THUNK_DATA OriginalFirstThunk; // RVA to original unbound IAT + } u; + DWORD TimeDateStamp; // 0 if not bound, + // -1 if bound, and real date\time stamp + // in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT (new BIND) + // O.W. date/time stamp of DLL bound to (Old BIND) + + DWORD ForwarderChain; // -1 if no forwarders + DWORD Name; + PIMAGE_THUNK_DATA FirstThunk; // RVA to IAT (if bound this IAT has actual addresses) +} IMAGE_IMPORT_DESCRIPTOR; +typedef IMAGE_IMPORT_DESCRIPTOR *PIMAGE_IMPORT_DESCRIPTOR; + +// +// New format import descriptors pointed to by DataDirectory[ IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT ] +// + +typedef struct IMAGE_BOUND_IMPORT_DESCRIPTOR { + DWORD TimeDateStamp; + WORD OffsetModuleName; + WORD NumberOfModuleForwarderRefs; +// Array of zero or more IMAGE_BOUND_FORWARDER_REF follows +} IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR; + +typedef struct IMAGE_BOUND_FORWARDER_REF { + DWORD TimeDateStamp; + WORD OffsetModuleName; + WORD Reserved; +} IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF; + +typedef struct IMAGE_RESOURCE_DIRECTORY { + DWORD Characteristics; + DWORD TimeDateStamp; + WORD MajorVersion; + WORD MinorVersion; + WORD NumberOfNamedEntries; + WORD NumberOfIdEntries; +// IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; +} IMAGE_RESOURCE_DIRECTORY, *PIMAGE_RESOURCE_DIRECTORY; + +#define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000 +#define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000 + +// +// Each directory contains the 32-bit Name of the entry and an offset, +// relative to the beginning of the resource directory of the data associated +// with this directory entry. If the name of the entry is an actual text +// string instead of an integer Id, then the high order bit of the name field +// is set to one and the low order 31-bits are an offset, relative to the +// beginning of the resource directory of the string, which is of type +// IMAGE_RESOURCE_DIRECTORY_STRING. Otherwise the high bit is clear and the +// low-order 16-bits are the integer Id that identify this resource directory +// entry. If the directory entry is yet another resource directory (i.e. a +// subdirectory), then the high order bit of the offset field will be +// set to indicate this. Otherwise the high bit is clear and the offset +// field points to a resource data entry. +// + +typedef struct IMAGE_RESOURCE_DIRECTORY_ENTRY { + union { + struct { + DWORD NameOffset:31; + DWORD NameIsString:1; + } SU1; + DWORD Name; + WORD Id; + } UU1; + union { + DWORD OffsetToData; + struct { + DWORD OffsetToDirectory:31; + DWORD DataIsDirectory:1; + } SU1; + } UU2; +} IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY; + +// +// For resource directory entries that have actual string names, the Name +// field of the directory entry points to an object of the following type. +// All of these string objects are stored together after the last resource +// directory entry and before the first resource data object. This minimizes +// the impact of these variable length objects on the alignment of the fixed +// size directory entry objects. +// + +typedef struct IMAGE_RESOURCE_DIRECTORY_STRING { + WORD Length; + char NameString[ 1 ]; +} IMAGE_RESOURCE_DIRECTORY_STRING, *PIMAGE_RESOURCE_DIRECTORY_STRING; + + +typedef struct IMAGE_RESOURCE_DIR_STRING_U { + WORD Length; + wchar_t NameString[ 1 ]; +} IMAGE_RESOURCE_DIR_STRING_U, *PIMAGE_RESOURCE_DIR_STRING_U; + + +// +// Each resource data entry describes a leaf node in the resource directory +// tree. It contains an offset, relative to the beginning of the resource +// directory of the data for the resource, a size field that gives the number +// of bytes of data at that offset, a CodePage that should be used when +// decoding code point values within the resource data. Typically for new +// applications the code page would be the unicode code page. +// + +typedef struct IMAGE_RESOURCE_DATA_ENTRY { + DWORD OffsetToData; + DWORD Size; + DWORD CodePage; + DWORD Reserved; +} IMAGE_RESOURCE_DATA_ENTRY, *PIMAGE_RESOURCE_DATA_ENTRY; + +typedef struct IMAGE_PE_HEADERS { + DWORD Signature; + IMAGE_FILE_HEADER FileHeader; + IMAGE_OPTIONAL_HEADER OptionalHeader; +} IMAGE_PE_HEADERS, *PIMAGE_PE_HEADERS; + +#pragma pack(pop) + +#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field)) + +#define IMAGE_FIRST_SECTION( ntheader ) ((PIMAGE_SECTION_HEADER) \ + ((DWORD)ntheader + \ + FIELD_OFFSET( IMAGE_PE_HEADERS, OptionalHeader ) + \ + ((PIMAGE_PE_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader \ + )) + +#endif \ No newline at end of file diff --git a/mobius/include/os/port.h b/mobius/include/os/port.h new file mode 100644 index 0000000..b1cde4a --- /dev/null +++ b/mobius/include/os/port.h @@ -0,0 +1,21 @@ +#ifndef __OS_PORT_H +#define __OS_PORT_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +addr_t portCreate(const wchar_t* name); +bool portListen(addr_t port); +bool portConnect(addr_t port, const wchar_t* remote); +addr_t portAccept(addr_t server); +bool portClose(addr_t port); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/os/serial.h b/mobius/include/os/serial.h new file mode 100644 index 0000000..34c5a76 --- /dev/null +++ b/mobius/include/os/serial.h @@ -0,0 +1,64 @@ +#ifndef __OS_SERIAL_H +#define __OS_SERIAL_H + +/* +** ISR I/O Modes +*/ +/********************************........xx.. */ +#define BYTE_MODE 0x00 /* 00000000b */ +#define PACKET_MODE 0x01 /* 00000001b */ +#define VARIABLE_MODE 0x02 /* 00000010b */ + +/* +** Line Control Register +*/ +/********************************........xx.. */ +#define CLEAR_BITS 0xFC /* 11111100b */ +#define BITS_5 0x00 /* 00000000b */ +#define BITS_6 0x01 /* 00000001b */ +#define BITS_7 0x02 /* 00000010b */ +#define BITS_8 0x03 /* 00000011b */ +/********************************.......x... */ +#define CLEAR_STOP 0xFB /* 11111011b */ +#define STOP_1 0x00 /* 00000000b */ +#define STOP_2 0x04 /* 00000100b (Doesn't work w/ BITS_5) */ +/*********************************...xxx.... */ +#define CLEAR_PARITY 0xE7 /* 11000111b */ +#define NO_PARITY 0x00 /* 00000000b */ +#define ODD_PARITY 0x08 /* 00001000b */ +#define EVEN_PARITY 0x18 /* 00011000b */ +#define MARK_PARITY 0x28 /* 00101000b */ +#define SPACE_PARITY 0x38 /* 00111000b */ +/********************************...x....... */ +#define CLEAR_MODE 0xBF /* 10111111b */ +#define NORMAL 0x00 /* 00000000b */ +#define BREAK 0x40 /* 01000000b */ + +/* +** HandShaking +*/ +#define DTR 0x01 // 00000001b +#define RTS 0x02 // 00000010b +#define LOOPBACK 0x10 // 00010000b + +/* +** Modem/Line Status Register +*/ +#define D_CTS 0x0100 // 00000001 00000000b +#define D_DSR 0x0200 // 00000010 00000000b +#define D_RI 0x0400 // 00000100 00000000b +#define D_DCD 0x0800 // 00001000 00000000b +#define CTS 0x1000 // 00010000 00000000b +#define DSR 0x2000 // 00100000 00000000b +#define RI 0x4000 // 01000000 00000000b +#define DCD 0x8000 // 10000000 00000000b +#define RBF 0x0001 // 00000000 00000001b +#define OVR_ERROR 0x0002 // 00000000 00000010b +#define PAR_ERROR 0x0004 // 00000000 00000100b +#define FRM_ERROR 0x0008 // 00000000 00001000b +#define BRK_ERROR 0x0010 // 00000000 00010000b +#define THREMPTY 0x0020 // 00000000 00100000b +#define TEMPTY 0x0040 // 00000000 01000000b +#define FFO_ERROR 0x0080 // 00000000 10000000b + +#endif \ No newline at end of file diff --git a/mobius/include/os/stream.h b/mobius/include/os/stream.h new file mode 100644 index 0000000..41e4b9c --- /dev/null +++ b/mobius/include/os/stream.h @@ -0,0 +1,70 @@ +#ifndef __STREAM_H +#define __STREAM_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +enum { ioRaw, ioUnicode, ioAnsi }; +enum { seekSet, seekCur, seekEnd }; + +typedef struct folderitem_t folderitem_t; +struct folderitem_t +{ + dword size; + union + { + dword find_handle; + IUnknown *item_handle; + } u; + const wchar_t* spec; + wchar_t* name; + size_t name_max; + dword attributes; + size_t length; +}; + +#define ATTR_READ_ONLY 0x01 +#define ATTR_HIDDEN 0x02 +#define ATTR_SYSTEM 0x04 +#define ATTR_VOLUME_ID 0x08 +#define ATTR_DIRECTORY 0x10 +#define ATTR_ARCHIVE 0x20 +#define ATTR_DEVICE 0x1000 +#define ATTR_LINK 0x2000 + +#undef INTERFACE +#define INTERFACE IStream +DECLARE_INTERFACE(IStream) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void ** ppvObject) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + STDMETHOD_(size_t, Read)(THIS_ void* buffer, size_t length) PURE; + STDMETHOD_(size_t, Write)(THIS_ const void* buffer, size_t length) PURE; + STDMETHOD(SetIoMode)(THIS_ dword mode) PURE; + STDMETHOD(IsReady)(THIS) PURE; + STDMETHOD(Stat)(THIS_ folderitem_t* buf) PURE; + STDMETHOD(Seek)(THIS_ long offset, int origin) PURE; +}; + +// {816B7D54-910A-4187-AEF6-F30EFEFE4AEE} +DEFINE_GUID(IID_IStream, +0x816b7d54, 0x910a, 0x4187, 0xae, 0xf6, 0xf3, 0xe, 0xfe, 0xfe, 0x4a, 0xee); + +size_t IStream_Read(IStream* ptr, void* buf, size_t len); +size_t IStream_Write(IStream* ptr, const void* buf, size_t len); +HRESULT IStream_SetIoMode(IStream* ptr, dword mode); +HRESULT IStream_IsReady(IStream* ptr); +HRESULT IStream_Stat(IStream* ptr, folderitem_t* buf); +HRESULT IStream_Seek(IStream* ptr, long offset, int origin); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/printf.h b/mobius/include/printf.h new file mode 100644 index 0000000..f8501e4 --- /dev/null +++ b/mobius/include/printf.h @@ -0,0 +1,30 @@ +#ifndef __PRINTF_H +#define __PRINTF_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include "stdarg.h" + +/*! + * \ingroup libc + * \defgroup printf printf() implementation + * @{ + */ + +typedef bool (*PRINTFUNC) (void* pContext, const char* str, dword dwLen); +typedef bool (*WPRINTFUNC) (void* pContext, const wchar_t* str, dword dwLen); + +int doprintf(PRINTFUNC func, void* pContext, const char* fmt, va_list ptr); +int dowprintf(WPRINTFUNC func, void* pContext, const wchar_t* fmt, va_list ptr); + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/regex.h b/mobius/include/regex.h new file mode 100644 index 0000000..cf6389e --- /dev/null +++ b/mobius/include/regex.h @@ -0,0 +1,6 @@ +#ifndef __REGEX_H +#define __REGEX_H + +typedef void* regex_t; + +#endif \ No newline at end of file diff --git a/mobius/include/stdarg.h b/mobius/include/stdarg.h new file mode 100644 index 0000000..5170639 --- /dev/null +++ b/mobius/include/stdarg.h @@ -0,0 +1,41 @@ +#ifndef __STDARG_H +#define __STDARG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + * \ingroup libc + * \defgroup stdarg Variable argument list handling + * @{ + */ + +/* width of stack == width of int */ +#define STACKITEM int + +typedef char *va_list; + +/* round up width of objects pushed on stack. The expression before the +& ensures that we get 0 for objects of size 0. */ +#define VA_SIZE(TYPE) \ + ((sizeof(TYPE) + sizeof(STACKITEM) - 1) \ + & ~(sizeof(STACKITEM) - 1)) + +/* &(LASTARG) points to the LEFTMOST argument of the function call +(before the ...) */ +#define va_start(AP, LASTARG) \ + (AP=((va_list)&(LASTARG) + VA_SIZE(LASTARG))) + +#define va_end(AP) /* nothing */ + +#define va_arg(AP, TYPE) \ + (AP += VA_SIZE(TYPE), *((TYPE *)(AP - VA_SIZE(TYPE)))) + +//@} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/mobius/include/stdio.h b/mobius/include/stdio.h new file mode 100644 index 0000000..18b1e85 --- /dev/null +++ b/mobius/include/stdio.h @@ -0,0 +1,71 @@ +#ifndef __STDIO_H +#define __STDIO_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include +#include + +/*! + * \ingroup libc + * \defgroup stdio Standard input and output + * @{ + */ + +typedef struct FILE FILE; +struct FILE +{ + addr_t fd; +}; + +extern FILE __iobuf[3]; +#define stdin (__iobuf + 0) +#define stdout (__iobuf + 1) +#define stderr (__iobuf + 2) + +int wprintf(const wchar_t* fmt, ...); +int vwprintf(const wchar_t* fmt, va_list ptr); +int vswprintf(wchar_t *buffer, const wchar_t *format, va_list argptr); +int swprintf(wchar_t *buffer, const wchar_t *format, ...); + +int printf(const char* fmt, ...); +int vprintf(const char* fmt, va_list ptr); +int vsprintf(char *buffer, const char *format, va_list argptr); +int sprintf(char *buffer, const char *format, ...); + +wint_t putwchar(wint_t c); +int putchar(int c); +int _cputws(const wchar_t* str); +int _cputs(const char* str); + +int fprintf(FILE* file, const char* fmt, ...); + +FILE* fopen(const char* filename, const char* mode); +int fclose(FILE* f); +size_t fread (void* pBuffer, size_t sizeObject, size_t sizeObjCount, + FILE* fileRead); +size_t fwrite (const void* pObjArray, size_t sizeObject, size_t sizeObjCount, + FILE* fileWrite); +int fseek(FILE *stream, long offset, int origin); +long ftell(FILE *stream); + +int fputc(int c, FILE *stream); +wint_t fputwc(wint_t c, FILE *stream); + +void _pwerror(const wchar_t* string); + +#define SEEK_CUR 1 +#define SEEK_END 2 +#define SEEK_SET 0 + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/stdlib.h b/mobius/include/stdlib.h new file mode 100644 index 0000000..a1d0854 --- /dev/null +++ b/mobius/include/stdlib.h @@ -0,0 +1,50 @@ +#ifndef __STDLIB_H +#define __STDLIB_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +/*! + * \ingroup libc + * \defgroup stdlib Standard library definitions + * @{ + */ + +#define countof(a) (sizeof(a) / sizeof(a[0])) + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + +#include + +int rand(); +void srand(unsigned long new_seed); +void exit(int status); +int atexit(void (__cdecl *func)(void)); +int match(const wchar_t *mask, const wchar_t *name); +long strtol(const char *nptr, char **endptr, int base); +long wcstol(const wchar_t *nptr, wchar_t **endptr, int base); +void qsort(void *Base, size_t Num, size_t Width, + int(*Compare) (const void *, const void *)); + +#define MAX_PATH 256 + +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 1 + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/string.h b/mobius/include/string.h new file mode 100644 index 0000000..4ffd3f3 --- /dev/null +++ b/mobius/include/string.h @@ -0,0 +1,39 @@ +#ifndef __STRING_H +#define __STRING_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! + * \ingroup libc + * \defgroup string String routines + * @{ + */ + +#include + +/* ANSI-character functions */ +size_t strlen(const char* str); +int stricmp(const char* str1, const char* str2); +int strncmp(const char* str1, const char* str2, size_t count); +char *strcpy(char *strDestination, const char *strSource); +int strcmp(const char *string1, const char *string2); +char *strtok(char *string, const char *control); +char *strpbrk(const char *s1, const char *s2); +char *strncpy(char* Dst, const char* Src, unsigned int Count); + +/* Buffer manipulation functions */ +void *memset(void *dest, int c, size_t count); +void *memcpy(void *dest, const void *src, size_t count); +void *memmove(void* dest, const void *src, size_t count); +int memcmp(const void *buf1, const void *buf2, size_t count); + +//@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/include/strings.h b/mobius/include/strings.h new file mode 100644 index 0000000..e9d2839 --- /dev/null +++ b/mobius/include/strings.h @@ -0,0 +1,6 @@ +#ifndef _STRINGS_H +#define _STRINGS_H + +#include + +#endif /* _STRINGS_H */ diff --git a/mobius/include/sys/error.h b/mobius/include/sys/error.h new file mode 100644 index 0000000..b09b457 --- /dev/null +++ b/mobius/include/sys/error.h @@ -0,0 +1,6 @@ +#ifndef __SYS_ERROR_H +#define __SYS_ERROR_H + +#include + +#endif \ No newline at end of file diff --git a/mobius/include/sys/stat.h b/mobius/include/sys/stat.h new file mode 100644 index 0000000..f3efdf9 --- /dev/null +++ b/mobius/include/sys/stat.h @@ -0,0 +1,47 @@ +#ifndef __SYS_STAT_H +#define __SYS_STAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct stat { + short st_dev; + short st_ino; + unsigned short st_mode; + short st_nlink; + short st_uid; + short st_gid; + short st_rdev; + short st_align_for_word32; + long st_size; + long st_atime; + long st_mtime; + long st_ctime; + long st_blksize; +}; + +#define S_IFMT 0xF000 /* file type mask */ +#define S_IFDIR 0x4000 /* directory */ +#define S_IFIFO 0x1000 /* FIFO special */ +#define S_IFCHR 0x2000 /* character special */ +#define S_IFBLK 0x3000 /* block special */ +#define S_IFREG 0x8000 /* or just 0x0000, regular */ +#define S_IREAD 0x0100 /* owner may read */ +#define S_IWRITE 0x0080 /* owner may write */ +#define S_IEXEC 0x0040 /* owner may execute */ + +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) + +int stat(const char *, struct stat *); +int fstat(int, struct stat *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/mobius/include/sys/types.h b/mobius/include/sys/types.h new file mode 100644 index 0000000..2362c30 --- /dev/null +++ b/mobius/include/sys/types.h @@ -0,0 +1,96 @@ +#ifndef __SYS_TYPES_H +#define __SYS_TYPES_H + +//! An unsigned 8-bit number +typedef unsigned char byte; +//! An unsigned 16-bit number +typedef unsigned short word; +//! An unsigned 32-bit number +typedef unsigned int dword; + +#ifdef _MSC_VER +typedef unsigned __int64 qword; +#else +//! An unsigned 64-bit number +typedef unsigned long long qword; +#endif + +//! An address that should not be dereferenced. +/*! + * Often used to denote physical memory addresses, addresses within another + * process's address space, or addresses outside of memory (for example, + * on a magnetic storage device). + */ +typedef dword addr_t; + +#ifdef _MSC_VER +/* + * Visual C++ expects (?) size_t to be unsigned int, whereas gcc's built-in + * string functions expect it to be unsigned long. + */ + +#ifndef _SIZE_T_DEFINED +typedef unsigned int size_t; +#define _SIZE_T_DEFINED +#endif + +#else + +#ifndef _SIZE_T_DEFINED +//! The result of the sizeof operator. +/*! + * Describes the sizes of objects up to 4GB (232) in size. + */ +typedef unsigned int size_t; +#define _SIZE_T_DEFINED +#endif + +#endif + +#ifndef __cplusplus + +typedef byte _Bool; + +#ifndef bool +//! A boolean (true or false) value +#define bool _Bool +#endif + +#ifndef true +//! Boolean true +#define true 1 +#endif + +#ifndef false +//! Boolean false +#define false 0 +#endif + +#endif + +#ifndef NULL +//! The NULL pointer +#define NULL 0 +#endif + +typedef int status_t; + +#ifndef _WCHAR_T_DEFINED + +typedef unsigned short __wchar_ucs2_t; + +//! A single Unicode character +#define wchar_t __wchar_ucs2_t +#define _WCHAR_T_DEFINED +#endif + +#ifndef _WCTYPE_T_DEFINED +//! A data type capable of holding any wide character or an end-of-file value +typedef int wint_t; +//! A data type capable of representing all characters of any national +//! character set +typedef wchar_t wctype_t; +#define _WCTYPE_T_DEFINED +#endif + +#endif diff --git a/mobius/include/unistd.h b/mobius/include/unistd.h new file mode 100644 index 0000000..4b93d68 --- /dev/null +++ b/mobius/include/unistd.h @@ -0,0 +1,4 @@ +#ifndef __UNISTD_H +#define __UNISTD_H + +#endif \ No newline at end of file diff --git a/mobius/include/values.h b/mobius/include/values.h new file mode 100644 index 0000000..66689a9 --- /dev/null +++ b/mobius/include/values.h @@ -0,0 +1,57 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_values_h_ +#define __dj_include_values_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#define BITSPERBYTE 8 + +#define CHARBITS 8 +#define SHORTBITS 16 +#define INTBITS 32 +#define LONGBITS 32 +#define PTRBITS 32 +#define DOUBLEBITS 64 +#define FLOATBITS 32 + +#define MINSHORT ((short)0x8000) +#define MININT ((int)0x80000000L) +#define MINLONG ((long)0x80000000L) + +#define MAXSHORT ((short)0x7fff) +#define MAXINT ((int)0x7fffffff) +#define MAXLONG ((long)0x7fffffff) + +#define MAXDOUBLE 1.79769313486231570e+308 +#define MAXFLOAT ((float)3.40282346638528860e+38) +#define MINDOUBLE 2.22507385850720140e-308 +#define MINFLOAT ((float)1.17549435082228750e-38) +#define _IEEE 0 +#define _DEXPLEN 11 +#define _FEXPLEN 8 +#define _HIDDENBIT 1 +#define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE) +#define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE) +#define DMINEXP (-DMAXEXP) +#define FMINEXP (-FMAXEXP) + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_values_h_ */ diff --git a/mobius/include/wchar.h b/mobius/include/wchar.h new file mode 100644 index 0000000..7762099 --- /dev/null +++ b/mobius/include/wchar.h @@ -0,0 +1,54 @@ +#ifndef __WCHAR_H +#define __WCHAR_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! + * \ingroup libc + * \defgroup wchar Wide character routines + * @{ + */ + +#include + +//! Describes attributes relating to a particular Unicode code point +struct wchar_info_t +{ + //! Specifies the 16-bit value of the character + wchar_t code_point; + //! Specifies the classes to which the character belongs + unsigned short char_class; + //! Specifes the same character in upper case, if appropriate + wchar_t upper, + //! Specifes the same character in lower case, if appropriate + lower; +}; +typedef struct wchar_info_t wchar_info_t; + +/* Wide-character functions */ +size_t wcslen(const wchar_t* str); +wchar_t *wcscpy(wchar_t *strDestination, const wchar_t *strSource); +wchar_t *wcsncpy(wchar_t *strDestination, const wchar_t *strSource, size_t count); +int wcscmp(const wchar_t* str1, const wchar_t* str2); +int wcsicmp(const wchar_t* str1, const wchar_t* str2); +wchar_t *wcschr(const wchar_t* str, int c); +wchar_t *wcsrchr(const wchar_t* str, int c); +wchar_t *wcscat(wchar_t* dest, const wchar_t* src); +wchar_t *wcsdup(const wchar_t* str); +wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2); + +/* ANSI/wide conversion functions */ +size_t mbstowcs(wchar_t *wcstr, const char *mbstr, size_t count); +size_t wcstombs(char *mbstr, const wchar_t *wcstr, size_t count); +wchar_t *_wcserror(int errcode); + +//@} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/mobius/lib/kdebug.exp b/mobius/lib/kdebug.exp new file mode 100644 index 0000000..e6b2a52 --- /dev/null +++ b/mobius/lib/kdebug.exp Binary files differ diff --git a/mobius/lib/kdebug.lib b/mobius/lib/kdebug.lib new file mode 100644 index 0000000..05b6ebf --- /dev/null +++ b/mobius/lib/kdebug.lib Binary files differ diff --git a/mobius/lib/kernel.exp b/mobius/lib/kernel.exp new file mode 100644 index 0000000..01298bb --- /dev/null +++ b/mobius/lib/kernel.exp Binary files differ diff --git a/mobius/lib/kernel.lib b/mobius/lib/kernel.lib new file mode 100644 index 0000000..1b818f4 --- /dev/null +++ b/mobius/lib/kernel.lib Binary files differ diff --git a/mobius/lib/kernelu.lib b/mobius/lib/kernelu.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/mobius/lib/kernelu.lib diff --git a/mobius/lib/libcs.lib b/mobius/lib/libcs.lib new file mode 100644 index 0000000..bf632a7 --- /dev/null +++ b/mobius/lib/libcs.lib Binary files differ diff --git a/mobius/mobius.dsw b/mobius/mobius.dsw new file mode 100644 index 0000000..431f759 --- /dev/null +++ b/mobius/mobius.dsw @@ -0,0 +1,278 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "all"=.\src\all.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name kdebug + End Project Dependency + Begin Project Dependency + Project_Dep_Name tali + End Project Dependency +}}} + +############################################################################### + +Project: "boot"=.\src\boot\boot.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "cat"=.\src\cat\cat.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name kernelu + End Project Dependency + Begin Project Dependency + Project_Dep_Name libc + End Project Dependency +}}} + +############################################################################### + +Project: "console"=.\src\console\console.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "fortune"=.\src\fortune\fortune.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name libc + End Project Dependency + Begin Project Dependency + Project_Dep_Name kernelu + End Project Dependency +}}} + +############################################################################### + +Project: "gui"=.\src\gui\gui.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "hello"=.\src\hello\hello.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name libc + End Project Dependency + Begin Project Dependency + Project_Dep_Name kernelu + End Project Dependency +}}} + +############################################################################### + +Project: "kernel"=.\src\kernel\kernel.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "kernelu"=.\src\kernelu\kernelu.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "libc"=.\src\libc\libc.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name kernelu + End Project Dependency +}}} + +############################################################################### + +Project: "ls"=.\src\ls\ls.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name kernelu + End Project Dependency + Begin Project Dependency + Project_Dep_Name libc + End Project Dependency +}}} + +############################################################################### + +Project: "mgl"=.\src\mgl\mgl.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "mount"=.\src\mount\mount.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name kernelu + End Project Dependency + Begin Project Dependency + Project_Dep_Name libc + End Project Dependency +}}} + +############################################################################### + +Project: "ramdisk"=.\src\tools\ramdisk\ramdisk.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "sertest"=.\src\sertest\sertest.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name libc + End Project Dependency + Begin Project Dependency + Project_Dep_Name kernelu + End Project Dependency +}}} + +############################################################################### + +Project: "short"=.\src\short\short.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name libc + End Project Dependency + Begin Project Dependency + Project_Dep_Name kernelu + End Project Dependency +}}} + +############################################################################### + +Project: "tetris"=.\src\tetris\tetris.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name libc + End Project Dependency + Begin Project Dependency + Project_Dep_Name kernelu + End Project Dependency +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/mobius/src/Makefile b/mobius/src/Makefile new file mode 100644 index 0000000..74c5dbb --- /dev/null +++ b/mobius/src/Makefile @@ -0,0 +1,15 @@ +include make.actions + +DIRS= kernel drivers kernelu libc \ + freetype-2.0.4 mgl \ + devtest init short console \ + tetris hello boot ../bin + +all: crt0.o crt0dll.o + for %i in ($(DIRS)) do @make -C %i + +clean: + for %i in ($(DIRS)) do @make -C %i clean + +floppy: all + make -C ../bin floppy diff --git a/mobius/src/all.dsp b/mobius/src/all.dsp new file mode 100644 index 0000000..94d8397 --- /dev/null +++ b/mobius/src/all.dsp @@ -0,0 +1,100 @@ +# Microsoft Developer Studio Project File - Name="all" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=all - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "all.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "all.mak" CFG="all - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "all - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "all - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "all - Win32 Release" + +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f all.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "all.exe" +# PROP BASE Bsc_Name "all.bsc" +# PROP BASE Target_Dir "" +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "domake" +# PROP Rebuild_Opt "/a" +# PROP Target_File "all.exe" +# PROP Bsc_Name "all.bsc" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "all - Win32 Debug" + +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f all.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "all.exe" +# PROP BASE Bsc_Name "all.bsc" +# PROP BASE Target_Dir "" +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "all - Win32 Release" +# Name "all - Win32 Debug" + +!IF "$(CFG)" == "all - Win32 Release" + +!ELSEIF "$(CFG)" == "all - Win32 Debug" + +!ENDIF + +# Begin Group "bin" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\bin\Makefile +# End Source File +# End Group +# Begin Source File + +SOURCE=C:\BOCHS\bochs.out +# End Source File +# Begin Source File + +SOURCE=..\bin\coffbase.txt +# End Source File +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/all.plg b/mobius/src/all.plg new file mode 100644 index 0000000..85d7791 --- /dev/null +++ b/mobius/src/all.plg @@ -0,0 +1,19 @@ + + +
+

Build Log

+

+--------------------Configuration: all - Win32 Debug-------------------- +

+ +'make' is not recognized as an internal or external command, +operable program or batch file. +Error executing i:\winnt\system32\cmd.exe. + + + +

Results

+all.exe - 1 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/boot/Makefile b/mobius/src/boot/Makefile new file mode 100644 index 0000000..4d67e91 --- /dev/null +++ b/mobius/src/boot/Makefile @@ -0,0 +1,29 @@ +BIN= ..\..\bin +TARGET= $(BIN)\mobel_pe.com +BOOTSECT= $(BIN)\bootsect.com +OBJS= startup.obj mobel_pe.obj disk.obj vfs.obj \ + fat.obj loaderb.obj +LIBPATH=f:\tc\lib +CFLAGS= -w -mt -O2 -d -Z -1 -vi +LFLAGS =/x /c + +all: $(TARGET) $(BOOTSECT) + +$(TARGET): $(OBJS) Makefile + tlink $(LFLAGS) /t $(OBJS),$(TARGET),,$(LIBPATH)\cs.lib + ndisasmw $(TARGET) > listing.txt + +%.obj: %.c Makefile + tcc -c $(CFLAGS) -o$@ $< + +%.obj: %.asm + nasm -DNODOS -f obj -o$@ $< + +$(BOOTSECT): bootsect.asm + nasm -f bin -o$@ $< + +floppy: $(TARGET) + copy $(TARGET) a: + +bochs: $(TARGET) + make -C ../../bin \ No newline at end of file diff --git a/mobius/src/boot/bootsect.asm b/mobius/src/boot/bootsect.asm new file mode 100644 index 0000000..33fa530 --- /dev/null +++ b/mobius/src/boot/bootsect.asm @@ -0,0 +1,346 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Project: Bootstrap ;; +;; Module: rpboot.asm ;; +;; Date: 7-3-99 ;; +;; Purpose: This module contains the portion of the bootstrap that loads ;; +;; the kernel loader into memory. It is based on a bootstrap ;; +;; examples by Gareth Owen and Sean Tash. ;; +;; ;; +;; Created by Ben L. Titzer ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +[BITS 16] ; bios starts out in 16-bit real mode +[ORG 0x7c00] ; data offset of zero + +%define LOAD_SEGMENT 0x1000 ; load the loader to segment 0x1000 +%define STACK_SEGMENT 0x9000 ; stack segment + +jmp short start ; jump to beginning of code +nop + +;============================================================================; +;============================ F A T I N F O ===============================; +;============================================================================; + +bsOEM db "-M�bius-" ; OEM String +bsSectSize dw 512 ; Bytes per sector +bsClustSize db 1 ; Sectors per cluster +bsRessect dw 1 ; # of reserved sectors +bsFatCnt db 2 ; # of fat copies +bsRootSize dw 224 ; size of root directory +bsTotalSect dw 2880 ; total # of sectors if < 32 meg +bsMedia db 0xF0 ; Media Descriptor +bsFatSize dw 9 ; Size of each FAT +bsTrackSect dw 18 ; Sectors per track +bsHeadCnt dw 2 ; number of read-write heads +bsHidenSect dd 0 ; number of hidden sectors +bsHugeSect dd 0 ; if bsTotalSect is 0 this value is + ; the number of sectors +bsBootDrv db 0 ; holds drive that the bs came from +bsReserv db 0 ; not used for anything +bsBootSign db 29h ; boot signature 29h +bsVolID dd 0 ; Disk volume ID also used for temp + ; sector # / # sectors to load +bsVoLabel + + root_strt db " " ; volume label is used internally + root_scts db " " ; while in memory for storage + file_strt db " " ; of other variables. + file_scts db " " ; this is just done to save space. + db " " + rs_fail db " " + +bsFSType db "FAT12 " ; File System type + +;============================================================================; + + filename db 'MOBEL_PECOM' + rebootmsg db 'Press any key',13,10,0 + diskerror db "Disk error.",0 + loadmsg db "Loading...",0 + + +;============================================================================; +;====================== B O O T S E C T O R C O D E ======================; +;============================================================================; + + start: + + cli ; clear interrupts while we setup a stack + mov [bsBootDrv], dl ; save what drive we booted from + mov ax,STACK_SEGMENT ; setup stack segment + mov ss,ax + mov sp,0xffff ; use the whole segment + +; mov cx,[bsTrackSect] ; update int 1E FDC param table +; mov bx,0x0078 +; lds si,[ds:bx] +; mov byte [si+4], cl +; mov byte [si+9], 0x0F + + sti ; put interrupts back on + + push ds + mov dl,[bsBootDrv] ; reset controller + xor ax,ax + int 0x13 + pop ds + jc bootfail2 ; display error message + jmp cont +bootfail2: jmp bootfail +cont: + xor ax, ax ; clear ax + mov ds, ax ; set up data segment accordingly + mov es, ax + + mov si,loadmsg ; display load message + call putstr + + + xor ax,ax ; find the root directory + mov al,[bsFatCnt] + mov bx,[bsFatSize] + mul bx + add ax,word [bsHidenSect] + adc ax,word [bsHidenSect+2] + add ax,word [bsRessect] ; ax holds root directory location + mov word [root_strt],ax + + call findfile + + xor ax,ax + add ax,word [root_scts] + add ax,word [file_strt] ; sector number + add ax,word [root_strt] + sub ax,2 ; correction for a mis-calc + mov cx,word [file_scts] ; number of sectors + + mov bx,LOAD_SEGMENT+10h ; the 10h is because it's a com file + mov es,bx + +nextsector: + push ax ; save registers + push cx + push dx + push es + + xor bx,bx ; set zero offset + call readsect ; read a sector + + pop es ; restore registers + pop dx + pop cx + pop ax + mov bx,es + add bx,20h ; increment address 512 bytes + mov es,bx + inc ax ; read next sector + loopnz nextsector + + mov dl, [bsBootDrv] + mov ax,LOAD_SEGMENT ; set segment registers and jump + mov es,ax + mov ds,ax + push ax ; push the segment + mov ax,100h ; its a com file, execution starts at 100h + push ax ; push offset + retf ; call the second stage +findfile: + push ax ; save registers + push bx + push cx + push dx + push si + push di + + mov ax,LOAD_SEGMENT ; put root directory at LOAD_SEGMENT + mov es,ax + mov ax,32 ; AX = ((32*RootSize)/512) + 2 + mul word [bsRootSize] + div word [bsSectSize] + mov cx,ax ; cx holds # of sectors in root + mov word [root_scts],ax + mov ax,word [root_strt] ; get prev. saved loc. for root dir + +searchrootsect: + xor bx,bx + push cx ; save count + push ax ; save sector number + push es + push dx + call readsect + xor bx,bx +checkentry: + mov di,bx ; set address to check from + mov cx,11 ; check 11 bytes + mov si,filename ; address of string to check with + repz cmpsb ; check string against filename + je foundit ; if equal, we found it + add bx,32 ; otherwise, check next entry + cmp bx,[bsSectSize] ; end of sector? + jne checkentry ; if not end, continue + + pop dx ; restore registers + pop es + pop ax + pop cx + inc ax ; check next sector when we loop again + loopnz searchrootsect ; loop until either found or not + jmp bootfail ; couldn't find it: die + +foundit: + pop dx ; get these off the stack + pop es + pop ax + pop cx + + mov di,0x1A ; get clustor # + add di,bx + push bx ; save bx for finding # of sectors + mov ax,[es:di] + xor bx,bx ; calculate sector # + mov bl,[bsClustSize] + mul bx ; ax holds sector # + mov word [file_strt],ax + + pop bx ; get location of directory entry + mov di,0x1C + add di,bx + mov ax,[es:di] ; put number of bytes in ax + xor dx,dx + mov bx,[bsSectSize] ; # of bytes / 512 + div bx + inc ax + mov word [file_scts],ax ; save number of sectors to load + + pop di ; restore registers + pop si + pop dx + pop cx + pop bx + pop ax + + ret ; return to caller + + bootfail: + mov si,diskerror ; display error message + call putstr + call reboot + + + +;============================================================================; +;=========================== F U N C T I O N S ==============================; +;============================================================================; + + readsect: ; ES:BX = Location ; AX = Sector + mov [rs_fail], byte 0 ; no failures yet + + readsect2: + + push ax ; store sector + + mov si,[bsTrackSect] + div si ; divide logical sect by track size + inc dl ; sector # begins at 1 + mov [bsReserv],dl ; sector to read + xor dx,dx ; logical track left in ax + div word [bsHeadCnt] ; leaves head in dl, cyl in ax + mov dh, [bsBootDrv] ; + xchg dl,dh ; head to dh, drive to dl + mov cx,ax ; cyl to cx + xchg cl,ch ; low 8 bits of cyl to ch, hi 2 bits + shl cl,6 ; shifted to bits 6 and 7 + or cl, byte [bsReserv] ; or with sector number + mov al,1 ; number of sectors + mov ah,2 ; use read function of int 0x13 + int 0x13 ; read sector + jc readfail ; display error message + pop ax + ret ; return to caller + + readfail: ; read failed + inc byte [rs_fail] + cmp byte [rs_fail], 4 ; stop at 4 tries + je bootfail + + mov dl,[bsBootDrv] ; reset controller + xor ax,ax + int 0x13 + pop ax + jmp readsect2 + + + +;============================================================================; + +%ifdef PUTINT + putint: ; print ax to screen + + mov si, di ; if di is set, then print leading zeroes + mov bx, 10000 + mov cx, ax ; store a copy of ax + + pi1: + cmp bx, 1 ; if we are on last digit + jne cn + mov si, 1 ; make sure we print it (even if zero) + cn: + mov ax, cx ; get current num + xor dx, dx ; clear dx + div bx ; divide by decimal + mov cx, dx ; save remainder + or si, ax ; if si and ax are zero, it's a leading zero + jz nz + add ax, '0' ; make a character + mov ah, 0eh ; print character function + int 0x10 ; call BIOS + + nz: + mov ax, bx ; we have to reduce the radix too + xor dx, dx ; clear dx + mov bx, 10 ; use 10 as new divider + div bx ; divide + mov bx, ax ; save result + or bx, bx ; if zero, we're done + jnz pi1 + + ret +%endif + +;============================================================================; + + putstr: ; Dump ds:si to screen. + lodsb ; load byte at ds:si into al + or al,al ; test if character is 0 (end) + jz done + mov ah,0eh ; put character + mov bx,0009 ; attribute + int 0x10 ; call BIOS + jmp putstr + done: + ret + +;============================================================================; + + reboot: + mov si, rebootmsg ; be polite, and say we're rebooting + call putstr + mov ah, 0 ; subfuction 0 + int 016h ; call bios to wait for key + + db 0EAh ; machine language to jump to FFFF:0000 (reboot) + dw 0000h + dw 0FFFFh + + +;============================================================================; +;============================ E N D C O D E ===============================; +;============================================================================; + + +padding times 510-($-$$) db 0 ; make the file the right size +BootSig dw 0xAA55 ; magic word for BIOS + +;============================================================================; + diff --git a/mobius/src/boot/bootsect.d b/mobius/src/boot/bootsect.d new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/mobius/src/boot/bootsect.d diff --git a/mobius/src/boot/bootsect.old.asm b/mobius/src/boot/bootsect.old.asm new file mode 100644 index 0000000..8825e56 --- /dev/null +++ b/mobius/src/boot/bootsect.old.asm @@ -0,0 +1,262 @@ +; GazOS Operating System +; Copyright (C) 1999 Gareth Owen +; +; This program is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version 2 +; of the License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program; if not, write to the Free Software +; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +%include "gdtnasm.inc" +; GazOS bootsector by Gareth Owen + +%define ONE_MEG 0x100000 +%define MEM_INCR ONE_MEG +%define LOAD_ADDR ONE_MEG +%define RDSK_ADDR (ONE_MEG * 2) +%define BUFFER_ADDR 0x8000 +%define KERNEL_SIZE (kernel_end - kernel_start) +%define RDSK_SIZE (ramdisk_end - kernel_end) + +[ORG 0x7c00] +jmp start +nop + +;START BOOTSECTOR HEADER + +;id db 'GazFS' ; Filing System ID +;version dd 1h ; Filing System Version +;fs_start dd 52 ; LBA address for start of root dir + +BytesPerSector dw 512 +SectorsPerTrack dw 18 +TotalHeads dw 2 +TotalSectors dd 2880 ; 1474560/512 for a 1.44meg disk + +;END BOOTSECTOR HEADER + +;BOOTSECTOR DATA +file_entry_nextdata equ 273 ; Offset in file_entry structure to the nextdata LBA pointer +data_entry_data equ 9 ; Offset in data_entry structure to the data +bootdrv db 0 + +;END BOOTSECTOR DATA + +start: +xor ax, ax +mov ds, ax +mov [bootdrv], dl + +; First get into protected mode +cli ;{0} +n5: in al, 0x64 ;Enable A20 {4A} {5} + test al, 2 + jnz n5 + mov al, 0xD1 + out 0x64, al +n6: in al, 0x64 + test al, 2 + jnz n6 + mov al, 0xDF + out 0x60, al + lgdt [gdtinfo] ;Load GDT + mov ecx, CR0 ;Switch to protected mode + inc cx + mov CR0, ecx + + mov ax, flat_data-gdt_table ; Selector for 4Gb data seg + mov ds, ax ; {2} Extend limit for ds + mov es, ax ; Extend limit for es + mov fs, ax ; fs and... + mov gs, ax ; gs + dec cx ; switch back to real mode + mov CR0, ecx + + sti + + xor eax, eax + mov ds, ax + + mov dl, [bootdrv] ; Store the boot drive + mov ax, 1 ; sector number + + mov cx, KERNEL_SIZE / 512; total sectors + mov ebx, LOAD_ADDR ; destination in memory + call load + mov cx, RDSK_SIZE / 512 + mov ebx, RDSK_ADDR + call load + jmp count_memory + +;************************************** +;* in: +;* eax: start sector +;* ebx: start of destination buffer +;* cx: number of sectors +;* dl: disk drive +;* out: +;* ax: end sector +;* ebx: end of destination buffer +;* modifies: +;* bx, es, edi, esi, ecx +;************************************** + +load: + mov si, BUFFER_ADDR >> 4 + mov es, si + mov di, 1 +load_loop: + push ebx + call read_sectors + pop ebx + + push cx + push di + push es + + xor cx, cx + mov es, cx + movzx ecx, word [BytesPerSector] + mov edi, ebx + add ebx, ecx + mov esi, BUFFER_ADDR + a32 rep movsb + + pop es + pop di + pop cx + + ;mov bx, es + ;add bx, 32 + ;mov es, bx + + inc ax + loop load_loop + ret + +count_memory: + ; Turn off the floppy motor, its annoying leaving it on ! + mov edx,0x3f2 + mov al,0x0c + out dx,al + ; set, restore and test a byte at each 1 Mb boundary + ; the end is reached when byte read != byte written + mov edi,0 +.start: + mov al,byte [es:edi] + mov byte [es:edi],0aah + mov ah,byte [es:edi] + mov byte [es:edi],al + cmp ah,0aah + jne .finish + add edi,MEM_INCR + jmp .start + +.finish: + mov [memory_top],edi + +; Re-enter protected mode ! A20 is already enabled + cli ; No interrupts please at all + lgdt [gdtinfo] + mov ecx, cr0 + inc cx + mov cr0, ecx + mov ax, flat_data-gdt_table + mov fs, ax + mov gs, ax + mov ax, kernel_data-gdt_table + mov ds, ax + mov es, ax + mov ss, ax + + jmp dword (flat_code-gdt_table):pmode1 + +read_sectors: +; Input: +; EAX = LBN +; DI = sector count +; ES = segment +; Output: +; BL = low byte of ES +; EBX high half cleared +; DL = 0x80 +; EDX high half cleared +; ESI = 0 + + pusha + + cdq ;edx = 0 + movzx ebx, byte [SectorsPerTrack] + div ebx ;EAX=track ;EDX=sector-1 + mov cx, dx ;CL=sector-1 ;CH=0 + inc cx ; CL=Sector number + xor dx, dx + mov bl, [TotalHeads] + div ebx + + mov dh, dl ;Head + mov dl, [bootdrv] ;Drive 0 + xchg ch, al ;CH=Low 8 bits of cylinder number; AL=0 + shr ax, 2 ;AL[6:7]=High two bits of cylinder; AH=0 + or cl, al ;CX = Cylinder and sector + mov ax, di ;AX = Maximum sectors to xfer +retry: + mov ah, 2 ;Read + xor bx, bx + int 13h + jc retry + + popa + + ret + +[BITS 32] +pmode1: + + push dword 2 + popfd + + mov eax, dword[fs:memory_top] + mov ebx, KERNEL_SIZE + mov ecx, LOAD_ADDR + mov edx, RDSK_SIZE + mov esi, RDSK_ADDR + + ;jmp $ + jmp (kernel_code-gdt_table):0 + +gdtinfo: + +dw gdtlength +dd gdt_table + +;********* GDT TABLE +gdt_table: + +null_desc desc 0,0,0 +flat_code desc 0, 0xFFFFF, D_CODE + D_READ + D_BIG + D_BIG_LIM +flat_data desc 0, 0xFFFFF, D_DATA + D_WRITE + D_BIG + D_BIG_LIM +kernel_code desc LOAD_ADDR, 0xFFFFF, D_CODE + D_READ + D_BIG + D_BIG_LIM +kernel_data desc LOAD_ADDR, 0xFFFFF, D_DATA + D_WRITE + D_BIG + D_BIG_LIM + +gdtlength equ $ - gdt_table - 1 +;********* END GDT TABLE +memory_top: dd 0 + +times 510-($-$$) nop +dw 0xAA55 + +kernel_start: +incbin "kernel.bin" +kernel_end: +incbin "ramdisk.bin" +ramdisk_end: \ No newline at end of file diff --git a/mobius/src/boot/bootsect.raw.asm b/mobius/src/boot/bootsect.raw.asm new file mode 100644 index 0000000..f95fe27 --- /dev/null +++ b/mobius/src/boot/bootsect.raw.asm @@ -0,0 +1,329 @@ +; GazOS Operating System +; Copyright (C) 1999 Gareth Owen +; +; This program is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version 2 +; of the License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program; if not, write to the Free Software +; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +%include "gdtnasm.inc" +; GazOS bootsector by Gareth Owen + +%define ONE_MEG 0x100000 +%define MEM_INCR ONE_MEG +%define LOAD_ADDR ONE_MEG +%define RDSK_ADDR (ONE_MEG * 2) +%define BUFFER_ADDR 0x8000 +%define KERNEL_SIZE (kernel_end - kernel_start) +%define RDSK_SIZE (ramdisk_end - kernel_end) + +[ORG 0x7c00] +jmp start +nop + +;START BOOTSECTOR HEADER + +;id db 'GazFS' ; Filing System ID +;version dd 1h ; Filing System Version +;fs_start dd 52 ; LBA address for start of root dir + +BytesPerSector dw 512 +SectorsPerTrack dw 18 +TotalHeads dw 2 +TotalSectors dd 2880 ; 1474560/512 for a 1.44meg disk + +;END BOOTSECTOR HEADER + +;BOOTSECTOR DATA +file_entry_nextdata equ 273 ; Offset in file_entry structure to the nextdata LBA pointer +data_entry_data equ 9 ; Offset in data_entry structure to the data +bootdrv db 0 + +;END BOOTSECTOR DATA + +start: + xor ax, ax + mov ds, ax + + mov si, msg + call print + + mov [bootdrv], dl + +; First get into protected mode +cli ;{0} +n5: in al, 0x64 ;Enable A20 {4A} {5} + test al, 2 + jnz n5 + mov al, 0xD1 + out 0x64, al +n6: in al, 0x64 + test al, 2 + jnz n6 + mov al, 0xDF + out 0x60, al + lgdt [gdtinfo] ;Load GDT + mov ecx, CR0 ;Switch to protected mode + inc cx + mov CR0, ecx + + mov ax, flat_data-gdt_table ; Selector for 4Gb data seg + mov ds, ax ; {2} Extend limit for ds + mov es, ax ; Extend limit for es + mov fs, ax ; fs and... + mov gs, ax ; gs + dec cx ; switch back to real mode + mov CR0, ecx + + sti + + xor eax, eax + mov ds, ax + + mov dl, [bootdrv] ; Store the boot drive + mov ax, 1 ; sector number + + mov si, msg2 + call print + mov cx, KERNEL_SIZE / 512; total sectors + mov ebx, LOAD_ADDR ; destination in memory + call load + + mov si, msg3 + call print + mov cx, RDSK_SIZE / 512 + mov ebx, RDSK_ADDR + call load + jmp count_memory + +;************************************** +;* in: +;* eax: start sector +;* ebx: start of destination buffer +;* cx: number of sectors +;* dl: disk drive +;* out: +;* ax: end sector +;* ebx: end of destination buffer +;* modifies: +;* bx, es, edi, esi, ecx, bp +;************************************** + +load: + mov si, BUFFER_ADDR >> 4 + mov es, si + mov di, 1 + xor bp, bp + mov [sectors_total], cx +load_loop: + push ebx + call read_sectors + pop ebx + + push cx + push di + push es + + xor cx, cx + mov es, cx + movzx ecx, word [BytesPerSector] + mov edi, ebx + add ebx, ecx + mov esi, BUFFER_ADDR + a32 rep movsb + + pop es + pop di + pop cx + + ;mov bx, es + ;add bx, 32 + ;mov es, bx + + inc ax + + inc bp + + push ax + push bx + + mov ax, [sectors_total] + mov bx, 80 + div bx + xor ah, ah + cmp bp, ax + jle .1 + + xor bp, bp + push bp + + mov ax, 0efeh + xor bx, bx + int 10h + + pop bp + +.1: + pop bx + pop ax + + loop load_loop + ret + +count_memory: + ; Turn off the floppy motor, its annoying leaving it on ! + mov edx,0x3f2 + mov al,0x0c + out dx,al + ; set, restore and test a byte at each 1 Mb boundary + ; the end is reached when byte read != byte written + mov edi,0 +.start: + mov al,byte [es:edi] + mov byte [es:edi],0aah + mov ah,byte [es:edi] + mov byte [es:edi],al + cmp ah,0aah + jne .finish + add edi,MEM_INCR + jmp .start + +.finish: + mov [memory_top],edi + +; Re-enter protected mode ! A20 is already enabled + cli ; No interrupts please at all + lgdt [gdtinfo] + mov ecx, cr0 + inc cx + mov cr0, ecx + mov ax, flat_data-gdt_table + mov fs, ax + mov gs, ax + mov ax, kernel_data-gdt_table + mov ds, ax + mov es, ax + mov ss, ax + + jmp dword (flat_code-gdt_table):pmode1 + +read_sectors: +; Input: +; EAX = LBN +; DI = sector count +; ES = segment +; Output: +; BL = low byte of ES +; EBX high half cleared +; DL = 0x80 +; EDX high half cleared +; ESI = 0 + + pusha + + cdq ;edx = 0 + movzx ebx, byte [SectorsPerTrack] + div ebx ;EAX=track ;EDX=sector-1 + mov cx, dx ;CL=sector-1 ;CH=0 + inc cx ; CL=Sector number + xor dx, dx + mov bl, [TotalHeads] + div ebx + + mov dh, dl ;Head + mov dl, [bootdrv] ;Drive 0 + xchg ch, al ;CH=Low 8 bits of cylinder number; AL=0 + shr ax, 2 ;AL[6:7]=High two bits of cylinder; AH=0 + or cl, al ;CX = Cylinder and sector + mov ax, di ;AX = Maximum sectors to xfer +retry: + mov ah, 2 ;Read + xor bx, bx + int 13h + jc retry + + popa + + ret + +;************************************** +;* in: +;* si: address of message (NUL-terminated) +;* modifies: +;* nothing +;************************************** + +print: + push ax + push bx + mov ah, 0eh + xor bx, bx + +.1: + mov al, [si] + test al, al + jz .2 + int 10h + inc si + jmp .1 + +.2: + pop bx + pop ax + ret + +[BITS 32] +pmode1: + + push dword 2 + popfd + + mov eax, dword[fs:memory_top] + mov ebx, KERNEL_SIZE + mov ecx, LOAD_ADDR + mov edx, RDSK_SIZE + mov esi, RDSK_ADDR + + ;jmp $ + jmp (kernel_code-gdt_table):0 + +gdtinfo: + +dw gdtlength +dd gdt_table + +gdt_table: + +null_desc desc 0,0,0 +flat_code desc 0, 0xFFFFF, D_CODE + D_READ + D_BIG + D_BIG_LIM +flat_data desc 0, 0xFFFFF, D_DATA + D_WRITE + D_BIG + D_BIG_LIM +kernel_code desc LOAD_ADDR, 0xFFFFF, D_CODE + D_READ + D_BIG + D_BIG_LIM +kernel_data desc LOAD_ADDR, 0xFFFFF, D_DATA + D_WRITE + D_BIG + D_BIG_LIM + +gdtlength equ $ - gdt_table - 1 + +sectors_total: + dw 0 +msg: db "Starting The M�bius", 13, 10, 0 +msg2: db "kernel", 13, 10, 0 +msg3: db 13, 10, "ramdisk", 13, 10, 0 +memory_top: dd 0 + +times 510-($-$$) nop +dw 0xAA55 + +kernel_start: +incbin "kernel.bin" +kernel_end: +incbin "ramdisk.bin" +ramdisk_end: diff --git a/mobius/src/boot/gdtnasm.inc b/mobius/src/boot/gdtnasm.inc new file mode 100644 index 0000000..da5c127 --- /dev/null +++ b/mobius/src/boot/gdtnasm.inc @@ -0,0 +1,109 @@ +; gdtnasm.inc symbols and macros for building descriptors +; Version 1.0 March 5, 1998 +; Sample code +; by John S. Fine johnfine@erols.com +; I do not place any restrictions on your use of this source code +; I do not provide any warranty of the correctness of this source code +;_____________________________________________________________________________ +; +; This is a quick kludge to do in a single module program, some of the +; things that my gdt.inc does in a program linked with JLOC +;_____________________________________________________________________________ +; +; The desc macro pieces together a segment descriptor. +; +; desc offset, selector, flags ;For gate descriptors +; desc base, limit, flags ;For all other descriptors +; +; base is the full 32 bit base address of the segment +; limit is one less than the segment length in 1 or 4K byte units +; flags the sum of all the "D_" equates which apply (for call gates, you +; also add the "parameter dword count" to flags). +;_____________________________________________________________________________ + +;Each descriptor should have exactly one of next 8 codes to define the type of +;descriptor +D_LDT EQU 200h ;LDT segment +D_TASK EQU 500h ;Task gate +D_TSS EQU 900h ;TSS +D_CALL EQU 0C00h ;386 call gate +D_INT EQU 0E00h ;386 interrupt gate +D_TRAP EQU 0F00h ;386 trap gate +D_DATA EQU 1000h ;Data segment +D_CODE EQU 1800h ;Code segment + +;Descriptors may include the following as appropriate: +D_DPL3 EQU 6000h ;DPL3 or mask for DPL +D_DPL2 EQU 4000h +D_DPL1 EQU 2000h +D_PRESENT EQU 8000h ;Present +D_NOT_PRESENT EQU 8000h ;Not Present + ;Note, the PRESENT bit is set by default + ;Include NOT_PRESENT to turn it off + ;Do not specify D_PRESENT + +;Segment descriptors (not gates) may include: +D_ACC EQU 100h ;Accessed (Data or Code) + +D_WRITE EQU 200h ;Writable (Data segments only) +D_READ EQU 200h ;Readable (Code segments only) +D_BUSY EQU 200h ;Busy (TSS only) + +D_EXDOWN EQU 400h ;Expand down (Data segments only) +D_CONFORM EQU 400h ;Conforming (Code segments only) + +D_BIG EQU 40h ;Default to 32 bit mode (USE32) +D_BIG_LIM EQU 80h ;Limit is in 4K units + +%define work_around_nasm_prepend_bug + +%macro desc 3 +work_around_nasm_prepend_bug +%if (%3) & (~(%3)>>2) & 0x400 ;Gate + dw %1 + dw %2 + dw (%3)+D_PRESENT + dw (%1) >> 16 +%else ;Not a gate + dw %2 + dw %1 + db (%1) >> 16 + db ((%3)+D_PRESENT) >> 8 + db (%3) + ((%2) >> 16) + db (%1) >> 24 +%endif +%endmacro + +;----------------------------------------------------------------------------- +; +; A gate is identified as any descriptor whose flags has bit 10 set and +; bit 12 clear. +; +; For a gate, the following rearrangement occurs: +; +; subField Final location +; ------------------ -------------- +; Selector[0..15] 16..31 +; Minor control bits 32..39 +; Major control bits 40..47 +; Offset[0..15] 0..15 +; Offset[16..31] 48..63 +; +; For non-gates the following rearrangement occurs: +; +; subField Final location +; ------------------ -------------- +; Limit[0..15] 0..15 +; Limit[16..19] 48..51 +; Minor control bits 52..57 +; Major control bits 40..47 +; Base[0..23] 16..39 +; Base[24..31] 56..63 +; +; The last parameter to the desc macro contains all the control bits +; combined. It is generated by adding together the appropriate +; D_ constants. For all descriptors, it has the major control bits in D_ +; bits 8 to 15. The minor control bits are in either D_ bits 0 to 7 or bits +; 4 to 7 depending on the type of descriptor. +;_____________________________________________________________________________ + diff --git a/mobius/src/boot/minifs.asm b/mobius/src/boot/minifs.asm new file mode 100644 index 0000000..f8b3e67 --- /dev/null +++ b/mobius/src/boot/minifs.asm @@ -0,0 +1,441 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Project: Second Stage Bootloader ;; +;; Module: minifs.asm ;; +;; Date: 02-21-2000 ;; +;; Purpose: This module contains the portion of the bootstrap that handles ;; +;; filesystem input and ouput in order to load the kernel. ;; +;; ;; +;; Created by Ben L. Titzer ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;fs_name db 'VFAT',0 ; name of filesystem we are using +;fs_hname db 'VFAT RFS' ; name of secondary manager to load + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; B O O T S E C T O R ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +bootsect db 0,0,0 + +bsOEM db "ok ok ok" ; OEM String +bsSectSize dw 512 ; Bytes per sector +bsClustSize db 1 ; Sectors per cluster +bsRessect dw 1 ; # of reserved sectors +bsFatCnt db 2 ; # of fat copies +bsRootSize dw 224 ; size of root directory +bsTotalSect dw 2880 ; total # of sectors if < 32 meg +bsMedia db 0xF0 ; Media Descriptor +bsFatSize dw 9 ; Size of each FAT +bsTrackSect dw 18 ; Sectors per track +bsHeadCnt dw 2 ; number of read-write heads +bsHidenSect dd 0 ; number of hidden sectors +bsHugeSect dd 0 ; if bsTotalSect is 0 this value is + ; the number of sectors +bsBootDrv db 0 ; holds drive that the bs came from +bsReserv db 0 ; not used for anything +bsBootSign db 29h ; boot signature 29h +bsVolID dd 0 ; Disk volume ID also used for temp + ; sector # / # sectors to load +bsVoLabel db " " ; Volume Label +bsFSType db "FAT12 " ; File System type + +bs_padding times 512-($-bootsect) db 0 ; padding + +root_strt dw 0 ; start of root directory +root_scts dw 0 ; num sectors of root directory +file_strt dw 0 ; start of file +file_scts dw 0 ; num sectors of file +tmpname dw 0 ; temporary name of file to load + +debug db ' - ',0 +dot db '.',0 +xstr db 'x',0 +rsfail db 'readsect failed!',0 +fsinitfail db 'intiatilization failed!',0 + + +;============================================================================; + +fs_init: ; initialize filesystem + + push ds + mov dl,[boot_drv] ; reset controller + xor ax,ax + int 0x13 + pop ds + jc fs_init_fail ; failed to initialize device + + xor ax,ax ; find start of root directory + mov al,[bsFatCnt] ; skip any FATs + mov bx,[bsFatSize] + mul bx ; have to multiply by FAT size + add ax,word [bsHidenSect] ; add any hidden sectors + adc ax,word [bsHidenSect+2] + add ax,word [bsRessect] ; add any reserved sectors + mov word [root_strt],ax ; store sector # of root directory + + mov ax,32 ; find size in sectors of root dir + mul word [bsRootSize] ; ((32*RootSize)/512) + 2 + div word [bsSectSize] + mov word [root_scts],ax ; store number of sectors in root dir + + xor ax, ax ; we have to load sector 0 + mov bx, ds + mov es, bx + mov bx, bootsect + call fs_readsect ; read sector 0, bootsector + cmp al, FS_OK ; did it work? + jne fs_init_fail ; nope, report error + + mov al, FS_OK ; signal success + ret ; return to caller + +fs_init_fail: + mov al, FS_ERROR ; signal that it didn't work + ret + +;============================================================================; + +fs_loadfail1: + mov ax, FS_ERROR + ret + +fs_loadfile: ; load file name with name at ds:si into ebx ; es:di + + call fs_rootfind ; try to find the file in root dir + cmp ax, FS_OK ; if it is 0, then not found + jne fs_loadfail1 ; failed to locate file + + xor eax,eax + add ax,word [root_scts] + add ax,word [file_strt] ; sector number + add ax,word [root_strt] + sub ax,2 ; correction for a mis-calc + mov cx,word [file_scts] ; number of sectors + mov dl,[boot_drv] + + push es + push edi + push esi + push bp + call load + pop bp + pop esi + pop edi + pop es + + mov ax, FS_OK + ret + +sectors_total: dw 0 + +;************************************** +;* in: +;* eax: start sector +;* ebx: start of destination buffer +;* cx: number of sectors +;* dl: disk drive +;* out: +;* ax: end sector +;* ebx: end of destination buffer +;* modifies: +;* bx, es, edi, esi, ecx, bp +;************************************** + +load: + mov si, BUFFER_ADDR >> 4 + mov es, si + mov di, 1 + xor bp, bp + mov [sectors_total], cx + +load_loop: + push ebx + call read_sectors + pop ebx + + push cx + push di + push es + push ds + + xor ecx, ecx + mov es, cx + mov ds, cx + ;movzx ecx, word [bsSectSize] + mov ecx, 512 + mov edi, ebx + add ebx, ecx + mov esi, BUFFER_ADDR + + ;cli + ;hlt + + a32 rep movsb + + pop ds + pop es + pop di + pop cx + + ;mov bx, es + ;add bx, 32 + ;mov es, bx + + inc ax + + inc bp + + push ax + push bx + + mov ax, [sectors_total] + mov bx, 80 + div bx + xor ah, ah + cmp bp, ax + jle .1 + + ;push bp + + mov ax, 0efeh + xor bx, bx + int 10h + + ;pop bp + xor bp, bp + +.1: + pop bx + pop ax + + loop load_loop + ret + +%if 0 + +loadloop: + push ax ; save registers + push cx + push dx + push es + push di ; save this offset + + mov bx,di ; use offset we were given + call fs_readsect ; read a sector + mov [temp], ax + + pop di + pop es ; restore registers + pop dx + pop cx + pop ax + + mov ax, [temp] + or ax, ax + jnz fs_loadfail + + push ax + push bx + mov ax, 0e00h | '.' + xor bx, bx + int 10h + ;mov si, dot + ;call putstr + pop bx + pop ax + + mov bx,es + add bx,20h ; increment address 512 bytes + mov es,bx + inc ax ; read next sector + loopnz loadloop ; loop until cx is zero + + mov ax, FS_OK + ret + +%endif + +fs_loadfail: + mov ax, FS_ERROR + ret + +;============================================================================; + +fs_rootfind: ; searches for file in root directory + push bx + push cx + push dx + push si + push di + + mov ax, [root_strt] ; start of root directory + mov cx, [root_scts] ; number of sectors in root dir + dec cx ; don't check the junk sector + xor dx, dx + mov [tmpname], si ; filename to search for + +checksect: + + mov bx, sectorbuf ; load shit into sector buffer + push cx ; save count + push ax ; save sector number + push es + push dx + call fs_readsect ; read the root sector + cmp ax, FS_OK + jne fs_loadfail + mov bx, sectorbuf ; use stuff in sector buffer + +checkentry: + mov di,bx ; set address to check from + mov cx,11 ; check 11 bytes + mov si,[tmpname] ; address of string to check with + repz cmpsb ; check string against filename + je foundit ; if equal, we found it + add bx,32 ; otherwise, check next entry + cmp bx,sectorbuf_end ; end of sector? + jl checkentry ; if not end, continue + + pop dx ; restore registers + pop es + pop ax + pop cx + inc ax ; check next sector when we loop again + loopnz checksect ; loop until end of root sectors + jmp notfound ; couldn't find it: die + +foundit: + pop dx ; get these off the stack + pop es + pop ax + pop cx + + mov di,0x1A ; get clustor # + add di,bx + push bx ; save bx for finding # of sectors + mov ax,[es:di] + xor bx,bx ; calculate sector # + mov bl,[bsClustSize] + mul bx ; ax holds sector # + mov word [file_strt],ax + + pop bx ; get location of directory entry + mov di,0x1C + add di,bx + mov eax, [es:di] ; put number of bytes in ax + ;xor edx, edx + ;xor ebx, ebx + ;mov bx, word [bsSectSize] ; # of bytes / 512 + ;div ebx + shr eax, 9 + inc ax + mov word [file_scts],ax ; save number of sectors to load + + pop di ; restore registers + pop si + pop dx + pop cx + pop bx + + mov ax, FS_OK ; we good + ret ; return to caller + +notfound: + pop di ; restore registers + pop si + pop dx + pop cx + pop bx + mov ax, FS_ERROR ; didn't find it + ret + +read_sectors: +; Input: +; EAX = LBN +; DI = sector count +; ES = segment +; Output: +; BL = low byte of ES +; EBX high half cleared +; DL = 0x80 +; EDX high half cleared +; ESI = 0 + + pusha + + cdq ;edx = 0 + movzx ebx, byte [bsTrackSect] + div ebx ;EAX=track ;EDX=sector-1 + mov cx, dx ;CL=sector-1 ;CH=0 + inc cx ; CL=Sector number + xor dx, dx + mov bl, [bsHeadCnt] + div ebx + + mov dh, dl ;Head + mov dl, [boot_drv] ;Drive 0 + xchg ch, al ;CH=Low 8 bits of cylinder number; AL=0 + shr ax, 2 ;AL[6:7]=High two bits of cylinder; AH=0 + or cl, al ;CX = Cylinder and sector + mov ax, di ;AX = Maximum sectors to xfer +.retry: + mov ah, 2 ;Read + xor bx, bx + int 13h + jc .retry + + popa + + ret + +;============================================================================; + +rs_fails: db 0 + +fs_readsect: ; ES:BX = Location ; AX = Sector + + mov [rs_fails], word 0 ; start with 0 failures + +fs_readsect2: + push ax ; save sector + + mov si,[bsTrackSect] + div si ; divide logical sect by track size + inc dl ; sector # begins at 1 + mov [bsReserv],dl ; sector to read + xor dx,dx ; logical track left in ax + div word [bsHeadCnt] ; leaves head in dl, cyl in ax + mov dh, [boot_drv] ; + xchg dl,dh ; head to dh, drive to dl + mov cx,ax ; cyl to cx + xchg cl,ch ; low 8 bits of cyl to ch, hi 2 bits + shl cl,6 ; shifted to bits 6 and 7 + or cl, byte [bsReserv] ; or with sector number + mov al,1 ; number of sectors + + mov ah,2 ; use read function of int 0x13 + int 0x13 ; read sector + jc readfail ; error + pop ax + mov ax, FS_OK ; success + ret ; return to caller + +readfail: + inc byte [rs_fails] ; increment number of failures + cmp byte [rs_fails], 10 ; 4th try? + je readfail3 ; if so, give up + + mov dl,[boot_drv] ; reset controller + xor ax,ax + int 0x13 + + pop ax ; restore sector number + jmp fs_readsect2 ; retry + +readfail3: + pop ax ; fix stack + mov ax, FS_ERROR ; signal an error + ret ; return + +;============================================================================; diff --git a/mobius/src/boot/mobel.asm b/mobius/src/boot/mobel.asm new file mode 100644 index 0000000..2e93cfd --- /dev/null +++ b/mobius/src/boot/mobel.asm @@ -0,0 +1,355 @@ +[bits 16] +[org 100h] +[section .text] + +%include "gdtnasm.inc" + +%define ONE_MEG 0x100000 +%define MEM_INCR ONE_MEG +%define LOAD_ADDR ONE_MEG +%define RDSK_ADDR (ONE_MEG * 2) +%define BUFFER_ADDR 0xfe00 ;0x20000 + +%define FS_OK 1 +%define FS_ERROR 0 + +start: + mov si, msg_loader + call print + + mov [boot_drv], dl + + + ;****************************************************** + ; Switch to "flat-real" mode + ;****************************************************** + + cli +n5: in al, 0x64 ; Enable A20 gate + test al, 2 + jnz n5 + mov al, 0xD1 + out 0x64, al +n6: in al, 0x64 + test al, 2 + jnz n6 + mov al, 0xDF + out 0x60, al + + xor eax, eax + mov ax, cs ; get code segment + shl eax, 4 ; convert segment -> linear + add [gdtinfo+2], eax ; do the fixups + add [loader_code+2], eax + add [loader_data+2], eax + + lgdt [gdtinfo] ; Load GDTR + mov ecx, CR0 ; Set CR0.PE + inc cx + mov CR0, ecx + + mov ax, flat_data - gdt ; Selector for 4Gb data seg + mov ds, ax ; Extend limit for ds + mov es, ax ; Extend limit for es + mov fs, ax ; fs and... + mov gs, ax ; gs + dec cx ; switch back to real mode + mov CR0, ecx + sti + + mov ax, cs + mov ds, ax + + + ;****************************************************** + ; Count installed memory + ;****************************************************** + + mov si, msg_memory + call print + +count_memory: + ; set, restore and test a byte at each 1 Mb boundary + ; the end is reached when byte read != byte written + xor edi, edi +.start: + mov al, byte [es:edi] ; Save the byte + mov byte [es:edi], 0aah ; Write a new one (0AAh) + mov ah, byte [es:edi] ; Read it back + mov byte [es:edi],al ; Restore the old one + cmp ah, 0aah ; Check the byte... + jne .finish ; ...if it's different, stop + + mov al, byte [es:edi] ; Repeat for 55h + mov byte [es:edi], 55h + mov ah, byte [es:edi] + mov byte [es:edi],al + cmp ah, 55h + jne .finish + + add edi,MEM_INCR ; Skip to the next chunk + jmp .start + +.finish: + mov [memory_top],edi ; edi contains failed address + + mov eax, edi ; Remind the user how much memory they have + shr eax, 20 + call print_int + mov si, msg_memory.mb + call print + jmp load_kernel + +load_fail: ; Generic failure proc used during loading + mov si, msg_failed + call print + jmp $ + + ;****************************************************** + ; Load the kernel into extended memory + ;****************************************************** + +load_kernel: + mov si, msg_fs_init + call print + + call fs_init ; Initialize the file system + + test al, al + jz load_fail + mov si, msg_done + call print + + mov si, msg_loading_kernel + call print + + mov ebx, LOAD_ADDR ; Load to LOAD_ADDR + mov si, kernel_name + + call fs_loadfile ; Load the kernel + + test al, al + jz load_fail + + xor eax, eax ; Get the size of the kernel in sectors + mov ax, [file_scts] + shl eax, 9 + mov [kernel_size], eax ; Store the size of the kernel + call print_int + mov si, msg_done + call print + +;%if 0 + mov si, msg_loading_ramdisk + call print + + mov ebx, RDSK_ADDR ; Load to RDSK_ADDR + mov si, ramdisk_name + + call fs_loadfile ; Load the ramdisk + + test al, al + jz load_fail + + xor eax, eax ; Get the size of the ramdisk in sectors + mov ax, [file_scts] + shl eax, 9 + mov [rdsk_size], eax ; Store the size of the ramdisk + call print_int + mov si, msg_done + call print +;%endif + + mov dx, 0x3f2 ; Turn off the floppy motor + mov al, 0x0c + out dx, al + + ;****************************************************** + ; Enable full protected mode + ;****************************************************** + + ; Interrupts make this thing go *bang* from now on + + cli + + mov ecx, cr0 + inc cx ; Set CR0.PE for the last time... + mov cr0, ecx + mov ax, loader_data - gdt + mov fs, ax ; fs = loader data + mov ax, flat_data - gdt + mov gs, ax ; gs = linear data + mov ax, kernel_data - gdt + mov ds, ax ; ds = es = ss = kernel data + mov es, ax + mov ss, ax + + ; Reload CS to complete the move to protected mode + jmp dword (loader_code-gdt):pmode1 + +%include "minifs.asm" ; File system procedures (currently FAT12) + +;********************************************************** +;* print: print a string using the BIOS +;* +;* in: +;* si: address of message (NUL-terminated) +;* modifies: +;* nothing +;********************************************************** + +print: + push ax ; Save some registers + push bx + ; INT 10/0Eh has been known to use BP, but we don't need it + + mov ah, 0eh + xor bx, bx ; Page 0 + +.1: + mov al, [si] ; Load a byte... + test al, al ; ...stop on NUL + jz .2 + int 10h ; Write it + inc si + jmp .1 + +.2: + pop bx + pop ax + ret + +;********************************************************** +;* print_int: print a 32-bit number in decimal using the BIOS +;* +;* in: +;* eax: number to be printed +;* modifies: +;* nothing +;********************************************************** + +print_int: + push ebx ; save registers + push ecx + push edx + push esi + push edi + + + mov esi, 0 ; don't print leading zeroes + mov ebx, 1000000000 + mov ecx, eax ; store a copy of ax + + +.pipm: + cmp ebx, 1 ; if we are on last digit + jne .cnpm + mov esi, 1 ; make sure we print it (even if zero) +.cnpm: + mov eax, ecx ; get current num + xor edx, edx ; clear dx + div ebx ; divide by decimal + mov ecx, edx ; save remainder + or esi, eax ; if si and ax are zero, it's a leading zero + jz .lz ; leading zero + + push ebx + xor bx, bx + add al, '0' + mov ah, 0eh + int 10h + pop ebx + +.lz: + mov eax, ebx ; we have to reduce the radix too + xor edx, edx ; clear dx + mov ebx, 10 ; use 10 as new divider + div ebx ; divide + mov ebx, eax ; save result + or ebx, ebx ; if zero, we're done + jnz .pipm + + pop edi ; restore registers + pop esi + pop edx + pop ecx + pop ebx + + ret + + + +[bits 32] + + ;****************************************************** + ; Protected-mode code + ;****************************************************** + + +pmode1: + push dword 2 ; clear EFLAGS apart from bit 1 + popfd + +%if 1 + mov al, byte [ds:0xe6a] + mov byte [gs:0b8000h], al + mov al, byte [ds:0xe6c] + mov byte [gs:0b8002h], al + mov al, byte [ds:0xe6e] + mov byte [gs:0b8004h], al + mov al, byte [ds:0xe70] + mov byte [gs:0b8006h], al +%endif + + ; Set up the kernel's entry variables + mov eax, dword [fs:memory_top] + mov ebx, dword [fs:kernel_size] + mov ecx, LOAD_ADDR + mov edx, dword [fs:rdsk_size] + mov esi, RDSK_ADDR + + ; Start the kernel! + jmp (kernel_code-gdt):0 + ;jmp $ + + +[section .data] +gdtinfo: dw gdtlength + dd gdt + +gdt: + +null_desc desc 0,0,0 +loader_code desc 0, 0xFFFF, D_CODE + D_READ + D_BIG + D_BIG_LIM +loader_data desc 0, 0xFFFF, D_DATA + D_WRITE + D_BIG + D_BIG_LIM +kernel_code desc LOAD_ADDR, 0xFFFFF, D_CODE + D_READ + D_BIG + D_BIG_LIM +kernel_data desc LOAD_ADDR, 0xFFFFF, D_DATA + D_WRITE + D_BIG + D_BIG_LIM +flat_code desc 0, 0xFFFFF, D_CODE + D_READ + D_BIG + D_BIG_LIM +flat_data desc 0, 0xFFFFF, D_DATA + D_WRITE + D_BIG + D_BIG_LIM + +gdtlength equ $ - gdt - 1 + +msg_loader: db 13, 10, "Starting The M�bius...", 13, 10, 0 +msg_memory: db "System memory: ", 0 +.mb: db "MB", 13, 10, 0 +msg_fs_init: + db "Starting file system", 0 +msg_done: db " OK", 13, 10, 0 +msg_failed: db " failed", 13, 10, 0 +msg_loading_kernel: + db "Loading the kernel ", 0 +msg_loading_ramdisk: + db "Loading the ramdisk ", 0 + +kernel_name: + db "KERNEL BIN", 0 +ramdisk_name: + db "RAMDISK BIN", 0 + +boot_drv: db 0 +memory_top: dd 0 +kernel_size:dd 0 +rdsk_size: dd 0 + +sectorbuf: times 512 db 0 +sectorbuf_end: \ No newline at end of file diff --git a/mobius/src/boot/mobel.d b/mobius/src/boot/mobel.d new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/mobius/src/boot/mobel.d diff --git a/mobius/src/boot/mobel_pe.asm b/mobius/src/boot/mobel_pe.asm new file mode 100644 index 0000000..ea7db44 --- /dev/null +++ b/mobius/src/boot/mobel_pe.asm @@ -0,0 +1,85 @@ + .286 + ifndef ??version +?debug macro + endm +$comm macro name,dist,size,count + comm dist name:BYTE:count*size + endm + else +$comm macro name,dist,size,count + comm dist name[size]:BYTE:count + endm + endif + ?debug S "mobel_pe.c" + ?debug C E94A75092B0A6D6F62656C5F70652E63 +_TEXT segment byte public 'CODE' +_TEXT ends +DGROUP group _DATA,_BSS + assume cs:_TEXT,ds:DGROUP +_DATA segment word public 'DATA' +d@ label byte +d@w label word +_DATA ends +_BSS segment word public 'BSS' +b@ label byte +b@w label word +_BSS ends +_DATA segment word public 'DATA' + db 72 + db 101 + db 108 + db 108 + db 111 + db 44 + db 32 + db 119 + db 111 + db 114 + db 108 + db 100 + db 33 + db 0 +_DATA ends +_TEXT segment byte public 'CODE' + assume cs:_TEXT +_main proc near + enter 14,0 + push ss + lea ax,word ptr [bp-14] + push ax + push ds + push offset DGROUP:d@+0 + mov cx,14 + call near ptr N_SCOPY@ + mov ax, 1301h + mov bx, 0007h + mov cx, sizeof([bp-14]) + mov dx, 0 + mov bp, offset [bp-14] +@1@170: + jmp short @1@170 + leave + ret +_main endp +_TEXT ends +_BSS segment word public 'BSS' +__ext_mem_size label word + db 4 dup (?) +__got_32bit_cpu label byte + db 1 dup (?) + db 1 dup (?) +__conv_mem_size label word + db 4 dup (?) + ?debug C E9 +_BSS ends +_DATA segment word public 'DATA' +s@ label byte +_DATA ends +_TEXT segment byte public 'CODE' +_TEXT ends + public __conv_mem_size + public __got_32bit_cpu + public _main + extrn N_SCOPY@:far + public __ext_mem_size + end diff --git a/mobius/src/cat/Makefile b/mobius/src/cat/Makefile new file mode 100644 index 0000000..7264e0b --- /dev/null +++ b/mobius/src/cat/Makefile @@ -0,0 +1,10 @@ +include ../make.actions + +TARGET= $(BIN)/cat.exe +OBJS= cat.o ../crt0.o +LIBS= $(LIB)/kernelu.lib $(LIB)/libc.lib + +all: $(TARGET) + +$(TARGET): $(OBJS) + ld -o $(TARGET) $(OBJS) $(LIBS) \ No newline at end of file diff --git a/mobius/src/cat/cat.c b/mobius/src/cat/cat.c new file mode 100644 index 0000000..df3acbb --- /dev/null +++ b/mobius/src/cat/cat.c @@ -0,0 +1,38 @@ +#define INITGUID +#include +#include + +int main(int argc, char** argv) +{ + IStream* file; + char buf[1024]; + size_t read, i; + bool is_tty; + folderitem_t stat; + + file = (IStream*) fsOpen(procCmdLine(), &IID_IStream); + if (!file) + { + wprintf(L"%s: failed to open\n", procCmdLine()); + return 1; + } + + stat.size = sizeof(stat); + is_tty = FAILED(IStream_Stat(file, &stat)) || + (stat.attributes & ATTR_DEVICE); + if (is_tty) + _cputws(L"It's a character device\n"); + else + _cputws(L"It's a file\n"); + + do + { + read = IStream_Read(file, buf, is_tty ? 1 : sizeof(buf)); + for (i = 0; i < read; i++) + putwchar(buf[i]); + } while (read); + + putwchar('\n'); + IUnknown_Release(file); + return 0; +} \ No newline at end of file diff --git a/mobius/src/cat/cat.dsp b/mobius/src/cat/cat.dsp new file mode 100644 index 0000000..f8c21a2 --- /dev/null +++ b/mobius/src/cat/cat.dsp @@ -0,0 +1,91 @@ +# Microsoft Developer Studio Project File - Name="cat" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=cat - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "cat.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "cat.mak" CFG="cat - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "cat - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "cat - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "cat - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\..\bin" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "__MOBIUS__" /YX /FD /c +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 ..\crt0.obj /nologo /base:"0x40000000" /subsystem:console /machine:I386 /nodefaultlib +# SUBTRACT LINK32 /incremental:yes + +!ELSEIF "$(CFG)" == "cat - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\..\bin" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "__MOBIUS__" /YX /FD /c +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ..\crt0.obj /nologo /base:"0x40000000" /subsystem:console /incremental:no /debug /machine:I386 /nodefaultlib /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "cat - Win32 Release" +# Name "cat - Win32 Debug" +# Begin Source File + +SOURCE=.\cat.c +# End Source File +# End Target +# End Project diff --git a/mobius/src/cat/cat.plg b/mobius/src/cat/cat.plg new file mode 100644 index 0000000..7ee732f --- /dev/null +++ b/mobius/src/cat/cat.plg @@ -0,0 +1,29 @@ +--------------------Configuration: cat - Win32 Debug-------------------- +Begining build with project "F:\Projects\mobius\src\cat\cat.dsp", at root. +Active configuration is Win32 (x86) Console Application (based on Win32 (x86) Console Application) + +Project's tools are: + "32-bit C/C++ Compiler for 80x86" with flags "/nologo /MLd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "__MOBIUS__" /Fp"Debug/cat.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /c " + "Win32 Resource Compiler" with flags "/l 0x809 /d "_DEBUG" " + "Browser Database Maker" with flags "/nologo /o"cat.bsc" " + "COFF Linker for 80x86" with flags "..\crt0.obj /nologo /base:"0x40000000" /subsystem:console /incremental:no /pdb:"cat.pdb" /debug /machine:I386 /nodefaultlib /out:"cat.exe" /pdbtype:sept " + "Custom Build" with flags "" + "" with flags "" + +Creating temp file "D:\DOCUME~1\TIMROB~1\LOCALS~1\Temp\RSP303.tmp" with contents +Creating command line "cl.exe @D:\DOCUME~1\TIMROB~1\LOCALS~1\Temp\RSP303.tmp" +Creating temp file "D:\DOCUME~1\TIMROB~1\LOCALS~1\Temp\RSP304.tmp" with contents <..\crt0.obj /nologo /base:"0x40000000" /subsystem:console /incremental:no /pdb:"cat.pdb" /debug /machine:I386 /nodefaultlib /out:"cat.exe" /pdbtype:sept +.\Debug\cat.obj +\Projects\mobius\src\ifproxy\ifproxy.lib +\Projects\mobius\src\kernelu\kernelu.lib +\Projects\mobius\src\libc\libc.lib> +Creating command line "link.exe @D:\DOCUME~1\TIMROB~1\LOCALS~1\Temp\RSP304.tmp" +Compiling... +cat.c +Linking... + + + +cat.exe - 0 error(s), 0 warning(s) diff --git a/mobius/src/console/Makefile b/mobius/src/console/Makefile new file mode 100644 index 0000000..bae9057 --- /dev/null +++ b/mobius/src/console/Makefile @@ -0,0 +1,12 @@ +include ../make.actions + +TARGET= $(BIN)/console.exe +OBJS= console.o +LIBS= $(LIB)/libc.lib $(LIB)/kernelu.lib + +all: $(TARGET) + +$(TARGET): $(OBJS) $(LIBS) + ld -o $(TARGET) --subsystem native --image-base 0x40000000 \ + $(OBJS) \ + $(LIBS) \ No newline at end of file diff --git a/mobius/src/console/console.c b/mobius/src/console/console.c new file mode 100644 index 0000000..c40dc49 --- /dev/null +++ b/mobius/src/console/console.c @@ -0,0 +1,683 @@ +/*! + * \ingroup programs + * \defgroup console Console server + * + * Console server for The M�bius + * + * - Sets up a server port (named CONSOLE_PORT = L"console") and waits for + * connections. + * - Starts a new thread for each connection and creates an + * on-screen console. + * - Receives characters over the connection and displays them on the console. + * - Sends any keys pressed over the connection. + * - Allows switching between consoles (via Ctrl+Tab/Ctrl+Shift+Tab) and + * closing of consoles (via Ctrl+F4). + * + * Most console I/O for programs is handled by kernelu.dll. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//@{ + +//! Colours to be used for console title bars +#define CON_TITLE_COLOUR 0x1700 +//! Colours to be used for the buttons on console title bars +#define CON_BUTTON_COLOUR 0x7900 + +//! The text-mode VGA device +addr_t vgatext; + +typedef struct console_t console_t; + +//! Describes a console +/*! + * The console server maintains one console_t structure for each connection + * to its server port. + */ +struct console_t +{ + //! Connection to the client program + addr_t port; + //! Base address of the console's video buffer, relative to the start + //! of video memory + addr_t base; + //! Location of the text cursor + unsigned x, y; + //! Attributes (colour/intensity) currently selected for new text + word attrib; + //! Variables describing the state of the escape sequence parser + int esc, esc1, esc2, esc3; + //! Width and height of the console + short width, height; + //! Console's title + wchar_t* title; +}; + +//! Number of consoles currently allocated +int num_consoles; +console_t *consoles[8], *con_current; +int mouse_x, mouse_y; + +void conWriteToScreen(console_t* con, word* buf, size_t length) +{ + request_t dreq; + + dreq.code = DEV_WRITE; + dreq.params.write.length = length; + dreq.params.write.buffer = buf; + dreq.params.write.pos = con->base + (con->width * (con->y + 1) + con->x) * 2; + con->x += length / sizeof(word); + if (devUserRequest(vgatext, &dreq, sizeof(dreq))) + thrWaitHandle(&dreq.event, 1, true); + + devUserFinishRequest(&dreq, true); +} + +void conDrawMouse(bool draw) +{ + request_t dreq; + word w = 0x1234; + + dreq.code = DEV_WRITE; + dreq.params.write.length = sizeof(w); + dreq.params.write.buffer = &w; + dreq.params.write.pos = con_current->base + + (con_current->width * mouse_y + mouse_x) * 2; + if (devUserRequest(vgatext, &dreq, sizeof(dreq))) + thrWaitHandle(&dreq.event, 1, true); + + devUserFinishRequest(&dreq, true); +} + +void conWriteTitle(console_t* con) +{ + request_t dreq; + word* buf; + int i; + const wchar_t* ch; + char n[2]; + int index; + + index = -1; + for (i = 0; i < num_consoles; i++) + if (consoles[i] == con) + { + index = i; + break; + } + + buf = malloc(con->width * sizeof(word)); + for (i = 0; i < con->width; i++) + buf[i] = CON_TITLE_COLOUR | 0x20; + + i = 1; + for (ch = L"Ctrl+F1=Help"; *ch && i < con->width; ch++, i++) + { + wcstombs(n, ch, 1); + buf[i] = CON_TITLE_COLOUR | (byte) n[0]; + } + + i = (con->width - wcslen(con->title)) / 2; + if (i < 0) + i = 0; + + if (index > 0) + buf[max(i - 2, 0)] = CON_TITLE_COLOUR | 27; + + for (ch = con->title; *ch && i < con->width; ch++, i++) + { + wcstombs(n, ch, 1); + buf[i] = CON_TITLE_COLOUR | (byte) n[0]; + } + + if (index > -1 && + index < num_consoles - 1) + buf[min(i + 1, con->width - 1)] = CON_TITLE_COLOUR | 26; + + buf[con->width - 1] = CON_BUTTON_COLOUR | 0xFE; + + dreq.code = DEV_WRITE; + dreq.params.write.length = con->width * sizeof(word); + dreq.params.write.buffer = buf; + dreq.params.write.pos = con->base; + if (devUserRequest(vgatext, &dreq, sizeof(dreq))) + thrWaitHandle(&dreq.event, 1, true); + + devUserFinishRequest(&dreq, true); + free(buf); +} + +void conClear(console_t* con) +{ + word *buf; + int i; + + buf = malloc(sizeof(word) * con->width * con->height); + for (i = 0; i < con->width * con->height; i++) + buf[i] = con->attrib | 0x20; + + con->x = con->y = 0; + conWriteToScreen(con, buf, sizeof(word) * con->width * con->height); + con->x = con->y = 0; + free(buf); +} + +void conSetAttrib(console_t* con, byte att) +{ + static const char ansi_to_vga[] = + { + 0, 4, 2, 6, 1, 5, 3, 7 + }; + unsigned char new_att; + + new_att = con->attrib >> 8; + if(att == 0) + new_att &= ~0x08; /* bold off */ + else if(att == 1) + new_att |= 0x08; /* bold on */ + else if(att >= 30 && att <= 37) + { + att = ansi_to_vga[att - 30]; + new_att = (new_att & ~0x07) | att;/* fg color */ + } + else if(att >= 40 && att <= 47) + { + att = ansi_to_vga[att - 40] << 4; + new_att = (new_att & ~0x70) | att;/* bg color */ + } + + con->attrib = new_att << 8; +} + +void conUpdateBase(console_t* con) +{ + dword params[2]; + params[0] = con->base; + params[1] = con->base + + (con->x + (con->y + 1) * con->width) * 2; + devIoCtl(vgatext, 0, params, sizeof(params)); +} + +void conSwitch(console_t* con) +{ + con_current = con; + conUpdateBase(con); + conWriteTitle(con); +} + +void conClose(console_t* con) +{ + unsigned i; + + for (i = 0; i < num_consoles; i++) + if (consoles[i] == con) + consoles[i] = NULL; + + if (con->port) + portClose(con->port); + + free(con); +} + +void conWriteInternal(console_t* con, const wchar_t* buf, size_t length) +{ + word* cells; + const wchar_t *next_ctrl; + wchar_t temp[100]; + int i, j, k; + size_t len; + + //wprintf(L"conWriteInternal: writing %d...", length); + j = 0; + while (j < length) + { + if (con->esc == 0) + { + next_ctrl = NULL; + for (k = j; k < length; k++) + if (wcschr(L"\t\r\n\b\x1b", buf[k])) + { + next_ctrl = buf + k; + break; + } + + if (next_ctrl == NULL) + next_ctrl = buf + length; + + if (next_ctrl > buf + j) + { + wchar_t w; + char n[2]; + + len = next_ctrl - (buf + j); + wcsncpy(temp, buf + j, len); + temp[len] = '\0'; + + /*cells = (word*) temp; + for (i = 0; i < len; i++) + { + w = temp[i]; + wcstombs(n, &w, 1); + cells[i] = con->attrib | (byte) n[0]; + } + + conWriteToScreen(con, cells, len * sizeof(word));*/ + dputws(temp); + j += len; + } + else + { + switch (*next_ctrl) + { + case '\t': + con->x = (con->x + 4) & -3; + break; + case '\n': + con->x = 0; + con->y++; + break; + case '\r': + con->x = 0; + break; + case '\b': + if (con->x > 0) + { + con->x--; + conWriteInternal(con, L" ", 1); + con->x--; + } + break; + case '\x1b': + con->esc = 1; + con->esc1 = 0; + break; + } + + j++; + } + } + else + { + wchar_t c; + + c = buf[j++]; + + if (con->esc == 1) + { + if (c == L'[') + { + con->esc++; + con->esc1 = 0; + continue; + } + } + else if (con->esc == 2) + { + if (iswdigit(c)) + { + con->esc1 = con->esc1 * 10 + c - L'0'; + continue; + } + else if (c == ';') + { + con->esc++; + con->esc2 = 0; + continue; + } + else if (c == 'J') + { + if (con->esc1 == 2) + conClear(con); + } + else if (c == 'm') + conSetAttrib(con, con->esc1); + + con->esc = 0; + continue; + } + else if (con->esc == 3) + { + if (iswdigit(c)) + { + con->esc2 = con->esc2 * 10 + c - '0'; + continue; + } + else if(c == ';') + { + con->esc++; /* ESC[num1;num2; */ + con->esc3 = 0; + continue; + } + /* ESC[num1;num2H -- move cursor to num1,num2 */ + else if(c == 'H') + { + if(con->esc2 < con->width) + con->x = con->esc2; + if(con->esc1 < con->height) + con->y = con->esc1; + } + /* ESC[num1;num2m -- set attributes num1,num2 */ + else if(c == 'm') + { + conSetAttrib(con, con->esc1); + conSetAttrib(con, con->esc2); + } + con->esc = 0; + continue; + } + /* ESC[num1;num2;num3 */ + else if(con->esc == 4) + { + if (iswdigit(c)) + { + con->esc3 = con->esc3 * 10 + c - '0'; + continue; + } + /* ESC[num1;num2;num3m -- set attributes num1,num2,num3 */ + else if(c == 'm') + { + conSetAttrib(con, con->esc1); + conSetAttrib(con, con->esc2); + conSetAttrib(con, con->esc3); + } + con->esc = 0; + continue; + } + + con->esc = 0; + } + } + + //wprintf(L"done\n"); + + if (con == con_current) + conUpdateBase(con); +} + +bool conWrite(const wchar_t *str) +{ + conWriteInternal(con_current, str, wcslen(str)); + return true; +} + +console_t *conCreate(addr_t port) +{ + console_t *con; + wchar_t str[16]; + + con = malloc(sizeof(console_t)); + con->port = port; + con->base = num_consoles * 4000; + con->attrib = 0x0700; + con->esc = 0; + con->width = 80; + con->height = 24; + swprintf(str, L"Console %d", num_consoles + 1); + con->title = wcsdup(str); + + consoles[num_consoles++] = con; + + conWriteTitle(con); + conClear(con); + conSwitch(con); + + return con; +} + +void conClientThread(addr_t param) +{ + console_t* con; + console_request_t req; + //console_reply_t reply; + size_t length, written; + wchar_t buf[100]; + + con = (console_t*) param; + + //wprintf(L"[%d] conClientThread: port %x\n", thrGetId(), con->port); + while (thrWaitHandle(&con->port, 1, true)) + { + //wprintf(L"[%d] reading...", thrGetId()); + length = sizeof(req); + if (!fsRead(con->port, &req, &length) || + length < sizeof(req)) + { + _pwerror(L"console"); + continue; + } + + //wprintf(L"done\n"); + //reply.code = req.code; + switch (req.code) + { + case CON_WRITE: + written = 0; + while (written < req.params.write.length) + { + length = min(req.params.write.length, countof(buf)); + length *= sizeof(wchar_t); + if (!fsRead(con->port, buf, &length)) + break; + + length /= sizeof(wchar_t); + conWriteInternal(con, buf, length); + written += length; + } + break; + + case CON_CLOSE: + conClose(con); + thrExit(0); + + default: + //reply.code = CON_UNKNOWN; + break; + } + + //length = sizeof(reply); + //fsWrite(con->port, &reply, &length); + } +} + +void conHelpThread(dword param) +{ + console_t *con, *old_current; + + old_current = con_current; + con = conCreate(NULL); + conWrite(L"\x1b[30;47m\x1b[2JThe M�bius Help"); + thrSleep(1000); + conClose(con); + conSwitch(old_current); + thrExit(0); +} + +void conKeyboardThread(dword param) +{ + addr_t keyboard; + request_t req; + dword key, old_key; + size_t length; + unsigned con_current_index = 0; + //wchar_t ch; + + //wprintf(L"Keyboard thread (%d)\n", thrGetId()); + keyboard = devOpen(L"keyboard", NULL); + while (true) + { + req.code = DEV_READ; + req.params.read.buffer = &key; + req.params.read.length = sizeof(key); + + //wprintf(L"Request..."); + if (!devUserRequest(keyboard, &req, sizeof(req))) + break; + + //wprintf(L"done\nWait..."); + thrWaitHandle(&req.event, 1, true); + //wprintf(L"done\n"); + devUserFinishRequest(&req, true); + + //wprintf(L"Key pressed\n"); + + old_key = key; + if (key & KBD_BUCKY_CTRL) + { + if (consoles[con_current_index] != con_current) + con_current_index = -1; + + switch (key & ~KBD_BUCKY_ANY) + { + case KEY_F1: + thrCreate(conHelpThread, 0, 16); + break; + + case KEY_F4: + conClose(con_current); + + case '\t': + if (key & KBD_BUCKY_SHIFT) + do + { + con_current_index = (con_current_index - 1) % num_consoles; + } while (consoles[con_current_index] == NULL); + else + do + { + con_current_index = (con_current_index + 1) % num_consoles; + } while (consoles[con_current_index] == NULL); + + conSwitch(consoles[con_current_index]); + continue; + } + } + + if (con_current) + { + length = sizeof(old_key); + fsWrite(con_current->port, &old_key, &length); + + //ch = old_key; + //if (ch) + //conWriteInternal(con_current, &ch, 1); + } + } + + devClose(keyboard); + thrExit(0); +} + +void conMouseThread(dword param) +{ + addr_t mouse; + request_t req; + mouse_packet_t packet; + + mouse = devOpen(L"mouse", NULL); + while (true) + { + req.code = DEV_READ; + req.params.read.buffer = &packet; + req.params.read.length = sizeof(packet); + + if (!devUserRequest(mouse, &req, sizeof(req))) + break; + + thrWaitHandle(&req.event, 1, true); + devUserFinishRequest(&req, true); + + conDrawMouse(false); + mouse_x += packet.dx; + mouse_y += packet.dy; + conDrawMouse(true); + } + + devClose(mouse); + thrExit(0); +} + +void NtProcessStartup() +{ + addr_t port, client; + addr_t video; + console_t* con; + request_t *req; + vid_rect_t *rect; + vid_text_t *text; + size_t size; + int i; + + vgatext = devOpen(L"vgatext", NULL); + video = devOpen(L"vga4", NULL); + + size = sizeof(*req) - sizeof(union request_params_t) + sizeof(vid_rect_t); + req = malloc(size); + req->code = VID_FILLRECT; + rect = (vid_rect_t*) &req->params; + rect->colour = 6; + + for (i = 0; i < 16; i++) + { + rect->rect.left = i * 32; + rect->rect.top = 0; + rect->rect.right = rect->rect.left + 32; + rect->rect.bottom = rect->rect.top + 32; + rect->colour = i; + devUserRequestSync(video, req, size); + } + + free(req); + + size = sizeof(*req) - sizeof(union request_params_t) + sizeof(vid_text_t); + req = malloc(size); + req->code = VID_TEXTOUT; + text = (vid_text_t*) &req->params; + text->buffer = (addr_t) L"Hello, world!"; + text->length = wcslen((wchar_t*) text->buffer) * sizeof(wchar_t); + text->backColour = (pixel_t) -1; + + for (i = 0; i < 10; i++) + { + text->x = rand() % 100; + text->y = rand() % 100; + text->foreColour = rand() % 16; + devUserRequestSync(video, req, size); + } + + free(req); + + devClose(video); + + port = portCreate(CONSOLE_PORT); + portListen(port); + + thrCreate(conKeyboardThread, 0, 16); + //thrCreate(conMouseThread, 0, 16); + wprintf(L"Console server\n"); + while (true) + { + thrWaitHandle(&port, 1, true); + client = portAccept(port); + con = conCreate(client); + thrCreate(conClientThread, (dword) con, 16); + } + + devClose(vgatext); + procExit(0); +} + +//@} \ No newline at end of file diff --git a/mobius/src/console/console.dsp b/mobius/src/console/console.dsp new file mode 100644 index 0000000..bf636ad --- /dev/null +++ b/mobius/src/console/console.dsp @@ -0,0 +1,109 @@ +# Microsoft Developer Studio Project File - Name="console" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=console - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "console.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "console.mak" CFG="console - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "console - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "console - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "console - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f console.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "console.exe" +# PROP BASE Bsc_Name "console.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\bin\console.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "console - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f console.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "console.exe" +# PROP BASE Bsc_Name "console.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\bin\console.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "console - Win32 Release" +# Name "console - Win32 Debug" + +!IF "$(CFG)" == "console - Win32 Release" + +!ELSEIF "$(CFG)" == "console - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\console.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\..\include\os\console.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/console/console.plg b/mobius/src/console/console.plg new file mode 100644 index 0000000..147764e --- /dev/null +++ b/mobius/src/console/console.plg @@ -0,0 +1,19 @@ + + +
+

Build Log

+

+--------------------Configuration: console - Win32 Debug-------------------- +

+ +'make' is not recognized as an internal or external command, +operable program or batch file. +Error executing i:\winnt\system32\cmd.exe. + + + +

Results

+console.exe - 1 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/crt0.c b/mobius/src/crt0.c new file mode 100644 index 0000000..b97de24 --- /dev/null +++ b/mobius/src/crt0.c @@ -0,0 +1,16 @@ +#include +#include + +/* + * mainCRTStartup + * + * The entry point for applications linked to libc.dll. + * Initializes libc and calls the program's main, then terminates the process. + */ + +int main(); + +void mainCRTStartup() +{ + exit(main()); +} \ No newline at end of file diff --git a/mobius/src/crt0dll.c b/mobius/src/crt0dll.c new file mode 100644 index 0000000..2d379f9 --- /dev/null +++ b/mobius/src/crt0dll.c @@ -0,0 +1,16 @@ +#include + +/*#pragma data_seg(".info") +module_info_t __declspec(allocate(".info")) _info; +#pragma data_seg()*/ + +bool STDCALL DllMainCRTStartup(dword hDllHandle, dword dwReason, void* lpreserved) +{ + /*__asm + { + mov eax, [_info] + mov [_info], eax + }*/ + + return DllMain(hDllHandle, dwReason, lpreserved); +} diff --git a/mobius/src/devtest/Makefile b/mobius/src/devtest/Makefile new file mode 100644 index 0000000..15752cb --- /dev/null +++ b/mobius/src/devtest/Makefile @@ -0,0 +1,22 @@ +TARGET= $(BIN)/devtest.exe +OBJS= devtest.o ../crt0.o +LIBS= $(LIB)/libc.lib $(LIB)/kernelu.lib + +include ../make.actions + +all: $(TARGET) + +$(TARGET): $(OBJS) $(LIBS) Makefile +# link /nologo /libpath:$(LIB) /base:0x40000000 /debug /debugtype:coff \ +# /out:$(TARGET) \ +# /subsystem:native /entry:NtProcessStartup /nodefaultlib \ +# $(OBJS) $(LIBS) + ld -g -L $(LIB) --image-base 0x40000000 --subsystem native \ + --entry _mainCRTStartup -o $(TARGET) \ + $(OBJS) $(LIBS) + +clean: + rm $(TARGET) + rm $(OBJS) + +include $(OBJS:.o=.d) \ No newline at end of file diff --git a/mobius/src/devtest/devtest.c b/mobius/src/devtest/devtest.c new file mode 100644 index 0000000..e762cba --- /dev/null +++ b/mobius/src/devtest/devtest.c @@ -0,0 +1,266 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void TestConsole(wchar_t* buf) +{ + addr_t client; + console_request_t req; + console_reply_t reply; + size_t length; + wchar_t name[10]; + + wprintf(L"[%d] conConnector\n", thrGetId()); + swprintf(name, L"client%d", thrGetId()); + + client = portCreate(name); + if (!portConnect(client, CONSOLE_PORT)) + { + wprintf(CONSOLE_PORT L": port not found\n"); + portClose(client); + return; + } + + wprintf(L"[%d] Connecting...", thrGetId()); + thrWaitHandle(&client, 1, true); + wprintf(L"done\n"); + + //while (true) + { + length = sizeof(req); + req.code = CON_WRITE; + req.params.write.length = wcslen(buf); + fsWrite(client, &req, &length); + length = req.params.write.length * sizeof(wchar_t); + fsWrite(client, buf, &length); + + thrWaitHandle(&client, 1, true); + + length = sizeof(reply); + fsRead(client, &reply, &length); + wprintf(L"[%d] Reply: code = %x\n", thrGetId(), reply.code); + } +} + +void TestMouseAndKeyboard() +{ + addr_t mouse, keyboard; + request_t mreq, kreq; + wchar_t str[50]; + dword key; + mouse_packet_t pkt; + addr_t events[2]; + unsigned first; + + mouse = devOpen(L"ps2mouse", NULL); + if (mouse == NULL) + _cputws(L"Failed to open mouse\n"); + + keyboard = devOpen(L"keyboard", NULL); + if (keyboard == NULL) + _cputws(L"Failed to open keyboard\n"); + + for (;;) + { + kreq.header.code = DEV_READ; + kreq.params.read.buffer = &key; + kreq.params.read.length = sizeof(key); + if (devUserRequest(keyboard, &kreq, sizeof(kreq)) == 0) + events[0] = (addr_t) kreq.header.event; + else + events[0] = NULL; + + mreq.header.code = DEV_READ; + mreq.params.read.buffer = &pkt; + mreq.params.read.length = sizeof(pkt); + if (devUserRequest(mouse, &mreq, sizeof(mreq)) == 0) + events[1] = (addr_t) mreq.header.event; + else + events[1] = NULL; + + first = thrWaitHandle(events, 1, false); + devUserFinishRequest(&kreq, true); + devUserFinishRequest(&mreq, true); + + if (first == 0) + str[0] = (wchar_t) key; + else + str[0] = pkt.buttons + '0'; + + str[1] = 0; + _cputws(str); + + if (key == 27) + break; + } + + devClose(keyboard); + devClose(mouse); +} + +void dump(const byte* buf, size_t size) +{ + wchar_t temp[4]; + int j; + + for (j = 0; j < size; j++) + { + if (((buf[j] >> 4) & 0xf) > 9) + temp[0] = ((buf[j] >> 4) & 0xf) + 'a' - 10; + else + temp[0] = ((buf[j] >> 4) & 0xf) + '0'; + + if ((buf[j] & 0xf) > 9) + temp[1] = (buf[j] & 0xf) + 'a' - 10; + else + temp[1] = (buf[j] & 0xf) + '0'; + + temp[2] = ' '; + temp[3] = 0; + _cputws(temp); + } + + _cputws(L"\n"); +} + +void TestStorage(const wchar_t *device) +{ + static byte sector[512 * 5], sector2[512 * 3]; + static request_t req, req2; + + addr_t ide; + int i; + + ide = devOpen(device, NULL); + if (!ide) + { + wprintf(L"Failed to open %s\n", device); + return; + } + + for (i = 0; i < 4; i++) + { + req.header.code = DEV_READ; + req.params.read.buffer = sector; + req.params.read.length = sizeof(sector); + req.params.read.pos = i * 512; + + req2.header.code = DEV_READ; + req2.params.read.buffer = sector2; + req2.params.read.length = sizeof(sector2); + req2.params.read.pos = (i + 2) * 512; + + devUserRequest(ide, &req, sizeof(req)); + devUserRequest(ide, &req2, sizeof(req2)); + + thrWaitHandle((addr_t*) &req.header.event, 1, true); + devUserFinishRequest(&req, true); + + if (req.header.result == 0) + { + _cputws(L"1: "); + dump(sector, 8); + } + + thrWaitHandle((addr_t*) &req2.header.event, 1, true); + devUserFinishRequest(&req2, true); + + if (req2.header.result == 0) + { + _cputws(L"2: "); + dump(sector2, 8); + } + } + + devClose(ide); +} + +void TestFileSystem(const wchar_t* filename) +{ + addr_t fd; + request_t req; + static char buf[8]; + static wchar_t wide[countof(buf) + 1]; + + fd = fsOpen(filename); + + memset(buf, 0, sizeof(buf)); + while (true) + { + req.header.code = FS_READ; + req.params.fs_read.fd = fd; + req.params.fs_read.buffer = (addr_t) buf; + req.params.fs_read.length = sizeof(buf); + + if (!fsRequest(fd, &req, sizeof(req))) + { + wprintf(L"Request failed\n"); + break; + } + else + { + thrWaitHandle(&req.header.event, 1, true); + devUserFinishRequest(&req, true); + + if (req.header.result == 0) + { + //wprintf(L"Request succeeded (length = %d): press any key\n", + //req.params.fs_read.length); + wide[countof(buf)] = 0; + mbstowcs(wide, buf, countof(buf)); + _cputws(wide); + _cputws(L"\n-- More --\r"); + if (towlower(_wgetch()) == 'q') + break; + } + else + { + wprintf(L"Request failed: %x\n", req.header.result); + break; + } + } + } + + fsClose(fd); +} + +int main() +{ + wprintf(L"Device test program\n"); + + //_cputws(L"Press any key to test the console\n"); + //TestConsole(L"Hello, world!"); + + //_cputws(L"Press any key to test file system\n"); + //_wgetch(); + //TestFileSystem(L"text/Keyboard Layouts/uk-cap.txt"); + //TestFileSystem(L"/Mobius/windows/bootlog.txt"); + //TestFileSystem(L"/devices/keyboard"); + //TestFileSystem(L"coffbase.txt"); + + _cputws(L"Press any key to test floppy\n"); + _wgetch(); + TestStorage(L"floppy0"); + + _cputws(L"Press any key to test IDE\n"); + _wgetch(); + TestStorage(L"ide0a"); + + //_cputws(L"Press any key to test the mouse and keyboard\n"); + //_wgetch(); + //_cputws(L"Testing mouse and keyboard... (press Esc to exit)\n"); + //TestMouseAndKeyboard(); + + _cputws(L"Finished!\n"); + + return 0; +} \ No newline at end of file diff --git a/mobius/src/domake.bat b/mobius/src/domake.bat new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/mobius/src/domake.bat diff --git a/mobius/src/drivers/Makefile b/mobius/src/drivers/Makefile new file mode 100644 index 0000000..ee56bdd --- /dev/null +++ b/mobius/src/drivers/Makefile @@ -0,0 +1,5 @@ +all: + for /f %i in ('type DIRS') do @make -C %i --unix + +clean: + for /f %i in ('type DIRS') do @make -C %i clean --unix diff --git a/mobius/src/drivers/ata/Makefile b/mobius/src/drivers/ata/Makefile new file mode 100644 index 0000000..035429a --- /dev/null +++ b/mobius/src/drivers/ata/Makefile @@ -0,0 +1,5 @@ +TARGET= $(BIN)/ata.drv +OBJS= ata.o +BASE= ata + +include ../make.driver diff --git a/mobius/src/drivers/ata/ata.c b/mobius/src/drivers/ata/ata.c new file mode 100644 index 0000000..321cc37 --- /dev/null +++ b/mobius/src/drivers/ata/ata.c @@ -0,0 +1,604 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ata.h" + +#include + +dword sysUpTime(); + +#define MAX_DRIVES 2 + +typedef struct atadrive_t atadrive_t; +struct atadrive_t +{ + device_t dev; + word port; + byte unit; + word sectors, heads, cylinders, mult_max; + wchar_t name[41]; + dword total_sectors; +}; + +typedef struct atactrl_t atactrl_t; +struct atactrl_t +{ + device_t dev; + byte irq; + atadrive_t* cur_drive; + atadrive_t* drives[MAX_DRIVES]; +}; + +typedef struct atapart_t atapart_t; +struct atapart_t +{ + device_t dev; + device_t* drive; + dword start_sector, total_sectors; +}; + +bool ataWaitStatus(atadrive_t* ctx, word mask, word bits) +{ + dword end; + word stat; + + end = sysUpTime() + 2000; + while (((stat = in(ctx->port + ATA_REG_STATUS)) & mask) != bits) + { + if (sysUpTime() >= end) + { + TRACE1("ATA: wait failed; stat = %x\n", stat); + return false; + } + } + + return true; +} + +void ataBlockToChs(atadrive_t* ctx, addr_t block, dword *cyl, dword *head, dword *sect) +{ + *sect = block % ctx->sectors + 1; + block /= ctx->sectors; + *head = block % ctx->heads; + block /= ctx->heads; + *cyl = block; +} + +size_t ataBlockRead(atadrive_t* ctx, addr_t start, size_t blocks, void* buffer) +{ + unsigned short *buf; + int cyl, head, sect; + size_t i, read, per = min(blocks, ctx->mult_max); + + if (!ctx->heads || !ctx->sectors) + return 0; + + buf = (unsigned short *) buffer; + read = 0; + + while (read < blocks) + { + ataBlockToChs(ctx, start, &cyl, &head, §); + TRACE4("%d = %d:%d:%d\t", start, cyl, head, sect); + if (!ataWaitStatus(ctx, ATA_BUSY, 0)) + return read; + + out(ctx->port + ATA_REG_DRVHD, ctx->unit); + if (!ataWaitStatus(ctx, ATA_BUSY | ATA_READY, ATA_READY)) + return read; + + out(ctx->port + ATA_REG_LOCYL, cyl & 0xff); + out(ctx->port + ATA_REG_HICYL, (cyl >> 8) & 0xff); + out(ctx->port + ATA_REG_SECTOR, sect); + out(ctx->port + ATA_REG_DRVHD, head); + out(ctx->port + ATA_REG_COUNT, per); + out(ctx->port + ATA_REG_CMD, ATA_CMD_READ); + + if (!ataWaitStatus(ctx, ATA_BUSY | ATA_DRQ, ATA_DRQ)) + return read; + + for (i = 0; i < 256 * per; i++) + buf[i] = in16(ctx->port + ATA_REG_DATA); + + read += per; + start += per; + buf += per * 256; + } + + return read; +} + +bool ataStartRead(atadrive_t* ctx, addr_t start, size_t blocks) +{ + int cyl, head, sect; + size_t per = min(blocks, ctx->mult_max); + atactrl_t* ctrl = (atactrl_t*) ctx->dev.config->parent; + + assert(ctrl != NULL); + + if (!ctx->heads || !ctx->sectors) + return false; + + ataBlockToChs(ctx, start, &cyl, &head, §); + TRACE4("%d = %d:%d:%d\t", start, cyl, head, sect); + if (!ataWaitStatus(ctx, ATA_BUSY, 0)) + return false; + + out(ctx->port + ATA_REG_DRVHD, ctx->unit); + if (!ataWaitStatus(ctx, ATA_BUSY | ATA_READY, ATA_READY)) + return false; + + out(ctx->port + ATA_REG_LOCYL, cyl & 0xff); + out(ctx->port + ATA_REG_HICYL, (cyl >> 8) & 0xff); + out(ctx->port + ATA_REG_SECTOR, sect); + out(ctx->port + ATA_REG_DRVHD, head); + out(ctx->port + ATA_REG_COUNT, per); + out(ctx->port + ATA_REG_CMD, ATA_CMD_READ); + return true; +} + +size_t ataBlockWrite(atadrive_t* ctx, addr_t start, size_t blocks, const void* buffer) +{ + return 0; +} + +wchar_t *ataConvertName(const word* in_data, int off_start, int off_end) +{ + static wchar_t ret_val[255]; + int loop, loop1; + + for (loop = off_start, loop1 = 0; loop <= off_end; loop++) + { + ret_val [loop1++] = (char) (in_data [loop] / 256); /* Get High byte */ + ret_val [loop1++] = (char) (in_data [loop] % 256); /* Get Low byte */ + } + + for (loop1--; loop1 >= 0 && ret_val[loop1] == ' '; loop1--) + ; + + ret_val[loop1 + 1] = '\0'; /* Make sure it ends in a NULL character */ + return ret_val; +} + +#pragma pack(push, 1) + +typedef struct partition_t partition_t; +struct partition_t +{ + byte bBoot; + byte bStartHead; + byte bStartSector; + byte bStartCylinder; + byte bSystem; + byte bEndHead; + byte bEndSector; + byte bEndCylinder; + dword dwStartSector; + dword dwSectorCount; +}; +#pragma pack(pop) + +const wchar_t* part_type(int type) +{ + switch (type) + { + case 0x00: + return L"FDISK_TYPE_EMPTY"; + case 0x01: + return L"FDISK_TYPE_FAT12"; + case 0x04: + return L"FDISK_TYPE_FAT16_SMALL"; + case 0x05: + return L"FDISK_TYPE_EXTENDED"; + case 0x06: + return L"FDISK_TYPE_FAT16_BIG"; + //case 0x07: + case 0x0C: + return L"FDISK_TYPE_FAT32"; + case 0x0F: + return L"FDISK_TYPE_NTFS"; + case 0x82: + return L"FDISK_TYPE_LINUX_SWAP"; + case 0x83: + return L"FDISK_TYPE_EXT2"; + case 0xa5: + return L"FDISK_TYPE_FREEBSD"; + case 0xa6: + return L"FDISK_TYPE_OPENBSD"; + case 0xeb: + return L"FDISK_TYPE_BFS"; + default: + return L"unknown"; + } +} + +void nsleep(dword ns) +{ +} + +bool ataNextRequest(atadrive_t* ctx) +{ + atactrl_t* ctrl; + request_t *req, *next; + + assert(ctx->dev.config != NULL); + ctrl = (atactrl_t*) ctx->dev.config->parent; + assert(ctrl != NULL); + + if (ctx->dev.req_first == NULL) + { + ctrl->cur_drive = NULL; + return true; // All requests are finished + } + + req = ctx->dev.req_first; + if (ctrl->cur_drive == NULL) + { + /* No requests are pending on the controller */ + TRACE1("ata: starting request buf = %p\n", req->params.read.buffer); + ctrl->cur_drive = ctx; + req->user_length = req->params.read.length; + req->params.read.length = 0; + } + else + { + assert(ctrl->cur_drive == ctx); + + /* There is a request on the controller, and it's ours */ + + if (req->params.read.length >= req->user_length) + { + TRACE0("ata: finished\n"); + next = req->next; + devFinishRequest(&ctx->dev, req); + req = next; + + if (ctx->dev.req_first == NULL) + { + TRACE0("ata: this drive has finished\n"); + ctrl->cur_drive = NULL; + return true; + } + + req = next; + req->user_length = req->params.read.length; + req->params.read.length = 0; + } + } + + if (req->params.read.length < req->user_length) + { + size_t toread = req->user_length - req->params.read.length; + TRACE2("ata: pos = %d read %d\n", + (size_t) (req->params.read.pos / 512), + toread / 512); + if (!ataStartRead(ctx, + (size_t) (req->params.read.pos / 512), + toread / 512)) + wprintf(L"ata: ataStartRead failed\n"); + + /* Controller will generate an interrupt when the op has finished */ + } + + return false; +} + +bool ataRequest(device_t* dev, request_t* req) +{ + atadrive_t* ctx = (atadrive_t*) dev; + block_size_t* size; + + switch (req->code) + { + case DEV_REMOVE: + hndFree(ctx); + hndSignal(req->event, true); + return true; + + case DEV_OPEN: + case DEV_CLOSE: + hndSignal(req->event, true); + return true; + + case DEV_READ: + case DEV_WRITE: + TRACE0("ata: start request\n"); + devStartRequest(dev, req); + ataNextRequest(ctx); + return true; + + case BLK_GETSIZE: + size = (block_size_t*) req->params.buffered.buffer; + size->block_size = 512; + size->total_blocks = ctx->total_sectors; + hndSignal(req->event, true); + return true; + + default: + wprintf(L"ataRequest: %c%c\n", req->code / 256, req->code % 256); + } + + req->result = ENOTIMPL; + return false; +} + +bool ataPartitionRequest(device_t* dev, request_t* req) +{ + atapart_t* ctx = (atapart_t*) dev; + block_size_t* size; + + switch (req->code) + { + case DEV_REMOVE: + hndFree(ctx); + hndSignal(req->event, true); + return true; + + case BLK_GETSIZE: + size = (block_size_t*) req->params.buffered.buffer; + size->block_size = 512; + size->total_blocks = ctx->total_sectors; + hndSignal(req->event, true); + return true; + + case DEV_READ: + case DEV_WRITE: + req->params.read.pos += ctx->start_sector * 512; + default: + return ataRequest(ctx->drive, req); + } +} + +bool ataControllerRequest(device_t* dev, request_t* req) +{ + atactrl_t* ctx = (atactrl_t*) dev; + atadrive_t* drive; + word *buf, per; + int i; + addr_t start; + request_t* drvreq; + size_t toread; + + switch (req->code) + { + case DEV_REMOVE: + devRegisterIrq(dev, ctx->irq, false); + hndFree(ctx); + hndSignal(req->event, true); + return true; + + case DEV_ISR: + assert(req->params.isr.irq == ctx->irq); + TRACE1("DEV_ISR: %d\t", req->params.isr.irq); + + drive = ctx->cur_drive; + if (drive) + { + drvreq = drive->dev.req_first; + if (drvreq) + { + toread = drvreq->user_length - drvreq->params.read.length; + per = min(toread / 512, drive->mult_max); + start = (size_t) (drvreq->params.read.length / 512); + buf = (word*) (drvreq->params.read.buffer + start * 512); + + for (i = 0; i < 256 * per; i++) + buf[i] = in16(drive->port + ATA_REG_DATA); + + drvreq->params.read.length += per * 512; + drvreq->params.read.pos += per * 512; + } + + while (ataNextRequest(drive)) + { + TRACE0("atactrl: Drive finished, looking for another\n"); + ctx->cur_drive = NULL; + + drive = NULL; + for (i = 0; i < MAX_DRIVES; i++) + if (ctx->drives[i] && + ctx->drives[i]->dev.req_first) + { + drive = ctx->drives[i]; + break; + } + + if (drive == NULL) + { + TRACE0("atactrl: No more drives; all finished!\n"); + break; + } + } + } + + return true; + } + + req->result = ENOTIMPL; + return false; +} + +bool ataWaitTimeout(word port, byte mask, byte match, dword timeout) +{ + dword end = sysUpTime() + timeout; + byte stat; + + while (((stat = in(port)) & mask) != match) + { + if (sysUpTime() > end) + { + TRACE1("ata: wait failed, stat = 0x%02x\n", stat); + return false; + } + } + + return true; +} + +device_t* ataAddControllerDevice(driver_t* drv, const wchar_t* name, device_config_t* cfg) +{ + word dd[256]; + int dd_off, i, j; + atadrive_t *drive; + atapart_t *part; + atactrl_t *ctrl; + wchar_t str[10]; + partition_t *parts; + word port, irq; + byte units[MAX_DRIVES] = { 0xA0, 0xB0 }; + device_config_t *dcfg; + device_t *cached; + + parts = (partition_t*) (dd + 0xdf); + i = devFindResource(cfg, dresIo, 0); + if (i > -1) + port = cfg->resources[i].u.io.base; + else + port = 0x1F0; + + i = devFindResource(cfg, dresIrq, 0); + if (i > -1) + irq = cfg->resources[i].u.irq; + else + irq = 14; + + TRACE2("IDE controller: port %x irq %d\n", port, irq); + + /* soft reset both drives on this I/F (selects master) */ + out(port + ATA_REG_DEVCTRL, 0x06); + nsleep(400); + /* release soft reset AND enable interrupts from drive */ + out(port + ATA_REG_DEVCTRL, 0x00); + nsleep(400); + /* wait up to 2 seconds for status = + BUSY=0 READY=1 DF=? DSC=? DRQ=? CORR=? IDX=? ERR=0 */ + + if (!ataWaitTimeout(port + 7, 0xC1, 0x40, 5000)) + { + wprintf(L"ata: no master detected\n"); + return NULL; + } + + ctrl = hndAlloc(sizeof(atactrl_t), NULL); + ctrl->dev.driver = drv; + ctrl->dev.request = ataControllerRequest; + ctrl->dev.req_first = ctrl->dev.req_last = NULL; + ctrl->dev.config = cfg; + ctrl->irq = irq; + ctrl->cur_drive = NULL; + + for (i = 0; i < countof(units); i++) /* Loop through drives on this controller */ + { + ctrl->drives[i] = NULL; + + TRACE0("Wait not busy..."); + if (!ataWaitTimeout(port + 7, 0xff, 0x50, 2000)) + continue; + TRACE0("done\n"); + + out(port + 6, units[i]); /* Get first/second drive */ + out(port + 7, 0xEC); /* Get drive info data */ + + TRACE0("Wait ready..."); + if (!ataWaitTimeout(port + 7, 0xff, 0x58, 2000)) + continue; + TRACE0("done\n"); + + TRACE1("locyl = %x ", in(port + ATA_REG_LOCYL)); + TRACE1("hicyl = %x\n", in(port + ATA_REG_HICYL)); + + for (dd_off = 0; dd_off != 256; dd_off++) /* Read "sector" */ + dd[dd_off] = in16(port); + + drive = hndAlloc(sizeof(atadrive_t), NULL); + drive->dev.driver = drv; + drive->dev.request = ataRequest; + drive->dev.req_first = drive->dev.req_last = NULL; + drive->dev.config = NULL; + drive->port = port; + drive->unit = units[i]; + drive->cylinders = dd[1]; + drive->heads = dd[3]; + drive->sectors = dd[6]; + drive->total_sectors = drive->sectors * drive->heads * drive->cylinders; + + ctrl->drives[i] = drive; + + if (((dd[119] & 1) != 0) && (dd[118] != 0)) + drive->mult_max = dd[94]; + else + drive->mult_max = 1; + + wcscpy(drive->name, ataConvertName(dd, 27, 46)); + wcscat(drive->name, L" "); + wcscat(drive->name, ataConvertName(dd, 10, 19)); + swprintf(str, L"ide%d", i); + + dcfg = hndAlloc(sizeof(device_config_t), NULL); + dcfg->parent = &ctrl->dev; + dcfg->num_resources = 0; + dcfg->resources = NULL; + dcfg->device_id = dcfg->vendor_id = 0xffff; + dcfg->subsystem = 0xffffffff; + + //cached = &drive->dev; + devRegister(str, &drive->dev, dcfg); + wprintf(L"Registered %s => %s [ ", str, drive->name); + + if (ataBlockRead(drive, 0, 1, dd)) + { + for (j = 0; j < 4; j++) + { + word c, h, s; + + c = parts[j].bStartCylinder | + ((word) parts[j].bStartSector & 0xc0) << 2; + h = parts[j].bStartHead; + s = parts[j].bStartSector & 0x3f; + + if (parts[j].bSystem) + { + part = hndAlloc(sizeof(atapart_t), NULL); + part->dev.driver = drv; + part->dev.request = ataPartitionRequest; + part->drive = &drive->dev; + + part->start_sector = parts[j].dwStartSector; + part->total_sectors = parts[j].dwSectorCount; + swprintf(str, L"ide%d%c", i, j + 'a'); + + dcfg = hndAlloc(sizeof(device_config_t), NULL); + dcfg->parent = &ctrl->dev; + dcfg->num_resources = 0; + dcfg->resources = NULL; + dcfg->device_id = dcfg->vendor_id = 0xffff; + dcfg->subsystem = 0xffffffff; + + cached = ccInstallBlockCache(&part->dev, 512); + devRegister(str, cached, dcfg); + wprintf(L"%s ", part_type(parts[j].bSystem)); + } + } + } + + _cputws(L"]\n"); + } + + //wprintf(L"Finished detection!\n"); + + devRegisterIrq(&ctrl->dev, ctrl->irq, true); + return &ctrl->dev; +} + +bool STDCALL INIT_CODE drvInit(driver_t* drv) +{ + drv->add_device = ataAddControllerDevice; + return true; +} \ No newline at end of file diff --git a/mobius/src/drivers/ata/ata.dsp b/mobius/src/drivers/ata/ata.dsp new file mode 100644 index 0000000..78fa807 --- /dev/null +++ b/mobius/src/drivers/ata/ata.dsp @@ -0,0 +1,117 @@ +# Microsoft Developer Studio Project File - Name="ata" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=ata - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "ata.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "ata.mak" CFG="ata - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "ata - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "ata - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "ata - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f ata.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "ata.exe" +# PROP BASE Bsc_Name "ata.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "nmake /f "ata.mak"" +# PROP Rebuild_Opt "/a" +# PROP Target_File "ata.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "ata - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f ata.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "ata.exe" +# PROP BASE Bsc_Name "ata.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "set" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\bin\ata.dll" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "ata - Win32 Release" +# Name "ata - Win32 Debug" + +!IF "$(CFG)" == "ata - Win32 Release" + +!ELSEIF "$(CFG)" == "ata - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\ata.c +# End Source File +# Begin Source File + +SOURCE=.\ata.rc +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\ata.h +# End Source File +# Begin Source File + +SOURCE=.\resource.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/ata/ata.h b/mobius/src/drivers/ata/ata.h new file mode 100644 index 0000000..ff5a2d1 --- /dev/null +++ b/mobius/src/drivers/ata/ata.h @@ -0,0 +1,59 @@ +#ifndef __ATA_H +#define __ATA_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +/*! + * \ingroup drivers + * \defgroup ata ATA/ATAPI + * @{ + */ + +/* ATA register file (offsets from 0x1F0 or 0x170) */ +#define ATA_REG_DATA 0 /* data (16-bit) */ +#define ATA_REG_FEAT 1 /* write: feature reg */ +#define ATA_REG_ERROR ATA_REG_FEAT /* read: error */ +#define ATA_REG_COUNT 2 /* sector count */ +#define ATA_REG_SECTOR 3 /* sector */ +#define ATA_REG_LOCYL 4 /* LSB of cylinder */ +#define ATA_REG_HICYL 5 /* MSB of cylinder */ +#define ATA_REG_DRVHD 6 /* drive select; head */ +#define ATA_REG_CMD 7 /* write: drive command */ +#define ATA_REG_STATUS 7 /* read: status and error flags */ +#define ATA_REG_DEVCTRL 0x206 /* write: device control */ +//efine ATA_REG_ALTSTAT 0x206 /* read: alternate status/error */ + +/* a few of the ATA registers are used differently by ATAPI... */ +#define ATAPI_REG_REASON 2 /* interrupt reason */ +#define ATAPI_REG_LOCNT 4 /* LSB of transfer count */ +#define ATAPI_REG_HICNT 5 /* MSB of transfer count */ + +/* ATA command bytes */ +#define ATA_CMD_READ 0x20 /* read sectors */ +#define ATA_CMD_PKT 0xA0 /* signals ATAPI packet command */ +#define ATA_CMD_PID 0xA1 /* identify ATAPI device */ +#define ATA_CMD_READMULT 0xC4 /* read sectors, one interrupt */ +#define ATA_CMD_MULTMODE 0xC6 +#define ATA_CMD_ID 0xEC /* identify ATA device */ + +#define ATA_ERR 0x01 +#define ATA_IDX 0x02 +#define ATA_CORR 0x04 +#define ATA_DRQ 0x08 +#define ATA_DSC 0x10 +#define ATA_DF 0x20 +#define ATA_READY 0x40 +#define ATA_BUSY 0x80 + +//!@} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/ata/ata.old.cpp b/mobius/src/drivers/ata/ata.old.cpp new file mode 100644 index 0000000..4fe4c51 --- /dev/null +++ b/mobius/src/drivers/ata/ata.old.cpp @@ -0,0 +1,517 @@ +#include +#include +#include +#include +#include +#include "ata.h" +#include + +#define CLRSCR L"\x1b[2J" +#define DEBUG(s) + +volatile word _interrupt_occurred; + +void __cdecl AtaIrq(dword context, int irq) +{ + //wprintf(L"ATA(PI) interrupt %d\n", irq); + _interrupt_occurred |= 1 << irq; +} + +CAtaDrive::CAtaDrive() +{ + m_refs = 0; +} + +// IUnknown methods +HRESULT CAtaDrive::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IDevice)) + { + *ppvObject = (IDevice*) this; + AddRef(); + return S_OK; + } + else if (InlineIsEqualGUID(iid, IID_IBlockDevice)) + { + *ppvObject = (IBlockDevice*) this; + AddRef(); + return S_OK; + } + + return E_FAIL; +} + +// IDevice method +HRESULT CAtaDrive::GetInfo(device_t* buf) +{ + if (buf->size < sizeof(device_t)) + return E_FAIL; + + wcscpy(buf->name, m_name); + return S_OK; +} + +HRESULT CAtaDrive::DeviceOpen() +{ + return S_OK; +} + +// IBlockDevice methods +HRESULT CAtaDrive::GetSize(blocksize_t *size) +{ + size_t old_size = size->size; + if (old_size < sizeof(blocksize_t)) + return E_FAIL; + + *size = m_size; + size->size = old_size; + return S_OK; +} + +bool CAtaDrive::WaitStatus(word mask, word bits) +{ + dword end; + word stat; + + end = sysUpTime() + 2000; + while (((stat = in(m_port + ATA_REG_STATUS)) & mask) != bits) + { + if (sysUpTime() >= end) + { + wprintf(L"ATA: wait failed; stat = %x\n", stat); + return false; + } + } + + return true; +} + +void CAtaDrive::Select() +{ + out(m_port + ATA_REG_DRVHD, m_unit); +} + +void CAtaDrive::BlockToChs(int block, int *cyl, int *head, int *sect) +{ + *sect = block % m_sectors + 1; + block /= m_sectors; + *head = block % m_heads; + block /= m_heads; + *cyl = block; + + /**cyl = block / (m_heads * m_sectors); + block %= m_heads * m_sectors; + *head = block / m_sectors; + block %= m_sectors; + *sect = block;*/ +} + +size_t CAtaDrive::BlockRead(addr_t start, size_t blocks, void* buffer) +{ + unsigned short *buf; + int cyl, head, sect; + size_t i, read, per = min(blocks, m_mult_max); + + if (!m_heads || !m_sectors) + return 0; + + buf = (unsigned short *) buffer; + start += m_start_sector; + read = 0; + + while (read < blocks) + { + BlockToChs(start, &cyl, &head, §); + //wprintf(L"%d = %d:%d:%d\t", start, cyl, head, sect); + //IDE_WAIT_0 (STATUS, 7); + if (!WaitStatus(ATA_BUSY, 0)) + return read; + + //IDE_SEL_DH (bus, device, head); + //IDE_WAIT_0 (STATUS, 7); + //IDE_WAIT_1 (STATUS, 6); + Select(); + /*if (!WaitStatus(ATA_BUSY, 0) || + !WaitStatus(ATA_READY, ATA_READY)) + return read;*/ + if (!WaitStatus(ATA_BUSY | ATA_READY, ATA_READY)) + return read; + + out(m_port + ATA_REG_LOCYL, cyl & 0xff); + out(m_port + ATA_REG_HICYL, (cyl >> 8) & 0xff); + out(m_port + ATA_REG_SECTOR, sect /*+ 1*/); + out(m_port + ATA_REG_DRVHD, head); + out(m_port + ATA_REG_COUNT, per); + out(m_port + ATA_REG_CMD, ATA_CMD_READ); + //IDE_WAIT_0 (STATUS, 7); + //IDE_WAIT_1 (STATUS, 3); + /*if (!WaitStatus(ATA_BUSY, 0) || + !WaitStatus(ATA_DRQ, ATA_DRQ)) + return read;*/ + if (!WaitStatus(ATA_BUSY | ATA_DRQ, ATA_DRQ)) + return read; + + for (i = 0; i < 256 * per; i++) + buf[i] = in16(m_port + ATA_REG_DATA); + + read += per; + start += per; + buf += per * 256; + } + + return read; +} + +size_t CAtaDrive::BlockWrite(addr_t start, size_t blocks, const void* buffer) +{ + return 0; +} + +wchar_t *ConvertName(const word* in_data, int off_start, int off_end) +{ + static wchar_t ret_val[255]; + int loop, loop1, last_space = 0; + + for (loop = off_start, loop1 = 0; loop <= off_end; loop++) + { + ret_val [loop1++] = (char) (in_data [loop] / 256); /* Get High byte */ + ret_val [loop1++] = (char) (in_data [loop] % 256); /* Get Low byte */ + } + + for (loop1--; loop1 >= 0 && ret_val[loop1] == ' '; loop1--) + ; + + ret_val[loop1 + 1] = '\0'; /* Make sure it ends in a NULL character */ + return ret_val; +} + +#pragma pack(push, 1) + +struct partition_t +{ + byte bBoot; + byte bStartHead; + byte bStartSector; + byte bStartCylinder; + byte bSystem; + byte bEndHead; + byte bEndSector; + byte bEndCylinder; + dword dwStartSector; + dword dwSectorCount; +}; +#pragma pack(pop) + +const wchar_t* part_type(int type) +{ + switch (type) + { + case 0x00: + return L"FDISK_TYPE_EMPTY"; + case 0x01: + return L"FDISK_TYPE_FAT12"; + case 0x04: + return L"FDISK_TYPE_FAT16_SMALL"; + case 0x05: + return L"FDISK_TYPE_EXTENDED"; + case 0x06: + return L"FDISK_TYPE_FAT16_BIG"; + //case 0x07: + case 0x0C: + return L"FDISK_TYPE_FAT32"; + case 0x0F: + return L"FDISK_TYPE_NTFS"; + case 0x82: + return L"FDISK_TYPE_LINUX_SWAP"; + case 0x83: + return L"FDISK_TYPE_EXT2"; + case 0xa5: + return L"FDISK_TYPE_FREEBSD"; + case 0xa6: + return L"FDISK_TYPE_OPENBSD"; + case 0xeb: + return L"FDISK_TYPE_BFS"; + default: + return L"unknown"; + } +} + +void ataDetect() +{ + word dd[256]; + int dd_off, i, j; + word ports[4] = { 0x1F0, 0x1F0, 0x170, 0x170 }; + byte units[4] = { 0xA0, 0xB0, 0xA0, 0xB0 }; + word irqs[4] = { 0x4000, 0x4000, 0x8000, 0x8000 }; + dword end; + bool fail = false; + byte stat; + CAtaDrive *drive, *partdrive; + wchar_t str[10]; + partition_t *parts; + + sysRegisterIrq(14, AtaIrq, NULL); + sysRegisterIrq(15, AtaIrq, NULL); + + parts = (partition_t*) (dd + 0xdf); + for (i = 0; i < 4; i++) /* Loop through drives */ + { + wprintf(L"Detecting drive %d...\n", i); + + if (units[i] == 0xA0) + { + out(ports[i] + ATA_REG_DEVCTRL, 0x06); + nsleep(400); + /* release soft reset AND enable interrupts from drive */ + out(ports[i] + ATA_REG_DEVCTRL, 0x00); + nsleep(400); + /* wait up to 2 seconds for status = + BUSY=0 READY=1 DF=? DSC=? DRQ=? CORR=? IDX=? ERR=0 */ + + end = sysUpTime() + 5000; + fail = false; + while (((stat = in(ports[i] + 7)) & 0xC1) != 0x40) + { + if (sysUpTime() >= end) + { + fail = true; + break; + } + } + + if (fail) + { + wprintf(L"stat = %x, no master detected\n", stat); + i++; // Skip slave as well + continue; + } + } + + fail = false; + + // Get IDE Drive info + + //_interrupt_occurred = 0; + //end = sysUpTime() + 2000; + //while (/*(_interrupt_occurred & irqs[i]) == 0 &&*/ + //((stat = in(ports[i] + 7)) & ATA_READY) == 0) + /*{ + //putwchar('.'); + //wprintf(L"%d %d\r", sysUpTime(), end); + if (sysUpTime() >= end) + { + fail = true; + break; + } + } + + if (fail) + { + wprintf(L"%d: Drive isn't ready (stat = %x), trying anyway\n", i, stat); + //continue; + }*/ + + end = sysUpTime() + 2000; + while ((stat = in(ports[i] + ATA_REG_STATUS) & ATA_BUSY)) + { + if (sysUpTime() >= end) + { + fail = true; + break; + } + } + + if (fail) + { + wprintf(L"stat=%x: fail on wait BUSY = 0\n", stat); + continue; + } + + //_interrupt_occurred = 0; + + out(ports[i] + 6, units[i]); // Get first/second drive + + end = sysUpTime() + 2000; + while (((stat = in(ports[i] + ATA_REG_STATUS) & ATA_READY) == 0)) + { + if (sysUpTime() >= end) + { + fail = true; + break; + } + } + + if (fail) + { + wprintf(L"stat=%x: fail on wait READY = 1\n", stat); + continue; + } + + out(ports[i] + 7, ATA_CMD_ID); // Get drive info data + + end = sysUpTime() + 2000; + while (((stat = in(ports[i] + ATA_REG_STATUS) & ATA_DRQ) == 0)) + { + if ((stat & ATA_ERR) || + sysUpTime() >= end) + { + fail = true; + break; + } + } + + /*end = sysUpTime() + 2000; + fail = false; + + while (!_interrupt_occurred) + { + if (sysUpTime() >= end) + { + fail = true; + break; + } + } + + if (fail) + { + _cputws(L"not present\n"); + continue; + }*/ + + /* Wait for data ready */ + /* was ATA_READY | ATA_DSC | ATA_DRQ 58 */ + //while ((stat = in(ports[i] + 7)) != (ATA_READY | ATA_DSC)) + //while (//!_interrupt_occurred && + //(stat = in(ports[i] + 7)) != (ATA_READY | ATA_DSC | ATA_DRQ)) + //while (/*(_interrupt_occurred & irqs[i]) == 0 &&*/ + /* ((stat = in(ports[i] + 7)) & ATA_DRQ) == 0) + { + if (sysUpTime() >= end) + { + fail = true; + break; + } + }*/ + + //if (((stat = in(ports[i] + 7)) & ATA_DRQ) == 0) + if (fail) + { + wprintf(L"stat = %x, ATAPI? ", stat); + + _interrupt_occurred = 0; + out(ports[i] + 7, ATA_CMD_PID); /* Get ATAPI drive info data */ + + end = sysUpTime() + 2000; + fail = false; + /* Wait for data ready */ + //while ((stat = in(ports[i] + 7)) != (ATA_READY | ATA_DSC)) + while ((_interrupt_occurred & irqs[i]) == 0 && + ((stat = in(ports[i] + 7)) & ATA_DRQ) == 0) + { + if (sysUpTime() >= end) + { + fail = true; + break; + } + } + + if (fail) + { + wprintf(L"stat = %x, not present\n", stat); + continue; + } + } + + for (dd_off = 0; dd_off != 256; dd_off++) /* Read "sector" */ + dd[dd_off] = in16(ports[i]); + + /*wprintf(L"Model Number______________________: %s\n", ConvertName(dd, 27, 46)); + wprintf(L"Serial Number_____________________: %s\n", ConvertName(dd, 10, 19)); + wprintf(L"Controller Revision Number________: %s\n\n", ConvertName(dd, 23, 26)); + wprintf(L"Able to do Double Word Transfer___: %6s\n", (dd [48] == 0 ? L"No" : L"Yes")); + wprintf(L"Controller type___________________: %04X\n", dd [20]); + wprintf(L"Controller buffer size (bytes)____: %6u\n", dd [21] * 512); + wprintf(L"Number of ECC bytes transferred___: %6u\n", dd [22]); + wprintf(L"Number of sectors per interrupt___: %6u\n\n", dd [47]); + wprintf(L"Number of Cylinders (Fixed)_______: %6u\n", dd [1]); + wprintf(L"Number of Heads___________________: %6u\n", dd [3]); + wprintf(L"Number of Sectors per Track_______: %6u\n\n", dd [6]);*/ + + drive = new CAtaDrive; + drive->m_port = ports[i]; + drive->m_irq = irqs[i]; + drive->m_unit = units[i]; + drive->m_cylinders = dd[1]; + drive->m_heads = dd[3]; + drive->m_sectors = dd[6]; + drive->m_start_sector = 0; + drive->m_total_sectors = drive->m_sectors * drive->m_heads * drive->m_cylinders; + + if (((dd[119] & 1) != 0) && (dd[118] != 0)) + drive->m_mult_max = dd[94]; + else + drive->m_mult_max = 1; + + wcscpy(drive->m_name, ConvertName(dd, 27, 46)); + wcscat(drive->m_name, L" "); + wcscat(drive->m_name, ConvertName(dd, 10, 19)); + swprintf(str, L"ide%d", i); + sysExtRegisterDevice(str, drive); + wprintf(L"Registered %s => %s [ ", str, drive->m_name); + + if (drive->BlockRead(0, 1, dd)) + { + for (j = 0; j < 4; j++) + { + word c, h, s; + + c = parts[j].bStartCylinder | + ((word) parts[j].bStartSector & 0xc0) << 2; + h = parts[j].bStartHead; + s = parts[j].bStartSector & 0x3f; + + if (parts[j].bSystem) + { + /*wprintf(L"CHS\t%d:%d:%d\t" + L"System\t%x (%s)\t" + L"Start\t%d\t", + c, h, s, + parts[j].bSystem, + part_type(parts[j].bSystem), + parts[j].dwStartSector); + + wprintf(L"Size\t"); + kb = parts[j].dwSectorCount / 2; + if (kb > 1048576) + wprintf(L"%d Mb\n", kb / 1024); + else + wprintf(L"%d Kb\n", kb);*/ + + partdrive = new CAtaDrive; + *partdrive = *drive; + + partdrive->m_start_sector = parts[j].dwStartSector; + /*partdrive->m_start_sector = s + + h * partdrive->m_sectors + + c * partdrive->m_heads;*/ + partdrive->m_total_sectors = parts[j].dwSectorCount; + swprintf(str, L"ide%d%c", i, j + 'a'); + sysExtRegisterDevice(str, partdrive); + //wprintf(L"%c ", j + 'a'); + wprintf(L"%s ", part_type(parts[j].bSystem)); + + /*if (partdrive->BlockRead(0, 2, buf) == 2) + DumpBootSector(buf);*/ + } + } + } + + _cputws(L"]\n"); + + //_wgetch(); + } + + wprintf(L"Finished detection!\n"); + //for (;;) ; +} diff --git a/mobius/src/drivers/ata/ata.rc b/mobius/src/drivers/ata/ata.rc new file mode 100644 index 0000000..bcb9534 --- /dev/null +++ b/mobius/src/drivers/ata/ata.rc @@ -0,0 +1,105 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.K.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 0,1,0,0 + PRODUCTVERSION 0,1,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x0L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904b0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "ATA/ATAPI kernel drivers\0" + VALUE "FileVersion", "0.1.0.0\0" + VALUE "InternalName", "ata\0" + VALUE "LegalCopyright", "Copyright � 2001\0" + VALUE "OriginalFilename", "ata.dll\0" + VALUE "ProductName", "The M�bius operating system\0" + VALUE "ProductVersion", "0.1.0.0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1200 + END +END + +#endif // !_MAC + +#endif // English (U.K.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/mobius/src/drivers/ata/resource.h b/mobius/src/drivers/ata/resource.h new file mode 100644 index 0000000..493c9d4 --- /dev/null +++ b/mobius/src/drivers/ata/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by ata.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/mobius/src/drivers/cmos/Makefile b/mobius/src/drivers/cmos/Makefile new file mode 100644 index 0000000..530ef63 --- /dev/null +++ b/mobius/src/drivers/cmos/Makefile @@ -0,0 +1,7 @@ +TARGET= $(BIN)/cmos.drv +OBJS= cmos.o +BASE= cmos + +include ../make.driver + +include $(OBJS:.o=.d) \ No newline at end of file diff --git a/mobius/src/drivers/cmos/cmos.c b/mobius/src/drivers/cmos/cmos.c new file mode 100644 index 0000000..6b4900b --- /dev/null +++ b/mobius/src/drivers/cmos/cmos.c @@ -0,0 +1,254 @@ +#include +#include +#include + +#define DEBUG +#include + +/*! + * \ingroup drivers + * \defgroup cmos CMOS/RTC + * @{ + */ + +#define PCIDEV_RTC 0x1f00 + +#define CMOS_CTRL 0x70 +#define CMOS_DATA 0x71 + +#define RTC_SECOND 0 +#define RTC_MINUTE 2 +#define RTC_HOUR 4 +#define RTC_DAYMONTH 7 +#define RTC_MONTH 8 +#define RTC_YEAR 9 +#define RTC_STATUS_B 11 + +byte rtcRead(word port, byte reg) +{ + byte high_digit, low_digit; + out(port, reg); + high_digit = low_digit = in(port + 1); + /* convert from BCD to binary */ + high_digit >>= 4; + high_digit &= 0x0F; + low_digit &= 0x0F; + return 10 * high_digit + low_digit; +} + +/***************************************************************************** +Finds the number of days between two dates in the Gregorian calendar. +- it's a leap year if the year is divisible by 4, +- UNLESS the year is also divisible by 100, +- UNLESS the year is also divisible by 400 + +This code divides the time between start_day/start_year and end_day/end_year +into "slices": fourcent (400-year) slices in the middle, bracketed on +either end by century slices, fouryear (4-year) slices, and year slices. + +It's a highly generalized algorithm. If you call it with + greg_to_jdn(-4713, 327, curr_day_in_year, curr_year); +you get the true Julian Day Number +(JDN; days since Nov 24, 4714 BC/BCE in [proleptic] Gregorian calendar) +Call with + greg_to_jdn(1970, 0, curr_day_in_year, curr_year); +you get the number of days in the Unix epoch (since Jan 1, 1970) + +This algorithm produces identical results to the one shown here: + http://serendipity.magnet.ch/hermetic/cal_stud/jdn.htm +I think it's easier to see where my code came from, however. + +And don't worry about all that heavy-duty math. GCC is pretty +good at folding constants, and doing strength-reduction +(shifts instead of divides, AND instead of MOD, etc.) +*****************************************************************************/ +static long days_between_dates(short start_year, unsigned short start_day, + short end_year, unsigned short end_day) +{ + short fourcents, centuries, fouryears, years; + long days; + + fourcents = end_year / 400 - start_year / 400; + centuries = end_year / 100 - start_year / 100 - +/* subtract from 'centuries' the centuries already accounted for by +'fourcents' */ + fourcents * 4; + fouryears = end_year / 4 - start_year / 4 - +/* subtract from 'fouryears' the fouryears already accounted for by +'fourcents' and 'centuries' */ + fourcents * 100 - centuries * 25; + years = end_year - start_year - +/* subtract from 'years' the years already accounted for by +'fourcents', 'centuries', and 'fouryears' */ + 400 * fourcents - 100 * centuries - 4 * fouryears; +/* add it up: 97 leap days every fourcent */ + days = (365L * 400 + 97) * fourcents; +/* 24 leap days every residual century */ + days += (365L * 100 + 24) * centuries; +/* 1 leap day every residual fouryear */ + days += (365L * 4 + 1) * fouryears; +/* 0 leap days for residual years */ + days += (365L * 1) * years; +/* residual days (need the cast!) */ + days += ((long)end_day - start_day); +/* account for terminal leap year */ + if(end_year % 4 == 0 && end_day >= 60) + { + days++; + if(end_year % 100 == 0) + days--; + if(end_year % 400 == 0) + days++; + } +/* xxx - what have I wrought? I don't know what's going on here, +but the code won't work properly without it */ + if(end_year >= 0) + { + days++; + if(end_year % 4 == 0) + days--; + if(end_year % 100 == 0) + days++; + if(end_year % 400 == 0) + days--; + } + if(start_year > 0) + days--; + return days; +} + +/***************************************************************************** +NOTE: this function works only with local time, stored in the CMOS clock. +It knows nothing of GMT or timezones. +*****************************************************************************/ +#define EPOCH_YEAR 1970 +#define EPOCH_DAY 0 /* Jan 1 */ + +unsigned long sys_time(void) +{ + static const unsigned short days_to_date[12] = + { +/* jan feb mar apr may jun jul aug sep oct nov dec */ + 0, + 31, + 31 + 28, + 31 + 28 + 31, + 31 + 28 + 31 + 30, + 31 + 28 + 31 + 30 + 31, + 31 + 28 + 31 + 30 + 31 + 30, + 31 + 28 + 31 + 30 + 31 + 30 + 31, + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31, + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30, + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31, + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + }; + unsigned short day, month, hour, minute, second; + unsigned long time; + short year; + +/* b2=0 BCD mode, vs. binary (binary mode seems to be buggy) +b1=1 24-hour mode, vs. 12-hour mode + +### - This could be done once when the OS initializes, +instead of being done on every syscall. */ + out(CMOS_CTRL, RTC_STATUS_B); + out(CMOS_DATA, (in(CMOS_DATA) & ~6) | 2); +/* wait for stored time value to stop changing */ + out(CMOS_CTRL, 10); + while(in(CMOS_DATA) & 128) + /* nothing */; +/* get year (0-99) xxx - OH NO, Y2K! + year = read_cmos(9) + 1900; */ + year = rtcRead(CMOS_CTRL, RTC_YEAR) + 2000; +/* get month (1-12) */ + month = rtcRead(CMOS_CTRL, RTC_MONTH); +/* get date (1-31) */ + day = rtcRead(CMOS_CTRL, RTC_DAYMONTH); + TRACE3("Current date: MM/DD/YYYY=%u/%u/%u\n", + month, day, year); +/* convert date to (0-30) */ + day--; +/* convert month to (0-11), convert to days-to-date, add */ + day += days_to_date[month - 1]; + TRACE2("Epoch day/year=%u/%u\n", EPOCH_DAY, EPOCH_YEAR); + TRACE2("Current day/year=%u/%u\n", day, year); +/* convert to MJDN (days since Jan 1, 1970) */ + time = days_between_dates(EPOCH_YEAR, EPOCH_DAY, year, day); +/* read current time */ + hour = rtcRead(CMOS_CTRL, RTC_HOUR); /* 0-23 */ + minute = rtcRead(CMOS_CTRL, RTC_MINUTE); /* 0-59 */ + second = rtcRead(CMOS_CTRL, RTC_SECOND); /* 0-59 */ + TRACE3("Current time is %u:%u:%u\n", hour, minute, second); +/* convert time to hours, add current hour */ + time *= 24; + time += hour; +/* convert to minutes, add current minute */ + time *= 60; + time += minute; +/* convert to seconds, add current second */ + time *= 60; + time += second; + + return time; +} + +bool rtcRequest(device_t* dev, request_t* req) +{ + qword* qw; + + switch (req->code) + { + case DEV_REMOVE: + hndFree(dev); + + case DEV_OPEN: + case DEV_CLOSE: + hndSignal(req->event, true); + return true; + + case DEV_READ: + if (req->params.read.length < sizeof(qword)) + { + req->result = EBUFFER; + return false; + } + + qw = (qword*) req->params.read.buffer; + *qw = sys_time(); + hndSignal(req->event, true); + return true; + } + + req->result = ENOTIMPL; + return false; +} + +device_t* cmosAddDevice(driver_t* drv, const wchar_t* name, device_config_t* cfg) +{ + device_t* dev; + + TRACE2("cmos: %x/%x\n", cfg->vendor_id, cfg->device_id); + if (cfg->vendor_id != 0xffff) + return NULL; + + switch (cfg->device_id) + { + case PCIDEV_RTC: + dev = hndAlloc(sizeof(device_t), NULL); + dev->request = rtcRequest; + dev->driver = drv; + + TRACE2("CMOS %s installed; time = %u\n", name, sys_time()); + return dev; + } + + return NULL; +} + +bool STDCALL INIT_CODE drvInit(driver_t* drv) +{ + drv->add_device = cmosAddDevice; + return true; +} + +//@} \ No newline at end of file diff --git a/mobius/src/drivers/cmos/cmos.d b/mobius/src/drivers/cmos/cmos.d new file mode 100644 index 0000000..09f54cd --- /dev/null +++ b/mobius/src/drivers/cmos/cmos.d @@ -0,0 +1,13 @@ +cmos.o: cmos.c f:\Projects\mobius\include\kernel/kernel.h \ + f:\Projects\mobius\include\kernel/i386.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h f:\Projects\mobius\include\os/os.h \ + f:\Projects\mobius\include\kernel/driver.h \ + f:\Projects\mobius\include\kernel/proc.h \ + f:\Projects\mobius\include\kernel/obj.h \ + f:\Projects\mobius\include\os/pe.h \ + f:\Projects\mobius\include\kernel/handle.h \ + f:\Projects\mobius\include\os/devreq.h \ + f:\Projects\mobius\include\sys/error.h \ + f:\Projects\mobius\include\errno.h \ + f:\Projects\mobius\include\kernel/debug.h diff --git a/mobius/src/drivers/cmos/cmos.dsp b/mobius/src/drivers/cmos/cmos.dsp new file mode 100644 index 0000000..efd99ec --- /dev/null +++ b/mobius/src/drivers/cmos/cmos.dsp @@ -0,0 +1,105 @@ +# Microsoft Developer Studio Project File - Name="cmos" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=cmos - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "cmos.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "cmos.mak" CFG="cmos - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "cmos - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "cmos - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "cmos - Win32 Release" + +# PROP BASE Use_MFC +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f cmos.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "cmos.exe" +# PROP BASE Bsc_Name "cmos.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\cmos.drv" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "cmos - Win32 Debug" + +# PROP BASE Use_MFC +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f cmos.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "cmos.exe" +# PROP BASE Bsc_Name "cmos.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\cmos.drv" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "cmos - Win32 Release" +# Name "cmos - Win32 Debug" + +!IF "$(CFG)" == "cmos - Win32 Release" + +!ELSEIF "$(CFG)" == "cmos - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\cmos.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/common/driver.h b/mobius/src/drivers/common/driver.h new file mode 100644 index 0000000..c108b84 --- /dev/null +++ b/mobius/src/drivers/common/driver.h @@ -0,0 +1,15 @@ +#ifndef __DRIVER_H +#define __DRIVER_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/drivers.dsw b/mobius/src/drivers/drivers.dsw new file mode 100644 index 0000000..79d3769 --- /dev/null +++ b/mobius/src/drivers/drivers.dsw @@ -0,0 +1,173 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "ata"=.\ata\ata.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "cmos"=.\cmos\cmos.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "fat"=.\fat\fat.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "fdc"=.\fdc\fdc.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "isa"=.\isa\isa.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "kdebug"=.\kdebug\kdebug.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "keyboard"=.\keyboard\keyboard.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "pci"=.\pci\pci.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "ps2mouse"=.\ps2mouse\ps2mouse.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "sermouse"=.\sermouse\sermouse.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "sound"=.\sound\sound.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "vga"=.\vga\vga.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "vgatext"=.\vgatext\vgatext.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/mobius/src/drivers/drivers.opt b/mobius/src/drivers/drivers.opt new file mode 100644 index 0000000..3599f1b --- /dev/null +++ b/mobius/src/drivers/drivers.opt @@ -0,0 +1 @@ +��ࡱ \ No newline at end of file diff --git a/mobius/src/drivers/fat/Makefile b/mobius/src/drivers/fat/Makefile new file mode 100644 index 0000000..99c4951 --- /dev/null +++ b/mobius/src/drivers/fat/Makefile @@ -0,0 +1,7 @@ +TARGET= $(BIN)/fat.drv +OBJS= fat.o +BASE= fat + +include ../make.driver + +include $(OBJS:.o=.d) \ No newline at end of file diff --git a/mobius/src/drivers/fat/fat.c b/mobius/src/drivers/fat/fat.c new file mode 100644 index 0000000..57dfd92 --- /dev/null +++ b/mobius/src/drivers/fat/fat.c @@ -0,0 +1,530 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fat.h" + +//#define DEBUG +#include + +//! \ingroup fat +//@{ + +typedef struct fat_root_t fat_root_t; +struct fat_root_t +{ + device_t dev; + device_t *disk; + fat_bootsector_t boot_sector; + byte *fat; + byte fat_bits; + dword bytes_per_cluster; + dword data_start, root_start; +}; + +typedef struct fat_file_t fat_file_t; +struct fat_file_t +{ + file_t file; + fat_dirent_t entry; + qword cached_pos; + dword cached_cluster; +}; + +#define FAT_AVAILABLE 0 +#define FAT_RESERVED_START 0xfff0 +#define FAT_RESERVED_END 0xfff6 +#define FAT_BAD 0xfff7 +#define FAT_EOC_START 0xfff8 +#define FAT_EOC_END 0xffff + +#define IS_EOC_CLUSTER(c) ((c) >= FAT_EOC_START && (c) <= FAT_EOC_END) + +void dump(const byte* buf, size_t size) +{ + int j; + + for (j = 0; j < size; j++) + wprintf(L"%02x ", buf[j]); + + _cputws(L"\n"); +} + +dword fatGetNextCluster(fat_root_t* root, dword cluster) +{ + dword FATOffset; + word w; + byte* b; + + assert(cluster < + root->boot_sector.sectors / root->boot_sector.sectors_per_cluster); + switch (root->fat_bits) + { + case 12: + FATOffset = cluster + cluster / 2; + break; + case 16: + FATOffset = cluster * 2; + break; + } + + b = root->fat + FATOffset; + w = *(word*) b; + //dump(b - 2, 16); + + if (root->fat_bits == 12) + { + if (cluster & 1) // cluster is odd + w >>= 4; + else // cluster is even + w &= 0xfff; + + if (w >= 0xff0) + w |= 0xf000; + } + + /*wprintf(L"FATOffset = 0x%x = 0x%x, w = 0x%04x = 0x%02x%02x\n", + FATOffset, + FATOffset + root->boot_sector.reserved_sectors * + root->boot_sector.bytes_per_sector, + w, + b[1], b[0]);*/ + return w; +} + +bool fatLookupEntry(fat_root_t* root, dword cluster, + const wchar_t* filename, bool is_root, fat_dirent_t* entry) +{ + union + { + fat_dirent_t di; + fat_lfnslot_t lfn; + } u[512 / sizeof(fat_dirent_t)]; + wchar_t name[MAX_PATH], temp[14], *nameptr; + size_t length; + int i, j, k; + qword pos; + + if (is_root) + cluster = 0; + + while (true) + { + if (is_root) + pos = (root->root_start + cluster) * root->boot_sector.bytes_per_sector; + else + pos = root->data_start * root->boot_sector.bytes_per_sector + + (cluster - 2) * root->bytes_per_cluster; + + //wprintf(L"fatLookupEntry%s: cluster = %d pos = 0x%x\n", + //is_root ? L"(root)" : L"", cluster, (dword) pos); + length = sizeof(u); + if (devReadSync(root->disk, pos, u, &length)) + { + wprintf(L"fatLookupEntry: disk read failed\n"); + return false; + } + + for (j = 0; j < countof(u); j++) + { + if (u[j].di.name[0] == 0) + { + wprintf(L"fatLookupEntry: end of directory\n"); + return false; + } + if (u[j].di.name[0] != 0xe5) + { + memset(name, 0, sizeof(name)); + + if ((u[j].di.attribs & ATTR_LONG_NAME) == 0) + { + for (i = 0; i < 8; i++) + { + if (u[j].di.name[i] == ' ') + { + name[i] = 0; + break; + } + else if (iswupper(u[j].di.name[i])) + name[i] = towlower(u[j].di.name[i]); + else + name[i] = u[j].di.name[i]; + } + + if (u[j].di.extension[0] != ' ') + { + wcscat(name, L"."); + + k = wcslen(name); + for (i = 0; i < 3; i++) + { + if (u[j].di.extension[i] == ' ') + { + name[i + k] = 0; + break; + } + else if (iswupper(u[j].di.extension[i])) + name[i + k] = towlower(u[j].di.extension[i]); + else + name[i + k] = u[j].di.extension[i]; + } + } + } + else + { + //int lfn_start = j; + while ((u[j].di.attribs & ATTR_LONG_NAME) == ATTR_LONG_NAME) + { + //wprintf(L" ", u[j].di.name[0]); + if (u[j].di.name[0] != 0xe5) + { + memset(temp, 0, sizeof(temp)); + nameptr = temp; + + for (i = 0; i < 5; i++) + { + *nameptr = u[j].lfn.name0_4[i]; + nameptr++; + } + + for (i = 0; i < 6; i++) + { + *nameptr = u[j].lfn.name5_10[i]; + nameptr++; + } + + for (i = 0; i < 2; i++) + { + *nameptr = u[j].lfn.name11_12[i]; + nameptr++; + } + + i = wcslen(temp); + memmove(name + i, name, wcslen(name) * sizeof(wchar_t)); + memcpy(name, temp, i * sizeof(wchar_t)); + } + + j++; + } + + //j = lfn_start; + } + + if (name[0]) + { + TRACE2("%s\t\t%x\n", name, u[j].di.first_cluster); + if (wcsicmp(name, filename) == 0) + { + *entry = u[j].di; + TRACE2("%s: found at cluster %x\n", + name, u[j].di.first_cluster); + return true; + } + } + } + } + + if (is_root) + { + cluster++; + + if (cluster >= + (root->boot_sector.num_root_entries * 32) / root->boot_sector.bytes_per_sector) + { + wprintf(L"fatLookupEntry(root): end of chain\n"); + return false; + } + } + else + { + cluster = fatGetNextCluster(root, cluster); + if (IS_EOC_CLUSTER(cluster)) + { + wprintf(L"fatLookupEntry: end of chain\n"); + return false; + } + } + } + + return false; +} + +dword fatFindCluster(fat_file_t* file, qword pos) +{ + fat_root_t *root = (fat_root_t*) file->file.fsd; + qword ptr; + dword cluster; + + cluster = (dword) file->entry.first_cluster; + //wprintf(L"fatFindCluster: first_cluster = 0x%x\n", file->entry.first_cluster); + ptr = root->bytes_per_cluster; + while (ptr <= pos) + { + if (IS_EOC_CLUSTER(cluster)) + return -1; + + ptr += root->bytes_per_cluster; + cluster = fatGetNextCluster(root, cluster); + } + + return cluster; +} + +bool fatOpenFile(fat_root_t* root, request_t* req) +{ + wchar_t *ch, component[MAX_PATH]; + const wchar_t* path; + dword cluster; + fat_file_t *fd; + bool is_root; + fat_dirent_t entry; + + path = req->params.fs_open.name + 1; + cluster = 0; + is_root = true; + + while ((ch = wcschr(path, '/'))) + { + wcsncpy(component, path, ch - path); + path += wcslen(component) + 1; + + //wprintf(L"fatLookupEntry: %s @ %d\n", component, cluster); + if (!fatLookupEntry(root, cluster, component, is_root, &entry)) + { + req->result = ENOTFOUND; + return false; + } + + is_root = false; + cluster = entry.first_cluster; + } + + if (!fatLookupEntry(root, cluster, path, is_root, &entry)) + { + req->result = ENOTFOUND; + return false; + } + + fd = hndAlloc(sizeof(fat_file_t), NULL); + fd->file.fsd = &root->dev; + fd->file.pos = 0; + fd->entry = entry; + fd->cached_pos = 0; + fd->cached_cluster = entry.first_cluster; + + req->params.fs_open.fd = &fd->file; + hndSignal(req->event, true); + return true; +} + +bool fatReadFile(fat_root_t* root, request_t* req) +{ + fat_file_t* file; + dword cluster, diff; + qword cluster_pos, user_pos; + size_t length, this_cluster; + status_t hr; + + file = (fat_file_t*) req->params.fs_read.fd; + + if (file->file.pos != file->cached_pos) + file->cached_cluster = fatFindCluster(file, file->file.pos); + + cluster = file->cached_cluster; + req->user_length = req->params.fs_read.length; + req->params.fs_read.length = 0; + this_cluster = 0; + + TRACE1("[%x] ", cluster); + while (req->params.fs_read.length < req->user_length) + { + user_pos = file->file.pos + req->params.fs_read.length; + user_pos &= -root->bytes_per_cluster; + diff = file->file.pos + req->params.fs_read.length - user_pos; + + cluster_pos = root->data_start * root->boot_sector.bytes_per_sector + + (cluster - 2) * root->bytes_per_cluster + this_cluster + + diff; + TRACE1("(%lu) ", (unsigned long) cluster_pos); + length = min(req->user_length - req->params.fs_read.length, + root->bytes_per_cluster); + /*if (length < root->boot_sector.bytes_per_sector) + length = root->boot_sector.bytes_per_sector;*/ + + //wprintf(L"fatReadFile: pos = %d cluster = 0x%x length = %d\n", + //(dword) file->file.pos, + //cluster, + //length); + + hr = devReadSync(root->disk, + cluster_pos, + (byte*) req->params.fs_read.buffer + req->params.fs_read.length, + &length); + + if (hr || length == 0) + { + wprintf(L"fatReadFile: disk read failed at %u\n", + (unsigned long) cluster_pos); + req->result = hr; + file->cached_pos = file->file.pos; + file->cached_cluster = cluster; + return false; + } + + req->params.fs_read.length += length; + file->file.pos += length; + + if (IS_EOC_CLUSTER(cluster)) + break; + + this_cluster += length; + if (this_cluster >= root->bytes_per_cluster) + { + cluster = fatGetNextCluster(root, cluster); + this_cluster -= root->bytes_per_cluster; + } + + TRACE2("read %d bytes; next cluster = %x\n", length, cluster); + } + + //wprintf(L"fat: finished read\n"); + file->cached_pos = file->file.pos; + file->cached_cluster = cluster; + hndSignal(req->event, true); + return true; +} + +bool fatRequest(device_t* dev, request_t* req) +{ + fat_root_t* root = (fat_root_t*) dev; + + switch (req->code) + { + case FS_CLOSE: + hndFree(req->params.fs_close.fd); + + case DEV_OPEN: + case DEV_CLOSE: + hndSignal(req->event, true); + return true; + + case FS_OPEN: + return fatOpenFile(root, req); + + case FS_READ: + return fatReadFile(root, req); + + case FS_GETLENGTH: + { + fat_file_t *fd = (fat_file_t*) req->params.fs_getlength.fd; + req->params.fs_getlength.length = fd->entry.file_length; + hndSignal(req->event, true); + return true; + } + } + + req->code = ENOTIMPL; + return false; +} + +device_t* fatMountFs(driver_t* driver, const wchar_t* path, device_t* dev) +{ + fat_root_t *root; + size_t length; + dword RootDirSectors, FatSectors; + //byte* temp; + block_size_t size; + request_t req; + + root = hndAlloc(sizeof(fat_root_t), NULL); + root->dev.driver = driver; + root->dev.request = fatRequest; + root->disk = dev; + + size.total_blocks = 0; + req.code = BLK_GETSIZE; + req.params.buffered.buffer = (addr_t) &size; + req.params.buffered.length = sizeof(size); + if (devRequestSync(root->disk, &req) != 0 || + size.total_blocks > 20740) + { + TRACE1("Total blocks = %d, using FAT16\n", size.total_blocks); + root->fat_bits = 16; + } + else + { + TRACE1("Total blocks = %d, using FAT12\n", size.total_blocks); + root->fat_bits = 12; + } + + length = sizeof(fat_bootsector_t); + if (devReadSync(root->disk, 0, &root->boot_sector, &length) || + length < sizeof(fat_bootsector_t)) + { + hndFree(root); + return NULL; + } + + assert(root->boot_sector.sectors_per_fat != 0); + assert(root->boot_sector.bytes_per_sector != 0); + + root->bytes_per_cluster = root->boot_sector.bytes_per_sector * + root->boot_sector.sectors_per_cluster; + + root->fat = malloc(root->boot_sector.sectors_per_fat * + root->boot_sector.bytes_per_sector); + assert(root->fat != NULL); + + TRACE2("FAT starts at sector %d = 0x%x\n", + root->boot_sector.reserved_sectors, + root->boot_sector.reserved_sectors * + root->boot_sector.bytes_per_sector); + + length = root->boot_sector.sectors_per_fat * + root->boot_sector.bytes_per_sector; + if (devReadSync(root->disk, + root->boot_sector.reserved_sectors * + root->boot_sector.bytes_per_sector, + root->fat, + &length)) + { + free(root->fat); + hndFree(root); + return NULL; + } + + RootDirSectors = (root->boot_sector.num_root_entries * 32) / + root->boot_sector.bytes_per_sector; + FatSectors = root->boot_sector.num_fats * root->boot_sector.sectors_per_fat; + root->data_start = root->boot_sector.reserved_sectors + + FatSectors + + RootDirSectors; + + root->root_start = root->boot_sector.reserved_sectors + + root->boot_sector.hidden_sectors + + root->boot_sector.sectors_per_fat * + root->boot_sector.num_fats; + + /*length = root->boot_sector.num_root_entries * 32; + temp = malloc(length); + devReadSync(root->disk, root->root_start * root->boot_sector.bytes_per_sector, + temp, &length); + free(temp);*/ + + return &root->dev; +} + +bool STDCALL drvInit(driver_t* drv) +{ + drv->add_device = NULL; + drv->mount_fs = fatMountFs; + return true; +} + +//@} \ No newline at end of file diff --git a/mobius/src/drivers/fat/fat.d b/mobius/src/drivers/fat/fat.d new file mode 100644 index 0000000..30a499f --- /dev/null +++ b/mobius/src/drivers/fat/fat.d @@ -0,0 +1,21 @@ +fat.o: fat.c f:\Projects\mobius\include\kernel/kernel.h \ + f:\Projects\mobius\include\kernel/i386.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h f:\Projects\mobius\include\os/os.h \ + f:\Projects\mobius\include\kernel/driver.h \ + f:\Projects\mobius\include\kernel/proc.h \ + f:\Projects\mobius\include\kernel/obj.h \ + f:\Projects\mobius\include\os/pe.h \ + f:\Projects\mobius\include\kernel/handle.h \ + f:\Projects\mobius\include\os/devreq.h \ + f:\Projects\mobius\include\kernel/fs.h \ + f:\Projects\mobius\include\errno.h \ + f:\Projects\mobius\include\stdlib.h \ + f:\Projects\mobius\include\malloc.h \ + f:\Projects\mobius\include\string.h \ + f:\Projects\mobius\include\ctype.h \ + f:\Projects\mobius\include\os/blkdev.h \ + f:\Projects\mobius\include\os/fs.h fat.h \ + f:\Projects\mobius\include\kernel/debug.h \ + f:\Projects\mobius\include\stdio.h \ + f:\Projects\mobius\include\stdarg.h f:\Projects\mobius\include\io.h diff --git a/mobius/src/drivers/fat/fat.dsp b/mobius/src/drivers/fat/fat.dsp new file mode 100644 index 0000000..4793ef2 --- /dev/null +++ b/mobius/src/drivers/fat/fat.dsp @@ -0,0 +1,109 @@ +# Microsoft Developer Studio Project File - Name="fat" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=fat - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "fat.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "fat.mak" CFG="fat - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "fat - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "fat - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "fat - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f fat.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "fat.exe" +# PROP BASE Bsc_Name "fat.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\fat.drv" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "fat - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f fat.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "fat.exe" +# PROP BASE Bsc_Name "fat.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "set" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\fat.drv" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "fat - Win32 Release" +# Name "fat - Win32 Debug" + +!IF "$(CFG)" == "fat - Win32 Release" + +!ELSEIF "$(CFG)" == "fat - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\fat.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\fat.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/fat/fat.h b/mobius/src/drivers/fat/fat.h new file mode 100644 index 0000000..071239e --- /dev/null +++ b/mobius/src/drivers/fat/fat.h @@ -0,0 +1,72 @@ +#ifndef __FAT_H +#define __FAT_H + +/*! + * \ingroup drivers + * \defgroup fat FAT file system + * @{ + */ + +#pragma pack(push, 1) + +typedef struct fat_bootsector_t fat_bootsector_t; +struct fat_bootsector_t +{ + word jmp; + byte nop; + byte oem_name[8]; + word bytes_per_sector; + byte sectors_per_cluster; + word reserved_sectors; + byte num_fats; + word num_root_entries; + word sectors; + byte media_descriptor; + word sectors_per_fat; + word sectors_per_track; + word num_heads; + dword hidden_sectors; + dword total_sectors; + byte drive; + byte reserved2; + byte boot_sig; + dword serial_number; + byte volume[11]; + byte system[8]; + byte code[450]; +}; + +typedef struct fat_dirent_t fat_dirent_t; +struct fat_dirent_t +{ + byte name[8]; + byte extension[3]; + byte attribs; + byte reserved[10]; + word write_time; + word write_date; + word first_cluster; + dword file_length; +}; + +typedef struct fat_lfnslot_t fat_lfnslot_t; +struct fat_lfnslot_t +{ + byte id; // sequence number for slot + wchar_t name0_4[5]; // first 5 characters in name + byte attrivs; // attribute byte + byte reserved; // always 0 + byte alias_checksum; // checksum for 8.3 alias + wchar_t name5_10[6]; // 6 more characters in name + word first_cluster; // starting cluster number + wchar_t name11_12[2]; // last 2 characters in name +}; + +#pragma pack(pop) + +#define ATTR_LONG_NAME \ + (ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID) + +//@} + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/fat/fat.plg b/mobius/src/drivers/fat/fat.plg new file mode 100644 index 0000000..b4f3dae --- /dev/null +++ b/mobius/src/drivers/fat/fat.plg @@ -0,0 +1,54 @@ + + +
+

Build Log

+

+--------------------Configuration: fat - Win32 Debug-------------------- +

+ +ALLUSERSPROFILE=I:\Documents and Settings\All Users +APPDATA=I:\Documents and Settings\Tim Robinson\Application Data +BLASTER=A220 I7 D1 T2 +CommonProgramFiles=I:\Program Files\Common Files +COMPUTERNAME=TIM +ComSpec=I:\WINNT\system32\cmd.exe +HOMEDRIVE=I: +HOMEPATH=\ +include=F:\Program Files\Microsoft Visual Studio\VC98\INCLUDE;F:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE;F:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE +INTDIR=.\Debug +lib=F:\Program Files\Microsoft Visual Studio\VC98\LIB;F:\Program Files\Microsoft Visual Studio\VC98\MFC\LIB +LOGONSERVER=\\TIM +MSDevDir=F:\Program Files\Microsoft Visual Studio\Common\MSDev98 +NUMBER_OF_PROCESSORS=1 +OS=Windows_NT +Os2LibPath=I:\WINNT\system32\os2\dll; +OUTDIR=.\Debug +Path=F:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;F:\Program Files\Microsoft Visual Studio\VC98\BIN;F:\Program Files\Microsoft Visual Studio\Common\TOOLS;F:\Program Files\Microsoft Visual Studio\Common\TOOLS\WINNT;I:\WINNT\system32;I:\WINNT;I:\WINNT\System32\Wbem +PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH +PROCESSOR_ARCHITECTURE=x86 +PROCESSOR_IDENTIFIER=x86 Family 6 Model 7 Stepping 3, GenuineIntel +PROCESSOR_LEVEL=6 +PROCESSOR_REVISION=0703 +ProgramFiles=I:\Program Files +PROMPT=$P$G +SNDSCAPE=D:\WINDOWS +SystemDrive=I: +SystemRoot=I:\WINNT +TEMP=I:\DOCUME~1\TIMROB~1\LOCALS~1\Temp +TMP=I:\DOCUME~1\TIMROB~1\LOCALS~1\Temp +USERDOMAIN=TIM +USERNAME=Tim Robinson +USERPROFILE=I:\Documents and Settings\Tim Robinson +VIM=c:\unix\usr\local\wbin +windir=I:\WINNT +_ACP_LIB=F:\Program Files\Microsoft Visual Studio\VC98\LIB;F:\Program Files\Microsoft Visual Studio\VC98\MFC\LIB +_ACP_PATH=F:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;F:\Program Files\Microsoft Visual Studio\VC98\BIN;F:\Program Files\Microsoft Visual Studio\Common\TOOLS;F:\Program Files\Microsoft Visual Studio\Common\TOOLS\WINNT;I:\WINNT\system32;I:\WINNT;I:\WINNT\System32\Wbem +_MSDEV_BLD_ENV_=1 + + + +

Results

+fat.drv - 0 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/drivers/fdc/Makefile b/mobius/src/drivers/fdc/Makefile new file mode 100644 index 0000000..211db9e --- /dev/null +++ b/mobius/src/drivers/fdc/Makefile @@ -0,0 +1,11 @@ +# +# Floppy Controller code makefile +# + +TARGET= $(BIN)/fdc.drv +OBJS= fdc.o util.o +BASE= fdc + +include ../make.driver + +include $(OBJS:.o=.d) diff --git a/mobius/src/drivers/fdc/fdc.c b/mobius/src/drivers/fdc/fdc.c new file mode 100644 index 0000000..f8ff19a --- /dev/null +++ b/mobius/src/drivers/fdc/fdc.c @@ -0,0 +1,674 @@ +/* + * fdc.c + * + * floppy controller handler functions + * + * Copyright (C) 1998 Fabian Nunez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * The author can be reached by email at: fabian@cs.uct.ac.za + * + * or by airmail at: Fabian Nunez + * 10 Eastbrooke + * Highstead Road + * Rondebosch 7700 + * South Africa + */ + +#include +#include +#include +#include +#include +#include +#include +#include "util.h" +#include "fdc.h" + +#include + +//! \ingroup fdc +//!@{ + +/* globals */ +struct Fdc +{ + device_t dev; + + volatile bool done; + bool dchange; + bool motor; + dword motor_end; + byte status[7]; + byte statsz; + byte sr0; + byte fdc_track; + DrvGeom geometry; + + long tbaddr; /* physical address of track buffer located below 1M */ +}; + +/* prototypes */ +void sendbyte(byte b); +unsigned getbyte(); +void int1c(Fdc* fdc); +bool fdcWait(Fdc* fdc, bool sensei); +bool fdc_rw(Fdc* fdc, int block,byte *blockbuff,bool read); + +/* helper functions */ + +/* deinit driver */ +void fdcCleanup(Fdc* fdc) +{ + //set_irq_handler(6,NULL,&oldirq6); + //wprintf(L"uninstalling IRQ6 handler\n"); + //set_irq_handler(0x1c,NULL,&oldint1c); + //wprintf(L"uninstalling timer handler\n"); + + devRegisterIrq(&fdc->dev, 6, false); + devRegisterIrq(&fdc->dev, 0, false); + + /* stop motor forcefully */ + out(FDC_DOR, FDC_DOR_ENABLE | FDC_DOR_IRQIO); +} + +/* sendbyte() routine from intel manual */ +void sendbyte(byte b) +{ + volatile int msr; + int tmo; + + for (tmo = 0;tmo < 128;tmo++) { + msr = in(FDC_MSR); + if ((msr & 0xc0) == 0x80) { + out(FDC_DATA, b); + return; + } + in(0x80); /* delay */ + } +} + +/* getbyte() routine from intel manual */ +unsigned getbyte() +{ + volatile int msr; + int tmo; + + for (tmo = 0;tmo < 128;tmo++) { + msr = in(FDC_MSR); + if ((msr & 0xd0) == 0xd0) { + return in(FDC_DATA); + } + in(0x80); /* delay */ + } + + return (unsigned) -1; /* read timeout */ +} + +/* this waits for FDC command to complete */ +bool fdcWait(Fdc* fdc, bool sensei) +{ + dword timeout_end = sysUpTime() + 1000; /* set timeout to 1 second */ + bool failed; + + failed = false; + /* wait for IRQ6 handler to signal command finished */ + enable(); + while (!fdc->done) + if (sysUpTime() > timeout_end) + { + failed = true; + break; + } + + /* read in command result bytes */ + fdc->statsz = 0; + while ((fdc->statsz < 7) && (in(FDC_MSR) & (1<<4))) { + fdc->status[fdc->statsz++] = getbyte(); + } + + if (sensei) { + /* send a "sense interrupt status" command */ + sendbyte(CMD_SENSEI); + fdc->sr0 = getbyte(); + fdc->fdc_track = getbyte(); + } + + fdc->done = false; + + if (failed) { + /* timed out! */ + if (in(FDC_DIR) & 0x80) /* check for diskchange */ + fdc->dchange = true; + + return false; + } else + return true; +} + +/* + * converts linear block address to head/track/sector + * + * blocks are numbered 0..heads*tracks*spt-1 + * blocks 0..spt-1 are serviced by head #0 + * blocks spt..spt*2-1 are serviced by head 1 + * + * WARNING: garbage in == garbage out + */ +void block2hts(Fdc* fdc, int block,int *head,int *track,int *sector) +{ + *head = (block % (fdc->geometry.spt * fdc->geometry.heads)) / (fdc->geometry.spt); + *track = block / (fdc->geometry.spt * fdc->geometry.heads); + *sector = block % fdc->geometry.spt + 1; +} + +/**** disk operations ****/ + +/* this gets the FDC to a known state */ +void fdcReset(Fdc* fdc) +{ + /* stop the motor and disable IRQ/DMA */ + out(FDC_DOR, 0); + + fdc->motor_end = -1; + fdc->motor = false; + + /* program data rate (500K/s) */ + //out(FDC_DRS,0); + + /* re-enable interrupts */ + out(FDC_DOR, FDC_DOR_ENABLE | FDC_DOR_IRQIO); + + /* resetting triggered an interrupt - handle it */ + fdc->done = true; + fdcWait(fdc, true); + + /* specify drive timings (got these off the BIOS) */ + sendbyte(CMD_SPECIFY); + sendbyte(0xdf); /* SRT = 3ms, HUT = 240ms */ + sendbyte(0x02); /* HLT = 16ms, ND = 0 */ + + /* clear "disk change" status */ + fdcSeek(fdc, 1); + fdcRecalibrate(fdc); + + fdc->dchange = false; +} + +/* this returns whether there was a disk change */ +bool fdcDiskChange(Fdc* fdc) +{ + return fdc->dchange; +} + +/* this turns the motor on */ +void fdcMotorOn(Fdc* fdc) +{ + if (!fdc->motor) + { + out(FDC_DOR, FDC_DOR_MOTOR0 | FDC_DOR_ENABLE | FDC_DOR_IRQIO); + msleep(500); /* delay 500ms for motor to spin up */ + fdc->motor = true; + //TRACE0("floppy: motor on\n"); + } + + fdc->motor_end = -1; /* stop motor kill countdown */ +} + +/* this turns the motor off */ +void fdcMotorOff(Fdc* fdc) +{ + if (fdc->motor) { + fdc->motor_end = sysUpTime() + 2000; /* start motor kill countdown: 36 ticks ~ 2s */ + } +} + +/* recalibrate the drive */ +void fdcRecalibrate(Fdc* fdc) +{ + /* turn the motor on */ + fdcMotorOn(fdc); + + /* send actual command bytes */ + sendbyte(CMD_RECAL); + sendbyte(0); + + /* wait until seek finished */ + fdcWait(fdc, true); + + /* turn the motor off */ + fdcMotorOff(fdc); +} + +/* seek to track */ +bool fdcSeek(Fdc* fdc, int track) +{ + if (fdc->fdc_track == track) /* already there? */ + return true; + + fdcMotorOn(fdc); + + /* send actual command bytes */ + sendbyte(CMD_SEEK); + sendbyte(0); + sendbyte(track); + + /* wait until seek finished */ + if (!fdcWait(fdc, true)) + return false; /* timeout! */ + + /* now let head settle for 15ms */ + msleep(15); + + fdcMotorOff(fdc); + + /* check that seek worked */ + if ((fdc->sr0 != 0x20) || (fdc->fdc_track != track)) + return false; + else + return true; +} + +/* checks drive geometry - call this after any disk change */ +bool fdcLogDisk(Fdc* fdc, DrvGeom *g) +{ + /* get drive in a known status before we do anything */ + fdcReset(fdc); + + /* assume disk is 1.68M and try and read block #21 on first track */ + fdc->geometry.heads = DG168_HEADS; + fdc->geometry.tracks = DG168_TRACKS; + fdc->geometry.spt = DG168_SPT; + + if (fdcReadBlock(fdc, 20,NULL)) { + /* disk is a 1.68M disk */ + if (g) { + g->heads = fdc->geometry.heads; + g->tracks = fdc->geometry.tracks; + g->spt = fdc->geometry.spt; + } + return true; + } + + /* OK, not 1.68M - try again for 1.44M reading block #18 on first track */ + fdc->geometry.heads = DG144_HEADS; + fdc->geometry.tracks = DG144_TRACKS; + fdc->geometry.spt = DG144_SPT; + + if (fdcReadBlock(fdc, 17,NULL)) { + /* disk is a 1.44M disk */ + if (g) { + g->heads = fdc->geometry.heads; + g->tracks = fdc->geometry.tracks; + g->spt = fdc->geometry.spt; + } + return true; + } + + /* it's not 1.44M or 1.68M - we don't support it */ + return false; +} + +/* read block (blockbuff is 512 byte buffer) */ +bool fdcReadBlock(Fdc* fdc, int block,byte *blockbuff) +{ + return fdc_rw(fdc, block,blockbuff,true); +} + +/* write block (blockbuff is 512 byte buffer) */ +bool fdcWriteBlock(Fdc* fdc, int block,byte *blockbuff) +{ + return fdc_rw(fdc, block,blockbuff,false); +} + +/* + * since reads and writes differ only by a few lines, this handles both. This + * function is called by read_block() and write_block() + */ +bool fdc_rw(Fdc* fdc, int block,byte *blockbuff,bool read) +{ + int head,track,sector,tries,i; + + /* convert logical address into physical address */ + block2hts(fdc, block,&head,&track,§or); + TRACE4("block %d = %d:%02d:%02d\n",block,head,track,sector); + + /* spin up the disk */ + fdcMotorOn(fdc); + + if (!read && blockbuff) + { + /* copy data from data buffer into track buffer */ + //movedata(_my_ds(),(long)blockbuff,_dos_ds,tbaddr,512); + memcpy((void*) fdc->tbaddr, blockbuff, 512); + } + + for (tries = 0;tries < 3;tries++) + { + TRACE1("attempt %d\t", tries); + /* check for diskchange */ + if (in(FDC_DIR) & 0x80) + { + fdc->dchange = true; + fdcSeek(fdc, 1); /* clear "disk change" status */ + fdcRecalibrate(fdc); + fdcMotorOff(fdc); + return false; + } + + /* move head to right track */ + TRACE0("seek\t"); + if (!fdcSeek(fdc, track)) + { + fdcMotorOff(fdc); + return false; + } + + /* program data rate (500K/s) */ + out(FDC_CCR, FDC_CCR_500K); + + /* send command */ + if (read) + { + TRACE0("dma\t"); + dma_xfer(2,fdc->tbaddr,512,false); + TRACE0("read\t"); + sendbyte(CMD_READ); + } else + { + TRACE0("dma\t"); + dma_xfer(2,fdc->tbaddr,512,true); + TRACE0("write\t"); + sendbyte(CMD_WRITE); + } + + sendbyte(head << 2); + sendbyte(track); + sendbyte(head); + sendbyte(sector); + sendbyte(2); /* 512 bytes/sector */ + sendbyte(fdc->geometry.spt); + if (fdc->geometry.spt == DG144_SPT) + sendbyte(DG144_GAP3RW); /* gap 3 size for 1.44M read/write */ + else + sendbyte(DG168_GAP3RW); /* gap 3 size for 1.68M read/write */ + sendbyte(0xff); /* DTL = unused */ + + /* wait for command completion */ + /* read/write don't need "sense interrupt status" */ + TRACE0("wait\t"); + if (!fdcWait(fdc, false)) + { + TRACE0("failed\n"); + return false; /* timed out! */ + } + + TRACE0("finished\n"); + if ((fdc->status[0] & 0xc0) == 0) break; /* worked! outta here! */ + + fdcRecalibrate(fdc); /* oops, try again... */ + } + + /* stop the motor */ + fdcMotorOff(fdc); + + if (read && blockbuff) { + /* copy data from track buffer into data buffer */ + //movedata(_dos_ds,tbaddr,_my_ds(),(long)blockbuff,512); + memcpy(blockbuff, (void*) fdc->tbaddr, 512); + } + + TRACE0("status bytes: "); + for (i = 0;i < fdc->statsz;i++) + TRACE1("%02x ",fdc->status[i]); + + TRACE0("\n"); + + return (tries != 3); +} + +/* this formats a track, given a certain geometry */ +bool fdcFormatTrack(Fdc* fdc, byte track,DrvGeom *g) +{ + int i,h,r,r_id,split; + byte tmpbuff[256]; + + /* check geometry */ + if (g->spt != DG144_SPT && g->spt != DG168_SPT) + return false; + + /* spin up the disk */ + fdcMotorOn(fdc); + + /* program data rate (500K/s) */ + out(FDC_CCR,0); + + fdcSeek(fdc, track); /* seek to track */ + + /* precalc some constants for interleave calculation */ + split = g->spt / 2; + if (g->spt & 1) split++; + + for (h = 0;h < g->heads;h++) { + /* for each head... */ + + /* check for diskchange */ + if (in(FDC_DIR) & 0x80) { + fdc->dchange = true; + fdcSeek(fdc, 1); /* clear "disk change" status */ + fdcRecalibrate(fdc); + fdcMotorOff(fdc); + return false; + } + + i = 0; /* reset buffer index */ + for (r = 0;r < g->spt;r++) { + /* for each sector... */ + + /* calculate 1:2 interleave (seems optimal in my system) */ + r_id = r / 2 + 1; + if (r & 1) r_id += split; + + /* add some head skew (2 sectors should be enough) */ + if (h & 1) { + r_id -= 2; + if (r_id < 1) r_id += g->spt; + } + + /* add some track skew (1/2 a revolution) */ + if (track & 1) { + r_id -= g->spt / 2; + if (r_id < 1) r_id += g->spt; + } + + /**** interleave now calculated - sector ID is stored in r_id ****/ + + /* fill in sector ID's */ + tmpbuff[i++] = track; + tmpbuff[i++] = h; + tmpbuff[i++] = r_id; + tmpbuff[i++] = 2; + } + + /* copy sector ID's to track buffer */ + //movedata(_my_ds(),(long)tmpbuff,_dos_ds,tbaddr,i); + memcpy((void*) fdc->tbaddr, tmpbuff, i); + + /* start dma xfer */ + dma_xfer(2,fdc->tbaddr,i,true); + + /* prepare "format track" command */ + sendbyte(CMD_FORMAT); + sendbyte(h << 2); + sendbyte(2); + sendbyte(g->spt); + if (g->spt == DG144_SPT) + sendbyte(DG144_GAP3FMT); /* gap3 size for 1.44M format */ + else + sendbyte(DG168_GAP3FMT); /* gap3 size for 1.68M format */ + sendbyte(0); /* filler byte */ + + /* wait for command to finish */ + if (!fdcWait(fdc, false)) + return false; + + if (fdc->status[0] & 0xc0) { + fdcMotorOff(fdc); + return false; + } + } + + fdcMotorOff(fdc); + + return true; +} + +bool fdcRequest(device_t* dev, request_t* req) +{ + Fdc* fdc = (Fdc*) dev; + int tries; + DrvGeom geom; + dword pos; + block_size_t* size; + + //if (req->code != DEV_ISR) + //TRACE2("#%c%c", req->code / 256, req->code % 256); + + switch (req->code) + { + case DEV_REMOVE: + fdcCleanup(fdc); + hndFree(fdc); + case DEV_OPEN: + case DEV_CLOSE: + hndSignal(req->event, true); + return true; + + case DEV_ISR: + switch (req->params.isr.irq) + { + case 0: + if (fdc->motor_end != -1 && + sysUpTime() >= fdc->motor_end && + fdc->motor) + { + //TRACE0("floppy: turning off motor\n"); + out(FDC_DOR, FDC_DOR_ENABLE | FDC_DOR_IRQIO); /* turn off floppy motor */ + fdc->motor = false; + fdc->motor_end = -1; + } + + return false; + case 6: + fdc->done = true; + return true; + } + + return false; + + case DEV_READ: + case DEV_WRITE: + if (req->params.buffered.length < 512) + { + req->result = EINVALID; + return false; + } + + req->user_length = req->params.buffered.length; + req->params.buffered.length = 0; + pos = req->params.buffered.pos / 512; + while (req->params.buffered.length < req->user_length) + { + for (tries = 0; tries < 2; tries++) + { + if (fdc_rw(fdc, + pos, + (byte*) req->params.buffered.buffer + + req->params.buffered.length, + req->code == DEV_READ)) + { + pos++; + req->params.buffered.length += 512; + break; + } + else if (!fdcLogDisk(fdc, &geom)) + { + req->result = EINVALID; + return false; + } + else + TRACE3("floppy: new disk geometry: %%d:%02d:%02d\n", + geom.heads, geom.tracks, geom.spt); + } + } + + hndSignal(req->event, true); + return true; + + case BLK_GETSIZE: + size = (block_size_t*) req->params.buffered.buffer; + size->block_size = 512; + size->total_blocks = + fdc->geometry.heads * fdc->geometry.tracks * fdc->geometry.spt; + hndSignal(req->event, true); + return true; + } + + req->result = ENOTIMPL; + return false; +} + +device_t* fdcAddDevice(driver_t* drv, const wchar_t* name, device_config_t* cfg) +{ + Fdc *fdc; + int i; + + fdc = hndAlloc(sizeof(Fdc), NULL); + memset(fdc, 0, sizeof(Fdc)); + fdc->dev.request = fdcRequest; + fdc->fdc_track = 0xff; + fdc->geometry.heads = DG144_HEADS; + fdc->geometry.tracks = DG144_TRACKS; + fdc->geometry.spt = DG144_SPT; + + devRegisterIrq(&fdc->dev, 6, true); + devRegisterIrq(&fdc->dev, 0, true); + + /* allocate track buffer (must be located below 1M) */ + fdc->tbaddr = alloc_dma_buffer(); + + fdcReset(fdc); + + /* get floppy controller version */ + sendbyte(CMD_VERSION); + i = getbyte(); + + if (i == 0x80) + wprintf(L"NEC765 controller found\n"); + else + wprintf(L"enhanced controller found\n"); + + return ccInstallBlockCache(&fdc->dev, 512); + //return &fdc->dev; +} + +bool STDCALL INIT_CODE drvInit(driver_t* drv) +{ + drv->add_device = fdcAddDevice; + return true; +} + +//@} \ No newline at end of file diff --git a/mobius/src/drivers/fdc/fdc.d b/mobius/src/drivers/fdc/fdc.d new file mode 100644 index 0000000..bb83cf7 --- /dev/null +++ b/mobius/src/drivers/fdc/fdc.d @@ -0,0 +1,17 @@ +fdc.o: fdc.c f:\Projects\mobius\include\kernel/kernel.h \ + f:\Projects\mobius\include\kernel/i386.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h f:\Projects\mobius\include\os/os.h \ + f:\Projects\mobius\include\kernel/driver.h \ + f:\Projects\mobius\include\kernel/proc.h \ + f:\Projects\mobius\include\kernel/obj.h \ + f:\Projects\mobius\include\os/pe.h \ + f:\Projects\mobius\include\kernel/handle.h \ + f:\Projects\mobius\include\os/devreq.h \ + f:\Projects\mobius\include\kernel/sys.h \ + f:\Projects\mobius\include\kernel/cache.h \ + f:\Projects\mobius\include\stdio.h \ + f:\Projects\mobius\include\stdarg.h f:\Projects\mobius\include\io.h \ + f:\Projects\mobius\include\os/blkdev.h \ + f:\Projects\mobius\include\errno.h util.h mytypes.h fdc.h \ + f:\Projects\mobius\include\kernel/debug.h diff --git a/mobius/src/drivers/fdc/fdc.dsp b/mobius/src/drivers/fdc/fdc.dsp new file mode 100644 index 0000000..4a0f398 --- /dev/null +++ b/mobius/src/drivers/fdc/fdc.dsp @@ -0,0 +1,121 @@ +# Microsoft Developer Studio Project File - Name="fdc" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=fdc - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "fdc.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "fdc.mak" CFG="fdc - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "fdc - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "fdc - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "fdc - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f fdc.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "fdc.exe" +# PROP BASE Bsc_Name "fdc.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\fdc.drv" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "fdc - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f fdc.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "fdc.exe" +# PROP BASE Bsc_Name "fdc.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "set" +# PROP Rebuild_Opt "rebuils" +# PROP Target_File "..\..\..\bin\fdc.drv" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "fdc - Win32 Release" +# Name "fdc - Win32 Debug" + +!IF "$(CFG)" == "fdc - Win32 Release" + +!ELSEIF "$(CFG)" == "fdc - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\fdc.c +# End Source File +# Begin Source File + +SOURCE=.\util.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\fdc.h +# End Source File +# Begin Source File + +SOURCE=.\mytypes.h +# End Source File +# Begin Source File + +SOURCE=.\util.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/fdc/fdc.h b/mobius/src/drivers/fdc/fdc.h new file mode 100644 index 0000000..466ae4a --- /dev/null +++ b/mobius/src/drivers/fdc/fdc.h @@ -0,0 +1,112 @@ +/* + * fdc.h + * + * header for floppy controller handler + * + * Copyright (C) 1998 Fabian Nunez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * The author can be reached by email at: fabian@cs.uct.ac.za + * + * or by airmail at: Fabian Nunez + * 10 Eastbrooke + * Highstead Road + * Rondebosch 7700 + * South Africa + */ + +#ifndef FDC_H_ +#define FDC_H_ + +#include "mytypes.h" + +/*! + * \ingroup drivers + * \defgroup fdc Floppy drive controller + * @{ + */ + +/* datatypes */ + +/* drive geometry */ +typedef struct DrvGeom { + byte heads; + byte tracks; + byte spt; /* sectors per track */ +} DrvGeom; + +/* drive geometries */ +#define DG144_HEADS 2 /* heads per drive (1.44M) */ +#define DG144_TRACKS 80 /* number of tracks (1.44M) */ +#define DG144_SPT 18 /* sectors per track (1.44M) */ +#define DG144_GAP3FMT 0x54 /* gap3 while formatting (1.44M) */ +#define DG144_GAP3RW 0x1b /* gap3 while reading/writing (1.44M) */ + +#define DG168_HEADS 2 /* heads per drive (1.68M) */ +#define DG168_TRACKS 80 /* number of tracks (1.68M) */ +#define DG168_SPT 21 /* sectors per track (1.68M) */ +#define DG168_GAP3FMT 0x0c /* gap3 while formatting (1.68M) */ +#define DG168_GAP3RW 0x1c /* gap3 while reading/writing (1.68M) */ + +/* IO ports */ +#define FDC_DOR (0x3f2) /* Digital Output Register */ +#define FDC_MSR (0x3f4) /* Main Status Register (input) */ +#define FDC_DRS (0x3f4) /* Data Rate Select Register (output) */ +#define FDC_DATA (0x3f5) /* Data Register */ +#define FDC_DIR (0x3f7) /* Digital Input Register (input) */ +#define FDC_CCR (0x3f7) /* Configuration Control Register (output) */ + +/* command bytes (these are 765 commands + options such as MFM, etc) */ +#define CMD_SPECIFY (0x03) /* specify drive timings */ +#define CMD_WRITE (0xc5) /* write data (+ MT,MFM) */ +#define CMD_READ (0xe6) /* read data (+ MT,MFM,SK) */ +#define CMD_RECAL (0x07) /* recalibrate */ +#define CMD_SENSEI (0x08) /* sense interrupt status */ +#define CMD_FORMAT (0x4d) /* format track (+ MFM) */ +#define CMD_SEEK (0x0f) /* seek track */ +#define CMD_VERSION (0x10) /* FDC version */ + +#define FDC_DOR_ENABLE 0x4 +#define FDC_DOR_IRQIO 0x8 +#define FDC_DOR_MOTOR0 0x10 +#define FDC_DOR_MOTOR1 0x20 +#define FDC_DOR_MOTOR2 0x40 +#define FDC_DOR_MOTOR3 0x80 + +#define FDC_CCR_500K 0 +#define FDC_CCR_250K 2 + +typedef struct Fdc Fdc; + +/* function prototypes */ + +void fdcInit(Fdc* fdc); +void fdcCleanup(Fdc* fdc); + +void fdcReset(Fdc* fdc); +bool fdcDiskChange(Fdc* fdc); +void fdcMotorOn(Fdc* fdc); +void fdcMotorOff(Fdc* fdc); +void fdcRecalibrate(Fdc* fdc); +bool fdcSeek(Fdc* fdc, int track); +bool fdcLogDisk(Fdc* fdc, DrvGeom *g); +bool fdcReadBlock(Fdc* fdc, int block,byte *blockbuff); +bool fdcWriteBlock(Fdc* fdc, int block,byte *blockbuff); +bool fdcFormatTrack(Fdc* fdc, byte track,DrvGeom *g); + +//@} + +#endif /* FDC_H_ */ diff --git a/mobius/src/drivers/fdc/fdc.plg b/mobius/src/drivers/fdc/fdc.plg new file mode 100644 index 0000000..2e9765c --- /dev/null +++ b/mobius/src/drivers/fdc/fdc.plg @@ -0,0 +1,55 @@ + + +
+

Build Log

+

+--------------------Configuration: fdc - Win32 Debug-------------------- +

+ +ALLUSERSPROFILE=I:\Documents and Settings\All Users +APPDATA=I:\Documents and Settings\Tim Robinson\Application Data +BLASTER=A220 I7 D1 T2 +CommonProgramFiles=I:\Program Files\Common Files +COMPUTERNAME=TIM +ComSpec=I:\WINNT\system32\cmd.exe +HOMEDRIVE=I: +HOMEPATH=\ +include=F:\Program Files\Microsoft Visual Studio\VC98\INCLUDE;F:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE;F:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE;f:\projects\mobius\include +INTDIR=.\Debug +lib=F:\Program Files\Microsoft Visual Studio\VC98\LIB;F:\Program Files\Microsoft Visual Studio\VC98\MFC\LIB +LOGONSERVER=\\TIM +MSDevDir=F:\Program Files\Microsoft Visual Studio\Common\MSDev98 +NUMBER_OF_PROCESSORS=1 +OS=Windows_NT +Os2LibPath=I:\WINNT\system32\os2\dll; +OUTDIR=.\Debug +Path=F:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;F:\Program Files\Microsoft Visual Studio\VC98\BIN;F:\Program Files\Microsoft Visual Studio\Common\TOOLS;F:\Program Files\Microsoft Visual Studio\Common\TOOLS\WINNT;I:\WINNT\system32;I:\WINNT;I:\WINNT\System32\Wbem +PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH +PROCESSOR_ARCHITECTURE=x86 +PROCESSOR_IDENTIFIER=x86 Family 6 Model 7 Stepping 3, GenuineIntel +PROCESSOR_LEVEL=6 +PROCESSOR_REVISION=0703 +ProgramFiles=I:\Program Files +PROMPT=$P$G +SNDSCAPE=D:\WINDOWS +SystemDrive=I: +SystemRoot=I:\WINNT +TEMP=I:\DOCUME~1\TIMROB~1\LOCALS~1\Temp +TMP=I:\DOCUME~1\TIMROB~1\LOCALS~1\Temp +USERDOMAIN=TIM +USERNAME=Tim Robinson +USERPROFILE=I:\Documents and Settings\Tim Robinson +VIM=c:\unix\usr\local\wbin +windir=I:\WINNT +_ACP_LIB=F:\Program Files\Microsoft Visual Studio\VC98\LIB;F:\Program Files\Microsoft Visual Studio\VC98\MFC\LIB +_ACP_PATH=F:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;F:\Program Files\Microsoft Visual Studio\VC98\BIN;F:\Program Files\Microsoft Visual Studio\Common\TOOLS;F:\Program Files\Microsoft Visual Studio\Common\TOOLS\WINNT;I:\WINNT\system32;I:\WINNT;I:\WINNT\System32\Wbem +_MSDEV_BLD_ENV_=1 +_NT_SYMBOL_PATH=f:\ + + + +

Results

+fdc.drv - 0 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/drivers/fdc/mytypes.h b/mobius/src/drivers/fdc/mytypes.h new file mode 100644 index 0000000..ab5a99d --- /dev/null +++ b/mobius/src/drivers/fdc/mytypes.h @@ -0,0 +1,68 @@ +/* + * mytypes.h + * + * assorted portability-inducing datatypes + * + * Copyright (C) 1998 Fabian Nunez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * The author can be reached by email at: fabian@cs.uct.ac.za + * + * or by airmail at: Fabian Nunez + * 10 Eastbrooke + * Highstead Road + * Rondebosch 7700 + * South Africa + */ + +#ifndef MYTYPES_H_ +#define MYTYPES_H_ + +#if 0 +/* hardware datatypes */ +typedef unsigned char BYTE; /* 8-bit byte */ +typedef unsigned short WORD; /* 16-bit word */ +typedef unsigned long DWORD; /* 32-bit dword */ +typedef addr_t ADDR; /* address that should not be deref'd */ +#endif + +/* integer types */ +typedef unsigned char UINT8; /* 8-bit unsigned integer */ +typedef signed char INT8; /* 8-bit signed integer */ +typedef unsigned short UINT16; /* 16-bit unsigned integer */ +typedef signed short INT16; /* 16-bit signed integer */ +typedef unsigned long UINT32; /* 32-bit unsigned integer */ +typedef signed long INT32; /* 32-bit signed integer */ + +#include + +/* logical datatypes */ +typedef unsigned char CHAR; /* ISO 8859-1 character */ +typedef unsigned char *STRPTR; /* C-style NUL-terminated string */ +typedef enum { FALSE=0,TRUE=1 } BOOL; /* boolean value */ + +/* constants */ +#ifndef NULL +#define NULL ((void *)0) +#endif /* NULL */ + +/* useful macros */ +#define BITFIELD(name,width) unsigned int name : width +#define HIBYTE(x) ((BYTE)((x) >> 8)) +#define LOBYTE(x) ((BYTE)((x) & 0xff)) +#define ABS(x) ((x) < 0 ? -(x) : (x)) /* NB: multiple evaluations! */ + +#endif /* MYTYPES_H_ */ diff --git a/mobius/src/drivers/fdc/test.c b/mobius/src/drivers/fdc/test.c new file mode 100644 index 0000000..869a2fb --- /dev/null +++ b/mobius/src/drivers/fdc/test.c @@ -0,0 +1,118 @@ +/* + * Demo of fdc functions + */ + +#include +#include +#include +#include /* for biostime() */ +#include +#include "fdc.h" + +#define FORMAT + +/* ensure all mem is locked */ +int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY; + +/* test functions */ +int main(void) +{ + int block,i,c,track; + BYTE trackbuff[512]; + DrvGeom geometry; + + for (i = 0;i < 512;i++) trackbuff[i] = 0; + + init(); + atexit(deinit); + + puts("insert a HD stiffy that has nothing of value in it and press enter"); + getchar(); + +#ifdef FORMAT + + log_disk(NULL); + + geometry.heads = DG168_HEADS; + geometry.tracks = DG168_TRACKS; + geometry.spt = DG168_SPT; + + /* format disk */ + for (i = 0;i < geometry.tracks;i++) { + if (!format_track(i,&geometry)) { + if (diskchange()) + printf("diskchange - abort!\n"); + else + printf("\nerror!\n"); + return 1; + } + fprintf(stderr,"formatted track %d\r",i); + } + +#endif + + if (!log_disk(&geometry)) { + printf("cannot read geometry!\n"); + exit(1); + } + + if (geometry.spt == DG144_SPT) + printf("1.44M format\n"); + else + printf("1.68M format\n"); + + /* write block */ + for (block = 0;block < geometry.spt;block++) { + sprintf(trackbuff,"block number %d",block); + + if (!write_block(block,trackbuff)) { + if (diskchange()) + printf("diskchange - abort!\n"); + else + printf("error writing!\n"); + return 1; + } + } + + /* read block */ + for (block = 0;block < geometry.spt;block++) { + strcpy(trackbuff,"************"); + if (!read_block(block,trackbuff)) { + if (diskchange()) + printf("diskchange - abort!\n"); + else + printf("error reading!\n"); + return 1; + } + + /* display block (1st 16 bytes) */ + for (i = 0;i < 16;i++) + printf("%02x ",trackbuff[i]); + + printf(": "); + + for (i = 0;i < 16;i++) { + c = trackbuff[i]; + printf("%c",isprint(c) ? c : '.'); + } + + printf("\n"); + } + + srand(biostime(0,0)); + + /* seek a few times */ + for (i = 0;i < 10;i++) { + track = rand() % 80; + printf("seeking to %d: ",track); + if (seek(track)) + printf("OK\n"); + else + printf("error!\n"); + } + + printf("All done - press enter to finish\n"); + getchar(); + + return 0; +} diff --git a/mobius/src/drivers/fdc/util.c b/mobius/src/drivers/fdc/util.c new file mode 100644 index 0000000..4d8c15a --- /dev/null +++ b/mobius/src/drivers/fdc/util.c @@ -0,0 +1,101 @@ +/* + * util.c + * + * Assorted IRQ/DMA utility functions for DJGPP 2.01 + * + * Copyright (C) 1998 Fabian Nunez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * The author can be reached by email at: fabian@cs.uct.ac.za + * + * or by airmail at: Fabian Nunez + * 10 Eastbrooke + * Highstead Road + * Rondebosch 7700 + * South Africa + */ + +#include +#include +#include +#include "util.h" + +/* definition of DMA channels */ +const static DmaChannel dmainfo[] = { + { 0x87, 0x00, 0x01 }, + { 0x83, 0x02, 0x03 }, + { 0x81, 0x04, 0x05 }, + { 0x82, 0x06, 0x07 } +}; + +/* + * this allocates a 4KB buffer in the < 1M range, maps it and returns the + * linear address, also setting the physical in the integer pointed at + */ +long alloc_dma_buffer() +{ + addr_t phys; + phys = memAllocLow(); + assert(phys + PAGE_SIZE < 0x100000); + assert(((phys + PAGE_SIZE) & 0xffff) >= ((phys + PAGE_SIZE) & 0xffff)); + wprintf(L"DMA transfer buffer is at 0x%x\n", phys); + return phys; +} + +/* + * this sets up a DMA trasfer between a device and memory. Pass the DMA + * channel number (0..3), the physical address of the buffer and transfer + * length. If 'read' is TRUE, then transfer will be from memory to device, + * else from the device to memory. + */ +void dma_xfer(int channel,long physaddr,int length,BOOL read) +{ + long page,offset; + + assert(channel < 4); + + /* calculate dma page and offset */ + page = physaddr >> 16; + offset = physaddr & 0xffff; + length -= 1; /* with dma, if you want k bytes, you ask for k - 1 */ + + disable(); /* disable irq's */ + + /* set the mask bit for the channel */ + out(0x0a,channel | 4); + + /* clear flipflop */ + out(0x0c,0); + + /* set DMA mode (write+single+r/w) */ + out(0x0b,(read ? 0x48 : 0x44) + channel); + + /* set DMA page */ + out(dmainfo[channel].page,page); + + /* set DMA offset */ + out(dmainfo[channel].offset,offset & 0xff); /* low byte */ + out(dmainfo[channel].offset,offset >> 8); /* high byte */ + + /* set DMA length */ + out(dmainfo[channel].length,length & 0xff); /* low byte */ + out(dmainfo[channel].length,length >> 8); /* high byte */ + + /* clear DMA mask bit */ + out(0x0a,channel); + + enable(); /* enable irq's */ +} diff --git a/mobius/src/drivers/fdc/util.d b/mobius/src/drivers/fdc/util.d new file mode 100644 index 0000000..b737dd5 --- /dev/null +++ b/mobius/src/drivers/fdc/util.d @@ -0,0 +1,11 @@ +util.o: util.c f:\Projects\mobius\include\kernel/kernel.h \ + f:\Projects\mobius\include\kernel/i386.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h f:\Projects\mobius\include\os/os.h \ + f:\Projects\mobius\include\kernel/driver.h \ + f:\Projects\mobius\include\kernel/proc.h \ + f:\Projects\mobius\include\kernel/obj.h \ + f:\Projects\mobius\include\os/pe.h \ + f:\Projects\mobius\include\kernel/handle.h \ + f:\Projects\mobius\include\os/devreq.h \ + f:\Projects\mobius\include\kernel/memory.h util.h mytypes.h diff --git a/mobius/src/drivers/fdc/util.h b/mobius/src/drivers/fdc/util.h new file mode 100644 index 0000000..2fed6d3 --- /dev/null +++ b/mobius/src/drivers/fdc/util.h @@ -0,0 +1,59 @@ +/* + * util.h + * + * header for IRQ/DMA utility functions for DJGPP 2.01 + * + * Copyright (C) 1998 Fabian Nunez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * The author can be reached by email at: fabian@cs.uct.ac.za + * + * or by airmail at: Fabian Nunez + * 10 Eastbrooke + * Highstead Road + * Rondebosch 7700 + * South Africa + */ + +#ifndef UTIL_H_ +#define UTIL_H_ + +#include "mytypes.h" +//#include + +/* used to store hardware definition of DMA channels */ +typedef struct DmaChannel { + byte page; /* page register */ + byte offset; /* offset register */ + byte length; /* length register */ +} DmaChannel; + +/* function prototypes */ +long alloc_dma_buffer(); +void dma_xfer(int channel,long physaddr,int length,BOOL read); + +/* inline funcs */ +extern inline void wfill(word *start,UINT32 size,word value) +{ + asm volatile ("cld\n" + "\trep\n" + "\tstosw" + : /* no outputs */ + : "D"(start),"c"(size),"a"(value) + : "%edi","%ecx"); +} + +#endif /* UTIL_H_ */ diff --git a/mobius/src/drivers/isa/Makefile b/mobius/src/drivers/isa/Makefile new file mode 100644 index 0000000..d936186 --- /dev/null +++ b/mobius/src/drivers/isa/Makefile @@ -0,0 +1,7 @@ +TARGET= $(BIN)/isa.drv +OBJS= isa.o +BASE= isa + +include ../make.driver + +include $(OBJS:.o=.d) \ No newline at end of file diff --git a/mobius/src/drivers/isa/isa.c b/mobius/src/drivers/isa/isa.c new file mode 100644 index 0000000..7687fde --- /dev/null +++ b/mobius/src/drivers/isa/isa.c @@ -0,0 +1,133 @@ +#include +#include +#include +#include +#include +#include + +/*! + * \ingroup drivers + * \defgroup isa ISA bus + * @{ + */ + +device_t *isa; +wchar_t devname[16]; +int num_resources; +device_resource_t *resources; +word vendor, device; + +void isaAddItem(hashelem_t* elem) +{ + device_resource_t res; + wchar_t *data, *ch; + + data = (wchar_t*) elem->data; + if (wcsicmp(elem->str, L"name") == 0) + wcscpy(devname, data); + else if (wcsicmp(elem->str, L"io") == 0) + { + ch = wcschr(data, ','); + if (ch) + { + *ch = 0; + ch++; + } + else + ch = L"1"; + + res.cls = dresIo; + res.u.io.base = wcstol(data, NULL, 16); + res.u.io.length = wcstol(ch, NULL, 0); + goto add_resource; + } + else if (wcsicmp(elem->str, L"memory") == 0) + { + ch = wcschr(data, ','); + if (ch) + { + *ch = 0; + ch++; + } + else + ch = L"1"; + + res.cls = dresMemory; + res.u.memory.base = wcstol(data, NULL, 16); + res.u.memory.length = wcstol(ch, NULL, 0); + goto add_resource; + } + else if (wcsicmp(elem->str, L"irq") == 0) + { + res.cls = dresIrq; + res.u.irq = wcstol(data, NULL, 0); + goto add_resource; + } + else if (wcsicmp(elem->str, L"vendor") == 0) + vendor = wcstol(data, NULL, 16); + else if (wcsicmp(elem->str, L"device") == 0) + device = wcstol(data, NULL, 16); + else + wprintf(L"%s: invalid keyword\n", elem->str); + + return; + +add_resource: + num_resources++; + resources = realloc(resources, sizeof(device_resource_t) * num_resources); + resources[num_resources - 1] = res; +} + +bool STDCALL INIT_CODE drvInit(driver_t* drv) +{ + void* file; + //char line[256], *p, *dest; + char* p; + size_t length; + hashtable_t *table; + device_config_t *cfg; + + file = ramOpen(L"isa.cfg"); + if (!file) + return false; + + isa = hndAlloc(sizeof(device_t), NULL); + isa->driver = drv; + isa->request = NULL; + isa->req_first = isa->req_last = NULL; + isa->config = NULL; + devRegister(L"isa", isa, NULL); + + length = ramFileLength(L"isa.cfg"); + + p = (char*) file; + + while (p < (char*) file + length) + { + memset(devname, 0, sizeof(devname)); + num_resources = 0; + resources = NULL; + vendor = 0xffff; + device = 0xffff; + + table = cfgParseStrLine((const char**) &p); + hashList(table, isaAddItem); + cfgDeleteTable(table); + + if (devname[0]) + { + cfg = hndAlloc(sizeof(device_config_t), NULL); + cfg->parent = isa; + cfg->vendor_id = vendor; + cfg->device_id = device; + cfg->subsystem = 0xffffffff; + cfg->num_resources = num_resources; + cfg->resources = resources; + devRegister(devname, NULL, cfg); + } + } + + return true; +} + +//@} \ No newline at end of file diff --git a/mobius/src/drivers/isa/isa.d b/mobius/src/drivers/isa/isa.d new file mode 100644 index 0000000..efe2f42 --- /dev/null +++ b/mobius/src/drivers/isa/isa.d @@ -0,0 +1,17 @@ +isa.o: isa.c f:\Projects\mobius\include\kernel/kernel.h \ + f:\Projects\mobius\include\kernel/i386.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h f:\Projects\mobius\include\os/os.h \ + f:\Projects\mobius\include\kernel/driver.h \ + f:\Projects\mobius\include\kernel/proc.h \ + f:\Projects\mobius\include\kernel/obj.h \ + f:\Projects\mobius\include\os/pe.h \ + f:\Projects\mobius\include\kernel/handle.h \ + f:\Projects\mobius\include\os/devreq.h \ + f:\Projects\mobius\include\kernel/ramdisk.h \ + f:\Projects\mobius\include\kernel/memory.h \ + f:\Projects\mobius\include\kernel/config.h \ + f:\Projects\mobius\include\kernel/hash.h \ + f:\Projects\mobius\include\stdlib.h \ + f:\Projects\mobius\include\malloc.h \ + f:\Projects\mobius\include\string.h diff --git a/mobius/src/drivers/isa/isa.dsp b/mobius/src/drivers/isa/isa.dsp new file mode 100644 index 0000000..8503e30 --- /dev/null +++ b/mobius/src/drivers/isa/isa.dsp @@ -0,0 +1,105 @@ +# Microsoft Developer Studio Project File - Name="isa" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=isa - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "isa.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "isa.mak" CFG="isa - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "isa - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "isa - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "isa - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f isa.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "isa.exe" +# PROP BASE Bsc_Name "isa.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\isa.drv" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "isa - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f isa.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "isa.exe" +# PROP BASE Bsc_Name "isa.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "set" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\isa.drv" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "isa - Win32 Release" +# Name "isa - Win32 Debug" + +!IF "$(CFG)" == "isa - Win32 Release" + +!ELSEIF "$(CFG)" == "isa - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\isa.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/isa/isa.plg b/mobius/src/drivers/isa/isa.plg new file mode 100644 index 0000000..9d9aeb6 --- /dev/null +++ b/mobius/src/drivers/isa/isa.plg @@ -0,0 +1,18 @@ + + +
+

Build Log

+

+--------------------Configuration: isa - Win32 Debug-------------------- +

+ +gcc -D__MOBIUS__ -DKERNEL -O2 -Wall -If:\Projects\mobius\include -MD -c isa.c +link /out:f:\Projects\mobius\bin/isa.drv /nologo /debug /debugtype:coff /libpath:f:\Projects\mobius\lib /nodefaultlib /entry:drvInit /subsystem:native /base:@f:\Projects\mobius\bin\coffbase.txt,isa isa.o kernel.lib + + + +

Results

+isa.drv - 0 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/drivers/kdebug/Makefile b/mobius/src/drivers/kdebug/Makefile new file mode 100644 index 0000000..d3179dd --- /dev/null +++ b/mobius/src/drivers/kdebug/Makefile @@ -0,0 +1,15 @@ +TARGET= $(BIN)/kdebug.dll +OBJS= kdebug.o disasm.o insnsd.o sync.o +EXP= kdebug.exp +IMP= $(LIB)/kdebug.lib +BASE= kdebug + +include ../make.driver + +%.exp: %.def + dlltool -e $@ -m i386 --input-def $< -D $(@:.exp=.dll) + +$(LIB)/%.lib: %.def + lib /def:$< /out:$@ /nologo /machine:ix86 + +include $(OBJS:.o=.d) \ No newline at end of file diff --git a/mobius/src/drivers/kdebug/disasm.c b/mobius/src/drivers/kdebug/disasm.c new file mode 100644 index 0000000..5a240a6 --- /dev/null +++ b/mobius/src/drivers/kdebug/disasm.c @@ -0,0 +1,741 @@ +/* disasm.c where all the _work_ gets done in the Netwide Disassembler + * + * The Netwide Assembler is copyright (C) 1996 Simon Tatham and + * Julian Hall. All rights reserved. The software is + * redistributable under the licence given in the file "Licence" + * distributed in the NASM archive. + * + * initial version 27/iii/95 by Simon Tatham + */ + +#include +#include + +#include "nasm.h" +#include "disasm.h" +#include "sync.h" +#include "insns.h" + +#include "names.c" + +extern struct itemplate **itable[]; + +/* + * Flags that go into the `segment' field of `insn' structures + * during disassembly. + */ +#define SEG_RELATIVE 1 +#define SEG_32BIT 2 +#define SEG_RMREG 4 +#define SEG_DISP8 8 +#define SEG_DISP16 16 +#define SEG_DISP32 32 +#define SEG_NODISP 64 +#define SEG_SIGNED 128 + +int add_label(struct itemplate* p, insn* ins, wchar_t* str, int operand); + +static int whichreg(long regflags, int regval) +{ + static int reg32[] = { + R_EAX, R_ECX, R_EDX, R_EBX, R_ESP, R_EBP, R_ESI, R_EDI }; + static int reg16[] = { + R_AX, R_CX, R_DX, R_BX, R_SP, R_BP, R_SI, R_DI }; + static int reg8[] = { + R_AL, R_CL, R_DL, R_BL, R_AH, R_CH, R_DH, R_BH }; + static int sreg[] = { + R_ES, R_CS, R_SS, R_DS, R_FS, R_GS, 0, 0 }; + static int creg[] = { + R_CR0, 0, R_CR2, R_CR3, R_CR4, 0, 0, 0 }; + static int dreg[] = { + R_DR0, R_DR1, R_DR2, R_DR3, 0, 0, R_DR6, R_DR7 }; + static int treg[] = { + 0, 0, 0, R_TR3, R_TR4, R_TR5, R_TR6, R_TR7 }; + static int fpureg[] = { + R_ST0, R_ST1, R_ST2, R_ST3, R_ST4, R_ST5, R_ST6, R_ST7 }; + static int mmxreg[] = { + R_MM0, R_MM1, R_MM2, R_MM3, R_MM4, R_MM5, R_MM6, R_MM7 }; + static int xmmreg[] = { + R_XMM0, R_XMM1, R_XMM2, R_XMM3, R_XMM4, R_XMM5, R_XMM6, R_XMM7 }; + + if (!(REG_AL & ~regflags)) + return R_AL; + if (!(REG_AX & ~regflags)) + return R_AX; + if (!(REG_EAX & ~regflags)) + return R_EAX; + if (!(REG_DX & ~regflags)) + return R_DX; + if (!(REG_CL & ~regflags)) + return R_CL; + if (!(REG_CX & ~regflags)) + return R_CX; + if (!(REG_ECX & ~regflags)) + return R_ECX; + if (!(REG_CR4 & ~regflags)) + return R_CR4; + if (!(FPU0 & ~regflags)) + return R_ST0; + if (!(REG_CS & ~regflags)) + return R_CS; + if (!(REG_DESS & ~regflags)) + return (regval == 0 || regval == 2 || regval == 3 ? sreg[regval] : 0); + if (!(REG_FSGS & ~regflags)) + return (regval == 4 || regval == 5 ? sreg[regval] : 0); + if (!((REGMEM|BITS8) & ~regflags)) + return reg8[regval]; + if (!((REGMEM|BITS16) & ~regflags)) + return reg16[regval]; + if (!((REGMEM|BITS32) & ~regflags)) + return reg32[regval]; + if (!(REG_SREG & ~regflags)) + return sreg[regval]; + if (!(REG_CREG & ~regflags)) + return creg[regval]; + if (!(REG_DREG & ~regflags)) + return dreg[regval]; + if (!(REG_TREG & ~regflags)) + return treg[regval]; + if (!(FPUREG & ~regflags)) + return fpureg[regval]; + if (!(MMXREG & ~regflags)) + return mmxreg[regval]; + if (!(XMMREG & ~regflags)) + return xmmreg[regval]; + return 0; +} + +static wchar_t *whichcond(int condval) +{ + static int conds[] = { + C_O, C_NO, C_C, C_NC, C_Z, C_NZ, C_NA, C_A, + C_S, C_NS, C_PE, C_PO, C_L, C_NL, C_NG, C_G + }; + return conditions[conds[condval]]; +} + +/* + * Process an effective address (ModRM) specification. + */ +static unsigned char *do_ea (unsigned char *data, int modrm, int asize, + int segsize, operand *op) +{ + int mod, rm, scale, index, base; + + mod = (modrm >> 6) & 03; + rm = modrm & 07; + + if (mod == 3) { /* pure register version */ + op->basereg = rm; + op->segment |= SEG_RMREG; + return data; + } + + op->addr_size = 0; + + if (asize == 16) { + /* + * specifies the displacement size (none, byte or + * word), and specifies the register combination. + * Exception: mod=0,rm=6 does not specify [BP] as one might + * expect, but instead specifies [disp16]. + */ + op->indexreg = op->basereg = -1; + op->scale = 1; /* always, in 16 bits */ + switch (rm) { + case 0: op->basereg = R_BX; op->indexreg = R_SI; break; + case 1: op->basereg = R_BX; op->indexreg = R_DI; break; + case 2: op->basereg = R_BP; op->indexreg = R_SI; break; + case 3: op->basereg = R_BP; op->indexreg = R_DI; break; + case 4: op->basereg = R_SI; break; + case 5: op->basereg = R_DI; break; + case 6: op->basereg = R_BP; break; + case 7: op->basereg = R_BX; break; + } + if (rm == 6 && mod == 0) { /* special case */ + op->basereg = -1; + if (segsize != 16) + op->addr_size = 16; + mod = 2; /* fake disp16 */ + } + switch (mod) { + case 0: + op->segment |= SEG_NODISP; + break; + case 1: + op->segment |= SEG_DISP8; + op->offset = (signed char) *data++; + break; + case 2: + op->segment |= SEG_DISP16; + op->offset = *data++; + op->offset |= (*data++) << 8; + break; + } + return data; + } else { + /* + * Once again, specifies displacement size (this time + * none, byte or *dword*), while specifies the base + * register. Again, [EBP] is missing, replaced by a pure + * disp32 (this time that's mod=0,rm=*5*). However, rm=4 + * indicates not a single base register, but instead the + * presence of a SIB byte... + */ + op->indexreg = -1; + switch (rm) { + case 0: op->basereg = R_EAX; break; + case 1: op->basereg = R_ECX; break; + case 2: op->basereg = R_EDX; break; + case 3: op->basereg = R_EBX; break; + case 5: op->basereg = R_EBP; break; + case 6: op->basereg = R_ESI; break; + case 7: op->basereg = R_EDI; break; + } + if (rm == 5 && mod == 0) { + op->basereg = -1; + if (segsize != 32) + op->addr_size = 32; + mod = 2; /* fake disp32 */ + } + if (rm == 4) { /* process SIB */ + scale = (*data >> 6) & 03; + index = (*data >> 3) & 07; + base = *data & 07; + data++; + + op->scale = 1 << scale; + switch (index) { + case 0: op->indexreg = R_EAX; break; + case 1: op->indexreg = R_ECX; break; + case 2: op->indexreg = R_EDX; break; + case 3: op->indexreg = R_EBX; break; + case 4: op->indexreg = -1; break; + case 5: op->indexreg = R_EBP; break; + case 6: op->indexreg = R_ESI; break; + case 7: op->indexreg = R_EDI; break; + } + + switch (base) { + case 0: op->basereg = R_EAX; break; + case 1: op->basereg = R_ECX; break; + case 2: op->basereg = R_EDX; break; + case 3: op->basereg = R_EBX; break; + case 4: op->basereg = R_ESP; break; + case 6: op->basereg = R_ESI; break; + case 7: op->basereg = R_EDI; break; + case 5: + if (mod == 0) { + mod = 2; + op->basereg = -1; + } else + op->basereg = R_EBP; + break; + } + } + switch (mod) { + case 0: + op->segment |= SEG_NODISP; + break; + case 1: + op->segment |= SEG_DISP8; + op->offset = (signed char) *data++; + break; + case 2: + op->segment |= SEG_DISP32; + op->offset = *data++; + op->offset |= (*data++) << 8; + op->offset |= ((long) *data++) << 16; + op->offset |= ((long) *data++) << 24; + break; + } + return data; + } +} + +/* + * Determine whether the instruction template in t corresponds to the data + * stream in data. Return the number of bytes matched if so. + */ +static int matches (struct itemplate *t, unsigned char *data, int asize, + int osize, int segsize, int rep, insn *ins) +{ + unsigned char * r = (unsigned char *)(t->code); + unsigned char * origdata = data; + int a_used = FALSE, o_used = FALSE; + int drep = 0; + + if ( rep == 0xF2 ) + drep = P_REPNE; + else if ( rep == 0xF3 ) + drep = P_REP; + + while (*r) + { + int c = *r++; + if (c >= 01 && c <= 03) { + while (c--) + if (*r++ != *data++) + return FALSE; + } + if (c == 04) { + switch (*data++) { + case 0x07: ins->oprs[0].basereg = 0; break; + case 0x17: ins->oprs[0].basereg = 2; break; + case 0x1F: ins->oprs[0].basereg = 3; break; + default: return FALSE; + } + } + if (c == 05) { + switch (*data++) { + case 0xA1: ins->oprs[0].basereg = 4; break; + case 0xA9: ins->oprs[0].basereg = 5; break; + default: return FALSE; + } + } + if (c == 06) { + switch (*data++) { + case 0x06: ins->oprs[0].basereg = 0; break; + case 0x0E: ins->oprs[0].basereg = 1; break; + case 0x16: ins->oprs[0].basereg = 2; break; + case 0x1E: ins->oprs[0].basereg = 3; break; + default: return FALSE; + } + } + if (c == 07) { + switch (*data++) { + case 0xA0: ins->oprs[0].basereg = 4; break; + case 0xA8: ins->oprs[0].basereg = 5; break; + default: return FALSE; + } + } + if (c >= 010 && c <= 012) { + int t = *r++, d = *data++; + if (d < t || d > t+7) + return FALSE; + else { + ins->oprs[c-010].basereg = d-t; + ins->oprs[c-010].segment |= SEG_RMREG; + } + } + if (c == 017) + if (*data++) + return FALSE; + if (c >= 014 && c <= 016) { + ins->oprs[c-014].offset = (signed char) *data++; + ins->oprs[c-014].segment |= SEG_SIGNED; + } + if (c >= 020 && c <= 022) + ins->oprs[c-020].offset = *data++; + if (c >= 024 && c <= 026) + ins->oprs[c-024].offset = *data++; + if (c >= 030 && c <= 032) { + ins->oprs[c-030].offset = *data++; + ins->oprs[c-030].offset |= (*data++ << 8); + } + if (c >= 034 && c <= 036) { + ins->oprs[c-034].offset = *data++; + ins->oprs[c-034].offset |= (*data++ << 8); + if (asize == 32) { + ins->oprs[c-034].offset |= (((long) *data++) << 16); + ins->oprs[c-034].offset |= (((long) *data++) << 24); + } + if (segsize != asize) + ins->oprs[c-034].addr_size = asize; + } + if (c >= 040 && c <= 042) { + ins->oprs[c-040].offset = *data++; + ins->oprs[c-040].offset |= (*data++ << 8); + ins->oprs[c-040].offset |= (((long) *data++) << 16); + ins->oprs[c-040].offset |= (((long) *data++) << 24); + } + if (c >= 050 && c <= 052) { + ins->oprs[c-050].offset = (signed char) *data++; + ins->oprs[c-050].segment |= SEG_RELATIVE; + } + if (c >= 060 && c <= 062) { + ins->oprs[c-060].offset = *data++; + ins->oprs[c-060].offset |= (*data++ << 8); + ins->oprs[c-060].segment |= SEG_RELATIVE; + ins->oprs[c-060].segment &= ~SEG_32BIT; + } + if (c >= 064 && c <= 066) { + ins->oprs[c-064].offset = *data++; + ins->oprs[c-064].offset |= (*data++ << 8); + if (asize == 32) { + ins->oprs[c-064].offset |= (((long) *data++) << 16); + ins->oprs[c-064].offset |= (((long) *data++) << 24); + ins->oprs[c-064].segment |= SEG_32BIT; + } else + ins->oprs[c-064].segment &= ~SEG_32BIT; + ins->oprs[c-064].segment |= SEG_RELATIVE; + if (segsize != asize) + ins->oprs[c-064].addr_size = asize; + } + if (c >= 070 && c <= 072) { + ins->oprs[c-070].offset = *data++; + ins->oprs[c-070].offset |= (*data++ << 8); + ins->oprs[c-070].offset |= (((long) *data++) << 16); + ins->oprs[c-070].offset |= (((long) *data++) << 24); + ins->oprs[c-070].segment |= SEG_32BIT | SEG_RELATIVE; + } + if (c >= 0100 && c <= 0177) { + int modrm = *data++; + ins->oprs[c & 07].basereg = (modrm >> 3) & 07; + ins->oprs[c & 07].segment |= SEG_RMREG; + data = do_ea (data, modrm, asize, segsize, + &ins->oprs[(c >> 3) & 07]); + } + if (c >= 0200 && c <= 0277) { + int modrm = *data++; + if (((modrm >> 3) & 07) != (c & 07)) + return FALSE; /* spare field doesn't match up */ + data = do_ea (data, modrm, asize, segsize, + &ins->oprs[(c >> 3) & 07]); + } + if (c >= 0300 && c <= 0302) { + if (asize) + ins->oprs[c-0300].segment |= SEG_32BIT; + else + ins->oprs[c-0300].segment &= ~SEG_32BIT; + a_used = TRUE; + } + if (c == 0310) { + if (asize == 32) + return FALSE; + else + a_used = TRUE; + } + if (c == 0311) { + if (asize == 16) + return FALSE; + else + a_used = TRUE; + } + if (c == 0312) { + if (asize != segsize) + return FALSE; + else + a_used = TRUE; + } + if (c == 0320) { + if (osize == 32) + return FALSE; + else + o_used = TRUE; + } + if (c == 0321) { + if (osize == 16) + return FALSE; + else + o_used = TRUE; + } + if (c == 0322) { + if (osize != segsize) + return FALSE; + else + o_used = TRUE; + } + if (c == 0330) { + int t = *r++, d = *data++; + if (d < t || d > t+15) + return FALSE; + else + ins->condition = d - t; + } + if (c == 0331) { + if ( rep ) + return FALSE; + } + if (c == 0332) { + if (drep == P_REP) + drep = P_REPE; + } + if (c == 0333) { + if ( rep != 0xF3 ) + return FALSE; + drep = 0; + } + } + + /* + * Check for unused rep or a/o prefixes. + */ + ins->nprefix = 0; + if (drep) + ins->prefixes[ins->nprefix++] = drep; + if (!a_used && asize != segsize) + ins->prefixes[ins->nprefix++] = (asize == 16 ? P_A16 : P_A32); + if (!o_used && osize != segsize) + ins->prefixes[ins->nprefix++] = (osize == 16 ? P_O16 : P_O32); + + return data - origdata; +} + +long disasm (unsigned char *data, wchar_t *output, int segsize, long offset, + int autosync, unsigned long prefer) +{ + struct itemplate **p, **best_p; + int length, best_length = 0; + wchar_t *segover; + int rep, lock, asize, osize, i, slen, colon; + unsigned char *origdata; + int works; + insn tmp_ins, ins; + unsigned long goodness, best; + + /* + * Scan for prefixes. + */ + asize = osize = segsize; + segover = NULL; + rep = lock = 0; + origdata = data; + for (;;) { + if (*data == 0xF3 || *data == 0xF2) + rep = *data++; + else if (*data == 0xF0) + lock = *data++; + else if (*data == 0x2E || *data == 0x36 || *data == 0x3E || + *data == 0x26 || *data == 0x64 || *data == 0x65) { + switch (*data++) { + case 0x2E: segover = L"cs"; break; + case 0x36: segover = L"ss"; break; + case 0x3E: segover = L"ds"; break; + case 0x26: segover = L"es"; break; + case 0x64: segover = L"fs"; break; + case 0x65: segover = L"gs"; break; + } + } else if (*data == 0x66) + osize = 48 - segsize, data++; + else if (*data == 0x67) + asize = 48 - segsize, data++; + else + break; + } + + tmp_ins.oprs[0].segment = tmp_ins.oprs[1].segment = + tmp_ins.oprs[2].segment = + tmp_ins.oprs[0].addr_size = tmp_ins.oprs[1].addr_size = + tmp_ins.oprs[2].addr_size = (segsize == 16 ? 0 : SEG_32BIT); + tmp_ins.condition = -1; + best = ~0UL; /* Worst possible */ + best_p = NULL; + for (p = itable[*data]; *p; p++) { + if ( (length = matches(*p, data, asize, osize, + segsize, rep, &tmp_ins)) ) { + works = TRUE; + /* + * Final check to make sure the types of r/m match up. + */ + for (i = 0; i < (*p)->operands; i++) { + if ( + /* If it's a mem-only EA but we have a register, die. */ + ((tmp_ins.oprs[i].segment & SEG_RMREG) && + !(MEMORY & ~(*p)->opd[i])) || + + /* If it's a reg-only EA but we have a memory ref, die. */ + (!(tmp_ins.oprs[i].segment & SEG_RMREG) && + !(REGNORM & ~(*p)->opd[i]) && + !((*p)->opd[i] & REG_SMASK)) || + + /* Register type mismatch (eg FS vs REG_DESS): die. */ + ((((*p)->opd[i] & (REGISTER | FPUREG)) || + (tmp_ins.oprs[i].segment & SEG_RMREG)) && + !whichreg ((*p)->opd[i], tmp_ins.oprs[i].basereg))) { + works = FALSE; + break; + } + } + + if (works) { + goodness = ((*p)->flags & IF_PFMASK) ^ prefer; + if ( goodness < best ) { + /* This is the best one found so far */ + best = goodness; + best_p = p; + best_length = length; + ins = tmp_ins; + } + } + } + } + + if (!best_p) + return 0; /* no instruction was matched */ + + /* Pick the best match */ + p = best_p; + length = best_length; + + slen = 0; + + if (lock) + slen += swprintf(output+slen, L"lock "); + for (i = 0; i < ins.nprefix; i++) + switch (ins.prefixes[i]) { + case P_REP: slen += swprintf(output+slen, L"rep "); break; + case P_REPE: slen += swprintf(output+slen, L"repe "); break; + case P_REPNE: slen += swprintf(output+slen, L"repne "); break; + case P_A16: slen += swprintf(output+slen, L"a16 "); break; + case P_A32: slen += swprintf(output+slen, L"a32 "); break; + case P_O16: slen += swprintf(output+slen, L"o16 "); break; + case P_O32: slen += swprintf(output+slen, L"o32 "); break; + } + + for (i = 0; i < elements(ico); i++) + if ((*p)->opcode == ico[i]) { + slen += swprintf(output+slen, L"%s%s", icn[i], + whichcond(ins.condition)); + break; + } + if (i >= elements(ico)) + slen += swprintf(output+slen, L"%s", insn_names[(*p)->opcode]); + colon = FALSE; + length += data - origdata; /* fix up for prefixes */ + for (i=0; i<(*p)->operands; i++) { + output[slen++] = (colon ? ':' : i==0 ? ' ' : ','); + + if (ins.oprs[i].segment & SEG_RELATIVE) { + ins.oprs[i].offset += offset + length; + /* + * sort out wraparound + */ + if (!(ins.oprs[i].segment & SEG_32BIT)) + ins.oprs[i].offset &= 0xFFFF; + /* + * add sync marker, if autosync is on + */ + if (autosync) + add_sync (ins.oprs[i].offset, 0L); + } + + if ((*p)->opd[i] & COLON) + colon = TRUE; + else + colon = FALSE; + + if (((*p)->opd[i] & (REGISTER | FPUREG)) || + (ins.oprs[i].segment & SEG_RMREG)) + { + ins.oprs[i].basereg = whichreg ((*p)->opd[i], + ins.oprs[i].basereg); + if ( (*p)->opd[i] & TO ) + slen += swprintf(output+slen, L"to "); + slen += swprintf(output+slen, L"%s", + reg_names[ins.oprs[i].basereg-EXPR_REG_START]); + } else if (!(UNITY & ~(*p)->opd[i])) { + output[slen++] = '1'; + } else if ( (*p)->opd[i] & IMMEDIATE ) { + if ( (*p)->opd[i] & BITS8 ) { + slen += swprintf(output+slen, L"byte "); + if (ins.oprs[i].segment & SEG_SIGNED) { + if (ins.oprs[i].offset < 0) { + ins.oprs[i].offset *= -1; + output[slen++] = '-'; + } else + output[slen++] = '+'; + } + } else if ( (*p)->opd[i] & BITS16 ) { + slen += swprintf(output+slen, L"word "); + } else if ( (*p)->opd[i] & BITS32 ) { + slen += swprintf(output+slen, L"dword "); + } else if ( (*p)->opd[i] & NEAR ) { + slen += swprintf(output+slen, L"near "); + } else if ( (*p)->opd[i] & SHORT ) { + slen += swprintf(output+slen, L"short "); + } + //slen += sprintf(output+slen, "0x%lx", ins.oprs[i].offset); + slen += add_label(*p, &ins, output+slen, i); + } else if ( !(MEM_OFFS & ~(*p)->opd[i]) ) { + wchar_t buf[50]; + add_label(*p, &ins, buf, i); + slen += swprintf(output+slen, L"[%s%s%s%s]", + (segover ? segover : L""), + (segover ? L":" : L""), + (ins.oprs[i].addr_size == 32 ? L"dword " : + ins.oprs[i].addr_size == 16 ? L"word " : L""), + buf); + segover = NULL; + } else if ( !(REGMEM & ~(*p)->opd[i]) ) { + int started = FALSE; + if ( (*p)->opd[i] & BITS8 ) + slen += swprintf(output+slen, L"byte "); + if ( (*p)->opd[i] & BITS16 ) + slen += swprintf(output+slen, L"word "); + if ( (*p)->opd[i] & BITS32 ) + slen += swprintf(output+slen, L"dword "); + if ( (*p)->opd[i] & BITS64 ) + slen += swprintf(output+slen, L"qword "); + if ( (*p)->opd[i] & BITS80 ) + slen += swprintf(output+slen, L"tword "); + if ( (*p)->opd[i] & FAR ) + slen += swprintf(output+slen, L"far "); + if ( (*p)->opd[i] & NEAR ) + slen += swprintf(output+slen, L"near "); + output[slen++] = '['; + if (ins.oprs[i].addr_size) + slen += swprintf(output+slen, L"%s", + (ins.oprs[i].addr_size == 32 ? L"dword " : + ins.oprs[i].addr_size == 16 ? L"word " : L"")); + if (segover) { + slen += swprintf(output+slen, L"%s:", segover); + segover = NULL; + } + if (ins.oprs[i].basereg != -1) { + slen += swprintf(output+slen, L"%s", + reg_names[(ins.oprs[i].basereg - + EXPR_REG_START)]); + started = TRUE; + } + if (ins.oprs[i].indexreg != -1) { + if (started) + output[slen++] = '+'; + slen += swprintf(output+slen, L"%s", + reg_names[(ins.oprs[i].indexreg - + EXPR_REG_START)]); + if (ins.oprs[i].scale > 1) + slen += swprintf(output+slen, L"*%d", ins.oprs[i].scale); + started = TRUE; + } + if (ins.oprs[i].segment & SEG_DISP8) { + int sign = '+'; + if (ins.oprs[i].offset & 0x80) { + ins.oprs[i].offset = - (signed char) ins.oprs[i].offset; + sign = '-'; + } + slen += swprintf(output+slen, L"%c0x%lx", sign, + ins.oprs[i].offset); + } else if (ins.oprs[i].segment & SEG_DISP16) { + if (started) + output[slen++] = '+'; + //slen += sprintf(output+slen, "0x%lx", ins.oprs[i].offset); + slen += add_label(*p, &ins, output+slen, i); + } else if (ins.oprs[i].segment & SEG_DISP32) { + if (started) + output[slen++] = '+'; + //slen += sprintf(output+slen, "0x%lx", ins.oprs[i].offset); + slen += add_label(*p, &ins, output+slen, i); + } + output[slen++] = ']'; + } else { + slen += swprintf(output+slen, L"", i); + } + } + output[slen] = '\0'; + if (segover) { /* unused segment override */ + wchar_t *p = output; + int count = slen+1; + while (count--) + p[count+3] = p[count]; + wcsncpy(output, segover, 2); + output[2] = ' '; + } + return length; +} + +long eatbyte (unsigned char *data, wchar_t *output) +{ + swprintf(output, L"db 0x%02X", *data); + return 1; +} diff --git a/mobius/src/drivers/kdebug/disasm.d b/mobius/src/drivers/kdebug/disasm.d new file mode 100644 index 0000000..33da7ea --- /dev/null +++ b/mobius/src/drivers/kdebug/disasm.d @@ -0,0 +1,6 @@ +disasm.o: disasm.c f:\Projects\mobius\include\stdio.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h \ + f:\Projects\mobius\include\stdarg.h f:\Projects\mobius\include\io.h \ + f:\Projects\mobius\include\string.h nasm.h insnsi.h disasm.h sync.h \ + insns.h names.c insnsn.c diff --git a/mobius/src/drivers/kdebug/disasm.h b/mobius/src/drivers/kdebug/disasm.h new file mode 100644 index 0000000..f4a647b --- /dev/null +++ b/mobius/src/drivers/kdebug/disasm.h @@ -0,0 +1,18 @@ +/* disasm.h header file for disasm.c + * + * The Netwide Assembler is copyright (C) 1996 Simon Tatham and + * Julian Hall. All rights reserved. The software is + * redistributable under the licence given in the file "Licence" + * distributed in the NASM archive. + */ + +#ifndef NASM_DISASM_H +#define NASM_DISASM_H + +#define INSN_MAX 32 /* one instruction can't be longer than this */ + +long disasm (unsigned char *data, wchar_t *output, int segsize, long offset, + int autosync, unsigned long prefer); +long eatbyte (unsigned char *data, wchar_t *output); + +#endif diff --git a/mobius/src/drivers/kdebug/insns.h b/mobius/src/drivers/kdebug/insns.h new file mode 100644 index 0000000..aade391 --- /dev/null +++ b/mobius/src/drivers/kdebug/insns.h @@ -0,0 +1,78 @@ +/* insns.h header file for insns.c + * $Id: insns.h,v 1.1.1.1 2001/06/04 23:47:40 pavlovskii Exp $ + * + * The Netwide Assembler is copyright (C) 1996 Simon Tatham and + * Julian Hall. All rights reserved. The software is + * redistributable under the licence given in the file "Licence" + * distributed in the NASM archive. + */ + +#ifndef NASM_INSNS_H +#define NASM_INSNS_H + +struct itemplate { + int opcode; /* the token, passed from "parser.c" */ + int operands; /* number of operands */ + long opd[3]; /* bit flags for operand types */ + char *code; /* the code it assembles to */ + unsigned long flags; /* some flags */ +}; + +/* + * Instruction template flags. These specify which processor + * targets the instruction is eligible for, whether it is + * privileged or undocumented, and also specify extra error + * checking on the matching of the instruction. + * + * IF_SM stands for Size Match: any operand whose size is not + * explicitly specified by the template is `really' intended to be + * the same size as the first size-specified operand. + * Non-specification is tolerated in the input instruction, but + * _wrong_ specification is not. + * + * IF_SM2 invokes Size Match on only the first _two_ operands, for + * three-operand instructions such as SHLD: it implies that the + * first two operands must match in size, but that the third is + * required to be _unspecified_. + * + * IF_SB invokes Size Byte: operands with unspecified size in the + * template are really bytes, and so no non-byte specification in + * the input instruction will be tolerated. IF_SW similarly invokes + * Size Word, and IF_SD invokes Size Doubleword. + * + * (The default state if neither IF_SM nor IF_SM2 is specified is + * that any operand with unspecified size in the template is + * required to have unspecified size in the instruction too...) + */ + +#define IF_SM 0x00000001UL /* size match */ +#define IF_SM2 0x00000002UL /* size match first two operands */ +#define IF_SB 0x00000004UL /* unsized operands can't be non-byte */ +#define IF_SW 0x00000008UL /* unsized operands can't be non-word */ +#define IF_SD 0x00000010UL /* unsized operands can't be nondword */ +#define IF_AR0 0x00000020UL /* SB, SW, SD applies to argument 0 */ +#define IF_AR1 0x00000040UL /* SB, SW, SD applies to argument 1 */ +#define IF_AR2 0x00000060UL /* SB, SW, SD applies to argument 2 */ +#define IF_ARMASK 0x00000060UL /* mask for unsized argument spec */ +#define IF_PRIV 0x00000100UL /* it's a privileged instruction */ +#define IF_SMM 0x00000200UL /* it's only valid in SMM */ +#define IF_PROT 0x00000400UL /* it's protected mode only */ +#define IF_UNDOC 0x00001000UL /* it's an undocumented instruction */ +#define IF_FPU 0x00002000UL /* it's an FPU instruction */ +#define IF_MMX 0x00004000UL /* it's an MMX instruction */ +#define IF_3DNOW 0x00008000UL /* it's a 3DNow! instruction */ +#define IF_SSE 0x00010000UL /* it's a SSE (KNI, MMX2) instruction */ +#define IF_PMASK 0xFF000000UL /* the mask for processor types */ +#define IF_PFMASK 0xF001FF00UL /* the mask for disassembly "prefer" */ +#define IF_8086 0x00000000UL /* 8086 instruction */ +#define IF_186 0x01000000UL /* 186+ instruction */ +#define IF_286 0x02000000UL /* 286+ instruction */ +#define IF_386 0x03000000UL /* 386+ instruction */ +#define IF_486 0x04000000UL /* 486+ instruction */ +#define IF_PENT 0x05000000UL /* Pentium instruction */ +#define IF_P6 0x06000000UL /* P6 instruction */ +#define IF_KATMAI 0x07000000UL /* Katmai instructions */ +#define IF_CYRIX 0x10000000UL /* Cyrix-specific instruction */ +#define IF_AMD 0x20000000UL /* AMD-specific instruction */ + +#endif diff --git a/mobius/src/drivers/kdebug/insnsd.c b/mobius/src/drivers/kdebug/insnsd.c new file mode 100644 index 0000000..029f3eb --- /dev/null +++ b/mobius/src/drivers/kdebug/insnsd.c @@ -0,0 +1,3842 @@ +/* This file auto-generated from insns.dat by insns.pl - don't edit it */ + +#include +#include "nasm.h" +#include "insns.h" + +static struct itemplate instrux[] = { + {I_AAA, 0, {0,0,0}, "\1\x37", IF_8086}, + {I_AAD, 0, {0,0,0}, "\2\xD5\x0A", IF_8086}, + {I_AAD, 1, {IMMEDIATE,0,0}, "\1\xD5\24", IF_8086|IF_SB}, + {I_AAM, 0, {0,0,0}, "\2\xD4\x0A", IF_8086}, + {I_AAM, 1, {IMMEDIATE,0,0}, "\1\xD4\24", IF_8086|IF_SB}, + {I_AAS, 0, {0,0,0}, "\1\x3F", IF_8086}, + {I_ADC, 2, {MEMORY,REG8,0}, "\300\1\x10\101", IF_8086|IF_SM}, + {I_ADC, 2, {REG8,REG8,0}, "\300\1\x10\101", IF_8086}, + {I_ADC, 2, {MEMORY,REG16,0}, "\320\300\1\x11\101", IF_8086|IF_SM}, + {I_ADC, 2, {REG16,REG16,0}, "\320\300\1\x11\101", IF_8086}, + {I_ADC, 2, {MEMORY,REG32,0}, "\321\300\1\x11\101", IF_386|IF_SM}, + {I_ADC, 2, {REG32,REG32,0}, "\321\300\1\x11\101", IF_386}, + {I_ADC, 2, {REG8,MEMORY,0}, "\301\1\x12\110", IF_8086|IF_SM}, + {I_ADC, 2, {REG8,REG8,0}, "\301\1\x12\110", IF_8086}, + {I_ADC, 2, {REG16,MEMORY,0}, "\320\301\1\x13\110", IF_8086|IF_SM}, + {I_ADC, 2, {REG16,REG16,0}, "\320\301\1\x13\110", IF_8086}, + {I_ADC, 2, {REG32,MEMORY,0}, "\321\301\1\x13\110", IF_386|IF_SM}, + {I_ADC, 2, {REG32,REG32,0}, "\321\301\1\x13\110", IF_386}, + {I_ADC, 2, {REGMEM|BITS16,IMMEDIATE|BITS8,0}, "\320\300\1\x83\202\15", IF_8086}, + {I_ADC, 2, {REGMEM|BITS32,IMMEDIATE|BITS8,0}, "\321\300\1\x83\202\15", IF_386}, + {I_ADC, 2, {REG_AL,IMMEDIATE,0}, "\1\x14\21", IF_8086|IF_SM}, + {I_ADC, 2, {REG_AX,IMMEDIATE,0}, "\320\1\x15\31", IF_8086|IF_SM}, + {I_ADC, 2, {REG_EAX,IMMEDIATE,0}, "\321\1\x15\41", IF_386|IF_SM}, + {I_ADC, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\x80\202\21", IF_8086|IF_SM}, + {I_ADC, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\x81\202\31", IF_8086|IF_SM}, + {I_ADC, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\x81\202\41", IF_386|IF_SM}, + {I_ADC, 2, {MEMORY,IMMEDIATE|BITS8,0}, "\300\1\x80\202\21", IF_8086|IF_SM}, + {I_ADC, 2, {MEMORY,IMMEDIATE|BITS16,0}, "\320\300\1\x81\202\31", IF_8086|IF_SM}, + {I_ADC, 2, {MEMORY,IMMEDIATE|BITS32,0}, "\321\300\1\x81\202\41", IF_386|IF_SM}, + {I_ADD, 2, {MEMORY,REG8,0}, "\300\17\101", IF_8086|IF_SM}, + {I_ADD, 2, {REG8,REG8,0}, "\300\17\101", IF_8086}, + {I_ADD, 2, {MEMORY,REG16,0}, "\320\300\1\x01\101", IF_8086|IF_SM}, + {I_ADD, 2, {REG16,REG16,0}, "\320\300\1\x01\101", IF_8086}, + {I_ADD, 2, {MEMORY,REG32,0}, "\321\300\1\x01\101", IF_386|IF_SM}, + {I_ADD, 2, {REG32,REG32,0}, "\321\300\1\x01\101", IF_386}, + {I_ADD, 2, {REG8,MEMORY,0}, "\301\1\x02\110", IF_8086|IF_SM}, + {I_ADD, 2, {REG8,REG8,0}, "\301\1\x02\110", IF_8086}, + {I_ADD, 2, {REG16,MEMORY,0}, "\320\301\1\x03\110", IF_8086|IF_SM}, + {I_ADD, 2, {REG16,REG16,0}, "\320\301\1\x03\110", IF_8086}, + {I_ADD, 2, {REG32,MEMORY,0}, "\321\301\1\x03\110", IF_386|IF_SM}, + {I_ADD, 2, {REG32,REG32,0}, "\321\301\1\x03\110", IF_386}, + {I_ADD, 2, {REGMEM|BITS16,IMMEDIATE|BITS8,0}, "\320\300\1\x83\200\15", IF_8086}, + {I_ADD, 2, {REGMEM|BITS32,IMMEDIATE|BITS8,0}, "\321\300\1\x83\200\15", IF_386}, + {I_ADD, 2, {REG_AL,IMMEDIATE,0}, "\1\x04\21", IF_8086|IF_SM}, + {I_ADD, 2, {REG_AX,IMMEDIATE,0}, "\320\1\x05\31", IF_8086|IF_SM}, + {I_ADD, 2, {REG_EAX,IMMEDIATE,0}, "\321\1\x05\41", IF_386|IF_SM}, + {I_ADD, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\x80\200\21", IF_8086|IF_SM}, + {I_ADD, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\x81\200\31", IF_8086|IF_SM}, + {I_ADD, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\x81\200\41", IF_386|IF_SM}, + {I_ADD, 2, {MEMORY,IMMEDIATE|BITS8,0}, "\300\1\x80\200\21", IF_8086|IF_SM}, + {I_ADD, 2, {MEMORY,IMMEDIATE|BITS16,0}, "\320\300\1\x81\200\31", IF_8086|IF_SM}, + {I_ADD, 2, {MEMORY,IMMEDIATE|BITS32,0}, "\321\300\1\x81\200\41", IF_386|IF_SM}, + {I_AND, 2, {MEMORY,REG8,0}, "\300\1\x20\101", IF_8086|IF_SM}, + {I_AND, 2, {REG8,REG8,0}, "\300\1\x20\101", IF_8086}, + {I_AND, 2, {MEMORY,REG16,0}, "\320\300\1\x21\101", IF_8086|IF_SM}, + {I_AND, 2, {REG16,REG16,0}, "\320\300\1\x21\101", IF_8086}, + {I_AND, 2, {MEMORY,REG32,0}, "\321\300\1\x21\101", IF_386|IF_SM}, + {I_AND, 2, {REG32,REG32,0}, "\321\300\1\x21\101", IF_386}, + {I_AND, 2, {REG8,MEMORY,0}, "\301\1\x22\110", IF_8086|IF_SM}, + {I_AND, 2, {REG8,REG8,0}, "\301\1\x22\110", IF_8086}, + {I_AND, 2, {REG16,MEMORY,0}, "\320\301\1\x23\110", IF_8086|IF_SM}, + {I_AND, 2, {REG16,REG16,0}, "\320\301\1\x23\110", IF_8086}, + {I_AND, 2, {REG32,MEMORY,0}, "\321\301\1\x23\110", IF_386|IF_SM}, + {I_AND, 2, {REG32,REG32,0}, "\321\301\1\x23\110", IF_386}, + {I_AND, 2, {REGMEM|BITS16,IMMEDIATE|BITS8,0}, "\320\300\1\x83\204\15", IF_8086}, + {I_AND, 2, {REGMEM|BITS32,IMMEDIATE|BITS8,0}, "\321\300\1\x83\204\15", IF_386}, + {I_AND, 2, {REG_AL,IMMEDIATE,0}, "\1\x24\21", IF_8086|IF_SM}, + {I_AND, 2, {REG_AX,IMMEDIATE,0}, "\320\1\x25\31", IF_8086|IF_SM}, + {I_AND, 2, {REG_EAX,IMMEDIATE,0}, "\321\1\x25\41", IF_386|IF_SM}, + {I_AND, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\x80\204\21", IF_8086|IF_SM}, + {I_AND, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\x81\204\31", IF_8086|IF_SM}, + {I_AND, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\x81\204\41", IF_386|IF_SM}, + {I_AND, 2, {MEMORY,IMMEDIATE|BITS8,0}, "\300\1\x80\204\21", IF_8086|IF_SM}, + {I_AND, 2, {MEMORY,IMMEDIATE|BITS16,0}, "\320\300\1\x81\204\31", IF_8086|IF_SM}, + {I_AND, 2, {MEMORY,IMMEDIATE|BITS32,0}, "\321\300\1\x81\204\41", IF_386|IF_SM}, + {I_ARPL, 2, {MEMORY,REG16,0}, "\300\1\x63\101", IF_286|IF_PROT|IF_SM}, + {I_ARPL, 2, {REG16,REG16,0}, "\300\1\x63\101", IF_286|IF_PROT}, + {I_BOUND, 2, {REG16,MEMORY,0}, "\320\301\1\x62\110", IF_186}, + {I_BOUND, 2, {REG32,MEMORY,0}, "\321\301\1\x62\110", IF_386}, + {I_BSF, 2, {REG16,MEMORY,0}, "\320\301\2\x0F\xBC\110", IF_386|IF_SM}, + {I_BSF, 2, {REG16,REG16,0}, "\320\301\2\x0F\xBC\110", IF_386}, + {I_BSF, 2, {REG32,MEMORY,0}, "\321\301\2\x0F\xBC\110", IF_386|IF_SM}, + {I_BSF, 2, {REG32,REG32,0}, "\321\301\2\x0F\xBC\110", IF_386}, + {I_BSR, 2, {REG16,MEMORY,0}, "\320\301\2\x0F\xBD\110", IF_386|IF_SM}, + {I_BSR, 2, {REG16,REG16,0}, "\320\301\2\x0F\xBD\110", IF_386}, + {I_BSR, 2, {REG32,MEMORY,0}, "\321\301\2\x0F\xBD\110", IF_386|IF_SM}, + {I_BSR, 2, {REG32,REG32,0}, "\321\301\2\x0F\xBD\110", IF_386}, + {I_BSWAP, 1, {REG32,0,0}, "\321\1\x0F\10\xC8", IF_486}, + {I_BT, 2, {MEMORY,REG16,0}, "\320\300\2\x0F\xA3\101", IF_386|IF_SM}, + {I_BT, 2, {REG16,REG16,0}, "\320\300\2\x0F\xA3\101", IF_386}, + {I_BT, 2, {MEMORY,REG32,0}, "\321\300\2\x0F\xA3\101", IF_386|IF_SM}, + {I_BT, 2, {REG32,REG32,0}, "\321\300\2\x0F\xA3\101", IF_386}, + {I_BT, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\2\x0F\xBA\204\25", IF_386|IF_SB}, + {I_BT, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\2\x0F\xBA\204\25", IF_386|IF_SB}, + {I_BTC, 2, {MEMORY,REG16,0}, "\320\300\2\x0F\xBB\101", IF_386|IF_SM}, + {I_BTC, 2, {REG16,REG16,0}, "\320\300\2\x0F\xBB\101", IF_386}, + {I_BTC, 2, {MEMORY,REG32,0}, "\321\300\2\x0F\xBB\101", IF_386|IF_SM}, + {I_BTC, 2, {REG32,REG32,0}, "\321\300\2\x0F\xBB\101", IF_386}, + {I_BTC, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\2\x0F\xBA\207\25", IF_386|IF_SB}, + {I_BTC, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\2\x0F\xBA\207\25", IF_386|IF_SB}, + {I_BTR, 2, {MEMORY,REG16,0}, "\320\300\2\x0F\xB3\101", IF_386|IF_SM}, + {I_BTR, 2, {REG16,REG16,0}, "\320\300\2\x0F\xB3\101", IF_386}, + {I_BTR, 2, {MEMORY,REG32,0}, "\321\300\2\x0F\xB3\101", IF_386|IF_SM}, + {I_BTR, 2, {REG32,REG32,0}, "\321\300\2\x0F\xB3\101", IF_386}, + {I_BTR, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\2\x0F\xBA\206\25", IF_386|IF_SB}, + {I_BTR, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\2\x0F\xBA\206\25", IF_386|IF_SB}, + {I_BTS, 2, {MEMORY,REG16,0}, "\320\300\2\x0F\xAB\101", IF_386|IF_SM}, + {I_BTS, 2, {REG16,REG16,0}, "\320\300\2\x0F\xAB\101", IF_386}, + {I_BTS, 2, {MEMORY,REG32,0}, "\321\300\2\x0F\xAB\101", IF_386|IF_SM}, + {I_BTS, 2, {REG32,REG32,0}, "\321\300\2\x0F\xAB\101", IF_386}, + {I_BTS, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\2\x0F\xBA\205\25", IF_386|IF_SB}, + {I_BTS, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\2\x0F\xBA\205\25", IF_386|IF_SB}, + {I_CALL, 1, {IMMEDIATE,0,0}, "\322\1\xE8\64", IF_8086}, + {I_CALL, 1, {IMMEDIATE|NEAR,0,0}, "\322\1\xE8\64", IF_8086}, + {I_CALL, 1, {IMMEDIATE|BITS16,0,0}, "\320\1\xE8\64", IF_8086}, + {I_CALL, 1, {IMMEDIATE|BITS16|NEAR,0,0}, "\320\1\xE8\64", IF_8086}, + {I_CALL, 1, {IMMEDIATE|BITS32,0,0}, "\321\1\xE8\64", IF_8086}, + {I_CALL, 1, {IMMEDIATE|BITS32|NEAR,0,0}, "\321\1\xE8\64", IF_8086}, + {I_CALL, 2, {IMMEDIATE|COLON,IMMEDIATE,0}, "\322\1\x9A\35\30", IF_8086}, + {I_CALL, 2, {IMMEDIATE|BITS16|COLON,IMMEDIATE,0}, "\320\1\x9A\31\30", IF_8086}, + {I_CALL, 2, {IMMEDIATE|COLON,IMMEDIATE|BITS16,0}, "\320\1\x9A\31\30", IF_8086}, + {I_CALL, 2, {IMMEDIATE|BITS32|COLON,IMMEDIATE,0}, "\321\1\x9A\41\30", IF_386}, + {I_CALL, 2, {IMMEDIATE|COLON,IMMEDIATE|BITS32,0}, "\321\1\x9A\41\30", IF_386}, + {I_CALL, 1, {MEMORY|FAR,0,0}, "\322\300\1\xFF\203", IF_8086}, + {I_CALL, 1, {MEMORY|BITS16|FAR,0,0}, "\320\300\1\xFF\203", IF_8086}, + {I_CALL, 1, {MEMORY|BITS32|FAR,0,0}, "\321\300\1\xFF\203", IF_386}, + {I_CALL, 1, {MEMORY|NEAR,0,0}, "\322\300\1\xFF\202", IF_8086}, + {I_CALL, 1, {MEMORY|BITS16|NEAR,0,0}, "\320\300\1\xFF\202", IF_8086}, + {I_CALL, 1, {MEMORY|BITS32|NEAR,0,0}, "\321\300\1\xFF\202", IF_386}, + {I_CALL, 1, {REG16,0,0}, "\320\300\1\xFF\202", IF_8086}, + {I_CALL, 1, {REG32,0,0}, "\321\300\1\xFF\202", IF_386}, + {I_CALL, 1, {MEMORY,0,0}, "\322\300\1\xFF\202", IF_8086}, + {I_CALL, 1, {MEMORY|BITS16,0,0}, "\320\300\1\xFF\202", IF_8086}, + {I_CALL, 1, {MEMORY|BITS32,0,0}, "\321\300\1\xFF\202", IF_386}, + {I_CBW, 0, {0,0,0}, "\320\1\x98", IF_8086}, + {I_CDQ, 0, {0,0,0}, "\321\1\x99", IF_386}, + {I_CLC, 0, {0,0,0}, "\1\xF8", IF_8086}, + {I_CLD, 0, {0,0,0}, "\1\xFC", IF_8086}, + {I_CLI, 0, {0,0,0}, "\1\xFA", IF_8086}, + {I_CLTS, 0, {0,0,0}, "\2\x0F\x06", IF_286|IF_PRIV}, + {I_CMC, 0, {0,0,0}, "\1\xF5", IF_8086}, + {I_CMP, 2, {MEMORY,REG8,0}, "\300\1\x38\101", IF_8086|IF_SM}, + {I_CMP, 2, {REG8,REG8,0}, "\300\1\x38\101", IF_8086}, + {I_CMP, 2, {MEMORY,REG16,0}, "\320\300\1\x39\101", IF_8086|IF_SM}, + {I_CMP, 2, {REG16,REG16,0}, "\320\300\1\x39\101", IF_8086}, + {I_CMP, 2, {MEMORY,REG32,0}, "\321\300\1\x39\101", IF_386|IF_SM}, + {I_CMP, 2, {REG32,REG32,0}, "\321\300\1\x39\101", IF_386}, + {I_CMP, 2, {REG8,MEMORY,0}, "\301\1\x3A\110", IF_8086|IF_SM}, + {I_CMP, 2, {REG8,REG8,0}, "\301\1\x3A\110", IF_8086}, + {I_CMP, 2, {REG16,MEMORY,0}, "\320\301\1\x3B\110", IF_8086|IF_SM}, + {I_CMP, 2, {REG16,REG16,0}, "\320\301\1\x3B\110", IF_8086}, + {I_CMP, 2, {REG32,MEMORY,0}, "\321\301\1\x3B\110", IF_386|IF_SM}, + {I_CMP, 2, {REG32,REG32,0}, "\321\301\1\x3B\110", IF_386}, + {I_CMP, 2, {REGMEM|BITS16,IMMEDIATE|BITS8,0}, "\320\300\1\x83\207\15", IF_8086}, + {I_CMP, 2, {REGMEM|BITS32,IMMEDIATE|BITS8,0}, "\321\300\1\x83\207\15", IF_386}, + {I_CMP, 2, {REG_AL,IMMEDIATE,0}, "\1\x3C\21", IF_8086|IF_SM}, + {I_CMP, 2, {REG_AX,IMMEDIATE,0}, "\320\1\x3D\31", IF_8086|IF_SM}, + {I_CMP, 2, {REG_EAX,IMMEDIATE,0}, "\321\1\x3D\41", IF_386|IF_SM}, + {I_CMP, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\x80\207\21", IF_8086|IF_SM}, + {I_CMP, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\x81\207\31", IF_8086|IF_SM}, + {I_CMP, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\x81\207\41", IF_386|IF_SM}, + {I_CMP, 2, {MEMORY,IMMEDIATE|BITS8,0}, "\300\1\x80\207\21", IF_8086|IF_SM}, + {I_CMP, 2, {MEMORY,IMMEDIATE|BITS16,0}, "\320\300\1\x81\207\31", IF_8086|IF_SM}, + {I_CMP, 2, {MEMORY,IMMEDIATE|BITS32,0}, "\321\300\1\x81\207\41", IF_386|IF_SM}, + {I_CMPSB, 0, {0,0,0}, "\332\1\xA6", IF_8086}, + {I_CMPSD, 0, {0,0,0}, "\332\321\1\xA7", IF_386}, + {I_CMPSW, 0, {0,0,0}, "\332\320\1\xA7", IF_8086}, + {I_CMPXCHG, 2, {MEMORY,REG8,0}, "\300\2\x0F\xB0\101", IF_PENT|IF_SM}, + {I_CMPXCHG, 2, {REG8,REG8,0}, "\300\2\x0F\xB0\101", IF_PENT}, + {I_CMPXCHG, 2, {MEMORY,REG16,0}, "\320\300\2\x0F\xB1\101", IF_PENT|IF_SM}, + {I_CMPXCHG, 2, {REG16,REG16,0}, "\320\300\2\x0F\xB1\101", IF_PENT}, + {I_CMPXCHG, 2, {MEMORY,REG32,0}, "\321\300\2\x0F\xB1\101", IF_PENT|IF_SM}, + {I_CMPXCHG, 2, {REG32,REG32,0}, "\321\300\2\x0F\xB1\101", IF_PENT}, + {I_CMPXCHG486, 2, {MEMORY,REG8,0}, "\300\2\x0F\xA6\101", IF_486|IF_SM|IF_UNDOC}, + {I_CMPXCHG486, 2, {REG8,REG8,0}, "\300\2\x0F\xA6\101", IF_486|IF_UNDOC}, + {I_CMPXCHG486, 2, {MEMORY,REG16,0}, "\320\300\2\x0F\xA7\101", IF_486|IF_SM|IF_UNDOC}, + {I_CMPXCHG486, 2, {REG16,REG16,0}, "\320\300\2\x0F\xA7\101", IF_486|IF_UNDOC}, + {I_CMPXCHG486, 2, {MEMORY,REG32,0}, "\321\300\2\x0F\xA7\101", IF_486|IF_SM|IF_UNDOC}, + {I_CMPXCHG486, 2, {REG32,REG32,0}, "\321\300\2\x0F\xA7\101", IF_486|IF_UNDOC}, + {I_CMPXCHG8B, 1, {MEMORY,0,0}, "\300\2\x0F\xC7\201", IF_PENT}, + {I_CPUID, 0, {0,0,0}, "\2\x0F\xA2", IF_PENT}, + {I_CWD, 0, {0,0,0}, "\320\1\x99", IF_8086}, + {I_CWDE, 0, {0,0,0}, "\321\1\x98", IF_386}, + {I_DAA, 0, {0,0,0}, "\1\x27", IF_8086}, + {I_DAS, 0, {0,0,0}, "\1\x2F", IF_8086}, + {I_DEC, 1, {REG16,0,0}, "\320\10\x48", IF_8086}, + {I_DEC, 1, {REG32,0,0}, "\321\10\x48", IF_386}, + {I_DEC, 1, {REGMEM|BITS8,0,0}, "\300\1\xFE\201", IF_8086}, + {I_DEC, 1, {REGMEM|BITS16,0,0}, "\320\300\1\xFF\201", IF_8086}, + {I_DEC, 1, {REGMEM|BITS32,0,0}, "\321\300\1\xFF\201", IF_386}, + {I_DIV, 1, {REGMEM|BITS8,0,0}, "\300\1\xF6\206", IF_8086}, + {I_DIV, 1, {REGMEM|BITS16,0,0}, "\320\300\1\xF7\206", IF_8086}, + {I_DIV, 1, {REGMEM|BITS32,0,0}, "\321\300\1\xF7\206", IF_386}, + {I_EMMS, 0, {0,0,0}, "\2\x0F\x77", IF_PENT|IF_MMX}, + {I_ENTER, 2, {IMMEDIATE,IMMEDIATE,0}, "\1\xC8\30\25", IF_186}, + {I_EQU, 1, {IMMEDIATE,0,0}, "\0", IF_8086}, + {I_EQU, 2, {IMMEDIATE|COLON,IMMEDIATE,0}, "\0", IF_8086}, + {I_F2XM1, 0, {0,0,0}, "\2\xD9\xF0", IF_8086|IF_FPU}, + {I_FABS, 0, {0,0,0}, "\2\xD9\xE1", IF_8086|IF_FPU}, + {I_FADD, 1, {MEMORY|BITS32,0,0}, "\300\1\xD8\200", IF_8086|IF_FPU}, + {I_FADD, 1, {MEMORY|BITS64,0,0}, "\300\1\xDC\200", IF_8086|IF_FPU}, + {I_FADD, 1, {FPUREG|TO,0,0}, "\1\xDC\10\xC0", IF_8086|IF_FPU}, + {I_FADD, 1, {FPUREG,0,0}, "\1\xD8\10\xC0", IF_8086|IF_FPU}, + {I_FADD, 2, {FPUREG,FPU0,0}, "\1\xDC\10\xC0", IF_8086|IF_FPU}, + {I_FADD, 2, {FPU0,FPUREG,0}, "\1\xD8\11\xC0", IF_8086|IF_FPU}, + {I_FADDP, 1, {FPUREG,0,0}, "\1\xDE\10\xC0", IF_8086|IF_FPU}, + {I_FADDP, 2, {FPUREG,FPU0,0}, "\1\xDE\10\xC0", IF_8086|IF_FPU}, + {I_FBLD, 1, {MEMORY|BITS80,0,0}, "\300\1\xDF\204", IF_8086|IF_FPU}, + {I_FBLD, 1, {MEMORY,0,0}, "\300\1\xDF\204", IF_8086|IF_FPU}, + {I_FBSTP, 1, {MEMORY|BITS80,0,0}, "\300\1\xDF\206", IF_8086|IF_FPU}, + {I_FBSTP, 1, {MEMORY,0,0}, "\300\1\xDF\206", IF_8086|IF_FPU}, + {I_FCHS, 0, {0,0,0}, "\2\xD9\xE0", IF_8086|IF_FPU}, + {I_FCLEX, 0, {0,0,0}, "\3\x9B\xDB\xE2", IF_8086|IF_FPU}, + {I_FCMOVB, 1, {FPUREG,0,0}, "\1\xDA\10\xC0", IF_P6|IF_FPU}, + {I_FCMOVB, 2, {FPU0,FPUREG,0}, "\1\xDA\11\xC0", IF_P6|IF_FPU}, + {I_FCMOVBE, 1, {FPUREG,0,0}, "\1\xDA\10\xD0", IF_P6|IF_FPU}, + {I_FCMOVBE, 2, {FPU0,FPUREG,0}, "\1\xDA\11\xD0", IF_P6|IF_FPU}, + {I_FCMOVE, 1, {FPUREG,0,0}, "\1\xDA\10\xC8", IF_P6|IF_FPU}, + {I_FCMOVE, 2, {FPU0,FPUREG,0}, "\1\xDA\11\xC8", IF_P6|IF_FPU}, + {I_FCMOVNB, 1, {FPUREG,0,0}, "\1\xDB\10\xC0", IF_P6|IF_FPU}, + {I_FCMOVNB, 2, {FPU0,FPUREG,0}, "\1\xDB\11\xC0", IF_P6|IF_FPU}, + {I_FCMOVNBE, 1, {FPUREG,0,0}, "\1\xDB\10\xD0", IF_P6|IF_FPU}, + {I_FCMOVNBE, 2, {FPU0,FPUREG,0}, "\1\xDB\11\xD0", IF_P6|IF_FPU}, + {I_FCMOVNE, 1, {FPUREG,0,0}, "\1\xDB\10\xC8", IF_P6|IF_FPU}, + {I_FCMOVNE, 2, {FPU0,FPUREG,0}, "\1\xDB\11\xC8", IF_P6|IF_FPU}, + {I_FCMOVNU, 1, {FPUREG,0,0}, "\1\xDB\10\xD8", IF_P6|IF_FPU}, + {I_FCMOVNU, 2, {FPU0,FPUREG,0}, "\1\xDB\11\xD8", IF_P6|IF_FPU}, + {I_FCMOVU, 1, {FPUREG,0,0}, "\1\xDA\10\xD8", IF_P6|IF_FPU}, + {I_FCMOVU, 2, {FPU0,FPUREG,0}, "\1\xDA\11\xD8", IF_P6|IF_FPU}, + {I_FCOM, 1, {MEMORY|BITS32,0,0}, "\300\1\xD8\202", IF_8086|IF_FPU}, + {I_FCOM, 1, {MEMORY|BITS64,0,0}, "\300\1\xDC\202", IF_8086|IF_FPU}, + {I_FCOM, 1, {FPUREG,0,0}, "\1\xD8\10\xD0", IF_8086|IF_FPU}, + {I_FCOM, 2, {FPU0,FPUREG,0}, "\1\xD8\11\xD0", IF_8086|IF_FPU}, + {I_FCOMI, 1, {FPUREG,0,0}, "\1\xDB\10\xF0", IF_P6|IF_FPU}, + {I_FCOMI, 2, {FPU0,FPUREG,0}, "\1\xDB\11\xF0", IF_P6|IF_FPU}, + {I_FCOMIP, 1, {FPUREG,0,0}, "\1\xDF\10\xF0", IF_P6|IF_FPU}, + {I_FCOMIP, 2, {FPU0,FPUREG,0}, "\1\xDF\11\xF0", IF_P6|IF_FPU}, + {I_FCOMP, 1, {MEMORY|BITS32,0,0}, "\300\1\xD8\203", IF_8086|IF_FPU}, + {I_FCOMP, 1, {MEMORY|BITS64,0,0}, "\300\1\xDC\203", IF_8086|IF_FPU}, + {I_FCOMP, 1, {FPUREG,0,0}, "\1\xD8\10\xD8", IF_8086|IF_FPU}, + {I_FCOMP, 2, {FPU0,FPUREG,0}, "\1\xD8\11\xD8", IF_8086|IF_FPU}, + {I_FCOMPP, 0, {0,0,0}, "\2\xDE\xD9", IF_8086|IF_FPU}, + {I_FCOS, 0, {0,0,0}, "\2\xD9\xFF", IF_386|IF_FPU}, + {I_FDECSTP, 0, {0,0,0}, "\2\xD9\xF6", IF_8086|IF_FPU}, + {I_FDISI, 0, {0,0,0}, "\3\x9B\xDB\xE1", IF_8086|IF_FPU}, + {I_FDIV, 1, {MEMORY|BITS32,0,0}, "\300\1\xD8\206", IF_8086|IF_FPU}, + {I_FDIV, 1, {MEMORY|BITS64,0,0}, "\300\1\xDC\206", IF_8086|IF_FPU}, + {I_FDIV, 1, {FPUREG|TO,0,0}, "\1\xDC\10\xF8", IF_8086|IF_FPU}, + {I_FDIV, 2, {FPUREG,FPU0,0}, "\1\xDC\10\xF8", IF_8086|IF_FPU}, + {I_FDIV, 1, {FPUREG,0,0}, "\1\xD8\10\xF0", IF_8086|IF_FPU}, + {I_FDIV, 2, {FPU0,FPUREG,0}, "\1\xD8\11\xF0", IF_8086|IF_FPU}, + {I_FDIVP, 2, {FPUREG,FPU0,0}, "\1\xDE\10\xF8", IF_8086|IF_FPU}, + {I_FDIVP, 1, {FPUREG,0,0}, "\1\xDE\10\xF8", IF_8086|IF_FPU}, + {I_FDIVR, 1, {MEMORY|BITS32,0,0}, "\300\1\xD8\207", IF_8086|IF_FPU}, + {I_FDIVR, 1, {MEMORY|BITS64,0,0}, "\300\1\xDC\207", IF_8086|IF_FPU}, + {I_FDIVR, 1, {FPUREG|TO,0,0}, "\1\xDC\10\xF0", IF_8086|IF_FPU}, + {I_FDIVR, 2, {FPUREG,FPU0,0}, "\1\xDC\10\xF0", IF_8086|IF_FPU}, + {I_FDIVR, 1, {FPUREG,0,0}, "\1\xD8\10\xF8", IF_8086|IF_FPU}, + {I_FDIVR, 2, {FPU0,FPUREG,0}, "\1\xD8\11\xF8", IF_8086|IF_FPU}, + {I_FDIVRP, 1, {FPUREG,0,0}, "\1\xDE\10\xF0", IF_8086|IF_FPU}, + {I_FDIVRP, 2, {FPUREG,FPU0,0}, "\1\xDE\10\xF0", IF_8086|IF_FPU}, + {I_FEMMS, 0, {0,0,0}, "\2\x0F\x0E", IF_PENT|IF_3DNOW}, + {I_FENI, 0, {0,0,0}, "\3\x9B\xDB\xE0", IF_8086|IF_FPU}, + {I_FFREE, 1, {FPUREG,0,0}, "\1\xDD\10\xC0", IF_8086|IF_FPU}, + {I_FIADD, 1, {MEMORY|BITS32,0,0}, "\300\1\xDA\200", IF_8086|IF_FPU}, + {I_FIADD, 1, {MEMORY|BITS16,0,0}, "\300\1\xDE\200", IF_8086|IF_FPU}, + {I_FICOM, 1, {MEMORY|BITS32,0,0}, "\300\1\xDA\202", IF_8086|IF_FPU}, + {I_FICOM, 1, {MEMORY|BITS16,0,0}, "\300\1\xDE\202", IF_8086|IF_FPU}, + {I_FICOMP, 1, {MEMORY|BITS32,0,0}, "\300\1\xDA\203", IF_8086|IF_FPU}, + {I_FICOMP, 1, {MEMORY|BITS16,0,0}, "\300\1\xDE\203", IF_8086|IF_FPU}, + {I_FIDIV, 1, {MEMORY|BITS32,0,0}, "\300\1\xDA\206", IF_8086|IF_FPU}, + {I_FIDIV, 1, {MEMORY|BITS16,0,0}, "\300\1\xDE\206", IF_8086|IF_FPU}, + {I_FIDIVR, 1, {MEMORY|BITS32,0,0}, "\300\1\xDA\207", IF_8086|IF_FPU}, + {I_FIDIVR, 1, {MEMORY|BITS16,0,0}, "\300\1\xDE\207", IF_8086|IF_FPU}, + {I_FILD, 1, {MEMORY|BITS32,0,0}, "\300\1\xDB\200", IF_8086|IF_FPU}, + {I_FILD, 1, {MEMORY|BITS16,0,0}, "\300\1\xDF\200", IF_8086|IF_FPU}, + {I_FILD, 1, {MEMORY|BITS64,0,0}, "\300\1\xDF\205", IF_8086|IF_FPU}, + {I_FIMUL, 1, {MEMORY|BITS32,0,0}, "\300\1\xDA\201", IF_8086|IF_FPU}, + {I_FIMUL, 1, {MEMORY|BITS16,0,0}, "\300\1\xDE\201", IF_8086|IF_FPU}, + {I_FINCSTP, 0, {0,0,0}, "\2\xD9\xF7", IF_8086|IF_FPU}, + {I_FINIT, 0, {0,0,0}, "\3\x9B\xDB\xE3", IF_8086|IF_FPU}, + {I_FIST, 1, {MEMORY|BITS32,0,0}, "\300\1\xDB\202", IF_8086|IF_FPU}, + {I_FIST, 1, {MEMORY|BITS16,0,0}, "\300\1\xDF\202", IF_8086|IF_FPU}, + {I_FISTP, 1, {MEMORY|BITS32,0,0}, "\300\1\xDB\203", IF_8086|IF_FPU}, + {I_FISTP, 1, {MEMORY|BITS16,0,0}, "\300\1\xDF\203", IF_8086|IF_FPU}, + {I_FISTP, 1, {MEMORY|BITS64,0,0}, "\300\1\xDF\207", IF_8086|IF_FPU}, + {I_FISUB, 1, {MEMORY|BITS32,0,0}, "\300\1\xDA\204", IF_8086|IF_FPU}, + {I_FISUB, 1, {MEMORY|BITS16,0,0}, "\300\1\xDE\204", IF_8086|IF_FPU}, + {I_FISUBR, 1, {MEMORY|BITS32,0,0}, "\300\1\xDA\205", IF_8086|IF_FPU}, + {I_FISUBR, 1, {MEMORY|BITS16,0,0}, "\300\1\xDE\205", IF_8086|IF_FPU}, + {I_FLD, 1, {MEMORY|BITS32,0,0}, "\300\1\xD9\200", IF_8086|IF_FPU}, + {I_FLD, 1, {MEMORY|BITS64,0,0}, "\300\1\xDD\200", IF_8086|IF_FPU}, + {I_FLD, 1, {MEMORY|BITS80,0,0}, "\300\1\xDB\205", IF_8086|IF_FPU}, + {I_FLD, 1, {FPUREG,0,0}, "\1\xD9\10\xC0", IF_8086|IF_FPU}, + {I_FLD1, 0, {0,0,0}, "\2\xD9\xE8", IF_8086|IF_FPU}, + {I_FLDCW, 1, {MEMORY,0,0}, "\300\1\xD9\205", IF_8086|IF_FPU|IF_SW}, + {I_FLDENV, 1, {MEMORY,0,0}, "\300\1\xD9\204", IF_8086|IF_FPU}, + {I_FLDL2E, 0, {0,0,0}, "\2\xD9\xEA", IF_8086|IF_FPU}, + {I_FLDL2T, 0, {0,0,0}, "\2\xD9\xE9", IF_8086|IF_FPU}, + {I_FLDLG2, 0, {0,0,0}, "\2\xD9\xEC", IF_8086|IF_FPU}, + {I_FLDLN2, 0, {0,0,0}, "\2\xD9\xED", IF_8086|IF_FPU}, + {I_FLDPI, 0, {0,0,0}, "\2\xD9\xEB", IF_8086|IF_FPU}, + {I_FLDZ, 0, {0,0,0}, "\2\xD9\xEE", IF_8086|IF_FPU}, + {I_FMUL, 1, {MEMORY|BITS32,0,0}, "\300\1\xD8\201", IF_8086|IF_FPU}, + {I_FMUL, 1, {MEMORY|BITS64,0,0}, "\300\1\xDC\201", IF_8086|IF_FPU}, + {I_FMUL, 1, {FPUREG|TO,0,0}, "\1\xDC\10\xC8", IF_8086|IF_FPU}, + {I_FMUL, 2, {FPUREG,FPU0,0}, "\1\xDC\10\xC8", IF_8086|IF_FPU}, + {I_FMUL, 1, {FPUREG,0,0}, "\1\xD8\10\xC8", IF_8086|IF_FPU}, + {I_FMUL, 2, {FPU0,FPUREG,0}, "\1\xD8\11\xC8", IF_8086|IF_FPU}, + {I_FMULP, 1, {FPUREG,0,0}, "\1\xDE\10\xC8", IF_8086|IF_FPU}, + {I_FMULP, 2, {FPUREG,FPU0,0}, "\1\xDE\10\xC8", IF_8086|IF_FPU}, + {I_FNCLEX, 0, {0,0,0}, "\2\xDB\xE2", IF_8086|IF_FPU}, + {I_FNDISI, 0, {0,0,0}, "\2\xDB\xE1", IF_8086|IF_FPU}, + {I_FNENI, 0, {0,0,0}, "\2\xDB\xE0", IF_8086|IF_FPU}, + {I_FNINIT, 0, {0,0,0}, "\2\xDB\xE3", IF_8086|IF_FPU}, + {I_FNOP, 0, {0,0,0}, "\2\xD9\xD0", IF_8086|IF_FPU}, + {I_FNSAVE, 1, {MEMORY,0,0}, "\300\1\xDD\206", IF_8086|IF_FPU}, + {I_FNSTCW, 1, {MEMORY,0,0}, "\300\1\xD9\207", IF_8086|IF_FPU|IF_SW}, + {I_FNSTENV, 1, {MEMORY,0,0}, "\300\1\xD9\206", IF_8086|IF_FPU}, + {I_FNSTSW, 1, {MEMORY,0,0}, "\300\1\xDD\207", IF_8086|IF_FPU|IF_SW}, + {I_FNSTSW, 1, {REG_AX,0,0}, "\2\xDF\xE0", IF_286|IF_FPU}, + {I_FPATAN, 0, {0,0,0}, "\2\xD9\xF3", IF_8086|IF_FPU}, + {I_FPREM, 0, {0,0,0}, "\2\xD9\xF8", IF_8086|IF_FPU}, + {I_FPREM1, 0, {0,0,0}, "\2\xD9\xF5", IF_386|IF_FPU}, + {I_FPTAN, 0, {0,0,0}, "\2\xD9\xF2", IF_8086|IF_FPU}, + {I_FRNDINT, 0, {0,0,0}, "\2\xD9\xFC", IF_8086|IF_FPU}, + {I_FRSTOR, 1, {MEMORY,0,0}, "\300\1\xDD\204", IF_8086|IF_FPU}, + {I_FSAVE, 1, {MEMORY,0,0}, "\300\2\x9B\xDD\206", IF_8086|IF_FPU}, + {I_FSCALE, 0, {0,0,0}, "\2\xD9\xFD", IF_8086|IF_FPU}, + {I_FSETPM, 0, {0,0,0}, "\2\xDB\xE4", IF_286|IF_FPU}, + {I_FSIN, 0, {0,0,0}, "\2\xD9\xFE", IF_386|IF_FPU}, + {I_FSINCOS, 0, {0,0,0}, "\2\xD9\xFB", IF_386|IF_FPU}, + {I_FSQRT, 0, {0,0,0}, "\2\xD9\xFA", IF_8086|IF_FPU}, + {I_FST, 1, {MEMORY|BITS32,0,0}, "\300\1\xD9\202", IF_8086|IF_FPU}, + {I_FST, 1, {MEMORY|BITS64,0,0}, "\300\1\xDD\202", IF_8086|IF_FPU}, + {I_FST, 1, {FPUREG,0,0}, "\1\xDD\10\xD0", IF_8086|IF_FPU}, + {I_FSTCW, 1, {MEMORY,0,0}, "\300\2\x9B\xD9\207", IF_8086|IF_FPU|IF_SW}, + {I_FSTENV, 1, {MEMORY,0,0}, "\300\2\x9B\xD9\206", IF_8086|IF_FPU}, + {I_FSTP, 1, {MEMORY|BITS32,0,0}, "\300\1\xD9\203", IF_8086|IF_FPU}, + {I_FSTP, 1, {MEMORY|BITS64,0,0}, "\300\1\xDD\203", IF_8086|IF_FPU}, + {I_FSTP, 1, {MEMORY|BITS80,0,0}, "\300\1\xDB\207", IF_8086|IF_FPU}, + {I_FSTP, 1, {FPUREG,0,0}, "\1\xDD\10\xD8", IF_8086|IF_FPU}, + {I_FSTSW, 1, {MEMORY,0,0}, "\300\2\x9B\xDD\207", IF_8086|IF_FPU|IF_SW}, + {I_FSTSW, 1, {REG_AX,0,0}, "\3\x9B\xDF\xE0", IF_286|IF_FPU}, + {I_FSUB, 1, {MEMORY|BITS32,0,0}, "\300\1\xD8\204", IF_8086|IF_FPU}, + {I_FSUB, 1, {MEMORY|BITS64,0,0}, "\300\1\xDC\204", IF_8086|IF_FPU}, + {I_FSUB, 1, {FPUREG|TO,0,0}, "\1\xDC\10\xE8", IF_8086|IF_FPU}, + {I_FSUB, 2, {FPUREG,FPU0,0}, "\1\xDC\10\xE8", IF_8086|IF_FPU}, + {I_FSUB, 1, {FPUREG,0,0}, "\1\xD8\10\xE0", IF_8086|IF_FPU}, + {I_FSUB, 2, {FPU0,FPUREG,0}, "\1\xD8\11\xE0", IF_8086|IF_FPU}, + {I_FSUBP, 1, {FPUREG,0,0}, "\1\xDE\10\xE8", IF_8086|IF_FPU}, + {I_FSUBP, 2, {FPUREG,FPU0,0}, "\1\xDE\10\xE8", IF_8086|IF_FPU}, + {I_FSUBR, 1, {MEMORY|BITS32,0,0}, "\300\1\xD8\205", IF_8086|IF_FPU}, + {I_FSUBR, 1, {MEMORY|BITS64,0,0}, "\300\1\xDC\205", IF_8086|IF_FPU}, + {I_FSUBR, 1, {FPUREG|TO,0,0}, "\1\xDC\10\xE0", IF_8086|IF_FPU}, + {I_FSUBR, 2, {FPUREG,FPU0,0}, "\1\xDC\10\xE0", IF_8086|IF_FPU}, + {I_FSUBR, 1, {FPUREG,0,0}, "\1\xD8\10\xE8", IF_8086|IF_FPU}, + {I_FSUBR, 2, {FPU0,FPUREG,0}, "\1\xD8\11\xE8", IF_8086|IF_FPU}, + {I_FSUBRP, 1, {FPUREG,0,0}, "\1\xDE\10\xE0", IF_8086|IF_FPU}, + {I_FSUBRP, 2, {FPUREG,FPU0,0}, "\1\xDE\10\xE0", IF_8086|IF_FPU}, + {I_FTST, 0, {0,0,0}, "\2\xD9\xE4", IF_8086|IF_FPU}, + {I_FUCOM, 1, {FPUREG,0,0}, "\1\xDD\10\xE0", IF_386|IF_FPU}, + {I_FUCOM, 2, {FPU0,FPUREG,0}, "\1\xDD\11\xE0", IF_386|IF_FPU}, + {I_FUCOMI, 1, {FPUREG,0,0}, "\1\xDB\10\xE8", IF_P6|IF_FPU}, + {I_FUCOMI, 2, {FPU0,FPUREG,0}, "\1\xDB\11\xE8", IF_P6|IF_FPU}, + {I_FUCOMIP, 1, {FPUREG,0,0}, "\1\xDF\10\xE8", IF_P6|IF_FPU}, + {I_FUCOMIP, 2, {FPU0,FPUREG,0}, "\1\xDF\11\xE8", IF_P6|IF_FPU}, + {I_FUCOMP, 1, {FPUREG,0,0}, "\1\xDD\10\xE8", IF_386|IF_FPU}, + {I_FUCOMP, 2, {FPU0,FPUREG,0}, "\1\xDD\11\xE8", IF_386|IF_FPU}, + {I_FUCOMPP, 0, {0,0,0}, "\2\xDA\xE9", IF_386|IF_FPU}, + {I_FXAM, 0, {0,0,0}, "\2\xD9\xE5", IF_8086|IF_FPU}, + {I_FXCH, 0, {0,0,0}, "\2\xD9\xC9", IF_8086|IF_FPU}, + {I_FXCH, 1, {FPUREG,0,0}, "\1\xD9\10\xC8", IF_8086|IF_FPU}, + {I_FXCH, 2, {FPUREG,FPU0,0}, "\1\xD9\10\xC8", IF_8086|IF_FPU}, + {I_FXCH, 2, {FPU0,FPUREG,0}, "\1\xD9\11\xC8", IF_8086|IF_FPU}, + {I_FXTRACT, 0, {0,0,0}, "\2\xD9\xF4", IF_8086|IF_FPU}, + {I_FYL2X, 0, {0,0,0}, "\2\xD9\xF1", IF_8086|IF_FPU}, + {I_FYL2XP1, 0, {0,0,0}, "\2\xD9\xF9", IF_8086|IF_FPU}, + {I_HLT, 0, {0,0,0}, "\1\xF4", IF_8086|IF_PRIV}, + {I_IDIV, 1, {REGMEM|BITS8,0,0}, "\300\1\xF6\207", IF_8086}, + {I_IDIV, 1, {REGMEM|BITS16,0,0}, "\320\300\1\xF7\207", IF_8086}, + {I_IDIV, 1, {REGMEM|BITS32,0,0}, "\321\300\1\xF7\207", IF_386}, + {I_IMUL, 1, {REGMEM|BITS8,0,0}, "\300\1\xF6\205", IF_8086}, + {I_IMUL, 1, {REGMEM|BITS16,0,0}, "\320\300\1\xF7\205", IF_8086}, + {I_IMUL, 1, {REGMEM|BITS32,0,0}, "\321\300\1\xF7\205", IF_386}, + {I_IMUL, 2, {REG16,MEMORY,0}, "\320\301\2\x0F\xAF\110", IF_386|IF_SM}, + {I_IMUL, 2, {REG16,REG16,0}, "\320\301\2\x0F\xAF\110", IF_386}, + {I_IMUL, 2, {REG32,MEMORY,0}, "\321\301\2\x0F\xAF\110", IF_386|IF_SM}, + {I_IMUL, 2, {REG32,REG32,0}, "\321\301\2\x0F\xAF\110", IF_386}, + {I_IMUL, 3, {REG16,MEMORY,IMMEDIATE|BITS8}, "\320\301\1\x6B\110\16", IF_286|IF_SM}, + {I_IMUL, 3, {REG16,REG16,IMMEDIATE|BITS8}, "\320\301\1\x6B\110\16", IF_286}, + {I_IMUL, 3, {REG16,MEMORY,IMMEDIATE}, "\320\301\1\x69\110\32", IF_286|IF_SM}, + {I_IMUL, 3, {REG16,REG16,IMMEDIATE}, "\320\301\1\x69\110\32", IF_286|IF_SM}, + {I_IMUL, 3, {REG32,MEMORY,IMMEDIATE|BITS8}, "\321\301\1\x6B\110\16", IF_386|IF_SM}, + {I_IMUL, 3, {REG32,REG32,IMMEDIATE|BITS8}, "\321\301\1\x6B\110\16", IF_386}, + {I_IMUL, 3, {REG32,MEMORY,IMMEDIATE}, "\321\301\1\x69\110\42", IF_386|IF_SM}, + {I_IMUL, 3, {REG32,REG32,IMMEDIATE}, "\321\301\1\x69\110\42", IF_386|IF_SM}, + {I_IMUL, 2, {REG16,IMMEDIATE|BITS8,0}, "\320\1\x6B\100\15", IF_286}, + {I_IMUL, 2, {REG16,IMMEDIATE,0}, "\320\1\x69\100\31", IF_286|IF_SM}, + {I_IMUL, 2, {REG32,IMMEDIATE|BITS8,0}, "\321\1\x6B\100\15", IF_386}, + {I_IMUL, 2, {REG32,IMMEDIATE,0}, "\321\1\x69\100\41", IF_386|IF_SM}, + {I_IN, 2, {REG_AL,IMMEDIATE,0}, "\1\xE4\25", IF_8086|IF_SB}, + {I_IN, 2, {REG_AX,IMMEDIATE,0}, "\320\1\xE5\25", IF_8086|IF_SB}, + {I_IN, 2, {REG_EAX,IMMEDIATE,0}, "\321\1\xE5\25", IF_386|IF_SB}, + {I_IN, 2, {REG_AL,REG_DX,0}, "\1\xEC", IF_8086}, + {I_IN, 2, {REG_AX,REG_DX,0}, "\320\1\xED", IF_8086}, + {I_IN, 2, {REG_EAX,REG_DX,0}, "\321\1\xED", IF_386}, + {I_INC, 1, {REG16,0,0}, "\320\10\x40", IF_8086}, + {I_INC, 1, {REG32,0,0}, "\321\10\x40", IF_386}, + {I_INC, 1, {REGMEM|BITS8,0,0}, "\300\1\xFE\200", IF_8086}, + {I_INC, 1, {REGMEM|BITS16,0,0}, "\320\300\1\xFF\200", IF_8086}, + {I_INC, 1, {REGMEM|BITS32,0,0}, "\321\300\1\xFF\200", IF_386}, + {I_INSB, 0, {0,0,0}, "\1\x6C", IF_186}, + {I_INSD, 0, {0,0,0}, "\321\1\x6D", IF_386}, + {I_INSW, 0, {0,0,0}, "\320\1\x6D", IF_186}, + {I_INT, 1, {IMMEDIATE,0,0}, "\1\xCD\24", IF_8086|IF_SB}, + {I_INT1, 0, {0,0,0}, "\1\xF1", IF_386}, + {I_INT3, 0, {0,0,0}, "\1\xCC", IF_8086}, + {I_INTO, 0, {0,0,0}, "\1\xCE", IF_8086}, + {I_INVD, 0, {0,0,0}, "\2\x0F\x08", IF_486|IF_PRIV}, + {I_INVLPG, 1, {MEMORY,0,0}, "\300\2\x0F\x01\207", IF_486|IF_PRIV}, + {I_IRET, 0, {0,0,0}, "\322\1\xCF", IF_8086}, + {I_IRETD, 0, {0,0,0}, "\321\1\xCF", IF_386}, + {I_IRETW, 0, {0,0,0}, "\320\1\xCF", IF_8086}, + {I_JCXZ, 1, {IMMEDIATE,0,0}, "\320\1\xE3\50", IF_8086}, + {I_JECXZ, 1, {IMMEDIATE,0,0}, "\321\1\xE3\50", IF_386}, + {I_JMP, 1, {IMMEDIATE|SHORT,0,0}, "\1\xEB\50", IF_8086}, + {I_JMP, 1, {IMMEDIATE,0,0}, "\322\1\xE9\64", IF_8086}, + {I_JMP, 1, {IMMEDIATE|BITS16,0,0}, "\320\1\xE9\64", IF_8086}, + {I_JMP, 1, {IMMEDIATE|BITS32,0,0}, "\321\1\xE9\64", IF_8086}, + {I_JMP, 2, {IMMEDIATE|COLON,IMMEDIATE,0}, "\322\1\xEA\35\30", IF_8086}, + {I_JMP, 2, {IMMEDIATE|BITS16|COLON,IMMEDIATE,0}, "\320\1\xEA\31\30", IF_8086}, + {I_JMP, 2, {IMMEDIATE|COLON,IMMEDIATE|BITS16,0}, "\320\1\xEA\31\30", IF_8086}, + {I_JMP, 2, {IMMEDIATE|BITS32|COLON,IMMEDIATE,0}, "\321\1\xEA\41\30", IF_386}, + {I_JMP, 2, {IMMEDIATE|COLON,IMMEDIATE|BITS32,0}, "\321\1\xEA\41\30", IF_386}, + {I_JMP, 1, {MEMORY|FAR,0,0}, "\322\300\1\xFF\205", IF_8086}, + {I_JMP, 1, {MEMORY|BITS16|FAR,0,0}, "\320\300\1\xFF\205", IF_8086}, + {I_JMP, 1, {MEMORY|BITS32|FAR,0,0}, "\321\300\1\xFF\205", IF_386}, + {I_JMP, 1, {MEMORY|NEAR,0,0}, "\322\300\1\xFF\204", IF_8086}, + {I_JMP, 1, {MEMORY|BITS16|NEAR,0,0}, "\320\300\1\xFF\204", IF_8086}, + {I_JMP, 1, {MEMORY|BITS32|NEAR,0,0}, "\321\300\1\xFF\204", IF_386}, + {I_JMP, 1, {REG16,0,0}, "\320\300\1\xFF\204", IF_8086}, + {I_JMP, 1, {REG32,0,0}, "\321\300\1\xFF\204", IF_386}, + {I_JMP, 1, {MEMORY,0,0}, "\322\300\1\xFF\204", IF_8086}, + {I_JMP, 1, {MEMORY|BITS16,0,0}, "\320\300\1\xFF\204", IF_8086}, + {I_JMP, 1, {MEMORY|BITS32,0,0}, "\321\300\1\xFF\204", IF_386}, + {I_LAHF, 0, {0,0,0}, "\1\x9F", IF_8086}, + {I_LAR, 2, {REG16,MEMORY,0}, "\320\301\2\x0F\x02\110", IF_286|IF_PROT|IF_SM}, + {I_LAR, 2, {REG16,REG16,0}, "\320\301\2\x0F\x02\110", IF_286|IF_PROT}, + {I_LAR, 2, {REG32,MEMORY,0}, "\321\301\2\x0F\x02\110", IF_286|IF_PROT|IF_SM}, + {I_LAR, 2, {REG32,REG32,0}, "\321\301\2\x0F\x02\110", IF_286|IF_PROT}, + {I_LDS, 2, {REG16,MEMORY,0}, "\320\301\1\xC5\110", IF_8086}, + {I_LDS, 2, {REG32,MEMORY,0}, "\321\301\1\xC5\110", IF_8086}, + {I_LEA, 2, {REG16,MEMORY,0}, "\320\301\1\x8D\110", IF_8086}, + {I_LEA, 2, {REG32,MEMORY,0}, "\321\301\1\x8D\110", IF_8086}, + {I_LEAVE, 0, {0,0,0}, "\1\xC9", IF_186}, + {I_LES, 2, {REG16,MEMORY,0}, "\320\301\1\xC4\110", IF_8086}, + {I_LES, 2, {REG32,MEMORY,0}, "\321\301\1\xC4\110", IF_8086}, + {I_LFS, 2, {REG16,MEMORY,0}, "\320\301\2\x0F\xB4\110", IF_386}, + {I_LFS, 2, {REG32,MEMORY,0}, "\321\301\2\x0F\xB4\110", IF_386}, + {I_LGDT, 1, {MEMORY,0,0}, "\300\2\x0F\x01\202", IF_286|IF_PRIV}, + {I_LGS, 2, {REG16,MEMORY,0}, "\320\301\2\x0F\xB5\110", IF_386}, + {I_LGS, 2, {REG32,MEMORY,0}, "\321\301\2\x0F\xB5\110", IF_386}, + {I_LIDT, 1, {MEMORY,0,0}, "\300\2\x0F\x01\203", IF_286|IF_PRIV}, + {I_LLDT, 1, {MEMORY,0,0}, "\300\1\x0F\17\202", IF_286|IF_PROT|IF_PRIV}, + {I_LLDT, 1, {MEMORY|BITS16,0,0}, "\300\1\x0F\17\202", IF_286|IF_PROT|IF_PRIV}, + {I_LLDT, 1, {REG16,0,0}, "\300\1\x0F\17\202", IF_286|IF_PROT|IF_PRIV}, + {I_LMSW, 1, {MEMORY,0,0}, "\300\2\x0F\x01\206", IF_286|IF_PRIV}, + {I_LMSW, 1, {MEMORY|BITS16,0,0}, "\300\2\x0F\x01\206", IF_286|IF_PRIV}, + {I_LMSW, 1, {REG16,0,0}, "\300\2\x0F\x01\206", IF_286|IF_PRIV}, + {I_LOADALL, 0, {0,0,0}, "\2\x0F\x07", IF_386|IF_UNDOC}, + {I_LOADALL286, 0, {0,0,0}, "\2\x0F\x05", IF_286|IF_UNDOC}, + {I_LODSB, 0, {0,0,0}, "\1\xAC", IF_8086}, + {I_LODSD, 0, {0,0,0}, "\321\1\xAD", IF_386}, + {I_LODSW, 0, {0,0,0}, "\320\1\xAD", IF_8086}, + {I_LOOP, 1, {IMMEDIATE,0,0}, "\312\1\xE2\50", IF_8086}, + {I_LOOP, 2, {IMMEDIATE,REG_CX,0}, "\310\1\xE2\50", IF_8086}, + {I_LOOP, 2, {IMMEDIATE,REG_ECX,0}, "\311\1\xE2\50", IF_386}, + {I_LOOPE, 1, {IMMEDIATE,0,0}, "\312\1\xE1\50", IF_8086}, + {I_LOOPE, 2, {IMMEDIATE,REG_CX,0}, "\310\1\xE1\50", IF_8086}, + {I_LOOPE, 2, {IMMEDIATE,REG_ECX,0}, "\311\1\xE1\50", IF_386}, + {I_LOOPNE, 1, {IMMEDIATE,0,0}, "\312\1\xE0\50", IF_8086}, + {I_LOOPNE, 2, {IMMEDIATE,REG_CX,0}, "\310\1\xE0\50", IF_8086}, + {I_LOOPNE, 2, {IMMEDIATE,REG_ECX,0}, "\311\1\xE0\50", IF_386}, + {I_LOOPNZ, 1, {IMMEDIATE,0,0}, "\312\1\xE0\50", IF_8086}, + {I_LOOPNZ, 2, {IMMEDIATE,REG_CX,0}, "\310\1\xE0\50", IF_8086}, + {I_LOOPNZ, 2, {IMMEDIATE,REG_ECX,0}, "\311\1\xE0\50", IF_386}, + {I_LOOPZ, 1, {IMMEDIATE,0,0}, "\312\1\xE1\50", IF_8086}, + {I_LOOPZ, 2, {IMMEDIATE,REG_CX,0}, "\310\1\xE1\50", IF_8086}, + {I_LOOPZ, 2, {IMMEDIATE,REG_ECX,0}, "\311\1\xE1\50", IF_386}, + {I_LSL, 2, {REG16,MEMORY,0}, "\320\301\2\x0F\x03\110", IF_286|IF_PROT|IF_SM}, + {I_LSL, 2, {REG16,REG16,0}, "\320\301\2\x0F\x03\110", IF_286|IF_PROT}, + {I_LSL, 2, {REG32,MEMORY,0}, "\321\301\2\x0F\x03\110", IF_286|IF_PROT|IF_SM}, + {I_LSL, 2, {REG32,REG32,0}, "\321\301\2\x0F\x03\110", IF_286|IF_PROT}, + {I_LSS, 2, {REG16,MEMORY,0}, "\320\301\2\x0F\xB2\110", IF_386}, + {I_LSS, 2, {REG32,MEMORY,0}, "\321\301\2\x0F\xB2\110", IF_386}, + {I_LTR, 1, {MEMORY,0,0}, "\300\1\x0F\17\203", IF_286|IF_PROT|IF_PRIV}, + {I_LTR, 1, {MEMORY|BITS16,0,0}, "\300\1\x0F\17\203", IF_286|IF_PROT|IF_PRIV}, + {I_LTR, 1, {REG16,0,0}, "\300\1\x0F\17\203", IF_286|IF_PROT|IF_PRIV}, + {I_MOV, 2, {MEMORY,REG_CS,0}, "\320\300\1\x8C\201", IF_8086|IF_SM}, + {I_MOV, 2, {MEMORY,REG_DESS,0}, "\320\300\1\x8C\101", IF_8086|IF_SM}, + {I_MOV, 2, {MEMORY,REG_FSGS,0}, "\320\300\1\x8C\101", IF_386|IF_SM}, + {I_MOV, 2, {REG16,REG_CS,0}, "\320\300\1\x8C\201", IF_8086}, + {I_MOV, 2, {REG16,REG_DESS,0}, "\320\300\1\x8C\101", IF_8086}, + {I_MOV, 2, {REG16,REG_FSGS,0}, "\320\300\1\x8C\101", IF_386}, + {I_MOV, 2, {REGMEM|BITS32,REG_CS,0}, "\321\300\1\x8C\201", IF_8086}, + {I_MOV, 2, {REGMEM|BITS32,REG_DESS,0}, "\321\300\1\x8C\101", IF_8086}, + {I_MOV, 2, {REGMEM|BITS32,REG_FSGS,0}, "\321\300\1\x8C\101", IF_386}, + {I_MOV, 2, {REG_DESS,MEMORY,0}, "\320\301\1\x8E\110", IF_8086|IF_SM}, + {I_MOV, 2, {REG_FSGS,MEMORY,0}, "\320\301\1\x8E\110", IF_386|IF_SM}, + {I_MOV, 2, {REG_DESS,REG16,0}, "\320\301\1\x8E\110", IF_8086}, + {I_MOV, 2, {REG_FSGS,REG16,0}, "\320\301\1\x8E\110", IF_386}, + {I_MOV, 2, {REG_DESS,REGMEM|BITS32,0}, "\321\301\1\x8E\110", IF_8086}, + {I_MOV, 2, {REG_FSGS,REGMEM|BITS32,0}, "\321\301\1\x8E\110", IF_386}, + {I_MOV, 2, {REG_AL,MEM_OFFS,0}, "\301\1\xA0\35", IF_8086|IF_SM}, + {I_MOV, 2, {REG_AX,MEM_OFFS,0}, "\301\320\1\xA1\35", IF_8086|IF_SM}, + {I_MOV, 2, {REG_EAX,MEM_OFFS,0}, "\301\321\1\xA1\35", IF_386|IF_SM}, + {I_MOV, 2, {MEM_OFFS,REG_AL,0}, "\300\1\xA2\34", IF_8086|IF_SM}, + {I_MOV, 2, {MEM_OFFS,REG_AX,0}, "\300\320\1\xA3\34", IF_8086|IF_SM}, + {I_MOV, 2, {MEM_OFFS,REG_EAX,0}, "\300\321\1\xA3\34", IF_386|IF_SM}, + {I_MOV, 2, {REG32,REG_CR4,0}, "\2\x0F\x20\204", IF_PENT|IF_PRIV}, + {I_MOV, 2, {REG32,REG_CREG,0}, "\2\x0F\x20\101", IF_386|IF_PRIV}, + {I_MOV, 2, {REG32,REG_DREG,0}, "\2\x0F\x21\101", IF_386|IF_PRIV}, + {I_MOV, 2, {REG32,REG_TREG,0}, "\2\x0F\x24\101", IF_386|IF_PRIV}, + {I_MOV, 2, {REG_CR4,REG32,0}, "\2\x0F\x22\214", IF_PENT|IF_PRIV}, + {I_MOV, 2, {REG_CREG,REG32,0}, "\2\x0F\x22\110", IF_386|IF_PRIV}, + {I_MOV, 2, {REG_DREG,REG32,0}, "\2\x0F\x23\110", IF_386|IF_PRIV}, + {I_MOV, 2, {REG_TREG,REG32,0}, "\2\x0F\x26\110", IF_386|IF_PRIV}, + {I_MOV, 2, {MEMORY,REG8,0}, "\300\1\x88\101", IF_8086|IF_SM}, + {I_MOV, 2, {REG8,REG8,0}, "\300\1\x88\101", IF_8086}, + {I_MOV, 2, {MEMORY,REG16,0}, "\320\300\1\x89\101", IF_8086|IF_SM}, + {I_MOV, 2, {REG16,REG16,0}, "\320\300\1\x89\101", IF_8086}, + {I_MOV, 2, {MEMORY,REG32,0}, "\321\300\1\x89\101", IF_386|IF_SM}, + {I_MOV, 2, {REG32,REG32,0}, "\321\300\1\x89\101", IF_386}, + {I_MOV, 2, {REG8,MEMORY,0}, "\301\1\x8A\110", IF_8086|IF_SM}, + {I_MOV, 2, {REG8,REG8,0}, "\301\1\x8A\110", IF_8086}, + {I_MOV, 2, {REG16,MEMORY,0}, "\320\301\1\x8B\110", IF_8086|IF_SM}, + {I_MOV, 2, {REG16,REG16,0}, "\320\301\1\x8B\110", IF_8086}, + {I_MOV, 2, {REG32,MEMORY,0}, "\321\301\1\x8B\110", IF_386|IF_SM}, + {I_MOV, 2, {REG32,REG32,0}, "\321\301\1\x8B\110", IF_386}, + {I_MOV, 2, {REG8,IMMEDIATE,0}, "\10\xB0\21", IF_8086|IF_SM}, + {I_MOV, 2, {REG16,IMMEDIATE,0}, "\320\10\xB8\31", IF_8086|IF_SM}, + {I_MOV, 2, {REG32,IMMEDIATE,0}, "\321\10\xB8\41", IF_386|IF_SM}, + {I_MOV, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\xC6\200\21", IF_8086|IF_SM}, + {I_MOV, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\xC7\200\31", IF_8086|IF_SM}, + {I_MOV, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\xC7\200\41", IF_386|IF_SM}, + {I_MOV, 2, {MEMORY,IMMEDIATE|BITS8,0}, "\300\1\xC6\200\21", IF_8086|IF_SM}, + {I_MOV, 2, {MEMORY,IMMEDIATE|BITS16,0}, "\320\300\1\xC7\200\31", IF_8086|IF_SM}, + {I_MOV, 2, {MEMORY,IMMEDIATE|BITS32,0}, "\321\300\1\xC7\200\41", IF_386|IF_SM}, + {I_MOVD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x6E\110", IF_PENT|IF_MMX|IF_SD}, + {I_MOVD, 2, {MMXREG,REG32,0}, "\2\x0F\x6E\110", IF_PENT|IF_MMX}, + {I_MOVD, 2, {MEMORY,MMXREG,0}, "\300\2\x0F\x7E\101", IF_PENT|IF_MMX|IF_SD}, + {I_MOVD, 2, {REG32,MMXREG,0}, "\2\x0F\x7E\101", IF_PENT|IF_MMX}, + {I_MOVQ, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x6F\110", IF_PENT|IF_MMX|IF_SM}, + {I_MOVQ, 2, {MMXREG,MMXREG,0}, "\2\x0F\x6F\110", IF_PENT|IF_MMX}, + {I_MOVQ, 2, {MEMORY,MMXREG,0}, "\300\2\x0F\x7F\101", IF_PENT|IF_MMX|IF_SM}, + {I_MOVQ, 2, {MMXREG,MMXREG,0}, "\2\x0F\x7F\101", IF_PENT|IF_MMX}, + {I_MOVSB, 0, {0,0,0}, "\1\xA4", IF_8086}, + {I_MOVSD, 0, {0,0,0}, "\321\1\xA5", IF_386}, + {I_MOVSW, 0, {0,0,0}, "\320\1\xA5", IF_8086}, + {I_MOVSX, 2, {REG16,MEMORY,0}, "\320\301\2\x0F\xBE\110", IF_386|IF_SB}, + {I_MOVSX, 2, {REG16,REG8,0}, "\320\301\2\x0F\xBE\110", IF_386}, + {I_MOVSX, 2, {REG32,REGMEM|BITS8,0}, "\321\301\2\x0F\xBE\110", IF_386}, + {I_MOVSX, 2, {REG32,REGMEM|BITS16,0}, "\321\301\2\x0F\xBF\110", IF_386}, + {I_MOVZX, 2, {REG16,MEMORY,0}, "\320\301\2\x0F\xB6\110", IF_386|IF_SB}, + {I_MOVZX, 2, {REG16,REG8,0}, "\320\301\2\x0F\xB6\110", IF_386}, + {I_MOVZX, 2, {REG32,REGMEM|BITS8,0}, "\321\301\2\x0F\xB6\110", IF_386}, + {I_MOVZX, 2, {REG32,REGMEM|BITS16,0}, "\321\301\2\x0F\xB7\110", IF_386}, + {I_MUL, 1, {REGMEM|BITS8,0,0}, "\300\1\xF6\204", IF_8086}, + {I_MUL, 1, {REGMEM|BITS16,0,0}, "\320\300\1\xF7\204", IF_8086}, + {I_MUL, 1, {REGMEM|BITS32,0,0}, "\321\300\1\xF7\204", IF_386}, + {I_NEG, 1, {REGMEM|BITS8,0,0}, "\300\1\xF6\203", IF_8086}, + {I_NEG, 1, {REGMEM|BITS16,0,0}, "\320\300\1\xF7\203", IF_8086}, + {I_NEG, 1, {REGMEM|BITS32,0,0}, "\321\300\1\xF7\203", IF_386}, + {I_NOP, 0, {0,0,0}, "\1\x90", IF_8086}, + {I_NOT, 1, {REGMEM|BITS8,0,0}, "\300\1\xF6\202", IF_8086}, + {I_NOT, 1, {REGMEM|BITS16,0,0}, "\320\300\1\xF7\202", IF_8086}, + {I_NOT, 1, {REGMEM|BITS32,0,0}, "\321\300\1\xF7\202", IF_386}, + {I_OR, 2, {MEMORY,REG8,0}, "\300\1\x08\101", IF_8086|IF_SM}, + {I_OR, 2, {REG8,REG8,0}, "\300\1\x08\101", IF_8086}, + {I_OR, 2, {MEMORY,REG16,0}, "\320\300\1\x09\101", IF_8086|IF_SM}, + {I_OR, 2, {REG16,REG16,0}, "\320\300\1\x09\101", IF_8086}, + {I_OR, 2, {MEMORY,REG32,0}, "\321\300\1\x09\101", IF_386|IF_SM}, + {I_OR, 2, {REG32,REG32,0}, "\321\300\1\x09\101", IF_386}, + {I_OR, 2, {REG8,MEMORY,0}, "\301\1\x0A\110", IF_8086|IF_SM}, + {I_OR, 2, {REG8,REG8,0}, "\301\1\x0A\110", IF_8086}, + {I_OR, 2, {REG16,MEMORY,0}, "\320\301\1\x0B\110", IF_8086|IF_SM}, + {I_OR, 2, {REG16,REG16,0}, "\320\301\1\x0B\110", IF_8086}, + {I_OR, 2, {REG32,MEMORY,0}, "\321\301\1\x0B\110", IF_386|IF_SM}, + {I_OR, 2, {REG32,REG32,0}, "\321\301\1\x0B\110", IF_386}, + {I_OR, 2, {REGMEM|BITS16,IMMEDIATE|BITS8,0}, "\320\300\1\x83\201\15", IF_8086}, + {I_OR, 2, {REGMEM|BITS32,IMMEDIATE|BITS8,0}, "\321\300\1\x83\201\15", IF_386}, + {I_OR, 2, {REG_AL,IMMEDIATE,0}, "\1\x0C\21", IF_8086|IF_SM}, + {I_OR, 2, {REG_AX,IMMEDIATE,0}, "\320\1\x0D\31", IF_8086|IF_SM}, + {I_OR, 2, {REG_EAX,IMMEDIATE,0}, "\321\1\x0D\41", IF_386|IF_SM}, + {I_OR, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\x80\201\21", IF_8086|IF_SM}, + {I_OR, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\x81\201\31", IF_8086|IF_SM}, + {I_OR, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\x81\201\41", IF_386|IF_SM}, + {I_OR, 2, {MEMORY,IMMEDIATE|BITS8,0}, "\300\1\x80\201\21", IF_8086|IF_SM}, + {I_OR, 2, {MEMORY,IMMEDIATE|BITS16,0}, "\320\300\1\x81\201\31", IF_8086|IF_SM}, + {I_OR, 2, {MEMORY,IMMEDIATE|BITS32,0}, "\321\300\1\x81\201\41", IF_386|IF_SM}, + {I_OUT, 2, {IMMEDIATE,REG_AL,0}, "\1\xE6\24", IF_8086|IF_SB}, + {I_OUT, 2, {IMMEDIATE,REG_AX,0}, "\320\1\xE7\24", IF_8086|IF_SB}, + {I_OUT, 2, {IMMEDIATE,REG_EAX,0}, "\321\1\xE7\24", IF_386|IF_SB}, + {I_OUT, 2, {REG_DX,REG_AL,0}, "\1\xEE", IF_8086}, + {I_OUT, 2, {REG_DX,REG_AX,0}, "\320\1\xEF", IF_8086}, + {I_OUT, 2, {REG_DX,REG_EAX,0}, "\321\1\xEF", IF_386}, + {I_OUTSB, 0, {0,0,0}, "\1\x6E", IF_186}, + {I_OUTSD, 0, {0,0,0}, "\321\1\x6F", IF_386}, + {I_OUTSW, 0, {0,0,0}, "\320\1\x6F", IF_186}, + {I_PACKSSDW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x6B\110", IF_PENT|IF_MMX|IF_SM}, + {I_PACKSSDW, 2, {MMXREG,MMXREG,0}, "\2\x0F\x6B\110", IF_PENT|IF_MMX}, + {I_PACKSSWB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x63\110", IF_PENT|IF_MMX|IF_SM}, + {I_PACKSSWB, 2, {MMXREG,MMXREG,0}, "\2\x0F\x63\110", IF_PENT|IF_MMX}, + {I_PACKUSWB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x67\110", IF_PENT|IF_MMX|IF_SM}, + {I_PACKUSWB, 2, {MMXREG,MMXREG,0}, "\2\x0F\x67\110", IF_PENT|IF_MMX}, + {I_PADDB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xFC\110", IF_PENT|IF_MMX|IF_SM}, + {I_PADDB, 2, {MMXREG,MMXREG,0}, "\2\x0F\xFC\110", IF_PENT|IF_MMX}, + {I_PADDD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xFE\110", IF_PENT|IF_MMX|IF_SM}, + {I_PADDD, 2, {MMXREG,MMXREG,0}, "\2\x0F\xFE\110", IF_PENT|IF_MMX}, + {I_PADDSB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xEC\110", IF_PENT|IF_MMX|IF_SM}, + {I_PADDSB, 2, {MMXREG,MMXREG,0}, "\2\x0F\xEC\110", IF_PENT|IF_MMX}, + {I_PADDSIW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x51\110", IF_PENT|IF_MMX|IF_SM|IF_CYRIX}, + {I_PADDSIW, 2, {MMXREG,MMXREG,0}, "\2\x0F\x51\110", IF_PENT|IF_MMX|IF_CYRIX}, + {I_PADDSW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xED\110", IF_PENT|IF_MMX|IF_SM}, + {I_PADDSW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xED\110", IF_PENT|IF_MMX}, + {I_PADDUSB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xDC\110", IF_PENT|IF_MMX|IF_SM}, + {I_PADDUSB, 2, {MMXREG,MMXREG,0}, "\2\x0F\xDC\110", IF_PENT|IF_MMX}, + {I_PADDUSW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xDD\110", IF_PENT|IF_MMX|IF_SM}, + {I_PADDUSW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xDD\110", IF_PENT|IF_MMX}, + {I_PADDW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xFD\110", IF_PENT|IF_MMX|IF_SM}, + {I_PADDW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xFD\110", IF_PENT|IF_MMX}, + {I_PAND, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xDB\110", IF_PENT|IF_MMX|IF_SM}, + {I_PAND, 2, {MMXREG,MMXREG,0}, "\2\x0F\xDB\110", IF_PENT|IF_MMX}, + {I_PANDN, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xDF\110", IF_PENT|IF_MMX|IF_SM}, + {I_PANDN, 2, {MMXREG,MMXREG,0}, "\2\x0F\xDF\110", IF_PENT|IF_MMX}, + {I_PAVEB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x50\110", IF_PENT|IF_MMX|IF_SM|IF_CYRIX}, + {I_PAVEB, 2, {MMXREG,MMXREG,0}, "\2\x0F\x50\110", IF_PENT|IF_MMX|IF_CYRIX}, + {I_PAVGUSB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\xBF", IF_PENT|IF_3DNOW|IF_SM}, + {I_PAVGUSB, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\xBF", IF_PENT|IF_3DNOW}, + {I_PCMPEQB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x74\110", IF_PENT|IF_MMX|IF_SM}, + {I_PCMPEQB, 2, {MMXREG,MMXREG,0}, "\2\x0F\x74\110", IF_PENT|IF_MMX}, + {I_PCMPEQD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x76\110", IF_PENT|IF_MMX|IF_SM}, + {I_PCMPEQD, 2, {MMXREG,MMXREG,0}, "\2\x0F\x76\110", IF_PENT|IF_MMX}, + {I_PCMPEQW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x75\110", IF_PENT|IF_MMX|IF_SM}, + {I_PCMPEQW, 2, {MMXREG,MMXREG,0}, "\2\x0F\x75\110", IF_PENT|IF_MMX}, + {I_PCMPGTB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x64\110", IF_PENT|IF_MMX|IF_SM}, + {I_PCMPGTB, 2, {MMXREG,MMXREG,0}, "\2\x0F\x64\110", IF_PENT|IF_MMX}, + {I_PCMPGTD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x66\110", IF_PENT|IF_MMX|IF_SM}, + {I_PCMPGTD, 2, {MMXREG,MMXREG,0}, "\2\x0F\x66\110", IF_PENT|IF_MMX}, + {I_PCMPGTW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x65\110", IF_PENT|IF_MMX|IF_SM}, + {I_PCMPGTW, 2, {MMXREG,MMXREG,0}, "\2\x0F\x65\110", IF_PENT|IF_MMX}, + {I_PDISTIB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x54\110", IF_PENT|IF_MMX|IF_SM|IF_CYRIX}, + {I_PF2ID, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\x1D", IF_PENT|IF_3DNOW|IF_SM}, + {I_PF2ID, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\x1D", IF_PENT|IF_3DNOW}, + {I_PFACC, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\xAE", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFACC, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\xAE", IF_PENT|IF_3DNOW}, + {I_PFADD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\x9E", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFADD, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\x9E", IF_PENT|IF_3DNOW}, + {I_PFCMPEQ, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\xB0", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFCMPEQ, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\xB0", IF_PENT|IF_3DNOW}, + {I_PFCMPGE, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\x90", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFCMPGE, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\x90", IF_PENT|IF_3DNOW}, + {I_PFCMPGT, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\xA0", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFCMPGT, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\xA0", IF_PENT|IF_3DNOW}, + {I_PFMAX, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\xA4", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFMAX, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\xA4", IF_PENT|IF_3DNOW}, + {I_PFMIN, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\x94", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFMIN, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\x94", IF_PENT|IF_3DNOW}, + {I_PFMUL, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\xB4", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFMUL, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\xB4", IF_PENT|IF_3DNOW}, + {I_PFRCP, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\x96", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFRCP, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\x96", IF_PENT|IF_3DNOW}, + {I_PFRCPIT1, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\xA6", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFRCPIT1, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\xA6", IF_PENT|IF_3DNOW}, + {I_PFRCPIT2, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\xB6", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFRCPIT2, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\xB6", IF_PENT|IF_3DNOW}, + {I_PFRSQIT1, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\xA7", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFRSQIT1, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\xA7", IF_PENT|IF_3DNOW}, + {I_PFRSQRT, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\x97", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFRSQRT, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\x97", IF_PENT|IF_3DNOW}, + {I_PFSUB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\x9A", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFSUB, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\x9A", IF_PENT|IF_3DNOW}, + {I_PFSUBR, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\xAA", IF_PENT|IF_3DNOW|IF_SM}, + {I_PFSUBR, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\xAA", IF_PENT|IF_3DNOW}, + {I_PI2FD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\01\x0D", IF_PENT|IF_3DNOW|IF_SM}, + {I_PI2FD, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\01\x0D", IF_PENT|IF_3DNOW}, + {I_PMACHRIW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x5E\110", IF_PENT|IF_MMX|IF_SM|IF_CYRIX}, + {I_PMADDWD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xF5\110", IF_PENT|IF_MMX|IF_SM}, + {I_PMADDWD, 2, {MMXREG,MMXREG,0}, "\2\x0F\xF5\110", IF_PENT|IF_MMX}, + {I_PMAGW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x52\110", IF_PENT|IF_MMX|IF_SM|IF_CYRIX}, + {I_PMAGW, 2, {MMXREG,MMXREG,0}, "\2\x0F\x52\110", IF_PENT|IF_MMX|IF_CYRIX}, + {I_PMULHRIW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x5D\110", IF_PENT|IF_MMX|IF_SM|IF_CYRIX}, + {I_PMULHRIW, 2, {MMXREG,MMXREG,0}, "\2\x0F\x5D\110", IF_PENT|IF_MMX|IF_CYRIX}, + {I_PMULHRWA, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x0F\110\1\xB7", IF_PENT|IF_3DNOW|IF_SM}, + {I_PMULHRWA, 2, {MMXREG,MMXREG,0}, "\2\x0F\x0F\110\1\xB7", IF_PENT|IF_3DNOW}, + {I_PMULHRWC, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x59\110", IF_PENT|IF_MMX|IF_SM|IF_CYRIX}, + {I_PMULHRWC, 2, {MMXREG,MMXREG,0}, "\2\x0F\x59\110", IF_PENT|IF_MMX|IF_CYRIX}, + {I_PMULHW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xE5\110", IF_PENT|IF_MMX|IF_SM}, + {I_PMULHW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xE5\110", IF_PENT|IF_MMX}, + {I_PMULLW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xD5\110", IF_PENT|IF_MMX|IF_SM}, + {I_PMULLW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xD5\110", IF_PENT|IF_MMX}, + {I_PMVGEZB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x5C\110", IF_PENT|IF_MMX|IF_SM|IF_CYRIX}, + {I_PMVLZB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x5B\110", IF_PENT|IF_MMX|IF_SM|IF_CYRIX}, + {I_PMVNZB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x5A\110", IF_PENT|IF_MMX|IF_SM|IF_CYRIX}, + {I_PMVZB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x58\110", IF_PENT|IF_MMX|IF_SM|IF_CYRIX}, + {I_POP, 1, {REG16,0,0}, "\320\10\x58", IF_8086}, + {I_POP, 1, {REG32,0,0}, "\321\10\x58", IF_386}, + {I_POP, 1, {REGMEM|BITS16,0,0}, "\320\300\1\x8F\200", IF_8086}, + {I_POP, 1, {REGMEM|BITS32,0,0}, "\321\300\1\x8F\200", IF_386}, + {I_POP, 1, {REG_DESS,0,0}, "\4", IF_8086}, + {I_POP, 1, {REG_FSGS,0,0}, "\1\x0F\5", IF_386}, + {I_POPA, 0, {0,0,0}, "\322\1\x61", IF_186}, + {I_POPAD, 0, {0,0,0}, "\321\1\x61", IF_386}, + {I_POPAW, 0, {0,0,0}, "\320\1\x61", IF_186}, + {I_POPF, 0, {0,0,0}, "\322\1\x9D", IF_186}, + {I_POPFD, 0, {0,0,0}, "\321\1\x9D", IF_386}, + {I_POPFW, 0, {0,0,0}, "\320\1\x9D", IF_186}, + {I_POR, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xEB\110", IF_PENT|IF_MMX|IF_SM}, + {I_POR, 2, {MMXREG,MMXREG,0}, "\2\x0F\xEB\110", IF_PENT|IF_MMX}, + {I_PREFETCH, 1, {MEMORY,0,0}, "\2\x0F\x0D\200", IF_PENT|IF_3DNOW|IF_SM}, + {I_PREFETCHW, 1, {MEMORY,0,0}, "\2\x0F\x0D\201", IF_PENT|IF_3DNOW|IF_SM}, + {I_PSLLD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xF2\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSLLD, 2, {MMXREG,MMXREG,0}, "\2\x0F\xF2\110", IF_PENT|IF_MMX}, + {I_PSLLD, 2, {MMXREG,IMMEDIATE,0}, "\2\x0F\x72\206\25", IF_PENT|IF_MMX}, + {I_PSLLQ, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xF3\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSLLQ, 2, {MMXREG,MMXREG,0}, "\2\x0F\xF3\110", IF_PENT|IF_MMX}, + {I_PSLLQ, 2, {MMXREG,IMMEDIATE,0}, "\2\x0F\x73\206\25", IF_PENT|IF_MMX}, + {I_PSLLW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xF1\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSLLW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xF1\110", IF_PENT|IF_MMX}, + {I_PSLLW, 2, {MMXREG,IMMEDIATE,0}, "\2\x0F\x71\206\25", IF_PENT|IF_MMX}, + {I_PSRAD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xE2\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSRAD, 2, {MMXREG,MMXREG,0}, "\2\x0F\xE2\110", IF_PENT|IF_MMX}, + {I_PSRAD, 2, {MMXREG,IMMEDIATE,0}, "\2\x0F\x72\204\25", IF_PENT|IF_MMX}, + {I_PSRAW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xE1\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSRAW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xE1\110", IF_PENT|IF_MMX}, + {I_PSRAW, 2, {MMXREG,IMMEDIATE,0}, "\2\x0F\x71\204\25", IF_PENT|IF_MMX}, + {I_PSRLD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xD2\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSRLD, 2, {MMXREG,MMXREG,0}, "\2\x0F\xD2\110", IF_PENT|IF_MMX}, + {I_PSRLD, 2, {MMXREG,IMMEDIATE,0}, "\2\x0F\x72\202\25", IF_PENT|IF_MMX}, + {I_PSRLQ, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xD3\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSRLQ, 2, {MMXREG,MMXREG,0}, "\2\x0F\xD3\110", IF_PENT|IF_MMX}, + {I_PSRLQ, 2, {MMXREG,IMMEDIATE,0}, "\2\x0F\x73\202\25", IF_PENT|IF_MMX}, + {I_PSRLW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xD1\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSRLW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xD1\110", IF_PENT|IF_MMX}, + {I_PSRLW, 2, {MMXREG,IMMEDIATE,0}, "\2\x0F\x71\202\25", IF_PENT|IF_MMX}, + {I_PSUBB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xF8\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSUBB, 2, {MMXREG,MMXREG,0}, "\2\x0F\xF8\110", IF_PENT|IF_MMX}, + {I_PSUBD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xFA\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSUBD, 2, {MMXREG,MMXREG,0}, "\2\x0F\xFA\110", IF_PENT|IF_MMX}, + {I_PSUBSB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xE8\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSUBSB, 2, {MMXREG,MMXREG,0}, "\2\x0F\xE8\110", IF_PENT|IF_MMX}, + {I_PSUBSIW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x55\110", IF_PENT|IF_MMX|IF_SM|IF_CYRIX}, + {I_PSUBSIW, 2, {MMXREG,MMXREG,0}, "\2\x0F\x55\110", IF_PENT|IF_MMX|IF_CYRIX}, + {I_PSUBSW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xE9\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSUBSW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xE9\110", IF_PENT|IF_MMX}, + {I_PSUBUSB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xD8\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSUBUSB, 2, {MMXREG,MMXREG,0}, "\2\x0F\xD8\110", IF_PENT|IF_MMX}, + {I_PSUBUSW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xD9\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSUBUSW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xD9\110", IF_PENT|IF_MMX}, + {I_PSUBW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xF9\110", IF_PENT|IF_MMX|IF_SM}, + {I_PSUBW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xF9\110", IF_PENT|IF_MMX}, + {I_PUNPCKHBW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x68\110", IF_PENT|IF_MMX|IF_SM}, + {I_PUNPCKHBW, 2, {MMXREG,MMXREG,0}, "\2\x0F\x68\110", IF_PENT|IF_MMX}, + {I_PUNPCKHDQ, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x6A\110", IF_PENT|IF_MMX|IF_SM}, + {I_PUNPCKHDQ, 2, {MMXREG,MMXREG,0}, "\2\x0F\x6A\110", IF_PENT|IF_MMX}, + {I_PUNPCKHWD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x69\110", IF_PENT|IF_MMX|IF_SM}, + {I_PUNPCKHWD, 2, {MMXREG,MMXREG,0}, "\2\x0F\x69\110", IF_PENT|IF_MMX}, + {I_PUNPCKLBW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x60\110", IF_PENT|IF_MMX|IF_SM}, + {I_PUNPCKLBW, 2, {MMXREG,MMXREG,0}, "\2\x0F\x60\110", IF_PENT|IF_MMX}, + {I_PUNPCKLDQ, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x62\110", IF_PENT|IF_MMX|IF_SM}, + {I_PUNPCKLDQ, 2, {MMXREG,MMXREG,0}, "\2\x0F\x62\110", IF_PENT|IF_MMX}, + {I_PUNPCKLWD, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\x61\110", IF_PENT|IF_MMX|IF_SM}, + {I_PUNPCKLWD, 2, {MMXREG,MMXREG,0}, "\2\x0F\x61\110", IF_PENT|IF_MMX}, + {I_PUSH, 1, {REG16,0,0}, "\320\10\x50", IF_8086}, + {I_PUSH, 1, {REG32,0,0}, "\321\10\x50", IF_386}, + {I_PUSH, 1, {REGMEM|BITS16,0,0}, "\320\300\1\xFF\206", IF_8086}, + {I_PUSH, 1, {REGMEM|BITS32,0,0}, "\321\300\1\xFF\206", IF_386}, + {I_PUSH, 1, {REG_FSGS,0,0}, "\1\x0F\7", IF_386}, + {I_PUSH, 1, {REG_SREG,0,0}, "\6", IF_8086}, + {I_PUSH, 1, {IMMEDIATE|BITS8,0,0}, "\1\x6A\14", IF_286}, + {I_PUSH, 1, {IMMEDIATE|BITS16,0,0}, "\320\1\x68\30", IF_286}, + {I_PUSH, 1, {IMMEDIATE|BITS32,0,0}, "\321\1\x68\40", IF_386}, + {I_PUSHA, 0, {0,0,0}, "\322\1\x60", IF_186}, + {I_PUSHAD, 0, {0,0,0}, "\321\1\x60", IF_386}, + {I_PUSHAW, 0, {0,0,0}, "\320\1\x60", IF_186}, + {I_PUSHF, 0, {0,0,0}, "\322\1\x9C", IF_186}, + {I_PUSHFD, 0, {0,0,0}, "\321\1\x9C", IF_386}, + {I_PUSHFW, 0, {0,0,0}, "\320\1\x9C", IF_186}, + {I_PXOR, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xEF\110", IF_PENT|IF_MMX|IF_SM}, + {I_PXOR, 2, {MMXREG,MMXREG,0}, "\2\x0F\xEF\110", IF_PENT|IF_MMX}, + {I_RCL, 2, {REGMEM|BITS8,UNITY,0}, "\300\1\xD0\202", IF_8086}, + {I_RCL, 2, {REGMEM|BITS8,REG_CL,0}, "\300\1\xD2\202", IF_8086}, + {I_RCL, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\xC0\202\25", IF_186|IF_SB}, + {I_RCL, 2, {REGMEM|BITS16,UNITY,0}, "\320\300\1\xD1\202", IF_8086}, + {I_RCL, 2, {REGMEM|BITS16,REG_CL,0}, "\320\300\1\xD3\202", IF_8086}, + {I_RCL, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\xC1\202\25", IF_186|IF_SB}, + {I_RCL, 2, {REGMEM|BITS32,UNITY,0}, "\321\300\1\xD1\202", IF_386}, + {I_RCL, 2, {REGMEM|BITS32,REG_CL,0}, "\321\300\1\xD3\202", IF_386}, + {I_RCL, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\xC1\202\25", IF_386|IF_SB}, + {I_RCR, 2, {REGMEM|BITS8,UNITY,0}, "\300\1\xD0\203", IF_8086}, + {I_RCR, 2, {REGMEM|BITS8,REG_CL,0}, "\300\1\xD2\203", IF_8086}, + {I_RCR, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\xC0\203\25", IF_186|IF_SB}, + {I_RCR, 2, {REGMEM|BITS16,UNITY,0}, "\320\300\1\xD1\203", IF_8086}, + {I_RCR, 2, {REGMEM|BITS16,REG_CL,0}, "\320\300\1\xD3\203", IF_8086}, + {I_RCR, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\xC1\203\25", IF_186|IF_SB}, + {I_RCR, 2, {REGMEM|BITS32,UNITY,0}, "\321\300\1\xD1\203", IF_386}, + {I_RCR, 2, {REGMEM|BITS32,REG_CL,0}, "\321\300\1\xD3\203", IF_386}, + {I_RCR, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\xC1\203\25", IF_386|IF_SB}, + {I_RDSHR, 0, {0,0,0}, "\2\x0F\x36", IF_P6|IF_CYRIX|IF_SMM}, + {I_RDMSR, 0, {0,0,0}, "\2\x0F\x32", IF_PENT|IF_PRIV}, + {I_RDPMC, 0, {0,0,0}, "\2\x0F\x33", IF_P6}, + {I_RDTSC, 0, {0,0,0}, "\2\x0F\x31", IF_PENT}, + {I_RESB, 1, {IMMEDIATE,0,0}, "\340", IF_8086}, + {I_RET, 0, {0,0,0}, "\1\xC3", IF_8086}, + {I_RET, 1, {IMMEDIATE,0,0}, "\1\xC2\30", IF_8086|IF_SW}, + {I_RETF, 0, {0,0,0}, "\1\xCB", IF_8086}, + {I_RETF, 1, {IMMEDIATE,0,0}, "\1\xCA\30", IF_8086|IF_SW}, + {I_RETN, 0, {0,0,0}, "\1\xC3", IF_8086}, + {I_RETN, 1, {IMMEDIATE,0,0}, "\1\xC2\30", IF_8086|IF_SW}, + {I_ROL, 2, {REGMEM|BITS8,UNITY,0}, "\300\1\xD0\200", IF_8086}, + {I_ROL, 2, {REGMEM|BITS8,REG_CL,0}, "\300\1\xD2\200", IF_8086}, + {I_ROL, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\xC0\200\25", IF_186|IF_SB}, + {I_ROL, 2, {REGMEM|BITS16,UNITY,0}, "\320\300\1\xD1\200", IF_8086}, + {I_ROL, 2, {REGMEM|BITS16,REG_CL,0}, "\320\300\1\xD3\200", IF_8086}, + {I_ROL, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\xC1\200\25", IF_186|IF_SB}, + {I_ROL, 2, {REGMEM|BITS32,UNITY,0}, "\321\300\1\xD1\200", IF_386}, + {I_ROL, 2, {REGMEM|BITS32,REG_CL,0}, "\321\300\1\xD3\200", IF_386}, + {I_ROL, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\xC1\200\25", IF_386|IF_SB}, + {I_ROR, 2, {REGMEM|BITS8,UNITY,0}, "\300\1\xD0\201", IF_8086}, + {I_ROR, 2, {REGMEM|BITS8,REG_CL,0}, "\300\1\xD2\201", IF_8086}, + {I_ROR, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\xC0\201\25", IF_186|IF_SB}, + {I_ROR, 2, {REGMEM|BITS16,UNITY,0}, "\320\300\1\xD1\201", IF_8086}, + {I_ROR, 2, {REGMEM|BITS16,REG_CL,0}, "\320\300\1\xD3\201", IF_8086}, + {I_ROR, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\xC1\201\25", IF_186|IF_SB}, + {I_ROR, 2, {REGMEM|BITS32,UNITY,0}, "\321\300\1\xD1\201", IF_386}, + {I_ROR, 2, {REGMEM|BITS32,REG_CL,0}, "\321\300\1\xD3\201", IF_386}, + {I_ROR, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\xC1\201\25", IF_386|IF_SB}, + {I_RSDC, 2, {REG_SREG,MEMORY|BITS80,0}, "\301\2\x0F\x79\101", IF_486|IF_CYRIX|IF_SMM}, + {I_RSLDT, 1, {MEMORY|BITS80,0,0}, "\300\2\x0F\x7B\200", IF_486|IF_CYRIX|IF_SMM}, + {I_RSM, 0, {0,0,0}, "\2\x0F\xAA", IF_PENT|IF_SMM}, + {I_SAHF, 0, {0,0,0}, "\1\x9E", IF_8086}, + {I_SALC, 0, {0,0,0}, "\1\xD6", IF_8086|IF_UNDOC}, + {I_SAR, 2, {REGMEM|BITS8,UNITY,0}, "\300\1\xD0\207", IF_8086}, + {I_SAR, 2, {REGMEM|BITS8,REG_CL,0}, "\300\1\xD2\207", IF_8086}, + {I_SAR, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\xC0\207\25", IF_186|IF_SB}, + {I_SAR, 2, {REGMEM|BITS16,UNITY,0}, "\320\300\1\xD1\207", IF_8086}, + {I_SAR, 2, {REGMEM|BITS16,REG_CL,0}, "\320\300\1\xD3\207", IF_8086}, + {I_SAR, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\xC1\207\25", IF_186|IF_SB}, + {I_SAR, 2, {REGMEM|BITS32,UNITY,0}, "\321\300\1\xD1\207", IF_386}, + {I_SAR, 2, {REGMEM|BITS32,REG_CL,0}, "\321\300\1\xD3\207", IF_386}, + {I_SAR, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\xC1\207\25", IF_386|IF_SB}, + {I_SBB, 2, {MEMORY,REG8,0}, "\300\1\x18\101", IF_8086|IF_SM}, + {I_SBB, 2, {REG8,REG8,0}, "\300\1\x18\101", IF_8086}, + {I_SBB, 2, {MEMORY,REG16,0}, "\320\300\1\x19\101", IF_8086|IF_SM}, + {I_SBB, 2, {REG16,REG16,0}, "\320\300\1\x19\101", IF_8086}, + {I_SBB, 2, {MEMORY,REG32,0}, "\321\300\1\x19\101", IF_386|IF_SM}, + {I_SBB, 2, {REG32,REG32,0}, "\321\300\1\x19\101", IF_386}, + {I_SBB, 2, {REG8,MEMORY,0}, "\301\1\x1A\110", IF_8086|IF_SM}, + {I_SBB, 2, {REG8,REG8,0}, "\301\1\x1A\110", IF_8086}, + {I_SBB, 2, {REG16,MEMORY,0}, "\320\301\1\x1B\110", IF_8086|IF_SM}, + {I_SBB, 2, {REG16,REG16,0}, "\320\301\1\x1B\110", IF_8086}, + {I_SBB, 2, {REG32,MEMORY,0}, "\321\301\1\x1B\110", IF_386|IF_SM}, + {I_SBB, 2, {REG32,REG32,0}, "\321\301\1\x1B\110", IF_386}, + {I_SBB, 2, {REGMEM|BITS16,IMMEDIATE|BITS8,0}, "\320\300\1\x83\203\15", IF_8086}, + {I_SBB, 2, {REGMEM|BITS32,IMMEDIATE|BITS8,0}, "\321\300\1\x83\203\15", IF_8086}, + {I_SBB, 2, {REG_AL,IMMEDIATE,0}, "\1\x1C\21", IF_8086|IF_SM}, + {I_SBB, 2, {REG_AX,IMMEDIATE,0}, "\320\1\x1D\31", IF_8086|IF_SM}, + {I_SBB, 2, {REG_EAX,IMMEDIATE,0}, "\321\1\x1D\41", IF_386|IF_SM}, + {I_SBB, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\x80\203\21", IF_8086|IF_SM}, + {I_SBB, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\x81\203\31", IF_8086|IF_SM}, + {I_SBB, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\x81\203\41", IF_386|IF_SM}, + {I_SBB, 2, {MEMORY,IMMEDIATE|BITS8,0}, "\300\1\x80\203\21", IF_8086|IF_SM}, + {I_SBB, 2, {MEMORY,IMMEDIATE|BITS16,0}, "\320\300\1\x81\203\31", IF_8086|IF_SM}, + {I_SBB, 2, {MEMORY,IMMEDIATE|BITS32,0}, "\321\300\1\x81\203\41", IF_386|IF_SM}, + {I_SCASB, 0, {0,0,0}, "\332\1\xAE", IF_8086}, + {I_SCASD, 0, {0,0,0}, "\332\321\1\xAF", IF_386}, + {I_SCASW, 0, {0,0,0}, "\332\320\1\xAF", IF_8086}, + {I_SGDT, 1, {MEMORY,0,0}, "\300\2\x0F\x01\200", IF_286}, + {I_SHL, 2, {REGMEM|BITS8,UNITY,0}, "\300\1\xD0\204", IF_8086}, + {I_SHL, 2, {REGMEM|BITS8,REG_CL,0}, "\300\1\xD2\204", IF_8086}, + {I_SHL, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\xC0\204\25", IF_186|IF_SB}, + {I_SHL, 2, {REGMEM|BITS16,UNITY,0}, "\320\300\1\xD1\204", IF_8086}, + {I_SHL, 2, {REGMEM|BITS16,REG_CL,0}, "\320\300\1\xD3\204", IF_8086}, + {I_SHL, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\xC1\204\25", IF_186|IF_SB}, + {I_SHL, 2, {REGMEM|BITS32,UNITY,0}, "\321\300\1\xD1\204", IF_386}, + {I_SHL, 2, {REGMEM|BITS32,REG_CL,0}, "\321\300\1\xD3\204", IF_386}, + {I_SHL, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\xC1\204\25", IF_386|IF_SB}, + {I_SHLD, 3, {MEMORY,REG16,IMMEDIATE}, "\300\320\2\x0F\xA4\101\26", IF_386|IF_SM2|IF_SB|IF_AR2}, + {I_SHLD, 3, {REG16,REG16,IMMEDIATE}, "\300\320\2\x0F\xA4\101\26", IF_386|IF_SM2|IF_SB|IF_AR2}, + {I_SHLD, 3, {MEMORY,REG32,IMMEDIATE}, "\300\321\2\x0F\xA4\101\26", IF_386|IF_SM2|IF_SB|IF_AR2}, + {I_SHLD, 3, {REG32,REG32,IMMEDIATE}, "\300\321\2\x0F\xA4\101\26", IF_386|IF_SM2|IF_SB|IF_AR2}, + {I_SHLD, 3, {MEMORY,REG16,REG_CL}, "\300\320\2\x0F\xA5\101", IF_386|IF_SM}, + {I_SHLD, 3, {REG16,REG16,REG_CL}, "\300\320\2\x0F\xA5\101", IF_386}, + {I_SHLD, 3, {MEMORY,REG32,REG_CL}, "\300\321\2\x0F\xA5\101", IF_386|IF_SM}, + {I_SHLD, 3, {REG32,REG32,REG_CL}, "\300\321\2\x0F\xA5\101", IF_386}, + {I_SHR, 2, {REGMEM|BITS8,UNITY,0}, "\300\1\xD0\205", IF_8086}, + {I_SHR, 2, {REGMEM|BITS8,REG_CL,0}, "\300\1\xD2\205", IF_8086}, + {I_SHR, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\xC0\205\25", IF_186|IF_SB}, + {I_SHR, 2, {REGMEM|BITS16,UNITY,0}, "\320\300\1\xD1\205", IF_8086}, + {I_SHR, 2, {REGMEM|BITS16,REG_CL,0}, "\320\300\1\xD3\205", IF_8086}, + {I_SHR, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\xC1\205\25", IF_186|IF_SB}, + {I_SHR, 2, {REGMEM|BITS32,UNITY,0}, "\321\300\1\xD1\205", IF_386}, + {I_SHR, 2, {REGMEM|BITS32,REG_CL,0}, "\321\300\1\xD3\205", IF_386}, + {I_SHR, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\xC1\205\25", IF_386|IF_SB}, + {I_SHRD, 3, {MEMORY,REG16,IMMEDIATE}, "\300\320\2\x0F\xAC\101\26", IF_386|IF_SM2|IF_SB|IF_AR2}, + {I_SHRD, 3, {REG16,REG16,IMMEDIATE}, "\300\320\2\x0F\xAC\101\26", IF_386|IF_SM2|IF_SB|IF_AR2}, + {I_SHRD, 3, {MEMORY,REG32,IMMEDIATE}, "\300\321\2\x0F\xAC\101\26", IF_386|IF_SM2|IF_SB|IF_AR2}, + {I_SHRD, 3, {REG32,REG32,IMMEDIATE}, "\300\321\2\x0F\xAC\101\26", IF_386|IF_SM2|IF_SB|IF_AR2}, + {I_SHRD, 3, {MEMORY,REG16,REG_CL}, "\300\320\2\x0F\xAD\101", IF_386|IF_SM}, + {I_SHRD, 3, {REG16,REG16,REG_CL}, "\300\320\2\x0F\xAD\101", IF_386}, + {I_SHRD, 3, {MEMORY,REG32,REG_CL}, "\300\321\2\x0F\xAD\101", IF_386|IF_SM}, + {I_SHRD, 3, {REG32,REG32,REG_CL}, "\300\321\2\x0F\xAD\101", IF_386}, + {I_SIDT, 1, {MEMORY,0,0}, "\300\2\x0F\x01\201", IF_286}, + {I_SLDT, 1, {MEMORY,0,0}, "\300\1\x0F\17\200", IF_286}, + {I_SLDT, 1, {MEMORY|BITS16,0,0}, "\300\1\x0F\17\200", IF_286}, + {I_SLDT, 1, {REG16,0,0}, "\300\1\x0F\17\200", IF_286}, + {I_SMI, 0, {0,0,0}, "\1\xF1", IF_386|IF_UNDOC}, + {I_SMINT, 0, {0,0,0}, "\2\x0F\x38", IF_P6|IF_CYRIX}, + {I_SMSW, 1, {MEMORY,0,0}, "\300\2\x0F\x01\204", IF_286}, + {I_SMSW, 1, {MEMORY|BITS16,0,0}, "\300\2\x0F\x01\204", IF_286}, + {I_SMSW, 1, {REG16,0,0}, "\300\2\x0F\x01\204", IF_286}, + {I_STC, 0, {0,0,0}, "\1\xF9", IF_8086}, + {I_STD, 0, {0,0,0}, "\1\xFD", IF_8086}, + {I_STI, 0, {0,0,0}, "\1\xFB", IF_8086}, + {I_STOSB, 0, {0,0,0}, "\1\xAA", IF_8086}, + {I_STOSD, 0, {0,0,0}, "\321\1\xAB", IF_386}, + {I_STOSW, 0, {0,0,0}, "\320\1\xAB", IF_8086}, + {I_STR, 1, {MEMORY,0,0}, "\300\1\x0F\17\201", IF_286|IF_PROT}, + {I_STR, 1, {MEMORY|BITS16,0,0}, "\300\1\x0F\17\201", IF_286|IF_PROT}, + {I_STR, 1, {REG16,0,0}, "\300\1\x0F\17\201", IF_286|IF_PROT}, + {I_SUB, 2, {MEMORY,REG8,0}, "\300\1\x28\101", IF_8086|IF_SM}, + {I_SUB, 2, {REG8,REG8,0}, "\300\1\x28\101", IF_8086}, + {I_SUB, 2, {MEMORY,REG16,0}, "\320\300\1\x29\101", IF_8086|IF_SM}, + {I_SUB, 2, {REG16,REG16,0}, "\320\300\1\x29\101", IF_8086}, + {I_SUB, 2, {MEMORY,REG32,0}, "\321\300\1\x29\101", IF_386|IF_SM}, + {I_SUB, 2, {REG32,REG32,0}, "\321\300\1\x29\101", IF_386}, + {I_SUB, 2, {REG8,MEMORY,0}, "\301\1\x2A\110", IF_8086|IF_SM}, + {I_SUB, 2, {REG8,REG8,0}, "\301\1\x2A\110", IF_8086}, + {I_SUB, 2, {REG16,MEMORY,0}, "\320\301\1\x2B\110", IF_8086|IF_SM}, + {I_SUB, 2, {REG16,REG16,0}, "\320\301\1\x2B\110", IF_8086}, + {I_SUB, 2, {REG32,MEMORY,0}, "\321\301\1\x2B\110", IF_386|IF_SM}, + {I_SUB, 2, {REG32,REG32,0}, "\321\301\1\x2B\110", IF_386}, + {I_SUB, 2, {REGMEM|BITS16,IMMEDIATE|BITS8,0}, "\320\300\1\x83\205\15", IF_8086}, + {I_SUB, 2, {REGMEM|BITS32,IMMEDIATE|BITS8,0}, "\321\300\1\x83\205\15", IF_386}, + {I_SUB, 2, {REG_AL,IMMEDIATE,0}, "\1\x2C\21", IF_8086|IF_SM}, + {I_SUB, 2, {REG_AX,IMMEDIATE,0}, "\320\1\x2D\31", IF_8086|IF_SM}, + {I_SUB, 2, {REG_EAX,IMMEDIATE,0}, "\321\1\x2D\41", IF_386|IF_SM}, + {I_SUB, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\x80\205\21", IF_8086|IF_SM}, + {I_SUB, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\x81\205\31", IF_8086|IF_SM}, + {I_SUB, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\x81\205\41", IF_386|IF_SM}, + {I_SUB, 2, {MEMORY,IMMEDIATE|BITS8,0}, "\300\1\x80\205\21", IF_8086|IF_SM}, + {I_SUB, 2, {MEMORY,IMMEDIATE|BITS16,0}, "\320\300\1\x81\205\31", IF_8086|IF_SM}, + {I_SUB, 2, {MEMORY,IMMEDIATE|BITS32,0}, "\321\300\1\x81\205\41", IF_386|IF_SM}, + {I_SVDC, 2, {MEMORY|BITS80,REG_SREG,0}, "\300\2\x0F\x78\101", IF_486|IF_CYRIX|IF_SMM}, + {I_SVLDT, 1, {MEMORY|BITS80,0,0}, "\300\2\x0F\x7A\200", IF_486|IF_CYRIX|IF_SMM}, + {I_SVTS, 1, {MEMORY|BITS80,0,0}, "\300\2\x0F\x7C\200", IF_486|IF_CYRIX|IF_SMM}, + {I_SYSCALL, 0, {0,0,0}, "\2\x0F\x05", IF_P6|IF_AMD}, + {I_SYSENTER, 0, {0,0,0}, "\2\x0F\x34", IF_P6}, + {I_SYSEXIT, 0, {0,0,0}, "\2\x0F\x36", IF_P6|IF_PRIV}, + {I_SYSRET, 0, {0,0,0}, "\2\x0F\x07", IF_P6|IF_PRIV|IF_AMD}, + {I_TEST, 2, {MEMORY,REG8,0}, "\300\1\x84\101", IF_8086|IF_SM}, + {I_TEST, 2, {REG8,REG8,0}, "\300\1\x84\101", IF_8086}, + {I_TEST, 2, {MEMORY,REG16,0}, "\320\300\1\x85\101", IF_8086|IF_SM}, + {I_TEST, 2, {REG16,REG16,0}, "\320\300\1\x85\101", IF_8086}, + {I_TEST, 2, {MEMORY,REG32,0}, "\321\300\1\x85\101", IF_386|IF_SM}, + {I_TEST, 2, {REG32,REG32,0}, "\321\300\1\x85\101", IF_386}, + {I_TEST, 2, {REG8,MEMORY,0}, "\301\1\x84\110", IF_8086|IF_SM}, + {I_TEST, 2, {REG16,MEMORY,0}, "\320\301\1\x85\110", IF_8086|IF_SM}, + {I_TEST, 2, {REG32,MEMORY,0}, "\321\301\1\x85\110", IF_386|IF_SM}, + {I_TEST, 2, {REG_AL,IMMEDIATE,0}, "\1\xA8\21", IF_8086|IF_SM}, + {I_TEST, 2, {REG_AX,IMMEDIATE,0}, "\320\1\xA9\31", IF_8086|IF_SM}, + {I_TEST, 2, {REG_EAX,IMMEDIATE,0}, "\321\1\xA9\41", IF_386|IF_SM}, + {I_TEST, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\xF6\200\21", IF_8086|IF_SM}, + {I_TEST, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\xF7\200\31", IF_8086|IF_SM}, + {I_TEST, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\xF7\200\41", IF_386|IF_SM}, + {I_TEST, 2, {MEMORY,IMMEDIATE|BITS8,0}, "\300\1\xF6\200\21", IF_8086|IF_SM}, + {I_TEST, 2, {MEMORY,IMMEDIATE|BITS16,0}, "\320\300\1\xF7\200\31", IF_8086|IF_SM}, + {I_TEST, 2, {MEMORY,IMMEDIATE|BITS32,0}, "\321\300\1\xF7\200\41", IF_386|IF_SM}, + {I_UD1, 0, {0,0,0}, "\2\x0F\xB9", IF_286|IF_UNDOC}, + {I_UD2, 0, {0,0,0}, "\2\x0F\x0B", IF_286}, + {I_UMOV, 2, {MEMORY,REG8,0}, "\300\2\x0F\x10\101", IF_386|IF_UNDOC|IF_SM}, + {I_UMOV, 2, {REG8,REG8,0}, "\300\2\x0F\x10\101", IF_386|IF_UNDOC}, + {I_UMOV, 2, {MEMORY,REG16,0}, "\320\300\2\x0F\x11\101", IF_386|IF_UNDOC|IF_SM}, + {I_UMOV, 2, {REG16,REG16,0}, "\320\300\2\x0F\x11\101", IF_386|IF_UNDOC}, + {I_UMOV, 2, {MEMORY,REG32,0}, "\321\300\2\x0F\x11\101", IF_386|IF_UNDOC|IF_SM}, + {I_UMOV, 2, {REG32,REG32,0}, "\321\300\2\x0F\x11\101", IF_386|IF_UNDOC}, + {I_UMOV, 2, {REG8,MEMORY,0}, "\301\2\x0F\x12\110", IF_386|IF_UNDOC|IF_SM}, + {I_UMOV, 2, {REG8,REG8,0}, "\301\2\x0F\x12\110", IF_386|IF_UNDOC}, + {I_UMOV, 2, {REG16,MEMORY,0}, "\320\301\2\x0F\x13\110", IF_386|IF_UNDOC|IF_SM}, + {I_UMOV, 2, {REG16,REG16,0}, "\320\301\2\x0F\x13\110", IF_386|IF_UNDOC}, + {I_UMOV, 2, {REG32,MEMORY,0}, "\321\301\2\x0F\x13\110", IF_386|IF_UNDOC|IF_SM}, + {I_UMOV, 2, {REG32,REG32,0}, "\321\301\2\x0F\x13\110", IF_386|IF_UNDOC}, + {I_VERR, 1, {MEMORY,0,0}, "\300\1\x0F\17\204", IF_286|IF_PROT}, + {I_VERR, 1, {MEMORY|BITS16,0,0}, "\300\1\x0F\17\204", IF_286|IF_PROT}, + {I_VERR, 1, {REG16,0,0}, "\300\1\x0F\17\204", IF_286|IF_PROT}, + {I_VERW, 1, {MEMORY,0,0}, "\300\1\x0F\17\205", IF_286|IF_PROT}, + {I_VERW, 1, {MEMORY|BITS16,0,0}, "\300\1\x0F\17\205", IF_286|IF_PROT}, + {I_VERW, 1, {REG16,0,0}, "\300\1\x0F\17\205", IF_286|IF_PROT}, + {I_WAIT, 0, {0,0,0}, "\1\x9B", IF_8086}, + {I_WBINVD, 0, {0,0,0}, "\2\x0F\x09", IF_486|IF_PRIV}, + {I_WRSHR, 0, {0,0,0}, "\2\x0F\x37", IF_P6|IF_CYRIX|IF_SMM}, + {I_WRMSR, 0, {0,0,0}, "\2\x0F\x30", IF_PENT|IF_PRIV}, + {I_XADD, 2, {MEMORY,REG8,0}, "\300\2\x0F\xC0\101", IF_486|IF_SM}, + {I_XADD, 2, {REG8,REG8,0}, "\300\2\x0F\xC0\101", IF_486}, + {I_XADD, 2, {MEMORY,REG16,0}, "\320\300\2\x0F\xC1\101", IF_486|IF_SM}, + {I_XADD, 2, {REG16,REG16,0}, "\320\300\2\x0F\xC1\101", IF_486}, + {I_XADD, 2, {MEMORY,REG32,0}, "\321\300\2\x0F\xC1\101", IF_486|IF_SM}, + {I_XADD, 2, {REG32,REG32,0}, "\321\300\2\x0F\xC1\101", IF_486}, + {I_XCHG, 2, {REG_AX,REG16,0}, "\320\11\x90", IF_8086}, + {I_XCHG, 2, {REG_EAX,REG32,0}, "\321\11\x90", IF_386}, + {I_XCHG, 2, {REG16,REG_AX,0}, "\320\10\x90", IF_8086}, + {I_XCHG, 2, {REG32,REG_EAX,0}, "\321\10\x90", IF_386}, + {I_XCHG, 2, {REG8,MEMORY,0}, "\301\1\x86\110", IF_8086|IF_SM}, + {I_XCHG, 2, {REG8,REG8,0}, "\301\1\x86\110", IF_8086}, + {I_XCHG, 2, {REG16,MEMORY,0}, "\320\301\1\x87\110", IF_8086|IF_SM}, + {I_XCHG, 2, {REG16,REG16,0}, "\320\301\1\x87\110", IF_8086}, + {I_XCHG, 2, {REG32,MEMORY,0}, "\321\301\1\x87\110", IF_386|IF_SM}, + {I_XCHG, 2, {REG32,REG32,0}, "\321\301\1\x87\110", IF_386}, + {I_XCHG, 2, {MEMORY,REG8,0}, "\300\1\x86\101", IF_8086|IF_SM}, + {I_XCHG, 2, {REG8,REG8,0}, "\300\1\x86\101", IF_8086}, + {I_XCHG, 2, {MEMORY,REG16,0}, "\320\300\1\x87\101", IF_8086|IF_SM}, + {I_XCHG, 2, {REG16,REG16,0}, "\320\300\1\x87\101", IF_8086}, + {I_XCHG, 2, {MEMORY,REG32,0}, "\321\300\1\x87\101", IF_386|IF_SM}, + {I_XCHG, 2, {REG32,REG32,0}, "\321\300\1\x87\101", IF_386}, + {I_XLATB, 0, {0,0,0}, "\1\xD7", IF_8086}, + {I_XOR, 2, {MEMORY,REG8,0}, "\300\1\x30\101", IF_8086|IF_SM}, + {I_XOR, 2, {REG8,REG8,0}, "\300\1\x30\101", IF_8086}, + {I_XOR, 2, {MEMORY,REG16,0}, "\320\300\1\x31\101", IF_8086|IF_SM}, + {I_XOR, 2, {REG16,REG16,0}, "\320\300\1\x31\101", IF_8086}, + {I_XOR, 2, {MEMORY,REG32,0}, "\321\300\1\x31\101", IF_386|IF_SM}, + {I_XOR, 2, {REG32,REG32,0}, "\321\300\1\x31\101", IF_386}, + {I_XOR, 2, {REG8,MEMORY,0}, "\301\1\x32\110", IF_8086|IF_SM}, + {I_XOR, 2, {REG8,REG8,0}, "\301\1\x32\110", IF_8086}, + {I_XOR, 2, {REG16,MEMORY,0}, "\320\301\1\x33\110", IF_8086|IF_SM}, + {I_XOR, 2, {REG16,REG16,0}, "\320\301\1\x33\110", IF_8086}, + {I_XOR, 2, {REG32,MEMORY,0}, "\321\301\1\x33\110", IF_386|IF_SM}, + {I_XOR, 2, {REG32,REG32,0}, "\321\301\1\x33\110", IF_386}, + {I_XOR, 2, {REGMEM|BITS16,IMMEDIATE|BITS8,0}, "\320\300\1\x83\206\15", IF_8086}, + {I_XOR, 2, {REGMEM|BITS32,IMMEDIATE|BITS8,0}, "\321\300\1\x83\206\15", IF_386}, + {I_XOR, 2, {REG_AL,IMMEDIATE,0}, "\1\x34\21", IF_8086|IF_SM}, + {I_XOR, 2, {REG_AX,IMMEDIATE,0}, "\320\1\x35\31", IF_8086|IF_SM}, + {I_XOR, 2, {REG_EAX,IMMEDIATE,0}, "\321\1\x35\41", IF_386|IF_SM}, + {I_XOR, 2, {REGMEM|BITS8,IMMEDIATE,0}, "\300\1\x80\206\21", IF_8086|IF_SM}, + {I_XOR, 2, {REGMEM|BITS16,IMMEDIATE,0}, "\320\300\1\x81\206\31", IF_8086|IF_SM}, + {I_XOR, 2, {REGMEM|BITS32,IMMEDIATE,0}, "\321\300\1\x81\206\41", IF_386|IF_SM}, + {I_XOR, 2, {MEMORY,IMMEDIATE|BITS8,0}, "\300\1\x80\206\21", IF_8086|IF_SM}, + {I_XOR, 2, {MEMORY,IMMEDIATE|BITS16,0}, "\320\300\1\x81\206\31", IF_8086|IF_SM}, + {I_XOR, 2, {MEMORY,IMMEDIATE|BITS32,0}, "\321\300\1\x81\206\41", IF_386|IF_SM}, + {I_CMOVcc, 2, {REG16,MEMORY,0}, "\320\301\1\x0F\330\x40\110", IF_P6|IF_SM}, + {I_CMOVcc, 2, {REG16,REG16,0}, "\320\301\1\x0F\330\x40\110", IF_P6}, + {I_CMOVcc, 2, {REG32,MEMORY,0}, "\321\301\1\x0F\330\x40\110", IF_P6|IF_SM}, + {I_CMOVcc, 2, {REG32,REG32,0}, "\321\301\1\x0F\330\x40\110", IF_P6}, + {I_Jcc, 1, {IMMEDIATE|NEAR,0,0}, "\322\1\x0F\330\x80\64", IF_386}, + {I_Jcc, 1, {IMMEDIATE|BITS16|NEAR,0,0}, "\320\1\x0F\330\x80\64", IF_386}, + {I_Jcc, 1, {IMMEDIATE|BITS32|NEAR,0,0}, "\321\1\x0F\330\x80\64", IF_386}, + {I_Jcc, 1, {IMMEDIATE,0,0}, "\330\x70\50", IF_8086}, + {I_SETcc, 1, {MEMORY,0,0}, "\300\1\x0F\330\x90\200", IF_386|IF_SB}, + {I_SETcc, 1, {REG8,0,0}, "\300\1\x0F\330\x90\200", IF_386}, + {I_ADDPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\x58\110", IF_KATMAI|IF_SSE}, + {I_ADDPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\x58\110", IF_KATMAI|IF_SSE}, + {I_ADDSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\x58\110", IF_KATMAI|IF_SSE}, + {I_ADDSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\x58\110", IF_KATMAI|IF_SSE}, + {I_ANDNPS, 2, {XMMREG,MEMORY,0}, "\301\2\x0F\x55\110", IF_KATMAI|IF_SSE}, + {I_ANDNPS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x55\110", IF_KATMAI|IF_SSE}, + {I_ANDPS, 2, {XMMREG,MEMORY,0}, "\301\2\x0F\x54\110", IF_KATMAI|IF_SSE}, + {I_ANDPS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x54\110", IF_KATMAI|IF_SSE}, + {I_CMPEQPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\xC2\110\1\x00", IF_KATMAI|IF_SSE}, + {I_CMPEQPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\xC2\110\1\x00", IF_KATMAI|IF_SSE}, + {I_CMPEQSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\xC2\110\1\0x00", IF_KATMAI|IF_SSE}, + {I_CMPEQSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\xC2\110\1\x00", IF_KATMAI|IF_SSE}, + {I_CMPLEPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\xC2\110\1\x02", IF_KATMAI|IF_SSE}, + {I_CMPLEPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\xC2\110\1\x02", IF_KATMAI|IF_SSE}, + {I_CMPLESS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\xC2\110\1\x02", IF_KATMAI|IF_SSE}, + {I_CMPLESS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\xC2\110\1\x02", IF_KATMAI|IF_SSE}, + {I_CMPLTPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\xC2\110\1\x01", IF_KATMAI|IF_SSE}, + {I_CMPLTPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\xC2\110\1\x01", IF_KATMAI|IF_SSE}, + {I_CMPLTSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\xC2\110\1\x01", IF_KATMAI|IF_SSE}, + {I_CMPLTSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\xC2\110\1\x01", IF_KATMAI|IF_SSE}, + {I_CMPNEQPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\xC2\110\1\x04", IF_KATMAI|IF_SSE}, + {I_CMPNEQPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\xC2\110\1\x04", IF_KATMAI|IF_SSE}, + {I_CMPNEQSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\xC2\110\1\x04", IF_KATMAI|IF_SSE}, + {I_CMPNEQSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\xC2\110\1\x04", IF_KATMAI|IF_SSE}, + {I_CMPNLEPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\xC2\110\1\x06", IF_KATMAI|IF_SSE}, + {I_CMPNLEPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\xC2\110\1\x06", IF_KATMAI|IF_SSE}, + {I_CMPNLESS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\xC2\110\1\x06", IF_KATMAI|IF_SSE}, + {I_CMPNLESS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\xC2\110\1\x06", IF_KATMAI|IF_SSE}, + {I_CMPNLTPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\xC2\110\1\x05", IF_KATMAI|IF_SSE}, + {I_CMPNLTPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\xC2\110\1\x05", IF_KATMAI|IF_SSE}, + {I_CMPNLTSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\xC2\110\1\x05", IF_KATMAI|IF_SSE}, + {I_CMPNLTSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\xC2\110\1\x05", IF_KATMAI|IF_SSE}, + {I_CMPORDPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\xC2\110\1\x07", IF_KATMAI|IF_SSE}, + {I_CMPORDPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\xC2\110\1\x07", IF_KATMAI|IF_SSE}, + {I_CMPORDSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\xC2\110\1\x07", IF_KATMAI|IF_SSE}, + {I_CMPORDSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\xC2\110\1\x07", IF_KATMAI|IF_SSE}, + {I_CMPUNORDPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\xC2\110\1\x03", IF_KATMAI|IF_SSE}, + {I_CMPUNORDPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\xC2\110\1\x03", IF_KATMAI|IF_SSE}, + {I_CMPUNORDSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\xC2\110\1\x03", IF_KATMAI|IF_SSE}, + {I_CMPUNORDSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\xC2\110\1\x03", IF_KATMAI|IF_SSE}, + {I_CMPPS, 3, {XMMREG,MEMORY,IMMEDIATE}, "\301\331\2\x0F\xC2\110\22", IF_KATMAI|IF_SSE|IF_SB|IF_AR2}, + {I_CMPPS, 3, {XMMREG,XMMREG,IMMEDIATE}, "\331\2\x0F\xC2\110\22", IF_KATMAI|IF_SSE|IF_SB|IF_AR2}, + {I_CMPSS, 3, {XMMREG,MEMORY,IMMEDIATE}, "\301\333\2\x0F\xC2\110\22", IF_KATMAI|IF_SSE|IF_SB|IF_AR2}, + {I_CMPSS, 3, {XMMREG,XMMREG,IMMEDIATE}, "\333\2\x0F\xC2\110\22", IF_KATMAI|IF_SSE|IF_SB|IF_AR2}, + {I_COMISS, 2, {XMMREG,MEMORY,0}, "\301\2\x0F\x2F\110", IF_KATMAI|IF_SSE}, + {I_COMISS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x2F\110", IF_KATMAI|IF_SSE}, + {I_CVTPI2PS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\x2A\110", IF_KATMAI|IF_SSE|IF_MMX}, + {I_CVTPI2PS, 2, {XMMREG,MMXREG,0}, "\331\2\x0F\x2A\110", IF_KATMAI|IF_SSE|IF_MMX}, + {I_CVTPS2PI, 2, {MMXREG,MEMORY,0}, "\301\331\2\x0F\x2D\110", IF_KATMAI|IF_SSE|IF_MMX}, + {I_CVTPS2PI, 2, {MMXREG,XMMREG,0}, "\331\2\x0F\x2D\110", IF_KATMAI|IF_SSE|IF_MMX}, + {I_CVTSI2SS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\x2A\110", IF_KATMAI|IF_SSE|IF_SD|IF_AR1}, + {I_CVTSI2SS, 2, {XMMREG,REG32,0}, "\333\2\x0F\x2A\110", IF_KATMAI|IF_SSE}, + {I_CVTSS2SI, 2, {REG32,MEMORY,0}, "\301\333\2\x0F\x2D\110", IF_KATMAI|IF_SSE}, + {I_CVTSS2SI, 2, {REG32,XMMREG,0}, "\333\2\x0F\x2D\110", IF_KATMAI|IF_SSE}, + {I_CVTTPS2PI, 2, {MMXREG,MEMORY,0}, "\301\331\2\x0F\x2C\110", IF_KATMAI|IF_SSE|IF_MMX}, + {I_CVTTPS2PI, 2, {MMXREG,XMMREG,0}, "\331\2\x0F\x2C\110", IF_KATMAI|IF_SSE|IF_MMX}, + {I_CVTTSS2SI, 2, {REG32,MEMORY,0}, "\301\333\2\x0F\x2C\110", IF_KATMAI|IF_SSE}, + {I_CVTTSS2SI, 2, {REG32,XMMREG,0}, "\333\2\x0F\x2C\110", IF_KATMAI|IF_SSE}, + {I_DIVPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\x5E\110", IF_KATMAI|IF_SSE}, + {I_DIVPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\x5E\110", IF_KATMAI|IF_SSE}, + {I_DIVSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\x5E\110", IF_KATMAI|IF_SSE}, + {I_DIVSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\x5E\110", IF_KATMAI|IF_SSE}, + {I_LDMXCSR, 1, {MEMORY,0,0}, "\300\2\x0F\xAE\202", IF_KATMAI|IF_SSE|IF_SD}, + {I_MAXPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\x5F\110", IF_KATMAI|IF_SSE}, + {I_MAXPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\x5F\110", IF_KATMAI|IF_SSE}, + {I_MAXSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\x5F\110", IF_KATMAI|IF_SSE}, + {I_MAXSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\x5F\110", IF_KATMAI|IF_SSE}, + {I_MINPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\x5D\110", IF_KATMAI|IF_SSE}, + {I_MINPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\x5D\110", IF_KATMAI|IF_SSE}, + {I_MINSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\x5D\110", IF_KATMAI|IF_SSE}, + {I_MINSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\x5D\110", IF_KATMAI|IF_SSE}, + {I_MOVAPS, 2, {XMMREG,MEMORY,0}, "\301\2\x0F\x28\110", IF_KATMAI|IF_SSE}, + {I_MOVAPS, 2, {MEMORY,XMMREG,0}, "\300\2\x0F\x29\101", IF_KATMAI|IF_SSE}, + {I_MOVAPS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x28\110", IF_KATMAI|IF_SSE}, + {I_MOVAPS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x29\101", IF_KATMAI|IF_SSE}, + {I_MOVHPS, 2, {XMMREG,MEMORY,0}, "\301\2\x0F\x16\110", IF_KATMAI|IF_SSE}, + {I_MOVHPS, 2, {MEMORY,XMMREG,0}, "\300\2\x0F\x17\101", IF_KATMAI|IF_SSE}, + {I_MOVLHPS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x16\110", IF_KATMAI|IF_SSE}, + {I_MOVLPS, 2, {XMMREG,MEMORY,0}, "\301\2\x0F\x12\110", IF_KATMAI|IF_SSE}, + {I_MOVLPS, 2, {MEMORY,XMMREG,0}, "\300\2\x0F\x13\101", IF_KATMAI|IF_SSE}, + {I_MOVHLPS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x12\110", IF_KATMAI|IF_SSE}, + {I_MOVMSKPS, 2, {REG32,XMMREG,0}, "\2\x0F\x50\110", IF_KATMAI|IF_SSE}, + {I_MOVNTPS, 2, {MEMORY,XMMREG,0}, "\2\x0F\x2B\101", IF_KATMAI|IF_SSE}, + {I_MOVSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\x10\110", IF_KATMAI|IF_SSE}, + {I_MOVSS, 2, {MEMORY,XMMREG,0}, "\300\333\2\x0F\x11\101", IF_KATMAI|IF_SSE}, + {I_MOVSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\x10\110", IF_KATMAI|IF_SSE}, + {I_MOVSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\x11\101", IF_KATMAI|IF_SSE}, + {I_MOVUPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\x10\110", IF_KATMAI|IF_SSE}, + {I_MOVUPS, 2, {MEMORY,XMMREG,0}, "\300\331\2\x0F\x11\101", IF_KATMAI|IF_SSE}, + {I_MOVUPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\x10\110", IF_KATMAI|IF_SSE}, + {I_MOVUPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\x11\101", IF_KATMAI|IF_SSE}, + {I_MULPS, 2, {XMMREG,MEMORY,0}, "\301\2\x0F\x59\110", IF_KATMAI|IF_SSE}, + {I_MULPS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x59\110", IF_KATMAI|IF_SSE}, + {I_MULSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\x59\110", IF_KATMAI|IF_SSE}, + {I_MULSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\x59\110", IF_KATMAI|IF_SSE}, + {I_ORPS, 2, {XMMREG,MEMORY,0}, "\301\2\x0F\x56\110", IF_KATMAI|IF_SSE}, + {I_ORPS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x56\110", IF_KATMAI|IF_SSE}, + {I_RCPPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\x53\110", IF_KATMAI|IF_SSE}, + {I_RCPPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\x53\110", IF_KATMAI|IF_SSE}, + {I_RCPSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\x53\110", IF_KATMAI|IF_SSE}, + {I_RCPSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\x53\110", IF_KATMAI|IF_SSE}, + {I_RSQRTPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\x52\110", IF_KATMAI|IF_SSE}, + {I_RSQRTPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\x52\110", IF_KATMAI|IF_SSE}, + {I_RSQRTSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\x52\110", IF_KATMAI|IF_SSE}, + {I_RSQRTSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\x52\110", IF_KATMAI|IF_SSE}, + {I_SHUFPS, 3, {XMMREG,MEMORY,IMMEDIATE}, "\301\2\x0F\xC6\110\22", IF_KATMAI|IF_SSE|IF_SB|IF_AR2}, + {I_SHUFPS, 3, {XMMREG,XMMREG,IMMEDIATE}, "\2\x0F\xC6\110\22", IF_KATMAI|IF_SSE|IF_SB|IF_AR2}, + {I_SQRTPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\x51\110", IF_KATMAI|IF_SSE}, + {I_SQRTPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\x51\110", IF_KATMAI|IF_SSE}, + {I_SQRTSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\x51\110", IF_KATMAI|IF_SSE}, + {I_SQRTSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\x51\110", IF_KATMAI|IF_SSE}, + {I_STMXCSR, 1, {MEMORY,0,0}, "\300\2\x0F\xAE\203", IF_KATMAI|IF_SSE|IF_SD}, + {I_SUBPS, 2, {XMMREG,MEMORY,0}, "\301\331\2\x0F\x5C\110", IF_KATMAI|IF_SSE}, + {I_SUBPS, 2, {XMMREG,XMMREG,0}, "\331\2\x0F\x5C\110", IF_KATMAI|IF_SSE}, + {I_SUBSS, 2, {XMMREG,MEMORY,0}, "\301\333\2\x0F\x5C\110", IF_KATMAI|IF_SSE}, + {I_SUBSS, 2, {XMMREG,XMMREG,0}, "\333\2\x0F\x5C\110", IF_KATMAI|IF_SSE}, + {I_UCOMISS, 2, {XMMREG,MEMORY,0}, "\301\2\x0F\x2E\110", IF_KATMAI|IF_SSE}, + {I_UCOMISS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x2E\110", IF_KATMAI|IF_SSE}, + {I_UNPCKHPS, 2, {XMMREG,MEMORY,0}, "\301\2\x0F\x15\110", IF_KATMAI|IF_SSE}, + {I_UNPCKHPS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x15\110", IF_KATMAI|IF_SSE}, + {I_UNPCKLPS, 2, {XMMREG,MEMORY,0}, "\301\2\x0F\x14\110", IF_KATMAI|IF_SSE}, + {I_UNPCKLPS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x14\110", IF_KATMAI|IF_SSE}, + {I_XORPS, 2, {XMMREG,MEMORY,0}, "\301\2\x0F\x57\110", IF_KATMAI|IF_SSE}, + {I_XORPS, 2, {XMMREG,XMMREG,0}, "\2\x0F\x57\110", IF_KATMAI|IF_SSE}, + {I_FXRSTOR, 1, {MEMORY,0,0}, "\300\2\x0F\xAE\201", IF_P6|IF_SSE|IF_FPU}, + {I_FXSAVE, 1, {MEMORY,0,0}, "\300\2\x0F\xAE\200", IF_P6|IF_SSE|IF_FPU}, + {I_PREFETCHNTA, 1, {MEMORY,0,0}, "\300\2\x0F\x18\200", IF_KATMAI}, + {I_PREFETCHT0, 1, {MEMORY,0,0}, "\300\2\x0F\x18\201", IF_KATMAI}, + {I_PREFETCHT1, 1, {MEMORY,0,0}, "\300\2\x0F\x18\202", IF_KATMAI}, + {I_PREFETCHT2, 1, {MEMORY,0,0}, "\300\2\x0F\x18\203", IF_KATMAI}, + {I_SFENCE, 0, {0,0,0}, "\3\x0F\xAE\xF8", IF_KATMAI}, + {I_MASKMOVQ, 2, {MMXREG,MMXREG,0}, "\2\x0F\xF7\110", IF_KATMAI|IF_MMX}, + {I_MOVNTQ, 2, {MEMORY,MMXREG,0}, "\2\x0F\xE7\101", IF_KATMAI|IF_MMX|IF_SM}, + {I_PAVGB, 2, {MMXREG,MMXREG,0}, "\2\x0F\xE0\110", IF_KATMAI|IF_MMX}, + {I_PAVGB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xE0\110", IF_KATMAI|IF_MMX|IF_SM}, + {I_PAVGW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xE3\110", IF_KATMAI|IF_MMX}, + {I_PAVGW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xE3\110", IF_KATMAI|IF_MMX|IF_SM}, + {I_PEXTRW, 3, {REG32,MMXREG,IMMEDIATE}, "\2\x0F\xC5\110\22", IF_KATMAI|IF_MMX|IF_SB|IF_AR2}, + {I_PINSRW, 3, {MMXREG,REG16,IMMEDIATE}, "\2\x0F\xC4\110\22", IF_KATMAI|IF_MMX|IF_SB|IF_AR2}, + {I_PINSRW, 3, {MMXREG,MEMORY,IMMEDIATE}, "\301\2\x0F\xC4\110\22", IF_KATMAI|IF_MMX|IF_SB|IF_AR2}, + {I_PMAXSW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xEE\110", IF_KATMAI|IF_MMX}, + {I_PMAXSW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xEE\110", IF_KATMAI|IF_MMX|IF_SM}, + {I_PMAXUB, 2, {MMXREG,MMXREG,0}, "\2\x0F\xDE\110", IF_KATMAI|IF_MMX}, + {I_PMAXUB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xDE\110", IF_KATMAI|IF_MMX|IF_SM}, + {I_PMINSW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xEA\110", IF_KATMAI|IF_MMX}, + {I_PMINSW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xEA\110", IF_KATMAI|IF_MMX|IF_SM}, + {I_PMINUB, 2, {MMXREG,MMXREG,0}, "\2\x0F\xDA\110", IF_KATMAI|IF_MMX}, + {I_PMINUB, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xDA\110", IF_KATMAI|IF_MMX|IF_SM}, + {I_PMOVMSKB, 2, {REG32,MMXREG,0}, "\2\x0F\xD7\110", IF_KATMAI|IF_MMX}, + {I_PMULHUW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xE4\110", IF_KATMAI|IF_MMX}, + {I_PMULHUW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xE4\110", IF_KATMAI|IF_MMX|IF_SM}, + {I_PSADBW, 2, {MMXREG,MMXREG,0}, "\2\x0F\xF6\110", IF_KATMAI|IF_MMX}, + {I_PSADBW, 2, {MMXREG,MEMORY,0}, "\301\2\x0F\xF6\110", IF_KATMAI|IF_MMX|IF_SM}, + {I_PSHUFW, 3, {MMXREG,MMXREG,IMMEDIATE}, "\2\x0F\x70\110\22", IF_KATMAI|IF_MMX|IF_SB|IF_AR2}, + {I_PSHUFW, 3, {MMXREG,MEMORY,IMMEDIATE}, "\301\2\x0F\x70\110\22", IF_KATMAI|IF_MMX|IF_SM2|IF_SB|IF_AR2}, + {-1} +}; + +static struct itemplate *itable_00[] = { + instrux + 29, + instrux + 30, + NULL +}; + +static struct itemplate *itable_01[] = { + instrux + 31, + instrux + 32, + instrux + 33, + instrux + 34, + NULL +}; + +static struct itemplate *itable_02[] = { + instrux + 35, + instrux + 36, + NULL +}; + +static struct itemplate *itable_03[] = { + instrux + 37, + instrux + 38, + instrux + 39, + instrux + 40, + NULL +}; + +static struct itemplate *itable_04[] = { + instrux + 43, + NULL +}; + +static struct itemplate *itable_05[] = { + instrux + 44, + instrux + 45, + NULL +}; + +static struct itemplate *itable_06[] = { + instrux + 779, + NULL +}; + +static struct itemplate *itable_07[] = { + instrux + 710, + NULL +}; + +static struct itemplate *itable_08[] = { + instrux + 578, + instrux + 579, + NULL +}; + +static struct itemplate *itable_09[] = { + instrux + 580, + instrux + 581, + instrux + 582, + instrux + 583, + NULL +}; + +static struct itemplate *itable_0A[] = { + instrux + 584, + instrux + 585, + NULL +}; + +static struct itemplate *itable_0B[] = { + instrux + 586, + instrux + 587, + instrux + 588, + instrux + 589, + NULL +}; + +static struct itemplate *itable_0C[] = { + instrux + 592, + NULL +}; + +static struct itemplate *itable_0D[] = { + instrux + 593, + instrux + 594, + NULL +}; + +static struct itemplate *itable_0E[] = { + instrux + 779, + NULL +}; + +static struct itemplate *itable_0F[] = { + instrux + 79, + instrux + 80, + instrux + 81, + instrux + 82, + instrux + 83, + instrux + 84, + instrux + 85, + instrux + 86, + instrux + 87, + instrux + 88, + instrux + 89, + instrux + 90, + instrux + 91, + instrux + 92, + instrux + 93, + instrux + 94, + instrux + 95, + instrux + 96, + instrux + 97, + instrux + 98, + instrux + 99, + instrux + 100, + instrux + 101, + instrux + 102, + instrux + 103, + instrux + 104, + instrux + 105, + instrux + 106, + instrux + 107, + instrux + 108, + instrux + 109, + instrux + 110, + instrux + 111, + instrux + 139, + instrux + 167, + instrux + 168, + instrux + 169, + instrux + 170, + instrux + 171, + instrux + 172, + instrux + 173, + instrux + 174, + instrux + 175, + instrux + 176, + instrux + 177, + instrux + 178, + instrux + 179, + instrux + 180, + instrux + 193, + instrux + 261, + instrux + 385, + instrux + 386, + instrux + 387, + instrux + 388, + instrux + 419, + instrux + 420, + instrux + 447, + instrux + 448, + instrux + 449, + instrux + 450, + instrux + 458, + instrux + 459, + instrux + 460, + instrux + 461, + instrux + 462, + instrux + 463, + instrux + 464, + instrux + 465, + instrux + 466, + instrux + 467, + instrux + 468, + instrux + 469, + instrux + 470, + instrux + 471, + instrux + 490, + instrux + 491, + instrux + 492, + instrux + 493, + instrux + 494, + instrux + 495, + instrux + 496, + instrux + 497, + instrux + 498, + instrux + 520, + instrux + 521, + instrux + 522, + instrux + 523, + instrux + 524, + instrux + 525, + instrux + 526, + instrux + 527, + instrux + 549, + instrux + 550, + instrux + 551, + instrux + 552, + instrux + 553, + instrux + 554, + instrux + 555, + instrux + 556, + instrux + 560, + instrux + 561, + instrux + 562, + instrux + 563, + instrux + 564, + instrux + 565, + instrux + 566, + instrux + 567, + instrux + 610, + instrux + 611, + instrux + 612, + instrux + 613, + instrux + 614, + instrux + 615, + instrux + 616, + instrux + 617, + instrux + 618, + instrux + 619, + instrux + 620, + instrux + 621, + instrux + 622, + instrux + 623, + instrux + 624, + instrux + 625, + instrux + 626, + instrux + 627, + instrux + 628, + instrux + 629, + instrux + 630, + instrux + 631, + instrux + 632, + instrux + 633, + instrux + 634, + instrux + 635, + instrux + 636, + instrux + 637, + instrux + 638, + instrux + 639, + instrux + 640, + instrux + 641, + instrux + 642, + instrux + 643, + instrux + 644, + instrux + 645, + instrux + 646, + instrux + 647, + instrux + 648, + instrux + 649, + instrux + 650, + instrux + 651, + instrux + 652, + instrux + 653, + instrux + 654, + instrux + 655, + instrux + 656, + instrux + 657, + instrux + 658, + instrux + 659, + instrux + 660, + instrux + 661, + instrux + 662, + instrux + 663, + instrux + 664, + instrux + 665, + instrux + 666, + instrux + 667, + instrux + 668, + instrux + 669, + instrux + 670, + instrux + 671, + instrux + 672, + instrux + 673, + instrux + 674, + instrux + 675, + instrux + 676, + instrux + 677, + instrux + 678, + instrux + 679, + instrux + 680, + instrux + 681, + instrux + 682, + instrux + 683, + instrux + 684, + instrux + 685, + instrux + 686, + instrux + 687, + instrux + 688, + instrux + 689, + instrux + 690, + instrux + 691, + instrux + 692, + instrux + 693, + instrux + 694, + instrux + 695, + instrux + 696, + instrux + 697, + instrux + 698, + instrux + 699, + instrux + 700, + instrux + 701, + instrux + 702, + instrux + 703, + instrux + 704, + instrux + 705, + instrux + 711, + instrux + 718, + instrux + 719, + instrux + 720, + instrux + 721, + instrux + 722, + instrux + 723, + instrux + 724, + instrux + 725, + instrux + 726, + instrux + 727, + instrux + 728, + instrux + 729, + instrux + 730, + instrux + 731, + instrux + 732, + instrux + 733, + instrux + 734, + instrux + 735, + instrux + 736, + instrux + 737, + instrux + 738, + instrux + 739, + instrux + 740, + instrux + 741, + instrux + 742, + instrux + 743, + instrux + 744, + instrux + 745, + instrux + 746, + instrux + 747, + instrux + 748, + instrux + 749, + instrux + 750, + instrux + 751, + instrux + 752, + instrux + 753, + instrux + 754, + instrux + 755, + instrux + 756, + instrux + 757, + instrux + 758, + instrux + 759, + instrux + 760, + instrux + 761, + instrux + 762, + instrux + 763, + instrux + 764, + instrux + 765, + instrux + 766, + instrux + 767, + instrux + 768, + instrux + 769, + instrux + 770, + instrux + 771, + instrux + 772, + instrux + 773, + instrux + 778, + instrux + 789, + instrux + 790, + instrux + 809, + instrux + 810, + instrux + 811, + instrux + 812, + instrux + 838, + instrux + 839, + instrux + 840, + instrux + 878, + instrux + 888, + instrux + 889, + instrux + 890, + instrux + 891, + instrux + 892, + instrux + 893, + instrux + 894, + instrux + 895, + instrux + 905, + instrux + 906, + instrux + 907, + instrux + 908, + instrux + 909, + instrux + 910, + instrux + 911, + instrux + 912, + instrux + 913, + instrux + 914, + instrux + 915, + instrux + 916, + instrux + 918, + instrux + 919, + instrux + 920, + instrux + 921, + instrux + 928, + instrux + 929, + instrux + 930, + instrux + 954, + instrux + 955, + instrux + 956, + instrux + 957, + instrux + 958, + instrux + 959, + instrux + 960, + instrux + 979, + instrux + 980, + instrux + 981, + instrux + 982, + instrux + 983, + instrux + 984, + instrux + 985, + instrux + 986, + instrux + 987, + instrux + 988, + instrux + 989, + instrux + 990, + instrux + 991, + instrux + 992, + instrux + 993, + instrux + 994, + instrux + 995, + instrux + 996, + instrux + 997, + instrux + 998, + instrux + 1000, + instrux + 1001, + instrux + 1002, + instrux + 1003, + instrux + 1004, + instrux + 1005, + instrux + 1006, + instrux + 1007, + instrux + 1008, + instrux + 1049, + instrux + 1050, + instrux + 1051, + instrux + 1052, + instrux + 1053, + instrux + 1054, + instrux + 1055, + instrux + 1057, + instrux + 1058, + instrux + 1059, + instrux + 1060, + instrux + 1061, + instrux + 1062, + instrux + 1063, + instrux + 1064, + instrux + 1065, + instrux + 1066, + instrux + 1067, + instrux + 1068, + instrux + 1069, + instrux + 1070, + instrux + 1071, + instrux + 1072, + instrux + 1073, + instrux + 1074, + instrux + 1075, + instrux + 1076, + instrux + 1077, + instrux + 1078, + instrux + 1079, + instrux + 1080, + instrux + 1081, + instrux + 1082, + instrux + 1083, + instrux + 1084, + instrux + 1085, + instrux + 1086, + instrux + 1087, + instrux + 1088, + instrux + 1089, + instrux + 1090, + instrux + 1091, + instrux + 1092, + instrux + 1093, + instrux + 1094, + instrux + 1095, + instrux + 1096, + instrux + 1097, + instrux + 1098, + instrux + 1099, + instrux + 1100, + instrux + 1101, + instrux + 1102, + instrux + 1103, + instrux + 1104, + instrux + 1105, + instrux + 1106, + instrux + 1107, + instrux + 1108, + instrux + 1109, + instrux + 1110, + instrux + 1111, + instrux + 1112, + instrux + 1113, + instrux + 1114, + instrux + 1115, + instrux + 1116, + instrux + 1117, + instrux + 1118, + instrux + 1119, + instrux + 1120, + instrux + 1121, + instrux + 1122, + instrux + 1123, + instrux + 1124, + instrux + 1125, + instrux + 1126, + instrux + 1127, + instrux + 1128, + instrux + 1129, + instrux + 1130, + instrux + 1131, + instrux + 1132, + instrux + 1133, + instrux + 1134, + instrux + 1135, + instrux + 1136, + instrux + 1137, + instrux + 1138, + instrux + 1139, + instrux + 1140, + instrux + 1141, + instrux + 1142, + instrux + 1143, + instrux + 1144, + instrux + 1145, + instrux + 1146, + instrux + 1147, + instrux + 1148, + instrux + 1149, + instrux + 1150, + instrux + 1151, + instrux + 1152, + instrux + 1153, + instrux + 1154, + instrux + 1155, + instrux + 1156, + instrux + 1157, + instrux + 1158, + instrux + 1159, + instrux + 1160, + instrux + 1161, + instrux + 1162, + instrux + 1163, + instrux + 1164, + instrux + 1165, + instrux + 1166, + instrux + 1167, + instrux + 1168, + instrux + 1169, + instrux + 1170, + instrux + 1171, + instrux + 1172, + instrux + 1173, + instrux + 1174, + instrux + 1175, + instrux + 1176, + instrux + 1177, + instrux + 1178, + instrux + 1179, + instrux + 1180, + instrux + 1181, + instrux + 1182, + instrux + 1183, + instrux + 1184, + instrux + 1185, + instrux + 1186, + instrux + 1187, + instrux + 1188, + instrux + 1189, + instrux + 1190, + instrux + 1191, + instrux + 1192, + instrux + 1193, + instrux + 1194, + instrux + 1195, + instrux + 1196, + instrux + 1197, + instrux + 1198, + instrux + 1199, + instrux + 1200, + instrux + 1201, + instrux + 1202, + instrux + 1203, + instrux + 1204, + instrux + 1205, + instrux + 1206, + instrux + 1207, + instrux + 1208, + instrux + 1209, + instrux + 1210, + instrux + 1211, + instrux + 1212, + instrux + 1213, + NULL +}; + +static struct itemplate *itable_10[] = { + instrux + 6, + instrux + 7, + NULL +}; + +static struct itemplate *itable_11[] = { + instrux + 8, + instrux + 9, + instrux + 10, + instrux + 11, + NULL +}; + +static struct itemplate *itable_12[] = { + instrux + 12, + instrux + 13, + NULL +}; + +static struct itemplate *itable_13[] = { + instrux + 14, + instrux + 15, + instrux + 16, + instrux + 17, + NULL +}; + +static struct itemplate *itable_14[] = { + instrux + 20, + NULL +}; + +static struct itemplate *itable_15[] = { + instrux + 21, + instrux + 22, + NULL +}; + +static struct itemplate *itable_16[] = { + instrux + 779, + NULL +}; + +static struct itemplate *itable_17[] = { + instrux + 710, + NULL +}; + +static struct itemplate *itable_18[] = { + instrux + 852, + instrux + 853, + NULL +}; + +static struct itemplate *itable_19[] = { + instrux + 854, + instrux + 855, + instrux + 856, + instrux + 857, + NULL +}; + +static struct itemplate *itable_1A[] = { + instrux + 858, + instrux + 859, + NULL +}; + +static struct itemplate *itable_1B[] = { + instrux + 860, + instrux + 861, + instrux + 862, + instrux + 863, + NULL +}; + +static struct itemplate *itable_1C[] = { + instrux + 866, + NULL +}; + +static struct itemplate *itable_1D[] = { + instrux + 867, + instrux + 868, + NULL +}; + +static struct itemplate *itable_1E[] = { + instrux + 779, + NULL +}; + +static struct itemplate *itable_1F[] = { + instrux + 710, + NULL +}; + +static struct itemplate *itable_20[] = { + instrux + 52, + instrux + 53, + NULL +}; + +static struct itemplate *itable_21[] = { + instrux + 54, + instrux + 55, + instrux + 56, + instrux + 57, + NULL +}; + +static struct itemplate *itable_22[] = { + instrux + 58, + instrux + 59, + NULL +}; + +static struct itemplate *itable_23[] = { + instrux + 60, + instrux + 61, + instrux + 62, + instrux + 63, + NULL +}; + +static struct itemplate *itable_24[] = { + instrux + 66, + NULL +}; + +static struct itemplate *itable_25[] = { + instrux + 67, + instrux + 68, + NULL +}; + +static struct itemplate *itable_26[] = { + NULL +}; + +static struct itemplate *itable_27[] = { + instrux + 183, + NULL +}; + +static struct itemplate *itable_28[] = { + instrux + 931, + instrux + 932, + NULL +}; + +static struct itemplate *itable_29[] = { + instrux + 933, + instrux + 934, + instrux + 935, + instrux + 936, + NULL +}; + +static struct itemplate *itable_2A[] = { + instrux + 937, + instrux + 938, + NULL +}; + +static struct itemplate *itable_2B[] = { + instrux + 939, + instrux + 940, + instrux + 941, + instrux + 942, + NULL +}; + +static struct itemplate *itable_2C[] = { + instrux + 945, + NULL +}; + +static struct itemplate *itable_2D[] = { + instrux + 946, + instrux + 947, + NULL +}; + +static struct itemplate *itable_2E[] = { + NULL +}; + +static struct itemplate *itable_2F[] = { + instrux + 184, + NULL +}; + +static struct itemplate *itable_30[] = { + instrux + 1026, + instrux + 1027, + NULL +}; + +static struct itemplate *itable_31[] = { + instrux + 1028, + instrux + 1029, + instrux + 1030, + instrux + 1031, + NULL +}; + +static struct itemplate *itable_32[] = { + instrux + 1032, + instrux + 1033, + NULL +}; + +static struct itemplate *itable_33[] = { + instrux + 1034, + instrux + 1035, + instrux + 1036, + instrux + 1037, + NULL +}; + +static struct itemplate *itable_34[] = { + instrux + 1040, + NULL +}; + +static struct itemplate *itable_35[] = { + instrux + 1041, + instrux + 1042, + NULL +}; + +static struct itemplate *itable_36[] = { + NULL +}; + +static struct itemplate *itable_37[] = { + instrux + 0, + NULL +}; + +static struct itemplate *itable_38[] = { + instrux + 141, + instrux + 142, + NULL +}; + +static struct itemplate *itable_39[] = { + instrux + 143, + instrux + 144, + instrux + 145, + instrux + 146, + NULL +}; + +static struct itemplate *itable_3A[] = { + instrux + 147, + instrux + 148, + NULL +}; + +static struct itemplate *itable_3B[] = { + instrux + 149, + instrux + 150, + instrux + 151, + instrux + 152, + NULL +}; + +static struct itemplate *itable_3C[] = { + instrux + 155, + NULL +}; + +static struct itemplate *itable_3D[] = { + instrux + 156, + instrux + 157, + NULL +}; + +static struct itemplate *itable_3E[] = { + NULL +}; + +static struct itemplate *itable_3F[] = { + instrux + 5, + NULL +}; + +static struct itemplate *itable_40[] = { + instrux + 407, + instrux + 408, + NULL +}; + +static struct itemplate *itable_41[] = { + instrux + 407, + instrux + 408, + NULL +}; + +static struct itemplate *itable_42[] = { + instrux + 407, + instrux + 408, + NULL +}; + +static struct itemplate *itable_43[] = { + instrux + 407, + instrux + 408, + NULL +}; + +static struct itemplate *itable_44[] = { + instrux + 407, + instrux + 408, + NULL +}; + +static struct itemplate *itable_45[] = { + instrux + 407, + instrux + 408, + NULL +}; + +static struct itemplate *itable_46[] = { + instrux + 407, + instrux + 408, + NULL +}; + +static struct itemplate *itable_47[] = { + instrux + 407, + instrux + 408, + NULL +}; + +static struct itemplate *itable_48[] = { + instrux + 185, + instrux + 186, + NULL +}; + +static struct itemplate *itable_49[] = { + instrux + 185, + instrux + 186, + NULL +}; + +static struct itemplate *itable_4A[] = { + instrux + 185, + instrux + 186, + NULL +}; + +static struct itemplate *itable_4B[] = { + instrux + 185, + instrux + 186, + NULL +}; + +static struct itemplate *itable_4C[] = { + instrux + 185, + instrux + 186, + NULL +}; + +static struct itemplate *itable_4D[] = { + instrux + 185, + instrux + 186, + NULL +}; + +static struct itemplate *itable_4E[] = { + instrux + 185, + instrux + 186, + NULL +}; + +static struct itemplate *itable_4F[] = { + instrux + 185, + instrux + 186, + NULL +}; + +static struct itemplate *itable_50[] = { + instrux + 774, + instrux + 775, + NULL +}; + +static struct itemplate *itable_51[] = { + instrux + 774, + instrux + 775, + NULL +}; + +static struct itemplate *itable_52[] = { + instrux + 774, + instrux + 775, + NULL +}; + +static struct itemplate *itable_53[] = { + instrux + 774, + instrux + 775, + NULL +}; + +static struct itemplate *itable_54[] = { + instrux + 774, + instrux + 775, + NULL +}; + +static struct itemplate *itable_55[] = { + instrux + 774, + instrux + 775, + NULL +}; + +static struct itemplate *itable_56[] = { + instrux + 774, + instrux + 775, + NULL +}; + +static struct itemplate *itable_57[] = { + instrux + 774, + instrux + 775, + NULL +}; + +static struct itemplate *itable_58[] = { + instrux + 706, + instrux + 707, + NULL +}; + +static struct itemplate *itable_59[] = { + instrux + 706, + instrux + 707, + NULL +}; + +static struct itemplate *itable_5A[] = { + instrux + 706, + instrux + 707, + NULL +}; + +static struct itemplate *itable_5B[] = { + instrux + 706, + instrux + 707, + NULL +}; + +static struct itemplate *itable_5C[] = { + instrux + 706, + instrux + 707, + NULL +}; + +static struct itemplate *itable_5D[] = { + instrux + 706, + instrux + 707, + NULL +}; + +static struct itemplate *itable_5E[] = { + instrux + 706, + instrux + 707, + NULL +}; + +static struct itemplate *itable_5F[] = { + instrux + 706, + instrux + 707, + NULL +}; + +static struct itemplate *itable_60[] = { + instrux + 783, + instrux + 784, + instrux + 785, + NULL +}; + +static struct itemplate *itable_61[] = { + instrux + 712, + instrux + 713, + instrux + 714, + NULL +}; + +static struct itemplate *itable_62[] = { + instrux + 77, + instrux + 78, + NULL +}; + +static struct itemplate *itable_63[] = { + instrux + 75, + instrux + 76, + NULL +}; + +static struct itemplate *itable_64[] = { + NULL +}; + +static struct itemplate *itable_65[] = { + NULL +}; + +static struct itemplate *itable_66[] = { + NULL +}; + +static struct itemplate *itable_67[] = { + NULL +}; + +static struct itemplate *itable_68[] = { + instrux + 781, + instrux + 782, + NULL +}; + +static struct itemplate *itable_69[] = { + instrux + 391, + instrux + 392, + instrux + 395, + instrux + 396, + instrux + 398, + instrux + 400, + NULL +}; + +static struct itemplate *itable_6A[] = { + instrux + 780, + NULL +}; + +static struct itemplate *itable_6B[] = { + instrux + 389, + instrux + 390, + instrux + 393, + instrux + 394, + instrux + 397, + instrux + 399, + NULL +}; + +static struct itemplate *itable_6C[] = { + instrux + 412, + NULL +}; + +static struct itemplate *itable_6D[] = { + instrux + 413, + instrux + 414, + NULL +}; + +static struct itemplate *itable_6E[] = { + instrux + 607, + NULL +}; + +static struct itemplate *itable_6F[] = { + instrux + 608, + instrux + 609, + NULL +}; + +static struct itemplate *itable_70[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_71[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_72[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_73[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_74[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_75[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_76[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_77[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_78[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_79[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_7A[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_7B[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_7C[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_7D[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_7E[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_7F[] = { + instrux + 1056, + NULL +}; + +static struct itemplate *itable_80[] = { + instrux + 23, + instrux + 26, + instrux + 46, + instrux + 49, + instrux + 69, + instrux + 72, + instrux + 158, + instrux + 161, + instrux + 595, + instrux + 598, + instrux + 869, + instrux + 872, + instrux + 948, + instrux + 951, + instrux + 1043, + instrux + 1046, + NULL +}; + +static struct itemplate *itable_81[] = { + instrux + 24, + instrux + 25, + instrux + 27, + instrux + 28, + instrux + 47, + instrux + 48, + instrux + 50, + instrux + 51, + instrux + 70, + instrux + 71, + instrux + 73, + instrux + 74, + instrux + 159, + instrux + 160, + instrux + 162, + instrux + 163, + instrux + 596, + instrux + 597, + instrux + 599, + instrux + 600, + instrux + 870, + instrux + 871, + instrux + 873, + instrux + 874, + instrux + 949, + instrux + 950, + instrux + 952, + instrux + 953, + instrux + 1044, + instrux + 1045, + instrux + 1047, + instrux + 1048, + NULL +}; + +static struct itemplate *itable_82[] = { + NULL +}; + +static struct itemplate *itable_83[] = { + instrux + 18, + instrux + 19, + instrux + 41, + instrux + 42, + instrux + 64, + instrux + 65, + instrux + 153, + instrux + 154, + instrux + 590, + instrux + 591, + instrux + 864, + instrux + 865, + instrux + 943, + instrux + 944, + instrux + 1038, + instrux + 1039, + NULL +}; + +static struct itemplate *itable_84[] = { + instrux + 961, + instrux + 962, + instrux + 967, + NULL +}; + +static struct itemplate *itable_85[] = { + instrux + 963, + instrux + 964, + instrux + 965, + instrux + 966, + instrux + 968, + instrux + 969, + NULL +}; + +static struct itemplate *itable_86[] = { + instrux + 1013, + instrux + 1014, + instrux + 1019, + instrux + 1020, + NULL +}; + +static struct itemplate *itable_87[] = { + instrux + 1015, + instrux + 1016, + instrux + 1017, + instrux + 1018, + instrux + 1021, + instrux + 1022, + instrux + 1023, + instrux + 1024, + NULL +}; + +static struct itemplate *itable_88[] = { + instrux + 528, + instrux + 529, + NULL +}; + +static struct itemplate *itable_89[] = { + instrux + 530, + instrux + 531, + instrux + 532, + instrux + 533, + NULL +}; + +static struct itemplate *itable_8A[] = { + instrux + 534, + instrux + 535, + NULL +}; + +static struct itemplate *itable_8B[] = { + instrux + 536, + instrux + 537, + instrux + 538, + instrux + 539, + NULL +}; + +static struct itemplate *itable_8C[] = { + instrux + 499, + instrux + 500, + instrux + 501, + instrux + 502, + instrux + 503, + instrux + 504, + instrux + 505, + instrux + 506, + instrux + 507, + NULL +}; + +static struct itemplate *itable_8D[] = { + instrux + 453, + instrux + 454, + NULL +}; + +static struct itemplate *itable_8E[] = { + instrux + 508, + instrux + 509, + instrux + 510, + instrux + 511, + instrux + 512, + instrux + 513, + NULL +}; + +static struct itemplate *itable_8F[] = { + instrux + 708, + instrux + 709, + NULL +}; + +static struct itemplate *itable_90[] = { + instrux + 574, + instrux + 1009, + instrux + 1010, + instrux + 1011, + instrux + 1012, + NULL +}; + +static struct itemplate *itable_91[] = { + instrux + 1009, + instrux + 1010, + instrux + 1011, + instrux + 1012, + NULL +}; + +static struct itemplate *itable_92[] = { + instrux + 1009, + instrux + 1010, + instrux + 1011, + instrux + 1012, + NULL +}; + +static struct itemplate *itable_93[] = { + instrux + 1009, + instrux + 1010, + instrux + 1011, + instrux + 1012, + NULL +}; + +static struct itemplate *itable_94[] = { + instrux + 1009, + instrux + 1010, + instrux + 1011, + instrux + 1012, + NULL +}; + +static struct itemplate *itable_95[] = { + instrux + 1009, + instrux + 1010, + instrux + 1011, + instrux + 1012, + NULL +}; + +static struct itemplate *itable_96[] = { + instrux + 1009, + instrux + 1010, + instrux + 1011, + instrux + 1012, + NULL +}; + +static struct itemplate *itable_97[] = { + instrux + 1009, + instrux + 1010, + instrux + 1011, + instrux + 1012, + NULL +}; + +static struct itemplate *itable_98[] = { + instrux + 134, + instrux + 182, + NULL +}; + +static struct itemplate *itable_99[] = { + instrux + 135, + instrux + 181, + NULL +}; + +static struct itemplate *itable_9A[] = { + instrux + 118, + instrux + 119, + instrux + 120, + instrux + 121, + instrux + 122, + NULL +}; + +static struct itemplate *itable_9B[] = { + instrux + 212, + instrux + 244, + instrux + 262, + instrux + 280, + instrux + 327, + instrux + 336, + instrux + 337, + instrux + 342, + instrux + 343, + instrux + 999, + NULL +}; + +static struct itemplate *itable_9C[] = { + instrux + 786, + instrux + 787, + instrux + 788, + NULL +}; + +static struct itemplate *itable_9D[] = { + instrux + 715, + instrux + 716, + instrux + 717, + NULL +}; + +static struct itemplate *itable_9E[] = { + instrux + 841, + NULL +}; + +static struct itemplate *itable_9F[] = { + instrux + 446, + NULL +}; + +static struct itemplate *itable_A0[] = { + instrux + 514, + NULL +}; + +static struct itemplate *itable_A1[] = { + instrux + 515, + instrux + 516, + NULL +}; + +static struct itemplate *itable_A2[] = { + instrux + 517, + NULL +}; + +static struct itemplate *itable_A3[] = { + instrux + 518, + instrux + 519, + NULL +}; + +static struct itemplate *itable_A4[] = { + instrux + 557, + NULL +}; + +static struct itemplate *itable_A5[] = { + instrux + 558, + instrux + 559, + NULL +}; + +static struct itemplate *itable_A6[] = { + instrux + 164, + NULL +}; + +static struct itemplate *itable_A7[] = { + instrux + 165, + instrux + 166, + NULL +}; + +static struct itemplate *itable_A8[] = { + instrux + 970, + NULL +}; + +static struct itemplate *itable_A9[] = { + instrux + 971, + instrux + 972, + NULL +}; + +static struct itemplate *itable_AA[] = { + instrux + 925, + NULL +}; + +static struct itemplate *itable_AB[] = { + instrux + 926, + instrux + 927, + NULL +}; + +static struct itemplate *itable_AC[] = { + instrux + 472, + NULL +}; + +static struct itemplate *itable_AD[] = { + instrux + 473, + instrux + 474, + NULL +}; + +static struct itemplate *itable_AE[] = { + instrux + 875, + NULL +}; + +static struct itemplate *itable_AF[] = { + instrux + 876, + instrux + 877, + NULL +}; + +static struct itemplate *itable_B0[] = { + instrux + 540, + NULL +}; + +static struct itemplate *itable_B1[] = { + instrux + 540, + NULL +}; + +static struct itemplate *itable_B2[] = { + instrux + 540, + NULL +}; + +static struct itemplate *itable_B3[] = { + instrux + 540, + NULL +}; + +static struct itemplate *itable_B4[] = { + instrux + 540, + NULL +}; + +static struct itemplate *itable_B5[] = { + instrux + 540, + NULL +}; + +static struct itemplate *itable_B6[] = { + instrux + 540, + NULL +}; + +static struct itemplate *itable_B7[] = { + instrux + 540, + NULL +}; + +static struct itemplate *itable_B8[] = { + instrux + 541, + instrux + 542, + NULL +}; + +static struct itemplate *itable_B9[] = { + instrux + 541, + instrux + 542, + NULL +}; + +static struct itemplate *itable_BA[] = { + instrux + 541, + instrux + 542, + NULL +}; + +static struct itemplate *itable_BB[] = { + instrux + 541, + instrux + 542, + NULL +}; + +static struct itemplate *itable_BC[] = { + instrux + 541, + instrux + 542, + NULL +}; + +static struct itemplate *itable_BD[] = { + instrux + 541, + instrux + 542, + NULL +}; + +static struct itemplate *itable_BE[] = { + instrux + 541, + instrux + 542, + NULL +}; + +static struct itemplate *itable_BF[] = { + instrux + 541, + instrux + 542, + NULL +}; + +static struct itemplate *itable_C0[] = { + instrux + 793, + instrux + 802, + instrux + 822, + instrux + 831, + instrux + 845, + instrux + 881, + instrux + 898, + NULL +}; + +static struct itemplate *itable_C1[] = { + instrux + 796, + instrux + 799, + instrux + 805, + instrux + 808, + instrux + 825, + instrux + 828, + instrux + 834, + instrux + 837, + instrux + 848, + instrux + 851, + instrux + 884, + instrux + 887, + instrux + 901, + instrux + 904, + NULL +}; + +static struct itemplate *itable_C2[] = { + instrux + 815, + instrux + 819, + NULL +}; + +static struct itemplate *itable_C3[] = { + instrux + 814, + instrux + 818, + NULL +}; + +static struct itemplate *itable_C4[] = { + instrux + 456, + instrux + 457, + NULL +}; + +static struct itemplate *itable_C5[] = { + instrux + 451, + instrux + 452, + NULL +}; + +static struct itemplate *itable_C6[] = { + instrux + 543, + instrux + 546, + NULL +}; + +static struct itemplate *itable_C7[] = { + instrux + 544, + instrux + 545, + instrux + 547, + instrux + 548, + NULL +}; + +static struct itemplate *itable_C8[] = { + instrux + 194, + NULL +}; + +static struct itemplate *itable_C9[] = { + instrux + 455, + NULL +}; + +static struct itemplate *itable_CA[] = { + instrux + 817, + NULL +}; + +static struct itemplate *itable_CB[] = { + instrux + 816, + NULL +}; + +static struct itemplate *itable_CC[] = { + instrux + 417, + NULL +}; + +static struct itemplate *itable_CD[] = { + instrux + 415, + NULL +}; + +static struct itemplate *itable_CE[] = { + instrux + 418, + NULL +}; + +static struct itemplate *itable_CF[] = { + instrux + 421, + instrux + 422, + instrux + 423, + NULL +}; + +static struct itemplate *itable_D0[] = { + instrux + 791, + instrux + 800, + instrux + 820, + instrux + 829, + instrux + 843, + instrux + 879, + instrux + 896, + NULL +}; + +static struct itemplate *itable_D1[] = { + instrux + 794, + instrux + 797, + instrux + 803, + instrux + 806, + instrux + 823, + instrux + 826, + instrux + 832, + instrux + 835, + instrux + 846, + instrux + 849, + instrux + 882, + instrux + 885, + instrux + 899, + instrux + 902, + NULL +}; + +static struct itemplate *itable_D2[] = { + instrux + 792, + instrux + 801, + instrux + 821, + instrux + 830, + instrux + 844, + instrux + 880, + instrux + 897, + NULL +}; + +static struct itemplate *itable_D3[] = { + instrux + 795, + instrux + 798, + instrux + 804, + instrux + 807, + instrux + 824, + instrux + 827, + instrux + 833, + instrux + 836, + instrux + 847, + instrux + 850, + instrux + 883, + instrux + 886, + instrux + 900, + instrux + 903, + NULL +}; + +static struct itemplate *itable_D4[] = { + instrux + 3, + instrux + 4, + NULL +}; + +static struct itemplate *itable_D5[] = { + instrux + 1, + instrux + 2, + NULL +}; + +static struct itemplate *itable_D6[] = { + instrux + 842, + NULL +}; + +static struct itemplate *itable_D7[] = { + instrux + 1025, + NULL +}; + +static struct itemplate *itable_D8[] = { + instrux + 199, + instrux + 202, + instrux + 204, + instrux + 229, + instrux + 231, + instrux + 232, + instrux + 237, + instrux + 239, + instrux + 240, + instrux + 245, + instrux + 249, + instrux + 250, + instrux + 253, + instrux + 257, + instrux + 258, + instrux + 303, + instrux + 307, + instrux + 308, + instrux + 344, + instrux + 348, + instrux + 349, + instrux + 352, + instrux + 356, + instrux + 357, + NULL +}; + +static struct itemplate *itable_D9[] = { + instrux + 197, + instrux + 198, + instrux + 211, + instrux + 242, + instrux + 243, + instrux + 279, + instrux + 290, + instrux + 293, + instrux + 294, + instrux + 295, + instrux + 296, + instrux + 297, + instrux + 298, + instrux + 299, + instrux + 300, + instrux + 301, + instrux + 302, + instrux + 315, + instrux + 317, + instrux + 318, + instrux + 321, + instrux + 322, + instrux + 323, + instrux + 324, + instrux + 325, + instrux + 328, + instrux + 330, + instrux + 331, + instrux + 332, + instrux + 333, + instrux + 338, + instrux + 360, + instrux + 370, + instrux + 371, + instrux + 372, + instrux + 373, + instrux + 374, + instrux + 375, + instrux + 376, + instrux + 377, + NULL +}; + +static struct itemplate *itable_DA[] = { + instrux + 213, + instrux + 214, + instrux + 215, + instrux + 216, + instrux + 217, + instrux + 218, + instrux + 227, + instrux + 228, + instrux + 264, + instrux + 266, + instrux + 268, + instrux + 270, + instrux + 272, + instrux + 277, + instrux + 286, + instrux + 288, + instrux + 369, + NULL +}; + +static struct itemplate *itable_DB[] = { + instrux + 219, + instrux + 220, + instrux + 221, + instrux + 222, + instrux + 223, + instrux + 224, + instrux + 225, + instrux + 226, + instrux + 233, + instrux + 234, + instrux + 274, + instrux + 281, + instrux + 283, + instrux + 292, + instrux + 311, + instrux + 312, + instrux + 313, + instrux + 314, + instrux + 329, + instrux + 340, + instrux + 363, + instrux + 364, + NULL +}; + +static struct itemplate *itable_DC[] = { + instrux + 200, + instrux + 201, + instrux + 203, + instrux + 230, + instrux + 238, + instrux + 246, + instrux + 247, + instrux + 248, + instrux + 254, + instrux + 255, + instrux + 256, + instrux + 304, + instrux + 305, + instrux + 306, + instrux + 345, + instrux + 346, + instrux + 347, + instrux + 353, + instrux + 354, + instrux + 355, + NULL +}; + +static struct itemplate *itable_DD[] = { + instrux + 263, + instrux + 291, + instrux + 316, + instrux + 319, + instrux + 326, + instrux + 334, + instrux + 335, + instrux + 339, + instrux + 341, + instrux + 361, + instrux + 362, + instrux + 367, + instrux + 368, + NULL +}; + +static struct itemplate *itable_DE[] = { + instrux + 205, + instrux + 206, + instrux + 241, + instrux + 251, + instrux + 252, + instrux + 259, + instrux + 260, + instrux + 265, + instrux + 267, + instrux + 269, + instrux + 271, + instrux + 273, + instrux + 278, + instrux + 287, + instrux + 289, + instrux + 309, + instrux + 310, + instrux + 350, + instrux + 351, + instrux + 358, + instrux + 359, + NULL +}; + +static struct itemplate *itable_DF[] = { + instrux + 207, + instrux + 208, + instrux + 209, + instrux + 210, + instrux + 235, + instrux + 236, + instrux + 275, + instrux + 276, + instrux + 282, + instrux + 284, + instrux + 285, + instrux + 320, + instrux + 365, + instrux + 366, + NULL +}; + +static struct itemplate *itable_E0[] = { + instrux + 481, + instrux + 482, + instrux + 483, + instrux + 484, + instrux + 485, + instrux + 486, + NULL +}; + +static struct itemplate *itable_E1[] = { + instrux + 478, + instrux + 479, + instrux + 480, + instrux + 487, + instrux + 488, + instrux + 489, + NULL +}; + +static struct itemplate *itable_E2[] = { + instrux + 475, + instrux + 476, + instrux + 477, + NULL +}; + +static struct itemplate *itable_E3[] = { + instrux + 424, + instrux + 425, + NULL +}; + +static struct itemplate *itable_E4[] = { + instrux + 401, + NULL +}; + +static struct itemplate *itable_E5[] = { + instrux + 402, + instrux + 403, + NULL +}; + +static struct itemplate *itable_E6[] = { + instrux + 601, + NULL +}; + +static struct itemplate *itable_E7[] = { + instrux + 602, + instrux + 603, + NULL +}; + +static struct itemplate *itable_E8[] = { + instrux + 112, + instrux + 113, + instrux + 114, + instrux + 115, + instrux + 116, + instrux + 117, + NULL +}; + +static struct itemplate *itable_E9[] = { + instrux + 427, + instrux + 428, + instrux + 429, + NULL +}; + +static struct itemplate *itable_EA[] = { + instrux + 430, + instrux + 431, + instrux + 432, + instrux + 433, + instrux + 434, + NULL +}; + +static struct itemplate *itable_EB[] = { + instrux + 426, + NULL +}; + +static struct itemplate *itable_EC[] = { + instrux + 404, + NULL +}; + +static struct itemplate *itable_ED[] = { + instrux + 405, + instrux + 406, + NULL +}; + +static struct itemplate *itable_EE[] = { + instrux + 604, + NULL +}; + +static struct itemplate *itable_EF[] = { + instrux + 605, + instrux + 606, + NULL +}; + +static struct itemplate *itable_F0[] = { + NULL +}; + +static struct itemplate *itable_F1[] = { + instrux + 416, + instrux + 917, + NULL +}; + +static struct itemplate *itable_F2[] = { + NULL +}; + +static struct itemplate *itable_F3[] = { + NULL +}; + +static struct itemplate *itable_F4[] = { + instrux + 378, + NULL +}; + +static struct itemplate *itable_F5[] = { + instrux + 140, + NULL +}; + +static struct itemplate *itable_F6[] = { + instrux + 190, + instrux + 379, + instrux + 382, + instrux + 568, + instrux + 571, + instrux + 575, + instrux + 973, + instrux + 976, + NULL +}; + +static struct itemplate *itable_F7[] = { + instrux + 191, + instrux + 192, + instrux + 380, + instrux + 381, + instrux + 383, + instrux + 384, + instrux + 569, + instrux + 570, + instrux + 572, + instrux + 573, + instrux + 576, + instrux + 577, + instrux + 974, + instrux + 975, + instrux + 977, + instrux + 978, + NULL +}; + +static struct itemplate *itable_F8[] = { + instrux + 136, + NULL +}; + +static struct itemplate *itable_F9[] = { + instrux + 922, + NULL +}; + +static struct itemplate *itable_FA[] = { + instrux + 138, + NULL +}; + +static struct itemplate *itable_FB[] = { + instrux + 924, + NULL +}; + +static struct itemplate *itable_FC[] = { + instrux + 137, + NULL +}; + +static struct itemplate *itable_FD[] = { + instrux + 923, + NULL +}; + +static struct itemplate *itable_FE[] = { + instrux + 187, + instrux + 409, + NULL +}; + +static struct itemplate *itable_FF[] = { + instrux + 123, + instrux + 124, + instrux + 125, + instrux + 126, + instrux + 127, + instrux + 128, + instrux + 129, + instrux + 130, + instrux + 131, + instrux + 132, + instrux + 133, + instrux + 188, + instrux + 189, + instrux + 410, + instrux + 411, + instrux + 435, + instrux + 436, + instrux + 437, + instrux + 438, + instrux + 439, + instrux + 440, + instrux + 441, + instrux + 442, + instrux + 443, + instrux + 444, + instrux + 445, + instrux + 776, + instrux + 777, + NULL +}; + +struct itemplate **itable[] = { + itable_00, + itable_01, + itable_02, + itable_03, + itable_04, + itable_05, + itable_06, + itable_07, + itable_08, + itable_09, + itable_0A, + itable_0B, + itable_0C, + itable_0D, + itable_0E, + itable_0F, + itable_10, + itable_11, + itable_12, + itable_13, + itable_14, + itable_15, + itable_16, + itable_17, + itable_18, + itable_19, + itable_1A, + itable_1B, + itable_1C, + itable_1D, + itable_1E, + itable_1F, + itable_20, + itable_21, + itable_22, + itable_23, + itable_24, + itable_25, + itable_26, + itable_27, + itable_28, + itable_29, + itable_2A, + itable_2B, + itable_2C, + itable_2D, + itable_2E, + itable_2F, + itable_30, + itable_31, + itable_32, + itable_33, + itable_34, + itable_35, + itable_36, + itable_37, + itable_38, + itable_39, + itable_3A, + itable_3B, + itable_3C, + itable_3D, + itable_3E, + itable_3F, + itable_40, + itable_41, + itable_42, + itable_43, + itable_44, + itable_45, + itable_46, + itable_47, + itable_48, + itable_49, + itable_4A, + itable_4B, + itable_4C, + itable_4D, + itable_4E, + itable_4F, + itable_50, + itable_51, + itable_52, + itable_53, + itable_54, + itable_55, + itable_56, + itable_57, + itable_58, + itable_59, + itable_5A, + itable_5B, + itable_5C, + itable_5D, + itable_5E, + itable_5F, + itable_60, + itable_61, + itable_62, + itable_63, + itable_64, + itable_65, + itable_66, + itable_67, + itable_68, + itable_69, + itable_6A, + itable_6B, + itable_6C, + itable_6D, + itable_6E, + itable_6F, + itable_70, + itable_71, + itable_72, + itable_73, + itable_74, + itable_75, + itable_76, + itable_77, + itable_78, + itable_79, + itable_7A, + itable_7B, + itable_7C, + itable_7D, + itable_7E, + itable_7F, + itable_80, + itable_81, + itable_82, + itable_83, + itable_84, + itable_85, + itable_86, + itable_87, + itable_88, + itable_89, + itable_8A, + itable_8B, + itable_8C, + itable_8D, + itable_8E, + itable_8F, + itable_90, + itable_91, + itable_92, + itable_93, + itable_94, + itable_95, + itable_96, + itable_97, + itable_98, + itable_99, + itable_9A, + itable_9B, + itable_9C, + itable_9D, + itable_9E, + itable_9F, + itable_A0, + itable_A1, + itable_A2, + itable_A3, + itable_A4, + itable_A5, + itable_A6, + itable_A7, + itable_A8, + itable_A9, + itable_AA, + itable_AB, + itable_AC, + itable_AD, + itable_AE, + itable_AF, + itable_B0, + itable_B1, + itable_B2, + itable_B3, + itable_B4, + itable_B5, + itable_B6, + itable_B7, + itable_B8, + itable_B9, + itable_BA, + itable_BB, + itable_BC, + itable_BD, + itable_BE, + itable_BF, + itable_C0, + itable_C1, + itable_C2, + itable_C3, + itable_C4, + itable_C5, + itable_C6, + itable_C7, + itable_C8, + itable_C9, + itable_CA, + itable_CB, + itable_CC, + itable_CD, + itable_CE, + itable_CF, + itable_D0, + itable_D1, + itable_D2, + itable_D3, + itable_D4, + itable_D5, + itable_D6, + itable_D7, + itable_D8, + itable_D9, + itable_DA, + itable_DB, + itable_DC, + itable_DD, + itable_DE, + itable_DF, + itable_E0, + itable_E1, + itable_E2, + itable_E3, + itable_E4, + itable_E5, + itable_E6, + itable_E7, + itable_E8, + itable_E9, + itable_EA, + itable_EB, + itable_EC, + itable_ED, + itable_EE, + itable_EF, + itable_F0, + itable_F1, + itable_F2, + itable_F3, + itable_F4, + itable_F5, + itable_F6, + itable_F7, + itable_F8, + itable_F9, + itable_FA, + itable_FB, + itable_FC, + itable_FD, + itable_FE, + itable_FF, +}; diff --git a/mobius/src/drivers/kdebug/insnsd.d b/mobius/src/drivers/kdebug/insnsd.d new file mode 100644 index 0000000..0d7bae8 --- /dev/null +++ b/mobius/src/drivers/kdebug/insnsd.d @@ -0,0 +1,5 @@ +insnsd.o: insnsd.c f:\Projects\mobius\include\stdio.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h \ + f:\Projects\mobius\include\stdarg.h f:\Projects\mobius\include\io.h \ + nasm.h insnsi.h insns.h diff --git a/mobius/src/drivers/kdebug/insnsi.h b/mobius/src/drivers/kdebug/insnsi.h new file mode 100644 index 0000000..891069b --- /dev/null +++ b/mobius/src/drivers/kdebug/insnsi.h @@ -0,0 +1,464 @@ +/* This file is auto-generated from insns.dat by insns.pl - don't edit it */ + +/* This file in included by nasm.h */ + +/* Instruction names */ +enum { + I_AAA, + I_AAD, + I_AAM, + I_AAS, + I_ADC, + I_ADD, + I_ADDPS, + I_ADDSS, + I_AND, + I_ANDNPS, + I_ANDPS, + I_ARPL, + I_BOUND, + I_BSF, + I_BSR, + I_BSWAP, + I_BT, + I_BTC, + I_BTR, + I_BTS, + I_CALL, + I_CBW, + I_CDQ, + I_CLC, + I_CLD, + I_CLI, + I_CLTS, + I_CMC, + I_CMP, + I_CMPEQPS, + I_CMPEQSS, + I_CMPLEPS, + I_CMPLESS, + I_CMPLTPS, + I_CMPLTSS, + I_CMPNEQPS, + I_CMPNEQSS, + I_CMPNLEPS, + I_CMPNLESS, + I_CMPNLTPS, + I_CMPNLTSS, + I_CMPORDPS, + I_CMPORDSS, + I_CMPPS, + I_CMPSB, + I_CMPSD, + I_CMPSS, + I_CMPSW, + I_CMPUNORDPS, + I_CMPUNORDSS, + I_CMPXCHG, + I_CMPXCHG486, + I_CMPXCHG8B, + I_COMISS, + I_CPUID, + I_CVTPI2PS, + I_CVTPS2PI, + I_CVTSI2SS, + I_CVTSS2SI, + I_CVTTPS2PI, + I_CVTTSS2SI, + I_CWD, + I_CWDE, + I_DAA, + I_DAS, + I_DB, + I_DD, + I_DEC, + I_DIV, + I_DIVPS, + I_DIVSS, + I_DQ, + I_DT, + I_DW, + I_EMMS, + I_ENTER, + I_EQU, + I_F2XM1, + I_FABS, + I_FADD, + I_FADDP, + I_FBLD, + I_FBSTP, + I_FCHS, + I_FCLEX, + I_FCMOVB, + I_FCMOVBE, + I_FCMOVE, + I_FCMOVNB, + I_FCMOVNBE, + I_FCMOVNE, + I_FCMOVNU, + I_FCMOVU, + I_FCOM, + I_FCOMI, + I_FCOMIP, + I_FCOMP, + I_FCOMPP, + I_FCOS, + I_FDECSTP, + I_FDISI, + I_FDIV, + I_FDIVP, + I_FDIVR, + I_FDIVRP, + I_FEMMS, + I_FENI, + I_FFREE, + I_FIADD, + I_FICOM, + I_FICOMP, + I_FIDIV, + I_FIDIVR, + I_FILD, + I_FIMUL, + I_FINCSTP, + I_FINIT, + I_FIST, + I_FISTP, + I_FISUB, + I_FISUBR, + I_FLD, + I_FLD1, + I_FLDCW, + I_FLDENV, + I_FLDL2E, + I_FLDL2T, + I_FLDLG2, + I_FLDLN2, + I_FLDPI, + I_FLDZ, + I_FMUL, + I_FMULP, + I_FNCLEX, + I_FNDISI, + I_FNENI, + I_FNINIT, + I_FNOP, + I_FNSAVE, + I_FNSTCW, + I_FNSTENV, + I_FNSTSW, + I_FPATAN, + I_FPREM, + I_FPREM1, + I_FPTAN, + I_FRNDINT, + I_FRSTOR, + I_FSAVE, + I_FSCALE, + I_FSETPM, + I_FSIN, + I_FSINCOS, + I_FSQRT, + I_FST, + I_FSTCW, + I_FSTENV, + I_FSTP, + I_FSTSW, + I_FSUB, + I_FSUBP, + I_FSUBR, + I_FSUBRP, + I_FTST, + I_FUCOM, + I_FUCOMI, + I_FUCOMIP, + I_FUCOMP, + I_FUCOMPP, + I_FXAM, + I_FXCH, + I_FXRSTOR, + I_FXSAVE, + I_FXTRACT, + I_FYL2X, + I_FYL2XP1, + I_HLT, + I_IBTS, + I_ICEBP, + I_IDIV, + I_IMUL, + I_IN, + I_INC, + I_INCBIN, + I_INSB, + I_INSD, + I_INSW, + I_INT, + I_INT01, + I_INT03, + I_INT1, + I_INT3, + I_INTO, + I_INVD, + I_INVLPG, + I_IRET, + I_IRETD, + I_IRETW, + I_JCXZ, + I_JECXZ, + I_JMP, + I_LAHF, + I_LAR, + I_LDMXCSR, + I_LDS, + I_LEA, + I_LEAVE, + I_LES, + I_LFS, + I_LGDT, + I_LGS, + I_LIDT, + I_LLDT, + I_LMSW, + I_LOADALL, + I_LOADALL286, + I_LODSB, + I_LODSD, + I_LODSW, + I_LOOP, + I_LOOPE, + I_LOOPNE, + I_LOOPNZ, + I_LOOPZ, + I_LSL, + I_LSS, + I_LTR, + I_MASKMOVQ, + I_MAXPS, + I_MAXSS, + I_MINPS, + I_MINSS, + I_MOV, + I_MOVAPS, + I_MOVD, + I_MOVHLPS, + I_MOVHPS, + I_MOVLHPS, + I_MOVLPS, + I_MOVMSKPS, + I_MOVNTPS, + I_MOVNTQ, + I_MOVQ, + I_MOVSB, + I_MOVSD, + I_MOVSS, + I_MOVSW, + I_MOVSX, + I_MOVUPS, + I_MOVZX, + I_MUL, + I_MULPS, + I_MULSS, + I_NEG, + I_NOP, + I_NOT, + I_OR, + I_ORPS, + I_OUT, + I_OUTSB, + I_OUTSD, + I_OUTSW, + I_PACKSSDW, + I_PACKSSWB, + I_PACKUSWB, + I_PADDB, + I_PADDD, + I_PADDSB, + I_PADDSIW, + I_PADDSW, + I_PADDUSB, + I_PADDUSW, + I_PADDW, + I_PAND, + I_PANDN, + I_PAVEB, + I_PAVGB, + I_PAVGUSB, + I_PAVGW, + I_PCMPEQB, + I_PCMPEQD, + I_PCMPEQW, + I_PCMPGTB, + I_PCMPGTD, + I_PCMPGTW, + I_PDISTIB, + I_PEXTRW, + I_PF2ID, + I_PFACC, + I_PFADD, + I_PFCMPEQ, + I_PFCMPGE, + I_PFCMPGT, + I_PFMAX, + I_PFMIN, + I_PFMUL, + I_PFRCP, + I_PFRCPIT1, + I_PFRCPIT2, + I_PFRSQIT1, + I_PFRSQRT, + I_PFSUB, + I_PFSUBR, + I_PI2FD, + I_PINSRW, + I_PMACHRIW, + I_PMADDWD, + I_PMAGW, + I_PMAXSW, + I_PMAXUB, + I_PMINSW, + I_PMINUB, + I_PMOVMSKB, + I_PMULHRIW, + I_PMULHRWA, + I_PMULHRWC, + I_PMULHUW, + I_PMULHW, + I_PMULLW, + I_PMVGEZB, + I_PMVLZB, + I_PMVNZB, + I_PMVZB, + I_POP, + I_POPA, + I_POPAD, + I_POPAW, + I_POPF, + I_POPFD, + I_POPFW, + I_POR, + I_PREFETCH, + I_PREFETCHNTA, + I_PREFETCHT0, + I_PREFETCHT1, + I_PREFETCHT2, + I_PREFETCHW, + I_PSADBW, + I_PSHUFW, + I_PSLLD, + I_PSLLQ, + I_PSLLW, + I_PSRAD, + I_PSRAW, + I_PSRLD, + I_PSRLQ, + I_PSRLW, + I_PSUBB, + I_PSUBD, + I_PSUBSB, + I_PSUBSIW, + I_PSUBSW, + I_PSUBUSB, + I_PSUBUSW, + I_PSUBW, + I_PUNPCKHBW, + I_PUNPCKHDQ, + I_PUNPCKHWD, + I_PUNPCKLBW, + I_PUNPCKLDQ, + I_PUNPCKLWD, + I_PUSH, + I_PUSHA, + I_PUSHAD, + I_PUSHAW, + I_PUSHF, + I_PUSHFD, + I_PUSHFW, + I_PXOR, + I_RCL, + I_RCPPS, + I_RCPSS, + I_RCR, + I_RDMSR, + I_RDPMC, + I_RDSHR, + I_RDTSC, + I_RESB, + I_RESD, + I_RESQ, + I_REST, + I_RESW, + I_RET, + I_RETF, + I_RETN, + I_ROL, + I_ROR, + I_RSDC, + I_RSLDT, + I_RSM, + I_RSQRTPS, + I_RSQRTSS, + I_SAHF, + I_SAL, + I_SALC, + I_SAR, + I_SBB, + I_SCASB, + I_SCASD, + I_SCASW, + I_SFENCE, + I_SGDT, + I_SHL, + I_SHLD, + I_SHR, + I_SHRD, + I_SHUFPS, + I_SIDT, + I_SLDT, + I_SMI, + I_SMINT, + I_SMINTOLD, + I_SMSW, + I_SQRTPS, + I_SQRTSS, + I_STC, + I_STD, + I_STI, + I_STMXCSR, + I_STOSB, + I_STOSD, + I_STOSW, + I_STR, + I_SUB, + I_SUBPS, + I_SUBSS, + I_SVDC, + I_SVLDT, + I_SVTS, + I_SYSCALL, + I_SYSENTER, + I_SYSEXIT, + I_SYSRET, + I_TEST, + I_UCOMISS, + I_UD1, + I_UD2, + I_UMOV, + I_UNPCKHPS, + I_UNPCKLPS, + I_VERR, + I_VERW, + I_WAIT, + I_WBINVD, + I_WRMSR, + I_WRSHR, + I_XADD, + I_XBTS, + I_XCHG, + I_XLATB, + I_XOR, + I_XORPS, + I_CMOVcc, + I_Jcc, + I_SETcc +}; + +#define MAX_INSLEN 11 diff --git a/mobius/src/drivers/kdebug/insnsn.c b/mobius/src/drivers/kdebug/insnsn.c new file mode 100644 index 0000000..dbfadd2 --- /dev/null +++ b/mobius/src/drivers/kdebug/insnsn.c @@ -0,0 +1,474 @@ +/* This file is auto-generated from insns.dat by insns.pl - don't edit it */ + +/* This file in included by names.c */ + +#include + +static wchar_t *insn_names[] = { + L"aaa", + L"aad", + L"aam", + L"aas", + L"adc", + L"add", + L"addps", + L"addss", + L"and", + L"andnps", + L"andps", + L"arpl", + L"bound", + L"bsf", + L"bsr", + L"bswap", + L"bt", + L"btc", + L"btr", + L"bts", + L"call", + L"cbw", + L"cdq", + L"clc", + L"cld", + L"cli", + L"clts", + L"cmc", + L"cmp", + L"cmpeqps", + L"cmpeqss", + L"cmpleps", + L"cmpless", + L"cmpltps", + L"cmpltss", + L"cmpneqps", + L"cmpneqss", + L"cmpnleps", + L"cmpnless", + L"cmpnltps", + L"cmpnltss", + L"cmpordps", + L"cmpordss", + L"cmpps", + L"cmpsb", + L"cmpsd", + L"cmpss", + L"cmpsw", + L"cmpunordps", + L"cmpunordss", + L"cmpxchg", + L"cmpxchg486", + L"cmpxchg8b", + L"comiss", + L"cpuid", + L"cvtpi2ps", + L"cvtps2pi", + L"cvtsi2ss", + L"cvtss2si", + L"cvttps2pi", + L"cvttss2si", + L"cwd", + L"cwde", + L"daa", + L"das", + L"db", + L"dd", + L"dec", + L"div", + L"divps", + L"divss", + L"dq", + L"dt", + L"dw", + L"emms", + L"enter", + L"equ", + L"f2xm1", + L"fabs", + L"fadd", + L"faddp", + L"fbld", + L"fbstp", + L"fchs", + L"fclex", + L"fcmovb", + L"fcmovbe", + L"fcmove", + L"fcmovnb", + L"fcmovnbe", + L"fcmovne", + L"fcmovnu", + L"fcmovu", + L"fcom", + L"fcomi", + L"fcomip", + L"fcomp", + L"fcompp", + L"fcos", + L"fdecstp", + L"fdisi", + L"fdiv", + L"fdivp", + L"fdivr", + L"fdivrp", + L"femms", + L"feni", + L"ffree", + L"fiadd", + L"ficom", + L"ficomp", + L"fidiv", + L"fidivr", + L"fild", + L"fimul", + L"fincstp", + L"finit", + L"fist", + L"fistp", + L"fisub", + L"fisubr", + L"fld", + L"fld1", + L"fldcw", + L"fldenv", + L"fldl2e", + L"fldl2t", + L"fldlg2", + L"fldln2", + L"fldpi", + L"fldz", + L"fmul", + L"fmulp", + L"fnclex", + L"fndisi", + L"fneni", + L"fninit", + L"fnop", + L"fnsave", + L"fnstcw", + L"fnstenv", + L"fnstsw", + L"fpatan", + L"fprem", + L"fprem1", + L"fptan", + L"frndint", + L"frstor", + L"fsave", + L"fscale", + L"fsetpm", + L"fsin", + L"fsincos", + L"fsqrt", + L"fst", + L"fstcw", + L"fstenv", + L"fstp", + L"fstsw", + L"fsub", + L"fsubp", + L"fsubr", + L"fsubrp", + L"ftst", + L"fucom", + L"fucomi", + L"fucomip", + L"fucomp", + L"fucompp", + L"fxam", + L"fxch", + L"fxrstor", + L"fxsave", + L"fxtract", + L"fyl2x", + L"fyl2xp1", + L"hlt", + L"ibts", + L"icebp", + L"idiv", + L"imul", + L"in", + L"inc", + L"incbin", + L"insb", + L"insd", + L"insw", + L"int", + L"int01", + L"int03", + L"int1", + L"int3", + L"into", + L"invd", + L"invlpg", + L"iret", + L"iretd", + L"iretw", + L"jcxz", + L"jecxz", + L"jmp", + L"lahf", + L"lar", + L"ldmxcsr", + L"lds", + L"lea", + L"leave", + L"les", + L"lfs", + L"lgdt", + L"lgs", + L"lidt", + L"lldt", + L"lmsw", + L"loadall", + L"loadall286", + L"lodsb", + L"lodsd", + L"lodsw", + L"loop", + L"loope", + L"loopne", + L"loopnz", + L"loopz", + L"lsl", + L"lss", + L"ltr", + L"maskmovq", + L"maxps", + L"maxss", + L"minps", + L"minss", + L"mov", + L"movaps", + L"movd", + L"movhlps", + L"movhps", + L"movlhps", + L"movlps", + L"movmskps", + L"movntps", + L"movntq", + L"movq", + L"movsb", + L"movsd", + L"movss", + L"movsw", + L"movsx", + L"movups", + L"movzx", + L"mul", + L"mulps", + L"mulss", + L"neg", + L"nop", + L"not", + L"or", + L"orps", + L"out", + L"outsb", + L"outsd", + L"outsw", + L"packssdw", + L"packsswb", + L"packuswb", + L"paddb", + L"paddd", + L"paddsb", + L"paddsiw", + L"paddsw", + L"paddusb", + L"paddusw", + L"paddw", + L"pand", + L"pandn", + L"paveb", + L"pavgb", + L"pavgusb", + L"pavgw", + L"pcmpeqb", + L"pcmpeqd", + L"pcmpeqw", + L"pcmpgtb", + L"pcmpgtd", + L"pcmpgtw", + L"pdistib", + L"pextrw", + L"pf2id", + L"pfacc", + L"pfadd", + L"pfcmpeq", + L"pfcmpge", + L"pfcmpgt", + L"pfmax", + L"pfmin", + L"pfmul", + L"pfrcp", + L"pfrcpit1", + L"pfrcpit2", + L"pfrsqit1", + L"pfrsqrt", + L"pfsub", + L"pfsubr", + L"pi2fd", + L"pinsrw", + L"pmachriw", + L"pmaddwd", + L"pmagw", + L"pmaxsw", + L"pmaxub", + L"pminsw", + L"pminub", + L"pmovmskb", + L"pmulhriw", + L"pmulhrwa", + L"pmulhrwc", + L"pmulhuw", + L"pmulhw", + L"pmullw", + L"pmvgezb", + L"pmvlzb", + L"pmvnzb", + L"pmvzb", + L"pop", + L"popa", + L"popad", + L"popaw", + L"popf", + L"popfd", + L"popfw", + L"por", + L"prefetch", + L"prefetchnta", + L"prefetcht0", + L"prefetcht1", + L"prefetcht2", + L"prefetchw", + L"psadbw", + L"pshufw", + L"pslld", + L"psllq", + L"psllw", + L"psrad", + L"psraw", + L"psrld", + L"psrlq", + L"psrlw", + L"psubb", + L"psubd", + L"psubsb", + L"psubsiw", + L"psubsw", + L"psubusb", + L"psubusw", + L"psubw", + L"punpckhbw", + L"punpckhdq", + L"punpckhwd", + L"punpcklbw", + L"punpckldq", + L"punpcklwd", + L"push", + L"pusha", + L"pushad", + L"pushaw", + L"pushf", + L"pushfd", + L"pushfw", + L"pxor", + L"rcl", + L"rcpps", + L"rcpss", + L"rcr", + L"rdmsr", + L"rdpmc", + L"rdshr", + L"rdtsc", + L"resb", + L"resd", + L"resq", + L"rest", + L"resw", + L"ret", + L"retf", + L"retn", + L"rol", + L"ror", + L"rsdc", + L"rsldt", + L"rsm", + L"rsqrtps", + L"rsqrtss", + L"sahf", + L"sal", + L"salc", + L"sar", + L"sbb", + L"scasb", + L"scasd", + L"scasw", + L"sfence", + L"sgdt", + L"shl", + L"shld", + L"shr", + L"shrd", + L"shufps", + L"sidt", + L"sldt", + L"smi", + L"smint", + L"smintold", + L"smsw", + L"sqrtps", + L"sqrtss", + L"stc", + L"std", + L"sti", + L"stmxcsr", + L"stosb", + L"stosd", + L"stosw", + L"str", + L"sub", + L"subps", + L"subss", + L"svdc", + L"svldt", + L"svts", + L"syscall", + L"sysenter", + L"sysexit", + L"sysret", + L"test", + L"ucomiss", + L"ud1", + L"ud2", + L"umov", + L"unpckhps", + L"unpcklps", + L"verr", + L"verw", + L"wait", + L"wbinvd", + L"wrmsr", + L"wrshr", + L"xadd", + L"xbts", + L"xchg", + L"xlatb", + L"xor", + L"xorps" +}; + +/* Conditional instructions */ +static wchar_t *icn[] = { + L"cmov", + L"j", + L"set" +}; + +/* and the corresponding opcodes */ +static int ico[] = { + I_CMOVcc, + I_Jcc, + I_SETcc +}; diff --git a/mobius/src/drivers/kdebug/kdebug.c b/mobius/src/drivers/kdebug/kdebug.c new file mode 100644 index 0000000..2835cad --- /dev/null +++ b/mobius/src/drivers/kdebug/kdebug.c @@ -0,0 +1,722 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "../keyboard/british.h" +#include "nasm.h" +#include "insns.h" +#include "disasm.h" +#include "sync.h" + +/*! + * \ingroup drivers + * \defgroup kdebug Kernel debugger + * @{ + */ + +#define KSTACK_BOTTOM 0xc0009000 +#define KSTACK_TOP 0xc000b000 +#define USTACK_BOTTOM 0 +#define USTACK_TOP 0xc0000000 + +bool key_read; +wchar_t key; +device_t* keyboard; + +static const wchar_t* thread_states[] = +{ + L"THREAD_RUNNING", + L"THREAD_DELETED", + L"THREAD_WAIT_TIMEOUT", + L"THREAD_WAIT_HANDLE", + L"THREAD_WAIT_OBJECT", +}; + +static const wchar_t* commands[] = +{ + L"help", + L"ctx", + L"stk", + L"mods", + L"threads", + L"thread", + L"t", + L"go", + L"quit", + L"vmm", +}; + +thread_t* thr; +addr_t fault_addr; + +void dbgBreak() +{ + asm("int3"); +} + +bool in_debugger; + +bool dbgLookupSymbol(module_t *mod, void* sym, addr_t* address, SYMENT *syment) +{ + static SYMENT closest; + + IMAGE_DOS_HEADER* dos; + IMAGE_PE_HEADERS* pe; + IMAGE_SECTION_HEADER* sections; + SYMENT symbol; + int i; + addr_t addr; + size_t closest_diff; + bool found; + + dos = (IMAGE_DOS_HEADER*) mod->base; + pe = (IMAGE_PE_HEADERS*) ((dword) mod->base + dos->e_lfanew); + sections = IMAGE_FIRST_SECTION(pe); + + /*symbols = (SYMENT*) ((byte*) rawdata + + pe->FileHeader.PointerToSymbolTable);*/ + + if (mod->file) + fsSeek(mod->file, pe->FileHeader.PointerToSymbolTable); + else + return false; + + closest_diff = (addr_t) (dword) -1; + found = false; + for (i = 0; i < pe->FileHeader.NumberOfSymbols; i++) + { + fsRead(mod->file, &symbol, sizeof(symbol)); + + if (symbol.e_sclass == C_EXT || + symbol.e_sclass == C_STAT || + symbol.e_sclass == C_LABEL) + { + addr = mod->base + symbol.e_value; + if (symbol.e_scnum > 0) + addr += sections[symbol.e_scnum - 1].VirtualAddress; + + //wprintf(L"%d scnum = %d addr = %x\n", + //i, symbols[i].e_scnum, addr); + + if ((addr_t) sym >= addr && + (addr_t) sym - addr < closest_diff) + { + closest = symbol; + closest_diff = (addr_t) sym - addr; + found = true; + } + } + } + + if (found && address) + { + addr = mod->base + closest.e_value; + if (closest.e_scnum > 0) + addr += sections[closest.e_scnum - 1].VirtualAddress; + *address = addr; + } + + *syment = closest; + return found; +} + +char* dbgGetStringsTable(module_t *mod) +{ + IMAGE_DOS_HEADER *dos; + IMAGE_PE_HEADERS *pe; + IMAGE_SECTION_HEADER* sections; + SYMENT *symbols; + int i; + + dos = (IMAGE_DOS_HEADER*) mod->base; + pe = (IMAGE_PE_HEADERS*) (mod->base + dos->e_lfanew); + sections = IMAGE_FIRST_SECTION(pe); + + for (i = 0; i < pe->FileHeader.NumberOfSections; i++) + if (pe->FileHeader.PointerToSymbolTable >= sections[i].PointerToRawData && + pe->FileHeader.PointerToSymbolTable < + sections[i].PointerToRawData + sections[i].SizeOfRawData) + { + symbols = (SYMENT*) ((char*) mod->base + sections[i].VirtualAddress + + pe->FileHeader.PointerToSymbolTable - sections[i].PointerToRawData); + return (char*) (symbols + pe->FileHeader.NumberOfSymbols); + } + + return NULL; +} + +char* dbgGetSymbolName(void* strings, SYMENT* se) +{ + static char temp[9]; + + if (se->e.e.e_zeroes == 0) + { + if (se->e.e.e_offset) + return (char*) strings + se->e.e.e_offset; + else + return NULL; + } + else + { + strncpy(temp, se->e.e_name, 8); + return temp; + } +} + +module_t* dbgLookupModule(process_t* proc, addr_t addr) +{ + module_t* mod; + + for (mod = proc->mod_first; mod; mod = mod->next) + if (addr >= mod->base && addr < mod->base + mod->length) + return mod; + + return NULL; +} + +bool dbgIsValidEsp(process_t* proc, dword _esp) +{ + if ((_esp >= KSTACK_BOTTOM && _esp <= KSTACK_TOP - 4) || + _esp >= 0xf0000000 || + (proc->stack_end && _esp >= proc->stack_end && _esp < 0x80000000 - 4)) + return true; + else + return false; +} + +const wchar_t* dbgFormatAddress(dword flags, dword seg, dword ofs) +{ + static wchar_t str[50]; + if (flags & EFLAG_VM) + swprintf(str, L"%04x:%04x", seg, ofs); + else + swprintf(str, L"%08x", ofs); + return str; +} + +void dbgDumpStack(process_t* proc, dword _ebp) +{ + dword *pebp = (dword*) _ebp; + module_t* mod; + SYMENT sym; + char *strings, *name; + addr_t addr; + + _cputws(L"ebp\t\tReturn To\tModule\n"); + do + { + wprintf(L"%08x\t", (dword) pebp); + + if (dbgIsValidEsp(proc, (dword) pebp)) + { + wprintf(L"%08x\t", pebp[1]); + + if (proc) + { + mod = dbgLookupModule(proc, pebp[1]); + if (mod) + { + _cputws(mod->name); + if (dbgLookupSymbol(mod, (void*) pebp[1], &addr, &sym)) + { + strings = dbgGetStringsTable(mod); + name = dbgGetSymbolName(strings, &sym); + if (name) + wprintf(L"\t%S + 0x%x", name, pebp[1] - addr); + } + } + else + _cputws(L"(unknown)"); + } + + pebp = (dword*) *pebp; + } + + putwchar('\n'); + } while (dbgIsValidEsp(proc, (dword) pebp)); +} + +void dbgDumpModules(process_t* proc) +{ + module_t* mod; + + _cputws(L"Name\t\tBase\t\tLength\n"); + for (mod = proc->mod_first; mod; mod = mod->next) + wprintf(L"%s\t%08x\t%08x\n", mod->name, mod->base, mod->length); +} + +void dbgDumpThreads() +{ + thread_t *t; + context_t *c; + + for (t = thr_first; t; t = t->next) + { + c = thrContext(t); + wprintf(L"%d\t%s\t%s\n", + t->id, dbgFormatAddress(c->eflags, c->cs, c->eip), + thread_states[t->state]); + } +} + +void dbgDumpContext(const context_t* ctx) +{ + wprintf(L"EAX %08x\tEBX %08x\tECX %08x\tEDX %08x\n", + ctx->regs.eax, ctx->regs.ebx, ctx->regs.ecx, ctx->regs.edx); + wprintf(L"ESI %08x\tEDI %08x\tESP %08x\tEBP %08x\n", + /* note: ctx->regs.esp refers to kernel esp at time of pusha => ignored. + Use ctx->esp instead => pushed by interrupt */ + ctx->regs.esi, ctx->regs.edi, ctx->esp, ctx->regs.ebp); + wprintf(L" DS %08x\t ES %08x\t FS %08x\t GS %08x\t\n", + ctx->ds, ctx->es, ctx->fs, ctx->gs); + wprintf(L" CS %08x\t SS %08x\t\n", ctx->cs, ctx->ss); + wprintf(L"EIP %08x\t eflags %08x\tintr %08x\n", ctx->eip, ctx->eflags, ctx->intr); +} + +void dbgSwitchThreads(thread_t* t, context_t* ctx) +{ + module_t* mod; + handle_t* hnd; + + thr = t; + mod = dbgLookupModule(thr->process, ctx->eip); + if (ctx->eflags & EFLAG_TF && ctx->intr == EXCEPTION_DEBUG) + ; + /*wprintf(L"Step: %s (%s)\n", dbgFormatAddress(ctx->eflags, ctx->cs, ctx->eip), + mod ? mod->name : L"unknown module");*/ + else + { + wprintf(L"Thread %d: exception %d at %s (%s): address %08x\n", thr->id, ctx->intr, + dbgFormatAddress(ctx->eflags, ctx->cs, ctx->eip), + mod ? mod->name : L"unknown module", fault_addr); + wprintf(L"State: %s ", thread_states[thr->state]); + + switch (thr->state) + { + case THREAD_RUNNING: + case THREAD_DELETED: + putwchar('\n'); + break; + case THREAD_WAIT_TIMEOUT: + wprintf(L"at %d, in %d ms\n", thr->wait.time, thr->wait.time - sysUpTime()); + break; + case THREAD_WAIT_HANDLE: + hnd = hndHandle(thr->wait.handle.handles[0]); + wprintf(L"for %p (%s:%d)\n", hnd, hnd->file, hnd->line); + break; + //case THREAD_WAIT_OBJECT: + //wprintf(L"for %p\n", thr->wait.object); + //break; + } + } +} + +wint_t getwchar() +{ + dword key; + size_t len = sizeof(key); + + if (keyboard == NULL) + return 0; + + do + { + key = 0; + + if (devReadSync(keyboard, 0, &key, &len) != 0) + return 0; + + } while ((wchar_t) key == 0); + + return key; +} + +wchar_t* _getws(wchar_t* buffer) +{ + wchar_t *buf, ch; + + buf = buffer; + do + { + ch = getwchar(); + + switch (ch) + { + case '\n': + putwchar('\n'); + *buf = 0; + break; + case '\b': + if (buf > buffer) + { + buf--; + _cputws(L"\b \b"); + } + break; + default: + putwchar(ch); + *buf = ch; + buf++; + break; + } + } while (ch != '\n'); + + return buffer; +} + +//! Bugger me! This function's huge! I can't believe the amount of effort +//! required to extract line & file information from COFF debugging info. +void dbgLookupLineNumber(addr_t base, void* rawdata, void* symbol, + unsigned* line, char** file) +{ + IMAGE_DOS_HEADER* dos; + IMAGE_PE_HEADERS* pe; + IMAGE_SECTION_HEADER* sections; + int i, j; + LINENO *line_numbers, *found, *func; + SYMENT *se, *symbols, *filename; + AUXENT *aux; + char *strings; + + *line = 0; + *file = NULL; + + dos = (IMAGE_DOS_HEADER*) base; + pe = (IMAGE_PE_HEADERS*) ((dword) base + dos->e_lfanew); + sections = IMAGE_FIRST_SECTION(pe); + + found = NULL; + for (i = 0; i < pe->FileHeader.NumberOfSections; i++) + { + if (strncmp(sections[i].Name, ".text", sizeof(sections[i].Name)) == 0) + { + line_numbers = malloc(sizeof(LINENO) * sections[i].NumberOfLinenumbers); + memcpy(line_numbers, + (byte*) rawdata + sections[i].PointerToLinenumbers, + sizeof(LINENO) * sections[i].NumberOfLinenumbers); + + if (line_numbers) + { + found = NULL; + func = NULL; + for (j = 0; j < sections[i].NumberOfLinenumbers; j++) + { + if (line_numbers[j].l_lnno) + { + //wprintf(L"line %d\t%x\n", line_numbers[j].l_lnno, + //line_numbers[j].l_addr.l_paddr); + + if (line_numbers[j].l_addr.l_paddr >= (dword) symbol) + { + found = line_numbers + j; + break; + } + } + else + func = line_numbers + j; + //wprintf(L"function %d\n", line_numbers[j].l_addr.l_symndx); + } + + if (found) + break; + } + + free(line_numbers); + break; + } + } + + if (found) + { + *line = found->l_lnno - 1; + symbols = (SYMENT*) ((byte*) rawdata + + pe->FileHeader.PointerToSymbolTable); + + strings = (char*) (symbols + pe->FileHeader.NumberOfSymbols); + + se = symbols + func->l_addr.l_symndx; + if (func) + { + aux = NULL; + for (i = func->l_addr.l_symndx; i < pe->FileHeader.NumberOfSymbols; i++) + { + if (symbols[i].e_sclass == C_FCN) + { + aux = (AUXENT*) (symbols + i + 1); + *line += aux->x_sym.x_misc.x_lnsz.x_lnno; + break; + } + } + + if (aux) + { + filename = symbols + func->l_addr.l_symndx; + for (i = 0; i < pe->FileHeader.NumberOfSymbols; i++) + { + if (symbols[i].e_sclass == C_FILE) + filename = symbols + i; + + if (i >= func->l_addr.l_symndx) + break; + } + } + } + + free(line_numbers); + + if (filename->e_sclass == C_FILE) + { + aux = (AUXENT*) (filename + 1); + if (aux->x_file.x_n.x_zeroes == 0) + { + if (aux->x_file.x_n.x_offset) + *file = (char*) strings + aux->x_file.x_n.x_offset; + else + *file = NULL; + } + else + *file = aux->x_file.x_fname; + } + else + *file = dbgGetSymbolName(strings, filename); + } +} + +void dbgDumpVmm(process_t *proc) +{ + vm_area_t *area; + + wprintf(L"Low memory:\t%uKB\n", (pool_low.free_pages * PAGE_SIZE) / 1024); + wprintf(L"All memory:\t%uKB\n", (pool_all.free_pages * PAGE_SIZE) / 1024); + + wprintf(L"\tBlock\t\tStart\t\tEnd\t\t\tPages\n"); + for (area = proc->first_vm_area; area; area = area->next) + wprintf(L"%c\t%p\t%08x\t%08x\t%x\n", + //area->is_committed ? 'C' : '_', + ' ', + area, + area->start, + area->start + area->pages * PAGE_SIZE, + area->pages); +} + +int add_label(struct itemplate* p, insn* ins, wchar_t* str, int operand) +{ + SYMENT sym; + module_t *mod; + addr_t addr, realaddr; + char *name, *strings; + + addr = ins->oprs[operand].offset; + mod = dbgLookupModule(thr->process, addr); + + if (mod && dbgLookupSymbol(mod, (void*) addr, &realaddr, &sym)) + { + strings = dbgGetStringsTable(mod); + name = dbgGetSymbolName(strings, &sym); + if (addr == realaddr) + return swprintf(str, L"%S", name); + else + return swprintf(str, L"%S + 0x%x", name, addr - realaddr); + } + else + return swprintf(str, L"0x%x", addr); +} + +bool dbgAttach(thread_t* t, context_t* ctx, addr_t addr) +{ + static wchar_t buf[256]; + static int lastCommand; + + unsigned id; + int i; + module_t *mod; + //unsigned line; + char *name; + void* strings; + addr_t symaddr; + SYMENT sym; + + if (keyboard == NULL) + keyboard = devOpen(L"keyboard", NULL); + + t->suspend++; + enable(); + fault_addr = addr; + dbgSwitchThreads(t, ctx); + while (true) + { + if (memTranslate(thr->process->page_dir, (void*) ctx->eip)) + disasm((unsigned char*) ctx->eip, buf, 32, ctx->eip, true, 0); + else + wcscpy(buf, L"(disassembly unavailable)"); + + /*mod = dbgLookupModule(thr->process, ctx->eip); + if (mod) + { + //dbgLookupLineNumber(mod, (void*) ctx->eip, &line, &file); + //wprintf(L"%S:%d:\t", file, line); + + if (dbgLookupSymbol(mod, (void*) ctx->eip, &symaddr, &sym)) + { + strings = dbgGetStringsTable(mod); + name = dbgGetSymbolName(strings, &sym); + if (name) + wprintf(L"%S + 0x%x", name, ctx->eip - symaddr); + } + + _cputws(L"\n"); + }*/ + + wprintf(L"%s\t%s\n> ", + dbgFormatAddress(ctx->eflags, ctx->cs, ctx->eip), buf); + + _getws(buf); + + if (buf[0]) + { + for (i = 0; i < countof(commands); i++) + if (wcsicmp(buf, commands[i]) == 0) + break; + lastCommand = i; + } + else + i = lastCommand; + + switch (i) + { + case 0: + _cputws( + L"help\t\t" L"Help\n" + L"ctx\t\t" L"Dump context\n" + L"stk\t\t" L"Dump stack\n" + L"vmm\t\t" L"Dump process memory blocks\n" + L"mods\t\t" L"List modules\n" + L"threads\t" L"List all threads\n" + L"thread\t" L"Switch threads\n" + L"t\t\t\t" L"Single step\n" + L"go\t\t" L"Quit and continue thread\n" + L"quit\t\t" L"Terminate thread and quit\n"); + break; + case 1: + dbgDumpContext(ctx); + break; + case 2: + dbgDumpStack(thr->process, ctx->regs.ebp); + break; + case 3: + dbgDumpModules(thr->process); + break; + case 4: + dbgDumpThreads(); + break; + case 5: + _cputws(L"Thread id: "); + _getws(buf); + id = wcstol(buf, NULL, 10); + for (t = thr_first; t; t = t->next) + if (t->id == id) + { + in_debugger = false; + ctx->eflags &= ~EFLAG_TF; + dbgInvoke(t, thrContext(t), 0); + return true; + } + + wprintf(L"Thread %d not found\n", id); + break; + case 6: + ctx->eflags |= EFLAG_TF; + in_debugger = false; + t->suspend--; + return true; + case 7: + ctx->eflags &= ~EFLAG_TF; + in_debugger = false; + t->suspend--; + return true; + case 8: + if (thr->id == 0) + halt(0); + else + procTerminate(thr->process); + in_debugger = false; + t->suspend--; + return true; + case 9: + dbgDumpVmm(thr->process); + break; + default: + wprintf(L"%s: invalid command\n", buf); + break; + } + } +} + +bool dbgRequest(device_t* dev, request_t* req) +{ + byte k; + wchar_t* temp; + + //wprintf(L"<%c%c>", req->code / 256, req->code % 256); + switch (req->code) + { + case DEV_ISR: + k = in(0x60); + + if (k < countof(keys)) + { + key = keys[k]; + key_read = true; + + if (key == 27 && !in_debugger) + dbgInvoke(thrCurrent(), thrContext(thrCurrent()), 0); + } + + return true; + + case DEV_OPEN: + case DEV_CLOSE: + hndSignal(req->event, true); + return true; + + case DEV_WRITE: + //wprintf(L"Write: %p, %d bytes\n", req->params.write.buffer, req->params.write.length); + temp = (wchar_t*) malloc(req->params.write.length + sizeof(wchar_t)); + memcpy(temp, req->params.write.buffer, req->params.write.length); + temp[req->params.write.length / sizeof(wchar_t)] = 0; + _cputws(temp); + free(temp); + hndSignal(req->event, true); + return true; + } + + req->result = ENOTIMPL; + return false; +} + +bool STDCALL drvInit(driver_t* drv) +{ + device_t* dev; + init_sync(); + + dev = hndAlloc(sizeof(device_t), NULL); + dev->driver = drv; + dev->request = dbgRequest; + devRegister(L"debugger", dev, NULL); + //devRegisterIrq(dev, 1, true); + return true; +} + +//@} \ No newline at end of file diff --git a/mobius/src/drivers/kdebug/kdebug.d b/mobius/src/drivers/kdebug/kdebug.d new file mode 100644 index 0000000..20ca6a9 --- /dev/null +++ b/mobius/src/drivers/kdebug/kdebug.d @@ -0,0 +1,22 @@ +kdebug.o: kdebug.c f:\Projects\mobius\include\kernel/kernel.h \ + f:\Projects\mobius\include\kernel/i386.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h f:\Projects\mobius\include\os/os.h \ + f:\Projects\mobius\include\kernel/thread.h \ + f:\Projects\mobius\include\kernel/proc.h \ + f:\Projects\mobius\include\kernel/obj.h \ + f:\Projects\mobius\include\os/pe.h \ + f:\Projects\mobius\include\kernel/handle.h \ + f:\Projects\mobius\include\kernel/driver.h \ + f:\Projects\mobius\include\os/devreq.h \ + f:\Projects\mobius\include\kernel/sys.h \ + f:\Projects\mobius\include\kernel/memory.h \ + f:\Projects\mobius\include\errno.h f:\Projects\mobius\include\stdio.h \ + f:\Projects\mobius\include\stdarg.h f:\Projects\mobius\include\io.h \ + f:\Projects\mobius\include\conio.h \ + f:\Projects\mobius\include\stdlib.h \ + f:\Projects\mobius\include\malloc.h \ + f:\Projects\mobius\include\string.h \ + f:\Projects\mobius\include\os/keyboard.h \ + f:\Projects\mobius\include\os/coff.h ../keyboard/british.h nasm.h \ + insnsi.h insns.h disasm.h sync.h diff --git a/mobius/src/drivers/kdebug/kdebug.def b/mobius/src/drivers/kdebug/kdebug.def new file mode 100644 index 0000000..7465887 --- /dev/null +++ b/mobius/src/drivers/kdebug/kdebug.def @@ -0,0 +1,12 @@ +NAME kdebug.dll +EXPORTS + dbgAttach + dbgBreak + dbgDumpContext + dbgDumpModules + dbgDumpStack + dbgDumpThreads + dbgFormatAddress + dbgIsValidEsp + dbgLookupModule + getwchar diff --git a/mobius/src/drivers/kdebug/kdebug.dsp b/mobius/src/drivers/kdebug/kdebug.dsp new file mode 100644 index 0000000..9c891ae --- /dev/null +++ b/mobius/src/drivers/kdebug/kdebug.dsp @@ -0,0 +1,149 @@ +# Microsoft Developer Studio Project File - Name="kdebug" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=kdebug - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "kdebug.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "kdebug.mak" CFG="kdebug - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "kdebug - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "kdebug - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "kdebug - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f kdebug.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "kdebug.exe" +# PROP BASE Bsc_Name "kdebug.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\kdebug.dll" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "kdebug - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "kdebug___Win32_Debug" +# PROP BASE Intermediate_Dir "kdebug___Win32_Debug" +# PROP BASE Cmd_Line "NMAKE /f kdebug.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "kdebug.exe" +# PROP BASE Bsc_Name "kdebug.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "kdebug___Win32_Debug" +# PROP Intermediate_Dir "kdebug___Win32_Debug" +# PROP Cmd_Line "set" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\kdebug.dll" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "kdebug - Win32 Release" +# Name "kdebug - Win32 Debug" + +!IF "$(CFG)" == "kdebug - Win32 Release" + +!ELSEIF "$(CFG)" == "kdebug - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\disasm.c +# End Source File +# Begin Source File + +SOURCE=.\insnsd.c +# End Source File +# Begin Source File + +SOURCE=.\kdebug.c +# End Source File +# Begin Source File + +SOURCE=.\kdebug.def +# End Source File +# Begin Source File + +SOURCE=.\sync.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\..\..\include\os\coff.h +# End Source File +# Begin Source File + +SOURCE=.\disasm.h +# End Source File +# Begin Source File + +SOURCE=.\insns.h +# End Source File +# Begin Source File + +SOURCE=.\insnsi.h +# End Source File +# Begin Source File + +SOURCE=.\nasm.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\include\os\pe.h +# End Source File +# Begin Source File + +SOURCE=.\sync.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/kdebug/kdebug.exp b/mobius/src/drivers/kdebug/kdebug.exp new file mode 100644 index 0000000..109a0a0 --- /dev/null +++ b/mobius/src/drivers/kdebug/kdebug.exp Binary files differ diff --git a/mobius/src/drivers/kdebug/kdebug.plg b/mobius/src/drivers/kdebug/kdebug.plg new file mode 100644 index 0000000..e537c9c --- /dev/null +++ b/mobius/src/drivers/kdebug/kdebug.plg @@ -0,0 +1,17 @@ + + +
+

Build Log

+

+--------------------Configuration: kdebug - Win32 Debug-------------------- +

+ +make: Nothing to be done for `all'. + + + +

Results

+kdebug.dll - 0 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/drivers/kdebug/names.c b/mobius/src/drivers/kdebug/names.c new file mode 100644 index 0000000..0968edd --- /dev/null +++ b/mobius/src/drivers/kdebug/names.c @@ -0,0 +1,28 @@ +/* names.c included source file defining instruction and register + * names for the Netwide [Dis]Assembler + * + * The Netwide Assembler is copyright (C) 1996 Simon Tatham and + * Julian Hall. All rights reserved. The software is + * redistributable under the licence given in the file "Licence" + * distributed in the NASM archive. + */ + +static wchar_t *reg_names[] = { /* register names, as strings */ + L"ah", L"al", L"ax", L"bh", L"bl", L"bp", L"bx", L"ch", L"cl", + L"cr0", L"cr2", L"cr3", L"cr4", L"cs", L"cx", L"dh", L"di", L"dl", L"dr0", + L"dr1", L"dr2", L"dr3", L"dr6", L"dr7", L"ds", L"dx", L"eax", L"ebp", + L"ebx", L"ecx", L"edi", L"edx", L"es", L"esi", L"esp", L"fs", L"gs", + L"mm0", L"mm1", L"mm2", L"mm3", L"mm4", L"mm5", L"mm6", L"mm7", L"si", + L"sp", L"ss", L"st0", L"st1", L"st2", L"st3", L"st4", L"st5", L"st6", + L"st7", L"tr3", L"tr4", L"tr5", L"tr6", L"tr7", + L"xmm0", L"xmm1", L"xmm2", L"xmm3", L"xmm4", L"xmm5", L"xmm6", L"xmm7" +}; + +static wchar_t *conditions[] = { /* condition code names */ + L"a", L"ae", L"b", L"be", L"c", L"e", L"g", L"ge", L"l", L"le", L"na", L"nae", + L"nb", L"nbe", L"nc", L"ne", L"ng", L"nge", L"nl", L"nle", L"no", L"np", + L"ns", L"nz", L"o", L"p", L"pe", L"po", L"s", L"z" +}; + +/* Instruction names automatically generated from insns.dat */ +#include "insnsn.c" diff --git a/mobius/src/drivers/kdebug/nasm.h b/mobius/src/drivers/kdebug/nasm.h new file mode 100644 index 0000000..240d2d4 --- /dev/null +++ b/mobius/src/drivers/kdebug/nasm.h @@ -0,0 +1,842 @@ +/* nasm.h main header file for the Netwide Assembler: inter-module interface + * + * The Netwide Assembler is copyright (C) 1996 Simon Tatham and + * Julian Hall. All rights reserved. The software is + * redistributable under the licence given in the file "Licence" + * distributed in the NASM archive. + * + * initial version: 27/iii/95 by Simon Tatham + */ + +#ifndef NASM_NASM_H +#define NASM_NASM_H + +#define NASM_MAJOR_VER 0 +#define NASM_MINOR_VER 98 +#define NASM_VER "0.98" + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef FALSE +#define FALSE 0 /* comes in handy */ +#endif +#ifndef TRUE +#define TRUE 1 +#endif + +#define NO_SEG -1L /* null segment value */ +#define SEG_ABS 0x40000000L /* mask for far-absolute segments */ + +#ifndef FILENAME_MAX +#define FILENAME_MAX 256 +#endif + +/* + * Name pollution problems: on Digital UNIX pulls in some + * strange hardware header file which sees fit to define R_SP. We + * undefine it here so as not to break the enum below. + */ +#ifdef R_SP +#undef R_SP +#endif + +/* + * We must declare the existence of this structure type up here, + * since we have to reference it before we define it... + */ +struct ofmt; + +/* + * ------------------------- + * Error reporting functions + * ------------------------- + */ + +/* + * An error reporting function should look like this. + */ +typedef void (*efunc) (int severity, char *fmt, ...); + +/* + * These are the error severity codes which get passed as the first + * argument to an efunc. + */ + +#define ERR_WARNING 0 /* warn only: no further action */ +#define ERR_NONFATAL 1 /* terminate assembly after phase */ +#define ERR_FATAL 2 /* instantly fatal: exit with error */ +#define ERR_PANIC 3 /* internal error: panic instantly + * and dump core for reference */ +#define ERR_MASK 0x0F /* mask off the above codes */ +#define ERR_NOFILE 0x10 /* don't give source file name/line */ +#define ERR_USAGE 0x20 /* print a usage message */ +#define ERR_PASS1 0x80 /* only print this error on pass one */ + +/* + * These codes define specific types of suppressible warning. + */ +#define ERR_WARN_MNP 0x0100 /* macro-num-parameters warning */ +#define ERR_WARN_OL 0x0200 /* orphan label (no colon, and + * alone on line) */ +#define ERR_WARN_NOV 0x0300 /* numeric overflow */ +#define ERR_WARN_MASK 0xFF00 /* the mask for this feature */ +#define ERR_WARN_SHR 8 /* how far to shift right */ +#define ERR_WARN_MAX 3 /* the highest numbered one */ + +/* + * ----------------------- + * Other function typedefs + * ----------------------- + */ + +/* + * A label-lookup function should look like this. + */ +typedef int (*lfunc) (char *label, long *segment, long *offset); + +/* + * And a label-definition function like this. The boolean parameter + * `is_norm' states whether the label is a `normal' label (which + * should affect the local-label system), or something odder like + * an EQU or a segment-base symbol, which shouldn't. + */ +typedef void (*ldfunc) (char *label, long segment, long offset, char *special, + int is_norm, int isextrn, struct ofmt *ofmt, + efunc error); + +/* + * List-file generators should look like this: + */ +typedef struct { + /* + * Called to initialise the listing file generator. Before this + * is called, the other routines will silently do nothing when + * called. The `char *' parameter is the file name to write the + * listing to. + */ + void (*init) (char *, efunc); + + /* + * Called to clear stuff up and close the listing file. + */ + void (*cleanup) (void); + + /* + * Called to output binary data. Parameters are: the offset; + * the data; the data type. Data types are similar to the + * output-format interface, only OUT_ADDRESS will _always_ be + * displayed as if it's relocatable, so ensure that any non- + * relocatable address has been converted to OUT_RAWDATA by + * then. Note that OUT_RAWDATA+0 is a valid data type, and is a + * dummy call used to give the listing generator an offset to + * work with when doing things like uplevel(LIST_TIMES) or + * uplevel(LIST_INCBIN). + */ + void (*output) (long, void *, unsigned long); + + /* + * Called to send a text line to the listing generator. The + * `int' parameter is LIST_READ or LIST_MACRO depending on + * whether the line came directly from an input file or is the + * result of a multi-line macro expansion. + */ + void (*line) (int, char *); + + /* + * Called to change one of the various levelled mechanisms in + * the listing generator. LIST_INCLUDE and LIST_MACRO can be + * used to increase the nesting level of include files and + * macro expansions; LIST_TIMES and LIST_INCBIN switch on the + * two binary-output-suppression mechanisms for large-scale + * pseudo-instructions. + * + * LIST_MACRO_NOLIST is synonymous with LIST_MACRO except that + * it indicates the beginning of the expansion of a `nolist' + * macro, so anything under that level won't be expanded unless + * it includes another file. + */ + void (*uplevel) (int); + + /* + * Reverse the effects of uplevel. + */ + void (*downlevel) (int); +} ListGen; + +/* + * The expression evaluator must be passed a scanner function; a + * standard scanner is provided as part of nasmlib.c. The + * preprocessor will use a different one. Scanners, and the + * token-value structures they return, look like this. + * + * The return value from the scanner is always a copy of the + * `t_type' field in the structure. + */ +struct tokenval { + int t_type; + long t_integer, t_inttwo; + char *t_charptr; +}; +typedef int (*scanner) (void *private_data, struct tokenval *tv); + +/* + * Token types returned by the scanner, in addition to ordinary + * ASCII character values, and zero for end-of-string. + */ +enum { /* token types, other than chars */ + TOKEN_INVALID = -1, /* a placeholder value */ + TOKEN_EOS = 0, /* end of string */ + TOKEN_EQ = '=', TOKEN_GT = '>', TOKEN_LT = '<', /* aliases */ + TOKEN_ID = 256, TOKEN_NUM, TOKEN_REG, TOKEN_INSN, /* major token types */ + TOKEN_ERRNUM, /* numeric constant with error in */ + TOKEN_HERE, TOKEN_BASE, /* $ and $$ */ + TOKEN_SPECIAL, /* BYTE, WORD, DWORD, FAR, NEAR, etc */ + TOKEN_PREFIX, /* A32, O16, LOCK, REPNZ, TIMES, etc */ + TOKEN_SHL, TOKEN_SHR, /* << and >> */ + TOKEN_SDIV, TOKEN_SMOD, /* // and %% */ + TOKEN_GE, TOKEN_LE, TOKEN_NE, /* >=, <= and <> (!= is same as <>) */ + TOKEN_DBL_AND, TOKEN_DBL_OR, TOKEN_DBL_XOR, /* &&, || and ^^ */ + TOKEN_SEG, TOKEN_WRT, /* SEG and WRT */ + TOKEN_FLOAT /* floating-point constant */ +}; + +typedef struct { + long segment; + long offset; + int known; +} loc_t; + +/* + * Expression-evaluator datatype. Expressions, within the + * evaluator, are stored as an array of these beasts, terminated by + * a record with type==0. Mostly, it's a vector type: each type + * denotes some kind of a component, and the value denotes the + * multiple of that component present in the expression. The + * exception is the WRT type, whose `value' field denotes the + * segment to which the expression is relative. These segments will + * be segment-base types, i.e. either odd segment values or SEG_ABS + * types. So it is still valid to assume that anything with a + * `value' field of zero is insignificant. + */ +typedef struct { + long type; /* a register, or EXPR_xxx */ + long value; /* must be >= 32 bits */ +} expr; + +/* + * The evaluator can also return hints about which of two registers + * used in an expression should be the base register. See also the + * `operand' structure. + */ +struct eval_hints { + int base; + int type; +}; + +/* + * The actual expression evaluator function looks like this. When + * called, it expects the first token of its expression to already + * be in `*tv'; if it is not, set tv->t_type to TOKEN_INVALID and + * it will start by calling the scanner. + * + * If a forward reference happens during evaluation, the evaluator + * must set `*fwref' to TRUE if `fwref' is non-NULL. + * + * `critical' is non-zero if the expression may not contain forward + * references. The evaluator will report its own error if this + * occurs; if `critical' is 1, the error will be "symbol not + * defined before use", whereas if `critical' is 2, the error will + * be "symbol undefined". + * + * If `critical' has bit 4 set (in addition to its main value: 0x11 + * and 0x12 correspond to 1 and 2) then an extended expression + * syntax is recognised, in which relational operators such as =, < + * and >= are accepted, as well as low-precedence logical operators + * &&, ^^ and ||. + * + * If `hints' is non-NULL, it gets filled in with some hints as to + * the base register in complex effective addresses. + */ +typedef expr *(*evalfunc) (scanner sc, void *scprivate, struct tokenval *tv, + int *fwref, int critical, efunc error, + struct eval_hints *hints); + +/* + * Special values for expr->type. ASSUMPTION MADE HERE: the number + * of distinct register names (i.e. possible "type" fields for an + * expr structure) does not exceed 124 (EXPR_REG_START through + * EXPR_REG_END). + */ +#define EXPR_REG_START 1 +#define EXPR_REG_END 124 +#define EXPR_UNKNOWN 125L /* for forward references */ +#define EXPR_SIMPLE 126L +#define EXPR_WRT 127L +#define EXPR_SEGBASE 128L + +/* + * Preprocessors ought to look like this: + */ +typedef struct { + /* + * Called at the start of a pass; given a file name, the number + * of the pass, an error reporting function, an evaluator + * function, and a listing generator to talk to. + */ + void (*reset) (char *, int, efunc, evalfunc, ListGen *); + + /* + * Called to fetch a line of preprocessed source. The line + * returned has been malloc'ed, and so should be freed after + * use. + */ + char *(*getline) (void); + + /* + * Called at the end of a pass. + */ + void (*cleanup) (void); +} Preproc; + +/* + * ---------------------------------------------------------------- + * Some lexical properties of the NASM source language, included + * here because they are shared between the parser and preprocessor + * ---------------------------------------------------------------- + */ + +/* + * isidstart matches any character that may start an identifier, and isidchar + * matches any character that may appear at places other than the start of an + * identifier. E.g. a period may only appear at the start of an identifier + * (for local labels), whereas a number may appear anywhere *but* at the + * start. + */ + +#define isidstart(c) ( isalpha(c) || (c)=='_' || (c)=='.' || (c)=='?' \ + || (c)=='@' ) +#define isidchar(c) ( isidstart(c) || isdigit(c) || (c)=='$' || (c)=='#' \ + || (c)=='~' ) + +/* Ditto for numeric constants. */ + +#define isnumstart(c) ( isdigit(c) || (c)=='$' ) +#define isnumchar(c) ( isalnum(c) ) + +/* This returns the numeric value of a given 'digit'. */ + +#define numvalue(c) ((c)>='a' ? (c)-'a'+10 : (c)>='A' ? (c)-'A'+10 : (c)-'0') + +/* + * Data-type flags that get passed to listing-file routines. + */ +enum { + LIST_READ, LIST_MACRO, LIST_MACRO_NOLIST, LIST_INCLUDE, + LIST_INCBIN, LIST_TIMES +}; + +/* + * ----------------------------------------------------------- + * Format of the `insn' structure returned from `parser.c' and + * passed into `assemble.c' + * ----------------------------------------------------------- + */ + +/* + * Here we define the operand types. These are implemented as bit + * masks, since some are subsets of others; e.g. AX in a MOV + * instruction is a special operand type, whereas AX in other + * contexts is just another 16-bit register. (Also, consider CL in + * shift instructions, DX in OUT, etc.) + */ + +/* size, and other attributes, of the operand */ +#define BITS8 0x00000001L +#define BITS16 0x00000002L +#define BITS32 0x00000004L +#define BITS64 0x00000008L /* FPU only */ +#define BITS80 0x00000010L /* FPU only */ +#define FAR 0x00000020L /* grotty: this means 16:16 or */ + /* 16:32, like in CALL/JMP */ +#define NEAR 0x00000040L +#define SHORT 0x00000080L /* and this means what it says :) */ + +#define SIZE_MASK 0x000000FFL /* all the size attributes */ +#define NON_SIZE (~SIZE_MASK) + +#define TO 0x00000100L /* reverse effect in FADD, FSUB &c */ +#define COLON 0x00000200L /* operand is followed by a colon */ + +/* type of operand: memory reference, register, etc. */ +#define MEMORY 0x00204000L +#define REGISTER 0x00001000L /* register number in 'basereg' */ +#define IMMEDIATE 0x00002000L + +#define REGMEM 0x00200000L /* for r/m, ie EA, operands */ +#define REGNORM 0x00201000L /* 'normal' reg, qualifies as EA */ +#define REG8 0x00201001L +#define REG16 0x00201002L +#define REG32 0x00201004L +#define MMXREG 0x00201008L /* MMX registers */ +#define XMMREG 0x00201010L /* XMM Katmai reg */ +#define FPUREG 0x01000000L /* floating point stack registers */ +#define FPU0 0x01000800L /* FPU stack register zero */ + +/* special register operands: these may be treated differently */ +#define REG_SMASK 0x00070000L /* a mask for the following */ +#define REG_ACCUM 0x00211000L /* accumulator: AL, AX or EAX */ +#define REG_AL 0x00211001L /* REG_ACCUM | BITSxx */ +#define REG_AX 0x00211002L /* ditto */ +#define REG_EAX 0x00211004L /* and again */ +#define REG_COUNT 0x00221000L /* counter: CL, CX or ECX */ +#define REG_CL 0x00221001L /* REG_COUNT | BITSxx */ +#define REG_CX 0x00221002L /* ditto */ +#define REG_ECX 0x00221004L /* another one */ +#define REG_DX 0x00241002L +#define REG_SREG 0x00081002L /* any segment register */ +#define REG_CS 0x01081002L /* CS */ +#define REG_DESS 0x02081002L /* DS, ES, SS (non-CS 86 registers) */ +#define REG_FSGS 0x04081002L /* FS, GS (386 extended registers) */ +#define REG_CDT 0x00101004L /* CRn, DRn and TRn */ +#define REG_CREG 0x08101004L /* CRn */ +#define REG_CR4 0x08101404L /* CR4 (Pentium only) */ +#define REG_DREG 0x10101004L /* DRn */ +#define REG_TREG 0x20101004L /* TRn */ + +/* special type of EA */ +#define MEM_OFFS 0x00604000L /* simple [address] offset */ + +/* special type of immediate operand */ +#define ONENESS 0x00800000L /* so UNITY == IMMEDIATE | ONENESS */ +#define UNITY 0x00802000L /* for shift/rotate instructions */ + +/* + * Next, the codes returned from the parser, for registers and + * instructions. + */ + +enum { /* register names */ + R_AH = EXPR_REG_START, R_AL, R_AX, R_BH, R_BL, R_BP, R_BX, R_CH, + R_CL, R_CR0, R_CR2, R_CR3, R_CR4, R_CS, R_CX, R_DH, R_DI, R_DL, + R_DR0, R_DR1, R_DR2, R_DR3, R_DR6, R_DR7, R_DS, R_DX, R_EAX, + R_EBP, R_EBX, R_ECX, R_EDI, R_EDX, R_ES, R_ESI, R_ESP, R_FS, + R_GS, R_MM0, R_MM1, R_MM2, R_MM3, R_MM4, R_MM5, R_MM6, R_MM7, + R_SI, R_SP, R_SS, R_ST0, R_ST1, R_ST2, R_ST3, R_ST4, R_ST5, + R_ST6, R_ST7, R_TR3, R_TR4, R_TR5, R_TR6, R_TR7, + R_XMM0, R_XMM1, R_XMM2, R_XMM3, R_XMM4, R_XMM5, R_XMM6, R_XMM7, REG_ENUM_LIMIT +}; + +/* Instruction names automatically generated from insns.dat */ +#include "insnsi.h" + +/* max length of any instruction, register name etc. */ +#if MAX_INSLEN > 9 +#define MAX_KEYWORD MAX_INSLEN +#else +#define MAX_KEYWORD 9 +#endif + +enum { /* condition code names */ + C_A, C_AE, C_B, C_BE, C_C, C_E, C_G, C_GE, C_L, C_LE, C_NA, C_NAE, + C_NB, C_NBE, C_NC, C_NE, C_NG, C_NGE, C_NL, C_NLE, C_NO, C_NP, + C_NS, C_NZ, C_O, C_P, C_PE, C_PO, C_S, C_Z +}; + +/* + * Note that because segment registers may be used as instruction + * prefixes, we must ensure the enumerations for prefixes and + * register names do not overlap. + */ +enum { /* instruction prefixes */ + PREFIX_ENUM_START = REG_ENUM_LIMIT, + P_A16 = PREFIX_ENUM_START, P_A32, P_LOCK, P_O16, P_O32, P_REP, P_REPE, + P_REPNE, P_REPNZ, P_REPZ, P_TIMES +}; + +enum { /* extended operand types */ + EOT_NOTHING, EOT_DB_STRING, EOT_DB_NUMBER +}; + +enum { /* special EA flags */ + EAF_BYTEOFFS = 1, /* force offset part to byte size */ + EAF_WORDOFFS = 2, /* force offset part to [d]word size */ + EAF_TIMESTWO = 4 /* really do EAX*2 not EAX+EAX */ +}; + +enum { /* values for `hinttype' */ + EAH_NOHINT = 0, /* no hint at all - our discretion */ + EAH_MAKEBASE = 1, /* try to make given reg the base */ + EAH_NOTBASE = 2 /* try _not_ to make reg the base */ +}; + +typedef struct { /* operand to an instruction */ + long type; /* type of operand */ + int addr_size; /* 0 means default; 16; 32 */ + int basereg, indexreg, scale; /* registers and scale involved */ + int hintbase, hinttype; /* hint as to real base register */ + long segment; /* immediate segment, if needed */ + long offset; /* any immediate number */ + long wrt; /* segment base it's relative to */ + int eaflags; /* special EA flags */ + int opflags; /* see OPFLAG_* defines below */ +} operand; + +#define OPFLAG_FORWARD 1 /* operand is a forward reference */ +#define OPFLAG_EXTERN 2 /* operand is an external reference */ + +typedef struct extop { /* extended operand */ + struct extop *next; /* linked list */ + long type; /* defined above */ + char *stringval; /* if it's a string, then here it is */ + int stringlen; /* ... and here's how long it is */ + long segment; /* if it's a number/address, then... */ + long offset; /* ... it's given here ... */ + long wrt; /* ... and here */ +} extop; + +#define MAXPREFIX 4 + +typedef struct { /* an instruction itself */ + char *label; /* the label defined, or NULL */ + int prefixes[MAXPREFIX]; /* instruction prefixes, if any */ + int nprefix; /* number of entries in above */ + int opcode; /* the opcode - not just the string */ + int condition; /* the condition code, if Jcc/SETcc */ + int operands; /* how many operands? 0-3 + * (more if db et al) */ + operand oprs[3]; /* the operands, defined as above */ + extop *eops; /* extended operands */ + int eops_float; /* true if DD and floating */ + long times; /* repeat count (TIMES prefix) */ + int forw_ref; /* is there a forward reference? */ +} insn; + +enum geninfo { GI_SWITCH }; +/* + * ------------------------------------------------------------ + * The data structure defining an output format driver, and the + * interfaces to the functions therein. + * ------------------------------------------------------------ + */ + +struct ofmt { + /* + * This is a short (one-liner) description of the type of + * output generated by the driver. + */ + char *fullname; + + /* + * This is a single keyword used to select the driver. + */ + char *shortname; + + /* + * this is reserved for out module specific help. + * It is set to NULL in all the out modules but is not implemented + * in the main program + */ + char *helpstring; + + /* + * this is a pointer to the first element of the debug information + */ + struct dfmt **debug_formats; + + /* + * and a pointer to the element that is being used + * note: this is set to the default at compile time and changed if the + * -F option is selected. If developing a set of new debug formats for + * an output format, be sure to set this to whatever default you want + * + */ + struct dfmt *current_dfmt; + + /* + * This, if non-NULL, is a NULL-terminated list of `char *'s + * pointing to extra standard macros supplied by the object + * format (e.g. a sensible initial default value of __SECT__, + * and user-level equivalents for any format-specific + * directives). + */ + char **stdmac; + + /* + * This procedure is called at the start of an output session. + * It tells the output format what file it will be writing to, + * what routine to report errors through, and how to interface + * to the label manager and expression evaluator if necessary. + * It also gives it a chance to do other initialisation. + */ + void (*init) (FILE *fp, efunc error, ldfunc ldef, evalfunc eval); + + /* + * This procedure is called to pass generic information to the + * object file. The first parameter gives the information type + * (currently only command line switches) + * and the second parameter gives the value. This function returns + * 1 if recognized, 0 if unrecognized + */ + int (*setinfo)(enum geninfo type, char **string); + + /* + * This procedure is called by assemble() to write actual + * generated code or data to the object file. Typically it + * doesn't have to actually _write_ it, just store it for + * later. + * + * The `type' argument specifies the type of output data, and + * usually the size as well: its contents are described below. + */ + void (*output) (long segto, void *data, unsigned long type, + long segment, long wrt); + + /* + * This procedure is called once for every symbol defined in + * the module being assembled. It gives the name and value of + * the symbol, in NASM's terms, and indicates whether it has + * been declared to be global. Note that the parameter "name", + * when passed, will point to a piece of static storage + * allocated inside the label manager - it's safe to keep using + * that pointer, because the label manager doesn't clean up + * until after the output driver has. + * + * Values of `is_global' are: 0 means the symbol is local; 1 + * means the symbol is global; 2 means the symbol is common (in + * which case `offset' holds the _size_ of the variable). + * Anything else is available for the output driver to use + * internally. + * + * This routine explicitly _is_ allowed to call the label + * manager to define further symbols, if it wants to, even + * though it's been called _from_ the label manager. That much + * re-entrancy is guaranteed in the label manager. However, the + * label manager will in turn call this routine, so it should + * be prepared to be re-entrant itself. + * + * The `special' parameter contains special information passed + * through from the command that defined the label: it may have + * been an EXTERN, a COMMON or a GLOBAL. The distinction should + * be obvious to the output format from the other parameters. + */ + void (*symdef) (char *name, long segment, long offset, int is_global, + char *special); + + /* + * This procedure is called when the source code requests a + * segment change. It should return the corresponding segment + * _number_ for the name, or NO_SEG if the name is not a valid + * segment name. + * + * It may also be called with NULL, in which case it is to + * return the _default_ section number for starting assembly in. + * + * It is allowed to modify the string it is given a pointer to. + * + * It is also allowed to specify a default instruction size for + * the segment, by setting `*bits' to 16 or 32. Or, if it + * doesn't wish to define a default, it can leave `bits' alone. + */ + long (*section) (char *name, int pass, int *bits); + + /* + * This procedure is called to modify the segment base values + * returned from the SEG operator. It is given a segment base + * value (i.e. a segment value with the low bit set), and is + * required to produce in return a segment value which may be + * different. It can map segment bases to absolute numbers by + * means of returning SEG_ABS types. + * + * It should return NO_SEG if the segment base cannot be + * determined; the evaluator (which calls this routine) is + * responsible for throwing an error condition if that occurs + * in pass two or in a critical expression. + */ + long (*segbase) (long segment); + + /* + * This procedure is called to allow the output driver to + * process its own specific directives. When called, it has the + * directive word in `directive' and the parameter string in + * `value'. It is called in both assembly passes, and `pass' + * will be either 1 or 2. + * + * This procedure should return zero if it does not _recognise_ + * the directive, so that the main program can report an error. + * If it recognises the directive but then has its own errors, + * it should report them itself and then return non-zero. It + * should also return non-zero if it correctly processes the + * directive. + */ + int (*directive) (char *directive, char *value, int pass); + + /* + * This procedure is called before anything else - even before + * the "init" routine - and is passed the name of the input + * file from which this output file is being generated. It + * should return its preferred name for the output file in + * `outname', if outname[0] is not '\0', and do nothing to + * `outname' otherwise. Since it is called before the driver is + * properly initialised, it has to be passed its error handler + * separately. + * + * This procedure may also take its own copy of the input file + * name for use in writing the output file: it is _guaranteed_ + * that it will be called before the "init" routine. + * + * The parameter `outname' points to an area of storage + * guaranteed to be at least FILENAME_MAX in size. + */ + void (*filename) (char *inname, char *outname, efunc error); + + /* + * This procedure is called after assembly finishes, to allow + * the output driver to clean itself up and free its memory. + * Typically, it will also be the point at which the object + * file actually gets _written_. + * + * One thing the cleanup routine should always do is to close + * the output file pointer. + */ + void (*cleanup) (int debuginfo); +}; + +/* + * values for the `type' parameter to an output function. Each one + * must have the actual number of _bytes_ added to it. + * + * Exceptions are OUT_RELxADR, which denote an x-byte relocation + * which will be a relative jump. For this we need to know the + * distance in bytes from the start of the relocated record until + * the end of the containing instruction. _This_ is what is stored + * in the size part of the parameter, in this case. + * + * Also OUT_RESERVE denotes reservation of N bytes of BSS space, + * and the contents of the "data" parameter is irrelevant. + * + * The "data" parameter for the output function points to a "long", + * containing the address in question, unless the type is + * OUT_RAWDATA, in which case it points to an "unsigned char" + * array. + */ +#define OUT_RAWDATA 0x00000000UL +#define OUT_ADDRESS 0x10000000UL +#define OUT_REL2ADR 0x20000000UL +#define OUT_REL4ADR 0x30000000UL +#define OUT_RESERVE 0x40000000UL +#define OUT_TYPMASK 0xF0000000UL +#define OUT_SIZMASK 0x0FFFFFFFUL + +/* + * ------------------------------------------------------------ + * The data structure defining a debug format driver, and the + * interfaces to the functions therein. + * ------------------------------------------------------------ + */ + +struct dfmt { + + /* + * This is a short (one-liner) description of the type of + * output generated by the driver. + */ + char *fullname; + + /* + * This is a single keyword used to select the driver. + */ + char *shortname; + + + /* + * init - called initially to set up local pointer to object format, + * void pointer to implementation defined data, file pointer (which + * probably won't be used, but who knows?), and error function. + */ + void (*init) (struct ofmt * of, void * id, FILE * fp, efunc error); + + /* + * linenum - called any time there is output with a change of + * line number or file. + */ + void (*linenum) (const char * filename, long linenumber, long segto); + + /* + * debug_deflabel - called whenever a label is defined. Parameters + * are the same as to 'symdef()' in the output format. This function + * would be called before the output format version. + */ + + void (*debug_deflabel) (char * name, long segment, long offset, + int is_global, char * special); + /* + * debug_directive - called whenever a DEBUG directive other than 'LINE' + * is encountered. 'directive' contains the first parameter to the + * DEBUG directive, and params contains the rest. For example, + * 'DEBUG VAR _somevar:int' would translate to a call to this + * function with 'directive' equal to "VAR" and 'params' equal to + * "_somevar:int". + */ + void (*debug_directive) (const char * directive, const char * params); + + /* + * typevalue - called whenever the assembler wishes to register a type + * for the last defined label. This routine MUST detect if a type was + * already registered and not re-register it. + */ + void (*debug_typevalue) (long type); + + /* + * debug_output - called whenever output is required + * 'type' is the type of info required, and this is format-specific + */ + void (*debug_output) (int type, void *param); + + /* + * cleanup - called after processing of file is complete + */ + void (*cleanup) (void); + +}; +/* + * The type definition macros + * for debugging + * + * low 3 bits: reserved + * next 5 bits: type + * next 24 bits: number of elements for arrays (0 for labels) + */ + +#define TY_UNKNOWN 0x00 +#define TY_LABEL 0x08 +#define TY_BYTE 0x10 +#define TY_WORD 0x18 +#define TY_DWORD 0x20 +#define TY_FLOAT 0x28 +#define TY_QWORD 0x30 +#define TY_TBYTE 0x38 +#define TY_COMMON 0xE0 +#define TY_SEG 0xE8 +#define TY_EXTERN 0xF0 +#define TY_EQU 0xF8 + +#define TYM_TYPE(x) ((x) & 0xF8) +#define TYM_ELEMENTS(x) (((x) & 0xFFFFFF00) >> 8) + +#define TYS_ELEMENTS(x) ((x) << 8) +/* + * ----- + * Other + * ----- + */ + +/* + * This is a useful #define which I keep meaning to use more often: + * the number of elements of a statically defined array. + */ + +#define elements(x) ( sizeof(x) / sizeof(*(x)) ) + +#endif diff --git a/mobius/src/drivers/kdebug/sync.c b/mobius/src/drivers/kdebug/sync.c new file mode 100644 index 0000000..174bb84 --- /dev/null +++ b/mobius/src/drivers/kdebug/sync.c @@ -0,0 +1,110 @@ +/* sync.c the Netwide Disassembler synchronisation processing module + * + * The Netwide Assembler is copyright (C) 1996 Simon Tatham and + * Julian Hall. All rights reserved. The software is + * redistributable under the licence given in the file "Licence" + * distributed in the NASM archive. + */ + +#include +#include +#include + +#include "sync.h" + +#define SYNC_MAX 4096 /* max # of sync points */ + +/* + * This lot manages the current set of sync points by means of a + * heap (priority queue) structure. + */ + +static struct Sync { + unsigned long pos; + unsigned long length; +} *synx; +static int nsynx; + +void init_sync(void) +{ + /* + * I'd like to allocate an array of size SYNC_MAX, then write + * `synx--' which would allow numbering the array from one + * instead of zero without wasting memory. Sadly I don't trust + * this to work in 16-bit Large model, so it's staying the way + * it is. Btw, we don't care about freeing this array, since it + * has to last for the duration of the program and will then be + * auto-freed on exit. And I'm lazy ;-) + * + * Speaking of 16-bit Large model, that's also the reason I'm + * not declaring this array statically - by doing it + * dynamically I avoid problems with the total size of DGROUP + * in Borland C. + */ + synx = malloc((SYNC_MAX+1) * sizeof(*synx)); + if (!synx) + wprintf(L"ndisasm: not enough memory for sync array\n"); + nsynx = 0; +} + +void add_sync(unsigned long pos, unsigned long length) +{ + int i; + + if (nsynx == SYNC_MAX) + return; /* can't do anything - overflow */ + + nsynx++; + synx[nsynx].pos = pos; + synx[nsynx].length = length; + + for (i = nsynx; i > 1; i /= 2) { + if (synx[i/2].pos > synx[i].pos) { + struct Sync t; + t = synx[i/2]; /* structure copy */ + synx[i/2] = synx[i]; /* structure copy again */ + synx[i] = t; /* another structure copy */ + } + } +} + +unsigned long next_sync(unsigned long position, unsigned long *length) +{ + while (nsynx > 0 && synx[1].pos + synx[1].length <= position) { + int i, j; + struct Sync t; + t = synx[nsynx]; /* structure copy */ + synx[nsynx] = synx[1]; /* structure copy */ + synx[1] = t; /* ditto */ + + nsynx--; + + i = 1; + while (i*2 <= nsynx) { + j = i*2; + if (synx[j].pos < synx[i].pos && + (j+1 > nsynx || synx[j+1].pos > synx[j].pos)) { + t = synx[j]; /* structure copy */ + synx[j] = synx[i]; /* lots of these... */ + synx[i] = t; /* ...aren't there? */ + i = j; + } else if (j+1 <= nsynx && synx[j+1].pos < synx[i].pos) { + t = synx[j+1]; /* structure copy */ + synx[j+1] = synx[i]; /* structure copy */ + synx[i] = t; /* structure copy */ + i = j+1; + } else + break; + } + } + + if (nsynx > 0) { + if (length) + *length = synx[1].length; + return synx[1].pos; + } else { + if (length) + *length = 0L; + return ULONG_MAX; + } +} diff --git a/mobius/src/drivers/kdebug/sync.d b/mobius/src/drivers/kdebug/sync.d new file mode 100644 index 0000000..76e5b8e --- /dev/null +++ b/mobius/src/drivers/kdebug/sync.d @@ -0,0 +1,7 @@ +sync.o: sync.c f:\Projects\mobius\include\stdio.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h \ + f:\Projects\mobius\include\stdarg.h f:\Projects\mobius\include\io.h \ + f:\Projects\mobius\include\stdlib.h \ + f:\Projects\mobius\include\malloc.h \ + f:\Projects\mobius\include\limits.h sync.h diff --git a/mobius/src/drivers/kdebug/sync.h b/mobius/src/drivers/kdebug/sync.h new file mode 100644 index 0000000..ecb9201 --- /dev/null +++ b/mobius/src/drivers/kdebug/sync.h @@ -0,0 +1,16 @@ +/* sync.h header file for sync.c + * + * The Netwide Assembler is copyright (C) 1996 Simon Tatham and + * Julian Hall. All rights reserved. The software is + * redistributable under the licence given in the file "Licence" + * distributed in the NASM archive. + */ + +#ifndef NASM_SYNC_H +#define NASM_SYNC_H + +void init_sync(void); +void add_sync(unsigned long position, unsigned long length); +unsigned long next_sync(unsigned long position, unsigned long *length); + +#endif diff --git a/mobius/src/drivers/kdll/8390.h b/mobius/src/drivers/kdll/8390.h new file mode 100644 index 0000000..6016c5b --- /dev/null +++ b/mobius/src/drivers/kdll/8390.h @@ -0,0 +1,158 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Novell Eagle 2000 driver + * FILE: include/8390.h + * PURPOSE: National Semiconductor 8390 NIC definitions + */ +#ifndef __8390_H +#define __8390_H + +/* Page 0 register layout (PS1 = 0, PS0 = 0) */ +#define PG0_CR 0x00 /* Command Register (R/W) */ +#define PG0_CLDA0 0x01 /* Current Local DMA Address 0 (R) */ +#define PG0_PSTART 0x01 /* Page Start Register (W) */ +#define PG0_CLDA1 0x02 /* Current Local DMA Address 1 (R) */ +#define PG0_PSTOP 0x02 /* Page Stop Register (W) */ +#define PG0_BNRY 0x03 /* Boundary Pointer (R/W) */ +#define PG0_TSR 0x04 /* Transmit Status Register (R) */ +#define PG0_TPSR 0x04 /* Transmit Page Start Register (W) */ +#define PG0_NCR 0x05 /* Number of Collisions Register (R) */ +#define PG0_TBCR0 0x05 /* Transmit Byte Count Register 0 (W) */ +#define PG0_FIFO 0x06 /* FIFO (R) */ +#define PG0_TBCR1 0x06 /* Transmit Byte Count Register 1 (W) */ +#define PG0_ISR 0x07 /* Interrupt Status Register (R/W) */ +#define PG0_CRDA0 0x08 /* Current Remote DMA Address 0 (R) */ +#define PG0_RSAR0 0x08 /* Remote Start Address Register 0 (W) */ +#define PG0_CRDA1 0x09 /* Current Remote DMA Address 1 (R) */ +#define PG0_RSAR1 0x09 /* Remote Start Address Register 1 (W) */ +#define PG0_RBCR0 0x0A /* Remote Byte Count Register 0 (W) */ +#define PG0_RBCR1 0x0B /* Remote Byte Count Register 1 (W) */ +#define PG0_RSR 0x0C /* Receive Status Register (R) */ +#define PG0_RCR 0x0C /* Receive Configuration Register (W) */ +#define PG0_CNTR0 0x0D /* Tally Counter 0 (Frame Alignment Errors) (R) */ +#define PG0_TCR 0x0D /* Transmit Configuration Register (W) */ +#define PG0_CNTR1 0x0E /* Tally Counter 1 (CRC Errors) (R) */ +#define PG0_DCR 0x0E /* Data Configuration Register (W) */ +#define PG0_CNTR2 0x0F /* Tally Counter 2 (Missed Packet Errors) (R) */ +#define PG0_IMR 0x0F /* Interrupt Mask Register (W) */ + +/* Page 1 register layout (PS1 = 0, PS0 = 1) */ +#define PG1_CR 0x00 /* Command Register (R/W) */ +#define PG1_PAR 0x01 /* Physical Address Registers (6 registers) (R/W) */ +#define PG1_CURR 0x07 /* Current Page Register (R/W) */ +#define PG1_MAR 0x08 /* Multicast Address Registers (8 registers) (R/W) */ + +/* Page 2 register layout (PS1 = 1, PS0 = 0) */ +#define PG2_CR 0x00 /* Command Register (R/W) */ +#define PG2_PSTART 0x01 /* Page Start Register (R) */ +#define PG2_CLDA0 0x01 /* Current Local DMA Address 0 (W) */ +#define PG2_PSTOP 0x02 /* Page Stop Register (R) */ +#define PG2_CLDA1 0x02 /* Current Local DMA Address 1 (W) */ +#define PG2_RNPP 0x03 /* Remote Next Packet Pointer (R/W) */ +#define PG2_TPSR 0x04 /* Transmit Page Start Address (R) */ +#define PG2_LNPP 0x05 /* Local Next Packet Pointer (R/W) */ +#define PG2_AC1 0x06 /* Address Counter (Upper) (R/W) */ +#define PG2_AC0 0x07 /* Address Counter (Lower) (R/W) */ +#define PG2_RCR 0x0C /* Receive Configuration Register (R) */ +#define PG2_TCR 0x0D /* Transmit Configuration Register (R) */ +#define PG2_DCR 0x0E /* Data Configuration Register (R) */ +#define PG2_IMR 0x0F /* Interrupt Mask Register (R) */ + +/* Bits in PGX_CR - Command Register */ +#define CR_STP 0x01 /* Stop chip */ +#define CR_STA 0x02 /* Start chip */ +#define CR_TXP 0x04 /* Transmit a frame */ +#define CR_RD0 0x08 /* Remote read */ +#define CR_RD1 0x10 /* Remote write */ +#define CR_RD2 0x20 /* Abort/complete remote DMA */ +#define CR_PAGE0 0x00 /* Select page 0 of chip registers */ +#define CR_PAGE1 0x40 /* Select page 1 of chip registers */ +#define CR_PAGE2 0x80 /* Select page 2 of chip registers */ + +/* Bits in PG0_ISR - Interrupt Status Register */ +#define ISR_PRX 0x01 /* Packet received, no errors */ +#define ISR_PTX 0x02 /* Packet transmitted, no errors */ +#define ISR_RXE 0x04 /* Receive error */ +#define ISR_TXE 0x08 /* Transmit error */ +#define ISR_OVW 0x10 /* Overwrite warning */ +#define ISR_CNT 0x20 /* Counter overflow */ +#define ISR_RDC 0x40 /* Remote DMA complete */ +#define ISR_RST 0x80 /* Reset status */ + +/* Bits in PG0_TSR - Transmit Status Register */ +#define TSR_PTX 0x01h /* Packet transmitted without error */ +#define TSR_COL 0x04h /* Collided at least once */ +#define TSR_ABT 0x08h /* Collided 16 times and was dropped */ +#define TSR_CRS 0x10h /* Carrier sense lost */ +#define TSR_FU 0x20h /* Transmit FIFO Underrun */ +#define TSR_CDH 0x40h /* Collision detect heartbeat */ +#define TSR_OWC 0x80h /* Out of window collision */ + +/* Bits for PG0_RCR - Receive Configuration Register */ +#define RCR_SEP 0x01 /* Save error packets */ +#define RCR_AR 0x02 /* Accept runt packets */ +#define RCR_AB 0x04 /* Accept broadcasts */ +#define RCR_AM 0x08 /* Accept multicast */ +#define RCR_PRO 0x10 /* Promiscuous physical addresses */ +#define RCR_MON 0x20 /* Monitor mode */ + +/* Bits in PG0_RSR - Receive Status Register */ +#define RSR_PRX 0x01 /* Received packet intact */ +#define RSR_CRC 0x02 /* CRC error */ +#define RSR_FAE 0x04 /* Frame alignment error */ +#define RSR_FO 0x08 /* FIFO overrun */ +#define RSR_MPA 0x10 /* Missed packet */ +#define RSR_PHY 0x20 /* Physical/multicast address */ +#define RSR_DIS 0x40 /* Receiver disabled (monitor mode) */ +#define RSR_DFR 0x80 /* Deferring */ + +/* Bits in PG0_TCR - Transmit Configuration Register */ +#define TCR_CRC 0x01 /* Inhibit CRC, do not append CRC */ +#define TCR_LOOP 0x02 /* Set loopback mode */ +#define TCR_LB01 0x06 /* Encoded loopback control */ +#define TCR_ATD 0x08 /* Auto transmit disable */ +#define TCR_OFST 0x10 /* Collision offset enable */ + +/* Bits in PG0_DCR - Data Configuration Register */ +#define DCR_WTS 0x01 /* Word transfer mode selection */ +#define DCR_BOS 0x02 /* Byte order selection */ +#define DCR_LAS 0x04 /* Long address selection */ +#define DCR_LS 0x08 /* Loopback select (when 0) */ +#define DCR_ARM 0x10 /* Autoinitialize remote */ +#define DCR_FT00 0x00 /* Burst length selection (1 word/2 bytes) */ +#define DCR_FT01 0x20 /* burst length selection (2 words/4 bytes) */ +#define DCR_FT10 0x40 /* Burst length selection (4 words/8 bytes) */ +#define DCR_FT11 0x60 /* Burst length selection (6 words/12 bytes) */ + +/* Bits in PG0_IMR - Interrupt Mask Register */ +#define IMR_PRXE 0x01 /* Packet received interrupt enable */ +#define IMR_PTXE 0x02 /* Packet transmitted interrupt enable */ +#define IMR_RXEE 0x04 /* Receive error interrupt enable */ +#define IMR_TXEE 0x08 /* Transmit error interrupt enable */ +#define IMR_OVWE 0x10 /* Overwrite warning interrupt enable */ +#define IMR_CNTE 0x20 /* Counter overflow interrupt enable */ +#define IMR_RDCE 0x40 /* Remote DMA complete interrupt enable */ +#define IMR_ALLE 0x7F /* All interrupts enable */ + + +/* NIC prepended structure to a received packet */ +typedef struct _packet_hdr_t packet_hdr_t; +struct _packet_hdr_t +{ + byte Status; /* See RSR_* constants */ + byte NextPacket; /* Pointer to next packet in chain */ + word PacketLength; /* Length of packet including this header */ +}; + +/*#define NICDisableInterrupts(Adapter) \ + NdisRawWritePortUchar((Adapter)->IOBase + PG0_IMR, 0x00); + +#define NICEnableInterrupts(Adapter) \ + NdisRawWritePortUchar((Adapter)->IOBase + PG0_IMR, (Adapter)->InterruptMask); + +VOID MiniportHandleInterrupt( + IN NDIS_HANDLE MiniportAdapterContext);*/ + +#endif /* __8390_H */ + +/* EOF */ diff --git a/mobius/src/drivers/kdll/Makefile b/mobius/src/drivers/kdll/Makefile new file mode 100644 index 0000000..fab0c40 --- /dev/null +++ b/mobius/src/drivers/kdll/Makefile @@ -0,0 +1,8 @@ +TARGET= $(BIN)/kdll.drv +OBJS= common.o config.o \ + fat16.o folder.o main.o ne2000.o \ + pci.o ramdisk.o serial.o \ + wildcard.o +BASE= @$(BIN)\coffbase.txt,kdll + +include ../make.driver diff --git a/mobius/src/drivers/kdll/common.c b/mobius/src/drivers/kdll/common.c new file mode 100644 index 0000000..c34d9ba --- /dev/null +++ b/mobius/src/drivers/kdll/common.c @@ -0,0 +1,2 @@ +#define INITGUID +#include \ No newline at end of file diff --git a/mobius/src/drivers/kdll/config.cpp b/mobius/src/drivers/kdll/config.cpp new file mode 100644 index 0000000..933abb8 --- /dev/null +++ b/mobius/src/drivers/kdll/config.cpp @@ -0,0 +1,178 @@ +#include +#include +#include +#include +#include +#include +#include "config.h" + +config_t cfg_builtin = +{ + NULL, NULL, + L"System Default", + config_t::dispText, + 5000 +}; + +config_t *cfg_current = &cfg_builtin, *cfg_first = &cfg_builtin, *cfg_last; + +void ProcessKernelRcLine(const wchar_t* line, const wchar_t* setting, config_t* cfg) +{ + wprintf(L"[%s] %s = %s\n", cfg->name, line, setting); + + if (wcscmp(line, L"display") == 0) + { + if (wcsicmp(setting, L"gui") == 0) + cfg->display = config_t::dispGui; + else + cfg->display = config_t::dispText; + } + else if (wcscmp(line, L"timeout") == 0) + cfg->timeout = wcstol(setting, NULL, 10); +} + +bool ProcessKernelRcSection(IStream* strm, config_t* cfg) +{ + char ch; + wchar_t line[256], *buf, *setting; + bool comment = false; + + buf = line; + while (strm->Read(&ch, sizeof(ch))) + { + switch (ch) + { + case '\r': + break; + + case '\n': + *buf = '\0'; + + buf = wcschr(line, '#'); + if (buf) + *buf = '\0'; + + if (*line) + { + setting = wcschr(line, '='); + if (setting) + { + *setting = '\0'; + setting++; + } + else + setting = L"1"; + + for (buf = line; *buf; buf++) + if (iswupper(*buf)) + *buf = towlower(*buf); + + ProcessKernelRcLine(line, setting, cfg); + } + + buf = line; + comment = false; + break; + + case '#': + comment = true; + default: + if (buf < line + countof(line)) + { + *buf = ch; + buf++; + } + break; + + case '[': + if (!comment) + return true; + } + } + + return false; +} + +void ProcessKernelRc() +{ + IStream* strm; + wchar_t line[256], *buf; + char ch; + config_t *cfg, common; + bool finished = false, has_common = false; + + strm = (IStream*) fsOpen(L"/boot/kernelrc", IID_IStream); + if (!strm) + return; + + strm->SetIoMode(ioAnsi); + + //finished = !ProcessKernelRcSection(strm, &config); + + buf = line; + while (!finished && strm->Read(&ch, sizeof(ch))) + { + switch (ch) + { + case '\r': + case '[': + case ']': + break; + + case '\n': + *buf = '\0'; + + buf = wcschr(line, '#'); + if (buf) + *buf = '\0'; + + buf = line; + + if (line[0]) + { + if (!has_common) + { + //memset(&common, 0, sizeof(common)); + common = cfg_builtin; + wcscpy(common.name, line); + + if (!ProcessKernelRcSection(strm, &common)) + finished = true; + + has_common = true; + } + else + { + cfg = (config_t*) malloc(sizeof(config_t)); + *cfg = common; + wcsncpy(cfg->name, line, countof(cfg->name)); + cfg->next = NULL; + cfg->prev = cfg_last; + + if (cfg_last) + cfg_last->next = cfg; + + if (cfg_first == NULL) + cfg_current = cfg_first = cfg; + + cfg_last = cfg; + + if (!ProcessKernelRcSection(strm, cfg)) + finished = true; + } + } + + break; + + default: + if (buf < line + countof(line)) + { + *buf = ch; + buf++; + } + break; + } + } + + strm->Release(); +} \ No newline at end of file diff --git a/mobius/src/drivers/kdll/config.h b/mobius/src/drivers/kdll/config.h new file mode 100644 index 0000000..824f6de --- /dev/null +++ b/mobius/src/drivers/kdll/config.h @@ -0,0 +1,30 @@ +#ifndef __CONFIG_H +#define __CONFIG_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +typedef struct _config_t config_t; +struct _config_t +{ + config_t *prev, *next; + wchar_t name[40]; + enum { dispText, dispGui } display; + dword timeout; +}; + +extern config_t *cfg_current, *cfg_first, *cfg_last; + +void ProcessKernelRc(); +bool ProcessKernelRcSection(IStream* strm, config_t* cfg); +void ProcessKernelRcLine(const wchar_t* line, const wchar_t* setting, config_t* cfg); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/kdll/fat16.cpp b/mobius/src/drivers/kdll/fat16.cpp new file mode 100644 index 0000000..cda1839 --- /dev/null +++ b/mobius/src/drivers/kdll/fat16.cpp @@ -0,0 +1,569 @@ +#include +#include +#include "fat.h" +#include +#include +#include +#include + +#define FAT_BYTES 2 // FAT16 +// #define FAT_BYTES 4 // FAT32 (nyi) +#define CLUSTER_CACHE 1 + +#if 0 +#define TRACE wprintf +#else + +static int TRACE(...) +{ + return 0; +} + +#endif + +extern "C" bool wildcard(const wchar_t* str, const wchar_t* spec); + +struct folderitem_fat_t : folderitem_t +{ + folderitem_fat_t* next; + IUnknown* mount; + fat_dirent_t dirent; +}; + +class CFatFile : public IUnknown, public IStream +{ +protected: + folderitem_fat_t m_stat; + addr_t m_dwPosition; + byte* m_pCache; + dword m_dwCacheSize, m_dwCachePtr; + IBlockDevice* m_pDevice; + dword m_dwReadCluster; + fat_bootsector_t m_bpb; + bool m_bIsRoot; + + dword GetNextCluster(dword dwCluster); + bool ReadCluster(dword dwCluster, void* pBuf, size_t size); + + friend class CFatFolder; + +public: + CFatFile(IBlockDevice* pDev, const folderitem_fat_t* stat); + virtual ~CFatFile(); + + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + IMPLEMENT_IUNKNOWN(CFatFile); + + STDMETHOD_(size_t, Read) (void* pBuffer, size_t dwLength); + STDMETHOD_(size_t, Write) (const void* pBuffer, size_t dwLength); + STDMETHOD(SetIoMode)(dword mode); + STDMETHOD(IsReady)(); + STDMETHOD(Stat)(folderitem_t* buf); + STDMETHOD(Seek)(long offset, int origin); +}; + +class CFatFolder : public IUnknown, public IFolder +{ +public: + CFatFolder(IBlockDevice* pDev, const folderitem_fat_t* stat, bool bIsRoot); + virtual ~CFatFolder(); + + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + IMPLEMENT_IUNKNOWN(CFatFolder); + + STDMETHOD(FindFirst)(const wchar_t* spec, folderitem_t* buf); + STDMETHOD(FindNext)(folderitem_t* buf); + STDMETHOD(FindClose)(folderitem_t* pBuf); + STDMETHOD(Open)(folderitem_t* item, const wchar_t* params); + STDMETHOD(Mount)(const wchar_t* name, IUnknown* obj); + +protected: + CFatFile m_file; + folderitem_fat_t* m_item_first; + + void ScanDir(); +}; + +extern "C" IFolder* FatRoot_Create(IBlockDevice* pDevice) +{ + folderitem_fat_t buf; + memset(&buf, 0, sizeof(buf)); + buf.size = sizeof(buf); + return new CFatFolder(pDevice, &buf, true); +} + +/**************************************************************************** + * CFatFile * + ****************************************************************************/ +CFatFile::CFatFile(IBlockDevice* pDev, const folderitem_fat_t* stat) +{ + m_pDevice = pDev; + //IUnknown_AddRef(pDev); + pDev->AddRef(); + + memset(&m_bpb, 0, sizeof(m_bpb)); + //pDev->Seek(0, SEEK_SET); + //pDev->ReadFile(&m_bpb, sizeof(m_bpb)); + //IBlockDevice_BlockRead(pDev, 0, 1, &m_bpb); + pDev->BlockRead(0, 1, &m_bpb); + + m_stat = *stat; + m_dwReadCluster = (dword) -1; + m_bIsRoot = false; + m_dwCacheSize = m_bpb.nBytesPerSector * m_bpb.nSectorsPerCluster * + CLUSTER_CACHE; + m_dwCachePtr = (dword) -1; + m_pCache = (byte*) malloc(m_dwCacheSize); + m_refs = 0; +} + +CFatFile::~CFatFile() +{ + TRACE(L"[CFatFile] deleting\n"); + if (m_pCache) + free(m_pCache); + if (m_pDevice) + m_pDevice->Release(); + //IUnknown_Release(m_pDevice); +} + +HRESULT CFatFile::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IStream)) + { + AddRef(); + *ppvObject = (IStream*) this; + return S_OK; + } + else + return E_FAIL; +} + +size_t CFatFile::Read(void* pBuffer, size_t dwLength) +{ + size_t dwRead = 0; + int i; + + if (m_dwReadCluster == (dword) -1) + { + if (m_dwPosition == 0) + m_dwReadCluster = m_stat.dirent.nFirstCluster; + else + return 0; + } + + if (m_dwPosition + dwLength > m_stat.length) + dwLength = m_stat.length - m_dwPosition; + + while (dwRead < dwLength) + { + if (m_dwCachePtr >= m_dwCacheSize) + { + //TRACE(L"[clus = %x] ", m_dwReadCluster); + + if (m_dwReadCluster >= 0xFFF8) + { + m_dwPosition += dwRead; + m_dwCachePtr = (dword) -1; + return dwRead; + } + + if (!ReadCluster(m_dwReadCluster, m_pCache, m_dwCacheSize)) + { + TRACE(L"ReadCluster failed\n"); + m_dwPosition += dwRead; + m_dwCachePtr = (dword) -1; + return dwRead; + } + + m_dwCachePtr = 0; + m_dwReadCluster = GetNextCluster(m_dwReadCluster); + } + + //TRACE(L"{cache = %d} ", m_dwCacheSize - m_dwCachePtr); + i = min(m_dwCacheSize - m_dwCachePtr, dwLength - dwRead); + memcpy((byte*) pBuffer + dwRead, m_pCache + m_dwCachePtr, i); + m_dwCachePtr += i; + dwRead += i; + } + + m_dwPosition += dwLength; + return dwRead; +} + +size_t CFatFile::Write(const void* pBuffer, size_t dwLength) +{ + return 0; +} + +HRESULT CFatFile::SetIoMode(dword mode) +{ + return S_OK; +} + +HRESULT CFatFile::IsReady() +{ + return S_OK; +} + +HRESULT CFatFile::Stat(folderitem_t* buf) +{ + if (buf->size == sizeof(folderitem_fat_t)) + memcpy(buf, &m_stat, sizeof(folderitem_fat_t)); + else + *buf = m_stat; + + return S_OK; +} + +dword CFatFile::GetNextCluster(dword dwCluster) +{ + dword FATOffset, ThisFATSecNum, ThisFATEntOffset; + byte sector[512]; + + FATOffset = dwCluster * FAT_BYTES; + ThisFATSecNum = m_bpb.nReservedSectors + + (FATOffset / m_bpb.nBytesPerSector); + ThisFATEntOffset = FATOffset % m_bpb.nBytesPerSector; + + //m_pDevice->Seek(ThisFATSecNum, SEEK_SET); + //m_pDevice->ReadFile(sector, sizeof(sector)); + //IBlockDevice_BlockRead(m_pDevice, ThisFATSecNum, 1, sector); + m_pDevice->BlockRead(ThisFATSecNum, 1, sector); + return *(word*) (sector + ThisFATEntOffset); +} + +HRESULT CFatFile::Seek(long offset, int origin) +{ + return E_FAIL; +} + +bool CFatFile::ReadCluster(dword dwCluster, void* pBuf, size_t size) +{ + dword RootDirSectors, FirstDataSector, FirstSectorofCluster; + + if (m_bIsRoot) + RootDirSectors = 0; + else + RootDirSectors = + ((m_bpb.nRootDirectoryEntries * 32) + (m_bpb.nBytesPerSector - 1)) + / m_bpb.nBytesPerSector; + + FirstDataSector = m_bpb.nReservedSectors + + (m_bpb.nFatCount * m_bpb.nSectorsPerFat) + RootDirSectors; + + if (m_bIsRoot) + dwCluster += 2; + + FirstSectorofCluster = ((dwCluster - 2) * m_bpb.nSectorsPerCluster) + + FirstDataSector; + + //m_pDevice->Seek(FirstSectorofCluster, SEEK_SET); + //return m_pDevice->ReadFile(pBuf, size) == (int) size; + size /= 512; + //return IBlockDevice_BlockRead(m_pDevice, FirstSectorofCluster, size, pBuf) == size; + return m_pDevice->BlockRead(FirstSectorofCluster, size, pBuf) == size; +} + +/**************************************************************************** + * CFatFolder * + ****************************************************************************/ +CFatFolder::CFatFolder(IBlockDevice* pDev, const folderitem_fat_t* stat, bool bIsRoot) : + m_file(pDev, stat) +{ + m_refs = 0; + m_file.m_bIsRoot = bIsRoot; + m_item_first = NULL; + + if (bIsRoot) + m_file.m_stat.length = sizeof(fat_dirent_t) * m_file.m_bpb.nRootDirectoryEntries; +} + +CFatFolder::~CFatFolder() +{ + folderitem_fat_t *item, *next; + + for (item = m_item_first; item; item = next) + { + next = item->next; + + if (item->mount) + item->mount->Release(); + //IUnknown_Release(item->mount); + + item->mount = NULL; + free(item->name); + delete item; + } +} + +HRESULT CFatFolder::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IFolder)) + { + AddRef(); + *ppvObject = (IFolder*) this; + return S_OK; + } + else if (InlineIsEqualGUID(iid, IID_IStream)) + { + AddRef(); + *ppvObject = (IStream*) &m_file; + return S_OK; + } + else + return E_FAIL; +} + +HRESULT CFatFolder::FindFirst(const wchar_t* szSpec, folderitem_t* item) +{ + if (m_item_first == NULL) + ScanDir(); + + item->spec = wcsdup(szSpec); + item->u.find_handle = (dword) m_item_first; + TRACE(L"FindFirst %s\n", item->spec); + return S_OK; +} + +HRESULT CFatFolder::FindNext(folderitem_t* item) +{ + folderitem_fat_t *fitem = (folderitem_fat_t*) item->u.find_handle; + + if (fitem == NULL) + return E_FAIL; + else + { + while (fitem) + { + if (wildcard(fitem->name, item->spec)) + { + TRACE(L"[fat] item = %s spec = %s\n", fitem->name, item->spec); + item->u.find_handle = (dword) fitem->next; + + wcsncpy(item->name, fitem->name, item->name_max); + item->attributes = fitem->attributes; + item->length = fitem->length; + + if (item->size == sizeof(folderitem_fat_t)) + { + ((folderitem_fat_t*) item)->mount = fitem->mount; + ((folderitem_fat_t*) item)->next = fitem->next; + ((folderitem_fat_t*) item)->dirent = fitem->dirent; + } + + return S_OK; + } + + fitem = fitem->next; + item->u.find_handle = (dword) fitem; + } + + return E_FAIL; + } +} + +HRESULT CFatFolder::FindClose(folderitem_t* pBuf) +{ + //TRACE(L"FindClose\n"); + free((void*) pBuf->spec); + return S_OK; +} + +HRESULT CFatFolder::Open(folderitem_t* item, const wchar_t* params) +{ + folderitem_fat_t buf; + IUnknown* pFile; + wchar_t temp[MAX_PATH]; + + TRACE(L"[OpenChild] %s\n", item->name); + buf.size = sizeof(folderitem_fat_t); + buf.name = temp; + buf.name_max = countof(temp); + if (FAILED(FindFirst(item->name, &buf)) || + FAILED(FindNext(&buf))) + return E_FAIL; + + if (buf.mount) + { + TRACE(L"Found mount point %p\n", buf.mount); + pFile = buf.mount; + //IUnknown_AddRef(pFile); + pFile->AddRef(); + } + else if (buf.attributes & ATTR_DIRECTORY) + { + TRACE(L"Found dir at %x\n", buf.dirent.nFirstCluster); + pFile = new CFatFolder(m_file.m_pDevice, &buf, false); + } + else + { + TRACE(L"Found file at %x\n", buf.dirent.nFirstCluster); + pFile = new CFatFile(m_file.m_pDevice, &buf); + } + + //FindClose((FileFind*) &buf); + + if (item->size == sizeof(folderitem_fat_t)) + memcpy(item, &buf, sizeof(folderitem_fat_t)); + else + *item = buf; + + item->u.item_handle = pFile; + FindClose(&buf); + //return pFile; + return S_OK; +} + +HRESULT CFatFolder::Mount(const wchar_t* name, IUnknown* obj) +{ + folderitem_fat_t* item = new folderitem_fat_t; + + item->size = sizeof(folderitem_fat_t); + memset(item, 0, sizeof(item)); + item->name = wcsdup(name); + item->attributes = ATTR_DIRECTORY | ATTR_LINK; + item->length = 0; + item->mount = obj; + obj->AddRef(); + item->next = m_item_first; + m_item_first = item; + + return S_OK; +} + +void CFatFolder::ScanDir() +{ + union + { + fat_dirent_t dirent; + fat_lfnslot_t lfn; + }; + int i, j, count; + wchar_t name[MAX_PATH], temp[14], *nameptr; + + m_file.m_dwPosition = 0; + m_file.m_dwCachePtr = (dword) -1; + m_file.m_dwReadCluster = (dword) -1; + + count = 0; + while (1) + { + if (m_file.Read(&dirent, sizeof(dirent)) < sizeof(dirent)) + { + TRACE(L"End of file: %d\n", count); + return; + } + + if (dirent.szFilename[0] == 0) + { + TRACE(L"End of directory: %d\n", count); + return; + } + + if (dirent.szFilename[0] != 0xe5) + { + memset(name, 0, sizeof(name)); + + if ((dirent.nAttributes & ATTR_LONG_NAME) != ATTR_LONG_NAME) + { + for (i = 0; i < 8; i++) + { + if (dirent.szFilename[i] == ' ') + { + name[i] = 0; + break; + } + else if (iswupper(dirent.szFilename[i])) + name[i] = towlower(dirent.szFilename[i]); + else + name[i] = dirent.szFilename[i]; + } + + if (dirent.szExtension[0] != ' ') + { + wcscat(name, L"."); + + j = wcslen(name); + for (i = 0; i < 3; i++) + { + if (dirent.szExtension[i] == ' ') + { + name[i + j] = 0; + break; + } + else if (iswupper(dirent.szExtension[i])) + name[i + j] = towlower(dirent.szExtension[i]); + else + name[i + j] = dirent.szExtension[i]; + } + } + + //TRACE(L"short: name = \"%s\" (\"%s\")\n", name, item->spec); + } + else + { + while ((dirent.nAttributes & ATTR_LONG_NAME) + == ATTR_LONG_NAME) + { + //TRACE(L" ", dirent.szFilename[0]); + if (dirent.szFilename[0] != 0xe5) + { + memset(temp, 0, sizeof(temp)); + nameptr = temp; + + for (i = 0; i < 5; i++) + { + *nameptr = lfn.name0_4[i]; + nameptr++; + } + + for (i = 0; i < 6; i++) + { + *nameptr = lfn.name5_10[i]; + nameptr++; + } + + for (i = 0; i < 2; i++) + { + *nameptr = lfn.name11_12[i]; + nameptr++; + } + + i = wcslen(temp); + memmove(name + i, name, wcslen(name) * sizeof(wchar_t)); + memcpy(name, temp, i * sizeof(wchar_t)); + } + + if (m_file.Read(&dirent, sizeof(dirent)) < sizeof(dirent)) + { + TRACE(L"End of file (lfn): %d\n", count); + return; + } + } + + //TRACE(L"long: name = \"%s\" (\"%s\")\n", name, item->spec); + } + + //if (wildcard(name, item->spec)) + { + folderitem_fat_t* item; + //TRACE(L"Found item %s size = %d\n", name, dirent.dwFileSize); + + item = new folderitem_fat_t; + memset(item, 0, sizeof(item)); + item->size = sizeof(folderitem_fat_t); + item->name = wcsdup(name); + item->length = dirent.dwFileSize; + item->attributes = dirent.nAttributes; + item->dirent = dirent; + item->next = m_item_first; + m_item_first = item; + + count++; + } + } + } +} \ No newline at end of file diff --git a/mobius/src/drivers/kdll/fat16.tmp.cpp b/mobius/src/drivers/kdll/fat16.tmp.cpp new file mode 100644 index 0000000..91465cc --- /dev/null +++ b/mobius/src/drivers/kdll/fat16.tmp.cpp @@ -0,0 +1,514 @@ +#include +#include +#include "fat.h" +#include +#include +#include +#include + +#define FAT_BYTES 2 // FAT16 +// #define FAT_BYTES 4 // FAT32 (nyi) +#define CLUSTER_CACHE 1 + +#if 0 +#define TRACE wprintf +#else + +int TRACE(...) +{ + return 0; +} + +#endif + +extern "C" bool wildcard(const wchar_t* str, const wchar_t* spec); + +struct folderitem_fat_t : folderitem_t +{ + folderitem_fat_t* next; + IUnknown* mount; +}; + +class FatFile : public IUnknown, public IStream +{ +protected: + fat_filefind_t m_stat; + addr_t m_dwPosition; + byte* m_pCache; + dword m_dwCacheSize, m_dwCachePtr; + IBlockDevice* m_pDevice; + dword m_dwReadCluster; + fat_bootsector_t m_bpb; + bool m_bIsRoot; + + dword GetNextCluster(dword dwCluster); + bool ReadCluster(dword dwCluster, void* pBuf, size_t size); + + friend class FatFolder; + +public: + FatFile(IBlockDevice* pDev, const fat_filefind_t* stat); + virtual ~FatFile(); + + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + IMPLEMENT_IUNKNOWN; + + STDMETHOD_(size_t, Read) (void* pBuffer, size_t dwLength); + STDMETHOD_(size_t, Write) (const void* pBuffer, size_t dwLength); + STDMETHOD(SetIoMode)(dword mode); + STDMETHOD(IsReady)(); + STDMETHOD(Stat)(folderitem_t* buf); +}; + +class FatFolder : public IUnknown, public IFolder +{ +public: + FatFolder(IBlockDevice* pDev, const fat_filefind_t* stat, bool bIsRoot); + virtual ~FatFolder(); + + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + IMPLEMENT_IUNKNOWN; + + STDMETHOD(FindFirst)(const wchar_t* spec, folderitem_t* buf); + STDMETHOD(FindNext)(folderitem_t* buf); + STDMETHOD(FindClose)(folderitem_t* pBuf); + STDMETHOD(Open)(folderitem_t* item, const wchar_t* params); + STDMETHOD(Mount)(const wchar_t* name, IUnknown* obj); + +protected: + FatFile m_file; + folderitem_fat_t* m_item_first; + + void ScanDir(); +}; + +extern "C" IFolder* FatRoot_Create(IBlockDevice* pDevice) +{ + fat_filefind_t buf = + { + { + sizeof(buf), + NULL, + NULL, + NULL, + 0, + 0, + 0 + }, + { + "", + "", + 0, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + 0, 0, 0, 0 + } + }; + + return new FatFolder(pDevice, &buf, true); +} + +/**************************************************************************** + * FatFile * + ****************************************************************************/ +FatFile::FatFile(IBlockDevice* pDev, const fat_filefind_t* stat) +{ + m_pDevice = pDev; + IUnknown_AddRef(pDev); + + memset(&m_bpb, 0, sizeof(m_bpb)); + //pDev->Seek(0, SEEK_SET); + //pDev->ReadFile(&m_bpb, sizeof(m_bpb)); + IBlockDevice_BlockRead(pDev, 0, 1, &m_bpb); + + m_stat = *stat; + m_dwReadCluster = (dword) -1; + m_bIsRoot = false; + m_dwCacheSize = m_bpb.nBytesPerSector * m_bpb.nSectorsPerCluster * + CLUSTER_CACHE; + m_dwCachePtr = (dword) -1; + m_pCache = (byte*) malloc(m_dwCacheSize); +} + +FatFile::~FatFile() +{ + TRACE(L"[fatfile] deleting\n"); + if (m_pCache) + free(m_pCache); + if (m_pDevice) + IUnknown_Release(m_pDevice); +} + +HRESULT FatFile::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IStream)) + { + AddRef(); + *ppvObject = (IStream*) this; + return S_OK; + } + else + return E_FAIL; +} + +size_t FatFile::Read(void* pBuffer, size_t dwLength) +{ + size_t dwRead = 0; + int i; + + if (m_dwReadCluster == (dword) -1) + { + if (m_dwPosition == 0) + m_dwReadCluster = m_stat.dirent.nFirstCluster; + else + return 0; + } + + while (dwRead < dwLength) + { + if (m_dwCachePtr >= m_dwCacheSize) + { + TRACE(L"[clus = %x] ", m_dwReadCluster); + + if (m_dwReadCluster >= 0xFFF8) + { + m_dwPosition += dwRead; + m_dwCachePtr = (dword) -1; + return dwRead; + } + + if (!ReadCluster(m_dwReadCluster, m_pCache, m_dwCacheSize)) + { + TRACE(L"ReadCluster failed\n"); + m_dwPosition += dwRead; + m_dwCachePtr = (dword) -1; + return dwRead; + } + + m_dwCachePtr = 0; + m_dwReadCluster = GetNextCluster(m_dwReadCluster); + } + + TRACE(L"{cache = %d} ", m_dwCacheSize - m_dwCachePtr); + i = min(m_dwCacheSize - m_dwCachePtr, dwLength - dwRead); + memcpy((byte*) pBuffer + dwRead, m_pCache + m_dwCachePtr, i); + m_dwCachePtr += i; + dwRead += i; + } + + m_dwPosition += dwLength; + return dwRead; +} + +size_t FatFile::Write(const void* pBuffer, size_t dwLength) +{ + return 0; +} + +HRESULT FatFile::SetIoMode(dword mode) +{ + return S_OK; +} + +HRESULT FatFile::IsReady() +{ + return S_OK; +} + +HRESULT FatFile::Stat(folderitem_t* buf) +{ + if (buf->size == sizeof(fat_filefind_t)) + memcpy(buf, &m_stat, sizeof(fat_filefind_t)); + else + *buf = m_stat.ff; + + return S_OK; +} + +dword FatFile::GetNextCluster(dword dwCluster) +{ + dword FATOffset, ThisFATSecNum, ThisFATEntOffset; + byte sector[512]; + + FATOffset = dwCluster * FAT_BYTES; + ThisFATSecNum = m_bpb.nReservedSectors + + (FATOffset / m_bpb.nBytesPerSector); + ThisFATEntOffset = FATOffset % m_bpb.nBytesPerSector; + + //m_pDevice->Seek(ThisFATSecNum, SEEK_SET); + //m_pDevice->ReadFile(sector, sizeof(sector)); + IBlockDevice_BlockRead(m_pDevice, ThisFATSecNum, 1, sector); + return *(word*) (sector + ThisFATEntOffset); +} + +bool FatFile::ReadCluster(dword dwCluster, void* pBuf, size_t size) +{ + dword RootDirSectors, FirstDataSector, FirstSectorofCluster; + + if (m_bIsRoot) + RootDirSectors = 0; + else + RootDirSectors = + ((m_bpb.nRootDirectoryEntries * 32) + (m_bpb.nBytesPerSector - 1)) + / m_bpb.nBytesPerSector; + + FirstDataSector = m_bpb.nReservedSectors + + (m_bpb.nFatCount * m_bpb.nSectorsPerFat) + RootDirSectors; + + if (m_bIsRoot) + dwCluster += 2; + + FirstSectorofCluster = ((dwCluster - 2) * m_bpb.nSectorsPerCluster) + + FirstDataSector; + + //m_pDevice->Seek(FirstSectorofCluster, SEEK_SET); + //return m_pDevice->ReadFile(pBuf, size) == (int) size; + size /= 512; + return IBlockDevice_BlockRead(m_pDevice, FirstSectorofCluster, size, pBuf) == size; +} + +/**************************************************************************** + * FatFolder * + ****************************************************************************/ +FatFolder::FatFolder(IBlockDevice* pDev, const fat_filefind_t* stat, bool bIsRoot) : + m_file(pDev, stat) +{ + m_file.m_bIsRoot = bIsRoot; + m_item_first = NULL; +} + +FatFolder::~FatFolder() +{ + folderitem_fat_t *item, *next; + + for (item = m_item_first; item; item = next) + { + next = item->next; + if (item->mount) + IUnknown_Release(item->mount); + item->mount = NULL; + delete item; + } +} + +HRESULT FatFolder::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IFolder)) + { + AddRef(); + *ppvObject = (IFolder*) this; + return S_OK; + } + else if (InlineIsEqualGUID(iid, IID_IStream)) + { + AddRef(); + *ppvObject = (IStream*) &m_file; + return S_OK; + } + else + return E_FAIL; +} + +HRESULT FatFolder::FindFirst(const wchar_t* szSpec, folderitem_t* item) +{ + item->spec = wcsdup(szSpec); + //TRACE(L"FindFirst %s\n", item->spec); + return S_OK; +} + +HRESULT FatFolder::FindNext(folderitem_t* item) +{ + union + { + fat_dirent_t dirent; + fat_lfnslot_t lfn; + }; + int i, j; + wchar_t name[MAX_PATH], temp[14], *nameptr; + + while (1) + { + if (m_file.Read(&dirent, sizeof(dirent)) < sizeof(dirent)) + { + TRACE(L"End of file"); + return E_FAIL; + } + + if (dirent.szFilename[0] == 0) + { + TRACE(L"End of directory\n"); + return E_FAIL; + } + + if (dirent.szFilename[0] != 0xe5) + { + memset(name, 0, sizeof(name)); + + if ((dirent.nAttributes & ATTR_LONG_NAME) != ATTR_LONG_NAME) + { + for (i = 0; i < 8; i++) + { + if (dirent.szFilename[i] == ' ') + { + name[i] = 0; + break; + } + else if (iswupper(dirent.szFilename[i])) + name[i] = towlower(dirent.szFilename[i]); + else + name[i] = dirent.szFilename[i]; + } + + if (dirent.szExtension[0] != ' ') + { + wcscat(name, L"."); + + j = wcslen(name); + for (i = 0; i < 3; i++) + { + if (dirent.szExtension[i] == ' ') + { + name[i + j] = 0; + break; + } + else if (iswupper(dirent.szExtension[i])) + name[i + j] = towlower(dirent.szExtension[i]); + else + name[i + j] = dirent.szExtension[i]; + } + } + + TRACE(L"short: name = \"%s\" (\"%s\")\n", name, item->spec); + } + else + { + while ((dirent.nAttributes & ATTR_LONG_NAME) + == ATTR_LONG_NAME) + { + TRACE(L" ", dirent.szFilename[0]); + if (dirent.szFilename[0] != 0xe5) + { + memset(temp, 0, sizeof(temp)); + nameptr = temp; + + for (i = 0; i < 5; i++) + { + *nameptr = lfn.name0_4[i]; + nameptr++; + } + + for (i = 0; i < 6; i++) + { + *nameptr = lfn.name5_10[i]; + nameptr++; + } + + for (i = 0; i < 2; i++) + { + *nameptr = lfn.name11_12[i]; + nameptr++; + } + + i = wcslen(temp); + memmove(name + i, name, wcslen(name) * sizeof(wchar_t)); + memcpy(name, temp, i * sizeof(wchar_t)); + } + + if (m_file.Read(&dirent, sizeof(dirent)) < sizeof(dirent)) + { + TRACE(L"End of file"); + return E_FAIL; + } + } + + //TRACE(L"long: name = \"%s\" (\"%s\")\n", name, item->spec); + } + + if (wildcard(name, item->spec)) + { + //TRACE(L"Found item size = %d\n", dirent.dwFileSize); + wcscpy(item->name, name); + item->length = dirent.dwFileSize; + item->attributes = dirent.nAttributes; + + if (item->size == sizeof(fat_filefind_t)) + memcpy((fat_filefind_t*) (item + 1), &dirent, sizeof(dirent)); + + return S_OK; + } + } + } + + return E_FAIL; +} + +HRESULT FatFolder::FindClose(folderitem_t* pBuf) +{ + //TRACE(L"FindClose\n"); + free((void*) pBuf->spec); + m_file.m_dwPosition = 0; + m_file.m_dwCachePtr = (dword) -1; + m_file.m_dwReadCluster = (dword) -1; + return S_OK; +} + +HRESULT FatFolder::Open(folderitem_t* item, const wchar_t* params) +{ + fat_filefind_t buf; + IUnknown* pFile; + wchar_t temp[MAX_PATH]; + + TRACE(L"[OpenChild] %s\n", item->name); + buf.ff.size = sizeof(fat_filefind_t); + buf.ff.name = temp; + buf.ff.name_max = countof(temp); + if (FAILED(FindFirst(item->name, &buf.ff)) || + FAILED(FindNext(&buf.ff))) + return E_FAIL; + + if (buf.ff.attributes & ATTR_DIRECTORY) + { + TRACE(L"Found dir at %x\n", buf.dirent.nFirstCluster); + pFile = new FatFolder(m_file.m_pDevice, &buf, false); + } + else + { + TRACE(L"Found file at %x\n", buf.dirent.nFirstCluster); + pFile = new FatFile(m_file.m_pDevice, &buf); + } + + //FindClose((FileFind*) &buf); + + if (item->size == sizeof(fat_filefind_t)) + memcpy(item, &buf, sizeof(fat_filefind_t)); + else + *item = buf.ff; + + item->u.item_handle = pFile; + FindClose(&buf.ff); + //return pFile; + return S_OK; +} + +HRESULT FatFolder::Mount(const wchar_t* name, IUnknown* obj) +{ + folderitem_fat_t* item = new folderitem_fat_t; + + item->size = sizeof(folderitem_fat_t); + memset(item, 0, sizeof(item)); + item->name = wcsdup(name); + item->attributes = ATTR_DIRECTORY | ATTR_LINK; + item->length = 0; + + if (m_item_first) + m_item_first->next = item; + else + m_item_first = item; + + return S_OK; +} + +void FatFolder::ScanDir() +{ +} \ No newline at end of file diff --git a/mobius/src/drivers/kdll/fb.h b/mobius/src/drivers/kdll/fb.h new file mode 100644 index 0000000..a619aac --- /dev/null +++ b/mobius/src/drivers/kdll/fb.h @@ -0,0 +1,487 @@ +#ifndef _LINUX_FB_H +#define _LINUX_FB_H + +#include + +/* Definitions of frame buffers */ + +#define FB_MAJOR 29 + +#define FB_MODES_SHIFT 5 /* 32 modes per framebuffer */ +#define FB_NUM_MINORS 256 /* 256 Minors */ +#define FB_MAX (FB_NUM_MINORS / (1 << FB_MODES_SHIFT)) +#define GET_FB_IDX(node) (MINOR(node) >> FB_MODES_SHIFT) + + +/* ioctls + 0x46 is 'F' */ +#define FBIOGET_VSCREENINFO 0x4600 +#define FBIOPUT_VSCREENINFO 0x4601 +#define FBIOGET_FSCREENINFO 0x4602 +#define FBIOGETCMAP 0x4604 +#define FBIOPUTCMAP 0x4605 +#define FBIOPAN_DISPLAY 0x4606 +/* 0x4607-0x460B are defined below */ +/* #define FBIOGET_MONITORSPEC 0x460C */ +/* #define FBIOPUT_MONITORSPEC 0x460D */ +/* #define FBIOSWITCH_MONIBIT 0x460E */ +#define FBIOGET_CON2FBMAP 0x460F +#define FBIOPUT_CON2FBMAP 0x4610 + +#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */ +#define FB_TYPE_PLANES 1 /* Non interleaved planes */ +#define FB_TYPE_INTERLEAVED_PLANES 2 /* Interleaved planes */ +#define FB_TYPE_TEXT 3 /* Text/attributes */ + +#define FB_AUX_TEXT_MDA 0 /* Monochrome text */ +#define FB_AUX_TEXT_CGA 1 /* CGA/EGA/VGA Color text */ +#define FB_AUX_TEXT_S3_MMIO 2 /* S3 MMIO fasttext */ +#define FB_AUX_TEXT_MGA_STEP16 3 /* MGA Millenium I: text, attr, 14 reserved bytes */ +#define FB_AUX_TEXT_MGA_STEP8 4 /* other MGAs: text, attr, 6 reserved bytes */ + +#define FB_VISUAL_MONO01 0 /* Monochr. 1=Black 0=White */ +#define FB_VISUAL_MONO10 1 /* Monochr. 1=White 0=Black */ +#define FB_VISUAL_TRUECOLOR 2 /* True color */ +#define FB_VISUAL_PSEUDOCOLOR 3 /* Pseudo color (like atari) */ +#define FB_VISUAL_DIRECTCOLOR 4 /* Direct color */ +#define FB_VISUAL_STATIC_PSEUDOCOLOR 5 /* Pseudo color readonly */ + +#define FB_ACCEL_NONE 0 /* no hardware accelerator */ +#define FB_ACCEL_ATARIBLITT 1 /* Atari Blitter */ +#define FB_ACCEL_AMIGABLITT 2 /* Amiga Blitter */ +#define FB_ACCEL_S3_TRIO64 3 /* Cybervision64 (S3 Trio64) */ +#define FB_ACCEL_NCR_77C32BLT 4 /* RetinaZ3 (NCR 77C32BLT) */ +#define FB_ACCEL_S3_VIRGE 5 /* Cybervision64/3D (S3 ViRGE) */ +#define FB_ACCEL_ATI_MACH64GX 6 /* ATI Mach 64GX family */ +#define FB_ACCEL_DEC_TGA 7 /* DEC 21030 TGA */ +#define FB_ACCEL_ATI_MACH64CT 8 /* ATI Mach 64CT family */ +#define FB_ACCEL_ATI_MACH64VT 9 /* ATI Mach 64CT family VT class */ +#define FB_ACCEL_ATI_MACH64GT 10 /* ATI Mach 64CT family GT class */ +#define FB_ACCEL_SUN_CREATOR 11 /* Sun Creator/Creator3D */ +#define FB_ACCEL_SUN_CGSIX 12 /* Sun cg6 */ +#define FB_ACCEL_SUN_LEO 13 /* Sun leo/zx */ +#define FB_ACCEL_IMS_TWINTURBO 14 /* IMS Twin Turbo */ +#define FB_ACCEL_3DLABS_PERMEDIA2 15 /* 3Dlabs Permedia 2 */ +#define FB_ACCEL_MATROX_MGA2064W 16 /* Matrox MGA2064W (Millenium) */ +#define FB_ACCEL_MATROX_MGA1064SG 17 /* Matrox MGA1064SG (Mystique) */ +#define FB_ACCEL_MATROX_MGA2164W 18 /* Matrox MGA2164W (Millenium II) */ +#define FB_ACCEL_MATROX_MGA2164W_AGP 19 /* Matrox MGA2164W (Millenium II) */ +#define FB_ACCEL_MATROX_MGAG100 20 /* Matrox G100 (Productiva G100) */ +#define FB_ACCEL_MATROX_MGAG200 21 /* Matrox G200 (Myst, Mill, ...) */ + +struct fb_fix_screeninfo { + wchar_t id[16]; /* identification string eg "TT Builtin" */ + char *smem_start; /* Start of frame buffer mem */ + /* (physical address) */ + dword smem_len; /* Length of frame buffer mem */ + dword type; /* see FB_TYPE_* */ + dword type_aux; /* Interleave for interleaved Planes */ + dword visual; /* see FB_VISUAL_* */ + word xpanstep; /* zero if no hardware panning */ + word ypanstep; /* zero if no hardware panning */ + word ywrapstep; /* zero if no hardware ywrap */ + dword line_length; /* length of a line in bytes */ + char *mmio_start; /* Start of Memory Mapped I/O */ + /* (physical address) */ + dword mmio_len; /* Length of Memory Mapped I/O */ + dword accel; /* Type of acceleration available */ + word reserved[3]; /* Reserved for future compatibility */ +}; + +/* Interpretation of offset for color fields: All offsets are from the right, + * inside a "pixel" value, which is exactly 'bits_per_pixel' wide (means: you + * can use the offset as right argument to <<). A pixel afterwards is a bit + * stream and is written to video memory as that unmodified. This implies + * big-endian byte order if bits_per_pixel is greater than 8. + */ +struct fb_bitfield { + dword offset; /* beginning of bitfield */ + dword length; /* length of bitfield */ + dword msb_right; /* != 0 : Most significant bit is */ + /* right */ +}; + +#define FB_NONSTD_HAM 1 /* Hold-And-Modify (HAM) */ + +#define FB_ACTIVATE_NOW 0 /* set values immediately (or vbl)*/ +#define FB_ACTIVATE_NXTOPEN 1 /* activate on next open */ +#define FB_ACTIVATE_TEST 2 /* don't set, round up impossible */ +#define FB_ACTIVATE_MASK 15 + /* values */ +#define FB_ACTIVATE_VBL 16 /* activate values on next vbl */ +#define FB_CHANGE_CMAP_VBL 32 /* change colormap on vbl */ +#define FB_ACTIVATE_ALL 64 /* change all VCs on this fb */ + +#define FB_ACCELF_TEXT 1 /* text mode acceleration */ + +#define FB_SYNC_HOR_HIGH_ACT 1 /* horizontal sync high active */ +#define FB_SYNC_VERT_HIGH_ACT 2 /* vertical sync high active */ +#define FB_SYNC_EXT 4 /* external sync */ +#define FB_SYNC_COMP_HIGH_ACT 8 /* composite sync high active */ +#define FB_SYNC_BROADCAST 16 /* broadcast video timings */ + /* vtotal = 144d/288n/576i => PAL */ + /* vtotal = 121d/242n/484i => NTSC */ +#define FB_SYNC_ON_GREEN 32 /* sync on green */ + +#define FB_VMODE_NONINTERLACED 0 /* non interlaced */ +#define FB_VMODE_INTERLACED 1 /* interlaced */ +#define FB_VMODE_DOUBLE 2 /* double scan */ +#define FB_VMODE_MASK 255 + +#define FB_VMODE_YWRAP 256 /* ywrap instead of panning */ +#define FB_VMODE_SMOOTH_XPAN 512 /* smooth xpan possible (internally used) */ +#define FB_VMODE_CONUPDATE 512 /* don't update x/yoffset */ + +struct fb_var_screeninfo { + dword xres; /* visible resolution */ + dword yres; + dword xres_virtual; /* virtual resolution */ + dword yres_virtual; + dword xoffset; /* offset from virtual to visible */ + dword yoffset; /* resolution */ + + dword bits_per_pixel; /* guess what */ + dword grayscale; /* != 0 Graylevels instead of colors */ + + struct fb_bitfield red; /* bitfield in fb mem if true color, */ + struct fb_bitfield green; /* else only length is significant */ + struct fb_bitfield blue; + struct fb_bitfield transp; /* transparency */ + + dword nonstd; /* != 0 Non standard pixel format */ + + dword activate; /* see FB_ACTIVATE_* */ + + dword height; /* height of picture in mm */ + dword width; /* width of picture in mm */ + + dword accel_flags; /* acceleration flags (hints) */ + + /* Timing: All values in pixclocks, except pixclock (of course) */ + dword pixclock; /* pixel clock in ps (pico seconds) */ + dword left_margin; /* time from sync to picture */ + dword right_margin; /* time from picture to sync */ + dword upper_margin; /* time from sync to picture */ + dword lower_margin; + dword hsync_len; /* length of horizontal sync */ + dword vsync_len; /* length of vertical sync */ + dword sync; /* see FB_SYNC_* */ + dword vmode; /* see FB_VMODE_* */ + dword reserved[6]; /* Reserved for future compatibility */ +}; + +struct fb_cmap { + dword start; /* First entry */ + dword len; /* Number of entries */ + word *red; /* Red values */ + word *green; + word *blue; + word *transp; /* transparency, can be NULL */ +}; + +struct fb_con2fbmap { + dword console; + dword framebuffer; +}; + +struct fb_monspecs { + dword hfmin; /* hfreq lower limit (Hz) */ + dword hfmax; /* hfreq upper limit (Hz) */ + word vfmin; /* vfreq lower limit (Hz) */ + word vfmax; /* vfreq upper limit (Hz) */ + unsigned dpms : 1; /* supports DPMS */ +}; + +#ifdef __KERNEL__ + +#include + + +struct fb_info; +struct fb_info_gen; +struct vm_area_struct; +struct file; + + /* + * Frame buffer operations + */ + +struct fb_ops { + /* open/release and usage marking */ + int (*fb_open)(struct fb_info *info, int user); + int (*fb_release)(struct fb_info *info, int user); + /* get non settable parameters */ + int (*fb_get_fix)(struct fb_fix_screeninfo *fix, int con, + struct fb_info *info); + /* get settable parameters */ + int (*fb_get_var)(struct fb_var_screeninfo *var, int con, + struct fb_info *info); + /* set settable parameters */ + int (*fb_set_var)(struct fb_var_screeninfo *var, int con, + struct fb_info *info); + /* get colormap */ + int (*fb_get_cmap)(struct fb_cmap *cmap, int kspc, int con, + struct fb_info *info); + /* set colormap */ + int (*fb_set_cmap)(struct fb_cmap *cmap, int kspc, int con, + struct fb_info *info); + /* pan display */ + int (*fb_pan_display)(struct fb_var_screeninfo *var, int con, + struct fb_info *info); + /* perform fb specific ioctl */ + int (*fb_ioctl)(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg, int con, struct fb_info *info); + /* perform fb specific mmap */ + int (*fb_mmap)(struct fb_info *info, struct file *file, struct vm_area_struct *vma); +}; + + + /* + * This is the interface between the low-level console driver and the + * low-level frame buffer device + */ + +struct display { + /* Filled in by the frame buffer device */ + + struct fb_var_screeninfo var; /* variable infos. yoffset and vmode */ + /* are updated by fbcon.c */ + struct fb_cmap cmap; /* colormap */ + char *screen_base; /* pointer to top of virtual screen */ + /* (virtual address) */ + int visual; + int type; /* see FB_TYPE_* */ + int type_aux; /* Interleave for interleaved Planes */ + u_short ypanstep; /* zero if no hardware ypan */ + u_short ywrapstep; /* zero if no hardware ywrap */ + u_long line_length; /* length of a line in bytes */ + u_short can_soft_blank; /* zero if no hardware blanking */ + u_short inverse; /* != 0 text black on white as default */ + struct display_switch *dispsw; /* low level operations */ + void *dispsw_data; /* optional dispsw helper data */ + +#if 0 + struct fb_fix_cursorinfo fcrsr; + struct fb_var_cursorinfo *vcrsr; + struct fb_cursorstate crsrstate; +#endif + + /* Filled in by the low-level console driver */ + + struct vc_data *conp; /* pointer to console data */ + struct fb_info *fb_info; /* frame buffer for this console */ + int vrows; /* number of virtual rows */ + unsigned short cursor_x; /* current cursor position */ + unsigned short cursor_y; + int fgcol; /* text colors */ + int bgcol; + u_long next_line; /* offset to one line below */ + u_long next_plane; /* offset to next plane */ + u_char *fontdata; /* Font associated to this display */ + unsigned short _fontheightlog; + unsigned short _fontwidthlog; + unsigned short _fontheight; + unsigned short _fontwidth; + int userfont; /* != 0 if fontdata kmalloc()ed */ + u_short scrollmode; /* Scroll Method */ + short yscroll; /* Hardware scrolling */ + unsigned char fgshift, bgshift; + unsigned short charmask; /* 0xff or 0x1ff */ +}; + + +struct fb_info { + char modename[40]; /* default video mode */ + int node; + int flags; +#define FBINFO_FLAG_MODULE 1 /* Low-level driver is a module */ + struct fb_ops *fbops; + struct fb_monspecs monspecs; + struct display *disp; /* initial display variable */ + struct vc_data *display_fg; /* Console visible on this display */ + char fontname[40]; /* default font name */ + int (*changevar)(int); /* tell console var has changed */ + int (*switch_con)(int, struct fb_info*); + /* tell fb to switch consoles */ + int (*updatevar)(int, struct fb_info*); + /* tell fb to update the vars */ + void (*blank)(int, struct fb_info*); /* tell fb to (un)blank the screen */ + /* arg = 0: unblank */ + /* arg > 0: VESA level (arg-1) */ + + /* From here on everything is device dependent */ +}; + +#ifdef MODULE +#define FBINFO_FLAG_DEFAULT FBINFO_FLAG_MODULE +#else +#define FBINFO_FLAG_DEFAULT 0 +#endif + + /* + * This structure abstracts from the underlying hardware. It is not + * mandatory but used by the `generic' frame buffer operations. + * Read drivers/video/skeletonfb.c for more information. + */ + +struct fbgen_hwswitch { + void (*detect)(void); + int (*encode_fix)(struct fb_fix_screeninfo *fix, const void *par, + struct fb_info_gen *info); + int (*decode_var)(const struct fb_var_screeninfo *var, void *par, + struct fb_info_gen *info); + int (*encode_var)(struct fb_var_screeninfo *var, const void *par, + struct fb_info_gen *info); + void (*get_par)(void *par, struct fb_info_gen *info); + void (*set_par)(const void *par, struct fb_info_gen *info); + int (*getcolreg)(unsigned regno, unsigned *red, unsigned *green, + unsigned *blue, unsigned *transp, struct fb_info *info); + int (*setcolreg)(unsigned regno, unsigned red, unsigned green, + unsigned blue, unsigned transp, struct fb_info *info); + int (*pan_display)(const struct fb_var_screeninfo *var, + struct fb_info_gen *info); + int (*blank)(int blank_mode, struct fb_info_gen *info); + void (*set_dispsw)(const void *par, struct display *disp, + struct fb_info_gen *info); +}; + +struct fb_info_gen { + struct fb_info info; + + /* Entries for a generic frame buffer device */ + /* Yes, this starts looking like C++ */ + u_int parsize; + struct fbgen_hwswitch *fbhw; + + /* From here on everything is device dependent */ +}; + + /* + * `Generic' versions of the frame buffer device operations + */ + +extern int fbgen_get_fix(struct fb_fix_screeninfo *fix, int con, + struct fb_info *info); +extern int fbgen_get_var(struct fb_var_screeninfo *var, int con, + struct fb_info *info); +extern int fbgen_set_var(struct fb_var_screeninfo *var, int con, + struct fb_info *info); +extern int fbgen_get_cmap(struct fb_cmap *cmap, int kspc, int con, + struct fb_info *info); +extern int fbgen_set_cmap(struct fb_cmap *cmap, int kspc, int con, + struct fb_info *info); +extern int fbgen_pan_display(struct fb_var_screeninfo *var, int con, + struct fb_info *info); +extern int fbgen_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg, int con, + struct fb_info *info); + + /* + * Helper functions + */ + +extern int fbgen_do_set_var(struct fb_var_screeninfo *var, int isactive, + struct fb_info_gen *info); +extern void fbgen_set_disp(int con, struct fb_info_gen *info); +extern void fbgen_install_cmap(int con, struct fb_info_gen *info); +extern int fbgen_update_var(int con, struct fb_info *info); +extern int fbgen_switch(int con, struct fb_info *info); +extern void fbgen_blank(int blank, struct fb_info *info); + + +struct fb_videomode { + const char *name; + struct fb_var_screeninfo var; +}; + + +/* drivers/char/fbmem.c */ +extern int register_framebuffer(struct fb_info *fb_info); +extern int unregister_framebuffer(const struct fb_info *fb_info); +extern int fbmon_valid_timings(u_int pixclock, u_int htotal, u_int vtotal, + const struct fb_info *fb_info); +extern int fbmon_dpms(const struct fb_info *fb_info); + + +extern int num_registered_fb; +extern struct fb_info *registered_fb[FB_MAX]; +extern char con2fb_map[MAX_NR_CONSOLES]; + +/* drivers/video/fbcon.c */ +extern struct display fb_display[MAX_NR_CONSOLES]; + +/* drivers/video/fbcmap.c */ +extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp); +extern void fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to, + int fsfromto); +extern int fb_get_cmap(struct fb_cmap *cmap, int kspc, + int (*getcolreg)(u_int, u_int *, u_int *, u_int *, + u_int *, struct fb_info *), + struct fb_info *fb_info); +extern int fb_set_cmap(struct fb_cmap *cmap, int kspc, + int (*setcolreg)(u_int, u_int, u_int, u_int, u_int, + struct fb_info *), + struct fb_info *fb_info); +extern struct fb_cmap *fb_default_cmap(int len); +extern void fb_invert_cmaps(void); + +/* VESA Blanking Levels */ +#define VESA_NO_BLANKING 0 +#define VESA_VSYNC_SUSPEND 1 +#define VESA_HSYNC_SUSPEND 2 +#define VESA_POWERDOWN 3 + +#endif /* __KERNEL__ */ + +#if 1 + +#define FBCMD_GET_CURRENTPAR 0xDEAD0005 +#define FBCMD_SET_CURRENTPAR 0xDEAD8005 + +#endif + + +#if 1 /* Preliminary */ + + /* + * Hardware Cursor + */ + +#define FBIOGET_FCURSORINFO 0x4607 +#define FBIOGET_VCURSORINFO 0x4608 +#define FBIOPUT_VCURSORINFO 0x4609 +#define FBIOGET_CURSORSTATE 0x460A +#define FBIOPUT_CURSORSTATE 0x460B + + +struct fb_fix_cursorinfo { + word crsr_width; /* width and height of the cursor in */ + word crsr_height; /* pixels (zero if no cursor) */ + word crsr_xsize; /* cursor size in display pixels */ + word crsr_ysize; + word crsr_color1; /* colormap entry for cursor color1 */ + word crsr_color2; /* colormap entry for cursor color2 */ +}; + +struct fb_var_cursorinfo { + word width; + word height; + word xspot; + word yspot; + byte data[1]; /* field with [height][width] */ +}; + +struct fb_cursorstate { + short xoffset; + short yoffset; + word mode; +}; + +#define FB_CURSOR_OFF 0 +#define FB_CURSOR_ON 1 +#define FB_CURSOR_FLASH 2 + +#endif /* Preliminary */ + +#endif /* _LINUX_FB_H */ + diff --git a/mobius/src/drivers/kdll/folder.cpp b/mobius/src/drivers/kdll/folder.cpp new file mode 100644 index 0000000..faf5e27 --- /dev/null +++ b/mobius/src/drivers/kdll/folder.cpp @@ -0,0 +1,208 @@ +#include +#include +#include +#include +#include "folder.h" + +#if 0 +#define TRACE wprintf +#else + +static int TRACE(...) +{ + return 0; +} + +#endif + +extern "C" bool wildcard(const wchar_t* str, const wchar_t* spec); + +extern "C" IFolder* Folder_Create() +{ + return new CFolder; +} + +CFolder::CFolder() +{ + m_refs = 0; + m_item_first = NULL; + m_scanned = false; +} + +CFolder::~CFolder() +{ + folderitem_ext_t *item, *next; + + for (item = m_item_first; item; item = next) + { + next = item->next; + + if (item->mount) + item->mount->Release(); + //IUnknown_Release(item->mount); + + item->mount = NULL; + free(item->name); + delete item; + } +} + +HRESULT CFolder::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IFolder)) + { + AddRef(); + *ppvObject = (IFolder*) this; + return S_OK; + } + else + return E_FAIL; +} + +HRESULT CFolder::FindFirst(const wchar_t* szSpec, folderitem_t* item) +{ + if (!m_scanned) + { + ScanDir(); + m_scanned = true; + } + + item->spec = wcsdup(szSpec); + item->u.find_handle = (dword) m_item_first; + return S_OK; +} + +HRESULT CFolder::FindNext(folderitem_t* item) +{ + folderitem_ext_t *fitem = (folderitem_ext_t*) item->u.find_handle; + + if (fitem == NULL) + return E_FAIL; + else + { + while (fitem) + { + if (wildcard(fitem->name, item->spec)) + { + item->u.find_handle = (dword) fitem->next; + + wcsncpy(item->name, fitem->name, item->name_max); + item->attributes = fitem->attributes; + item->length = fitem->length; + + if (item->size == sizeof(folderitem_ext_t)) + { + ((folderitem_ext_t*) item)->next = fitem->next; + ((folderitem_ext_t*) item)->mount = fitem->mount; + ((folderitem_ext_t*) item)->data = fitem->data; + } + + return S_OK; + } + + fitem = fitem->next; + item->u.find_handle = (dword) fitem; + } + + return E_FAIL; + } +} + +HRESULT CFolder::FindClose(folderitem_t* pBuf) +{ + free((void*) pBuf->spec); + return S_OK; +} + +HRESULT CFolder::Open(folderitem_t* item, const wchar_t* params) +{ + folderitem_ext_t buf; + IUnknown* pFile; + wchar_t temp[MAX_PATH]; + + TRACE(L"[OpenChild] %s\n", item->name); + memset(&buf, 0, sizeof(buf)); + buf.size = sizeof(buf); + buf.name = temp; + buf.name_max = countof(temp); + if (FAILED(FindFirst(item->name, &buf)) || + FAILED(FindNext(&buf))) + return E_FAIL; + + pFile = DoOpen(&buf); + + if (item->size == sizeof(folderitem_ext_t)) + memcpy(item, &buf, sizeof(folderitem_ext_t)); + else + *item = buf; + + item->u.item_handle = pFile; + FindClose(&buf); + return S_OK; +} + +HRESULT CFolder::Mount(const wchar_t* name, IUnknown* obj) +{ + folderitem_ext_t* item; + folderitem_t info; + //IStream* strm; + + TRACE(L"CFolder::Mount(%s, %p)\n", name, obj); + + for (item = m_item_first; item; item = item->next) + { + if (wcsicmp(name, item->name) == 0) + { + if (item->mount) + item->mount->Release(); + + break; + } + } + + if (item == NULL) + { + item = new folderitem_ext_t; + memset(item, 0, sizeof(item)); + + item->next = m_item_first; + m_item_first = item; + item->name = wcsdup(name); + } + + info.size = sizeof(info); + info.name = NULL; + info.name_max = 0; + info.attributes = 0; + info.length = 0; + + /*if (obj && SUCCEEDED(obj->QueryInterface(IID_IStream, (void**) &strm))) + { + strm->Stat(&info); + strm->Release(); + }*/ + + item->size = sizeof(folderitem_ext_t); + item->attributes = ATTR_LINK | info.attributes; + item->length = info.length; + item->mount = obj; + obj->AddRef(); + + return S_OK; +} + +void CFolder::ScanDir() +{ +} + +IUnknown* CFolder::DoOpen(folderitem_ext_t* buf) +{ + if (buf->mount) + { + buf->mount->AddRef(); + return buf->mount; + } + else + return NULL; +} \ No newline at end of file diff --git a/mobius/src/drivers/kdll/folder.h b/mobius/src/drivers/kdll/folder.h new file mode 100644 index 0000000..d118042 --- /dev/null +++ b/mobius/src/drivers/kdll/folder.h @@ -0,0 +1,36 @@ +#ifndef __FOLDER_H +#define __FOLDER_H + +#include + +struct folderitem_ext_t : folderitem_t +{ + folderitem_ext_t* next; + void* data; + IUnknown* mount; +}; + +class CFolder : public IUnknown, public IFolder +{ +public: + CFolder(); + ~CFolder(); + + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + IMPLEMENT_IUNKNOWN(CFolder); + + STDMETHOD(FindFirst)(const wchar_t* spec, folderitem_t* buf); + STDMETHOD(FindNext)(folderitem_t* buf); + STDMETHOD(FindClose)(folderitem_t* pBuf); + STDMETHOD(Open)(folderitem_t* item, const wchar_t* params); + STDMETHOD(Mount)(const wchar_t* name, IUnknown* obj); + +protected: + folderitem_ext_t* m_item_first; + bool m_scanned; + + virtual void ScanDir(); + virtual IUnknown* DoOpen(folderitem_ext_t* buf); +}; + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/kdll/kdll.aps b/mobius/src/drivers/kdll/kdll.aps new file mode 100644 index 0000000..7c8a0ff --- /dev/null +++ b/mobius/src/drivers/kdll/kdll.aps Binary files differ diff --git a/mobius/src/drivers/kdll/kdll.bsc b/mobius/src/drivers/kdll/kdll.bsc new file mode 100644 index 0000000..954d053 --- /dev/null +++ b/mobius/src/drivers/kdll/kdll.bsc @@ -0,0 +1 @@ +Microsoft C/C++ program database 2.00 diff --git a/mobius/src/drivers/kdll/kdll.dll b/mobius/src/drivers/kdll/kdll.dll new file mode 100644 index 0000000..66789c5 --- /dev/null +++ b/mobius/src/drivers/kdll/kdll.dll Binary files differ diff --git a/mobius/src/drivers/kdll/kdll.dsp b/mobius/src/drivers/kdll/kdll.dsp new file mode 100644 index 0000000..e4842e2 --- /dev/null +++ b/mobius/src/drivers/kdll/kdll.dsp @@ -0,0 +1,209 @@ +# Microsoft Developer Studio Project File - Name="kdll" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=kdll - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "kdll.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "kdll.mak" CFG="kdll - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "kdll - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "kdll - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "kdll - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "kdll___Win32_Release" +# PROP BASE Intermediate_Dir "kdll___Win32_Release" +# PROP BASE Cmd_Line "NMAKE /f kdll.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "kdll.exe" +# PROP BASE Bsc_Name "kdll.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "kdll___Win32_Release" +# PROP Intermediate_Dir "kdll___Win32_Release" +# PROP Cmd_Line "nmake /f "kdll.mak"" +# PROP Rebuild_Opt "/a" +# PROP Target_File "kdll.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "kdll - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "kdll___Win32_Debug" +# PROP BASE Intermediate_Dir "kdll___Win32_Debug" +# PROP BASE Cmd_Line "NMAKE /f kdll.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "kdll.exe" +# PROP BASE Bsc_Name "kdll.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "kdll___Win32_Debug" +# PROP Intermediate_Dir "kdll___Win32_Debug" +# PROP Cmd_Line "set" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\bin\kdll.dll" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "kdll - Win32 Release" +# Name "kdll - Win32 Debug" + +!IF "$(CFG)" == "kdll - Win32 Release" + +!ELSEIF "$(CFG)" == "kdll - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\common.c +# End Source File +# Begin Source File + +SOURCE=.\config.cpp +# End Source File +# Begin Source File + +SOURCE=.\console.cpp +# End Source File +# Begin Source File + +SOURCE=.\crt0.c +# End Source File +# Begin Source File + +SOURCE=.\fat16.cpp +# End Source File +# Begin Source File + +SOURCE=.\fat16.tmp.cpp +# End Source File +# Begin Source File + +SOURCE=.\folder.cpp +# End Source File +# Begin Source File + +SOURCE=.\kdll.rc +# End Source File +# Begin Source File + +SOURCE=.\main.cpp +# End Source File +# Begin Source File + +SOURCE=.\Ne2000.cpp +# End Source File +# Begin Source File + +SOURCE=.\pci.c +# End Source File +# Begin Source File + +SOURCE=.\ramdisk.cpp +# End Source File +# Begin Source File + +SOURCE=.\serial.cpp +# End Source File +# Begin Source File + +SOURCE=.\textcons.cpp +# End Source File +# Begin Source File + +SOURCE=.\wildcard.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\8390.h +# End Source File +# Begin Source File + +SOURCE=.\british.h +# End Source File +# Begin Source File + +SOURCE=.\config.h +# End Source File +# Begin Source File + +SOURCE=.\console.h +# End Source File +# Begin Source File + +SOURCE=.\fat.h +# End Source File +# Begin Source File + +SOURCE=.\fb.h +# End Source File +# Begin Source File + +SOURCE=.\folder.h +# End Source File +# Begin Source File + +SOURCE=.\Ne2000.h +# End Source File +# Begin Source File + +SOURCE=.\pci.h +# End Source File +# Begin Source File + +SOURCE=.\ramdisk.h +# End Source File +# Begin Source File + +SOURCE=.\resource.h +# End Source File +# Begin Source File + +SOURCE=.\textcons.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/kdll/kdll.exp b/mobius/src/drivers/kdll/kdll.exp new file mode 100644 index 0000000..1e1cf71 --- /dev/null +++ b/mobius/src/drivers/kdll/kdll.exp Binary files differ diff --git a/mobius/src/drivers/kdll/kdll.lib b/mobius/src/drivers/kdll/kdll.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/mobius/src/drivers/kdll/kdll.lib diff --git a/mobius/src/drivers/kdll/kdll.plg b/mobius/src/drivers/kdll/kdll.plg new file mode 100644 index 0000000..b7599e6 --- /dev/null +++ b/mobius/src/drivers/kdll/kdll.plg @@ -0,0 +1,47 @@ + + +
+

Build Log

+

+--------------------Configuration: kdll - Win32 Debug-------------------- +

+ +cl /nologo /D__MOBIUS__ /DKERNEL /If:\Projects\mobius\include /c fat16.cpp /Fofat16.o +fat16.cpp +fat16.cpp(40) : error C2143: syntax error : missing ';' before '*' +fat16.cpp(40) : error C2501: 'IBlockDevice' : missing storage-class or type specifiers +fat16.cpp(40) : error C2501: 'm_pDevice' : missing storage-class or type specifiers +fat16.cpp(51) : error C2629: unexpected 'class CFatFile (' +fat16.cpp(51) : error C2238: unexpected token(s) preceding ';' +fat16.cpp(68) : error C2629: unexpected 'class CFatFolder (' +fat16.cpp(68) : error C2238: unexpected token(s) preceding ';' +fat16.cpp(87) : error C2061: syntax error : identifier 'IBlockDevice' +fat16.cpp(92) : error C2065: 'pDevice' : undeclared identifier +fat16.cpp(98) : error C2065: 'IBlockDevice' : undeclared identifier +fat16.cpp(98) : error C2065: 'pDev' : undeclared identifier +fat16.cpp(98) : error C2059: syntax error : 'const' +fat16.cpp(99) : error C2143: syntax error : missing ';' before '{' +fat16.cpp(99) : error C2447: missing function header (old-style formal list?) +fat16.cpp(125) : error C2065: 'm_pDevice' : undeclared identifier +fat16.cpp(126) : error C2227: left of '->Release' must point to class/struct/union +fat16.cpp(233) : error C2227: left of '->BlockRead' must point to class/struct/union +fat16.cpp(266) : error C2227: left of '->BlockRead' must point to class/struct/union +fat16.cpp(272) : error C2059: syntax error : 'const' +fat16.cpp(273) : error C2065: 'stat' : undeclared identifier +fat16.cpp(274) : error C2448: '' : function-style initializer appears to be a function definition +fat16.cpp(399) : error C2039: 'm_pDevice' : is not a member of 'CFatFile' + fat16.cpp(33) : see declaration of 'CFatFile' +fat16.cpp(399) : error C2661: 'CFatFolder::CFatFolder' : no overloaded function takes 3 parameters +fat16.cpp(404) : error C2039: 'm_pDevice' : is not a member of 'CFatFile' + fat16.cpp(33) : see declaration of 'CFatFile' +fat16.cpp(404) : error C2661: 'CFatFile::CFatFile' : no overloaded function takes 2 parameters +make: *** [fat16.o] Error 2 +Error executing make. + + + +

Results

+kdll.dll - 26 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/drivers/kdll/kdll.rc b/mobius/src/drivers/kdll/kdll.rc new file mode 100644 index 0000000..48a6cdd --- /dev/null +++ b/mobius/src/drivers/kdll/kdll.rc @@ -0,0 +1,105 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.K.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x0L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904b0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "Kernel Drivers DLL\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "kdll\0" + VALUE "LegalCopyright", "Copyright � 2001\0" + VALUE "OriginalFilename", "kdll.dll\0" + VALUE "ProductName", "The M�bius operating system\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1200 + END +END + +#endif // !_MAC + +#endif // English (U.K.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/mobius/src/drivers/kdll/listing.txt b/mobius/src/drivers/kdll/listing.txt new file mode 100644 index 0000000..09fab9c --- /dev/null +++ b/mobius/src/drivers/kdll/listing.txt @@ -0,0 +1,12824 @@ +Microsoft (R) COFF Binary File Dumper Version 5.00.7022 +Copyright (C) Microsoft Corp 1992-1997. All rights reserved. + + +Dump of file ..\..\bin\kdll.dll + +File Type: DLL + +?AtaIrq@@YAXPAXH@Z (void __cdecl AtaIrq(void *,int)): + E0001000: 55 push ebp + E0001001: 8B EC mov ebp,esp + E0001003: B8 01 00 00 00 mov eax,1 + E0001008: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E000100B: D3 E0 shl eax,cl + E000100D: 66 8B 0D 50 C6 00 mov cx,word ptr ds:[E000C650h] + E0 + E0001014: 66 0B C8 or cx,ax + E0001017: 66 89 0D 50 C6 00 mov word ptr ds:[E000C650h],cx + E0 + E000101E: 5D pop ebp + E000101F: C3 ret +??0CAtaDrive@@QAE@XZ (public: __thiscall CAtaDrive::CAtaDrive(void)): + E0001020: 55 push ebp + E0001021: 8B EC mov ebp,esp + E0001023: 83 EC 0C sub esp,0Ch + E0001026: 89 4D F4 mov dword ptr [ebp-0Ch],ecx + E0001029: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E000102C: C7 00 C8 A0 00 E0 mov dword ptr [eax],0E000A0C8h + E0001032: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0001035: 83 C1 04 add ecx,4 + E0001038: 89 4D FC mov dword ptr [ebp-4],ecx + E000103B: 8B 55 FC mov edx,dword ptr [ebp-4] + E000103E: C7 02 B0 A0 00 E0 mov dword ptr [edx],0E000A0B0h + E0001044: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0001047: 83 C0 08 add eax,8 + E000104A: 89 45 F8 mov dword ptr [ebp-8],eax + E000104D: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0001050: C7 01 98 A0 00 E0 mov dword ptr [ecx],0E000A098h + E0001056: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0001059: C7 02 88 A0 00 E0 mov dword ptr [edx],0E000A088h + E000105F: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0001062: C7 40 04 70 A0 00 mov dword ptr [eax+4],0E000A070h + E0 + E0001069: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E000106C: C7 41 08 58 A0 00 mov dword ptr [ecx+8],0E000A058h + E0 + E0001073: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0001076: C7 82 80 00 00 00 mov dword ptr [edx+00000080h],0 + 00 00 00 00 + E0001080: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0001083: 8B E5 mov esp,ebp + E0001085: 5D pop ebp + E0001086: C3 ret +?QueryInterface@CAtaDrive@@UAAKABU_GUID@@PAPAX@Z (public: virtual unsigned long __cdecl CAtaDrive::QueryInterface(struct _GUID const &,void * *)): + E0001087: 55 push ebp + E0001088: 8B EC mov ebp,esp + E000108A: 83 EC 08 sub esp,8 + E000108D: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0001090: 8B 08 mov ecx,dword ptr [eax] + E0001092: 3B 0D D8 A0 00 E0 cmp ecx,dword ptr ds:[E000A0D8h] + E0001098: 75 2A jne E00010C4 + E000109A: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E000109D: 8B 42 04 mov eax,dword ptr [edx+4] + E00010A0: 3B 05 DC A0 00 E0 cmp eax,dword ptr ds:[E000A0DCh] + E00010A6: 75 1C jne E00010C4 + E00010A8: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00010AB: 8B 51 08 mov edx,dword ptr [ecx+8] + E00010AE: 3B 15 E0 A0 00 E0 cmp edx,dword ptr ds:[E000A0E0h] + E00010B4: 75 0E jne E00010C4 + E00010B6: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00010B9: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E00010BC: 3B 0D E4 A0 00 E0 cmp ecx,dword ptr ds:[E000A0E4h] + E00010C2: 74 37 je E00010FB + E00010C4: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00010C7: 8B 02 mov eax,dword ptr [edx] + E00010C9: 3B 05 08 A1 00 E0 cmp eax,dword ptr ds:[E000A108h] + E00010CF: 75 5D jne E000112E + E00010D1: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00010D4: 8B 51 04 mov edx,dword ptr [ecx+4] + E00010D7: 3B 15 0C A1 00 E0 cmp edx,dword ptr ds:[E000A10Ch] + E00010DD: 75 4F jne E000112E + E00010DF: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00010E2: 8B 48 08 mov ecx,dword ptr [eax+8] + E00010E5: 3B 0D 10 A1 00 E0 cmp ecx,dword ptr ds:[E000A110h] + E00010EB: 75 41 jne E000112E + E00010ED: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00010F0: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E00010F3: 3B 05 14 A1 00 E0 cmp eax,dword ptr ds:[E000A114h] + E00010F9: 75 33 jne E000112E + E00010FB: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E00010FF: 74 0B je E000110C + E0001101: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0001104: 83 C1 04 add ecx,4 + E0001107: 89 4D FC mov dword ptr [ebp-4],ecx + E000110A: EB 07 jmp E0001113 + E000110C: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0001113: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0001116: 8B 45 FC mov eax,dword ptr [ebp-4] + E0001119: 89 02 mov dword ptr [edx],eax + E000111B: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000111E: 8B 11 mov edx,dword ptr [ecx] + E0001120: 8B 45 08 mov eax,dword ptr [ebp+8] + E0001123: 50 push eax + E0001124: FF 52 04 call dword ptr [edx+4] + E0001127: 83 C4 04 add esp,4 + E000112A: 33 C0 xor eax,eax + E000112C: EB 6F jmp E000119D + E000112E: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0001131: 8B 11 mov edx,dword ptr [ecx] + E0001133: 3B 15 28 A1 00 E0 cmp edx,dword ptr ds:[E000A128h] + E0001139: 75 5D jne E0001198 + E000113B: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000113E: 8B 48 04 mov ecx,dword ptr [eax+4] + E0001141: 3B 0D 2C A1 00 E0 cmp ecx,dword ptr ds:[E000A12Ch] + E0001147: 75 4F jne E0001198 + E0001149: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E000114C: 8B 42 08 mov eax,dword ptr [edx+8] + E000114F: 3B 05 30 A1 00 E0 cmp eax,dword ptr ds:[E000A130h] + E0001155: 75 41 jne E0001198 + E0001157: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E000115A: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E000115D: 3B 15 34 A1 00 E0 cmp edx,dword ptr ds:[E000A134h] + E0001163: 75 33 jne E0001198 + E0001165: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E0001169: 74 0B je E0001176 + E000116B: 8B 45 08 mov eax,dword ptr [ebp+8] + E000116E: 83 C0 08 add eax,8 + E0001171: 89 45 F8 mov dword ptr [ebp-8],eax + E0001174: EB 07 jmp E000117D + E0001176: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E000117D: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E0001180: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0001183: 89 11 mov dword ptr [ecx],edx + E0001185: 8B 45 08 mov eax,dword ptr [ebp+8] + E0001188: 8B 08 mov ecx,dword ptr [eax] + E000118A: 8B 55 08 mov edx,dword ptr [ebp+8] + E000118D: 52 push edx + E000118E: FF 51 04 call dword ptr [ecx+4] + E0001191: 83 C4 04 add esp,4 + E0001194: 33 C0 xor eax,eax + E0001196: EB 05 jmp E000119D + E0001198: B8 00 00 00 80 mov eax,80000000h + E000119D: 8B E5 mov esp,ebp + E000119F: 5D pop ebp + E00011A0: C3 ret +?GetInfo@CAtaDrive@@UAAKPAUdevice_t@@@Z (public: virtual unsigned long __cdecl CAtaDrive::GetInfo(struct device_t *)): + E00011A1: 55 push ebp + E00011A2: 8B EC mov ebp,esp + E00011A4: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00011A7: 83 38 0C cmp dword ptr [eax],0Ch + E00011AA: 73 07 jae E00011B3 + E00011AC: B8 00 00 00 80 mov eax,80000000h + E00011B1: EB 18 jmp E00011CB + E00011B3: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00011B6: 83 C1 22 add ecx,22h + E00011B9: 51 push ecx + E00011BA: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00011BD: 8B 42 04 mov eax,dword ptr [edx+4] + E00011C0: 50 push eax + E00011C1: E8 44 8D 00 00 call E0009F0A + E00011C6: 83 C4 08 add esp,8 + E00011C9: 33 C0 xor eax,eax + E00011CB: 5D pop ebp + E00011CC: C3 ret +?DeviceOpen@CAtaDrive@@UAAKXZ (public: virtual unsigned long __cdecl CAtaDrive::DeviceOpen(void)): + E00011CD: 55 push ebp + E00011CE: 8B EC mov ebp,esp + E00011D0: 33 C0 xor eax,eax + E00011D2: 5D pop ebp + E00011D3: C3 ret +?GetSize@CAtaDrive@@UAAKPAUblocksize_t@@@Z (public: virtual unsigned long __cdecl CAtaDrive::GetSize(struct blocksize_t *)): + E00011D4: 55 push ebp + E00011D5: 8B EC mov ebp,esp + E00011D7: 51 push ecx + E00011D8: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00011DB: 8B 08 mov ecx,dword ptr [eax] + E00011DD: 89 4D FC mov dword ptr [ebp-4],ecx + E00011E0: 83 7D FC 0C cmp dword ptr [ebp-4],0Ch + E00011E4: 73 07 jae E00011ED + E00011E6: B8 00 00 00 80 mov eax,80000000h + E00011EB: EB 23 jmp E0001210 + E00011ED: 8B 55 08 mov edx,dword ptr [ebp+8] + E00011F0: 83 C2 04 add edx,4 + E00011F3: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00011F6: 8B 0A mov ecx,dword ptr [edx] + E00011F8: 89 08 mov dword ptr [eax],ecx + E00011FA: 8B 4A 04 mov ecx,dword ptr [edx+4] + E00011FD: 89 48 04 mov dword ptr [eax+4],ecx + E0001200: 8B 52 08 mov edx,dword ptr [edx+8] + E0001203: 89 50 08 mov dword ptr [eax+8],edx + E0001206: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0001209: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000120C: 89 08 mov dword ptr [eax],ecx + E000120E: 33 C0 xor eax,eax + E0001210: 8B E5 mov esp,ebp + E0001212: 5D pop ebp + E0001213: C3 ret +?WaitStatus@CAtaDrive@@QAE_NGG@Z (public: bool __thiscall CAtaDrive::WaitStatus(unsigned short,unsigned short)): + E0001214: 55 push ebp + E0001215: 8B EC mov ebp,esp + E0001217: 83 EC 14 sub esp,14h + E000121A: 53 push ebx + E000121B: 56 push esi + E000121C: 57 push edi + E000121D: 89 4D EC mov dword ptr [ebp-14h],ecx + E0001220: E8 F1 8C 00 00 call E0009F16 + E0001225: 05 D0 07 00 00 add eax,7D0h + E000122A: 89 45 F8 mov dword ptr [ebp-8],eax + E000122D: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0001230: 33 C9 xor ecx,ecx + E0001232: 66 8B 48 18 mov cx,word ptr [eax+18h] + E0001236: 83 C1 07 add ecx,7 + E0001239: 66 89 4D F4 mov word ptr [ebp-0Ch],cx + E000123D: 33 C0 xor eax,eax + E000123F: 66 8B 55 F4 mov dx,word ptr [ebp-0Ch] + E0001243: EC in al,dx + E0001244: 88 45 F0 mov byte ptr [ebp-10h],al + E0001247: 66 0F B6 55 F0 movzx dx,byte ptr [ebp-10h] + E000124C: 66 89 55 FC mov word ptr [ebp-4],dx + E0001250: 8B 45 FC mov eax,dword ptr [ebp-4] + E0001253: 25 FF FF 00 00 and eax,0FFFFh + E0001258: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000125B: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0001261: 23 C1 and eax,ecx + E0001263: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0001266: 81 E2 FF FF 00 00 and edx,0FFFFh + E000126C: 3B C2 cmp eax,edx + E000126E: 74 26 je E0001296 + E0001270: E8 A1 8C 00 00 call E0009F16 + E0001275: 3B 45 F8 cmp eax,dword ptr [ebp-8] + E0001278: 72 1A jb E0001294 + E000127A: 8B 45 FC mov eax,dword ptr [ebp-4] + E000127D: 25 FF FF 00 00 and eax,0FFFFh + E0001282: 50 push eax + E0001283: 68 00 B0 00 E0 push 0E000B000h + E0001288: E8 83 8C 00 00 call E0009F10 + E000128D: 83 C4 08 add esp,8 + E0001290: 32 C0 xor al,al + E0001292: EB 04 jmp E0001298 + E0001294: EB 97 jmp E000122D + E0001296: B0 01 mov al,1 + E0001298: 5F pop edi + E0001299: 5E pop esi + E000129A: 5B pop ebx + E000129B: 8B E5 mov esp,ebp + E000129D: 5D pop ebp + E000129E: C2 08 00 ret 8 +?Select@CAtaDrive@@QAEXXZ (public: void __thiscall CAtaDrive::Select(void)): + E00012A1: 55 push ebp + E00012A2: 8B EC mov ebp,esp + E00012A4: 83 EC 0C sub esp,0Ch + E00012A7: 53 push ebx + E00012A8: 56 push esi + E00012A9: 57 push edi + E00012AA: 89 4D F4 mov dword ptr [ebp-0Ch],ecx + E00012AD: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E00012B0: 8A 48 1C mov cl,byte ptr [eax+1Ch] + E00012B3: 88 4D F8 mov byte ptr [ebp-8],cl + E00012B6: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E00012B9: 33 C0 xor eax,eax + E00012BB: 66 8B 42 18 mov ax,word ptr [edx+18h] + E00012BF: 83 C0 06 add eax,6 + E00012C2: 66 89 45 FC mov word ptr [ebp-4],ax + E00012C6: 66 8B 55 FC mov dx,word ptr [ebp-4] + E00012CA: 8A 45 F8 mov al,byte ptr [ebp-8] + E00012CD: EE out dx,al + E00012CE: 5F pop edi + E00012CF: 5E pop esi + E00012D0: 5B pop ebx + E00012D1: 8B E5 mov esp,ebp + E00012D3: 5D pop ebp + E00012D4: C3 ret +?BlockToChs@CAtaDrive@@QAEXHPAH00@Z (public: void __thiscall CAtaDrive::BlockToChs(int,int *,int *,int *)): + E00012D5: 55 push ebp + E00012D6: 8B EC mov ebp,esp + E00012D8: 51 push ecx + E00012D9: 89 4D FC mov dword ptr [ebp-4],ecx + E00012DC: 8B 45 FC mov eax,dword ptr [ebp-4] + E00012DF: 33 C9 xor ecx,ecx + E00012E1: 66 8B 48 1E mov cx,word ptr [eax+1Eh] + E00012E5: 8B 45 08 mov eax,dword ptr [ebp+8] + E00012E8: 99 cwd + E00012E9: F7 F9 idiv eax,ecx + E00012EB: 83 C2 01 add edx,1 + E00012EE: 8B 45 14 mov eax,dword ptr [ebp+14h] + E00012F1: 89 10 mov dword ptr [eax],edx + E00012F3: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00012F6: 33 D2 xor edx,edx + E00012F8: 66 8B 51 1E mov dx,word ptr [ecx+1Eh] + E00012FC: 8B CA mov ecx,edx + E00012FE: 8B 45 08 mov eax,dword ptr [ebp+8] + E0001301: 99 cwd + E0001302: F7 F9 idiv eax,ecx + E0001304: 89 45 08 mov dword ptr [ebp+8],eax + E0001307: 8B 55 FC mov edx,dword ptr [ebp-4] + E000130A: 33 C0 xor eax,eax + E000130C: 66 8B 42 20 mov ax,word ptr [edx+20h] + E0001310: 8B C8 mov ecx,eax + E0001312: 8B 45 08 mov eax,dword ptr [ebp+8] + E0001315: 99 cwd + E0001316: F7 F9 idiv eax,ecx + E0001318: 8B 45 10 mov eax,dword ptr [ebp+10h] + E000131B: 89 10 mov dword ptr [eax],edx + E000131D: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0001320: 33 D2 xor edx,edx + E0001322: 66 8B 51 20 mov dx,word ptr [ecx+20h] + E0001326: 8B CA mov ecx,edx + E0001328: 8B 45 08 mov eax,dword ptr [ebp+8] + E000132B: 99 cwd + E000132C: F7 F9 idiv eax,ecx + E000132E: 89 45 08 mov dword ptr [ebp+8],eax + E0001331: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0001334: 8B 45 08 mov eax,dword ptr [ebp+8] + E0001337: 89 02 mov dword ptr [edx],eax + E0001339: 8B E5 mov esp,ebp + E000133B: 5D pop ebp + E000133C: C2 10 00 ret 10h +?BlockRead@CAtaDrive@@UAAIIIPAX@Z (public: virtual unsigned int __cdecl CAtaDrive::BlockRead(unsigned int,unsigned int,void *)): + E000133F: 55 push ebp + E0001340: 8B EC mov ebp,esp + E0001342: 83 EC 4C sub esp,4Ch + E0001345: 53 push ebx + E0001346: 56 push esi + E0001347: 57 push edi + E0001348: 8B 45 08 mov eax,dword ptr [ebp+8] + E000134B: 33 C9 xor ecx,ecx + E000134D: 66 8B 48 1C mov cx,word ptr [eax+1Ch] + E0001351: 39 4D 10 cmp dword ptr [ebp+10h],ecx + E0001354: 73 08 jae E000135E + E0001356: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0001359: 89 55 B4 mov dword ptr [ebp-4Ch],edx + E000135C: EB 0C jmp E000136A + E000135E: 8B 45 08 mov eax,dword ptr [ebp+8] + E0001361: 33 C9 xor ecx,ecx + E0001363: 66 8B 48 1C mov cx,word ptr [eax+1Ch] + E0001367: 89 4D B4 mov dword ptr [ebp-4Ch],ecx + E000136A: 8B 55 B4 mov edx,dword ptr [ebp-4Ch] + E000136D: 89 55 F0 mov dword ptr [ebp-10h],edx + E0001370: 8B 45 08 mov eax,dword ptr [ebp+8] + E0001373: 33 C9 xor ecx,ecx + E0001375: 66 8B 48 18 mov cx,word ptr [eax+18h] + E0001379: 85 C9 test ecx,ecx + E000137B: 74 0D je E000138A + E000137D: 8B 55 08 mov edx,dword ptr [ebp+8] + E0001380: 33 C0 xor eax,eax + E0001382: 66 8B 42 16 mov ax,word ptr [edx+16h] + E0001386: 85 C0 test eax,eax + E0001388: 75 07 jne E0001391 + E000138A: 33 C0 xor eax,eax + E000138C: E9 CB 01 00 00 jmp E000155C + E0001391: 8B 4D 14 mov ecx,dword ptr [ebp+14h] + E0001394: 89 4D F4 mov dword ptr [ebp-0Ch],ecx + E0001397: 8B 55 08 mov edx,dword ptr [ebp+8] + E000139A: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000139D: 03 42 70 add eax,dword ptr [edx+70h] + E00013A0: 89 45 0C mov dword ptr [ebp+0Ch],eax + E00013A3: C7 45 E8 00 00 00 mov dword ptr [ebp-18h],0 + 00 + E00013AA: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E00013AD: 3B 4D 10 cmp ecx,dword ptr [ebp+10h] + E00013B0: 0F 83 A3 01 00 00 jae E0001559 + E00013B6: 8D 55 FC lea edx,dword ptr [ebp-4] + E00013B9: 52 push edx + E00013BA: 8D 45 F8 lea eax,dword ptr [ebp-8] + E00013BD: 50 push eax + E00013BE: 8D 4D EC lea ecx,dword ptr [ebp-14h] + E00013C1: 51 push ecx + E00013C2: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00013C5: 52 push edx + E00013C6: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00013C9: 83 E9 08 sub ecx,8 + E00013CC: E8 04 FF FF FF call E00012D5 + E00013D1: 6A 00 push 0 + E00013D3: 68 80 00 00 00 push 80h + E00013D8: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00013DB: 83 E9 08 sub ecx,8 + E00013DE: E8 31 FE FF FF call E0001214 + E00013E3: 25 FF 00 00 00 and eax,0FFh + E00013E8: 85 C0 test eax,eax + E00013EA: 75 08 jne E00013F4 + E00013EC: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E00013EF: E9 68 01 00 00 jmp E000155C + E00013F4: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00013F7: 83 E9 08 sub ecx,8 + E00013FA: E8 A2 FE FF FF call E00012A1 + E00013FF: 6A 40 push 40h + E0001401: 68 C0 00 00 00 push 0C0h + E0001406: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0001409: 83 E9 08 sub ecx,8 + E000140C: E8 03 FE FF FF call E0001214 + E0001411: 25 FF 00 00 00 and eax,0FFh + E0001416: 85 C0 test eax,eax + E0001418: 75 08 jne E0001422 + E000141A: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E000141D: E9 3A 01 00 00 jmp E000155C + E0001422: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0001425: 25 FF 00 00 00 and eax,0FFh + E000142A: 88 45 DC mov byte ptr [ebp-24h],al + E000142D: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0001430: 33 D2 xor edx,edx + E0001432: 66 8B 51 10 mov dx,word ptr [ecx+10h] + E0001436: 83 C2 04 add edx,4 + E0001439: 66 89 55 E0 mov word ptr [ebp-20h],dx + E000143D: 66 8B 55 E0 mov dx,word ptr [ebp-20h] + E0001441: 8A 45 DC mov al,byte ptr [ebp-24h] + E0001444: EE out dx,al + E0001445: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0001448: C1 F8 08 sar eax,8 + E000144B: 25 FF 00 00 00 and eax,0FFh + E0001450: 88 45 D4 mov byte ptr [ebp-2Ch],al + E0001453: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0001456: 33 D2 xor edx,edx + E0001458: 66 8B 51 10 mov dx,word ptr [ecx+10h] + E000145C: 83 C2 05 add edx,5 + E000145F: 66 89 55 D8 mov word ptr [ebp-28h],dx + E0001463: 66 8B 55 D8 mov dx,word ptr [ebp-28h] + E0001467: 8A 45 D4 mov al,byte ptr [ebp-2Ch] + E000146A: EE out dx,al + E000146B: 8B 45 08 mov eax,dword ptr [ebp+8] + E000146E: 33 C9 xor ecx,ecx + E0001470: 66 8B 48 10 mov cx,word ptr [eax+10h] + E0001474: 83 C1 03 add ecx,3 + E0001477: 66 89 4D D0 mov word ptr [ebp-30h],cx + E000147B: 66 8B 55 D0 mov dx,word ptr [ebp-30h] + E000147F: 8A 45 FC mov al,byte ptr [ebp-4] + E0001482: EE out dx,al + E0001483: 8B 55 08 mov edx,dword ptr [ebp+8] + E0001486: 33 C0 xor eax,eax + E0001488: 66 8B 42 10 mov ax,word ptr [edx+10h] + E000148C: 83 C0 06 add eax,6 + E000148F: 66 89 45 CC mov word ptr [ebp-34h],ax + E0001493: 66 8B 55 CC mov dx,word ptr [ebp-34h] + E0001497: 8A 45 F8 mov al,byte ptr [ebp-8] + E000149A: EE out dx,al + E000149B: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000149E: 33 D2 xor edx,edx + E00014A0: 66 8B 51 10 mov dx,word ptr [ecx+10h] + E00014A4: 83 C2 02 add edx,2 + E00014A7: 66 89 55 C8 mov word ptr [ebp-38h],dx + E00014AB: 66 8B 55 C8 mov dx,word ptr [ebp-38h] + E00014AF: 8A 45 F0 mov al,byte ptr [ebp-10h] + E00014B2: EE out dx,al + E00014B3: C6 45 C0 20 mov byte ptr [ebp-40h],20h + E00014B7: 8B 45 08 mov eax,dword ptr [ebp+8] + E00014BA: 33 C9 xor ecx,ecx + E00014BC: 66 8B 48 10 mov cx,word ptr [eax+10h] + E00014C0: 83 C1 07 add ecx,7 + E00014C3: 66 89 4D C4 mov word ptr [ebp-3Ch],cx + E00014C7: 66 8B 55 C4 mov dx,word ptr [ebp-3Ch] + E00014CB: 8A 45 C0 mov al,byte ptr [ebp-40h] + E00014CE: EE out dx,al + E00014CF: 6A 08 push 8 + E00014D1: 68 88 00 00 00 push 88h + E00014D6: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00014D9: 83 E9 08 sub ecx,8 + E00014DC: E8 33 FD FF FF call E0001214 + E00014E1: 25 FF 00 00 00 and eax,0FFh + E00014E6: 85 C0 test eax,eax + E00014E8: 75 05 jne E00014EF + E00014EA: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E00014ED: EB 6D jmp E000155C + E00014EF: C7 45 E4 00 00 00 mov dword ptr [ebp-1Ch],0 + 00 + E00014F6: EB 09 jmp E0001501 + E00014F8: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E00014FB: 83 C2 01 add edx,1 + E00014FE: 89 55 E4 mov dword ptr [ebp-1Ch],edx + E0001501: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E0001504: C1 E0 08 shl eax,8 + E0001507: 39 45 E4 cmp dword ptr [ebp-1Ch],eax + E000150A: 73 27 jae E0001533 + E000150C: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000150F: 66 8B 51 10 mov dx,word ptr [ecx+10h] + E0001513: 66 89 55 BC mov word ptr [ebp-44h],dx + E0001517: 33 C0 xor eax,eax + E0001519: 66 8B 55 BC mov dx,word ptr [ebp-44h] + E000151D: 66 ED in ax,dx + E000151F: 66 89 45 B8 mov word ptr [ebp-48h],ax + E0001523: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0001526: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0001529: 66 8B 55 B8 mov dx,word ptr [ebp-48h] + E000152D: 66 89 14 41 mov word ptr [ecx+eax*2],dx + E0001531: EB C5 jmp E00014F8 + E0001533: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0001536: 03 45 F0 add eax,dword ptr [ebp-10h] + E0001539: 89 45 E8 mov dword ptr [ebp-18h],eax + E000153C: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E000153F: 03 4D F0 add ecx,dword ptr [ebp-10h] + E0001542: 89 4D 0C mov dword ptr [ebp+0Ch],ecx + E0001545: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0001548: C1 E2 08 shl edx,8 + E000154B: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E000154E: 8D 0C 50 lea ecx,dword ptr [eax+edx*2] + E0001551: 89 4D F4 mov dword ptr [ebp-0Ch],ecx + E0001554: E9 51 FE FF FF jmp E00013AA + E0001559: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E000155C: 5F pop edi + E000155D: 5E pop esi + E000155E: 5B pop ebx + E000155F: 8B E5 mov esp,ebp + E0001561: 5D pop ebp + E0001562: C3 ret +?BlockWrite@CAtaDrive@@UAAIIIPBX@Z (public: virtual unsigned int __cdecl CAtaDrive::BlockWrite(unsigned int,unsigned int,void const *)): + E0001563: 55 push ebp + E0001564: 8B EC mov ebp,esp + E0001566: 33 C0 xor eax,eax + E0001568: 5D pop ebp + E0001569: C3 ret +?ConvertName@@YAPAGPBGHH@Z (unsigned short * __cdecl ConvertName(unsigned short const *,int,int)): + E000156A: 55 push ebp + E000156B: 8B EC mov ebp,esp + E000156D: 83 EC 0C sub esp,0Ch + E0001570: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E0001577: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000157A: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E000157D: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0001584: EB 09 jmp E000158F + E0001586: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0001589: 83 C1 01 add ecx,1 + E000158C: 89 4D F4 mov dword ptr [ebp-0Ch],ecx + E000158F: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0001592: 3B 55 10 cmp edx,dword ptr [ebp+10h] + E0001595: 7F 68 jg E00015FF + E0001597: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E000159A: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000159D: 33 D2 xor edx,edx + E000159F: 66 8B 14 41 mov dx,word ptr [ecx+eax*2] + E00015A3: 8B C2 mov eax,edx + E00015A5: 99 cwd + E00015A6: 81 E2 FF 00 00 00 and edx,0FFh + E00015AC: 03 C2 add eax,edx + E00015AE: C1 F8 08 sar eax,8 + E00015B1: 66 0F BE C0 movsx ax,al + E00015B5: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00015B8: 66 89 04 4D 58 C6 mov word ptr [ecx*2+E000C658h],ax + 00 E0 + E00015C0: 8B 55 FC mov edx,dword ptr [ebp-4] + E00015C3: 83 C2 01 add edx,1 + E00015C6: 89 55 FC mov dword ptr [ebp-4],edx + E00015C9: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E00015CC: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00015CF: 33 D2 xor edx,edx + E00015D1: 66 8B 14 41 mov dx,word ptr [ecx+eax*2] + E00015D5: 8B C2 mov eax,edx + E00015D7: 99 cwd + E00015D8: 33 C2 xor eax,edx + E00015DA: 2B C2 sub eax,edx + E00015DC: 25 FF 00 00 00 and eax,0FFh + E00015E1: 33 C2 xor eax,edx + E00015E3: 2B C2 sub eax,edx + E00015E5: 66 0F BE C0 movsx ax,al + E00015E9: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00015EC: 66 89 04 4D 58 C6 mov word ptr [ecx*2+E000C658h],ax + 00 E0 + E00015F4: 8B 55 FC mov edx,dword ptr [ebp-4] + E00015F7: 83 C2 01 add edx,1 + E00015FA: 89 55 FC mov dword ptr [ebp-4],edx + E00015FD: EB 87 jmp E0001586 + E00015FF: 8B 45 FC mov eax,dword ptr [ebp-4] + E0001602: 83 E8 01 sub eax,1 + E0001605: 89 45 FC mov dword ptr [ebp-4],eax + E0001608: EB 09 jmp E0001613 + E000160A: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000160D: 83 E9 01 sub ecx,1 + E0001610: 89 4D FC mov dword ptr [ebp-4],ecx + E0001613: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0001617: 7C 14 jl E000162D + E0001619: 8B 55 FC mov edx,dword ptr [ebp-4] + E000161C: 33 C0 xor eax,eax + E000161E: 66 8B 04 55 58 C6 mov ax,word ptr [edx*2+E000C658h] + 00 E0 + E0001626: 83 F8 20 cmp eax,20h + E0001629: 75 02 jne E000162D + E000162B: EB DD jmp E000160A + E000162D: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0001630: 66 C7 04 4D 5A C6 mov word ptr [ecx*2+E000C65Ah],0 + 00 E0 00 00 + E000163A: B8 58 C6 00 E0 mov eax,0E000C658h + E000163F: 8B E5 mov esp,ebp + E0001641: 5D pop ebp + E0001642: C3 ret +?part_type@@YAPBGH@Z (unsigned short const * __cdecl part_type(int)): + E0001643: 55 push ebp + E0001644: 8B EC mov ebp,esp + E0001646: 51 push ecx + E0001647: 8B 45 08 mov eax,dword ptr [ebp+8] + E000164A: 89 45 FC mov dword ptr [ebp-4],eax + E000164D: 81 7D FC EB 00 00 cmp dword ptr [ebp-4],0EBh + 00 + E0001654: 77 66 ja E00016BC + E0001656: 8B 55 FC mov edx,dword ptr [ebp-4] + E0001659: 33 C9 xor ecx,ecx + E000165B: 8A 8A F9 16 00 E0 mov cl,byte ptr [edx+E00016F9h] + E0001661: FF 24 8D C5 16 00 jmp dword ptr [ecx*4+E00016C5h] + E0 + E0001668: B8 3C B0 00 E0 mov eax,0E000B03Ch + E000166D: EB 52 jmp E00016C1 + E000166F: B8 60 B0 00 E0 mov eax,0E000B060h + E0001674: EB 4B jmp E00016C1 + E0001676: B8 84 B0 00 E0 mov eax,0E000B084h + E000167B: EB 44 jmp E00016C1 + E000167D: B8 B4 B0 00 E0 mov eax,0E000B0B4h + E0001682: EB 3D jmp E00016C1 + E0001684: B8 DC B0 00 E0 mov eax,0E000B0DCh + E0001689: EB 36 jmp E00016C1 + E000168B: B8 08 B1 00 E0 mov eax,0E000B108h + E0001690: EB 2F jmp E00016C1 + E0001692: B8 2C B1 00 E0 mov eax,0E000B12Ch + E0001697: EB 28 jmp E00016C1 + E0001699: B8 4C B1 00 E0 mov eax,0E000B14Ch + E000169E: EB 21 jmp E00016C1 + E00016A0: B8 78 B1 00 E0 mov eax,0E000B178h + E00016A5: EB 1A jmp E00016C1 + E00016A7: B8 98 B1 00 E0 mov eax,0E000B198h + E00016AC: EB 13 jmp E00016C1 + E00016AE: B8 C0 B1 00 E0 mov eax,0E000B1C0h + E00016B3: EB 0C jmp E00016C1 + E00016B5: B8 E8 B1 00 E0 mov eax,0E000B1E8h + E00016BA: EB 05 jmp E00016C1 + E00016BC: B8 08 B2 00 E0 mov eax,0E000B208h + E00016C1: 8B E5 mov esp,ebp + E00016C3: 5D pop ebp + E00016C4: C3 ret + E00016C5: 68 16 00 E0 6F push 6FE00016h + E00016CA: 16 push ss + E00016CB: 00 E0 add al,ah + E00016CD: 76 16 jbe E00016E5 + E00016CF: 00 E0 add al,ah + E00016D1: 7D 16 jge E00016E9 + E00016D3: 00 E0 add al,ah + E00016D5: 84 16 test byte ptr [esi],dl + E00016D7: 00 E0 add al,ah + E00016D9: 8B 16 mov edx,dword ptr [esi] + E00016DB: 00 E0 add al,ah + E00016DD: 92 xchg eax,edx + E00016DE: 16 push ss + E00016DF: 00 E0 add al,ah + E00016E1: 99 cwd + E00016E2: 16 push ss + E00016E3: 00 E0 add al,ah + E00016E5: A0 16 00 E0 A7 mov al,[A7E00016] + E00016EA: 16 push ss + E00016EB: 00 E0 add al,ah + E00016ED: AE scas byte ptr es:[edi] + E00016EE: 16 push ss + E00016EF: 00 E0 add al,ah + E00016F1: B5 16 mov ch,16h + E00016F3: 00 E0 add al,ah + E00016F5: BC 16 00 E0 00 mov esp,0E00016h + E00016FA: 01 0C 0C add dword ptr [esp+ecx],ecx + E00016FD: 02 03 add al,byte ptr [ebx] + E00016FF: 04 0C add al,0Ch + E0001701: 0C 0C or al,0Ch + E0001703: 0C 0C or al,0Ch + E0001705: 05 0C 0C 06 0C add eax,0C060C0Ch + E000170A: 0C 0C or al,0Ch + E000170C: 0C 0C or al,0Ch + E000170E: 0C 0C or al,0Ch + E0001710: 0C 0C or al,0Ch + E0001712: 0C 0C or al,0Ch + E0001714: 0C 0C or al,0Ch + E0001716: 0C 0C or al,0Ch + E0001718: 0C 0C or al,0Ch + E000171A: 0C 0C or al,0Ch + E000171C: 0C 0C or al,0Ch + E000171E: 0C 0C or al,0Ch + E0001720: 0C 0C or al,0Ch + E0001722: 0C 0C or al,0Ch + E0001724: 0C 0C or al,0Ch + E0001726: 0C 0C or al,0Ch + E0001728: 0C 0C or al,0Ch + E000172A: 0C 0C or al,0Ch + E000172C: 0C 0C or al,0Ch + E000172E: 0C 0C or al,0Ch + E0001730: 0C 0C or al,0Ch + E0001732: 0C 0C or al,0Ch + E0001734: 0C 0C or al,0Ch + E0001736: 0C 0C or al,0Ch + E0001738: 0C 0C or al,0Ch + E000173A: 0C 0C or al,0Ch + E000173C: 0C 0C or al,0Ch + E000173E: 0C 0C or al,0Ch + E0001740: 0C 0C or al,0Ch + E0001742: 0C 0C or al,0Ch + E0001744: 0C 0C or al,0Ch + E0001746: 0C 0C or al,0Ch + E0001748: 0C 0C or al,0Ch + E000174A: 0C 0C or al,0Ch + E000174C: 0C 0C or al,0Ch + E000174E: 0C 0C or al,0Ch + E0001750: 0C 0C or al,0Ch + E0001752: 0C 0C or al,0Ch + E0001754: 0C 0C or al,0Ch + E0001756: 0C 0C or al,0Ch + E0001758: 0C 0C or al,0Ch + E000175A: 0C 0C or al,0Ch + E000175C: 0C 0C or al,0Ch + E000175E: 0C 0C or al,0Ch + E0001760: 0C 0C or al,0Ch + E0001762: 0C 0C or al,0Ch + E0001764: 0C 0C or al,0Ch + E0001766: 0C 0C or al,0Ch + E0001768: 0C 0C or al,0Ch + E000176A: 0C 0C or al,0Ch + E000176C: 0C 0C or al,0Ch + E000176E: 0C 0C or al,0Ch + E0001770: 0C 0C or al,0Ch + E0001772: 0C 0C or al,0Ch + E0001774: 0C 0C or al,0Ch + E0001776: 0C 0C or al,0Ch + E0001778: 0C 0C or al,0Ch + E000177A: 0C 07 or al,7 + E000177C: 08 0C 0C or byte ptr [esp+ecx],cl + E000177F: 0C 0C or al,0Ch + E0001781: 0C 0C or al,0Ch + E0001783: 0C 0C or al,0Ch + E0001785: 0C 0C or al,0Ch + E0001787: 0C 0C or al,0Ch + E0001789: 0C 0C or al,0Ch + E000178B: 0C 0C or al,0Ch + E000178D: 0C 0C or al,0Ch + E000178F: 0C 0C or al,0Ch + E0001791: 0C 0C or al,0Ch + E0001793: 0C 0C or al,0Ch + E0001795: 0C 0C or al,0Ch + E0001797: 0C 0C or al,0Ch + E0001799: 0C 0C or al,0Ch + E000179B: 0C 0C or al,0Ch + E000179D: 0C 09 or al,9 + E000179F: 0A 0C 0C or cl,byte ptr [esp+ecx] + E00017A2: 0C 0C or al,0Ch + E00017A4: 0C 0C or al,0Ch + E00017A6: 0C 0C or al,0Ch + E00017A8: 0C 0C or al,0Ch + E00017AA: 0C 0C or al,0Ch + E00017AC: 0C 0C or al,0Ch + E00017AE: 0C 0C or al,0Ch + E00017B0: 0C 0C or al,0Ch + E00017B2: 0C 0C or al,0Ch + E00017B4: 0C 0C or al,0Ch + E00017B6: 0C 0C or al,0Ch + E00017B8: 0C 0C or al,0Ch + E00017BA: 0C 0C or al,0Ch + E00017BC: 0C 0C or al,0Ch + E00017BE: 0C 0C or al,0Ch + E00017C0: 0C 0C or al,0Ch + E00017C2: 0C 0C or al,0Ch + E00017C4: 0C 0C or al,0Ch + E00017C6: 0C 0C or al,0Ch + E00017C8: 0C 0C or al,0Ch + E00017CA: 0C 0C or al,0Ch + E00017CC: 0C 0C or al,0Ch + E00017CE: 0C 0C or al,0Ch + E00017D0: 0C 0C or al,0Ch + E00017D2: 0C 0C or al,0Ch + E00017D4: 0C 0C or al,0Ch + E00017D6: 0C 0C or al,0Ch + E00017D8: 0C 0C or al,0Ch + E00017DA: 0C 0C or al,0Ch + E00017DC: 0C 0C or al,0Ch + E00017DE: 0C 0C or al,0Ch + E00017E0: 0C 0C or al,0Ch + E00017E2: 0C 0C or al,0Ch + E00017E4: 0B 55 8B or edx,dword ptr [ebp-75h] +?ataDetect@@YAXXZ (void __cdecl ataDetect(void)) + 2: + E00017E7: EC in al,dx + E00017E8: 81 EC CC 02 00 00 sub esp,2CCh + E00017EE: 53 push ebx + E00017EF: 56 push esi + E00017F0: 57 push edi + E00017F1: 66 C7 45 D8 F0 01 mov word ptr [ebp-28h],1F0h + E00017F7: 66 C7 45 DA F0 01 mov word ptr [ebp-26h],1F0h + E00017FD: 66 C7 45 DC 70 01 mov word ptr [ebp-24h],170h + E0001803: 66 C7 45 DE 70 01 mov word ptr [ebp-22h],170h + E0001809: C6 85 BC FD FF FF mov byte ptr [ebp+FFFFFDBCh],0A0h + A0 + E0001810: C6 85 BD FD FF FF mov byte ptr [ebp+FFFFFDBDh],0B0h + B0 + E0001817: C6 85 BE FD FF FF mov byte ptr [ebp+FFFFFDBEh],0A0h + A0 + E000181E: C6 85 BF FD FF FF mov byte ptr [ebp+FFFFFDBFh],0B0h + B0 + E0001825: 66 C7 85 C4 FD FF mov word ptr [ebp+FFFFFDC4h],4000h + FF 00 40 + E000182E: 66 C7 85 C6 FD FF mov word ptr [ebp+FFFFFDC6h],4000h + FF 00 40 + E0001837: 66 C7 85 C8 FD FF mov word ptr [ebp+FFFFFDC8h],8000h + FF 00 80 + E0001840: 66 C7 85 CA FD FF mov word ptr [ebp+FFFFFDCAh],8000h + FF 00 80 + E0001849: C6 45 E4 00 mov byte ptr [ebp-1Ch],0 + E000184D: 6A 00 push 0 + E000184F: 68 00 10 00 E0 push 0E0001000h + E0001854: 6A 0E push 0Eh + E0001856: E8 D3 86 00 00 call E0009F2E + E000185B: 83 C4 0C add esp,0Ch + E000185E: 6A 00 push 0 + E0001860: 68 00 10 00 E0 push 0E0001000h + E0001865: 6A 0F push 0Fh + E0001867: E8 C2 86 00 00 call E0009F2E + E000186C: 83 C4 0C add esp,0Ch + E000186F: 8D 45 8A lea eax,dword ptr [ebp-76h] + E0001872: 89 85 C0 FD FF FF mov dword ptr [ebp+FFFFFDC0h],eax + E0001878: C7 45 D0 00 00 00 mov dword ptr [ebp-30h],0 + 00 + E000187F: EB 09 jmp E000188A + E0001881: 8B 4D D0 mov ecx,dword ptr [ebp-30h] + E0001884: 83 C1 01 add ecx,1 + E0001887: 89 4D D0 mov dword ptr [ebp-30h],ecx + E000188A: 83 7D D0 04 cmp dword ptr [ebp-30h],4 + E000188E: 0F 8D 95 09 00 00 jge E0002229 + E0001894: 8B 55 D0 mov edx,dword ptr [ebp-30h] + E0001897: 52 push edx + E0001898: 68 18 B2 00 E0 push 0E000B218h + E000189D: E8 6E 86 00 00 call E0009F10 + E00018A2: 83 C4 08 add esp,8 + E00018A5: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E00018A8: 33 C9 xor ecx,ecx + E00018AA: 8A 8C 05 BC FD FF mov cl,byte ptr [ebp+eax+FFFFFDBCh] + FF + E00018B1: 81 F9 A0 00 00 00 cmp ecx,0A0h + E00018B7: 0F 85 FA 00 00 00 jne E00019B7 + E00018BD: C6 85 98 FD FF FF mov byte ptr [ebp+FFFFFD98h],6 + 06 + E00018C4: 8B 55 D0 mov edx,dword ptr [ebp-30h] + E00018C7: 33 C0 xor eax,eax + E00018C9: 66 8B 44 55 D8 mov ax,word ptr [ebp+edx*2-28h] + E00018CE: 05 06 02 00 00 add eax,206h + E00018D3: 66 89 85 9C FD FF mov word ptr [ebp+FFFFFD9Ch],ax + FF + E00018DA: 66 8B 95 9C FD FF mov dx,word ptr [ebp+FFFFFD9Ch] + FF + E00018E1: 8A 85 98 FD FF FF mov al,byte ptr [ebp+FFFFFD98h] + E00018E7: EE out dx,al + E00018E8: 68 90 01 00 00 push 190h + E00018ED: E8 0E 40 00 00 call E0005900 + E00018F2: 83 C4 04 add esp,4 + E00018F5: C6 85 90 FD FF FF mov byte ptr [ebp+FFFFFD90h],0 + 00 + E00018FC: 8B 4D D0 mov ecx,dword ptr [ebp-30h] + E00018FF: 33 D2 xor edx,edx + E0001901: 66 8B 54 4D D8 mov dx,word ptr [ebp+ecx*2-28h] + E0001906: 81 C2 06 02 00 00 add edx,206h + E000190C: 66 89 95 94 FD FF mov word ptr [ebp+FFFFFD94h],dx + FF + E0001913: 66 8B 95 94 FD FF mov dx,word ptr [ebp+FFFFFD94h] + FF + E000191A: 8A 85 90 FD FF FF mov al,byte ptr [ebp+FFFFFD90h] + E0001920: EE out dx,al + E0001921: 68 90 01 00 00 push 190h + E0001926: E8 D5 3F 00 00 call E0005900 + E000192B: 83 C4 04 add esp,4 + E000192E: E8 E3 85 00 00 call E0009F16 + E0001933: 05 88 13 00 00 add eax,1388h + E0001938: 89 45 E0 mov dword ptr [ebp-20h],eax + E000193B: C6 45 E4 00 mov byte ptr [ebp-1Ch],0 + E000193F: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E0001942: 33 C9 xor ecx,ecx + E0001944: 66 8B 4C 45 D8 mov cx,word ptr [ebp+eax*2-28h] + E0001949: 83 C1 07 add ecx,7 + E000194C: 66 89 8D 8C FD FF mov word ptr [ebp+FFFFFD8Ch],cx + FF + E0001953: 33 C0 xor eax,eax + E0001955: 66 8B 95 8C FD FF mov dx,word ptr [ebp+FFFFFD8Ch] + FF + E000195C: EC in al,dx + E000195D: 88 45 E8 mov byte ptr [ebp-18h],al + E0001960: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E0001963: 81 E2 FF 00 00 00 and edx,0FFh + E0001969: 81 E2 C1 00 00 00 and edx,0C1h + E000196F: 83 FA 40 cmp edx,40h + E0001972: 74 12 je E0001986 + E0001974: E8 9D 85 00 00 call E0009F16 + E0001979: 3B 45 E0 cmp eax,dword ptr [ebp-20h] + E000197C: 72 06 jb E0001984 + E000197E: C6 45 E4 01 mov byte ptr [ebp-1Ch],1 + E0001982: EB 02 jmp E0001986 + E0001984: EB B9 jmp E000193F + E0001986: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0001989: 25 FF 00 00 00 and eax,0FFh + E000198E: 85 C0 test eax,eax + E0001990: 74 25 je E00019B7 + E0001992: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E0001995: 81 E1 FF 00 00 00 and ecx,0FFh + E000199B: 51 push ecx + E000199C: 68 48 B2 00 E0 push 0E000B248h + E00019A1: E8 6A 85 00 00 call E0009F10 + E00019A6: 83 C4 08 add esp,8 + E00019A9: 8B 55 D0 mov edx,dword ptr [ebp-30h] + E00019AC: 83 C2 01 add edx,1 + E00019AF: 89 55 D0 mov dword ptr [ebp-30h],edx + E00019B2: E9 CA FE FF FF jmp E0001881 + E00019B7: C6 45 E4 00 mov byte ptr [ebp-1Ch],0 + E00019BB: E8 56 85 00 00 call E0009F16 + E00019C0: 05 D0 07 00 00 add eax,7D0h + E00019C5: 89 45 E0 mov dword ptr [ebp-20h],eax + E00019C8: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E00019CB: 33 C9 xor ecx,ecx + E00019CD: 66 8B 4C 45 D8 mov cx,word ptr [ebp+eax*2-28h] + E00019D2: 83 C1 07 add ecx,7 + E00019D5: 66 89 8D 88 FD FF mov word ptr [ebp+FFFFFD88h],cx + FF + E00019DC: 33 C0 xor eax,eax + E00019DE: 66 8B 95 88 FD FF mov dx,word ptr [ebp+FFFFFD88h] + FF + E00019E5: EC in al,dx + E00019E6: 88 85 84 FD FF FF mov byte ptr [ebp+FFFFFD84h],al + E00019EC: 8B 95 84 FD FF FF mov edx,dword ptr [ebp+FFFFFD84h] + E00019F2: 81 E2 FF 00 00 00 and edx,0FFh + E00019F8: 81 E2 80 00 00 00 and edx,80h + E00019FE: 88 55 E8 mov byte ptr [ebp-18h],dl + E0001A01: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0001A04: 25 FF 00 00 00 and eax,0FFh + E0001A09: 85 C0 test eax,eax + E0001A0B: 74 12 je E0001A1F + E0001A0D: E8 04 85 00 00 call E0009F16 + E0001A12: 3B 45 E0 cmp eax,dword ptr [ebp-20h] + E0001A15: 72 06 jb E0001A1D + E0001A17: C6 45 E4 01 mov byte ptr [ebp-1Ch],1 + E0001A1B: EB 02 jmp E0001A1F + E0001A1D: EB A9 jmp E00019C8 + E0001A1F: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0001A22: 81 E1 FF 00 00 00 and ecx,0FFh + E0001A28: 85 C9 test ecx,ecx + E0001A2A: 74 1C je E0001A48 + E0001A2C: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E0001A2F: 81 E2 FF 00 00 00 and edx,0FFh + E0001A35: 52 push edx + E0001A36: 68 88 B2 00 E0 push 0E000B288h + E0001A3B: E8 D0 84 00 00 call E0009F10 + E0001A40: 83 C4 08 add esp,8 + E0001A43: E9 39 FE FF FF jmp E0001881 + E0001A48: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E0001A4B: 8A 8C 05 BC FD FF mov cl,byte ptr [ebp+eax+FFFFFDBCh] + FF + E0001A52: 88 8D 7C FD FF FF mov byte ptr [ebp+FFFFFD7Ch],cl + E0001A58: 8B 55 D0 mov edx,dword ptr [ebp-30h] + E0001A5B: 33 C0 xor eax,eax + E0001A5D: 66 8B 44 55 D8 mov ax,word ptr [ebp+edx*2-28h] + E0001A62: 83 C0 06 add eax,6 + E0001A65: 66 89 85 80 FD FF mov word ptr [ebp+FFFFFD80h],ax + FF + E0001A6C: 66 8B 95 80 FD FF mov dx,word ptr [ebp+FFFFFD80h] + FF + E0001A73: 8A 85 7C FD FF FF mov al,byte ptr [ebp+FFFFFD7Ch] + E0001A79: EE out dx,al + E0001A7A: E8 97 84 00 00 call E0009F16 + E0001A7F: 05 D0 07 00 00 add eax,7D0h + E0001A84: 89 45 E0 mov dword ptr [ebp-20h],eax + E0001A87: 8B 4D D0 mov ecx,dword ptr [ebp-30h] + E0001A8A: 33 D2 xor edx,edx + E0001A8C: 66 8B 54 4D D8 mov dx,word ptr [ebp+ecx*2-28h] + E0001A91: 83 C2 07 add edx,7 + E0001A94: 66 89 95 78 FD FF mov word ptr [ebp+FFFFFD78h],dx + FF + E0001A9B: 33 C0 xor eax,eax + E0001A9D: 66 8B 95 78 FD FF mov dx,word ptr [ebp+FFFFFD78h] + FF + E0001AA4: EC in al,dx + E0001AA5: 88 85 74 FD FF FF mov byte ptr [ebp+FFFFFD74h],al + E0001AAB: 8B 85 74 FD FF FF mov eax,dword ptr [ebp+FFFFFD74h] + E0001AB1: 25 FF 00 00 00 and eax,0FFh + E0001AB6: 83 E0 40 and eax,40h + E0001AB9: 88 45 E8 mov byte ptr [ebp-18h],al + E0001ABC: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E0001ABF: 81 E1 FF 00 00 00 and ecx,0FFh + E0001AC5: 85 C9 test ecx,ecx + E0001AC7: 75 12 jne E0001ADB + E0001AC9: E8 48 84 00 00 call E0009F16 + E0001ACE: 3B 45 E0 cmp eax,dword ptr [ebp-20h] + E0001AD1: 72 06 jb E0001AD9 + E0001AD3: C6 45 E4 01 mov byte ptr [ebp-1Ch],1 + E0001AD7: EB 02 jmp E0001ADB + E0001AD9: EB AC jmp E0001A87 + E0001ADB: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0001ADE: 81 E2 FF 00 00 00 and edx,0FFh + E0001AE4: 85 D2 test edx,edx + E0001AE6: 74 1B je E0001B03 + E0001AE8: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0001AEB: 25 FF 00 00 00 and eax,0FFh + E0001AF0: 50 push eax + E0001AF1: 68 C8 B2 00 E0 push 0E000B2C8h + E0001AF6: E8 15 84 00 00 call E0009F10 + E0001AFB: 83 C4 08 add esp,8 + E0001AFE: E9 7E FD FF FF jmp E0001881 + E0001B03: C6 85 6C FD FF FF mov byte ptr [ebp+FFFFFD6Ch],0ECh + EC + E0001B0A: 8B 4D D0 mov ecx,dword ptr [ebp-30h] + E0001B0D: 33 D2 xor edx,edx + E0001B0F: 66 8B 54 4D D8 mov dx,word ptr [ebp+ecx*2-28h] + E0001B14: 83 C2 07 add edx,7 + E0001B17: 66 89 95 70 FD FF mov word ptr [ebp+FFFFFD70h],dx + FF + E0001B1E: 66 8B 95 70 FD FF mov dx,word ptr [ebp+FFFFFD70h] + FF + E0001B25: 8A 85 6C FD FF FF mov al,byte ptr [ebp+FFFFFD6Ch] + E0001B2B: EE out dx,al + E0001B2C: E8 E5 83 00 00 call E0009F16 + E0001B31: 05 D0 07 00 00 add eax,7D0h + E0001B36: 89 45 E0 mov dword ptr [ebp-20h],eax + E0001B39: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E0001B3C: 33 C9 xor ecx,ecx + E0001B3E: 66 8B 4C 45 D8 mov cx,word ptr [ebp+eax*2-28h] + E0001B43: 83 C1 07 add ecx,7 + E0001B46: 66 89 8D 68 FD FF mov word ptr [ebp+FFFFFD68h],cx + FF + E0001B4D: 33 C0 xor eax,eax + E0001B4F: 66 8B 95 68 FD FF mov dx,word ptr [ebp+FFFFFD68h] + FF + E0001B56: EC in al,dx + E0001B57: 88 85 64 FD FF FF mov byte ptr [ebp+FFFFFD64h],al + E0001B5D: 8B 95 64 FD FF FF mov edx,dword ptr [ebp+FFFFFD64h] + E0001B63: 81 E2 FF 00 00 00 and edx,0FFh + E0001B69: 83 E2 08 and edx,8 + E0001B6C: 88 55 E8 mov byte ptr [ebp-18h],dl + E0001B6F: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0001B72: 25 FF 00 00 00 and eax,0FFh + E0001B77: 85 C0 test eax,eax + E0001B79: 75 22 jne E0001B9D + E0001B7B: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E0001B7E: 81 E1 FF 00 00 00 and ecx,0FFh + E0001B84: 83 E1 01 and ecx,1 + E0001B87: 85 C9 test ecx,ecx + E0001B89: 75 0A jne E0001B95 + E0001B8B: E8 86 83 00 00 call E0009F16 + E0001B90: 3B 45 E0 cmp eax,dword ptr [ebp-20h] + E0001B93: 72 06 jb E0001B9B + E0001B95: C6 45 E4 01 mov byte ptr [ebp-1Ch],1 + E0001B99: EB 02 jmp E0001B9D + E0001B9B: EB 9C jmp E0001B39 + E0001B9D: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0001BA0: 81 E2 FF 00 00 00 and edx,0FFh + E0001BA6: 85 D2 test edx,edx + E0001BA8: 0F 84 DF 00 00 00 je E0001C8D + E0001BAE: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0001BB1: 25 FF 00 00 00 and eax,0FFh + E0001BB6: 50 push eax + E0001BB7: 68 0C B3 00 E0 push 0E000B30Ch + E0001BBC: E8 4F 83 00 00 call E0009F10 + E0001BC1: 83 C4 08 add esp,8 + E0001BC4: 66 C7 05 50 C6 00 mov word ptr ds:[E000C650h],0 + E0 00 00 + E0001BCD: C6 85 5C FD FF FF mov byte ptr [ebp+FFFFFD5Ch],0A1h + A1 + E0001BD4: 8B 4D D0 mov ecx,dword ptr [ebp-30h] + E0001BD7: 33 D2 xor edx,edx + E0001BD9: 66 8B 54 4D D8 mov dx,word ptr [ebp+ecx*2-28h] + E0001BDE: 83 C2 07 add edx,7 + E0001BE1: 66 89 95 60 FD FF mov word ptr [ebp+FFFFFD60h],dx + FF + E0001BE8: 66 8B 95 60 FD FF mov dx,word ptr [ebp+FFFFFD60h] + FF + E0001BEF: 8A 85 5C FD FF FF mov al,byte ptr [ebp+FFFFFD5Ch] + E0001BF5: EE out dx,al + E0001BF6: E8 1B 83 00 00 call E0009F16 + E0001BFB: 05 D0 07 00 00 add eax,7D0h + E0001C00: 89 45 E0 mov dword ptr [ebp-20h],eax + E0001C03: C6 45 E4 00 mov byte ptr [ebp-1Ch],0 + E0001C07: 33 C0 xor eax,eax + E0001C09: 66 A1 50 C6 00 E0 mov ax,[E000C650] + E0001C0F: 8B 4D D0 mov ecx,dword ptr [ebp-30h] + E0001C12: 33 D2 xor edx,edx + E0001C14: 66 8B 94 4D C4 FD mov dx,word ptr [ebp+ecx*2+FFFFFDC4h] + FF FF + E0001C1C: 23 C2 and eax,edx + E0001C1E: 85 C0 test eax,eax + E0001C20: 75 43 jne E0001C65 + E0001C22: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E0001C25: 33 C9 xor ecx,ecx + E0001C27: 66 8B 4C 45 D8 mov cx,word ptr [ebp+eax*2-28h] + E0001C2C: 83 C1 07 add ecx,7 + E0001C2F: 66 89 8D 58 FD FF mov word ptr [ebp+FFFFFD58h],cx + FF + E0001C36: 33 C0 xor eax,eax + E0001C38: 66 8B 95 58 FD FF mov dx,word ptr [ebp+FFFFFD58h] + FF + E0001C3F: EC in al,dx + E0001C40: 88 45 E8 mov byte ptr [ebp-18h],al + E0001C43: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E0001C46: 81 E2 FF 00 00 00 and edx,0FFh + E0001C4C: 83 E2 08 and edx,8 + E0001C4F: 85 D2 test edx,edx + E0001C51: 75 12 jne E0001C65 + E0001C53: E8 BE 82 00 00 call E0009F16 + E0001C58: 3B 45 E0 cmp eax,dword ptr [ebp-20h] + E0001C5B: 72 06 jb E0001C63 + E0001C5D: C6 45 E4 01 mov byte ptr [ebp-1Ch],1 + E0001C61: EB 02 jmp E0001C65 + E0001C63: EB A2 jmp E0001C07 + E0001C65: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0001C68: 25 FF 00 00 00 and eax,0FFh + E0001C6D: 85 C0 test eax,eax + E0001C6F: 74 1C je E0001C8D + E0001C71: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E0001C74: 81 E1 FF 00 00 00 and ecx,0FFh + E0001C7A: 51 push ecx + E0001C7B: 68 34 B3 00 E0 push 0E000B334h + E0001C80: E8 8B 82 00 00 call E0009F10 + E0001C85: 83 C4 08 add esp,8 + E0001C88: E9 F4 FB FF FF jmp E0001881 + E0001C8D: C7 45 D4 00 00 00 mov dword ptr [ebp-2Ch],0 + 00 + E0001C94: EB 09 jmp E0001C9F + E0001C96: 8B 55 D4 mov edx,dword ptr [ebp-2Ch] + E0001C99: 83 C2 01 add edx,1 + E0001C9C: 89 55 D4 mov dword ptr [ebp-2Ch],edx + E0001C9F: 81 7D D4 00 01 00 cmp dword ptr [ebp-2Ch],100h + 00 + E0001CA6: 74 35 je E0001CDD + E0001CA8: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E0001CAB: 66 8B 4C 45 D8 mov cx,word ptr [ebp+eax*2-28h] + E0001CB0: 66 89 8D 54 FD FF mov word ptr [ebp+FFFFFD54h],cx + FF + E0001CB7: 33 C0 xor eax,eax + E0001CB9: 66 8B 95 54 FD FF mov dx,word ptr [ebp+FFFFFD54h] + FF + E0001CC0: 66 ED in ax,dx + E0001CC2: 66 89 85 50 FD FF mov word ptr [ebp+FFFFFD50h],ax + FF + E0001CC9: 8B 55 D4 mov edx,dword ptr [ebp-2Ch] + E0001CCC: 66 8B 85 50 FD FF mov ax,word ptr [ebp+FFFFFD50h] + FF + E0001CD3: 66 89 84 55 CC FD mov word ptr [ebp+edx*2+FFFFFDCCh],ax + FF FF + E0001CDB: EB B9 jmp E0001C96 + E0001CDD: 68 84 00 00 00 push 84h + E0001CE2: E8 8F 82 00 00 call E0009F76 + E0001CE7: 83 C4 04 add esp,4 + E0001CEA: 89 85 A4 FD FF FF mov dword ptr [ebp+FFFFFDA4h],eax + E0001CF0: 83 BD A4 FD FF FF cmp dword ptr [ebp+FFFFFDA4h],0 + 00 + E0001CF7: 74 13 je E0001D0C + E0001CF9: 8B 8D A4 FD FF FF mov ecx,dword ptr [ebp+FFFFFDA4h] + E0001CFF: E8 1C F3 FF FF call E0001020 + E0001D04: 89 85 48 FD FF FF mov dword ptr [ebp+FFFFFD48h],eax + E0001D0A: EB 0A jmp E0001D16 + E0001D0C: C7 85 48 FD FF FF mov dword ptr [ebp+FFFFFD48h],0 + 00 00 00 00 + E0001D16: 8B 8D 48 FD FF FF mov ecx,dword ptr [ebp+FFFFFD48h] + E0001D1C: 89 8D B4 FD FF FF mov dword ptr [ebp+FFFFFDB4h],ecx + E0001D22: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E0001D28: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E0001D2B: 66 8B 4C 45 D8 mov cx,word ptr [ebp+eax*2-28h] + E0001D30: 66 89 4A 18 mov word ptr [edx+18h],cx + E0001D34: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E0001D3A: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E0001D3D: 66 8B 8C 45 C4 FD mov cx,word ptr [ebp+eax*2+FFFFFDC4h] + FF FF + E0001D45: 66 89 4A 1A mov word ptr [edx+1Ah],cx + E0001D49: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E0001D4F: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E0001D52: 8A 8C 05 BC FD FF mov cl,byte ptr [ebp+eax+FFFFFDBCh] + FF + E0001D59: 88 4A 1C mov byte ptr [edx+1Ch],cl + E0001D5C: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E0001D62: 66 8B 85 CE FD FF mov ax,word ptr [ebp+FFFFFDCEh] + FF + E0001D69: 66 89 42 22 mov word ptr [edx+22h],ax + E0001D6D: 8B 8D B4 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB4h] + E0001D73: 66 8B 95 D2 FD FF mov dx,word ptr [ebp+FFFFFDD2h] + FF + E0001D7A: 66 89 51 20 mov word ptr [ecx+20h],dx + E0001D7E: 8B 85 B4 FD FF FF mov eax,dword ptr [ebp+FFFFFDB4h] + E0001D84: 66 8B 8D D8 FD FF mov cx,word ptr [ebp+FFFFFDD8h] + FF + E0001D8B: 66 89 48 1E mov word ptr [eax+1Eh],cx + E0001D8F: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E0001D95: C7 42 78 00 00 00 mov dword ptr [edx+78h],0 + 00 + E0001D9C: 8B 85 B4 FD FF FF mov eax,dword ptr [ebp+FFFFFDB4h] + E0001DA2: 33 C9 xor ecx,ecx + E0001DA4: 66 8B 48 1E mov cx,word ptr [eax+1Eh] + E0001DA8: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E0001DAE: 33 C0 xor eax,eax + E0001DB0: 66 8B 42 20 mov ax,word ptr [edx+20h] + E0001DB4: 0F AF C8 imul ecx,eax + E0001DB7: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E0001DBD: 33 C0 xor eax,eax + E0001DBF: 66 8B 42 22 mov ax,word ptr [edx+22h] + E0001DC3: 0F AF C8 imul ecx,eax + E0001DC6: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E0001DCC: 89 4A 7C mov dword ptr [edx+7Ch],ecx + E0001DCF: 8B 85 BA FE FF FF mov eax,dword ptr [ebp+FFFFFEBAh] + E0001DD5: 25 FF FF 00 00 and eax,0FFFFh + E0001DDA: 83 E0 01 and eax,1 + E0001DDD: 85 C0 test eax,eax + E0001DDF: 74 23 je E0001E04 + E0001DE1: 8B 8D B8 FE FF FF mov ecx,dword ptr [ebp+FFFFFEB8h] + E0001DE7: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0001DED: 85 C9 test ecx,ecx + E0001DEF: 74 13 je E0001E04 + E0001DF1: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E0001DF7: 66 8B 85 88 FE FF mov ax,word ptr [ebp+FFFFFE88h] + FF + E0001DFE: 66 89 42 24 mov word ptr [edx+24h],ax + E0001E02: EB 0C jmp E0001E10 + E0001E04: 8B 8D B4 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB4h] + E0001E0A: 66 C7 41 24 01 00 mov word ptr [ecx+24h],1 + E0001E10: 6A 2E push 2Eh + E0001E12: 6A 1B push 1Bh + E0001E14: 8D 95 CC FD FF FF lea edx,dword ptr [ebp+FFFFFDCCh] + E0001E1A: 52 push edx + E0001E1B: E8 4A F7 FF FF call E000156A + E0001E20: 83 C4 0C add esp,0Ch + E0001E23: 50 push eax + E0001E24: 8B 85 B4 FD FF FF mov eax,dword ptr [ebp+FFFFFDB4h] + E0001E2A: 83 C0 26 add eax,26h + E0001E2D: 50 push eax + E0001E2E: E8 D7 80 00 00 call E0009F0A + E0001E33: 83 C4 08 add esp,8 + E0001E36: 68 64 B3 00 E0 push 0E000B364h + E0001E3B: 8B 8D B4 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB4h] + E0001E41: 83 C1 26 add ecx,26h + E0001E44: 51 push ecx + E0001E45: E8 DE 80 00 00 call E0009F28 + E0001E4A: 83 C4 08 add esp,8 + E0001E4D: 6A 13 push 13h + E0001E4F: 6A 0A push 0Ah + E0001E51: 8D 95 CC FD FF FF lea edx,dword ptr [ebp+FFFFFDCCh] + E0001E57: 52 push edx + E0001E58: E8 0D F7 FF FF call E000156A + E0001E5D: 83 C4 0C add esp,0Ch + E0001E60: 50 push eax + E0001E61: 8B 85 B4 FD FF FF mov eax,dword ptr [ebp+FFFFFDB4h] + E0001E67: 83 C0 26 add eax,26h + E0001E6A: 50 push eax + E0001E6B: E8 B8 80 00 00 call E0009F28 + E0001E70: 83 C4 08 add esp,8 + E0001E73: 8B 4D D0 mov ecx,dword ptr [ebp-30h] + E0001E76: 51 push ecx + E0001E77: 68 68 B3 00 E0 push 0E000B368h + E0001E7C: 8D 55 EC lea edx,dword ptr [ebp-14h] + E0001E7F: 52 push edx + E0001E80: E8 EB 80 00 00 call E0009F70 + E0001E85: 83 C4 0C add esp,0Ch + E0001E88: 83 BD B4 FD FF FF cmp dword ptr [ebp+FFFFFDB4h],0 + 00 + E0001E8F: 74 11 je E0001EA2 + E0001E91: 8B 85 B4 FD FF FF mov eax,dword ptr [ebp+FFFFFDB4h] + E0001E97: 83 C0 04 add eax,4 + E0001E9A: 89 85 44 FD FF FF mov dword ptr [ebp+FFFFFD44h],eax + E0001EA0: EB 0A jmp E0001EAC + E0001EA2: C7 85 44 FD FF FF mov dword ptr [ebp+FFFFFD44h],0 + 00 00 00 00 + E0001EAC: 8B 8D 44 FD FF FF mov ecx,dword ptr [ebp+FFFFFD44h] + E0001EB2: 51 push ecx + E0001EB3: 8D 55 EC lea edx,dword ptr [ebp-14h] + E0001EB6: 52 push edx + E0001EB7: E8 66 80 00 00 call E0009F22 + E0001EBC: 83 C4 08 add esp,8 + E0001EBF: 8B 85 B4 FD FF FF mov eax,dword ptr [ebp+FFFFFDB4h] + E0001EC5: 83 C0 26 add eax,26h + E0001EC8: 50 push eax + E0001EC9: 8D 4D EC lea ecx,dword ptr [ebp-14h] + E0001ECC: 51 push ecx + E0001ECD: 68 74 B3 00 E0 push 0E000B374h + E0001ED2: E8 39 80 00 00 call E0009F10 + E0001ED7: 83 C4 0C add esp,0Ch + E0001EDA: 8D 95 CC FD FF FF lea edx,dword ptr [ebp+FFFFFDCCh] + E0001EE0: 52 push edx + E0001EE1: 6A 01 push 1 + E0001EE3: 6A 00 push 0 + E0001EE5: 8B 85 B4 FD FF FF mov eax,dword ptr [ebp+FFFFFDB4h] + E0001EEB: 83 C0 08 add eax,8 + E0001EEE: 8B 8D B4 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB4h] + E0001EF4: 8B 51 08 mov edx,dword ptr [ecx+8] + E0001EF7: 50 push eax + E0001EF8: FF 52 10 call dword ptr [edx+10h] + E0001EFB: 83 C4 10 add esp,10h + E0001EFE: 85 C0 test eax,eax + E0001F00: 0F 84 11 03 00 00 je E0002217 + E0001F06: C7 45 CC 00 00 00 mov dword ptr [ebp-34h],0 + 00 + E0001F0D: EB 09 jmp E0001F18 + E0001F0F: 8B 45 CC mov eax,dword ptr [ebp-34h] + E0001F12: 83 C0 01 add eax,1 + E0001F15: 89 45 CC mov dword ptr [ebp-34h],eax + E0001F18: 83 7D CC 04 cmp dword ptr [ebp-34h],4 + E0001F1C: 0F 8D F5 02 00 00 jge E0002217 + E0001F22: 8B 4D CC mov ecx,dword ptr [ebp-34h] + E0001F25: C1 E1 04 shl ecx,4 + E0001F28: 8B 95 C0 FD FF FF mov edx,dword ptr [ebp+FFFFFDC0h] + E0001F2E: 33 C0 xor eax,eax + E0001F30: 8A 44 0A 03 mov al,byte ptr [edx+ecx+3] + E0001F34: 8B 4D CC mov ecx,dword ptr [ebp-34h] + E0001F37: C1 E1 04 shl ecx,4 + E0001F3A: 8B 95 C0 FD FF FF mov edx,dword ptr [ebp+FFFFFDC0h] + E0001F40: 33 DB xor ebx,ebx + E0001F42: 8A 5C 0A 02 mov bl,byte ptr [edx+ecx+2] + E0001F46: 81 E3 C0 00 00 00 and ebx,0C0h + E0001F4C: C1 E3 02 shl ebx,2 + E0001F4F: 0B C3 or eax,ebx + E0001F51: 66 89 85 AC FD FF mov word ptr [ebp+FFFFFDACh],ax + FF + E0001F58: 8B 45 CC mov eax,dword ptr [ebp-34h] + E0001F5B: C1 E0 04 shl eax,4 + E0001F5E: 8B 8D C0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDC0h] + E0001F64: 66 0F B6 54 01 01 movzx dx,byte ptr [ecx+eax+1] + E0001F6A: 66 89 95 A8 FD FF mov word ptr [ebp+FFFFFDA8h],dx + FF + E0001F71: 8B 45 CC mov eax,dword ptr [ebp-34h] + E0001F74: C1 E0 04 shl eax,4 + E0001F77: 8B 8D C0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDC0h] + E0001F7D: 33 D2 xor edx,edx + E0001F7F: 8A 54 01 02 mov dl,byte ptr [ecx+eax+2] + E0001F83: 83 E2 3F and edx,3Fh + E0001F86: 66 89 95 B0 FD FF mov word ptr [ebp+FFFFFDB0h],dx + FF + E0001F8D: 8B 45 CC mov eax,dword ptr [ebp-34h] + E0001F90: C1 E0 04 shl eax,4 + E0001F93: 8B 8D C0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDC0h] + E0001F99: 33 D2 xor edx,edx + E0001F9B: 8A 54 01 04 mov dl,byte ptr [ecx+eax+4] + E0001F9F: 85 D2 test edx,edx + E0001FA1: 0F 84 6B 02 00 00 je E0002212 + E0001FA7: 68 84 00 00 00 push 84h + E0001FAC: E8 C5 7F 00 00 call E0009F76 + E0001FB1: 83 C4 04 add esp,4 + E0001FB4: 89 85 A0 FD FF FF mov dword ptr [ebp+FFFFFDA0h],eax + E0001FBA: 83 BD A0 FD FF FF cmp dword ptr [ebp+FFFFFDA0h],0 + 00 + E0001FC1: 74 13 je E0001FD6 + E0001FC3: 8B 8D A0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDA0h] + E0001FC9: E8 52 F0 FF FF call E0001020 + E0001FCE: 89 85 40 FD FF FF mov dword ptr [ebp+FFFFFD40h],eax + E0001FD4: EB 0A jmp E0001FE0 + E0001FD6: C7 85 40 FD FF FF mov dword ptr [ebp+FFFFFD40h],0 + 00 00 00 00 + E0001FE0: 8B 85 40 FD FF FF mov eax,dword ptr [ebp+FFFFFD40h] + E0001FE6: 89 85 B8 FD FF FF mov dword ptr [ebp+FFFFFDB8h],eax + E0001FEC: 83 BD B4 FD FF FF cmp dword ptr [ebp+FFFFFDB4h],0 + 00 + E0001FF3: 74 11 je E0002006 + E0001FF5: 8B 8D B4 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB4h] + E0001FFB: 83 C1 04 add ecx,4 + E0001FFE: 89 8D 3C FD FF FF mov dword ptr [ebp+FFFFFD3Ch],ecx + E0002004: EB 0A jmp E0002010 + E0002006: C7 85 3C FD FF FF mov dword ptr [ebp+FFFFFD3Ch],0 + 00 00 00 00 + E0002010: 83 BD B4 FD FF FF cmp dword ptr [ebp+FFFFFDB4h],0 + 00 + E0002017: 74 11 je E000202A + E0002019: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E000201F: 83 C2 08 add edx,8 + E0002022: 89 95 38 FD FF FF mov dword ptr [ebp+FFFFFD38h],edx + E0002028: EB 0A jmp E0002034 + E000202A: C7 85 38 FD FF FF mov dword ptr [ebp+FFFFFD38h],0 + 00 00 00 00 + E0002034: 8B 85 B4 FD FF FF mov eax,dword ptr [ebp+FFFFFDB4h] + E000203A: 83 C0 0C add eax,0Ch + E000203D: 8B 8D B8 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB8h] + E0002043: 83 C1 0C add ecx,0Ch + E0002046: 8B 10 mov edx,dword ptr [eax] + E0002048: 89 11 mov dword ptr [ecx],edx + E000204A: 8B 50 04 mov edx,dword ptr [eax+4] + E000204D: 89 51 04 mov dword ptr [ecx+4],edx + E0002050: 8B 40 08 mov eax,dword ptr [eax+8] + E0002053: 89 41 08 mov dword ptr [ecx+8],eax + E0002056: 8B 8D B8 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB8h] + E000205C: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E0002062: 66 8B 42 18 mov ax,word ptr [edx+18h] + E0002066: 66 89 41 18 mov word ptr [ecx+18h],ax + E000206A: 8B 8D B8 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB8h] + E0002070: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E0002076: 66 8B 42 1A mov ax,word ptr [edx+1Ah] + E000207A: 66 89 41 1A mov word ptr [ecx+1Ah],ax + E000207E: 8B 8D B8 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB8h] + E0002084: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E000208A: 8A 42 1C mov al,byte ptr [edx+1Ch] + E000208D: 88 41 1C mov byte ptr [ecx+1Ch],al + E0002090: 8B 8D B8 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB8h] + E0002096: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E000209C: 66 8B 42 1E mov ax,word ptr [edx+1Eh] + E00020A0: 66 89 41 1E mov word ptr [ecx+1Eh],ax + E00020A4: 8B 8D B8 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB8h] + E00020AA: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E00020B0: 66 8B 42 20 mov ax,word ptr [edx+20h] + E00020B4: 66 89 41 20 mov word ptr [ecx+20h],ax + E00020B8: 8B 8D B8 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB8h] + E00020BE: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E00020C4: 66 8B 42 22 mov ax,word ptr [edx+22h] + E00020C8: 66 89 41 22 mov word ptr [ecx+22h],ax + E00020CC: 8B 8D B8 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB8h] + E00020D2: 8B 95 B4 FD FF FF mov edx,dword ptr [ebp+FFFFFDB4h] + E00020D8: 66 8B 42 24 mov ax,word ptr [edx+24h] + E00020DC: 66 89 41 24 mov word ptr [ecx+24h],ax + E00020E0: C7 85 4C FD FF FF mov dword ptr [ebp+FFFFFD4Ch],0 + 00 00 00 00 + E00020EA: EB 0F jmp E00020FB + E00020EC: 8B 8D 4C FD FF FF mov ecx,dword ptr [ebp+FFFFFD4Ch] + E00020F2: 83 C1 01 add ecx,1 + E00020F5: 89 8D 4C FD FF FF mov dword ptr [ebp+FFFFFD4Ch],ecx + E00020FB: 83 BD 4C FD FF FF cmp dword ptr [ebp+FFFFFD4Ch],29h + 29 + E0002102: 73 24 jae E0002128 + E0002104: 8B 95 4C FD FF FF mov edx,dword ptr [ebp+FFFFFD4Ch] + E000210A: 8B 85 B8 FD FF FF mov eax,dword ptr [ebp+FFFFFDB8h] + E0002110: 8B 8D 4C FD FF FF mov ecx,dword ptr [ebp+FFFFFD4Ch] + E0002116: 8B B5 B4 FD FF FF mov esi,dword ptr [ebp+FFFFFDB4h] + E000211C: 66 8B 4C 4E 26 mov cx,word ptr [esi+ecx*2+26h] + E0002121: 66 89 4C 50 26 mov word ptr [eax+edx*2+26h],cx + E0002126: EB C4 jmp E00020EC + E0002128: 8B 95 B8 FD FF FF mov edx,dword ptr [ebp+FFFFFDB8h] + E000212E: 8B 85 B4 FD FF FF mov eax,dword ptr [ebp+FFFFFDB4h] + E0002134: 8B 48 78 mov ecx,dword ptr [eax+78h] + E0002137: 89 4A 78 mov dword ptr [edx+78h],ecx + E000213A: 8B 95 B8 FD FF FF mov edx,dword ptr [ebp+FFFFFDB8h] + E0002140: 8B 85 B4 FD FF FF mov eax,dword ptr [ebp+FFFFFDB4h] + E0002146: 8B 48 7C mov ecx,dword ptr [eax+7Ch] + E0002149: 89 4A 7C mov dword ptr [edx+7Ch],ecx + E000214C: 8B 95 B8 FD FF FF mov edx,dword ptr [ebp+FFFFFDB8h] + E0002152: 8B 85 B4 FD FF FF mov eax,dword ptr [ebp+FFFFFDB4h] + E0002158: 8B 88 80 00 00 00 mov ecx,dword ptr [eax+00000080h] + E000215E: 89 8A 80 00 00 00 mov dword ptr [edx+00000080h],ecx + E0002164: 8B 55 CC mov edx,dword ptr [ebp-34h] + E0002167: C1 E2 04 shl edx,4 + E000216A: 8B 85 B8 FD FF FF mov eax,dword ptr [ebp+FFFFFDB8h] + E0002170: 8B 8D C0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDC0h] + E0002176: 8B 54 11 08 mov edx,dword ptr [ecx+edx+8] + E000217A: 89 50 78 mov dword ptr [eax+78h],edx + E000217D: 8B 45 CC mov eax,dword ptr [ebp-34h] + E0002180: C1 E0 04 shl eax,4 + E0002183: 8B 8D B8 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB8h] + E0002189: 8B 95 C0 FD FF FF mov edx,dword ptr [ebp+FFFFFDC0h] + E000218F: 8B 44 02 0C mov eax,dword ptr [edx+eax+0Ch] + E0002193: 89 41 7C mov dword ptr [ecx+7Ch],eax + E0002196: 8B 4D CC mov ecx,dword ptr [ebp-34h] + E0002199: 83 C1 61 add ecx,61h + E000219C: 51 push ecx + E000219D: 8B 55 D0 mov edx,dword ptr [ebp-30h] + E00021A0: 52 push edx + E00021A1: 68 A4 B3 00 E0 push 0E000B3A4h + E00021A6: 8D 45 EC lea eax,dword ptr [ebp-14h] + E00021A9: 50 push eax + E00021AA: E8 C1 7D 00 00 call E0009F70 + E00021AF: 83 C4 10 add esp,10h + E00021B2: 83 BD B8 FD FF FF cmp dword ptr [ebp+FFFFFDB8h],0 + 00 + E00021B9: 74 11 je E00021CC + E00021BB: 8B 8D B8 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB8h] + E00021C1: 83 C1 04 add ecx,4 + E00021C4: 89 8D 34 FD FF FF mov dword ptr [ebp+FFFFFD34h],ecx + E00021CA: EB 0A jmp E00021D6 + E00021CC: C7 85 34 FD FF FF mov dword ptr [ebp+FFFFFD34h],0 + 00 00 00 00 + E00021D6: 8B 95 34 FD FF FF mov edx,dword ptr [ebp+FFFFFD34h] + E00021DC: 52 push edx + E00021DD: 8D 45 EC lea eax,dword ptr [ebp-14h] + E00021E0: 50 push eax + E00021E1: E8 3C 7D 00 00 call E0009F22 + E00021E6: 83 C4 08 add esp,8 + E00021E9: 8B 4D CC mov ecx,dword ptr [ebp-34h] + E00021EC: C1 E1 04 shl ecx,4 + E00021EF: 8B 95 C0 FD FF FF mov edx,dword ptr [ebp+FFFFFDC0h] + E00021F5: 33 C0 xor eax,eax + E00021F7: 8A 44 0A 04 mov al,byte ptr [edx+ecx+4] + E00021FB: 50 push eax + E00021FC: E8 42 F4 FF FF call E0001643 + E0002201: 83 C4 04 add esp,4 + E0002204: 50 push eax + E0002205: 68 B4 B3 00 E0 push 0E000B3B4h + E000220A: E8 01 7D 00 00 call E0009F10 + E000220F: 83 C4 08 add esp,8 + E0002212: E9 F8 FC FF FF jmp E0001F0F + E0002217: 68 BC B3 00 E0 push 0E000B3BCh + E000221C: E8 FB 7C 00 00 call E0009F1C + E0002221: 83 C4 04 add esp,4 + E0002224: E9 58 F6 FF FF jmp E0001881 + E0002229: 68 C4 B3 00 E0 push 0E000B3C4h + E000222E: E8 DD 7C 00 00 call E0009F10 + E0002233: 83 C4 04 add esp,4 + E0002236: 5F pop edi + E0002237: 5E pop esi + E0002238: 5B pop ebx + E0002239: 8B E5 mov esp,ebp + E000223B: 5D pop ebp + E000223C: C3 ret + E000223D: CC int 3 + E000223E: CC int 3 + E000223F: CC int 3 +?AddRef@CAtaDrive@@UAAKXZ (public: virtual unsigned long __cdecl CAtaDrive::AddRef(void)): + E0002240: 55 push ebp + E0002241: 8B EC mov ebp,esp + E0002243: 8B 45 08 mov eax,dword ptr [ebp+8] + E0002246: 8B 88 80 00 00 00 mov ecx,dword ptr [eax+00000080h] + E000224C: 83 C1 01 add ecx,1 + E000224F: 8B 55 08 mov edx,dword ptr [ebp+8] + E0002252: 89 8A 80 00 00 00 mov dword ptr [edx+00000080h],ecx + E0002258: 8B 45 08 mov eax,dword ptr [ebp+8] + E000225B: 8B 80 80 00 00 00 mov eax,dword ptr [eax+00000080h] + E0002261: 5D pop ebp + E0002262: C3 ret + E0002263: CC int 3 + E0002264: CC int 3 + E0002265: CC int 3 + E0002266: CC int 3 + E0002267: CC int 3 + E0002268: CC int 3 + E0002269: CC int 3 + E000226A: CC int 3 + E000226B: CC int 3 + E000226C: CC int 3 + E000226D: CC int 3 + E000226E: CC int 3 + E000226F: CC int 3 +?Release@CAtaDrive@@UAAKXZ (public: virtual unsigned long __cdecl CAtaDrive::Release(void)): + E0002270: 55 push ebp + E0002271: 8B EC mov ebp,esp + E0002273: 51 push ecx + E0002274: 8B 45 08 mov eax,dword ptr [ebp+8] + E0002277: 83 B8 80 00 00 00 cmp dword ptr [eax+00000080h],0 + 00 + E000227E: 75 16 jne E0002296 + E0002280: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0002283: 89 4D FC mov dword ptr [ebp-4],ecx + E0002286: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002289: 52 push edx + E000228A: E8 DB 7C 00 00 call E0009F6A + E000228F: 83 C4 04 add esp,4 + E0002292: 33 C0 xor eax,eax + E0002294: EB 1E jmp E00022B4 + E0002296: 8B 45 08 mov eax,dword ptr [ebp+8] + E0002299: 8B 80 80 00 00 00 mov eax,dword ptr [eax+00000080h] + E000229F: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00022A2: 8B 91 80 00 00 00 mov edx,dword ptr [ecx+00000080h] + E00022A8: 83 EA 01 sub edx,1 + E00022AB: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00022AE: 89 91 80 00 00 00 mov dword ptr [ecx+00000080h],edx + E00022B4: 8B E5 mov esp,ebp + E00022B6: 5D pop ebp + E00022B7: C3 ret + E00022B8: CC int 3 + E00022B9: CC int 3 + E00022BA: CC int 3 + E00022BB: CC int 3 + E00022BC: CC int 3 + E00022BD: CC int 3 + E00022BE: CC int 3 + E00022BF: CC int 3 +?QueryInterface@CAtaDrive@@W3AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CAtaDrive::QueryInterface`adjustor{4}' (struct _GUID const &,void * *)): + E00022C0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E00022C5: E9 BD ED FF FF jmp E0001087 + E00022CA: CC int 3 + E00022CB: CC int 3 + E00022CC: CC int 3 + E00022CD: CC int 3 + E00022CE: CC int 3 + E00022CF: CC int 3 +?AddRef@CAtaDrive@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CAtaDrive::AddRef`adjustor{4}' (void)): + E00022D0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E00022D5: E9 66 FF FF FF jmp E0002240 + E00022DA: CC int 3 + E00022DB: CC int 3 + E00022DC: CC int 3 + E00022DD: CC int 3 + E00022DE: CC int 3 + E00022DF: CC int 3 +?Release@CAtaDrive@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CAtaDrive::Release`adjustor{4}' (void)): + E00022E0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E00022E5: E9 86 FF FF FF jmp E0002270 + E00022EA: CC int 3 + E00022EB: CC int 3 + E00022EC: CC int 3 + E00022ED: CC int 3 + E00022EE: CC int 3 + E00022EF: CC int 3 +?QueryInterface@CAtaDrive@@W7AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CAtaDrive::QueryInterface`adjustor{8}' (struct _GUID const &,void * *)): + E00022F0: 83 6C 24 04 08 sub dword ptr [esp+4],8 + E00022F5: E9 8D ED FF FF jmp E0001087 + E00022FA: CC int 3 + E00022FB: CC int 3 + E00022FC: CC int 3 + E00022FD: CC int 3 + E00022FE: CC int 3 + E00022FF: CC int 3 +?AddRef@CAtaDrive@@W7AAKXZ ([thunk]:public: virtual unsigned long __cdecl CAtaDrive::AddRef`adjustor{8}' (void)): + E0002300: 83 6C 24 04 08 sub dword ptr [esp+4],8 + E0002305: E9 36 FF FF FF jmp E0002240 + E000230A: CC int 3 + E000230B: CC int 3 + E000230C: CC int 3 + E000230D: CC int 3 + E000230E: CC int 3 + E000230F: CC int 3 +?Release@CAtaDrive@@W7AAKXZ ([thunk]:public: virtual unsigned long __cdecl CAtaDrive::Release`adjustor{8}' (void)): + E0002310: 83 6C 24 04 08 sub dword ptr [esp+4],8 + E0002315: E9 56 FF FF FF jmp E0002270 + E000231A: CC int 3 + E000231B: CC int 3 + E000231C: CC int 3 + E000231D: CC int 3 + E000231E: CC int 3 + E000231F: CC int 3 +_ProcessKernelRcLine: + E0002320: 55 push ebp + E0002321: 8B EC mov ebp,esp + E0002323: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002326: 50 push eax + E0002327: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000232A: 51 push ecx + E000232B: 8B 55 10 mov edx,dword ptr [ebp+10h] + E000232E: 83 C2 08 add edx,8 + E0002331: 52 push edx + E0002332: 68 58 B4 00 E0 push 0E000B458h + E0002337: E8 D4 7B 00 00 call E0009F10 + E000233C: 83 C4 10 add esp,10h + E000233F: 68 74 B4 00 E0 push 0E000B474h + E0002344: 8B 45 08 mov eax,dword ptr [ebp+8] + E0002347: 50 push eax + E0002348: E8 ED 7B 00 00 call E0009F3A + E000234D: 83 C4 08 add esp,8 + E0002350: 85 C0 test eax,eax + E0002352: 75 2D jne E0002381 + E0002354: 68 84 B4 00 E0 push 0E000B484h + E0002359: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E000235C: 51 push ecx + E000235D: E8 D2 7B 00 00 call E0009F34 + E0002362: 83 C4 08 add esp,8 + E0002365: 85 C0 test eax,eax + E0002367: 75 0C jne E0002375 + E0002369: 8B 55 10 mov edx,dword ptr [ebp+10h] + E000236C: C7 42 58 01 00 00 mov dword ptr [edx+58h],1 + 00 + E0002373: EB 0A jmp E000237F + E0002375: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0002378: C7 40 58 00 00 00 mov dword ptr [eax+58h],0 + 00 + E000237F: EB 2B jmp E00023AC + E0002381: 68 8C B4 00 E0 push 0E000B48Ch + E0002386: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0002389: 51 push ecx + E000238A: E8 AB 7B 00 00 call E0009F3A + E000238F: 83 C4 08 add esp,8 + E0002392: 85 C0 test eax,eax + E0002394: 75 16 jne E00023AC + E0002396: 6A 0A push 0Ah + E0002398: 6A 00 push 0 + E000239A: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E000239D: 52 push edx + E000239E: E8 D9 7B 00 00 call E0009F7C + E00023A3: 83 C4 0C add esp,0Ch + E00023A6: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E00023A9: 89 41 5C mov dword ptr [ecx+5Ch],eax + E00023AC: 5D pop ebp + E00023AD: C3 ret +_ProcessKernelRcSection: + E00023AE: 55 push ebp + E00023AF: 8B EC mov ebp,esp + E00023B1: 81 EC 14 02 00 00 sub esp,214h + E00023B7: C6 85 F0 FD FF FF mov byte ptr [ebp+FFFFFDF0h],0 + 00 + E00023BE: 8D 85 00 FE FF FF lea eax,dword ptr [ebp+FFFFFE00h] + E00023C4: 89 85 FC FD FF FF mov dword ptr [ebp+FFFFFDFCh],eax + E00023CA: 6A 01 push 1 + E00023CC: 8D 8D F4 FD FF FF lea ecx,dword ptr [ebp+FFFFFDF4h] + E00023D2: 51 push ecx + E00023D3: 8B 55 08 mov edx,dword ptr [ebp+8] + E00023D6: 8B 02 mov eax,dword ptr [edx] + E00023D8: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00023DB: 51 push ecx + E00023DC: FF 50 0C call dword ptr [eax+0Ch] + E00023DF: 83 C4 0C add esp,0Ch + E00023E2: 85 C0 test eax,eax + E00023E4: 0F 84 B1 01 00 00 je E000259B + E00023EA: 0F BE 95 F4 FD FF movsx edx,byte ptr [ebp+FFFFFDF4h] + FF + E00023F1: 89 95 EC FD FF FF mov dword ptr [ebp+FFFFFDECh],edx + E00023F7: 8B 85 EC FD FF FF mov eax,dword ptr [ebp+FFFFFDECh] + E00023FD: 83 E8 0A sub eax,0Ah + E0002400: 89 85 EC FD FF FF mov dword ptr [ebp+FFFFFDECh],eax + E0002406: 83 BD EC FD FF FF cmp dword ptr [ebp+FFFFFDECh],51h + 51 + E000240D: 0F 87 42 01 00 00 ja E0002555 + E0002413: 8B 95 EC FD FF FF mov edx,dword ptr [ebp+FFFFFDECh] + E0002419: 33 C9 xor ecx,ecx + E000241B: 8A 8A B5 25 00 E0 mov cl,byte ptr [edx+E00025B5h] + E0002421: FF 24 8D A1 25 00 jmp dword ptr [ecx*4+E00025A1h] + E0 + E0002428: E9 69 01 00 00 jmp E0002596 + E000242D: 8B 85 FC FD FF FF mov eax,dword ptr [ebp+FFFFFDFCh] + E0002433: 66 C7 00 00 00 mov word ptr [eax],0 + E0002438: 6A 23 push 23h + E000243A: 8D 8D 00 FE FF FF lea ecx,dword ptr [ebp+FFFFFE00h] + E0002440: 51 push ecx + E0002441: E8 48 7B 00 00 call E0009F8E + E0002446: 83 C4 08 add esp,8 + E0002449: 89 85 FC FD FF FF mov dword ptr [ebp+FFFFFDFCh],eax + E000244F: 83 BD FC FD FF FF cmp dword ptr [ebp+FFFFFDFCh],0 + 00 + E0002456: 74 0B je E0002463 + E0002458: 8B 95 FC FD FF FF mov edx,dword ptr [ebp+FFFFFDFCh] + E000245E: 66 C7 02 00 00 mov word ptr [edx],0 + E0002463: 8B 85 00 FE FF FF mov eax,dword ptr [ebp+FFFFFE00h] + E0002469: 25 FF FF 00 00 and eax,0FFFFh + E000246E: 85 C0 test eax,eax + E0002470: 0F 84 C3 00 00 00 je E0002539 + E0002476: 6A 3D push 3Dh + E0002478: 8D 8D 00 FE FF FF lea ecx,dword ptr [ebp+FFFFFE00h] + E000247E: 51 push ecx + E000247F: E8 0A 7B 00 00 call E0009F8E + E0002484: 83 C4 08 add esp,8 + E0002487: 89 85 F8 FD FF FF mov dword ptr [ebp+FFFFFDF8h],eax + E000248D: 83 BD F8 FD FF FF cmp dword ptr [ebp+FFFFFDF8h],0 + 00 + E0002494: 74 1C je E00024B2 + E0002496: 8B 95 F8 FD FF FF mov edx,dword ptr [ebp+FFFFFDF8h] + E000249C: 66 C7 02 00 00 mov word ptr [edx],0 + E00024A1: 8B 85 F8 FD FF FF mov eax,dword ptr [ebp+FFFFFDF8h] + E00024A7: 83 C0 02 add eax,2 + E00024AA: 89 85 F8 FD FF FF mov dword ptr [ebp+FFFFFDF8h],eax + E00024B0: EB 0A jmp E00024BC + E00024B2: C7 85 F8 FD FF FF mov dword ptr [ebp+FFFFFDF8h],0E000B49Ch + 9C B4 00 E0 + E00024BC: 8D 8D 00 FE FF FF lea ecx,dword ptr [ebp+FFFFFE00h] + E00024C2: 89 8D FC FD FF FF mov dword ptr [ebp+FFFFFDFCh],ecx + E00024C8: EB 0F jmp E00024D9 + E00024CA: 8B 95 FC FD FF FF mov edx,dword ptr [ebp+FFFFFDFCh] + E00024D0: 83 C2 02 add edx,2 + E00024D3: 89 95 FC FD FF FF mov dword ptr [ebp+FFFFFDFCh],edx + E00024D9: 8B 85 FC FD FF FF mov eax,dword ptr [ebp+FFFFFDFCh] + E00024DF: 33 C9 xor ecx,ecx + E00024E1: 66 8B 08 mov cx,word ptr [eax] + E00024E4: 85 C9 test ecx,ecx + E00024E6: 74 37 je E000251F + E00024E8: 8B 95 FC FD FF FF mov edx,dword ptr [ebp+FFFFFDFCh] + E00024EE: 33 C0 xor eax,eax + E00024F0: 66 8B 02 mov ax,word ptr [edx] + E00024F3: 50 push eax + E00024F4: E8 8F 7A 00 00 call E0009F88 + E00024F9: 83 C4 04 add esp,4 + E00024FC: 85 C0 test eax,eax + E00024FE: 74 1D je E000251D + E0002500: 8B 8D FC FD FF FF mov ecx,dword ptr [ebp+FFFFFDFCh] + E0002506: 33 D2 xor edx,edx + E0002508: 66 8B 11 mov dx,word ptr [ecx] + E000250B: 52 push edx + E000250C: E8 71 7A 00 00 call E0009F82 + E0002511: 83 C4 04 add esp,4 + E0002514: 8B 8D FC FD FF FF mov ecx,dword ptr [ebp+FFFFFDFCh] + E000251A: 66 89 01 mov word ptr [ecx],ax + E000251D: EB AB jmp E00024CA + E000251F: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0002522: 52 push edx + E0002523: 8B 85 F8 FD FF FF mov eax,dword ptr [ebp+FFFFFDF8h] + E0002529: 50 push eax + E000252A: 8D 8D 00 FE FF FF lea ecx,dword ptr [ebp+FFFFFE00h] + E0002530: 51 push ecx + E0002531: E8 EA FD FF FF call E0002320 + E0002536: 83 C4 0C add esp,0Ch + E0002539: 8D 95 00 FE FF FF lea edx,dword ptr [ebp+FFFFFE00h] + E000253F: 89 95 FC FD FF FF mov dword ptr [ebp+FFFFFDFCh],edx + E0002545: C6 85 F0 FD FF FF mov byte ptr [ebp+FFFFFDF0h],0 + 00 + E000254C: EB 48 jmp E0002596 + E000254E: C6 85 F0 FD FF FF mov byte ptr [ebp+FFFFFDF0h],1 + 01 + E0002555: 8D 45 00 lea eax,dword ptr [ebp] + E0002558: 39 85 FC FD FF FF cmp dword ptr [ebp+FFFFFDFCh],eax + E000255E: 73 20 jae E0002580 + E0002560: 66 0F BE 8D F4 FD movsx cx,byte ptr [ebp+FFFFFDF4h] + FF FF + E0002568: 8B 95 FC FD FF FF mov edx,dword ptr [ebp+FFFFFDFCh] + E000256E: 66 89 0A mov word ptr [edx],cx + E0002571: 8B 85 FC FD FF FF mov eax,dword ptr [ebp+FFFFFDFCh] + E0002577: 83 C0 02 add eax,2 + E000257A: 89 85 FC FD FF FF mov dword ptr [ebp+FFFFFDFCh],eax + E0002580: EB 14 jmp E0002596 + E0002582: 8B 8D F0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDF0h] + E0002588: 81 E1 FF 00 00 00 and ecx,0FFh + E000258E: 85 C9 test ecx,ecx + E0002590: 75 04 jne E0002596 + E0002592: B0 01 mov al,1 + E0002594: EB 07 jmp E000259D + E0002596: E9 2F FE FF FF jmp E00023CA + E000259B: 32 C0 xor al,al + E000259D: 8B E5 mov esp,ebp + E000259F: 5D pop ebp + E00025A0: C3 ret + E00025A1: 2D 24 00 E0 28 sub eax,28E00024h + E00025A6: 24 00 and al,0 + E00025A8: E0 4E loopne E00025F8 + E00025AA: 25 00 E0 82 25 and eax,2582E000h + E00025AF: 00 E0 add al,ah + E00025B1: 55 push ebp + E00025B2: 25 00 E0 00 04 and eax,400E000h + E00025B7: 04 01 add al,1 + E00025B9: 04 04 add al,4 + E00025BB: 04 04 add al,4 + E00025BD: 04 04 add al,4 + E00025BF: 04 04 add al,4 + E00025C1: 04 04 add al,4 + E00025C3: 04 04 add al,4 + E00025C5: 04 04 add al,4 + E00025C7: 04 04 add al,4 + E00025C9: 04 04 add al,4 + E00025CB: 04 04 add al,4 + E00025CD: 04 02 add al,2 + E00025CF: 04 04 add al,4 + E00025D1: 04 04 add al,4 + E00025D3: 04 04 add al,4 + E00025D5: 04 04 add al,4 + E00025D7: 04 04 add al,4 + E00025D9: 04 04 add al,4 + E00025DB: 04 04 add al,4 + E00025DD: 04 04 add al,4 + E00025DF: 04 04 add al,4 + E00025E1: 04 04 add al,4 + E00025E3: 04 04 add al,4 + E00025E5: 04 04 add al,4 + E00025E7: 04 04 add al,4 + E00025E9: 04 04 add al,4 + E00025EB: 04 04 add al,4 + E00025ED: 04 04 add al,4 + E00025EF: 04 04 add al,4 + E00025F1: 04 04 add al,4 + E00025F3: 04 04 add al,4 + E00025F5: 04 04 add al,4 + E00025F7: 04 04 add al,4 + E00025F9: 04 04 add al,4 + E00025FB: 04 04 add al,4 + E00025FD: 04 04 add al,4 + E00025FF: 04 04 add al,4 + E0002601: 04 04 add al,4 + E0002603: 04 04 add al,4 + E0002605: 04 03 add al,3 +_ProcessKernelRc: + E0002607: 55 push ebp + E0002608: 8B EC mov ebp,esp + E000260A: 81 EC 7C 02 00 00 sub esp,27Ch + E0002610: 56 push esi + E0002611: 57 push edi + E0002612: C6 45 FC 00 mov byte ptr [ebp-4],0 + E0002616: C6 85 88 FD FF FF mov byte ptr [ebp+FFFFFD88h],0 + 00 + E000261D: 68 18 A1 00 E0 push 0E000A118h + E0002622: 68 A0 B4 00 E0 push 0E000B4A0h + E0002627: E8 6E 79 00 00 call E0009F9A + E000262C: 83 C4 08 add esp,8 + E000262F: 89 45 F8 mov dword ptr [ebp-8],eax + E0002632: 83 7D F8 00 cmp dword ptr [ebp-8],0 + E0002636: 75 05 jne E000263D + E0002638: E9 47 02 00 00 jmp E0002884 + E000263D: 6A 02 push 2 + E000263F: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0002642: 8B 08 mov ecx,dword ptr [eax] + E0002644: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0002647: 52 push edx + E0002648: FF 51 14 call dword ptr [ecx+14h] + E000264B: 83 C4 08 add esp,8 + E000264E: 8D 85 F8 FD FF FF lea eax,dword ptr [ebp+FFFFFDF8h] + E0002654: 89 85 F4 FD FF FF mov dword ptr [ebp+FFFFFDF4h],eax + E000265A: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000265D: 81 E1 FF 00 00 00 and ecx,0FFh + E0002663: 85 C9 test ecx,ecx + E0002665: 0F 85 0A 02 00 00 jne E0002875 + E000266B: 6A 01 push 1 + E000266D: 8D 95 EC FD FF FF lea edx,dword ptr [ebp+FFFFFDECh] + E0002673: 52 push edx + E0002674: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0002677: 8B 08 mov ecx,dword ptr [eax] + E0002679: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000267C: 52 push edx + E000267D: FF 51 0C call dword ptr [ecx+0Ch] + E0002680: 83 C4 0C add esp,0Ch + E0002683: 85 C0 test eax,eax + E0002685: 0F 84 EA 01 00 00 je E0002875 + E000268B: 0F BE 85 EC FD FF movsx eax,byte ptr [ebp+FFFFFDECh] + FF + E0002692: 89 85 84 FD FF FF mov dword ptr [ebp+FFFFFD84h],eax + E0002698: 8B 8D 84 FD FF FF mov ecx,dword ptr [ebp+FFFFFD84h] + E000269E: 83 E9 0A sub ecx,0Ah + E00026A1: 89 8D 84 FD FF FF mov dword ptr [ebp+FFFFFD84h],ecx + E00026A7: 83 BD 84 FD FF FF cmp dword ptr [ebp+FFFFFD84h],53h + 53 + E00026AE: 0F 87 91 01 00 00 ja E0002845 + E00026B4: 8B 85 84 FD FF FF mov eax,dword ptr [ebp+FFFFFD84h] + E00026BA: 33 D2 xor edx,edx + E00026BC: 8A 90 9E 28 00 E0 mov dl,byte ptr [eax+E000289Eh] + E00026C2: FF 24 95 8A 28 00 jmp dword ptr [edx*4+E000288Ah] + E0 + E00026C9: E9 A2 01 00 00 jmp E0002870 + E00026CE: 8B 8D F4 FD FF FF mov ecx,dword ptr [ebp+FFFFFDF4h] + E00026D4: 66 C7 01 00 00 mov word ptr [ecx],0 + E00026D9: 6A 23 push 23h + E00026DB: 8D 95 F8 FD FF FF lea edx,dword ptr [ebp+FFFFFDF8h] + E00026E1: 52 push edx + E00026E2: E8 A7 78 00 00 call E0009F8E + E00026E7: 83 C4 08 add esp,8 + E00026EA: 89 85 F4 FD FF FF mov dword ptr [ebp+FFFFFDF4h],eax + E00026F0: 83 BD F4 FD FF FF cmp dword ptr [ebp+FFFFFDF4h],0 + 00 + E00026F7: 74 0B je E0002704 + E00026F9: 8B 85 F4 FD FF FF mov eax,dword ptr [ebp+FFFFFDF4h] + E00026FF: 66 C7 00 00 00 mov word ptr [eax],0 + E0002704: 8D 8D F8 FD FF FF lea ecx,dword ptr [ebp+FFFFFDF8h] + E000270A: 89 8D F4 FD FF FF mov dword ptr [ebp+FFFFFDF4h],ecx + E0002710: 8B 95 F8 FD FF FF mov edx,dword ptr [ebp+FFFFFDF8h] + E0002716: 81 E2 FF FF 00 00 and edx,0FFFFh + E000271C: 85 D2 test edx,edx + E000271E: 0F 84 1F 01 00 00 je E0002843 + E0002724: 8B 85 88 FD FF FF mov eax,dword ptr [ebp+FFFFFD88h] + E000272A: 25 FF 00 00 00 and eax,0FFh + E000272F: 85 C0 test eax,eax + E0002731: 75 54 jne E0002787 + E0002733: B9 18 00 00 00 mov ecx,18h + E0002738: BE F0 B3 00 E0 mov esi,0E000B3F0h + E000273D: 8D BD 8C FD FF FF lea edi,dword ptr [ebp+FFFFFD8Ch] + E0002743: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E0002745: 8D 8D F8 FD FF FF lea ecx,dword ptr [ebp+FFFFFDF8h] + E000274B: 51 push ecx + E000274C: 8D 95 94 FD FF FF lea edx,dword ptr [ebp+FFFFFD94h] + E0002752: 52 push edx + E0002753: E8 B2 77 00 00 call E0009F0A + E0002758: 83 C4 08 add esp,8 + E000275B: 8D 85 8C FD FF FF lea eax,dword ptr [ebp+FFFFFD8Ch] + E0002761: 50 push eax + E0002762: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0002765: 51 push ecx + E0002766: E8 43 FC FF FF call E00023AE + E000276B: 83 C4 08 add esp,8 + E000276E: 25 FF 00 00 00 and eax,0FFh + E0002773: 85 C0 test eax,eax + E0002775: 75 04 jne E000277B + E0002777: C6 45 FC 01 mov byte ptr [ebp-4],1 + E000277B: C6 85 88 FD FF FF mov byte ptr [ebp+FFFFFD88h],1 + 01 + E0002782: E9 BC 00 00 00 jmp E0002843 + E0002787: 6A 60 push 60h + E0002789: E8 B2 77 00 00 call E0009F40 + E000278E: 83 C4 04 add esp,4 + E0002791: 89 85 F0 FD FF FF mov dword ptr [ebp+FFFFFDF0h],eax + E0002797: B9 18 00 00 00 mov ecx,18h + E000279C: 8D B5 8C FD FF FF lea esi,dword ptr [ebp+FFFFFD8Ch] + E00027A2: 8B BD F0 FD FF FF mov edi,dword ptr [ebp+FFFFFDF0h] + E00027A8: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E00027AA: 6A 28 push 28h + E00027AC: 8D 95 F8 FD FF FF lea edx,dword ptr [ebp+FFFFFDF8h] + E00027B2: 52 push edx + E00027B3: 8B 85 F0 FD FF FF mov eax,dword ptr [ebp+FFFFFDF0h] + E00027B9: 83 C0 08 add eax,8 + E00027BC: 50 push eax + E00027BD: E8 D2 77 00 00 call E0009F94 + E00027C2: 83 C4 0C add esp,0Ch + E00027C5: 8B 8D F0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDF0h] + E00027CB: C7 41 04 00 00 00 mov dword ptr [ecx+4],0 + 00 + E00027D2: 8B 95 F0 FD FF FF mov edx,dword ptr [ebp+FFFFFDF0h] + E00027D8: A1 58 C8 00 E0 mov eax,[E000C858] + E00027DD: 89 02 mov dword ptr [edx],eax + E00027DF: 83 3D 58 C8 00 E0 cmp dword ptr ds:[E000C858h],0 + 00 + E00027E6: 74 0F je E00027F7 + E00027E8: 8B 0D 58 C8 00 E0 mov ecx,dword ptr ds:[E000C858h] + E00027EE: 8B 95 F0 FD FF FF mov edx,dword ptr [ebp+FFFFFDF0h] + E00027F4: 89 51 04 mov dword ptr [ecx+4],edx + E00027F7: 83 3D 54 B4 00 E0 cmp dword ptr ds:[E000B454h],0 + 00 + E00027FE: 75 17 jne E0002817 + E0002800: 8B 85 F0 FD FF FF mov eax,dword ptr [ebp+FFFFFDF0h] + E0002806: A3 54 B4 00 E0 mov [E000B454],eax + E000280B: 8B 0D 54 B4 00 E0 mov ecx,dword ptr ds:[E000B454h] + E0002811: 89 0D 50 B4 00 E0 mov dword ptr ds:[E000B450h],ecx + E0002817: 8B 95 F0 FD FF FF mov edx,dword ptr [ebp+FFFFFDF0h] + E000281D: 89 15 58 C8 00 E0 mov dword ptr ds:[E000C858h],edx + E0002823: 8B 85 F0 FD FF FF mov eax,dword ptr [ebp+FFFFFDF0h] + E0002829: 50 push eax + E000282A: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E000282D: 51 push ecx + E000282E: E8 7B FB FF FF call E00023AE + E0002833: 83 C4 08 add esp,8 + E0002836: 25 FF 00 00 00 and eax,0FFh + E000283B: 85 C0 test eax,eax + E000283D: 75 04 jne E0002843 + E000283F: C6 45 FC 01 mov byte ptr [ebp-4],1 + E0002843: EB 2B jmp E0002870 + E0002845: 8D 55 F8 lea edx,dword ptr [ebp-8] + E0002848: 39 95 F4 FD FF FF cmp dword ptr [ebp+FFFFFDF4h],edx + E000284E: 73 20 jae E0002870 + E0002850: 66 0F BE 85 EC FD movsx ax,byte ptr [ebp+FFFFFDECh] + FF FF + E0002858: 8B 8D F4 FD FF FF mov ecx,dword ptr [ebp+FFFFFDF4h] + E000285E: 66 89 01 mov word ptr [ecx],ax + E0002861: 8B 95 F4 FD FF FF mov edx,dword ptr [ebp+FFFFFDF4h] + E0002867: 83 C2 02 add edx,2 + E000286A: 89 95 F4 FD FF FF mov dword ptr [ebp+FFFFFDF4h],edx + E0002870: E9 E5 FD FF FF jmp E000265A + E0002875: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0002878: 8B 08 mov ecx,dword ptr [eax] + E000287A: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000287D: 52 push edx + E000287E: FF 51 08 call dword ptr [ecx+8] + E0002881: 83 C4 04 add esp,4 + E0002884: 5F pop edi + E0002885: 5E pop esi + E0002886: 8B E5 mov esp,ebp + E0002888: 5D pop ebp + E0002889: C3 ret + E000288A: CE into + E000288B: 26 00 E0 add al,ah + E000288E: C9 leave + E000288F: 26 00 E0 add al,ah + E0002892: C9 leave + E0002893: 26 00 E0 add al,ah + E0002896: C9 leave + E0002897: 26 00 E0 add al,ah + E000289A: 45 inc ebp + E000289B: 28 00 sub byte ptr [eax],al + E000289D: E0 00 loopne E000289F + E000289F: 04 04 add al,4 + E00028A1: 01 04 04 add dword ptr [esp+eax],eax + E00028A4: 04 04 add al,4 + E00028A6: 04 04 add al,4 + E00028A8: 04 04 add al,4 + E00028AA: 04 04 add al,4 + E00028AC: 04 04 add al,4 + E00028AE: 04 04 add al,4 + E00028B0: 04 04 add al,4 + E00028B2: 04 04 add al,4 + E00028B4: 04 04 add al,4 + E00028B6: 04 04 add al,4 + E00028B8: 04 04 add al,4 + E00028BA: 04 04 add al,4 + E00028BC: 04 04 add al,4 + E00028BE: 04 04 add al,4 + E00028C0: 04 04 add al,4 + E00028C2: 04 04 add al,4 + E00028C4: 04 04 add al,4 + E00028C6: 04 04 add al,4 + E00028C8: 04 04 add al,4 + E00028CA: 04 04 add al,4 + E00028CC: 04 04 add al,4 + E00028CE: 04 04 add al,4 + E00028D0: 04 04 add al,4 + E00028D2: 04 04 add al,4 + E00028D4: 04 04 add al,4 + E00028D6: 04 04 add al,4 + E00028D8: 04 04 add al,4 + E00028DA: 04 04 add al,4 + E00028DC: 04 04 add al,4 + E00028DE: 04 04 add al,4 + E00028E0: 04 04 add al,4 + E00028E2: 04 04 add al,4 + E00028E4: 04 04 add al,4 + E00028E6: 04 04 add al,4 + E00028E8: 04 04 add al,4 + E00028EA: 04 04 add al,4 + E00028EC: 04 04 add al,4 + E00028EE: 04 02 add al,2 + E00028F0: 04 03 add al,3 + E00028F2: CC int 3 + E00028F3: CC int 3 + E00028F4: CC int 3 + E00028F5: CC int 3 + E00028F6: CC int 3 + E00028F7: CC int 3 + E00028F8: CC int 3 + E00028F9: CC int 3 + E00028FA: CC int 3 + E00028FB: CC int 3 + E00028FC: CC int 3 + E00028FD: CC int 3 + E00028FE: CC int 3 + E00028FF: CC int 3 +??0CConsole@@QAE@XZ (public: __thiscall CConsole::CConsole(void)): + E0002900: 55 push ebp + E0002901: 8B EC mov ebp,esp + E0002903: 83 EC 08 sub esp,8 + E0002906: 89 4D F8 mov dword ptr [ebp-8],ecx + E0002909: 8B 45 F8 mov eax,dword ptr [ebp-8] + E000290C: C7 00 C8 A0 00 E0 mov dword ptr [eax],0E000A0C8h + E0002912: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0002915: 83 C1 04 add ecx,4 + E0002918: 89 4D FC mov dword ptr [ebp-4],ecx + E000291B: 8B 55 FC mov edx,dword ptr [ebp-4] + E000291E: C7 02 B0 A0 00 E0 mov dword ptr [edx],0E000A0B0h + E0002924: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0002927: C7 00 B8 A1 00 E0 mov dword ptr [eax],0E000A1B8h + E000292D: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0002930: C7 41 04 A0 A1 00 mov dword ptr [ecx+4],0E000A1A0h + E0 + E0002937: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000293A: C7 42 08 00 00 00 mov dword ptr [edx+8],0 + 00 + E0002941: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0002944: 66 C7 40 0C 00 00 mov word ptr [eax+0Ch],0 + E000294A: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E000294D: 66 C7 41 0E 00 00 mov word ptr [ecx+0Eh],0 + E0002953: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0002956: 66 C7 42 12 00 00 mov word ptr [edx+12h],0 + E000295C: 8B 45 F8 mov eax,dword ptr [ebp-8] + E000295F: 66 C7 40 10 00 00 mov word ptr [eax+10h],0 + E0002965: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0002968: 66 C7 41 18 00 07 mov word ptr [ecx+18h],700h + E000296E: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0002971: C6 42 14 00 mov byte ptr [edx+14h],0 + E0002975: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0002978: 8B E5 mov esp,ebp + E000297A: 5D pop ebp + E000297B: C3 ret +?QueryInterface@CConsole@@UAAKABU_GUID@@PAPAX@Z (public: virtual unsigned long __cdecl CConsole::QueryInterface(struct _GUID const &,void * *)): + E000297C: 55 push ebp + E000297D: 8B EC mov ebp,esp + E000297F: 83 EC 10 sub esp,10h + E0002982: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002985: 8B 08 mov ecx,dword ptr [eax] + E0002987: 3B 0D D8 A0 00 E0 cmp ecx,dword ptr ds:[E000A0D8h] + E000298D: 75 2A jne E00029B9 + E000298F: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0002992: 8B 42 04 mov eax,dword ptr [edx+4] + E0002995: 3B 05 DC A0 00 E0 cmp eax,dword ptr ds:[E000A0DCh] + E000299B: 75 1C jne E00029B9 + E000299D: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00029A0: 8B 51 08 mov edx,dword ptr [ecx+8] + E00029A3: 3B 15 E0 A0 00 E0 cmp edx,dword ptr ds:[E000A0E0h] + E00029A9: 75 0E jne E00029B9 + E00029AB: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00029AE: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E00029B1: 3B 0D E4 A0 00 E0 cmp ecx,dword ptr ds:[E000A0E4h] + E00029B7: 74 37 je E00029F0 + E00029B9: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00029BC: 8B 02 mov eax,dword ptr [edx] + E00029BE: 3B 05 08 A1 00 E0 cmp eax,dword ptr ds:[E000A108h] + E00029C4: 75 60 jne E0002A26 + E00029C6: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00029C9: 8B 51 04 mov edx,dword ptr [ecx+4] + E00029CC: 3B 15 0C A1 00 E0 cmp edx,dword ptr ds:[E000A10Ch] + E00029D2: 75 52 jne E0002A26 + E00029D4: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00029D7: 8B 48 08 mov ecx,dword ptr [eax+8] + E00029DA: 3B 0D 10 A1 00 E0 cmp ecx,dword ptr ds:[E000A110h] + E00029E0: 75 44 jne E0002A26 + E00029E2: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00029E5: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E00029E8: 3B 05 14 A1 00 E0 cmp eax,dword ptr ds:[E000A114h] + E00029EE: 75 36 jne E0002A26 + E00029F0: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00029F3: 8B 11 mov edx,dword ptr [ecx] + E00029F5: 8B 45 08 mov eax,dword ptr [ebp+8] + E00029F8: 50 push eax + E00029F9: FF 52 04 call dword ptr [edx+4] + E00029FC: 83 C4 04 add esp,4 + E00029FF: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E0002A03: 74 0B je E0002A10 + E0002A05: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0002A08: 83 C1 04 add ecx,4 + E0002A0B: 89 4D F8 mov dword ptr [ebp-8],ecx + E0002A0E: EB 07 jmp E0002A17 + E0002A10: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E0002A17: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0002A1A: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0002A1D: 89 02 mov dword ptr [edx],eax + E0002A1F: 33 C0 xor eax,eax + E0002A21: E9 A7 00 00 00 jmp E0002ACD + E0002A26: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0002A29: 8B 11 mov edx,dword ptr [ecx] + E0002A2B: 3B 15 18 A1 00 E0 cmp edx,dword ptr ds:[E000A118h] + E0002A31: 0F 85 88 00 00 00 jne E0002ABF + E0002A37: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002A3A: 8B 48 04 mov ecx,dword ptr [eax+4] + E0002A3D: 3B 0D 1C A1 00 E0 cmp ecx,dword ptr ds:[E000A11Ch] + E0002A43: 75 7A jne E0002ABF + E0002A45: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0002A48: 8B 42 08 mov eax,dword ptr [edx+8] + E0002A4B: 3B 05 20 A1 00 E0 cmp eax,dword ptr ds:[E000A120h] + E0002A51: 75 6C jne E0002ABF + E0002A53: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0002A56: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0002A59: 3B 15 24 A1 00 E0 cmp edx,dword ptr ds:[E000A124h] + E0002A5F: 75 5E jne E0002ABF + E0002A61: 8B 45 08 mov eax,dword ptr [ebp+8] + E0002A64: 8B 08 mov ecx,dword ptr [eax] + E0002A66: 8B 55 08 mov edx,dword ptr [ebp+8] + E0002A69: 52 push edx + E0002A6A: FF 51 04 call dword ptr [ecx+4] + E0002A6D: 83 C4 04 add esp,4 + E0002A70: 6A 14 push 14h + E0002A72: E8 FF 74 00 00 call E0009F76 + E0002A77: 83 C4 04 add esp,4 + E0002A7A: 89 45 FC mov dword ptr [ebp-4],eax + E0002A7D: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0002A81: 74 11 je E0002A94 + E0002A83: 8B 45 08 mov eax,dword ptr [ebp+8] + E0002A86: 50 push eax + E0002A87: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002A8A: E8 5E 06 00 00 call E00030ED + E0002A8F: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0002A92: EB 07 jmp E0002A9B + E0002A94: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E0002A9B: 83 7D F4 00 cmp dword ptr [ebp-0Ch],0 + E0002A9F: 74 0B je E0002AAC + E0002AA1: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0002AA4: 83 C1 04 add ecx,4 + E0002AA7: 89 4D F0 mov dword ptr [ebp-10h],ecx + E0002AAA: EB 07 jmp E0002AB3 + E0002AAC: C7 45 F0 00 00 00 mov dword ptr [ebp-10h],0 + 00 + E0002AB3: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0002AB6: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E0002AB9: 89 02 mov dword ptr [edx],eax + E0002ABB: 33 C0 xor eax,eax + E0002ABD: EB 0E jmp E0002ACD + E0002ABF: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E0002AC2: C7 01 00 00 00 00 mov dword ptr [ecx],0 + E0002AC8: B8 00 00 00 80 mov eax,80000000h + E0002ACD: 8B E5 mov esp,ebp + E0002ACF: 5D pop ebp + E0002AD0: C3 ret +?AddRef@CConsole@@UAAKXZ (public: virtual unsigned long __cdecl CConsole::AddRef(void)): + E0002AD1: 55 push ebp + E0002AD2: 8B EC mov ebp,esp + E0002AD4: 8B 45 08 mov eax,dword ptr [ebp+8] + E0002AD7: 8B 48 08 mov ecx,dword ptr [eax+8] + E0002ADA: 83 C1 01 add ecx,1 + E0002ADD: 8B 55 08 mov edx,dword ptr [ebp+8] + E0002AE0: 89 4A 08 mov dword ptr [edx+8],ecx + E0002AE3: 8B 45 08 mov eax,dword ptr [ebp+8] + E0002AE6: 8B 40 08 mov eax,dword ptr [eax+8] + E0002AE9: 5D pop ebp + E0002AEA: C3 ret +?Release@CConsole@@UAAKXZ (public: virtual unsigned long __cdecl CConsole::Release(void)): + E0002AEB: 55 push ebp + E0002AEC: 8B EC mov ebp,esp + E0002AEE: 51 push ecx + E0002AEF: 8B 45 08 mov eax,dword ptr [ebp+8] + E0002AF2: 83 78 08 00 cmp dword ptr [eax+8],0 + E0002AF6: 75 16 jne E0002B0E + E0002AF8: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0002AFB: 89 4D FC mov dword ptr [ebp-4],ecx + E0002AFE: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002B01: 52 push edx + E0002B02: E8 63 74 00 00 call E0009F6A + E0002B07: 83 C4 04 add esp,4 + E0002B0A: 33 C0 xor eax,eax + E0002B0C: EB 15 jmp E0002B23 + E0002B0E: 8B 45 08 mov eax,dword ptr [ebp+8] + E0002B11: 8B 48 08 mov ecx,dword ptr [eax+8] + E0002B14: 83 E9 01 sub ecx,1 + E0002B17: 8B 55 08 mov edx,dword ptr [ebp+8] + E0002B1A: 89 4A 08 mov dword ptr [edx+8],ecx + E0002B1D: 8B 45 08 mov eax,dword ptr [ebp+8] + E0002B20: 8B 40 08 mov eax,dword ptr [eax+8] + E0002B23: 8B E5 mov esp,ebp + E0002B25: 5D pop ebp + E0002B26: C3 ret +?GetInfo@CConsole@@UAAKPAUdevice_t@@@Z (public: virtual unsigned long __cdecl CConsole::GetInfo(struct device_t *)): + E0002B27: 55 push ebp + E0002B28: 8B EC mov ebp,esp + E0002B2A: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002B2D: 83 38 0C cmp dword ptr [eax],0Ch + E0002B30: 73 07 jae E0002B39 + E0002B32: B8 00 00 00 80 mov eax,80000000h + E0002B37: EB 16 jmp E0002B4F + E0002B39: 68 C0 B4 00 E0 push 0E000B4C0h + E0002B3E: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0002B41: 8B 51 04 mov edx,dword ptr [ecx+4] + E0002B44: 52 push edx + E0002B45: E8 C0 73 00 00 call E0009F0A + E0002B4A: 83 C4 08 add esp,8 + E0002B4D: 33 C0 xor eax,eax + E0002B4F: 5D pop ebp + E0002B50: C3 ret +?DeviceOpen@CConsole@@UAAKXZ (public: virtual unsigned long __cdecl CConsole::DeviceOpen(void)): + E0002B51: 55 push ebp + E0002B52: 8B EC mov ebp,esp + E0002B54: 33 C0 xor eax,eax + E0002B56: 5D pop ebp + E0002B57: C3 ret +?WriteCharacter@CConsole@@QAEXIG@Z (public: void __thiscall CConsole::WriteCharacter(unsigned int,unsigned short)): + E0002B58: 55 push ebp + E0002B59: 8B EC mov ebp,esp + E0002B5B: 83 EC 08 sub esp,8 + E0002B5E: 89 4D FC mov dword ptr [ebp-4],ecx + E0002B61: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E0002B65: 75 6E jne E0002BD5 + E0002B67: 6A 00 push 0 + E0002B69: 66 8B 45 0C mov ax,word ptr [ebp+0Ch] + E0002B6D: 50 push eax + E0002B6E: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002B71: 33 D2 xor edx,edx + E0002B73: 66 8B 51 0E mov dx,word ptr [ecx+0Eh] + E0002B77: 52 push edx + E0002B78: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002B7B: 33 C9 xor ecx,ecx + E0002B7D: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0002B81: 51 push ecx + E0002B82: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002B85: 8B 02 mov eax,dword ptr [edx] + E0002B87: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002B8A: FF 50 10 call dword ptr [eax+10h] + E0002B8D: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002B90: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0002B94: 66 83 C2 01 add dx,1 + E0002B98: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002B9B: 66 89 50 0C mov word ptr [eax+0Ch],dx + E0002B9F: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002BA2: 33 D2 xor edx,edx + E0002BA4: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0002BA8: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002BAB: 33 C9 xor ecx,ecx + E0002BAD: 66 8B 48 10 mov cx,word ptr [eax+10h] + E0002BB1: 3B D1 cmp edx,ecx + E0002BB3: 7C 1B jl E0002BD0 + E0002BB5: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002BB8: 66 C7 42 0C 00 00 mov word ptr [edx+0Ch],0 + E0002BBE: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002BC1: 66 8B 48 0E mov cx,word ptr [eax+0Eh] + E0002BC5: 66 83 C1 01 add cx,1 + E0002BC9: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002BCC: 66 89 4A 0E mov word ptr [edx+0Eh],cx + E0002BD0: E9 B3 03 00 00 jmp E0002F88 + E0002BD5: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002BD8: 33 C9 xor ecx,ecx + E0002BDA: 8A 48 14 mov cl,byte ptr [eax+14h] + E0002BDD: 83 F9 01 cmp ecx,1 + E0002BE0: 75 2E jne E0002C10 + E0002BE2: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0002BE5: 81 E2 FF FF 00 00 and edx,0FFFFh + E0002BEB: 83 FA 5B cmp edx,5Bh + E0002BEE: 75 1B jne E0002C0B + E0002BF0: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002BF3: 8A 48 14 mov cl,byte ptr [eax+14h] + E0002BF6: 80 C1 01 add cl,1 + E0002BF9: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002BFC: 88 4A 14 mov byte ptr [edx+14h],cl + E0002BFF: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002C02: C6 40 15 00 mov byte ptr [eax+15h],0 + E0002C06: E9 B6 03 00 00 jmp E0002FC1 + E0002C0B: E9 5F 02 00 00 jmp E0002E6F + E0002C10: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002C13: 33 D2 xor edx,edx + E0002C15: 8A 51 14 mov dl,byte ptr [ecx+14h] + E0002C18: 83 FA 02 cmp edx,2 + E0002C1B: 0F 85 B5 00 00 00 jne E0002CD6 + E0002C21: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002C24: 25 FF FF 00 00 and eax,0FFFFh + E0002C29: 83 F8 30 cmp eax,30h + E0002C2C: 7C 31 jl E0002C5F + E0002C2E: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0002C31: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0002C37: 83 F9 39 cmp ecx,39h + E0002C3A: 7F 23 jg E0002C5F + E0002C3C: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002C3F: 33 C0 xor eax,eax + E0002C41: 8A 42 15 mov al,byte ptr [edx+15h] + E0002C44: 6B C0 0A imul eax,eax,0Ah + E0002C47: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0002C4A: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0002C50: 8D 54 08 D0 lea edx,dword ptr [eax+ecx-30h] + E0002C54: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002C57: 88 50 15 mov byte ptr [eax+15h],dl + E0002C5A: E9 62 03 00 00 jmp E0002FC1 + E0002C5F: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0002C62: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0002C68: 83 F9 3B cmp ecx,3Bh + E0002C6B: 75 1A jne E0002C87 + E0002C6D: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002C70: 8A 42 14 mov al,byte ptr [edx+14h] + E0002C73: 04 01 add al,1 + E0002C75: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002C78: 88 41 14 mov byte ptr [ecx+14h],al + E0002C7B: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002C7E: C6 42 16 00 mov byte ptr [edx+16h],0 + E0002C82: E9 3A 03 00 00 jmp E0002FC1 + E0002C87: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002C8A: 25 FF FF 00 00 and eax,0FFFFh + E0002C8F: 83 F8 4A cmp eax,4Ah + E0002C92: 75 1A jne E0002CAE + E0002C94: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002C97: 33 D2 xor edx,edx + E0002C99: 8A 51 15 mov dl,byte ptr [ecx+15h] + E0002C9C: 83 FA 02 cmp edx,2 + E0002C9F: 75 0B jne E0002CAC + E0002CA1: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002CA4: 8B 10 mov edx,dword ptr [eax] + E0002CA6: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002CA9: FF 52 14 call dword ptr [edx+14h] + E0002CAC: EB 1C jmp E0002CCA + E0002CAE: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002CB1: 25 FF FF 00 00 and eax,0FFFFh + E0002CB6: 83 F8 6D cmp eax,6Dh + E0002CB9: 75 0F jne E0002CCA + E0002CBB: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002CBE: 8A 51 15 mov dl,byte ptr [ecx+15h] + E0002CC1: 52 push edx + E0002CC2: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002CC5: E8 29 03 00 00 call E0002FF3 + E0002CCA: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002CCD: C6 40 14 00 mov byte ptr [eax+14h],0 + E0002CD1: E9 EB 02 00 00 jmp E0002FC1 + E0002CD6: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002CD9: 33 D2 xor edx,edx + E0002CDB: 8A 51 14 mov dl,byte ptr [ecx+14h] + E0002CDE: 83 FA 03 cmp edx,3 + E0002CE1: 0F 85 F4 00 00 00 jne E0002DDB + E0002CE7: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002CEA: 25 FF FF 00 00 and eax,0FFFFh + E0002CEF: 83 F8 30 cmp eax,30h + E0002CF2: 7C 31 jl E0002D25 + E0002CF4: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0002CF7: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0002CFD: 83 F9 39 cmp ecx,39h + E0002D00: 7F 23 jg E0002D25 + E0002D02: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002D05: 33 C0 xor eax,eax + E0002D07: 8A 42 16 mov al,byte ptr [edx+16h] + E0002D0A: 6B C0 0A imul eax,eax,0Ah + E0002D0D: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0002D10: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0002D16: 8D 54 08 D0 lea edx,dword ptr [eax+ecx-30h] + E0002D1A: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002D1D: 88 50 16 mov byte ptr [eax+16h],dl + E0002D20: E9 9C 02 00 00 jmp E0002FC1 + E0002D25: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0002D28: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0002D2E: 83 F9 3B cmp ecx,3Bh + E0002D31: 75 1A jne E0002D4D + E0002D33: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002D36: 8A 42 14 mov al,byte ptr [edx+14h] + E0002D39: 04 01 add al,1 + E0002D3B: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002D3E: 88 41 14 mov byte ptr [ecx+14h],al + E0002D41: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002D44: C6 42 17 00 mov byte ptr [edx+17h],0 + E0002D48: E9 74 02 00 00 jmp E0002FC1 + E0002D4D: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002D50: 25 FF FF 00 00 and eax,0FFFFh + E0002D55: 83 F8 48 cmp eax,48h + E0002D58: 75 4A jne E0002DA4 + E0002D5A: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002D5D: 33 D2 xor edx,edx + E0002D5F: 8A 51 16 mov dl,byte ptr [ecx+16h] + E0002D62: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002D65: 33 C9 xor ecx,ecx + E0002D67: 66 8B 48 10 mov cx,word ptr [eax+10h] + E0002D6B: 3B D1 cmp edx,ecx + E0002D6D: 7D 0F jge E0002D7E + E0002D6F: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002D72: 66 0F B6 42 16 movzx ax,byte ptr [edx+16h] + E0002D77: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002D7A: 66 89 41 0C mov word ptr [ecx+0Ch],ax + E0002D7E: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002D81: 33 C0 xor eax,eax + E0002D83: 8A 42 15 mov al,byte ptr [edx+15h] + E0002D86: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002D89: 33 D2 xor edx,edx + E0002D8B: 66 8B 51 12 mov dx,word ptr [ecx+12h] + E0002D8F: 3B C2 cmp eax,edx + E0002D91: 7D 0F jge E0002DA2 + E0002D93: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002D96: 66 0F B6 48 15 movzx cx,byte ptr [eax+15h] + E0002D9B: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002D9E: 66 89 4A 0E mov word ptr [edx+0Eh],cx + E0002DA2: EB 2B jmp E0002DCF + E0002DA4: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002DA7: 25 FF FF 00 00 and eax,0FFFFh + E0002DAC: 83 F8 6D cmp eax,6Dh + E0002DAF: 75 1E jne E0002DCF + E0002DB1: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002DB4: 8A 51 15 mov dl,byte ptr [ecx+15h] + E0002DB7: 52 push edx + E0002DB8: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002DBB: E8 33 02 00 00 call E0002FF3 + E0002DC0: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002DC3: 8A 48 16 mov cl,byte ptr [eax+16h] + E0002DC6: 51 push ecx + E0002DC7: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002DCA: E8 24 02 00 00 call E0002FF3 + E0002DCF: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002DD2: C6 42 14 00 mov byte ptr [edx+14h],0 + E0002DD6: E9 E6 01 00 00 jmp E0002FC1 + E0002DDB: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002DDE: 33 C9 xor ecx,ecx + E0002DE0: 8A 48 14 mov cl,byte ptr [eax+14h] + E0002DE3: 83 F9 04 cmp ecx,4 + E0002DE6: 0F 85 83 00 00 00 jne E0002E6F + E0002DEC: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0002DEF: 81 E2 FF FF 00 00 and edx,0FFFFh + E0002DF5: 83 FA 30 cmp edx,30h + E0002DF8: 7C 2F jl E0002E29 + E0002DFA: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002DFD: 25 FF FF 00 00 and eax,0FFFFh + E0002E02: 83 F8 39 cmp eax,39h + E0002E05: 7F 22 jg E0002E29 + E0002E07: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002E0A: 33 D2 xor edx,edx + E0002E0C: 8A 51 17 mov dl,byte ptr [ecx+17h] + E0002E0F: 6B D2 0A imul edx,edx,0Ah + E0002E12: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002E15: 25 FF FF 00 00 and eax,0FFFFh + E0002E1A: 8D 4C 02 D0 lea ecx,dword ptr [edx+eax-30h] + E0002E1E: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002E21: 88 4A 17 mov byte ptr [edx+17h],cl + E0002E24: E9 98 01 00 00 jmp E0002FC1 + E0002E29: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002E2C: 25 FF FF 00 00 and eax,0FFFFh + E0002E31: 83 F8 6D cmp eax,6Dh + E0002E34: 75 2D jne E0002E63 + E0002E36: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002E39: 8A 51 15 mov dl,byte ptr [ecx+15h] + E0002E3C: 52 push edx + E0002E3D: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002E40: E8 AE 01 00 00 call E0002FF3 + E0002E45: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002E48: 8A 48 16 mov cl,byte ptr [eax+16h] + E0002E4B: 51 push ecx + E0002E4C: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002E4F: E8 9F 01 00 00 call E0002FF3 + E0002E54: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002E57: 8A 42 17 mov al,byte ptr [edx+17h] + E0002E5A: 50 push eax + E0002E5B: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002E5E: E8 90 01 00 00 call E0002FF3 + E0002E63: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002E66: C6 41 14 00 mov byte ptr [ecx+14h],0 + E0002E6A: E9 52 01 00 00 jmp E0002FC1 + E0002E6F: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002E72: C6 42 14 00 mov byte ptr [edx+14h],0 + E0002E76: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0002E79: 25 FF FF 00 00 and eax,0FFFFh + E0002E7E: 89 45 F8 mov dword ptr [ebp-8],eax + E0002E81: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0002E84: 83 E9 08 sub ecx,8 + E0002E87: 89 4D F8 mov dword ptr [ebp-8],ecx + E0002E8A: 83 7D F8 13 cmp dword ptr [ebp-8],13h + E0002E8E: 0F 87 85 00 00 00 ja E0002F19 + E0002E94: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0002E97: 33 D2 xor edx,edx + E0002E99: 8A 90 DF 2F 00 E0 mov dl,byte ptr [eax+E0002FDFh] + E0002E9F: FF 24 95 C7 2F 00 jmp dword ptr [edx*4+E0002FC7h] + E0 + E0002EA6: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002EA9: 66 C7 41 0C 00 00 mov word ptr [ecx+0Ch],0 + E0002EAF: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002EB2: 66 8B 42 0E mov ax,word ptr [edx+0Eh] + E0002EB6: 66 05 01 00 add ax,1 + E0002EBA: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002EBD: 66 89 41 0E mov word ptr [ecx+0Eh],ax + E0002EC1: E9 C2 00 00 00 jmp E0002F88 + E0002EC6: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002EC9: 66 C7 42 0C 00 00 mov word ptr [edx+0Ch],0 + E0002ECF: E9 B4 00 00 00 jmp E0002F88 + E0002ED4: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002ED7: 33 C9 xor ecx,ecx + E0002ED9: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0002EDD: 83 C1 04 add ecx,4 + E0002EE0: 83 E1 FC and ecx,0FCh + E0002EE3: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002EE6: 66 89 4A 0C mov word ptr [edx+0Ch],cx + E0002EEA: E9 99 00 00 00 jmp E0002F88 + E0002EEF: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002EF2: 33 C9 xor ecx,ecx + E0002EF4: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0002EF8: 85 C9 test ecx,ecx + E0002EFA: 7E 12 jle E0002F0E + E0002EFC: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002EFF: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0002F03: 66 2D 01 00 sub ax,1 + E0002F07: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002F0A: 66 89 41 0C mov word ptr [ecx+0Ch],ax + E0002F0E: EB 78 jmp E0002F88 + E0002F10: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002F13: C6 42 14 01 mov byte ptr [edx+14h],1 + E0002F17: EB 6F jmp E0002F88 + E0002F19: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002F1C: 66 8B 48 18 mov cx,word ptr [eax+18h] + E0002F20: 51 push ecx + E0002F21: 66 8B 55 0C mov dx,word ptr [ebp+0Ch] + E0002F25: 52 push edx + E0002F26: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002F29: 33 C9 xor ecx,ecx + E0002F2B: 66 8B 48 0E mov cx,word ptr [eax+0Eh] + E0002F2F: 51 push ecx + E0002F30: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002F33: 33 C0 xor eax,eax + E0002F35: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0002F39: 50 push eax + E0002F3A: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002F3D: 8B 11 mov edx,dword ptr [ecx] + E0002F3F: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002F42: FF 52 10 call dword ptr [edx+10h] + E0002F45: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002F48: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0002F4C: 66 83 C1 01 add cx,1 + E0002F50: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002F53: 66 89 4A 0C mov word ptr [edx+0Ch],cx + E0002F57: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002F5A: 33 C9 xor ecx,ecx + E0002F5C: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0002F60: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002F63: 33 C0 xor eax,eax + E0002F65: 66 8B 42 10 mov ax,word ptr [edx+10h] + E0002F69: 3B C8 cmp ecx,eax + E0002F6B: 7C 1B jl E0002F88 + E0002F6D: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002F70: 66 C7 41 0C 00 00 mov word ptr [ecx+0Ch],0 + E0002F76: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002F79: 66 8B 42 0E mov ax,word ptr [edx+0Eh] + E0002F7D: 66 05 01 00 add ax,1 + E0002F81: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002F84: 66 89 41 0E mov word ptr [ecx+0Eh],ax + E0002F88: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002F8B: 33 C0 xor eax,eax + E0002F8D: 66 8B 42 0E mov ax,word ptr [edx+0Eh] + E0002F91: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002F94: 33 D2 xor edx,edx + E0002F96: 66 8B 51 12 mov dx,word ptr [ecx+12h] + E0002F9A: 3B C2 cmp eax,edx + E0002F9C: 7C 23 jl E0002FC1 + E0002F9E: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002FA1: 66 8B 48 0E mov cx,word ptr [eax+0Eh] + E0002FA5: 66 83 E9 01 sub cx,1 + E0002FA9: 8B 55 FC mov edx,dword ptr [ebp-4] + E0002FAC: 66 89 4A 0E mov word ptr [edx+0Eh],cx + E0002FB0: 6A FF push 0FFh + E0002FB2: 6A 00 push 0 + E0002FB4: 8B 45 FC mov eax,dword ptr [ebp-4] + E0002FB7: 8B 10 mov edx,dword ptr [eax] + E0002FB9: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0002FBC: FF 52 18 call dword ptr [edx+18h] + E0002FBF: EB C7 jmp E0002F88 + E0002FC1: 8B E5 mov esp,ebp + E0002FC3: 5D pop ebp + E0002FC4: C2 08 00 ret 8 + E0002FC7: EF out dx,eax + E0002FC8: 2E 00 E0 add al,ah + E0002FCB: D4 aam + E0002FCC: 2E 00 E0 add al,ah + E0002FCF: A6 cmps byte ptr [esi],byte ptr es:[edi] + E0002FD0: 2E 00 E0 add al,ah + E0002FD3: C6 2E 00 mov byte ptr [esi],0 + E0002FD6: E0 10 loopne E0002FE8 + E0002FD8: 2F das + E0002FD9: 00 E0 add al,ah + E0002FDB: 19 2F sbb dword ptr [edi],ebp + E0002FDD: 00 E0 add al,ah + E0002FDF: 00 01 add byte ptr [ecx],al + E0002FE1: 02 05 05 03 05 05 add al,byte ptr ds:[05050305h] + E0002FE7: 05 05 05 05 05 add eax,5050505h + E0002FEC: 05 05 05 05 05 add eax,5050505h + E0002FF1: 05 04 55 8B EC add eax,0EC8B5504h +?SetAttrib@CConsole@@QAEXE@Z (public: void __thiscall CConsole::SetAttrib(unsigned char)) + 3: + E0002FF6: 83 EC 08 sub esp,8 + E0002FF9: 89 4D F8 mov dword ptr [ebp-8],ecx + E0002FFC: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0002FFF: 33 C9 xor ecx,ecx + E0003001: 66 8B 48 18 mov cx,word ptr [eax+18h] + E0003005: C1 F9 08 sar ecx,8 + E0003008: 88 4D FC mov byte ptr [ebp-4],cl + E000300B: 8B 55 08 mov edx,dword ptr [ebp+8] + E000300E: 81 E2 FF 00 00 00 and edx,0FFh + E0003014: 85 D2 test edx,edx + E0003016: 75 0D jne E0003025 + E0003018: 8A 45 FC mov al,byte ptr [ebp-4] + E000301B: 24 F7 and al,0F7h + E000301D: 88 45 FC mov byte ptr [ebp-4],al + E0003020: E9 B0 00 00 00 jmp E00030D5 + E0003025: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003028: 81 E1 FF 00 00 00 and ecx,0FFh + E000302E: 83 F9 01 cmp ecx,1 + E0003031: 75 0E jne E0003041 + E0003033: 8A 55 FC mov dl,byte ptr [ebp-4] + E0003036: 80 CA 08 or dl,8 + E0003039: 88 55 FC mov byte ptr [ebp-4],dl + E000303C: E9 94 00 00 00 jmp E00030D5 + E0003041: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003044: 25 FF 00 00 00 and eax,0FFh + E0003049: 83 F8 1E cmp eax,1Eh + E000304C: 7C 3C jl E000308A + E000304E: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003051: 81 E1 FF 00 00 00 and ecx,0FFh + E0003057: 83 F9 25 cmp ecx,25h + E000305A: 7F 2E jg E000308A + E000305C: 8B 55 08 mov edx,dword ptr [ebp+8] + E000305F: 81 E2 FF 00 00 00 and edx,0FFh + E0003065: 8A 82 7A A1 00 E0 mov al,byte ptr [edx+E000A17Ah] + E000306B: 88 45 08 mov byte ptr [ebp+8],al + E000306E: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0003071: 81 E1 FF 00 00 00 and ecx,0FFh + E0003077: 83 E1 F8 and ecx,0F8h + E000307A: 8B 55 08 mov edx,dword ptr [ebp+8] + E000307D: 81 E2 FF 00 00 00 and edx,0FFh + E0003083: 0B CA or ecx,edx + E0003085: 88 4D FC mov byte ptr [ebp-4],cl + E0003088: EB 4B jmp E00030D5 + E000308A: 8B 45 08 mov eax,dword ptr [ebp+8] + E000308D: 25 FF 00 00 00 and eax,0FFh + E0003092: 83 F8 28 cmp eax,28h + E0003095: 7C 3E jl E00030D5 + E0003097: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000309A: 81 E1 FF 00 00 00 and ecx,0FFh + E00030A0: 83 F9 2F cmp ecx,2Fh + E00030A3: 7F 30 jg E00030D5 + E00030A5: 8B 55 08 mov edx,dword ptr [ebp+8] + E00030A8: 81 E2 FF 00 00 00 and edx,0FFh + E00030AE: 0F BE 82 70 A1 00 movsx eax,byte ptr [edx+E000A170h] + E0 + E00030B5: C1 E0 04 shl eax,4 + E00030B8: 88 45 08 mov byte ptr [ebp+8],al + E00030BB: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00030BE: 81 E1 FF 00 00 00 and ecx,0FFh + E00030C4: 83 E1 8F and ecx,8Fh + E00030C7: 8B 55 08 mov edx,dword ptr [ebp+8] + E00030CA: 81 E2 FF 00 00 00 and edx,0FFh + E00030D0: 0B CA or ecx,edx + E00030D2: 88 4D FC mov byte ptr [ebp-4],cl + E00030D5: 8B 45 FC mov eax,dword ptr [ebp-4] + E00030D8: 25 FF 00 00 00 and eax,0FFh + E00030DD: C1 E0 08 shl eax,8 + E00030E0: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00030E3: 66 89 41 18 mov word ptr [ecx+18h],ax + E00030E7: 8B E5 mov esp,ebp + E00030E9: 5D pop ebp + E00030EA: C2 04 00 ret 4 +??0CStream@CConsole@@QAE@PAV1@@Z (public: __thiscall CConsole::CStream::CStream(class CStream *)): + E00030ED: 55 push ebp + E00030EE: 8B EC mov ebp,esp + E00030F0: 83 EC 08 sub esp,8 + E00030F3: 89 4D F8 mov dword ptr [ebp-8],ecx + E00030F6: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00030F9: C7 00 C8 A0 00 E0 mov dword ptr [eax],0E000A0C8h + E00030FF: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003102: 83 C1 04 add ecx,4 + E0003105: 89 4D FC mov dword ptr [ebp-4],ecx + E0003108: 8B 55 FC mov edx,dword ptr [ebp-4] + E000310B: C7 02 10 A2 00 E0 mov dword ptr [edx],0E000A210h + E0003111: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0003114: C7 00 00 A2 00 E0 mov dword ptr [eax],0E000A200h + E000311A: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E000311D: C7 41 04 D8 A1 00 mov dword ptr [ecx+4],0E000A1D8h + E0 + E0003124: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0003127: 8B 45 08 mov eax,dword ptr [ebp+8] + E000312A: 89 42 08 mov dword ptr [edx+8],eax + E000312D: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003130: 8B 51 08 mov edx,dword ptr [ecx+8] + E0003133: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0003136: 8B 48 08 mov ecx,dword ptr [eax+8] + E0003139: 8B 01 mov eax,dword ptr [ecx] + E000313B: 52 push edx + E000313C: FF 50 04 call dword ptr [eax+4] + E000313F: 83 C4 04 add esp,4 + E0003142: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003145: C7 41 0C 01 00 00 mov dword ptr [ecx+0Ch],1 + 00 + E000314C: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000314F: C7 42 10 00 00 00 mov dword ptr [edx+10h],0 + 00 + E0003156: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0003159: 8B E5 mov esp,ebp + E000315B: 5D pop ebp + E000315C: C2 04 00 ret 4 +??1CStream@CConsole@@QAE@XZ (public: __thiscall CConsole::CStream::~CStream(void)): + E000315F: 55 push ebp + E0003160: 8B EC mov ebp,esp + E0003162: 51 push ecx + E0003163: 89 4D FC mov dword ptr [ebp-4],ecx + E0003166: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003169: C7 00 00 A2 00 E0 mov dword ptr [eax],0E000A200h + E000316F: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0003172: C7 41 04 D8 A1 00 mov dword ptr [ecx+4],0E000A1D8h + E0 + E0003179: 8B 55 FC mov edx,dword ptr [ebp-4] + E000317C: 83 7A 08 00 cmp dword ptr [edx+8],0 + E0003180: 74 15 je E0003197 + E0003182: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003185: 8B 48 08 mov ecx,dword ptr [eax+8] + E0003188: 8B 55 FC mov edx,dword ptr [ebp-4] + E000318B: 8B 42 08 mov eax,dword ptr [edx+8] + E000318E: 8B 10 mov edx,dword ptr [eax] + E0003190: 51 push ecx + E0003191: FF 52 08 call dword ptr [edx+8] + E0003194: 83 C4 04 add esp,4 + E0003197: 8B E5 mov esp,ebp + E0003199: 5D pop ebp + E000319A: C3 ret +?QueryInterface@CStream@CConsole@@UAAKABU_GUID@@PAPAX@Z (public: virtual unsigned long __cdecl CConsole::CStream::QueryInterface(struct _GUID const &,void * *)): + E000319B: 55 push ebp + E000319C: 8B EC mov ebp,esp + E000319E: 83 EC 08 sub esp,8 + E00031A1: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00031A4: 8B 08 mov ecx,dword ptr [eax] + E00031A6: 3B 0D D8 A0 00 E0 cmp ecx,dword ptr ds:[E000A0D8h] + E00031AC: 75 2A jne E00031D8 + E00031AE: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00031B1: 8B 42 04 mov eax,dword ptr [edx+4] + E00031B4: 3B 05 DC A0 00 E0 cmp eax,dword ptr ds:[E000A0DCh] + E00031BA: 75 1C jne E00031D8 + E00031BC: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00031BF: 8B 51 08 mov edx,dword ptr [ecx+8] + E00031C2: 3B 15 E0 A0 00 E0 cmp edx,dword ptr ds:[E000A0E0h] + E00031C8: 75 0E jne E00031D8 + E00031CA: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00031CD: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E00031D0: 3B 0D E4 A0 00 E0 cmp ecx,dword ptr ds:[E000A0E4h] + E00031D6: 74 37 je E000320F + E00031D8: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00031DB: 8B 02 mov eax,dword ptr [edx] + E00031DD: 3B 05 18 A1 00 E0 cmp eax,dword ptr ds:[E000A118h] + E00031E3: 75 60 jne E0003245 + E00031E5: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00031E8: 8B 51 04 mov edx,dword ptr [ecx+4] + E00031EB: 3B 15 1C A1 00 E0 cmp edx,dword ptr ds:[E000A11Ch] + E00031F1: 75 52 jne E0003245 + E00031F3: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00031F6: 8B 48 08 mov ecx,dword ptr [eax+8] + E00031F9: 3B 0D 20 A1 00 E0 cmp ecx,dword ptr ds:[E000A120h] + E00031FF: 75 44 jne E0003245 + E0003201: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0003204: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0003207: 3B 05 24 A1 00 E0 cmp eax,dword ptr ds:[E000A124h] + E000320D: 75 36 jne E0003245 + E000320F: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003212: 8B 11 mov edx,dword ptr [ecx] + E0003214: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003217: 50 push eax + E0003218: FF 52 04 call dword ptr [edx+4] + E000321B: 83 C4 04 add esp,4 + E000321E: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E0003222: 74 0B je E000322F + E0003224: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003227: 83 C1 04 add ecx,4 + E000322A: 89 4D FC mov dword ptr [ebp-4],ecx + E000322D: EB 07 jmp E0003236 + E000322F: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0003236: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0003239: 8B 45 FC mov eax,dword ptr [ebp-4] + E000323C: 89 02 mov dword ptr [edx],eax + E000323E: 33 C0 xor eax,eax + E0003240: E9 84 00 00 00 jmp E00032C9 + E0003245: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003248: 8B 11 mov edx,dword ptr [ecx] + E000324A: 3B 15 08 A1 00 E0 cmp edx,dword ptr ds:[E000A108h] + E0003250: 75 69 jne E00032BB + E0003252: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0003255: 8B 48 04 mov ecx,dword ptr [eax+4] + E0003258: 3B 0D 0C A1 00 E0 cmp ecx,dword ptr ds:[E000A10Ch] + E000325E: 75 5B jne E00032BB + E0003260: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0003263: 8B 42 08 mov eax,dword ptr [edx+8] + E0003266: 3B 05 10 A1 00 E0 cmp eax,dword ptr ds:[E000A110h] + E000326C: 75 4D jne E00032BB + E000326E: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003271: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0003274: 3B 15 14 A1 00 E0 cmp edx,dword ptr ds:[E000A114h] + E000327A: 75 3F jne E00032BB + E000327C: 8B 45 08 mov eax,dword ptr [ebp+8] + E000327F: 8B 48 08 mov ecx,dword ptr [eax+8] + E0003282: 8B 55 08 mov edx,dword ptr [ebp+8] + E0003285: 8B 42 08 mov eax,dword ptr [edx+8] + E0003288: 8B 10 mov edx,dword ptr [eax] + E000328A: 51 push ecx + E000328B: FF 52 04 call dword ptr [edx+4] + E000328E: 83 C4 04 add esp,4 + E0003291: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003294: 83 78 08 00 cmp dword ptr [eax+8],0 + E0003298: 74 0E je E00032A8 + E000329A: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000329D: 8B 51 08 mov edx,dword ptr [ecx+8] + E00032A0: 83 C2 04 add edx,4 + E00032A3: 89 55 F8 mov dword ptr [ebp-8],edx + E00032A6: EB 07 jmp E00032AF + E00032A8: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E00032AF: 8B 45 10 mov eax,dword ptr [ebp+10h] + E00032B2: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00032B5: 89 08 mov dword ptr [eax],ecx + E00032B7: 33 C0 xor eax,eax + E00032B9: EB 0E jmp E00032C9 + E00032BB: 8B 55 10 mov edx,dword ptr [ebp+10h] + E00032BE: C7 02 00 00 00 00 mov dword ptr [edx],0 + E00032C4: B8 00 00 00 80 mov eax,80000000h + E00032C9: 8B E5 mov esp,ebp + E00032CB: 5D pop ebp + E00032CC: C3 ret +?AddRef@CStream@CConsole@@UAAKXZ (public: virtual unsigned long __cdecl CConsole::CStream::AddRef(void)): + E00032CD: 55 push ebp + E00032CE: 8B EC mov ebp,esp + E00032D0: 8B 45 08 mov eax,dword ptr [ebp+8] + E00032D3: 8B 48 10 mov ecx,dword ptr [eax+10h] + E00032D6: 83 C1 01 add ecx,1 + E00032D9: 8B 55 08 mov edx,dword ptr [ebp+8] + E00032DC: 89 4A 10 mov dword ptr [edx+10h],ecx + E00032DF: 8B 45 08 mov eax,dword ptr [ebp+8] + E00032E2: 8B 40 10 mov eax,dword ptr [eax+10h] + E00032E5: 5D pop ebp + E00032E6: C3 ret +?Release@CStream@CConsole@@UAAKXZ (public: virtual unsigned long __cdecl CConsole::CStream::Release(void)): + E00032E7: 55 push ebp + E00032E8: 8B EC mov ebp,esp + E00032EA: 83 EC 0C sub esp,0Ch + E00032ED: 8B 45 08 mov eax,dword ptr [ebp+8] + E00032F0: 83 78 10 00 cmp dword ptr [eax+10h],0 + E00032F4: 75 45 jne E000333B + E00032F6: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00032F9: 89 4D F8 mov dword ptr [ebp-8],ecx + E00032FC: 8B 55 F8 mov edx,dword ptr [ebp-8] + E00032FF: 89 55 FC mov dword ptr [ebp-4],edx + E0003302: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0003306: 74 28 je E0003330 + E0003308: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000330B: E8 4F FE FF FF call E000315F + E0003310: B8 01 00 00 00 mov eax,1 + E0003315: 83 E0 01 and eax,1 + E0003318: 85 C0 test eax,eax + E000331A: 74 0C je E0003328 + E000331C: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000331F: 51 push ecx + E0003320: E8 45 6C 00 00 call E0009F6A + E0003325: 83 C4 04 add esp,4 + E0003328: 8B 55 FC mov edx,dword ptr [ebp-4] + E000332B: 89 55 F4 mov dword ptr [ebp-0Ch],edx + E000332E: EB 07 jmp E0003337 + E0003330: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E0003337: 33 C0 xor eax,eax + E0003339: EB 15 jmp E0003350 + E000333B: 8B 45 08 mov eax,dword ptr [ebp+8] + E000333E: 8B 48 10 mov ecx,dword ptr [eax+10h] + E0003341: 83 E9 01 sub ecx,1 + E0003344: 8B 55 08 mov edx,dword ptr [ebp+8] + E0003347: 89 4A 10 mov dword ptr [edx+10h],ecx + E000334A: 8B 45 08 mov eax,dword ptr [ebp+8] + E000334D: 8B 40 10 mov eax,dword ptr [eax+10h] + E0003350: 8B E5 mov esp,ebp + E0003352: 5D pop ebp + E0003353: C3 ret +?Read@CStream@CConsole@@UAAIPAXI@Z (public: virtual unsigned int __cdecl CConsole::CStream::Read(void *,unsigned int)): + E0003354: 55 push ebp + E0003355: 8B EC mov ebp,esp + E0003357: 33 C0 xor eax,eax + E0003359: 5D pop ebp + E000335A: C3 ret +?Write@CStream@CConsole@@UAAIPBXI@Z (public: virtual unsigned int __cdecl CConsole::CStream::Write(void const *,unsigned int)): + E000335B: 55 push ebp + E000335C: 8B EC mov ebp,esp + E000335E: 83 EC 0C sub esp,0Ch + E0003361: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0003368: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000336B: 89 45 F8 mov dword ptr [ebp-8],eax + E000336E: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0003371: 3B 4D 10 cmp ecx,dword ptr [ebp+10h] + E0003374: 73 78 jae E00033EE + E0003376: 8B 55 08 mov edx,dword ptr [ebp+8] + E0003379: 8B 42 08 mov eax,dword ptr [edx+8] + E000337C: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E000337F: 83 7D F4 00 cmp dword ptr [ebp-0Ch],0 + E0003383: 72 67 jb E00033EC + E0003385: 83 7D F4 01 cmp dword ptr [ebp-0Ch],1 + E0003389: 76 08 jbe E0003393 + E000338B: 83 7D F4 02 cmp dword ptr [ebp-0Ch],2 + E000338F: 74 2F je E00033C0 + E0003391: EB 59 jmp E00033EC + E0003393: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003396: 66 8B 11 mov dx,word ptr [ecx] + E0003399: 52 push edx + E000339A: 8B 45 08 mov eax,dword ptr [ebp+8] + E000339D: 8B 48 08 mov ecx,dword ptr [eax+8] + E00033A0: 51 push ecx + E00033A1: 8B 55 08 mov edx,dword ptr [ebp+8] + E00033A4: 8B 4A 04 mov ecx,dword ptr [edx+4] + E00033A7: E8 AC F7 FF FF call E0002B58 + E00033AC: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00033AF: 83 C0 02 add eax,2 + E00033B2: 89 45 F8 mov dword ptr [ebp-8],eax + E00033B5: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00033B8: 83 C1 02 add ecx,2 + E00033BB: 89 4D FC mov dword ptr [ebp-4],ecx + E00033BE: EB 2C jmp E00033EC + E00033C0: 8B 55 F8 mov edx,dword ptr [ebp-8] + E00033C3: 66 0F BE 02 movsx ax,byte ptr [edx] + E00033C7: 50 push eax + E00033C8: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00033CB: 8B 51 08 mov edx,dword ptr [ecx+8] + E00033CE: 52 push edx + E00033CF: 8B 45 08 mov eax,dword ptr [ebp+8] + E00033D2: 8B 48 04 mov ecx,dword ptr [eax+4] + E00033D5: E8 7E F7 FF FF call E0002B58 + E00033DA: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00033DD: 83 C1 01 add ecx,1 + E00033E0: 89 4D F8 mov dword ptr [ebp-8],ecx + E00033E3: 8B 55 FC mov edx,dword ptr [ebp-4] + E00033E6: 83 C2 01 add edx,1 + E00033E9: 89 55 FC mov dword ptr [ebp-4],edx + E00033EC: EB 80 jmp E000336E + E00033EE: 8B 45 08 mov eax,dword ptr [ebp+8] + E00033F1: 8B 48 04 mov ecx,dword ptr [eax+4] + E00033F4: 8B 55 08 mov edx,dword ptr [ebp+8] + E00033F7: 8B 42 04 mov eax,dword ptr [edx+4] + E00033FA: 8B 10 mov edx,dword ptr [eax] + E00033FC: FF 52 0C call dword ptr [edx+0Ch] + E00033FF: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003402: 8B E5 mov esp,ebp + E0003404: 5D pop ebp + E0003405: C3 ret +?SetIoMode@CStream@CConsole@@UAAKI@Z (public: virtual unsigned long __cdecl CConsole::CStream::SetIoMode(unsigned int)): + E0003406: 55 push ebp + E0003407: 8B EC mov ebp,esp + E0003409: 8B 45 08 mov eax,dword ptr [ebp+8] + E000340C: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E000340F: 89 48 08 mov dword ptr [eax+8],ecx + E0003412: 33 C0 xor eax,eax + E0003414: 5D pop ebp + E0003415: C3 ret +?IsReady@CStream@CConsole@@UAAKXZ (public: virtual unsigned long __cdecl CConsole::CStream::IsReady(void)): + E0003416: 55 push ebp + E0003417: 8B EC mov ebp,esp + E0003419: 33 C0 xor eax,eax + E000341B: 5D pop ebp + E000341C: C3 ret +?Stat@CStream@CConsole@@UAAKPAU_folderitem_t@@@Z (public: virtual unsigned long __cdecl CConsole::CStream::Stat(struct _folderitem_t *)): + E000341D: 55 push ebp + E000341E: 8B EC mov ebp,esp + E0003420: B8 00 00 00 80 mov eax,80000000h + E0003425: 5D pop ebp + E0003426: C3 ret +?Seek@CStream@CConsole@@UAAKJH@Z (public: virtual unsigned long __cdecl CConsole::CStream::Seek(long,int)): + E0003427: 55 push ebp + E0003428: 8B EC mov ebp,esp + E000342A: B8 00 00 00 80 mov eax,80000000h + E000342F: 5D pop ebp + E0003430: C3 ret + E0003431: CC int 3 + E0003432: CC int 3 + E0003433: CC int 3 + E0003434: CC int 3 + E0003435: CC int 3 + E0003436: CC int 3 + E0003437: CC int 3 + E0003438: CC int 3 + E0003439: CC int 3 + E000343A: CC int 3 + E000343B: CC int 3 + E000343C: CC int 3 + E000343D: CC int 3 + E000343E: CC int 3 + E000343F: CC int 3 +?QueryInterface@CConsole@@W3AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CConsole::QueryInterface`adjustor{4}' (struct _GUID const &,void * *)): + E0003440: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0003445: E9 32 F5 FF FF jmp E000297C + E000344A: CC int 3 + E000344B: CC int 3 + E000344C: CC int 3 + E000344D: CC int 3 + E000344E: CC int 3 + E000344F: CC int 3 +?AddRef@CConsole@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CConsole::AddRef`adjustor{4}' (void)): + E0003450: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0003455: E9 77 F6 FF FF jmp E0002AD1 + E000345A: CC int 3 + E000345B: CC int 3 + E000345C: CC int 3 + E000345D: CC int 3 + E000345E: CC int 3 + E000345F: CC int 3 +?Release@CConsole@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CConsole::Release`adjustor{4}' (void)): + E0003460: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0003465: E9 81 F6 FF FF jmp E0002AEB + E000346A: CC int 3 + E000346B: CC int 3 + E000346C: CC int 3 + E000346D: CC int 3 + E000346E: CC int 3 + E000346F: CC int 3 +?QueryInterface@CStream@CConsole@@W3AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CConsole::CStream::QueryInterface`adjustor{4}' (struct _GUID const &,void * *)): + E0003470: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0003475: E9 21 FD FF FF jmp E000319B + E000347A: CC int 3 + E000347B: CC int 3 + E000347C: CC int 3 + E000347D: CC int 3 + E000347E: CC int 3 + E000347F: CC int 3 +?AddRef@CStream@CConsole@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CConsole::CStream::AddRef`adjustor{4}' (void)): + E0003480: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0003485: E9 43 FE FF FF jmp E00032CD + E000348A: CC int 3 + E000348B: CC int 3 + E000348C: CC int 3 + E000348D: CC int 3 + E000348E: CC int 3 + E000348F: CC int 3 +?Release@CStream@CConsole@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CConsole::CStream::Release`adjustor{4}' (void)): + E0003490: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0003495: E9 4D FE FF FF jmp E00032E7 + E000349A: CC int 3 + E000349B: CC int 3 + E000349C: CC int 3 + E000349D: CC int 3 + E000349E: CC int 3 + E000349F: CC int 3 +_FatRoot_Create: + E00034A0: 55 push ebp + E00034A1: 8B EC mov ebp,esp + E00034A3: 83 EC 50 sub esp,50h + E00034A6: 57 push edi + E00034A7: B9 11 00 00 00 mov ecx,11h + E00034AC: 33 C0 xor eax,eax + E00034AE: 8D 7D BC lea edi,dword ptr [ebp-44h] + E00034B1: F3 AB rep stos dword ptr es:[edi] + E00034B3: C7 45 BC 44 00 00 mov dword ptr [ebp-44h],44h + 00 + E00034BA: 68 7C 02 00 00 push 27Ch + E00034BF: E8 B2 6A 00 00 call E0009F76 + E00034C4: 83 C4 04 add esp,4 + E00034C7: 89 45 B8 mov dword ptr [ebp-48h],eax + E00034CA: 83 7D B8 00 cmp dword ptr [ebp-48h],0 + E00034CE: 74 17 je E00034E7 + E00034D0: 6A 01 push 1 + E00034D2: 8D 45 BC lea eax,dword ptr [ebp-44h] + E00034D5: 50 push eax + E00034D6: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00034D9: 51 push ecx + E00034DA: 8B 4D B8 mov ecx,dword ptr [ebp-48h] + E00034DD: E8 A7 05 00 00 call E0003A89 + E00034E2: 89 45 B4 mov dword ptr [ebp-4Ch],eax + E00034E5: EB 07 jmp E00034EE + E00034E7: C7 45 B4 00 00 00 mov dword ptr [ebp-4Ch],0 + 00 + E00034EE: 83 7D B4 00 cmp dword ptr [ebp-4Ch],0 + E00034F2: 74 0B je E00034FF + E00034F4: 8B 55 B4 mov edx,dword ptr [ebp-4Ch] + E00034F7: 83 C2 04 add edx,4 + E00034FA: 89 55 B0 mov dword ptr [ebp-50h],edx + E00034FD: EB 07 jmp E0003506 + E00034FF: C7 45 B0 00 00 00 mov dword ptr [ebp-50h],0 + 00 + E0003506: 8B 45 B0 mov eax,dword ptr [ebp-50h] + E0003509: 5F pop edi + E000350A: 8B E5 mov esp,ebp + E000350C: 5D pop ebp + E000350D: C3 ret +??0CFatFile@@QAE@PAUIBlockDevice@@PBUfolderitem_fat_t@@@Z (public: __thiscall CFatFile::CFatFile(struct IBlockDevice *,struct folderitem_fat_t const *)): + E000350E: 55 push ebp + E000350F: 8B EC mov ebp,esp + E0003511: 83 EC 08 sub esp,8 + E0003514: 56 push esi + E0003515: 57 push edi + E0003516: 89 4D F8 mov dword ptr [ebp-8],ecx + E0003519: 8B 45 F8 mov eax,dword ptr [ebp-8] + E000351C: C7 00 C8 A0 00 E0 mov dword ptr [eax],0E000A0C8h + E0003522: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003525: 83 C1 04 add ecx,4 + E0003528: 89 4D FC mov dword ptr [ebp-4],ecx + E000352B: 8B 55 FC mov edx,dword ptr [ebp-4] + E000352E: C7 02 10 A2 00 E0 mov dword ptr [edx],0E000A210h + E0003534: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0003537: C7 00 60 A2 00 E0 mov dword ptr [eax],0E000A260h + E000353D: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003540: C7 41 04 38 A2 00 mov dword ptr [ecx+4],0E000A238h + E0 + E0003547: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000354A: 8B 45 08 mov eax,dword ptr [ebp+8] + E000354D: 89 42 5C mov dword ptr [edx+5Ch],eax + E0003550: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003553: 8B 11 mov edx,dword ptr [ecx] + E0003555: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003558: 50 push eax + E0003559: FF 52 04 call dword ptr [edx+4] + E000355C: 83 C4 04 add esp,4 + E000355F: B9 80 00 00 00 mov ecx,80h + E0003564: 33 C0 xor eax,eax + E0003566: 8B 7D F8 mov edi,dword ptr [ebp-8] + E0003569: 83 C7 64 add edi,64h + E000356C: F3 AB rep stos dword ptr es:[edi] + E000356E: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003571: 83 C1 64 add ecx,64h + E0003574: 51 push ecx + E0003575: 6A 01 push 1 + E0003577: 6A 00 push 0 + E0003579: 8B 55 08 mov edx,dword ptr [ebp+8] + E000357C: 8B 02 mov eax,dword ptr [edx] + E000357E: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003581: 51 push ecx + E0003582: FF 50 10 call dword ptr [eax+10h] + E0003585: 83 C4 10 add esp,10h + E0003588: 8B 75 0C mov esi,dword ptr [ebp+0Ch] + E000358B: 8B 7D F8 mov edi,dword ptr [ebp-8] + E000358E: 83 C7 08 add edi,8 + E0003591: B9 11 00 00 00 mov ecx,11h + E0003596: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E0003598: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000359B: C7 42 60 FF FF FF mov dword ptr [edx+60h],0FFFFFFFFh + FF + E00035A2: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00035A5: C6 80 64 02 00 00 mov byte ptr [eax+00000264h],0 + 00 + E00035AC: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00035AF: 33 D2 xor edx,edx + E00035B1: 66 8B 51 6F mov dx,word ptr [ecx+6Fh] + E00035B5: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00035B8: 33 C9 xor ecx,ecx + E00035BA: 8A 48 71 mov cl,byte ptr [eax+71h] + E00035BD: 0F AF D1 imul edx,ecx + E00035C0: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00035C3: 89 50 54 mov dword ptr [eax+54h],edx + E00035C6: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00035C9: C7 41 58 FF FF FF mov dword ptr [ecx+58h],0FFFFFFFFh + FF + E00035D0: 8B 55 F8 mov edx,dword ptr [ebp-8] + E00035D3: 8B 42 54 mov eax,dword ptr [edx+54h] + E00035D6: 50 push eax + E00035D7: E8 64 69 00 00 call E0009F40 + E00035DC: 83 C4 04 add esp,4 + E00035DF: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00035E2: 89 41 50 mov dword ptr [ecx+50h],eax + E00035E5: 8B 55 F8 mov edx,dword ptr [ebp-8] + E00035E8: C7 82 68 02 00 00 mov dword ptr [edx+00000268h],0 + 00 00 00 00 + E00035F2: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00035F5: 5F pop edi + E00035F6: 5E pop esi + E00035F7: 8B E5 mov esp,ebp + E00035F9: 5D pop ebp + E00035FA: C2 08 00 ret 8 +??1CFatFile@@UAE@XZ (public: virtual __thiscall CFatFile::~CFatFile(void)): + E00035FD: 55 push ebp + E00035FE: 8B EC mov ebp,esp + E0003600: 51 push ecx + E0003601: 89 4D FC mov dword ptr [ebp-4],ecx + E0003604: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003607: C7 00 60 A2 00 E0 mov dword ptr [eax],0E000A260h + E000360D: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0003610: C7 41 04 38 A2 00 mov dword ptr [ecx+4],0E000A238h + E0 + E0003617: 68 D0 B4 00 E0 push 0E000B4D0h + E000361C: E8 3D 00 00 00 call E000365E + E0003621: 83 C4 04 add esp,4 + E0003624: 8B 55 FC mov edx,dword ptr [ebp-4] + E0003627: 83 7A 50 00 cmp dword ptr [edx+50h],0 + E000362B: 74 0F je E000363C + E000362D: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003630: 8B 48 50 mov ecx,dword ptr [eax+50h] + E0003633: 51 push ecx + E0003634: E8 0D 69 00 00 call E0009F46 + E0003639: 83 C4 04 add esp,4 + E000363C: 8B 55 FC mov edx,dword ptr [ebp-4] + E000363F: 83 7A 5C 00 cmp dword ptr [edx+5Ch],0 + E0003643: 74 15 je E000365A + E0003645: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003648: 8B 48 5C mov ecx,dword ptr [eax+5Ch] + E000364B: 8B 55 FC mov edx,dword ptr [ebp-4] + E000364E: 8B 42 5C mov eax,dword ptr [edx+5Ch] + E0003651: 8B 10 mov edx,dword ptr [eax] + E0003653: 51 push ecx + E0003654: FF 52 08 call dword ptr [edx+8] + E0003657: 83 C4 04 add esp,4 + E000365A: 8B E5 mov esp,ebp + E000365C: 5D pop ebp + E000365D: C3 ret +?TRACE@@YAHZZ (int __cdecl TRACE(...)): + E000365E: 55 push ebp + E000365F: 8B EC mov ebp,esp + E0003661: 33 C0 xor eax,eax + E0003663: 5D pop ebp + E0003664: C3 ret +?QueryInterface@CFatFile@@UAAKABU_GUID@@PAPAX@Z (public: virtual unsigned long __cdecl CFatFile::QueryInterface(struct _GUID const &,void * *)): + E0003665: 55 push ebp + E0003666: 8B EC mov ebp,esp + E0003668: 51 push ecx + E0003669: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000366C: 8B 08 mov ecx,dword ptr [eax] + E000366E: 3B 0D D8 A0 00 E0 cmp ecx,dword ptr ds:[E000A0D8h] + E0003674: 75 2A jne E00036A0 + E0003676: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0003679: 8B 42 04 mov eax,dword ptr [edx+4] + E000367C: 3B 05 DC A0 00 E0 cmp eax,dword ptr ds:[E000A0DCh] + E0003682: 75 1C jne E00036A0 + E0003684: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003687: 8B 51 08 mov edx,dword ptr [ecx+8] + E000368A: 3B 15 E0 A0 00 E0 cmp edx,dword ptr ds:[E000A0E0h] + E0003690: 75 0E jne E00036A0 + E0003692: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0003695: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E0003698: 3B 0D E4 A0 00 E0 cmp ecx,dword ptr ds:[E000A0E4h] + E000369E: 74 37 je E00036D7 + E00036A0: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00036A3: 8B 02 mov eax,dword ptr [edx] + E00036A5: 3B 05 18 A1 00 E0 cmp eax,dword ptr ds:[E000A118h] + E00036AB: 75 5D jne E000370A + E00036AD: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00036B0: 8B 51 04 mov edx,dword ptr [ecx+4] + E00036B3: 3B 15 1C A1 00 E0 cmp edx,dword ptr ds:[E000A11Ch] + E00036B9: 75 4F jne E000370A + E00036BB: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00036BE: 8B 48 08 mov ecx,dword ptr [eax+8] + E00036C1: 3B 0D 20 A1 00 E0 cmp ecx,dword ptr ds:[E000A120h] + E00036C7: 75 41 jne E000370A + E00036C9: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00036CC: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E00036CF: 3B 05 24 A1 00 E0 cmp eax,dword ptr ds:[E000A124h] + E00036D5: 75 33 jne E000370A + E00036D7: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00036DA: 8B 11 mov edx,dword ptr [ecx] + E00036DC: 8B 45 08 mov eax,dword ptr [ebp+8] + E00036DF: 50 push eax + E00036E0: FF 52 04 call dword ptr [edx+4] + E00036E3: 83 C4 04 add esp,4 + E00036E6: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E00036EA: 74 0B je E00036F7 + E00036EC: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00036EF: 83 C1 04 add ecx,4 + E00036F2: 89 4D FC mov dword ptr [ebp-4],ecx + E00036F5: EB 07 jmp E00036FE + E00036F7: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E00036FE: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0003701: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003704: 89 02 mov dword ptr [edx],eax + E0003706: 33 C0 xor eax,eax + E0003708: EB 05 jmp E000370F + E000370A: B8 00 00 00 80 mov eax,80000000h + E000370F: 8B E5 mov esp,ebp + E0003711: 5D pop ebp + E0003712: C3 ret +?Read@CFatFile@@UAAIPAXI@Z (public: virtual unsigned int __cdecl CFatFile::Read(void *,unsigned int)): + E0003713: 55 push ebp + E0003714: 8B EC mov ebp,esp + E0003716: 83 EC 0C sub esp,0Ch + E0003719: 56 push esi + E000371A: 57 push edi + E000371B: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0003722: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003725: 83 78 5C FF cmp dword ptr [eax+5Ch],0FFh + E0003729: 75 21 jne E000374C + E000372B: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000372E: 83 79 48 00 cmp dword ptr [ecx+48h],0 + E0003732: 75 11 jne E0003745 + E0003734: 8B 55 08 mov edx,dword ptr [ebp+8] + E0003737: 33 C0 xor eax,eax + E0003739: 66 8B 42 42 mov ax,word ptr [edx+42h] + E000373D: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003740: 89 41 5C mov dword ptr [ecx+5Ch],eax + E0003743: EB 07 jmp E000374C + E0003745: 33 C0 xor eax,eax + E0003747: E9 6C 01 00 00 jmp E00038B8 + E000374C: 8B 55 08 mov edx,dword ptr [ebp+8] + E000374F: 8B 42 48 mov eax,dword ptr [edx+48h] + E0003752: 03 45 10 add eax,dword ptr [ebp+10h] + E0003755: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003758: 3B 41 1C cmp eax,dword ptr [ecx+1Ch] + E000375B: 76 0F jbe E000376C + E000375D: 8B 55 08 mov edx,dword ptr [ebp+8] + E0003760: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003763: 8B 4A 1C mov ecx,dword ptr [edx+1Ch] + E0003766: 2B 48 48 sub ecx,dword ptr [eax+48h] + E0003769: 89 4D 10 mov dword ptr [ebp+10h],ecx + E000376C: 8B 55 FC mov edx,dword ptr [ebp-4] + E000376F: 3B 55 10 cmp edx,dword ptr [ebp+10h] + E0003772: 0F 83 2E 01 00 00 jae E00038A6 + E0003778: 8B 45 08 mov eax,dword ptr [ebp+8] + E000377B: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000377E: 8B 50 54 mov edx,dword ptr [eax+54h] + E0003781: 3B 51 50 cmp edx,dword ptr [ecx+50h] + E0003784: 0F 82 A6 00 00 00 jb E0003830 + E000378A: 8B 45 08 mov eax,dword ptr [ebp+8] + E000378D: 81 78 5C F8 FF 00 cmp dword ptr [eax+5Ch],0FFF8h + 00 + E0003794: 72 21 jb E00037B7 + E0003796: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003799: 8B 51 48 mov edx,dword ptr [ecx+48h] + E000379C: 03 55 FC add edx,dword ptr [ebp-4] + E000379F: 8B 45 08 mov eax,dword ptr [ebp+8] + E00037A2: 89 50 48 mov dword ptr [eax+48h],edx + E00037A5: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00037A8: C7 41 54 FF FF FF mov dword ptr [ecx+54h],0FFFFFFFFh + FF + E00037AF: 8B 45 FC mov eax,dword ptr [ebp-4] + E00037B2: E9 01 01 00 00 jmp E00038B8 + E00037B7: 8B 55 08 mov edx,dword ptr [ebp+8] + E00037BA: 8B 42 50 mov eax,dword ptr [edx+50h] + E00037BD: 50 push eax + E00037BE: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00037C1: 8B 51 4C mov edx,dword ptr [ecx+4Ch] + E00037C4: 52 push edx + E00037C5: 8B 45 08 mov eax,dword ptr [ebp+8] + E00037C8: 8B 48 5C mov ecx,dword ptr [eax+5Ch] + E00037CB: 51 push ecx + E00037CC: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00037CF: 83 E9 04 sub ecx,4 + E00037D2: E8 D5 01 00 00 call E00039AC + E00037D7: 25 FF 00 00 00 and eax,0FFh + E00037DC: 85 C0 test eax,eax + E00037DE: 75 2E jne E000380E + E00037E0: 68 FC B4 00 E0 push 0E000B4FCh + E00037E5: E8 74 FE FF FF call E000365E + E00037EA: 83 C4 04 add esp,4 + E00037ED: 8B 55 08 mov edx,dword ptr [ebp+8] + E00037F0: 8B 42 48 mov eax,dword ptr [edx+48h] + E00037F3: 03 45 FC add eax,dword ptr [ebp-4] + E00037F6: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00037F9: 89 41 48 mov dword ptr [ecx+48h],eax + E00037FC: 8B 55 08 mov edx,dword ptr [ebp+8] + E00037FF: C7 42 54 FF FF FF mov dword ptr [edx+54h],0FFFFFFFFh + FF + E0003806: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003809: E9 AA 00 00 00 jmp E00038B8 + E000380E: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003811: C7 40 54 00 00 00 mov dword ptr [eax+54h],0 + 00 + E0003818: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000381B: 8B 51 5C mov edx,dword ptr [ecx+5Ch] + E000381E: 52 push edx + E000381F: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003822: 83 E9 04 sub ecx,4 + E0003825: E8 DE 00 00 00 call E0003908 + E000382A: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000382D: 89 41 5C mov dword ptr [ecx+5Ch],eax + E0003830: 8B 55 08 mov edx,dword ptr [ebp+8] + E0003833: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003836: 8B 4A 50 mov ecx,dword ptr [edx+50h] + E0003839: 2B 48 54 sub ecx,dword ptr [eax+54h] + E000383C: 8B 55 10 mov edx,dword ptr [ebp+10h] + E000383F: 2B 55 FC sub edx,dword ptr [ebp-4] + E0003842: 3B CA cmp ecx,edx + E0003844: 73 11 jae E0003857 + E0003846: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003849: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000384C: 8B 50 50 mov edx,dword ptr [eax+50h] + E000384F: 2B 51 54 sub edx,dword ptr [ecx+54h] + E0003852: 89 55 F4 mov dword ptr [ebp-0Ch],edx + E0003855: EB 09 jmp E0003860 + E0003857: 8B 45 10 mov eax,dword ptr [ebp+10h] + E000385A: 2B 45 FC sub eax,dword ptr [ebp-4] + E000385D: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0003860: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0003863: 89 4D F8 mov dword ptr [ebp-8],ecx + E0003866: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003869: 8B 55 08 mov edx,dword ptr [ebp+8] + E000386C: 8B 72 4C mov esi,dword ptr [edx+4Ch] + E000386F: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003872: 03 70 54 add esi,dword ptr [eax+54h] + E0003875: 8B 7D 0C mov edi,dword ptr [ebp+0Ch] + E0003878: 03 7D FC add edi,dword ptr [ebp-4] + E000387B: 8B D1 mov edx,ecx + E000387D: C1 E9 02 shr ecx,2 + E0003880: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E0003882: 8B CA mov ecx,edx + E0003884: 83 E1 03 and ecx,3 + E0003887: F3 A4 rep movs byte ptr es:[edi],byte ptr [esi] + E0003889: 8B 45 08 mov eax,dword ptr [ebp+8] + E000388C: 8B 48 54 mov ecx,dword ptr [eax+54h] + E000388F: 03 4D F8 add ecx,dword ptr [ebp-8] + E0003892: 8B 55 08 mov edx,dword ptr [ebp+8] + E0003895: 89 4A 54 mov dword ptr [edx+54h],ecx + E0003898: 8B 45 FC mov eax,dword ptr [ebp-4] + E000389B: 03 45 F8 add eax,dword ptr [ebp-8] + E000389E: 89 45 FC mov dword ptr [ebp-4],eax + E00038A1: E9 C6 FE FF FF jmp E000376C + E00038A6: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00038A9: 8B 51 48 mov edx,dword ptr [ecx+48h] + E00038AC: 03 55 10 add edx,dword ptr [ebp+10h] + E00038AF: 8B 45 08 mov eax,dword ptr [ebp+8] + E00038B2: 89 50 48 mov dword ptr [eax+48h],edx + E00038B5: 8B 45 FC mov eax,dword ptr [ebp-4] + E00038B8: 5F pop edi + E00038B9: 5E pop esi + E00038BA: 8B E5 mov esp,ebp + E00038BC: 5D pop ebp + E00038BD: C3 ret +?Write@CFatFile@@UAAIPBXI@Z (public: virtual unsigned int __cdecl CFatFile::Write(void const *,unsigned int)): + E00038BE: 55 push ebp + E00038BF: 8B EC mov ebp,esp + E00038C1: 33 C0 xor eax,eax + E00038C3: 5D pop ebp + E00038C4: C3 ret +?SetIoMode@CFatFile@@UAAKI@Z (public: virtual unsigned long __cdecl CFatFile::SetIoMode(unsigned int)): + E00038C5: 55 push ebp + E00038C6: 8B EC mov ebp,esp + E00038C8: 33 C0 xor eax,eax + E00038CA: 5D pop ebp + E00038CB: C3 ret +?IsReady@CFatFile@@UAAKXZ (public: virtual unsigned long __cdecl CFatFile::IsReady(void)): + E00038CC: 55 push ebp + E00038CD: 8B EC mov ebp,esp + E00038CF: 33 C0 xor eax,eax + E00038D1: 5D pop ebp + E00038D2: C3 ret +?Stat@CFatFile@@UAAKPAU_folderitem_t@@@Z (public: virtual unsigned long __cdecl CFatFile::Stat(struct _folderitem_t *)): + E00038D3: 55 push ebp + E00038D4: 8B EC mov ebp,esp + E00038D6: 56 push esi + E00038D7: 57 push edi + E00038D8: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00038DB: 83 38 44 cmp dword ptr [eax],44h + E00038DE: 75 12 jne E00038F2 + E00038E0: 8B 75 08 mov esi,dword ptr [ebp+8] + E00038E3: 83 C6 04 add esi,4 + E00038E6: B9 11 00 00 00 mov ecx,11h + E00038EB: 8B 7D 0C mov edi,dword ptr [ebp+0Ch] + E00038EE: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E00038F0: EB 10 jmp E0003902 + E00038F2: 8B 75 08 mov esi,dword ptr [ebp+8] + E00038F5: 83 C6 04 add esi,4 + E00038F8: B9 07 00 00 00 mov ecx,7 + E00038FD: 8B 7D 0C mov edi,dword ptr [ebp+0Ch] + E0003900: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E0003902: 33 C0 xor eax,eax + E0003904: 5F pop edi + E0003905: 5E pop esi + E0003906: 5D pop ebp + E0003907: C3 ret +?GetNextCluster@CFatFile@@IAEII@Z (protected: unsigned int __thiscall CFatFile::GetNextCluster(unsigned int)): + E0003908: 55 push ebp + E0003909: 8B EC mov ebp,esp + E000390B: 81 EC 10 02 00 00 sub esp,210h + E0003911: 56 push esi + E0003912: 89 8D F0 FD FF FF mov dword ptr [ebp+FFFFFDF0h],ecx + E0003918: 8B 45 08 mov eax,dword ptr [ebp+8] + E000391B: D1 E0 shl eax,1 + E000391D: 89 45 FC mov dword ptr [ebp-4],eax + E0003920: 8B 8D F0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDF0h] + E0003926: 33 D2 xor edx,edx + E0003928: 66 8B 51 72 mov dx,word ptr [ecx+72h] + E000392C: 8B CA mov ecx,edx + E000392E: 8B 95 F0 FD FF FF mov edx,dword ptr [ebp+FFFFFDF0h] + E0003934: 33 C0 xor eax,eax + E0003936: 66 8B 42 6F mov ax,word ptr [edx+6Fh] + E000393A: 8B F0 mov esi,eax + E000393C: 8B 45 FC mov eax,dword ptr [ebp-4] + E000393F: 33 D2 xor edx,edx + E0003941: F7 F6 div eax,esi + E0003943: 03 C8 add ecx,eax + E0003945: 89 8D F4 FD FF FF mov dword ptr [ebp+FFFFFDF4h],ecx + E000394B: 8B 8D F0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDF0h] + E0003951: 33 D2 xor edx,edx + E0003953: 66 8B 51 6F mov dx,word ptr [ecx+6Fh] + E0003957: 8B CA mov ecx,edx + E0003959: 8B 45 FC mov eax,dword ptr [ebp-4] + E000395C: 33 D2 xor edx,edx + E000395E: F7 F1 div eax,ecx + E0003960: 89 55 F8 mov dword ptr [ebp-8],edx + E0003963: 8D 95 F8 FD FF FF lea edx,dword ptr [ebp+FFFFFDF8h] + E0003969: 52 push edx + E000396A: 6A 01 push 1 + E000396C: 8B 85 F4 FD FF FF mov eax,dword ptr [ebp+FFFFFDF4h] + E0003972: 50 push eax + E0003973: 8B 8D F0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDF0h] + E0003979: 8B 51 5C mov edx,dword ptr [ecx+5Ch] + E000397C: 8B 85 F0 FD FF FF mov eax,dword ptr [ebp+FFFFFDF0h] + E0003982: 8B 48 5C mov ecx,dword ptr [eax+5Ch] + E0003985: 8B 01 mov eax,dword ptr [ecx] + E0003987: 52 push edx + E0003988: FF 50 10 call dword ptr [eax+10h] + E000398B: 83 C4 10 add esp,10h + E000398E: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003991: 33 C0 xor eax,eax + E0003993: 66 8B 84 0D F8 FD mov ax,word ptr [ebp+ecx+FFFFFDF8h] + FF FF + E000399B: 5E pop esi + E000399C: 8B E5 mov esp,ebp + E000399E: 5D pop ebp + E000399F: C2 04 00 ret 4 +?Seek@CFatFile@@UAAKJH@Z (public: virtual unsigned long __cdecl CFatFile::Seek(long,int)): + E00039A2: 55 push ebp + E00039A3: 8B EC mov ebp,esp + E00039A5: B8 00 00 00 80 mov eax,80000000h + E00039AA: 5D pop ebp + E00039AB: C3 ret +?ReadCluster@CFatFile@@IAE_NIPAXI@Z (protected: bool __thiscall CFatFile::ReadCluster(unsigned int,void *,unsigned int)): + E00039AC: 55 push ebp + E00039AD: 8B EC mov ebp,esp + E00039AF: 83 EC 10 sub esp,10h + E00039B2: 56 push esi + E00039B3: 89 4D F0 mov dword ptr [ebp-10h],ecx + E00039B6: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E00039B9: 33 C9 xor ecx,ecx + E00039BB: 8A 88 64 02 00 00 mov cl,byte ptr [eax+00000264h] + E00039C1: 85 C9 test ecx,ecx + E00039C3: 74 09 je E00039CE + E00039C5: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E00039CC: EB 2A jmp E00039F8 + E00039CE: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E00039D1: 33 C0 xor eax,eax + E00039D3: 66 8B 42 75 mov ax,word ptr [edx+75h] + E00039D7: C1 E0 05 shl eax,5 + E00039DA: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E00039DD: 33 D2 xor edx,edx + E00039DF: 66 8B 51 6F mov dx,word ptr [ecx+6Fh] + E00039E3: 8D 44 10 FF lea eax,dword ptr [eax+edx-1] + E00039E7: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E00039EA: 33 D2 xor edx,edx + E00039EC: 66 8B 51 6F mov dx,word ptr [ecx+6Fh] + E00039F0: 8B CA mov ecx,edx + E00039F2: 99 cwd + E00039F3: F7 F9 idiv eax,ecx + E00039F5: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E00039F8: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E00039FB: 33 C0 xor eax,eax + E00039FD: 66 8B 42 72 mov ax,word ptr [edx+72h] + E0003A01: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0003A04: 33 D2 xor edx,edx + E0003A06: 8A 51 74 mov dl,byte ptr [ecx+74h] + E0003A09: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0003A0C: 33 F6 xor esi,esi + E0003A0E: 66 8B 71 7A mov si,word ptr [ecx+7Ah] + E0003A12: 0F AF D6 imul edx,esi + E0003A15: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0003A18: 03 C8 add ecx,eax + E0003A1A: 03 D1 add edx,ecx + E0003A1C: 89 55 FC mov dword ptr [ebp-4],edx + E0003A1F: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0003A22: 33 C0 xor eax,eax + E0003A24: 8A 82 64 02 00 00 mov al,byte ptr [edx+00000264h] + E0003A2A: 85 C0 test eax,eax + E0003A2C: 74 09 je E0003A37 + E0003A2E: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003A31: 83 C1 02 add ecx,2 + E0003A34: 89 4D 08 mov dword ptr [ebp+8],ecx + E0003A37: 8B 55 08 mov edx,dword ptr [ebp+8] + E0003A3A: 83 EA 02 sub edx,2 + E0003A3D: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E0003A40: 33 C9 xor ecx,ecx + E0003A42: 8A 48 71 mov cl,byte ptr [eax+71h] + E0003A45: 0F AF D1 imul edx,ecx + E0003A48: 03 55 FC add edx,dword ptr [ebp-4] + E0003A4B: 89 55 F8 mov dword ptr [ebp-8],edx + E0003A4E: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0003A51: C1 EA 09 shr edx,9 + E0003A54: 89 55 10 mov dword ptr [ebp+10h],edx + E0003A57: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0003A5A: 50 push eax + E0003A5B: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E0003A5E: 51 push ecx + E0003A5F: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0003A62: 52 push edx + E0003A63: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E0003A66: 8B 48 5C mov ecx,dword ptr [eax+5Ch] + E0003A69: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0003A6C: 8B 42 5C mov eax,dword ptr [edx+5Ch] + E0003A6F: 8B 10 mov edx,dword ptr [eax] + E0003A71: 51 push ecx + E0003A72: FF 52 10 call dword ptr [edx+10h] + E0003A75: 83 C4 10 add esp,10h + E0003A78: 33 C9 xor ecx,ecx + E0003A7A: 3B 45 10 cmp eax,dword ptr [ebp+10h] + E0003A7D: 0F 94 C1 sete cl + E0003A80: 8A C1 mov al,cl + E0003A82: 5E pop esi + E0003A83: 8B E5 mov esp,ebp + E0003A85: 5D pop ebp + E0003A86: C2 0C 00 ret 0Ch +??0CFatFolder@@QAE@PAUIBlockDevice@@PBUfolderitem_fat_t@@_N@Z (public: __thiscall CFatFolder::CFatFolder(struct IBlockDevice *,struct folderitem_fat_t const *,bool)): + E0003A89: 55 push ebp + E0003A8A: 8B EC mov ebp,esp + E0003A8C: 83 EC 08 sub esp,8 + E0003A8F: 89 4D F8 mov dword ptr [ebp-8],ecx + E0003A92: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0003A95: C7 00 C8 A0 00 E0 mov dword ptr [eax],0E000A0C8h + E0003A9B: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003A9E: 83 C1 04 add ecx,4 + E0003AA1: 89 4D FC mov dword ptr [ebp-4],ecx + E0003AA4: 8B 55 FC mov edx,dword ptr [ebp-4] + E0003AA7: C7 02 A0 A2 00 E0 mov dword ptr [edx],0E000A2A0h + E0003AAD: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0003AB0: 50 push eax + E0003AB1: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003AB4: 51 push ecx + E0003AB5: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003AB8: 83 C1 0C add ecx,0Ch + E0003ABB: E8 4E FA FF FF call E000350E + E0003AC0: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0003AC3: C7 02 90 A2 00 E0 mov dword ptr [edx],0E000A290h + E0003AC9: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0003ACC: C7 40 04 70 A2 00 mov dword ptr [eax+4],0E000A270h + E0 + E0003AD3: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003AD6: C7 41 08 00 00 00 mov dword ptr [ecx+8],0 + 00 + E0003ADD: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0003AE0: 8A 45 10 mov al,byte ptr [ebp+10h] + E0003AE3: 88 82 70 02 00 00 mov byte ptr [edx+00000270h],al + E0003AE9: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003AEC: C7 81 78 02 00 00 mov dword ptr [ecx+00000278h],0 + 00 00 00 00 + E0003AF6: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0003AF9: 81 E2 FF 00 00 00 and edx,0FFh + E0003AFF: 85 D2 test edx,edx + E0003B01: 74 15 je E0003B18 + E0003B03: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0003B06: 33 C9 xor ecx,ecx + E0003B08: 66 8B 88 81 00 00 mov cx,word ptr [eax+00000081h] + 00 + E0003B0F: C1 E1 05 shl ecx,5 + E0003B12: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0003B15: 89 4A 2C mov dword ptr [edx+2Ch],ecx + E0003B18: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0003B1B: 8B E5 mov esp,ebp + E0003B1D: 5D pop ebp + E0003B1E: C2 0C 00 ret 0Ch +??1CFatFolder@@UAE@XZ (public: virtual __thiscall CFatFolder::~CFatFolder(void)): + E0003B21: 55 push ebp + E0003B22: 8B EC mov ebp,esp + E0003B24: 83 EC 10 sub esp,10h + E0003B27: 89 4D F0 mov dword ptr [ebp-10h],ecx + E0003B2A: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E0003B2D: C7 00 90 A2 00 E0 mov dword ptr [eax],0E000A290h + E0003B33: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0003B36: C7 41 04 70 A2 00 mov dword ptr [ecx+4],0E000A270h + E0 + E0003B3D: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0003B40: 8B 82 78 02 00 00 mov eax,dword ptr [edx+00000278h] + E0003B46: 89 45 FC mov dword ptr [ebp-4],eax + E0003B49: EB 06 jmp E0003B51 + E0003B4B: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0003B4E: 89 4D FC mov dword ptr [ebp-4],ecx + E0003B51: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0003B55: 74 54 je E0003BAB + E0003B57: 8B 55 FC mov edx,dword ptr [ebp-4] + E0003B5A: 8B 42 1C mov eax,dword ptr [edx+1Ch] + E0003B5D: 89 45 F8 mov dword ptr [ebp-8],eax + E0003B60: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0003B63: 83 79 20 00 cmp dword ptr [ecx+20h],0 + E0003B67: 74 15 je E0003B7E + E0003B69: 8B 55 FC mov edx,dword ptr [ebp-4] + E0003B6C: 8B 42 20 mov eax,dword ptr [edx+20h] + E0003B6F: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0003B72: 8B 51 20 mov edx,dword ptr [ecx+20h] + E0003B75: 8B 0A mov ecx,dword ptr [edx] + E0003B77: 50 push eax + E0003B78: FF 51 08 call dword ptr [ecx+8] + E0003B7B: 83 C4 04 add esp,4 + E0003B7E: 8B 55 FC mov edx,dword ptr [ebp-4] + E0003B81: C7 42 20 00 00 00 mov dword ptr [edx+20h],0 + 00 + E0003B88: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003B8B: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E0003B8E: 51 push ecx + E0003B8F: E8 B2 63 00 00 call E0009F46 + E0003B94: 83 C4 04 add esp,4 + E0003B97: 8B 55 FC mov edx,dword ptr [ebp-4] + E0003B9A: 89 55 F4 mov dword ptr [ebp-0Ch],edx + E0003B9D: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0003BA0: 50 push eax + E0003BA1: E8 C4 63 00 00 call E0009F6A + E0003BA6: 83 C4 04 add esp,4 + E0003BA9: EB A0 jmp E0003B4B + E0003BAB: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0003BAE: 83 C1 0C add ecx,0Ch + E0003BB1: E8 47 FA FF FF call E00035FD + E0003BB6: 8B E5 mov esp,ebp + E0003BB8: 5D pop ebp + E0003BB9: C3 ret +?QueryInterface@CFatFolder@@UAAKABU_GUID@@PAPAX@Z (public: virtual unsigned long __cdecl CFatFolder::QueryInterface(struct _GUID const &,void * *)): + E0003BBA: 55 push ebp + E0003BBB: 8B EC mov ebp,esp + E0003BBD: 83 EC 08 sub esp,8 + E0003BC0: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0003BC3: 8B 08 mov ecx,dword ptr [eax] + E0003BC5: 3B 0D D8 A0 00 E0 cmp ecx,dword ptr ds:[E000A0D8h] + E0003BCB: 75 2A jne E0003BF7 + E0003BCD: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0003BD0: 8B 42 04 mov eax,dword ptr [edx+4] + E0003BD3: 3B 05 DC A0 00 E0 cmp eax,dword ptr ds:[E000A0DCh] + E0003BD9: 75 1C jne E0003BF7 + E0003BDB: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003BDE: 8B 51 08 mov edx,dword ptr [ecx+8] + E0003BE1: 3B 15 E0 A0 00 E0 cmp edx,dword ptr ds:[E000A0E0h] + E0003BE7: 75 0E jne E0003BF7 + E0003BE9: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0003BEC: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E0003BEF: 3B 0D E4 A0 00 E0 cmp ecx,dword ptr ds:[E000A0E4h] + E0003BF5: 74 37 je E0003C2E + E0003BF7: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0003BFA: 8B 02 mov eax,dword ptr [edx] + E0003BFC: 3B 05 38 A1 00 E0 cmp eax,dword ptr ds:[E000A138h] + E0003C02: 75 5D jne E0003C61 + E0003C04: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003C07: 8B 51 04 mov edx,dword ptr [ecx+4] + E0003C0A: 3B 15 3C A1 00 E0 cmp edx,dword ptr ds:[E000A13Ch] + E0003C10: 75 4F jne E0003C61 + E0003C12: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0003C15: 8B 48 08 mov ecx,dword ptr [eax+8] + E0003C18: 3B 0D 40 A1 00 E0 cmp ecx,dword ptr ds:[E000A140h] + E0003C1E: 75 41 jne E0003C61 + E0003C20: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0003C23: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0003C26: 3B 05 44 A1 00 E0 cmp eax,dword ptr ds:[E000A144h] + E0003C2C: 75 33 jne E0003C61 + E0003C2E: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003C31: 8B 11 mov edx,dword ptr [ecx] + E0003C33: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003C36: 50 push eax + E0003C37: FF 52 04 call dword ptr [edx+4] + E0003C3A: 83 C4 04 add esp,4 + E0003C3D: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E0003C41: 74 0B je E0003C4E + E0003C43: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003C46: 83 C1 04 add ecx,4 + E0003C49: 89 4D FC mov dword ptr [ebp-4],ecx + E0003C4C: EB 07 jmp E0003C55 + E0003C4E: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0003C55: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0003C58: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003C5B: 89 02 mov dword ptr [edx],eax + E0003C5D: 33 C0 xor eax,eax + E0003C5F: EB 73 jmp E0003CD4 + E0003C61: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003C64: 8B 11 mov edx,dword ptr [ecx] + E0003C66: 3B 15 18 A1 00 E0 cmp edx,dword ptr ds:[E000A118h] + E0003C6C: 75 61 jne E0003CCF + E0003C6E: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0003C71: 8B 48 04 mov ecx,dword ptr [eax+4] + E0003C74: 3B 0D 1C A1 00 E0 cmp ecx,dword ptr ds:[E000A11Ch] + E0003C7A: 75 53 jne E0003CCF + E0003C7C: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0003C7F: 8B 42 08 mov eax,dword ptr [edx+8] + E0003C82: 3B 05 20 A1 00 E0 cmp eax,dword ptr ds:[E000A120h] + E0003C88: 75 45 jne E0003CCF + E0003C8A: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003C8D: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0003C90: 3B 15 24 A1 00 E0 cmp edx,dword ptr ds:[E000A124h] + E0003C96: 75 37 jne E0003CCF + E0003C98: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003C9B: 8B 08 mov ecx,dword ptr [eax] + E0003C9D: 8B 55 08 mov edx,dword ptr [ebp+8] + E0003CA0: 52 push edx + E0003CA1: FF 51 04 call dword ptr [ecx+4] + E0003CA4: 83 C4 04 add esp,4 + E0003CA7: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003CAA: 83 C0 0C add eax,0Ch + E0003CAD: 85 C0 test eax,eax + E0003CAF: 74 0B je E0003CBC + E0003CB1: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003CB4: 83 C1 10 add ecx,10h + E0003CB7: 89 4D F8 mov dword ptr [ebp-8],ecx + E0003CBA: EB 07 jmp E0003CC3 + E0003CBC: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E0003CC3: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0003CC6: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0003CC9: 89 02 mov dword ptr [edx],eax + E0003CCB: 33 C0 xor eax,eax + E0003CCD: EB 05 jmp E0003CD4 + E0003CCF: B8 00 00 00 80 mov eax,80000000h + E0003CD4: 8B E5 mov esp,ebp + E0003CD6: 5D pop ebp + E0003CD7: C3 ret +?FindFirst@CFatFolder@@UAAKPBGPAU_folderitem_t@@@Z (public: virtual unsigned long __cdecl CFatFolder::FindFirst(unsigned short const *,struct _folderitem_t *)): + E0003CD8: 55 push ebp + E0003CD9: 8B EC mov ebp,esp + E0003CDB: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003CDE: 83 B8 74 02 00 00 cmp dword ptr [eax+00000274h],0 + 00 + E0003CE5: 75 0B jne E0003CF2 + E0003CE7: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003CEA: 83 E9 04 sub ecx,4 + E0003CED: E8 B5 03 00 00 call E00040A7 + E0003CF2: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003CF5: 51 push ecx + E0003CF6: E8 A5 62 00 00 call E0009FA0 + E0003CFB: 83 C4 04 add esp,4 + E0003CFE: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0003D01: 89 42 08 mov dword ptr [edx+8],eax + E0003D04: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0003D07: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003D0A: 8B 91 74 02 00 00 mov edx,dword ptr [ecx+00000274h] + E0003D10: 89 50 04 mov dword ptr [eax+4],edx + E0003D13: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0003D16: 8B 48 08 mov ecx,dword ptr [eax+8] + E0003D19: 51 push ecx + E0003D1A: 68 24 B5 00 E0 push 0E000B524h + E0003D1F: E8 3A F9 FF FF call E000365E + E0003D24: 83 C4 08 add esp,8 + E0003D27: 33 C0 xor eax,eax + E0003D29: 5D pop ebp + E0003D2A: C3 ret +?FindNext@CFatFolder@@UAAKPAU_folderitem_t@@@Z (public: virtual unsigned long __cdecl CFatFolder::FindNext(struct _folderitem_t *)): + E0003D2B: 55 push ebp + E0003D2C: 8B EC mov ebp,esp + E0003D2E: 51 push ecx + E0003D2F: 56 push esi + E0003D30: 57 push edi + E0003D31: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0003D34: 8B 48 04 mov ecx,dword ptr [eax+4] + E0003D37: 89 4D FC mov dword ptr [ebp-4],ecx + E0003D3A: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0003D3E: 75 0A jne E0003D4A + E0003D40: B8 00 00 00 80 mov eax,80000000h + E0003D45: E9 DC 00 00 00 jmp E0003E26 + E0003D4A: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0003D4E: 0F 84 CD 00 00 00 je E0003E21 + E0003D54: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0003D57: 8B 42 08 mov eax,dword ptr [edx+8] + E0003D5A: 50 push eax + E0003D5B: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0003D5E: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0003D61: 52 push edx + E0003D62: E8 F9 60 00 00 call E0009E60 + E0003D67: 83 C4 08 add esp,8 + E0003D6A: 25 FF 00 00 00 and eax,0FFh + E0003D6F: 85 C0 test eax,eax + E0003D71: 0F 84 93 00 00 00 je E0003E0A + E0003D77: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0003D7A: 8B 48 08 mov ecx,dword ptr [eax+8] + E0003D7D: 51 push ecx + E0003D7E: 8B 55 FC mov edx,dword ptr [ebp-4] + E0003D81: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0003D84: 50 push eax + E0003D85: 68 40 B5 00 E0 push 0E000B540h + E0003D8A: E8 CF F8 FF FF call E000365E + E0003D8F: 83 C4 0C add esp,0Ch + E0003D92: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003D95: 8B 55 FC mov edx,dword ptr [ebp-4] + E0003D98: 8B 42 1C mov eax,dword ptr [edx+1Ch] + E0003D9B: 89 41 04 mov dword ptr [ecx+4],eax + E0003D9E: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003DA1: 8B 51 10 mov edx,dword ptr [ecx+10h] + E0003DA4: 52 push edx + E0003DA5: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003DA8: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E0003DAB: 51 push ecx + E0003DAC: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0003DAF: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0003DB2: 50 push eax + E0003DB3: E8 DC 61 00 00 call E0009F94 + E0003DB8: 83 C4 0C add esp,0Ch + E0003DBB: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003DBE: 8B 55 FC mov edx,dword ptr [ebp-4] + E0003DC1: 8B 42 14 mov eax,dword ptr [edx+14h] + E0003DC4: 89 41 14 mov dword ptr [ecx+14h],eax + E0003DC7: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003DCA: 8B 55 FC mov edx,dword ptr [ebp-4] + E0003DCD: 8B 42 18 mov eax,dword ptr [edx+18h] + E0003DD0: 89 41 18 mov dword ptr [ecx+18h],eax + E0003DD3: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003DD6: 83 39 44 cmp dword ptr [ecx],44h + E0003DD9: 75 2B jne E0003E06 + E0003DDB: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0003DDE: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003DE1: 8B 48 20 mov ecx,dword ptr [eax+20h] + E0003DE4: 89 4A 20 mov dword ptr [edx+20h],ecx + E0003DE7: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0003DEA: 8B 45 FC mov eax,dword ptr [ebp-4] + E0003DED: 8B 48 1C mov ecx,dword ptr [eax+1Ch] + E0003DF0: 89 4A 1C mov dword ptr [edx+1Ch],ecx + E0003DF3: 8B 75 FC mov esi,dword ptr [ebp-4] + E0003DF6: 83 C6 24 add esi,24h + E0003DF9: 8B 7D 0C mov edi,dword ptr [ebp+0Ch] + E0003DFC: 83 C7 24 add edi,24h + E0003DFF: B9 08 00 00 00 mov ecx,8 + E0003E04: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E0003E06: 33 C0 xor eax,eax + E0003E08: EB 1C jmp E0003E26 + E0003E0A: 8B 55 FC mov edx,dword ptr [ebp-4] + E0003E0D: 8B 42 1C mov eax,dword ptr [edx+1Ch] + E0003E10: 89 45 FC mov dword ptr [ebp-4],eax + E0003E13: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003E16: 8B 55 FC mov edx,dword ptr [ebp-4] + E0003E19: 89 51 04 mov dword ptr [ecx+4],edx + E0003E1C: E9 29 FF FF FF jmp E0003D4A + E0003E21: B8 00 00 00 80 mov eax,80000000h + E0003E26: 5F pop edi + E0003E27: 5E pop esi + E0003E28: 8B E5 mov esp,ebp + E0003E2A: 5D pop ebp + E0003E2B: C3 ret +?FindClose@CFatFolder@@UAAKPAU_folderitem_t@@@Z (public: virtual unsigned long __cdecl CFatFolder::FindClose(struct _folderitem_t *)): + E0003E2C: 55 push ebp + E0003E2D: 8B EC mov ebp,esp + E0003E2F: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0003E32: 8B 48 08 mov ecx,dword ptr [eax+8] + E0003E35: 51 push ecx + E0003E36: E8 0B 61 00 00 call E0009F46 + E0003E3B: 83 C4 04 add esp,4 + E0003E3E: 33 C0 xor eax,eax + E0003E40: 5D pop ebp + E0003E41: C3 ret +?Open@CFatFolder@@UAAKPAU_folderitem_t@@PBG@Z (public: virtual unsigned long __cdecl CFatFolder::Open(struct _folderitem_t *,unsigned short const *)): + E0003E42: 55 push ebp + E0003E43: 8B EC mov ebp,esp + E0003E45: 81 EC 58 02 00 00 sub esp,258h + E0003E4B: 56 push esi + E0003E4C: 57 push edi + E0003E4D: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0003E50: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E0003E53: 51 push ecx + E0003E54: 68 78 B5 00 E0 push 0E000B578h + E0003E59: E8 00 F8 FF FF call E000365E + E0003E5E: 83 C4 08 add esp,8 + E0003E61: C7 45 BC 44 00 00 mov dword ptr [ebp-44h],44h + 00 + E0003E68: 8D 95 BC FD FF FF lea edx,dword ptr [ebp+FFFFFDBCh] + E0003E6E: 89 55 C8 mov dword ptr [ebp-38h],edx + E0003E71: C7 45 CC 00 01 00 mov dword ptr [ebp-34h],100h + 00 + E0003E78: 8D 45 BC lea eax,dword ptr [ebp-44h] + E0003E7B: 50 push eax + E0003E7C: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0003E7F: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0003E82: 52 push edx + E0003E83: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003E86: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003E89: 8B 11 mov edx,dword ptr [ecx] + E0003E8B: 50 push eax + E0003E8C: FF 52 0C call dword ptr [edx+0Ch] + E0003E8F: 83 C4 0C add esp,0Ch + E0003E92: 25 00 00 00 80 and eax,80000000h + E0003E97: 3D 00 00 00 80 cmp eax,80000000h + E0003E9C: 74 1F je E0003EBD + E0003E9E: 8D 45 BC lea eax,dword ptr [ebp-44h] + E0003EA1: 50 push eax + E0003EA2: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0003EA5: 8B 55 08 mov edx,dword ptr [ebp+8] + E0003EA8: 8B 02 mov eax,dword ptr [edx] + E0003EAA: 51 push ecx + E0003EAB: FF 50 10 call dword ptr [eax+10h] + E0003EAE: 83 C4 08 add esp,8 + E0003EB1: 25 00 00 00 80 and eax,80000000h + E0003EB6: 3D 00 00 00 80 cmp eax,80000000h + E0003EBB: 75 0A jne E0003EC7 + E0003EBD: B8 00 00 00 80 mov eax,80000000h + E0003EC2: E9 5A 01 00 00 jmp E0004021 + E0003EC7: 83 7D DC 00 cmp dword ptr [ebp-24h],0 + E0003ECB: 74 34 je E0003F01 + E0003ECD: 8B 4D DC mov ecx,dword ptr [ebp-24h] + E0003ED0: 51 push ecx + E0003ED1: 68 98 B5 00 E0 push 0E000B598h + E0003ED6: E8 83 F7 FF FF call E000365E + E0003EDB: 83 C4 08 add esp,8 + E0003EDE: 8B 55 DC mov edx,dword ptr [ebp-24h] + E0003EE1: 89 95 B8 FD FF FF mov dword ptr [ebp+FFFFFDB8h],edx + E0003EE7: 8B 85 B8 FD FF FF mov eax,dword ptr [ebp+FFFFFDB8h] + E0003EED: 8B 08 mov ecx,dword ptr [eax] + E0003EEF: 8B 95 B8 FD FF FF mov edx,dword ptr [ebp+FFFFFDB8h] + E0003EF5: 52 push edx + E0003EF6: FF 51 04 call dword ptr [ecx+4] + E0003EF9: 83 C4 04 add esp,4 + E0003EFC: E9 DB 00 00 00 jmp E0003FDC + E0003F01: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E0003F04: 83 E0 10 and eax,10h + E0003F07: 85 C0 test eax,eax + E0003F09: 74 6B je E0003F76 + E0003F0B: 8B 4D FA mov ecx,dword ptr [ebp-6] + E0003F0E: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0003F14: 51 push ecx + E0003F15: 68 C4 B5 00 E0 push 0E000B5C4h + E0003F1A: E8 3F F7 FF FF call E000365E + E0003F1F: 83 C4 08 add esp,8 + E0003F22: 68 7C 02 00 00 push 27Ch + E0003F27: E8 4A 60 00 00 call E0009F76 + E0003F2C: 83 C4 04 add esp,4 + E0003F2F: 89 85 B4 FD FF FF mov dword ptr [ebp+FFFFFDB4h],eax + E0003F35: 83 BD B4 FD FF FF cmp dword ptr [ebp+FFFFFDB4h],0 + 00 + E0003F3C: 74 20 je E0003F5E + E0003F3E: 6A 00 push 0 + E0003F40: 8D 55 BC lea edx,dword ptr [ebp-44h] + E0003F43: 52 push edx + E0003F44: 8B 45 08 mov eax,dword ptr [ebp+8] + E0003F47: 8B 48 64 mov ecx,dword ptr [eax+64h] + E0003F4A: 51 push ecx + E0003F4B: 8B 8D B4 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB4h] + E0003F51: E8 33 FB FF FF call E0003A89 + E0003F56: 89 85 AC FD FF FF mov dword ptr [ebp+FFFFFDACh],eax + E0003F5C: EB 0A jmp E0003F68 + E0003F5E: C7 85 AC FD FF FF mov dword ptr [ebp+FFFFFDACh],0 + 00 00 00 00 + E0003F68: 8B 95 AC FD FF FF mov edx,dword ptr [ebp+FFFFFDACh] + E0003F6E: 89 95 B8 FD FF FF mov dword ptr [ebp+FFFFFDB8h],edx + E0003F74: EB 66 jmp E0003FDC + E0003F76: 8B 45 FA mov eax,dword ptr [ebp-6] + E0003F79: 25 FF FF 00 00 and eax,0FFFFh + E0003F7E: 50 push eax + E0003F7F: 68 E8 B5 00 E0 push 0E000B5E8h + E0003F84: E8 D5 F6 FF FF call E000365E + E0003F89: 83 C4 08 add esp,8 + E0003F8C: 68 6C 02 00 00 push 26Ch + E0003F91: E8 E0 5F 00 00 call E0009F76 + E0003F96: 83 C4 04 add esp,4 + E0003F99: 89 85 B0 FD FF FF mov dword ptr [ebp+FFFFFDB0h],eax + E0003F9F: 83 BD B0 FD FF FF cmp dword ptr [ebp+FFFFFDB0h],0 + 00 + E0003FA6: 74 1E je E0003FC6 + E0003FA8: 8D 4D BC lea ecx,dword ptr [ebp-44h] + E0003FAB: 51 push ecx + E0003FAC: 8B 55 08 mov edx,dword ptr [ebp+8] + E0003FAF: 8B 42 64 mov eax,dword ptr [edx+64h] + E0003FB2: 50 push eax + E0003FB3: 8B 8D B0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB0h] + E0003FB9: E8 50 F5 FF FF call E000350E + E0003FBE: 89 85 A8 FD FF FF mov dword ptr [ebp+FFFFFDA8h],eax + E0003FC4: EB 0A jmp E0003FD0 + E0003FC6: C7 85 A8 FD FF FF mov dword ptr [ebp+FFFFFDA8h],0 + 00 00 00 00 + E0003FD0: 8B 8D A8 FD FF FF mov ecx,dword ptr [ebp+FFFFFDA8h] + E0003FD6: 89 8D B8 FD FF FF mov dword ptr [ebp+FFFFFDB8h],ecx + E0003FDC: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0003FDF: 83 3A 44 cmp dword ptr [edx],44h + E0003FE2: 75 0F jne E0003FF3 + E0003FE4: B9 11 00 00 00 mov ecx,11h + E0003FE9: 8D 75 BC lea esi,dword ptr [ebp-44h] + E0003FEC: 8B 7D 0C mov edi,dword ptr [ebp+0Ch] + E0003FEF: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E0003FF1: EB 0D jmp E0004000 + E0003FF3: B9 07 00 00 00 mov ecx,7 + E0003FF8: 8D 75 BC lea esi,dword ptr [ebp-44h] + E0003FFB: 8B 7D 0C mov edi,dword ptr [ebp+0Ch] + E0003FFE: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E0004000: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0004003: 8B 8D B8 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB8h] + E0004009: 89 48 04 mov dword ptr [eax+4],ecx + E000400C: 8D 55 BC lea edx,dword ptr [ebp-44h] + E000400F: 52 push edx + E0004010: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004013: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004016: 8B 11 mov edx,dword ptr [ecx] + E0004018: 50 push eax + E0004019: FF 52 14 call dword ptr [edx+14h] + E000401C: 83 C4 08 add esp,8 + E000401F: 33 C0 xor eax,eax + E0004021: 5F pop edi + E0004022: 5E pop esi + E0004023: 8B E5 mov esp,ebp + E0004025: 5D pop ebp + E0004026: C3 ret +?Mount@CFatFolder@@UAAKPBGPAUIUnknown@@@Z (public: virtual unsigned long __cdecl CFatFolder::Mount(unsigned short const *,struct IUnknown *)): + E0004027: 55 push ebp + E0004028: 8B EC mov ebp,esp + E000402A: 51 push ecx + E000402B: 6A 44 push 44h + E000402D: E8 44 5F 00 00 call E0009F76 + E0004032: 83 C4 04 add esp,4 + E0004035: 89 45 FC mov dword ptr [ebp-4],eax + E0004038: 8B 45 FC mov eax,dword ptr [ebp-4] + E000403B: C7 00 44 00 00 00 mov dword ptr [eax],44h + E0004041: 33 C9 xor ecx,ecx + E0004043: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004046: 89 0A mov dword ptr [edx],ecx + E0004048: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000404B: 50 push eax + E000404C: E8 4F 5F 00 00 call E0009FA0 + E0004051: 83 C4 04 add esp,4 + E0004054: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004057: 89 41 0C mov dword ptr [ecx+0Ch],eax + E000405A: 8B 55 FC mov edx,dword ptr [ebp-4] + E000405D: C7 42 14 10 20 00 mov dword ptr [edx+14h],2010h + 00 + E0004064: 8B 45 FC mov eax,dword ptr [ebp-4] + E0004067: C7 40 18 00 00 00 mov dword ptr [eax+18h],0 + 00 + E000406E: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004071: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0004074: 89 51 20 mov dword ptr [ecx+20h],edx + E0004077: 8B 45 10 mov eax,dword ptr [ebp+10h] + E000407A: 8B 08 mov ecx,dword ptr [eax] + E000407C: 8B 55 10 mov edx,dword ptr [ebp+10h] + E000407F: 52 push edx + E0004080: FF 51 04 call dword ptr [ecx+4] + E0004083: 83 C4 04 add esp,4 + E0004086: 8B 45 FC mov eax,dword ptr [ebp-4] + E0004089: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000408C: 8B 91 74 02 00 00 mov edx,dword ptr [ecx+00000274h] + E0004092: 89 50 1C mov dword ptr [eax+1Ch],edx + E0004095: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004098: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000409B: 89 88 74 02 00 00 mov dword ptr [eax+00000274h],ecx + E00040A1: 33 C0 xor eax,eax + E00040A3: 8B E5 mov esp,ebp + E00040A5: 5D pop ebp + E00040A6: C3 ret +?ScanDir@CFatFolder@@IAEXXZ (protected: void __thiscall CFatFolder::ScanDir(void)): + E00040A7: 55 push ebp + E00040A8: 8B EC mov ebp,esp + E00040AA: 81 EC 54 02 00 00 sub esp,254h + E00040B0: 56 push esi + E00040B1: 57 push edi + E00040B2: 89 8D AC FD FF FF mov dword ptr [ebp+FFFFFDACh],ecx + E00040B8: 8B 85 AC FD FF FF mov eax,dword ptr [ebp+FFFFFDACh] + E00040BE: C7 40 58 00 00 00 mov dword ptr [eax+58h],0 + 00 + E00040C5: 8B 8D AC FD FF FF mov ecx,dword ptr [ebp+FFFFFDACh] + E00040CB: C7 41 64 FF FF FF mov dword ptr [ecx+64h],0FFFFFFFFh + FF + E00040D2: 8B 95 AC FD FF FF mov edx,dword ptr [ebp+FFFFFDACh] + E00040D8: C7 42 6C FF FF FF mov dword ptr [edx+6Ch],0FFFFFFFFh + FF + E00040DF: C7 45 D8 00 00 00 mov dword ptr [ebp-28h],0 + 00 + E00040E6: B8 01 00 00 00 mov eax,1 + E00040EB: 85 C0 test eax,eax + E00040ED: 0F 84 E1 03 00 00 je E00044D4 + E00040F3: 6A 20 push 20h + E00040F5: 8D 4D DC lea ecx,dword ptr [ebp-24h] + E00040F8: 51 push ecx + E00040F9: 8B 95 AC FD FF FF mov edx,dword ptr [ebp+FFFFFDACh] + E00040FF: 83 C2 10 add edx,10h + E0004102: 8B 85 AC FD FF FF mov eax,dword ptr [ebp+FFFFFDACh] + E0004108: 8B 48 10 mov ecx,dword ptr [eax+10h] + E000410B: 52 push edx + E000410C: FF 51 0C call dword ptr [ecx+0Ch] + E000410F: 83 C4 0C add esp,0Ch + E0004112: 83 F8 20 cmp eax,20h + E0004115: 73 16 jae E000412D + E0004117: 8B 55 D8 mov edx,dword ptr [ebp-28h] + E000411A: 52 push edx + E000411B: 68 0C B6 00 E0 push 0E000B60Ch + E0004120: E8 39 F5 FF FF call E000365E + E0004125: 83 C4 08 add esp,8 + E0004128: E9 A7 03 00 00 jmp E00044D4 + E000412D: 8B 45 DC mov eax,dword ptr [ebp-24h] + E0004130: 25 FF 00 00 00 and eax,0FFh + E0004135: 85 C0 test eax,eax + E0004137: 75 16 jne E000414F + E0004139: 8B 4D D8 mov ecx,dword ptr [ebp-28h] + E000413C: 51 push ecx + E000413D: 68 30 B6 00 E0 push 0E000B630h + E0004142: E8 17 F5 FF FF call E000365E + E0004147: 83 C4 08 add esp,8 + E000414A: E9 85 03 00 00 jmp E00044D4 + E000414F: 8B 55 DC mov edx,dword ptr [ebp-24h] + E0004152: 81 E2 FF 00 00 00 and edx,0FFh + E0004158: 81 FA E5 00 00 00 cmp edx,0E5h + E000415E: 0F 84 6B 03 00 00 je E00044CF + E0004164: B9 80 00 00 00 mov ecx,80h + E0004169: 33 C0 xor eax,eax + E000416B: 8D BD B4 FD FF FF lea edi,dword ptr [ebp+FFFFFDB4h] + E0004171: F3 AB rep stos dword ptr es:[edi] + E0004173: 8B 45 E7 mov eax,dword ptr [ebp-19h] + E0004176: 25 FF 00 00 00 and eax,0FFh + E000417B: 83 E0 0F and eax,0Fh + E000417E: 83 F8 0F cmp eax,0Fh + E0004181: 0F 84 46 01 00 00 je E00042CD + E0004187: C7 45 B8 00 00 00 mov dword ptr [ebp-48h],0 + 00 + E000418E: EB 09 jmp E0004199 + E0004190: 8B 4D B8 mov ecx,dword ptr [ebp-48h] + E0004193: 83 C1 01 add ecx,1 + E0004196: 89 4D B8 mov dword ptr [ebp-48h],ecx + E0004199: 83 7D B8 08 cmp dword ptr [ebp-48h],8 + E000419D: 7D 68 jge E0004207 + E000419F: 8B 55 B8 mov edx,dword ptr [ebp-48h] + E00041A2: 33 C0 xor eax,eax + E00041A4: 8A 44 15 DC mov al,byte ptr [ebp+edx-24h] + E00041A8: 83 F8 20 cmp eax,20h + E00041AB: 75 0F jne E00041BC + E00041AD: 8B 4D B8 mov ecx,dword ptr [ebp-48h] + E00041B0: 66 C7 84 4D B4 FD mov word ptr [ebp+ecx*2+FFFFFDB4h],0 + FF FF 00 00 + E00041BA: EB 4B jmp E0004207 + E00041BC: 8B 55 B8 mov edx,dword ptr [ebp-48h] + E00041BF: 33 C0 xor eax,eax + E00041C1: 8A 44 15 DC mov al,byte ptr [ebp+edx-24h] + E00041C5: 50 push eax + E00041C6: E8 BD 5D 00 00 call E0009F88 + E00041CB: 83 C4 04 add esp,4 + E00041CE: 85 C0 test eax,eax + E00041D0: 74 1F je E00041F1 + E00041D2: 8B 4D B8 mov ecx,dword ptr [ebp-48h] + E00041D5: 33 D2 xor edx,edx + E00041D7: 8A 54 0D DC mov dl,byte ptr [ebp+ecx-24h] + E00041DB: 52 push edx + E00041DC: E8 A1 5D 00 00 call E0009F82 + E00041E1: 83 C4 04 add esp,4 + E00041E4: 8B 4D B8 mov ecx,dword ptr [ebp-48h] + E00041E7: 66 89 84 4D B4 FD mov word ptr [ebp+ecx*2+FFFFFDB4h],ax + FF FF + E00041EF: EB 14 jmp E0004205 + E00041F1: 8B 55 B8 mov edx,dword ptr [ebp-48h] + E00041F4: 66 0F B6 44 15 DC movzx ax,byte ptr [ebp+edx-24h] + E00041FA: 8B 4D B8 mov ecx,dword ptr [ebp-48h] + E00041FD: 66 89 84 4D B4 FD mov word ptr [ebp+ecx*2+FFFFFDB4h],ax + FF FF + E0004205: EB 89 jmp E0004190 + E0004207: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E000420A: 81 E2 FF 00 00 00 and edx,0FFh + E0004210: 83 FA 20 cmp edx,20h + E0004213: 0F 84 AF 00 00 00 je E00042C8 + E0004219: 68 5C B6 00 E0 push 0E000B65Ch + E000421E: 8D 85 B4 FD FF FF lea eax,dword ptr [ebp+FFFFFDB4h] + E0004224: 50 push eax + E0004225: E8 FE 5C 00 00 call E0009F28 + E000422A: 83 C4 08 add esp,8 + E000422D: 8D 8D B4 FD FF FF lea ecx,dword ptr [ebp+FFFFFDB4h] + E0004233: 51 push ecx + E0004234: E8 13 5D 00 00 call E0009F4C + E0004239: 83 C4 04 add esp,4 + E000423C: 89 45 B4 mov dword ptr [ebp-4Ch],eax + E000423F: C7 45 B8 00 00 00 mov dword ptr [ebp-48h],0 + 00 + E0004246: EB 09 jmp E0004251 + E0004248: 8B 55 B8 mov edx,dword ptr [ebp-48h] + E000424B: 83 C2 01 add edx,1 + E000424E: 89 55 B8 mov dword ptr [ebp-48h],edx + E0004251: 83 7D B8 03 cmp dword ptr [ebp-48h],3 + E0004255: 7D 71 jge E00042C8 + E0004257: 8B 45 B8 mov eax,dword ptr [ebp-48h] + E000425A: 33 C9 xor ecx,ecx + E000425C: 8A 4C 05 E4 mov cl,byte ptr [ebp+eax-1Ch] + E0004260: 83 F9 20 cmp ecx,20h + E0004263: 75 12 jne E0004277 + E0004265: 8B 55 B8 mov edx,dword ptr [ebp-48h] + E0004268: 03 55 B4 add edx,dword ptr [ebp-4Ch] + E000426B: 66 C7 84 55 B4 FD mov word ptr [ebp+edx*2+FFFFFDB4h],0 + FF FF 00 00 + E0004275: EB 51 jmp E00042C8 + E0004277: 8B 45 B8 mov eax,dword ptr [ebp-48h] + E000427A: 33 C9 xor ecx,ecx + E000427C: 8A 4C 05 E4 mov cl,byte ptr [ebp+eax-1Ch] + E0004280: 51 push ecx + E0004281: E8 02 5D 00 00 call E0009F88 + E0004286: 83 C4 04 add esp,4 + E0004289: 85 C0 test eax,eax + E000428B: 74 22 je E00042AF + E000428D: 8B 55 B8 mov edx,dword ptr [ebp-48h] + E0004290: 33 C0 xor eax,eax + E0004292: 8A 44 15 E4 mov al,byte ptr [ebp+edx-1Ch] + E0004296: 50 push eax + E0004297: E8 E6 5C 00 00 call E0009F82 + E000429C: 83 C4 04 add esp,4 + E000429F: 8B 4D B8 mov ecx,dword ptr [ebp-48h] + E00042A2: 03 4D B4 add ecx,dword ptr [ebp-4Ch] + E00042A5: 66 89 84 4D B4 FD mov word ptr [ebp+ecx*2+FFFFFDB4h],ax + FF FF + E00042AD: EB 17 jmp E00042C6 + E00042AF: 8B 55 B8 mov edx,dword ptr [ebp-48h] + E00042B2: 66 0F B6 44 15 E4 movzx ax,byte ptr [ebp+edx-1Ch] + E00042B8: 8B 4D B8 mov ecx,dword ptr [ebp-48h] + E00042BB: 03 4D B4 add ecx,dword ptr [ebp-4Ch] + E00042BE: 66 89 84 4D B4 FD mov word ptr [ebp+ecx*2+FFFFFDB4h],ax + FF FF + E00042C6: EB 80 jmp E0004248 + E00042C8: E9 63 01 00 00 jmp E0004430 + E00042CD: 8B 55 E7 mov edx,dword ptr [ebp-19h] + E00042D0: 81 E2 FF 00 00 00 and edx,0FFh + E00042D6: 83 E2 0F and edx,0Fh + E00042D9: 83 FA 0F cmp edx,0Fh + E00042DC: 0F 85 4E 01 00 00 jne E0004430 + E00042E2: 8B 45 DC mov eax,dword ptr [ebp-24h] + E00042E5: 25 FF 00 00 00 and eax,0FFh + E00042EA: 3D E5 00 00 00 cmp eax,0E5h + E00042EF: 0F 84 FC 00 00 00 je E00043F1 + E00042F5: B9 07 00 00 00 mov ecx,7 + E00042FA: 33 C0 xor eax,eax + E00042FC: 8D 7D BC lea edi,dword ptr [ebp-44h] + E00042FF: F3 AB rep stos dword ptr es:[edi] + E0004301: 8D 4D BC lea ecx,dword ptr [ebp-44h] + E0004304: 89 4D FC mov dword ptr [ebp-4],ecx + E0004307: C7 45 B8 00 00 00 mov dword ptr [ebp-48h],0 + 00 + E000430E: EB 09 jmp E0004319 + E0004310: 8B 55 B8 mov edx,dword ptr [ebp-48h] + E0004313: 83 C2 01 add edx,1 + E0004316: 89 55 B8 mov dword ptr [ebp-48h],edx + E0004319: 83 7D B8 05 cmp dword ptr [ebp-48h],5 + E000431D: 7D 19 jge E0004338 + E000431F: 8B 45 FC mov eax,dword ptr [ebp-4] + E0004322: 8B 4D B8 mov ecx,dword ptr [ebp-48h] + E0004325: 66 8B 54 4D DD mov dx,word ptr [ebp+ecx*2-23h] + E000432A: 66 89 10 mov word ptr [eax],dx + E000432D: 8B 45 FC mov eax,dword ptr [ebp-4] + E0004330: 83 C0 02 add eax,2 + E0004333: 89 45 FC mov dword ptr [ebp-4],eax + E0004336: EB D8 jmp E0004310 + E0004338: C7 45 B8 00 00 00 mov dword ptr [ebp-48h],0 + 00 + E000433F: EB 09 jmp E000434A + E0004341: 8B 4D B8 mov ecx,dword ptr [ebp-48h] + E0004344: 83 C1 01 add ecx,1 + E0004347: 89 4D B8 mov dword ptr [ebp-48h],ecx + E000434A: 83 7D B8 06 cmp dword ptr [ebp-48h],6 + E000434E: 7D 19 jge E0004369 + E0004350: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004353: 8B 45 B8 mov eax,dword ptr [ebp-48h] + E0004356: 66 8B 4C 45 EA mov cx,word ptr [ebp+eax*2-16h] + E000435B: 66 89 0A mov word ptr [edx],cx + E000435E: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004361: 83 C2 02 add edx,2 + E0004364: 89 55 FC mov dword ptr [ebp-4],edx + E0004367: EB D8 jmp E0004341 + E0004369: C7 45 B8 00 00 00 mov dword ptr [ebp-48h],0 + 00 + E0004370: EB 09 jmp E000437B + E0004372: 8B 45 B8 mov eax,dword ptr [ebp-48h] + E0004375: 83 C0 01 add eax,1 + E0004378: 89 45 B8 mov dword ptr [ebp-48h],eax + E000437B: 83 7D B8 02 cmp dword ptr [ebp-48h],2 + E000437F: 7D 19 jge E000439A + E0004381: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004384: 8B 55 B8 mov edx,dword ptr [ebp-48h] + E0004387: 66 8B 44 55 F8 mov ax,word ptr [ebp+edx*2-8] + E000438C: 66 89 01 mov word ptr [ecx],ax + E000438F: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004392: 83 C1 02 add ecx,2 + E0004395: 89 4D FC mov dword ptr [ebp-4],ecx + E0004398: EB D8 jmp E0004372 + E000439A: 8D 55 BC lea edx,dword ptr [ebp-44h] + E000439D: 52 push edx + E000439E: E8 A9 5B 00 00 call E0009F4C + E00043A3: 83 C4 04 add esp,4 + E00043A6: 89 45 B8 mov dword ptr [ebp-48h],eax + E00043A9: 8D 85 B4 FD FF FF lea eax,dword ptr [ebp+FFFFFDB4h] + E00043AF: 50 push eax + E00043B0: E8 97 5B 00 00 call E0009F4C + E00043B5: 83 C4 04 add esp,4 + E00043B8: D1 E0 shl eax,1 + E00043BA: 50 push eax + E00043BB: 8D 8D B4 FD FF FF lea ecx,dword ptr [ebp+FFFFFDB4h] + E00043C1: 51 push ecx + E00043C2: 8B 55 B8 mov edx,dword ptr [ebp-48h] + E00043C5: 8D 84 55 B4 FD FF lea eax,dword ptr [ebp+edx*2+FFFFFDB4h] + FF + E00043CC: 50 push eax + E00043CD: E8 D4 5B 00 00 call E0009FA6 + E00043D2: 83 C4 0C add esp,0Ch + E00043D5: 8B 4D B8 mov ecx,dword ptr [ebp-48h] + E00043D8: D1 E1 shl ecx,1 + E00043DA: 8D 75 BC lea esi,dword ptr [ebp-44h] + E00043DD: 8D BD B4 FD FF FF lea edi,dword ptr [ebp+FFFFFDB4h] + E00043E3: 8B D1 mov edx,ecx + E00043E5: C1 E9 02 shr ecx,2 + E00043E8: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E00043EA: 8B CA mov ecx,edx + E00043EC: 83 E1 03 and ecx,3 + E00043EF: F3 A4 rep movs byte ptr es:[edi],byte ptr [esi] + E00043F1: 6A 20 push 20h + E00043F3: 8D 45 DC lea eax,dword ptr [ebp-24h] + E00043F6: 50 push eax + E00043F7: 8B 8D AC FD FF FF mov ecx,dword ptr [ebp+FFFFFDACh] + E00043FD: 83 C1 10 add ecx,10h + E0004400: 8B 95 AC FD FF FF mov edx,dword ptr [ebp+FFFFFDACh] + E0004406: 8B 42 10 mov eax,dword ptr [edx+10h] + E0004409: 51 push ecx + E000440A: FF 50 0C call dword ptr [eax+0Ch] + E000440D: 83 C4 0C add esp,0Ch + E0004410: 83 F8 20 cmp eax,20h + E0004413: 73 16 jae E000442B + E0004415: 8B 4D D8 mov ecx,dword ptr [ebp-28h] + E0004418: 51 push ecx + E0004419: 68 60 B6 00 E0 push 0E000B660h + E000441E: E8 3B F2 FF FF call E000365E + E0004423: 83 C4 08 add esp,8 + E0004426: E9 A9 00 00 00 jmp E00044D4 + E000442B: E9 9D FE FF FF jmp E00042CD + E0004430: 6A 44 push 44h + E0004432: E8 3F 5B 00 00 call E0009F76 + E0004437: 83 C4 04 add esp,4 + E000443A: 89 85 B0 FD FF FF mov dword ptr [ebp+FFFFFDB0h],eax + E0004440: 33 D2 xor edx,edx + E0004442: 8B 85 B0 FD FF FF mov eax,dword ptr [ebp+FFFFFDB0h] + E0004448: 89 10 mov dword ptr [eax],edx + E000444A: 8B 8D B0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB0h] + E0004450: C7 01 44 00 00 00 mov dword ptr [ecx],44h + E0004456: 8D 95 B4 FD FF FF lea edx,dword ptr [ebp+FFFFFDB4h] + E000445C: 52 push edx + E000445D: E8 3E 5B 00 00 call E0009FA0 + E0004462: 83 C4 04 add esp,4 + E0004465: 8B 8D B0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB0h] + E000446B: 89 41 0C mov dword ptr [ecx+0Ch],eax + E000446E: 8B 95 B0 FD FF FF mov edx,dword ptr [ebp+FFFFFDB0h] + E0004474: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0004477: 89 42 18 mov dword ptr [edx+18h],eax + E000447A: 8B 4D E7 mov ecx,dword ptr [ebp-19h] + E000447D: 81 E1 FF 00 00 00 and ecx,0FFh + E0004483: 8B 95 B0 FD FF FF mov edx,dword ptr [ebp+FFFFFDB0h] + E0004489: 89 4A 14 mov dword ptr [edx+14h],ecx + E000448C: 8B BD B0 FD FF FF mov edi,dword ptr [ebp+FFFFFDB0h] + E0004492: 83 C7 24 add edi,24h + E0004495: B9 08 00 00 00 mov ecx,8 + E000449A: 8D 75 DC lea esi,dword ptr [ebp-24h] + E000449D: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E000449F: 8B 85 B0 FD FF FF mov eax,dword ptr [ebp+FFFFFDB0h] + E00044A5: 8B 8D AC FD FF FF mov ecx,dword ptr [ebp+FFFFFDACh] + E00044AB: 8B 91 78 02 00 00 mov edx,dword ptr [ecx+00000278h] + E00044B1: 89 50 1C mov dword ptr [eax+1Ch],edx + E00044B4: 8B 85 AC FD FF FF mov eax,dword ptr [ebp+FFFFFDACh] + E00044BA: 8B 8D B0 FD FF FF mov ecx,dword ptr [ebp+FFFFFDB0h] + E00044C0: 89 88 78 02 00 00 mov dword ptr [eax+00000278h],ecx + E00044C6: 8B 55 D8 mov edx,dword ptr [ebp-28h] + E00044C9: 83 C2 01 add edx,1 + E00044CC: 89 55 D8 mov dword ptr [ebp-28h],edx + E00044CF: E9 12 FC FF FF jmp E00040E6 + E00044D4: 5F pop edi + E00044D5: 5E pop esi + E00044D6: 8B E5 mov esp,ebp + E00044D8: 5D pop ebp + E00044D9: C3 ret + E00044DA: CC int 3 + E00044DB: CC int 3 + E00044DC: CC int 3 + E00044DD: CC int 3 + E00044DE: CC int 3 + E00044DF: CC int 3 +?AddRef@CFatFile@@UAAKXZ (public: virtual unsigned long __cdecl CFatFile::AddRef(void)): + E00044E0: 55 push ebp + E00044E1: 8B EC mov ebp,esp + E00044E3: 8B 45 08 mov eax,dword ptr [ebp+8] + E00044E6: 8B 88 68 02 00 00 mov ecx,dword ptr [eax+00000268h] + E00044EC: 83 C1 01 add ecx,1 + E00044EF: 8B 55 08 mov edx,dword ptr [ebp+8] + E00044F2: 89 8A 68 02 00 00 mov dword ptr [edx+00000268h],ecx + E00044F8: 8B 45 08 mov eax,dword ptr [ebp+8] + E00044FB: 8B 80 68 02 00 00 mov eax,dword ptr [eax+00000268h] + E0004501: 5D pop ebp + E0004502: C3 ret + E0004503: CC int 3 + E0004504: CC int 3 + E0004505: CC int 3 + E0004506: CC int 3 + E0004507: CC int 3 + E0004508: CC int 3 + E0004509: CC int 3 + E000450A: CC int 3 + E000450B: CC int 3 + E000450C: CC int 3 + E000450D: CC int 3 + E000450E: CC int 3 + E000450F: CC int 3 +?Release@CFatFile@@UAAKXZ (public: virtual unsigned long __cdecl CFatFile::Release(void)): + E0004510: 55 push ebp + E0004511: 8B EC mov ebp,esp + E0004513: 83 EC 0C sub esp,0Ch + E0004516: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004519: 83 B8 68 02 00 00 cmp dword ptr [eax+00000268h],0 + 00 + E0004520: 75 2F jne E0004551 + E0004522: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004525: 89 4D F8 mov dword ptr [ebp-8],ecx + E0004528: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000452B: 89 55 FC mov dword ptr [ebp-4],edx + E000452E: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0004532: 74 12 je E0004546 + E0004534: 6A 01 push 1 + E0004536: 8B 45 FC mov eax,dword ptr [ebp-4] + E0004539: 8B 10 mov edx,dword ptr [eax] + E000453B: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000453E: FF 52 0C call dword ptr [edx+0Ch] + E0004541: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0004544: EB 07 jmp E000454D + E0004546: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E000454D: 33 C0 xor eax,eax + E000454F: EB 1E jmp E000456F + E0004551: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004554: 8B 80 68 02 00 00 mov eax,dword ptr [eax+00000268h] + E000455A: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000455D: 8B 91 68 02 00 00 mov edx,dword ptr [ecx+00000268h] + E0004563: 83 EA 01 sub edx,1 + E0004566: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004569: 89 91 68 02 00 00 mov dword ptr [ecx+00000268h],edx + E000456F: 8B E5 mov esp,ebp + E0004571: 5D pop ebp + E0004572: C3 ret + E0004573: CC int 3 + E0004574: CC int 3 + E0004575: CC int 3 + E0004576: CC int 3 + E0004577: CC int 3 + E0004578: CC int 3 + E0004579: CC int 3 + E000457A: CC int 3 + E000457B: CC int 3 + E000457C: CC int 3 + E000457D: CC int 3 + E000457E: CC int 3 + E000457F: CC int 3 +??_GCFatFile@@UAEPAXI@Z (public: virtual void * __thiscall CFatFile::`scalar deleting destructor'(unsigned int)): + E0004580: 55 push ebp + E0004581: 8B EC mov ebp,esp + E0004583: 51 push ecx + E0004584: 89 4D FC mov dword ptr [ebp-4],ecx + E0004587: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000458A: E8 6E F0 FF FF call E00035FD + E000458F: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004592: 83 E0 01 and eax,1 + E0004595: 85 C0 test eax,eax + E0004597: 74 0C je E00045A5 + E0004599: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000459C: 51 push ecx + E000459D: E8 C8 59 00 00 call E0009F6A + E00045A2: 83 C4 04 add esp,4 + E00045A5: 8B 45 FC mov eax,dword ptr [ebp-4] + E00045A8: 8B E5 mov esp,ebp + E00045AA: 5D pop ebp + E00045AB: C2 04 00 ret 4 + E00045AE: CC int 3 + E00045AF: CC int 3 +?AddRef@CFatFolder@@UAAKXZ (public: virtual unsigned long __cdecl CFatFolder::AddRef(void)): + E00045B0: 55 push ebp + E00045B1: 8B EC mov ebp,esp + E00045B3: 8B 45 08 mov eax,dword ptr [ebp+8] + E00045B6: 8B 48 08 mov ecx,dword ptr [eax+8] + E00045B9: 83 C1 01 add ecx,1 + E00045BC: 8B 55 08 mov edx,dword ptr [ebp+8] + E00045BF: 89 4A 08 mov dword ptr [edx+8],ecx + E00045C2: 8B 45 08 mov eax,dword ptr [ebp+8] + E00045C5: 8B 40 08 mov eax,dword ptr [eax+8] + E00045C8: 5D pop ebp + E00045C9: C3 ret + E00045CA: CC int 3 + E00045CB: CC int 3 + E00045CC: CC int 3 + E00045CD: CC int 3 + E00045CE: CC int 3 + E00045CF: CC int 3 +?Release@CFatFolder@@UAAKXZ (public: virtual unsigned long __cdecl CFatFolder::Release(void)): + E00045D0: 55 push ebp + E00045D1: 8B EC mov ebp,esp + E00045D3: 83 EC 0C sub esp,0Ch + E00045D6: 8B 45 08 mov eax,dword ptr [ebp+8] + E00045D9: 83 78 08 00 cmp dword ptr [eax+8],0 + E00045DD: 75 2F jne E000460E + E00045DF: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00045E2: 89 4D F8 mov dword ptr [ebp-8],ecx + E00045E5: 8B 55 F8 mov edx,dword ptr [ebp-8] + E00045E8: 89 55 FC mov dword ptr [ebp-4],edx + E00045EB: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E00045EF: 74 12 je E0004603 + E00045F1: 6A 01 push 1 + E00045F3: 8B 45 FC mov eax,dword ptr [ebp-4] + E00045F6: 8B 10 mov edx,dword ptr [eax] + E00045F8: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00045FB: FF 52 0C call dword ptr [edx+0Ch] + E00045FE: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0004601: EB 07 jmp E000460A + E0004603: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E000460A: 33 C0 xor eax,eax + E000460C: EB 15 jmp E0004623 + E000460E: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004611: 8B 40 08 mov eax,dword ptr [eax+8] + E0004614: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004617: 8B 51 08 mov edx,dword ptr [ecx+8] + E000461A: 83 EA 01 sub edx,1 + E000461D: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004620: 89 51 08 mov dword ptr [ecx+8],edx + E0004623: 8B E5 mov esp,ebp + E0004625: 5D pop ebp + E0004626: C3 ret + E0004627: CC int 3 + E0004628: CC int 3 + E0004629: CC int 3 + E000462A: CC int 3 + E000462B: CC int 3 + E000462C: CC int 3 + E000462D: CC int 3 + E000462E: CC int 3 + E000462F: CC int 3 +??_GCFatFolder@@UAEPAXI@Z (public: virtual void * __thiscall CFatFolder::`scalar deleting destructor'(unsigned int)): + E0004630: 55 push ebp + E0004631: 8B EC mov ebp,esp + E0004633: 51 push ecx + E0004634: 89 4D FC mov dword ptr [ebp-4],ecx + E0004637: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000463A: E8 E2 F4 FF FF call E0003B21 + E000463F: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004642: 83 E0 01 and eax,1 + E0004645: 85 C0 test eax,eax + E0004647: 74 0C je E0004655 + E0004649: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000464C: 51 push ecx + E000464D: E8 18 59 00 00 call E0009F6A + E0004652: 83 C4 04 add esp,4 + E0004655: 8B 45 FC mov eax,dword ptr [ebp-4] + E0004658: 8B E5 mov esp,ebp + E000465A: 5D pop ebp + E000465B: C2 04 00 ret 4 + E000465E: CC int 3 + E000465F: CC int 3 +?QueryInterface@CFatFile@@W3AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CFatFile::QueryInterface`adjustor{4}' (struct _GUID const &,void * *)): + E0004660: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0004665: E9 FB EF FF FF jmp E0003665 + E000466A: CC int 3 + E000466B: CC int 3 + E000466C: CC int 3 + E000466D: CC int 3 + E000466E: CC int 3 + E000466F: CC int 3 +?AddRef@CFatFile@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CFatFile::AddRef`adjustor{4}' (void)): + E0004670: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0004675: E9 66 FE FF FF jmp E00044E0 + E000467A: CC int 3 + E000467B: CC int 3 + E000467C: CC int 3 + E000467D: CC int 3 + E000467E: CC int 3 + E000467F: CC int 3 +?Release@CFatFile@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CFatFile::Release`adjustor{4}' (void)): + E0004680: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0004685: E9 86 FE FF FF jmp E0004510 + E000468A: CC int 3 + E000468B: CC int 3 + E000468C: CC int 3 + E000468D: CC int 3 + E000468E: CC int 3 + E000468F: CC int 3 +?QueryInterface@CFatFolder@@W3AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CFatFolder::QueryInterface`adjustor{4}' (struct _GUID const &,void * *)): + E0004690: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0004695: E9 20 F5 FF FF jmp E0003BBA + E000469A: CC int 3 + E000469B: CC int 3 + E000469C: CC int 3 + E000469D: CC int 3 + E000469E: CC int 3 + E000469F: CC int 3 +?AddRef@CFatFolder@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CFatFolder::AddRef`adjustor{4}' (void)): + E00046A0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E00046A5: E9 06 FF FF FF jmp E00045B0 + E00046AA: CC int 3 + E00046AB: CC int 3 + E00046AC: CC int 3 + E00046AD: CC int 3 + E00046AE: CC int 3 + E00046AF: CC int 3 +?Release@CFatFolder@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CFatFolder::Release`adjustor{4}' (void)): + E00046B0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E00046B5: E9 16 FF FF FF jmp E00045D0 + E00046BA: CC int 3 + E00046BB: CC int 3 + E00046BC: CC int 3 + E00046BD: CC int 3 + E00046BE: CC int 3 + E00046BF: CC int 3 +_Folder_Create: + E00046C0: 55 push ebp + E00046C1: 8B EC mov ebp,esp + E00046C3: 83 EC 0C sub esp,0Ch + E00046C6: 6A 14 push 14h + E00046C8: E8 A9 58 00 00 call E0009F76 + E00046CD: 83 C4 04 add esp,4 + E00046D0: 89 45 FC mov dword ptr [ebp-4],eax + E00046D3: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E00046D7: 74 0D je E00046E6 + E00046D9: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00046DC: E8 2B 00 00 00 call E000470C + E00046E1: 89 45 F8 mov dword ptr [ebp-8],eax + E00046E4: EB 07 jmp E00046ED + E00046E6: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E00046ED: 83 7D F8 00 cmp dword ptr [ebp-8],0 + E00046F1: 74 0B je E00046FE + E00046F3: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00046F6: 83 C0 04 add eax,4 + E00046F9: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E00046FC: EB 07 jmp E0004705 + E00046FE: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E0004705: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0004708: 8B E5 mov esp,ebp + E000470A: 5D pop ebp + E000470B: C3 ret +??0CFolder@@QAE@XZ (public: __thiscall CFolder::CFolder(void)): + E000470C: 55 push ebp + E000470D: 8B EC mov ebp,esp + E000470F: 83 EC 08 sub esp,8 + E0004712: 89 4D F8 mov dword ptr [ebp-8],ecx + E0004715: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0004718: C7 00 C8 A0 00 E0 mov dword ptr [eax],0E000A0C8h + E000471E: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0004721: 83 C1 04 add ecx,4 + E0004724: 89 4D FC mov dword ptr [ebp-4],ecx + E0004727: 8B 55 FC mov edx,dword ptr [ebp-4] + E000472A: C7 02 A0 A2 00 E0 mov dword ptr [edx],0E000A2A0h + E0004730: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0004733: C7 00 E0 A2 00 E0 mov dword ptr [eax],0E000A2E0h + E0004739: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E000473C: C7 41 04 C0 A2 00 mov dword ptr [ecx+4],0E000A2C0h + E0 + E0004743: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0004746: C7 42 08 00 00 00 mov dword ptr [edx+8],0 + 00 + E000474D: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0004750: C7 40 0C 00 00 00 mov dword ptr [eax+0Ch],0 + 00 + E0004757: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E000475A: C6 41 10 00 mov byte ptr [ecx+10h],0 + E000475E: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0004761: 8B E5 mov esp,ebp + E0004763: 5D pop ebp + E0004764: C3 ret +??1CFolder@@QAE@XZ (public: __thiscall CFolder::~CFolder(void)): + E0004765: 55 push ebp + E0004766: 8B EC mov ebp,esp + E0004768: 83 EC 10 sub esp,10h + E000476B: 89 4D F0 mov dword ptr [ebp-10h],ecx + E000476E: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E0004771: C7 00 E0 A2 00 E0 mov dword ptr [eax],0E000A2E0h + E0004777: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E000477A: C7 41 04 C0 A2 00 mov dword ptr [ecx+4],0E000A2C0h + E0 + E0004781: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0004784: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0004787: 89 45 FC mov dword ptr [ebp-4],eax + E000478A: EB 06 jmp E0004792 + E000478C: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E000478F: 89 4D FC mov dword ptr [ebp-4],ecx + E0004792: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0004796: 74 54 je E00047EC + E0004798: 8B 55 FC mov edx,dword ptr [ebp-4] + E000479B: 8B 42 1C mov eax,dword ptr [edx+1Ch] + E000479E: 89 45 F8 mov dword ptr [ebp-8],eax + E00047A1: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00047A4: 83 79 24 00 cmp dword ptr [ecx+24h],0 + E00047A8: 74 15 je E00047BF + E00047AA: 8B 55 FC mov edx,dword ptr [ebp-4] + E00047AD: 8B 42 24 mov eax,dword ptr [edx+24h] + E00047B0: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00047B3: 8B 51 24 mov edx,dword ptr [ecx+24h] + E00047B6: 8B 0A mov ecx,dword ptr [edx] + E00047B8: 50 push eax + E00047B9: FF 51 08 call dword ptr [ecx+8] + E00047BC: 83 C4 04 add esp,4 + E00047BF: 8B 55 FC mov edx,dword ptr [ebp-4] + E00047C2: C7 42 24 00 00 00 mov dword ptr [edx+24h],0 + 00 + E00047C9: 8B 45 FC mov eax,dword ptr [ebp-4] + E00047CC: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E00047CF: 51 push ecx + E00047D0: E8 71 57 00 00 call E0009F46 + E00047D5: 83 C4 04 add esp,4 + E00047D8: 8B 55 FC mov edx,dword ptr [ebp-4] + E00047DB: 89 55 F4 mov dword ptr [ebp-0Ch],edx + E00047DE: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E00047E1: 50 push eax + E00047E2: E8 83 57 00 00 call E0009F6A + E00047E7: 83 C4 04 add esp,4 + E00047EA: EB A0 jmp E000478C + E00047EC: 8B E5 mov esp,ebp + E00047EE: 5D pop ebp + E00047EF: C3 ret +?QueryInterface@CFolder@@UAAKABU_GUID@@PAPAX@Z (public: virtual unsigned long __cdecl CFolder::QueryInterface(struct _GUID const &,void * *)): + E00047F0: 55 push ebp + E00047F1: 8B EC mov ebp,esp + E00047F3: 51 push ecx + E00047F4: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00047F7: 8B 08 mov ecx,dword ptr [eax] + E00047F9: 3B 0D D8 A0 00 E0 cmp ecx,dword ptr ds:[E000A0D8h] + E00047FF: 75 2A jne E000482B + E0004801: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0004804: 8B 42 04 mov eax,dword ptr [edx+4] + E0004807: 3B 05 DC A0 00 E0 cmp eax,dword ptr ds:[E000A0DCh] + E000480D: 75 1C jne E000482B + E000480F: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0004812: 8B 51 08 mov edx,dword ptr [ecx+8] + E0004815: 3B 15 E0 A0 00 E0 cmp edx,dword ptr ds:[E000A0E0h] + E000481B: 75 0E jne E000482B + E000481D: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0004820: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E0004823: 3B 0D E4 A0 00 E0 cmp ecx,dword ptr ds:[E000A0E4h] + E0004829: 74 37 je E0004862 + E000482B: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E000482E: 8B 02 mov eax,dword ptr [edx] + E0004830: 3B 05 38 A1 00 E0 cmp eax,dword ptr ds:[E000A138h] + E0004836: 75 5D jne E0004895 + E0004838: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E000483B: 8B 51 04 mov edx,dword ptr [ecx+4] + E000483E: 3B 15 3C A1 00 E0 cmp edx,dword ptr ds:[E000A13Ch] + E0004844: 75 4F jne E0004895 + E0004846: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0004849: 8B 48 08 mov ecx,dword ptr [eax+8] + E000484C: 3B 0D 40 A1 00 E0 cmp ecx,dword ptr ds:[E000A140h] + E0004852: 75 41 jne E0004895 + E0004854: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0004857: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E000485A: 3B 05 44 A1 00 E0 cmp eax,dword ptr ds:[E000A144h] + E0004860: 75 33 jne E0004895 + E0004862: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004865: 8B 11 mov edx,dword ptr [ecx] + E0004867: 8B 45 08 mov eax,dword ptr [ebp+8] + E000486A: 50 push eax + E000486B: FF 52 04 call dword ptr [edx+4] + E000486E: 83 C4 04 add esp,4 + E0004871: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E0004875: 74 0B je E0004882 + E0004877: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000487A: 83 C1 04 add ecx,4 + E000487D: 89 4D FC mov dword ptr [ebp-4],ecx + E0004880: EB 07 jmp E0004889 + E0004882: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0004889: 8B 55 10 mov edx,dword ptr [ebp+10h] + E000488C: 8B 45 FC mov eax,dword ptr [ebp-4] + E000488F: 89 02 mov dword ptr [edx],eax + E0004891: 33 C0 xor eax,eax + E0004893: EB 05 jmp E000489A + E0004895: B8 00 00 00 80 mov eax,80000000h + E000489A: 8B E5 mov esp,ebp + E000489C: 5D pop ebp + E000489D: C3 ret +?FindFirst@CFolder@@UAAKPBGPAU_folderitem_t@@@Z (public: virtual unsigned long __cdecl CFolder::FindFirst(unsigned short const *,struct _folderitem_t *)): + E000489E: 55 push ebp + E000489F: 8B EC mov ebp,esp + E00048A1: 8B 45 08 mov eax,dword ptr [ebp+8] + E00048A4: 33 C9 xor ecx,ecx + E00048A6: 8A 48 0C mov cl,byte ptr [eax+0Ch] + E00048A9: 85 C9 test ecx,ecx + E00048AB: 75 16 jne E00048C3 + E00048AD: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00048B0: 83 E9 04 sub ecx,4 + E00048B3: 8B 55 08 mov edx,dword ptr [ebp+8] + E00048B6: 8B 42 FC mov eax,dword ptr [edx-4] + E00048B9: FF 50 0C call dword ptr [eax+0Ch] + E00048BC: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00048BF: C6 41 0C 01 mov byte ptr [ecx+0Ch],1 + E00048C3: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00048C6: 52 push edx + E00048C7: E8 D4 56 00 00 call E0009FA0 + E00048CC: 83 C4 04 add esp,4 + E00048CF: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E00048D2: 89 41 08 mov dword ptr [ecx+8],eax + E00048D5: 8B 55 10 mov edx,dword ptr [ebp+10h] + E00048D8: 8B 45 08 mov eax,dword ptr [ebp+8] + E00048DB: 8B 48 08 mov ecx,dword ptr [eax+8] + E00048DE: 89 4A 04 mov dword ptr [edx+4],ecx + E00048E1: 33 C0 xor eax,eax + E00048E3: 5D pop ebp + E00048E4: C3 ret +?FindNext@CFolder@@UAAKPAU_folderitem_t@@@Z (public: virtual unsigned long __cdecl CFolder::FindNext(struct _folderitem_t *)): + E00048E5: 55 push ebp + E00048E6: 8B EC mov ebp,esp + E00048E8: 51 push ecx + E00048E9: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00048EC: 8B 48 04 mov ecx,dword ptr [eax+4] + E00048EF: 89 4D FC mov dword ptr [ebp-4],ecx + E00048F2: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E00048F6: 75 0A jne E0004902 + E00048F8: B8 00 00 00 80 mov eax,80000000h + E00048FD: E9 B6 00 00 00 jmp E00049B8 + E0004902: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0004906: 0F 84 A7 00 00 00 je E00049B3 + E000490C: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E000490F: 8B 42 08 mov eax,dword ptr [edx+8] + E0004912: 50 push eax + E0004913: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004916: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0004919: 52 push edx + E000491A: E8 41 55 00 00 call E0009E60 + E000491F: 83 C4 08 add esp,8 + E0004922: 25 FF 00 00 00 and eax,0FFh + E0004927: 85 C0 test eax,eax + E0004929: 74 71 je E000499C + E000492B: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000492E: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004931: 8B 51 1C mov edx,dword ptr [ecx+1Ch] + E0004934: 89 50 04 mov dword ptr [eax+4],edx + E0004937: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000493A: 8B 48 10 mov ecx,dword ptr [eax+10h] + E000493D: 51 push ecx + E000493E: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004941: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0004944: 50 push eax + E0004945: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0004948: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E000494B: 52 push edx + E000494C: E8 43 56 00 00 call E0009F94 + E0004951: 83 C4 0C add esp,0Ch + E0004954: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0004957: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000495A: 8B 51 14 mov edx,dword ptr [ecx+14h] + E000495D: 89 50 14 mov dword ptr [eax+14h],edx + E0004960: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0004963: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004966: 8B 51 18 mov edx,dword ptr [ecx+18h] + E0004969: 89 50 18 mov dword ptr [eax+18h],edx + E000496C: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000496F: 83 38 28 cmp dword ptr [eax],28h + E0004972: 75 24 jne E0004998 + E0004974: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0004977: 8B 55 FC mov edx,dword ptr [ebp-4] + E000497A: 8B 42 1C mov eax,dword ptr [edx+1Ch] + E000497D: 89 41 1C mov dword ptr [ecx+1Ch],eax + E0004980: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0004983: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004986: 8B 42 24 mov eax,dword ptr [edx+24h] + E0004989: 89 41 24 mov dword ptr [ecx+24h],eax + E000498C: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E000498F: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004992: 8B 42 20 mov eax,dword ptr [edx+20h] + E0004995: 89 41 20 mov dword ptr [ecx+20h],eax + E0004998: 33 C0 xor eax,eax + E000499A: EB 1C jmp E00049B8 + E000499C: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000499F: 8B 51 1C mov edx,dword ptr [ecx+1Ch] + E00049A2: 89 55 FC mov dword ptr [ebp-4],edx + E00049A5: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00049A8: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00049AB: 89 48 04 mov dword ptr [eax+4],ecx + E00049AE: E9 4F FF FF FF jmp E0004902 + E00049B3: B8 00 00 00 80 mov eax,80000000h + E00049B8: 8B E5 mov esp,ebp + E00049BA: 5D pop ebp + E00049BB: C3 ret +?FindClose@CFolder@@UAAKPAU_folderitem_t@@@Z (public: virtual unsigned long __cdecl CFolder::FindClose(struct _folderitem_t *)): + E00049BC: 55 push ebp + E00049BD: 8B EC mov ebp,esp + E00049BF: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00049C2: 8B 48 08 mov ecx,dword ptr [eax+8] + E00049C5: 51 push ecx + E00049C6: E8 7B 55 00 00 call E0009F46 + E00049CB: 83 C4 04 add esp,4 + E00049CE: 33 C0 xor eax,eax + E00049D0: 5D pop ebp + E00049D1: C3 ret +?Open@CFolder@@UAAKPAU_folderitem_t@@PBG@Z (public: virtual unsigned long __cdecl CFolder::Open(struct _folderitem_t *,unsigned short const *)): + E00049D2: 55 push ebp + E00049D3: 8B EC mov ebp,esp + E00049D5: 81 EC 2C 02 00 00 sub esp,22Ch + E00049DB: 56 push esi + E00049DC: 57 push edi + E00049DD: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00049E0: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E00049E3: 51 push ecx + E00049E4: 68 90 B6 00 E0 push 0E000B690h + E00049E9: E8 D6 00 00 00 call E0004AC4 + E00049EE: 83 C4 08 add esp,8 + E00049F1: B9 0A 00 00 00 mov ecx,0Ah + E00049F6: 33 C0 xor eax,eax + E00049F8: 8D 7D D8 lea edi,dword ptr [ebp-28h] + E00049FB: F3 AB rep stos dword ptr es:[edi] + E00049FD: C7 45 D8 28 00 00 mov dword ptr [ebp-28h],28h + 00 + E0004A04: 8D 95 D8 FD FF FF lea edx,dword ptr [ebp+FFFFFDD8h] + E0004A0A: 89 55 E4 mov dword ptr [ebp-1Ch],edx + E0004A0D: C7 45 E8 00 01 00 mov dword ptr [ebp-18h],100h + 00 + E0004A14: 8D 45 D8 lea eax,dword ptr [ebp-28h] + E0004A17: 50 push eax + E0004A18: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0004A1B: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0004A1E: 52 push edx + E0004A1F: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004A22: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004A25: 8B 11 mov edx,dword ptr [ecx] + E0004A27: 50 push eax + E0004A28: FF 52 0C call dword ptr [edx+0Ch] + E0004A2B: 83 C4 0C add esp,0Ch + E0004A2E: 25 00 00 00 80 and eax,80000000h + E0004A33: 3D 00 00 00 80 cmp eax,80000000h + E0004A38: 74 1F je E0004A59 + E0004A3A: 8D 45 D8 lea eax,dword ptr [ebp-28h] + E0004A3D: 50 push eax + E0004A3E: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004A41: 8B 55 08 mov edx,dword ptr [ebp+8] + E0004A44: 8B 02 mov eax,dword ptr [edx] + E0004A46: 51 push ecx + E0004A47: FF 50 10 call dword ptr [eax+10h] + E0004A4A: 83 C4 08 add esp,8 + E0004A4D: 25 00 00 00 80 and eax,80000000h + E0004A52: 3D 00 00 00 80 cmp eax,80000000h + E0004A57: 75 07 jne E0004A60 + E0004A59: B8 00 00 00 80 mov eax,80000000h + E0004A5E: EB 5E jmp E0004ABE + E0004A60: 8D 4D D8 lea ecx,dword ptr [ebp-28h] + E0004A63: 51 push ecx + E0004A64: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004A67: 83 E9 04 sub ecx,4 + E0004A6A: 8B 55 08 mov edx,dword ptr [ebp+8] + E0004A6D: 8B 42 FC mov eax,dword ptr [edx-4] + E0004A70: FF 50 10 call dword ptr [eax+10h] + E0004A73: 89 85 D4 FD FF FF mov dword ptr [ebp+FFFFFDD4h],eax + E0004A79: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0004A7C: 83 39 28 cmp dword ptr [ecx],28h + E0004A7F: 75 0F jne E0004A90 + E0004A81: B9 0A 00 00 00 mov ecx,0Ah + E0004A86: 8D 75 D8 lea esi,dword ptr [ebp-28h] + E0004A89: 8B 7D 0C mov edi,dword ptr [ebp+0Ch] + E0004A8C: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E0004A8E: EB 0D jmp E0004A9D + E0004A90: B9 07 00 00 00 mov ecx,7 + E0004A95: 8D 75 D8 lea esi,dword ptr [ebp-28h] + E0004A98: 8B 7D 0C mov edi,dword ptr [ebp+0Ch] + E0004A9B: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E0004A9D: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0004AA0: 8B 85 D4 FD FF FF mov eax,dword ptr [ebp+FFFFFDD4h] + E0004AA6: 89 42 04 mov dword ptr [edx+4],eax + E0004AA9: 8D 4D D8 lea ecx,dword ptr [ebp-28h] + E0004AAC: 51 push ecx + E0004AAD: 8B 55 08 mov edx,dword ptr [ebp+8] + E0004AB0: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004AB3: 8B 08 mov ecx,dword ptr [eax] + E0004AB5: 52 push edx + E0004AB6: FF 51 14 call dword ptr [ecx+14h] + E0004AB9: 83 C4 08 add esp,8 + E0004ABC: 33 C0 xor eax,eax + E0004ABE: 5F pop edi + E0004ABF: 5E pop esi + E0004AC0: 8B E5 mov esp,ebp + E0004AC2: 5D pop ebp + E0004AC3: C3 ret +?TRACE@@YAHZZ (int __cdecl TRACE(...)): + E0004AC4: 55 push ebp + E0004AC5: 8B EC mov ebp,esp + E0004AC7: 33 C0 xor eax,eax + E0004AC9: 5D pop ebp + E0004ACA: C3 ret +?Mount@CFolder@@UAAKPBGPAUIUnknown@@@Z (public: virtual unsigned long __cdecl CFolder::Mount(unsigned short const *,struct IUnknown *)): + E0004ACB: 55 push ebp + E0004ACC: 8B EC mov ebp,esp + E0004ACE: 83 EC 20 sub esp,20h + E0004AD1: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004AD4: 8B 48 08 mov ecx,dword ptr [eax+8] + E0004AD7: 89 4D FC mov dword ptr [ebp-4],ecx + E0004ADA: EB 09 jmp E0004AE5 + E0004ADC: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004ADF: 8B 42 1C mov eax,dword ptr [edx+1Ch] + E0004AE2: 89 45 FC mov dword ptr [ebp-4],eax + E0004AE5: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0004AE9: 74 39 je E0004B24 + E0004AEB: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004AEE: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0004AF1: 52 push edx + E0004AF2: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0004AF5: 50 push eax + E0004AF6: E8 39 54 00 00 call E0009F34 + E0004AFB: 83 C4 08 add esp,8 + E0004AFE: 85 C0 test eax,eax + E0004B00: 75 20 jne E0004B22 + E0004B02: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004B05: 83 79 24 00 cmp dword ptr [ecx+24h],0 + E0004B09: 74 15 je E0004B20 + E0004B0B: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004B0E: 8B 42 24 mov eax,dword ptr [edx+24h] + E0004B11: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004B14: 8B 51 24 mov edx,dword ptr [ecx+24h] + E0004B17: 8B 0A mov ecx,dword ptr [edx] + E0004B19: 50 push eax + E0004B1A: FF 51 08 call dword ptr [ecx+8] + E0004B1D: 83 C4 04 add esp,4 + E0004B20: EB 02 jmp E0004B24 + E0004B22: EB B8 jmp E0004ADC + E0004B24: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0004B28: 75 3B jne E0004B65 + E0004B2A: 6A 28 push 28h + E0004B2C: E8 45 54 00 00 call E0009F76 + E0004B31: 83 C4 04 add esp,4 + E0004B34: 89 45 FC mov dword ptr [ebp-4],eax + E0004B37: 33 D2 xor edx,edx + E0004B39: 8B 45 FC mov eax,dword ptr [ebp-4] + E0004B3C: 89 10 mov dword ptr [eax],edx + E0004B3E: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004B41: 8B 55 08 mov edx,dword ptr [ebp+8] + E0004B44: 8B 42 08 mov eax,dword ptr [edx+8] + E0004B47: 89 41 1C mov dword ptr [ecx+1Ch],eax + E0004B4A: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004B4D: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004B50: 89 51 08 mov dword ptr [ecx+8],edx + E0004B53: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0004B56: 50 push eax + E0004B57: E8 44 54 00 00 call E0009FA0 + E0004B5C: 83 C4 04 add esp,4 + E0004B5F: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004B62: 89 41 0C mov dword ptr [ecx+0Ch],eax + E0004B65: C7 45 E0 1C 00 00 mov dword ptr [ebp-20h],1Ch + 00 + E0004B6C: C7 45 EC 00 00 00 mov dword ptr [ebp-14h],0 + 00 + E0004B73: C7 45 F0 00 00 00 mov dword ptr [ebp-10h],0 + 00 + E0004B7A: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E0004B81: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E0004B88: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004B8B: C7 02 28 00 00 00 mov dword ptr [edx],28h + E0004B91: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0004B94: 80 CC 20 or ah,20h + E0004B97: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004B9A: 89 41 14 mov dword ptr [ecx+14h],eax + E0004B9D: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004BA0: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0004BA3: 89 42 18 mov dword ptr [edx+18h],eax + E0004BA6: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004BA9: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0004BAC: 89 51 24 mov dword ptr [ecx+24h],edx + E0004BAF: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0004BB2: 8B 08 mov ecx,dword ptr [eax] + E0004BB4: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0004BB7: 52 push edx + E0004BB8: FF 51 04 call dword ptr [ecx+4] + E0004BBB: 83 C4 04 add esp,4 + E0004BBE: 33 C0 xor eax,eax + E0004BC0: 8B E5 mov esp,ebp + E0004BC2: 5D pop ebp + E0004BC3: C3 ret +?ScanDir@CFolder@@MAEXXZ (protected: virtual void __thiscall CFolder::ScanDir(void)): + E0004BC4: 55 push ebp + E0004BC5: 8B EC mov ebp,esp + E0004BC7: 51 push ecx + E0004BC8: 89 4D FC mov dword ptr [ebp-4],ecx + E0004BCB: 8B E5 mov esp,ebp + E0004BCD: 5D pop ebp + E0004BCE: C3 ret +?DoOpen@CFolder@@MAEPAUIUnknown@@PAUfolderitem_ext_t@@@Z (protected: virtual struct IUnknown * __thiscall CFolder::DoOpen(struct folderitem_ext_t *)): + E0004BCF: 55 push ebp + E0004BD0: 8B EC mov ebp,esp + E0004BD2: 51 push ecx + E0004BD3: 89 4D FC mov dword ptr [ebp-4],ecx + E0004BD6: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004BD9: 83 78 24 00 cmp dword ptr [eax+24h],0 + E0004BDD: 74 1D je E0004BFC + E0004BDF: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004BE2: 8B 51 24 mov edx,dword ptr [ecx+24h] + E0004BE5: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004BE8: 8B 48 24 mov ecx,dword ptr [eax+24h] + E0004BEB: 8B 01 mov eax,dword ptr [ecx] + E0004BED: 52 push edx + E0004BEE: FF 50 04 call dword ptr [eax+4] + E0004BF1: 83 C4 04 add esp,4 + E0004BF4: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004BF7: 8B 41 24 mov eax,dword ptr [ecx+24h] + E0004BFA: EB 02 jmp E0004BFE + E0004BFC: 33 C0 xor eax,eax + E0004BFE: 8B E5 mov esp,ebp + E0004C00: 5D pop ebp + E0004C01: C2 04 00 ret 4 + E0004C04: CC int 3 + E0004C05: CC int 3 + E0004C06: CC int 3 + E0004C07: CC int 3 + E0004C08: CC int 3 + E0004C09: CC int 3 + E0004C0A: CC int 3 + E0004C0B: CC int 3 + E0004C0C: CC int 3 + E0004C0D: CC int 3 + E0004C0E: CC int 3 + E0004C0F: CC int 3 +?AddRef@CFolder@@UAAKXZ (public: virtual unsigned long __cdecl CFolder::AddRef(void)): + E0004C10: 55 push ebp + E0004C11: 8B EC mov ebp,esp + E0004C13: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004C16: 8B 48 08 mov ecx,dword ptr [eax+8] + E0004C19: 83 C1 01 add ecx,1 + E0004C1C: 8B 55 08 mov edx,dword ptr [ebp+8] + E0004C1F: 89 4A 08 mov dword ptr [edx+8],ecx + E0004C22: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004C25: 8B 40 08 mov eax,dword ptr [eax+8] + E0004C28: 5D pop ebp + E0004C29: C3 ret + E0004C2A: CC int 3 + E0004C2B: CC int 3 + E0004C2C: CC int 3 + E0004C2D: CC int 3 + E0004C2E: CC int 3 + E0004C2F: CC int 3 +?Release@CFolder@@UAAKXZ (public: virtual unsigned long __cdecl CFolder::Release(void)): + E0004C30: 55 push ebp + E0004C31: 8B EC mov ebp,esp + E0004C33: 83 EC 0C sub esp,0Ch + E0004C36: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004C39: 83 78 08 00 cmp dword ptr [eax+8],0 + E0004C3D: 75 45 jne E0004C84 + E0004C3F: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004C42: 89 4D F8 mov dword ptr [ebp-8],ecx + E0004C45: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0004C48: 89 55 FC mov dword ptr [ebp-4],edx + E0004C4B: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0004C4F: 74 28 je E0004C79 + E0004C51: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004C54: E8 0C FB FF FF call E0004765 + E0004C59: B8 01 00 00 00 mov eax,1 + E0004C5E: 83 E0 01 and eax,1 + E0004C61: 85 C0 test eax,eax + E0004C63: 74 0C je E0004C71 + E0004C65: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004C68: 51 push ecx + E0004C69: E8 FC 52 00 00 call E0009F6A + E0004C6E: 83 C4 04 add esp,4 + E0004C71: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004C74: 89 55 F4 mov dword ptr [ebp-0Ch],edx + E0004C77: EB 07 jmp E0004C80 + E0004C79: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E0004C80: 33 C0 xor eax,eax + E0004C82: EB 15 jmp E0004C99 + E0004C84: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004C87: 8B 40 08 mov eax,dword ptr [eax+8] + E0004C8A: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004C8D: 8B 51 08 mov edx,dword ptr [ecx+8] + E0004C90: 83 EA 01 sub edx,1 + E0004C93: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004C96: 89 51 08 mov dword ptr [ecx+8],edx + E0004C99: 8B E5 mov esp,ebp + E0004C9B: 5D pop ebp + E0004C9C: C3 ret + E0004C9D: CC int 3 + E0004C9E: CC int 3 + E0004C9F: CC int 3 +?QueryInterface@CFolder@@W3AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CFolder::QueryInterface`adjustor{4}' (struct _GUID const &,void * *)): + E0004CA0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0004CA5: E9 46 FB FF FF jmp E00047F0 + E0004CAA: CC int 3 + E0004CAB: CC int 3 + E0004CAC: CC int 3 + E0004CAD: CC int 3 + E0004CAE: CC int 3 + E0004CAF: CC int 3 +?AddRef@CFolder@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CFolder::AddRef`adjustor{4}' (void)): + E0004CB0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0004CB5: E9 56 FF FF FF jmp E0004C10 + E0004CBA: CC int 3 + E0004CBB: CC int 3 + E0004CBC: CC int 3 + E0004CBD: CC int 3 + E0004CBE: CC int 3 + E0004CBF: CC int 3 +?Release@CFolder@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CFolder::Release`adjustor{4}' (void)): + E0004CC0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0004CC5: E9 66 FF FF FF jmp E0004C30 + E0004CCA: CC int 3 + E0004CCB: CC int 3 + E0004CCC: CC int 3 + E0004CCD: CC int 3 + E0004CCE: CC int 3 + E0004CCF: CC int 3 +??0CKeyboard@@QAE@XZ (public: __thiscall CKeyboard::CKeyboard(void)): + E0004CD0: 55 push ebp + E0004CD1: 8B EC mov ebp,esp + E0004CD3: 83 EC 0C sub esp,0Ch + E0004CD6: 89 4D F4 mov dword ptr [ebp-0Ch],ecx + E0004CD9: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0004CDC: C7 00 C8 A0 00 E0 mov dword ptr [eax],0E000A0C8h + E0004CE2: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0004CE5: 83 C1 04 add ecx,4 + E0004CE8: 89 4D FC mov dword ptr [ebp-4],ecx + E0004CEB: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004CEE: C7 02 B0 A0 00 E0 mov dword ptr [edx],0E000A0B0h + E0004CF4: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0004CF7: 83 C0 08 add eax,8 + E0004CFA: 89 45 F8 mov dword ptr [ebp-8],eax + E0004CFD: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0004D00: C7 01 10 A2 00 E0 mov dword ptr [ecx],0E000A210h + E0004D06: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0004D09: C7 02 28 A6 00 E0 mov dword ptr [edx],0E000A628h + E0004D0F: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0004D12: C7 40 04 10 A6 00 mov dword ptr [eax+4],0E000A610h + E0 + E0004D19: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0004D1C: C7 41 08 E8 A5 00 mov dword ptr [ecx+8],0E000A5E8h + E0 + E0004D23: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0004D26: C7 42 0C 00 00 00 mov dword ptr [edx+0Ch],0 + 00 + E0004D2D: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0004D30: C7 40 10 00 00 00 mov dword ptr [eax+10h],0 + 00 + E0004D37: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0004D3A: 83 C1 14 add ecx,14h + E0004D3D: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0004D40: 89 4A 28 mov dword ptr [edx+28h],ecx + E0004D43: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0004D46: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0004D49: 8B 51 28 mov edx,dword ptr [ecx+28h] + E0004D4C: 89 50 24 mov dword ptr [eax+24h],edx + E0004D4F: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0004D52: C7 40 30 00 00 00 mov dword ptr [eax+30h],0 + 00 + E0004D59: 68 E0 B6 00 E0 push 0E000B6E0h + E0004D5E: 68 F5 00 00 00 push 0F5h + E0004D63: 6A 60 push 60h + E0004D65: E8 D5 01 00 00 call E0004F3F + E0004D6A: 83 C4 0C add esp,0Ch + E0004D6D: 6A 60 push 60h + E0004D6F: 6A 64 push 64h + E0004D71: E8 FB 00 00 00 call E0004E71 + E0004D76: 83 C4 08 add esp,8 + E0004D79: 6A 07 push 7 + E0004D7B: 6A 60 push 60h + E0004D7D: E8 EF 00 00 00 call E0004E71 + E0004D82: 83 C4 08 add esp,8 + E0004D85: 68 E4 B6 00 E0 push 0E000B6E4h + E0004D8A: 68 F2 00 00 00 push 0F2h + E0004D8F: 6A 60 push 60h + E0004D91: E8 A9 01 00 00 call E0004F3F + E0004D96: 83 C4 0C add esp,0Ch + E0004D99: E8 2D 01 00 00 call E0004ECB + E0004D9E: 25 FF 00 00 00 and eax,0FFh + E0004DA3: 3D AB 00 00 00 cmp eax,0ABh + E0004DA8: 75 53 jne E0004DFD + E0004DAA: E8 1C 01 00 00 call E0004ECB + E0004DAF: 25 FF 00 00 00 and eax,0FFh + E0004DB4: 3D 83 00 00 00 cmp eax,83h + E0004DB9: 75 42 jne E0004DFD + E0004DBB: 68 E8 B6 00 E0 push 0E000B6E8h + E0004DC0: 68 F0 00 00 00 push 0F0h + E0004DC5: 6A 60 push 60h + E0004DC7: E8 73 01 00 00 call E0004F3F + E0004DCC: 83 C4 0C add esp,0Ch + E0004DCF: 68 EC B6 00 E0 push 0E000B6ECh + E0004DD4: 6A 01 push 1 + E0004DD6: 6A 60 push 60h + E0004DD8: E8 62 01 00 00 call E0004F3F + E0004DDD: 83 C4 0C add esp,0Ch + E0004DE0: 68 F0 B6 00 E0 push 0E000B6F0h + E0004DE5: 68 FA 00 00 00 push 0FAh + E0004DEA: 6A 60 push 60h + E0004DEC: E8 4E 01 00 00 call E0004F3F + E0004DF1: 83 C4 0C add esp,0Ch + E0004DF4: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0004DF7: C6 41 34 01 mov byte ptr [ecx+34h],1 + E0004DFB: EB 07 jmp E0004E04 + E0004DFD: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0004E00: C6 42 34 00 mov byte ptr [edx+34h],0 + E0004E04: 68 F4 B6 00 E0 push 0E000B6F4h + E0004E09: 68 F3 00 00 00 push 0F3h + E0004E0E: 6A 60 push 60h + E0004E10: E8 2A 01 00 00 call E0004F3F + E0004E15: 83 C4 0C add esp,0Ch + E0004E18: 68 F8 B6 00 E0 push 0E000B6F8h + E0004E1D: 6A 00 push 0 + E0004E1F: 6A 60 push 60h + E0004E21: E8 19 01 00 00 call E0004F3F + E0004E26: 83 C4 0C add esp,0Ch + E0004E29: 68 FC B6 00 E0 push 0E000B6FCh + E0004E2E: 68 F4 00 00 00 push 0F4h + E0004E33: 6A 60 push 60h + E0004E35: E8 05 01 00 00 call E0004F3F + E0004E3A: 83 C4 0C add esp,0Ch + E0004E3D: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0004E40: 50 push eax + E0004E41: 68 57 4E 00 E0 push 0E0004E57h + E0004E46: 6A 01 push 1 + E0004E48: E8 E1 50 00 00 call E0009F2E + E0004E4D: 83 C4 0C add esp,0Ch + E0004E50: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0004E53: 8B E5 mov esp,ebp + E0004E55: 5D pop ebp + E0004E56: C3 ret +?Isr@CKeyboard@@KAXPAV1@H@Z (protected: static void __cdecl CKeyboard::Isr(class CKeyboard *,int)): + E0004E57: 55 push ebp + E0004E58: 8B EC mov ebp,esp + E0004E5A: 53 push ebx + E0004E5B: 56 push esi + E0004E5C: 57 push edi + E0004E5D: FB sti + E0004E5E: E8 68 00 00 00 call E0004ECB + E0004E63: 50 push eax + E0004E64: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004E67: E8 41 06 00 00 call E00054AD + E0004E6C: 5F pop edi + E0004E6D: 5E pop esi + E0004E6E: 5B pop ebx + E0004E6F: 5D pop ebp + E0004E70: C3 ret +?HwWrite@CKeyboard@@SAXGE@Z (public: static void __cdecl CKeyboard::HwWrite(unsigned short,unsigned char)): + E0004E71: 55 push ebp + E0004E72: 8B EC mov ebp,esp + E0004E74: 83 EC 0C sub esp,0Ch + E0004E77: 53 push ebx + E0004E78: 56 push esi + E0004E79: 57 push edi + E0004E7A: C7 45 F8 20 A1 07 mov dword ptr [ebp-8],7A120h + 00 + E0004E81: EB 09 jmp E0004E8C + E0004E83: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0004E86: 83 E8 01 sub eax,1 + E0004E89: 89 45 F8 mov dword ptr [ebp-8],eax + E0004E8C: 83 7D F8 00 cmp dword ptr [ebp-8],0 + E0004E90: 74 24 je E0004EB6 + E0004E92: 66 C7 45 F4 64 00 mov word ptr [ebp-0Ch],64h + E0004E98: 33 C0 xor eax,eax + E0004E9A: 66 8B 55 F4 mov dx,word ptr [ebp-0Ch] + E0004E9E: EC in al,dx + E0004E9F: 88 45 FC mov byte ptr [ebp-4],al + E0004EA2: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004EA5: 81 E1 FF 00 00 00 and ecx,0FFh + E0004EAB: 83 E1 02 and ecx,2 + E0004EAE: 85 C9 test ecx,ecx + E0004EB0: 75 02 jne E0004EB4 + E0004EB2: EB 02 jmp E0004EB6 + E0004EB4: EB CD jmp E0004E83 + E0004EB6: 83 7D F8 00 cmp dword ptr [ebp-8],0 + E0004EBA: 74 08 je E0004EC4 + E0004EBC: 66 8B 55 08 mov dx,word ptr [ebp+8] + E0004EC0: 8A 45 0C mov al,byte ptr [ebp+0Ch] + E0004EC3: EE out dx,al + E0004EC4: 5F pop edi + E0004EC5: 5E pop esi + E0004EC6: 5B pop ebx + E0004EC7: 8B E5 mov esp,ebp + E0004EC9: 5D pop ebp + E0004ECA: C3 ret +?HwRead@CKeyboard@@SAEXZ (public: static unsigned char __cdecl CKeyboard::HwRead(void)): + E0004ECB: 55 push ebp + E0004ECC: 8B EC mov ebp,esp + E0004ECE: 83 EC 14 sub esp,14h + E0004ED1: 53 push ebx + E0004ED2: 56 push esi + E0004ED3: 57 push edi + E0004ED4: C7 45 F4 50 C3 00 mov dword ptr [ebp-0Ch],0C350h + 00 + E0004EDB: EB 09 jmp E0004EE6 + E0004EDD: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0004EE0: 83 E8 01 sub eax,1 + E0004EE3: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0004EE6: 83 7D F4 00 cmp dword ptr [ebp-0Ch],0 + E0004EEA: 74 4A je E0004F36 + E0004EEC: 66 C7 45 F0 64 00 mov word ptr [ebp-10h],64h + E0004EF2: 33 C0 xor eax,eax + E0004EF4: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E0004EF8: EC in al,dx + E0004EF9: 88 45 FC mov byte ptr [ebp-4],al + E0004EFC: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004EFF: 81 E1 FF 00 00 00 and ecx,0FFh + E0004F05: 83 E1 01 and ecx,1 + E0004F08: 85 C9 test ecx,ecx + E0004F0A: 74 28 je E0004F34 + E0004F0C: 66 C7 45 EC 60 00 mov word ptr [ebp-14h],60h + E0004F12: 33 C0 xor eax,eax + E0004F14: 66 8B 55 EC mov dx,word ptr [ebp-14h] + E0004F18: EC in al,dx + E0004F19: 88 45 F8 mov byte ptr [ebp-8],al + E0004F1C: 8B 55 FC mov edx,dword ptr [ebp-4] + E0004F1F: 81 E2 FF 00 00 00 and edx,0FFh + E0004F25: 81 E2 C0 00 00 00 and edx,0C0h + E0004F2B: 85 D2 test edx,edx + E0004F2D: 75 05 jne E0004F34 + E0004F2F: 8A 45 F8 mov al,byte ptr [ebp-8] + E0004F32: EB 04 jmp E0004F38 + E0004F34: EB A7 jmp E0004EDD + E0004F36: 0C FF or al,0FFh + E0004F38: 5F pop edi + E0004F39: 5E pop esi + E0004F3A: 5B pop ebx + E0004F3B: 8B E5 mov esp,ebp + E0004F3D: 5D pop ebp + E0004F3E: C3 ret +?HwWriteRead@CKeyboard@@SAEGEPBD@Z (public: static unsigned char __cdecl CKeyboard::HwWriteRead(unsigned short,unsigned char,char const *)): + E0004F3F: 55 push ebp + E0004F40: 8B EC mov ebp,esp + E0004F42: 51 push ecx + E0004F43: 8A 45 0C mov al,byte ptr [ebp+0Ch] + E0004F46: 50 push eax + E0004F47: 66 8B 4D 08 mov cx,word ptr [ebp+8] + E0004F4B: 51 push ecx + E0004F4C: E8 20 FF FF FF call E0004E71 + E0004F51: 83 C4 08 add esp,8 + E0004F54: EB 09 jmp E0004F5F + E0004F56: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0004F59: 83 C2 01 add edx,1 + E0004F5C: 89 55 10 mov dword ptr [ebp+10h],edx + E0004F5F: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0004F62: 0F BE 08 movsx ecx,byte ptr [eax] + E0004F65: 85 C9 test ecx,ecx + E0004F67: 74 38 je E0004FA1 + E0004F69: E8 5D FF FF FF call E0004ECB + E0004F6E: 25 FF 00 00 00 and eax,0FFh + E0004F73: 89 45 FC mov dword ptr [ebp-4],eax + E0004F76: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0004F79: 33 C0 xor eax,eax + E0004F7B: 8A 02 mov al,byte ptr [edx] + E0004F7D: 3B 45 FC cmp eax,dword ptr [ebp-4] + E0004F80: 74 1D je E0004F9F + E0004F82: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0004F85: 51 push ecx + E0004F86: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0004F89: 0F BE 02 movsx eax,byte ptr [edx] + E0004F8C: 50 push eax + E0004F8D: 68 00 B7 00 E0 push 0E000B700h + E0004F92: E8 79 4F 00 00 call E0009F10 + E0004F97: 83 C4 0C add esp,0Ch + E0004F9A: 8A 45 FC mov al,byte ptr [ebp-4] + E0004F9D: EB 04 jmp E0004FA3 + E0004F9F: EB B5 jmp E0004F56 + E0004FA1: 32 C0 xor al,al + E0004FA3: 8B E5 mov esp,ebp + E0004FA5: 5D pop ebp + E0004FA6: C3 ret +?ScancodeToKey@CKeyboard@@IAEIE@Z (protected: unsigned int __thiscall CKeyboard::ScancodeToKey(unsigned char)): + E0004FA7: 55 push ebp + E0004FA8: 8B EC mov ebp,esp + E0004FAA: 83 EC 18 sub esp,18h + E0004FAD: 89 4D EC mov dword ptr [ebp-14h],ecx + E0004FB0: 8B 45 08 mov eax,dword ptr [ebp+8] + E0004FB3: 25 FF 00 00 00 and eax,0FFh + E0004FB8: 25 80 00 00 00 and eax,80h + E0004FBD: F7 D8 neg eax + E0004FBF: 1B C0 sbb eax,eax + E0004FC1: 40 inc eax + E0004FC2: 88 45 FC mov byte ptr [ebp-4],al + E0004FC5: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0004FC8: 81 E1 FF 00 00 00 and ecx,0FFh + E0004FCE: 80 E1 7F and cl,7Fh + E0004FD1: 88 4D F0 mov byte ptr [ebp-10h],cl + E0004FD4: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E0004FDB: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0004FDE: 81 E2 FF 00 00 00 and edx,0FFh + E0004FE4: 89 55 E8 mov dword ptr [ebp-18h],edx + E0004FE7: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0004FEA: 83 E8 1D sub eax,1Dh + E0004FED: 89 45 E8 mov dword ptr [ebp-18h],eax + E0004FF0: 81 7D E8 E2 00 00 cmp dword ptr [ebp-18h],0E2h + 00 + E0004FF7: 0F 87 F1 01 00 00 ja E00051EE + E0004FFD: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E0005000: 33 C9 xor ecx,ecx + E0005002: 8A 8A A2 53 00 E0 mov cl,byte ptr [edx+E00053A2h] + E0005008: FF 24 8D 7E 53 00 jmp dword ptr [ecx*4+E000537Eh] + E0 + E000500F: 8B 45 FC mov eax,dword ptr [ebp-4] + E0005012: 25 FF 00 00 00 and eax,0FFh + E0005017: 85 C0 test eax,eax + E0005019: 74 14 je E000502F + E000501B: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E000501E: 8B 51 10 mov edx,dword ptr [ecx+10h] + E0005021: 81 CA 00 00 40 00 or edx,400000h + E0005027: 8B 45 EC mov eax,dword ptr [ebp-14h] + E000502A: 89 50 10 mov dword ptr [eax+10h],edx + E000502D: EB 12 jmp E0005041 + E000502F: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0005032: 8B 51 10 mov edx,dword ptr [ecx+10h] + E0005035: 81 E2 FF FF BF FF and edx,0FFBFFFFFh + E000503B: 8B 45 EC mov eax,dword ptr [ebp-14h] + E000503E: 89 50 10 mov dword ptr [eax+10h],edx + E0005041: E9 18 03 00 00 jmp E000535E + E0005046: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0005049: 81 E1 FF 00 00 00 and ecx,0FFh + E000504F: 85 C9 test ecx,ecx + E0005051: 74 1A je E000506D + E0005053: 8B 55 EC mov edx,dword ptr [ebp-14h] + E0005056: 8B 42 10 mov eax,dword ptr [edx+10h] + E0005059: 25 00 00 20 00 and eax,200000h + E000505E: 85 C0 test eax,eax + E0005060: 75 0B jne E000506D + E0005062: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0005065: 66 C7 41 2C 00 00 mov word ptr [ecx+2Ch],0 + E000506B: EB 29 jmp E0005096 + E000506D: 8B 55 FC mov edx,dword ptr [ebp-4] + E0005070: 81 E2 FF 00 00 00 and edx,0FFh + E0005076: 85 D2 test edx,edx + E0005078: 75 1C jne E0005096 + E000507A: 8B 45 EC mov eax,dword ptr [ebp-14h] + E000507D: 8B 48 10 mov ecx,dword ptr [eax+10h] + E0005080: 81 E1 00 00 20 00 and ecx,200000h + E0005086: 85 C9 test ecx,ecx + E0005088: 74 0C je E0005096 + E000508A: 8B 55 EC mov edx,dword ptr [ebp-14h] + E000508D: 33 C0 xor eax,eax + E000508F: 66 8B 42 2C mov ax,word ptr [edx+2Ch] + E0005093: 89 45 F8 mov dword ptr [ebp-8],eax + E0005096: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0005099: 81 E1 FF 00 00 00 and ecx,0FFh + E000509F: 85 C9 test ecx,ecx + E00050A1: 74 13 je E00050B6 + E00050A3: 8B 55 EC mov edx,dword ptr [ebp-14h] + E00050A6: 8B 42 10 mov eax,dword ptr [edx+10h] + E00050A9: 0D 00 00 20 00 or eax,200000h + E00050AE: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E00050B1: 89 41 10 mov dword ptr [ecx+10h],eax + E00050B4: EB 11 jmp E00050C7 + E00050B6: 8B 55 EC mov edx,dword ptr [ebp-14h] + E00050B9: 8B 42 10 mov eax,dword ptr [edx+10h] + E00050BC: 25 FF FF DF FF and eax,0FFDFFFFFh + E00050C1: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E00050C4: 89 41 10 mov dword ptr [ecx+10h],eax + E00050C7: E9 92 02 00 00 jmp E000535E + E00050CC: 8B 55 FC mov edx,dword ptr [ebp-4] + E00050CF: 81 E2 FF 00 00 00 and edx,0FFh + E00050D5: 85 D2 test edx,edx + E00050D7: 74 14 je E00050ED + E00050D9: 8B 45 EC mov eax,dword ptr [ebp-14h] + E00050DC: 8B 48 10 mov ecx,dword ptr [eax+10h] + E00050DF: 81 C9 00 00 80 00 or ecx,800000h + E00050E5: 8B 55 EC mov edx,dword ptr [ebp-14h] + E00050E8: 89 4A 10 mov dword ptr [edx+10h],ecx + E00050EB: EB 12 jmp E00050FF + E00050ED: 8B 45 EC mov eax,dword ptr [ebp-14h] + E00050F0: 8B 48 10 mov ecx,dword ptr [eax+10h] + E00050F3: 81 E1 FF FF 7F FF and ecx,0FF7FFFFFh + E00050F9: 8B 55 EC mov edx,dword ptr [ebp-14h] + E00050FC: 89 4A 10 mov dword ptr [edx+10h],ecx + E00050FF: E9 5A 02 00 00 jmp E000535E + E0005104: 8B 45 FC mov eax,dword ptr [ebp-4] + E0005107: 25 FF 00 00 00 and eax,0FFh + E000510C: 85 C0 test eax,eax + E000510E: 75 17 jne E0005127 + E0005110: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0005113: 8B 51 10 mov edx,dword ptr [ecx+10h] + E0005116: 81 F2 00 00 00 02 xor edx,2000000h + E000511C: 8B 45 EC mov eax,dword ptr [ebp-14h] + E000511F: 89 50 10 mov dword ptr [eax+10h],edx + E0005122: E9 4C 02 00 00 jmp E0005373 + E0005127: E9 32 02 00 00 jmp E000535E + E000512C: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000512F: 81 E1 FF 00 00 00 and ecx,0FFh + E0005135: 85 C9 test ecx,ecx + E0005137: 75 16 jne E000514F + E0005139: 8B 55 EC mov edx,dword ptr [ebp-14h] + E000513C: 8B 42 10 mov eax,dword ptr [edx+10h] + E000513F: 35 00 00 00 01 xor eax,1000000h + E0005144: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0005147: 89 41 10 mov dword ptr [ecx+10h],eax + E000514A: E9 1F 02 00 00 jmp E000536E + E000514F: E9 0A 02 00 00 jmp E000535E + E0005154: 8B 55 FC mov edx,dword ptr [ebp-4] + E0005157: 81 E2 FF 00 00 00 and edx,0FFh + E000515D: 85 D2 test edx,edx + E000515F: 75 17 jne E0005178 + E0005161: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0005164: 8B 48 10 mov ecx,dword ptr [eax+10h] + E0005167: 81 F1 00 00 00 04 xor ecx,4000000h + E000516D: 8B 55 EC mov edx,dword ptr [ebp-14h] + E0005170: 89 4A 10 mov dword ptr [edx+10h],ecx + E0005173: E9 F1 01 00 00 jmp E0005369 + E0005178: E9 E1 01 00 00 jmp E000535E + E000517D: 68 ED 00 00 00 push 0EDh + E0005182: 6A 60 push 60h + E0005184: E8 E8 FC FF FF call E0004E71 + E0005189: 83 C4 08 add esp,8 + E000518C: C6 45 F4 00 mov byte ptr [ebp-0Ch],0 + E0005190: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0005193: 8B 48 10 mov ecx,dword ptr [eax+10h] + E0005196: 81 E1 00 00 00 04 and ecx,4000000h + E000519C: 85 C9 test ecx,ecx + E000519E: 74 09 je E00051A9 + E00051A0: 8A 55 F4 mov dl,byte ptr [ebp-0Ch] + E00051A3: 80 CA 01 or dl,1 + E00051A6: 88 55 F4 mov byte ptr [ebp-0Ch],dl + E00051A9: 8B 45 EC mov eax,dword ptr [ebp-14h] + E00051AC: 8B 48 10 mov ecx,dword ptr [eax+10h] + E00051AF: 81 E1 00 00 00 02 and ecx,2000000h + E00051B5: 85 C9 test ecx,ecx + E00051B7: 74 09 je E00051C2 + E00051B9: 8A 55 F4 mov dl,byte ptr [ebp-0Ch] + E00051BC: 80 CA 02 or dl,2 + E00051BF: 88 55 F4 mov byte ptr [ebp-0Ch],dl + E00051C2: 8B 45 EC mov eax,dword ptr [ebp-14h] + E00051C5: 8B 48 10 mov ecx,dword ptr [eax+10h] + E00051C8: 81 E1 00 00 00 01 and ecx,1000000h + E00051CE: 85 C9 test ecx,ecx + E00051D0: 74 09 je E00051DB + E00051D2: 8A 55 F4 mov dl,byte ptr [ebp-0Ch] + E00051D5: 80 CA 04 or dl,4 + E00051D8: 88 55 F4 mov byte ptr [ebp-0Ch],dl + E00051DB: 8A 45 F4 mov al,byte ptr [ebp-0Ch] + E00051DE: 50 push eax + E00051DF: 6A 60 push 60h + E00051E1: E8 8B FC FF FF call E0004E71 + E00051E6: 83 C4 08 add esp,8 + E00051E9: E9 70 01 00 00 jmp E000535E + E00051EE: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00051F1: 81 E1 FF 00 00 00 and ecx,0FFh + E00051F7: 85 C9 test ecx,ecx + E00051F9: 0F 84 5F 01 00 00 je E000535E + E00051FF: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0005202: 81 E2 FF 00 00 00 and edx,0FFh + E0005208: 83 FA 47 cmp edx,47h + E000520B: 0F 8C C6 00 00 00 jl E00052D7 + E0005211: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E0005214: 25 FF 00 00 00 and eax,0FFh + E0005219: 83 F8 52 cmp eax,52h + E000521C: 0F 8F B5 00 00 00 jg E00052D7 + E0005222: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0005225: 81 E1 FF 00 00 00 and ecx,0FFh + E000522B: 83 F9 4A cmp ecx,4Ah + E000522E: 0F 84 A3 00 00 00 je E00052D7 + E0005234: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0005237: 81 E2 FF 00 00 00 and edx,0FFh + E000523D: 83 FA 4E cmp edx,4Eh + E0005240: 0F 84 91 00 00 00 je E00052D7 + E0005246: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0005249: 8B 48 10 mov ecx,dword ptr [eax+10h] + E000524C: 81 E1 00 00 20 00 and ecx,200000h + E0005252: 85 C9 test ecx,ecx + E0005254: 74 45 je E000529B + E0005256: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0005259: 81 E2 FF 00 00 00 and edx,0FFh + E000525F: 83 3C 95 94 B5 00 cmp dword ptr [edx*4+E000B594h],0FFh + E0 FF + E0005267: 74 32 je E000529B + E0005269: 8B 45 EC mov eax,dword ptr [ebp-14h] + E000526C: 66 8B 48 2C mov cx,word ptr [eax+2Ch] + E0005270: 66 6B C9 0A imul cx,cx,0Ah + E0005274: 8B 55 EC mov edx,dword ptr [ebp-14h] + E0005277: 66 89 4A 2C mov word ptr [edx+2Ch],cx + E000527B: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E000527E: 25 FF 00 00 00 and eax,0FFh + E0005283: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0005286: 66 8B 51 2C mov dx,word ptr [ecx+2Ch] + E000528A: 66 03 14 85 94 B5 add dx,word ptr [eax*4+E000B594h] + 00 E0 + E0005292: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0005295: 66 89 50 2C mov word ptr [eax+2Ch],dx + E0005299: EB 3A jmp E00052D5 + E000529B: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E000529E: 8B 51 10 mov edx,dword ptr [ecx+10h] + E00052A1: 81 E2 00 00 00 02 and edx,2000000h + E00052A7: 85 D2 test edx,edx + E00052A9: 74 17 je E00052C2 + E00052AB: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E00052AE: 25 FF 00 00 00 and eax,0FFh + E00052B3: 8B 0C 85 94 B5 00 mov ecx,dword ptr [eax*4+E000B594h] + E0 + E00052BA: 83 C1 30 add ecx,30h + E00052BD: 89 4D F8 mov dword ptr [ebp-8],ecx + E00052C0: EB 13 jmp E00052D5 + E00052C2: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E00052C5: 81 E2 FF 00 00 00 and edx,0FFh + E00052CB: 8B 04 95 F8 A2 00 mov eax,dword ptr [edx*4+E000A2F8h] + E0 + E00052D2: 89 45 F8 mov dword ptr [ebp-8],eax + E00052D5: EB 37 jmp E000530E + E00052D7: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E00052DA: 8B 51 10 mov edx,dword ptr [ecx+10h] + E00052DD: 81 E2 00 00 80 00 and edx,800000h + E00052E3: 85 D2 test edx,edx + E00052E5: 74 14 je E00052FB + E00052E7: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E00052EA: 25 FF 00 00 00 and eax,0FFh + E00052EF: 8B 0C 85 70 A4 00 mov ecx,dword ptr [eax*4+E000A470h] + E0 + E00052F6: 89 4D F8 mov dword ptr [ebp-8],ecx + E00052F9: EB 13 jmp E000530E + E00052FB: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E00052FE: 81 E2 FF 00 00 00 and edx,0FFh + E0005304: 8B 04 95 F8 A2 00 mov eax,dword ptr [edx*4+E000A2F8h] + E0 + E000530B: 89 45 F8 mov dword ptr [ebp-8],eax + E000530E: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0005311: 8B 51 10 mov edx,dword ptr [ecx+10h] + E0005314: 81 E2 00 00 00 01 and edx,1000000h + E000531A: 85 D2 test edx,edx + E000531C: 74 40 je E000535E + E000531E: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0005321: 50 push eax + E0005322: E8 61 4C 00 00 call E0009F88 + E0005327: 83 C4 04 add esp,4 + E000532A: 85 C0 test eax,eax + E000532C: 74 11 je E000533F + E000532E: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0005331: 51 push ecx + E0005332: E8 4B 4C 00 00 call E0009F82 + E0005337: 83 C4 04 add esp,4 + E000533A: 89 45 F8 mov dword ptr [ebp-8],eax + E000533D: EB 1F jmp E000535E + E000533F: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0005342: 52 push edx + E0005343: E8 6A 4C 00 00 call E0009FB2 + E0005348: 83 C4 04 add esp,4 + E000534B: 85 C0 test eax,eax + E000534D: 74 0F je E000535E + E000534F: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0005352: 50 push eax + E0005353: E8 54 4C 00 00 call E0009FAC + E0005358: 83 C4 04 add esp,4 + E000535B: 89 45 F8 mov dword ptr [ebp-8],eax + E000535E: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0005361: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0005364: 0B 41 10 or eax,dword ptr [ecx+10h] + E0005367: EB 0F jmp E0005378 + E0005369: E9 0F FE FF FF jmp E000517D + E000536E: E9 0A FE FF FF jmp E000517D + E0005373: E9 05 FE FF FF jmp E000517D + E0005378: 8B E5 mov esp,ebp + E000537A: 5D pop ebp + E000537B: C2 04 00 ret 4 + E000537E: 0Fh + E000537F: 50 push eax + E0005380: 00 E0 add al,ah + E0005382: CC int 3 + E0005383: 50 push eax + E0005384: 00 E0 add al,ah + E0005386: CC int 3 + E0005387: 50 push eax + E0005388: 00 E0 add al,ah + E000538A: 46 inc esi + E000538B: 50 push eax + E000538C: 00 E0 add al,ah + E000538E: 2C 51 sub al,51h + E0005390: 00 E0 add al,ah + E0005392: 04 51 add al,51h + E0005394: 00 E0 add al,ah + E0005396: 54 push esp + E0005397: 51 push ecx + E0005398: 00 E0 add al,ah + E000539A: 0Fh + E000539B: 50 push eax + E000539C: 00 E0 add al,ah + E000539E: EE out dx,al + E000539F: 51 push ecx + E00053A0: 00 E0 add al,ah + E00053A2: 00 08 add byte ptr [eax],cl + E00053A4: 08 08 or byte ptr [eax],cl + E00053A6: 08 08 or byte ptr [eax],cl + E00053A8: 08 08 or byte ptr [eax],cl + E00053AA: 08 08 or byte ptr [eax],cl + E00053AC: 08 08 or byte ptr [eax],cl + E00053AE: 08 01 or byte ptr [ecx],al + E00053B0: 08 08 or byte ptr [eax],cl + E00053B2: 08 08 or byte ptr [eax],cl + E00053B4: 08 08 or byte ptr [eax],cl + E00053B6: 08 08 or byte ptr [eax],cl + E00053B8: 08 08 or byte ptr [eax],cl + E00053BA: 08 02 or byte ptr [edx],al + E00053BC: 08 03 or byte ptr [ebx],al + E00053BE: 08 04 08 or byte ptr [eax+ecx],al + E00053C1: 08 08 or byte ptr [eax],cl + E00053C3: 08 08 or byte ptr [eax],cl + E00053C5: 08 08 or byte ptr [eax],cl + E00053C7: 08 08 or byte ptr [eax],cl + E00053C9: 08 05 06 08 08 08 or byte ptr ds:[08080806h],al + E00053CF: 08 08 or byte ptr [eax],cl + E00053D1: 08 08 or byte ptr [eax],cl + E00053D3: 08 08 or byte ptr [eax],cl + E00053D5: 08 08 or byte ptr [eax],cl + E00053D7: 08 08 or byte ptr [eax],cl + E00053D9: 08 08 or byte ptr [eax],cl + E00053DB: 08 08 or byte ptr [eax],cl + E00053DD: 08 08 or byte ptr [eax],cl + E00053DF: 08 08 or byte ptr [eax],cl + E00053E1: 08 08 or byte ptr [eax],cl + E00053E3: 08 08 or byte ptr [eax],cl + E00053E5: 08 08 or byte ptr [eax],cl + E00053E7: 08 08 or byte ptr [eax],cl + E00053E9: 08 08 or byte ptr [eax],cl + E00053EB: 08 08 or byte ptr [eax],cl + E00053ED: 08 08 or byte ptr [eax],cl + E00053EF: 08 08 or byte ptr [eax],cl + E00053F1: 08 08 or byte ptr [eax],cl + E00053F3: 08 08 or byte ptr [eax],cl + E00053F5: 08 08 or byte ptr [eax],cl + E00053F7: 08 08 or byte ptr [eax],cl + E00053F9: 08 08 or byte ptr [eax],cl + E00053FB: 08 08 or byte ptr [eax],cl + E00053FD: 08 08 or byte ptr [eax],cl + E00053FF: 08 08 or byte ptr [eax],cl + E0005401: 08 08 or byte ptr [eax],cl + E0005403: 08 08 or byte ptr [eax],cl + E0005405: 08 08 or byte ptr [eax],cl + E0005407: 08 08 or byte ptr [eax],cl + E0005409: 08 08 or byte ptr [eax],cl + E000540B: 08 08 or byte ptr [eax],cl + E000540D: 08 08 or byte ptr [eax],cl + E000540F: 08 08 or byte ptr [eax],cl + E0005411: 08 08 or byte ptr [eax],cl + E0005413: 08 08 or byte ptr [eax],cl + E0005415: 08 08 or byte ptr [eax],cl + E0005417: 08 08 or byte ptr [eax],cl + E0005419: 08 08 or byte ptr [eax],cl + E000541B: 08 08 or byte ptr [eax],cl + E000541D: 08 08 or byte ptr [eax],cl + E000541F: 08 08 or byte ptr [eax],cl + E0005421: 08 08 or byte ptr [eax],cl + E0005423: 08 08 or byte ptr [eax],cl + E0005425: 08 08 or byte ptr [eax],cl + E0005427: 08 08 or byte ptr [eax],cl + E0005429: 08 08 or byte ptr [eax],cl + E000542B: 08 08 or byte ptr [eax],cl + E000542D: 08 08 or byte ptr [eax],cl + E000542F: 08 08 or byte ptr [eax],cl + E0005431: 08 08 or byte ptr [eax],cl + E0005433: 08 08 or byte ptr [eax],cl + E0005435: 08 08 or byte ptr [eax],cl + E0005437: 08 08 or byte ptr [eax],cl + E0005439: 08 08 or byte ptr [eax],cl + E000543B: 08 08 or byte ptr [eax],cl + E000543D: 08 08 or byte ptr [eax],cl + E000543F: 08 08 or byte ptr [eax],cl + E0005441: 08 08 or byte ptr [eax],cl + E0005443: 08 08 or byte ptr [eax],cl + E0005445: 08 08 or byte ptr [eax],cl + E0005447: 08 08 or byte ptr [eax],cl + E0005449: 08 08 or byte ptr [eax],cl + E000544B: 08 08 or byte ptr [eax],cl + E000544D: 08 08 or byte ptr [eax],cl + E000544F: 08 08 or byte ptr [eax],cl + E0005451: 08 08 or byte ptr [eax],cl + E0005453: 08 08 or byte ptr [eax],cl + E0005455: 08 08 or byte ptr [eax],cl + E0005457: 08 08 or byte ptr [eax],cl + E0005459: 08 08 or byte ptr [eax],cl + E000545B: 08 08 or byte ptr [eax],cl + E000545D: 08 08 or byte ptr [eax],cl + E000545F: 08 08 or byte ptr [eax],cl + E0005461: 08 08 or byte ptr [eax],cl + E0005463: 08 08 or byte ptr [eax],cl + E0005465: 08 08 or byte ptr [eax],cl + E0005467: 08 08 or byte ptr [eax],cl + E0005469: 08 08 or byte ptr [eax],cl + E000546B: 08 08 or byte ptr [eax],cl + E000546D: 08 08 or byte ptr [eax],cl + E000546F: 08 08 or byte ptr [eax],cl + E0005471: 08 08 or byte ptr [eax],cl + E0005473: 08 08 or byte ptr [eax],cl + E0005475: 08 08 or byte ptr [eax],cl + E0005477: 08 08 or byte ptr [eax],cl + E0005479: 08 08 or byte ptr [eax],cl + E000547B: 08 08 or byte ptr [eax],cl + E000547D: 08 08 or byte ptr [eax],cl + E000547F: 08 08 or byte ptr [eax],cl + E0005481: 08 08 or byte ptr [eax],cl + E0005483: 08 07 or byte ptr [edi],al +?Reboot@@YAXXZ (void __cdecl Reboot(void)): + E0005485: 55 push ebp + E0005486: 8B EC mov ebp,esp + E0005488: 83 EC 08 sub esp,8 + E000548B: 53 push ebx + E000548C: 56 push esi + E000548D: 57 push edi + E000548E: 66 C7 45 F8 00 00 mov word ptr [ebp-8],0 + E0005494: 66 C7 45 FA 00 00 mov word ptr [ebp-6],0 + E000549A: 66 C7 45 FC 00 00 mov word ptr [ebp-4],0 + E00054A0: 0F 01 5D F8 lidt fword ptr [ebp-8] + E00054A4: CD 00 int 0 + E00054A6: 5F pop edi + E00054A7: 5E pop esi + E00054A8: 5B pop ebx + E00054A9: 8B E5 mov esp,ebp + E00054AB: 5D pop ebp + E00054AC: C3 ret +?Key@CKeyboard@@IAEXE@Z (protected: void __thiscall CKeyboard::Key(unsigned char)): + E00054AD: 55 push ebp + E00054AE: 8B EC mov ebp,esp + E00054B0: 83 EC 08 sub esp,8 + E00054B3: 89 4D F8 mov dword ptr [ebp-8],ecx + E00054B6: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00054B9: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00054BC: 8B 50 24 mov edx,dword ptr [eax+24h] + E00054BF: 3B 51 28 cmp edx,dword ptr [ecx+28h] + E00054C2: 72 57 jb E000551B + E00054C4: 8A 45 08 mov al,byte ptr [ebp+8] + E00054C7: 50 push eax + E00054C8: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00054CB: E8 D7 FA FF FF call E0004FA7 + E00054D0: 89 45 FC mov dword ptr [ebp-4],eax + E00054D3: 81 7D FC 0D 00 61 cmp dword ptr [ebp-4],61000Dh + 00 + E00054DA: 75 05 jne E00054E1 + E00054DC: E8 A4 FF FF FF call E0005485 + E00054E1: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E00054E5: 74 34 je E000551B + E00054E7: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00054EA: 8B 51 24 mov edx,dword ptr [ecx+24h] + E00054ED: 8B 45 FC mov eax,dword ptr [ebp-4] + E00054F0: 89 02 mov dword ptr [edx],eax + E00054F2: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00054F5: 8B 51 24 mov edx,dword ptr [ecx+24h] + E00054F8: 83 C2 04 add edx,4 + E00054FB: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00054FE: 89 50 24 mov dword ptr [eax+24h],edx + E0005501: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0005504: 83 C1 24 add ecx,24h + E0005507: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000550A: 39 4A 24 cmp dword ptr [edx+24h],ecx + E000550D: 72 0C jb E000551B + E000550F: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0005512: 83 C0 14 add eax,14h + E0005515: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0005518: 89 41 24 mov dword ptr [ecx+24h],eax + E000551B: 8B E5 mov esp,ebp + E000551D: 5D pop ebp + E000551E: C2 04 00 ret 4 +?QueryInterface@CKeyboard@@UAAKABU_GUID@@PAPAX@Z (public: virtual unsigned long __cdecl CKeyboard::QueryInterface(struct _GUID const &,void * *)): + E0005521: 55 push ebp + E0005522: 8B EC mov ebp,esp + E0005524: 83 EC 08 sub esp,8 + E0005527: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000552A: 8B 08 mov ecx,dword ptr [eax] + E000552C: 3B 0D D8 A0 00 E0 cmp ecx,dword ptr ds:[E000A0D8h] + E0005532: 75 2A jne E000555E + E0005534: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0005537: 8B 42 04 mov eax,dword ptr [edx+4] + E000553A: 3B 05 DC A0 00 E0 cmp eax,dword ptr ds:[E000A0DCh] + E0005540: 75 1C jne E000555E + E0005542: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0005545: 8B 51 08 mov edx,dword ptr [ecx+8] + E0005548: 3B 15 E0 A0 00 E0 cmp edx,dword ptr ds:[E000A0E0h] + E000554E: 75 0E jne E000555E + E0005550: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0005553: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E0005556: 3B 0D E4 A0 00 E0 cmp ecx,dword ptr ds:[E000A0E4h] + E000555C: 74 37 je E0005595 + E000555E: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0005561: 8B 02 mov eax,dword ptr [edx] + E0005563: 3B 05 08 A1 00 E0 cmp eax,dword ptr ds:[E000A108h] + E0005569: 75 5D jne E00055C8 + E000556B: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E000556E: 8B 51 04 mov edx,dword ptr [ecx+4] + E0005571: 3B 15 0C A1 00 E0 cmp edx,dword ptr ds:[E000A10Ch] + E0005577: 75 4F jne E00055C8 + E0005579: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000557C: 8B 48 08 mov ecx,dword ptr [eax+8] + E000557F: 3B 0D 10 A1 00 E0 cmp ecx,dword ptr ds:[E000A110h] + E0005585: 75 41 jne E00055C8 + E0005587: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E000558A: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E000558D: 3B 05 14 A1 00 E0 cmp eax,dword ptr ds:[E000A114h] + E0005593: 75 33 jne E00055C8 + E0005595: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0005598: 8B 11 mov edx,dword ptr [ecx] + E000559A: 8B 45 08 mov eax,dword ptr [ebp+8] + E000559D: 50 push eax + E000559E: FF 52 04 call dword ptr [edx+4] + E00055A1: 83 C4 04 add esp,4 + E00055A4: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E00055A8: 74 0B je E00055B5 + E00055AA: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00055AD: 83 C1 04 add ecx,4 + E00055B0: 89 4D FC mov dword ptr [ebp-4],ecx + E00055B3: EB 07 jmp E00055BC + E00055B5: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E00055BC: 8B 55 10 mov edx,dword ptr [ebp+10h] + E00055BF: 8B 45 FC mov eax,dword ptr [ebp-4] + E00055C2: 89 02 mov dword ptr [edx],eax + E00055C4: 33 C0 xor eax,eax + E00055C6: EB 78 jmp E0005640 + E00055C8: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00055CB: 8B 11 mov edx,dword ptr [ecx] + E00055CD: 3B 15 18 A1 00 E0 cmp edx,dword ptr ds:[E000A118h] + E00055D3: 75 5D jne E0005632 + E00055D5: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00055D8: 8B 48 04 mov ecx,dword ptr [eax+4] + E00055DB: 3B 0D 1C A1 00 E0 cmp ecx,dword ptr ds:[E000A11Ch] + E00055E1: 75 4F jne E0005632 + E00055E3: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00055E6: 8B 42 08 mov eax,dword ptr [edx+8] + E00055E9: 3B 05 20 A1 00 E0 cmp eax,dword ptr ds:[E000A120h] + E00055EF: 75 41 jne E0005632 + E00055F1: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00055F4: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E00055F7: 3B 15 24 A1 00 E0 cmp edx,dword ptr ds:[E000A124h] + E00055FD: 75 33 jne E0005632 + E00055FF: 8B 45 08 mov eax,dword ptr [ebp+8] + E0005602: 8B 08 mov ecx,dword ptr [eax] + E0005604: 8B 55 08 mov edx,dword ptr [ebp+8] + E0005607: 52 push edx + E0005608: FF 51 04 call dword ptr [ecx+4] + E000560B: 83 C4 04 add esp,4 + E000560E: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E0005612: 74 0B je E000561F + E0005614: 8B 45 08 mov eax,dword ptr [ebp+8] + E0005617: 83 C0 08 add eax,8 + E000561A: 89 45 F8 mov dword ptr [ebp-8],eax + E000561D: EB 07 jmp E0005626 + E000561F: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E0005626: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E0005629: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000562C: 89 11 mov dword ptr [ecx],edx + E000562E: 33 C0 xor eax,eax + E0005630: EB 0E jmp E0005640 + E0005632: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0005635: C7 00 00 00 00 00 mov dword ptr [eax],0 + E000563B: B8 00 00 00 80 mov eax,80000000h + E0005640: 8B E5 mov esp,ebp + E0005642: 5D pop ebp + E0005643: C3 ret +?AddRef@CKeyboard@@UAAKXZ (public: virtual unsigned long __cdecl CKeyboard::AddRef(void)): + E0005644: 55 push ebp + E0005645: 8B EC mov ebp,esp + E0005647: 8B 45 08 mov eax,dword ptr [ebp+8] + E000564A: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E000564D: 83 C1 01 add ecx,1 + E0005650: 8B 55 08 mov edx,dword ptr [ebp+8] + E0005653: 89 4A 0C mov dword ptr [edx+0Ch],ecx + E0005656: 8B 45 08 mov eax,dword ptr [ebp+8] + E0005659: 8B 40 0C mov eax,dword ptr [eax+0Ch] + E000565C: 5D pop ebp + E000565D: C3 ret +?Release@CKeyboard@@UAAKXZ (public: virtual unsigned long __cdecl CKeyboard::Release(void)): + E000565E: 55 push ebp + E000565F: 8B EC mov ebp,esp + E0005661: 51 push ecx + E0005662: 8B 45 08 mov eax,dword ptr [ebp+8] + E0005665: 83 78 0C 00 cmp dword ptr [eax+0Ch],0 + E0005669: 75 16 jne E0005681 + E000566B: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000566E: 89 4D FC mov dword ptr [ebp-4],ecx + E0005671: 8B 55 FC mov edx,dword ptr [ebp-4] + E0005674: 52 push edx + E0005675: E8 F0 48 00 00 call E0009F6A + E000567A: 83 C4 04 add esp,4 + E000567D: 33 C0 xor eax,eax + E000567F: EB 15 jmp E0005696 + E0005681: 8B 45 08 mov eax,dword ptr [ebp+8] + E0005684: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E0005687: 83 E9 01 sub ecx,1 + E000568A: 8B 55 08 mov edx,dword ptr [ebp+8] + E000568D: 89 4A 0C mov dword ptr [edx+0Ch],ecx + E0005690: 8B 45 08 mov eax,dword ptr [ebp+8] + E0005693: 8B 40 0C mov eax,dword ptr [eax+0Ch] + E0005696: 8B E5 mov esp,ebp + E0005698: 5D pop ebp + E0005699: C3 ret +?GetInfo@CKeyboard@@UAAKPAUdevice_t@@@Z (public: virtual unsigned long __cdecl CKeyboard::GetInfo(struct device_t *)): + E000569A: 55 push ebp + E000569B: 8B EC mov ebp,esp + E000569D: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00056A0: 83 38 0C cmp dword ptr [eax],0Ch + E00056A3: 73 07 jae E00056AC + E00056A5: B8 00 00 00 80 mov eax,80000000h + E00056AA: EB 38 jmp E00056E4 + E00056AC: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00056AF: 33 D2 xor edx,edx + E00056B1: 8A 51 30 mov dl,byte ptr [ecx+30h] + E00056B4: 85 D2 test edx,edx + E00056B6: 74 16 je E00056CE + E00056B8: 68 58 B7 00 E0 push 0E000B758h + E00056BD: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00056C0: 8B 48 04 mov ecx,dword ptr [eax+4] + E00056C3: 51 push ecx + E00056C4: E8 41 48 00 00 call E0009F0A + E00056C9: 83 C4 08 add esp,8 + E00056CC: EB 14 jmp E00056E2 + E00056CE: 68 74 B7 00 E0 push 0E000B774h + E00056D3: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00056D6: 8B 42 04 mov eax,dword ptr [edx+4] + E00056D9: 50 push eax + E00056DA: E8 2B 48 00 00 call E0009F0A + E00056DF: 83 C4 08 add esp,8 + E00056E2: 33 C0 xor eax,eax + E00056E4: 5D pop ebp + E00056E5: C3 ret +?DeviceOpen@CKeyboard@@UAAKXZ (public: virtual unsigned long __cdecl CKeyboard::DeviceOpen(void)): + E00056E6: 55 push ebp + E00056E7: 8B EC mov ebp,esp + E00056E9: 33 C0 xor eax,eax + E00056EB: 5D pop ebp + E00056EC: C3 ret +?Read@CKeyboard@@UAAIPAXI@Z (public: virtual unsigned int __cdecl CKeyboard::Read(void *,unsigned int)): + E00056ED: 55 push ebp + E00056EE: 8B EC mov ebp,esp + E00056F0: 83 EC 10 sub esp,10h + E00056F3: 53 push ebx + E00056F4: 56 push esi + E00056F5: 57 push edi + E00056F6: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00056F9: 89 45 FC mov dword ptr [ebp-4],eax + E00056FC: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E0005703: 83 7D 10 00 cmp dword ptr [ebp+10h],0 + E0005707: 0F 86 F9 00 00 00 jbe E0005806 + E000570D: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0005710: 8B 55 08 mov edx,dword ptr [ebp+8] + E0005713: 8B 41 20 mov eax,dword ptr [ecx+20h] + E0005716: 3B 42 1C cmp eax,dword ptr [edx+1Ch] + E0005719: 75 03 jne E000571E + E000571B: FB sti + E000571C: EB EF jmp E000570D + E000571E: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0005721: 8B 51 20 mov edx,dword ptr [ecx+20h] + E0005724: 8B 02 mov eax,dword ptr [edx] + E0005726: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0005729: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000572C: 8B 51 20 mov edx,dword ptr [ecx+20h] + E000572F: 83 C2 04 add edx,4 + E0005732: 8B 45 08 mov eax,dword ptr [ebp+8] + E0005735: 89 50 20 mov dword ptr [eax+20h],edx + E0005738: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000573B: 83 C1 1C add ecx,1Ch + E000573E: 8B 55 08 mov edx,dword ptr [ebp+8] + E0005741: 39 4A 20 cmp dword ptr [edx+20h],ecx + E0005744: 72 0C jb E0005752 + E0005746: 8B 45 08 mov eax,dword ptr [ebp+8] + E0005749: 83 C0 0C add eax,0Ch + E000574C: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000574F: 89 41 20 mov dword ptr [ecx+20h],eax + E0005752: 8B 55 08 mov edx,dword ptr [ebp+8] + E0005755: 83 7A 28 00 cmp dword ptr [edx+28h],0 + E0005759: 74 22 je E000577D + E000575B: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E000575E: 25 FF FF 01 00 and eax,1FFFFh + E0005763: 3D 00 00 01 00 cmp eax,10000h + E0005768: 72 13 jb E000577D + E000576A: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E000576D: 81 E1 FF FF 01 00 and ecx,1FFFFh + E0005773: 81 F9 00 00 02 00 cmp ecx,20000h + E0005779: 73 02 jae E000577D + E000577B: EB 86 jmp E0005703 + E000577D: 8B 55 08 mov edx,dword ptr [ebp+8] + E0005780: 8B 42 28 mov eax,dword ptr [edx+28h] + E0005783: 89 45 F0 mov dword ptr [ebp-10h],eax + E0005786: 83 7D F0 00 cmp dword ptr [ebp-10h],0 + E000578A: 74 0E je E000579A + E000578C: 83 7D F0 01 cmp dword ptr [ebp-10h],1 + E0005790: 74 24 je E00057B6 + E0005792: 83 7D F0 02 cmp dword ptr [ebp-10h],2 + E0005796: 74 41 je E00057D9 + E0005798: EB 5E jmp E00057F8 + E000579A: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000579D: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E00057A0: 89 11 mov dword ptr [ecx],edx + E00057A2: 8B 45 FC mov eax,dword ptr [ebp-4] + E00057A5: 83 C0 04 add eax,4 + E00057A8: 89 45 FC mov dword ptr [ebp-4],eax + E00057AB: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E00057AE: 83 E9 04 sub ecx,4 + E00057B1: 89 4D 10 mov dword ptr [ebp+10h],ecx + E00057B4: EB 42 jmp E00057F8 + E00057B6: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E00057B9: 81 E2 FF FF 00 00 and edx,0FFFFh + E00057BF: 8B 45 FC mov eax,dword ptr [ebp-4] + E00057C2: 66 89 10 mov word ptr [eax],dx + E00057C5: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00057C8: 83 C1 02 add ecx,2 + E00057CB: 89 4D FC mov dword ptr [ebp-4],ecx + E00057CE: 8B 55 10 mov edx,dword ptr [ebp+10h] + E00057D1: 83 EA 02 sub edx,2 + E00057D4: 89 55 10 mov dword ptr [ebp+10h],edx + E00057D7: EB 1F jmp E00057F8 + E00057D9: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E00057DC: 25 FF 00 00 00 and eax,0FFh + E00057E1: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00057E4: 89 01 mov dword ptr [ecx],eax + E00057E6: 8B 55 FC mov edx,dword ptr [ebp-4] + E00057E9: 83 C2 01 add edx,1 + E00057EC: 89 55 FC mov dword ptr [ebp-4],edx + E00057EF: 8B 45 10 mov eax,dword ptr [ebp+10h] + E00057F2: 83 E8 01 sub eax,1 + E00057F5: 89 45 10 mov dword ptr [ebp+10h],eax + E00057F8: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00057FB: 83 C1 01 add ecx,1 + E00057FE: 89 4D F8 mov dword ptr [ebp-8],ecx + E0005801: E9 FD FE FF FF jmp E0005703 + E0005806: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0005809: 5F pop edi + E000580A: 5E pop esi + E000580B: 5B pop ebx + E000580C: 8B E5 mov esp,ebp + E000580E: 5D pop ebp + E000580F: C3 ret +?Write@CKeyboard@@UAAIPBXI@Z (public: virtual unsigned int __cdecl CKeyboard::Write(void const *,unsigned int)): + E0005810: 55 push ebp + E0005811: 8B EC mov ebp,esp + E0005813: 33 C0 xor eax,eax + E0005815: 5D pop ebp + E0005816: C3 ret +?SetIoMode@CKeyboard@@UAAKI@Z (public: virtual unsigned long __cdecl CKeyboard::SetIoMode(unsigned int)): + E0005817: 55 push ebp + E0005818: 8B EC mov ebp,esp + E000581A: 8B 45 08 mov eax,dword ptr [ebp+8] + E000581D: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0005820: 89 48 28 mov dword ptr [eax+28h],ecx + E0005823: 33 C0 xor eax,eax + E0005825: 5D pop ebp + E0005826: C3 ret +?IsReady@CKeyboard@@UAAKXZ (public: virtual unsigned long __cdecl CKeyboard::IsReady(void)): + E0005827: 55 push ebp + E0005828: 8B EC mov ebp,esp + E000582A: 8B 45 08 mov eax,dword ptr [ebp+8] + E000582D: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0005830: 8B 50 20 mov edx,dword ptr [eax+20h] + E0005833: 33 C0 xor eax,eax + E0005835: 3B 51 1C cmp edx,dword ptr [ecx+1Ch] + E0005838: 0F 94 C0 sete al + E000583B: 5D pop ebp + E000583C: C3 ret +?Stat@CKeyboard@@UAAKPAU_folderitem_t@@@Z (public: virtual unsigned long __cdecl CKeyboard::Stat(struct _folderitem_t *)): + E000583D: 55 push ebp + E000583E: 8B EC mov ebp,esp + E0005840: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0005843: 83 38 1C cmp dword ptr [eax],1Ch + E0005846: 73 07 jae E000584F + E0005848: B8 00 00 00 80 mov eax,80000000h + E000584D: EB 3A jmp E0005889 + E000584F: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0005852: 83 79 0C 00 cmp dword ptr [ecx+0Ch],0 + E0005856: 74 1B je E0005873 + E0005858: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E000585B: 8B 42 10 mov eax,dword ptr [edx+10h] + E000585E: 50 push eax + E000585F: 68 94 B7 00 E0 push 0E000B794h + E0005864: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0005867: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E000586A: 52 push edx + E000586B: E8 24 47 00 00 call E0009F94 + E0005870: 83 C4 0C add esp,0Ch + E0005873: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0005876: C7 40 14 00 10 00 mov dword ptr [eax+14h],1000h + 00 + E000587D: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0005880: C7 41 18 00 00 00 mov dword ptr [ecx+18h],0 + 00 + E0005887: 33 C0 xor eax,eax + E0005889: 5D pop ebp + E000588A: C3 ret +?Seek@CKeyboard@@UAAKJH@Z (public: virtual unsigned long __cdecl CKeyboard::Seek(long,int)): + E000588B: 55 push ebp + E000588C: 8B EC mov ebp,esp + E000588E: B8 00 00 00 80 mov eax,80000000h + E0005893: 5D pop ebp + E0005894: C3 ret + E0005895: CC int 3 + E0005896: CC int 3 + E0005897: CC int 3 + E0005898: CC int 3 + E0005899: CC int 3 + E000589A: CC int 3 + E000589B: CC int 3 + E000589C: CC int 3 + E000589D: CC int 3 + E000589E: CC int 3 + E000589F: CC int 3 +?QueryInterface@CKeyboard@@W3AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CKeyboard::QueryInterface`adjustor{4}' (struct _GUID const &,void * *)): + E00058A0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E00058A5: E9 77 FC FF FF jmp E0005521 + E00058AA: CC int 3 + E00058AB: CC int 3 + E00058AC: CC int 3 + E00058AD: CC int 3 + E00058AE: CC int 3 + E00058AF: CC int 3 +?AddRef@CKeyboard@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CKeyboard::AddRef`adjustor{4}' (void)): + E00058B0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E00058B5: E9 8A FD FF FF jmp E0005644 + E00058BA: CC int 3 + E00058BB: CC int 3 + E00058BC: CC int 3 + E00058BD: CC int 3 + E00058BE: CC int 3 + E00058BF: CC int 3 +?Release@CKeyboard@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CKeyboard::Release`adjustor{4}' (void)): + E00058C0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E00058C5: E9 94 FD FF FF jmp E000565E + E00058CA: CC int 3 + E00058CB: CC int 3 + E00058CC: CC int 3 + E00058CD: CC int 3 + E00058CE: CC int 3 + E00058CF: CC int 3 +?QueryInterface@CKeyboard@@W7AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CKeyboard::QueryInterface`adjustor{8}' (struct _GUID const &,void * *)): + E00058D0: 83 6C 24 04 08 sub dword ptr [esp+4],8 + E00058D5: E9 47 FC FF FF jmp E0005521 + E00058DA: CC int 3 + E00058DB: CC int 3 + E00058DC: CC int 3 + E00058DD: CC int 3 + E00058DE: CC int 3 + E00058DF: CC int 3 +?AddRef@CKeyboard@@W7AAKXZ ([thunk]:public: virtual unsigned long __cdecl CKeyboard::AddRef`adjustor{8}' (void)): + E00058E0: 83 6C 24 04 08 sub dword ptr [esp+4],8 + E00058E5: E9 5A FD FF FF jmp E0005644 + E00058EA: CC int 3 + E00058EB: CC int 3 + E00058EC: CC int 3 + E00058ED: CC int 3 + E00058EE: CC int 3 + E00058EF: CC int 3 +?Release@CKeyboard@@W7AAKXZ ([thunk]:public: virtual unsigned long __cdecl CKeyboard::Release`adjustor{8}' (void)): + E00058F0: 83 6C 24 04 08 sub dword ptr [esp+4],8 + E00058F5: E9 64 FD FF FF jmp E000565E + E00058FA: CC int 3 + E00058FB: CC int 3 + E00058FC: CC int 3 + E00058FD: CC int 3 + E00058FE: CC int 3 + E00058FF: CC int 3 +_nsleep: + E0005900: 55 push ebp + E0005901: 8B EC mov ebp,esp + E0005903: 5D pop ebp + E0005904: C3 ret +_msleep: + E0005905: 55 push ebp + E0005906: 8B EC mov ebp,esp + E0005908: 51 push ecx + E0005909: E8 08 46 00 00 call E0009F16 + E000590E: 03 45 08 add eax,dword ptr [ebp+8] + E0005911: 89 45 FC mov dword ptr [ebp-4],eax + E0005914: E8 FD 45 00 00 call E0009F16 + E0005919: 3B 45 FC cmp eax,dword ptr [ebp-4] + E000591C: 73 02 jae E0005920 + E000591E: EB F4 jmp E0005914 + E0005920: 8B E5 mov esp,ebp + E0005922: 5D pop ebp + E0005923: C3 ret +_insw: + E0005924: 55 push ebp + E0005925: 8B EC mov ebp,esp + E0005927: 53 push ebx + E0005928: 56 push esi + E0005929: 57 push edi + E000592A: 0F B7 55 08 movzx edx,word ptr [ebp+8] + E000592E: 8B 7D 0C mov edi,dword ptr [ebp+0Ch] + E0005931: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E0005934: FC cld + E0005935: F3 66 6D rep ins word ptr es:[edi],dx + E0005938: 5F pop edi + E0005939: 5E pop esi + E000593A: 5B pop ebx + E000593B: 5D pop ebp + E000593C: C3 ret +?DisplayConfigMenu@@YAXXZ (void __cdecl DisplayConfigMenu(void)): + E000593D: 55 push ebp + E000593E: 8B EC mov ebp,esp + E0005940: 83 EC 08 sub esp,8 + E0005943: C7 45 F8 06 00 00 mov dword ptr [ebp-8],6 + 00 + E000594A: 68 A8 B7 00 E0 push 0E000B7A8h + E000594F: E8 C8 45 00 00 call E0009F1C + E0005954: 83 C4 04 add esp,4 + E0005957: A1 54 B4 00 E0 mov eax,[E000B454] + E000595C: 89 45 FC mov dword ptr [ebp-4],eax + E000595F: EB 09 jmp E000596A + E0005961: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0005964: 8B 51 04 mov edx,dword ptr [ecx+4] + E0005967: 89 55 FC mov dword ptr [ebp-4],edx + E000596A: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E000596E: 74 4A je E00059BA + E0005970: 8B 45 FC mov eax,dword ptr [ebp-4] + E0005973: 3B 05 50 B4 00 E0 cmp eax,dword ptr ds:[E000B450h] + E0005979: 75 0F jne E000598A + E000597B: 68 F8 B7 00 E0 push 0E000B7F8h + E0005980: E8 97 45 00 00 call E0009F1C + E0005985: 83 C4 04 add esp,4 + E0005988: EB 0D jmp E0005997 + E000598A: 68 0C B8 00 E0 push 0E000B80Ch + E000598F: E8 88 45 00 00 call E0009F1C + E0005994: 83 C4 04 add esp,4 + E0005997: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000599A: 83 C1 08 add ecx,8 + E000599D: 51 push ecx + E000599E: 8B 55 F8 mov edx,dword ptr [ebp-8] + E00059A1: 52 push edx + E00059A2: 68 20 B8 00 E0 push 0E000B820h + E00059A7: E8 64 45 00 00 call E0009F10 + E00059AC: 83 C4 0C add esp,0Ch + E00059AF: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00059B2: 83 C0 02 add eax,2 + E00059B5: 89 45 F8 mov dword ptr [ebp-8],eax + E00059B8: EB A7 jmp E0005961 + E00059BA: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00059BD: 83 C1 04 add ecx,4 + E00059C0: 89 4D F8 mov dword ptr [ebp-8],ecx + E00059C3: 68 3C B8 00 E0 push 0E000B83Ch + E00059C8: E8 4F 45 00 00 call E0009F1C + E00059CD: 83 C4 04 add esp,4 + E00059D0: 8B 55 F8 mov edx,dword ptr [ebp-8] + E00059D3: 83 C2 02 add edx,2 + E00059D6: 52 push edx + E00059D7: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00059DA: 83 C0 01 add eax,1 + E00059DD: 50 push eax + E00059DE: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00059E1: 51 push ecx + E00059E2: 68 50 B8 00 E0 push 0E000B850h + E00059E7: E8 24 45 00 00 call E0009F10 + E00059EC: 83 C4 10 add esp,10h + E00059EF: 8B E5 mov esp,ebp + E00059F1: 5D pop ebp + E00059F2: C3 ret +?PickConfigMenu@@YA_NXZ (bool __cdecl PickConfigMenu(void)): + E00059F3: 55 push ebp + E00059F4: 8B EC mov ebp,esp + E00059F6: 83 EC 10 sub esp,10h + E00059F9: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0005A00: B8 01 00 00 00 mov eax,1 + E0005A05: 85 C0 test eax,eax + E0005A07: 0F 84 0E 01 00 00 je E0005B1B + E0005A0D: E8 B2 45 00 00 call E0009FC4 + E0005A12: 85 C0 test eax,eax + E0005A14: 75 60 jne E0005A76 + E0005A16: 83 3D 60 C8 00 E0 cmp dword ptr ds:[E000C860h],0FFh + FF + E0005A1D: 74 55 je E0005A74 + E0005A1F: E8 F2 44 00 00 call E0009F16 + E0005A24: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0005A27: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0005A2A: 3B 0D 60 C8 00 E0 cmp ecx,dword ptr ds:[E000C860h] + E0005A30: 72 07 jb E0005A39 + E0005A32: B0 01 mov al,1 + E0005A34: E9 E2 00 00 00 jmp E0005B1B + E0005A39: A1 60 C8 00 E0 mov eax,[E000C860] + E0005A3E: 2B 45 F4 sub eax,dword ptr [ebp-0Ch] + E0005A41: 33 D2 xor edx,edx + E0005A43: B9 E8 03 00 00 mov ecx,3E8h + E0005A48: F7 F1 div eax,ecx + E0005A4A: 39 45 FC cmp dword ptr [ebp-4],eax + E0005A4D: 74 25 je E0005A74 + E0005A4F: A1 60 C8 00 E0 mov eax,[E000C860] + E0005A54: 2B 45 F4 sub eax,dword ptr [ebp-0Ch] + E0005A57: 33 D2 xor edx,edx + E0005A59: B9 E8 03 00 00 mov ecx,3E8h + E0005A5E: F7 F1 div eax,ecx + E0005A60: 89 45 FC mov dword ptr [ebp-4],eax + E0005A63: 8B 55 FC mov edx,dword ptr [ebp-4] + E0005A66: 52 push edx + E0005A67: 68 14 B9 00 E0 push 0E000B914h + E0005A6C: E8 9F 44 00 00 call E0009F10 + E0005A71: 83 C4 08 add esp,8 + E0005A74: EB 97 jmp E0005A0D + E0005A76: C7 05 60 C8 00 E0 mov dword ptr ds:[E000C860h],0FFFFFFFFh + FF FF FF FF + E0005A80: E8 39 45 00 00 call E0009FBE + E0005A85: 89 45 F8 mov dword ptr [ebp-8],eax + E0005A88: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0005A8B: 89 45 F0 mov dword ptr [ebp-10h],eax + E0005A8E: 83 7D F0 0A cmp dword ptr [ebp-10h],0Ah + E0005A92: 74 5F je E0005AF3 + E0005A94: 81 7D F0 13 00 01 cmp dword ptr [ebp-10h],10013h + 00 + E0005A9B: 74 0B je E0005AA8 + E0005A9D: 81 7D F0 14 00 01 cmp dword ptr [ebp-10h],10014h + 00 + E0005AA4: 74 27 je E0005ACD + E0005AA6: EB 4F jmp E0005AF7 + E0005AA8: 8B 0D 50 B4 00 E0 mov ecx,dword ptr ds:[E000B450h] + E0005AAE: 8B 11 mov edx,dword ptr [ecx] + E0005AB0: 89 15 50 B4 00 E0 mov dword ptr ds:[E000B450h],edx + E0005AB6: 83 3D 50 B4 00 E0 cmp dword ptr ds:[E000B450h],0 + 00 + E0005ABD: 75 0A jne E0005AC9 + E0005ABF: A1 58 C8 00 E0 mov eax,[E000C858] + E0005AC4: A3 50 B4 00 E0 mov [E000B450],eax + E0005AC9: 32 C0 xor al,al + E0005ACB: EB 4E jmp E0005B1B + E0005ACD: 8B 0D 50 B4 00 E0 mov ecx,dword ptr ds:[E000B450h] + E0005AD3: 8B 51 04 mov edx,dword ptr [ecx+4] + E0005AD6: 89 15 50 B4 00 E0 mov dword ptr ds:[E000B450h],edx + E0005ADC: 83 3D 50 B4 00 E0 cmp dword ptr ds:[E000B450h],0 + 00 + E0005AE3: 75 0A jne E0005AEF + E0005AE5: A1 54 B4 00 E0 mov eax,[E000B454] + E0005AEA: A3 50 B4 00 E0 mov [E000B450],eax + E0005AEF: 32 C0 xor al,al + E0005AF1: EB 28 jmp E0005B1B + E0005AF3: B0 01 mov al,1 + E0005AF5: EB 24 jmp E0005B1B + E0005AF7: 81 7D F8 FF FF 00 cmp dword ptr [ebp-8],0FFFFh + 00 + E0005AFE: 7F 16 jg E0005B16 + E0005B00: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0005B03: 51 push ecx + E0005B04: E8 AF 44 00 00 call E0009FB8 + E0005B09: 83 C4 04 add esp,4 + E0005B0C: 6A 08 push 8 + E0005B0E: E8 A5 44 00 00 call E0009FB8 + E0005B13: 83 C4 04 add esp,4 + E0005B16: E9 E5 FE FF FF jmp E0005A00 + E0005B1B: 8B E5 mov esp,ebp + E0005B1D: 5D pop ebp + E0005B1E: C3 ret +_drvInit: + E0005B1F: 55 push ebp + E0005B20: 8B EC mov ebp,esp + E0005B22: 83 EC 50 sub esp,50h + E0005B25: 53 push ebx + E0005B26: 56 push esi + E0005B27: 57 push edi + E0005B28: E8 93 EB FF FF call E00046C0 + E0005B2D: A3 64 C8 00 E0 mov [E000C864],eax + E0005B32: 64 A1 04 00 00 00 mov eax,fs:[00000004] + E0005B38: 89 45 D0 mov dword ptr [ebp-30h],eax + E0005B3B: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E0005B3E: 8B 48 14 mov ecx,dword ptr [eax+14h] + E0005B41: 8B 15 64 C8 00 E0 mov edx,dword ptr ds:[E000C864h] + E0005B47: 89 51 04 mov dword ptr [ecx+4],edx + E0005B4A: A1 64 C8 00 E0 mov eax,[E000C864] + E0005B4F: 50 push eax + E0005B50: 68 2C B9 00 E0 push 0E000B92Ch + E0005B55: E8 FE 43 00 00 call E0009F58 + E0005B5A: 83 C4 08 add esp,8 + E0005B5D: E8 2E 2D 00 00 call E0008890 + E0005B62: 89 45 FC mov dword ptr [ebp-4],eax + E0005B65: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0005B68: 51 push ecx + E0005B69: 68 38 B9 00 E0 push 0E000B938h + E0005B6E: 8B 15 64 C8 00 E0 mov edx,dword ptr ds:[E000C864h] + E0005B74: 8B 02 mov eax,dword ptr [edx] + E0005B76: 8B 0D 64 C8 00 E0 mov ecx,dword ptr ds:[E000C864h] + E0005B7C: 51 push ecx + E0005B7D: FF 50 1C call dword ptr [eax+1Ch] + E0005B80: 83 C4 0C add esp,0Ch + E0005B83: E8 38 EB FF FF call E00046C0 + E0005B88: A3 5C C8 00 E0 mov [E000C85C],eax + E0005B8D: 8B 15 5C C8 00 E0 mov edx,dword ptr ds:[E000C85Ch] + E0005B93: 52 push edx + E0005B94: 68 44 B9 00 E0 push 0E000B944h + E0005B99: E8 BA 43 00 00 call E0009F58 + E0005B9E: 83 C4 08 add esp,8 + E0005BA1: A1 5C C8 00 E0 mov eax,[E000C85C] + E0005BA6: 50 push eax + E0005BA7: 68 54 B9 00 E0 push 0E000B954h + E0005BAC: 8B 0D 64 C8 00 E0 mov ecx,dword ptr ds:[E000C864h] + E0005BB2: 8B 11 mov edx,dword ptr [ecx] + E0005BB4: A1 64 C8 00 E0 mov eax,[E000C864] + E0005BB9: 50 push eax + E0005BBA: FF 52 1C call dword ptr [edx+1Ch] + E0005BBD: 83 C4 0C add esp,0Ch + E0005BC0: 6A 38 push 38h + E0005BC2: E8 AF 43 00 00 call E0009F76 + E0005BC7: 83 C4 04 add esp,4 + E0005BCA: 89 45 DC mov dword ptr [ebp-24h],eax + E0005BCD: 83 7D DC 00 cmp dword ptr [ebp-24h],0 + E0005BD1: 74 0D je E0005BE0 + E0005BD3: 8B 4D DC mov ecx,dword ptr [ebp-24h] + E0005BD6: E8 F5 F0 FF FF call E0004CD0 + E0005BDB: 89 45 CC mov dword ptr [ebp-34h],eax + E0005BDE: EB 07 jmp E0005BE7 + E0005BE0: C7 45 CC 00 00 00 mov dword ptr [ebp-34h],0 + 00 + E0005BE7: 83 7D CC 00 cmp dword ptr [ebp-34h],0 + E0005BEB: 74 0B je E0005BF8 + E0005BED: 8B 4D CC mov ecx,dword ptr [ebp-34h] + E0005BF0: 83 C1 04 add ecx,4 + E0005BF3: 89 4D C8 mov dword ptr [ebp-38h],ecx + E0005BF6: EB 07 jmp E0005BFF + E0005BF8: C7 45 C8 00 00 00 mov dword ptr [ebp-38h],0 + 00 + E0005BFF: 8B 55 C8 mov edx,dword ptr [ebp-38h] + E0005C02: 52 push edx + E0005C03: 68 64 B9 00 E0 push 0E000B964h + E0005C08: E8 15 43 00 00 call E0009F22 + E0005C0D: 83 C4 08 add esp,8 + E0005C10: 6A 20 push 20h + E0005C12: E8 5F 43 00 00 call E0009F76 + E0005C17: 83 C4 04 add esp,4 + E0005C1A: 89 45 D8 mov dword ptr [ebp-28h],eax + E0005C1D: 83 7D D8 00 cmp dword ptr [ebp-28h],0 + E0005C21: 74 0D je E0005C30 + E0005C23: 8B 4D D8 mov ecx,dword ptr [ebp-28h] + E0005C26: E8 B5 3F 00 00 call E0009BE0 + E0005C2B: 89 45 C4 mov dword ptr [ebp-3Ch],eax + E0005C2E: EB 07 jmp E0005C37 + E0005C30: C7 45 C4 00 00 00 mov dword ptr [ebp-3Ch],0 + 00 + E0005C37: 8B 45 C4 mov eax,dword ptr [ebp-3Ch] + E0005C3A: 89 45 EC mov dword ptr [ebp-14h],eax + E0005C3D: 83 7D EC 00 cmp dword ptr [ebp-14h],0 + E0005C41: 74 0B je E0005C4E + E0005C43: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0005C46: 83 C1 04 add ecx,4 + E0005C49: 89 4D C0 mov dword ptr [ebp-40h],ecx + E0005C4C: EB 07 jmp E0005C55 + E0005C4E: C7 45 C0 00 00 00 mov dword ptr [ebp-40h],0 + 00 + E0005C55: 8B 55 C0 mov edx,dword ptr [ebp-40h] + E0005C58: 52 push edx + E0005C59: 68 78 B9 00 E0 push 0E000B978h + E0005C5E: E8 BF 42 00 00 call E0009F22 + E0005C63: 83 C4 08 add esp,8 + E0005C66: E8 5F 43 00 00 call E0009FCA + E0005C6B: A1 54 B4 00 E0 mov eax,[E000B454] + E0005C70: 83 78 04 00 cmp dword ptr [eax+4],0 + E0005C74: 74 33 je E0005CA9 + E0005C76: E8 9B 42 00 00 call E0009F16 + E0005C7B: 8B 0D 50 B4 00 E0 mov ecx,dword ptr ds:[E000B450h] + E0005C81: 03 41 5C add eax,dword ptr [ecx+5Ch] + E0005C84: A3 60 C8 00 E0 mov [E000C860],eax + E0005C89: E8 AF FC FF FF call E000593D + E0005C8E: E8 60 FD FF FF call E00059F3 + E0005C93: 25 FF 00 00 00 and eax,0FFh + E0005C98: 85 C0 test eax,eax + E0005C9A: 74 ED je E0005C89 + E0005C9C: 68 88 B9 00 E0 push 0E000B988h + E0005CA1: E8 76 42 00 00 call E0009F1C + E0005CA6: 83 C4 04 add esp,4 + E0005CA9: 6A 34 push 34h + E0005CAB: E8 C6 42 00 00 call E0009F76 + E0005CB0: 83 C4 04 add esp,4 + E0005CB3: 89 45 D4 mov dword ptr [ebp-2Ch],eax + E0005CB6: 83 7D D4 00 cmp dword ptr [ebp-2Ch],0 + E0005CBA: 74 0D je E0005CC9 + E0005CBC: 8B 4D D4 mov ecx,dword ptr [ebp-2Ch] + E0005CBF: E8 D3 24 00 00 call E0008197 + E0005CC4: 89 45 BC mov dword ptr [ebp-44h],eax + E0005CC7: EB 07 jmp E0005CD0 + E0005CC9: C7 45 BC 00 00 00 mov dword ptr [ebp-44h],0 + 00 + E0005CD0: 83 7D BC 00 cmp dword ptr [ebp-44h],0 + E0005CD4: 74 0B je E0005CE1 + E0005CD6: 8B 55 BC mov edx,dword ptr [ebp-44h] + E0005CD9: 83 C2 04 add edx,4 + E0005CDC: 89 55 B8 mov dword ptr [ebp-48h],edx + E0005CDF: EB 07 jmp E0005CE8 + E0005CE1: C7 45 B8 00 00 00 mov dword ptr [ebp-48h],0 + 00 + E0005CE8: 8B 45 B8 mov eax,dword ptr [ebp-48h] + E0005CEB: 50 push eax + E0005CEC: 68 94 B9 00 E0 push 0E000B994h + E0005CF1: E8 2C 42 00 00 call E0009F22 + E0005CF6: 83 C4 08 add esp,8 + E0005CF9: E8 1B 04 00 00 call E0006119 + E0005CFE: 89 45 B4 mov dword ptr [ebp-4Ch],eax + E0005D01: 83 7D B4 00 cmp dword ptr [ebp-4Ch],0 + E0005D05: 74 0B je E0005D12 + E0005D07: 8B 4D B4 mov ecx,dword ptr [ebp-4Ch] + E0005D0A: 83 C1 04 add ecx,4 + E0005D0D: 89 4D B0 mov dword ptr [ebp-50h],ecx + E0005D10: EB 07 jmp E0005D19 + E0005D12: C7 45 B0 00 00 00 mov dword ptr [ebp-50h],0 + 00 + E0005D19: 8B 55 B0 mov edx,dword ptr [ebp-50h] + E0005D1C: 89 55 F8 mov dword ptr [ebp-8],edx + E0005D1F: 83 7D F8 00 cmp dword ptr [ebp-8],0 + E0005D23: 74 11 je E0005D36 + E0005D25: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0005D28: 50 push eax + E0005D29: 68 A0 B9 00 E0 push 0E000B9A0h + E0005D2E: E8 EF 41 00 00 call E0009F22 + E0005D33: 83 C4 08 add esp,8 + E0005D36: 6A 04 push 4 + E0005D38: 68 F8 03 00 00 push 3F8h + E0005D3D: E8 8E 30 00 00 call E0008DD0 + E0005D42: 83 C4 08 add esp,8 + E0005D45: 50 push eax + E0005D46: 68 B0 B9 00 E0 push 0E000B9B0h + E0005D4B: E8 D2 41 00 00 call E0009F22 + E0005D50: 83 C4 08 add esp,8 + E0005D53: 6A 03 push 3 + E0005D55: 68 F8 02 00 00 push 2F8h + E0005D5A: E8 71 30 00 00 call E0008DD0 + E0005D5F: 83 C4 08 add esp,8 + E0005D62: 50 push eax + E0005D63: 68 C0 B9 00 E0 push 0E000B9C0h + E0005D68: E8 B5 41 00 00 call E0009F22 + E0005D6D: 83 C4 08 add esp,8 + E0005D70: E8 70 BA FF FF call E00017E5 + E0005D75: 68 D0 B9 00 E0 push 0E000B9D0h + E0005D7A: E8 D3 41 00 00 call E0009F52 + E0005D7F: 83 C4 04 add esp,4 + E0005D82: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0005D85: 83 7D F4 00 cmp dword ptr [ebp-0Ch],0 + E0005D89: 74 79 je E0005E04 + E0005D8B: 8D 4D E4 lea ecx,dword ptr [ebp-1Ch] + E0005D8E: 51 push ecx + E0005D8F: 68 28 A1 00 E0 push 0E000A128h + E0005D94: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0005D97: 8B 02 mov eax,dword ptr [edx] + E0005D99: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0005D9C: 51 push ecx + E0005D9D: FF 10 call dword ptr [eax] + E0005D9F: 83 C4 0C add esp,0Ch + E0005DA2: 25 00 00 00 80 and eax,80000000h + E0005DA7: 85 C0 test eax,eax + E0005DA9: 75 4A jne E0005DF5 + E0005DAB: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0005DAE: 52 push edx + E0005DAF: E8 EC D6 FF FF call E00034A0 + E0005DB4: 83 C4 04 add esp,4 + E0005DB7: 89 45 E0 mov dword ptr [ebp-20h],eax + E0005DBA: 8B 45 E0 mov eax,dword ptr [ebp-20h] + E0005DBD: 50 push eax + E0005DBE: 68 EC B9 00 E0 push 0E000B9ECh + E0005DC3: 8B 0D 64 C8 00 E0 mov ecx,dword ptr ds:[E000C864h] + E0005DC9: 8B 11 mov edx,dword ptr [ecx] + E0005DCB: A1 64 C8 00 E0 mov eax,[E000C864] + E0005DD0: 50 push eax + E0005DD1: FF 52 1C call dword ptr [edx+1Ch] + E0005DD4: 83 C4 0C add esp,0Ch + E0005DD7: 8B 4D E0 mov ecx,dword ptr [ebp-20h] + E0005DDA: 8B 11 mov edx,dword ptr [ecx] + E0005DDC: 8B 45 E0 mov eax,dword ptr [ebp-20h] + E0005DDF: 50 push eax + E0005DE0: FF 52 08 call dword ptr [edx+8] + E0005DE3: 83 C4 04 add esp,4 + E0005DE6: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0005DE9: 8B 11 mov edx,dword ptr [ecx] + E0005DEB: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0005DEE: 50 push eax + E0005DEF: FF 52 08 call dword ptr [edx+8] + E0005DF2: 83 C4 04 add esp,4 + E0005DF5: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0005DF8: 8B 11 mov edx,dword ptr [ecx] + E0005DFA: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0005DFD: 50 push eax + E0005DFE: FF 52 08 call dword ptr [edx+8] + E0005E01: 83 C4 04 add esp,4 + E0005E04: 8B 0D 54 B4 00 E0 mov ecx,dword ptr ds:[E000B454h] + E0005E0A: 89 4D F0 mov dword ptr [ebp-10h],ecx + E0005E0D: EB 06 jmp E0005E15 + E0005E0F: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E0005E12: 89 55 F0 mov dword ptr [ebp-10h],edx + E0005E15: 83 7D F0 00 cmp dword ptr [ebp-10h],0 + E0005E19: 74 17 je E0005E32 + E0005E1B: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E0005E1E: 8B 48 04 mov ecx,dword ptr [eax+4] + E0005E21: 89 4D E8 mov dword ptr [ebp-18h],ecx + E0005E24: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0005E27: 52 push edx + E0005E28: E8 19 41 00 00 call E0009F46 + E0005E2D: 83 C4 04 add esp,4 + E0005E30: EB DD jmp E0005E0F + E0005E32: C7 05 50 B4 00 E0 mov dword ptr ds:[E000B450h],0 + 00 00 00 00 + E0005E3C: A1 50 B4 00 E0 mov eax,[E000B450] + E0005E41: A3 58 C8 00 E0 mov [E000C858],eax + E0005E46: 8B 0D 58 C8 00 E0 mov ecx,dword ptr ds:[E000C858h] + E0005E4C: 89 0D 54 B4 00 E0 mov dword ptr ds:[E000B454h],ecx + E0005E52: B0 01 mov al,1 + E0005E54: 5F pop edi + E0005E55: 5E pop esi + E0005E56: 5B pop ebx + E0005E57: 8B E5 mov esp,ebp + E0005E59: 5D pop ebp + E0005E5A: C3 ret + E0005E5B: CC int 3 + E0005E5C: CC int 3 + E0005E5D: CC int 3 + E0005E5E: CC int 3 + E0005E5F: CC int 3 +??0CNe2000@@QAE@G@Z (public: __thiscall CNe2000::CNe2000(unsigned short)): + E0005E60: 55 push ebp + E0005E61: 8B EC mov ebp,esp + E0005E63: 83 EC 1C sub esp,1Ch + E0005E66: 57 push edi + E0005E67: 89 4D E4 mov dword ptr [ebp-1Ch],ecx + E0005E6A: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0005E6D: C7 00 C8 A0 00 E0 mov dword ptr [eax],0E000A0C8h + E0005E73: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0005E76: 83 C1 04 add ecx,4 + E0005E79: 89 4D E8 mov dword ptr [ebp-18h],ecx + E0005E7C: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E0005E7F: C7 02 B0 A0 00 E0 mov dword ptr [edx],0E000A0B0h + E0005E85: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0005E88: 66 8B 4D 08 mov cx,word ptr [ebp+8] + E0005E8C: 66 89 48 0C mov word ptr [eax+0Ch],cx + E0005E90: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0005E93: C7 02 50 A6 00 E0 mov dword ptr [edx],0E000A650h + E0005E99: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0005E9C: C7 40 04 38 A6 00 mov dword ptr [eax+4],0E000A638h + E0 + E0005EA3: B9 11 00 00 00 mov ecx,11h + E0005EA8: 33 C0 xor eax,eax + E0005EAA: 8B 7D E4 mov edi,dword ptr [ebp-1Ch] + E0005EAD: 83 C7 20 add edi,20h + E0005EB0: F3 AB rep stos dword ptr es:[edi] + E0005EB2: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0005EB5: C7 41 10 00 00 00 mov dword ptr [ecx+10h],0 + 00 + E0005EBC: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0005EBF: C7 42 14 00 00 00 mov dword ptr [edx+14h],0 + 00 + E0005EC6: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0005EC9: C7 40 18 00 00 00 mov dword ptr [eax+18h],0 + 00 + E0005ED0: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0005ED3: C7 41 1C 00 00 00 mov dword ptr [ecx+1Ch],0 + 00 + E0005EDA: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0005EE1: EB 09 jmp E0005EEC + E0005EE3: 8B 55 FC mov edx,dword ptr [ebp-4] + E0005EE6: 83 C2 01 add edx,1 + E0005EE9: 89 55 FC mov dword ptr [ebp-4],edx + E0005EEC: 83 7D FC 02 cmp dword ptr [ebp-4],2 + E0005EF0: 7D 10 jge E0005F02 + E0005EF2: 8B 45 FC mov eax,dword ptr [ebp-4] + E0005EF5: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0005EF8: C7 44 81 64 00 00 mov dword ptr [ecx+eax*4+64h],0 + 00 00 + E0005F00: EB E1 jmp E0005EE3 + E0005F02: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0005F05: C7 42 6C 00 00 00 mov dword ptr [edx+6Ch],0 + 00 + E0005F0C: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0005F0F: C7 40 70 00 00 00 mov dword ptr [eax+70h],0 + 00 + E0005F16: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0005F19: C7 41 78 00 00 00 mov dword ptr [ecx+78h],0 + 00 + E0005F20: 6A 00 push 0 + E0005F22: 8D 55 EC lea edx,dword ptr [ebp-14h] + E0005F25: 52 push edx + E0005F26: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0005F29: E8 D1 04 00 00 call E00063FF + E0005F2E: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0005F31: 50 push eax + E0005F32: 68 73 5F 00 E0 push 0E0005F73h + E0005F37: 6A 05 push 5 + E0005F39: E8 F0 3F 00 00 call E0009F2E + E0005F3E: 83 C4 0C add esp,0Ch + E0005F41: 6A 01 push 1 + E0005F43: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0005F46: E8 20 0B 00 00 call E0006A6B + E0005F4B: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0005F4E: 5F pop edi + E0005F4F: 8B E5 mov esp,ebp + E0005F51: 5D pop ebp + E0005F52: C2 04 00 ret 4 +??1CNe2000@@UAE@XZ (public: virtual __thiscall CNe2000::~CNe2000(void)): + E0005F55: 55 push ebp + E0005F56: 8B EC mov ebp,esp + E0005F58: 51 push ecx + E0005F59: 89 4D FC mov dword ptr [ebp-4],ecx + E0005F5C: 8B 45 FC mov eax,dword ptr [ebp-4] + E0005F5F: C7 00 50 A6 00 E0 mov dword ptr [eax],0E000A650h + E0005F65: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0005F68: C7 41 04 38 A6 00 mov dword ptr [ecx+4],0E000A638h + E0 + E0005F6F: 8B E5 mov esp,ebp + E0005F71: 5D pop ebp + E0005F72: C3 ret +?Isr@CNe2000@@KAXPAXH@Z (protected: static void __cdecl CNe2000::Isr(void *,int)): + E0005F73: 55 push ebp + E0005F74: 8B EC mov ebp,esp + E0005F76: 83 EC 44 sub esp,44h + E0005F79: 53 push ebx + E0005F7A: 56 push esi + E0005F7B: 57 push edi + E0005F7C: 8B 45 08 mov eax,dword ptr [ebp+8] + E0005F7F: 89 45 F8 mov dword ptr [ebp-8],eax + E0005F82: 68 0C BA 00 E0 push 0E000BA0Ch + E0005F87: E8 90 3F 00 00 call E0009F1C + E0005F8C: 83 C4 04 add esp,4 + E0005F8F: C6 45 EC 20 mov byte ptr [ebp-14h],20h + E0005F93: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0005F96: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0005F9A: 66 89 55 F0 mov word ptr [ebp-10h],dx + E0005F9E: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E0005FA2: 8A 45 EC mov al,byte ptr [ebp-14h] + E0005FA5: EE out dx,al + E0005FA6: C7 45 FC 0D 00 00 mov dword ptr [ebp-4],0Dh + 00 + E0005FAD: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0005FB0: 33 C9 xor ecx,ecx + E0005FB2: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0005FB6: 83 C1 07 add ecx,7 + E0005FB9: 66 89 4D E8 mov word ptr [ebp-18h],cx + E0005FBD: 33 C0 xor eax,eax + E0005FBF: 66 8B 55 E8 mov dx,word ptr [ebp-18h] + E0005FC3: EC in al,dx + E0005FC4: 88 45 E4 mov byte ptr [ebp-1Ch],al + E0005FC7: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0005FCA: 81 E2 FF 00 00 00 and edx,0FFh + E0005FD0: 89 55 F4 mov dword ptr [ebp-0Ch],edx + E0005FD3: 83 7D F4 00 cmp dword ptr [ebp-0Ch],0 + E0005FD7: 0F 84 B4 00 00 00 je E0006091 + E0005FDD: 8B 45 FC mov eax,dword ptr [ebp-4] + E0005FE0: 83 E8 01 sub eax,1 + E0005FE3: 89 45 FC mov dword ptr [ebp-4],eax + E0005FE6: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0005FEA: 77 05 ja E0005FF1 + E0005FEC: E9 A0 00 00 00 jmp E0006091 + E0005FF1: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0005FF4: 83 E1 10 and ecx,10h + E0005FF7: 85 C9 test ecx,ecx + E0005FF9: 74 0A je E0006005 + E0005FFB: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0005FFE: E8 03 0C 00 00 call E0006C06 + E0006003: EB 12 jmp E0006017 + E0006005: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0006008: 83 E2 05 and edx,5 + E000600B: 85 D2 test edx,edx + E000600D: 74 08 je E0006017 + E000600F: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0006012: E8 42 15 00 00 call E0007559 + E0006017: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E000601A: 83 E0 02 and eax,2 + E000601D: 85 C0 test eax,eax + E000601F: 74 0A je E000602B + E0006021: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0006024: E8 B1 0D 00 00 call E0006DDA + E0006029: EB 12 jmp E000603D + E000602B: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E000602E: 83 E1 08 and ecx,8 + E0006031: 85 C9 test ecx,ecx + E0006033: 74 08 je E000603D + E0006035: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0006038: E8 8F 0F 00 00 call E0006FCC + E000603D: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0006040: 83 E2 20 and edx,20h + E0006043: 85 D2 test edx,edx + E0006045: 74 08 je E000604F + E0006047: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E000604A: E8 8F 18 00 00 call E00078DE + E000604F: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0006052: 83 E0 40 and eax,40h + E0006055: 85 C0 test eax,eax + E0006057: 74 1C je E0006075 + E0006059: C6 45 DC 40 mov byte ptr [ebp-24h],40h + E000605D: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0006060: 33 D2 xor edx,edx + E0006062: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006066: 83 C2 07 add edx,7 + E0006069: 66 89 55 E0 mov word ptr [ebp-20h],dx + E000606D: 66 8B 55 E0 mov dx,word ptr [ebp-20h] + E0006071: 8A 45 DC mov al,byte ptr [ebp-24h] + E0006074: EE out dx,al + E0006075: C6 45 D4 22 mov byte ptr [ebp-2Ch],22h + E0006079: 8B 45 F8 mov eax,dword ptr [ebp-8] + E000607C: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006080: 66 89 4D D8 mov word ptr [ebp-28h],cx + E0006084: 66 8B 55 D8 mov dx,word ptr [ebp-28h] + E0006088: 8A 45 D4 mov al,byte ptr [ebp-2Ch] + E000608B: EE out dx,al + E000608C: E9 1C FF FF FF jmp E0005FAD + E0006091: 83 7D F4 00 cmp dword ptr [ebp-0Ch],0 + E0006095: 74 7B je E0006112 + E0006097: C6 45 CC 22 mov byte ptr [ebp-34h],22h + E000609B: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000609E: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E00060A2: 66 89 45 D0 mov word ptr [ebp-30h],ax + E00060A6: 66 8B 55 D0 mov dx,word ptr [ebp-30h] + E00060AA: 8A 45 CC mov al,byte ptr [ebp-34h] + E00060AD: EE out dx,al + E00060AE: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E00060B2: 75 31 jne E00060E5 + E00060B4: 6A 0C push 0Ch + E00060B6: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E00060B9: 51 push ecx + E00060BA: 68 28 BA 00 E0 push 0E000BA28h + E00060BF: E8 4C 3E 00 00 call E0009F10 + E00060C4: 83 C4 0C add esp,0Ch + E00060C7: C6 45 C4 3F mov byte ptr [ebp-3Ch],3Fh + E00060CB: 8B 55 F8 mov edx,dword ptr [ebp-8] + E00060CE: 33 C0 xor eax,eax + E00060D0: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E00060D4: 83 C0 07 add eax,7 + E00060D7: 66 89 45 C8 mov word ptr [ebp-38h],ax + E00060DB: 66 8B 55 C8 mov dx,word ptr [ebp-38h] + E00060DF: 8A 45 C4 mov al,byte ptr [ebp-3Ch] + E00060E2: EE out dx,al + E00060E3: EB 2D jmp E0006112 + E00060E5: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E00060E8: 51 push ecx + E00060E9: 68 98 BA 00 E0 push 0E000BA98h + E00060EE: E8 1D 3E 00 00 call E0009F10 + E00060F3: 83 C4 08 add esp,8 + E00060F6: C6 45 BC FF mov byte ptr [ebp-44h],0FFh + E00060FA: 8B 55 F8 mov edx,dword ptr [ebp-8] + E00060FD: 33 C0 xor eax,eax + E00060FF: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006103: 83 C0 07 add eax,7 + E0006106: 66 89 45 C0 mov word ptr [ebp-40h],ax + E000610A: 66 8B 55 C0 mov dx,word ptr [ebp-40h] + E000610E: 8A 45 BC mov al,byte ptr [ebp-44h] + E0006111: EE out dx,al + E0006112: 5F pop edi + E0006113: 5E pop esi + E0006114: 5B pop ebx + E0006115: 8B E5 mov esp,ebp + E0006117: 5D pop ebp + E0006118: C3 ret +?Detect@CNe2000@@SAPAV1@XZ (public: static class CNe2000 * __cdecl CNe2000::Detect(void)): + E0006119: 55 push ebp + E000611A: 8B EC mov ebp,esp + E000611C: 83 EC 40 sub esp,40h + E000611F: 53 push ebx + E0006120: 56 push esi + E0006121: 57 push edi + E0006122: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E0006129: EB 09 jmp E0006134 + E000612B: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E000612E: 83 C0 01 add eax,1 + E0006131: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0006134: 83 7D F4 05 cmp dword ptr [ebp-0Ch],5 + E0006138: 0F 83 5D 01 00 00 jae E000629B + E000613E: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0006141: 66 8B 14 8D F8 B9 mov dx,word ptr [ecx*4+E000B9F8h] + 00 E0 + E0006149: 66 89 55 F0 mov word ptr [ebp-10h],dx + E000614D: 33 C0 xor eax,eax + E000614F: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E0006153: EC in al,dx + E0006154: 88 45 F8 mov byte ptr [ebp-8],al + E0006157: 33 C0 xor eax,eax + E0006159: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E000615D: EC in al,dx + E000615E: 88 45 E8 mov byte ptr [ebp-18h],al + E0006161: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0006164: 25 FF 00 00 00 and eax,0FFh + E0006169: 3D FF 00 00 00 cmp eax,0FFh + E000616E: 75 1C jne E000618C + E0006170: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0006173: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0006179: 51 push ecx + E000617A: 68 E4 BA 00 E0 push 0E000BAE4h + E000617F: E8 8C 3D 00 00 call E0009F10 + E0006184: 83 C4 08 add esp,8 + E0006187: E9 0A 01 00 00 jmp E0006296 + E000618C: C6 45 E4 61 mov byte ptr [ebp-1Ch],61h + E0006190: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E0006194: 8A 45 E4 mov al,byte ptr [ebp-1Ch] + E0006197: EE out dx,al + E0006198: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E000619B: 81 E2 FF FF 00 00 and edx,0FFFFh + E00061A1: 83 C2 0D add edx,0Dh + E00061A4: 66 89 55 E0 mov word ptr [ebp-20h],dx + E00061A8: 33 C0 xor eax,eax + E00061AA: 66 8B 55 E0 mov dx,word ptr [ebp-20h] + E00061AE: EC in al,dx + E00061AF: 88 45 FC mov byte ptr [ebp-4],al + E00061B2: C6 45 D8 FF mov byte ptr [ebp-28h],0FFh + E00061B6: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E00061B9: 25 FF FF 00 00 and eax,0FFFFh + E00061BE: 83 C0 0D add eax,0Dh + E00061C1: 66 89 45 DC mov word ptr [ebp-24h],ax + E00061C5: 66 8B 55 DC mov dx,word ptr [ebp-24h] + E00061C9: 8A 45 D8 mov al,byte ptr [ebp-28h] + E00061CC: EE out dx,al + E00061CD: C6 45 D4 20 mov byte ptr [ebp-2Ch],20h + E00061D1: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E00061D5: 8A 45 D4 mov al,byte ptr [ebp-2Ch] + E00061D8: EE out dx,al + E00061D9: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E00061DC: 81 E1 FF FF 00 00 and ecx,0FFFFh + E00061E2: 83 C1 0D add ecx,0Dh + E00061E5: 66 89 4D D0 mov word ptr [ebp-30h],cx + E00061E9: 33 C0 xor eax,eax + E00061EB: 66 8B 55 D0 mov dx,word ptr [ebp-30h] + E00061EF: EC in al,dx + E00061F0: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E00061F3: 81 E2 FF FF 00 00 and edx,0FFFFh + E00061F9: 83 C2 0D add edx,0Dh + E00061FC: 66 89 55 CC mov word ptr [ebp-34h],dx + E0006200: 33 C0 xor eax,eax + E0006202: 66 8B 55 CC mov dx,word ptr [ebp-34h] + E0006206: EC in al,dx + E0006207: 88 45 C8 mov byte ptr [ebp-38h],al + E000620A: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E000620D: 25 FF 00 00 00 and eax,0FFh + E0006212: 85 C0 test eax,eax + E0006214: 74 39 je E000624F + E0006216: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E000621A: 8A 45 F8 mov al,byte ptr [ebp-8] + E000621D: EE out dx,al + E000621E: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0006221: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0006227: 83 C1 0D add ecx,0Dh + E000622A: 66 89 4D C4 mov word ptr [ebp-3Ch],cx + E000622E: 66 8B 55 C4 mov dx,word ptr [ebp-3Ch] + E0006232: 8A 45 FC mov al,byte ptr [ebp-4] + E0006235: EE out dx,al + E0006236: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0006239: 81 E2 FF FF 00 00 and edx,0FFFFh + E000623F: 52 push edx + E0006240: 68 28 BB 00 E0 push 0E000BB28h + E0006245: E8 C6 3C 00 00 call E0009F10 + E000624A: 83 C4 08 add esp,8 + E000624D: EB 47 jmp E0006296 + E000624F: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E0006252: 25 FF FF 00 00 and eax,0FFFFh + E0006257: 50 push eax + E0006258: 68 60 BB 00 E0 push 0E000BB60h + E000625D: E8 AE 3C 00 00 call E0009F10 + E0006262: 83 C4 08 add esp,8 + E0006265: 6A 7C push 7Ch + E0006267: E8 0A 3D 00 00 call E0009F76 + E000626C: 83 C4 04 add esp,4 + E000626F: 89 45 EC mov dword ptr [ebp-14h],eax + E0006272: 83 7D EC 00 cmp dword ptr [ebp-14h],0 + E0006276: 74 12 je E000628A + E0006278: 66 8B 4D F0 mov cx,word ptr [ebp-10h] + E000627C: 51 push ecx + E000627D: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0006280: E8 DB FB FF FF call E0005E60 + E0006285: 89 45 C0 mov dword ptr [ebp-40h],eax + E0006288: EB 07 jmp E0006291 + E000628A: C7 45 C0 00 00 00 mov dword ptr [ebp-40h],0 + 00 + E0006291: 8B 45 C0 mov eax,dword ptr [ebp-40h] + E0006294: EB 07 jmp E000629D + E0006296: E9 90 FE FF FF jmp E000612B + E000629B: 33 C0 xor eax,eax + E000629D: 5F pop edi + E000629E: 5E pop esi + E000629F: 5B pop ebx + E00062A0: 8B E5 mov esp,ebp + E00062A2: 5D pop ebp + E00062A3: C3 ret +?DumpProm@CNe2000@@IAEHPAE@Z (protected: int __thiscall CNe2000::DumpProm(unsigned char *)): + E00062A4: 55 push ebp + E00062A5: 8B EC mov ebp,esp + E00062A7: 83 EC 64 sub esp,64h + E00062AA: 53 push ebx + E00062AB: 56 push esi + E00062AC: 57 push edi + E00062AD: 89 4D 9C mov dword ptr [ebp-64h],ecx + E00062B0: C6 45 F8 02 mov byte ptr [ebp-8],2 + E00062B4: C6 45 D0 20 mov byte ptr [ebp-30h],20h + E00062B8: 8B 45 9C mov eax,dword ptr [ebp-64h] + E00062BB: 33 C9 xor ecx,ecx + E00062BD: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E00062C1: 83 C1 0A add ecx,0Ah + E00062C4: 66 89 4D D4 mov word ptr [ebp-2Ch],cx + E00062C8: 66 8B 55 D4 mov dx,word ptr [ebp-2Ch] + E00062CC: 8A 45 D0 mov al,byte ptr [ebp-30h] + E00062CF: EE out dx,al + E00062D0: C6 45 C8 00 mov byte ptr [ebp-38h],0 + E00062D4: 8B 55 9C mov edx,dword ptr [ebp-64h] + E00062D7: 33 C0 xor eax,eax + E00062D9: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E00062DD: 83 C0 0B add eax,0Bh + E00062E0: 66 89 45 CC mov word ptr [ebp-34h],ax + E00062E4: 66 8B 55 CC mov dx,word ptr [ebp-34h] + E00062E8: 8A 45 C8 mov al,byte ptr [ebp-38h] + E00062EB: EE out dx,al + E00062EC: C6 45 C0 00 mov byte ptr [ebp-40h],0 + E00062F0: 8B 4D 9C mov ecx,dword ptr [ebp-64h] + E00062F3: 33 D2 xor edx,edx + E00062F5: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E00062F9: 83 C2 08 add edx,8 + E00062FC: 66 89 55 C4 mov word ptr [ebp-3Ch],dx + E0006300: 66 8B 55 C4 mov dx,word ptr [ebp-3Ch] + E0006304: 8A 45 C0 mov al,byte ptr [ebp-40h] + E0006307: EE out dx,al + E0006308: C6 45 B8 00 mov byte ptr [ebp-48h],0 + E000630C: 8B 45 9C mov eax,dword ptr [ebp-64h] + E000630F: 33 C9 xor ecx,ecx + E0006311: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006315: 83 C1 09 add ecx,9 + E0006318: 66 89 4D BC mov word ptr [ebp-44h],cx + E000631C: 66 8B 55 BC mov dx,word ptr [ebp-44h] + E0006320: 8A 45 B8 mov al,byte ptr [ebp-48h] + E0006323: EE out dx,al + E0006324: C6 45 B0 0A mov byte ptr [ebp-50h],0Ah + E0006328: 8B 55 9C mov edx,dword ptr [ebp-64h] + E000632B: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E000632F: 66 89 45 B4 mov word ptr [ebp-4Ch],ax + E0006333: 66 8B 55 B4 mov dx,word ptr [ebp-4Ch] + E0006337: 8A 45 B0 mov al,byte ptr [ebp-50h] + E000633A: EE out dx,al + E000633B: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0006342: EB 09 jmp E000634D + E0006344: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0006347: 83 C1 02 add ecx,2 + E000634A: 89 4D FC mov dword ptr [ebp-4],ecx + E000634D: 83 7D FC 20 cmp dword ptr [ebp-4],20h + E0006351: 73 64 jae E00063B7 + E0006353: 8B 55 9C mov edx,dword ptr [ebp-64h] + E0006356: 33 C0 xor eax,eax + E0006358: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E000635C: 83 C0 10 add eax,10h + E000635F: 66 89 45 AC mov word ptr [ebp-54h],ax + E0006363: 33 C0 xor eax,eax + E0006365: 66 8B 55 AC mov dx,word ptr [ebp-54h] + E0006369: EC in al,dx + E000636A: 88 45 A8 mov byte ptr [ebp-58h],al + E000636D: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0006370: 8A 55 A8 mov dl,byte ptr [ebp-58h] + E0006373: 88 54 0D D8 mov byte ptr [ebp+ecx-28h],dl + E0006377: 8B 45 9C mov eax,dword ptr [ebp-64h] + E000637A: 33 C9 xor ecx,ecx + E000637C: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006380: 83 C1 10 add ecx,10h + E0006383: 66 89 4D A4 mov word ptr [ebp-5Ch],cx + E0006387: 33 C0 xor eax,eax + E0006389: 66 8B 55 A4 mov dx,word ptr [ebp-5Ch] + E000638D: EC in al,dx + E000638E: 88 45 A0 mov byte ptr [ebp-60h],al + E0006391: 8B 55 FC mov edx,dword ptr [ebp-4] + E0006394: 8A 45 A0 mov al,byte ptr [ebp-60h] + E0006397: 88 44 15 D9 mov byte ptr [ebp+edx-27h],al + E000639B: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000639E: 33 D2 xor edx,edx + E00063A0: 8A 54 0D D8 mov dl,byte ptr [ebp+ecx-28h] + E00063A4: 8B 45 FC mov eax,dword ptr [ebp-4] + E00063A7: 33 C9 xor ecx,ecx + E00063A9: 8A 4C 05 D9 mov cl,byte ptr [ebp+eax-27h] + E00063AD: 3B D1 cmp edx,ecx + E00063AF: 74 04 je E00063B5 + E00063B1: C6 45 F8 01 mov byte ptr [ebp-8],1 + E00063B5: EB 8D jmp E0006344 + E00063B7: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E00063BE: EB 09 jmp E00063C9 + E00063C0: 8B 55 FC mov edx,dword ptr [ebp-4] + E00063C3: 83 C2 01 add edx,1 + E00063C6: 89 55 FC mov dword ptr [ebp-4],edx + E00063C9: 83 7D FC 10 cmp dword ptr [ebp-4],10h + E00063CD: 73 23 jae E00063F2 + E00063CF: 0F BE 45 F8 movsx eax,byte ptr [ebp-8] + E00063D3: 83 E8 02 sub eax,2 + E00063D6: F7 D8 neg eax + E00063D8: 1B C0 sbb eax,eax + E00063DA: F7 D0 not eax + E00063DC: 23 45 FC and eax,dword ptr [ebp-4] + E00063DF: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00063E2: 03 C8 add ecx,eax + E00063E4: 8B 55 08 mov edx,dword ptr [ebp+8] + E00063E7: 03 55 FC add edx,dword ptr [ebp-4] + E00063EA: 8A 44 0D D8 mov al,byte ptr [ebp+ecx-28h] + E00063EE: 88 02 mov byte ptr [edx],al + E00063F0: EB CE jmp E00063C0 + E00063F2: 0F BE 45 F8 movsx eax,byte ptr [ebp-8] + E00063F6: 5F pop edi + E00063F7: 5E pop esi + E00063F8: 5B pop ebx + E00063F9: 8B E5 mov esp,ebp + E00063FB: 5D pop ebp + E00063FC: C2 04 00 ret 4 +?Init@CNe2000@@IAE_NPAE0@Z (protected: bool __thiscall CNe2000::Init(unsigned char *,unsigned char *)): + E00063FF: 55 push ebp + E0006400: 8B EC mov ebp,esp + E0006402: 81 EC 04 01 00 00 sub esp,104h + E0006408: 53 push ebx + E0006409: 56 push esi + E000640A: 57 push edi + E000640B: 89 8D FC FE FF FF mov dword ptr [ebp+FFFFFEFCh],ecx + E0006411: 68 9C BB 00 E0 push 0E000BB9Ch + E0006416: E8 F5 3A 00 00 call E0009F10 + E000641B: 83 C4 04 add esp,4 + E000641E: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E0006424: 33 C9 xor ecx,ecx + E0006426: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E000642A: 83 C1 1F add ecx,1Fh + E000642D: 66 89 4D F8 mov word ptr [ebp-8],cx + E0006431: 33 C0 xor eax,eax + E0006433: 66 8B 55 F8 mov dx,word ptr [ebp-8] + E0006437: EC in al,dx + E0006438: 88 45 F4 mov byte ptr [ebp-0Ch],al + E000643B: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E0006441: 33 C0 xor eax,eax + E0006443: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006447: 83 C0 1F add eax,1Fh + E000644A: 66 89 45 F0 mov word ptr [ebp-10h],ax + E000644E: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E0006452: 8A 45 F4 mov al,byte ptr [ebp-0Ch] + E0006455: EE out dx,al + E0006456: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E000645C: 33 D2 xor edx,edx + E000645E: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006462: 83 C2 07 add edx,7 + E0006465: 66 89 55 EC mov word ptr [ebp-14h],dx + E0006469: 33 C0 xor eax,eax + E000646B: 66 8B 55 EC mov dx,word ptr [ebp-14h] + E000646F: EC in al,dx + E0006470: 88 45 E8 mov byte ptr [ebp-18h],al + E0006473: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0006476: 25 FF 00 00 00 and eax,0FFh + E000647B: 25 80 00 00 00 and eax,80h + E0006480: 85 C0 test eax,eax + E0006482: 75 02 jne E0006486 + E0006484: EB D0 jmp E0006456 + E0006486: 68 D8 BB 00 E0 push 0E000BBD8h + E000648B: E8 80 3A 00 00 call E0009F10 + E0006490: 83 C4 04 add esp,4 + E0006493: C6 45 E0 FF mov byte ptr [ebp-20h],0FFh + E0006497: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E000649D: 33 D2 xor edx,edx + E000649F: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E00064A3: 83 C2 07 add edx,7 + E00064A6: 66 89 55 E4 mov word ptr [ebp-1Ch],dx + E00064AA: 66 8B 55 E4 mov dx,word ptr [ebp-1Ch] + E00064AE: 8A 45 E0 mov al,byte ptr [ebp-20h] + E00064B1: EE out dx,al + E00064B2: C6 45 D8 21 mov byte ptr [ebp-28h],21h + E00064B6: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E00064BC: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E00064C0: 66 89 4D DC mov word ptr [ebp-24h],cx + E00064C4: 66 8B 55 DC mov dx,word ptr [ebp-24h] + E00064C8: 8A 45 D8 mov al,byte ptr [ebp-28h] + E00064CB: EE out dx,al + E00064CC: C6 45 D0 48 mov byte ptr [ebp-30h],48h + E00064D0: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E00064D6: 33 C0 xor eax,eax + E00064D8: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E00064DC: 83 C0 0E add eax,0Eh + E00064DF: 66 89 45 D4 mov word ptr [ebp-2Ch],ax + E00064E3: 66 8B 55 D4 mov dx,word ptr [ebp-2Ch] + E00064E7: 8A 45 D0 mov al,byte ptr [ebp-30h] + E00064EA: EE out dx,al + E00064EB: C6 45 C8 00 mov byte ptr [ebp-38h],0 + E00064EF: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E00064F5: 33 D2 xor edx,edx + E00064F7: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E00064FB: 83 C2 0A add edx,0Ah + E00064FE: 66 89 55 CC mov word ptr [ebp-34h],dx + E0006502: 66 8B 55 CC mov dx,word ptr [ebp-34h] + E0006506: 8A 45 C8 mov al,byte ptr [ebp-38h] + E0006509: EE out dx,al + E000650A: C6 45 C0 00 mov byte ptr [ebp-40h],0 + E000650E: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E0006514: 33 C9 xor ecx,ecx + E0006516: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E000651A: 83 C1 0B add ecx,0Bh + E000651D: 66 89 4D C4 mov word ptr [ebp-3Ch],cx + E0006521: 66 8B 55 C4 mov dx,word ptr [ebp-3Ch] + E0006525: 8A 45 C0 mov al,byte ptr [ebp-40h] + E0006528: EE out dx,al + E0006529: C6 45 B8 00 mov byte ptr [ebp-48h],0 + E000652D: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E0006533: 33 C0 xor eax,eax + E0006535: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006539: 83 C0 0F add eax,0Fh + E000653C: 66 89 45 BC mov word ptr [ebp-44h],ax + E0006540: 66 8B 55 BC mov dx,word ptr [ebp-44h] + E0006544: 8A 45 B8 mov al,byte ptr [ebp-48h] + E0006547: EE out dx,al + E0006548: C6 45 B0 FF mov byte ptr [ebp-50h],0FFh + E000654C: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E0006552: 33 D2 xor edx,edx + E0006554: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006558: 83 C2 07 add edx,7 + E000655B: 66 89 55 B4 mov word ptr [ebp-4Ch],dx + E000655F: 66 8B 55 B4 mov dx,word ptr [ebp-4Ch] + E0006563: 8A 45 B0 mov al,byte ptr [ebp-50h] + E0006566: EE out dx,al + E0006567: C6 45 A8 20 mov byte ptr [ebp-58h],20h + E000656B: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E0006571: 33 C9 xor ecx,ecx + E0006573: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006577: 83 C1 0C add ecx,0Ch + E000657A: 66 89 4D AC mov word ptr [ebp-54h],cx + E000657E: 66 8B 55 AC mov dx,word ptr [ebp-54h] + E0006582: 8A 45 A8 mov al,byte ptr [ebp-58h] + E0006585: EE out dx,al + E0006586: C6 45 A0 02 mov byte ptr [ebp-60h],2 + E000658A: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E0006590: 33 C0 xor eax,eax + E0006592: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006596: 83 C0 0D add eax,0Dh + E0006599: 66 89 45 A4 mov word ptr [ebp-5Ch],ax + E000659D: 66 8B 55 A4 mov dx,word ptr [ebp-5Ch] + E00065A1: 8A 45 A0 mov al,byte ptr [ebp-60h] + E00065A4: EE out dx,al + E00065A5: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00065A8: 51 push ecx + E00065A9: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E00065AF: E8 F0 FC FF FF call E00062A4 + E00065B4: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E00065BA: 89 42 18 mov dword ptr [edx+18h],eax + E00065BD: 8B 45 08 mov eax,dword ptr [ebp+8] + E00065C0: 33 C9 xor ecx,ecx + E00065C2: 8A 48 0E mov cl,byte ptr [eax+0Eh] + E00065C5: 83 F9 57 cmp ecx,57h + E00065C8: 75 0D jne E00065D7 + E00065CA: 8B 55 08 mov edx,dword ptr [ebp+8] + E00065CD: 33 C0 xor eax,eax + E00065CF: 8A 42 0F mov al,byte ptr [edx+0Fh] + E00065D2: 83 F8 57 cmp eax,57h + E00065D5: 74 14 je E00065EB + E00065D7: 68 E8 BB 00 E0 push 0E000BBE8h + E00065DC: E8 2F 39 00 00 call E0009F10 + E00065E1: 83 C4 04 add esp,4 + E00065E4: 32 C0 xor al,al + E00065E6: E9 77 04 00 00 jmp E0006A62 + E00065EB: 68 50 BC 00 E0 push 0E000BC50h + E00065F0: E8 1B 39 00 00 call E0009F10 + E00065F5: 83 C4 04 add esp,4 + E00065F8: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E00065FE: 83 79 18 02 cmp dword ptr [ecx+18h],2 + E0006602: 75 1F jne E0006623 + E0006604: C6 45 98 49 mov byte ptr [ebp-68h],49h + E0006608: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E000660E: 33 C0 xor eax,eax + E0006610: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006614: 83 C0 0E add eax,0Eh + E0006617: 66 89 45 9C mov word ptr [ebp-64h],ax + E000661B: 66 8B 55 9C mov dx,word ptr [ebp-64h] + E000661F: 8A 45 98 mov al,byte ptr [ebp-68h] + E0006622: EE out dx,al + E0006623: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E0006629: 8B 51 18 mov edx,dword ptr [ecx+18h] + E000662C: 83 EA 02 sub edx,2 + E000662F: F7 DA neg edx + E0006631: 1B D2 sbb edx,edx + E0006633: 83 E2 E0 and edx,0E0h + E0006636: 83 C2 40 add edx,40h + E0006639: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E000663F: 89 50 10 mov dword ptr [eax+10h],edx + E0006642: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E0006648: 8B 51 18 mov edx,dword ptr [ecx+18h] + E000664B: 83 EA 02 sub edx,2 + E000664E: F7 DA neg edx + E0006650: 1B D2 sbb edx,edx + E0006652: 83 E2 C0 and edx,0C0h + E0006655: 81 C2 80 00 00 00 add edx,80h + E000665B: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E0006661: 89 50 14 mov dword ptr [eax+14h],edx + E0006664: C6 45 90 21 mov byte ptr [ebp-70h],21h + E0006668: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E000666E: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006672: 66 89 55 94 mov word ptr [ebp-6Ch],dx + E0006676: 66 8B 55 94 mov dx,word ptr [ebp-6Ch] + E000667A: 8A 45 90 mov al,byte ptr [ebp-70h] + E000667D: EE out dx,al + E000667E: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E0006684: 8A 48 10 mov cl,byte ptr [eax+10h] + E0006687: 88 4D 88 mov byte ptr [ebp-78h],cl + E000668A: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E0006690: 33 C0 xor eax,eax + E0006692: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006696: 83 C0 04 add eax,4 + E0006699: 66 89 45 8C mov word ptr [ebp-74h],ax + E000669D: 66 8B 55 8C mov dx,word ptr [ebp-74h] + E00066A1: 8A 45 88 mov al,byte ptr [ebp-78h] + E00066A4: EE out dx,al + E00066A5: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E00066AB: 8B 51 10 mov edx,dword ptr [ecx+10h] + E00066AE: 83 C2 0C add edx,0Ch + E00066B1: 88 55 80 mov byte ptr [ebp-80h],dl + E00066B4: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E00066BA: 33 C9 xor ecx,ecx + E00066BC: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E00066C0: 83 C1 01 add ecx,1 + E00066C3: 66 89 4D 84 mov word ptr [ebp-7Ch],cx + E00066C7: 66 8B 55 84 mov dx,word ptr [ebp-7Ch] + E00066CB: 8A 45 80 mov al,byte ptr [ebp-80h] + E00066CE: EE out dx,al + E00066CF: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E00066D5: 8B 42 14 mov eax,dword ptr [edx+14h] + E00066D8: 83 E8 01 sub eax,1 + E00066DB: 88 85 78 FF FF FF mov byte ptr [ebp+FFFFFF78h],al + E00066E1: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E00066E7: 33 D2 xor edx,edx + E00066E9: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E00066ED: 83 C2 03 add edx,3 + E00066F0: 66 89 95 7C FF FF mov word ptr [ebp+FFFFFF7Ch],dx + FF + E00066F7: 66 8B 95 7C FF FF mov dx,word ptr [ebp+FFFFFF7Ch] + FF + E00066FE: 8A 85 78 FF FF FF mov al,byte ptr [ebp+FFFFFF78h] + E0006704: EE out dx,al + E0006705: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E000670B: 8A 48 14 mov cl,byte ptr [eax+14h] + E000670E: 88 8D 70 FF FF FF mov byte ptr [ebp+FFFFFF70h],cl + E0006714: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E000671A: 33 C0 xor eax,eax + E000671C: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006720: 83 C0 02 add eax,2 + E0006723: 66 89 85 74 FF FF mov word ptr [ebp+FFFFFF74h],ax + FF + E000672A: 66 8B 95 74 FF FF mov dx,word ptr [ebp+FFFFFF74h] + FF + E0006731: 8A 85 70 FF FF FF mov al,byte ptr [ebp+FFFFFF70h] + E0006737: EE out dx,al + E0006738: C6 85 68 FF FF FF mov byte ptr [ebp+FFFFFF68h],0 + 00 + E000673F: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E0006745: 33 D2 xor edx,edx + E0006747: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E000674B: 83 C2 0F add edx,0Fh + E000674E: 66 89 95 6C FF FF mov word ptr [ebp+FFFFFF6Ch],dx + FF + E0006755: 66 8B 95 6C FF FF mov dx,word ptr [ebp+FFFFFF6Ch] + FF + E000675C: 8A 85 68 FF FF FF mov al,byte ptr [ebp+FFFFFF68h] + E0006762: EE out dx,al + E0006763: C6 85 60 FF FF FF mov byte ptr [ebp+FFFFFF60h],0FFh + FF + E000676A: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E0006770: 33 C9 xor ecx,ecx + E0006772: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006776: 83 C1 07 add ecx,7 + E0006779: 66 89 8D 64 FF FF mov word ptr [ebp+FFFFFF64h],cx + FF + E0006780: 66 8B 95 64 FF FF mov dx,word ptr [ebp+FFFFFF64h] + FF + E0006787: 8A 85 60 FF FF FF mov al,byte ptr [ebp+FFFFFF60h] + E000678D: EE out dx,al + E000678E: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E0006794: 8B 42 10 mov eax,dword ptr [edx+10h] + E0006797: 83 C0 0C add eax,0Ch + E000679A: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E00067A0: 89 41 1C mov dword ptr [ecx+1Ch],eax + E00067A3: C6 85 58 FF FF FF mov byte ptr [ebp+FFFFFF58h],61h + 61 + E00067AA: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E00067B0: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E00067B4: 66 89 85 5C FF FF mov word ptr [ebp+FFFFFF5Ch],ax + FF + E00067BB: 66 8B 95 5C FF FF mov dx,word ptr [ebp+FFFFFF5Ch] + FF + E00067C2: 8A 85 58 FF FF FF mov al,byte ptr [ebp+FFFFFF58h] + E00067C8: EE out dx,al + E00067C9: 83 7D 0C 00 cmp dword ptr [ebp+0Ch],0 + E00067CD: 74 52 je E0006821 + E00067CF: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E00067D6: EB 09 jmp E00067E1 + E00067D8: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00067DB: 83 C1 01 add ecx,1 + E00067DE: 89 4D FC mov dword ptr [ebp-4],ecx + E00067E1: 83 7D FC 06 cmp dword ptr [ebp-4],6 + E00067E5: 73 38 jae E000681F + E00067E7: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00067EA: 03 55 FC add edx,dword ptr [ebp-4] + E00067ED: 8A 02 mov al,byte ptr [edx] + E00067EF: 88 85 50 FF FF FF mov byte ptr [ebp+FFFFFF50h],al + E00067F5: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E00067FB: 33 D2 xor edx,edx + E00067FD: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006801: 8B 45 FC mov eax,dword ptr [ebp-4] + E0006804: 8D 4C 02 01 lea ecx,dword ptr [edx+eax+1] + E0006808: 66 89 8D 54 FF FF mov word ptr [ebp+FFFFFF54h],cx + FF + E000680F: 66 8B 95 54 FF FF mov dx,word ptr [ebp+FFFFFF54h] + FF + E0006816: 8A 85 50 FF FF FF mov al,byte ptr [ebp+FFFFFF50h] + E000681C: EE out dx,al + E000681D: EB B9 jmp E00067D8 + E000681F: EB 50 jmp E0006871 + E0006821: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0006828: EB 09 jmp E0006833 + E000682A: 8B 55 FC mov edx,dword ptr [ebp-4] + E000682D: 83 C2 01 add edx,1 + E0006830: 89 55 FC mov dword ptr [ebp-4],edx + E0006833: 83 7D FC 06 cmp dword ptr [ebp-4],6 + E0006837: 73 38 jae E0006871 + E0006839: 8B 45 08 mov eax,dword ptr [ebp+8] + E000683C: 03 45 FC add eax,dword ptr [ebp-4] + E000683F: 8A 08 mov cl,byte ptr [eax] + E0006841: 88 8D 48 FF FF FF mov byte ptr [ebp+FFFFFF48h],cl + E0006847: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E000684D: 33 C0 xor eax,eax + E000684F: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006853: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0006856: 8D 54 08 01 lea edx,dword ptr [eax+ecx+1] + E000685A: 66 89 95 4C FF FF mov word ptr [ebp+FFFFFF4Ch],dx + FF + E0006861: 66 8B 95 4C FF FF mov dx,word ptr [ebp+FFFFFF4Ch] + FF + E0006868: 8A 85 48 FF FF FF mov al,byte ptr [ebp+FFFFFF48h] + E000686E: EE out dx,al + E000686F: EB B9 jmp E000682A + E0006871: 68 AC BC 00 E0 push 0E000BCACh + E0006876: E8 95 36 00 00 call E0009F10 + E000687B: 83 C4 04 add esp,4 + E000687E: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E0006884: 33 C9 xor ecx,ecx + E0006886: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E000688A: 83 C1 06 add ecx,6 + E000688D: 66 89 8D 44 FF FF mov word ptr [ebp+FFFFFF44h],cx + FF + E0006894: 33 C0 xor eax,eax + E0006896: 66 8B 95 44 FF FF mov dx,word ptr [ebp+FFFFFF44h] + FF + E000689D: EC in al,dx + E000689E: 88 85 40 FF FF FF mov byte ptr [ebp+FFFFFF40h],al + E00068A4: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E00068AA: 33 C0 xor eax,eax + E00068AC: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E00068B0: 83 C0 05 add eax,5 + E00068B3: 66 89 85 3C FF FF mov word ptr [ebp+FFFFFF3Ch],ax + FF + E00068BA: 33 C0 xor eax,eax + E00068BC: 66 8B 95 3C FF FF mov dx,word ptr [ebp+FFFFFF3Ch] + FF + E00068C3: EC in al,dx + E00068C4: 88 85 38 FF FF FF mov byte ptr [ebp+FFFFFF38h],al + E00068CA: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E00068D0: 33 D2 xor edx,edx + E00068D2: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E00068D6: 83 C2 04 add edx,4 + E00068D9: 66 89 95 34 FF FF mov word ptr [ebp+FFFFFF34h],dx + FF + E00068E0: 33 C0 xor eax,eax + E00068E2: 66 8B 95 34 FF FF mov dx,word ptr [ebp+FFFFFF34h] + FF + E00068E9: EC in al,dx + E00068EA: 88 85 30 FF FF FF mov byte ptr [ebp+FFFFFF30h],al + E00068F0: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E00068F6: 33 C9 xor ecx,ecx + E00068F8: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E00068FC: 83 C1 03 add ecx,3 + E00068FF: 66 89 8D 2C FF FF mov word ptr [ebp+FFFFFF2Ch],cx + FF + E0006906: 33 C0 xor eax,eax + E0006908: 66 8B 95 2C FF FF mov dx,word ptr [ebp+FFFFFF2Ch] + FF + E000690F: EC in al,dx + E0006910: 88 85 28 FF FF FF mov byte ptr [ebp+FFFFFF28h],al + E0006916: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E000691C: 33 C0 xor eax,eax + E000691E: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006922: 83 C0 02 add eax,2 + E0006925: 66 89 85 24 FF FF mov word ptr [ebp+FFFFFF24h],ax + FF + E000692C: 33 C0 xor eax,eax + E000692E: 66 8B 95 24 FF FF mov dx,word ptr [ebp+FFFFFF24h] + FF + E0006935: EC in al,dx + E0006936: 88 85 20 FF FF FF mov byte ptr [ebp+FFFFFF20h],al + E000693C: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E0006942: 33 D2 xor edx,edx + E0006944: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006948: 83 C2 01 add edx,1 + E000694B: 66 89 95 1C FF FF mov word ptr [ebp+FFFFFF1Ch],dx + FF + E0006952: 33 C0 xor eax,eax + E0006954: 66 8B 95 1C FF FF mov dx,word ptr [ebp+FFFFFF1Ch] + FF + E000695B: EC in al,dx + E000695C: 88 85 18 FF FF FF mov byte ptr [ebp+FFFFFF18h],al + E0006962: 8B 85 40 FF FF FF mov eax,dword ptr [ebp+FFFFFF40h] + E0006968: 25 FF 00 00 00 and eax,0FFh + E000696D: 50 push eax + E000696E: 8B 8D 38 FF FF FF mov ecx,dword ptr [ebp+FFFFFF38h] + E0006974: 81 E1 FF 00 00 00 and ecx,0FFh + E000697A: 51 push ecx + E000697B: 8B 95 30 FF FF FF mov edx,dword ptr [ebp+FFFFFF30h] + E0006981: 81 E2 FF 00 00 00 and edx,0FFh + E0006987: 52 push edx + E0006988: 8B 85 28 FF FF FF mov eax,dword ptr [ebp+FFFFFF28h] + E000698E: 25 FF 00 00 00 and eax,0FFh + E0006993: 50 push eax + E0006994: 8B 8D 20 FF FF FF mov ecx,dword ptr [ebp+FFFFFF20h] + E000699A: 81 E1 FF 00 00 00 and ecx,0FFh + E00069A0: 51 push ecx + E00069A1: 8B 95 18 FF FF FF mov edx,dword ptr [ebp+FFFFFF18h] + E00069A7: 81 E2 FF 00 00 00 and edx,0FFh + E00069AD: 52 push edx + E00069AE: 68 E4 BC 00 E0 push 0E000BCE4h + E00069B3: E8 58 35 00 00 call E0009F10 + E00069B8: 83 C4 1C add esp,1Ch + E00069BB: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E00069C2: EB 09 jmp E00069CD + E00069C4: 8B 45 FC mov eax,dword ptr [ebp-4] + E00069C7: 83 C0 01 add eax,1 + E00069CA: 89 45 FC mov dword ptr [ebp-4],eax + E00069CD: 83 7D FC 08 cmp dword ptr [ebp-4],8 + E00069D1: 73 31 jae E0006A04 + E00069D3: C6 85 10 FF FF FF mov byte ptr [ebp+FFFFFF10h],0FFh + FF + E00069DA: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E00069E0: 33 D2 xor edx,edx + E00069E2: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E00069E6: 8B 45 FC mov eax,dword ptr [ebp-4] + E00069E9: 8D 4C 02 08 lea ecx,dword ptr [edx+eax+8] + E00069ED: 66 89 8D 14 FF FF mov word ptr [ebp+FFFFFF14h],cx + FF + E00069F4: 66 8B 95 14 FF FF mov dx,word ptr [ebp+FFFFFF14h] + FF + E00069FB: 8A 85 10 FF FF FF mov al,byte ptr [ebp+FFFFFF10h] + E0006A01: EE out dx,al + E0006A02: EB C0 jmp E00069C4 + E0006A04: 8B 95 FC FE FF FF mov edx,dword ptr [ebp+FFFFFEFCh] + E0006A0A: 8B 42 10 mov eax,dword ptr [edx+10h] + E0006A0D: 83 C0 0C add eax,0Ch + E0006A10: 88 85 08 FF FF FF mov byte ptr [ebp+FFFFFF08h],al + E0006A16: 8B 8D FC FE FF FF mov ecx,dword ptr [ebp+FFFFFEFCh] + E0006A1C: 33 D2 xor edx,edx + E0006A1E: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006A22: 83 C2 07 add edx,7 + E0006A25: 66 89 95 0C FF FF mov word ptr [ebp+FFFFFF0Ch],dx + FF + E0006A2C: 66 8B 95 0C FF FF mov dx,word ptr [ebp+FFFFFF0Ch] + FF + E0006A33: 8A 85 08 FF FF FF mov al,byte ptr [ebp+FFFFFF08h] + E0006A39: EE out dx,al + E0006A3A: C6 85 00 FF FF FF mov byte ptr [ebp+FFFFFF00h],21h + 21 + E0006A41: 8B 85 FC FE FF FF mov eax,dword ptr [ebp+FFFFFEFCh] + E0006A47: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006A4B: 66 89 8D 04 FF FF mov word ptr [ebp+FFFFFF04h],cx + FF + E0006A52: 66 8B 95 04 FF FF mov dx,word ptr [ebp+FFFFFF04h] + FF + E0006A59: 8A 85 00 FF FF FF mov al,byte ptr [ebp+FFFFFF00h] + E0006A5F: EE out dx,al + E0006A60: B0 01 mov al,1 + E0006A62: 5F pop edi + E0006A63: 5E pop esi + E0006A64: 5B pop ebx + E0006A65: 8B E5 mov esp,ebp + E0006A67: 5D pop ebp + E0006A68: C2 08 00 ret 8 +?Start@CNe2000@@IAEX_N@Z (protected: void __thiscall CNe2000::Start(bool)): + E0006A6B: 55 push ebp + E0006A6C: 8B EC mov ebp,esp + E0006A6E: 83 EC 6C sub esp,6Ch + E0006A71: 53 push ebx + E0006A72: 56 push esi + E0006A73: 57 push edi + E0006A74: 89 4D 94 mov dword ptr [ebp-6Ch],ecx + E0006A77: 68 0C BD 00 E0 push 0E000BD0Ch + E0006A7C: E8 8F 34 00 00 call E0009F10 + E0006A81: 83 C4 04 add esp,4 + E0006A84: C6 45 F8 FF mov byte ptr [ebp-8],0FFh + E0006A88: 8B 45 94 mov eax,dword ptr [ebp-6Ch] + E0006A8B: 33 C9 xor ecx,ecx + E0006A8D: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006A91: 83 C1 07 add ecx,7 + E0006A94: 66 89 4D FC mov word ptr [ebp-4],cx + E0006A98: 66 8B 55 FC mov dx,word ptr [ebp-4] + E0006A9C: 8A 45 F8 mov al,byte ptr [ebp-8] + E0006A9F: EE out dx,al + E0006AA0: C6 45 F0 3F mov byte ptr [ebp-10h],3Fh + E0006AA4: 8B 55 94 mov edx,dword ptr [ebp-6Ch] + E0006AA7: 33 C0 xor eax,eax + E0006AA9: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006AAD: 83 C0 0F add eax,0Fh + E0006AB0: 66 89 45 F4 mov word ptr [ebp-0Ch],ax + E0006AB4: 66 8B 55 F4 mov dx,word ptr [ebp-0Ch] + E0006AB8: 8A 45 F0 mov al,byte ptr [ebp-10h] + E0006ABB: EE out dx,al + E0006ABC: C6 45 E8 22 mov byte ptr [ebp-18h],22h + E0006AC0: 8B 4D 94 mov ecx,dword ptr [ebp-6Ch] + E0006AC3: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006AC7: 66 89 55 EC mov word ptr [ebp-14h],dx + E0006ACB: 66 8B 55 EC mov dx,word ptr [ebp-14h] + E0006ACF: 8A 45 E8 mov al,byte ptr [ebp-18h] + E0006AD2: EE out dx,al + E0006AD3: C6 45 E0 00 mov byte ptr [ebp-20h],0 + E0006AD7: 8B 45 94 mov eax,dword ptr [ebp-6Ch] + E0006ADA: 33 C9 xor ecx,ecx + E0006ADC: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006AE0: 83 C1 0D add ecx,0Dh + E0006AE3: 66 89 4D E4 mov word ptr [ebp-1Ch],cx + E0006AE7: 66 8B 55 E4 mov dx,word ptr [ebp-1Ch] + E0006AEB: 8A 45 E0 mov al,byte ptr [ebp-20h] + E0006AEE: EE out dx,al + E0006AEF: 8B 55 08 mov edx,dword ptr [ebp+8] + E0006AF2: 81 E2 FF 00 00 00 and edx,0FFh + E0006AF8: 85 D2 test edx,edx + E0006AFA: 74 1E je E0006B1A + E0006AFC: C6 45 D8 18 mov byte ptr [ebp-28h],18h + E0006B00: 8B 45 94 mov eax,dword ptr [ebp-6Ch] + E0006B03: 33 C9 xor ecx,ecx + E0006B05: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006B09: 83 C1 0C add ecx,0Ch + E0006B0C: 66 89 4D DC mov word ptr [ebp-24h],cx + E0006B10: 66 8B 55 DC mov dx,word ptr [ebp-24h] + E0006B14: 8A 45 D8 mov al,byte ptr [ebp-28h] + E0006B17: EE out dx,al + E0006B18: EB 1C jmp E0006B36 + E0006B1A: C6 45 D0 0C mov byte ptr [ebp-30h],0Ch + E0006B1E: 8B 55 94 mov edx,dword ptr [ebp-6Ch] + E0006B21: 33 C0 xor eax,eax + E0006B23: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006B27: 83 C0 0C add eax,0Ch + E0006B2A: 66 89 45 D4 mov word ptr [ebp-2Ch],ax + E0006B2E: 66 8B 55 D4 mov dx,word ptr [ebp-2Ch] + E0006B32: 8A 45 D0 mov al,byte ptr [ebp-30h] + E0006B35: EE out dx,al + E0006B36: 68 3C BD 00 E0 push 0E000BD3Ch + E0006B3B: E8 D0 33 00 00 call E0009F10 + E0006B40: 83 C4 04 add esp,4 + E0006B43: C6 45 C8 50 mov byte ptr [ebp-38h],50h + E0006B47: 8B 4D 94 mov ecx,dword ptr [ebp-6Ch] + E0006B4A: 33 D2 xor edx,edx + E0006B4C: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006B50: 83 C2 0F add edx,0Fh + E0006B53: 66 89 55 CC mov word ptr [ebp-34h],dx + E0006B57: 66 8B 55 CC mov dx,word ptr [ebp-34h] + E0006B5B: 8A 45 C8 mov al,byte ptr [ebp-38h] + E0006B5E: EE out dx,al + E0006B5F: C6 45 C0 00 mov byte ptr [ebp-40h],0 + E0006B63: 8B 45 94 mov eax,dword ptr [ebp-6Ch] + E0006B66: 33 C9 xor ecx,ecx + E0006B68: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006B6C: 83 C1 0A add ecx,0Ah + E0006B6F: 66 89 4D C4 mov word ptr [ebp-3Ch],cx + E0006B73: 66 8B 55 C4 mov dx,word ptr [ebp-3Ch] + E0006B77: 8A 45 C0 mov al,byte ptr [ebp-40h] + E0006B7A: EE out dx,al + E0006B7B: C6 45 B8 00 mov byte ptr [ebp-48h],0 + E0006B7F: 8B 55 94 mov edx,dword ptr [ebp-6Ch] + E0006B82: 33 C0 xor eax,eax + E0006B84: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006B88: 83 C0 0B add eax,0Bh + E0006B8B: 66 89 45 BC mov word ptr [ebp-44h],ax + E0006B8F: 66 8B 55 BC mov dx,word ptr [ebp-44h] + E0006B93: 8A 45 B8 mov al,byte ptr [ebp-48h] + E0006B96: EE out dx,al + E0006B97: C6 45 B0 0A mov byte ptr [ebp-50h],0Ah + E0006B9B: 8B 4D 94 mov ecx,dword ptr [ebp-6Ch] + E0006B9E: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006BA2: 66 89 55 B4 mov word ptr [ebp-4Ch],dx + E0006BA6: 66 8B 55 B4 mov dx,word ptr [ebp-4Ch] + E0006BAA: 8A 45 B0 mov al,byte ptr [ebp-50h] + E0006BAD: EE out dx,al + E0006BAE: C6 45 A8 3F mov byte ptr [ebp-58h],3Fh + E0006BB2: 8B 45 94 mov eax,dword ptr [ebp-6Ch] + E0006BB5: 33 C9 xor ecx,ecx + E0006BB7: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006BBB: 83 C1 0F add ecx,0Fh + E0006BBE: 66 89 4D AC mov word ptr [ebp-54h],cx + E0006BC2: 66 8B 55 AC mov dx,word ptr [ebp-54h] + E0006BC6: 8A 45 A8 mov al,byte ptr [ebp-58h] + E0006BC9: EE out dx,al + E0006BCA: C6 45 A0 22 mov byte ptr [ebp-60h],22h + E0006BCE: 8B 55 94 mov edx,dword ptr [ebp-6Ch] + E0006BD1: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006BD5: 66 89 45 A4 mov word ptr [ebp-5Ch],ax + E0006BD9: 66 8B 55 A4 mov dx,word ptr [ebp-5Ch] + E0006BDD: 8A 45 A0 mov al,byte ptr [ebp-60h] + E0006BE0: EE out dx,al + E0006BE1: C6 45 98 FF mov byte ptr [ebp-68h],0FFh + E0006BE5: 8B 4D 94 mov ecx,dword ptr [ebp-6Ch] + E0006BE8: 33 D2 xor edx,edx + E0006BEA: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006BEE: 83 C2 07 add edx,7 + E0006BF1: 66 89 55 9C mov word ptr [ebp-64h],dx + E0006BF5: 66 8B 55 9C mov dx,word ptr [ebp-64h] + E0006BF9: 8A 45 98 mov al,byte ptr [ebp-68h] + E0006BFC: EE out dx,al + E0006BFD: 5F pop edi + E0006BFE: 5E pop esi + E0006BFF: 5B pop ebx + E0006C00: 8B E5 mov esp,ebp + E0006C02: 5D pop ebp + E0006C03: C2 04 00 ret 4 +?Overrun@CNe2000@@IAEXXZ (protected: void __thiscall CNe2000::Overrun(void)): + E0006C06: 55 push ebp + E0006C07: 8B EC mov ebp,esp + E0006C09: 83 EC 64 sub esp,64h + E0006C0C: 53 push ebx + E0006C0D: 56 push esi + E0006C0E: 57 push edi + E0006C0F: 89 4D 9C mov dword ptr [ebp-64h],ecx + E0006C12: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0006C19: 68 84 BD 00 E0 push 0E000BD84h + E0006C1E: E8 ED 32 00 00 call E0009F10 + E0006C23: 83 C4 04 add esp,4 + E0006C26: 8B 45 9C mov eax,dword ptr [ebp-64h] + E0006C29: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006C2D: 66 89 4D EC mov word ptr [ebp-14h],cx + E0006C31: 33 C0 xor eax,eax + E0006C33: 66 8B 55 EC mov dx,word ptr [ebp-14h] + E0006C37: EC in al,dx + E0006C38: 88 45 E8 mov byte ptr [ebp-18h],al + E0006C3B: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E0006C3E: 81 E2 FF 00 00 00 and edx,0FFh + E0006C44: 83 E2 04 and edx,4 + E0006C47: 89 55 F8 mov dword ptr [ebp-8],edx + E0006C4A: C6 45 E0 21 mov byte ptr [ebp-20h],21h + E0006C4E: 8B 45 9C mov eax,dword ptr [ebp-64h] + E0006C51: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006C55: 66 89 4D E4 mov word ptr [ebp-1Ch],cx + E0006C59: 66 8B 55 E4 mov dx,word ptr [ebp-1Ch] + E0006C5D: 8A 45 E0 mov al,byte ptr [ebp-20h] + E0006C60: EE out dx,al + E0006C61: 8B 55 9C mov edx,dword ptr [ebp-64h] + E0006C64: 8B 42 48 mov eax,dword ptr [edx+48h] + E0006C67: 83 C0 01 add eax,1 + E0006C6A: 8B 4D 9C mov ecx,dword ptr [ebp-64h] + E0006C6D: 89 41 48 mov dword ptr [ecx+48h],eax + E0006C70: E8 A1 32 00 00 call E0009F16 + E0006C75: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0006C78: 68 D0 BD 00 E0 push 0E000BDD0h + E0006C7D: E8 8E 32 00 00 call E0009F10 + E0006C82: 83 C4 04 add esp,4 + E0006C85: 6A 02 push 2 + E0006C87: E8 79 EC FF FF call E0005905 + E0006C8C: 83 C4 04 add esp,4 + E0006C8F: 68 E0 BD 00 E0 push 0E000BDE0h + E0006C94: E8 77 32 00 00 call E0009F10 + E0006C99: 83 C4 04 add esp,4 + E0006C9C: C6 45 D8 00 mov byte ptr [ebp-28h],0 + E0006CA0: 8B 55 9C mov edx,dword ptr [ebp-64h] + E0006CA3: 33 C0 xor eax,eax + E0006CA5: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006CA9: 83 C0 0A add eax,0Ah + E0006CAC: 66 89 45 DC mov word ptr [ebp-24h],ax + E0006CB0: 66 8B 55 DC mov dx,word ptr [ebp-24h] + E0006CB4: 8A 45 D8 mov al,byte ptr [ebp-28h] + E0006CB7: EE out dx,al + E0006CB8: C6 45 D0 00 mov byte ptr [ebp-30h],0 + E0006CBC: 8B 4D 9C mov ecx,dword ptr [ebp-64h] + E0006CBF: 33 D2 xor edx,edx + E0006CC1: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006CC5: 83 C2 0B add edx,0Bh + E0006CC8: 66 89 55 D4 mov word ptr [ebp-2Ch],dx + E0006CCC: 66 8B 55 D4 mov dx,word ptr [ebp-2Ch] + E0006CD0: 8A 45 D0 mov al,byte ptr [ebp-30h] + E0006CD3: EE out dx,al + E0006CD4: 83 7D F8 00 cmp dword ptr [ebp-8],0 + E0006CD8: 74 36 je E0006D10 + E0006CDA: 8B 45 9C mov eax,dword ptr [ebp-64h] + E0006CDD: 33 C9 xor ecx,ecx + E0006CDF: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006CE3: 83 C1 07 add ecx,7 + E0006CE6: 66 89 4D CC mov word ptr [ebp-34h],cx + E0006CEA: 33 C0 xor eax,eax + E0006CEC: 66 8B 55 CC mov dx,word ptr [ebp-34h] + E0006CF0: EC in al,dx + E0006CF1: 88 45 C8 mov byte ptr [ebp-38h],al + E0006CF4: 8B 55 C8 mov edx,dword ptr [ebp-38h] + E0006CF7: 81 E2 FF 00 00 00 and edx,0FFh + E0006CFD: 83 E2 0A and edx,0Ah + E0006D00: 89 55 F0 mov dword ptr [ebp-10h],edx + E0006D03: 83 7D F0 00 cmp dword ptr [ebp-10h],0 + E0006D07: 75 07 jne E0006D10 + E0006D09: C7 45 FC 01 00 00 mov dword ptr [ebp-4],1 + 00 + E0006D10: C6 45 C0 02 mov byte ptr [ebp-40h],2 + E0006D14: 8B 45 9C mov eax,dword ptr [ebp-64h] + E0006D17: 33 C9 xor ecx,ecx + E0006D19: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006D1D: 83 C1 0D add ecx,0Dh + E0006D20: 66 89 4D C4 mov word ptr [ebp-3Ch],cx + E0006D24: 66 8B 55 C4 mov dx,word ptr [ebp-3Ch] + E0006D28: 8A 45 C0 mov al,byte ptr [ebp-40h] + E0006D2B: EE out dx,al + E0006D2C: C6 45 B8 22 mov byte ptr [ebp-48h],22h + E0006D30: 8B 55 9C mov edx,dword ptr [ebp-64h] + E0006D33: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006D37: 66 89 45 BC mov word ptr [ebp-44h],ax + E0006D3B: 66 8B 55 BC mov dx,word ptr [ebp-44h] + E0006D3F: 8A 45 B8 mov al,byte ptr [ebp-48h] + E0006D42: EE out dx,al + E0006D43: 8B 4D 9C mov ecx,dword ptr [ebp-64h] + E0006D46: E8 0E 08 00 00 call E0007559 + E0006D4B: C6 45 B0 10 mov byte ptr [ebp-50h],10h + E0006D4F: 8B 4D 9C mov ecx,dword ptr [ebp-64h] + E0006D52: 33 D2 xor edx,edx + E0006D54: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0006D58: 83 C2 07 add edx,7 + E0006D5B: 66 89 55 B4 mov word ptr [ebp-4Ch],dx + E0006D5F: 66 8B 55 B4 mov dx,word ptr [ebp-4Ch] + E0006D63: 8A 45 B0 mov al,byte ptr [ebp-50h] + E0006D66: EE out dx,al + E0006D67: C6 45 A8 00 mov byte ptr [ebp-58h],0 + E0006D6B: 8B 45 9C mov eax,dword ptr [ebp-64h] + E0006D6E: 33 C9 xor ecx,ecx + E0006D70: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006D74: 83 C1 0D add ecx,0Dh + E0006D77: 66 89 4D AC mov word ptr [ebp-54h],cx + E0006D7B: 66 8B 55 AC mov dx,word ptr [ebp-54h] + E0006D7F: 8A 45 A8 mov al,byte ptr [ebp-58h] + E0006D82: EE out dx,al + E0006D83: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0006D87: 74 17 je E0006DA0 + E0006D89: C6 45 A0 26 mov byte ptr [ebp-60h],26h + E0006D8D: 8B 55 9C mov edx,dword ptr [ebp-64h] + E0006D90: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0006D94: 66 89 45 A4 mov word ptr [ebp-5Ch],ax + E0006D98: 66 8B 55 A4 mov dx,word ptr [ebp-5Ch] + E0006D9C: 8A 45 A0 mov al,byte ptr [ebp-60h] + E0006D9F: EE out dx,al + E0006DA0: 5F pop edi + E0006DA1: 5E pop esi + E0006DA2: 5B pop ebx + E0006DA3: 8B E5 mov esp,ebp + E0006DA5: 5D pop ebp + E0006DA6: C3 ret +?alloc_buffer_data@@YAPAUpacket_data_t@@I@Z (struct packet_data_t * __cdecl alloc_buffer_data(unsigned int)): + E0006DA7: 55 push ebp + E0006DA8: 8B EC mov ebp,esp + E0006DAA: 8B 45 08 mov eax,dword ptr [ebp+8] + E0006DAD: 50 push eax + E0006DAE: E8 8D 31 00 00 call E0009F40 + E0006DB3: 83 C4 04 add esp,4 + E0006DB6: 5D pop ebp + E0006DB7: C3 ret +?free_buffer@@YAXPAUpacket_buffer_t@@@Z (void __cdecl free_buffer(struct packet_buffer_t *)): + E0006DB8: 55 push ebp + E0006DB9: 8B EC mov ebp,esp + E0006DBB: 8B 45 08 mov eax,dword ptr [ebp+8] + E0006DBE: 50 push eax + E0006DBF: E8 82 31 00 00 call E0009F46 + E0006DC4: 83 C4 04 add esp,4 + E0006DC7: 5D pop ebp + E0006DC8: C3 ret +?free_buffer_data@@YAXPAUpacket_data_t@@@Z (void __cdecl free_buffer_data(struct packet_data_t *)): + E0006DC9: 55 push ebp + E0006DCA: 8B EC mov ebp,esp + E0006DCC: 8B 45 08 mov eax,dword ptr [ebp+8] + E0006DCF: 50 push eax + E0006DD0: E8 71 31 00 00 call E0009F46 + E0006DD5: 83 C4 04 add esp,4 + E0006DD8: 5D pop ebp + E0006DD9: C3 ret +?Transmit@CNe2000@@IAEXXZ (protected: void __thiscall CNe2000::Transmit(void)): + E0006DDA: 55 push ebp + E0006DDB: 8B EC mov ebp,esp + E0006DDD: 83 EC 1C sub esp,1Ch + E0006DE0: 53 push ebx + E0006DE1: 56 push esi + E0006DE2: 57 push edi + E0006DE3: 89 4D E4 mov dword ptr [ebp-1Ch],ecx + E0006DE6: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0006DE9: 33 C9 xor ecx,ecx + E0006DEB: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006DEF: 83 C1 04 add ecx,4 + E0006DF2: 66 89 4D F4 mov word ptr [ebp-0Ch],cx + E0006DF6: 33 C0 xor eax,eax + E0006DF8: 66 8B 55 F4 mov dx,word ptr [ebp-0Ch] + E0006DFC: EC in al,dx + E0006DFD: 88 45 F0 mov byte ptr [ebp-10h],al + E0006E00: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0006E03: 81 E2 FF 00 00 00 and edx,0FFh + E0006E09: 89 55 F8 mov dword ptr [ebp-8],edx + E0006E0C: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0006E0F: 8B 48 74 mov ecx,dword ptr [eax+74h] + E0006E12: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0006E15: 83 7C 8A 64 00 cmp dword ptr [edx+ecx*4+64h],0 + E0006E1A: 75 12 jne E0006E2E + E0006E1C: 68 F0 BD 00 E0 push 0E000BDF0h + E0006E21: E8 EA 30 00 00 call E0009F10 + E0006E26: 83 C4 04 add esp,4 + E0006E29: E9 97 01 00 00 jmp E0006FC5 + E0006E2E: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0006E31: 83 78 78 00 cmp dword ptr [eax+78h],0 + E0006E35: 75 0D jne E0006E44 + E0006E37: 68 54 BE 00 E0 push 0E000BE54h + E0006E3C: E8 CF 30 00 00 call E0009F10 + E0006E41: 83 C4 04 add esp,4 + E0006E44: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0006E47: 8B 51 74 mov edx,dword ptr [ecx+74h] + E0006E4A: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0006E4D: 8B 4C 90 64 mov ecx,dword ptr [eax+edx*4+64h] + E0006E51: 51 push ecx + E0006E52: E8 61 FF FF FF call E0006DB8 + E0006E57: 83 C4 04 add esp,4 + E0006E5A: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0006E5D: 8B 42 74 mov eax,dword ptr [edx+74h] + E0006E60: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0006E63: C7 44 81 64 00 00 mov dword ptr [ecx+eax*4+64h],0 + 00 00 + E0006E6B: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0006E72: EB 09 jmp E0006E7D + E0006E74: 8B 55 FC mov edx,dword ptr [ebp-4] + E0006E77: 83 C2 01 add edx,1 + E0006E7A: 89 55 FC mov dword ptr [ebp-4],edx + E0006E7D: 83 7D FC 02 cmp dword ptr [ebp-4],2 + E0006E81: 73 50 jae E0006ED3 + E0006E83: 8B 45 FC mov eax,dword ptr [ebp-4] + E0006E86: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0006E89: 83 7C 81 64 00 cmp dword ptr [ecx+eax*4+64h],0 + E0006E8E: 74 41 je E0006ED1 + E0006E90: 8B 55 FC mov edx,dword ptr [ebp-4] + E0006E93: 52 push edx + E0006E94: 68 A8 BE 00 E0 push 0E000BEA8h + E0006E99: E8 72 30 00 00 call E0009F10 + E0006E9E: 83 C4 08 add esp,8 + E0006EA1: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0006EA4: 8B 48 24 mov ecx,dword ptr [eax+24h] + E0006EA7: 83 C1 01 add ecx,1 + E0006EAA: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0006EAD: 89 4A 24 mov dword ptr [edx+24h],ecx + E0006EB0: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0006EB3: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0006EB6: 89 48 74 mov dword ptr [eax+74h],ecx + E0006EB9: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0006EBC: C7 42 78 01 00 00 mov dword ptr [edx+78h],1 + 00 + E0006EC3: 8B 45 FC mov eax,dword ptr [ebp-4] + E0006EC6: 50 push eax + E0006EC7: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0006ECA: E8 D1 0A 00 00 call E00079A0 + E0006ECF: EB 02 jmp E0006ED3 + E0006ED1: EB A1 jmp E0006E74 + E0006ED3: 83 7D FC 02 cmp dword ptr [ebp-4],2 + E0006ED7: 75 0A jne E0006EE3 + E0006ED9: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0006EDC: C7 41 78 00 00 00 mov dword ptr [ecx+78h],0 + 00 + E0006EE3: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0006EE6: 83 E2 04 and edx,4 + E0006EE9: 85 D2 test edx,edx + E0006EEB: 74 0F je E0006EFC + E0006EED: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0006EF0: 8B 48 4C mov ecx,dword ptr [eax+4Ch] + E0006EF3: 83 C1 01 add ecx,1 + E0006EF6: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0006EF9: 89 4A 4C mov dword ptr [edx+4Ch],ecx + E0006EFC: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0006EFF: 83 E0 01 and eax,1 + E0006F02: 85 C0 test eax,eax + E0006F04: 74 14 je E0006F1A + E0006F06: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0006F09: 8B 51 28 mov edx,dword ptr [ecx+28h] + E0006F0C: 83 C2 01 add edx,1 + E0006F0F: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0006F12: 89 50 28 mov dword ptr [eax+28h],edx + E0006F15: E9 8F 00 00 00 jmp E0006FA9 + E0006F1A: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0006F1D: 83 E1 08 and ecx,8 + E0006F20: 85 C9 test ecx,ecx + E0006F22: 74 1E je E0006F42 + E0006F24: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0006F27: 8B 42 50 mov eax,dword ptr [edx+50h] + E0006F2A: 83 C0 01 add eax,1 + E0006F2D: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0006F30: 89 41 50 mov dword ptr [ecx+50h],eax + E0006F33: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0006F36: 8B 42 4C mov eax,dword ptr [edx+4Ch] + E0006F39: 83 C0 10 add eax,10h + E0006F3C: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0006F3F: 89 41 4C mov dword ptr [ecx+4Ch],eax + E0006F42: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0006F45: 83 E2 10 and edx,10h + E0006F48: 85 D2 test edx,edx + E0006F4A: 74 0F je E0006F5B + E0006F4C: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0006F4F: 8B 48 54 mov ecx,dword ptr [eax+54h] + E0006F52: 83 C1 01 add ecx,1 + E0006F55: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0006F58: 89 4A 54 mov dword ptr [edx+54h],ecx + E0006F5B: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0006F5E: 83 E0 20 and eax,20h + E0006F61: 85 C0 test eax,eax + E0006F63: 74 0F je E0006F74 + E0006F65: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0006F68: 8B 51 58 mov edx,dword ptr [ecx+58h] + E0006F6B: 83 C2 01 add edx,1 + E0006F6E: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0006F71: 89 50 58 mov dword ptr [eax+58h],edx + E0006F74: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0006F77: 83 E1 40 and ecx,40h + E0006F7A: 85 C9 test ecx,ecx + E0006F7C: 74 0F je E0006F8D + E0006F7E: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0006F81: 8B 42 5C mov eax,dword ptr [edx+5Ch] + E0006F84: 83 C0 01 add eax,1 + E0006F87: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0006F8A: 89 41 5C mov dword ptr [ecx+5Ch],eax + E0006F8D: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0006F90: 81 E2 80 00 00 00 and edx,80h + E0006F96: 85 D2 test edx,edx + E0006F98: 74 0F je E0006FA9 + E0006F9A: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0006F9D: 8B 48 60 mov ecx,dword ptr [eax+60h] + E0006FA0: 83 C1 01 add ecx,1 + E0006FA3: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0006FA6: 89 4A 60 mov dword ptr [edx+60h],ecx + E0006FA9: C6 45 E8 02 mov byte ptr [ebp-18h],2 + E0006FAD: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0006FB0: 33 C9 xor ecx,ecx + E0006FB2: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0006FB6: 83 C1 07 add ecx,7 + E0006FB9: 66 89 4D EC mov word ptr [ebp-14h],cx + E0006FBD: 66 8B 55 EC mov dx,word ptr [ebp-14h] + E0006FC1: 8A 45 E8 mov al,byte ptr [ebp-18h] + E0006FC4: EE out dx,al + E0006FC5: 5F pop edi + E0006FC6: 5E pop esi + E0006FC7: 5B pop ebx + E0006FC8: 8B E5 mov esp,ebp + E0006FCA: 5D pop ebp + E0006FCB: C3 ret +?TransmitError@CNe2000@@IAEXXZ (protected: void __thiscall CNe2000::TransmitError(void)): + E0006FCC: 55 push ebp + E0006FCD: 8B EC mov ebp,esp + E0006FCF: 83 EC 14 sub esp,14h + E0006FD2: 53 push ebx + E0006FD3: 56 push esi + E0006FD4: 57 push edi + E0006FD5: 89 4D EC mov dword ptr [ebp-14h],ecx + E0006FD8: 8B 45 FC mov eax,dword ptr [ebp-4] + E0006FDB: 89 45 FC mov dword ptr [ebp-4],eax + E0006FDE: 33 C0 xor eax,eax + E0006FE0: 66 8B 55 FC mov dx,word ptr [ebp-4] + E0006FE4: EC in al,dx + E0006FE5: 88 45 F8 mov byte ptr [ebp-8],al + E0006FE8: 68 0C BF 00 E0 push 0E000BF0Ch + E0006FED: E8 1E 2F 00 00 call E0009F10 + E0006FF2: 83 C4 04 add esp,4 + E0006FF5: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0006FF8: 81 E1 FF 00 00 00 and ecx,0FFh + E0006FFE: 83 E1 08 and ecx,8 + E0007001: 85 C9 test ecx,ecx + E0007003: 74 0D je E0007012 + E0007005: 68 40 BF 00 E0 push 0E000BF40h + E000700A: E8 01 2F 00 00 call E0009F10 + E000700F: 83 C4 04 add esp,4 + E0007012: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0007015: 81 E2 FF 00 00 00 and edx,0FFh + E000701B: 83 E2 02 and edx,2 + E000701E: 85 D2 test edx,edx + E0007020: 74 0D je E000702F + E0007022: 68 6C BF 00 E0 push 0E000BF6Ch + E0007027: E8 E4 2E 00 00 call E0009F10 + E000702C: 83 C4 04 add esp,4 + E000702F: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0007032: 25 FF 00 00 00 and eax,0FFh + E0007037: 83 E0 10 and eax,10h + E000703A: 85 C0 test eax,eax + E000703C: 74 0D je E000704B + E000703E: 68 8C BF 00 E0 push 0E000BF8Ch + E0007043: E8 C8 2E 00 00 call E0009F10 + E0007048: 83 C4 04 add esp,4 + E000704B: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E000704E: 81 E1 FF 00 00 00 and ecx,0FFh + E0007054: 83 E1 20 and ecx,20h + E0007057: 85 C9 test ecx,ecx + E0007059: 74 0D je E0007068 + E000705B: 68 AC BF 00 E0 push 0E000BFACh + E0007060: E8 AB 2E 00 00 call E0009F10 + E0007065: 83 C4 04 add esp,4 + E0007068: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000706B: 81 E2 FF 00 00 00 and edx,0FFh + E0007071: 83 E2 40 and edx,40h + E0007074: 85 D2 test edx,edx + E0007076: 74 0D je E0007085 + E0007078: 68 CC BF 00 E0 push 0E000BFCCh + E000707D: E8 8E 2E 00 00 call E0009F10 + E0007082: 83 C4 04 add esp,4 + E0007085: C6 45 F0 08 mov byte ptr [ebp-10h],8 + E0007089: 8B 45 FC mov eax,dword ptr [ebp-4] + E000708C: 83 C0 07 add eax,7 + E000708F: 66 89 45 F4 mov word ptr [ebp-0Ch],ax + E0007093: 66 8B 55 F4 mov dx,word ptr [ebp-0Ch] + E0007097: 8A 45 F0 mov al,byte ptr [ebp-10h] + E000709A: EE out dx,al + E000709B: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E000709E: 81 E1 FF 00 00 00 and ecx,0FFh + E00070A4: 83 E1 28 and ecx,28h + E00070A7: 85 C9 test ecx,ecx + E00070A9: 74 15 je E00070C0 + E00070AB: 68 EC BF 00 E0 push 0E000BFECh + E00070B0: E8 5B 2E 00 00 call E0009F10 + E00070B5: 83 C4 04 add esp,4 + E00070B8: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E00070BB: E8 1A FD FF FF call E0006DDA + E00070C0: 5F pop edi + E00070C1: 5E pop esi + E00070C2: 5B pop ebx + E00070C3: 8B E5 mov esp,ebp + E00070C5: 5D pop ebp + E00070C6: C3 ret +?GetHeader@CNe2000@@IAEXIPAUbuffer_header_t@@@Z (protected: void __thiscall CNe2000::GetHeader(unsigned int,struct buffer_header_t *)): + E00070C7: 55 push ebp + E00070C8: 8B EC mov ebp,esp + E00070CA: 83 EC 4C sub esp,4Ch + E00070CD: 53 push ebx + E00070CE: 56 push esi + E00070CF: 57 push edi + E00070D0: 89 4D B4 mov dword ptr [ebp-4Ch],ecx + E00070D3: C6 45 F4 22 mov byte ptr [ebp-0Ch],22h + E00070D7: 8B 45 B4 mov eax,dword ptr [ebp-4Ch] + E00070DA: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E00070DE: 66 89 4D F8 mov word ptr [ebp-8],cx + E00070E2: 66 8B 55 F8 mov dx,word ptr [ebp-8] + E00070E6: 8A 45 F4 mov al,byte ptr [ebp-0Ch] + E00070E9: EE out dx,al + E00070EA: C6 45 EC 04 mov byte ptr [ebp-14h],4 + E00070EE: 8B 55 B4 mov edx,dword ptr [ebp-4Ch] + E00070F1: 33 C0 xor eax,eax + E00070F3: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E00070F7: 83 C0 0A add eax,0Ah + E00070FA: 66 89 45 F0 mov word ptr [ebp-10h],ax + E00070FE: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E0007102: 8A 45 EC mov al,byte ptr [ebp-14h] + E0007105: EE out dx,al + E0007106: C6 45 E4 00 mov byte ptr [ebp-1Ch],0 + E000710A: 8B 4D B4 mov ecx,dword ptr [ebp-4Ch] + E000710D: 33 D2 xor edx,edx + E000710F: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0007113: 83 C2 0B add edx,0Bh + E0007116: 66 89 55 E8 mov word ptr [ebp-18h],dx + E000711A: 66 8B 55 E8 mov dx,word ptr [ebp-18h] + E000711E: 8A 45 E4 mov al,byte ptr [ebp-1Ch] + E0007121: EE out dx,al + E0007122: C6 45 DC 00 mov byte ptr [ebp-24h],0 + E0007126: 8B 45 B4 mov eax,dword ptr [ebp-4Ch] + E0007129: 33 C9 xor ecx,ecx + E000712B: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E000712F: 83 C1 08 add ecx,8 + E0007132: 66 89 4D E0 mov word ptr [ebp-20h],cx + E0007136: 66 8B 55 E0 mov dx,word ptr [ebp-20h] + E000713A: 8A 45 DC mov al,byte ptr [ebp-24h] + E000713D: EE out dx,al + E000713E: 8B 55 B4 mov edx,dword ptr [ebp-4Ch] + E0007141: 33 C0 xor eax,eax + E0007143: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0007147: 83 C0 09 add eax,9 + E000714A: 66 89 45 D8 mov word ptr [ebp-28h],ax + E000714E: 66 8B 55 D8 mov dx,word ptr [ebp-28h] + E0007152: 8A 45 08 mov al,byte ptr [ebp+8] + E0007155: EE out dx,al + E0007156: C6 45 D0 0A mov byte ptr [ebp-30h],0Ah + E000715A: 8B 4D B4 mov ecx,dword ptr [ebp-4Ch] + E000715D: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0007161: 66 89 55 D4 mov word ptr [ebp-2Ch],dx + E0007165: 66 8B 55 D4 mov dx,word ptr [ebp-2Ch] + E0007169: 8A 45 D0 mov al,byte ptr [ebp-30h] + E000716C: EE out dx,al + E000716D: 8B 45 B4 mov eax,dword ptr [ebp-4Ch] + E0007170: 83 78 18 02 cmp dword ptr [eax+18h],2 + E0007174: 75 46 jne E00071BC + E0007176: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E000717D: EB 09 jmp E0007188 + E000717F: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0007182: 83 C1 01 add ecx,1 + E0007185: 89 4D FC mov dword ptr [ebp-4],ecx + E0007188: 83 7D FC 02 cmp dword ptr [ebp-4],2 + E000718C: 73 2C jae E00071BA + E000718E: 8B 55 B4 mov edx,dword ptr [ebp-4Ch] + E0007191: 33 C0 xor eax,eax + E0007193: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0007197: 83 C0 10 add eax,10h + E000719A: 66 89 45 CC mov word ptr [ebp-34h],ax + E000719E: 33 C0 xor eax,eax + E00071A0: 66 8B 55 CC mov dx,word ptr [ebp-34h] + E00071A4: 66 ED in ax,dx + E00071A6: 66 89 45 C8 mov word ptr [ebp-38h],ax + E00071AA: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00071AD: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00071B0: 66 8B 45 C8 mov ax,word ptr [ebp-38h] + E00071B4: 66 89 04 4A mov word ptr [edx+ecx*2],ax + E00071B8: EB C5 jmp E000717F + E00071BA: EB 3F jmp E00071FB + E00071BC: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E00071C3: EB 09 jmp E00071CE + E00071C5: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00071C8: 83 C1 01 add ecx,1 + E00071CB: 89 4D FC mov dword ptr [ebp-4],ecx + E00071CE: 83 7D FC 04 cmp dword ptr [ebp-4],4 + E00071D2: 73 27 jae E00071FB + E00071D4: 8B 55 B4 mov edx,dword ptr [ebp-4Ch] + E00071D7: 33 C0 xor eax,eax + E00071D9: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E00071DD: 83 C0 10 add eax,10h + E00071E0: 66 89 45 C4 mov word ptr [ebp-3Ch],ax + E00071E4: 33 C0 xor eax,eax + E00071E6: 66 8B 55 C4 mov dx,word ptr [ebp-3Ch] + E00071EA: EC in al,dx + E00071EB: 88 45 C0 mov byte ptr [ebp-40h],al + E00071EE: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00071F1: 03 4D FC add ecx,dword ptr [ebp-4] + E00071F4: 8A 55 C0 mov dl,byte ptr [ebp-40h] + E00071F7: 88 11 mov byte ptr [ecx],dl + E00071F9: EB CA jmp E00071C5 + E00071FB: C6 45 B8 40 mov byte ptr [ebp-48h],40h + E00071FF: 8B 45 B4 mov eax,dword ptr [ebp-4Ch] + E0007202: 33 C9 xor ecx,ecx + E0007204: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0007208: 83 C1 07 add ecx,7 + E000720B: 66 89 4D BC mov word ptr [ebp-44h],cx + E000720F: 66 8B 55 BC mov dx,word ptr [ebp-44h] + E0007213: 8A 45 B8 mov al,byte ptr [ebp-48h] + E0007216: EE out dx,al + E0007217: 5F pop edi + E0007218: 5E pop esi + E0007219: 5B pop ebx + E000721A: 8B E5 mov esp,ebp + E000721C: 5D pop ebp + E000721D: C2 08 00 ret 8 +?BlockInput@CNe2000@@IAEXPAEII@Z (protected: void __thiscall CNe2000::BlockInput(unsigned char *,unsigned int,unsigned int)): + E0007220: 55 push ebp + E0007221: 8B EC mov ebp,esp + E0007223: 81 EC 88 00 00 00 sub esp,88h + E0007229: 53 push ebx + E000722A: 56 push esi + E000722B: 57 push edi + E000722C: 89 8D 78 FF FF FF mov dword ptr [ebp+FFFFFF78h],ecx + E0007232: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0007235: 89 45 F8 mov dword ptr [ebp-8],eax + E0007238: C7 45 F4 28 00 00 mov dword ptr [ebp-0Ch],28h + 00 + E000723F: C6 45 E0 22 mov byte ptr [ebp-20h],22h + E0007243: 8B 8D 78 FF FF FF mov ecx,dword ptr [ebp+FFFFFF78h] + E0007249: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E000724D: 66 89 55 E4 mov word ptr [ebp-1Ch],dx + E0007251: 66 8B 55 E4 mov dx,word ptr [ebp-1Ch] + E0007255: 8A 45 E0 mov al,byte ptr [ebp-20h] + E0007258: EE out dx,al + E0007259: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000725C: 25 FF 00 00 00 and eax,0FFh + E0007261: 88 45 D8 mov byte ptr [ebp-28h],al + E0007264: 8B 8D 78 FF FF FF mov ecx,dword ptr [ebp+FFFFFF78h] + E000726A: 33 D2 xor edx,edx + E000726C: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0007270: 83 C2 0A add edx,0Ah + E0007273: 66 89 55 DC mov word ptr [ebp-24h],dx + E0007277: 66 8B 55 DC mov dx,word ptr [ebp-24h] + E000727B: 8A 45 D8 mov al,byte ptr [ebp-28h] + E000727E: EE out dx,al + E000727F: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0007282: C1 E8 08 shr eax,8 + E0007285: 88 45 D0 mov byte ptr [ebp-30h],al + E0007288: 8B 8D 78 FF FF FF mov ecx,dword ptr [ebp+FFFFFF78h] + E000728E: 33 D2 xor edx,edx + E0007290: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0007294: 83 C2 0B add edx,0Bh + E0007297: 66 89 55 D4 mov word ptr [ebp-2Ch],dx + E000729B: 66 8B 55 D4 mov dx,word ptr [ebp-2Ch] + E000729F: 8A 45 D0 mov al,byte ptr [ebp-30h] + E00072A2: EE out dx,al + E00072A3: 8B 45 10 mov eax,dword ptr [ebp+10h] + E00072A6: 25 FF 00 00 00 and eax,0FFh + E00072AB: 88 45 C8 mov byte ptr [ebp-38h],al + E00072AE: 8B 8D 78 FF FF FF mov ecx,dword ptr [ebp+FFFFFF78h] + E00072B4: 33 D2 xor edx,edx + E00072B6: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E00072BA: 83 C2 08 add edx,8 + E00072BD: 66 89 55 CC mov word ptr [ebp-34h],dx + E00072C1: 66 8B 55 CC mov dx,word ptr [ebp-34h] + E00072C5: 8A 45 C8 mov al,byte ptr [ebp-38h] + E00072C8: EE out dx,al + E00072C9: 8B 45 10 mov eax,dword ptr [ebp+10h] + E00072CC: C1 E8 08 shr eax,8 + E00072CF: 88 45 C0 mov byte ptr [ebp-40h],al + E00072D2: 8B 8D 78 FF FF FF mov ecx,dword ptr [ebp+FFFFFF78h] + E00072D8: 33 D2 xor edx,edx + E00072DA: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E00072DE: 83 C2 09 add edx,9 + E00072E1: 66 89 55 C4 mov word ptr [ebp-3Ch],dx + E00072E5: 66 8B 55 C4 mov dx,word ptr [ebp-3Ch] + E00072E9: 8A 45 C0 mov al,byte ptr [ebp-40h] + E00072EC: EE out dx,al + E00072ED: C6 45 B8 0A mov byte ptr [ebp-48h],0Ah + E00072F1: 8B 85 78 FF FF FF mov eax,dword ptr [ebp+FFFFFF78h] + E00072F7: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E00072FB: 66 89 4D BC mov word ptr [ebp-44h],cx + E00072FF: 66 8B 55 BC mov dx,word ptr [ebp-44h] + E0007303: 8A 45 B8 mov al,byte ptr [ebp-48h] + E0007306: EE out dx,al + E0007307: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E000730B: 0F 84 E2 00 00 00 je E00073F3 + E0007311: 8B 95 78 FF FF FF mov edx,dword ptr [ebp+FFFFFF78h] + E0007317: 83 7A 18 02 cmp dword ptr [edx+18h],2 + E000731B: 0F 85 89 00 00 00 jne E00073AA + E0007321: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0007328: EB 09 jmp E0007333 + E000732A: 8B 45 FC mov eax,dword ptr [ebp-4] + E000732D: 83 C0 01 add eax,1 + E0007330: 89 45 FC mov dword ptr [ebp-4],eax + E0007333: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0007336: D1 E9 shr ecx,1 + E0007338: 39 4D FC cmp dword ptr [ebp-4],ecx + E000733B: 73 2F jae E000736C + E000733D: 8B 95 78 FF FF FF mov edx,dword ptr [ebp+FFFFFF78h] + E0007343: 33 C0 xor eax,eax + E0007345: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0007349: 83 C0 10 add eax,10h + E000734C: 66 89 45 B4 mov word ptr [ebp-4Ch],ax + E0007350: 33 C0 xor eax,eax + E0007352: 66 8B 55 B4 mov dx,word ptr [ebp-4Ch] + E0007356: 66 ED in ax,dx + E0007358: 66 89 45 B0 mov word ptr [ebp-50h],ax + E000735C: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000735F: 8B 55 08 mov edx,dword ptr [ebp+8] + E0007362: 66 8B 45 B0 mov ax,word ptr [ebp-50h] + E0007366: 66 89 04 4A mov word ptr [edx+ecx*2],ax + E000736A: EB BE jmp E000732A + E000736C: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E000736F: 83 E1 01 and ecx,1 + E0007372: 85 C9 test ecx,ecx + E0007374: 74 32 je E00073A8 + E0007376: 8B 95 78 FF FF FF mov edx,dword ptr [ebp+FFFFFF78h] + E000737C: 33 C0 xor eax,eax + E000737E: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0007382: 83 C0 10 add eax,10h + E0007385: 66 89 45 AC mov word ptr [ebp-54h],ax + E0007389: 33 C0 xor eax,eax + E000738B: 66 8B 55 AC mov dx,word ptr [ebp-54h] + E000738F: EC in al,dx + E0007390: 88 45 A8 mov byte ptr [ebp-58h],al + E0007393: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0007396: 03 4D 0C add ecx,dword ptr [ebp+0Ch] + E0007399: 8A 55 A8 mov dl,byte ptr [ebp-58h] + E000739C: 88 51 FF mov byte ptr [ecx-1],dl + E000739F: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00073A2: 83 C0 01 add eax,1 + E00073A5: 89 45 F8 mov dword ptr [ebp-8],eax + E00073A8: EB 44 jmp E00073EE + E00073AA: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E00073B1: EB 09 jmp E00073BC + E00073B3: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00073B6: 83 C1 01 add ecx,1 + E00073B9: 89 4D FC mov dword ptr [ebp-4],ecx + E00073BC: 8B 55 FC mov edx,dword ptr [ebp-4] + E00073BF: 3B 55 0C cmp edx,dword ptr [ebp+0Ch] + E00073C2: 73 2A jae E00073EE + E00073C4: 8B 85 78 FF FF FF mov eax,dword ptr [ebp+FFFFFF78h] + E00073CA: 33 C9 xor ecx,ecx + E00073CC: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E00073D0: 83 C1 10 add ecx,10h + E00073D3: 66 89 4D A4 mov word ptr [ebp-5Ch],cx + E00073D7: 33 C0 xor eax,eax + E00073D9: 66 8B 55 A4 mov dx,word ptr [ebp-5Ch] + E00073DD: EC in al,dx + E00073DE: 88 45 A0 mov byte ptr [ebp-60h],al + E00073E1: 8B 55 08 mov edx,dword ptr [ebp+8] + E00073E4: 03 55 FC add edx,dword ptr [ebp-4] + E00073E7: 8A 45 A0 mov al,byte ptr [ebp-60h] + E00073EA: 88 02 mov byte ptr [edx],al + E00073EC: EB C5 jmp E00073B3 + E00073EE: E9 AA 00 00 00 jmp E000749D + E00073F3: 8B 8D 78 FF FF FF mov ecx,dword ptr [ebp+FFFFFF78h] + E00073F9: 83 79 18 02 cmp dword ptr [ecx+18h],2 + E00073FD: 75 68 jne E0007467 + E00073FF: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0007406: EB 09 jmp E0007411 + E0007408: 8B 55 FC mov edx,dword ptr [ebp-4] + E000740B: 83 C2 01 add edx,1 + E000740E: 89 55 FC mov dword ptr [ebp-4],edx + E0007411: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0007414: D1 E8 shr eax,1 + E0007416: 39 45 FC cmp dword ptr [ebp-4],eax + E0007419: 73 1D jae E0007438 + E000741B: 8B 8D 78 FF FF FF mov ecx,dword ptr [ebp+FFFFFF78h] + E0007421: 33 D2 xor edx,edx + E0007423: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E0007427: 83 C2 10 add edx,10h + E000742A: 66 89 55 9C mov word ptr [ebp-64h],dx + E000742E: 33 C0 xor eax,eax + E0007430: 66 8B 55 9C mov dx,word ptr [ebp-64h] + E0007434: 66 ED in ax,dx + E0007436: EB D0 jmp E0007408 + E0007438: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000743B: 83 E0 01 and eax,1 + E000743E: 85 C0 test eax,eax + E0007440: 74 23 je E0007465 + E0007442: 8B 8D 78 FF FF FF mov ecx,dword ptr [ebp+FFFFFF78h] + E0007448: 33 D2 xor edx,edx + E000744A: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E000744E: 83 C2 10 add edx,10h + E0007451: 66 89 55 98 mov word ptr [ebp-68h],dx + E0007455: 33 C0 xor eax,eax + E0007457: 66 8B 55 98 mov dx,word ptr [ebp-68h] + E000745B: EC in al,dx + E000745C: 8B 45 F8 mov eax,dword ptr [ebp-8] + E000745F: 83 C0 01 add eax,1 + E0007462: 89 45 F8 mov dword ptr [ebp-8],eax + E0007465: EB 36 jmp E000749D + E0007467: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E000746E: EB 09 jmp E0007479 + E0007470: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0007473: 83 C1 01 add ecx,1 + E0007476: 89 4D FC mov dword ptr [ebp-4],ecx + E0007479: 8B 55 FC mov edx,dword ptr [ebp-4] + E000747C: 3B 55 0C cmp edx,dword ptr [ebp+0Ch] + E000747F: 73 1C jae E000749D + E0007481: 8B 85 78 FF FF FF mov eax,dword ptr [ebp+FFFFFF78h] + E0007487: 33 C9 xor ecx,ecx + E0007489: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E000748D: 83 C1 10 add ecx,10h + E0007490: 66 89 4D 94 mov word ptr [ebp-6Ch],cx + E0007494: 33 C0 xor eax,eax + E0007496: 66 8B 55 94 mov dx,word ptr [ebp-6Ch] + E000749A: EC in al,dx + E000749B: EB D3 jmp E0007470 + E000749D: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E00074A4: EB 09 jmp E00074AF + E00074A6: 8B 55 FC mov edx,dword ptr [ebp-4] + E00074A9: 83 C2 01 add edx,1 + E00074AC: 89 55 FC mov dword ptr [ebp-4],edx + E00074AF: 8B 45 FC mov eax,dword ptr [ebp-4] + E00074B2: 3B 45 F4 cmp eax,dword ptr [ebp-0Ch] + E00074B5: 73 74 jae E000752B + E00074B7: 8B 8D 78 FF FF FF mov ecx,dword ptr [ebp+FFFFFF78h] + E00074BD: 33 D2 xor edx,edx + E00074BF: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E00074C3: 83 C2 09 add edx,9 + E00074C6: 66 89 55 90 mov word ptr [ebp-70h],dx + E00074CA: 33 C0 xor eax,eax + E00074CC: 66 8B 55 90 mov dx,word ptr [ebp-70h] + E00074D0: EC in al,dx + E00074D1: 88 45 8C mov byte ptr [ebp-74h],al + E00074D4: 8B 45 8C mov eax,dword ptr [ebp-74h] + E00074D7: 25 FF 00 00 00 and eax,0FFh + E00074DC: 89 45 EC mov dword ptr [ebp-14h],eax + E00074DF: 8B 8D 78 FF FF FF mov ecx,dword ptr [ebp+FFFFFF78h] + E00074E5: 33 D2 xor edx,edx + E00074E7: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E00074EB: 83 C2 08 add edx,8 + E00074EE: 66 89 55 88 mov word ptr [ebp-78h],dx + E00074F2: 33 C0 xor eax,eax + E00074F4: 66 8B 55 88 mov dx,word ptr [ebp-78h] + E00074F8: EC in al,dx + E00074F9: 88 45 84 mov byte ptr [ebp-7Ch],al + E00074FC: 8B 45 84 mov eax,dword ptr [ebp-7Ch] + E00074FF: 25 FF 00 00 00 and eax,0FFh + E0007504: 89 45 E8 mov dword ptr [ebp-18h],eax + E0007507: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E000750A: C1 E1 08 shl ecx,8 + E000750D: 03 4D E8 add ecx,dword ptr [ebp-18h] + E0007510: 89 4D F0 mov dword ptr [ebp-10h],ecx + E0007513: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0007516: 03 55 F8 add edx,dword ptr [ebp-8] + E0007519: 81 E2 FF 00 00 00 and edx,0FFh + E000751F: 3B 55 E8 cmp edx,dword ptr [ebp-18h] + E0007522: 75 02 jne E0007526 + E0007524: EB 05 jmp E000752B + E0007526: E9 7B FF FF FF jmp E00074A6 + E000752B: C6 85 7C FF FF FF mov byte ptr [ebp+FFFFFF7Ch],40h + 40 + E0007532: 8B 85 78 FF FF FF mov eax,dword ptr [ebp+FFFFFF78h] + E0007538: 33 C9 xor ecx,ecx + E000753A: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E000753E: 83 C1 07 add ecx,7 + E0007541: 66 89 4D 80 mov word ptr [ebp-80h],cx + E0007545: 66 8B 55 80 mov dx,word ptr [ebp-80h] + E0007549: 8A 85 7C FF FF FF mov al,byte ptr [ebp+FFFFFF7Ch] + E000754F: EE out dx,al + E0007550: 5F pop edi + E0007551: 5E pop esi + E0007552: 5B pop ebx + E0007553: 8B E5 mov esp,ebp + E0007555: 5D pop ebp + E0007556: C2 0C 00 ret 0Ch +?Receive@CNe2000@@IAEXXZ (protected: void __thiscall CNe2000::Receive(void)): + E0007559: 55 push ebp + E000755A: 8B EC mov ebp,esp + E000755C: 83 EC 60 sub esp,60h + E000755F: 53 push ebx + E0007560: 56 push esi + E0007561: 57 push edi + E0007562: 89 4D A0 mov dword ptr [ebp-60h],ecx + E0007565: C7 45 E8 00 00 00 mov dword ptr [ebp-18h],0 + 00 + E000756C: 83 7D E8 0A cmp dword ptr [ebp-18h],0Ah + E0007570: 0F 83 45 03 00 00 jae E00078BB + E0007576: C6 45 D4 60 mov byte ptr [ebp-2Ch],60h + E000757A: 8B 45 A0 mov eax,dword ptr [ebp-60h] + E000757D: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0007581: 66 89 4D D8 mov word ptr [ebp-28h],cx + E0007585: 66 8B 55 D8 mov dx,word ptr [ebp-28h] + E0007589: 8A 45 D4 mov al,byte ptr [ebp-2Ch] + E000758C: EE out dx,al + E000758D: 8B 55 A0 mov edx,dword ptr [ebp-60h] + E0007590: 33 C0 xor eax,eax + E0007592: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0007596: 83 C0 07 add eax,7 + E0007599: 66 89 45 D0 mov word ptr [ebp-30h],ax + E000759D: 33 C0 xor eax,eax + E000759F: 66 8B 55 D0 mov dx,word ptr [ebp-30h] + E00075A3: EC in al,dx + E00075A4: 88 45 CC mov byte ptr [ebp-34h],al + E00075A7: 8B 4D CC mov ecx,dword ptr [ebp-34h] + E00075AA: 81 E1 FF 00 00 00 and ecx,0FFh + E00075B0: 89 4D F8 mov dword ptr [ebp-8],ecx + E00075B3: C6 45 C4 20 mov byte ptr [ebp-3Ch],20h + E00075B7: 8B 55 A0 mov edx,dword ptr [ebp-60h] + E00075BA: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E00075BE: 66 89 45 C8 mov word ptr [ebp-38h],ax + E00075C2: 66 8B 55 C8 mov dx,word ptr [ebp-38h] + E00075C6: 8A 45 C4 mov al,byte ptr [ebp-3Ch] + E00075C9: EE out dx,al + E00075CA: 8B 4D A0 mov ecx,dword ptr [ebp-60h] + E00075CD: 33 D2 xor edx,edx + E00075CF: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E00075D3: 83 C2 03 add edx,3 + E00075D6: 66 89 55 C0 mov word ptr [ebp-40h],dx + E00075DA: 33 C0 xor eax,eax + E00075DC: 66 8B 55 C0 mov dx,word ptr [ebp-40h] + E00075E0: EC in al,dx + E00075E1: 88 45 BC mov byte ptr [ebp-44h],al + E00075E4: 8B 45 BC mov eax,dword ptr [ebp-44h] + E00075E7: 25 FF 00 00 00 and eax,0FFh + E00075EC: 83 C0 01 add eax,1 + E00075EF: 89 45 F0 mov dword ptr [ebp-10h],eax + E00075F2: 8B 4D A0 mov ecx,dword ptr [ebp-60h] + E00075F5: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E00075F8: 3B 51 14 cmp edx,dword ptr [ecx+14h] + E00075FB: 72 0C jb E0007609 + E00075FD: 8B 45 A0 mov eax,dword ptr [ebp-60h] + E0007600: 8B 48 10 mov ecx,dword ptr [eax+10h] + E0007603: 83 C1 0C add ecx,0Ch + E0007606: 89 4D F0 mov dword ptr [ebp-10h],ecx + E0007609: 8B 55 A0 mov edx,dword ptr [ebp-60h] + E000760C: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E000760F: 3B 42 1C cmp eax,dword ptr [edx+1Ch] + E0007612: 74 25 je E0007639 + E0007614: 68 50 C0 00 E0 push 0E000C050h + E0007619: E8 F2 28 00 00 call E0009F10 + E000761E: 83 C4 04 add esp,4 + E0007621: 8B 4D A0 mov ecx,dword ptr [ebp-60h] + E0007624: 8B 51 1C mov edx,dword ptr [ecx+1Ch] + E0007627: 52 push edx + E0007628: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E000762B: 50 push eax + E000762C: 68 B0 C0 00 E0 push 0E000C0B0h + E0007631: E8 DA 28 00 00 call E0009F10 + E0007636: 83 C4 0C add esp,0Ch + E0007639: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E000763C: 3B 4D F8 cmp ecx,dword ptr [ebp-8] + E000763F: 75 05 jne E0007646 + E0007641: E9 75 02 00 00 jmp E00078BB + E0007646: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0007649: C1 E2 08 shl edx,8 + E000764C: 89 55 EC mov dword ptr [ebp-14h],edx + E000764F: 8D 45 F4 lea eax,dword ptr [ebp-0Ch] + E0007652: 50 push eax + E0007653: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0007656: 51 push ecx + E0007657: 8B 4D A0 mov ecx,dword ptr [ebp-60h] + E000765A: E8 68 FA FF FF call E00070C7 + E000765F: 8B 55 F6 mov edx,dword ptr [ebp-0Ah] + E0007662: 81 E2 FF FF 00 00 and edx,0FFFFh + E0007668: 83 EA 04 sub edx,4 + E000766B: 89 55 E4 mov dword ptr [ebp-1Ch],edx + E000766E: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0007671: 83 C0 04 add eax,4 + E0007674: C1 E8 08 shr eax,8 + E0007677: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E000767A: 8D 54 01 01 lea edx,dword ptr [ecx+eax+1] + E000767E: 89 55 E0 mov dword ptr [ebp-20h],edx + E0007681: 8B 45 A0 mov eax,dword ptr [ebp-60h] + E0007684: 8B 48 10 mov ecx,dword ptr [eax+10h] + E0007687: 83 C1 0C add ecx,0Ch + E000768A: 8B 55 A0 mov edx,dword ptr [ebp-60h] + E000768D: 8B 42 14 mov eax,dword ptr [edx+14h] + E0007690: 2B C1 sub eax,ecx + E0007692: 89 45 FC mov dword ptr [ebp-4],eax + E0007695: 8B 4D F5 mov ecx,dword ptr [ebp-0Bh] + E0007698: 81 E1 FF 00 00 00 and ecx,0FFh + E000769E: 3B 4D E0 cmp ecx,dword ptr [ebp-20h] + E00076A1: 0F 84 9F 00 00 00 je E0007746 + E00076A7: 8B 55 F5 mov edx,dword ptr [ebp-0Bh] + E00076AA: 81 E2 FF 00 00 00 and edx,0FFh + E00076B0: 8B 45 E0 mov eax,dword ptr [ebp-20h] + E00076B3: 83 C0 01 add eax,1 + E00076B6: 3B D0 cmp edx,eax + E00076B8: 0F 84 88 00 00 00 je E0007746 + E00076BE: 8B 4D F5 mov ecx,dword ptr [ebp-0Bh] + E00076C1: 81 E1 FF 00 00 00 and ecx,0FFh + E00076C7: 8B 55 E0 mov edx,dword ptr [ebp-20h] + E00076CA: 2B 55 FC sub edx,dword ptr [ebp-4] + E00076CD: 3B CA cmp ecx,edx + E00076CF: 74 75 je E0007746 + E00076D1: 8B 45 F5 mov eax,dword ptr [ebp-0Bh] + E00076D4: 25 FF 00 00 00 and eax,0FFh + E00076D9: 8B 4D E0 mov ecx,dword ptr [ebp-20h] + E00076DC: 83 C1 01 add ecx,1 + E00076DF: 2B 4D FC sub ecx,dword ptr [ebp-4] + E00076E2: 3B C1 cmp eax,ecx + E00076E4: 74 60 je E0007746 + E00076E6: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E00076E9: 52 push edx + E00076EA: 8B 45 E0 mov eax,dword ptr [ebp-20h] + E00076ED: 50 push eax + E00076EE: 8B 4D F5 mov ecx,dword ptr [ebp-0Bh] + E00076F1: 81 E1 FF 00 00 00 and ecx,0FFh + E00076F7: 51 push ecx + E00076F8: 68 0C C1 00 E0 push 0E000C10Ch + E00076FD: E8 0E 28 00 00 call E0009F10 + E0007702: 83 C4 10 add esp,10h + E0007705: 8B 55 A0 mov edx,dword ptr [ebp-60h] + E0007708: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E000770B: 89 42 1C mov dword ptr [edx+1Ch],eax + E000770E: 8B 4D A0 mov ecx,dword ptr [ebp-60h] + E0007711: 8B 51 1C mov edx,dword ptr [ecx+1Ch] + E0007714: 83 EA 01 sub edx,1 + E0007717: 88 55 B4 mov byte ptr [ebp-4Ch],dl + E000771A: 8B 45 A0 mov eax,dword ptr [ebp-60h] + E000771D: 33 C9 xor ecx,ecx + E000771F: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0007723: 83 C1 03 add ecx,3 + E0007726: 66 89 4D B8 mov word ptr [ebp-48h],cx + E000772A: 66 8B 55 B8 mov dx,word ptr [ebp-48h] + E000772E: 8A 45 B4 mov al,byte ptr [ebp-4Ch] + E0007731: EE out dx,al + E0007732: 8B 55 A0 mov edx,dword ptr [ebp-60h] + E0007735: 8B 42 38 mov eax,dword ptr [edx+38h] + E0007738: 83 C0 01 add eax,1 + E000773B: 8B 4D A0 mov ecx,dword ptr [ebp-60h] + E000773E: 89 41 38 mov dword ptr [ecx+38h],eax + E0007741: E9 26 FE FF FF jmp E000756C + E0007746: 83 7D E4 3C cmp dword ptr [ebp-1Ch],3Ch + E000774A: 72 09 jb E0007755 + E000774C: 81 7D E4 EE 05 00 cmp dword ptr [ebp-1Ch],5EEh + 00 + E0007753: 76 25 jbe E000777A + E0007755: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0007758: 52 push edx + E0007759: 68 9C C1 00 E0 push 0E000C19Ch + E000775E: E8 AD 27 00 00 call E0009F10 + E0007763: 83 C4 08 add esp,8 + E0007766: 8B 45 A0 mov eax,dword ptr [ebp-60h] + E0007769: 8B 48 3C mov ecx,dword ptr [eax+3Ch] + E000776C: 83 C1 01 add ecx,1 + E000776F: 8B 55 A0 mov edx,dword ptr [ebp-60h] + E0007772: 89 4A 3C mov dword ptr [edx+3Ch],ecx + E0007775: E9 DE 00 00 00 jmp E0007858 + E000777A: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E000777D: 25 FF 00 00 00 and eax,0FFh + E0007782: 83 E0 0F and eax,0Fh + E0007785: 83 F8 01 cmp eax,1 + E0007788: 0F 85 81 00 00 00 jne E000780F + E000778E: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0007791: 51 push ecx + E0007792: E8 10 F6 FF FF call E0006DA7 + E0007797: 83 C4 04 add esp,4 + E000779A: 89 45 DC mov dword ptr [ebp-24h],eax + E000779D: 83 7D DC 00 cmp dword ptr [ebp-24h],0 + E00077A1: 75 33 jne E00077D6 + E00077A3: 68 DC C1 00 E0 push 0E000C1DCh + E00077A8: E8 63 27 00 00 call E0009F10 + E00077AD: 83 C4 04 add esp,4 + E00077B0: 8B 55 A0 mov edx,dword ptr [ebp-60h] + E00077B3: 8B 42 40 mov eax,dword ptr [edx+40h] + E00077B6: 83 C0 01 add eax,1 + E00077B9: 8B 4D A0 mov ecx,dword ptr [ebp-60h] + E00077BC: 89 41 40 mov dword ptr [ecx+40h],eax + E00077BF: 8B 55 EC mov edx,dword ptr [ebp-14h] + E00077C2: 83 C2 04 add edx,4 + E00077C5: 52 push edx + E00077C6: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E00077C9: 50 push eax + E00077CA: 6A 00 push 0 + E00077CC: 8B 4D A0 mov ecx,dword ptr [ebp-60h] + E00077CF: E8 4C FA FF FF call E0007220 + E00077D4: EB 37 jmp E000780D + E00077D6: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E00077D9: 83 C1 04 add ecx,4 + E00077DC: 51 push ecx + E00077DD: 8B 55 DC mov edx,dword ptr [ebp-24h] + E00077E0: 8B 02 mov eax,dword ptr [edx] + E00077E2: 50 push eax + E00077E3: 8B 4D DC mov ecx,dword ptr [ebp-24h] + E00077E6: 8B 51 04 mov edx,dword ptr [ecx+4] + E00077E9: 52 push edx + E00077EA: 8B 4D A0 mov ecx,dword ptr [ebp-60h] + E00077ED: E8 2E FA FF FF call E0007220 + E00077F2: 8B 45 DC mov eax,dword ptr [ebp-24h] + E00077F5: 50 push eax + E00077F6: E8 CE F5 FF FF call E0006DC9 + E00077FB: 83 C4 04 add esp,4 + E00077FE: 8B 4D A0 mov ecx,dword ptr [ebp-60h] + E0007801: 8B 51 20 mov edx,dword ptr [ecx+20h] + E0007804: 83 C2 01 add edx,1 + E0007807: 8B 45 A0 mov eax,dword ptr [ebp-60h] + E000780A: 89 50 20 mov dword ptr [eax+20h],edx + E000780D: EB 49 jmp E0007858 + E000780F: 8B 4D F6 mov ecx,dword ptr [ebp-0Ah] + E0007812: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0007818: 51 push ecx + E0007819: 8B 55 F5 mov edx,dword ptr [ebp-0Bh] + E000781C: 81 E2 FF 00 00 00 and edx,0FFh + E0007822: 52 push edx + E0007823: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0007826: 25 FF 00 00 00 and eax,0FFh + E000782B: 50 push eax + E000782C: 68 1C C2 00 E0 push 0E000C21Ch + E0007831: E8 DA 26 00 00 call E0009F10 + E0007836: 83 C4 10 add esp,10h + E0007839: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E000783C: 81 E1 FF 00 00 00 and ecx,0FFh + E0007842: 83 E1 08 and ecx,8 + E0007845: 85 C9 test ecx,ecx + E0007847: 74 0F je E0007858 + E0007849: 8B 55 A0 mov edx,dword ptr [ebp-60h] + E000784C: 8B 42 44 mov eax,dword ptr [edx+44h] + E000784F: 83 C0 01 add eax,1 + E0007852: 8B 4D A0 mov ecx,dword ptr [ebp-60h] + E0007855: 89 41 44 mov dword ptr [ecx+44h],eax + E0007858: 8B 55 F5 mov edx,dword ptr [ebp-0Bh] + E000785B: 81 E2 FF 00 00 00 and edx,0FFh + E0007861: 89 55 E0 mov dword ptr [ebp-20h],edx + E0007864: 8B 45 A0 mov eax,dword ptr [ebp-60h] + E0007867: 8B 4D E0 mov ecx,dword ptr [ebp-20h] + E000786A: 3B 48 14 cmp ecx,dword ptr [eax+14h] + E000786D: 72 1D jb E000788C + E000786F: 8B 55 E0 mov edx,dword ptr [ebp-20h] + E0007872: 52 push edx + E0007873: 68 9C C2 00 E0 push 0E000C29Ch + E0007878: E8 93 26 00 00 call E0009F10 + E000787D: 83 C4 08 add esp,8 + E0007880: 8B 45 A0 mov eax,dword ptr [ebp-60h] + E0007883: 8B 48 10 mov ecx,dword ptr [eax+10h] + E0007886: 83 C1 0C add ecx,0Ch + E0007889: 89 4D E0 mov dword ptr [ebp-20h],ecx + E000788C: 8B 55 A0 mov edx,dword ptr [ebp-60h] + E000788F: 8B 45 E0 mov eax,dword ptr [ebp-20h] + E0007892: 89 42 1C mov dword ptr [edx+1Ch],eax + E0007895: 8B 4D E0 mov ecx,dword ptr [ebp-20h] + E0007898: 83 E9 01 sub ecx,1 + E000789B: 88 4D AC mov byte ptr [ebp-54h],cl + E000789E: 8B 55 A0 mov edx,dword ptr [ebp-60h] + E00078A1: 33 C0 xor eax,eax + E00078A3: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E00078A7: 83 C0 03 add eax,3 + E00078AA: 66 89 45 B0 mov word ptr [ebp-50h],ax + E00078AE: 66 8B 55 B0 mov dx,word ptr [ebp-50h] + E00078B2: 8A 45 AC mov al,byte ptr [ebp-54h] + E00078B5: EE out dx,al + E00078B6: E9 B1 FC FF FF jmp E000756C + E00078BB: C6 45 A4 05 mov byte ptr [ebp-5Ch],5 + E00078BF: 8B 4D A0 mov ecx,dword ptr [ebp-60h] + E00078C2: 33 D2 xor edx,edx + E00078C4: 66 8B 51 0C mov dx,word ptr [ecx+0Ch] + E00078C8: 83 C2 07 add edx,7 + E00078CB: 66 89 55 A8 mov word ptr [ebp-58h],dx + E00078CF: 66 8B 55 A8 mov dx,word ptr [ebp-58h] + E00078D3: 8A 45 A4 mov al,byte ptr [ebp-5Ch] + E00078D6: EE out dx,al + E00078D7: 5F pop edi + E00078D8: 5E pop esi + E00078D9: 5B pop ebx + E00078DA: 8B E5 mov esp,ebp + E00078DC: 5D pop ebp + E00078DD: C3 ret +?Counters@CNe2000@@IAEXXZ (protected: void __thiscall CNe2000::Counters(void)): + E00078DE: 55 push ebp + E00078DF: 8B EC mov ebp,esp + E00078E1: 83 EC 24 sub esp,24h + E00078E4: 53 push ebx + E00078E5: 56 push esi + E00078E6: 57 push edi + E00078E7: 89 4D DC mov dword ptr [ebp-24h],ecx + E00078EA: 8B 45 DC mov eax,dword ptr [ebp-24h] + E00078ED: 33 C9 xor ecx,ecx + E00078EF: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E00078F3: 83 C1 0D add ecx,0Dh + E00078F6: 66 89 4D FC mov word ptr [ebp-4],cx + E00078FA: 33 C0 xor eax,eax + E00078FC: 66 8B 55 FC mov dx,word ptr [ebp-4] + E0007900: EC in al,dx + E0007901: 88 45 F8 mov byte ptr [ebp-8],al + E0007904: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0007907: 81 E2 FF 00 00 00 and edx,0FFh + E000790D: 8B 45 DC mov eax,dword ptr [ebp-24h] + E0007910: 8B 48 2C mov ecx,dword ptr [eax+2Ch] + E0007913: 03 CA add ecx,edx + E0007915: 8B 55 DC mov edx,dword ptr [ebp-24h] + E0007918: 89 4A 2C mov dword ptr [edx+2Ch],ecx + E000791B: 8B 45 DC mov eax,dword ptr [ebp-24h] + E000791E: 33 C9 xor ecx,ecx + E0007920: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0007924: 83 C1 0E add ecx,0Eh + E0007927: 66 89 4D F4 mov word ptr [ebp-0Ch],cx + E000792B: 33 C0 xor eax,eax + E000792D: 66 8B 55 F4 mov dx,word ptr [ebp-0Ch] + E0007931: EC in al,dx + E0007932: 88 45 F0 mov byte ptr [ebp-10h],al + E0007935: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0007938: 81 E2 FF 00 00 00 and edx,0FFh + E000793E: 8B 45 DC mov eax,dword ptr [ebp-24h] + E0007941: 8B 48 30 mov ecx,dword ptr [eax+30h] + E0007944: 03 CA add ecx,edx + E0007946: 8B 55 DC mov edx,dword ptr [ebp-24h] + E0007949: 89 4A 30 mov dword ptr [edx+30h],ecx + E000794C: 8B 45 DC mov eax,dword ptr [ebp-24h] + E000794F: 33 C9 xor ecx,ecx + E0007951: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E0007955: 83 C1 0F add ecx,0Fh + E0007958: 66 89 4D EC mov word ptr [ebp-14h],cx + E000795C: 33 C0 xor eax,eax + E000795E: 66 8B 55 EC mov dx,word ptr [ebp-14h] + E0007962: EC in al,dx + E0007963: 88 45 E8 mov byte ptr [ebp-18h],al + E0007966: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E0007969: 81 E2 FF 00 00 00 and edx,0FFh + E000796F: 8B 45 DC mov eax,dword ptr [ebp-24h] + E0007972: 8B 48 34 mov ecx,dword ptr [eax+34h] + E0007975: 03 CA add ecx,edx + E0007977: 8B 55 DC mov edx,dword ptr [ebp-24h] + E000797A: 89 4A 34 mov dword ptr [edx+34h],ecx + E000797D: C6 45 E0 20 mov byte ptr [ebp-20h],20h + E0007981: 8B 45 DC mov eax,dword ptr [ebp-24h] + E0007984: 33 C9 xor ecx,ecx + E0007986: 66 8B 48 0C mov cx,word ptr [eax+0Ch] + E000798A: 83 C1 07 add ecx,7 + E000798D: 66 89 4D E4 mov word ptr [ebp-1Ch],cx + E0007991: 66 8B 55 E4 mov dx,word ptr [ebp-1Ch] + E0007995: 8A 45 E0 mov al,byte ptr [ebp-20h] + E0007998: EE out dx,al + E0007999: 5F pop edi + E000799A: 5E pop esi + E000799B: 5B pop ebx + E000799C: 8B E5 mov esp,ebp + E000799E: 5D pop ebp + E000799F: C3 ret +?Send@CNe2000@@IAEHI@Z (protected: int __thiscall CNe2000::Send(unsigned int)): + E00079A0: 55 push ebp + E00079A1: 8B EC mov ebp,esp + E00079A3: 51 push ecx + E00079A4: 89 4D FC mov dword ptr [ebp-4],ecx + E00079A7: 33 C0 xor eax,eax + E00079A9: 8B E5 mov esp,ebp + E00079AB: 5D pop ebp + E00079AC: C2 04 00 ret 4 +?QueryInterface@CNe2000@@UAAKABU_GUID@@PAPAX@Z (public: virtual unsigned long __cdecl CNe2000::QueryInterface(struct _GUID const &,void * *)): + E00079AF: 55 push ebp + E00079B0: 8B EC mov ebp,esp + E00079B2: 51 push ecx + E00079B3: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00079B6: 8B 08 mov ecx,dword ptr [eax] + E00079B8: 3B 0D D8 A0 00 E0 cmp ecx,dword ptr ds:[E000A0D8h] + E00079BE: 75 2A jne E00079EA + E00079C0: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00079C3: 8B 42 04 mov eax,dword ptr [edx+4] + E00079C6: 3B 05 DC A0 00 E0 cmp eax,dword ptr ds:[E000A0DCh] + E00079CC: 75 1C jne E00079EA + E00079CE: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00079D1: 8B 51 08 mov edx,dword ptr [ecx+8] + E00079D4: 3B 15 E0 A0 00 E0 cmp edx,dword ptr ds:[E000A0E0h] + E00079DA: 75 0E jne E00079EA + E00079DC: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00079DF: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E00079E2: 3B 0D E4 A0 00 E0 cmp ecx,dword ptr ds:[E000A0E4h] + E00079E8: 74 37 je E0007A21 + E00079EA: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00079ED: 8B 02 mov eax,dword ptr [edx] + E00079EF: 3B 05 08 A1 00 E0 cmp eax,dword ptr ds:[E000A108h] + E00079F5: 75 5D jne E0007A54 + E00079F7: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00079FA: 8B 51 04 mov edx,dword ptr [ecx+4] + E00079FD: 3B 15 0C A1 00 E0 cmp edx,dword ptr ds:[E000A10Ch] + E0007A03: 75 4F jne E0007A54 + E0007A05: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0007A08: 8B 48 08 mov ecx,dword ptr [eax+8] + E0007A0B: 3B 0D 10 A1 00 E0 cmp ecx,dword ptr ds:[E000A110h] + E0007A11: 75 41 jne E0007A54 + E0007A13: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0007A16: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0007A19: 3B 05 14 A1 00 E0 cmp eax,dword ptr ds:[E000A114h] + E0007A1F: 75 33 jne E0007A54 + E0007A21: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E0007A25: 74 0B je E0007A32 + E0007A27: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0007A2A: 83 C1 04 add ecx,4 + E0007A2D: 89 4D FC mov dword ptr [ebp-4],ecx + E0007A30: EB 07 jmp E0007A39 + E0007A32: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0007A39: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0007A3C: 8B 45 FC mov eax,dword ptr [ebp-4] + E0007A3F: 89 02 mov dword ptr [edx],eax + E0007A41: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0007A44: 8B 11 mov edx,dword ptr [ecx] + E0007A46: 8B 45 08 mov eax,dword ptr [ebp+8] + E0007A49: 50 push eax + E0007A4A: FF 52 04 call dword ptr [edx+4] + E0007A4D: 83 C4 04 add esp,4 + E0007A50: 33 C0 xor eax,eax + E0007A52: EB 05 jmp E0007A59 + E0007A54: B8 00 00 00 80 mov eax,80000000h + E0007A59: 8B E5 mov esp,ebp + E0007A5B: 5D pop ebp + E0007A5C: C3 ret +?GetInfo@CNe2000@@UAAKPAUdevice_t@@@Z (public: virtual unsigned long __cdecl CNe2000::GetInfo(struct device_t *)): + E0007A5D: 55 push ebp + E0007A5E: 8B EC mov ebp,esp + E0007A60: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0007A63: 83 38 0C cmp dword ptr [eax],0Ch + E0007A66: 73 07 jae E0007A6F + E0007A68: B8 00 00 00 80 mov eax,80000000h + E0007A6D: EB 1D jmp E0007A8C + E0007A6F: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0007A72: 8B 51 08 mov edx,dword ptr [ecx+8] + E0007A75: 52 push edx + E0007A76: 68 10 C3 00 E0 push 0E000C310h + E0007A7B: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0007A7E: 8B 48 04 mov ecx,dword ptr [eax+4] + E0007A81: 51 push ecx + E0007A82: E8 0D 25 00 00 call E0009F94 + E0007A87: 83 C4 0C add esp,0Ch + E0007A8A: 33 C0 xor eax,eax + E0007A8C: 5D pop ebp + E0007A8D: C3 ret +?DeviceOpen@CNe2000@@UAAKXZ (public: virtual unsigned long __cdecl CNe2000::DeviceOpen(void)): + E0007A8E: 55 push ebp + E0007A8F: 8B EC mov ebp,esp + E0007A91: 33 C0 xor eax,eax + E0007A93: 5D pop ebp + E0007A94: C3 ret + E0007A95: CC int 3 + E0007A96: CC int 3 + E0007A97: CC int 3 + E0007A98: CC int 3 + E0007A99: CC int 3 + E0007A9A: CC int 3 + E0007A9B: CC int 3 + E0007A9C: CC int 3 + E0007A9D: CC int 3 + E0007A9E: CC int 3 + E0007A9F: CC int 3 +??_GCNe2000@@UAEPAXI@Z (public: virtual void * __thiscall CNe2000::`scalar deleting destructor'(unsigned int)): + E0007AA0: 55 push ebp + E0007AA1: 8B EC mov ebp,esp + E0007AA3: 51 push ecx + E0007AA4: 89 4D FC mov dword ptr [ebp-4],ecx + E0007AA7: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0007AAA: E8 A6 E4 FF FF call E0005F55 + E0007AAF: 8B 45 08 mov eax,dword ptr [ebp+8] + E0007AB2: 83 E0 01 and eax,1 + E0007AB5: 85 C0 test eax,eax + E0007AB7: 74 0C je E0007AC5 + E0007AB9: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0007ABC: 51 push ecx + E0007ABD: E8 A8 24 00 00 call E0009F6A + E0007AC2: 83 C4 04 add esp,4 + E0007AC5: 8B 45 FC mov eax,dword ptr [ebp-4] + E0007AC8: 8B E5 mov esp,ebp + E0007ACA: 5D pop ebp + E0007ACB: C2 04 00 ret 4 + E0007ACE: CC int 3 + E0007ACF: CC int 3 +?AddRef@CNe2000@@UAAKXZ (public: virtual unsigned long __cdecl CNe2000::AddRef(void)): + E0007AD0: 55 push ebp + E0007AD1: 8B EC mov ebp,esp + E0007AD3: 8B 45 08 mov eax,dword ptr [ebp+8] + E0007AD6: 8B 48 08 mov ecx,dword ptr [eax+8] + E0007AD9: 83 C1 01 add ecx,1 + E0007ADC: 8B 55 08 mov edx,dword ptr [ebp+8] + E0007ADF: 89 4A 08 mov dword ptr [edx+8],ecx + E0007AE2: 8B 45 08 mov eax,dword ptr [ebp+8] + E0007AE5: 8B 40 08 mov eax,dword ptr [eax+8] + E0007AE8: 5D pop ebp + E0007AE9: C3 ret + E0007AEA: CC int 3 + E0007AEB: CC int 3 + E0007AEC: CC int 3 + E0007AED: CC int 3 + E0007AEE: CC int 3 + E0007AEF: CC int 3 +?Release@CNe2000@@UAAKXZ (public: virtual unsigned long __cdecl CNe2000::Release(void)): + E0007AF0: 55 push ebp + E0007AF1: 8B EC mov ebp,esp + E0007AF3: 83 EC 0C sub esp,0Ch + E0007AF6: 8B 45 08 mov eax,dword ptr [ebp+8] + E0007AF9: 83 78 08 00 cmp dword ptr [eax+8],0 + E0007AFD: 75 2F jne E0007B2E + E0007AFF: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0007B02: 89 4D F8 mov dword ptr [ebp-8],ecx + E0007B05: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0007B08: 89 55 FC mov dword ptr [ebp-4],edx + E0007B0B: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0007B0F: 74 12 je E0007B23 + E0007B11: 6A 01 push 1 + E0007B13: 8B 45 FC mov eax,dword ptr [ebp-4] + E0007B16: 8B 10 mov edx,dword ptr [eax] + E0007B18: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0007B1B: FF 52 0C call dword ptr [edx+0Ch] + E0007B1E: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0007B21: EB 07 jmp E0007B2A + E0007B23: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E0007B2A: 33 C0 xor eax,eax + E0007B2C: EB 15 jmp E0007B43 + E0007B2E: 8B 45 08 mov eax,dword ptr [ebp+8] + E0007B31: 8B 40 08 mov eax,dword ptr [eax+8] + E0007B34: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0007B37: 8B 51 08 mov edx,dword ptr [ecx+8] + E0007B3A: 83 EA 01 sub edx,1 + E0007B3D: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0007B40: 89 51 08 mov dword ptr [ecx+8],edx + E0007B43: 8B E5 mov esp,ebp + E0007B45: 5D pop ebp + E0007B46: C3 ret + E0007B47: CC int 3 + E0007B48: CC int 3 + E0007B49: CC int 3 + E0007B4A: CC int 3 + E0007B4B: CC int 3 + E0007B4C: CC int 3 + E0007B4D: CC int 3 + E0007B4E: CC int 3 + E0007B4F: CC int 3 +?QueryInterface@CNe2000@@W3AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CNe2000::QueryInterface`adjustor{4}' (struct _GUID const &,void * *)): + E0007B50: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0007B55: E9 55 FE FF FF jmp E00079AF + E0007B5A: CC int 3 + E0007B5B: CC int 3 + E0007B5C: CC int 3 + E0007B5D: CC int 3 + E0007B5E: CC int 3 + E0007B5F: CC int 3 +?AddRef@CNe2000@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CNe2000::AddRef`adjustor{4}' (void)): + E0007B60: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0007B65: E9 66 FF FF FF jmp E0007AD0 + E0007B6A: CC int 3 + E0007B6B: CC int 3 + E0007B6C: CC int 3 + E0007B6D: CC int 3 + E0007B6E: CC int 3 + E0007B6F: CC int 3 +?Release@CNe2000@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CNe2000::Release`adjustor{4}' (void)): + E0007B70: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0007B75: E9 76 FF FF FF jmp E0007AF0 + E0007B7A: CC int 3 + E0007B7B: CC int 3 + E0007B7C: CC int 3 + E0007B7D: CC int 3 + E0007B7E: CC int 3 + E0007B7F: CC int 3 +_pci_read: + E0007B80: 55 push ebp + E0007B81: 8B EC mov ebp,esp + E0007B83: 83 EC 0C sub esp,0Ch + E0007B86: 8A 45 FF mov al,byte ptr [ebp-1] + E0007B89: 0C 80 or al,80h + E0007B8B: 88 45 FF mov byte ptr [ebp-1],al + E0007B8E: 8A 4D FF mov cl,byte ptr [ebp-1] + E0007B91: 80 E1 80 and cl,80h + E0007B94: 88 4D FF mov byte ptr [ebp-1],cl + E0007B97: 8A 55 08 mov dl,byte ptr [ebp+8] + E0007B9A: 8A 45 FE mov al,byte ptr [ebp-2] + E0007B9D: 24 00 and al,0 + E0007B9F: 0A C2 or al,dl + E0007BA1: 88 45 FE mov byte ptr [ebp-2],al + E0007BA4: 8A 4D 0C mov cl,byte ptr [ebp+0Ch] + E0007BA7: 80 E1 1F and cl,1Fh + E0007BAA: C0 E1 03 shl cl,3 + E0007BAD: 8A 55 FD mov dl,byte ptr [ebp-3] + E0007BB0: 80 E2 07 and dl,7 + E0007BB3: 0A D1 or dl,cl + E0007BB5: 88 55 FD mov byte ptr [ebp-3],dl + E0007BB8: 8A 45 10 mov al,byte ptr [ebp+10h] + E0007BBB: 24 07 and al,7 + E0007BBD: 8A 4D FD mov cl,byte ptr [ebp-3] + E0007BC0: 80 E1 F8 and cl,0F8h + E0007BC3: 0A C8 or cl,al + E0007BC5: 88 4D FD mov byte ptr [ebp-3],cl + E0007BC8: 8B 55 14 mov edx,dword ptr [ebp+14h] + E0007BCB: 81 E2 FC 00 00 00 and edx,0FCh + E0007BD1: 8A 45 FC mov al,byte ptr [ebp-4] + E0007BD4: 24 00 and al,0 + E0007BD6: 0A C2 or al,dl + E0007BD8: 88 45 FC mov byte ptr [ebp-4],al + E0007BDB: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0007BDE: 51 push ecx + E0007BDF: 68 F8 0C 00 00 push 0CF8h + E0007BE4: E8 74 04 00 00 call E000805D + E0007BE9: 83 C4 08 add esp,8 + E0007BEC: 8B 55 14 mov edx,dword ptr [ebp+14h] + E0007BEF: 83 E2 03 and edx,3 + E0007BF2: 81 C2 FC 0C 00 00 add edx,0CFCh + E0007BF8: 66 89 55 F8 mov word ptr [ebp-8],dx + E0007BFC: 8B 45 18 mov eax,dword ptr [ebp+18h] + E0007BFF: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0007C02: 83 7D F4 01 cmp dword ptr [ebp-0Ch],1 + E0007C06: 74 0E je E0007C16 + E0007C08: 83 7D F4 02 cmp dword ptr [ebp-0Ch],2 + E0007C0C: 74 1C je E0007C2A + E0007C0E: 83 7D F4 04 cmp dword ptr [ebp-0Ch],4 + E0007C12: 74 2A je E0007C3E + E0007C14: EB 37 jmp E0007C4D + E0007C16: 66 8B 4D F8 mov cx,word ptr [ebp-8] + E0007C1A: 51 push ecx + E0007C1B: E8 DE 03 00 00 call E0007FFE + E0007C20: 83 C4 04 add esp,4 + E0007C23: 25 FF 00 00 00 and eax,0FFh + E0007C28: EB 25 jmp E0007C4F + E0007C2A: 66 8B 55 F8 mov dx,word ptr [ebp-8] + E0007C2E: 52 push edx + E0007C2F: E8 DC 03 00 00 call E0008010 + E0007C34: 83 C4 04 add esp,4 + E0007C37: 25 FF FF 00 00 and eax,0FFFFh + E0007C3C: EB 11 jmp E0007C4F + E0007C3E: 66 8B 45 F8 mov ax,word ptr [ebp-8] + E0007C42: 50 push eax + E0007C43: E8 DB 03 00 00 call E0008023 + E0007C48: 83 C4 04 add esp,4 + E0007C4B: EB 02 jmp E0007C4F + E0007C4D: 33 C0 xor eax,eax + E0007C4F: 8B E5 mov esp,ebp + E0007C51: 5D pop ebp + E0007C52: C3 ret +_pci_write: + E0007C53: 55 push ebp + E0007C54: 8B EC mov ebp,esp + E0007C56: 83 EC 0C sub esp,0Ch + E0007C59: 8A 45 FF mov al,byte ptr [ebp-1] + E0007C5C: 0C 80 or al,80h + E0007C5E: 88 45 FF mov byte ptr [ebp-1],al + E0007C61: 8A 4D FF mov cl,byte ptr [ebp-1] + E0007C64: 80 E1 80 and cl,80h + E0007C67: 88 4D FF mov byte ptr [ebp-1],cl + E0007C6A: 8A 55 08 mov dl,byte ptr [ebp+8] + E0007C6D: 8A 45 FE mov al,byte ptr [ebp-2] + E0007C70: 24 00 and al,0 + E0007C72: 0A C2 or al,dl + E0007C74: 88 45 FE mov byte ptr [ebp-2],al + E0007C77: 8A 4D 0C mov cl,byte ptr [ebp+0Ch] + E0007C7A: 80 E1 1F and cl,1Fh + E0007C7D: C0 E1 03 shl cl,3 + E0007C80: 8A 55 FD mov dl,byte ptr [ebp-3] + E0007C83: 80 E2 07 and dl,7 + E0007C86: 0A D1 or dl,cl + E0007C88: 88 55 FD mov byte ptr [ebp-3],dl + E0007C8B: 8A 45 10 mov al,byte ptr [ebp+10h] + E0007C8E: 24 07 and al,7 + E0007C90: 8A 4D FD mov cl,byte ptr [ebp-3] + E0007C93: 80 E1 F8 and cl,0F8h + E0007C96: 0A C8 or cl,al + E0007C98: 88 4D FD mov byte ptr [ebp-3],cl + E0007C9B: 8B 55 14 mov edx,dword ptr [ebp+14h] + E0007C9E: 81 E2 FC 00 00 00 and edx,0FCh + E0007CA4: 8A 45 FC mov al,byte ptr [ebp-4] + E0007CA7: 24 00 and al,0 + E0007CA9: 0A C2 or al,dl + E0007CAB: 88 45 FC mov byte ptr [ebp-4],al + E0007CAE: 8B 4D 14 mov ecx,dword ptr [ebp+14h] + E0007CB1: 83 E1 03 and ecx,3 + E0007CB4: 81 C1 FC 0C 00 00 add ecx,0CFCh + E0007CBA: 66 89 4D F8 mov word ptr [ebp-8],cx + E0007CBE: 8B 55 FC mov edx,dword ptr [ebp-4] + E0007CC1: 52 push edx + E0007CC2: 68 F8 0C 00 00 push 0CF8h + E0007CC7: E8 91 03 00 00 call E000805D + E0007CCC: 83 C4 08 add esp,8 + E0007CCF: 8B 45 1C mov eax,dword ptr [ebp+1Ch] + E0007CD2: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0007CD5: 83 7D F4 01 cmp dword ptr [ebp-0Ch],1 + E0007CD9: 74 0E je E0007CE9 + E0007CDB: 83 7D F4 02 cmp dword ptr [ebp-0Ch],2 + E0007CDF: 74 1B je E0007CFC + E0007CE1: 83 7D F4 04 cmp dword ptr [ebp-0Ch],4 + E0007CE5: 74 29 je E0007D10 + E0007CE7: EB 38 jmp E0007D21 + E0007CE9: 8A 4D 18 mov cl,byte ptr [ebp+18h] + E0007CEC: 51 push ecx + E0007CED: 66 8B 55 F8 mov dx,word ptr [ebp-8] + E0007CF1: 52 push edx + E0007CF2: E8 3E 03 00 00 call E0008035 + E0007CF7: 83 C4 08 add esp,8 + E0007CFA: EB 25 jmp E0007D21 + E0007CFC: 66 8B 45 18 mov ax,word ptr [ebp+18h] + E0007D00: 50 push eax + E0007D01: 66 8B 4D F8 mov cx,word ptr [ebp-8] + E0007D05: 51 push ecx + E0007D06: E8 3D 03 00 00 call E0008048 + E0007D0B: 83 C4 08 add esp,8 + E0007D0E: EB 11 jmp E0007D21 + E0007D10: 8B 55 18 mov edx,dword ptr [ebp+18h] + E0007D13: 52 push edx + E0007D14: 66 8B 45 F8 mov ax,word ptr [ebp-8] + E0007D18: 50 push eax + E0007D19: E8 3F 03 00 00 call E000805D + E0007D1E: 83 C4 08 add esp,8 + E0007D21: 8B E5 mov esp,ebp + E0007D23: 5D pop ebp + E0007D24: C3 ret +_pci_probe: + E0007D25: 55 push ebp + E0007D26: 8B EC mov ebp,esp + E0007D28: 83 EC 14 sub esp,14h + E0007D2B: 8B 45 14 mov eax,dword ptr [ebp+14h] + E0007D2E: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0007D31: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E0007D38: EB 09 jmp E0007D43 + E0007D3A: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0007D3D: 83 C1 01 add ecx,1 + E0007D40: 89 4D F8 mov dword ptr [ebp-8],ecx + E0007D43: 83 7D F8 04 cmp dword ptr [ebp-8],4 + E0007D47: 7D 28 jge E0007D71 + E0007D49: 6A 04 push 4 + E0007D4B: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0007D4E: C1 E2 02 shl edx,2 + E0007D51: 52 push edx + E0007D52: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0007D55: 50 push eax + E0007D56: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0007D59: 51 push ecx + E0007D5A: 8B 55 08 mov edx,dword ptr [ebp+8] + E0007D5D: 52 push edx + E0007D5E: E8 1D FE FF FF call E0007B80 + E0007D63: 83 C4 14 add esp,14h + E0007D66: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0007D69: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0007D6C: 89 04 8A mov dword ptr [edx+ecx*4],eax + E0007D6F: EB C9 jmp E0007D3A + E0007D71: 8B 45 14 mov eax,dword ptr [ebp+14h] + E0007D74: 33 C9 xor ecx,ecx + E0007D76: 66 8B 08 mov cx,word ptr [eax] + E0007D79: 81 F9 FF FF 00 00 cmp ecx,0FFFFh + E0007D7F: 75 0A jne E0007D8B + E0007D81: B8 01 00 00 00 mov eax,1 + E0007D86: E9 6F 02 00 00 jmp E0007FFA + E0007D8B: 8B 55 14 mov edx,dword ptr [ebp+14h] + E0007D8E: 8A 45 08 mov al,byte ptr [ebp+8] + E0007D91: 88 42 10 mov byte ptr [edx+10h],al + E0007D94: 8B 4D 14 mov ecx,dword ptr [ebp+14h] + E0007D97: 8A 55 0C mov dl,byte ptr [ebp+0Ch] + E0007D9A: 88 51 11 mov byte ptr [ecx+11h],dl + E0007D9D: 8B 45 14 mov eax,dword ptr [ebp+14h] + E0007DA0: 8A 4D 10 mov cl,byte ptr [ebp+10h] + E0007DA3: 88 48 12 mov byte ptr [eax+12h],cl + E0007DA6: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0007DA9: 52 push edx + E0007DAA: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0007DAD: 50 push eax + E0007DAE: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0007DB1: 51 push ecx + E0007DB2: 68 54 C3 00 E0 push 0E000C354h + E0007DB7: E8 54 21 00 00 call E0009F10 + E0007DBC: 83 C4 10 add esp,10h + E0007DBF: 8B 55 14 mov edx,dword ptr [ebp+14h] + E0007DC2: 33 C0 xor eax,eax + E0007DC4: 8A 42 09 mov al,byte ptr [edx+9] + E0007DC7: 50 push eax + E0007DC8: 8B 4D 14 mov ecx,dword ptr [ebp+14h] + E0007DCB: 33 D2 xor edx,edx + E0007DCD: 8A 51 0A mov dl,byte ptr [ecx+0Ah] + E0007DD0: 52 push edx + E0007DD1: 8B 45 14 mov eax,dword ptr [ebp+14h] + E0007DD4: 33 C9 xor ecx,ecx + E0007DD6: 8A 48 0B mov cl,byte ptr [eax+0Bh] + E0007DD9: 51 push ecx + E0007DDA: 8B 55 14 mov edx,dword ptr [ebp+14h] + E0007DDD: 33 C0 xor eax,eax + E0007DDF: 66 8B 42 02 mov ax,word ptr [edx+2] + E0007DE3: 50 push eax + E0007DE4: 8B 4D 14 mov ecx,dword ptr [ebp+14h] + E0007DE7: 33 D2 xor edx,edx + E0007DE9: 66 8B 11 mov dx,word ptr [ecx] + E0007DEC: 52 push edx + E0007DED: 68 94 C3 00 E0 push 0E000C394h + E0007DF2: E8 19 21 00 00 call E0009F10 + E0007DF7: 83 C4 18 add esp,18h + E0007DFA: 8B 45 14 mov eax,dword ptr [ebp+14h] + E0007DFD: 33 C9 xor ecx,ecx + E0007DFF: 8A 48 0C mov cl,byte ptr [eax+0Ch] + E0007E02: 51 push ecx + E0007E03: 8B 55 14 mov edx,dword ptr [ebp+14h] + E0007E06: 33 C0 xor eax,eax + E0007E08: 8A 42 0D mov al,byte ptr [edx+0Dh] + E0007E0B: 50 push eax + E0007E0C: 8B 4D 14 mov ecx,dword ptr [ebp+14h] + E0007E0F: 33 D2 xor edx,edx + E0007E11: 8A 51 0E mov dl,byte ptr [ecx+0Eh] + E0007E14: 52 push edx + E0007E15: 8B 45 14 mov eax,dword ptr [ebp+14h] + E0007E18: 33 C9 xor ecx,ecx + E0007E1A: 8A 48 0F mov cl,byte ptr [eax+0Fh] + E0007E1D: 51 push ecx + E0007E1E: 8B 55 14 mov edx,dword ptr [ebp+14h] + E0007E21: 33 C0 xor eax,eax + E0007E23: 66 8B 42 04 mov ax,word ptr [edx+4] + E0007E27: 50 push eax + E0007E28: 8B 4D 14 mov ecx,dword ptr [ebp+14h] + E0007E2B: 33 D2 xor edx,edx + E0007E2D: 66 8B 51 06 mov dx,word ptr [ecx+6] + E0007E31: 52 push edx + E0007E32: 68 14 C4 00 E0 push 0E000C414h + E0007E37: E8 D4 20 00 00 call E0009F10 + E0007E3C: 83 C4 1C add esp,1Ch + E0007E3F: 8B 45 14 mov eax,dword ptr [ebp+14h] + E0007E42: 33 C9 xor ecx,ecx + E0007E44: 8A 48 0E mov cl,byte ptr [eax+0Eh] + E0007E47: 83 E1 7F and ecx,7Fh + E0007E4A: 89 4D EC mov dword ptr [ebp-14h],ecx + E0007E4D: 83 7D EC 00 cmp dword ptr [ebp-14h],0 + E0007E51: 74 0F je E0007E62 + E0007E53: 83 7D EC 01 cmp dword ptr [ebp-14h],1 + E0007E57: 0F 84 7F 01 00 00 je E0007FDC + E0007E5D: E9 89 01 00 00 jmp E0007FEB + E0007E62: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E0007E69: EB 09 jmp E0007E74 + E0007E6B: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0007E6E: 83 C2 01 add edx,1 + E0007E71: 89 55 F8 mov dword ptr [ebp-8],edx + E0007E74: 83 7D F8 06 cmp dword ptr [ebp-8],6 + E0007E78: 0F 8D 16 01 00 00 jge E0007F94 + E0007E7E: 6A 04 push 4 + E0007E80: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0007E83: 8D 0C 85 10 00 00 lea ecx,dword ptr [eax*4+00000010h] + 00 + E0007E8A: 51 push ecx + E0007E8B: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0007E8E: 52 push edx + E0007E8F: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0007E92: 50 push eax + E0007E93: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0007E96: 51 push ecx + E0007E97: E8 E4 FC FF FF call E0007B80 + E0007E9C: 83 C4 14 add esp,14h + E0007E9F: 89 45 FC mov dword ptr [ebp-4],eax + E0007EA2: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0007EA6: 0F 84 C7 00 00 00 je E0007F73 + E0007EAC: 6A 04 push 4 + E0007EAE: 6A FF push 0FFh + E0007EB0: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0007EB3: 8D 04 95 10 00 00 lea eax,dword ptr [edx*4+00000010h] + 00 + E0007EBA: 50 push eax + E0007EBB: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E0007EBE: 51 push ecx + E0007EBF: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0007EC2: 52 push edx + E0007EC3: 8B 45 08 mov eax,dword ptr [ebp+8] + E0007EC6: 50 push eax + E0007EC7: E8 87 FD FF FF call E0007C53 + E0007ECC: 83 C4 18 add esp,18h + E0007ECF: 6A 04 push 4 + E0007ED1: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0007ED4: 8D 14 8D 10 00 00 lea edx,dword ptr [ecx*4+00000010h] + 00 + E0007EDB: 52 push edx + E0007EDC: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0007EDF: 50 push eax + E0007EE0: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0007EE3: 51 push ecx + E0007EE4: 8B 55 08 mov edx,dword ptr [ebp+8] + E0007EE7: 52 push edx + E0007EE8: E8 93 FC FF FF call E0007B80 + E0007EED: 83 C4 14 add esp,14h + E0007EF0: 24 F0 and al,0F0h + E0007EF2: 89 45 F0 mov dword ptr [ebp-10h],eax + E0007EF5: 6A 04 push 4 + E0007EF7: 8B 45 FC mov eax,dword ptr [ebp-4] + E0007EFA: 50 push eax + E0007EFB: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0007EFE: 8D 14 8D 10 00 00 lea edx,dword ptr [ecx*4+00000010h] + 00 + E0007F05: 52 push edx + E0007F06: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0007F09: 50 push eax + E0007F0A: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0007F0D: 51 push ecx + E0007F0E: 8B 55 08 mov edx,dword ptr [ebp+8] + E0007F11: 52 push edx + E0007F12: E8 3C FD FF FF call E0007C53 + E0007F17: 83 C4 18 add esp,18h + E0007F1A: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E0007F1D: F7 D0 not eax + E0007F1F: 83 C0 01 add eax,1 + E0007F22: 89 45 F0 mov dword ptr [ebp-10h],eax + E0007F25: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0007F28: 83 E1 01 and ecx,1 + E0007F2B: 85 C9 test ecx,ecx + E0007F2D: 74 28 je E0007F57 + E0007F2F: 8B 55 FC mov edx,dword ptr [ebp-4] + E0007F32: 81 E2 FF FF 00 00 and edx,0FFFFh + E0007F38: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0007F3B: 8B 4D 14 mov ecx,dword ptr [ebp+14h] + E0007F3E: 89 54 81 14 mov dword ptr [ecx+eax*4+14h],edx + E0007F42: 8B 55 F0 mov edx,dword ptr [ebp-10h] + E0007F45: 81 E2 FF FF 00 00 and edx,0FFFFh + E0007F4B: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0007F4E: 8B 4D 14 mov ecx,dword ptr [ebp+14h] + E0007F51: 89 54 81 2C mov dword ptr [ecx+eax*4+2Ch],edx + E0007F55: EB 1A jmp E0007F71 + E0007F57: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0007F5A: 8B 45 14 mov eax,dword ptr [ebp+14h] + E0007F5D: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0007F60: 89 4C 90 14 mov dword ptr [eax+edx*4+14h],ecx + E0007F64: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0007F67: 8B 45 14 mov eax,dword ptr [ebp+14h] + E0007F6A: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0007F6D: 89 4C 90 2C mov dword ptr [eax+edx*4+2Ch],ecx + E0007F71: EB 1C jmp E0007F8F + E0007F73: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0007F76: 8B 45 14 mov eax,dword ptr [ebp+14h] + E0007F79: C7 44 90 14 00 00 mov dword ptr [eax+edx*4+14h],0 + 00 00 + E0007F81: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0007F84: 8B 55 14 mov edx,dword ptr [ebp+14h] + E0007F87: C7 44 8A 2C 00 00 mov dword ptr [edx+ecx*4+2Ch],0 + 00 00 + E0007F8F: E9 D7 FE FF FF jmp E0007E6B + E0007F94: 6A 01 push 1 + E0007F96: 6A 3C push 3Ch + E0007F98: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0007F9B: 50 push eax + E0007F9C: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0007F9F: 51 push ecx + E0007FA0: 8B 55 08 mov edx,dword ptr [ebp+8] + E0007FA3: 52 push edx + E0007FA4: E8 D7 FB FF FF call E0007B80 + E0007FA9: 83 C4 14 add esp,14h + E0007FAC: 89 45 FC mov dword ptr [ebp-4],eax + E0007FAF: 8B 45 FC mov eax,dword ptr [ebp-4] + E0007FB2: 2D FF 00 00 00 sub eax,0FFh + E0007FB7: F7 D8 neg eax + E0007FB9: 1B C0 sbb eax,eax + E0007FBB: 23 45 FC and eax,dword ptr [ebp-4] + E0007FBE: 8B 4D 14 mov ecx,dword ptr [ebp+14h] + E0007FC1: 88 41 13 mov byte ptr [ecx+13h],al + E0007FC4: 8B 55 14 mov edx,dword ptr [ebp+14h] + E0007FC7: 33 C0 xor eax,eax + E0007FC9: 8A 42 13 mov al,byte ptr [edx+13h] + E0007FCC: 50 push eax + E0007FCD: 68 90 C4 00 E0 push 0E000C490h + E0007FD2: E8 39 1F 00 00 call E0009F10 + E0007FD7: 83 C4 08 add esp,8 + E0007FDA: EB 1C jmp E0007FF8 + E0007FDC: 68 C0 C4 00 E0 push 0E000C4C0h + E0007FE1: E8 2A 1F 00 00 call E0009F10 + E0007FE6: 83 C4 04 add esp,4 + E0007FE9: EB 0D jmp E0007FF8 + E0007FEB: 68 F0 C4 00 E0 push 0E000C4F0h + E0007FF0: E8 1B 1F 00 00 call E0009F10 + E0007FF5: 83 C4 04 add esp,4 + E0007FF8: 33 C0 xor eax,eax + E0007FFA: 8B E5 mov esp,ebp + E0007FFC: 5D pop ebp + E0007FFD: C3 ret +_in: + E0007FFE: 55 push ebp + E0007FFF: 8B EC mov ebp,esp + E0008001: 53 push ebx + E0008002: 56 push esi + E0008003: 57 push edi + E0008004: 33 C0 xor eax,eax + E0008006: 66 8B 55 08 mov dx,word ptr [ebp+8] + E000800A: EC in al,dx + E000800B: 5F pop edi + E000800C: 5E pop esi + E000800D: 5B pop ebx + E000800E: 5D pop ebp + E000800F: C3 ret +_in16: + E0008010: 55 push ebp + E0008011: 8B EC mov ebp,esp + E0008013: 53 push ebx + E0008014: 56 push esi + E0008015: 57 push edi + E0008016: 33 C0 xor eax,eax + E0008018: 66 8B 55 08 mov dx,word ptr [ebp+8] + E000801C: 66 ED in ax,dx + E000801E: 5F pop edi + E000801F: 5E pop esi + E0008020: 5B pop ebx + E0008021: 5D pop ebp + E0008022: C3 ret +_in32: + E0008023: 55 push ebp + E0008024: 8B EC mov ebp,esp + E0008026: 53 push ebx + E0008027: 56 push esi + E0008028: 57 push edi + E0008029: 33 C0 xor eax,eax + E000802B: 66 8B 55 08 mov dx,word ptr [ebp+8] + E000802F: ED in eax,dx + E0008030: 5F pop edi + E0008031: 5E pop esi + E0008032: 5B pop ebx + E0008033: 5D pop ebp + E0008034: C3 ret +_out: + E0008035: 55 push ebp + E0008036: 8B EC mov ebp,esp + E0008038: 53 push ebx + E0008039: 56 push esi + E000803A: 57 push edi + E000803B: 66 8B 55 08 mov dx,word ptr [ebp+8] + E000803F: 8A 45 0C mov al,byte ptr [ebp+0Ch] + E0008042: EE out dx,al + E0008043: 5F pop edi + E0008044: 5E pop esi + E0008045: 5B pop ebx + E0008046: 5D pop ebp + E0008047: C3 ret +_out16: + E0008048: 55 push ebp + E0008049: 8B EC mov ebp,esp + E000804B: 53 push ebx + E000804C: 56 push esi + E000804D: 57 push edi + E000804E: 66 8B 55 08 mov dx,word ptr [ebp+8] + E0008052: 66 8B 45 0C mov ax,word ptr [ebp+0Ch] + E0008056: 66 EF out dx,ax + E0008058: 5F pop edi + E0008059: 5E pop esi + E000805A: 5B pop ebx + E000805B: 5D pop ebp + E000805C: C3 ret +_out32: + E000805D: 55 push ebp + E000805E: 8B EC mov ebp,esp + E0008060: 53 push ebx + E0008061: 56 push esi + E0008062: 57 push edi + E0008063: 66 8B 55 08 mov dx,word ptr [ebp+8] + E0008067: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000806A: EF out dx,eax + E000806B: 5F pop edi + E000806C: 5E pop esi + E000806D: 5B pop ebx + E000806E: 5D pop ebp + E000806F: C3 ret +_pci_find: + E0008070: 55 push ebp + E0008071: 8B EC mov ebp,esp + E0008073: 83 EC 08 sub esp,8 + E0008076: 66 C7 45 F8 00 00 mov word ptr [ebp-8],0 + E000807C: EB 0C jmp E000808A + E000807E: 66 8B 45 F8 mov ax,word ptr [ebp-8] + E0008082: 66 05 01 00 add ax,1 + E0008086: 66 89 45 F8 mov word ptr [ebp-8],ax + E000808A: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E000808D: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0008093: 81 F9 FF 00 00 00 cmp ecx,0FFh + E0008099: 7D 7C jge E0008117 + E000809B: 66 C7 45 FC 00 00 mov word ptr [ebp-4],0 + E00080A1: EB 0C jmp E00080AF + E00080A3: 66 8B 55 FC mov dx,word ptr [ebp-4] + E00080A7: 66 83 C2 01 add dx,1 + E00080AB: 66 89 55 FC mov word ptr [ebp-4],dx + E00080AF: 8B 45 FC mov eax,dword ptr [ebp-4] + E00080B2: 25 FF FF 00 00 and eax,0FFFFh + E00080B7: 83 F8 20 cmp eax,20h + E00080BA: 7D 56 jge E0008112 + E00080BC: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E00080BF: 51 push ecx + E00080C0: 6A 00 push 0 + E00080C2: 8B 55 FC mov edx,dword ptr [ebp-4] + E00080C5: 81 E2 FF FF 00 00 and edx,0FFFFh + E00080CB: 52 push edx + E00080CC: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00080CF: 25 FF FF 00 00 and eax,0FFFFh + E00080D4: 50 push eax + E00080D5: E8 4B FC FF FF call E0007D25 + E00080DA: 83 C4 10 add esp,10h + E00080DD: 85 C0 test eax,eax + E00080DF: 74 02 je E00080E3 + E00080E1: EB C0 jmp E00080A3 + E00080E3: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E00080E6: 33 D2 xor edx,edx + E00080E8: 66 8B 11 mov dx,word ptr [ecx] + E00080EB: 8B 45 08 mov eax,dword ptr [ebp+8] + E00080EE: 25 FF FF 00 00 and eax,0FFFFh + E00080F3: 3B D0 cmp edx,eax + E00080F5: 75 19 jne E0008110 + E00080F7: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E00080FA: 33 D2 xor edx,edx + E00080FC: 66 8B 51 02 mov dx,word ptr [ecx+2] + E0008100: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008103: 25 FF FF 00 00 and eax,0FFFFh + E0008108: 3B D0 cmp edx,eax + E000810A: 75 04 jne E0008110 + E000810C: B0 01 mov al,1 + E000810E: EB 09 jmp E0008119 + E0008110: EB 91 jmp E00080A3 + E0008112: E9 67 FF FF FF jmp E000807E + E0008117: 32 C0 xor al,al + E0008119: 8B E5 mov esp,ebp + E000811B: 5D pop ebp + E000811C: C3 ret + E000811D: CC int 3 + E000811E: CC int 3 + E000811F: CC int 3 +?Isr@CPs2Mouse@@KAXPAV1@H@Z (protected: static void __cdecl CPs2Mouse::Isr(class CPs2Mouse *,int)): + E0008120: 55 push ebp + E0008121: 8B EC mov ebp,esp + E0008123: 83 EC 08 sub esp,8 + E0008126: 53 push ebx + E0008127: 56 push esi + E0008128: 57 push edi + E0008129: 66 C7 45 F8 64 00 mov word ptr [ebp-8],64h + E000812F: 33 C0 xor eax,eax + E0008131: 66 8B 55 F8 mov dx,word ptr [ebp-8] + E0008135: EC in al,dx + E0008136: 88 45 FC mov byte ptr [ebp-4],al + E0008139: 8B 45 FC mov eax,dword ptr [ebp-4] + E000813C: 25 FF 00 00 00 and eax,0FFh + E0008141: 83 E0 01 and eax,1 + E0008144: 85 C0 test eax,eax + E0008146: 74 48 je E0008190 + E0008148: BA 01 00 00 00 mov edx,1 + E000814D: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0008150: D3 E2 shl edx,cl + E0008152: 66 A1 68 C8 00 E0 mov ax,[E000C868] + E0008158: 66 0B C2 or ax,dx + E000815B: 66 A3 68 C8 00 E0 mov [E000C868],ax + E0008161: 83 3D 6C C8 00 E0 cmp dword ptr ds:[E000C86Ch],0 + 00 + E0008168: 75 26 jne E0008190 + E000816A: 8B 0D 6C C8 00 E0 mov ecx,dword ptr ds:[E000C86Ch] + E0008170: 83 C1 01 add ecx,1 + E0008173: 89 0D 6C C8 00 E0 mov dword ptr ds:[E000C86Ch],ecx + E0008179: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000817C: E8 77 02 00 00 call E00083F8 + E0008181: 8B 15 6C C8 00 E0 mov edx,dword ptr ds:[E000C86Ch] + E0008187: 83 EA 01 sub edx,1 + E000818A: 89 15 6C C8 00 E0 mov dword ptr ds:[E000C86Ch],edx + E0008190: 5F pop edi + E0008191: 5E pop esi + E0008192: 5B pop ebx + E0008193: 8B E5 mov esp,ebp + E0008195: 5D pop ebp + E0008196: C3 ret +??0CPs2Mouse@@QAE@XZ (public: __thiscall CPs2Mouse::CPs2Mouse(void)): + E0008197: 55 push ebp + E0008198: 8B EC mov ebp,esp + E000819A: 83 EC 14 sub esp,14h + E000819D: 89 4D EC mov dword ptr [ebp-14h],ecx + E00081A0: 8B 45 EC mov eax,dword ptr [ebp-14h] + E00081A3: C7 00 C8 A0 00 E0 mov dword ptr [eax],0E000A0C8h + E00081A9: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E00081AC: 83 C1 04 add ecx,4 + E00081AF: 89 4D F4 mov dword ptr [ebp-0Ch],ecx + E00081B2: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E00081B5: C7 02 B0 A0 00 E0 mov dword ptr [edx],0E000A0B0h + E00081BB: 8B 45 EC mov eax,dword ptr [ebp-14h] + E00081BE: 83 C0 08 add eax,8 + E00081C1: 89 45 F0 mov dword ptr [ebp-10h],eax + E00081C4: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E00081C7: C7 01 10 A2 00 E0 mov dword ptr [ecx],0E000A210h + E00081CD: 8B 55 EC mov edx,dword ptr [ebp-14h] + E00081D0: C7 02 A0 A6 00 E0 mov dword ptr [edx],0E000A6A0h + E00081D6: 8B 45 EC mov eax,dword ptr [ebp-14h] + E00081D9: C7 40 04 88 A6 00 mov dword ptr [eax+4],0E000A688h + E0 + E00081E0: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E00081E3: C7 41 08 60 A6 00 mov dword ptr [ecx+8],0E000A660h + E0 + E00081EA: 8B 55 EC mov edx,dword ptr [ebp-14h] + E00081ED: C7 42 30 00 00 00 mov dword ptr [edx+30h],0 + 00 + E00081F4: 68 A8 00 00 00 push 0A8h + E00081F9: 6A 64 push 64h + E00081FB: E8 71 CC FF FF call E0004E71 + E0008200: 83 C4 08 add esp,8 + E0008203: C7 45 FC 28 C5 00 mov dword ptr [ebp-4],0E000C528h + E0 + E000820A: EB 09 jmp E0008215 + E000820C: 8B 45 FC mov eax,dword ptr [ebp-4] + E000820F: 83 C0 01 add eax,1 + E0008212: 89 45 FC mov dword ptr [ebp-4],eax + E0008215: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0008218: 33 D2 xor edx,edx + E000821A: 8A 11 mov dl,byte ptr [ecx] + E000821C: 85 D2 test edx,edx + E000821E: 74 26 je E0008246 + E0008220: 68 D4 00 00 00 push 0D4h + E0008225: 6A 64 push 64h + E0008227: E8 45 CC FF FF call E0004E71 + E000822C: 83 C4 08 add esp,8 + E000822F: 68 38 C5 00 E0 push 0E000C538h + E0008234: 8B 45 FC mov eax,dword ptr [ebp-4] + E0008237: 8A 08 mov cl,byte ptr [eax] + E0008239: 51 push ecx + E000823A: 6A 60 push 60h + E000823C: E8 FE CC FF FF call E0004F3F + E0008241: 83 C4 0C add esp,0Ch + E0008244: EB C6 jmp E000820C + E0008246: 6A 0A push 0Ah + E0008248: E8 B8 D6 FF FF call E0005905 + E000824D: 83 C4 04 add esp,4 + E0008250: 68 D4 00 00 00 push 0D4h + E0008255: 6A 64 push 64h + E0008257: E8 15 CC FF FF call E0004E71 + E000825C: 83 C4 08 add esp,8 + E000825F: 68 3C C5 00 E0 push 0E000C53Ch + E0008264: 68 F2 00 00 00 push 0F2h + E0008269: 6A 60 push 60h + E000826B: E8 CF CC FF FF call E0004F3F + E0008270: 83 C4 0C add esp,0Ch + E0008273: E8 53 CC FF FF call E0004ECB + E0008278: 88 45 F8 mov byte ptr [ebp-8],al + E000827B: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000827E: 81 E2 FF 00 00 00 and edx,0FFh + E0008284: 33 C0 xor eax,eax + E0008286: 83 FA 03 cmp edx,3 + E0008289: 0F 94 C0 sete al + E000828C: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E000828F: 88 41 0C mov byte ptr [ecx+0Ch],al + E0008292: 68 D4 00 00 00 push 0D4h + E0008297: 6A 64 push 64h + E0008299: E8 D3 CB FF FF call E0004E71 + E000829E: 83 C4 08 add esp,8 + E00082A1: 68 40 C5 00 E0 push 0E000C540h + E00082A6: 68 F3 00 00 00 push 0F3h + E00082AB: 6A 60 push 60h + E00082AD: E8 8D CC FF FF call E0004F3F + E00082B2: 83 C4 0C add esp,0Ch + E00082B5: 68 D4 00 00 00 push 0D4h + E00082BA: 6A 64 push 64h + E00082BC: E8 B0 CB FF FF call E0004E71 + E00082C1: 83 C4 08 add esp,8 + E00082C4: 68 44 C5 00 E0 push 0E000C544h + E00082C9: 68 FF 00 00 00 push 0FFh + E00082CE: 6A 60 push 60h + E00082D0: E8 6A CC FF FF call E0004F3F + E00082D5: 83 C4 0C add esp,0Ch + E00082D8: 68 D4 00 00 00 push 0D4h + E00082DD: 6A 64 push 64h + E00082DF: E8 8D CB FF FF call E0004E71 + E00082E4: 83 C4 08 add esp,8 + E00082E7: 68 48 C5 00 E0 push 0E000C548h + E00082EC: 68 F4 00 00 00 push 0F4h + E00082F1: 6A 60 push 60h + E00082F3: E8 47 CC FF FF call E0004F3F + E00082F8: 83 C4 0C add esp,0Ch + E00082FB: 8B 55 EC mov edx,dword ptr [ebp-14h] + E00082FE: 52 push edx + E00082FF: 68 20 81 00 E0 push 0E0008120h + E0008304: 6A 0C push 0Ch + E0008306: E8 23 1C 00 00 call E0009F2E + E000830B: 83 C4 0C add esp,0Ch + E000830E: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0008311: C7 40 24 00 00 00 mov dword ptr [eax+24h],0 + 00 + E0008318: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E000831B: C7 41 1C 00 00 00 mov dword ptr [ecx+1Ch],0 + 00 + E0008322: 8B 55 EC mov edx,dword ptr [ebp-14h] + E0008325: C7 42 18 40 01 00 mov dword ptr [edx+18h],140h + 00 + E000832C: 8B 45 EC mov eax,dword ptr [ebp-14h] + E000832F: C7 40 20 C8 00 00 mov dword ptr [eax+20h],0C8h + 00 + E0008336: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0008339: 8B 41 1C mov eax,dword ptr [ecx+1Ch] + E000833C: 8B 55 EC mov edx,dword ptr [ebp-14h] + E000833F: 03 42 18 add eax,dword ptr [edx+18h] + E0008342: 99 cwd + E0008343: 2B C2 sub eax,edx + E0008345: D1 F8 sar eax,1 + E0008347: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E000834A: 89 41 10 mov dword ptr [ecx+10h],eax + E000834D: 8B 55 EC mov edx,dword ptr [ebp-14h] + E0008350: 8B 42 24 mov eax,dword ptr [edx+24h] + E0008353: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0008356: 03 41 20 add eax,dword ptr [ecx+20h] + E0008359: 99 cwd + E000835A: 2B C2 sub eax,edx + E000835C: D1 F8 sar eax,1 + E000835E: 8B 55 EC mov edx,dword ptr [ebp-14h] + E0008361: 89 42 14 mov dword ptr [edx+14h],eax + E0008364: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0008367: 8B E5 mov esp,ebp + E0008369: 5D pop ebp + E000836A: C3 ret +?AuxRead@CPs2Mouse@@IAEEXZ (protected: unsigned char __thiscall CPs2Mouse::AuxRead(void)): + E000836B: 55 push ebp + E000836C: 8B EC mov ebp,esp + E000836E: 83 EC 14 sub esp,14h + E0008371: 53 push ebx + E0008372: 56 push esi + E0008373: 57 push edi + E0008374: 89 4D EC mov dword ptr [ebp-14h],ecx + E0008377: FB sti + E0008378: B8 01 00 00 00 mov eax,1 + E000837D: 85 C0 test eax,eax + E000837F: 74 6E je E00083EF + E0008381: 33 C9 xor ecx,ecx + E0008383: 85 C9 test ecx,ecx + E0008385: 74 0C je E0008393 + E0008387: 6A 3F push 3Fh + E0008389: E8 2A 1C 00 00 call E0009FB8 + E000838E: 83 C4 04 add esp,4 + E0008391: EB EE jmp E0008381 + E0008393: 66 8B 15 68 C8 00 mov dx,word ptr ds:[E000C868h] + E0 + E000839A: 66 81 E2 FF EF and dx,0EFFFh + E000839F: 66 89 15 68 C8 00 mov word ptr ds:[E000C868h],dx + E0 + E00083A6: 66 C7 45 F4 64 00 mov word ptr [ebp-0Ch],64h + E00083AC: 33 C0 xor eax,eax + E00083AE: 66 8B 55 F4 mov dx,word ptr [ebp-0Ch] + E00083B2: EC in al,dx + E00083B3: 88 45 FC mov byte ptr [ebp-4],al + E00083B6: 8B 45 FC mov eax,dword ptr [ebp-4] + E00083B9: 25 FF 00 00 00 and eax,0FFh + E00083BE: 83 E0 01 and eax,1 + E00083C1: 85 C0 test eax,eax + E00083C3: 74 28 je E00083ED + E00083C5: 66 C7 45 F0 60 00 mov word ptr [ebp-10h],60h + E00083CB: 33 C0 xor eax,eax + E00083CD: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E00083D1: EC in al,dx + E00083D2: 88 45 F8 mov byte ptr [ebp-8],al + E00083D5: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00083D8: 81 E1 FF 00 00 00 and ecx,0FFh + E00083DE: 81 E1 C0 00 00 00 and ecx,0C0h + E00083E4: 85 C9 test ecx,ecx + E00083E6: 75 05 jne E00083ED + E00083E8: 8A 45 F8 mov al,byte ptr [ebp-8] + E00083EB: EB 04 jmp E00083F1 + E00083ED: EB 89 jmp E0008378 + E00083EF: 0C FF or al,0FFh + E00083F1: 5F pop edi + E00083F2: 5E pop esi + E00083F3: 5B pop ebx + E00083F4: 8B E5 mov esp,ebp + E00083F6: 5D pop ebp + E00083F7: C3 ret +?Packet@CPs2Mouse@@QAEXXZ (public: void __thiscall CPs2Mouse::Packet(void)): + E00083F8: 55 push ebp + E00083F9: 8B EC mov ebp,esp + E00083FB: 83 EC 30 sub esp,30h + E00083FE: 89 4D E8 mov dword ptr [ebp-18h],ecx + E0008401: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E0008404: E8 62 FF FF FF call E000836B + E0008409: 88 45 F8 mov byte ptr [ebp-8],al + E000840C: 8B 45 F8 mov eax,dword ptr [ebp-8] + E000840F: 25 FF 00 00 00 and eax,0FFh + E0008414: 3D FF 00 00 00 cmp eax,0FFh + E0008419: 75 05 jne E0008420 + E000841B: E9 E5 01 00 00 jmp E0008605 + E0008420: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E0008423: E8 43 FF FF FF call E000836B + E0008428: 88 45 F9 mov byte ptr [ebp-7],al + E000842B: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E000842E: E8 38 FF FF FF call E000836B + E0008433: 88 45 FA mov byte ptr [ebp-6],al + E0008436: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E0008439: 33 D2 xor edx,edx + E000843B: 8A 51 0C mov dl,byte ptr [ecx+0Ch] + E000843E: 85 D2 test edx,edx + E0008440: 74 0D je E000844F + E0008442: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E0008445: E8 21 FF FF FF call E000836B + E000844A: 88 45 FB mov byte ptr [ebp-5],al + E000844D: EB 04 jmp E0008453 + E000844F: C6 45 FB 00 mov byte ptr [ebp-5],0 + E0008453: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0008456: 25 FF 00 00 00 and eax,0FFh + E000845B: 83 E0 04 and eax,4 + E000845E: D1 F8 sar eax,1 + E0008460: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0008463: 81 E1 FF 00 00 00 and ecx,0FFh + E0008469: 83 E1 02 and ecx,2 + E000846C: D1 F9 sar ecx,1 + E000846E: 0B C1 or eax,ecx + E0008470: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0008473: 81 E2 FF 00 00 00 and edx,0FFh + E0008479: 83 E2 01 and edx,1 + E000847C: C1 E2 02 shl edx,2 + E000847F: 0B C2 or eax,edx + E0008481: 89 45 FC mov dword ptr [ebp-4],eax + E0008484: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0008487: 25 FF 00 00 00 and eax,0FFh + E000848C: 83 E0 10 and eax,10h + E000848F: 85 C0 test eax,eax + E0008491: 74 14 je E00084A7 + E0008493: 8B 4D F9 mov ecx,dword ptr [ebp-7] + E0008496: 81 E1 FF 00 00 00 and ecx,0FFh + E000849C: 81 E9 00 01 00 00 sub ecx,100h + E00084A2: 89 4D E4 mov dword ptr [ebp-1Ch],ecx + E00084A5: EB 0C jmp E00084B3 + E00084A7: 8B 55 F9 mov edx,dword ptr [ebp-7] + E00084AA: 81 E2 FF 00 00 00 and edx,0FFh + E00084B0: 89 55 E4 mov dword ptr [ebp-1Ch],edx + E00084B3: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E00084B6: 89 45 F0 mov dword ptr [ebp-10h],eax + E00084B9: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00084BC: 81 E1 FF 00 00 00 and ecx,0FFh + E00084C2: 83 E1 20 and ecx,20h + E00084C5: 85 C9 test ecx,ecx + E00084C7: 74 16 je E00084DF + E00084C9: 8B 55 FA mov edx,dword ptr [ebp-6] + E00084CC: 81 E2 FF 00 00 00 and edx,0FFh + E00084D2: 81 EA 00 01 00 00 sub edx,100h + E00084D8: F7 DA neg edx + E00084DA: 89 55 E0 mov dword ptr [ebp-20h],edx + E00084DD: EB 0D jmp E00084EC + E00084DF: 8B 45 FA mov eax,dword ptr [ebp-6] + E00084E2: 25 FF 00 00 00 and eax,0FFh + E00084E7: F7 D8 neg eax + E00084E9: 89 45 E0 mov dword ptr [ebp-20h],eax + E00084EC: 8B 4D E0 mov ecx,dword ptr [ebp-20h] + E00084EF: 89 4D EC mov dword ptr [ebp-14h],ecx + E00084F2: 0F BE 55 FB movsx edx,byte ptr [ebp-5] + E00084F6: 89 55 F4 mov dword ptr [ebp-0Ch],edx + E00084F9: 83 7D F0 05 cmp dword ptr [ebp-10h],5 + E00084FD: 7F 06 jg E0008505 + E00084FF: 83 7D F0 FB cmp dword ptr [ebp-10h],0FBh + E0008503: 7D 09 jge E000850E + E0008505: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E0008508: C1 E0 02 shl eax,2 + E000850B: 89 45 F0 mov dword ptr [ebp-10h],eax + E000850E: 83 7D EC 05 cmp dword ptr [ebp-14h],5 + E0008512: 7F 06 jg E000851A + E0008514: 83 7D EC FB cmp dword ptr [ebp-14h],0FBh + E0008518: 7D 09 jge E0008523 + E000851A: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E000851D: C1 E1 02 shl ecx,2 + E0008520: 89 4D EC mov dword ptr [ebp-14h],ecx + E0008523: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E0008526: 8B 42 10 mov eax,dword ptr [edx+10h] + E0008529: 03 45 F0 add eax,dword ptr [ebp-10h] + E000852C: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E000852F: 89 41 10 mov dword ptr [ecx+10h],eax + E0008532: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E0008535: 8B 42 14 mov eax,dword ptr [edx+14h] + E0008538: 03 45 EC add eax,dword ptr [ebp-14h] + E000853B: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E000853E: 89 41 14 mov dword ptr [ecx+14h],eax + E0008541: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E0008544: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0008547: 8B 4A 10 mov ecx,dword ptr [edx+10h] + E000854A: 3B 48 18 cmp ecx,dword ptr [eax+18h] + E000854D: 7D 0B jge E000855A + E000854F: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E0008552: 8B 42 10 mov eax,dword ptr [edx+10h] + E0008555: 89 45 DC mov dword ptr [ebp-24h],eax + E0008558: EB 09 jmp E0008563 + E000855A: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E000855D: 8B 51 18 mov edx,dword ptr [ecx+18h] + E0008560: 89 55 DC mov dword ptr [ebp-24h],edx + E0008563: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0008566: 8B 4D DC mov ecx,dword ptr [ebp-24h] + E0008569: 89 48 10 mov dword ptr [eax+10h],ecx + E000856C: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E000856F: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0008572: 8B 4A 10 mov ecx,dword ptr [edx+10h] + E0008575: 3B 48 1C cmp ecx,dword ptr [eax+1Ch] + E0008578: 7E 0B jle E0008585 + E000857A: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E000857D: 8B 42 10 mov eax,dword ptr [edx+10h] + E0008580: 89 45 D8 mov dword ptr [ebp-28h],eax + E0008583: EB 09 jmp E000858E + E0008585: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E0008588: 8B 51 1C mov edx,dword ptr [ecx+1Ch] + E000858B: 89 55 D8 mov dword ptr [ebp-28h],edx + E000858E: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0008591: 8B 4D D8 mov ecx,dword ptr [ebp-28h] + E0008594: 89 48 10 mov dword ptr [eax+10h],ecx + E0008597: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E000859A: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E000859D: 8B 4A 14 mov ecx,dword ptr [edx+14h] + E00085A0: 3B 48 20 cmp ecx,dword ptr [eax+20h] + E00085A3: 7D 0B jge E00085B0 + E00085A5: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E00085A8: 8B 42 14 mov eax,dword ptr [edx+14h] + E00085AB: 89 45 D4 mov dword ptr [ebp-2Ch],eax + E00085AE: EB 09 jmp E00085B9 + E00085B0: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E00085B3: 8B 51 20 mov edx,dword ptr [ecx+20h] + E00085B6: 89 55 D4 mov dword ptr [ebp-2Ch],edx + E00085B9: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E00085BC: 8B 4D D4 mov ecx,dword ptr [ebp-2Ch] + E00085BF: 89 48 14 mov dword ptr [eax+14h],ecx + E00085C2: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E00085C5: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E00085C8: 8B 4A 14 mov ecx,dword ptr [edx+14h] + E00085CB: 3B 48 24 cmp ecx,dword ptr [eax+24h] + E00085CE: 7E 0B jle E00085DB + E00085D0: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E00085D3: 8B 42 14 mov eax,dword ptr [edx+14h] + E00085D6: 89 45 D0 mov dword ptr [ebp-30h],eax + E00085D9: EB 09 jmp E00085E4 + E00085DB: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E00085DE: 8B 51 24 mov edx,dword ptr [ecx+24h] + E00085E1: 89 55 D0 mov dword ptr [ebp-30h],edx + E00085E4: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E00085E7: 8B 4D D0 mov ecx,dword ptr [ebp-30h] + E00085EA: 89 48 14 mov dword ptr [eax+14h],ecx + E00085ED: 8B 55 E8 mov edx,dword ptr [ebp-18h] + E00085F0: 8B 45 FC mov eax,dword ptr [ebp-4] + E00085F3: 89 42 2C mov dword ptr [edx+2Ch],eax + E00085F6: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E00085F9: 8B 51 28 mov edx,dword ptr [ecx+28h] + E00085FC: 03 55 F4 add edx,dword ptr [ebp-0Ch] + E00085FF: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0008602: 89 50 28 mov dword ptr [eax+28h],edx + E0008605: 8B E5 mov esp,ebp + E0008607: 5D pop ebp + E0008608: C3 ret +?QueryInterface@CPs2Mouse@@UAAKABU_GUID@@PAPAX@Z (public: virtual unsigned long __cdecl CPs2Mouse::QueryInterface(struct _GUID const &,void * *)): + E0008609: 55 push ebp + E000860A: 8B EC mov ebp,esp + E000860C: 83 EC 08 sub esp,8 + E000860F: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008612: 8B 08 mov ecx,dword ptr [eax] + E0008614: 3B 0D D8 A0 00 E0 cmp ecx,dword ptr ds:[E000A0D8h] + E000861A: 75 2A jne E0008646 + E000861C: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E000861F: 8B 42 04 mov eax,dword ptr [edx+4] + E0008622: 3B 05 DC A0 00 E0 cmp eax,dword ptr ds:[E000A0DCh] + E0008628: 75 1C jne E0008646 + E000862A: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E000862D: 8B 51 08 mov edx,dword ptr [ecx+8] + E0008630: 3B 15 E0 A0 00 E0 cmp edx,dword ptr ds:[E000A0E0h] + E0008636: 75 0E jne E0008646 + E0008638: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000863B: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E000863E: 3B 0D E4 A0 00 E0 cmp ecx,dword ptr ds:[E000A0E4h] + E0008644: 74 37 je E000867D + E0008646: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0008649: 8B 02 mov eax,dword ptr [edx] + E000864B: 3B 05 08 A1 00 E0 cmp eax,dword ptr ds:[E000A108h] + E0008651: 75 5D jne E00086B0 + E0008653: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0008656: 8B 51 04 mov edx,dword ptr [ecx+4] + E0008659: 3B 15 0C A1 00 E0 cmp edx,dword ptr ds:[E000A10Ch] + E000865F: 75 4F jne E00086B0 + E0008661: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008664: 8B 48 08 mov ecx,dword ptr [eax+8] + E0008667: 3B 0D 10 A1 00 E0 cmp ecx,dword ptr ds:[E000A110h] + E000866D: 75 41 jne E00086B0 + E000866F: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0008672: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0008675: 3B 05 14 A1 00 E0 cmp eax,dword ptr ds:[E000A114h] + E000867B: 75 33 jne E00086B0 + E000867D: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008680: 8B 11 mov edx,dword ptr [ecx] + E0008682: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008685: 50 push eax + E0008686: FF 52 04 call dword ptr [edx+4] + E0008689: 83 C4 04 add esp,4 + E000868C: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E0008690: 74 0B je E000869D + E0008692: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008695: 83 C1 04 add ecx,4 + E0008698: 89 4D FC mov dword ptr [ebp-4],ecx + E000869B: EB 07 jmp E00086A4 + E000869D: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E00086A4: 8B 55 10 mov edx,dword ptr [ebp+10h] + E00086A7: 8B 45 FC mov eax,dword ptr [ebp-4] + E00086AA: 89 02 mov dword ptr [edx],eax + E00086AC: 33 C0 xor eax,eax + E00086AE: EB 6F jmp E000871F + E00086B0: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00086B3: 8B 11 mov edx,dword ptr [ecx] + E00086B5: 3B 15 18 A1 00 E0 cmp edx,dword ptr ds:[E000A118h] + E00086BB: 75 5D jne E000871A + E00086BD: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00086C0: 8B 48 04 mov ecx,dword ptr [eax+4] + E00086C3: 3B 0D 1C A1 00 E0 cmp ecx,dword ptr ds:[E000A11Ch] + E00086C9: 75 4F jne E000871A + E00086CB: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E00086CE: 8B 42 08 mov eax,dword ptr [edx+8] + E00086D1: 3B 05 20 A1 00 E0 cmp eax,dword ptr ds:[E000A120h] + E00086D7: 75 41 jne E000871A + E00086D9: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00086DC: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E00086DF: 3B 15 24 A1 00 E0 cmp edx,dword ptr ds:[E000A124h] + E00086E5: 75 33 jne E000871A + E00086E7: 8B 45 08 mov eax,dword ptr [ebp+8] + E00086EA: 8B 08 mov ecx,dword ptr [eax] + E00086EC: 8B 55 08 mov edx,dword ptr [ebp+8] + E00086EF: 52 push edx + E00086F0: FF 51 04 call dword ptr [ecx+4] + E00086F3: 83 C4 04 add esp,4 + E00086F6: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E00086FA: 74 0B je E0008707 + E00086FC: 8B 45 08 mov eax,dword ptr [ebp+8] + E00086FF: 83 C0 08 add eax,8 + E0008702: 89 45 F8 mov dword ptr [ebp-8],eax + E0008705: EB 07 jmp E000870E + E0008707: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E000870E: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E0008711: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0008714: 89 11 mov dword ptr [ecx],edx + E0008716: 33 C0 xor eax,eax + E0008718: EB 05 jmp E000871F + E000871A: B8 00 00 00 80 mov eax,80000000h + E000871F: 8B E5 mov esp,ebp + E0008721: 5D pop ebp + E0008722: C3 ret +?GetInfo@CPs2Mouse@@UAAKPAUdevice_t@@@Z (public: virtual unsigned long __cdecl CPs2Mouse::GetInfo(struct device_t *)): + E0008723: 55 push ebp + E0008724: 8B EC mov ebp,esp + E0008726: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008729: 83 38 0C cmp dword ptr [eax],0Ch + E000872C: 73 07 jae E0008735 + E000872E: B8 00 00 00 80 mov eax,80000000h + E0008733: EB 1D jmp E0008752 + E0008735: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0008738: 8B 51 08 mov edx,dword ptr [ecx+8] + E000873B: 52 push edx + E000873C: 68 4C C5 00 E0 push 0E000C54Ch + E0008741: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008744: 8B 48 04 mov ecx,dword ptr [eax+4] + E0008747: 51 push ecx + E0008748: E8 47 18 00 00 call E0009F94 + E000874D: 83 C4 0C add esp,0Ch + E0008750: 33 C0 xor eax,eax + E0008752: 5D pop ebp + E0008753: C3 ret +?DeviceOpen@CPs2Mouse@@UAAKXZ (public: virtual unsigned long __cdecl CPs2Mouse::DeviceOpen(void)): + E0008754: 55 push ebp + E0008755: 8B EC mov ebp,esp + E0008757: 33 C0 xor eax,eax + E0008759: 5D pop ebp + E000875A: C3 ret +?Read@CPs2Mouse@@UAAIPAXI@Z (public: virtual unsigned int __cdecl CPs2Mouse::Read(void *,unsigned int)): + E000875B: 55 push ebp + E000875C: 8B EC mov ebp,esp + E000875E: 51 push ecx + E000875F: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008762: 89 45 FC mov dword ptr [ebp-4],eax + E0008765: 83 7D 10 10 cmp dword ptr [ebp+10h],10h + E0008769: 73 04 jae E000876F + E000876B: 33 C0 xor eax,eax + E000876D: EB 28 jmp E0008797 + E000876F: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0008772: 8B 55 08 mov edx,dword ptr [ebp+8] + E0008775: 8B 42 08 mov eax,dword ptr [edx+8] + E0008778: 89 01 mov dword ptr [ecx],eax + E000877A: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000877D: 8B 55 08 mov edx,dword ptr [ebp+8] + E0008780: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0008783: 89 41 04 mov dword ptr [ecx+4],eax + E0008786: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0008789: 8B 55 08 mov edx,dword ptr [ebp+8] + E000878C: 8B 42 24 mov eax,dword ptr [edx+24h] + E000878F: 89 41 08 mov dword ptr [ecx+8],eax + E0008792: B8 10 00 00 00 mov eax,10h + E0008797: 8B E5 mov esp,ebp + E0008799: 5D pop ebp + E000879A: C3 ret +?Write@CPs2Mouse@@UAAIPBXI@Z (public: virtual unsigned int __cdecl CPs2Mouse::Write(void const *,unsigned int)): + E000879B: 55 push ebp + E000879C: 8B EC mov ebp,esp + E000879E: 33 C0 xor eax,eax + E00087A0: 5D pop ebp + E00087A1: C3 ret +?SetIoMode@CPs2Mouse@@UAAKI@Z (public: virtual unsigned long __cdecl CPs2Mouse::SetIoMode(unsigned int)): + E00087A2: 55 push ebp + E00087A3: 8B EC mov ebp,esp + E00087A5: 33 C0 xor eax,eax + E00087A7: 5D pop ebp + E00087A8: C3 ret +?IsReady@CPs2Mouse@@UAAKXZ (public: virtual unsigned long __cdecl CPs2Mouse::IsReady(void)): + E00087A9: 55 push ebp + E00087AA: 8B EC mov ebp,esp + E00087AC: 33 C0 xor eax,eax + E00087AE: 5D pop ebp + E00087AF: C3 ret +?Stat@CPs2Mouse@@UAAKPAU_folderitem_t@@@Z (public: virtual unsigned long __cdecl CPs2Mouse::Stat(struct _folderitem_t *)): + E00087B0: 55 push ebp + E00087B1: 8B EC mov ebp,esp + E00087B3: B8 00 00 00 80 mov eax,80000000h + E00087B8: 5D pop ebp + E00087B9: C3 ret +?Seek@CPs2Mouse@@UAAKJH@Z (public: virtual unsigned long __cdecl CPs2Mouse::Seek(long,int)): + E00087BA: 55 push ebp + E00087BB: 8B EC mov ebp,esp + E00087BD: B8 00 00 00 80 mov eax,80000000h + E00087C2: 5D pop ebp + E00087C3: C3 ret + E00087C4: CC int 3 + E00087C5: CC int 3 + E00087C6: CC int 3 + E00087C7: CC int 3 + E00087C8: CC int 3 + E00087C9: CC int 3 + E00087CA: CC int 3 + E00087CB: CC int 3 + E00087CC: CC int 3 + E00087CD: CC int 3 + E00087CE: CC int 3 + E00087CF: CC int 3 +?AddRef@CPs2Mouse@@UAAKXZ (public: virtual unsigned long __cdecl CPs2Mouse::AddRef(void)): + E00087D0: 55 push ebp + E00087D1: 8B EC mov ebp,esp + E00087D3: 8B 45 08 mov eax,dword ptr [ebp+8] + E00087D6: 8B 48 30 mov ecx,dword ptr [eax+30h] + E00087D9: 83 C1 01 add ecx,1 + E00087DC: 8B 55 08 mov edx,dword ptr [ebp+8] + E00087DF: 89 4A 30 mov dword ptr [edx+30h],ecx + E00087E2: 8B 45 08 mov eax,dword ptr [ebp+8] + E00087E5: 8B 40 30 mov eax,dword ptr [eax+30h] + E00087E8: 5D pop ebp + E00087E9: C3 ret + E00087EA: CC int 3 + E00087EB: CC int 3 + E00087EC: CC int 3 + E00087ED: CC int 3 + E00087EE: CC int 3 + E00087EF: CC int 3 +?Release@CPs2Mouse@@UAAKXZ (public: virtual unsigned long __cdecl CPs2Mouse::Release(void)): + E00087F0: 55 push ebp + E00087F1: 8B EC mov ebp,esp + E00087F3: 51 push ecx + E00087F4: 8B 45 08 mov eax,dword ptr [ebp+8] + E00087F7: 83 78 30 00 cmp dword ptr [eax+30h],0 + E00087FB: 75 16 jne E0008813 + E00087FD: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008800: 89 4D FC mov dword ptr [ebp-4],ecx + E0008803: 8B 55 FC mov edx,dword ptr [ebp-4] + E0008806: 52 push edx + E0008807: E8 5E 17 00 00 call E0009F6A + E000880C: 83 C4 04 add esp,4 + E000880F: 33 C0 xor eax,eax + E0008811: EB 15 jmp E0008828 + E0008813: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008816: 8B 40 30 mov eax,dword ptr [eax+30h] + E0008819: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000881C: 8B 51 30 mov edx,dword ptr [ecx+30h] + E000881F: 83 EA 01 sub edx,1 + E0008822: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008825: 89 51 30 mov dword ptr [ecx+30h],edx + E0008828: 8B E5 mov esp,ebp + E000882A: 5D pop ebp + E000882B: C3 ret + E000882C: CC int 3 + E000882D: CC int 3 + E000882E: CC int 3 + E000882F: CC int 3 +?QueryInterface@CPs2Mouse@@W3AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CPs2Mouse::QueryInterface`adjustor{4}' (struct _GUID const &,void * *)): + E0008830: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0008835: E9 CF FD FF FF jmp E0008609 + E000883A: CC int 3 + E000883B: CC int 3 + E000883C: CC int 3 + E000883D: CC int 3 + E000883E: CC int 3 + E000883F: CC int 3 +?AddRef@CPs2Mouse@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CPs2Mouse::AddRef`adjustor{4}' (void)): + E0008840: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0008845: E9 86 FF FF FF jmp E00087D0 + E000884A: CC int 3 + E000884B: CC int 3 + E000884C: CC int 3 + E000884D: CC int 3 + E000884E: CC int 3 + E000884F: CC int 3 +?Release@CPs2Mouse@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CPs2Mouse::Release`adjustor{4}' (void)): + E0008850: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0008855: E9 96 FF FF FF jmp E00087F0 + E000885A: CC int 3 + E000885B: CC int 3 + E000885C: CC int 3 + E000885D: CC int 3 + E000885E: CC int 3 + E000885F: CC int 3 +?QueryInterface@CPs2Mouse@@W7AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CPs2Mouse::QueryInterface`adjustor{8}' (struct _GUID const &,void * *)): + E0008860: 83 6C 24 04 08 sub dword ptr [esp+4],8 + E0008865: E9 9F FD FF FF jmp E0008609 + E000886A: CC int 3 + E000886B: CC int 3 + E000886C: CC int 3 + E000886D: CC int 3 + E000886E: CC int 3 + E000886F: CC int 3 +?AddRef@CPs2Mouse@@W7AAKXZ ([thunk]:public: virtual unsigned long __cdecl CPs2Mouse::AddRef`adjustor{8}' (void)): + E0008870: 83 6C 24 04 08 sub dword ptr [esp+4],8 + E0008875: E9 56 FF FF FF jmp E00087D0 + E000887A: CC int 3 + E000887B: CC int 3 + E000887C: CC int 3 + E000887D: CC int 3 + E000887E: CC int 3 + E000887F: CC int 3 +?Release@CPs2Mouse@@W7AAKXZ ([thunk]:public: virtual unsigned long __cdecl CPs2Mouse::Release`adjustor{8}' (void)): + E0008880: 83 6C 24 04 08 sub dword ptr [esp+4],8 + E0008885: E9 66 FF FF FF jmp E00087F0 + E000888A: CC int 3 + E000888B: CC int 3 + E000888C: CC int 3 + E000888D: CC int 3 + E000888E: CC int 3 + E000888F: CC int 3 +_RamDisk_Create: + E0008890: 55 push ebp + E0008891: 8B EC mov ebp,esp + E0008893: 83 EC 0C sub esp,0Ch + E0008896: 6A 14 push 14h + E0008898: E8 D9 16 00 00 call E0009F76 + E000889D: 83 C4 04 add esp,4 + E00088A0: 89 45 FC mov dword ptr [ebp-4],eax + E00088A3: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E00088A7: 74 0D je E00088B6 + E00088A9: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00088AC: E8 2B 00 00 00 call E00088DC + E00088B1: 89 45 F8 mov dword ptr [ebp-8],eax + E00088B4: EB 07 jmp E00088BD + E00088B6: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E00088BD: 83 7D F8 00 cmp dword ptr [ebp-8],0 + E00088C1: 74 0B je E00088CE + E00088C3: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00088C6: 83 C0 04 add eax,4 + E00088C9: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E00088CC: EB 07 jmp E00088D5 + E00088CE: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E00088D5: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E00088D8: 8B E5 mov esp,ebp + E00088DA: 5D pop ebp + E00088DB: C3 ret +??0CRamFolder@@QAE@XZ (public: __thiscall CRamFolder::CRamFolder(void)): + E00088DC: 55 push ebp + E00088DD: 8B EC mov ebp,esp + E00088DF: 51 push ecx + E00088E0: 89 4D FC mov dword ptr [ebp-4],ecx + E00088E3: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00088E6: E8 21 BE FF FF call E000470C + E00088EB: 8B 45 FC mov eax,dword ptr [ebp-4] + E00088EE: C7 00 D0 A6 00 E0 mov dword ptr [eax],0E000A6D0h + E00088F4: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00088F7: C7 41 04 B0 A6 00 mov dword ptr [ecx+4],0E000A6B0h + E0 + E00088FE: 8B 45 FC mov eax,dword ptr [ebp-4] + E0008901: 8B E5 mov esp,ebp + E0008903: 5D pop ebp + E0008904: C3 ret +??1CRamFolder@@UAE@XZ (public: virtual __thiscall CRamFolder::~CRamFolder(void)): + E0008905: 55 push ebp + E0008906: 8B EC mov ebp,esp + E0008908: 51 push ecx + E0008909: 89 4D FC mov dword ptr [ebp-4],ecx + E000890C: 8B 45 FC mov eax,dword ptr [ebp-4] + E000890F: C7 00 D0 A6 00 E0 mov dword ptr [eax],0E000A6D0h + E0008915: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0008918: C7 41 04 B0 A6 00 mov dword ptr [ecx+4],0E000A6B0h + E0 + E000891F: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0008922: E8 3E BE FF FF call E0004765 + E0008927: 8B E5 mov esp,ebp + E0008929: 5D pop ebp + E000892A: C3 ret +?ScanDir@CRamFolder@@MAEXXZ (protected: virtual void __thiscall CRamFolder::ScanDir(void)): + E000892B: 55 push ebp + E000892C: 8B EC mov ebp,esp + E000892E: 83 EC 34 sub esp,34h + E0008931: 89 4D CC mov dword ptr [ebp-34h],ecx + E0008934: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0D0000000h + D0 + E000893B: 8B 45 FC mov eax,dword ptr [ebp-4] + E000893E: 83 C0 08 add eax,8 + E0008941: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0008944: C7 45 D0 00 00 00 mov dword ptr [ebp-30h],0 + 00 + E000894B: EB 09 jmp E0008956 + E000894D: 8B 4D D0 mov ecx,dword ptr [ebp-30h] + E0008950: 83 C1 01 add ecx,1 + E0008953: 89 4D D0 mov dword ptr [ebp-30h],ecx + E0008956: 8B 55 FC mov edx,dword ptr [ebp-4] + E0008959: 8B 45 D0 mov eax,dword ptr [ebp-30h] + E000895C: 3B 42 04 cmp eax,dword ptr [edx+4] + E000895F: 0F 83 93 00 00 00 jae E00089F8 + E0008965: 6A 28 push 28h + E0008967: E8 0A 16 00 00 call E0009F76 + E000896C: 83 C4 04 add esp,4 + E000896F: 89 45 F8 mov dword ptr [ebp-8],eax + E0008972: 33 C9 xor ecx,ecx + E0008974: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0008977: 89 0A mov dword ptr [edx],ecx + E0008979: 8B 45 F8 mov eax,dword ptr [ebp-8] + E000897C: C7 00 1C 00 00 00 mov dword ptr [eax],1Ch + E0008982: 6A 10 push 10h + E0008984: 8B 4D D0 mov ecx,dword ptr [ebp-30h] + E0008987: 6B C9 18 imul ecx,ecx,18h + E000898A: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E000898D: 8D 44 0A 08 lea eax,dword ptr [edx+ecx+8] + E0008991: 50 push eax + E0008992: 8D 4D D4 lea ecx,dword ptr [ebp-2Ch] + E0008995: 51 push ecx + E0008996: E8 C3 15 00 00 call E0009F5E + E000899B: 83 C4 0C add esp,0Ch + E000899E: 8D 55 D4 lea edx,dword ptr [ebp-2Ch] + E00089A1: 52 push edx + E00089A2: E8 F9 15 00 00 call E0009FA0 + E00089A7: 83 C4 04 add esp,4 + E00089AA: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00089AD: 89 41 0C mov dword ptr [ecx+0Ch],eax + E00089B0: 8B 55 D0 mov edx,dword ptr [ebp-30h] + E00089B3: 6B D2 18 imul edx,edx,18h + E00089B6: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00089B9: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E00089BC: 8B 54 11 04 mov edx,dword ptr [ecx+edx+4] + E00089C0: 89 50 18 mov dword ptr [eax+18h],edx + E00089C3: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00089C6: C7 40 14 01 00 00 mov dword ptr [eax+14h],1 + 00 + E00089CD: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E00089D0: 8B 55 CC mov edx,dword ptr [ebp-34h] + E00089D3: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E00089D6: 89 41 1C mov dword ptr [ecx+1Ch],eax + E00089D9: 8B 4D D0 mov ecx,dword ptr [ebp-30h] + E00089DC: 6B C9 18 imul ecx,ecx,18h + E00089DF: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E00089E2: 03 D1 add edx,ecx + E00089E4: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00089E7: 89 50 20 mov dword ptr [eax+20h],edx + E00089EA: 8B 4D CC mov ecx,dword ptr [ebp-34h] + E00089ED: 8B 55 F8 mov edx,dword ptr [ebp-8] + E00089F0: 89 51 0C mov dword ptr [ecx+0Ch],edx + E00089F3: E9 55 FF FF FF jmp E000894D + E00089F8: 8B E5 mov esp,ebp + E00089FA: 5D pop ebp + E00089FB: C3 ret +?DoOpen@CRamFolder@@MAEPAUIUnknown@@PAUfolderitem_ext_t@@@Z (protected: virtual struct IUnknown * __thiscall CRamFolder::DoOpen(struct folderitem_ext_t *)): + E00089FC: 55 push ebp + E00089FD: 8B EC mov ebp,esp + E00089FF: 83 EC 14 sub esp,14h + E0008A02: 89 4D F0 mov dword ptr [ebp-10h],ecx + E0008A05: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008A08: 50 push eax + E0008A09: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0008A0C: E8 BE C1 FF FF call E0004BCF + E0008A11: 89 45 FC mov dword ptr [ebp-4],eax + E0008A14: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0008A18: 74 05 je E0008A1F + E0008A1A: 8B 45 FC mov eax,dword ptr [ebp-4] + E0008A1D: EB 4F jmp E0008A6E + E0008A1F: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008A22: 83 79 20 00 cmp dword ptr [ecx+20h],0 + E0008A26: 74 44 je E0008A6C + E0008A28: 8B 55 08 mov edx,dword ptr [ebp+8] + E0008A2B: 8B 42 20 mov eax,dword ptr [edx+20h] + E0008A2E: 89 45 F8 mov dword ptr [ebp-8],eax + E0008A31: 6A 18 push 18h + E0008A33: E8 3E 15 00 00 call E0009F76 + E0008A38: 83 C4 04 add esp,4 + E0008A3B: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0008A3E: 83 7D F4 00 cmp dword ptr [ebp-0Ch],0 + E0008A42: 74 1C je E0008A60 + E0008A44: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0008A47: 51 push ecx + E0008A48: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0008A4B: 8B 02 mov eax,dword ptr [edx] + E0008A4D: 2D 00 00 00 30 sub eax,30000000h + E0008A52: 50 push eax + E0008A53: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0008A56: E8 19 00 00 00 call E0008A74 + E0008A5B: 89 45 EC mov dword ptr [ebp-14h],eax + E0008A5E: EB 07 jmp E0008A67 + E0008A60: C7 45 EC 00 00 00 mov dword ptr [ebp-14h],0 + 00 + E0008A67: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0008A6A: EB 02 jmp E0008A6E + E0008A6C: 33 C0 xor eax,eax + E0008A6E: 8B E5 mov esp,ebp + E0008A70: 5D pop ebp + E0008A71: C2 04 00 ret 4 +??0CRamFile@@QAE@PAXPAUramfile_t@@@Z (public: __thiscall CRamFile::CRamFile(void *,struct ramfile_t *)): + E0008A74: 55 push ebp + E0008A75: 8B EC mov ebp,esp + E0008A77: 83 EC 08 sub esp,8 + E0008A7A: 89 4D F8 mov dword ptr [ebp-8],ecx + E0008A7D: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0008A80: C7 00 C8 A0 00 E0 mov dword ptr [eax],0E000A0C8h + E0008A86: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0008A89: 83 C1 04 add ecx,4 + E0008A8C: 89 4D FC mov dword ptr [ebp-4],ecx + E0008A8F: 8B 55 FC mov edx,dword ptr [ebp-4] + E0008A92: C7 02 10 A2 00 E0 mov dword ptr [edx],0E000A210h + E0008A98: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0008A9B: C7 00 10 A7 00 E0 mov dword ptr [eax],0E000A710h + E0008AA1: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0008AA4: C7 41 04 E8 A6 00 mov dword ptr [ecx+4],0E000A6E8h + E0 + E0008AAB: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0008AAE: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008AB1: 89 42 10 mov dword ptr [edx+10h],eax + E0008AB4: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0008AB7: C7 41 14 00 00 00 mov dword ptr [ecx+14h],0 + 00 + E0008ABE: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0008AC1: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008AC4: 89 42 0C mov dword ptr [edx+0Ch],eax + E0008AC7: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0008ACA: 8B E5 mov esp,ebp + E0008ACC: 5D pop ebp + E0008ACD: C2 08 00 ret 8 +?QueryInterface@CRamFile@@UAAKABU_GUID@@PAPAX@Z (public: virtual unsigned long __cdecl CRamFile::QueryInterface(struct _GUID const &,void * *)): + E0008AD0: 55 push ebp + E0008AD1: 8B EC mov ebp,esp + E0008AD3: 51 push ecx + E0008AD4: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008AD7: 8B 08 mov ecx,dword ptr [eax] + E0008AD9: 3B 0D D8 A0 00 E0 cmp ecx,dword ptr ds:[E000A0D8h] + E0008ADF: 75 2A jne E0008B0B + E0008AE1: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0008AE4: 8B 42 04 mov eax,dword ptr [edx+4] + E0008AE7: 3B 05 DC A0 00 E0 cmp eax,dword ptr ds:[E000A0DCh] + E0008AED: 75 1C jne E0008B0B + E0008AEF: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0008AF2: 8B 51 08 mov edx,dword ptr [ecx+8] + E0008AF5: 3B 15 E0 A0 00 E0 cmp edx,dword ptr ds:[E000A0E0h] + E0008AFB: 75 0E jne E0008B0B + E0008AFD: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008B00: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E0008B03: 3B 0D E4 A0 00 E0 cmp ecx,dword ptr ds:[E000A0E4h] + E0008B09: 74 37 je E0008B42 + E0008B0B: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0008B0E: 8B 02 mov eax,dword ptr [edx] + E0008B10: 3B 05 18 A1 00 E0 cmp eax,dword ptr ds:[E000A118h] + E0008B16: 75 5D jne E0008B75 + E0008B18: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0008B1B: 8B 51 04 mov edx,dword ptr [ecx+4] + E0008B1E: 3B 15 1C A1 00 E0 cmp edx,dword ptr ds:[E000A11Ch] + E0008B24: 75 4F jne E0008B75 + E0008B26: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008B29: 8B 48 08 mov ecx,dword ptr [eax+8] + E0008B2C: 3B 0D 20 A1 00 E0 cmp ecx,dword ptr ds:[E000A120h] + E0008B32: 75 41 jne E0008B75 + E0008B34: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0008B37: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0008B3A: 3B 05 24 A1 00 E0 cmp eax,dword ptr ds:[E000A124h] + E0008B40: 75 33 jne E0008B75 + E0008B42: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008B45: 8B 11 mov edx,dword ptr [ecx] + E0008B47: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008B4A: 50 push eax + E0008B4B: FF 52 04 call dword ptr [edx+4] + E0008B4E: 83 C4 04 add esp,4 + E0008B51: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E0008B55: 74 0B je E0008B62 + E0008B57: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008B5A: 83 C1 04 add ecx,4 + E0008B5D: 89 4D FC mov dword ptr [ebp-4],ecx + E0008B60: EB 07 jmp E0008B69 + E0008B62: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0008B69: 8B 55 10 mov edx,dword ptr [ebp+10h] + E0008B6C: 8B 45 FC mov eax,dword ptr [ebp-4] + E0008B6F: 89 02 mov dword ptr [edx],eax + E0008B71: 33 C0 xor eax,eax + E0008B73: EB 05 jmp E0008B7A + E0008B75: B8 00 00 00 80 mov eax,80000000h + E0008B7A: 8B E5 mov esp,ebp + E0008B7C: 5D pop ebp + E0008B7D: C3 ret +?Read@CRamFile@@UAAIPAXI@Z (public: virtual unsigned int __cdecl CRamFile::Read(void *,unsigned int)): + E0008B7E: 55 push ebp + E0008B7F: 8B EC mov ebp,esp + E0008B81: 56 push esi + E0008B82: 57 push edi + E0008B83: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008B86: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E0008B89: 03 48 10 add ecx,dword ptr [eax+10h] + E0008B8C: 8B 55 08 mov edx,dword ptr [ebp+8] + E0008B8F: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0008B92: 3B 48 04 cmp ecx,dword ptr [eax+4] + E0008B95: 76 12 jbe E0008BA9 + E0008B97: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008B9A: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0008B9D: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008BA0: 8B 4A 04 mov ecx,dword ptr [edx+4] + E0008BA3: 2B 48 10 sub ecx,dword ptr [eax+10h] + E0008BA6: 89 4D 10 mov dword ptr [ebp+10h],ecx + E0008BA9: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E0008BAC: 8B 55 08 mov edx,dword ptr [ebp+8] + E0008BAF: 8B 72 08 mov esi,dword ptr [edx+8] + E0008BB2: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008BB5: 03 70 10 add esi,dword ptr [eax+10h] + E0008BB8: 8B 7D 0C mov edi,dword ptr [ebp+0Ch] + E0008BBB: 8B D1 mov edx,ecx + E0008BBD: C1 E9 02 shr ecx,2 + E0008BC0: F3 A5 rep movs dword ptr es:[edi],dword ptr [esi] + E0008BC2: 8B CA mov ecx,edx + E0008BC4: 83 E1 03 and ecx,3 + E0008BC7: F3 A4 rep movs byte ptr es:[edi],byte ptr [esi] + E0008BC9: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008BCC: 8B 48 10 mov ecx,dword ptr [eax+10h] + E0008BCF: 03 4D 10 add ecx,dword ptr [ebp+10h] + E0008BD2: 8B 55 08 mov edx,dword ptr [ebp+8] + E0008BD5: 89 4A 10 mov dword ptr [edx+10h],ecx + E0008BD8: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0008BDB: 5F pop edi + E0008BDC: 5E pop esi + E0008BDD: 5D pop ebp + E0008BDE: C3 ret +?Write@CRamFile@@UAAIPBXI@Z (public: virtual unsigned int __cdecl CRamFile::Write(void const *,unsigned int)): + E0008BDF: 55 push ebp + E0008BE0: 8B EC mov ebp,esp + E0008BE2: 33 C0 xor eax,eax + E0008BE4: 5D pop ebp + E0008BE5: C3 ret +?SetIoMode@CRamFile@@UAAKI@Z (public: virtual unsigned long __cdecl CRamFile::SetIoMode(unsigned int)): + E0008BE6: 55 push ebp + E0008BE7: 8B EC mov ebp,esp + E0008BE9: 33 C0 xor eax,eax + E0008BEB: 5D pop ebp + E0008BEC: C3 ret +?IsReady@CRamFile@@UAAKXZ (public: virtual unsigned long __cdecl CRamFile::IsReady(void)): + E0008BED: 55 push ebp + E0008BEE: 8B EC mov ebp,esp + E0008BF0: 33 C0 xor eax,eax + E0008BF2: 5D pop ebp + E0008BF3: C3 ret +?Stat@CRamFile@@UAAKPAU_folderitem_t@@@Z (public: virtual unsigned long __cdecl CRamFile::Stat(struct _folderitem_t *)): + E0008BF4: 55 push ebp + E0008BF5: 8B EC mov ebp,esp + E0008BF7: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008BFA: 83 78 10 00 cmp dword ptr [eax+10h],0 + E0008BFE: 74 29 je E0008C29 + E0008C00: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0008C03: 83 79 0C 00 cmp dword ptr [ecx+0Ch],0 + E0008C07: 74 20 je E0008C29 + E0008C09: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0008C0C: 8B 42 10 mov eax,dword ptr [edx+10h] + E0008C0F: 50 push eax + E0008C10: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008C13: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0008C16: 83 C2 08 add edx,8 + E0008C19: 52 push edx + E0008C1A: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008C1D: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E0008C20: 51 push ecx + E0008C21: E8 38 13 00 00 call E0009F5E + E0008C26: 83 C4 0C add esp,0Ch + E0008C29: 8B 55 08 mov edx,dword ptr [ebp+8] + E0008C2C: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0008C2F: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0008C32: 8B 50 04 mov edx,dword ptr [eax+4] + E0008C35: 89 51 18 mov dword ptr [ecx+18h],edx + E0008C38: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008C3B: C7 40 14 01 00 00 mov dword ptr [eax+14h],1 + 00 + E0008C42: 33 C0 xor eax,eax + E0008C44: 5D pop ebp + E0008C45: C3 ret +?Seek@CRamFile@@UAAKJH@Z (public: virtual unsigned long __cdecl CRamFile::Seek(long,int)): + E0008C46: 55 push ebp + E0008C47: 8B EC mov ebp,esp + E0008C49: 51 push ecx + E0008C4A: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0008C4D: 89 45 FC mov dword ptr [ebp-4],eax + E0008C50: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0008C54: 74 11 je E0008C67 + E0008C56: 83 7D FC 01 cmp dword ptr [ebp-4],1 + E0008C5A: 74 33 je E0008C8F + E0008C5C: 83 7D FC 02 cmp dword ptr [ebp-4],2 + E0008C60: 74 68 je E0008CCA + E0008C62: E9 94 00 00 00 jmp E0008CFB + E0008C67: 83 7D 0C 00 cmp dword ptr [ebp+0Ch],0 + E0008C6B: 7C 19 jl E0008C86 + E0008C6D: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008C70: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0008C73: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008C76: 3B 42 04 cmp eax,dword ptr [edx+4] + E0008C79: 7D 0B jge E0008C86 + E0008C7B: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008C7E: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0008C81: 89 51 10 mov dword ptr [ecx+10h],edx + E0008C84: EB 07 jmp E0008C8D + E0008C86: B8 00 00 00 80 mov eax,80000000h + E0008C8B: EB 70 jmp E0008CFD + E0008C8D: EB 6C jmp E0008CFB + E0008C8F: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008C92: 8B 48 10 mov ecx,dword ptr [eax+10h] + E0008C95: 03 4D 0C add ecx,dword ptr [ebp+0Ch] + E0008C98: 85 C9 test ecx,ecx + E0008C9A: 72 25 jb E0008CC1 + E0008C9C: 8B 55 08 mov edx,dword ptr [ebp+8] + E0008C9F: 8B 42 10 mov eax,dword ptr [edx+10h] + E0008CA2: 03 45 0C add eax,dword ptr [ebp+0Ch] + E0008CA5: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008CA8: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0008CAB: 3B 42 04 cmp eax,dword ptr [edx+4] + E0008CAE: 73 11 jae E0008CC1 + E0008CB0: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008CB3: 8B 48 10 mov ecx,dword ptr [eax+10h] + E0008CB6: 03 4D 0C add ecx,dword ptr [ebp+0Ch] + E0008CB9: 8B 55 08 mov edx,dword ptr [ebp+8] + E0008CBC: 89 4A 10 mov dword ptr [edx+10h],ecx + E0008CBF: EB 07 jmp E0008CC8 + E0008CC1: B8 00 00 00 80 mov eax,80000000h + E0008CC6: EB 35 jmp E0008CFD + E0008CC8: EB 31 jmp E0008CFB + E0008CCA: 83 7D 0C 00 cmp dword ptr [ebp+0Ch],0 + E0008CCE: 7F 24 jg E0008CF4 + E0008CD0: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0008CD3: F7 D8 neg eax + E0008CD5: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008CD8: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0008CDB: 3B 42 04 cmp eax,dword ptr [edx+4] + E0008CDE: 7D 14 jge E0008CF4 + E0008CE0: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008CE3: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E0008CE6: 8B 51 04 mov edx,dword ptr [ecx+4] + E0008CE9: 03 55 0C add edx,dword ptr [ebp+0Ch] + E0008CEC: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008CEF: 89 50 10 mov dword ptr [eax+10h],edx + E0008CF2: EB 07 jmp E0008CFB + E0008CF4: B8 00 00 00 80 mov eax,80000000h + E0008CF9: EB 02 jmp E0008CFD + E0008CFB: 33 C0 xor eax,eax + E0008CFD: 8B E5 mov esp,ebp + E0008CFF: 5D pop ebp + E0008D00: C3 ret + E0008D01: CC int 3 + E0008D02: CC int 3 + E0008D03: CC int 3 + E0008D04: CC int 3 + E0008D05: CC int 3 + E0008D06: CC int 3 + E0008D07: CC int 3 + E0008D08: CC int 3 + E0008D09: CC int 3 + E0008D0A: CC int 3 + E0008D0B: CC int 3 + E0008D0C: CC int 3 + E0008D0D: CC int 3 + E0008D0E: CC int 3 + E0008D0F: CC int 3 +??_GCRamFolder@@UAEPAXI@Z (public: virtual void * __thiscall CRamFolder::`scalar deleting destructor'(unsigned int)): + E0008D10: 55 push ebp + E0008D11: 8B EC mov ebp,esp + E0008D13: 51 push ecx + E0008D14: 89 4D FC mov dword ptr [ebp-4],ecx + E0008D17: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0008D1A: E8 E6 FB FF FF call E0008905 + E0008D1F: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008D22: 83 E0 01 and eax,1 + E0008D25: 85 C0 test eax,eax + E0008D27: 74 0C je E0008D35 + E0008D29: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0008D2C: 51 push ecx + E0008D2D: E8 38 12 00 00 call E0009F6A + E0008D32: 83 C4 04 add esp,4 + E0008D35: 8B 45 FC mov eax,dword ptr [ebp-4] + E0008D38: 8B E5 mov esp,ebp + E0008D3A: 5D pop ebp + E0008D3B: C2 04 00 ret 4 + E0008D3E: CC int 3 + E0008D3F: CC int 3 +?AddRef@CRamFile@@UAAKXZ (public: virtual unsigned long __cdecl CRamFile::AddRef(void)): + E0008D40: 55 push ebp + E0008D41: 8B EC mov ebp,esp + E0008D43: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008D46: 8B 48 08 mov ecx,dword ptr [eax+8] + E0008D49: 83 C1 01 add ecx,1 + E0008D4C: 8B 55 08 mov edx,dword ptr [ebp+8] + E0008D4F: 89 4A 08 mov dword ptr [edx+8],ecx + E0008D52: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008D55: 8B 40 08 mov eax,dword ptr [eax+8] + E0008D58: 5D pop ebp + E0008D59: C3 ret + E0008D5A: CC int 3 + E0008D5B: CC int 3 + E0008D5C: CC int 3 + E0008D5D: CC int 3 + E0008D5E: CC int 3 + E0008D5F: CC int 3 +?Release@CRamFile@@UAAKXZ (public: virtual unsigned long __cdecl CRamFile::Release(void)): + E0008D60: 55 push ebp + E0008D61: 8B EC mov ebp,esp + E0008D63: 51 push ecx + E0008D64: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008D67: 83 78 08 00 cmp dword ptr [eax+8],0 + E0008D6B: 75 16 jne E0008D83 + E0008D6D: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008D70: 89 4D FC mov dword ptr [ebp-4],ecx + E0008D73: 8B 55 FC mov edx,dword ptr [ebp-4] + E0008D76: 52 push edx + E0008D77: E8 EE 11 00 00 call E0009F6A + E0008D7C: 83 C4 04 add esp,4 + E0008D7F: 33 C0 xor eax,eax + E0008D81: EB 15 jmp E0008D98 + E0008D83: 8B 45 08 mov eax,dword ptr [ebp+8] + E0008D86: 8B 40 08 mov eax,dword ptr [eax+8] + E0008D89: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008D8C: 8B 51 08 mov edx,dword ptr [ecx+8] + E0008D8F: 83 EA 01 sub edx,1 + E0008D92: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008D95: 89 51 08 mov dword ptr [ecx+8],edx + E0008D98: 8B E5 mov esp,ebp + E0008D9A: 5D pop ebp + E0008D9B: C3 ret + E0008D9C: CC int 3 + E0008D9D: CC int 3 + E0008D9E: CC int 3 + E0008D9F: CC int 3 +?QueryInterface@CRamFile@@W3AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CRamFile::QueryInterface`adjustor{4}' (struct _GUID const &,void * *)): + E0008DA0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0008DA5: E9 26 FD FF FF jmp E0008AD0 + E0008DAA: CC int 3 + E0008DAB: CC int 3 + E0008DAC: CC int 3 + E0008DAD: CC int 3 + E0008DAE: CC int 3 + E0008DAF: CC int 3 +?AddRef@CRamFile@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CRamFile::AddRef`adjustor{4}' (void)): + E0008DB0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0008DB5: E9 86 FF FF FF jmp E0008D40 + E0008DBA: CC int 3 + E0008DBB: CC int 3 + E0008DBC: CC int 3 + E0008DBD: CC int 3 + E0008DBE: CC int 3 + E0008DBF: CC int 3 +?Release@CRamFile@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CRamFile::Release`adjustor{4}' (void)): + E0008DC0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0008DC5: E9 96 FF FF FF jmp E0008D60 + E0008DCA: CC int 3 + E0008DCB: CC int 3 + E0008DCC: CC int 3 + E0008DCD: CC int 3 + E0008DCE: CC int 3 + E0008DCF: CC int 3 +_Serial_Create: + E0008DD0: 55 push ebp + E0008DD1: 8B EC mov ebp,esp + E0008DD3: 83 EC 0C sub esp,0Ch + E0008DD6: 68 2C 20 00 00 push 202Ch + E0008DDB: E8 96 11 00 00 call E0009F76 + E0008DE0: 83 C4 04 add esp,4 + E0008DE3: 89 45 FC mov dword ptr [ebp-4],eax + E0008DE6: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0008DEA: 74 16 je E0008E02 + E0008DEC: 8A 45 0C mov al,byte ptr [ebp+0Ch] + E0008DEF: 50 push eax + E0008DF0: 66 8B 4D 08 mov cx,word ptr [ebp+8] + E0008DF4: 51 push ecx + E0008DF5: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0008DF8: E8 A3 03 00 00 call E00091A0 + E0008DFD: 89 45 F8 mov dword ptr [ebp-8],eax + E0008E00: EB 07 jmp E0008E09 + E0008E02: C7 45 F8 00 00 00 mov dword ptr [ebp-8],0 + 00 + E0008E09: 83 7D F8 00 cmp dword ptr [ebp-8],0 + E0008E0D: 74 0B je E0008E1A + E0008E0F: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0008E12: 83 C2 04 add edx,4 + E0008E15: 89 55 F4 mov dword ptr [ebp-0Ch],edx + E0008E18: EB 07 jmp E0008E21 + E0008E1A: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E0008E21: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0008E24: 8B E5 mov esp,ebp + E0008E26: 5D pop ebp + E0008E27: C3 ret +?Isr@CSerialPort@@KAXPAXH@Z (protected: static void __cdecl CSerialPort::Isr(void *,int)): + E0008E28: 55 push ebp + E0008E29: 8B EC mov ebp,esp + E0008E2B: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0008E2E: E8 02 00 00 00 call E0008E35 + E0008E33: 5D pop ebp + E0008E34: C3 ret +?Interrupt@CSerialPort@@IAEXXZ (protected: void __thiscall CSerialPort::Interrupt(void)): + E0008E35: 55 push ebp + E0008E36: 8B EC mov ebp,esp + E0008E38: 81 EC 88 00 00 00 sub esp,88h + E0008E3E: 53 push ebx + E0008E3F: 56 push esi + E0008E40: 57 push edi + E0008E41: 89 8D 7C FF FF FF mov dword ptr [ebp+FFFFFF7Ch],ecx + E0008E47: 8B 85 7C FF FF FF mov eax,dword ptr [ebp+FFFFFF7Ch] + E0008E4D: C6 40 21 01 mov byte ptr [eax+21h],1 + E0008E51: 66 C7 45 F4 21 00 mov word ptr [ebp-0Ch],21h + E0008E57: 33 C0 xor eax,eax + E0008E59: 66 8B 55 F4 mov dx,word ptr [ebp-0Ch] + E0008E5D: EC in al,dx + E0008E5E: 88 45 F0 mov byte ptr [ebp-10h],al + E0008E61: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0008E64: 81 E1 FF 00 00 00 and ecx,0FFh + E0008E6A: 81 C9 10 FF FF FF or ecx,0FFFFFF10h + E0008E70: 88 4D E8 mov byte ptr [ebp-18h],cl + E0008E73: 66 C7 45 EC 21 00 mov word ptr [ebp-14h],21h + E0008E79: 66 8B 55 EC mov dx,word ptr [ebp-14h] + E0008E7D: 8A 45 E8 mov al,byte ptr [ebp-18h] + E0008E80: EE out dx,al + E0008E81: 8B 95 7C FF FF FF mov edx,dword ptr [ebp+FFFFFF7Ch] + E0008E87: 66 8B 42 16 mov ax,word ptr [edx+16h] + E0008E8B: 66 89 45 E4 mov word ptr [ebp-1Ch],ax + E0008E8F: 33 C0 xor eax,eax + E0008E91: 66 8B 55 E4 mov dx,word ptr [ebp-1Ch] + E0008E95: EC in al,dx + E0008E96: 88 45 E0 mov byte ptr [ebp-20h],al + E0008E99: 8B 4D E0 mov ecx,dword ptr [ebp-20h] + E0008E9C: 81 E1 FF 00 00 00 and ecx,0FFh + E0008EA2: 83 E1 06 and ecx,6 + E0008EA5: D1 F9 sar ecx,1 + E0008EA7: 88 4D FC mov byte ptr [ebp-4],cl + E0008EAA: 8B 55 FC mov edx,dword ptr [ebp-4] + E0008EAD: 81 E2 FF 00 00 00 and edx,0FFh + E0008EB3: 52 push edx + E0008EB4: 68 64 C5 00 E0 push 0E000C564h + E0008EB9: E8 52 10 00 00 call E0009F10 + E0008EBE: 83 C4 08 add esp,8 + E0008EC1: 8B 45 FC mov eax,dword ptr [ebp-4] + E0008EC4: 25 FF 00 00 00 and eax,0FFh + E0008EC9: 89 85 78 FF FF FF mov dword ptr [ebp+FFFFFF78h],eax + E0008ECF: 83 BD 78 FF FF FF cmp dword ptr [ebp+FFFFFF78h],3 + 03 + E0008ED6: 0F 87 CD 01 00 00 ja E00090A9 + E0008EDC: 8B 8D 78 FF FF FF mov ecx,dword ptr [ebp+FFFFFF78h] + E0008EE2: FF 24 8D 90 91 00 jmp dword ptr [ecx*4+E0009190h] + E0 + E0008EE9: 8B 95 7C FF FF FF mov edx,dword ptr [ebp+FFFFFF7Ch] + E0008EEF: 66 8B 42 14 mov ax,word ptr [edx+14h] + E0008EF3: 66 89 45 DC mov word ptr [ebp-24h],ax + E0008EF7: 33 C0 xor eax,eax + E0008EF9: 66 8B 55 DC mov dx,word ptr [ebp-24h] + E0008EFD: EC in al,dx + E0008EFE: 88 45 F8 mov byte ptr [ebp-8],al + E0008F01: C6 45 D4 00 mov byte ptr [ebp-2Ch],0 + E0008F05: 8B 8D 7C FF FF FF mov ecx,dword ptr [ebp+FFFFFF7Ch] + E0008F0B: 66 8B 51 14 mov dx,word ptr [ecx+14h] + E0008F0F: 66 89 55 D8 mov word ptr [ebp-28h],dx + E0008F13: 66 8B 55 D8 mov dx,word ptr [ebp-28h] + E0008F17: 8A 45 D4 mov al,byte ptr [ebp-2Ch] + E0008F1A: EE out dx,al + E0008F1B: 8B 85 7C FF FF FF mov eax,dword ptr [ebp+FFFFFF7Ch] + E0008F21: 66 8B 48 14 mov cx,word ptr [eax+14h] + E0008F25: 66 89 4D D0 mov word ptr [ebp-30h],cx + E0008F29: 66 8B 55 D0 mov dx,word ptr [ebp-30h] + E0008F2D: 8A 45 F8 mov al,byte ptr [ebp-8] + E0008F30: EE out dx,al + E0008F31: E9 4E 02 00 00 jmp E0009184 + E0008F36: 8B 95 7C FF FF FF mov edx,dword ptr [ebp+FFFFFF7Ch] + E0008F3C: 33 C0 xor eax,eax + E0008F3E: 66 8B 82 22 10 00 mov ax,word ptr [edx+00001022h] + 00 + E0008F45: 8B 8D 7C FF FF FF mov ecx,dword ptr [ebp+FFFFFF7Ch] + E0008F4B: 33 D2 xor edx,edx + E0008F4D: 66 8B 91 24 10 00 mov dx,word ptr [ecx+00001024h] + 00 + E0008F54: 3B C2 cmp eax,edx + E0008F56: 75 45 jne E0008F9D + E0008F58: 8B 85 7C FF FF FF mov eax,dword ptr [ebp+FFFFFF7Ch] + E0008F5E: 66 8B 48 14 mov cx,word ptr [eax+14h] + E0008F62: 66 89 4D CC mov word ptr [ebp-34h],cx + E0008F66: 33 C0 xor eax,eax + E0008F68: 66 8B 55 CC mov dx,word ptr [ebp-34h] + E0008F6C: EC in al,dx + E0008F6D: 88 45 C8 mov byte ptr [ebp-38h],al + E0008F70: 8B 55 C8 mov edx,dword ptr [ebp-38h] + E0008F73: 81 E2 FF 00 00 00 and edx,0FFh + E0008F79: 81 E2 FD 00 00 00 and edx,0FDh + E0008F7F: 88 55 C0 mov byte ptr [ebp-40h],dl + E0008F82: 8B 85 7C FF FF FF mov eax,dword ptr [ebp+FFFFFF7Ch] + E0008F88: 66 8B 48 14 mov cx,word ptr [eax+14h] + E0008F8C: 66 89 4D C4 mov word ptr [ebp-3Ch],cx + E0008F90: 66 8B 55 C4 mov dx,word ptr [ebp-3Ch] + E0008F94: 8A 45 C0 mov al,byte ptr [ebp-40h] + E0008F97: EE out dx,al + E0008F98: E9 E2 01 00 00 jmp E000917F + E0008F9D: 8B 95 7C FF FF FF mov edx,dword ptr [ebp+FFFFFF7Ch] + E0008FA3: 33 C0 xor eax,eax + E0008FA5: 66 8B 82 24 10 00 mov ax,word ptr [edx+00001024h] + 00 + E0008FAC: 8B 8D 7C FF FF FF mov ecx,dword ptr [ebp+FFFFFF7Ch] + E0008FB2: 33 D2 xor edx,edx + E0008FB4: 8A 54 01 22 mov dl,byte ptr [ecx+eax+22h] + E0008FB8: 52 push edx + E0008FB9: 68 84 C5 00 E0 push 0E000C584h + E0008FBE: E8 4D 0F 00 00 call E0009F10 + E0008FC3: 83 C4 08 add esp,8 + E0008FC6: 8B 85 7C FF FF FF mov eax,dword ptr [ebp+FFFFFF7Ch] + E0008FCC: 33 C9 xor ecx,ecx + E0008FCE: 66 8B 88 24 10 00 mov cx,word ptr [eax+00001024h] + 00 + E0008FD5: 8B 95 7C FF FF FF mov edx,dword ptr [ebp+FFFFFF7Ch] + E0008FDB: 8A 44 0A 22 mov al,byte ptr [edx+ecx+22h] + E0008FDF: 88 45 B8 mov byte ptr [ebp-48h],al + E0008FE2: 8B 8D 7C FF FF FF mov ecx,dword ptr [ebp+FFFFFF7Ch] + E0008FE8: 66 8B 51 12 mov dx,word ptr [ecx+12h] + E0008FEC: 66 89 55 BC mov word ptr [ebp-44h],dx + E0008FF0: 66 8B 55 BC mov dx,word ptr [ebp-44h] + E0008FF4: 8A 45 B8 mov al,byte ptr [ebp-48h] + E0008FF7: EE out dx,al + E0008FF8: 8B 85 7C FF FF FF mov eax,dword ptr [ebp+FFFFFF7Ch] + E0008FFE: 33 C9 xor ecx,ecx + E0009000: 66 8B 88 24 10 00 mov cx,word ptr [eax+00001024h] + 00 + E0009007: 83 C1 01 add ecx,1 + E000900A: 81 E1 FF 0F 00 00 and ecx,0FFFh + E0009010: 8B 95 7C FF FF FF mov edx,dword ptr [ebp+FFFFFF7Ch] + E0009016: 66 89 8A 24 10 00 mov word ptr [edx+00001024h],cx + 00 + E000901D: E9 87 00 00 00 jmp E00090A9 + E0009022: 8B 85 7C FF FF FF mov eax,dword ptr [ebp+FFFFFF7Ch] + E0009028: 66 8B 48 12 mov cx,word ptr [eax+12h] + E000902C: 66 89 4D B4 mov word ptr [ebp-4Ch],cx + E0009030: 33 C0 xor eax,eax + E0009032: 66 8B 55 B4 mov dx,word ptr [ebp-4Ch] + E0009036: EC in al,dx + E0009037: 88 45 B0 mov byte ptr [ebp-50h],al + E000903A: 8B 95 7C FF FF FF mov edx,dword ptr [ebp+FFFFFF7Ch] + E0009040: 33 C0 xor eax,eax + E0009042: 66 8B 82 26 20 00 mov ax,word ptr [edx+00002026h] + 00 + E0009049: 8B 8D 7C FF FF FF mov ecx,dword ptr [ebp+FFFFFF7Ch] + E000904F: 8A 55 B0 mov dl,byte ptr [ebp-50h] + E0009052: 88 94 01 26 10 00 mov byte ptr [ecx+eax+00001026h],dl + 00 + E0009059: 8B 85 7C FF FF FF mov eax,dword ptr [ebp+FFFFFF7Ch] + E000905F: 33 C9 xor ecx,ecx + E0009061: 66 8B 88 26 20 00 mov cx,word ptr [eax+00002026h] + 00 + E0009068: 83 C1 01 add ecx,1 + E000906B: 81 E1 FF 0F 00 00 and ecx,0FFFh + E0009071: 8B 95 7C FF FF FF mov edx,dword ptr [ebp+FFFFFF7Ch] + E0009077: 33 C0 xor eax,eax + E0009079: 66 8B 82 28 20 00 mov ax,word ptr [edx+00002028h] + 00 + E0009080: 3B C8 cmp ecx,eax + E0009082: 74 25 je E00090A9 + E0009084: 8B 8D 7C FF FF FF mov ecx,dword ptr [ebp+FFFFFF7Ch] + E000908A: 33 D2 xor edx,edx + E000908C: 66 8B 91 26 20 00 mov dx,word ptr [ecx+00002026h] + 00 + E0009093: 83 C2 01 add edx,1 + E0009096: 81 E2 FF 0F 00 00 and edx,0FFFh + E000909C: 8B 85 7C FF FF FF mov eax,dword ptr [ebp+FFFFFF7Ch] + E00090A2: 66 89 90 26 20 00 mov word ptr [eax+00002026h],dx + 00 + E00090A9: 8B 8D 7C FF FF FF mov ecx,dword ptr [ebp+FFFFFF7Ch] + E00090AF: 66 8B 51 16 mov dx,word ptr [ecx+16h] + E00090B3: 66 89 55 AC mov word ptr [ebp-54h],dx + E00090B7: 33 C0 xor eax,eax + E00090B9: 66 8B 55 AC mov dx,word ptr [ebp-54h] + E00090BD: EC in al,dx + E00090BE: 88 45 A8 mov byte ptr [ebp-58h],al + E00090C1: 8B 45 A8 mov eax,dword ptr [ebp-58h] + E00090C4: 25 FF 00 00 00 and eax,0FFh + E00090C9: 83 E0 01 and eax,1 + E00090CC: 85 C0 test eax,eax + E00090CE: 0F 84 AD FD FF FF je E0008E81 + E00090D4: 68 A0 C5 00 E0 push 0E000C5A0h + E00090D9: E8 3E 0E 00 00 call E0009F1C + E00090DE: 83 C4 04 add esp,4 + E00090E1: 8B 8D 7C FF FF FF mov ecx,dword ptr [ebp+FFFFFF7Ch] + E00090E7: 66 8B 51 1A mov dx,word ptr [ecx+1Ah] + E00090EB: 66 89 55 A4 mov word ptr [ebp-5Ch],dx + E00090EF: 33 C0 xor eax,eax + E00090F1: 66 8B 55 A4 mov dx,word ptr [ebp-5Ch] + E00090F5: EC in al,dx + E00090F6: 88 45 A0 mov byte ptr [ebp-60h],al + E00090F9: 8B 45 A0 mov eax,dword ptr [ebp-60h] + E00090FC: 25 FF 00 00 00 and eax,0FFh + E0009101: 0C 08 or al,8 + E0009103: 88 45 98 mov byte ptr [ebp-68h],al + E0009106: 8B 8D 7C FF FF FF mov ecx,dword ptr [ebp+FFFFFF7Ch] + E000910C: 66 8B 51 1A mov dx,word ptr [ecx+1Ah] + E0009110: 66 89 55 9C mov word ptr [ebp-64h],dx + E0009114: 66 8B 55 9C mov dx,word ptr [ebp-64h] + E0009118: 8A 45 98 mov al,byte ptr [ebp-68h] + E000911B: EE out dx,al + E000911C: C6 45 90 01 mov byte ptr [ebp-70h],1 + E0009120: 8B 85 7C FF FF FF mov eax,dword ptr [ebp+FFFFFF7Ch] + E0009126: 66 8B 48 14 mov cx,word ptr [eax+14h] + E000912A: 66 89 4D 94 mov word ptr [ebp-6Ch],cx + E000912E: 66 8B 55 94 mov dx,word ptr [ebp-6Ch] + E0009132: 8A 45 90 mov al,byte ptr [ebp-70h] + E0009135: EE out dx,al + E0009136: 66 C7 45 8C 21 00 mov word ptr [ebp-74h],21h + E000913C: 33 C0 xor eax,eax + E000913E: 66 8B 55 8C mov dx,word ptr [ebp-74h] + E0009142: EC in al,dx + E0009143: 88 45 88 mov byte ptr [ebp-78h],al + E0009146: 8B 55 88 mov edx,dword ptr [ebp-78h] + E0009149: 81 E2 FF 00 00 00 and edx,0FFh + E000914F: 81 E2 EF 00 00 00 and edx,0EFh + E0009155: 88 55 80 mov byte ptr [ebp-80h],dl + E0009158: 66 C7 45 84 21 00 mov word ptr [ebp-7Ch],21h + E000915E: 66 8B 55 84 mov dx,word ptr [ebp-7Ch] + E0009162: 8A 45 80 mov al,byte ptr [ebp-80h] + E0009165: EE out dx,al + E0009166: 68 B4 C5 00 E0 push 0E000C5B4h + E000916B: E8 AC 0D 00 00 call E0009F1C + E0009170: 83 C4 04 add esp,4 + E0009173: 8B 85 7C FF FF FF mov eax,dword ptr [ebp+FFFFFF7Ch] + E0009179: C6 40 21 00 mov byte ptr [eax+21h],0 + E000917D: EB 0A jmp E0009189 + E000917F: E9 50 FF FF FF jmp E00090D4 + E0009184: E9 4B FF FF FF jmp E00090D4 + E0009189: 5F pop edi + E000918A: 5E pop esi + E000918B: 5B pop ebx + E000918C: 8B E5 mov esp,ebp + E000918E: 5D pop ebp + E000918F: C3 ret + E0009190: E9 8E 00 E0 36 jmp 16E09223 + E0009195: 8F 00 pop dword ptr [eax] + E0009197: E0 22 loopne E00091BB + E0009199: 90 nop + E000919A: 00 E0 add al,ah + E000919C: E9 8E 00 E0 55 jmp 35E0922F +??0CSerialPort@@QAE@GE@Z (public: __thiscall CSerialPort::CSerialPort(unsigned short,unsigned char)) + 1: + E00091A1: 8B EC mov ebp,esp + E00091A3: 83 EC 38 sub esp,38h + E00091A6: 53 push ebx + E00091A7: 56 push esi + E00091A8: 57 push edi + E00091A9: 89 4D C8 mov dword ptr [ebp-38h],ecx + E00091AC: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E00091AF: C7 00 C8 A0 00 E0 mov dword ptr [eax],0E000A0C8h + E00091B5: 8B 4D C8 mov ecx,dword ptr [ebp-38h] + E00091B8: 83 C1 04 add ecx,4 + E00091BB: 89 4D F8 mov dword ptr [ebp-8],ecx + E00091BE: 8B 55 F8 mov edx,dword ptr [ebp-8] + E00091C1: C7 02 B0 A0 00 E0 mov dword ptr [edx],0E000A0B0h + E00091C7: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E00091CA: 83 C0 08 add eax,8 + E00091CD: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E00091D0: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E00091D3: C7 01 10 A2 00 E0 mov dword ptr [ecx],0E000A210h + E00091D9: 8B 55 C8 mov edx,dword ptr [ebp-38h] + E00091DC: C7 02 60 A7 00 E0 mov dword ptr [edx],0E000A760h + E00091E2: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E00091E5: C7 40 04 48 A7 00 mov dword ptr [eax+4],0E000A748h + E0 + E00091EC: 8B 4D C8 mov ecx,dword ptr [ebp-38h] + E00091EF: C7 41 08 20 A7 00 mov dword ptr [ecx+8],0E000A720h + E0 + E00091F6: 8B 55 C8 mov edx,dword ptr [ebp-38h] + E00091F9: C7 42 0C 00 00 00 mov dword ptr [edx+0Ch],0 + 00 + E0009200: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0009203: 25 FF 00 00 00 and eax,0FFh + E0009208: 50 push eax + E0009209: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000920C: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0009212: 51 push ecx + E0009213: 68 C0 C5 00 E0 push 0E000C5C0h + E0009218: E8 F3 0C 00 00 call E0009F10 + E000921D: 83 C4 0C add esp,0Ch + E0009220: 8B 55 C8 mov edx,dword ptr [ebp-38h] + E0009223: 66 8B 45 08 mov ax,word ptr [ebp+8] + E0009227: 66 89 42 10 mov word ptr [edx+10h],ax + E000922B: 8B 4D C8 mov ecx,dword ptr [ebp-38h] + E000922E: 8A 55 0C mov dl,byte ptr [ebp+0Ch] + E0009231: 88 51 20 mov byte ptr [ecx+20h],dl + E0009234: C7 45 FC 06 00 00 mov dword ptr [ebp-4],6 + 00 + E000923B: EB 09 jmp E0009246 + E000923D: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009240: 83 E8 01 sub eax,1 + E0009243: 89 45 FC mov dword ptr [ebp-4],eax + E0009246: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E000924A: 7E 19 jle E0009265 + E000924C: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000924F: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0009255: 03 4D FC add ecx,dword ptr [ebp-4] + E0009258: 8B 55 FC mov edx,dword ptr [ebp-4] + E000925B: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E000925E: 66 89 4C 50 12 mov word ptr [eax+edx*2+12h],cx + E0009263: EB D8 jmp E000923D + E0009265: 8B 4D C8 mov ecx,dword ptr [ebp-38h] + E0009268: E8 89 01 00 00 call E00093F6 + E000926D: 8B 4D C8 mov ecx,dword ptr [ebp-38h] + E0009270: E8 5E 01 00 00 call E00093D3 + E0009275: 8B 4D C8 mov ecx,dword ptr [ebp-38h] + E0009278: 51 push ecx + E0009279: 68 28 8E 00 E0 push 0E0008E28h + E000927E: 8B 55 C8 mov edx,dword ptr [ebp-38h] + E0009281: 8A 42 20 mov al,byte ptr [edx+20h] + E0009284: 50 push eax + E0009285: E8 A4 0C 00 00 call E0009F2E + E000928A: 83 C4 0C add esp,0Ch + E000928D: 8B 4D C8 mov ecx,dword ptr [ebp-38h] + E0009290: 66 8B 51 1A mov dx,word ptr [ecx+1Ah] + E0009294: 66 89 55 F0 mov word ptr [ebp-10h],dx + E0009298: 33 C0 xor eax,eax + E000929A: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E000929E: EC in al,dx + E000929F: 88 45 EC mov byte ptr [ebp-14h],al + E00092A2: 8B 45 EC mov eax,dword ptr [ebp-14h] + E00092A5: 25 FF 00 00 00 and eax,0FFh + E00092AA: 0C 08 or al,8 + E00092AC: 88 45 E4 mov byte ptr [ebp-1Ch],al + E00092AF: 8B 4D C8 mov ecx,dword ptr [ebp-38h] + E00092B2: 66 8B 51 1A mov dx,word ptr [ecx+1Ah] + E00092B6: 66 89 55 E8 mov word ptr [ebp-18h],dx + E00092BA: 66 8B 55 E8 mov dx,word ptr [ebp-18h] + E00092BE: 8A 45 E4 mov al,byte ptr [ebp-1Ch] + E00092C1: EE out dx,al + E00092C2: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E00092C5: 66 8B 48 18 mov cx,word ptr [eax+18h] + E00092C9: 66 89 4D E0 mov word ptr [ebp-20h],cx + E00092CD: 33 C0 xor eax,eax + E00092CF: 66 8B 55 E0 mov dx,word ptr [ebp-20h] + E00092D3: EC in al,dx + E00092D4: 88 45 DC mov byte ptr [ebp-24h],al + E00092D7: 8B 55 DC mov edx,dword ptr [ebp-24h] + E00092DA: 81 E2 FF 00 00 00 and edx,0FFh + E00092E0: 83 E2 7F and edx,7Fh + E00092E3: 88 55 D4 mov byte ptr [ebp-2Ch],dl + E00092E6: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E00092E9: 66 8B 48 18 mov cx,word ptr [eax+18h] + E00092ED: 66 89 4D D8 mov word ptr [ebp-28h],cx + E00092F1: 66 8B 55 D8 mov dx,word ptr [ebp-28h] + E00092F5: 8A 45 D4 mov al,byte ptr [ebp-2Ch] + E00092F8: EE out dx,al + E00092F9: C6 45 CC 01 mov byte ptr [ebp-34h],1 + E00092FD: 8B 55 C8 mov edx,dword ptr [ebp-38h] + E0009300: 66 8B 42 14 mov ax,word ptr [edx+14h] + E0009304: 66 89 45 D0 mov word ptr [ebp-30h],ax + E0009308: 66 8B 55 D0 mov dx,word ptr [ebp-30h] + E000930C: 8A 45 CC mov al,byte ptr [ebp-34h] + E000930F: EE out dx,al + E0009310: 8B 4D C8 mov ecx,dword ptr [ebp-38h] + E0009313: E8 DE 00 00 00 call E00093F6 + E0009318: 8B 4D C8 mov ecx,dword ptr [ebp-38h] + E000931B: E8 B3 00 00 00 call E00093D3 + E0009320: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E0009323: 5F pop edi + E0009324: 5E pop esi + E0009325: 5B pop ebx + E0009326: 8B E5 mov esp,ebp + E0009328: 5D pop ebp + E0009329: C2 08 00 ret 8 +??1CSerialPort@@UAE@XZ (public: virtual __thiscall CSerialPort::~CSerialPort(void)): + E000932C: 55 push ebp + E000932D: 8B EC mov ebp,esp + E000932F: 51 push ecx + E0009330: 89 4D FC mov dword ptr [ebp-4],ecx + E0009333: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009336: C7 00 60 A7 00 E0 mov dword ptr [eax],0E000A760h + E000933C: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000933F: C7 41 04 48 A7 00 mov dword ptr [ecx+4],0E000A748h + E0 + E0009346: 8B 55 FC mov edx,dword ptr [ebp-4] + E0009349: C7 42 08 20 A7 00 mov dword ptr [edx+8],0E000A720h + E0 + E0009350: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0009353: E8 04 00 00 00 call E000935C + E0009358: 8B E5 mov esp,ebp + E000935A: 5D pop ebp + E000935B: C3 ret +?ClosePort@CSerialPort@@IAEXXZ (protected: void __thiscall CSerialPort::ClosePort(void)): + E000935C: 55 push ebp + E000935D: 8B EC mov ebp,esp + E000935F: 83 EC 1C sub esp,1Ch + E0009362: 53 push ebx + E0009363: 56 push esi + E0009364: 57 push edi + E0009365: 89 4D E4 mov dword ptr [ebp-1Ch],ecx + E0009368: C6 45 F8 00 mov byte ptr [ebp-8],0 + E000936C: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E000936F: 66 8B 48 14 mov cx,word ptr [eax+14h] + E0009373: 66 89 4D FC mov word ptr [ebp-4],cx + E0009377: 66 8B 55 FC mov dx,word ptr [ebp-4] + E000937B: 8A 45 F8 mov al,byte ptr [ebp-8] + E000937E: EE out dx,al + E000937F: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0009382: 66 8B 42 1A mov ax,word ptr [edx+1Ah] + E0009386: 66 89 45 F4 mov word ptr [ebp-0Ch],ax + E000938A: 33 C0 xor eax,eax + E000938C: 66 8B 55 F4 mov dx,word ptr [ebp-0Ch] + E0009390: EC in al,dx + E0009391: 88 45 F0 mov byte ptr [ebp-10h],al + E0009394: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0009397: 81 E1 FF 00 00 00 and ecx,0FFh + E000939D: 81 E1 F7 00 00 00 and ecx,0F7h + E00093A3: 88 4D E8 mov byte ptr [ebp-18h],cl + E00093A6: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E00093A9: 66 8B 42 1A mov ax,word ptr [edx+1Ah] + E00093AD: 66 89 45 EC mov word ptr [ebp-14h],ax + E00093B1: 66 8B 55 EC mov dx,word ptr [ebp-14h] + E00093B5: 8A 45 E8 mov al,byte ptr [ebp-18h] + E00093B8: EE out dx,al + E00093B9: 6A 00 push 0 + E00093BB: 6A 00 push 0 + E00093BD: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E00093C0: 8A 51 20 mov dl,byte ptr [ecx+20h] + E00093C3: 52 push edx + E00093C4: E8 65 0B 00 00 call E0009F2E + E00093C9: 83 C4 0C add esp,0Ch + E00093CC: 5F pop edi + E00093CD: 5E pop esi + E00093CE: 5B pop ebx + E00093CF: 8B E5 mov esp,ebp + E00093D1: 5D pop ebp + E00093D2: C3 ret +?ClearRead@CSerialPort@@IAEXXZ (protected: void __thiscall CSerialPort::ClearRead(void)): + E00093D3: 55 push ebp + E00093D4: 8B EC mov ebp,esp + E00093D6: 51 push ecx + E00093D7: 89 4D FC mov dword ptr [ebp-4],ecx + E00093DA: 8B 45 FC mov eax,dword ptr [ebp-4] + E00093DD: 66 C7 80 28 20 00 mov word ptr [eax+00002028h],0 + 00 00 00 + E00093E6: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00093E9: 66 C7 81 26 20 00 mov word ptr [ecx+00002026h],0 + 00 00 00 + E00093F2: 8B E5 mov esp,ebp + E00093F4: 5D pop ebp + E00093F5: C3 ret +?ClearWrite@CSerialPort@@IAEXXZ (protected: void __thiscall CSerialPort::ClearWrite(void)): + E00093F6: 55 push ebp + E00093F7: 8B EC mov ebp,esp + E00093F9: 51 push ecx + E00093FA: 89 4D FC mov dword ptr [ebp-4],ecx + E00093FD: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009400: 66 C7 80 24 10 00 mov word ptr [eax+00001024h],0 + 00 00 00 + E0009409: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000940C: 66 C7 81 22 10 00 mov word ptr [ecx+00001022h],0 + 00 00 00 + E0009415: 8B E5 mov esp,ebp + E0009417: 5D pop ebp + E0009418: C3 ret +?HwRead@CSerialPort@@IAEDXZ (protected: char __thiscall CSerialPort::HwRead(void)): + E0009419: 55 push ebp + E000941A: 8B EC mov ebp,esp + E000941C: 83 EC 08 sub esp,8 + E000941F: 89 4D F8 mov dword ptr [ebp-8],ecx + E0009422: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0009425: 33 C9 xor ecx,ecx + E0009427: 66 8B 88 26 20 00 mov cx,word ptr [eax+00002026h] + 00 + E000942E: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0009431: 33 C0 xor eax,eax + E0009433: 66 8B 82 28 20 00 mov ax,word ptr [edx+00002028h] + 00 + E000943A: 3B C8 cmp ecx,eax + E000943C: 75 04 jne E0009442 + E000943E: 32 C0 xor al,al + E0009440: EB 3A jmp E000947C + E0009442: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0009445: 33 D2 xor edx,edx + E0009447: 66 8B 91 28 20 00 mov dx,word ptr [ecx+00002028h] + 00 + E000944E: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0009451: 8A 8C 10 26 10 00 mov cl,byte ptr [eax+edx+00001026h] + 00 + E0009458: 88 4D FC mov byte ptr [ebp-4],cl + E000945B: 8B 55 F8 mov edx,dword ptr [ebp-8] + E000945E: 33 C0 xor eax,eax + E0009460: 66 8B 82 28 20 00 mov ax,word ptr [edx+00002028h] + 00 + E0009467: 83 C0 01 add eax,1 + E000946A: 25 FF 0F 00 00 and eax,0FFFh + E000946F: 8B 4D F8 mov ecx,dword ptr [ebp-8] + E0009472: 66 89 81 28 20 00 mov word ptr [ecx+00002028h],ax + 00 + E0009479: 8A 45 FC mov al,byte ptr [ebp-4] + E000947C: 8B E5 mov esp,ebp + E000947E: 5D pop ebp + E000947F: C3 ret +?HwWrite@CSerialPort@@IAEHD@Z (protected: int __thiscall CSerialPort::HwWrite(char)): + E0009480: 55 push ebp + E0009481: 8B EC mov ebp,esp + E0009483: 83 EC 14 sub esp,14h + E0009486: 53 push ebx + E0009487: 56 push esi + E0009488: 57 push edi + E0009489: 89 4D EC mov dword ptr [ebp-14h],ecx + E000948C: 8B 45 EC mov eax,dword ptr [ebp-14h] + E000948F: 33 C9 xor ecx,ecx + E0009491: 66 8B 88 22 10 00 mov cx,word ptr [eax+00001022h] + 00 + E0009498: 83 C1 01 add ecx,1 + E000949B: 81 E1 FF 0F 00 00 and ecx,0FFFh + E00094A1: 8B 55 EC mov edx,dword ptr [ebp-14h] + E00094A4: 33 C0 xor eax,eax + E00094A6: 66 8B 82 24 10 00 mov ax,word ptr [edx+00001024h] + 00 + E00094AD: 3B C8 cmp ecx,eax + E00094AF: 74 0C je E00094BD + E00094B1: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E00094B4: 33 D2 xor edx,edx + E00094B6: 8A 51 21 mov dl,byte ptr [ecx+21h] + E00094B9: 85 D2 test edx,edx + E00094BB: 74 04 je E00094C1 + E00094BD: 33 C0 xor eax,eax + E00094BF: EB 6D jmp E000952E + E00094C1: 8B 45 EC mov eax,dword ptr [ebp-14h] + E00094C4: 33 C9 xor ecx,ecx + E00094C6: 66 8B 88 22 10 00 mov cx,word ptr [eax+00001022h] + 00 + E00094CD: 8B 55 EC mov edx,dword ptr [ebp-14h] + E00094D0: 8A 45 08 mov al,byte ptr [ebp+8] + E00094D3: 88 44 0A 22 mov byte ptr [edx+ecx+22h],al + E00094D7: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E00094DA: 33 D2 xor edx,edx + E00094DC: 66 8B 91 22 10 00 mov dx,word ptr [ecx+00001022h] + 00 + E00094E3: 83 C2 01 add edx,1 + E00094E6: 81 E2 FF 0F 00 00 and edx,0FFFh + E00094EC: 8B 45 EC mov eax,dword ptr [ebp-14h] + E00094EF: 66 89 90 22 10 00 mov word ptr [eax+00001022h],dx + 00 + E00094F6: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E00094F9: 66 8B 51 14 mov dx,word ptr [ecx+14h] + E00094FD: 66 89 55 FC mov word ptr [ebp-4],dx + E0009501: 33 C0 xor eax,eax + E0009503: 66 8B 55 FC mov dx,word ptr [ebp-4] + E0009507: EC in al,dx + E0009508: 88 45 F8 mov byte ptr [ebp-8],al + E000950B: 8B 45 F8 mov eax,dword ptr [ebp-8] + E000950E: 25 FF 00 00 00 and eax,0FFh + E0009513: 0C 02 or al,2 + E0009515: 88 45 F0 mov byte ptr [ebp-10h],al + E0009518: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E000951B: 66 8B 51 14 mov dx,word ptr [ecx+14h] + E000951F: 66 89 55 F4 mov word ptr [ebp-0Ch],dx + E0009523: 66 8B 55 F4 mov dx,word ptr [ebp-0Ch] + E0009527: 8A 45 F0 mov al,byte ptr [ebp-10h] + E000952A: EE out dx,al + E000952B: 83 C8 FF or eax,0FFh + E000952E: 5F pop edi + E000952F: 5E pop esi + E0009530: 5B pop ebx + E0009531: 8B E5 mov esp,ebp + E0009533: 5D pop ebp + E0009534: C2 04 00 ret 4 +?ReadStatus@CSerialPort@@IAEHXZ (protected: int __thiscall CSerialPort::ReadStatus(void)): + E0009537: 55 push ebp + E0009538: 8B EC mov ebp,esp + E000953A: 51 push ecx + E000953B: 89 4D FC mov dword ptr [ebp-4],ecx + E000953E: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009541: 33 C9 xor ecx,ecx + E0009543: 66 8B 88 26 20 00 mov cx,word ptr [eax+00002026h] + 00 + E000954A: 8B 55 FC mov edx,dword ptr [ebp-4] + E000954D: 33 C0 xor eax,eax + E000954F: 66 8B 82 28 20 00 mov ax,word ptr [edx+00002028h] + 00 + E0009556: 3B C8 cmp ecx,eax + E0009558: 7C 1E jl E0009578 + E000955A: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000955D: 33 D2 xor edx,edx + E000955F: 66 8B 91 26 20 00 mov dx,word ptr [ecx+00002026h] + 00 + E0009566: 8B C2 mov eax,edx + E0009568: 8B 4D FC mov ecx,dword ptr [ebp-4] + E000956B: 33 D2 xor edx,edx + E000956D: 66 8B 91 28 20 00 mov dx,word ptr [ecx+00002028h] + 00 + E0009574: 2B C2 sub eax,edx + E0009576: EB 21 jmp E0009599 + E0009578: 8B 45 FC mov eax,dword ptr [ebp-4] + E000957B: 33 C9 xor ecx,ecx + E000957D: 66 8B 88 26 20 00 mov cx,word ptr [eax+00002026h] + 00 + E0009584: 8B C1 mov eax,ecx + E0009586: 8B 55 FC mov edx,dword ptr [ebp-4] + E0009589: 33 C9 xor ecx,ecx + E000958B: 66 8B 8A 28 20 00 mov cx,word ptr [edx+00002028h] + 00 + E0009592: 2B C1 sub eax,ecx + E0009594: 05 FF 0F 00 00 add eax,0FFFh + E0009599: 8B E5 mov esp,ebp + E000959B: 5D pop ebp + E000959C: C3 ret +?WriteStatus@CSerialPort@@IAEHXZ (protected: int __thiscall CSerialPort::WriteStatus(void)): + E000959D: 55 push ebp + E000959E: 8B EC mov ebp,esp + E00095A0: 51 push ecx + E00095A1: 89 4D FC mov dword ptr [ebp-4],ecx + E00095A4: 8B 45 FC mov eax,dword ptr [ebp-4] + E00095A7: 33 C9 xor ecx,ecx + E00095A9: 66 8B 88 22 10 00 mov cx,word ptr [eax+00001022h] + 00 + E00095B0: 8B 55 FC mov edx,dword ptr [ebp-4] + E00095B3: 33 C0 xor eax,eax + E00095B5: 66 8B 82 24 10 00 mov ax,word ptr [edx+00001024h] + 00 + E00095BC: 3B C8 cmp ecx,eax + E00095BE: 7C 1E jl E00095DE + E00095C0: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00095C3: 33 D2 xor edx,edx + E00095C5: 66 8B 91 22 10 00 mov dx,word ptr [ecx+00001022h] + 00 + E00095CC: 8B C2 mov eax,edx + E00095CE: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00095D1: 33 D2 xor edx,edx + E00095D3: 66 8B 91 24 10 00 mov dx,word ptr [ecx+00001024h] + 00 + E00095DA: 2B C2 sub eax,edx + E00095DC: EB 21 jmp E00095FF + E00095DE: 8B 45 FC mov eax,dword ptr [ebp-4] + E00095E1: 33 C9 xor ecx,ecx + E00095E3: 66 8B 88 22 10 00 mov cx,word ptr [eax+00001022h] + 00 + E00095EA: 8B C1 mov eax,ecx + E00095EC: 8B 55 FC mov edx,dword ptr [ebp-4] + E00095EF: 33 C9 xor ecx,ecx + E00095F1: 66 8B 8A 24 10 00 mov cx,word ptr [edx+00001024h] + 00 + E00095F8: 2B C1 sub eax,ecx + E00095FA: 05 FF 0F 00 00 add eax,0FFFh + E00095FF: 8B E5 mov esp,ebp + E0009601: 5D pop ebp + E0009602: C3 ret +?SetBaud@CSerialPort@@IAEXH@Z (protected: void __thiscall CSerialPort::SetBaud(int)): + E0009603: 55 push ebp + E0009604: 8B EC mov ebp,esp + E0009606: 83 EC 38 sub esp,38h + E0009609: 53 push ebx + E000960A: 56 push esi + E000960B: 57 push edi + E000960C: 89 4D C8 mov dword ptr [ebp-38h],ecx + E000960F: 83 7D 08 00 cmp dword ptr [ebp+8],0 + E0009613: 75 05 jne E000961A + E0009615: E9 D0 00 00 00 jmp E00096EA + E000961A: B8 00 C2 01 00 mov eax,1C200h + E000961F: 99 cwd + E0009620: F7 7D 08 idiv eax,dword ptr [ebp+8] + E0009623: 88 45 FC mov byte ptr [ebp-4],al + E0009626: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E0009629: 66 8B 48 18 mov cx,word ptr [eax+18h] + E000962D: 66 89 4D F8 mov word ptr [ebp-8],cx + E0009631: 33 C0 xor eax,eax + E0009633: 66 8B 55 F8 mov dx,word ptr [ebp-8] + E0009637: EC in al,dx + E0009638: 88 45 F4 mov byte ptr [ebp-0Ch],al + E000963B: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E000963E: 81 E2 FF 00 00 00 and edx,0FFh + E0009644: 80 CA 80 or dl,80h + E0009647: 88 55 EC mov byte ptr [ebp-14h],dl + E000964A: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E000964D: 66 8B 48 18 mov cx,word ptr [eax+18h] + E0009651: 66 89 4D F0 mov word ptr [ebp-10h],cx + E0009655: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E0009659: 8A 45 EC mov al,byte ptr [ebp-14h] + E000965C: EE out dx,al + E000965D: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009660: 25 FF 00 00 00 and eax,0FFh + E0009665: 99 cwd + E0009666: 33 C2 xor eax,edx + E0009668: 2B C2 sub eax,edx + E000966A: 25 FF 00 00 00 and eax,0FFh + E000966F: 33 C2 xor eax,edx + E0009671: 2B C2 sub eax,edx + E0009673: 88 45 E4 mov byte ptr [ebp-1Ch],al + E0009676: 8B 55 C8 mov edx,dword ptr [ebp-38h] + E0009679: 66 8B 42 12 mov ax,word ptr [edx+12h] + E000967D: 66 89 45 E8 mov word ptr [ebp-18h],ax + E0009681: 66 8B 55 E8 mov dx,word ptr [ebp-18h] + E0009685: 8A 45 E4 mov al,byte ptr [ebp-1Ch] + E0009688: EE out dx,al + E0009689: 8B 45 FC mov eax,dword ptr [ebp-4] + E000968C: 25 FF 00 00 00 and eax,0FFh + E0009691: 99 cwd + E0009692: 81 E2 FF 00 00 00 and edx,0FFh + E0009698: 03 C2 add eax,edx + E000969A: C1 F8 08 sar eax,8 + E000969D: 88 45 DC mov byte ptr [ebp-24h],al + E00096A0: 8B 4D C8 mov ecx,dword ptr [ebp-38h] + E00096A3: 66 8B 51 14 mov dx,word ptr [ecx+14h] + E00096A7: 66 89 55 E0 mov word ptr [ebp-20h],dx + E00096AB: 66 8B 55 E0 mov dx,word ptr [ebp-20h] + E00096AF: 8A 45 DC mov al,byte ptr [ebp-24h] + E00096B2: EE out dx,al + E00096B3: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E00096B6: 66 8B 48 18 mov cx,word ptr [eax+18h] + E00096BA: 66 89 4D D8 mov word ptr [ebp-28h],cx + E00096BE: 33 C0 xor eax,eax + E00096C0: 66 8B 55 D8 mov dx,word ptr [ebp-28h] + E00096C4: EC in al,dx + E00096C5: 88 45 D4 mov byte ptr [ebp-2Ch],al + E00096C8: 8B 55 D4 mov edx,dword ptr [ebp-2Ch] + E00096CB: 81 E2 FF 00 00 00 and edx,0FFh + E00096D1: 83 E2 7F and edx,7Fh + E00096D4: 88 55 CC mov byte ptr [ebp-34h],dl + E00096D7: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E00096DA: 66 8B 48 18 mov cx,word ptr [eax+18h] + E00096DE: 66 89 4D D0 mov word ptr [ebp-30h],cx + E00096E2: 66 8B 55 D0 mov dx,word ptr [ebp-30h] + E00096E6: 8A 45 CC mov al,byte ptr [ebp-34h] + E00096E9: EE out dx,al + E00096EA: 5F pop edi + E00096EB: 5E pop esi + E00096EC: 5B pop ebx + E00096ED: 8B E5 mov esp,ebp + E00096EF: 5D pop ebp + E00096F0: C2 04 00 ret 4 +?GetBaud@CSerialPort@@IAEHXZ (protected: int __thiscall CSerialPort::GetBaud(void)): + E00096F3: 55 push ebp + E00096F4: 8B EC mov ebp,esp + E00096F6: 83 EC 38 sub esp,38h + E00096F9: 53 push ebx + E00096FA: 56 push esi + E00096FB: 57 push edi + E00096FC: 89 4D C8 mov dword ptr [ebp-38h],ecx + E00096FF: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E0009702: 66 8B 48 18 mov cx,word ptr [eax+18h] + E0009706: 66 89 4D F8 mov word ptr [ebp-8],cx + E000970A: 33 C0 xor eax,eax + E000970C: 66 8B 55 F8 mov dx,word ptr [ebp-8] + E0009710: EC in al,dx + E0009711: 88 45 F4 mov byte ptr [ebp-0Ch],al + E0009714: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0009717: 81 E2 FF 00 00 00 and edx,0FFh + E000971D: 80 CA 80 or dl,80h + E0009720: 88 55 EC mov byte ptr [ebp-14h],dl + E0009723: 8B 45 C8 mov eax,dword ptr [ebp-38h] + E0009726: 66 8B 48 18 mov cx,word ptr [eax+18h] + E000972A: 66 89 4D F0 mov word ptr [ebp-10h],cx + E000972E: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E0009732: 8A 45 EC mov al,byte ptr [ebp-14h] + E0009735: EE out dx,al + E0009736: 8B 55 C8 mov edx,dword ptr [ebp-38h] + E0009739: 66 8B 42 12 mov ax,word ptr [edx+12h] + E000973D: 66 89 45 E8 mov word ptr [ebp-18h],ax + E0009741: 33 C0 xor eax,eax + E0009743: 66 8B 55 E8 mov dx,word ptr [ebp-18h] + E0009747: EC in al,dx + E0009748: 88 45 E4 mov byte ptr [ebp-1Ch],al + E000974B: 8B 4D C8 mov ecx,dword ptr [ebp-38h] + E000974E: 66 8B 51 14 mov dx,word ptr [ecx+14h] + E0009752: 66 89 55 E0 mov word ptr [ebp-20h],dx + E0009756: 33 C0 xor eax,eax + E0009758: 66 8B 55 E0 mov dx,word ptr [ebp-20h] + E000975C: EC in al,dx + E000975D: 88 45 DC mov byte ptr [ebp-24h],al + E0009760: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0009763: 25 FF 00 00 00 and eax,0FFh + E0009768: 8B 4D DC mov ecx,dword ptr [ebp-24h] + E000976B: 81 E1 FF 00 00 00 and ecx,0FFh + E0009771: C1 E1 08 shl ecx,8 + E0009774: 0B C1 or eax,ecx + E0009776: 66 89 45 FC mov word ptr [ebp-4],ax + E000977A: 8B 55 C8 mov edx,dword ptr [ebp-38h] + E000977D: 66 8B 42 18 mov ax,word ptr [edx+18h] + E0009781: 66 89 45 D8 mov word ptr [ebp-28h],ax + E0009785: 33 C0 xor eax,eax + E0009787: 66 8B 55 D8 mov dx,word ptr [ebp-28h] + E000978B: EC in al,dx + E000978C: 88 45 D4 mov byte ptr [ebp-2Ch],al + E000978F: 8B 4D D4 mov ecx,dword ptr [ebp-2Ch] + E0009792: 81 E1 FF 00 00 00 and ecx,0FFh + E0009798: 83 E1 7F and ecx,7Fh + E000979B: 88 4D CC mov byte ptr [ebp-34h],cl + E000979E: 8B 55 C8 mov edx,dword ptr [ebp-38h] + E00097A1: 66 8B 42 18 mov ax,word ptr [edx+18h] + E00097A5: 66 89 45 D0 mov word ptr [ebp-30h],ax + E00097A9: 66 8B 55 D0 mov dx,word ptr [ebp-30h] + E00097AD: 8A 45 CC mov al,byte ptr [ebp-34h] + E00097B0: EE out dx,al + E00097B1: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00097B4: 81 E1 FF FF 00 00 and ecx,0FFFFh + E00097BA: 85 C9 test ecx,ecx + E00097BC: 75 04 jne E00097C2 + E00097BE: 33 C0 xor eax,eax + E00097C0: EB 11 jmp E00097D3 + E00097C2: 8B 4D FC mov ecx,dword ptr [ebp-4] + E00097C5: 81 E1 FF FF 00 00 and ecx,0FFFFh + E00097CB: B8 00 C2 01 00 mov eax,1C200h + E00097D0: 99 cwd + E00097D1: F7 F9 idiv eax,ecx + E00097D3: 5F pop edi + E00097D4: 5E pop esi + E00097D5: 5B pop ebx + E00097D6: 8B E5 mov esp,ebp + E00097D8: 5D pop ebp + E00097D9: C3 ret +?SetHandShake@CSerialPort@@IAEXH@Z (protected: void __thiscall CSerialPort::SetHandShake(int)): + E00097DA: 55 push ebp + E00097DB: 8B EC mov ebp,esp + E00097DD: 83 EC 0C sub esp,0Ch + E00097E0: 53 push ebx + E00097E1: 56 push esi + E00097E2: 57 push edi + E00097E3: 89 4D F4 mov dword ptr [ebp-0Ch],ecx + E00097E6: 8B 45 08 mov eax,dword ptr [ebp+8] + E00097E9: 25 FF 00 00 00 and eax,0FFh + E00097EE: 0C 08 or al,8 + E00097F0: 88 45 F8 mov byte ptr [ebp-8],al + E00097F3: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E00097F6: 66 8B 51 1A mov dx,word ptr [ecx+1Ah] + E00097FA: 66 89 55 FC mov word ptr [ebp-4],dx + E00097FE: 66 8B 55 FC mov dx,word ptr [ebp-4] + E0009802: 8A 45 F8 mov al,byte ptr [ebp-8] + E0009805: EE out dx,al + E0009806: 5F pop edi + E0009807: 5E pop esi + E0009808: 5B pop ebx + E0009809: 8B E5 mov esp,ebp + E000980B: 5D pop ebp + E000980C: C2 04 00 ret 4 +?GetHandShake@CSerialPort@@IAEHXZ (protected: int __thiscall CSerialPort::GetHandShake(void)): + E000980F: 55 push ebp + E0009810: 8B EC mov ebp,esp + E0009812: 83 EC 0C sub esp,0Ch + E0009815: 53 push ebx + E0009816: 56 push esi + E0009817: 57 push edi + E0009818: 89 4D F4 mov dword ptr [ebp-0Ch],ecx + E000981B: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E000981E: 66 8B 48 1A mov cx,word ptr [eax+1Ah] + E0009822: 66 89 4D FC mov word ptr [ebp-4],cx + E0009826: 33 C0 xor eax,eax + E0009828: 66 8B 55 FC mov dx,word ptr [ebp-4] + E000982C: EC in al,dx + E000982D: 88 45 F8 mov byte ptr [ebp-8],al + E0009830: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0009833: 25 FF 00 00 00 and eax,0FFh + E0009838: 5F pop edi + E0009839: 5E pop esi + E000983A: 5B pop ebx + E000983B: 8B E5 mov esp,ebp + E000983D: 5D pop ebp + E000983E: C3 ret +?GetStatus@CSerialPort@@IAEHXZ (protected: int __thiscall CSerialPort::GetStatus(void)): + E000983F: 55 push ebp + E0009840: 8B EC mov ebp,esp + E0009842: 83 EC 14 sub esp,14h + E0009845: 53 push ebx + E0009846: 56 push esi + E0009847: 57 push edi + E0009848: 89 4D EC mov dword ptr [ebp-14h],ecx + E000984B: 8B 45 EC mov eax,dword ptr [ebp-14h] + E000984E: 66 8B 48 1E mov cx,word ptr [eax+1Eh] + E0009852: 66 89 4D FC mov word ptr [ebp-4],cx + E0009856: 33 C0 xor eax,eax + E0009858: 66 8B 55 FC mov dx,word ptr [ebp-4] + E000985C: EC in al,dx + E000985D: 88 45 F8 mov byte ptr [ebp-8],al + E0009860: 8B 55 EC mov edx,dword ptr [ebp-14h] + E0009863: 66 8B 42 1C mov ax,word ptr [edx+1Ch] + E0009867: 66 89 45 F4 mov word ptr [ebp-0Ch],ax + E000986B: 33 C0 xor eax,eax + E000986D: 66 8B 55 F4 mov dx,word ptr [ebp-0Ch] + E0009871: EC in al,dx + E0009872: 88 45 F0 mov byte ptr [ebp-10h],al + E0009875: 8B 45 F8 mov eax,dword ptr [ebp-8] + E0009878: 25 FF 00 00 00 and eax,0FFh + E000987D: C1 E0 08 shl eax,8 + E0009880: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0009883: 81 E1 FF 00 00 00 and ecx,0FFh + E0009889: 0B C1 or eax,ecx + E000988B: 5F pop edi + E000988C: 5E pop esi + E000988D: 5B pop ebx + E000988E: 8B E5 mov esp,ebp + E0009890: 5D pop ebp + E0009891: C3 ret +?GetControl@CSerialPort@@IAEHXZ (protected: int __thiscall CSerialPort::GetControl(void)): + E0009892: 55 push ebp + E0009893: 8B EC mov ebp,esp + E0009895: 83 EC 0C sub esp,0Ch + E0009898: 53 push ebx + E0009899: 56 push esi + E000989A: 57 push edi + E000989B: 89 4D F4 mov dword ptr [ebp-0Ch],ecx + E000989E: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E00098A1: 66 8B 48 18 mov cx,word ptr [eax+18h] + E00098A5: 66 89 4D FC mov word ptr [ebp-4],cx + E00098A9: 33 C0 xor eax,eax + E00098AB: 66 8B 55 FC mov dx,word ptr [ebp-4] + E00098AF: EC in al,dx + E00098B0: 88 45 F8 mov byte ptr [ebp-8],al + E00098B3: 8B 45 F8 mov eax,dword ptr [ebp-8] + E00098B6: 25 FF 00 00 00 and eax,0FFh + E00098BB: 83 E0 0F and eax,0Fh + E00098BE: 5F pop edi + E00098BF: 5E pop esi + E00098C0: 5B pop ebx + E00098C1: 8B E5 mov esp,ebp + E00098C3: 5D pop ebp + E00098C4: C3 ret +?SetControl@CSerialPort@@IAEXH@Z (protected: void __thiscall CSerialPort::SetControl(int)): + E00098C5: 55 push ebp + E00098C6: 8B EC mov ebp,esp + E00098C8: 83 EC 0C sub esp,0Ch + E00098CB: 53 push ebx + E00098CC: 56 push esi + E00098CD: 57 push edi + E00098CE: 89 4D F4 mov dword ptr [ebp-0Ch],ecx + E00098D1: 8B 45 08 mov eax,dword ptr [ebp+8] + E00098D4: 25 FF 00 00 00 and eax,0FFh + E00098D9: 83 E0 7F and eax,7Fh + E00098DC: 88 45 F8 mov byte ptr [ebp-8],al + E00098DF: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E00098E2: 66 8B 51 18 mov dx,word ptr [ecx+18h] + E00098E6: 66 89 55 FC mov word ptr [ebp-4],dx + E00098EA: 66 8B 55 FC mov dx,word ptr [ebp-4] + E00098EE: 8A 45 F8 mov al,byte ptr [ebp-8] + E00098F1: EE out dx,al + E00098F2: 5F pop edi + E00098F3: 5E pop esi + E00098F4: 5B pop ebx + E00098F5: 8B E5 mov esp,ebp + E00098F7: 5D pop ebp + E00098F8: C2 04 00 ret 4 +?QueryInterface@CSerialPort@@UAAKABU_GUID@@PAPAX@Z (public: virtual unsigned long __cdecl CSerialPort::QueryInterface(struct _GUID const &,void * *)): + E00098FB: 55 push ebp + E00098FC: 8B EC mov ebp,esp + E00098FE: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0009901: 8B 08 mov ecx,dword ptr [eax] + E0009903: 3B 0D D8 A0 00 E0 cmp ecx,dword ptr ds:[E000A0D8h] + E0009909: 75 2A jne E0009935 + E000990B: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E000990E: 8B 42 04 mov eax,dword ptr [edx+4] + E0009911: 3B 05 DC A0 00 E0 cmp eax,dword ptr ds:[E000A0DCh] + E0009917: 75 1C jne E0009935 + E0009919: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E000991C: 8B 51 08 mov edx,dword ptr [ecx+8] + E000991F: 3B 15 E0 A0 00 E0 cmp edx,dword ptr ds:[E000A0E0h] + E0009925: 75 0E jne E0009935 + E0009927: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E000992A: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E000992D: 3B 0D E4 A0 00 E0 cmp ecx,dword ptr ds:[E000A0E4h] + E0009933: 74 37 je E000996C + E0009935: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0009938: 8B 02 mov eax,dword ptr [edx] + E000993A: 3B 05 18 A1 00 E0 cmp eax,dword ptr ds:[E000A118h] + E0009940: 75 45 jne E0009987 + E0009942: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0009945: 8B 51 04 mov edx,dword ptr [ecx+4] + E0009948: 3B 15 1C A1 00 E0 cmp edx,dword ptr ds:[E000A11Ch] + E000994E: 75 37 jne E0009987 + E0009950: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0009953: 8B 48 08 mov ecx,dword ptr [eax+8] + E0009956: 3B 0D 20 A1 00 E0 cmp ecx,dword ptr ds:[E000A120h] + E000995C: 75 29 jne E0009987 + E000995E: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0009961: 8B 42 0C mov eax,dword ptr [edx+0Ch] + E0009964: 3B 05 24 A1 00 E0 cmp eax,dword ptr ds:[E000A124h] + E000996A: 75 1B jne E0009987 + E000996C: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E000996F: 8B 11 mov edx,dword ptr [ecx] + E0009971: 8B 45 08 mov eax,dword ptr [ebp+8] + E0009974: 50 push eax + E0009975: FF 52 04 call dword ptr [edx+4] + E0009978: 83 C4 04 add esp,4 + E000997B: 8B 4D 10 mov ecx,dword ptr [ebp+10h] + E000997E: 8B 55 08 mov edx,dword ptr [ebp+8] + E0009981: 89 11 mov dword ptr [ecx],edx + E0009983: 33 C0 xor eax,eax + E0009985: EB 05 jmp E000998C + E0009987: B8 00 00 00 80 mov eax,80000000h + E000998C: 5D pop ebp + E000998D: C3 ret +?GetInfo@CSerialPort@@UAAKPAUdevice_t@@@Z (public: virtual unsigned long __cdecl CSerialPort::GetInfo(struct device_t *)): + E000998E: 55 push ebp + E000998F: 8B EC mov ebp,esp + E0009991: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0009994: 83 38 0C cmp dword ptr [eax],0Ch + E0009997: 73 07 jae E00099A0 + E0009999: B8 00 00 00 80 mov eax,80000000h + E000999E: EB 1D jmp E00099BD + E00099A0: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E00099A3: 8B 51 08 mov edx,dword ptr [ecx+8] + E00099A6: 52 push edx + E00099A7: 68 04 C6 00 E0 push 0E000C604h + E00099AC: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E00099AF: 8B 48 04 mov ecx,dword ptr [eax+4] + E00099B2: 51 push ecx + E00099B3: E8 DC 05 00 00 call E0009F94 + E00099B8: 83 C4 0C add esp,0Ch + E00099BB: 33 C0 xor eax,eax + E00099BD: 5D pop ebp + E00099BE: C3 ret +?DeviceOpen@CSerialPort@@UAAKXZ (public: virtual unsigned long __cdecl CSerialPort::DeviceOpen(void)): + E00099BF: 55 push ebp + E00099C0: 8B EC mov ebp,esp + E00099C2: 68 1C C6 00 E0 push 0E000C61Ch + E00099C7: E8 50 05 00 00 call E0009F1C + E00099CC: 83 C4 04 add esp,4 + E00099CF: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00099D2: 83 E9 04 sub ecx,4 + E00099D5: E8 F9 F9 FF FF call E00093D3 + E00099DA: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00099DD: 83 E9 04 sub ecx,4 + E00099E0: E8 11 FA FF FF call E00093F6 + E00099E5: 68 80 25 00 00 push 2580h + E00099EA: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00099ED: 83 E9 04 sub ecx,4 + E00099F0: E8 0E FC FF FF call E0009603 + E00099F5: 6A 03 push 3 + E00099F7: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E00099FA: 83 E9 04 sub ecx,4 + E00099FD: E8 C3 FE FF FF call E00098C5 + E0009A02: 6A 00 push 0 + E0009A04: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0009A07: 83 E9 04 sub ecx,4 + E0009A0A: E8 CB FD FF FF call E00097DA + E0009A0F: 33 C0 xor eax,eax + E0009A11: 5D pop ebp + E0009A12: C3 ret +?Read@CSerialPort@@UAAIPAXI@Z (public: virtual unsigned int __cdecl CSerialPort::Read(void *,unsigned int)): + E0009A13: 55 push ebp + E0009A14: 8B EC mov ebp,esp + E0009A16: 51 push ecx + E0009A17: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0009A1E: EB 09 jmp E0009A29 + E0009A20: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009A23: 83 C0 01 add eax,1 + E0009A26: 89 45 FC mov dword ptr [ebp-4],eax + E0009A29: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0009A2C: 3B 4D 10 cmp ecx,dword ptr [ebp+10h] + E0009A2F: 73 26 jae E0009A57 + E0009A31: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0009A34: 83 E9 08 sub ecx,8 + E0009A37: E8 FB FA FF FF call E0009537 + E0009A3C: 85 C0 test eax,eax + E0009A3E: 75 02 jne E0009A42 + E0009A40: EB EF jmp E0009A31 + E0009A42: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0009A45: 83 E9 08 sub ecx,8 + E0009A48: E8 CC F9 FF FF call E0009419 + E0009A4D: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0009A50: 03 55 FC add edx,dword ptr [ebp-4] + E0009A53: 88 02 mov byte ptr [edx],al + E0009A55: EB C9 jmp E0009A20 + E0009A57: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009A5A: 8B E5 mov esp,ebp + E0009A5C: 5D pop ebp + E0009A5D: C3 ret +?Write@CSerialPort@@UAAIPBXI@Z (public: virtual unsigned int __cdecl CSerialPort::Write(void const *,unsigned int)): + E0009A5E: 55 push ebp + E0009A5F: 8B EC mov ebp,esp + E0009A61: 51 push ecx + E0009A62: C7 45 FC 00 00 00 mov dword ptr [ebp-4],0 + 00 + E0009A69: EB 09 jmp E0009A74 + E0009A6B: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009A6E: 83 C0 01 add eax,1 + E0009A71: 89 45 FC mov dword ptr [ebp-4],eax + E0009A74: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0009A77: 3B 4D 10 cmp ecx,dword ptr [ebp+10h] + E0009A7A: 73 1C jae E0009A98 + E0009A7C: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0009A7F: 03 55 FC add edx,dword ptr [ebp-4] + E0009A82: 8A 02 mov al,byte ptr [edx] + E0009A84: 50 push eax + E0009A85: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0009A88: 83 E9 08 sub ecx,8 + E0009A8B: E8 F0 F9 FF FF call E0009480 + E0009A90: 85 C0 test eax,eax + E0009A92: 75 02 jne E0009A96 + E0009A94: EB 02 jmp E0009A98 + E0009A96: EB D3 jmp E0009A6B + E0009A98: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009A9B: 8B E5 mov esp,ebp + E0009A9D: 5D pop ebp + E0009A9E: C3 ret +?SetIoMode@CSerialPort@@UAAKI@Z (public: virtual unsigned long __cdecl CSerialPort::SetIoMode(unsigned int)): + E0009A9F: 55 push ebp + E0009AA0: 8B EC mov ebp,esp + E0009AA2: 33 C0 xor eax,eax + E0009AA4: 5D pop ebp + E0009AA5: C3 ret +?IsReady@CSerialPort@@UAAKXZ (public: virtual unsigned long __cdecl CSerialPort::IsReady(void)): + E0009AA6: 55 push ebp + E0009AA7: 8B EC mov ebp,esp + E0009AA9: 33 C0 xor eax,eax + E0009AAB: 5D pop ebp + E0009AAC: C3 ret +?Stat@CSerialPort@@UAAKPAU_folderitem_t@@@Z (public: virtual unsigned long __cdecl CSerialPort::Stat(struct _folderitem_t *)): + E0009AAD: 55 push ebp + E0009AAE: 8B EC mov ebp,esp + E0009AB0: B8 00 00 00 80 mov eax,80000000h + E0009AB5: 5D pop ebp + E0009AB6: C3 ret +?Seek@CSerialPort@@UAAKJH@Z (public: virtual unsigned long __cdecl CSerialPort::Seek(long,int)): + E0009AB7: 55 push ebp + E0009AB8: 8B EC mov ebp,esp + E0009ABA: B8 00 00 00 80 mov eax,80000000h + E0009ABF: 5D pop ebp + E0009AC0: C3 ret + E0009AC1: CC int 3 + E0009AC2: CC int 3 + E0009AC3: CC int 3 + E0009AC4: CC int 3 + E0009AC5: CC int 3 + E0009AC6: CC int 3 + E0009AC7: CC int 3 + E0009AC8: CC int 3 + E0009AC9: CC int 3 + E0009ACA: CC int 3 + E0009ACB: CC int 3 + E0009ACC: CC int 3 + E0009ACD: CC int 3 + E0009ACE: CC int 3 + E0009ACF: CC int 3 +?AddRef@CSerialPort@@UAAKXZ (public: virtual unsigned long __cdecl CSerialPort::AddRef(void)): + E0009AD0: 55 push ebp + E0009AD1: 8B EC mov ebp,esp + E0009AD3: 8B 45 08 mov eax,dword ptr [ebp+8] + E0009AD6: 8B 48 0C mov ecx,dword ptr [eax+0Ch] + E0009AD9: 83 C1 01 add ecx,1 + E0009ADC: 8B 55 08 mov edx,dword ptr [ebp+8] + E0009ADF: 89 4A 0C mov dword ptr [edx+0Ch],ecx + E0009AE2: 8B 45 08 mov eax,dword ptr [ebp+8] + E0009AE5: 8B 40 0C mov eax,dword ptr [eax+0Ch] + E0009AE8: 5D pop ebp + E0009AE9: C3 ret + E0009AEA: CC int 3 + E0009AEB: CC int 3 + E0009AEC: CC int 3 + E0009AED: CC int 3 + E0009AEE: CC int 3 + E0009AEF: CC int 3 +?Release@CSerialPort@@UAAKXZ (public: virtual unsigned long __cdecl CSerialPort::Release(void)): + E0009AF0: 55 push ebp + E0009AF1: 8B EC mov ebp,esp + E0009AF3: 83 EC 0C sub esp,0Ch + E0009AF6: 8B 45 08 mov eax,dword ptr [ebp+8] + E0009AF9: 83 78 0C 00 cmp dword ptr [eax+0Ch],0 + E0009AFD: 75 2F jne E0009B2E + E0009AFF: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0009B02: 89 4D F8 mov dword ptr [ebp-8],ecx + E0009B05: 8B 55 F8 mov edx,dword ptr [ebp-8] + E0009B08: 89 55 FC mov dword ptr [ebp-4],edx + E0009B0B: 83 7D FC 00 cmp dword ptr [ebp-4],0 + E0009B0F: 74 12 je E0009B23 + E0009B11: 6A 01 push 1 + E0009B13: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009B16: 8B 10 mov edx,dword ptr [eax] + E0009B18: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0009B1B: FF 52 0C call dword ptr [edx+0Ch] + E0009B1E: 89 45 F4 mov dword ptr [ebp-0Ch],eax + E0009B21: EB 07 jmp E0009B2A + E0009B23: C7 45 F4 00 00 00 mov dword ptr [ebp-0Ch],0 + 00 + E0009B2A: 33 C0 xor eax,eax + E0009B2C: EB 15 jmp E0009B43 + E0009B2E: 8B 45 08 mov eax,dword ptr [ebp+8] + E0009B31: 8B 40 0C mov eax,dword ptr [eax+0Ch] + E0009B34: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0009B37: 8B 51 0C mov edx,dword ptr [ecx+0Ch] + E0009B3A: 83 EA 01 sub edx,1 + E0009B3D: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0009B40: 89 51 0C mov dword ptr [ecx+0Ch],edx + E0009B43: 8B E5 mov esp,ebp + E0009B45: 5D pop ebp + E0009B46: C3 ret + E0009B47: CC int 3 + E0009B48: CC int 3 + E0009B49: CC int 3 + E0009B4A: CC int 3 + E0009B4B: CC int 3 + E0009B4C: CC int 3 + E0009B4D: CC int 3 + E0009B4E: CC int 3 + E0009B4F: CC int 3 +??_GCSerialPort@@UAEPAXI@Z (public: virtual void * __thiscall CSerialPort::`scalar deleting destructor'(unsigned int)): + E0009B50: 55 push ebp + E0009B51: 8B EC mov ebp,esp + E0009B53: 51 push ecx + E0009B54: 89 4D FC mov dword ptr [ebp-4],ecx + E0009B57: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0009B5A: E8 CD F7 FF FF call E000932C + E0009B5F: 8B 45 08 mov eax,dword ptr [ebp+8] + E0009B62: 83 E0 01 and eax,1 + E0009B65: 85 C0 test eax,eax + E0009B67: 74 0C je E0009B75 + E0009B69: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0009B6C: 51 push ecx + E0009B6D: E8 F8 03 00 00 call E0009F6A + E0009B72: 83 C4 04 add esp,4 + E0009B75: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009B78: 8B E5 mov esp,ebp + E0009B7A: 5D pop ebp + E0009B7B: C2 04 00 ret 4 + E0009B7E: CC int 3 + E0009B7F: CC int 3 +?QueryInterface@CSerialPort@@W3AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CSerialPort::QueryInterface`adjustor{4}' (struct _GUID const &,void * *)): + E0009B80: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0009B85: E9 71 FD FF FF jmp E00098FB + E0009B8A: CC int 3 + E0009B8B: CC int 3 + E0009B8C: CC int 3 + E0009B8D: CC int 3 + E0009B8E: CC int 3 + E0009B8F: CC int 3 +?AddRef@CSerialPort@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CSerialPort::AddRef`adjustor{4}' (void)): + E0009B90: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0009B95: E9 36 FF FF FF jmp E0009AD0 + E0009B9A: CC int 3 + E0009B9B: CC int 3 + E0009B9C: CC int 3 + E0009B9D: CC int 3 + E0009B9E: CC int 3 + E0009B9F: CC int 3 +?Release@CSerialPort@@W3AAKXZ ([thunk]:public: virtual unsigned long __cdecl CSerialPort::Release`adjustor{4}' (void)): + E0009BA0: 83 6C 24 04 04 sub dword ptr [esp+4],4 + E0009BA5: E9 46 FF FF FF jmp E0009AF0 + E0009BAA: CC int 3 + E0009BAB: CC int 3 + E0009BAC: CC int 3 + E0009BAD: CC int 3 + E0009BAE: CC int 3 + E0009BAF: CC int 3 +?QueryInterface@CSerialPort@@W7AAKABU_GUID@@PAPAX@Z ([thunk]:public: virtual unsigned long __cdecl CSerialPort::QueryInterface`adjustor{8}' (struct _GUID const &,void * *)): + E0009BB0: 83 6C 24 04 08 sub dword ptr [esp+4],8 + E0009BB5: E9 41 FD FF FF jmp E00098FB + E0009BBA: CC int 3 + E0009BBB: CC int 3 + E0009BBC: CC int 3 + E0009BBD: CC int 3 + E0009BBE: CC int 3 + E0009BBF: CC int 3 +?AddRef@CSerialPort@@W7AAKXZ ([thunk]:public: virtual unsigned long __cdecl CSerialPort::AddRef`adjustor{8}' (void)): + E0009BC0: 83 6C 24 04 08 sub dword ptr [esp+4],8 + E0009BC5: E9 06 FF FF FF jmp E0009AD0 + E0009BCA: CC int 3 + E0009BCB: CC int 3 + E0009BCC: CC int 3 + E0009BCD: CC int 3 + E0009BCE: CC int 3 + E0009BCF: CC int 3 +?Release@CSerialPort@@W7AAKXZ ([thunk]:public: virtual unsigned long __cdecl CSerialPort::Release`adjustor{8}' (void)): + E0009BD0: 83 6C 24 04 08 sub dword ptr [esp+4],8 + E0009BD5: E9 16 FF FF FF jmp E0009AF0 + E0009BDA: CC int 3 + E0009BDB: CC int 3 + E0009BDC: CC int 3 + E0009BDD: CC int 3 + E0009BDE: CC int 3 + E0009BDF: CC int 3 +??0CTextConsole@@QAE@XZ (public: __thiscall CTextConsole::CTextConsole(void)): + E0009BE0: 55 push ebp + E0009BE1: 8B EC mov ebp,esp + E0009BE3: 51 push ecx + E0009BE4: 89 4D FC mov dword ptr [ebp-4],ecx + E0009BE7: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0009BEA: E8 11 8D FF FF call E0002900 + E0009BEF: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009BF2: C7 00 88 A7 00 E0 mov dword ptr [eax],0E000A788h + E0009BF8: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0009BFB: C7 41 04 70 A7 00 mov dword ptr [ecx+4],0E000A770h + E0 + E0009C02: 8B 55 FC mov edx,dword ptr [ebp-4] + E0009C05: C7 42 1C 00 80 0B mov dword ptr [edx+1Ch],0B8000h + 00 + E0009C0C: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009C0F: 66 C7 40 10 50 00 mov word ptr [eax+10h],50h + E0009C15: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0009C18: 66 C7 41 12 19 00 mov word ptr [ecx+12h],19h + E0009C1E: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009C21: 8B E5 mov esp,ebp + E0009C23: 5D pop ebp + E0009C24: C3 ret +?UpdateCursor@CTextConsole@@MAEXXZ (protected: virtual void __thiscall CTextConsole::UpdateCursor(void)): + E0009C25: 55 push ebp + E0009C26: 8B EC mov ebp,esp + E0009C28: 83 EC 28 sub esp,28h + E0009C2B: 53 push ebx + E0009C2C: 56 push esi + E0009C2D: 57 push edi + E0009C2E: 89 4D D8 mov dword ptr [ebp-28h],ecx + E0009C31: 8B 45 D8 mov eax,dword ptr [ebp-28h] + E0009C34: 33 C9 xor ecx,ecx + E0009C36: 66 8B 48 0E mov cx,word ptr [eax+0Eh] + E0009C3A: 8B 55 D8 mov edx,dword ptr [ebp-28h] + E0009C3D: 33 C0 xor eax,eax + E0009C3F: 66 8B 42 10 mov ax,word ptr [edx+10h] + E0009C43: 0F AF C8 imul ecx,eax + E0009C46: 8B 55 D8 mov edx,dword ptr [ebp-28h] + E0009C49: 33 C0 xor eax,eax + E0009C4B: 66 8B 42 0C mov ax,word ptr [edx+0Ch] + E0009C4F: 03 C8 add ecx,eax + E0009C51: D1 E1 shl ecx,1 + E0009C53: 66 89 4D FC mov word ptr [ebp-4],cx + E0009C57: C6 45 F4 0E mov byte ptr [ebp-0Ch],0Eh + E0009C5B: 66 C7 45 F8 D4 03 mov word ptr [ebp-8],3D4h + E0009C61: 66 8B 55 F8 mov dx,word ptr [ebp-8] + E0009C65: 8A 45 F4 mov al,byte ptr [ebp-0Ch] + E0009C68: EE out dx,al + E0009C69: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0009C6C: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0009C72: C1 F9 09 sar ecx,9 + E0009C75: 88 4D EC mov byte ptr [ebp-14h],cl + E0009C78: 66 C7 45 F0 D5 03 mov word ptr [ebp-10h],3D5h + E0009C7E: 66 8B 55 F0 mov dx,word ptr [ebp-10h] + E0009C82: 8A 45 EC mov al,byte ptr [ebp-14h] + E0009C85: EE out dx,al + E0009C86: C6 45 E4 0F mov byte ptr [ebp-1Ch],0Fh + E0009C8A: 66 C7 45 E8 D4 03 mov word ptr [ebp-18h],3D4h + E0009C90: 66 8B 55 E8 mov dx,word ptr [ebp-18h] + E0009C94: 8A 45 E4 mov al,byte ptr [ebp-1Ch] + E0009C97: EE out dx,al + E0009C98: 8B 55 FC mov edx,dword ptr [ebp-4] + E0009C9B: 81 E2 FF FF 00 00 and edx,0FFFFh + E0009CA1: D1 FA sar edx,1 + E0009CA3: 88 55 DC mov byte ptr [ebp-24h],dl + E0009CA6: 66 C7 45 E0 D5 03 mov word ptr [ebp-20h],3D5h + E0009CAC: 66 8B 55 E0 mov dx,word ptr [ebp-20h] + E0009CB0: 8A 45 DC mov al,byte ptr [ebp-24h] + E0009CB3: EE out dx,al + E0009CB4: 5F pop edi + E0009CB5: 5E pop esi + E0009CB6: 5B pop ebx + E0009CB7: 8B E5 mov esp,ebp + E0009CB9: 5D pop ebp + E0009CBA: C3 ret +?Output@CTextConsole@@MAEXHHGG@Z (protected: virtual void __thiscall CTextConsole::Output(int,int,unsigned short,unsigned short)): + E0009CBB: 55 push ebp + E0009CBC: 8B EC mov ebp,esp + E0009CBE: 51 push ecx + E0009CBF: 89 4D FC mov dword ptr [ebp-4],ecx + E0009CC2: 8B 45 10 mov eax,dword ptr [ebp+10h] + E0009CC5: 25 FF FF 00 00 and eax,0FFFFh + E0009CCA: 8B 4D 14 mov ecx,dword ptr [ebp+14h] + E0009CCD: 81 E1 FF FF 00 00 and ecx,0FFFFh + E0009CD3: 0B C1 or eax,ecx + E0009CD5: 8B 55 FC mov edx,dword ptr [ebp-4] + E0009CD8: 33 C9 xor ecx,ecx + E0009CDA: 66 8B 4A 10 mov cx,word ptr [edx+10h] + E0009CDE: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0009CE1: 0F AF D1 imul edx,ecx + E0009CE4: 03 55 08 add edx,dword ptr [ebp+8] + E0009CE7: 8B 4D FC mov ecx,dword ptr [ebp-4] + E0009CEA: 8B 49 1C mov ecx,dword ptr [ecx+1Ch] + E0009CED: 66 89 04 51 mov word ptr [ecx+edx*2],ax + E0009CF1: 8B E5 mov esp,ebp + E0009CF3: 5D pop ebp + E0009CF4: C2 10 00 ret 10h +?Clear@CTextConsole@@MAEXXZ (protected: virtual void __thiscall CTextConsole::Clear(void)): + E0009CF7: 55 push ebp + E0009CF8: 8B EC mov ebp,esp + E0009CFA: 83 EC 14 sub esp,14h + E0009CFD: 53 push ebx + E0009CFE: 56 push esi + E0009CFF: 57 push edi + E0009D00: 89 4D EC mov dword ptr [ebp-14h],ecx + E0009D03: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0009D06: 33 C9 xor ecx,ecx + E0009D08: 66 8B 48 18 mov cx,word ptr [eax+18h] + E0009D0C: 83 C9 20 or ecx,20h + E0009D0F: 66 89 4D FC mov word ptr [ebp-4],cx + E0009D13: 8B 55 EC mov edx,dword ptr [ebp-14h] + E0009D16: 66 C7 42 0E 00 00 mov word ptr [edx+0Eh],0 + E0009D1C: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0009D1F: 66 C7 40 0C 00 00 mov word ptr [eax+0Ch],0 + E0009D25: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0009D28: 33 D2 xor edx,edx + E0009D2A: 66 8B 51 10 mov dx,word ptr [ecx+10h] + E0009D2E: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0009D31: 33 C9 xor ecx,ecx + E0009D33: 66 8B 48 12 mov cx,word ptr [eax+12h] + E0009D37: 0F AF D1 imul edx,ecx + E0009D3A: D1 E2 shl edx,1 + E0009D3C: 89 55 F0 mov dword ptr [ebp-10h],edx + E0009D3F: 8B 55 FC mov edx,dword ptr [ebp-4] + E0009D42: 81 E2 FF FF 00 00 and edx,0FFFFh + E0009D48: C1 E2 10 shl edx,10h + E0009D4B: 8B 45 FC mov eax,dword ptr [ebp-4] + E0009D4E: 25 FF FF 00 00 and eax,0FFFFh + E0009D53: 0B D0 or edx,eax + E0009D55: 89 55 F4 mov dword ptr [ebp-0Ch],edx + E0009D58: 8B 4D EC mov ecx,dword ptr [ebp-14h] + E0009D5B: 8B 51 1C mov edx,dword ptr [ecx+1Ch] + E0009D5E: 89 55 F8 mov dword ptr [ebp-8],edx + E0009D61: 8B 45 F0 mov eax,dword ptr [ebp-10h] + E0009D64: C1 E8 02 shr eax,2 + E0009D67: 89 45 F0 mov dword ptr [ebp-10h],eax + E0009D6A: 8B 4D F0 mov ecx,dword ptr [ebp-10h] + E0009D6D: 8B 45 F4 mov eax,dword ptr [ebp-0Ch] + E0009D70: 8B 7D F8 mov edi,dword ptr [ebp-8] + E0009D73: FC cld + E0009D74: F3 AB rep stos dword ptr es:[edi] + E0009D76: 5F pop edi + E0009D77: 5E pop esi + E0009D78: 5B pop ebx + E0009D79: 8B E5 mov esp,ebp + E0009D7B: 5D pop ebp + E0009D7C: C3 ret +?Scroll@CTextConsole@@MAEXHH@Z (protected: virtual void __thiscall CTextConsole::Scroll(int,int)): + E0009D7D: 55 push ebp + E0009D7E: 8B EC mov ebp,esp + E0009D80: 83 EC 1C sub esp,1Ch + E0009D83: 53 push ebx + E0009D84: 56 push esi + E0009D85: 57 push edi + E0009D86: 89 4D E4 mov dword ptr [ebp-1Ch],ecx + E0009D89: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0009D8C: 33 C9 xor ecx,ecx + E0009D8E: 66 8B 48 10 mov cx,word ptr [eax+10h] + E0009D92: D1 E1 shl ecx,1 + E0009D94: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0009D97: 33 C0 xor eax,eax + E0009D99: 66 8B 42 12 mov ax,word ptr [edx+12h] + E0009D9D: 03 45 0C add eax,dword ptr [ebp+0Ch] + E0009DA0: 0F AF C8 imul ecx,eax + E0009DA3: 89 4D F4 mov dword ptr [ebp-0Ch],ecx + E0009DA6: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0009DA9: 33 D2 xor edx,edx + E0009DAB: 66 8B 51 10 mov dx,word ptr [ecx+10h] + E0009DAF: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0009DB2: 0F AF C2 imul eax,edx + E0009DB5: D1 E0 shl eax,1 + E0009DB7: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0009DBA: 8B 51 1C mov edx,dword ptr [ecx+1Ch] + E0009DBD: 2B D0 sub edx,eax + E0009DBF: 89 55 F8 mov dword ptr [ebp-8],edx + E0009DC2: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0009DC5: 8B 48 1C mov ecx,dword ptr [eax+1Ch] + E0009DC8: 89 4D FC mov dword ptr [ebp-4],ecx + E0009DCB: 8B 55 F4 mov edx,dword ptr [ebp-0Ch] + E0009DCE: C1 EA 02 shr edx,2 + E0009DD1: 89 55 F4 mov dword ptr [ebp-0Ch],edx + E0009DD4: 8B 7D FC mov edi,dword ptr [ebp-4] + E0009DD7: 8B 75 F8 mov esi,dword ptr [ebp-8] + E0009DDA: 8B 4D F4 mov ecx,dword ptr [ebp-0Ch] + E0009DDD: F2 A5 repne movs dword ptr es:[edi],dword ptr [esi] + E0009DDF: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0009DE2: 33 C9 xor ecx,ecx + E0009DE4: 66 8B 48 10 mov cx,word ptr [eax+10h] + E0009DE8: D1 E1 shl ecx,1 + E0009DEA: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0009DED: F7 DA neg edx + E0009DEF: 0F AF CA imul ecx,edx + E0009DF2: 89 4D E8 mov dword ptr [ebp-18h],ecx + E0009DF5: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0009DF8: 33 C9 xor ecx,ecx + E0009DFA: 66 8B 48 18 mov cx,word ptr [eax+18h] + E0009DFE: 83 C9 20 or ecx,20h + E0009E01: C1 E1 10 shl ecx,10h + E0009E04: 8B 55 E4 mov edx,dword ptr [ebp-1Ch] + E0009E07: 33 C0 xor eax,eax + E0009E09: 66 8B 42 18 mov ax,word ptr [edx+18h] + E0009E0D: 0B C8 or ecx,eax + E0009E0F: 83 C9 20 or ecx,20h + E0009E12: 89 4D EC mov dword ptr [ebp-14h],ecx + E0009E15: 8B 4D E4 mov ecx,dword ptr [ebp-1Ch] + E0009E18: 33 D2 xor edx,edx + E0009E1A: 66 8B 51 10 mov dx,word ptr [ecx+10h] + E0009E1E: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0009E21: 33 C9 xor ecx,ecx + E0009E23: 66 8B 48 12 mov cx,word ptr [eax+12h] + E0009E27: 03 4D 0C add ecx,dword ptr [ebp+0Ch] + E0009E2A: 0F AF D1 imul edx,ecx + E0009E2D: 8B 45 E4 mov eax,dword ptr [ebp-1Ch] + E0009E30: 8B 48 1C mov ecx,dword ptr [eax+1Ch] + E0009E33: 8D 14 51 lea edx,dword ptr [ecx+edx*2] + E0009E36: 89 55 F0 mov dword ptr [ebp-10h],edx + E0009E39: 8B 45 E8 mov eax,dword ptr [ebp-18h] + E0009E3C: C1 E8 02 shr eax,2 + E0009E3F: 89 45 E8 mov dword ptr [ebp-18h],eax + E0009E42: 8B 4D E8 mov ecx,dword ptr [ebp-18h] + E0009E45: 8B 45 EC mov eax,dword ptr [ebp-14h] + E0009E48: 8B 7D F0 mov edi,dword ptr [ebp-10h] + E0009E4B: FC cld + E0009E4C: F3 AB rep stos dword ptr es:[edi] + E0009E4E: 5F pop edi + E0009E4F: 5E pop esi + E0009E50: 5B pop ebx + E0009E51: 8B E5 mov esp,ebp + E0009E53: 5D pop ebp + E0009E54: C2 08 00 ret 8 + E0009E57: CC int 3 + E0009E58: CC int 3 + E0009E59: CC int 3 + E0009E5A: CC int 3 + E0009E5B: CC int 3 + E0009E5C: CC int 3 + E0009E5D: CC int 3 + E0009E5E: CC int 3 + E0009E5F: CC int 3 +_wildcard: + E0009E60: 55 push ebp + E0009E61: 8B EC mov ebp,esp + E0009E63: 8B 45 0C mov eax,dword ptr [ebp+0Ch] + E0009E66: 33 C9 xor ecx,ecx + E0009E68: 66 8B 08 mov cx,word ptr [eax] + E0009E6B: 85 C9 test ecx,ecx + E0009E6D: 0F 84 82 00 00 00 je E0009EF5 + E0009E73: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0009E76: 33 C0 xor eax,eax + E0009E78: 66 8B 02 mov ax,word ptr [edx] + E0009E7B: 83 F8 2A cmp eax,2Ah + E0009E7E: 75 46 jne E0009EC6 + E0009E80: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0009E83: 83 C1 02 add ecx,2 + E0009E86: 89 4D 0C mov dword ptr [ebp+0Ch],ecx + E0009E89: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0009E8C: 33 C0 xor eax,eax + E0009E8E: 66 8B 02 mov ax,word ptr [edx] + E0009E91: 85 C0 test eax,eax + E0009E93: 75 04 jne E0009E99 + E0009E95: B0 01 mov al,1 + E0009E97: EB 5E jmp E0009EF7 + E0009E99: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0009E9C: 33 D2 xor edx,edx + E0009E9E: 66 8B 11 mov dx,word ptr [ecx] + E0009EA1: 85 D2 test edx,edx + E0009EA3: 74 1F je E0009EC4 + E0009EA5: 8B 45 08 mov eax,dword ptr [ebp+8] + E0009EA8: 33 C9 xor ecx,ecx + E0009EAA: 66 8B 08 mov cx,word ptr [eax] + E0009EAD: 8B 55 0C mov edx,dword ptr [ebp+0Ch] + E0009EB0: 33 C0 xor eax,eax + E0009EB2: 66 8B 02 mov ax,word ptr [edx] + E0009EB5: 3B C8 cmp ecx,eax + E0009EB7: 74 0B je E0009EC4 + E0009EB9: 8B 4D 08 mov ecx,dword ptr [ebp+8] + E0009EBC: 83 C1 02 add ecx,2 + E0009EBF: 89 4D 08 mov dword ptr [ebp+8],ecx + E0009EC2: EB D5 jmp E0009E99 + E0009EC4: EB 18 jmp E0009EDE + E0009EC6: 8B 55 08 mov edx,dword ptr [ebp+8] + E0009EC9: 33 C0 xor eax,eax + E0009ECB: 66 8B 02 mov ax,word ptr [edx] + E0009ECE: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0009ED1: 33 D2 xor edx,edx + E0009ED3: 66 8B 11 mov dx,word ptr [ecx] + E0009ED6: 3B C2 cmp eax,edx + E0009ED8: 74 04 je E0009EDE + E0009EDA: 32 C0 xor al,al + E0009EDC: EB 19 jmp E0009EF7 + E0009EDE: 8B 45 08 mov eax,dword ptr [ebp+8] + E0009EE1: 83 C0 02 add eax,2 + E0009EE4: 89 45 08 mov dword ptr [ebp+8],eax + E0009EE7: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch] + E0009EEA: 83 C1 02 add ecx,2 + E0009EED: 89 4D 0C mov dword ptr [ebp+0Ch],ecx + E0009EF0: E9 6E FF FF FF jmp E0009E63 + E0009EF5: B0 01 mov al,1 + E0009EF7: 5D pop ebp + E0009EF8: C3 ret + E0009EF9: CC int 3 + E0009EFA: CC int 3 + E0009EFB: CC int 3 + E0009EFC: CC int 3 + E0009EFD: CC int 3 + E0009EFE: CC int 3 + E0009EFF: CC int 3 +__DllMainCRTStartup@12: + E0009F00: 55 push ebp + E0009F01: 8B EC mov ebp,esp + E0009F03: B0 01 mov al,1 + E0009F05: 5D pop ebp + E0009F06: C2 0C 00 ret 0Ch + E0009F09: CC int 3 +_wcscpy: + E0009F0A: FF 25 E8 D0 00 E0 jmp dword ptr ds:[E000D0E8h] +_wprintf: + E0009F10: FF 25 CC D0 00 E0 jmp dword ptr ds:[E000D0CCh] +_sysUpTime: + E0009F16: FF 25 D0 D0 00 E0 jmp dword ptr ds:[E000D0D0h] +__cputws: + E0009F1C: FF 25 D4 D0 00 E0 jmp dword ptr ds:[E000D0D4h] +_sysExtRegisterDevice: + E0009F22: FF 25 D8 D0 00 E0 jmp dword ptr ds:[E000D0D8h] +_wcscat: + E0009F28: FF 25 DC D0 00 E0 jmp dword ptr ds:[E000D0DCh] +_sysRegisterIrq: + E0009F2E: FF 25 E0 D0 00 E0 jmp dword ptr ds:[E000D0E0h] +_wcsicmp: + E0009F34: FF 25 E4 D0 00 E0 jmp dword ptr ds:[E000D0E4h] +_wcscmp: + E0009F3A: FF 25 C8 D0 00 E0 jmp dword ptr ds:[E000D0C8h] +_malloc: + E0009F40: FF 25 EC D0 00 E0 jmp dword ptr ds:[E000D0ECh] +_free: + E0009F46: FF 25 F0 D0 00 E0 jmp dword ptr ds:[E000D0F0h] +_wcslen: + E0009F4C: FF 25 F4 D0 00 E0 jmp dword ptr ds:[E000D0F4h] +_sysOpen: + E0009F52: FF 25 F8 D0 00 E0 jmp dword ptr ds:[E000D0F8h] +_sysMount: + E0009F58: FF 25 FC D0 00 E0 jmp dword ptr ds:[E000D0FCh] +_mbstowcs: + E0009F5E: FF 25 00 D1 00 E0 jmp dword ptr ds:[E000D100h] +__purecall: + E0009F64: FF 25 08 D1 00 E0 jmp dword ptr ds:[E000D108h] +??3@YAXPAX@Z (void __cdecl operator delete(void *)): + E0009F6A: FF 25 0C D1 00 E0 jmp dword ptr ds:[E000D10Ch] +_swprintf: + E0009F70: FF 25 10 D1 00 E0 jmp dword ptr ds:[E000D110h] +??2@YAPAXI@Z (void * __cdecl operator new(unsigned int)): + E0009F76: FF 25 14 D1 00 E0 jmp dword ptr ds:[E000D114h] +_wcstol: + E0009F7C: FF 25 18 D1 00 E0 jmp dword ptr ds:[E000D118h] +_towlower: + E0009F82: FF 25 1C D1 00 E0 jmp dword ptr ds:[E000D11Ch] +_iswupper: + E0009F88: FF 25 20 D1 00 E0 jmp dword ptr ds:[E000D120h] +_wcschr: + E0009F8E: FF 25 24 D1 00 E0 jmp dword ptr ds:[E000D124h] +_wcsncpy: + E0009F94: FF 25 28 D1 00 E0 jmp dword ptr ds:[E000D128h] +_fsOpen: + E0009F9A: FF 25 2C D1 00 E0 jmp dword ptr ds:[E000D12Ch] +_wcsdup: + E0009FA0: FF 25 30 D1 00 E0 jmp dword ptr ds:[E000D130h] +_memmove: + E0009FA6: FF 25 34 D1 00 E0 jmp dword ptr ds:[E000D134h] +_towupper: + E0009FAC: FF 25 38 D1 00 E0 jmp dword ptr ds:[E000D138h] +_iswlower: + E0009FB2: FF 25 3C D1 00 E0 jmp dword ptr ds:[E000D13Ch] +_putwchar: + E0009FB8: FF 25 40 D1 00 E0 jmp dword ptr ds:[E000D140h] +__wgetch: + E0009FBE: FF 25 44 D1 00 E0 jmp dword ptr ds:[E000D144h] +__kbhit: + E0009FC4: FF 25 48 D1 00 E0 jmp dword ptr ds:[E000D148h] +_libc_init: + E0009FCA: FF 25 4C D1 00 E0 jmp dword ptr ds:[E000D14Ch] + + Summary + + 2000 .data + 1000 .idata + 1000 .info + 1000 .rdata + 1000 .reloc + 1000 .rsrc + 9000 .text diff --git a/mobius/src/drivers/kdll/main.cpp b/mobius/src/drivers/kdll/main.cpp new file mode 100644 index 0000000..6d022b8 --- /dev/null +++ b/mobius/src/drivers/kdll/main.cpp @@ -0,0 +1,211 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "ne2000.h" + +#include "pci.h" +#include "config.h" + +IFolder *root, *devices; +dword pick_timeout; + +extern "C" +{ + +void msleep(dword ms) +{ + dword end; + + end = sysUpTime() + ms; + while (sysUpTime() < end) + ; + + /*__asm + { + mov eax, 100h + mov ebx, ms + int 30h + }*/ +} + +void insw(unsigned short _port, unsigned short *_buf, unsigned _len) +{ + __asm + { + movzx edx, _port + mov edi, _buf + mov ecx, _len + cld + rep insw + } +} + +} + +extern "C" +{ + bool libc_init(); + void libc_exit(); + IFolder* Folder_Create(); + IFolder* FatRoot_Create(IBlockDevice* pDevice); + IFolder* RamDisk_Create(); + IDevice* Serial_Create(word base, byte irq); +} + +#define CLRSCR L"\x1b[2J" + +void DisplayConfigMenu() +{ + config_t* cfg; + int y = 6; + + //_cputws(CLRSCR); + _cputws(L"\x1b[3;8HThe M�bius -- Configuration Menu"); + + for (cfg = cfg_first; cfg; cfg = cfg->next) + { + if (cfg == cfg_current) + _cputws(L"\x1b[30;47m"); + else + _cputws(L"\x1b[37;40m"); + + wprintf(L"\x1b[%d;10H %s ", y, cfg->name); + y += 2; + } + + y += 4; + _cputws(L"\x1b[37;40m"); + wprintf(L"\x1b[%d;8HChoose the required " + L"\x1b[%d;8H configuration with the arrow " + L"\x1b[%d;8H keys and press Enter. ", y, y + 1, y + 2); +} + +bool PickConfigMenu() +{ + wint_t ch; + dword now, old_secs = 0; + + while (1) + { + while (!_kbhit()) + { + if (pick_timeout != (dword) -1) + { + now = sysUpTime(); + + if (now >= pick_timeout) + return true; + + if (old_secs != (pick_timeout - now) / 1000) + { + old_secs = (pick_timeout - now) / 1000; + wprintf(L"\x1b[0;75H%4d", old_secs); + } + } + } + + pick_timeout = (dword) -1; + switch ((ch = _wgetch())) + { + case KEY_UP: + cfg_current = cfg_current->prev; + if (!cfg_current) + cfg_current = cfg_last; + return false; + + case KEY_DOWN: + cfg_current = cfg_current->next; + if (!cfg_current) + cfg_current = cfg_first; + return false; + + case '\n': + return true; + + default: + if (ch <= 0xffff) + { + putwchar(ch); + putwchar('\b'); + } + break; + } + } +} + +#pragma data_seg(".info") +module_info_t __declspec(allocate(".info")) _info; +#pragma data_seg() + +extern "C" bool STDCALL drvInit() +{ + IDevice* ne2000; + IFolder* ram; + config_t *cfg, *next; + + __asm + { + mov eax, [_info] + mov [_info], eax + } + + root = Folder_Create(); + thrGetInfo()->process->root = root; + sysMount(L"root", (IUnknown*) root); + + ram = RamDisk_Create(); + root->Mount(L"boot", (IUnknown*) ram); + + devices = Folder_Create(); + sysMount(L"devmgr", (IUnknown*) devices); + root->Mount(L"devices", (IUnknown*) devices); + + libc_init(); + //ProcessKernelRc(); + + if (cfg_first->next) + { + pick_timeout = sysUpTime() + cfg_current->timeout; + + do + { + DisplayConfigMenu(); + } while (!PickConfigMenu()); + + _cputws(CLRSCR); + } + + /*if (cfg_current->display == config_t::dispGui) + { + + + libc_exit(); + libc_init(); + }*/ + + _cputws_check(L" \n" CHECK_L2 L"NE2000 card\r\t"); + ne2000 = CNe2000::Detect(); + if (ne2000) + sysExtRegisterDevice(L"ne2000", ne2000); + + _cputws_check(L" \n" CHECK_L2 L"Serial ports\r\t"); + sysExtRegisterDevice(L"serial0", Serial_Create(0x3f8, 4)); + sysExtRegisterDevice(L"serial1", Serial_Create(0x2f8, 3)); + + for (cfg = cfg_first; cfg; cfg = next) + { + next = cfg->next; + free(cfg); + } + + cfg_first = cfg_last = cfg_current = NULL; + return true; +} \ No newline at end of file diff --git a/mobius/src/drivers/kdll/ne2000.cpp b/mobius/src/drivers/kdll/ne2000.cpp new file mode 100644 index 0000000..e8a5919 --- /dev/null +++ b/mobius/src/drivers/kdll/ne2000.cpp @@ -0,0 +1,579 @@ +// Ne2000.cpp: implementation of the CNe2000 class. +// +////////////////////////////////////////////////////////////////////// + +#include "Ne2000.h" +#include +#include +#include + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CNe2000::CNe2000(word port) : m_port(port) +{ + byte prom[16]; + int f; + + memset(&m_stat, 0, sizeof(m_stat)); + m_pstart=0; + m_pstop=0; + m_wordlength=0; + m_current_page=0; + //m_notify=NULL; + for(f=0;fm_port, NIC_DMA_DISABLE | NIC_PAGE0); + overload=MAX_LOAD+1; + while ((isr=in(nic->m_port + INTERRUPTSTATUS))) + { + if((--overload)<=0) + break; + + if(isr & ISR_OVW) + nic->Overrun(); + else if(isr & (ISR_PRX | ISR_RXE)) + nic->Receive(); + + if(isr & ISR_PTX) + nic->Transmit(); + else if(isr & ISR_TXE) + nic->TransmitError(); + + if(isr & ISR_CNT) + nic->Counters(); + if(isr & ISR_RDC) + out(nic->m_port + INTERRUPTSTATUS, ISR_RDC); + + out(nic->m_port, NIC_DMA_DISABLE | NIC_PAGE0 | NIC_START); + } + + if(isr) + { + out(nic->m_port, NIC_DMA_DISABLE | NIC_PAGE0 | NIC_START); + + if(!overload) + { + wprintf(L"NE2000: Too many requests in ISR. ISR:%X MaxLoad:%X\n", + isr, MAX_LOAD); + out(nic->m_port + INTERRUPTSTATUS, ISR_ALL); // clear + } else { + wprintf(L"NE2000: Unhandeled interrupt, ISR:%X\n",isr); + out(nic->m_port + INTERRUPTSTATUS, 0xff); + // Ack it anyway + } + } +} + +static unsigned int default_ports[] = { 0x300, 0x280, 0x320, 0x340, 0x360 }; + +CNe2000* CNe2000::Detect() +{ + byte state, regd; + int i; + word port; + + for (i = 0; i < countof(default_ports); i++) + { + port = default_ports[i]; + + state = in(port); + if (in(port) == 0xff) + wprintf(L"No NE2000 card found on port %x\n", port); + else + { + out(port, NIC_DMA_DISABLE | NIC_PAGE1 | NIC_STOP); + regd = in(port + 0x0d); + out(port + 0x0d, 0xff); + out(port, NIC_DMA_DISABLE | NIC_PAGE0); + in(port + FAE_TALLY); /* reading CNTR0 resets it.*/ + + if (in(port + FAE_TALLY)) + { + /* counter didn't clear so probe fails*/ + out(port, state); /* restore command state*/ + out(port + 0x0d, regd); + wprintf(L"NE2000 failure on port %x\n", port); + } + else + { + wprintf(L"NE2000 card found on port %x\n", port); + return new CNe2000(port); + } + } + } + + return NULL; +} + +/* dumps the prom into a 16 byte buffer and returns the wordlength of +// the card. +// You should be able to make this procedure a wrapper of nic_block_input(). */ +int CNe2000::DumpProm(byte *prom) +{ + dword f; + char wordlength=2; /* default wordlength of 2 */ + unsigned char dump[32]; + out(m_port + REMOTEBYTECOUNT0, 32); /* read 32 bytes from DMA->IO */ + out(m_port + REMOTEBYTECOUNT1, 0); /* this is for the PROM dump */ + out(m_port + REMOTESTARTADDRESS0, 0); /* configure DMA for 0x0000 */ + out(m_port + REMOTESTARTADDRESS1, 0); + out(m_port, NIC_REM_READ | NIC_START); + for(f=0;f<32;f+=2) { + dump[f]=in(m_port + NE_DATA); + dump[f+1]=in(m_port + NE_DATA); + if(dump[f]!=dump[f+1]) wordlength=1; + } + /* if wordlength is 2 bytes, then collapse prom to 16 bytes */ + for(f=0;f>1);f++) + ((unsigned short *)header)[f]=in16(m_port+NE_DATA); + else for(f=0;f> 8); + out(m_port + REMOTESTARTADDRESS0, offset & 0xff); + out(m_port + REMOTESTARTADDRESS1, offset >> 8); + out(m_port, NIC_REM_READ | NIC_START); + + /* allow for no buffer */ + if(buf){ + if(m_wordlength==2) { + for(f=0;f<(len>>1);f++) + ((unsigned short *)buf)[f]=in16(m_port+NE_DATA); + if(len&0x01) { + ((unsigned char *)buf)[len-1]=in(m_port+NE_DATA); + xfers++; + } + } else { + for(f=0;f>1);f++) + in16(m_port+NE_DATA); + if(len&0x01) { + in(m_port+NE_DATA); + xfers++; + } + } else { + for(f=0;f=timeout) + kprintf("NE2000: Remote DMA address invalid. expected:%x - actual:%x\n", + offset+xfers, addr); HUH WHAT? BJS*/ + + out(m_port + INTERRUPTSTATUS, ISR_RDC); /* finish DMA cycle */ +} + +void CNe2000::Receive() +{ + dword packets=0; dword frame; dword rx_page; dword rx_offset; + dword len; dword next_pkt; dword numpages; + buffer_header_t header; + while(packets=m_pstop) frame=m_pstart+TXPAGES; + /* circual buffer */ + + if(frame != m_current_page) { + wprintf(L"NE2000: ERROR: mismatched read page pointers!\n"); + wprintf(L"NE2000: NIC-Boundary:%x dev-current_page:%x\n", + frame, m_current_page); } + +/* wprintf(L"Boundary-%x Current-%x\n",frame-1,rx_page); */ + if(frame==rx_page) break; /* all frames read */ + + rx_offset=frame << 8; /* current ptr in bytes(not pages) */ + + GetHeader(frame,&header); + len=header.count - sizeof(buffer_header_t); + /* length of packet */ + next_pkt=frame + 1 + ((len+4)>>8); /* next packet frame */ + + numpages=m_pstop-(m_pstart+TXPAGES); + if( (header.next!=next_pkt) + && (header.next!=next_pkt + 1) + && (header.next!=next_pkt - numpages) + && (header.next != next_pkt +1 - numpages)){ + wprintf(L"NE2000: ERROR: Index mismatch. header.next:%X next_pkt:%X frame:%X\n", + header.next,next_pkt,frame); + m_current_page=frame; + out(m_port + BOUNDARY, m_current_page-1); + m_stat.errors.rx++; + continue; + } + + if(len<60 || len>1518) { + wprintf(L"NE2000: invalid packet size:%d\n",len); + m_stat.errors.rx_size++; + } else if((header.status & 0x0f) == RSR_PRX) { + /* We have a good packet, so let's recieve it! */ + + packet_data_t *newpacket=alloc_buffer_data(len); + if(!newpacket) { + wprintf(L"NE2000: ERROR: out of memory!\n"); + m_stat.errors.rx_dropped++; + BlockInput(NULL,len,rx_offset+ + sizeof(buffer_header_t)); + } else { + BlockInput(newpacket->ptr,newpacket->len, + rx_offset+sizeof(buffer_header_t)); + /* read it */ + + //if(m_notify) m_notify(m_kore,newpacket); + //else + free_buffer_data(newpacket); + /* NOTE: you are responsible for deleting this buffer. */ + + m_stat.rx_packets++; + } + } else { + wprintf(L"NE2000: ERROR: bad packet. header-> status:%X next:%X len:%x.\n", + header.status,header.next,header.count); + if(header.status & RSR_FO) m_stat.errors.rx_fifo++; + } +/* wprintf(L"frame:%x header.next:%x next_pkt:%x\n", + frame,header.next,next_pkt); */ + next_pkt=header.next; + + if(next_pkt >= m_pstop) { + wprintf(L"NE2000: ERROR: next frame beyond local buffer! next:%x.\n", + next_pkt); + next_pkt=m_pstart+TXPAGES; + } + + m_current_page=next_pkt; + out(m_port + BOUNDARY, next_pkt-1); + } + out(m_port + INTERRUPTSTATUS, ISR_PRX | ISR_RXE); /* ack int */ +} + +void CNe2000::Counters() +{ + m_stat.errors.frame_alignment+=in(m_port+FAE_TALLY); + m_stat.errors.crc+=in(m_port+CRC_TALLY); + m_stat.errors.missed_packets+=in(m_port+MISS_PKT_TALLY); + /* reading the counters on the DC8390 clears them. */ + out(m_port + INTERRUPTSTATUS, ISR_CNT); /* ackkowledge int */ +} + +int CNe2000::Send(dword buf) +{ + return 0; +} + +HRESULT CNe2000::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IDevice)) + { + *ppvObject = (IDevice*) this; + AddRef(); + return S_OK; + } + + return E_FAIL; +} + +HRESULT CNe2000::GetInfo(device_t* buf) +{ + if (buf->size < sizeof(device_t)) + return E_FAIL; + + wcsncpy(buf->name, L"NE2000-compatible network adapter", buf->name_max); + return S_OK; +} + +HRESULT CNe2000::DeviceOpen() +{ + return S_OK; +} \ No newline at end of file diff --git a/mobius/src/drivers/kdll/ne2000.h b/mobius/src/drivers/kdll/ne2000.h new file mode 100644 index 0000000..778d1b6 --- /dev/null +++ b/mobius/src/drivers/kdll/ne2000.h @@ -0,0 +1,231 @@ +// Ne2000.h: interface for the CNe2000 class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_NE2000_H__9F497E86_4CD1_4D0E_8D3E_195294B52FF8__INCLUDED_) +#define AFX_NE2000_H__9F497E86_4CD1_4D0E_8D3E_195294B52FF8__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#include +#include + +#define PSTART 0x20 /* if NE2000 is byte length */ +#define PSTOP 0x40 +#define PSTARTW 0x40 /* if NE2000 is wordlength */ +#define PSTOPW 0x80 +#define MAX_LOAD 12 /* maximum services per IRQ request*/ +#define MAX_RX 10 /* maximum packets recieve per call*/ +#define MIN_LENGTH 60 /* minimum length for packet data */ +#define MAX_LENGTH 1500 /* maximum length for packet data area */ +#define TIMEOUT_DMAMATCH 40 /* for nic_block_input() */ +#define TIMEOUT_TX 40 + +/* DP8390 NIC Registers*/ +#define COMMAND 0x00 +#define STATUS COMMAND+0 +#define PHYSICAL COMMAND+1 /* page 1 */ +#define MULTICAST COMMAND+8 /* page 1 */ +#define PAGESTART COMMAND+1 /* page 0 */ +#define PAGESTOP COMMAND+2 +#define BOUNDARY COMMAND+3 +#define TRANSMITSTATUS COMMAND+4 +#define TRANSMITPAGE COMMAND+4 +#define TRANSMITBYTECOUNT0 COMMAND+5 +#define NCR COMMAND+5 +#define TRANSMITBYTECOUNT1 COMMAND+6 +#define INTERRUPTSTATUS COMMAND+7 +#define CURRENT COMMAND+7 /* page 1 */ +#define REMOTESTARTADDRESS0 COMMAND+8 +#define CRDMA0 COMMAND+8 +#define REMOTESTARTADDRESS1 COMMAND+9 +#define CRDMA1 COMMAND+9 +#define REMOTEBYTECOUNT0 COMMAND+10 /* how many bytes we will */ +#define REMOTEBYTECOUNT1 COMMAND+11 /* read through remote DMA->IO */ +#define RECEIVESTATUS COMMAND+12 +#define RECEIVECONFIGURATION COMMAND+12 +#define TRANSMITCONFIGURATION COMMAND+13 +#define FAE_TALLY COMMAND+13 /* page 0 */ +#define DATACONFIGURATION COMMAND+14 +#define CRC_TALLY COMMAND+14 +#define INTERRUPTMASK COMMAND+15 +#define MISS_PKT_TALLY COMMAND+15 + +/* NE2000 specific implementation registers */ +#define NE_RESET 0x1f /* Reset */ +#define NE_DATA 0x10 /* Data port (use for PROM) */ + +#define PAR0 COMMAND+1 +#define PAR1 COMMAND+2 +#define PAR2 COMMAND+3 +#define PAR3 COMMAND+4 +#define PAR4 COMMAND+5 +#define PAR5 COMMAND+6 + +/* NIC Commands */ +#define NIC_STOP 0x01 /* STOP */ +#define NIC_START 0x02 /* START */ +#define NIC_PAGE0 0x00 +#define NIC_PAGE1 0x40 +#define NIC_PAGE2 0x80 +#define NIC_TRANSMIT 0x04 /* Transmit a frame */ +#define NIC_REM_READ 0x08 /* Remote Read */ +#define NIC_REM_WRITE 0x10 /* Remote Write */ +#define NIC_DMA_DISABLE 0x20 /* Disable DMA */ + +/* Data Configuration Register */ +#define DCR_WTS 0x01 /* Word Transfer Select (0=byte, 1=word) */ +#define DCR_BOS 0x02 /* Byte Order Select (0=big-endian) */ +#define DCR_LAS 0x04 /* Long Address Select (0=dual 16-bit DMA) */ +#define DCR_LS 0x08 /* Loopback Select (0=loopback) */ +#define DCR_AR 0x10 /* Auto Initialize Remote */ +#define DCR_FT 0x60 /* (FT0 & FT1) FIFO Threshhold (see datasheet) */ +/*#define DCR_DEFAULT 0x58 Standard value for the DCR register */ +#define DCR_DEFAULT 0x48 /* don't use Automatic send packet */ +#define DCR_DEFAULT_WORD 0x49 /* defuault with wold length transfer */ + +/* Recieve Configure Register */ +#define RCR_SEP 0x01 /* Save Errored Packets */ +#define RCR_AR 0x02 /* Accept Runt Packets */ +#define RCR_AB 0x04 /* Accept Broadcast */ +#define RCR_AM 0x08 /* Accept Multicast */ +#define RCR_PRO 0x10 /* Promiscuous Physical */ +#define RCR_MON 0x20 /* Monitor Mode */ +/*#define RCR_DEFAULT 0x00 Standard value for the RCR register */ +#define RCR_DEFAULT 0x0c /* Accept Broadcast/Multicast Packets */ + +/* Recieve Status Register */ +/* note, this is also stored in the status byte in the buffer header. */ +/* That's the 4 byte entry in the local buffer, not the packet header. */ +#define RSR_PRX 0x01 /* Pakcet Received Intact */ +#define RSR_CRC 0x02 /* CRC Error */ +#define RSR_FAE 0x04 /* Frame Alignment Error */ +#define RSR_FO 0x08 /* FIFO Overrun */ +#define RSR_MPA 0x10 /* Missed Packet */ +#define RSR_PHY 0x20 /* Physical/Multicast Address (0=physical) */ +#define RSR_DIS 0x40 /* Receiver Disabled */ +#define RSR_DFR 0x80 /* Deferring */ + +/* Transmit Configure Register */ +#define TCR_CRC 0x01 /* Inhibit CRC (0=CRC active) */ +#define TCR_LB 0x06 /* (LB0 & LB1) Encoded Loopback Control */ +#define TCR_ATD 0x08 /* Auto Transmit Disable (0=normal) */ +#define TCR_OFST 0x10 /* Collision Offset Enable (1=low priority) */ +#define TCR_DEFAULT 0x00 /* Standard value for the TCR register */ +#define TCR_INTERNAL_LOOPBACK 0x02 /* Internal loopback configuration */ + +/* Transmit Status Register */ +#define TSR_PTX 0x01 /* Packet Transmitted */ +#define TSR_ND 0x02 /* Non-Deferral (Documented???) */ +#define TSR_COL 0x04 /* Transmit Collided */ +#define TSR_ABT 0x08 /* Transmit Aborted */ +#define TSR_CRS 0x10 /* Carrier Sense Lost */ +#define TSR_FU 0x20 /* FIFO Underrun */ +#define TSR_CDH 0x40 /* CD Heartbeat */ +#define TSR_OWC 0x80 /* Oout of Window Collision */ + +/* Interrupt Status Register */ +#define ISR_PRX 0x01 /* Packet Received */ +#define ISR_PTX 0x02 /* Packet Transmitted */ +#define ISR_RXE 0x04 /* Receive Error */ +#define ISR_TXE 0x08 /* Transmit Error */ +#define ISR_OVW 0x10 /* Overwrite Warning */ +#define ISR_CNT 0x20 /* Counter Overflow */ +#define ISR_RDC 0x40 /* Remote DMA Complete */ +#define ISR_RST 0x80 /* Reset Status */ +#define ISR_DEFAULT 0x00 /* Standard value for the ISR register */ +#define ISR_ALL 0x3f /* The services that we handle in the isr */ + +/* Interrupt Mask Register */ +#define IMR_PRXE 0x01 /* Packet Received Interrupt Enable */ +#define IMR_PTXE 0x02 /* Packet Transmitted Interrupt Enable */ +#define IMR_RXEE 0x04 /* Receive Error Interrupt Enable */ +#define IMR_TXEE 0x08 /* Transmit Error Interrupt Enable */ +#define IMR_OVWE 0x10 /* Overwrite Warning Interrupt Enable */ +#define IMR_CNTE 0x20 /* Counter Overflow Interrupt Enable */ +#define IMR_RDCE 0x40 /* DMA Complete Interrupt Enable */ +#define IMR_DEFAULT 0x3f /* CNTE | OVWE | TXEE | RXEE | PTXE | PRXE */ + +struct packet_data_t { /* each protocol layer can add it's own */ + dword len; + byte *ptr; +}; + +struct packet_buffer_t { + dword page; + dword count, len; + packet_data_t *buf; /* An array of data segments */ +}; + +struct nic_error_stat_t { + long frame_alignment, crc, missed_packets; + long rx, rx_size, rx_dropped, rx_fifo, rx_overruns; + long tx_collisions; + long tx_aborts, tx_carrier, tx_fifo, tx_heartbeat, tx_window; +}; + +struct nic_stat_t { + long rx_packets; + long tx_buffered, tx_packets; + nic_error_stat_t errors; +}; + +struct buffer_header_t { + unsigned char status; + unsigned char next; + unsigned short count; /* length of header and packet */ +}; + +#define LEN_PROM 16 +#define MAX_TX 2 /* be careful with this (dual buffers) */ +#define MAX_PAGESPERPACKET 6 +#define TXPAGES (MAX_TX*MAX_PAGESPERPACKET) +#define LEN_ADDR 6 + +class CNe2000 : + public IUnknown, + public IDevice +{ +public: + CNe2000(word port); + virtual ~CNe2000(); + + static CNe2000* Detect(); + + // IUnknown methods + IMPLEMENT_IUNKNOWN(CNe2000); + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + + // IDevice methods + STDMETHOD(GetInfo)(device_t* buf); + STDMETHOD(DeviceOpen)(); + +protected: + word m_port; + int m_pstart, m_pstop, m_wordlength, m_current_page; + nic_stat_t m_stat; + //void (*notify)(void *passback, packet_data *newpacket); + //void *kore; /* Passback pointer */ + packet_buffer_t *m_tx_packet[MAX_TX], *m_last_tx; + int m_busy, m_send, m_sending; + + static void Isr(dword ctx, int irq); + + bool Init(byte *prom, byte *manual); + int DumpProm(byte *prom); + void Start(bool promiscuous); + + void Overrun(); + void Transmit(); + void TransmitError(); + void GetHeader(dword page, buffer_header_t *header); + void BlockInput(byte *buf, dword len, dword offset); + void Receive(); + void Counters(); + + int Send(dword buf); +}; + +#endif // !defined(AFX_NE2000_H__9F497E86_4CD1_4D0E_8D3E_195294B52FF8__INCLUDED_) diff --git a/mobius/src/drivers/kdll/pci.c b/mobius/src/drivers/kdll/pci.c new file mode 100644 index 0000000..56489ef --- /dev/null +++ b/mobius/src/drivers/kdll/pci.c @@ -0,0 +1,154 @@ +/* Copyright 1999, Brian J. Swetland. All rights reserved. +** Distributed under the terms of the OpenBLT License +*/ + +#include +#include +#include + +#include +#include "pci.h" + +typedef struct confadd +{ + byte reg:8; + byte func:3; + byte dev:5; + byte bus:8; + byte rsvd:7; + byte enable:1; +} confadd; + +dword pci_read(int bus, int dev, int func, int reg, int bytes) +{ + word base; + + union { + confadd c; + dword n; + } u; + + u.c.enable = 1; + u.c.rsvd = 0; + u.c.bus = bus; + u.c.dev = dev; + u.c.func = func; + u.c.reg = reg & 0xFC; + + out32(0xCF8, u.n); + + base = 0xCFC + (reg & 0x03); + + switch(bytes){ + case 1: return in(base); + case 2: return in16(base); + case 4: return in32(base); + default: return 0; + } +} + +void pci_write(int bus, int dev, int func, int reg, dword v, int bytes) +{ + word base; + + union { + confadd c; + dword n; + } u; + + u.c.enable = 1; + u.c.rsvd = 0; + u.c.bus = bus; + u.c.dev = dev; + u.c.func = func; + u.c.reg = reg & 0xFC; + + base = 0xCFC + (reg & 0x03); + out32(0xCF8, u.n); + switch(bytes){ + case 1: out(base, (byte) v); break; + case 2: out16(base, (word) v); break; + case 4: out32(base, v); break; + } + +} + +int pci_probe(int bus, int dev, int func, pci_cfg_t *cfg) +{ + dword *word = (dword *) cfg; + dword v; + int i; + for(i=0;i<4;i++){ + word[i] = pci_read(bus,dev,func,4*i,4); + } + if(cfg->vendor_id == 0xffff) return 1; + + cfg->bus = bus; + cfg->dev = dev; + cfg->func = func; +#if 1 + wprintf(L"Device Info: /bus/pci/%d/%d/%d\n",bus,dev,func); + wprintf(L" * Vendor: %X Device: %X Class/SubClass/Interface %X/%X/%X\n", + cfg->vendor_id,cfg->device_id,cfg->base_class,cfg->sub_class,cfg->interface); + wprintf(L" * Status: %X Command: %X BIST/Type/Lat/CLS: %X/%X/%X/%X\n", + cfg->status, cfg->command, cfg->bist, cfg->header_type, + cfg->latency_timer, cfg->cache_line_size); +#endif + + switch(cfg->header_type & 0x7F){ + case 0: /* normal device */ + for(i=0;i<6;i++){ + v = pci_read(bus,dev,func,i*4 + 0x10, 4); + if(v) { + int v2; + pci_write(bus,dev,func,i*4 + 0x10, 0xffffffff, 4); + v2 = pci_read(bus,dev,func,i*4+0x10, 4) & 0xfffffff0; + pci_write(bus,dev,func,i*4 + 0x10, v, 4); + v2 = 1 + ~v2; + if(v & 1) { +// printf(" * Base Register %d IO: %x (%x)\n",i,v&0xfff0,v2&0xffff); + cfg->base[i] = v & 0xffff; + cfg->size[i] = v2 & 0xffff; + } else { +// printf(" * Base Register %d MM: %x (%x)\n",i,v&0xfffffff0,v2); + cfg->base[i] = v; + cfg->size[i] = v2; + } + } else { + cfg->base[i] = 0; + cfg->size[i] = 0; + } + + } + v = pci_read(bus,dev,func,0x3c,1); + cfg->irq = (v == 0xff ? 0 : v); + + wprintf(L" * Interrupt Line: %X\n",cfg->irq); + break; + case 1: + wprintf(L" * PCI <-> PCI Bridge\n"); + break; + default: + wprintf(L" * Unknown Header Type\n"); + } + return 0; +} + +bool pci_find(word vendor_id, word device_id, pci_cfg_t* cfg) +{ + word bus, dev; + + for (bus = 0; bus < 255; bus++) + { + for(dev = 0;dev < 32; dev++) + { + if (pci_probe(bus, dev, 0, cfg)) + continue; + + if (cfg->vendor_id == vendor_id && cfg->device_id == device_id) + return true; + } + } + + return false; +} \ No newline at end of file diff --git a/mobius/src/drivers/kdll/pci.h b/mobius/src/drivers/kdll/pci.h new file mode 100644 index 0000000..06bfc79 --- /dev/null +++ b/mobius/src/drivers/kdll/pci.h @@ -0,0 +1,152 @@ +/* Copyright 1999, Brian J. Swetland. All rights reserved. +** Distributed under the terms of the OpenBLT License +*/ + +#ifndef _PCI_H +#define _PCI_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _pci_cfg_t pci_cfg_t; +struct _pci_cfg_t +{ + /* normal header stuff */ + word vendor_id; + word device_id; + + word command; + word status; + + byte revision_id; + byte interface; + byte sub_class; + byte base_class; + + byte cache_line_size; + byte latency_timer; + byte header_type; + byte bist; + + /* device info */ + byte bus; + byte dev; + byte func; + byte irq; + + /* base registers */ + dword base[6]; + dword size[6]; +}; + +dword pci_read(int bus, int dev, int func, int reg, int bytes); +void pci_write(int bus, int dev, int func, int reg, dword v, int bytes); +int pci_probe(int bus, int dev, int func, pci_cfg_t *cfg); +bool pci_find(word vendor_id, word device_id, pci_cfg_t* cfg); + +#ifdef __cplusplus +} +#endif + +#ifdef PCI_STUB + +#include +#include + +namespace BLT { + +class PCI +{ +public: + int read(int bus, int dev, int func, int reg, dword *v, int bytes); + int write(int bus, int dev, int func, int reg, dword v, int bytes); + int get_nth_cfg(int n, pci_cfg *cfg); + + static PCI *FindService(); + ~PCI(); + +private: + PCI(Connection *pci); + Connection *pci; +}; + +inline int +PCI::read(int bus, int dev, int func, int reg, dword *v, int bytes) +{ + int32 res; + Message msg; + msg.PutInt32('code',2); + msg.PutInt32('arg0',bus); + msg.PutInt32('arg1',dev); + msg.PutInt32('arg2',func); + msg.PutInt32('arg3',reg); + msg.PutInt32('arg4',bytes); + + if((res = pci->Call(&msg,&msg))) return res; + msg.GetInt32('ret0',(int32*) v); + msg.GetInt32('resp',&res); + + return res; +} + +inline int +PCI::write(int bus, int dev, int func, int reg, dword v, int bytes) +{ + int32 res; + Message msg; + msg.PutInt32('code',3); + msg.PutInt32('arg0',bus); + msg.PutInt32('arg1',dev); + msg.PutInt32('arg2',func); + msg.PutInt32('arg3',reg); + msg.PutInt32('arg4',(int32)v); + msg.PutInt32('arg5',bytes); + + if((res = pci->Call(&msg,&msg))) return res; + msg.GetInt32('resp',&res); + + return res; +} + +inline int +PCI::get_nth_cfg(int n, pci_cfg *cfg) +{ + int32 res; + Message msg; + msg.PutInt32('code',1); + msg.PutInt32('arg0',n); + + if((res = pci->Call(&msg,&msg))) return res; + if((res = msg.GetData('ret0','pcic',cfg,sizeof(pci_cfg)))) return res; + msg.GetInt32('resp',&res); + + return res; +} + +inline PCI * +PCI::FindService() +{ + Connection *cnxn = Connection::FindService("pci"); + if(cnxn) { + return new PCI(cnxn); + } else { + return 0; + } +} + +PCI::PCI(Connection *cnxn){ + pci = cnxn; +} + +PCI::~PCI(){ + delete pci; +} + +} + +#endif + +#endif diff --git a/mobius/src/drivers/kdll/ramdisk.cpp b/mobius/src/drivers/kdll/ramdisk.cpp new file mode 100644 index 0000000..fe1efa9 --- /dev/null +++ b/mobius/src/drivers/kdll/ramdisk.cpp @@ -0,0 +1,188 @@ +// ramdisk.cpp: implementation of the CRamFolder class. +// +////////////////////////////////////////////////////////////////////// + +#include "ramdisk.h" +#include "folder.h" +#include +#include +#include + +#define RAMDISK_ADDR 0xd0000000 + +class CRamFolder : public CFolder +{ +public: + CRamFolder(); + virtual ~CRamFolder(); + +protected: + virtual void ScanDir(); + virtual IUnknown* DoOpen(folderitem_ext_t* buf); +}; + +class CRamFile : public IUnknown, public IStream +{ +public: + CRamFile(void* data, ramfile_t* file); + + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + IMPLEMENT_IUNKNOWN(CFatFile); + + STDMETHOD_(size_t, Read) (void* pBuffer, size_t dwLength); + STDMETHOD_(size_t, Write) (const void* pBuffer, size_t dwLength); + STDMETHOD(SetIoMode)(dword mode); + STDMETHOD(IsReady)(); + STDMETHOD(Stat)(folderitem_t* buf); + STDMETHOD(Seek)(THIS long offset, int origin); + +protected: + byte* m_data; + ramfile_t* m_file; + dword m_pos; +}; + +extern "C" IFolder* RamDisk_Create() +{ + return new CRamFolder; +} + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CRamFolder::CRamFolder() +{ +} + +CRamFolder::~CRamFolder() +{ + +} + +void CRamFolder::ScanDir() +{ + folderitem_ext_t* item; + dword i; + wchar_t temp[16]; + ramdisk_t* header; + ramfile_t* files; + + header = (ramdisk_t*) RAMDISK_ADDR; + files = (ramfile_t*) (header + 1); + + for (i = 0; i < header->num_files; i++) + { + item = new folderitem_ext_t; + + memset(item, 0, sizeof(folderitem_ext_t)); + item->size = sizeof(folderitem_t); + + mbstowcs(temp, files[i].name, countof(temp)); + + item->name = wcsdup(temp); + item->length = files[i].length; + item->attributes = ATTR_READ_ONLY; + item->next = m_item_first; + item->data = files + i; + m_item_first = item; + } +} + +IUnknown* CRamFolder::DoOpen(folderitem_ext_t* buf) +{ + IUnknown* file; + + file = CFolder::DoOpen(buf); + if (file) + return file; + else if (buf->data) + { + ramfile_t* file = (ramfile_t*) buf->data; + return new CRamFile((byte*) RAMDISK_ADDR + file->offset, file); + } + else + return NULL; +} + +CRamFile::CRamFile(void* data, ramfile_t* file) +{ + m_file = file; + m_pos = 0; + m_data = (byte*) data; +} + +HRESULT CRamFile::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IStream)) + { + AddRef(); + *ppvObject = (IStream*) this; + return S_OK; + } + else + return E_FAIL; +} + +size_t CRamFile::Read(void* pBuffer, size_t dwLength) +{ + if (dwLength + m_pos > m_file->length) + dwLength = m_file->length - m_pos; + + memcpy(pBuffer, m_data + m_pos, dwLength); + m_pos += dwLength; + return dwLength; +} + +size_t CRamFile::Write(const void* pBuffer, size_t dwLength) +{ + return 0; +} + +HRESULT CRamFile::SetIoMode(dword mode) +{ + return S_OK; +} + +HRESULT CRamFile::IsReady() +{ + return S_OK; +} + +HRESULT CRamFile::Stat(folderitem_t* buf) +{ + if (buf->name_max && buf->name) + mbstowcs(buf->name, m_file->name, buf->name_max); + + buf->length = m_file->length; + buf->attributes = ATTR_READ_ONLY; + return S_OK; +} + +HRESULT CRamFile::Seek(long offset, int origin) +{ + switch (origin) + { + case seekSet: + if (offset >= 0 && offset < (long) m_file->length) + m_pos = offset; + else + return E_FAIL; + break; + case seekCur: + if (m_pos + offset >= 0 && m_pos + offset < m_file->length) + m_pos += offset; + else + return E_FAIL; + break; + case seekEnd: + if (offset <= 0 && -offset < (long) m_file->length) + m_pos = m_file->length + offset; + else + return E_FAIL; + break; + } + + return S_OK; +} \ No newline at end of file diff --git a/mobius/src/drivers/kdll/ramdisk.h b/mobius/src/drivers/kdll/ramdisk.h new file mode 100644 index 0000000..20b2cde --- /dev/null +++ b/mobius/src/drivers/kdll/ramdisk.h @@ -0,0 +1,13 @@ +// ramdisk.h: interface for the CRamFolder class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_RAMDISK_H__BE7173CF_0009_4684_8737_A86BE5670336__INCLUDED_) +#define AFX_RAMDISK_H__BE7173CF_0009_4684_8737_A86BE5670336__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + + +#endif // !defined(AFX_RAMDISK_H__BE7173CF_0009_4684_8737_A86BE5670336__INCLUDED_) diff --git a/mobius/src/drivers/kdll/res/1.fnt b/mobius/src/drivers/kdll/res/1.fnt new file mode 100644 index 0000000..5ed787a --- /dev/null +++ b/mobius/src/drivers/kdll/res/1.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/res/12.fnt b/mobius/src/drivers/kdll/res/12.fnt new file mode 100644 index 0000000..aabec08 --- /dev/null +++ b/mobius/src/drivers/kdll/res/12.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/res/13.fnt b/mobius/src/drivers/kdll/res/13.fnt new file mode 100644 index 0000000..b9975fb --- /dev/null +++ b/mobius/src/drivers/kdll/res/13.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/res/14.fnt b/mobius/src/drivers/kdll/res/14.fnt new file mode 100644 index 0000000..957deff --- /dev/null +++ b/mobius/src/drivers/kdll/res/14.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/res/15.fnt b/mobius/src/drivers/kdll/res/15.fnt new file mode 100644 index 0000000..f53a607 --- /dev/null +++ b/mobius/src/drivers/kdll/res/15.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/res/2.fnt b/mobius/src/drivers/kdll/res/2.fnt new file mode 100644 index 0000000..5231f83 --- /dev/null +++ b/mobius/src/drivers/kdll/res/2.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/res/3.fnt b/mobius/src/drivers/kdll/res/3.fnt new file mode 100644 index 0000000..5231f83 --- /dev/null +++ b/mobius/src/drivers/kdll/res/3.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/res/84.fnt b/mobius/src/drivers/kdll/res/84.fnt new file mode 100644 index 0000000..19cdc88 --- /dev/null +++ b/mobius/src/drivers/kdll/res/84.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/res/85.fnt b/mobius/src/drivers/kdll/res/85.fnt new file mode 100644 index 0000000..b12a1f6 --- /dev/null +++ b/mobius/src/drivers/kdll/res/85.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/res/86.fnt b/mobius/src/drivers/kdll/res/86.fnt new file mode 100644 index 0000000..28c6401 --- /dev/null +++ b/mobius/src/drivers/kdll/res/86.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/res/87.fnt b/mobius/src/drivers/kdll/res/87.fnt new file mode 100644 index 0000000..a1c802e --- /dev/null +++ b/mobius/src/drivers/kdll/res/87.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/res/88.fnt b/mobius/src/drivers/kdll/res/88.fnt new file mode 100644 index 0000000..b1ea9c3 --- /dev/null +++ b/mobius/src/drivers/kdll/res/88.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/res/89.fnt b/mobius/src/drivers/kdll/res/89.fnt new file mode 100644 index 0000000..f012b0d --- /dev/null +++ b/mobius/src/drivers/kdll/res/89.fnt Binary files differ diff --git a/mobius/src/drivers/kdll/resource.h b/mobius/src/drivers/kdll/resource.h new file mode 100644 index 0000000..35a25b6 --- /dev/null +++ b/mobius/src/drivers/kdll/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by kdll.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/mobius/src/drivers/kdll/serial.cpp b/mobius/src/drivers/kdll/serial.cpp new file mode 100644 index 0000000..3281456 --- /dev/null +++ b/mobius/src/drivers/kdll/serial.cpp @@ -0,0 +1,449 @@ +#include +#include +#include +#include +#include +#include + +/* +;; *********************************************************** +;; Register Indexes for the 8250 UART +;; NOTE: Indexes have been multiplied by 2 to get the +;; correct location in the register table. +;; *********************************************************** +*/ +#define THR 0 // Transmit Holding Register (DLAB==0) +#define RBR 0 // Recieve Buffer Register (DLAB==0) +#define BAUDL 0 // Baud Rate Divisor, Low byte (DLAB==1) +#define BAUDH 1 // Baud Rate Divisor, High Byte (DLAB==1) +#define IER 1 // Interrupt Enable Register +#define IIR 2 // Interrupt Identification Register +#define FCR 2 // FIFO Control Register (UARTS 16550+) +#define LCR 3 // Line Control Register +#define MCR 4 // Modem Control Register +#define LSR 5 // Line Status Register +#define MSR 6 // Modem Status Register + +/* +;; *********************************************************** +;; Send and Receive Buffers +;; NOTE: The buffer sizes (SendSize & RecvSize) must be of a +;; size X such that log2(X+1)=Integer. In otherwords, +;; take a power of 2, subtract one, and that is a legal +;; buffer size. (1, 3, 7, 15, 31, 63, 127 ... 2^X-1) +;; *********************************************************** +*/ + +#define SendSize 4095 // 2^X-1 Send Buffer Size (4095) +#define RecvSize 4095 // 2^X-1 Receive Buffer Size (4095) + +class CSerialPort : public IUnknown, public IDevice, public IStream +{ +public: + CSerialPort(word base, byte irq); + virtual ~CSerialPort(); + + /* IUnknown methods */ + STDMETHOD(QueryInterface)(REFIID iid, void** obj); + IMPLEMENT_IUNKNOWN(CSerialPort); + + /* IDevice methods */ + STDMETHOD(GetInfo)(device_t* buf); + STDMETHOD(DeviceOpen)(); + + /* IStream methods */ + STDMETHOD_(size_t, Read)(void* buffer, size_t length); + STDMETHOD_(size_t, Write)(const void* buffer, size_t length); + STDMETHOD(SetIoMode)(dword mode); + STDMETHOD(IsReady)(); + STDMETHOD(Stat)(folderitem_t* buf); + STDMETHOD(Seek)(long offset, int origin); + +protected: + word m_port; // Port Base Address + word m_registers[7]; // Register Index Map + byte m_irq; // Vector Number + bool m_in_isr; + + byte m_send_buffer[SendSize]; // Send FIFO Buffer + word m_send_head; // Send FIFO Buffer Head Index + word m_send_tail; // Send FIFO Buffer Tail Index + + byte m_receive_buffer[RecvSize]; // Receive FIFO Buffer + word m_receive_head; // Receive FIFO Buffer Head Index + word m_receive_tail; // Receive FIFO Buffer Tail Index + + static void Isr(void* context, int irq); + void Interrupt(); + + void ClosePort(); + void ClearRead(); + void ClearWrite(); + char HwRead(); + int HwWrite(char data); + int ReadStatus(); + int WriteStatus(); + void SetBaud(int baud); + int GetBaud(); + void SetHandShake(int hand); + int GetHandShake(); + int GetStatus(); + int GetControl(); + void SetControl(int control); +}; + +extern "C" IDevice* Serial_Create(word port, byte irq) +{ + return new CSerialPort(port, irq); +} + +void CSerialPort::Isr(void* context, int irq) +{ + _cputws(L"Serial IRQ\n"); + ((CSerialPort*) context)->Interrupt(); +} + +void CSerialPort::Interrupt() +{ + byte intr, state; + + m_in_isr = true; + out(0x21, in(0x21) | ~0xef); + + do + { + intr = (in(m_registers[IIR]) & 6) >> 1; + wprintf(L"serial_isr: %x\n", intr); + + switch (intr) + { + case 0: // nothing + case 3: + state = in(m_registers[IER]); + //wprintf(L"state = %x ", state); + out(m_registers[IER], 0); + //_cputws(L"out(0) "); + out(m_registers[IER], state); + //_cputws(L"out(state)\n"); + goto finished; + + case 1: // transmit + if (m_send_head == m_send_tail) + { + out(m_registers[IER], in(m_registers[IER]) & 0xFD); + goto finished; + } + else + { + wprintf(L"transmit: %c\n", m_send_buffer[m_send_tail]); + out(m_registers[THR], m_send_buffer[m_send_tail]); + m_send_tail = (m_send_tail + 1) & SendSize; + } + + break; + + case 2: // receive + m_receive_buffer[m_receive_head] = in(m_registers[RBR]); + if (((m_receive_head + 1) & RecvSize) != m_receive_tail) + m_receive_head = (m_receive_head + 1) & RecvSize; + break; + } + } while ((in(m_registers[IIR]) & 1) == 0); + +finished: + + _cputws(L"finish: "); + out(m_registers[MCR], in(m_registers[MCR]) | 8); + out(m_registers[IER], 1); + + out(0x21, in(0x21) & 0xef); + _cputws(L"done\n"); + m_in_isr = false; +} + +CSerialPort::CSerialPort(word base, byte irq) +{ + int i; + + m_refs = 0; + + wprintf(L"CSerialPort::CSerialPort(%x, %d)\n", base, irq); + + /* + ;; *********************************************************** + ;; Set up COMM variables + ;; *********************************************************** + */ + m_port = base; + m_irq = irq; + + /* + ;; *********************************************************** + ;; Set up the Register Port Indexes + ;; *********************************************************** + */ + for (i = 6; i > 0; i--) + m_registers[i] = base + i; + + /* + ;; *********************************************************** + ;; Initialize the Read/Write Buffers + ;; *********************************************************** + */ + + ClearWrite(); + ClearRead(); + + /* + ;; *********************************************************** + ;; Install the ISR + ;; *********************************************************** + */ + + sysRegisterIrq(m_irq, (void (*) (dword, int)) Isr, (dword) this); + + out(m_registers[MCR], in(m_registers[MCR]) | 8); + out(m_registers[LCR], in(m_registers[LCR]) & 0x7F); + out(m_registers[IER], 1); + + /* + ;; *********************************************************** + ;; Clear the buffers again, just in case . . . + ;; *********************************************************** + */ + + ClearWrite(); + ClearRead(); +} + +CSerialPort::~CSerialPort() +{ + ClosePort(); +} + +void CSerialPort::ClosePort() +{ + /* + ;; *********************************************************** + ;; Disable the 8250 Interrupt (DLAB clear perhaps before this) + ;; *********************************************************** + */ + + out(m_registers[IER], 0); + out(m_registers[MCR], in(m_registers[MCR]) & 0xF7); + + /* + ;; *********************************************************** + ;; ISR is disabled, so reset old ISR Vector + ;; *********************************************************** + */ + + sysRegisterIrq(m_irq, NULL, 0); +} + +void CSerialPort::ClearRead() +{ + disable(); + m_receive_head = m_receive_tail = 0; + enable(); +} + +void CSerialPort::ClearWrite() +{ + disable(); + m_send_head = m_send_tail = 0; + disable(); +} + +char CSerialPort::HwRead() +{ + byte data; + + if (m_receive_head == m_receive_tail) + return 0; + + data = m_receive_buffer[m_receive_tail]; + m_receive_tail = (m_receive_tail + 1) & RecvSize; + return data; +} + +int CSerialPort::HwWrite(char data) +{ + /* + ;; *********************************************************** + ;; Check if buffer is FULL + ;; *********************************************************** + */ + + if (((m_send_head + 1) & SendSize) == m_send_tail || + m_in_isr) + return 0; + + m_send_buffer[m_send_head] = data; + m_send_head = (m_send_head + 1) & SendSize; + + /* + ;; *********************************************************** + ;; Enable the THRE Interrupt + ;; *********************************************************** + */ + + out(m_registers[IER], in(m_registers[IER]) | 2); + + return -1; +} + +int CSerialPort::ReadStatus() +{ + if (m_receive_head >= m_receive_tail) + return m_receive_head - m_receive_tail; + else + return m_receive_head - m_receive_tail + RecvSize; +} + +int CSerialPort::WriteStatus() +{ + if (m_send_head >= m_send_tail) + return m_send_head - m_send_tail; + else + return m_send_head - m_send_tail + SendSize; +} + +void CSerialPort::SetBaud(int baud) +{ + byte divisor; + + if (baud == 0) + return; + + divisor = 115200 / baud; + + disable(); + out(m_registers[LCR], in(m_registers[LCR]) | 0x80); + + out(m_registers[BAUDL], divisor % 256); + out(m_registers[BAUDH], divisor / 256); + + out(m_registers[LCR], in(m_registers[LCR]) & 0x7F); + enable(); +} + +int CSerialPort::GetBaud() +{ + word divisor; + + disable(); + out(m_registers[LCR], in(m_registers[LCR]) | 0x80); + divisor = in(m_registers[BAUDL]) | in(m_registers[BAUDH]) << 8; + out(m_registers[LCR], in(m_registers[LCR]) & 0x7F); + enable(); + + if (divisor == 0) + return 0; + + return 115200 / divisor; +} + +void CSerialPort::SetHandShake(int hand) +{ + out(m_registers[MCR], (byte) hand | 8); +} + +int CSerialPort::GetHandShake() +{ + return in(m_registers[MCR]); +} + +int CSerialPort::GetStatus() +{ + return in(m_registers[MSR]) << 8 | in(m_registers[LSR]); +} + +int CSerialPort::GetControl() +{ + return in(m_registers[LCR]) & 0xf; +} + +void CSerialPort::SetControl(int control) +{ + out(m_registers[LCR], (byte) control & 0x7F); +} + +HRESULT CSerialPort::QueryInterface(REFIID iid, void** obj) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IStream)) + { + AddRef(); + *obj = this; + return S_OK; + } + else + return E_FAIL; +} + +HRESULT CSerialPort::GetInfo(device_t* buf) +{ + if (buf->size < sizeof(device_t)) + return E_FAIL; + + wcsncpy(buf->name, L"Serial port", buf->name_max); + return S_OK; +} + +HRESULT CSerialPort::DeviceOpen() +{ + _cputws(L"CSerialPort::DeviceOpen\n"); + ClearRead(); + ClearWrite(); + SetBaud(9600); + SetControl(BITS_8 | NO_PARITY | STOP_1); + SetHandShake(0); + return S_OK; +} + +size_t CSerialPort::Read(void* buffer, size_t length) +{ + size_t i; + + for (i = 0; i < length; i++) + { + while (ReadStatus() == 0) + ; + + ((byte*) buffer)[i] = HwRead(); + } + + return i; +} + +size_t CSerialPort::Write(const void* buffer, size_t length) +{ + size_t i; + + for (i = 0; i < length; i++) + if (HwWrite(((const byte*) buffer)[i]) == 0) + break; + + return i; +} + +HRESULT CSerialPort::SetIoMode(dword mode) +{ + return S_OK; +} + +HRESULT CSerialPort::IsReady() +{ + return S_OK; +} + +HRESULT CSerialPort::Stat(folderitem_t* buf) +{ + return E_FAIL; +} + +HRESULT CSerialPort::Seek(long offset, int origin) +{ + return E_FAIL; +} \ No newline at end of file diff --git a/mobius/src/drivers/kdll/wildcard.c b/mobius/src/drivers/kdll/wildcard.c new file mode 100644 index 0000000..8cf803f --- /dev/null +++ b/mobius/src/drivers/kdll/wildcard.c @@ -0,0 +1,24 @@ +#include + +bool wildcard(const wchar_t* str, const wchar_t* spec) +{ + while (*spec) + { + if (*spec == '*') + { + spec++; + if (!*spec) + return true; + + while (*str && *str != *spec) + str++; + } + else if (*str != *spec) + return false; + + str++; + spec++; + } + + return true; +} \ No newline at end of file diff --git a/mobius/src/drivers/keyboard/Makefile b/mobius/src/drivers/keyboard/Makefile new file mode 100644 index 0000000..aa42ada --- /dev/null +++ b/mobius/src/drivers/keyboard/Makefile @@ -0,0 +1,7 @@ +TARGET= $(BIN)/keyboard.drv +OBJS= keyboard.o +BASE= keyboard + +include ../make.driver + +include $(OBJS:.o=.d) \ No newline at end of file diff --git a/mobius/src/drivers/keyboard/british.h b/mobius/src/drivers/keyboard/british.h new file mode 100644 index 0000000..f3dcea3 --- /dev/null +++ b/mobius/src/drivers/keyboard/british.h @@ -0,0 +1,58 @@ +#ifndef __KBD_BRITISH_H +#define __KBD_BRITISH_H + +static const dword keys[] = +{ + 0, +/* Esc 1 2 3 4 5 6 7 8 9 0 - = Bksp */ + 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', +/* Tab q w e r t y u i o p [ ] */ + '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', +/* Ctrl a s d f g h j k l ; ' ` */ + 0, + 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'','`', +/* LShift # z x c v b n m , . / RShift */ + 0, + '#', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0, + +/* PrtScr LAlt Space, Caps */ + KEY_PRTSC, 0, ' ', 0, + + KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, + KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, + 0,/*Num*/ 0,/*Scrl*/ KEY_HOME, KEY_UP, KEY_PGUP, + '-', KEY_LEFT, 0,/*Pad5*/KEY_RIGHT, '+', + KEY_END, KEY_DOWN, KEY_PGDN, KEY_INS, KEY_DEL, + KBD_BUCKY_ALT | KEY_PRTSC, + 0,/*55*/ '\\',/*56*/ KEY_F11, KEY_F12, + 0,/*59*/ 0,/*5a*/ KEY_LWIN, KEY_RWIN, KEY_MENU +}; + +static const dword keys_shift[] = +{ + 0, +/* Esc 1 2 3 4 5 6 7 8 9 0 - = Bksp */ + 27, '!', '\"',0xa3, '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b', +/* Tab q w e r t y u i o p [ ] */ + '\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', +/* Ctrl a s d f g h j k l ; ' ` */ + 0, + 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '@', 0xac, +/* LShift # z x c v b n m , . / RShift */ + 0, + '~', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 0, + +/* PrtScr LAlt Space, Caps */ + KEY_PRTSC, 0, ' ', 0, + + KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, + KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, + 0,/*Num*/ 0,/*Scrl*/ KEY_HOME, KEY_UP, KEY_PGUP, + '-', KEY_LEFT, 0,/*Pad5*/KEY_RIGHT, '+', + KEY_END, KEY_DOWN, KEY_PGDN, KEY_INS, KEY_DEL, + KBD_BUCKY_ALT | KEY_PRTSC, + '!',/*55*/ '|',/*56*/KEY_F11, KEY_F12, + 0,/*59*/ 0,/*5a*/ KEY_LWIN, KEY_RWIN, KEY_MENU +}; + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/keyboard/keyboard.c b/mobius/src/drivers/keyboard/keyboard.c new file mode 100644 index 0000000..948ef2d --- /dev/null +++ b/mobius/src/drivers/keyboard/keyboard.c @@ -0,0 +1,475 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include "keyboard.h" +#include "british.h" + +/*! + * \ingroup drivers + * \defgroup keyboard AT/PS2 keyboard + * @{ + */ + +typedef struct Keyboard Keyboard; +struct Keyboard +{ + device_t dev; + dword keys; + wchar_t compose; + dword *write, *read; + dword buffer[128]; + bool isps2; + word port, ctrl; +}; + +#define SET(var, bit, val) \ + { \ + if (val) \ + var |= bit; \ + else \ + var &= ~bit; \ + } + +void kbdHwWrite(Keyboard* ctx, word port, byte data) +{ + dword timeout; + byte stat; + + for (timeout = 500000L; timeout != 0; timeout--) + { + stat = in(ctx->ctrl); + + if ((stat & 0x02) == 0) + break; + } + + if (timeout != 0) + out(port, data); +} + +byte kbdHwRead(Keyboard* ctx) +{ + unsigned long Timeout; + byte Stat, Data; + + for (Timeout = 50000L; Timeout != 0; Timeout--) + { + Stat = in(ctx->ctrl); + + /* loop until 8042 output buffer full */ + if ((Stat & 0x01) != 0) + { + Data = in(ctx->port); + + /* loop if parity error or receive timeout */ + if((Stat & 0xC0) == 0) + return Data; + } + } + + return -1; +} + +byte kbdHwWriteRead(Keyboard* ctx, word port, byte data, const char* expect) +{ + int RetVal; + + kbdHwWrite(ctx, port, data); + for (; *expect; expect++) + { + RetVal = kbdHwRead(ctx); + if ((byte) *expect != RetVal) + { + TRACE2("[keyboard] error: expected 0x%x, got 0x%x\n", + (byte) *expect, RetVal); + return RetVal; + } + } + + return 0; +} + +dword kbdScancodeToKey(Keyboard* ctx, byte scancode) +{ + static int keypad[RAW_NUM0 - RAW_NUM7 + 1] = + { + 7, 8, 9, -1, + 4, 5, 6, -1, + 1, 2, 3, + 0 + }; + + bool down = (scancode & 0x80) == 0; + byte code = scancode & ~0x80; + dword key = 0; + byte temp; + + switch (code) + { + case RAW_LEFT_CTRL: + case RAW_RIGHT_CTRL: + SET(ctx->keys, KBD_BUCKY_CTRL, down); + break; + + case RAW_LEFT_ALT: + //case RAW_RIGHT_ALT: + if (down && (ctx->keys & KBD_BUCKY_ALT) == 0) + ctx->compose = 0; + else if (!down && (ctx->keys & KBD_BUCKY_ALT)) + key = ctx->compose; + + SET(ctx->keys, KBD_BUCKY_ALT, down); + break; + + case RAW_LEFT_SHIFT: + case RAW_RIGHT_SHIFT: + SET(ctx->keys, KBD_BUCKY_SHIFT, down); + break; + + case RAW_NUM_LOCK: + if (!down) + { + ctx->keys ^= KBD_BUCKY_NUM; + goto leds; + } + break; + + case RAW_CAPS_LOCK: + if (!down) + { + ctx->keys ^= KBD_BUCKY_CAPS; + goto leds; + } + break; + + case RAW_SCROLL_LOCK: + if (!down) + { + ctx->keys ^= KBD_BUCKY_SCRL; + goto leds; + } + break; + +leds: + kbdHwWrite(ctx, ctx->port, KEYB_SET_LEDS); + temp = 0; + if (ctx->keys & KBD_BUCKY_SCRL) + temp |= 1; + if (ctx->keys & KBD_BUCKY_NUM) + temp |= 2; + if (ctx->keys & KBD_BUCKY_CAPS) + temp |= 4; + kbdHwWrite(ctx, ctx->port, temp); + break; + + default: + if (down) + { + if (code >= RAW_NUM7 && + code <= RAW_NUM0 && + code != 0x4a && + code != 0x4e) + { + if (ctx->keys & KBD_BUCKY_ALT && + keypad[code - RAW_NUM7] != -1) + { + ctx->compose *= 10; + ctx->compose += keypad[code - RAW_NUM7]; + //wprintf(L"pad = %d compose = %d\n", + //keypad[code - RAW_NUM7], ctx->compose); + } + else if (ctx->keys & KBD_BUCKY_NUM) + key = '0' + keypad[code - RAW_NUM7]; + else + key = keys[code]; + } + else if (ctx->keys & KBD_BUCKY_SHIFT) + key = keys_shift[code]; + else + key = keys[code]; + + if (ctx->keys & KBD_BUCKY_CAPS) + { + if (iswupper(key)) + key = towlower(key); + else if (iswlower(key)) + key = towupper(key); + } + } + } + + return key | ctx->keys; +} + +size_t kbdRead(Keyboard* ctx, void* buffer, size_t length) +{ + dword ch, *buf = (dword*) buffer; + size_t read = 0; + + while (length > 0) + { + if (ctx->read == ctx->write) + return read; + + ch = *ctx->read; + ctx->read++; + if (ctx->read >= ctx->buffer + countof(ctx->buffer)) + ctx->read = ctx->buffer; + + *buf = ch; + buf++; + length -= sizeof(dword); + read += sizeof(dword); + } + + return read; +} + +void kbdDoRequests(Keyboard* ctx) +{ + request_t *req, *next; + size_t read; + dword key; + + while (ctx->dev.req_first && + (read = kbdRead(ctx, &key, sizeof(key)))) + { + for (req = ctx->dev.req_first; req; req = next) + { + /*wprintf(L"read = %d req = %p ", read, req); + wprintf(L"buffer = %p size = %d\n", req->params.read.buffer, + req->params.read.length); + + _cputws(L"Writing buffer...");*/ + ((dword*) req->params.read.buffer)[req->params.read.length / sizeof(dword)] = key; + //_cputws(L"done\nUpdating length..."); + req->params.read.length += read; + + next = req->next; + if (req->params.read.length >= req->user_length) + devFinishRequest(&ctx->dev, req); + //else + //_cputws(L"more to do\n"); + } + } +} + +void kbdKey(Keyboard* ctx, byte scancode) +{ + dword key; + + if (ctx->write >= ctx->read) + { + key = kbdScancodeToKey(ctx, scancode); + + if (key == (KBD_BUCKY_CTRL | KBD_BUCKY_ALT | KEY_DEL)) + keShutdown(SHUTDOWN_REBOOT); + else if (key == KEY_F11) + if (dbgInvoke(thrCurrent(), thrContext(thrCurrent()), 0)) + return; + + if (key) + { + *ctx->write = key; + ctx->write++; + + if (ctx->write >= ctx->buffer + countof(ctx->buffer)) + ctx->write = ctx->buffer; + + //wprintf(L"read = %d, write = %d\n", ctx->read - ctx->buffer, ctx->write - ctx->buffer); + //Read(&key, sizeof(key)); + //wprintf(L"%c", key); + } + + kbdDoRequests(ctx); + } +} + +bool kbdRequest(device_t* dev, request_t* req) +{ + Keyboard* ctx = (Keyboard*) dev; + + TRACE2("[%c%c]", req->code / 256, req->code % 256); + switch (req->code) + { + case DEV_READ: + devStartRequest(dev, req); + req->params.read.length = 0; + + kbdDoRequests(ctx); + return true; + + case DEV_OPEN: + case DEV_CLOSE: + hndSignal(req->event, true); + return true; + + case DEV_ISR: + kbdKey(ctx, kbdHwRead(ctx)); + return true; + + case CHR_GETSIZE: + *((size_t*) req->params.buffered.buffer) = ctx->write - ctx->read; + hndSignal(req->event, true); + return true; + } + + req->result = ENOTIMPL; + return false; +} + +Keyboard* INIT_CODE kbdInit(driver_t* drv, device_config_t *cfg) +{ + Keyboard* ctx; + dword i; + word port, ctrl; + device_t* kdebug; + byte status; + + ctx = (Keyboard*) hndAlloc(sizeof(Keyboard), NULL); + + if (cfg) + i = devFindResource(cfg, dresIo, 0); + else + i = -1; + + if (i == (dword) -1) + port = KEYB_PORT; + else + port = cfg->resources[i].u.io.base; + + if (cfg) + i = devFindResource(cfg, dresIo, 1); + else + i = -1; + + if (i == (dword) -1) + ctrl = KEYB_CTRL; + else + ctrl = cfg->resources[i].u.io.base; + + ctx->dev.driver = drv; + ctx->dev.request = kbdRequest; + ctx->dev.config = cfg; + ctx->dev.req_first = ctx->dev.req_last = NULL; + ctx->keys = 0; + ctx->write = ctx->read = ctx->buffer; + ctx->port = port; + ctx->ctrl = ctrl; + + TRACE2("keyboard: port = %x ctrl = %x\n", port, ctrl); + + /* + * The kernel debugger may have registered our IRQ1, which would make a + * mess of keyboard initialization. + */ + kdebug = devOpen(L"debugger", NULL); + devRegisterIrq(kdebug, 1, false); + devClose(kdebug); + +#if 0 + out(port, 0xff); /*reset keyboard */ + do { + status = in(ctrl); + } while (status & 0x02); + + out(ctrl, 0xAA); /*selftest */ + in(port); + out(ctrl, 0xAB); /*interface selftest */ + in(port); + + out(ctrl, 0xAE); /*enable keyboard */ + + out(port, 0xff); /*reset keyboard */ + + in(port); + in(port); + + out(ctrl, 0xAD); /*disable keyboard */ + + out(ctrl, 0x60); + out(port, 0x01 | 0x04 | 0x20 | 0x40); + + out(ctrl, 0xAE); /*enable keyboard */ +#else + /* Reset keyboard and disable scanning until further down */ + TRACE0("Disable..."); + kbdHwWriteRead(ctx, ctx->port, KEYB_RESET_DISABLE, KEYB_ACK); + + /* Set keyboard controller flags: + interrupts for keyboard & aux port + SYS bit (?) */ + TRACE0("done\nFlags..."); + kbdHwWrite(ctx, ctx->ctrl, KCTRL_WRITE_CMD_BYTE); + kbdHwWrite(ctx, ctx->port, KCTRL_IRQ1 | KCTRL_SYS | KCTRL_IRQ12); + + TRACE0("done\nIdentify..."); + kbdHwWriteRead(ctx, ctx->port, KEYB_IDENTIFY, KEYB_ACK); + if (kbdHwRead(ctx) == 0xAB && + kbdHwRead(ctx) == 0x83) + { + TRACE0("[keyboard] PS/2 keyboard detected\n"); + + /* Program desired scancode set, expect 0xFA (ACK)... */ + kbdHwWriteRead(ctx, ctx->port, KEYB_SET_SCANCODE_SET, KEYB_ACK); + + /* ...send scancode set value, expect 0xFA (ACK) */ + kbdHwWriteRead(ctx, ctx->port, 1, KEYB_ACK); + + /* make all keys typematic (auto-repeat) and make-break. This may work + only with scancode set 3, I'm not sure. Expect 0xFA (ACK) */ + kbdHwWriteRead(ctx, ctx->port, KEYB_ALL_TYPM_MAKE_BRK, KEYB_ACK); + + ctx->isps2 = true; + } + else + { + /* Argh... bloody bochs */ + TRACE0("[keyboard] AT keyboard detected\n"); + ctx->isps2 = false; + } + + /* Set typematic delay as short as possible; + Repeat as fast as possible, expect ACK... */ + TRACE0("Typematic..."); + kbdHwWriteRead(ctx, ctx->port, KEYB_SET_TYPEMATIC, KEYB_ACK); + + /* ...typematic control byte (0 corresponds to MODE CON RATE=30 DELAY=1), + expect 0xFA (ACK) */ + kbdHwWriteRead(ctx, ctx->port, 0, KEYB_ACK); + + /* Enable keyboard, expect 0xFA (ACK) */ + TRACE0("done\nEnable..."); + kbdHwWriteRead(ctx, ctx->port, KEYB_ENABLE, KEYB_ACK); +#endif + + TRACE0("done\nIRQ..."); + devRegisterIrq(&ctx->dev, 1, true); + TRACE0("done\n"); + return ctx; +} + +device_t* kbdAddDevice(driver_t* drv, const wchar_t* name, + device_config_t* cfg) +{ + return (device_t*) kbdInit(drv, cfg); +} + +bool STDCALL INIT_CODE drvInit(driver_t* drv) +{ + drv->add_device = kbdAddDevice; + //devRegister(L"keyboard", kbdAddDevice(drv, L"keyboard", NULL), NULL); + return true; +} + +//@} \ No newline at end of file diff --git a/mobius/src/drivers/keyboard/keyboard.d b/mobius/src/drivers/keyboard/keyboard.d new file mode 100644 index 0000000..dc0935f --- /dev/null +++ b/mobius/src/drivers/keyboard/keyboard.d @@ -0,0 +1,22 @@ +keyboard.o: keyboard.c f:\Projects\mobius\include\stdlib.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h \ + f:\Projects\mobius\include\malloc.h \ + f:\Projects\mobius\include\string.h \ + f:\Projects\mobius\include\stdio.h \ + f:\Projects\mobius\include\stdarg.h f:\Projects\mobius\include\io.h \ + f:\Projects\mobius\include\ctype.h \ + f:\Projects\mobius\include\kernel/kernel.h \ + f:\Projects\mobius\include\kernel/i386.h \ + f:\Projects\mobius\include\os/os.h \ + f:\Projects\mobius\include\kernel/sys.h \ + f:\Projects\mobius\include\kernel/driver.h \ + f:\Projects\mobius\include\kernel/proc.h \ + f:\Projects\mobius\include\kernel/obj.h \ + f:\Projects\mobius\include\os/pe.h \ + f:\Projects\mobius\include\kernel/handle.h \ + f:\Projects\mobius\include\os/devreq.h \ + f:\Projects\mobius\include\kernel/thread.h \ + f:\Projects\mobius\include\errno.h \ + f:\Projects\mobius\include\kernel/debug.h keyboard.h \ + f:\Projects\mobius\include\os/keyboard.h british.h diff --git a/mobius/src/drivers/keyboard/keyboard.dsp b/mobius/src/drivers/keyboard/keyboard.dsp new file mode 100644 index 0000000..2b78d3a --- /dev/null +++ b/mobius/src/drivers/keyboard/keyboard.dsp @@ -0,0 +1,113 @@ +# Microsoft Developer Studio Project File - Name="keyboard" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=keyboard - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "keyboard.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "keyboard.mak" CFG="keyboard - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "keyboard - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "keyboard - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "keyboard - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f keyboard.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "keyboard.exe" +# PROP BASE Bsc_Name "keyboard.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "nmake /f "keyboard.mak"" +# PROP Rebuild_Opt "/a" +# PROP Target_File "keyboard.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "keyboard - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f keyboard.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "keyboard.exe" +# PROP BASE Bsc_Name "keyboard.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "set" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\bin\keyboard.dll" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "keyboard - Win32 Release" +# Name "keyboard - Win32 Debug" + +!IF "$(CFG)" == "keyboard - Win32 Release" + +!ELSEIF "$(CFG)" == "keyboard - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\keyboard.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\british.h +# End Source File +# Begin Source File + +SOURCE=.\keyboard.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/keyboard/keyboard.h b/mobius/src/drivers/keyboard/keyboard.h new file mode 100644 index 0000000..daeb598 --- /dev/null +++ b/mobius/src/drivers/keyboard/keyboard.h @@ -0,0 +1,61 @@ +#ifndef __KEYBOARD_H +#define __KEYBOARD_H + +#include + +#define KEYB_PORT 0x60 /* keyboard port */ +#define KEYB_CTRL 0x64 /* keyboard controller port */ + +#define KCTRL_ENABLE_AUX 0xA8 /* enable aux port (PS/2 mouse) */ +#define KCTRL_WRITE_CMD_BYTE 0x60 /* write to command register */ +#define KCTRL_WRITE_AUX 0xD4 /* write next byte at port 60 to aux port */ + +/* flags for KCTRL_WRITE_CMD_BYTE */ +#define KCTRL_IRQ1 0x01 +#define KCTRL_IRQ12 0x02 +#define KCTRL_SYS 0x04 +#define KCTRL_OVERRIDE_INHIBIT 0x08 +#define KCTRL_DISABLE_KEYB 0x10 +#define KCTRL_DISABLE_AUX 0x20 +#define KCTRL_TRANSLATE_XT 0x40 + +/* commands to keyboard */ +#define KEYB_SET_LEDS 0xED +#define KEYB_SET_SCANCODE_SET 0xF0 +#define KEYB_IDENTIFY 0xF2 +#define KEYB_SET_TYPEMATIC 0xF3 +#define KEYB_ENABLE 0xF4 +#define KEYB_RESET_DISABLE 0xF5 +#define KEYB_ALL_TYPM_MAKE_BRK 0xFA + +/* default ACK from keyboard following command */ +#define KEYB_ACK "\xFA" + +/* commands to aux device (PS/2 mouse) */ +#define AUX_INFORMATION 0xE9 +#define AUX_ENABLE 0xF4 +#define AUX_IDENTIFY 0xF2 +#define AUX_RESET 0xFF + +/* "raw" set 1 scancodes from PC keyboard */ +#define RAW_LEFT_CTRL 0x1D +#define RAW_LEFT_SHIFT 0x2A +#define RAW_CAPS_LOCK 0x3A +#define RAW_LEFT_ALT 0x38 +#define RAW_RIGHT_ALT 0xFF +#define RAW_RIGHT_CTRL 0xFF +#define RAW_RIGHT_SHIFT 0x36 +#define RAW_SCROLL_LOCK 0x46 +#define RAW_NUM_LOCK 0x45 +#define RAW_NUM7 0x47 +#define RAW_NUM8 0x48 +#define RAW_NUM9 0x49 +#define RAW_NUM4 0x4b +#define RAW_NUM5 0x4c +#define RAW_NUM6 0x4d +#define RAW_NUM1 0x4f +#define RAW_NUM2 0x50 +#define RAW_NUM3 0x51 +#define RAW_NUM0 0x52 + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/keyboard/keyboard.plg b/mobius/src/drivers/keyboard/keyboard.plg new file mode 100644 index 0000000..fac3db3 --- /dev/null +++ b/mobius/src/drivers/keyboard/keyboard.plg @@ -0,0 +1,18 @@ + + +
+

Build Log

+

+--------------------Configuration: keyboard - Win32 Debug-------------------- +

+ +gcc -D__MOBIUS__ -DKERNEL -If:\Projects\mobius\include -MD -c keyboard.c +link /out:f:\Projects\mobius\bin/keyboard.dll /nologo /debug /debugtype:coff /libpath:f:\Projects\mobius\lib /nodefaultlib /entry:drvInit /subsystem:native /base:@f:\Projects\mobius\bin\coffbase.txt,keyboard keyboard.o kernel.lib + + + +

Results

+keyboard.dll - 0 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/drivers/keyboard/vc60.pdb b/mobius/src/drivers/keyboard/vc60.pdb new file mode 100644 index 0000000..954d053 --- /dev/null +++ b/mobius/src/drivers/keyboard/vc60.pdb @@ -0,0 +1 @@ +Microsoft C/C++ program database 2.00 diff --git a/mobius/src/drivers/make.driver b/mobius/src/drivers/make.driver new file mode 100644 index 0000000..a2c3c11 --- /dev/null +++ b/mobius/src/drivers/make.driver @@ -0,0 +1,47 @@ +ROOT= f:/projects/mobius +BIN= $(ROOT)/bin +LIB= $(ROOT)/lib +CPPFLAGS+= -g -D__MOBIUS__ -DKERNEL -Wall -nostdinc -I$(ROOT)/include -I. +CC= gcc +NASM= nasm +LDFLAGS+= -g --subsystem native --entry _drvInit@4 \ + --image-base `cat .base` +LIBS+= $(LIB)/kernel.lib +DEF= $(EXP:.exp=.def) + +%.d: %.c + $(CC) $(CPPFLAGS) -M -c $< -o $@ +%.o: %.c + $(CC) $(CPPFLAGS) -c $< -o $@ +%.o: %.cpp + $(CC) $(CPPFLAGS) -c $< -o$@ +%.d: %.cpp + $(CC) $(CPPFLAGS) -MD -c $< +%.d: %.asm + $(NASM) -M $< > $@ +%.o: %.asm + $(NASM) -f win32 -o $@ $< + +all: $(TARGET) $(IMP) + +.base: $(BIN)/coffbase.txt Makefile + $(BIN)/base.pl $(BASE) < $(BIN)/coffbase.txt > .base + +$(TARGET): $(OBJS) $(EXP) .base + ld -o $(TARGET) $(LDFLAGS) \ + $(OBJS) \ + $(EXP) \ + $(LIBS) + +%.exp: %.def + dlltool -e $@ -m i386 --input-def $< -D $(@:.exp=.drv) + +$(IMP): $(DEF) +# lib /def:$< /out:$@ /nologo /machine:ix86 + dlltool -m i386 --input-def $(DEF) --output-lib $(IMP) + +clean: + rm .base + rm $(OBJS) + rm $(TARGET) + rm $(OBJS:.o=.d) \ No newline at end of file diff --git a/mobius/src/drivers/pci/Makefile b/mobius/src/drivers/pci/Makefile new file mode 100644 index 0000000..4a3813d --- /dev/null +++ b/mobius/src/drivers/pci/Makefile @@ -0,0 +1,9 @@ +TARGET= $(BIN)/pci.drv +OBJS= pci.o +BASE= pci +EXP= pci.exp +IMP= $(LIB)/pci.lib + +include ../make.driver + +include $(OBJS:.o=.d) \ No newline at end of file diff --git a/mobius/src/drivers/pci/pci.c b/mobius/src/drivers/pci/pci.c new file mode 100644 index 0000000..e2a3a0a --- /dev/null +++ b/mobius/src/drivers/pci/pci.c @@ -0,0 +1,416 @@ +#include +#include +#include +#include +#include + +/*! + * \ingroup drivers + * \defgroup pci PCI bus + * @{ + */ + +typedef struct pci_cfg_t pci_cfg_t; +struct pci_cfg_t +{ + /* normal header stuff */ + word vendor_id; + word device_id; + + word command; + word status; + + byte revision_id; + byte interface; + byte sub_class; + byte base_class; + + byte cache_line_size; + byte latency_timer; + byte header_type; + byte bist; + + /* device info */ + byte bus; + byte dev; + byte func; + byte irq; + + /* base registers */ + dword base[6]; + dword size[6]; + + word subsys_vendor; + word subsys; +}; + +typedef struct confadd +{ + byte reg:8; + byte func:3; + byte dev:5; + byte bus:8; + byte rsvd:7; + byte enable:1; +} confadd; + +const struct +{ + byte base_class; + byte sub_class; + byte interface; + const wchar_t* name; +} classes[] = +{ + { 0x00, 0x00, 0x00, L"Undefined" }, + { 0x00, 0x01, 0x00, L"VGA" }, + + { 0x01, 0x00, 0x00, L"SCSI" }, + { 0x01, 0x01, 0x00, L"IDE" }, + { 0x01, 0x02, 0x00, L"Floppy" }, + { 0x01, 0x03, 0x00, L"IPI" }, + { 0x01, 0x04, 0x00, L"RAID" }, + { 0x01, 0x80, 0x00, L"Other" }, + + { 0x02, 0x00, 0x00, L"Ethernet" }, + { 0x02, 0x01, 0x00, L"Token Ring" }, + { 0x02, 0x02, 0x00, L"FDDI" }, + { 0x02, 0x03, 0x00, L"ATM" }, + { 0x02, 0x04, 0x00, L"ISDN" }, + { 0x02, 0x80, 0x00, L"Other" }, + + { 0x03, 0x00, 0x00, L"VGA" }, + { 0x03, 0x00, 0x01, L"VGA+8514" }, + { 0x03, 0x01, 0x00, L"XGA" }, + { 0x03, 0x02, 0x00, L"3D" }, + { 0x03, 0x80, 0x00, L"Other" }, + + { 0x04, 0x00, 0x00, L"Video" }, + { 0x04, 0x01, 0x00, L"Audio" }, + { 0x04, 0x02, 0x00, L"Telephony" }, + { 0x04, 0x80, 0x00, L"Other" }, + + { 0x05, 0x00, 0x00, L"RAM" }, + { 0x05, 0x01, 0x00, L"Flash" }, + { 0x05, 0x80, 0x00, L"Other" }, + + { 0x06, 0x00, 0x00, L"PCI to HOST" }, + { 0x06, 0x01, 0x00, L"PCI to ISA" }, + { 0x06, 0x02, 0x00, L"PCI to EISA" }, + { 0x06, 0x03, 0x00, L"PCI to MCA" }, + { 0x06, 0x04, 0x00, L"PCI to PCI" }, + { 0x06, 0x04, 0x01, L"PCI to PCI (Subtractive Decode)" }, + { 0x06, 0x05, 0x00, L"PCI to PCMCIA" }, + { 0x06, 0x06, 0x00, L"PCI to NuBUS" }, + { 0x06, 0x07, 0x00, L"PCI to Cardbus" }, + { 0x06, 0x08, 0x00, L"PCI to RACEway" }, + { 0x06, 0x09, 0x00, L"PCI to PCI" }, + { 0x06, 0x0A, 0x00, L"PCI to InfiBand" }, + { 0x06, 0x80, 0x00, L"PCI to Other" }, + + { 0x07, 0x00, 0x00, L"Serial" }, + { 0x07, 0x00, 0x01, L"Serial - 16450" }, + { 0x07, 0x00, 0x02, L"Serial - 16550" }, + { 0x07, 0x00, 0x03, L"Serial - 16650" }, + { 0x07, 0x00, 0x04, L"Serial - 16750" }, + { 0x07, 0x00, 0x05, L"Serial - 16850" }, + { 0x07, 0x00, 0x06, L"Serial - 16950" }, + { 0x07, 0x01, 0x00, L"Parallel" }, + { 0x07, 0x01, 0x01, L"Parallel - BiDir" }, + { 0x07, 0x01, 0x02, L"Parallel - ECP" }, + { 0x07, 0x01, 0x03, L"Parallel - IEEE1284" }, + { 0x07, 0x01, 0xFE, L"Parallel - IEEE1284 Target" }, + { 0x07, 0x02, 0x00, L"Multiport Serial" }, + { 0x07, 0x03, 0x00, L"Hayes Compatible Modem" }, + { 0x07, 0x03, 0x01, L"Hayes Compatible Modem, 16450" }, + { 0x07, 0x03, 0x02, L"Hayes Compatible Modem, 16550" }, + { 0x07, 0x03, 0x03, L"Hayes Compatible Modem, 16650" }, + { 0x07, 0x03, 0x04, L"Hayes Compatible Modem, 16750" }, + { 0x07, 0x80, 0x00, L"Other" }, + + { 0x08, 0x00, 0x00, L"PIC" }, + { 0x08, 0x00, 0x01, L"ISA PIC" }, + { 0x08, 0x00, 0x02, L"EISA PIC" }, + { 0x08, 0x00, 0x10, L"I/O APIC" }, + { 0x08, 0x00, 0x20, L"I/O(x) APIC" }, + { 0x08, 0x01, 0x00, L"DMA" }, + { 0x08, 0x01, 0x01, L"ISA DMA" }, + { 0x08, 0x01, 0x02, L"EISA DMA" }, + { 0x08, 0x02, 0x00, L"Timer" }, + { 0x08, 0x02, 0x01, L"ISA Timer" }, + { 0x08, 0x02, 0x02, L"EISA Timer" }, + { 0x08, 0x03, 0x00, L"RTC" }, + { 0x08, 0x03, 0x00, L"ISA RTC" }, + { 0x08, 0x03, 0x00, L"Hot-Plug" }, + { 0x08, 0x80, 0x00, L"Other" }, + + { 0x09, 0x00, 0x00, L"Keyboard" }, + { 0x09, 0x01, 0x00, L"Pen" }, + { 0x09, 0x02, 0x00, L"Mouse" }, + { 0x09, 0x03, 0x00, L"Scanner" }, + { 0x09, 0x04, 0x00, L"Game Port" }, + { 0x09, 0x80, 0x00, L"Other" }, + + { 0x0a, 0x00, 0x00, L"Generic" }, + { 0x0a, 0x80, 0x00, L"Other" }, + + { 0x0b, 0x00, 0x00, L"386" }, + { 0x0b, 0x01, 0x00, L"486" }, + { 0x0b, 0x02, 0x00, L"Pentium" }, + { 0x0b, 0x03, 0x00, L"PentiumPro" }, + { 0x0b, 0x10, 0x00, L"DEC Alpha" }, + { 0x0b, 0x20, 0x00, L"PowerPC" }, + { 0x0b, 0x30, 0x00, L"MIPS" }, + { 0x0b, 0x40, 0x00, L"Coprocessor" }, + { 0x0b, 0x80, 0x00, L"Other" }, + + { 0x0c, 0x00, 0x00, L"FireWire" }, + { 0x0c, 0x00, 0x10, L"OHCI FireWire" }, + { 0x0c, 0x01, 0x00, L"Access.bus" }, + { 0x0c, 0x02, 0x00, L"SSA" }, + { 0x0c, 0x03, 0x00, L"USB (UHCI)" }, + { 0x0c, 0x03, 0x10, L"USB (OHCI)" }, + { 0x0c, 0x03, 0x80, L"USB" }, + { 0x0c, 0x03, 0xFE, L"USB Device" }, + { 0x0c, 0x04, 0x00, L"Fiber" }, + { 0x0c, 0x05, 0x00, L"SMBus Controller" }, + { 0x0c, 0x06, 0x00, L"InfiniBand" }, + { 0x0c, 0x80, 0x00, L"Other" }, + + { 0x0d, 0x00, 0x00, L"iRDA" }, + { 0x0d, 0x01, 0x00, L"Consumer IR" }, + { 0x0d, 0x10, 0x00, L"RF" }, + { 0x0d, 0x80, 0x00, L"Other" }, + + { 0x0e, 0x00, 0x00, L"I2O" }, + { 0x0e, 0x80, 0x00, L"Other" }, + + { 0x0f, 0x01, 0x00, L"TV" }, + { 0x0f, 0x02, 0x00, L"Audio" }, + { 0x0f, 0x03, 0x00, L"Voice" }, + { 0x0f, 0x04, 0x00, L"Data" }, + { 0x0f, 0x80, 0x00, L"Other" }, + + { 0x10, 0x00, 0x00, L"Network" }, + { 0x10, 0x10, 0x00, L"Entertainment" }, + { 0x10, 0x80, 0x00, L"Other" }, + + { 0x11, 0x00, 0x00, L"DPIO Modules" }, + { 0x11, 0x01, 0x00, L"Performance Counters" }, + { 0x11, 0x10, 0x00, L"Comm Sync, Time+Frequency Measurement" }, + { 0x11, 0x80, 0x00, L"Other" }, +}; + +dword pciRead(int bus, int dev, int func, int reg, int bytes) +{ + word base; + + union { + confadd c; + dword n; + } u; + + u.n = 0; + u.c.enable = 1; + u.c.rsvd = 0; + u.c.bus = bus; + u.c.dev = dev; + u.c.func = func; + u.c.reg = reg & 0xFC; + + out32(0xCF8, u.n); + + base = 0xCFC + (reg & 0x03); + + switch(bytes){ + case 1: return in(base); + case 2: return in16(base); + case 4: return in32(base); + default: return 0; + } +} + +void pciWrite(int bus, int dev, int func, int reg, dword v, int bytes) +{ + word base; + + union { + confadd c; + dword n; + } u; + + u.n = 0; + u.c.enable = 1; + u.c.rsvd = 0; + u.c.bus = bus; + u.c.dev = dev; + u.c.func = func; + u.c.reg = reg & 0xFC; + + base = 0xCFC + (reg & 0x03); + out32(0xCF8, u.n); + switch(bytes){ + case 1: out(base, (byte) v); break; + case 2: out16(base, (word) v); break; + case 4: out32(base, v); break; + } + +} + +bool pciProbe(int bus, int dev, int func, pci_cfg_t *cfg) +{ + dword *word = (dword *) cfg; + dword v; + int i; + for(i=0;i<4;i++){ + word[i] = pciRead(bus,dev,func,4*i,4); + } + if(cfg->vendor_id == 0xffff) return false; + + cfg->bus = bus; + cfg->dev = dev; + cfg->func = func; + cfg->subsys_vendor = pciRead(bus, dev, func, 0x2c, 2); + cfg->subsys = pciRead(bus, dev, func, 0x2e, 2); + +#if 0 + wprintf(L"Device Info: /bus/pci/%d/%d/%d\n",bus,dev,func); + wprintf(L" * Vendor: %X Device: %X Class/SubClass/Interface %X/%X/%X\n", + cfg->vendor_id,cfg->device_id,cfg->base_class,cfg->sub_class,cfg->interface); + wprintf(L" * Status: %X Command: %X BIST/Type/Lat/CLS: %X/%X/%X/%X\n", + cfg->status, cfg->command, cfg->bist, cfg->header_type, + cfg->latency_timer, cfg->cache_line_size); +#endif + + switch(cfg->header_type & 0x7F){ + case 0: /* normal device */ + for(i=0;i<6;i++){ + v = pciRead(bus,dev,func,i*4 + 0x10, 4); + if(v) { + int v2; + pciWrite(bus,dev,func,i*4 + 0x10, 0xffffffff, 4); + v2 = pciRead(bus,dev,func,i*4+0x10, 4) & 0xfffffff0; + pciWrite(bus,dev,func,i*4 + 0x10, v, 4); + v2 = 1 + ~v2; + if(v & 1) { +// printf(" * Base Register %d IO: %x (%x)\n",i,v&0xfff0,v2&0xffff); + cfg->base[i] = v & 0xffff; + cfg->size[i] = v2 & 0xffff; + } else { +// printf(" * Base Register %d MM: %x (%x)\n",i,v&0xfffffff0,v2); + cfg->base[i] = v; + cfg->size[i] = v2; + } + } else { + cfg->base[i] = 0; + cfg->size[i] = 0; + } + + } + v = pciRead(bus,dev,func,0x3c,1); + cfg->irq = (v == 0xff ? 0 : v); + + //wprintf(L" * Interrupt Line: %X\n",cfg->irq); + break; + case 1: + //wprintf(L" * PCI <-> PCI Bridge\n"); + break; + default: + //wprintf(L" * Unknown Header Type\n"); + } + return true; +} + +bool STDCALL INIT_CODE drvInit(driver_t *drv) +{ + word bus, dev, func; + device_t *pci; + wchar_t name[20]; + device_config_t* cfg; + pci_cfg_t pcfg; + int i, j; + + pci = hndAlloc(sizeof(device_t), NULL); + pci->driver = drv; + pci->req_first = pci->req_last = NULL; + pci->request = NULL; + devRegister(L"pci", pci, NULL); + + for (bus = 0; bus < 2/*255*/; bus++) + { + wprintf(L"PCI scan: %d%%\r", (bus * 100) / 255); + + for (dev = 0; dev < 32; dev++) + { + for (func = 0; func < 8; func++) + { + if (pciProbe(bus, dev, func, &pcfg)) + { + //swprintf(name, L"pci/%d/%d", bus, dev); + wcscpy(name, L"pcidev"); + + cfg = hndAlloc(sizeof(device_config_t), NULL); + cfg->parent = pci; + cfg->vendor_id = pcfg.vendor_id; + cfg->device_id = pcfg.device_id; + cfg->subsystem = pcfg.subsys_vendor << 16 | pcfg.subsys; + + if (pcfg.irq) + cfg->num_resources = 1; + else + cfg->num_resources = 0; + + for (i = 0; i < countof(pcfg.base); i++) + if (pcfg.base[i]) + cfg->num_resources++; + + cfg->resources = hndAlloc(sizeof(device_resource_t) * + cfg->num_resources, NULL); + for (i = 0, j = 0; i < countof(pcfg.base); i++) + { + if (pcfg.base[i]) + { + if ((pcfg.base[i] & 0xffff0000) == 0) + { + cfg->resources[j].cls = dresIo; + cfg->resources[j].u.io.base = pcfg.base[i]; + cfg->resources[j].u.io.length = pcfg.size[i]; + } + else + { + cfg->resources[j].cls = dresMemory; + cfg->resources[j].u.memory.base = pcfg.base[i]; + cfg->resources[j].u.memory.length = pcfg.size[i]; + } + + j++; + } + } + + if (pcfg.irq) + { + cfg->resources[j].cls = dresIrq; + cfg->resources[j].u.irq = pcfg.irq; + } + + for (i = 0; i < countof(classes); i++) + if (pcfg.base_class == classes[i].base_class && + pcfg.sub_class == classes[i].sub_class && + pcfg.interface == classes[i].interface) + { + _cputws(classes[i].name); + putwchar(' '); + break; + } + + devRegister(name, NULL, cfg); + } + } + } + } + + wprintf(L"PCI: finished\n"); + return true; +} + +//@} \ No newline at end of file diff --git a/mobius/src/drivers/pci/pci.d b/mobius/src/drivers/pci/pci.d new file mode 100644 index 0000000..b6e4f26 --- /dev/null +++ b/mobius/src/drivers/pci/pci.d @@ -0,0 +1,15 @@ +pci.o: pci.c f:\Projects\mobius\include\kernel/kernel.h \ + f:\Projects\mobius\include\kernel/i386.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h f:\Projects\mobius\include\os/os.h \ + f:\Projects\mobius\include\kernel/driver.h \ + f:\Projects\mobius\include\kernel/proc.h \ + f:\Projects\mobius\include\kernel/obj.h \ + f:\Projects\mobius\include\os/pe.h \ + f:\Projects\mobius\include\kernel/handle.h \ + f:\Projects\mobius\include\os/devreq.h \ + f:\Projects\mobius\include\stdio.h \ + f:\Projects\mobius\include\stdarg.h f:\Projects\mobius\include\io.h \ + f:\Projects\mobius\include\stdlib.h \ + f:\Projects\mobius\include\malloc.h \ + f:\Projects\mobius\include\string.h diff --git a/mobius/src/drivers/pci/pci.dsp b/mobius/src/drivers/pci/pci.dsp new file mode 100644 index 0000000..f5a5ca9 --- /dev/null +++ b/mobius/src/drivers/pci/pci.dsp @@ -0,0 +1,109 @@ +# Microsoft Developer Studio Project File - Name="pci" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=pci - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pci.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pci.mak" CFG="pci - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pci - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "pci - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "pci - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f pci.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "pci.exe" +# PROP BASE Bsc_Name "pci.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\pci.drv" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "pci - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f pci.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "pci.exe" +# PROP BASE Bsc_Name "pci.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "set" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\pci.drv" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "pci - Win32 Release" +# Name "pci - Win32 Debug" + +!IF "$(CFG)" == "pci - Win32 Release" + +!ELSEIF "$(CFG)" == "pci - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pci.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\..\..\include\kernel\driver.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/pci/pci.plg b/mobius/src/drivers/pci/pci.plg new file mode 100644 index 0000000..86061d7 --- /dev/null +++ b/mobius/src/drivers/pci/pci.plg @@ -0,0 +1,17 @@ + + +
+

Build Log

+

+--------------------Configuration: pci - Win32 Debug-------------------- +

+ +make: Nothing to be done for `all'. + + + +

Results

+pci.drv - 0 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/drivers/pci/pci.s b/mobius/src/drivers/pci/pci.s new file mode 100644 index 0000000..f8f9ca8 --- /dev/null +++ b/mobius/src/drivers/pci/pci.s @@ -0,0 +1,498 @@ + .file "pci.c" +gcc2_compiled.: +___gnu_compiled_c: +.text + .align 4 +.globl _pciRead + .def _pciRead; .scl 2; .type 32; .endef +_pciRead: + pushl %ebp + movl %esp,%ebp + subl $16,%esp + orl $-2147483648,%ecx + xorl %eax,%eax + andl $-2147418113,%ecx + xorl %edx,%edx + pushl %ebx + movl 24(%ebp),%ebx + movb 8(%ebp),%al + sall $16,%eax + orl %eax,%ecx + movb 12(%ebp),%dl + andl $31,%edx + sall $11,%edx + andb $7,%ch + orl %edx,%ecx + xorl %eax,%eax + movb 16(%ebp),%al + andl $7,%eax + sall $8,%eax + andb $248,%ch + orl %eax,%ecx + movb 20(%ebp),%dl + andb $-4,%dl + movb %dl,-4(%ebp) + movb %dl,%cl + movl $3320,%edx + movl %ecx,%eax +/APP + outl %eax, %dx +/NO_APP + movl 20(%ebp),%ecx + andl $3,%ecx + addw $3324,%cx + cmpl $2,%ebx + je L23 + jg L29 + cmpl $1,%ebx + je L21 + jmp L27 + .p2align 4,,7 +L29: + cmpl $4,%ebx + je L25 + jmp L27 + .p2align 4,,7 +L21: + movl %ecx,%edx +/APP + inb %dx,%al +/NO_APP + andl $255,%eax + jmp L30 + .p2align 4,,7 +L23: + movl %ecx,%edx +/APP + inw %dx,%ax +/NO_APP + andl $65535,%eax + jmp L30 + .p2align 4,,7 +L25: + movl %ecx,%edx +/APP + inl %dx,%eax +/NO_APP + jmp L30 + .p2align 4,,7 +L27: + xorl %eax,%eax +L30: + movl -20(%ebp),%ebx + movl %ebp,%esp + popl %ebp + ret + .align 4 +.globl _pciWrite + .def _pciWrite; .scl 2; .type 32; .endef +_pciWrite: + pushl %ebp + movl %esp,%ebp + subl $16,%esp + pushl %edi + orl $-2147483648,%ecx + xorl %eax,%eax + pushl %esi + andl $-2147418113,%ecx + xorl %edx,%edx + pushl %ebx + movl 24(%ebp),%esi + movl 28(%ebp),%edi + movl 20(%ebp),%ebx + movb 8(%ebp),%al + sall $16,%eax + orl %eax,%ecx + movb 12(%ebp),%dl + andl $31,%edx + sall $11,%edx + andb $7,%ch + orl %edx,%ecx + xorl %eax,%eax + movb 16(%ebp),%al + andl $7,%eax + sall $8,%eax + andb $248,%ch + orl %eax,%ecx + movb 20(%ebp),%dl + andb $-4,%dl + movb %dl,-4(%ebp) + movb %dl,%cl + andl $3,%ebx + addl $3324,%ebx + movl $3320,%edx + movl %ecx,%eax +/APP + outl %eax, %dx +/NO_APP + cmpl $2,%edi + je L35 + jg L41 + cmpl $1,%edi + je L34 + jmp L33 + .p2align 4,,7 +L41: + cmpl $4,%edi + je L37 + jmp L33 + .p2align 4,,7 +L34: + movl %ebx,%edx + movl %esi,%eax +/APP + outb %al, %dx +/NO_APP + jmp L33 + .p2align 4,,7 +L35: + movl %ebx,%edx + movl %esi,%eax +/APP + outw %ax, %dx +/NO_APP + jmp L33 + .p2align 4,,7 +L37: + movl %ebx,%edx + movl %esi,%eax +/APP + outl %eax, %dx +/NO_APP +L33: + leal -28(%ebp),%esp + popl %ebx + popl %esi + popl %edi + movl %ebp,%esp + popl %ebp + ret + .align 32 +LC0: + .ascii "D\0e\0v\0i\0c\0e\0 \0I\0n\0f\0o\0:\0 \0/\0b\0u\0s\0/\0p\0c\0i\0/\0%\0d\0/\0%\0d\0/\0%\0d\0\12\0\0\0" + .align 32 +LC1: + .ascii " \0 \0*\0 \0V\0e\0n\0d\0o\0r\0:\0 \0%\0X\0 \0 \0 \0D\0e\0v\0i\0c\0e\0:\0 \0%\0X\0 \0 \0C\0l\0a\0s\0s\0/\0S\0u\0b\0C\0l\0a\0s\0s\0/\0I\0n\0t\0e\0r\0f\0a\0c\0e\0 \0%\0X\0/\0%\0X\0/\0%\0X\0\12\0\0\0" + .align 32 +LC2: + .ascii " \0 \0*\0 \0S\0t\0a\0t\0u\0s\0:\0 \0%\0X\0 \0 \0C\0o\0m\0m\0a\0n\0d\0:\0 \0%\0X\0 \0 \0B\0I\0S\0T\0/\0T\0y\0p\0e\0/\0L\0a\0t\0/\0C\0L\0S\0:\0 \0%\0X\0/\0%\0X\0/\0%\0X\0/\0%\0X\0\12\0\0\0" + .align 32 +LC3: + .ascii " \0 \0*\0 \0I\0n\0t\0e\0r\0r\0u\0p\0t\0 \0L\0i\0n\0e\0:\0 \0%\0X\0\12\0\0\0" + .align 32 +LC4: + .ascii " \0 \0*\0 \0P\0C\0I\0 \0<\0-\0>\0 \0P\0C\0I\0 \0B\0r\0i\0d\0g\0e\0\12\0\0\0" + .align 32 +LC5: + .ascii " \0 \0*\0 \0U\0n\0k\0n\0o\0w\0n\0 \0H\0e\0a\0d\0e\0r\0 \0T\0y\0p\0e\0\12\0\0\0" + .align 4 +.globl _pciProbe + .def _pciProbe; .scl 2; .type 32; .endef +_pciProbe: + pushl %ebp + movl %esp,%ebp + subl $16,%esp + pushl %edi + pushl %esi + pushl %ebx + movl $0,-4(%ebp) + xorl %ebx,%ebx + .p2align 4,,7 +L46: + pushl $4 + pushl %ebx + movl 16(%ebp),%edx + pushl %edx + movl 12(%ebp),%ecx + pushl %ecx + movl 8(%ebp),%edx + pushl %edx + call _pciRead + movl 20(%ebp),%ecx + movl %eax,(%ecx,%ebx) + addl $20,%esp + addl $4,%ebx + incl -4(%ebp) + cmpl $3,-4(%ebp) + jle L46 + cmpw $65535,(%ecx) + jne L48 + movl $1,%eax + jmp L65 + .p2align 4,,7 +L48: + movl 20(%ebp),%ecx + movb 8(%ebp),%dl + movb %dl,16(%ecx) + movb 12(%ebp),%dl + movb %dl,17(%ecx) + movb 16(%ebp),%dl + movb %dl,18(%ecx) + movl 16(%ebp),%ecx + pushl %ecx + movl 12(%ebp),%edx + pushl %edx + movl 8(%ebp),%ecx + pushl %ecx + pushl $LC0 + call _wprintf + movl 20(%ebp),%edx + xorl %eax,%eax + movb 9(%edx),%al + pushl %eax + xorl %eax,%eax + movb 10(%edx),%al + pushl %eax + xorl %eax,%eax + movb 11(%edx),%al + pushl %eax + xorl %eax,%eax + movw 2(%edx),%ax + pushl %eax + xorl %eax,%eax + movw (%edx),%ax + pushl %eax + pushl $LC1 + call _wprintf + movl 20(%ebp),%ecx + addl $40,%esp + xorl %eax,%eax + movb 12(%ecx),%al + pushl %eax + xorl %eax,%eax + movb 13(%ecx),%al + pushl %eax + xorl %eax,%eax + movb 14(%ecx),%al + pushl %eax + xorl %eax,%eax + movb 15(%ecx),%al + pushl %eax + xorl %eax,%eax + movw 4(%ecx),%ax + pushl %eax + xorl %eax,%eax + movw 6(%ecx),%ax + pushl %eax + pushl $LC2 + call _wprintf + movl 20(%ebp),%edx + addl $28,%esp + movb 14(%edx),%al + andb $127,%al + andl $255,%eax + testl %eax,%eax + je L50 + cmpl $1,%eax + je L62 + jmp L63 + .p2align 4,,7 +L50: + movl 20(%ebp),%ecx + movl 20(%ebp),%edx + movl $0,-4(%ebp) + addl $44,%ecx + movl %ecx,-8(%ebp) + addl $20,%edx + movl %edx,-12(%ebp) + movl $16,%edi + .p2align 4,,7 +L54: + pushl $4 + pushl %edi + movl 16(%ebp),%ecx + pushl %ecx + movl 12(%ebp),%edx + pushl %edx + movl 8(%ebp),%ecx + pushl %ecx + call _pciRead + movl %eax,%esi + addl $20,%esp + testl %esi,%esi + je L55 + pushl $4 + pushl $-1 + pushl %edi + movl 16(%ebp),%edx + pushl %edx + movl 12(%ebp),%ecx + pushl %ecx + movl 8(%ebp),%edx + pushl %edx + call _pciWrite + pushl $4 + pushl %edi + movl 16(%ebp),%ecx + pushl %ecx + movl 12(%ebp),%edx + pushl %edx + movl 8(%ebp),%ecx + pushl %ecx + call _pciRead + addl $44,%esp + pushl $4 + pushl %esi + pushl %edi + movl 16(%ebp),%edx + pushl %edx + movl %eax,%ebx + movl 12(%ebp),%ecx + pushl %ecx + andl $-16,%ebx + movl 8(%ebp),%edx + pushl %edx + call _pciWrite + movl %ebx,%eax + notl %eax + leal 1(%eax),%ebx + addl $24,%esp + testl $1,%esi + je L56 + movl -12(%ebp),%ecx + movl -8(%ebp),%edx + andl $65535,%esi + movl %esi,(%ecx) + andl $65535,%ebx + movl %ebx,(%edx) + jmp L53 + .p2align 4,,7 +L56: + movl -12(%ebp),%ecx + movl -8(%ebp),%edx + movl %esi,(%ecx) + movl %ebx,(%edx) + jmp L53 + .p2align 4,,7 +L55: + movl -12(%ebp),%ecx + movl -8(%ebp),%edx + movl $0,(%ecx) + movl $0,(%edx) +L53: + addl $4,-8(%ebp) + addl $4,-12(%ebp) + addl $4,%edi + incl -4(%ebp) + cmpl $5,-4(%ebp) + jle L54 + pushl $1 + pushl $60 + movl 16(%ebp),%ecx + pushl %ecx + movl 12(%ebp),%edx + pushl %edx + movl 8(%ebp),%ecx + pushl %ecx + call _pciRead + movl %eax,%esi + addl $20,%esp + cmpl $255,%esi + je L60 + movl %esi,%edx + movl 20(%ebp),%ecx + movb %dl,19(%ecx) + jmp L61 + .p2align 4,,7 +L60: + movl 20(%ebp),%edx + movb $0,19(%edx) +L61: + movl 20(%ebp),%ecx + xorl %eax,%eax + movb 19(%ecx),%al + pushl %eax + pushl $LC3 + call _wprintf + jmp L49 + .p2align 4,,7 +L62: + pushl $LC4 + jmp L66 + .p2align 4,,7 +L63: + pushl $LC5 +L66: + call _wprintf +L49: + xorl %eax,%eax +L65: + leal -28(%ebp),%esp + popl %ebx + popl %esi + popl %edi + movl %ebp,%esp + popl %ebp + ret + .align 4 +.globl _pciFind + .def _pciFind; .scl 2; .type 32; .endef +_pciFind: + pushl %ebp + movl %esp,%ebp + subl $16,%esp + pushl %edi + pushl %esi + xorl %esi,%esi + pushl %ebx + movl 16(%ebp),%edi + movl 8(%ebp),%edx + movw %dx,-2(%ebp) + movl 12(%ebp),%edx + movw %dx,-4(%ebp) + .p2align 4,,7 +L71: + xorl %ebx,%ebx + xorl %edx,%edx + movw %si,%dx + movl %edx,-8(%ebp) + .p2align 4,,7 +L75: + pushl %edi + pushl $0 + xorl %eax,%eax + movw %bx,%ax + pushl %eax + movl -8(%ebp),%edx + pushl %edx + call _pciProbe + addl $16,%esp + testl %eax,%eax + jne L74 + movw -2(%ebp),%dx + cmpw %dx,(%edi) + jne L74 + movl -4(%ebp),%edx + cmpw %dx,2(%edi) + jne L74 + movl $1,%eax + jmp L80 + .p2align 4,,7 +L74: + incw %bx + cmpw $31,%bx + jbe L75 + incw %si + cmpw $254,%si + jbe L71 + xorl %eax,%eax +L80: + leal -28(%ebp),%esp + popl %ebx + popl %esi + popl %edi + movl %ebp,%esp + popl %ebp + ret +.section .init,"x" + .align 4 +.globl _drvInit@12 + .def _drvInit@12; .scl 2; .type 32; .endef +_drvInit@12: + pushl %ebp + movl %esp,%ebp + movl $1,%eax + movl %ebp,%esp + popl %ebp + ret $12 + .def _wprintf; .scl 2; .type 32; .endef diff --git a/mobius/src/drivers/ps2mouse/Makefile b/mobius/src/drivers/ps2mouse/Makefile new file mode 100644 index 0000000..4218149 --- /dev/null +++ b/mobius/src/drivers/ps2mouse/Makefile @@ -0,0 +1,7 @@ +TARGET= $(BIN)/ps2mouse.drv +OBJS= ps2mouse.o +BASE= ps2mouse + +include ../make.driver + +include $(OBJS:.o=.d) \ No newline at end of file diff --git a/mobius/src/drivers/ps2mouse/ps2mouse.c b/mobius/src/drivers/ps2mouse/ps2mouse.c new file mode 100644 index 0000000..e614827 --- /dev/null +++ b/mobius/src/drivers/ps2mouse/ps2mouse.c @@ -0,0 +1,347 @@ +#include +#include +#include +#include +#include +#include +#include + +#define DEBUG +#include + +/*! + * \ingroup drivers + * \defgroup ps2mouse PS/2 aux port and mouse + * @{ + */ + +/* + * General keyboard defines -- + * needed for i8042 port (PS/2 controller) + */ + +#define KEYB_PORT 0x60 /* keyboard port */ +#define KEYB_CTRL 0x64 /* keyboard controller port */ + +#define KCTRL_ENABLE_AUX 0xA8 /* enable aux port (PS/2 mouse) */ +#define KCTRL_WRITE_CMD_BYTE 0x60 /* write to command register */ +#define KCTRL_WRITE_AUX 0xD4 /* write next byte at port 60 to aux port */ + +/* flags for KCTRL_WRITE_CMD_BYTE */ +#define KCTRL_IRQ1 0x01 +#define KCTRL_IRQ12 0x02 +#define KCTRL_SYS 0x04 +#define KCTRL_OVERRIDE_INHIBIT 0x08 +#define KCTRL_DISABLE_KEYB 0x10 +#define KCTRL_DISABLE_AUX 0x20 +#define KCTRL_TRANSLATE_XT 0x40 + +/* commands to keyboard */ +#define KEYB_SET_LEDS 0xED +#define KEYB_SET_SCANCODE_SET 0xF0 +#define KEYB_IDENTIFY 0xF2 +#define KEYB_SET_TYPEMATIC 0xF3 +#define KEYB_ENABLE 0xF4 +#define KEYB_RESET_DISABLE 0xF5 +#define KEYB_ALL_TYPM_MAKE_BRK 0xFA + +/* default ACK from keyboard following command */ +#define KEYB_ACK "\xFA" + +/* commands to aux device (PS/2 mouse) */ +#define AUX_INFORMATION 0xE9 +#define AUX_ENABLE 0xF4 +#define AUX_IDENTIFY 0xF2 +#define AUX_RESET 0xFF + +static word interrupts; + +typedef struct Ps2Mouse Ps2Mouse; +struct Ps2Mouse +{ + device_t dev; + bool has_wheel; +}; + +void INIT_CODE kbdWrite(word port, byte data) +{ + dword timeout; + byte stat; + + for (timeout = 500000L; timeout != 0; timeout--) + { + stat = in(KEYB_CTRL); + + if ((stat & 0x02) == 0) + break; + } + + if (timeout != 0) + out(port, data); +} + +byte kbdRead() +{ + unsigned long Timeout; + byte Stat, Data; + + for (Timeout = 50000L; Timeout != 0; Timeout--) + { + Stat = in(KEYB_CTRL); + + /* loop until 8042 output buffer full */ + if ((Stat & 0x01) != 0) + { + Data = in(KEYB_PORT); + + /* loop if parity error or receive timeout */ + if((Stat & 0xC0) == 0) + return Data; + } + } + + return -1; +} + +byte INIT_CODE kbdWriteRead(word port, byte data, const char* expect) +{ + int RetVal; + + kbdWrite(port, data); + for (; *expect; expect++) + { + RetVal = kbdRead(); + if ((byte) *expect != RetVal) + { + TRACE2("[keyboard] error: expected 0x%x, got 0x%x\n", + *expect, RetVal); + return RetVal; + } + } + + return 0; +} + +byte ps2AuxRead() +{ + byte Stat, Data; + + //enable(); + + while (true) + { + //while ((interrupts & 0x1000) == 0) + //; + + //interrupts &= ~0x1000; + + Stat = in(KEYB_CTRL); + if ((Stat & 0x01) != 0) + { + Data = in(KEYB_PORT); + + /* loop if parity error or receive timeout */ + if((Stat & 0xC0) == 0) + return Data; + } + } + + return (byte) -1; +} + +void ps2Packet(Ps2Mouse* ctx) +{ + int but, dx, dy, dw; + byte buf[4]; + request_t *req, *next; + mouse_packet_t* pkt; + + //putwchar(L'['); + buf[0] = ps2AuxRead(); + if (buf[0] == (byte) -1) + { + //putwchar(')'); + return; + } + + buf[1] = ps2AuxRead(); + buf[2] = ps2AuxRead(); + + if (ctx->has_wheel) + buf[3] = ps2AuxRead(); + else + buf[3] = 0; + + //putwchar(L']'); + //putwchar(L'\r'); + + /* Extract the data from the bytes read. + From svgalib ms.c. */ + but = (buf[0] & 0x04) >> 1 | /* Middle */ + (buf[0] & 0x02) >> 1 | /* Right */ + (buf[0] & 0x01) << 2; /* Left */ + dx = (buf[0] & 0x10) ? buf[1] - 256 : buf[1]; + dy = (buf[0] & 0x20) ? -(buf[2] - 256) : -buf[2]; + dw = (int) ((signed char) buf[3]); + + if (dx > 5 || dx < -5) + dx *= 4; + if (dy > 5 || dy < -5) + dy *= 4; + + TRACE4("%d %d %x %d\t", dx, dy, but, dw); + //putwchar('!'); + + if (ctx->dev.req_first) + { + for (req = ctx->dev.req_first; req; req = next) + { + //wprintf(L"ps2mouse: req = %p ", req); + pkt = (mouse_packet_t*) req->params.read.buffer; + //wprintf(L"pkt = %p\n", pkt); + + pkt->dx = dx; + pkt->dy = dy; + pkt->buttons = but; + pkt->dwheel = dw; + + next = req->next; + devFinishRequest(&ctx->dev, req); + //putwchar('.'); + } + + //putwchar('\n'); + //thrSchedule(); + } +} + +bool ps2Request(device_t* dev, request_t* req) +{ + static int in_isr = 0; + byte stat; + + TRACE2("{%c%c}", req->code / 256, req->code % 256); + switch (req->code) + { + case DEV_READ: + if (req->params.read.length < sizeof(mouse_packet_t)) + { + wprintf(L"%d: too small\n", req->params.read.length); + req->result = EBUFFER; + return false; + } + + devStartRequest(dev, req); + return true; + + case DEV_OPEN: + case DEV_CLOSE: + hndSignal(req->event, true); + return true; + + case DEV_REMOVE: + // xxx - shut down mouse + devRegisterIrq(dev, 12, false); + hndFree(dev); + hndSignal(req->event, true); + return true; + + case DEV_ISR: + stat = in(KEYB_CTRL); + if ((stat & 0x01) != 0) + { + interrupts |= 1 << req->params.isr.irq; + if (!in_isr) + { + in_isr++; + ps2Packet((Ps2Mouse*) dev); + in_isr--; + } + } + + // req->event ignored here + return true; + } + + req->result = ENOTIMPL; + return false; +} + +Ps2Mouse* INIT_CODE ps2Init(driver_t* drv, device_config_t* cfg) +{ + /* These strings nicked from gpm (I_imps2): I don't know how they work... */ + static byte s1[] = { 0xF3, 0xC8, 0xF3, 0x64, 0xF3, 0x50, 0 }; + //static byte s2[] = { 0xF6, 0xE6, 0xF4, 0xF3, 0x64, 0xE8, 0x03, 0 }; + Ps2Mouse* ctx; + const byte* ch; + byte id; + + ctx = (Ps2Mouse*) hndAlloc(sizeof(Ps2Mouse), NULL); + ctx->dev.driver = drv; + ctx->dev.request = ps2Request; + ctx->dev.req_first = ctx->dev.req_last = NULL; + + /* enable the aux port */ + kbdWrite(KEYB_CTRL, KCTRL_ENABLE_AUX); + + for (ch = s1; *ch; ch++) + { + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, *ch, KEYB_ACK); + } + + /* Bochs doesn't like this bit... */ +#if 0 + for (ch = s2; *ch; ch++) + { + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, *ch, KEYB_ACK); + } +#endif + + msleep(10); + + /* Identify mouse -- regular PS/2 mice should return zero here. + Unfortunately, my Intellimouse PS/2 also returns zero unless it has + been given the string 's2' above. Bochs doesn't support wheeled mice + and panics when it receives the F6h above. Fix needed. */ + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, AUX_IDENTIFY, KEYB_ACK); + id = kbdRead(); + + ctx->has_wheel = id == 3; + + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, 0xF3, KEYB_ACK); + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, 0xFF, KEYB_ACK); + + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, AUX_INFORMATION, KEYB_ACK); + TRACE1("[mouse] status = %d\n", kbdRead()); + TRACE1("[mouse] resolution = %d\n", kbdRead()); + TRACE1("[mouse] sample rate = %d\n", kbdRead()); + + /* enable aux device (mouse) */ + kbdWrite(KEYB_CTRL, KCTRL_WRITE_AUX); + kbdWriteRead(KEYB_PORT, AUX_ENABLE, KEYB_ACK); + + devRegisterIrq((device_t*) ctx, 12, true); + + return ctx; +} + +device_t* ps2AddDevice(driver_t* drv, const wchar_t* name, device_config_t* cfg) +{ + Ps2Mouse* mse = ps2Init(drv, cfg); + _cputws(L"PS/2 mouse driver installed\n"); + return (device_t*) mse; +} + +bool STDCALL INIT_CODE drvInit(driver_t* drv) +{ + drv->add_device = ps2AddDevice; + return true; +} + +//@} \ No newline at end of file diff --git a/mobius/src/drivers/ps2mouse/ps2mouse.d b/mobius/src/drivers/ps2mouse/ps2mouse.d new file mode 100644 index 0000000..1e7f36d --- /dev/null +++ b/mobius/src/drivers/ps2mouse/ps2mouse.d @@ -0,0 +1,18 @@ +ps2mouse.o: ps2mouse.c f:\Projects\mobius\include\stdlib.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h \ + f:\Projects\mobius\include\malloc.h \ + f:\Projects\mobius\include\kernel/kernel.h \ + f:\Projects\mobius\include\kernel/i386.h \ + f:\Projects\mobius\include\os/os.h \ + f:\Projects\mobius\include\kernel/driver.h \ + f:\Projects\mobius\include\kernel/proc.h \ + f:\Projects\mobius\include\kernel/obj.h \ + f:\Projects\mobius\include\os/pe.h \ + f:\Projects\mobius\include\kernel/handle.h \ + f:\Projects\mobius\include\os/devreq.h \ + f:\Projects\mobius\include\kernel/sys.h \ + f:\Projects\mobius\include\errno.h \ + f:\Projects\mobius\include\os/mouse.h \ + f:\Projects\mobius\include\kernel/thread.h \ + f:\Projects\mobius\include\kernel/debug.h diff --git a/mobius/src/drivers/ps2mouse/ps2mouse.dsp b/mobius/src/drivers/ps2mouse/ps2mouse.dsp new file mode 100644 index 0000000..f9d1b3a --- /dev/null +++ b/mobius/src/drivers/ps2mouse/ps2mouse.dsp @@ -0,0 +1,105 @@ +# Microsoft Developer Studio Project File - Name="ps2mouse" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=ps2mouse - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "ps2mouse.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "ps2mouse.mak" CFG="ps2mouse - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "ps2mouse - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "ps2mouse - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "ps2mouse - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f ps2mouse.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "ps2mouse.exe" +# PROP BASE Bsc_Name "ps2mouse.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "nmake /f "ps2mouse.mak"" +# PROP Rebuild_Opt "/a" +# PROP Target_File "ps2mouse.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "ps2mouse - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f ps2mouse.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "ps2mouse.exe" +# PROP BASE Bsc_Name "ps2mouse.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "set" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\bin\ps2mouse.dll" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "ps2mouse - Win32 Release" +# Name "ps2mouse - Win32 Debug" + +!IF "$(CFG)" == "ps2mouse - Win32 Release" + +!ELSEIF "$(CFG)" == "ps2mouse - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\ps2mouse.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/ps2mouse/ps2mouse.plg b/mobius/src/drivers/ps2mouse/ps2mouse.plg new file mode 100644 index 0000000..feff4d6 --- /dev/null +++ b/mobius/src/drivers/ps2mouse/ps2mouse.plg @@ -0,0 +1,18 @@ + + +
+

Build Log

+

+--------------------Configuration: ps2mouse - Win32 Debug-------------------- +

+ +gcc -D__MOBIUS__ -DKERNEL -If:\Projects\mobius\include -MD -c ps2mouse.c +link /out:f:\Projects\mobius\bin/ps2mouse.dll /nologo /debug /debugtype:coff /libpath:f:\Projects\mobius\lib /nodefaultlib /entry:drvInit /subsystem:native /base:@f:\Projects\mobius\bin\coffbase.txt,ps2mouse ps2mouse.o kernel.lib + + + +

Results

+ps2mouse.dll - 0 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/drivers/ps2mouse/vc60.pdb b/mobius/src/drivers/ps2mouse/vc60.pdb new file mode 100644 index 0000000..954d053 --- /dev/null +++ b/mobius/src/drivers/ps2mouse/vc60.pdb @@ -0,0 +1 @@ +Microsoft C/C++ program database 2.00 diff --git a/mobius/src/drivers/sermouse/Makefile b/mobius/src/drivers/sermouse/Makefile new file mode 100644 index 0000000..77eb468 --- /dev/null +++ b/mobius/src/drivers/sermouse/Makefile @@ -0,0 +1,7 @@ +TARGET= $(BIN)/sermouse.drv +OBJS= sermouse.o +BASE= sermouse + +include ../make.driver + +include $(OBJS:.o=.d) \ No newline at end of file diff --git a/mobius/src/drivers/sermouse/sermouse.c b/mobius/src/drivers/sermouse/sermouse.c new file mode 100644 index 0000000..461d8d0 --- /dev/null +++ b/mobius/src/drivers/sermouse/sermouse.c @@ -0,0 +1,316 @@ +/***************************************************************************** +serial mouse driver +*****************************************************************************/ +#include +#include +#include +#include +#include + +#define DEBUG +#include + +/*! + * \ingroup drivers + * \defgroup sermouse Serial mouse + * @{ + */ + +//#define peek40(OFF) *((word*) (0x400 + (OFF))) // xxx - FIX! +#define BUF_SIZE 64 + +typedef struct /* circular queue */ +{ + unsigned char *data; + unsigned size, in_ptr, out_ptr; +} queue_t; + +typedef struct +{ + device_t dev; + unsigned char _irq, _buffer[BUF_SIZE]; + unsigned short _io_adr; + queue_t _queue; + /* which COM port to use (1=COM1, 2=COM2, etc.) */ + unsigned char _com; +} SerMouse; + +/***************************************************************************** +*****************************************************************************/ +void enable_irq_at_8259(unsigned short irq) +{ + unsigned char mask; + + if(irq < 8) + { + mask = 1 << irq; + out(0x21, in(0x21) & ~mask); + } + else if(irq < 16) + { + irq -= 8; + mask = 1 << irq; + out(0xA1, in(0xA1) & ~mask); + out(0x21, in(0x21) & ~0x04); + } +} +/***************************************************************************** +*****************************************************************************/ +void disable_irq_at_8259(unsigned short irq) +{ + unsigned char mask; + + if(irq < 8) + { + mask = 1 << irq; + out(0x21, in(0x21) | mask); + } + else if(irq < 16) + { + irq -= 8; + mask = 1 << irq; + out(0xA1, in(0xA1) | mask); + } +} + +static __inline__ unsigned crit_begin(void) +{ + unsigned ret_val; + + __asm__ __volatile__("pushfl\n" + "popl %0\n" + "cli" + : "=a"(ret_val) + :); + return ret_val; +} + +static __inline__ void crit_end(unsigned flags) +{ + __asm__ __volatile__("pushl %0\n" + "popfl" + : + : "m"(flags) + ); +} + +int inq(queue_t *q, unsigned char data) +{ + unsigned flags, temp; + + flags = crit_begin(); + temp = q->in_ptr + 1; + if(temp >= q->size) + temp = 0; +/* if in_ptr reaches out_ptr, the queue is full */ + if(temp == q->out_ptr) + { + crit_end(flags); + return -1; + } + q->data[q->in_ptr] = data; + q->in_ptr = temp; + crit_end(flags); + return 0; +} +/***************************************************************************** +*****************************************************************************/ +int deq(queue_t *q, unsigned char *data) +{ + unsigned flags; + + flags = crit_begin(); +/* if in_ptr == out_ptr, the queue is empty */ + if(q->in_ptr == q->out_ptr) + { + crit_end(flags); + return -1; + } + *data = q->data[q->out_ptr]; + q->out_ptr++; + if(q->out_ptr >= q->size) + q->out_ptr = 0; + crit_end(flags); + return 0; +} + +bool mseRequest(device_t* dev, request_t* req) +{ + unsigned char temp; + SerMouse *ctx = (SerMouse*) dev; + + TRACE2("{%c%c}", req->code / 256, req->code % 256); + switch (req->code) + { + case DEV_READ: + if (req->params.read.length < sizeof(mouse_packet_t)) + { + TRACE1("%d: too small\n", req->params.read.length); + req->result = EBUFFER; + return false; + } + + devStartRequest(dev, req); + return true; + + case DEV_OPEN: + case DEV_CLOSE: + hndSignal(req->event, true); + return true; + + case DEV_REMOVE: + /* disable interrupts at serial chip */ + out(ctx->_io_adr + 1, 0); + /* disable interrupts at 8259s */ + disable_irq_at_8259(ctx->_irq); + hndFree(ctx); + hndSignal(req->event, true); + return true; + + case DEV_ISR: + temp = in(ctx->_io_adr + 5); + if (temp & 0x01) + { + temp = in(ctx->_io_adr + 0); + inq(&ctx->_queue, temp); + } + + in(ctx->_io_adr + 2); + + // req->event ignored here + return true; + } + + req->result = ENOTIMPL; + return false; +} + +/***************************************************************************** +*****************************************************************************/ +#define MAX_ID 16 + +bool STDCALL INIT_CODE drvInit(driver_t* drv) +{ + static const unsigned char com_to_irq[] = + { + 4, 3, 4, 3 + }; + + static const word io_port[] = + { + 0x3f8, 0x2f8, 0x3f8, 0x2f8 + }; + +/**/ + unsigned char b, id[MAX_ID], *ptr; + unsigned temp; + SerMouse *ctx; + + ctx = hndAlloc(sizeof(SerMouse), NULL); + + ctx->dev.driver = drv; + ctx->dev.request = mseRequest; + ctx->dev.req_first = ctx->dev.req_last = NULL; + ctx->_queue.data = ctx->_buffer; + ctx->_queue.size = BUF_SIZE; + ctx->_queue.in_ptr = ctx->_queue.out_ptr = 0; + ctx->_com = 1; + + if (ctx->_com < 1 || ctx->_com > 4) + { + TRACE1("Invalid COM port %u (must be 1-4)\n", ctx->_com); + return false; + } +/* get COM port I/O address from BIOS data segment */ + //ctx->_io_adr = peek40(0 + (ctx->_com - 1) * 2); + ctx->_io_adr = io_port[ctx->_com - 1]; + if(ctx->_io_adr == 0) + { + TRACE1("Sorry, no COM%u serial port on this PC\n", ctx->_com); + return false; + } + TRACE1("activating mouse on COM%u...\n", ctx->_com); + ctx->_irq = com_to_irq[ctx->_com - 1]; + /* install handler */ + devRegisterIrq((device_t*) ctx, ctx->_irq, true); + + +/* set up serial chip +turn off handshaking lines to power-down mouse, then delay */ + out(ctx->_io_adr + 4, 0); + msleep(500); + out(ctx->_io_adr + 3, 0x80); /* set DLAB to access baud divisor */ + out(ctx->_io_adr + 1, 0); /* 1200 baud */ + out(ctx->_io_adr + 0, 96); + out(ctx->_io_adr + 3, 0x02); /* clear DLAB bit, set 7N1 format */ + out(ctx->_io_adr + 2, 0); /* turn off FIFO, if any */ +/* activate Out2, RTS, and DTR to power the mouse */ + out(ctx->_io_adr + 4, 0x0B); +/* enable receiver interrupts */ + out(ctx->_io_adr + 1, 0x01); +/* enable interrupts at 8259s */ + enable_irq_at_8259(ctx->_irq); +/* wait a moment to get ID bytes from mouse. Microsoft mice just return +a single 'M' byte, some 3-button mice return "M3", my Logitech mouse +returns a string of bytes. I could find no documentation on these, +but I figured out some of it on my own. */ + ptr = id; + for(temp = 750; temp != 0; temp--) + { + while(deq(&ctx->_queue, &b) == 0) + { + TRACE1("%02X ", b); + *ptr = b; + ptr++; + if(ptr >= id + MAX_ID) + goto FOO; + } + msleep(1); + } + TRACE0("\n"); + + if (id == ptr) + TRACE0("No serial mouse found\n"); + +FOO: + if(ptr >= id + 11) + { +/* find the 'M' */ + for(ptr = id; ptr < id + MAX_ID - 7; ptr++) + { + if(*ptr == 'M') + break; + } + if(ptr < id + MAX_ID) + { +/* four bytes that each encode 4 bits of the numeric portion +of the PnP ID. Each byte has b4 set (i.e. ORed with 0x10) */ + temp = (ptr[8] & 0x0F); + temp <<= 4; + temp |= (ptr[9] & 0x0F); + temp <<= 4; + temp |= (ptr[10] & 0x0F); + temp <<= 4; + temp |= (ptr[11] & 0x0F); +/* three bytes that each encode one character of the character portion +of the PnP ID. Each byte has b5 set (i.e. ORed with 0x20) */ + TRACE4("mouse PnP ID: %c%c%c%04X\n", + '@' + (ptr[5] & 0x1F), + '@' + (ptr[6] & 0x1F), + '@' + (ptr[7] & 0x1F), temp); + } +/* example: Logitech serial mouse LGI8001 +('L' - '@') | 0x20 == 0x2C +('G' - '@') | 0x20 == 0x27 +('I' - '@') | 0x20 == 0x29 +('8' - '0') | 0x10 == 0x18 +('0' - '0') | 0x10 == 0x10 +('0' - '0') | 0x10 == 0x10 +('1' - '0') | 0x10 == 0x11 */ + } + + + return true; +} + +//@} \ No newline at end of file diff --git a/mobius/src/drivers/sermouse/sermouse.d b/mobius/src/drivers/sermouse/sermouse.d new file mode 100644 index 0000000..cef224e --- /dev/null +++ b/mobius/src/drivers/sermouse/sermouse.d @@ -0,0 +1,16 @@ +sermouse.o: sermouse.c f:\Projects\mobius\include\kernel/kernel.h \ + f:\Projects\mobius\include\kernel/i386.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h f:\Projects\mobius\include\os/os.h \ + f:\Projects\mobius\include\kernel/driver.h \ + f:\Projects\mobius\include\kernel/proc.h \ + f:\Projects\mobius\include\kernel/obj.h \ + f:\Projects\mobius\include\os/pe.h \ + f:\Projects\mobius\include\kernel/handle.h \ + f:\Projects\mobius\include\os/devreq.h \ + f:\Projects\mobius\include\kernel/sys.h \ + f:\Projects\mobius\include\os/mouse.h \ + f:\Projects\mobius\include\errno.h \ + f:\Projects\mobius\include\kernel/debug.h \ + f:\Projects\mobius\include\stdio.h \ + f:\Projects\mobius\include\stdarg.h f:\Projects\mobius\include\io.h diff --git a/mobius/src/drivers/sermouse/sermouse.dsp b/mobius/src/drivers/sermouse/sermouse.dsp new file mode 100644 index 0000000..6456bab --- /dev/null +++ b/mobius/src/drivers/sermouse/sermouse.dsp @@ -0,0 +1,105 @@ +# Microsoft Developer Studio Project File - Name="sermouse" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=sermouse - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "sermouse.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "sermouse.mak" CFG="sermouse - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "sermouse - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "sermouse - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "sermouse - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f sermouse.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "sermouse.exe" +# PROP BASE Bsc_Name "sermouse.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\bin\sermouse.dll" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "sermouse - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f sermouse.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "sermouse.exe" +# PROP BASE Bsc_Name "sermouse.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "set" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\bin\sermouse.dll" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "sermouse - Win32 Release" +# Name "sermouse - Win32 Debug" + +!IF "$(CFG)" == "sermouse - Win32 Release" + +!ELSEIF "$(CFG)" == "sermouse - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\sermouse.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/sermouse/sermouse.plg b/mobius/src/drivers/sermouse/sermouse.plg new file mode 100644 index 0000000..0aaff75 --- /dev/null +++ b/mobius/src/drivers/sermouse/sermouse.plg @@ -0,0 +1,18 @@ + + +
+

Build Log

+

+--------------------Configuration: sermouse - Win32 Debug-------------------- +

+ +gcc -D__MOBIUS__ -DKERNEL -O2 -Wall -If:\Projects\mobius\include -MD -c sermouse.c +link /out:f:\Projects\mobius\bin/sermouse.drv /nologo /debug /debugtype:coff /libpath:f:\Projects\mobius\lib /nodefaultlib /entry:drvInit /subsystem:native /base:@f:\Projects\mobius\bin\coffbase.txt,sermouse sermouse.o kernel.lib + + + +

Results

+sermouse.dll - 0 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/drivers/sound/Makefile b/mobius/src/drivers/sound/Makefile new file mode 100644 index 0000000..9b60e68 --- /dev/null +++ b/mobius/src/drivers/sound/Makefile @@ -0,0 +1,14 @@ +TARGET= $(BIN)/sound.drv +BASE= sound + +WSS= wss/wss.o +SB= sb/sb.o +SOLO1= solo1/solo1.o +FORMATS=wav.o wav01.o wav02.o wav06.o wav07.o wav34.o \ + wav49.o wav85.o au.o au01.o au023.o au27.o +OBJS= sound.o dma.o $(SOLO1) +LIBS= $(LIB)/pci.lib + +include ../make.driver + +include $(OBJS:.o=.d) diff --git a/mobius/src/drivers/sound/au.c b/mobius/src/drivers/sound/au.c new file mode 100644 index 0000000..be260db --- /dev/null +++ b/mobius/src/drivers/sound/au.c @@ -0,0 +1,49 @@ +/***************************************************************************** +common routines for .au files + +.au sub-formats: + 1=8-bit u-law + 2=8-bit linear + 3=16-bit linear + 27=A-law (not implemented) +*****************************************************************************/ +#include /* memcmp() */ +#include /* FILE, EOF, fread(), fgetc() */ +#include "sound.h" /* soundinfo */ + +/* byte offsets in .au file header */ +#define AU_HDR_MAGIC 0 +#define AU_HDR_HDRLEN 4 +#define AU_HDR_DATALEN 8 +#define AU_HDR_FMT 12 +#define AU_HDR_RATE 16 +#define AU_HDR_CHAN 20 +#define AU_HDR_SIZE 24 +/***************************************************************************** +*****************************************************************************/ +int au_validate(sound_info_t *info, unsigned sub_type) +{ + unsigned char buffer[AU_HDR_SIZE]; + unsigned long hdr_len; + + fseek(info->infile, 0, SEEK_SET); + if(fread(buffer, 1, AU_HDR_SIZE, info->infile) != AU_HDR_SIZE) + return -1; + if(memcmp(buffer + AU_HDR_MAGIC, ".snd", 4)) + return -1; +/* get data and header lengths */ + hdr_len = read_be32(buffer + AU_HDR_HDRLEN); + info->bytes_left = read_be32(buffer + AU_HDR_DATALEN); +/* coding */ + if(read_be32(buffer + AU_HDR_FMT) != sub_type) + return -1; + info->rate = read_be32(buffer + AU_HDR_RATE); + info->channels = read_be32(buffer + AU_HDR_CHAN); +/* skip rest of header */ + for(hdr_len -= AU_HDR_SIZE; hdr_len != 0; hdr_len--) + { + if(fgetc(info->infile) == EOF) + return -1; + } + return 0; +} diff --git a/mobius/src/drivers/sound/au01.c b/mobius/src/drivers/sound/au01.c new file mode 100644 index 0000000..4fb3a84 --- /dev/null +++ b/mobius/src/drivers/sound/au01.c @@ -0,0 +1,50 @@ +/***************************************************************************** +mu-law +sub-format 1 of .au format +*****************************************************************************/ +#include /* EOF, fgetc() */ +#include "sound.h" + +/* in MISC.C */ +short mulaw_expand(unsigned char data); + +/* in AU.C */ +int au_validate(sound_info_t *info, unsigned sub_type); +/***************************************************************************** +*****************************************************************************/ +static int get_sample(sound_info_t *info, short *left, short *right) +{ + int temp; + + temp = fgetc(info->infile); + if(temp == EOF) + return -1; + info->bytes_left--; + *left = mulaw_expand(temp); + if(info->channels == 1) + { + *right = *left; + return 0; + } + temp = fgetc(info->infile); + if(temp == EOF) + return -1; + info->bytes_left--; + *right = mulaw_expand(temp); + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static int validate(sound_info_t *info) +{ + fseek(info->infile, 0, SEEK_SET); + info->depth = 16; +/* au sub-format #1 is u-law */ + return au_validate(info, 1); +} +/***************************************************************************** +*****************************************************************************/ +codec_t _au01 = +{ + ".au mu-law", validate, get_sample +}; diff --git a/mobius/src/drivers/sound/au023.c b/mobius/src/drivers/sound/au023.c new file mode 100644 index 0000000..f0d51fd --- /dev/null +++ b/mobius/src/drivers/sound/au023.c @@ -0,0 +1,75 @@ +/***************************************************************************** +linear PCM +(8-bit) sub-format 2 of .au format +(16-bit) sub-format 3 of .au format + +Sox appears to make 16-bit linear PCM .au files when +asked to convert 16-bit .wav files to .au format +*****************************************************************************/ +#include /* EOF, fgetc() */ +#include "sound.h" + +/* in AU.C */ +int au_validate(sound_info_t *info, unsigned sub_type); +/***************************************************************************** +*****************************************************************************/ +static int get_sample(sound_info_t *info, short *left, short *right) +{ + unsigned char buffer[4]; + + if(info->depth == 16 && info->channels == 2) + { + if(fread(buffer, 1, 4, info->infile) != 4) + return -1; + *left = read_be16(buffer + 0); + *right = read_be16(buffer + 2); + } + else if(info->depth == 16 && info->channels == 1) + { + if(fread(buffer, 1, 2, info->infile) != 2) + return -1; + *left = read_be16(buffer + 0); + *right = *left; + } + else if(info->depth == 8 && info->channels == 2) + { + if(fread(buffer, 1, 2, info->infile) != 2) + return -1; + *left = buffer[0] << 8; + *right = buffer[1] << 8; + } + else if(info->depth == 8 && info->channels == 1) + { + if(fread(buffer, 1, 1, info->infile) != 1) + return -1; + *left = buffer[0] << 8; + *right = *left; + } + else + return -1; + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static int validate(sound_info_t *info) +{ + int err; + + fseek(info->infile, 0, SEEK_SET); +/* au sub-format #2 is 8-bit PCM */ + info->depth = 8; + err = au_validate(info, 2); + if(err != 0) + { +/* au sub-format #3 is 16-bit PCM */ + info->depth = 16; + err = au_validate(info, 3); + } + return err; +} +/***************************************************************************** +*****************************************************************************/ +codec_t _au023 = +{ + ".au linear PCM", validate, get_sample +}; diff --git a/mobius/src/drivers/sound/au27.c b/mobius/src/drivers/sound/au27.c new file mode 100644 index 0000000..1ecd449 --- /dev/null +++ b/mobius/src/drivers/sound/au27.c @@ -0,0 +1,50 @@ +/***************************************************************************** +A-law +sub-format 27 of .au format +*****************************************************************************/ +#include /* EOF, fgetc() */ +#include "sound.h" + +/* in MISC.C */ +short alaw_expand(unsigned char data); + +/* in AU.C */ +int au_validate(sound_info_t *info, unsigned sub_type); +/***************************************************************************** +*****************************************************************************/ +static int get_sample(sound_info_t *info, short *left, short *right) +{ + int temp; + + temp = fgetc(info->infile); + if(temp == EOF) + return -1; + info->bytes_left--; + *left = alaw_expand(temp); + if(info->channels == 1) + { + *right = *left; + return 0; + } + temp = fgetc(info->infile); + if(temp == EOF) + return -1; + info->bytes_left--; + *right = alaw_expand(temp); + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static int validate(sound_info_t *info) +{ + fseek(info->infile, 0, SEEK_SET); + info->depth = 16; +/* au sub-format #27 is A-law */ + return au_validate(info, 27); +} +/***************************************************************************** +*****************************************************************************/ +codec_t _au27 = +{ + ".au A-law", validate, get_sample +}; diff --git a/mobius/src/drivers/sound/dj.mak b/mobius/src/drivers/sound/dj.mak new file mode 100644 index 0000000..460a007 --- /dev/null +++ b/mobius/src/drivers/sound/dj.mak @@ -0,0 +1,53 @@ +MAKEFILE=dj.mak +DEBUG =-g -W -Wall +CFLAGS =$(DEBUG) -O2 +LFLAGS =$(DEBUG) + +OBJS =play.o misc.o irq.o dma.o \ + wss.o sb.o \ + wav.o wav01.o wav02.o wav06.o wav07.o wav34.o \ + wav49.o wav85.o au.o au01.o au023.o au27.o + +all: play.exe + +.c.o: + gcc $(CFLAGS) -c -o$@ $< + +play.exe: $(OBJS) $(MAKEFILE) + gcc $(LFLAGS) -o play.exe $(OBJS) + +dma.o: dma.c $(MAKEFILE) + +irq.o: irq.c defs.h irq.h $(MAKEFILE) + +wss.o: wss.c defs.h irq.h $(MAKEFILE) + +play.o: play.c defs.h $(MAKEFILE) + +wav.o: wav.c defs.h $(MAKEFILE) + +wav01.o: wav01.c defs.h $(MAKEFILE) + +wav02.o: wav02.c defs.h $(MAKEFILE) + +wav06.o: wav06.c defs.h $(MAKEFILE) + +wav07.o: wav07.c defs.h $(MAKEFILE) + +wav34.o: wav34.c defs.h $(MAKEFILE) + +wav49.o: wav49.c defs.h $(MAKEFILE) + +wav85.o: wav85.c defs.h $(MAKEFILE) + +au.o: au.c defs.h $(MAKEFILE) + +au01.o: au01.c defs.h $(MAKEFILE) + +au023.o: au023.c defs.h $(MAKEFILE) + +au27.o: au27.c defs.h $(MAKEFILE) + +clean: + del *.o + del *.exe diff --git a/mobius/src/drivers/sound/dma.c b/mobius/src/drivers/sound/dma.c new file mode 100644 index 0000000..6ce00af --- /dev/null +++ b/mobius/src/drivers/sound/dma.c @@ -0,0 +1,98 @@ +#include /* printf() */ +#include "sound.h" /* bool */ + +static const unsigned short _single_reg[8] = +{ + 0x0A, 0x0A, 0x0A, 0x0A, 0xD4, 0xD4, 0xD4, 0xD4 +}; +static const unsigned char _disable_cmd[8] = +{ + 0x04, 0x05, 0x06, 0x07, 0x04, 0x05, 0x06, 0x07, +}; +static const unsigned short _mode_reg[8] = +{ + 0x0B, 0x0B, 0x0B, 0x0B, 0xD6, 0xD6, 0xD6, 0xD6 +}; +static const unsigned short _ff_reg[8] = +{ + 0x0C, 0x0C, 0x0C, 0x0C, 0xD8, 0xD8, 0xD8, 0xD8 +}; +static const unsigned short _adr_reg[8] = +{ + 0x00, 0x02, 0x04, 0x06, 0xC0, 0xC4, 0xC8, 0xCC +}; +static const unsigned short _page_reg[8] = +{ + 0x87, 0x83, 0x81, 0x82, 0x8F, 0x8B, 0x89, 0x8A +}; +static const unsigned short _count_reg[8] = +{ + 0x01, 0x03, 0x05, 0x07, 0xC2, 0xC6, 0xCA, 0xCE +}; +static const unsigned char _enable_cmd[8] = +{ + 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, +}; +/***************************************************************************** +*****************************************************************************/ +int dma_from_mem(unsigned char chan, unsigned long adr, unsigned long count, + bool auto_init) +{ + static const unsigned char write_cmd[8] = + { + 0x48, 0x49, 0x4A, 0x4B, 0x48, 0x49, 0x4A, 0x4B + }; + +/* validate chan */ + if(chan > 7) + { + wprintf(L"dma_from_mem: DMA channel (%u) > 7\n", chan); + return -1; + } +/* 16 bit data is halved */ + if(chan >= 4) + { + adr >>= 1; + count >>= 1; + } + count--; +/* make sure transfer doesn't exceed max or cross a 64K boundary */ + if(adr + count >= 0x100000L) /* real mode; 1 meg */ +// if(adr + count >= 0x1000000L) /* pmode; 16 meg */ + { + wprintf(L"dma_from_mem: end adr (0x%lX) exceeds max\n", + adr + count); + return -2; + } + if((adr & 0x10000L) != ((adr + count) & 0x10000L)) + { + wprintf(L"dma_from_mem: DMA from adrs 0x%lX - 0x%lX " + "crosses 64K boundary\n", adr, adr + count); + return -3; + } +/* disable channel */ + out(_single_reg[chan], _disable_cmd[chan]); +/* set mode */ + out(_mode_reg[chan], + auto_init ? (write_cmd[chan] | 0x10) : write_cmd[chan]); +/* clear flip-flop, for LSB of address */ + out(_ff_reg[chan], 0); +/* address LSB */ + out(_adr_reg[chan], adr); + adr >>= 8; +/* address MSB */ + out(_adr_reg[chan], adr); + adr >>= 8; +/* page */ + out(_page_reg[chan], adr); +/* clear flip-flop, for LSB of count */ + out(_ff_reg[chan], 0); +/* count LSB */ + out(_count_reg[chan], count); + count >>= 8; +/* count MSB */ + out(_count_reg[chan], count); +/* enable channel */ + out(_single_reg[chan], _enable_cmd[chan]); + return 0; +} diff --git a/mobius/src/drivers/sound/misc.c b/mobius/src/drivers/sound/misc.c new file mode 100644 index 0000000..4648ea9 --- /dev/null +++ b/mobius/src/drivers/sound/misc.c @@ -0,0 +1,95 @@ +/***************************************************************************** +*****************************************************************************/ +short mulaw_expand(unsigned char data) +{ + static const unsigned short exp_tab[8] = + { + 0, 132, 396, 924, 1980, 4092, 8316, 16764 + }; + unsigned char exp; + short ret_val; + + data = ~data; + exp = (data >> 4) & 7; + ret_val = exp_tab[exp] + ((data & 0x0F) << (exp + 3)); + if((data & 0x80) != 0) + ret_val = -ret_val; + return ret_val; +} +/***************************************************************************** +xxx - use a formula, like u-law +*****************************************************************************/ +short alaw_expand(unsigned char data) +{ + static const short alaw2dma16[] = + { + -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736, + -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784, + -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368, + -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392, + -22016, -20992, -24064, -23040, -17920, -16896, -19968, -18944, + -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136, + -11008, -10496, -12032, -11520, -8960, -8448, -9984, -9472, + -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568, + -344, -328, -376, -360, -280, -264, -312, -296, + -472, -456, -504, -488, -408, -392, -440, -424, + -88, -72, -120, -104, -24, -8, -56, -40, + -216, -200, -248, -232, -152, -136, -184, -168, + -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184, + -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696, + -688, -656, -752, -720, -560, -528, -624, -592, + -944, -912, -1008, -976, -816, -784, -880, -848, + 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736, + 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784, + 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368, + 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392, + 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944, + 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136, + 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472, + 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568, + 344, 328, 376, 360, 280, 264, 312, 296, + 472, 456, 504, 488, 408, 392, 440, 424, + 88, 72, 120, 104, 24, 8, 56, 40, + 216, 200, 248, 232, 152, 136, 184, 168, + 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184, + 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696, + 688, 656, 752, 720, 560, 528, 624, 592, + 944, 912, 1008, 976, 816, 784, 880, 848 + }; + + return alaw2dma16[data]; +} +/***************************************************************************** +this function assumes sizeof(long)==4 +and it assumes little-endian CPU (e.g. x86) +*****************************************************************************/ +unsigned long read_be32(unsigned char *buffer) +{/* 'volatile' makes code a little smaller with GCC for x86 */ + volatile union + { + unsigned long dword; + unsigned char byte[4]; + } temp; + + temp.byte[0] = buffer[3]; + temp.byte[1] = buffer[2]; + temp.byte[2] = buffer[1]; + temp.byte[3] = buffer[0]; + return temp.dword; +} +/***************************************************************************** +this function assumes sizeof(short)==2 +and it assumes little-endian CPU (e.g. x86) +*****************************************************************************/ +unsigned short read_be16(unsigned char *buffer) +{ + union + { + unsigned long word; + unsigned char byte[2]; + } temp; + + temp.byte[0] = buffer[1]; + temp.byte[1] = buffer[0]; + return temp.word; +} diff --git a/mobius/src/drivers/sound/play.c b/mobius/src/drivers/sound/play.c new file mode 100644 index 0000000..56c0dbe --- /dev/null +++ b/mobius/src/drivers/sound/play.c @@ -0,0 +1,172 @@ +/***************************************************************************** +sndpkg release 2 - sound file player for DOS +Chris Giese , http://www.execpc.com/~geezer +Release date: Jan 3, 2001 +*****************************************************************************/ +#include /* strlen(), strcmpi() */ +#include /* FILE, printf(), fopen(), fread(), fclose() */ +#include /* kbhit(), getch() */ +#include /* MK_FP() */ +#include "sound.h" + +/* The nice thing about standards is... */ +#if defined(__DJGPP__) +#define strcmpi(A, B) stricmp(A, B) +#endif + +extern sound_t wss_drv, sb_drv; + +/* the Sound Blaster driver (sb_drv) does not yet work */ +static sound_t *_drv = &wss_drv; +//static driver_t *_drv = &sb_drv; + +extern codec_t _wav01, _wav02, _wav06, _wav07, _wav34, _wav49, _wav85; +extern codec_t _au01, _au023, _au27; + +static codec_t *_codecs[] = +{ +/* 0 */ &_wav01, &_wav02, &_wav06, &_wav07, &_wav34, &_wav49, &_wav85, +/* 7 */ &_au01, &_au023, &_au27 +/* 10 */ +}; +/***************************************************************************** +*****************************************************************************/ +static int play(char *filename) +{ + static short volume = 224; + static bool is_open; + unsigned short start_codec, curr_codec, key; + short left, right; + sound_info_t info; + codec_t *codec; + bool wait; + char *ext; + + wait = true; + info.fsd = NULL; +/* open .WAV file */ + info.infile = fopen(filename, "rb"); + if(info.infile == NULL) + { + wprintf(L"Can't open file '%s'\n", filename); + return 1; + } +/* deduce file type from filename extension. +Not to fear, if we guess wrong, all codecs will be checked. +Start checking with codec #0 (.WAV files) */ + start_codec = 0; + ext = filename + strlen(filename); + do + { + ext--; + if(*ext == '.') + { +/* if filename ends with ".au", start checking with codec #7 */ + if(!strcmpi(ext, ".au")) + start_codec = 7; +/* else if(!strcmpi(ext, ".voc")) + start_codec = ?; + else if(!strcmpi(ext, ".mp3")) + start_codec = ?; */ + break; + } + } while(ext > filename); +/* check format */ + curr_codec= start_codec; + do + { + codec = _codecs[curr_codec]; + wprintf(L"\tchecking %s...", codec->name); + if(codec->validate(&info) == 0) + { + wprintf(L"OK\n"); + goto OK; + } + wprintf(L"no\n"); + curr_codec++; + if(curr_codec >= sizeof(_codecs) / sizeof(_codecs[0])) + curr_codec = 0; + } while(curr_codec != start_codec); + wprintf(L"Unknown or unsupported file format or codec\n"); + return 2; +OK: + wprintf(L"File '%s': %u bits/sample, %ld samples/sec, %s\n", + filename, info.depth, info.rate, + info.channels == 1 ? "mono" : "stereo"); + if(!is_open) + { +/* detect hardware, activate it, alloc buffers, install interrupt handler */ + if(_drv->open() != 0) + { + wprintf(L"Error opening sound hardware\n"); + fclose(info.infile); + return 1; + } +/* other things to be done only once */ + wprintf(L"PgUp, PgDn set volume; Esc stops; Pause pauses\n"); + _drv->set_volume(volume); + is_open = true; + } + info.rate = _drv->find_closest_rate(info.rate); + if(_drv->set_fmt(info.depth, info.channels, info.rate) != 0) + { + wprintf(L"Error setting sound format (depth %u, channels %u, " + "rate %lu)\n", info.depth, info.channels, info.rate); + fclose(info.infile); + return 1; + } +/* play it */ + while(codec->get_sample(&info, &left, &right) == 0) + { + if(kbhit()) + { + key = getch(); + if(key == 0) + key = 0x100 | getch(); + if(key == 27) + { + wait = false; /* abort playback */ + break; + } + else if(key == 0x149) + { + volume += 4; + if(volume > 255) + volume = 255; + _drv->set_volume(volume); + } + else if(key == 0x151) + { + volume -= 4; + if(volume < 0) + volume = 0; + _drv->set_volume(volume); + } + } + if(_drv->write_sample(left, right) != 0) + { + wait = false; + break; + } + } +/* wait until playback is done (or abort playback) */ + _drv->stop_playback(wait); + fclose(info.infile); + return 0; +} +/***************************************************************************** +*****************************************************************************/ +int main(int arg_c, char *arg_v[]) +{ + int i; + + if(arg_c < 2) + { + wprintf(L"Plays .WAV and .au files\n"); + return 1; + } + for(i = 1; i < arg_c; i++) + (void)play(arg_v[i]); + _drv->close(); + return 0; +} diff --git a/mobius/src/drivers/sound/readme.txt b/mobius/src/drivers/sound/readme.txt new file mode 100644 index 0000000..a286f2d --- /dev/null +++ b/mobius/src/drivers/sound/readme.txt @@ -0,0 +1,89 @@ +================================================================ +sndpkg +================================================================ +Plays .WAV and .AU files in various formats (PCM, mu-law, A-law, +Microsoft ADPCM, and GSM) under DOS, using Windows Sound System +(WSS) sound board. + +Chris Giese , http://www.execpc.com/~geezer +Release date: Jan 3, 2001 + +You can do anything with this code but blame me for it or +call it your own. + +Send E-mail if you like it, hate it, or want to help with these: + +================================================================ +BUGS/PLANS/TO DO +================================================================ +showstoppers: +- put back DMA-probing code in wss.c +- wss.c: if you can't fill a buffer with data (i.e. at end of + input file), fill it with zeroes (or do something else to + make short files work with large buffers) +- include Win32 driver -OR- working SoundBlaster driver + (these are more common sound devices than my WSS) +- pin DJGPP interrupt functions into memory + +- test for DMA problems on machine with >16 meg RAM +- WSS softset doesn't work reliably +- can't probe board after running old version of play.exe +- finish/fix Sound Blaster driver +- restore Linux driver +- use formula (like mu-law) instead of table in alaw.c +- catch Ctrl-C and Ctrl-Break? + +- documentation +- list key registers of Sound Blaster +- port wss.c and sb.c to NASM, implement as DOS device driver + (SOUND$) TSR, that can be loaded/unloaded from command-line +- VOC files +- AIFF support, including AIFC with G.722 compression +- MP3 +- CELP (old 28.8 Real Audio) +- utilities/special effects: + reverb, reverse + increase/decrease playback speed + increase/decrease/maximize volume + mix sound files + equalizer/tone control/filtering + DTMF (TouchTone) detection +- add ability to write files in these formats, as well as read them +- Linux: shared library codecs, loadable at run-time? + good for proprietary/NDA codecs like TrueSpeech + (does xanim already do this?) +- write X11 clone of Win95 sound recorder +- test on big endian machine + +================================================================ +SOURCES +================================================================ +Voxware sound driver for Linux, by Hannu Savolainen +(hannu@voxware.pp.fi), for info on softsetting WSS DMA and IRQ +and providing initial working code. + +Voxware sound driver for Linux, by Michael Schlueter +(michael@duck.syd.de) and Michael Marte +(marte@informatik.uni-muenchen.de) for providing A-law decoding +table. + +DMA code came from Intel 8237 data sheet and some public-domain +code that I got from Simtel. + +AD1848 data sheet in .PDF format. It used to be on Analog +Devices web site (www.analog.com) but no longer. I still have a +copy; E-mail me if you want it. + +Marc Brevoort (m.r.j.Brevoort@ipr.nl) helped me get the original +AD1848-based player off the ground. He has AD1848 code for DOS +in Pascal. + +Sox and Chris Bagwell's Audio File Formats FAQ, for information +on WAV, au, and other files formats. + +Toast; the freeware GSM encoder/decoder from Jutta Degener and +Carsten Bormann. + +Allegro game library, for DMA code and for Antti Koskipaa's +Windows Sound System driver. + diff --git a/mobius/src/drivers/sound/sb/sb.c b/mobius/src/drivers/sound/sb/sb.c new file mode 100644 index 0000000..f7d93ed --- /dev/null +++ b/mobius/src/drivers/sound/sb/sb.c @@ -0,0 +1,487 @@ +#include "sound.h" /* DEBUG(X), among others */ +#include + +#define vpokeb(O,V) i386_lpoke8(0xB8000 + (O), V) + +/* DSP buffers -- large for few interrupts, small for responsiveness */ +#define NUM_BUFS 2 +#define LG2_BUF_SIZE 13 + +/* BUF_SIZE must be a multiple of PAGE_SIZE => LG2_BUF_SIZE >= PAGE_BITS */ +#define BUF_SIZE (1u << (LG2_BUF_SIZE)) + +#define PEEK_DLY 100 +#define POKE_DLY 100 +#define RESET_DLY 100 + +#define SBREG_MIX_ADR 0x04 +#define SBREG_MIX_DATA 0x05 +#define SBREG_RESET 0x06 +#define SBREG_READ 0x0A +#define SBREG_WRITE 0x0C +#define SBREG_POLL 0x0E + +#define SBCMD_PLAY 0x14 /* 8-bit DMA low-speed playback */ +#define SBCMD_SET_RATE 0x40 /* set sampling rate */ +#define SBCMD_SPKR_ON 0xD1 /* turn on speaker */ +#define SBCMD_SPKR_OFF 0xD3 /* turn OFF speaker */ +#define SBCMD_VERSION 0xE1 /* get DSP version */ +#define SBCMD_INTERRUPT 0xF2 /* generate an interrupts (for IRQ probe) */ + +/* in DMA.C */ +int dma_from_mem(unsigned char chan, unsigned long adr, unsigned long count, + bool auto_init); + +static unsigned char * volatile _dsp_buff_out; +static unsigned char *_dsp_buff_base, *_dsp_buff_in; +static volatile bool _playback_in_progress; + +static unsigned short _ioadr; +static unsigned char _irq, _dma = 3; +static bool _is_open, _16bit, _stereo; + +typedef struct sb_t sb_t; +struct sb_t +{ + sound_t snd; + device_t *dev; +}; + +/***************************************************************************** + name: sb_poke + action: waits up to 0.1 second for Sound Blaster DSP to become ready, + then writes command byte val + returns:0 if success + -1 if timeout +*****************************************************************************/ +static int sb_poke(sound_t *snd, unsigned char val) +{ + unsigned temp; + + for(temp = POKE_DLY; temp != 0; temp--) + { + if ((in(_ioadr + SBREG_WRITE) & 0x80) == 0) + { + out(_ioadr + SBREG_WRITE, val); + return 0; + } + msleep(1); + } + return -1; +} +/***************************************************************************** + name: sb_peek + action: waits up to 0.1 second for Sound Blaster DSP to become ready, + then reads data byte from chip + returns:0 if success + -1 if timeout +*****************************************************************************/ +static int sb_peek(sound_t *snd)//unsigned long Timeout) +{ + unsigned temp; + + for(temp = PEEK_DLY; temp != 0; temp--) + { + if((in(_ioadr + SBREG_POLL) & 0x80) == 0) + return in(_ioadr + SBREG_READ); + msleep(1); + } + return -1; +} +/***************************************************************************** +*****************************************************************************/ +static int sb_detect(sound_t *snd, unsigned short ioadr) +{ + unsigned short temp; + +/* SB reset: + 1) Write a 1 to the reset port (2x6) */ + out(ioadr + SBREG_RESET, 0x01); +/* 2) Wait for 3 microseconds */ + msleep(1); +/* 3) Write a 0 to the reset port (2x6) */ + out(ioadr + SBREG_RESET, 0); +/* 4) Poll the read-buffer status port (2xE) until bit 7 is set */ + for(temp = RESET_DLY; temp != 0; temp--) + { + msleep(1); + if(in(ioadr + SBREG_POLL) & 0x80) + break; + } + if(temp == 0) + return -1; +/* 5) Poll the read data port (2xA) until you receive an AA + +The DSP usually takes about 100 microseconds to initialized itself. +After this period of time, if the return value is not AA or there +is no data at all, then the SB card may not be installed or an +incorrect I/O address is being used. */ + for(temp = RESET_DLY; temp != 0; temp--) + { + msleep(1); + if(in(ioadr + SBREG_READ) == 0xAA) + break; + } + if(temp == 0) + return -1; + + (void)sb_poke(snd, SBCMD_VERSION); + //temp = sb_peek(snd); + temp = in(_ioadr + SBREG_READ); + wprintf(L"\tDSP version: %u.%u\n", temp, in(_ioadr + SBREG_READ)); + + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static void sb_set_volume(sound_t *snd, unsigned char level) +{ +// xxx +} +/***************************************************************************** +*****************************************************************************/ +static long sb_find_closest_rate(sound_t *snd, long rate) +{ + unsigned short time_const; + unsigned long ret_val; + +/* xxx - different algorithm for high-speed */ + time_const = 256L - 1000000L / rate; + if(time_const > 255) + return 0; + ret_val = 1000000L / (256L - time_const); + TRACE2("sb_find_closest_rate: %ld -> %ld\n", rate, ret_val); + return ret_val; +} +/***************************************************************************** +*****************************************************************************/ +static int sb_set_fmt(sound_t *snd, unsigned char depth, + unsigned char channels, long rate) +{ + unsigned short time_const; + unsigned char temp; + +/* xxx - different algorithm for high-speed */ + time_const = 256L - 1000000L / rate; + if(time_const > 255) + return -1; + if(sb_poke(snd, SBCMD_SET_RATE) != 0 || sb_poke(snd, time_const) != 0) + return -1; + +/* need SB16 (or better) only */ +// if(_Major < 0/* xxx */) +// return -1; +// if(_Minor < 0/* xxx */) +// return -1; + if(depth == 16) + _16bit = true; +// _Mode |= 0x0100; + else if(depth == 8) + _16bit = false; +// _Mode &= ~0x0100; + +/* need SB Pro (or better) only */ +// if(_Major < 0/* xxx */) +// return -1; +// if(_Minor < 0/* xxx */) +// return -1; + + out(_ioadr + SBREG_MIX_ADR, 0x0E); + temp = in(_ioadr + SBREG_MIX_DATA); + if(channels == 2) + { + _stereo = true; + temp |= 2; + } + else + { + _stereo = false; + temp &= ~2; + } + out(_ioadr + SBREG_MIX_DATA, temp); + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static void sb_start_playback(sound_t *snd, unsigned long count) +{ + count--; +/* unmute outputs, if not already unmuted */ + (void)sb_poke(snd, SBCMD_SPKR_ON); +/* start playback +xxx - different cmd (0x91 ?) for high-sped */ + (void)sb_poke(snd, SBCMD_PLAY); + (void)sb_poke(snd, count); + (void)sb_poke(snd, count >> 8); + _playback_in_progress = true; +} +/***************************************************************************** +*****************************************************************************/ +static void sb_stop_playback(sound_t *snd, bool wait) +{ + if(wait) + { + TRACE0("waiting...\n"); + while(_playback_in_progress) + /* nothing */; + } + else + { +/* mute outputs */ + (void)sb_poke(snd, SBCMD_SPKR_OFF); +/* end playback */ + // xxx + _playback_in_progress = false; + } +} +/***************************************************************************** +*****************************************************************************/ +static void sb_irq(sound_t *snd, unsigned num) +{ + unsigned short in_buf, out_buf; + + TRACE0("sb_irq\n"); + +/* clear interrupt at Sound Blaster */ + (void)in(_ioadr + SBREG_POLL); +/* clear interrupt at 8259 interrupt chips */ + //out(0x20, 0x20); + //if(_irq >= 8) + //out(0xA0, 0x20); +/* advance pointer */ + _dsp_buff_out += BUF_SIZE; + if(_dsp_buff_out >= _dsp_buff_base + NUM_BUFS * BUF_SIZE) + _dsp_buff_out = _dsp_buff_base; +/* are we now trying to play from the buffer currently being written? */ + in_buf = _dsp_buff_in - _dsp_buff_base; + in_buf >>= LG2_BUF_SIZE; + out_buf = _dsp_buff_out - _dsp_buff_base; + out_buf >>= LG2_BUF_SIZE; +/* yes, stop playback */ + if(in_buf == out_buf) + { +/* do NOT use printf() in an interrupt handler! */ + TRACE0("sb_irq: stopping\n"); + sb_stop_playback(snd, false); + } +} +/***************************************************************************** +*****************************************************************************/ +static int write_sample(sound_t *snd, short left, short right) +{ + unsigned short in_buf, out_buf, new_in_buf, count; + bool wait = false; + +/* to which buffer are we writing? */ + in_buf = _dsp_buff_in - _dsp_buff_base; + in_buf >>= LG2_BUF_SIZE; + while(1) +/* from which buffer are we playing? */ + { + out_buf = _dsp_buff_out - _dsp_buff_base; + out_buf >>= LG2_BUF_SIZE; +/* if they are the same, and if playback is active, +then wait until playback of this buffer is complete */ + if(out_buf != in_buf) + break; + if(!_playback_in_progress) + break; + if(!wait) + { + TRACE0("waiting..."); + wait = true; + } + } +/* store sample and advance pointer */ + if(_16bit) + { + write_le16(_dsp_buff_in, left); + _dsp_buff_in += 2; + if(_stereo) + { + write_le16(_dsp_buff_in, right); + _dsp_buff_in += 2; + count = BUF_SIZE >> 2; + } + else + count = BUF_SIZE >> 1; + } + else + { + left >>= 8; + *_dsp_buff_in = left; + _dsp_buff_in++; + if(_stereo) + { + right >>= 8; + *_dsp_buff_in = right; + _dsp_buff_in++; + count = BUF_SIZE >> 1; + } + else + count = BUF_SIZE; + } + if(_dsp_buff_in >= _dsp_buff_base + NUM_BUFS * BUF_SIZE) + _dsp_buff_in = _dsp_buff_base; +/* did we cross over into a new buffer? */ + new_in_buf = _dsp_buff_in - _dsp_buff_base; + new_in_buf >>= LG2_BUF_SIZE; +/* if yes, and if not currently playing, then kick-start playback */ + if((new_in_buf != in_buf) && !_playback_in_progress) + { +/* you should see this message ONCE, when playback starts +see it again if you pause/unpause the playback + +if you see it many times, something's wrong */ + wprintf(L"*** kicking playback ***\n"); + sb_start_playback(snd, count); + } + return 0; +} +/***************************************************************************** +*****************************************************************************/ + +#define f2l(X) ((addr_t)(X)) + +/***************************************************************************** +*****************************************************************************/ +static void sb_close(sound_t *snd) +{ + sb_t *sb = (sb_t*) snd; + TRACE0("sb_close\n"); +/* already closed? */ + if(!_is_open) + { + wprintf(L"sb_close: sound hardware already closed\n"); + return; + } +/* abort playback */ + if(_playback_in_progress) + { + TRACE0("aborting playback...\n"); + sb_stop_playback(snd, false); + } +/* restore old interrupt vector */ + devRegisterIrq(sb->dev, _irq, false); + _is_open = false; +} + +/***************************************************************************** +*****************************************************************************/ +static bool sb_open(sound_t *snd) +{ + static const unsigned short base_io_adr[] = + { + 0x220, 0x230, 0x240 + }; + unsigned short temp; +// unsigned char dma_mask; + int err = -1; + dword index; + sb_t *sb = (sb_t*) snd; + +/* already open? */ + if(_is_open) + { + wprintf(L"sb_open: sound hardware already open\n"); + return false; + } + + index = devFindResource(sb->dev->config, dresIrq, 0); + if (index == (dword) -1) + return false; + + _irq = sb->dev->config->resources[index].u.irq; + +/* PROBE FOR HARDWARE */ + TRACE1("sb_open: probing for Sound Blaster: IRQ %d\n", _irq); +/* probe for DSP chip */ + temp = 0; + for(; temp < sizeof(base_io_adr) / sizeof(base_io_adr[0]); temp++) + { + _ioadr = base_io_adr[temp]; + TRACE1("\tprobing at I/O=0x%03X...\n", _ioadr); + err = sb_detect(snd, _ioadr); + if(err == 0) + break; + } + if(err != 0) + { + wprintf(L"\terror: Sound Blaster not detected\n"); + return false; + } + + for (temp = 3; temp != 0; temp--) + { +/* trigger IRQ */ + (void)sb_poke(snd, SBCMD_INTERRUPT); +/* clear the generated IRQ */ + (void)in(_ioadr + SBREG_POLL); + } + +/* clear dangling IRQ at DSP chip */ +// (void)in(_ioadr + SBREG_POLL); +/* enable interrupts at 8259 interrupt controller chips */ + temp = 1; + temp <<= _irq; + out(0x21, in(0x21) & ~temp); + temp >>= 8; + out(0xA1, in(0xA1) & ~temp); +/* allocate low memory for DSP buffers - xxx +_dsp_buff_mem = (unsigned char *)farmalloc(65536L + NUM_BUFS * BUF_SIZE); +_dsp_buff_base = align_to_64k(_dsp_buff_mem); + then farfree(_dsp_buff_mem) in sb_close() +or use INT 21h AH=48h instead of farmalloc() */ + + /* xxx - fix this */ + _dsp_buff_base = + (unsigned char*) memAllocLowSpan((BUF_SIZE * NUM_BUFS) / PAGE_SIZE); + if (_dsp_buff_base == NULL) + { + wprintf(L"\tFailed to allocate %u pages\n", (BUF_SIZE * NUM_BUFS) / PAGE_SIZE); + return false; + } + + _dsp_buff_in = _dsp_buff_base; + _dsp_buff_out = _dsp_buff_base; +/* */ + wprintf(L"\tSound Blaster at I/O=0x%03X, IRQ=%u, DMA=%u\n", + _ioadr, _irq, _dma); + wprintf(L"\t%u DSP buffers at %p (%u bytes each, %u bytes total)\n", + NUM_BUFS, _dsp_buff_base, BUF_SIZE, NUM_BUFS * BUF_SIZE); +/* arm DMA */ + err = dma_from_mem(_dma, f2l(_dsp_buff_base), +// NUM_BUFS * BUF_SIZE, true); + BUF_SIZE, false); + if(err != 0) + return false; +/* crap, don't forget this, or sb_close() won't work */ + _is_open = true; +/* take over interrupt vector */ + devRegisterIrq(sb->dev, _irq, true); + return true; +} + +/***************************************************************************** +*****************************************************************************/ +sb_t sb_drv = +{ + { + sb_open, + sb_find_closest_rate, + sb_set_fmt, + sb_set_volume, + write_sample, + sb_stop_playback, + sb_close, + sb_irq, + }, + NULL +}; + + +sound_t *sb_init(device_t *dev) +{ + sb_drv.dev = dev; + return &sb_drv.snd; +} \ No newline at end of file diff --git a/mobius/src/drivers/sound/skel.c b/mobius/src/drivers/sound/skel.c new file mode 100644 index 0000000..5fb1994 --- /dev/null +++ b/mobius/src/drivers/sound/skel.c @@ -0,0 +1,207 @@ +/***************************************************************************** +"skeleton" driver +*****************************************************************************/ +#include "sound.h" /* DEBUG(X), among others */ + +/* DSP buffers -- large for few interrupts, small for responsiveness */ +#define NUM_BUFS 2 +#define LG2_BUF_SIZE 10 +#define BUF_SIZE (1u << (LG2_BUF_SIZE)) + +static bool _is_open; +static volatile bool _playback_in_progress; +/* THIS IS WRONG: static volatile unsigned char far *_dsp_buff_out; */ +static unsigned char far * volatile _dsp_buff_out; +static unsigned char far *_dsp_buff_mem, *_dsp_buff_base, *_dsp_buff_in; +/***************************************************************************** +*****************************************************************************/ +static void skel_set_volume(unsigned char level) +{ + DEBUG(printf("skel_set_volume: %u/255\n", level);) +} +/***************************************************************************** +*****************************************************************************/ +static long skel_find_closest_rate(long rate) +{ + DEBUG(printf("skel_find_closest_rate: %ld -> %ld\n", rate, + rate);) + return rate; +} +/***************************************************************************** +*****************************************************************************/ +static int skel_set_fmt(unsigned char depth, unsigned char channels, + long rate) +{ + switch(depth) + { + case 8: + break; + case 16: + break; + default: + printf("skel_set_fmt: error: bits/sample (%u) " + "is not 8 nor 16\n", depth); + return -1; + } + switch(channels) + { + case 1: + break; + case 2: + break; + default: + printf("skel_set_fmt: error: channels (%u) " + "is not 1 nor 2\n", channels); + return -1; + } + switch(rate) + { + case 8000: + case 11025: + case 22050: + case 44100u: + break; + default: + printf("skel_set_fmt: error: unsupported " + "sample rate %ld\n", rate); + return -1; + } + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static void skel_start_playback(unsigned long count) +{ + _playback_in_progress = true; +} +/***************************************************************************** +*****************************************************************************/ +static void skel_stop_playback(bool wait) +{ + if(wait) + { + DEBUG(printf("waiting...\n");) + while(_playback_in_progress) + /* nothing */; + } + else + { + _playback_in_progress = false; + } +} +/***************************************************************************** +*****************************************************************************/ +static int write_sample(short left, short right) +{ + unsigned short in_buf, out_buf, new_in_buf, count; + unsigned char depth, channels; + bool wait = false; + +depth = 8; +channels = 1; +/* to which buffer are we writing? */ + in_buf = _dsp_buff_in - _dsp_buff_base; + in_buf >>= LG2_BUF_SIZE; + while(1) +/* from which buffer are we playing? */ + { + out_buf = _dsp_buff_out - _dsp_buff_base; + out_buf >>= LG2_BUF_SIZE; +/* if they are the same, and if playback is active, +then wait until playback of this buffer is complete */ + if(out_buf != in_buf) + break; + if(!_playback_in_progress) + break; + if(!wait) + { + DEBUG(printf("waiting...");) + wait = true; + } + } +/* store sample and advance pointer */ + if(depth == 16) + { +/* assumes LITTLE ENDIAN 16-bit samples for this sound hardware */ + write_le16(_dsp_buff_in, left); + _dsp_buff_in += 2; + if(channels == 2) + { + write_le16(_dsp_buff_in, right); + _dsp_buff_in += 2; + count = BUF_SIZE >> 2; + } + else + count = BUF_SIZE >> 1; + } + else /* if(depth == 8) */ + { + left >>= 8; + *_dsp_buff_in = left; + _dsp_buff_in++; + if(channels == 2) + { + right >>= 8; + *_dsp_buff_in = right; + _dsp_buff_in++; + count = BUF_SIZE >> 1; + } + else + count = BUF_SIZE; + } + if(_dsp_buff_in >= _dsp_buff_base + NUM_BUFS * BUF_SIZE) + _dsp_buff_in = _dsp_buff_base; +/* did we cross over into a new buffer? */ + new_in_buf = _dsp_buff_in - _dsp_buff_base; + new_in_buf >>= LG2_BUF_SIZE; +/* if yes, and if not currently playing, then kick-start playback */ + if((new_in_buf != in_buf) && !_playback_in_progress) + { +/* you should see this message ONCE, when playback starts +see it again if you pause/unpause the playback + +if you see it many times, something's wrong */ + printf("*** kicking playback ***\n"); + skel_start_playback(count); + } + return 0; +} +/***************************************************************************** +detect sound hardware, allocate DSP buffers, install interrupt hanadler +*****************************************************************************/ +static int skel_open(void) +{ + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static void skel_close(void) +{ + DEBUG(printf("skel_close\n");) +/* already closed? */ + if(!_is_open) + { + printf("skel_close: sound hardware already closed\n"); + return; + } +/* abort playback */ + if(_playback_in_progress) + { + DEBUG(printf("aborting playback...\n");) + skel_stop_playback(false); + } +/* free DSP buffers; restore old interrupt vector */ + _is_open = false; +} +/***************************************************************************** +*****************************************************************************/ +sound_t skel_drv = +{ + skel_open, + skel_find_closest_rate, + skel_set_fmt, + skel_set_volume, + write_sample, + skel_stop_playback, + skel_close, +}; diff --git a/mobius/src/drivers/sound/softset.c b/mobius/src/drivers/sound/softset.c new file mode 100644 index 0000000..e606ce6 --- /dev/null +++ b/mobius/src/drivers/sound/softset.c @@ -0,0 +1,174 @@ +/***************************************************************************** +softset IRQ and DMA of original Windows Sound System board +Chris Giese http://www.execpc.com/~geezer +*****************************************************************************/ +#include /* atoi() */ +#include /* printf() */ +#include /* union REGS, int86(), inportb(), outportb() */ + +#if 0 +#define DEBUG(X) X +#else +#define DEBUG(X) +#endif + +#define POWER_UP_DLY 100000L +/***************************************************************************** +*****************************************************************************/ +static int ad1848_detect(unsigned short ioadr) +{ + unsigned char temp, reg_val; + unsigned long timeout; + +/* poll index register of AD1848 until it returns something other than 0x80 */ + for(timeout = POWER_UP_DLY; timeout != 0; timeout--) + { + if(inportb(ioadr) != 0x80) + break; + } + if(timeout == 0) + return -1; + DEBUG( + timeout = POWER_UP_DLY - timeout; + if(timeout != 0) + printf("\n", timeout); + ) +/* try writing various AD1848 registers (left and right input gain +and control regs) to see if chip is there */ + for(temp = 0; temp < 2; temp++) + { + outportb(ioadr + 0, temp); + outportb(ioadr + 1, 0xAA); + reg_val = inportb(ioadr + 1); + outportb(ioadr + 1, 0x45);/* b4 is reserved; always write 0 */ + if(reg_val != 0xAA || inportb(ioadr + 1) != 0x45) + return -1; + } +/* try changing the chip revision ID bits (they are read-only) */ + outportb(ioadr + 0, 0x0C); + reg_val = inportb(ioadr + 1); + outportb(ioadr + 1, reg_val ^ 0x0F); + if(((inportb(ioadr + 1) ^ reg_val) & 0x0F) != 0) + return -1; +/* found it! */ + return 0; +} +/***************************************************************************** +from PORTS.B of Ralf Brown's Interrupt List +(this is for WSS emulation by OPTi "Vendetta" chipset, +but it seems to work my original WSS board) + +Bit(s) Description (Table P0898) + 7 reserved + 6 IRQ sense source + 0 = normal + 1 = interrupt auto-selection + 5-3 WSS IRQ + 000 = disable + 001 = IRQ7 + 010-100 = IRQ9-IRQ11 + 101 = IRQ5 + 110-111 = reserved + 2-0 WSS DRQ + playback capture + 000 = disable disable + 001 = DRQ0 disable + 010 = DRQ1 disable + 011 = DRQ3 disable + 100 = disable DRQ1 + 101 = DRQ0 DRQ1 + 110 = DRQ1 DRQ0 + 111 = DRQ3 DRQ0 +*****************************************************************************/ +int main(int arg_c, char *arg_v[]) +{ + static const unsigned short base_io_adr[] = + { + 0x530, 0x604, 0xE80, 0xF40 + }; + unsigned char irq, dma, irq_bits, dma_bits, temp; + unsigned short ioadr = 0x530; + union REGS regs; + int err; + + if(arg_c < 3) + { + printf("Softsets Windows Sound System IRQ and DMA. Usage:\n" + "\t""softset irq dma\nirq=7,9,10,11; dma=0,1,3\n"); + return 1; + } +/* get IRQ num from command line and validate it */ + irq = atoi(arg_v[1]); + irq_bits = 0; + if(irq == 7) + irq_bits |= 0x08; + else if(irq == 9) + irq_bits |= 0x10; + else if(irq == 10) + irq_bits |= 0x18; + else if(irq == 11) + irq_bits |= 0x20; +/* maybe IRQ 5 for OPTi Vendetta chip, but not for original WSS... + else if(irq == 5) + irq_bits |= 0x28; */ + else + { + printf("Illegal IRQ number %u\n", irq); + return 2; + } +/* get DMA num from command line and validate it */ + dma = atoi(arg_v[2]); +/* NOTE: capture (record) DMA is always disabled here, either change +this or use single-mode DMA (set SDC bit in reg 9 of AD1848) */ + dma_bits = 0; + if(dma == 0) + dma_bits |= 0x01; + else if(dma == 1) + dma_bits |= 0x02; + else if(dma == 3) + dma_bits |= 0x03; + else + { + printf("Illegal DMA number %u\n", dma); + return 3; + } +/* make sure it's really DOS */ + regs.x.ax=0x1600; + int86(0x2F, ®s, ®s); + if(regs.h.al != 0 && regs.h.al != 0x80) + { + printf("Detected Windows version "); + if(regs.h.al == 0x01 || regs.h.al == 0xFF) + printf("2.x"); + else + printf("%u.%u", regs.h.al, regs.h.ah); + printf(", aborting\n"); + return 4; + } +/* probe for board +xxx - doesn't work! */ +#if 1 +ioadr = 0x530; +#else + temp = 0; + for(; temp < sizeof(base_io_adr) / sizeof(base_io_adr[0]); temp++) + { + ioadr = base_io_adr[temp] + 4; + DEBUG(printf("\t""probing at I/O=0x%03X...\n", ioadr);) + err = ad1848_detect(ioadr); + if(err == 0) + break; + } + if(err != 0) + { + printf("\t""error: chip not found\n"); + return 5; + } +#endif +/* do it */ + outportb(ioadr + 0, irq_bits | 0x40); + if((inportb(ioadr + 3) & 0x40) == 0) + printf("IRQ conflict?\n"); + outportb(ioadr, irq_bits | dma_bits); + return 0; +} diff --git a/mobius/src/drivers/sound/solo1/solo1.c b/mobius/src/drivers/sound/solo1/solo1.c new file mode 100644 index 0000000..cbd9d5a --- /dev/null +++ b/mobius/src/drivers/sound/solo1/solo1.c @@ -0,0 +1,282 @@ +/***************************************************************************** +"skeleton" driver +*****************************************************************************/ +#include "sound.h" +#include + +/* DSP buffers -- large for few interrupts, small for responsiveness */ +#define NUM_BUFS 2 +#define LG2_BUF_SIZE 10 +#define BUF_SIZE (1u << (LG2_BUF_SIZE)) + +typedef struct solo_t solo_t; +struct solo_t +{ + sound_t sound; + device_t *device; +}; + +#define PCI_VENDOR_ESS 0x125d +#define PCI_DEVICE_ESS_SOLO1 0x1969 + +static bool _is_open; +static volatile bool _playback_in_progress; +/* THIS IS WRONG: static volatile unsigned char far *_dsp_buff_out; */ +static unsigned char * volatile _dsp_buff_out; +static unsigned char *_dsp_buff_mem, *_dsp_buff_base, *_dsp_buff_in; +/***************************************************************************** +*****************************************************************************/ +static void solo_set_volume(sound_t *sound, unsigned char level) +{ + TRACE1("solo_set_volume: %u/255\n", level); +} +/***************************************************************************** +*****************************************************************************/ +static long solo_find_closest_rate(sound_t *sound, long rate) +{ + TRACE2("solo_find_closest_rate: %ld -> %ld\n", rate, rate); + return rate; +} +/***************************************************************************** +*****************************************************************************/ +static int solo_set_fmt(sound_t *sound, unsigned char depth, + unsigned char channels, long rate) +{ + switch(depth) + { + case 8: + break; + case 16: + break; + default: + wprintf(L"solo_set_fmt: error: bits/sample (%u) " + "is not 8 nor 16\n", depth); + return -1; + } + switch(channels) + { + case 1: + break; + case 2: + break; + default: + wprintf(L"solo_set_fmt: error: channels (%u) " + "is not 1 nor 2\n", channels); + return -1; + } + switch(rate) + { + case 8000: + case 11025: + case 22050: + case 44100u: + break; + default: + wprintf(L"solo_set_fmt: error: unsupported " + "sample rate %ld\n", rate); + return -1; + } + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static void solo_start_playback(sound_t *sound, unsigned long count) +{ + _playback_in_progress = true; +} +/***************************************************************************** +*****************************************************************************/ +static void solo_stop_playback(sound_t *sound, bool wait) +{ + if(wait) + { + TRACE0("waiting...\n"); + while(_playback_in_progress) + /* nothing */; + } + else + { + _playback_in_progress = false; + } +} +/***************************************************************************** +*****************************************************************************/ +static int write_sample(sound_t *sound, short left, short right) +{ + unsigned short in_buf, out_buf, new_in_buf, count; + unsigned char depth, channels; + bool wait = false; + +depth = 8; +channels = 1; +/* to which buffer are we writing? */ + in_buf = _dsp_buff_in - _dsp_buff_base; + in_buf >>= LG2_BUF_SIZE; + while(1) +/* from which buffer are we playing? */ + { + out_buf = _dsp_buff_out - _dsp_buff_base; + out_buf >>= LG2_BUF_SIZE; +/* if they are the same, and if playback is active, +then wait until playback of this buffer is complete */ + if(out_buf != in_buf) + break; + if(!_playback_in_progress) + break; + if(!wait) + { + TRACE0("waiting..."); + wait = true; + } + } +/* store sample and advance pointer */ + if(depth == 16) + { +/* assumes LITTLE ENDIAN 16-bit samples for this sound hardware */ + write_le16(_dsp_buff_in, left); + _dsp_buff_in += 2; + if(channels == 2) + { + write_le16(_dsp_buff_in, right); + _dsp_buff_in += 2; + count = BUF_SIZE >> 2; + } + else + count = BUF_SIZE >> 1; + } + else /* if(depth == 8) */ + { + left >>= 8; + *_dsp_buff_in = left; + _dsp_buff_in++; + if(channels == 2) + { + right >>= 8; + *_dsp_buff_in = right; + _dsp_buff_in++; + count = BUF_SIZE >> 1; + } + else + count = BUF_SIZE; + } + if(_dsp_buff_in >= _dsp_buff_base + NUM_BUFS * BUF_SIZE) + _dsp_buff_in = _dsp_buff_base; +/* did we cross over into a new buffer? */ + new_in_buf = _dsp_buff_in - _dsp_buff_base; + new_in_buf >>= LG2_BUF_SIZE; +/* if yes, and if not currently playing, then kick-start playback */ + if((new_in_buf != in_buf) && !_playback_in_progress) + { +/* you should see this message ONCE, when playback starts +see it again if you pause/unpause the playback + +if you see it many times, something's wrong */ + wprintf(L"*** kicking playback ***\n"); + solo_start_playback(sound, count); + } + return 0; +} +/***************************************************************************** +detect sound hardware, allocate DSP buffers, install interrupt hanadler +*****************************************************************************/ +static bool solo_open(sound_t *sound) +{ + solo_t *solo = (solo_t*) sound; + dword index, end; + word iobase, sbbase, vcbase, temp; + byte val; + + /* The SOLO-1 is a PCI device: check configuration */ + if (solo->device->config == NULL || + solo->device->config->vendor_id != PCI_VENDOR_ESS || + solo->device->config->device_id != PCI_DEVICE_ESS_SOLO1) + { + TRACE0("solo_open: invalid PCI config\n"); + return false; + } + + /* index should = zero */ + index = devFindResource(solo->device->config, dresIo, 0); + if (index == (dword) -1) + { + TRACE0("solo_open: no IO port configured\n"); + return false; + } + + iobase = solo->device->config->resources[index].u.io.base; + sbbase = solo->device->config->resources[index + 1].u.io.base; + vcbase = solo->device->config->resources[index + 2].u.io.base; + TRACE3("solo_open: resetting device at io=%x sb=%x vc=%x\n", + iobase, sbbase, vcbase); + + /* + * Reset the SOLO-1 + */ + + /* Pulse sbbase + 6, bit 0 */ + out(sbbase + 6, in(sbbase + 6) | 1); + temp = in(sbbase + 6); + out(sbbase + 6, in(sbbase + 6) & ~1); + + /* Wait at least 1ms for sbbase + 0xE bit 7 to be set */ + end = sysUpTime() + 10; + while (sysUpTime() < end && + (in(sbbase + 0xE) & 0x80) == 0) + ; + + /* Confirm that sbbase + 0xA == 0xAA */ + if ((val = in(sbbase + 0xA)) != 0xAA) + { + TRACE1("solo_open: reset failed (%x)\n", val); + return false; + } + + /* + * Configure SOLO-1 in native mode + */ + + + _is_open = true; + return true; +} +/***************************************************************************** +*****************************************************************************/ +static void solo_close(sound_t *sound) +{ + TRACE0("solo_close\n"); +/* already closed? */ + if(!_is_open) + { + wprintf(L"solo_close: sound hardware already closed\n"); + return; + } +/* abort playback */ + if(_playback_in_progress) + { + TRACE0("aborting playback...\n"); + solo_stop_playback(sound, false); + } +/* free DSP buffers; restore old interrupt vector */ + _is_open = false; +} +/***************************************************************************** +*****************************************************************************/ +solo_t solo_drv = +{ + { + solo_open, + solo_find_closest_rate, + solo_set_fmt, + solo_set_volume, + write_sample, + solo_stop_playback, + solo_close, + }, + NULL +}; + +sound_t *solo_init(device_t *dev) +{ + solo_drv.device = dev; + return &solo_drv.sound; +} \ No newline at end of file diff --git a/mobius/src/drivers/sound/sound.c b/mobius/src/drivers/sound/sound.c new file mode 100644 index 0000000..c03668d --- /dev/null +++ b/mobius/src/drivers/sound/sound.c @@ -0,0 +1,132 @@ +#include +#include +#include +#include +#include "sound.h" + +sound_t *sb_init(device_t *dev); +sound_t *wss_init(device_t *dev); +sound_t *solo_init(device_t *dev); + +typedef struct sound_dev_t sound_dev_t; +struct sound_dev_t +{ + device_t dev; + sound_t *snd; + dword play_end; + unsigned rate, bits_per_sample, channels; +}; + +bool sndRequest(device_t* dev, request_t* req) +{ + sound_dev_t *snd = (sound_dev_t*) dev; + byte *buf; + dword end; + + switch (req->code) + { + case DEV_ISR: + if (req->params.isr.irq == 0) + { + if (snd->play_end && sysUpTime() >= snd->play_end) + { + snd->play_end = 0; + snd->snd->stop_playback(snd->snd, false); + TRACE0("sndRequest: stop playback\n"); + } + } + else + snd->snd->irq(snd->snd, req->params.isr.irq); + + return true; + + case DEV_REMOVE: + devRegisterIrq(&snd->dev, 0, false); + snd->snd->close(snd->snd); + hndFree(snd); + + case DEV_OPEN: + case DEV_CLOSE: + hndSignal(req->event, true); + return true; + + case DEV_WRITE: + end = sysUpTime() + + (req->params.write.length * 1000 * 8) / + (snd->rate * snd->bits_per_sample); + req->user_length = req->params.write.length; + req->params.write.length = 0; + buf = (byte*) req->params.write.buffer; + + while (req->params.write.length < req->user_length) + { + snd->snd->write_sample(snd->snd, + buf[req->params.write.length], + buf[req->params.write.length]); + req->params.write.length++; + } + + //snd->play_end = end; + hndSignal(req->event, true); + return true; + } + + req->result = ENOTIMPL; + return false; +} + +device_t* sndAddDevice(driver_t* drv, const wchar_t* name, device_config_t* cfg) +{ + sound_dev_t* snd; + request_t req; + + snd = hndAlloc(sizeof(sound_dev_t), NULL); + snd->dev.request = sndRequest; + snd->dev.driver = drv; + snd->dev.config = cfg; + + snd->snd = solo_init(&snd->dev); + if (snd->snd == NULL) + { + hndFree(snd); + return NULL; + } + + if (!snd->snd->open(snd->snd)) + { + snd->snd->close(snd->snd); + hndFree(snd); + return NULL; + } + + snd->play_end = 0; + snd->rate = 22050; + snd->bits_per_sample = 8; + snd->channels = 1; + + snd->rate = snd->snd->find_closest_rate(snd->snd, snd->rate); + if (snd->rate == 0) + { + snd->snd->close(snd->snd); + hndFree(snd); + return NULL; + } + + snd->snd->set_fmt(snd->snd, + snd->bits_per_sample, + snd->channels, + snd->rate); + devRegisterIrq(&snd->dev, 0, true); + + req.code = DEV_WRITE; + req.params.write.buffer = (void*) 0x1000; + req.params.write.length = 0x10000; + devRequestSync(&snd->dev, &req); + return &snd->dev; +} + +bool STDCALL INIT_CODE drvInit(driver_t* drv) +{ + drv->add_device = sndAddDevice; + return true; +} \ No newline at end of file diff --git a/mobius/src/drivers/sound/sound.dsp b/mobius/src/drivers/sound/sound.dsp new file mode 100644 index 0000000..af696fb --- /dev/null +++ b/mobius/src/drivers/sound/sound.dsp @@ -0,0 +1,117 @@ +# Microsoft Developer Studio Project File - Name="sound" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=sound - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "sound.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "sound.mak" CFG="sound - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "sound - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "sound - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "sound - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f sound.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "sound.exe" +# PROP BASE Bsc_Name "sound.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "nmake /f "sound.mak"" +# PROP Rebuild_Opt "/a" +# PROP Target_File "sound.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "sound - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f sound.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "sound.exe" +# PROP BASE Bsc_Name "sound.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "nmake /f "sound.mak"" +# PROP Rebuild_Opt "/a" +# PROP Target_File "sound.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "sound - Win32 Release" +# Name "sound - Win32 Debug" + +!IF "$(CFG)" == "sound - Win32 Release" + +!ELSEIF "$(CFG)" == "sound - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\dma.c +# End Source File +# Begin Source File + +SOURCE=.\sb.c +# End Source File +# Begin Source File + +SOURCE=.\sound.c +# End Source File +# Begin Source File + +SOURCE=.\wss.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\sound.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/mobius/src/drivers/sound/sound.h b/mobius/src/drivers/sound/sound.h new file mode 100644 index 0000000..a019323 --- /dev/null +++ b/mobius/src/drivers/sound/sound.h @@ -0,0 +1,65 @@ +#include /* FILE */ +#include +#include + +#define DEBUG +#include + +/* these assumes sizeof(short)==2 +and it assumes little-endian CPU (e.g. x86) +these functions used to read from sound files */ +#define read_le16(S) *(unsigned short *)(S) +#define read_le32(S) *(unsigned long *)(S) +unsigned short read_be16(unsigned char *buffer); +unsigned long read_be32(unsigned char *buffer); + +/* these functions used to write to sound hardware */ +#define write_le16(D,S) *(unsigned short *)(D) = S + +/* byte offsets in "fmt " block of RIFF/WAVE file */ +#define WAV_FMT_LEN 0 /* 32-bit actual length of "fmt " block */ +#define WAV_FMT_FMT 4 /* 16-bit compression type */ +#define WAV_FMT_CHAN 6 /* 16-bit mono/stereo */ +#define WAV_FMT_RATE 8 /* 32-bit sample rate */ +#define WAV_FMT_BPS 12 /* 32-bit ? */ +#define WAV_FMT_ALIGN 16 /* 16-bit ? */ +#define WAV_FMT_DEPTH 18 /* 16-bit bits/sample */ +#define WAV_FMT_SIZE 20 /* min. length of "fmt " block */ + +#if (defined(__TURBOC__) || !defined(__cplusplus)) && !defined(bool) +typedef enum +{ + false = 0, true = 1 +} bool; +#endif + +typedef struct sound_t sound_t; +struct sound_t +{ + bool (*open)(sound_t *snd); + long (*find_closest_rate)(sound_t *snd, long rate); + int (*set_fmt)(sound_t *snd, unsigned char depth, + unsigned char channels, long rate); + void (*set_volume)(sound_t *snd, unsigned char level); + int (*write_sample)(sound_t *snd, short left, short right); + void (*stop_playback)(sound_t *snd, bool wait); + void (*close)(sound_t *snd); + void (*irq)(sound_t *snd, unsigned num); +}; + +typedef struct +{ + FILE *infile; + unsigned long bytes_left; + void *fsd; + unsigned char channels; + unsigned char depth; + long rate; +} sound_info_t; + +typedef struct +{ + const char *name; + int (*validate)(sound_info_t *info); + int (*get_sample)(sound_info_t *info, short *left, short *right); +} codec_t; diff --git a/mobius/src/drivers/sound/tc.mak b/mobius/src/drivers/sound/tc.mak new file mode 100644 index 0000000..7c880b1 --- /dev/null +++ b/mobius/src/drivers/sound/tc.mak @@ -0,0 +1,58 @@ +MAKEFILE=tc.mak +MODEL =l +CFLAGS =-v -w -m$(MODEL) -O2 -1 -d -Z -vi -f- +LFLAGS =/v /x /Lc:\tc\lib + +OBJS =play.o misc.o irq.o dma.o \ + wss.o sb.o \ + wav.o wav01.o wav02.o wav06.o wav07.o wav34.o \ + wav49.o wav85.o au.o au01.o au023.o au27.o + +all: play.exe + +.c.o: + tcc $(CFLAGS) -c -o$@ $< + +play.exe: $(OBJS) $(MAKEFILE) + tlink $(LFLAGS) @&&! +c0$(MODEL) $(OBJS) +$@ + # no map file (tlink /x) +c$(MODEL).lib +! + +dma.o: dma.c $(MAKEFILE) + +irq.o: irq.c defs.h irq.h $(MAKEFILE) + +wss.o: wss.c defs.h irq.h $(MAKEFILE) + +play.o: play.c defs.h $(MAKEFILE) + +wav.o: wav.c defs.h $(MAKEFILE) + +wav01.o: wav01.c defs.h $(MAKEFILE) + +wav02.o: wav02.c defs.h $(MAKEFILE) + +wav06.o: wav06.c defs.h $(MAKEFILE) + +wav07.o: wav07.c defs.h $(MAKEFILE) + +wav34.o: wav34.c defs.h $(MAKEFILE) + +wav49.o: wav49.c defs.h $(MAKEFILE) + +wav85.o: wav85.c defs.h $(MAKEFILE) + +au.o: au.c defs.h $(MAKEFILE) + +au01.o: au01.c defs.h $(MAKEFILE) + +au023.o: au023.c defs.h $(MAKEFILE) + +au27.o: au27.c defs.h $(MAKEFILE) + +clean: + del *.o + del *.exe diff --git a/mobius/src/drivers/sound/wav.c b/mobius/src/drivers/sound/wav.c new file mode 100644 index 0000000..f1ff68e --- /dev/null +++ b/mobius/src/drivers/sound/wav.c @@ -0,0 +1,71 @@ +/***************************************************************************** +common routines for .WAV files + +.WAV sub-formats: + 1=linear PCM + 2=Microsoft ADPCM + 6=A-law (ITU-T G.711, formerly CCITT G.711) + 7=u-law (ITU-T G.711, formerly CCITT G.711) + 34=True Speech + 49=GSM + 85=MP3 + +.WAV chunks +"fmt " +"data" xxx - this code does not handle multiple "data" chunks +"fact" xxx - this code does not skip more than one "fact" chunk +*****************************************************************************/ +#include /* memcmp() */ +#include "sound.h" +/***************************************************************************** +*****************************************************************************/ +int wav_validate(sound_info_t *info, unsigned sub_type) +{ + unsigned char buffer[WAV_FMT_SIZE]; + char *data; + long temp; + + fseek(info->infile, 0, SEEK_SET); +/* is it a .WAV file? */ + if(fread(buffer, 1, 12, info->infile) != 12) + return -1; + if(memcmp(buffer, "RIFF", 4) || memcmp(buffer + 8, "WAVE", 4)) + return -1; +/* skip to 'fmt ' section */ + do + { + if(fread(buffer, 1, 4, info->infile) != 4) + return -1; + } while (memcmp(buffer, "fmt ", 4) != 0); +/* read info from 'fmt ' section */ + if(fread(buffer, 1, WAV_FMT_SIZE, info->infile) != WAV_FMT_SIZE) + return -1; +/* 1=linear PCM, 2=ADPCM, 85=MP3, etc. */ + if (read_le16(buffer + WAV_FMT_FMT) != sub_type) + return -1; /* not the subtype we want */ + info->channels = read_le16(buffer + WAV_FMT_CHAN); + info->depth = read_le16(buffer + WAV_FMT_DEPTH); + info->rate = read_le32(buffer + WAV_FMT_RATE); +/* skip rest of 'fmt ' section */ + for(temp = read_le32(buffer) - (WAV_FMT_SIZE - 4); temp != 0; temp--) + { + if(fgetc(info->infile) == EOF) + return -1; + } +/* skip to 'data' section. This also skips the useless 'fact' sections. */ + for(data = "data"; *data != '\0'; ) + { + temp = fgetc(info->infile); + if(temp == EOF) + return -1; + if(temp == *data) + data++; + } +/* get length of data. +We do NOT handle .WAV files with multiple 'data' sections. */ + if(fread(buffer, 1, 4, info->infile) != 4) + return -1; + info->bytes_left = read_le32(buffer); +/* valid .WAV file */ + return 0; +} diff --git a/mobius/src/drivers/sound/wav01.c b/mobius/src/drivers/sound/wav01.c new file mode 100644 index 0000000..1eea846 --- /dev/null +++ b/mobius/src/drivers/sound/wav01.c @@ -0,0 +1,61 @@ +/***************************************************************************** +linear PCM +sub-format 1 of .WAV format +*****************************************************************************/ +#include /* fread() */ +#include "sound.h" + +/* in WAV.C */ +int wav_validate(sound_info_t *info, unsigned sub_type); +/***************************************************************************** +*****************************************************************************/ +static int get_sample(sound_info_t *info, short *left, short *right) +{ + unsigned char buffer[4]; + + if(info->depth == 16 && info->channels == 2) + { + if(fread(buffer, 1, 4, info->infile) != 4) + return -1; + *left = read_le16(buffer + 0); + *right = read_le16(buffer + 2); + } + else if(info->depth == 16 && info->channels == 1) + { + if(fread(buffer, 1, 2, info->infile) != 2) + return -1; + *left = read_le16(buffer + 0); + *right = *left; + } + else if(info->depth == 8 && info->channels == 2) + { + if(fread(buffer, 1, 2, info->infile) != 2) + return -1; + *left = buffer[0] << 8; + *right = buffer[1] << 8; + } + else if(info->depth == 8 && info->channels == 1) + { + if(fread(buffer, 1, 1, info->infile) != 1) + return -1; + *left = buffer[0] << 8; + *right = *left; + } + else + return -1; + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static int validate(sound_info_t *info) +{ + fseek(info->infile, 0, SEEK_SET); +/* WAV sub-format #1 is linear PCM */ + return wav_validate(info, 1); +} +/***************************************************************************** +*****************************************************************************/ +codec_t _wav01 = +{ + ".wav linear PCM", validate, get_sample +}; diff --git a/mobius/src/drivers/sound/wav02.c b/mobius/src/drivers/sound/wav02.c new file mode 100644 index 0000000..107e997 --- /dev/null +++ b/mobius/src/drivers/sound/wav02.c @@ -0,0 +1,291 @@ +/***************************************************************************** +Microsoft Adaptive Differential PCM (ADPCM) +sub-format 2 of .WAV format + +Source: file MSADPCM.C of Waveform Conversion Sample Application, + Microsoft Multimedia Systems Group + Copyright (C) Microsoft Corp. 1991, 1992. +*****************************************************************************/ +#include /* malloc() */ +#include /* memcmp() */ +#include /* FILE, EOF, fread(), fgetc() */ +#include "sound.h" /* sound_info_t */ + +typedef struct +{ + short delta, coeff1, coeff2; + short samp1, samp2; + unsigned char predictor; +} chaninfo_t; + +typedef struct +{ + unsigned samples_per_frame, samples_left; + chaninfo_t chan_info[2]; + unsigned char byte; +} adpcm_t; +/***************************************************************************** +*****************************************************************************/ +static void do_adpcm(chaninfo_t *chan_info, short *sample, signed char nybble) +{ +/* "Fixed point delta adaption table" */ + static const short gai_p4[] = + { + 230, 230, 230, 230, 307, 409, 512, 614, + 768, 614, 512, 409, 307, 230, 230, 230 + }; + long predict, output, old_delta; + +/* update delta */ + old_delta = chan_info->delta; + chan_info->delta = (gai_p4[nybble] * old_delta) >> 8; + if(chan_info->delta < 16) + chan_info->delta = 16; +/* sign-extend nybble */ + if(nybble & 0x08) + nybble -= 0x10; +/* predict next sample */ + predict = ((long)chan_info->samp1 * chan_info->coeff1 + + (long)chan_info->samp2 * chan_info->coeff2) >> 8; +/* reconstruct original PCM */ + output = nybble * old_delta + predict; +/* clip to 16 bits */ + if(output > 32767) + output = 32767; + else if(output < -32768L) + output = -32768L; +/* update previouses */ + chan_info->samp2 = chan_info->samp1; + chan_info->samp1 = output; +/* return the sample */ + *sample = output; +} +/***************************************************************************** +*****************************************************************************/ +static int get_sample(sound_info_t *info, short *left, short *right) +{/* technically, the GaiCoeff values should be read from the "fmt " +block of the .WAV file (ADPCM has 32 extra bytes in that block versus +regular PCM) instead of being hard-coded like this. */ + static const short gai_coeff1[] = + { + 256, 512, 0, 192, 240, 460, 392 + }; + static const short gai_coeff2[] = + { + 0, -256, 0, 64, 0, -208, -232 + }; + chaninfo_t *left_info, *right_info; + unsigned char buffer[14]; + adpcm_t *adpcm_info; + + adpcm_info = (adpcm_t *)info->fsd; + left_info = adpcm_info->chan_info + 0; + right_info = adpcm_info->chan_info + 1; + if(adpcm_info->samples_left == 0) +/* need to load a new mono ADPCM frame */ + { + DEBUG(printf("ftell()=%5lu: ", ftell(info->infile));) + if(info->channels == 1) + { + if(fread(buffer, 1, 7, info->infile) != 7) + return -1; + info->bytes_left -= 7; +/* 7-byte frame header: 8-bit predictor... */ + left_info->predictor = buffer[0]; +/* ...16-bit delta */ + left_info->delta = read_le16(buffer + 1); +/* ...16-bit Previous sample */ + left_info->samp1 = read_le16(buffer + 3); +/* ...16-bit next-to-Previous sample */ + left_info->samp2 = read_le16(buffer + 5); + } +/* need to load a new stereo ADPCM frame */ + else //if(info->channels == 2) + { + if(fread(buffer, 1, 14, info->infile) != 14) + return -1; + info->bytes_left -= 14; +/* 7-byte frame header: 8-bit Predictors... */ + left_info->predictor = buffer[0]; + right_info->predictor = buffer[1]; +/* ...16-bit Deltas */ + left_info->delta = read_le16(buffer + 2); + right_info->delta = read_le16(buffer + 4); +/* ...16-bit Previous samples */ + left_info->samp1 = read_le16(buffer + 6); + right_info->samp1 = read_le16(buffer + 8); +/* ...16-bit next-to-Previous samples */ + left_info->samp2 = read_le16(buffer + 10); + right_info->samp2 = read_le16(buffer + 12); +// DEBUG(printf("right: predictor=%u, Index=%4d, " +// "Prev=%5d, samp2=%5d\n", right_info->predictor, +// right_info->delta, right_info->samp1, +}// right_info->samp2);) } +// DEBUG(printf("left: predictor=%u, Index=%4d, Prev=%5d, " +// "samp2=%5d\n", left_info->predictor, +// left_info->delta, left_info->samp1, +// left_info->samp2);) +/* check Predictors. As with the GaiCoef values, the limit 6 should also +probably come from the ADPCM "fmt " block instead of being hard-coded. */ + if(left_info->predictor > 6) + { + DEBUG(printf("LPredictor > 6\n");) +/* xxx - return -2 for corrupt file? */ + return -2; + } + if(right_info->predictor > 6) + { + DEBUG(printf("RPredictor > 6\n");) + return -2; + } +/* cache coefficients 1 and 2 for each channel */ + left_info->coeff1 = gai_coeff1[left_info->predictor]; + left_info->coeff2 = gai_coeff2[left_info->predictor]; + right_info->coeff1 = gai_coeff1[right_info->predictor]; + right_info->coeff2 = gai_coeff2[right_info->predictor]; + adpcm_info->samples_left = adpcm_info->samples_per_frame; +/* return next-to-previous sample, from frame header */ + *left = left_info->samp2; + if(info->channels == 1) + *right = *left; + else + *right = right_info->samp2; + adpcm_info->samples_left--; + return 0; + } +/* return previous sample, from frame header */ + if(adpcm_info->samples_left == adpcm_info->samples_per_frame - 1) + { + *left = left_info->samp1; + if(info->channels == 1) + *right = *left; + else + *right = right_info->samp1; + adpcm_info->samples_left--; + return 0; + } +/* here's where it gets hairy */ + { + int temp; + signed char nybble; + + if(info->channels == 1) + { +/* odd sample: get least-significant nybble of previously-fetched byte +xxx - this works only if samples_per_frame is always even */ + if((adpcm_info->samples_left & 1) != 0) + nybble = adpcm_info->byte & 0x0F; +/* even sample: fetch new ADPCM data byte, get most-significant nybble */ + else + { + temp = fgetc(info->infile); + if(temp == EOF) + return -1; + info->bytes_left--; + adpcm_info->byte = temp; + nybble = (temp >> 4) & 0x0F; + } + do_adpcm(left_info, left, nybble); + *right = *left; + } + else + { + temp = fgetc(info->infile); + if(temp == EOF) + return -1; + info->bytes_left--; + nybble = (temp >> 4) & 0x0F; + do_adpcm(left_info, left, nybble); + nybble = temp & 0x0F; + do_adpcm(right_info, right, nybble); + } + adpcm_info->samples_left--; + } + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static int validate(sound_info_t *info) +{ +#if 0 /* can't do it -- need WAV_FMT_ALIGN entry for WAV file header */ + long temp; + int error; + + error = wav_validate(info->infile, info, 2); + if(error != 0) + return error; +/* compute samples_per_frame as below... */ + return 0; +} +#else + unsigned char buffer[WAV_FMT_SIZE]; + unsigned samples_per_frame; + char *data; + long temp; + + fseek(info->infile, 0, SEEK_SET); +/* is it a .WAV file? */ + if(fread(buffer, 1, 12, info->infile) != 12) +ERR: return -1; + if(memcmp(buffer, "RIFF", 4) || memcmp(buffer + 8, "WAVE", 4)) + return -1; /* not .WAV */ +/* skip to 'fmt ' section and read fmt block */ + do + { + if(fread(buffer, 1, 4, info->infile) != 4) + goto ERR; + } while(memcmp(buffer, "fmt ", 4)); + if(fread(buffer, 1, WAV_FMT_SIZE, info->infile) != WAV_FMT_SIZE) + goto ERR; + if(read_le16(buffer + WAV_FMT_FMT) != 2) + return -1; /* not MS-ADPCM */ +/* it is a .WAV file and it uses MS-ADPCM coding: get some info */ + info->channels = read_le16(buffer + WAV_FMT_CHAN); /* stereo or mono? */ + info->rate = read_le32(buffer + WAV_FMT_RATE); /* sample rate */ + info->depth = read_le16(buffer + WAV_FMT_DEPTH); /* bits/sample */ +/* skip rest of header */ + for(temp = read_le32(buffer) - (WAV_FMT_SIZE - 4); temp; temp--) + if(fgetc(info->infile) == EOF) + goto ERR; +/* compute samples_per_frame... +...buffer+WAV_FMT_ALIGN contains frame size in bytes... */ + temp = read_le16(buffer + WAV_FMT_ALIGN); +/* ...subtract 7 bytes for header (one header per channel)... */ + temp -= 7 * info->channels; +/* ...convert to bits... */ + temp <<= 3; +/* ...convert to samples (divide by ADPCM sample depth and channels)... */ + temp = temp / (info->depth * info->channels); +/* ...and add 2 for samp1 and samp2 in the ADPCM frame header */ + samples_per_frame = temp + 2; +/* skip to 'data' section. This also skips those useless +'fact' sections in the .WAV file. */ + for(data="data"; *data != '\0'; ) + { + temp = fgetc(info->infile); + if(temp == EOF) + goto ERR; + if(temp == *data) + data++; + } +/* get length of data */ + if(fread(buffer, 1, 4, info->infile) != 4) + goto ERR; + info->bytes_left = read_le32(buffer); +/* use calloc(), so it's zeroed */ + info->fsd = (void *)calloc(1, sizeof(adpcm_t)); + if(info->fsd == NULL) + return -1; + ((adpcm_t *)(info->fsd))->samples_per_frame = samples_per_frame; +/* */ + info->depth = 16; +/* valid MS-ADPCM */ + return 0; +} +#endif +/***************************************************************************** +*****************************************************************************/ +codec_t _wav02 = +{ + ".wav Microsoft ADPCM", validate, get_sample, +}; diff --git a/mobius/src/drivers/sound/wav06.c b/mobius/src/drivers/sound/wav06.c new file mode 100644 index 0000000..e060e4e --- /dev/null +++ b/mobius/src/drivers/sound/wav06.c @@ -0,0 +1,54 @@ +/***************************************************************************** +A-law +sub-format 6 of .WAV format +*****************************************************************************/ +#include /* EOF, fgetc() */ +#include "sound.h" + +/* in MISC.C */ +short alaw_expand(unsigned char data); + +/* in WAV.C */ +int wav_validate(sound_info_t *info, unsigned sub_type); +/***************************************************************************** +*****************************************************************************/ +static int get_sample(sound_info_t *info, short *left, short *right) +{ + int temp; + + temp = fgetc(info->infile); + if(temp == EOF) + return -1; + info->bytes_left--; + *left = alaw_expand(temp); + if(info->channels == 1) + { + *right = *left; + return 0; + } + temp = fgetc(info->infile); + if(temp == EOF) + return -1; + info->bytes_left--; + *right = alaw_expand(temp); + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static int validate(sound_info_t *info) +{ + int err; + + fseek(info->infile, 0, SEEK_SET); +/* WAV sub-format #6 is u-law */ + err = wav_validate(info, 6); + info->depth = 16; + return err; +} +/***************************************************************************** +*****************************************************************************/ +codec_t _wav06 = +{ + ".wav A-law", validate, get_sample +}; + diff --git a/mobius/src/drivers/sound/wav07.c b/mobius/src/drivers/sound/wav07.c new file mode 100644 index 0000000..028c110 --- /dev/null +++ b/mobius/src/drivers/sound/wav07.c @@ -0,0 +1,54 @@ +/***************************************************************************** +mu-law +sub-format 7 of .WAV format +*****************************************************************************/ +#include /* EOF, fgetc() */ +#include "sound.h" + +/* in MISC.C */ +short mulaw_expand(unsigned char data); + +/* in WAV.C */ +int wav_validate(sound_info_t *info, unsigned sub_type); +/***************************************************************************** +*****************************************************************************/ +static int get_sample(sound_info_t *info, short *left, short *right) +{ + int temp; + + temp = fgetc(info->infile); + if(temp == EOF) + return -1; + info->bytes_left--; + *left = mulaw_expand(temp); + if(info->channels == 1) + { + *right = *left; + return 0; + } + temp = fgetc(info->infile); + if(temp == EOF) + return -1; + info->bytes_left--; + *right = mulaw_expand(temp); + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static int validate(sound_info_t *info) +{ + int err; + + fseek(info->infile, 0, SEEK_SET); +/* WAV sub-format #7 is u-law */ + err = wav_validate(info, 7); + info->depth = 16; + return err; +} +/***************************************************************************** +*****************************************************************************/ +codec_t _wav07 = +{ + ".wav mu-law", validate, get_sample +}; + diff --git a/mobius/src/drivers/sound/wav34.c b/mobius/src/drivers/sound/wav34.c new file mode 100644 index 0000000..4b3d26b --- /dev/null +++ b/mobius/src/drivers/sound/wav34.c @@ -0,0 +1,32 @@ +/***************************************************************************** +DSP Group True Speech +sub-format 34 of .WAV format + +I haven't checked, but I think the True Speech codec +is either commerical ($) or non-disclosure (NDA). +*****************************************************************************/ +#include "sound.h" + +/* in WAV.C */ +int wav_validate(sound_info_t *info, unsigned sub_type); +/***************************************************************************** +*****************************************************************************/ +static int validate(sound_info_t *info) +{ +/* WAV sub-format #34 is True Speech */ + if(wav_validate(info, 34) == 0) + printf("SORRY, TRUE SPEECH NOT SUPPORTED..."); + return -1; +} +/***************************************************************************** +*****************************************************************************/ +static int get_sample(sound_info_t *info, short *left, short *right) +{ + return -1; +} +/***************************************************************************** +*****************************************************************************/ +codec_t _wav34 = +{ + ".wav TrueSpeech", validate, get_sample +}; diff --git a/mobius/src/drivers/sound/wav49.c b/mobius/src/drivers/sound/wav49.c new file mode 100644 index 0000000..a2ab62e --- /dev/null +++ b/mobius/src/drivers/sound/wav49.c @@ -0,0 +1,614 @@ +/***************************************************************************** +GSM +sub-format 49 of .WAV format + +MONO ONLY + +The original code came from the Toast website, listed below. +Any bugs in this code are due to Giese. + +The original code was full of macros that made my old compiler choke. +It was also hand-optimized: loops were unrolled, the 'register' keyword +was used a lot, and RPE_grid_positioning() used something like Duff's +device. My version leaves optimization to the compiler, which lets you make +the usual choice between size and speed (e.g. use the GCC -funroll-loops +option or not). + +I did, however, pare down the widths of data types where possible e.g. +changed 'int's and 'uword's to 'unsigned char'. The code in main() that +deals with .WAV files and the code in gsmDecodeFrame() that unpacks the +data is original. It's probably not as efficient as it could be, but I +can't seem to get DJGPP gprof working. I also took out the optional +floating-point code in long_term.c and short_term.c -- this code uses +mostly 16-bit integer math, with a little 32-bit when adding, subtracting, +or multiplying 16-bit values. + + +Source: http://kbs.cs.tu-berlin.de/~jutta/toast.html + +Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, +Technische Universitaet Berlin + +Any use of this software is permitted provided that this notice is not +removed and that neither the authors nor the Technische Universitaet Berlin +are deemed to have made any representations as to the suitability of this +software for any purpose nor are held responsible for any defects of +this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. + +As a matter of courtesy, the authors request to be informed about uses +this software has found, about bugs in this software, and about any +improvements that may be of general interest. + +Berlin, 28.11.1994 +Jutta Degener +Carsten Bormann +*****************************************************************************/ +#include /* calloc() */ +#include "sound.h" + +/* -32768 isn't reall long, just put 'L' there to shut Turbo C up */ +#define MIN_WORD -32768L +#define MAX_WORD 32767 + +#define SASR(x, by) ((x) >> (by)) +/* short a, short b, !(a == b == MIN_WORD) */ +#define GSM_MULT_R(a,b) (SASR(((long)(a) * (long)(b) + 16384), 15)) + +#define SATURATE(x) \ + ((x) < MIN_WORD ? MIN_WORD : (x) > MAX_WORD ? MAX_WORD: (x)) + +#define GSM_ADD(a, b) \ + (SATURATE((long)(a) + (long)(b))) + +#define GSM_SUB(a, b) \ + (SATURATE((long)(a) - (long)(b))) + +#define GSM_ABS(a) ((a) < 0 ? ((a) == MIN_WORD ? MAX_WORD : -(a)) : (a)) + +typedef struct +{ + short dp0[280]; + short z1; /* preprocessing.c, Offset_com. */ + long L_z2; /* Offset_com. */ + int mp; /* Preemphasis */ + short u[8]; /* short_term_aly_filter.c */ + short larpp[2][8]; /* */ + short j; /* */ + short ltp_cut; /* long_term.c, LTP crosscorr. */ + short nrp; /* 40 */ /* long_term.c, synthesis */ + short v[9]; /* short_term.c, synthesis */ + short msr; /* decoder.c, Postprocessing */ + + unsigned char gsm_frame[65]; + unsigned short bit_pos; + unsigned short samples_left; + short output[320]; +} gsm_decoder_t; +/***************************************************************************** +reads val_width-bit value from position bit_pos in bit_array +val_width <= 8 + +xxx - still fiddling with this. It gets called 76 times per GSM frame, +so it needs to be fast. 'gcc -O3' will probably inline it automatically, +but the puny compilers for 8- and 16-bit CPUs may not be so clever. +*****************************************************************************/ +unsigned char read_bits(unsigned char *bit_array, unsigned short *bit_pos, + unsigned char val_width) +{ + static const unsigned char mask_tab[] = + { + 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF + }; + unsigned short byte_pos, temp; + unsigned char bit_in_byte; + + byte_pos = (*bit_pos >> 3); + bit_in_byte = (*bit_pos & 7); +/* the value we read may straddle two bytes, +so read 16-bit value (2 bytes) from bit_pos */ + temp = *(unsigned short *)(bit_array + byte_pos); +/* shift right to get the bits of interest at the bottom of temp */ + temp >>= bit_in_byte; +/* update bit_pos */ + *bit_pos += val_width; +/* mask away the upper bits */ + temp &= mask_tab[val_width]; +/* return the bottom byte */ + return temp; +} +/***************************************************************************** +*****************************************************************************/ +static short gsm_asr(short a, int n) +{ + if(n >= 16) + return -(a < 0); + if(n >= 0) +/* this needs to be an arithmetic shift right (i.e. with sign) */ + return a >> n; + if(n < 0) + return a << -n; + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static short gsm_asl(short a, int n) +{ + if(n >= 16) + return 0; + if(n <= -16) + return -(a < 0); + if(n < 0) + return gsm_asr(a, -n); + return a << n; +} +/**************************************************************************** +SHORT TERM ANALYSIS FILTERING SECTION +4.2.8 + +larc[0-7]: coded log area ratio +larpp[]: out... +****************************************************************************/ +static void decoding_of_the_coded_log_area_ratios(unsigned char *larc, + short *larpp) +{ + static const short b_tab[] = + { + 0, 0, 2048, -2560, 94, -1792, -341, -1144 + }; +/* MIC[1..8] = minimum value of the larc[1..8] */ + static const short mic_tab[] = + { + -32, -32, -16, -16, -8, -8, -4, -4 + }; +/* INVA[1..8] = integer((32768 * 8) / real_A[1..8]) */ + static const short inva_tab[] = + { + 13107, 13107, 13107, 13107, 19223, 17476, 31454, 29708 + }; + unsigned char i; + short temp1; + + for(i = 0; i < 8; i++) + { + short temp2; + + temp1 = GSM_ADD(*larc, mic_tab[i]) << 10; + temp2 = b_tab[i] << 1; + temp1 = GSM_SUB(temp1, temp2); + temp1 = GSM_MULT_R(inva_tab[i], temp1); + *larpp = GSM_ADD(temp1, temp1); + larc++; + larpp++; + } +} +/**************************************************************************** +4.2.9 +Computation of the quantized reflection coefficients + +4.2.9.1 Interpolation of the larpp[1..8] to get the larp[1..8] + +Within each frame of 160 analyzed speech samples the short term +analysis and synthesis filters operate with four different sets of +coefficients, derived from the previous set of decoded LARs(larpp(j-1)) +and the actual set of decoded LARs (larpp(j)) + +Initial value: larpp(j-1)[1..8] = 0.) +****************************************************************************/ +static void coefficients_0_12(short *larpp_j_1, short *larpp_j, short *larp) +{ + unsigned char i; + + for(i = 8; i != 0; i--) + { + *larp = GSM_ADD(SASR(*larpp_j_1, 2), SASR(*larpp_j, 2)); + *larp = GSM_ADD(*larp, SASR(*larpp_j_1, 1)); + larp++; + larpp_j_1++; + larpp_j++; + } +} +/**************************************************************************** +****************************************************************************/ +static void coefficients_13_26(short *larpp_j_1, short *larpp_j, short *larp) +{ + unsigned char i; + + for(i = 8; i != 0; i--) + { + *larp = GSM_ADD(SASR(*larpp_j_1, 1), SASR(*larpp_j, 1)); + larpp_j_1++; + larpp_j++; + larp++; + } +} +/**************************************************************************** +****************************************************************************/ +static void coefficients_27_39(short *larpp_j_1, short *larpp_j, short *larp) +{ + unsigned char i; + + for(i = 8; i != 0; i--) + { + *larp = GSM_ADD(SASR(*larpp_j_1, 2), SASR(*larpp_j, 2)); + *larp = GSM_ADD(*larp, SASR(*larpp_j, 1)); + larpp_j_1++; + larpp_j++; + larp++; + } +} +/**************************************************************************** +****************************************************************************/ +static void coefficients_40_159(short *larpp_j, short *larp) +{ + unsigned char i; + + for(i = 8; i != 0; i--) + { + *larp = *larpp_j; + larp++; + larpp_j++; + } +} +/**************************************************************************** +4.2.9.2 + +larp[0-7]: IN/OUT + +The input of this procedure is the interpolated larp[0..7] array. +The reflection coefficients, rp[i], are used in the analysis +filter and in the synthesis filter. +****************************************************************************/ +static void larp_to_rp(short *larp) +{ + short temp; + int i; + + for(i = 8; i != 0; i--) + { + temp = GSM_ABS(*larp); + if(temp < 11059) + temp <<= 1; + else if(temp < 20070) + temp += 11059; + else + temp = GSM_ADD(temp >> 2, 26112); + + *larp = *larp < 0 ? -temp : temp; + larp++; + } +} +/**************************************************************************** +rrp[0..7]: IN +k: k_end - k_start +wt[0..k-1]: IN +sr[0..k-1]: OUT +****************************************************************************/ +static void short_term_synthesis_filtering(gsm_decoder_t *state, + short *rrp, int k, short *wt, short *sr) +{ + short sri, tmp1, tmp2; + short *v; + int i; + + v = state->v; + for(; k != 0; k--) + { + sri = *wt++; + for(i = 8; i--; ) + { + /* sri = GSM_SUB(sri, gsm_mult_r(rrp[i], v[i])); */ + tmp1 = rrp[i]; + tmp2 = v[i]; + tmp2 = (tmp1 == MIN_WORD && tmp2 == MIN_WORD + ? MAX_WORD + : 0x0FFFF & (((long)tmp1 * (long)tmp2 + + 16384) >> 15)) ; + sri = GSM_SUB(sri, tmp2); + /* v[i+1] = GSM_ADD(v[i], gsm_mult_r(rrp[i], sri)); + */ + tmp1 = (tmp1 == MIN_WORD && sri == MIN_WORD + ? MAX_WORD + : 0x0FFFF & (((long)tmp1 * (long)sri + + 16384) >> 15)) ; + v[i+1] = GSM_ADD(v[i], tmp1); + } + *sr++ = v[0] = sri; + } +} +/**************************************************************************** +wt[0..159]: received d IN +s[0..159]: signal OUT +****************************************************************************/ +static void gsm_short_term_synthesis_filter(gsm_decoder_t *state, + unsigned char *larcr, short *wt, short *s) +{ + short *larpp_j, *larpp_j_1, larp[8]; + + larpp_j = state->larpp[state->j]; + state->j ^= 1; + larpp_j_1 = state->larpp[state->j]; + decoding_of_the_coded_log_area_ratios(larcr, larpp_j); + + coefficients_0_12(larpp_j_1, larpp_j, larp); + larp_to_rp(larp); + short_term_synthesis_filtering(state, larp, 13, wt, s); + + coefficients_13_26(larpp_j_1, larpp_j, larp); + larp_to_rp(larp); + short_term_synthesis_filtering(state, larp, 14, wt + 13, s + 13); + + coefficients_27_39(larpp_j_1, larpp_j, larp); + larp_to_rp(larp); + short_term_synthesis_filtering(state, larp, 13, wt + 27, s + 27); + + coefficients_40_159(larpp_j, larp); + larp_to_rp(larp); + short_term_synthesis_filtering(state, larp, 120, wt + 40, s + 40); +} +/***************************************************************************** +4.12.15 + +xmaxc: IN +exp_out: OUT +mant_aout: OUT + +Computes exponent and mantissa of the decoded version of xmaxc +*****************************************************************************/ +static void apcm_quantization_xmaxc_to_exp_mant(short xmaxc, short *exp_out, + short *mant_out) +{ + short exp, mant; + + exp = 0; + if(xmaxc > 15) + exp = SASR(xmaxc, 3) - 1; + mant = xmaxc - (exp << 3); + if(mant == 0) + { + exp = -4; + mant = 7; + } + else + { + while(mant <= 7) + { + mant = (mant << 1) | 1; + exp--; + } + mant -= 8; + } + *exp_out = exp; + *mant_out = mant; +} +/***************************************************************************** +4.2.16 + +xmc[0..12] IN +mant +exp +xMp[0..12] OUT + + +This part is for decoding the RPE sequence of coded xmc[0..12] +samples to obtain the xmp[0..12] array. Table 4.6 is used to get +the mantissa of xmaxc (FAC[0..7]). +*****************************************************************************/ +static void apcm_inverse_quantization(unsigned char *xmc, short mant, + short exp, short *xmp) +{ + static const short gsm_fac[8] = + { + 18431, 20479, 22527, 24575, 26623, 28671, 30719, 32767 + }; + short temp, temp1, temp2, temp3; + int i; + + temp1 = gsm_fac[mant]; /* see 4.2-15 for mant */ + temp2 = GSM_SUB(6, exp); /* see 4.2-15 for exp */ + temp3 = gsm_asl(1, GSM_SUB(temp2, 1)); + for(i = 13; i != 0; i--) + { + temp = (*xmc++ << 1) - 7; /* restore sign */ + temp <<= 12; /* 16 bit signed */ + temp = GSM_MULT_R(temp1, temp); + temp = GSM_ADD(temp, temp3); + *xmp++ = gsm_asr(temp, temp2); + } +} +/***************************************************************************** +4.2.17 + +Mc: grid position IN +xmp[0..12]: IN +ep[0..39]: OUT + +This procedure computes the reconstructed long term residual signal +ep[0..39] for the LTP analysis filter. The inputs are the mc +which is the grid position selection and the xmp[0..12] decoded +RPE samples which are upsampled by a factor of 3 by inserting zero +values. +*****************************************************************************/ +static void rpe_grid_positioning(short mc, short *xmp, short *ep) +{ + int i, k; + + for(k = 0; k <= 39; k++) + ep[k] = 0; + for(i = 0; i <= 12; i++) + ep[mc + 3 * i] = xmp[i]; +} +/***************************************************************************** +4.3.2 +Ncr: +bcr: +erp[0..39]: IN +drp[-120..40]: IN[-120..-1], OUT[-120..40] + +This procedure uses the bcr and ncr parameter to realize the +long term synthesis filtering. The decoding of bcr needs table 4.3b. +*****************************************************************************/ +static void gsm_long_term_synthesis_filtering(gsm_decoder_t *state, + unsigned char ncr, unsigned char bcr, short *erp, short *drp) +{ + static const short gsm_qlb[4] = + { + 3277, 11469, 21299, 32767 + }; + short brp, drpp, nr; + int k; + +/* Check the limits of nr. */ + nr = ncr < 40 || ncr > 120 ? state->nrp : ncr; + state->nrp = nr; +/* Decoding of the LTP gain bcr */ + brp = gsm_qlb[bcr]; +/* Computation of the reconstructed short term residual signal drp[0..39] */ + for(k = 0; k <= 39; k++) + { + drpp = GSM_MULT_R(brp, drp[k - nr]); + drp[k] = GSM_ADD(erp[k], drpp); + } +/* Update of the reconstructed short term residual signal drp[ -1..-120 ] */ + for(k = 0; k <= 119; k++) + drp[k - 120] = drp[k - 80]; +} +/***************************************************************************** +*****************************************************************************/ +static void gsm_decode_frame(gsm_decoder_t *state, unsigned char *src, + short *dst) +{/* 260-bit GSM frame == 36 + 4 * (17 + 39) == 32.5 bytes +36 bits larc */ + static const unsigned char larc_width_table[] = + { + 6, 6, 5, 5, 4, 4, 3, 3 + }; +/* these values are repeated four times */ + static const unsigned char width_table[] = + { +/* 17 bits Nc[0], bc[0], mc[0], xmaxc[0] */ + 7, 2, 2, 6, +/* 39 bits (13x3) xmc[0-12] */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 + }; + unsigned char temp, parms[76], *parm_ptr, k; + short erp[40], *drp, wt[160], tmp; + const unsigned char *width; +/* read a frame from src and unpack it to parms: + 0-7 larc[0-7] + + 8 Nc[0] 25 Nc[1] + 9 bc[0] 26 bc[1] + 10 mc[0] 27 mc[1] + 11 xmaxc[0] 28 xmaxc[1] + 12-24 xmc[0-12] 29-41 xmc[13-25] + + 42 Nc[2] 59 Nc[3] + 43 bc[2] 60 bc[3] + 44 mc[2] 61 mc[3] + 45 xmaxc[2] 62 xmaxc[3] + 46-58 xmc[26-38] 63-75 xmc[39-51] */ + + parm_ptr = parms; + width = larc_width_table; + for(temp = 8; temp != 0; temp--) + { + *parm_ptr = read_bits(src, &state->bit_pos, *width); + parm_ptr++; + width++; + } + for(temp = 4; temp != 0; temp--) + { + width = width_table; + for(k = 17; k != 0; k--) + { + *parm_ptr = read_bits(src, &state->bit_pos, *width); + parm_ptr++; + width++; + } + } + drp = state->dp0 + 120; + parm_ptr = parms + 8; + for(temp = 0; temp < 4; temp++) + { + short exp, mant, xmp[13]; + + apcm_quantization_xmaxc_to_exp_mant(parm_ptr[3], &exp, &mant); + apcm_inverse_quantization(parm_ptr + 4, mant, exp, xmp); + rpe_grid_positioning(parm_ptr[2], xmp, erp); + gsm_long_term_synthesis_filtering(state, + parm_ptr[0], /* *Nc */ + parm_ptr[1], /* *bc */ + erp, drp); + for(k = 0; k <= 39; k++) + wt[temp * 40 + k] = drp[k]; + parm_ptr += 17; + } + gsm_short_term_synthesis_filter(state, + parms, /* larc */ + wt, dst); +/* postprocessing */ + for(temp = 160; temp != 0; temp--) + { + tmp = GSM_MULT_R(state->msr, 28180 ); + state->msr = GSM_ADD(*dst, tmp); /* Deemphasis */ + *dst = GSM_ADD(state->msr, state->msr) + & 0xFFF8; /* Truncation & Upscaling */ + dst++; + } +} +/***************************************************************************** +*****************************************************************************/ +static int get_sample(sound_info_t *info, short *left, short *right) +{ + gsm_decoder_t *state; + + state = (gsm_decoder_t *)info->fsd; +/* need to load a new GSM frame? */ + if(state->samples_left == 0) + { +/* read 65 bytes (two 32.5-byte GSM frames; Microsoft's packing method) */ + if(fread(state->gsm_frame, 1, 65, info->infile) != 65) + return -1; +/* decode the frames */ + state->bit_pos = 0; + gsm_decode_frame(state, state->gsm_frame, state->output); + gsm_decode_frame(state, state->gsm_frame, state->output + 160); + state->samples_left = 320; + } + *left = *right = state->output[320 - state->samples_left]; + state->samples_left--; + return 0; +} +/***************************************************************************** +*****************************************************************************/ +/* in WAV.C */ +int wav_validate(sound_info_t *info, unsigned sub_type); + +static int validate(sound_info_t *info) +{ + int err; + + fseek(info->infile, 0, SEEK_SET); +/* WAV sub-format #49 is GSM */ + err = wav_validate(info, 49); + if(err == 0) + { + if(info->channels != 1) + { + printf("sorry, only MONO GSM supported\n"); + return -1; + } +/* use calloc(), so it's zeroed */ + info->fsd = (void *)calloc(1, sizeof(gsm_decoder_t)); + if(info->fsd == NULL) + return -1; + info->depth = 16; + } + return err; +} +/***************************************************************************** +*****************************************************************************/ +codec_t _wav49 = +{ + ".wav Microsoft GSM", validate, get_sample +}; diff --git a/mobius/src/drivers/sound/wav85.c b/mobius/src/drivers/sound/wav85.c new file mode 100644 index 0000000..226bc15 --- /dev/null +++ b/mobius/src/drivers/sound/wav85.c @@ -0,0 +1,31 @@ +/***************************************************************************** +MP3 +sub-format 85 of .WAV format + +Who wants to implement this for me? :) +*****************************************************************************/ +#include "sound.h" + +/* in WAV.C */ +int wav_validate(sound_info_t *info, unsigned sub_type); +/***************************************************************************** +*****************************************************************************/ +static int validate(sound_info_t *info) +{ +/* WAV sub-format #85 is MP3 */ + if(wav_validate(info, 85) == 0) + printf("SORRY, MP3 NOT (YET) SUPPORTED..."); + return -1; +} +/***************************************************************************** +*****************************************************************************/ +static int get_sample(sound_info_t *info, short *left, short *right) +{ + return -1; +} +/***************************************************************************** +*****************************************************************************/ +codec_t _wav85 = +{ + ".wav MP3", validate, get_sample +}; diff --git a/mobius/src/drivers/sound/wss/wss.c b/mobius/src/drivers/sound/wss/wss.c new file mode 100644 index 0000000..6777ce9 --- /dev/null +++ b/mobius/src/drivers/sound/wss/wss.c @@ -0,0 +1,734 @@ +/***************************************************************************** +driver for Windows Sound System (Analog Devices AD1848 chip) +xxx - the logic in ad1848_irq() that decides whether or not to + call ad1848_stop_playback() may be defective + +xxx - need to pad buffer with zeroes at end of playback + that's why S8-PCM.WAV and M8-PCM.WAV are cut off at end + (with large BUF_SIZE) + +xxx - restore DMA-probing code + +xxx - get softset (see SOFTSET.C) working properly +*****************************************************************************/ +#include /* printf() */ +/* MK_FP(), FP_SEG(), FP_OFF(), setvect(), getvect() for Turbo C */ +#include "sound.h" /* DEBUG(X), among others */ +#include + +/* various AD1848-related delays -- +looks like a lot of thought went into them... */ +#define POWER_UP_DLY 100000L +#define RESYNC_DLY 100000L +#define ACI_HIGH_DLY 100000L +#define ACI_LOW_DLY 100000L + +/* DSP buffers -- large for few interrupts, small for responsiveness */ +#define NUM_BUFS 2 +#define LG2_BUF_SIZE 10 +#define BUF_SIZE (1u << (LG2_BUF_SIZE)) + +/* in DMA.C */ +int dma_from_mem(unsigned char chan, unsigned long adr, unsigned long count, + bool auto_init); + +/* ARGGGGH! Took me a few hours to track this bug down. +The while() loop in write_sample() was getting optimized into nothing. +Evidently, these two lines are NOT the same: +static volatile unsigned char *_dsp_buff_out; */ +static unsigned char * volatile _dsp_buff_out; + +//static unsigned short _dsp_buff_mem; +static unsigned char *_dsp_buff_in; +static unsigned char *_dsp_buff_base; +static volatile bool _playback_in_progress; + +static bool _is_open; +static unsigned short _ioadr; +static unsigned char _mode_byte, _irq, _dma = 3, _mce_bit = 0x40; + +typedef struct wss_t wss_t; +struct wss_t +{ + sound_t sound; + device_t *dev; +}; + +/***************************************************************************** +*****************************************************************************/ +static void ad1848_poke(unsigned char reg, unsigned char val) +{ + unsigned long timeout; + +/* wait for initialization, if ongoing, to finish */ + for(timeout = RESYNC_DLY; timeout != 0; timeout--) + { + if(in(_ioadr + 0) != 0x80) + break; + } + if(timeout == 0) + { + wprintf(L"ad1848_poke: error: timeout\n"); + return; + } +#ifdef DEBUG + timeout = RESYNC_DLY - timeout; + if(timeout != 0) + wprintf(L"\n", timeout); +#endif +/* address indirect register reg, and set MCE bit if necessary */ + out(_ioadr + 0, reg | _mce_bit); +/* write indirect register */ + out(_ioadr + 1, val); +} +/***************************************************************************** +*****************************************************************************/ +static unsigned char ad1848_peek(unsigned char reg) +{ + unsigned long timeout; + unsigned char ret_val; + +/* wait for initialization, if ongoing, to finish */ + for(timeout = RESYNC_DLY; timeout != 0; timeout--) + { + if(in(_ioadr + 0) != 0x80) + break; + } + if(timeout == 0) + { + wprintf(L"ad1848_peek: error: timeout\n"); + return -1; + } +#ifdef DEBUG + timeout = RESYNC_DLY - timeout; + if(timeout != 0) + wprintf(L"\n", timeout); +#endif +/* address indirect register reg, and set MCE bit if necessary */ + out(_ioadr + 0, reg | _mce_bit); +/* read indirect register */ + ret_val = in(_ioadr + 1); + return ret_val; +} +/***************************************************************************** +*****************************************************************************/ +static int ad1848_leave_mce(void) +{ + unsigned long timeout; + +/* wait for initialization, if ongoing, to finish */ + for(timeout = RESYNC_DLY; timeout != 0; timeout--) + { + if(in(_ioadr + 0) != 0x80) + break; + } + if(timeout == 0) + { + wprintf(L"ad1848_leave_mce: error: timeout\n"); + return -1; + } +#ifdef DEBUG + timeout = RESYNC_DLY - timeout; + if(timeout != 0) + wprintf(L"\n", timeout); +#endif +/* clear software MCE bit */ + _mce_bit &= ~0x40; +/* hardware already left MCE? */ + if(((in(_ioadr + 0) ^ _mce_bit) & 0x40) == 0) + return 0; +/* address indirect register 0, and clear hardware MCE bit */ + out(_ioadr + 0, _mce_bit); +/* wait for ACI to go high, then low. This must be done after +leaving the MCE state, regardless of the state of the ACAL bit. */ + for(timeout = ACI_HIGH_DLY; timeout != 0; timeout--) + { + if((ad1848_peek(11) & 0x20) != 0) + break; + } + if(timeout == 0) + { + wprintf(L"ad1848_leave_mce: error: ACI signal did " + "not go high\n"); + return -1; + } +#ifdef DEBUG + timeout = ACI_HIGH_DLY - timeout; + if(timeout != 0) + wprintf(L"\n", timeout); +#endif +/* */ + for(timeout = ACI_LOW_DLY; timeout != 0; timeout--) + { + if((ad1848_peek(11) & 0x20) == 0) + break; + } + if(timeout == 0) + { + wprintf(L"ad1848_leave_mce: error: ACI signal did " + "not return low\n"); + return -1; + } +#ifdef DEBUG + timeout = ACI_LOW_DLY - timeout; + if(timeout != 0) + wprintf(L"\n", timeout); +#endif + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static int ad1848_enter_mce(void) +{ + unsigned long timeout; + +/* wait for initialization, if ongoing, to finish */ + for(timeout = RESYNC_DLY; timeout != 0; timeout--) + { + if(in(_ioadr + 0) != 0x80) + break; + } + if(timeout == 0) + { + wprintf(L"ad1848_enter_mce: error: timeout\n"); + return - 1; + } +#ifdef DEBUG + timeout = RESYNC_DLY - timeout; + if(timeout != 0) + wprintf(L"\n", timeout); +#endif +/* set software MCE bit */ + _mce_bit |= 0x40; +/* hardware already in MCE? */ + if(((in(_ioadr + 0) ^ _mce_bit) & 0x40) == 0) + return 0; +/* address indirect register 0, and set hardware MCE bit */ + out(_ioadr + 0, _mce_bit); + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static int ad1848_detect(unsigned short ioadr) +{ + unsigned char temp, reg_val; + unsigned long timeout; + +/* poll index register of AD1848 until it returns something other than 0x80 */ + for(timeout = POWER_UP_DLY; timeout != 0; timeout--) + { + if(in(ioadr) != 0x80) + break; + } + if(timeout == 0) + return -1; +#ifdef DEBUG + timeout = POWER_UP_DLY - timeout; + if(timeout != 0) + wprintf(L"\n", timeout); +#endif +/* try writing various AD1848 registers (left and right input gain +and control regs) to see if chip is there */ + for(temp = 0; temp < 2; temp++) + { + out(ioadr + 0, temp); + out(ioadr + 1, 0xAA); + reg_val = in(ioadr + 1); + out(ioadr + 1, 0x45);/* b4 is reserved; always write 0 */ + if(reg_val != 0xAA || in(ioadr + 1) != 0x45) + return -1; + } +/* try changing the chip revision ID bits (they are read-only) */ + out(ioadr + 0, 0x0C); + reg_val = in(ioadr + 1); + out(ioadr + 1, reg_val ^ 0x0F); + if(((in(ioadr + 1) ^ reg_val) & 0x0F) != 0) + return -1; +/* found it! */ + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static void ad1848_set_volume(sound_t *sound, unsigned char level) +{ + unsigned char temp; + + level >>= 2; + TRACE1("ad1848_set_volume: %u/255\n", level << 2); +/* convert from gain to attenuation */ + level = 0x3F - level; +/* set left output level */ + temp = ad1848_peek(6) & ~0x3F; + ad1848_poke(6, temp | level); +/* set right output level */ + temp = ad1848_peek(7) & ~0x3F; + ad1848_poke(7, temp | level); +} +/***************************************************************************** +*****************************************************************************/ +#define ABS(X) (((X)<0) ? (-(X)) : (X)) + +static long ad1848_find_closest_rate(sound_t *sound, long rate) +{ + static const long rates[] = + { + 5512, 6615, 8000, 9600, 11025, 16000, 18900, + 22050, 27430, 32000, 33075L, 37800L, 44100L, 48000L + }; + unsigned char temp, closest = 0; + unsigned long delta; + + delta = -1uL; + for(temp = 0; temp < sizeof(rates) / sizeof(rates[0]); temp++) + { + if((unsigned long)ABS(rate - rates[temp]) < delta) + { + delta = ABS(rate - rates[temp]); + closest = temp; + } + } + TRACE2("ad1848_find_closest_rate: %ld -> %ld\n", rate, + rates[closest]); + return rates[closest]; +} +/***************************************************************************** +*****************************************************************************/ +static int ad1848_set_fmt(sound_t *sound, unsigned char depth, + unsigned char channels, long rate) +{ + _mode_byte = ad1848_peek(8) & ~0x5F; + switch(depth) + { + case 8: /* _mode_byte |= 0; */ break; + case 16: _mode_byte |= 0x40; break; + default: + wprintf(L"ad1848_set_fmt: error: bits/sample (%u) " + "is not 8 nor 16\n", depth); + return -1; + } + switch(channels) + { + case 1: /* _mode_byte |= 0; */ break; + case 2: _mode_byte |= 0x10; break; + default: + wprintf(L"ad1848_set_fmt: error: channels (%u) " + "is not 1 nor 2\n", channels); + return -1; + } + switch(rate) + { + case 8000: /* _mode_byte |= 0; */ break; + case 5512: _mode_byte |= 1; break; + case 16000: _mode_byte |= 2; break; + case 11025: _mode_byte |= 3; break; + case 27430: _mode_byte |= 4; break; + case 18900: _mode_byte |= 5; break; + case 32000: _mode_byte |= 6; break; + case 22050: _mode_byte |= 7; break; + + case 37800u: _mode_byte |= 9; break; + + case 44100u: _mode_byte |= 11; break; + case 48000u: _mode_byte |= 12; break; + case 33075u: _mode_byte |= 13; break; + case 9600: _mode_byte |= 14; break; + case 6615: _mode_byte |= 15; break; + default: + wprintf(L"ad1848_set_fmt: error: unsupported " + "sample rate %ld\n", rate); + return -1; + } + TRACE1("ad1848_set_fmt: mode byte=0x%X\n", _mode_byte); +/* must enter MCE state to change audio format or sample rate */ + ad1848_enter_mce(); + ad1848_poke(8, _mode_byte); + if(ad1848_leave_mce() != 0) + { + wprintf(L"ad1848_set_fmt: error leaving MCE state\n"); + return -1; + } + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static void ad1848_start_playback(sound_t *sound, unsigned long count) +{ + count--; +/* set AD1848 sample count for generation. +Register 15 (LSB of sample count) must be written first */ + ad1848_poke(15, count); + ad1848_poke(14, count >> 8); +/* select register 9; + single-channel DMA remains enabled (SDC; b2) + enable DMA playback (PEN; b0) */ +// ad1848_poke(9, 0x05); +/* select register 9; enable DMA playback (PEN; b0) +No need for MCE if only b0/b1 of register 9 are changed */ + ad1848_poke(9, ad1848_peek(9) | 0x01); +/* unmute outputs, if not already unmuted */ + ad1848_poke(6, ad1848_peek(6) & ~0x80); + ad1848_poke(7, ad1848_peek(7) & ~0x80); + _playback_in_progress = true; +} +/***************************************************************************** +*****************************************************************************/ +static void ad1848_stop_playback(sound_t *sound, bool wait) +{ + if(wait) + { + TRACE0("waiting...\n"); + while(_playback_in_progress) + /* nothing */; + } + else + { +/* mute outputs */ + ad1848_poke(6, ad1848_peek(6) | 0x80); + ad1848_poke(7, ad1848_peek(7) | 0x80); +/* select register 9: + single-channel DMA remains enabled (SDC; b2) + DMA playback off (PEN; b0) */ +// ad1848_poke(9, 0x04); +/* select register 9; disable DMA playback (PEN; b0) +No need for MCE if only b0/b1 of register 9 are changed */ + ad1848_poke(9, ad1848_peek(9) & ~0x01); + _playback_in_progress = false; + } +} +/***************************************************************************** +*****************************************************************************/ +static void ad1848_irq(sound_t *sound, unsigned irq) +{ + unsigned short in_buf, out_buf; + +/* clear at AD1848 */ + out(_ioadr + 2, 0); +/* clear at 8259 chips */ + //out(0x20, 0x20); + //if(_irq >= 8) + //out(0xA0, 0x20); +/* advance pointer */ + _dsp_buff_out += BUF_SIZE; + if(_dsp_buff_out >= _dsp_buff_base + NUM_BUFS * BUF_SIZE) + _dsp_buff_out = _dsp_buff_base; +/* are we now trying to play from the buffer currently being written? */ + in_buf = _dsp_buff_in - _dsp_buff_base; + in_buf >>= LG2_BUF_SIZE; + out_buf = _dsp_buff_out - _dsp_buff_base; + out_buf >>= LG2_BUF_SIZE; +/* yes, stop playback */ + if(in_buf == out_buf) + { +/* do NOT use printf() in an handler! */ + ad1848_stop_playback(sound, false); + } +} +/***************************************************************************** +*****************************************************************************/ +static int write_sample(sound_t *sound, short left, short right) +{ + unsigned short in_buf, out_buf, new_in_buf, count; + unsigned char depth, channels; + bool wait = false; + + depth = (_mode_byte & 0x40) ? 16 : 8; + channels = (_mode_byte & 0x10) ? 2 : 1; +/* to which buffer are we writing? */ + in_buf = _dsp_buff_in - _dsp_buff_base; + in_buf >>= LG2_BUF_SIZE; + while(1) +/* from which buffer are we playing? */ + { + out_buf = _dsp_buff_out - _dsp_buff_base; + out_buf >>= LG2_BUF_SIZE; +/* if they are the same, and if playback is active, +then wait until playback of this buffer is complete */ + if(out_buf != in_buf) + break; + if(!_playback_in_progress) + break; + if(!wait) + { + TRACE0("waiting..."); + wait = true; + } + } +/* store sample and advance pointer */ + if(depth == 16) + { + write_le16(_dsp_buff_in, left); + _dsp_buff_in += 2; + if(channels == 2) + { + write_le16(_dsp_buff_in, right); + _dsp_buff_in += 2; + count = BUF_SIZE >> 2; + } + else + count = BUF_SIZE >> 1; + } + else /* if(depth == 8) */ + { + left >>= 8; + *_dsp_buff_in = left; + _dsp_buff_in++; + if(channels == 2) + { + right >>= 8; + *_dsp_buff_in = right; + _dsp_buff_in++; + count = BUF_SIZE >> 1; + } + else + count = BUF_SIZE; + } + if(_dsp_buff_in >= _dsp_buff_base + NUM_BUFS * BUF_SIZE) + _dsp_buff_in = _dsp_buff_base; +/* did we cross over into a new buffer? */ + new_in_buf = _dsp_buff_in - _dsp_buff_base; + new_in_buf >>= LG2_BUF_SIZE; +/* if yes, and if not currently playing, then kick-start playback */ + if((new_in_buf != in_buf) && !_playback_in_progress) + { +/* you should see this message ONCE, when playback starts +see it again if you pause/unpause the playback + +if you see it many times, something's wrong */ + wprintf(L"*** kicking playback ***\n"); + ad1848_start_playback(sound, count); + } + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static bool ad1848_open(sound_t *sound) +{ + static const unsigned char init_vals[] = + { + 0xA8, 0xA8, /* input from line, input gain=0 */ + 0x08, 0x08, /* unmute aux #1, midrange aux #1 attenuate */ + 0x08, 0x08, /* unmute aux #2, midrange aux #2 attenuate */ + 0x90, 0x90, /* MUTE output, midrange output attenuate */ + 0x0C, /* 48000 Hz, mono, 8-bit, PCM */ +/* set PPIO (b6; for PIO playback), set ACAL (b3; auto-calibrate); +set SDC (b2; single-channel DMA) */ + 0x4D, + 0x02, /* enable interrupts */ + 0x00, 0x00, 0x00, + 0x00, 0x00 /* every sample */ + }; + static const unsigned short base_io_adr[] = + { + 0x530, 0x604, 0xE80, 0xF40 + }; + unsigned short temp; + unsigned long temp2; +// unsigned char dma_mask; + int err = -1; + dword index; + wss_t *wss = (wss_t*) sound; + +/* already open? */ + if(_is_open) + return 0; +/* PROBE FOR HARDWARE */ + TRACE0("ad1848_open: probing for Windows Sound System\n"); +/* probe for AD1848 chip 4 bytes above base I/O address */ + temp = 0; + for(; temp < sizeof(base_io_adr) / sizeof(base_io_adr[0]); temp++) + { + _ioadr = base_io_adr[temp] + 4; + TRACE1("\t""probing at I/O=0x%03X...\n", _ioadr); + err = ad1848_detect(_ioadr); + if(err == 0) + break; + } + if(err != 0) + { + wprintf(L"\t""error: Windows Sound System not detected\n"); + return false; + } +/* enter Mode Change Enable (MCE) mode to initialize registers, +esp. to set the CPIO bit in register 9 (enables PIO mode playback) */ + TRACE0("entering MCE to enable PIO mode playback\n"); + if(ad1848_enter_mce() != 0) + { + wprintf(L"\t""error entering MCE state\n"); + return false; + } + for(temp = 0; temp < 16; temp++) + ad1848_poke(temp, init_vals[temp]); +/* leave MCE (else IRQ auto-probe will not work) */ + TRACE0("leaving MCE mode\n"); + if(ad1848_leave_mce() != 0) + { + wprintf(L"\t""error leaving MCE state\n"); + return false; + } + +#if 0 +/* PROBE FOR IRQ */ + TRACE0("probing AD1848 chip IRQ...\n"); +// irq_mask = 0x0E80; /* IRQs 11, 10, 9, 7 */ + irq_mask = 0x0EA0; /* IRQs 11, 10, 9, 7, 5 */ +/* are one or more of those IRQs busy? */ + if(irq_start_probe(&irq_mask) != 0) + { + if(irq_mask == 0) /* they're ALL busy */ + { + wprintf(L"\t""error: all IRQs in use\n"); + return false; + } +/* try again, avoiding busy IRQs returned by first call */ + if(irq_start_probe(&irq_mask) != 0) + { + wprintf(L"\t""error: could not start IRQ probe\n"); + return false; + } + } +/* xxx - I don't know why I have to set this a second time.. +OSS driver for AD1848 says + "Write to I8 starts resynchronization. Wait until it completes." +so maybe I have to do that _immediately_ after writing register 8 above, +not waiting until regs 9-15 have also been written. */ + ad1848_poke(15, 0); + ad1848_poke(14, 0); +/* use PIO mode playback to trigger IRQs */ + TRACE0("\t""starting PIO mode playback...\n"); +/* MIN_IRQS (3) loops, 1 millisecond/loop == 3 millisecond probe time */ + for(temp = MIN_IRQS; temp != 0; temp--) + { +/* poll to see if chip ready for a sample */ + if((in(_ioadr + 2) & 2) != 0) +/* write zero sample */ + { + out(_ioadr + 3, 0); +/* clear the generated IRQ */ + out(_ioadr + 2, 0); + } +/* with sampling rate of 48000 Hz, this could go as low as +21 microseconds (usleep(21)?) for faster probing */ + msleep(1); + } +/* end probe */ + err = irq_end_probe(&irq_mask); +/* IRQ probe results: */ + TRACE2("\t""irq_end_probe() returned %d; " + "irq_mask=0x%04X\n", temp, irq_mask); + if(err < 0 || irq_mask == 0) + { + wprintf(L"\t""error: could not probe IRQ\n" + "Try using SOFTSET to set board IRQ and DMA\n"); + return -1; + } + _irq = err; +/* enter MCE again to turn off PIO mode */ + TRACE0("entering MCE to enable DMA mode playback\n"); + if(ad1848_enter_mce() != 0) + { + wprintf(L"\t""error entering MCE state\n"); + return -1; + } +#endif + + index = devFindResource(wss->dev->config, dresIrq, 0); + if (index == (dword) -1) + return false; + + _irq = wss->dev->config->resources[index].u.irq; + +/* xxx - don't know why I have to leave auto-calibrate turned on... + ad1848_poke(9, 0x04); SDC */ + ad1848_poke(9, 0x0C); /* ACAL, SDC */ + TRACE0("leaving MCE mode\n"); + if(ad1848_leave_mce() != 0) + { + wprintf(L"\t""error leaving MCE state\n"); + return -1; + } + + + +/* clear any dangling IRQ at AD1848 chip */ + out(_ioadr + 2, 0); +/* enable interrupts at 8259 controller chips */ + temp = 1; + temp <<= _irq; + out(0x21, in(0x21) & ~temp); + temp >>= 8; + out(0xA1, in(0xA1) & ~temp); + + _dsp_buff_base = + (unsigned char*) memAllocLowSpan((BUF_SIZE * NUM_BUFS) / PAGE_SIZE); + if (_dsp_buff_base == NULL) + { + wprintf(L"\tFailed to allocate %u pages\n", (BUF_SIZE * NUM_BUFS) / PAGE_SIZE); + return false; + } + + _dsp_buff_in = _dsp_buff_base; + _dsp_buff_out = _dsp_buff_base; + temp2 >>= 4; +/* */ + wprintf(L"\tAD1848 chip at I/O=0x%03X, IRQ=%u, DMA=%u\n", + _ioadr, _irq, _dma); + wprintf(L"\t%u DSP buffers at %04lX:0000 (%u bytes each, " + "%u bytes total)\n", NUM_BUFS, temp2, BUF_SIZE, + NUM_BUFS * BUF_SIZE); +/* arm auto-initializing DMA */ + err = dma_from_mem(_dma, (addr_t) _dsp_buff_base, + NUM_BUFS * BUF_SIZE, true); + if(err != 0) + return err; +/* crap, don't forget this, or ad1848_close() won't work */ + _is_open = true; +/* take over vector */ + devRegisterIrq(wss->dev, _irq, true); + return 0; +} +/***************************************************************************** +*****************************************************************************/ +static void ad1848_close(sound_t *sound) +{ + addr_t addr; + + TRACE0("ad1848_close\n"); +/* already closed? */ + if(!_is_open) + return; +/* abort playback */ + if(_playback_in_progress) + { + TRACE0("aborting playback...\n"); + ad1848_stop_playback(sound, false); + } + + for (addr = 0; addr < BUF_SIZE * NUM_BUFS; addr += PAGE_SIZE) + memFree((addr_t) _dsp_buff_base + addr); + +/* restore old vector */ + devRegisterIrq(((wss_t*) sound)->dev, _irq, true); + _is_open = false; +} +/***************************************************************************** +*****************************************************************************/ +wss_t wss_drv = +{ + { + ad1848_open, + ad1848_find_closest_rate, + ad1848_set_fmt, + ad1848_set_volume, + write_sample, + ad1848_stop_playback, + ad1848_close, + ad1848_irq, + }, + NULL +}; + +sound_t *wss_init(device_t *dev) +{ + wss_drv.dev = dev; + return &wss_drv.sound; +} \ No newline at end of file diff --git a/mobius/src/drivers/template.c b/mobius/src/drivers/template.c new file mode 100644 index 0000000..a300f24 --- /dev/null +++ b/mobius/src/drivers/template.c @@ -0,0 +1,36 @@ +#include +#include +#include + +bool devRequest(device_t* dev, request_t* req) +{ + switch (req->code) + { + case DEV_REMOVE: + hndFree(dev); + + case DEV_OPEN: + case DEV_CLOSE: + hndSignal(req->event, true); + return true; + } + + req->result = ENOTIMPL; + return false; +} + +device_t* devAddDevice(driver_t* drv, const wchar_t* name, device_config_t* cfg) +{ + device_t* dev; + + dev = hndAlloc(sizeof(device_t), NULL); + dev->request = devRequest; + dev->driver = drv; + return dev; +} + +bool STDCALL INIT_CODE drvInit(driver_t* drv) +{ + drv->add_device = vgatAddDevice; + return true; +} \ No newline at end of file diff --git a/mobius/src/drivers/textcons/Makefile b/mobius/src/drivers/textcons/Makefile new file mode 100644 index 0000000..d6de31c --- /dev/null +++ b/mobius/src/drivers/textcons/Makefile @@ -0,0 +1,5 @@ +TARGET= $(BIN)/textcons.drv +OBJS= console.o textcons.o +BASE= @$(BIN)\coffbase.txt,textcons + +include ../make.driver diff --git a/mobius/src/drivers/textcons/console.cpp b/mobius/src/drivers/textcons/console.cpp new file mode 100644 index 0000000..8025f8a --- /dev/null +++ b/mobius/src/drivers/textcons/console.cpp @@ -0,0 +1,367 @@ +#include "console.h" +#include +#include +#include + +/***************************************************************************** + * CConsole * + *****************************************************************************/ + +CConsole::CConsole() +{ + m_refs = 0; + m_con_x = 0; + m_con_y = 0; + m_width = m_height = 0; + m_attrib = 0x0700; + m_esc = 0; +} + +// IUnknown methods +HRESULT CConsole::QueryInterface(REFIID iid, void ** ppvObject) +{ + //wprintf(L"QI"); + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IDevice)) + { + //wprintf(L"(IDevice)\n"); + AddRef(); + *ppvObject = (IDevice*) this; + return S_OK; + } + else if (InlineIsEqualGUID(iid, IID_IStream)) + { + //wprintf(L"(IStream)\n"); + AddRef(); + *ppvObject = (IStream*) new CStream(this); + return S_OK; + } + + /*wprintf(L"(fail) %p %p {%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x} %p\n", + this, + iid.Data1, iid.Data2, iid.Data3, + iid.Data4[0], + iid.Data4[1], + iid.Data4[2], + iid.Data4[3], + iid.Data4[4], + iid.Data4[5], + iid.Data4[6], + iid.Data4[7], + ppvObject);*/ + *ppvObject = NULL; + return E_FAIL; +} + +ULONG CConsole::AddRef() +{ + return ++m_refs; +} + +ULONG CConsole::Release() +{ + if (m_refs == 0) + { + delete this; + return 0; + } + else + return --m_refs; +} + +// IDevice method +HRESULT CConsole::GetInfo(device_t* buf) +{ + if (buf->size < sizeof(device_t)) + return E_FAIL; + + wcscpy(buf->name, L"Console"); + return S_OK; +} + +HRESULT CConsole::DeviceOpen() +{ + return S_OK; +} + +void CConsole::WriteCharacter(dword mode, wchar_t c) +{ + if (mode == ioRaw) + { + Output(m_con_x, m_con_y, c, 0); + m_con_x++; + + if (m_con_x >= m_width) + { + m_con_x = 0; + m_con_y++; + } + } + else + { + if (m_esc == 1) + { + if (c == L'[') + { + m_esc++; + m_esc1 = 0; + return; + } + } + else if (m_esc == 2) + { + if (iswdigit(c)) + { + m_esc1 = m_esc1 * 10 + c - L'0'; + return; + } + else if (c == ';') + { + m_esc++; + m_esc2 = 0; + return; + } + else if (c == 'J') + { + if (m_esc1 == 2) + Clear(); + } + else if (c == 'm') + SetAttrib(m_esc1); + + m_esc = 0; + return; + } + else if (m_esc == 3) + { + if (iswdigit(c)) + { + m_esc2 = m_esc2 * 10 + c - '0'; + return; + } + else if(c == ';') + { + m_esc++; /* ESC[num1;num2; */ + m_esc3 = 0; + return; + } + /* ESC[num1;num2H -- move cursor to num1,num2 */ + else if(c == 'H') + { + if(m_esc2 < m_width) + m_con_x = m_esc2; + if(m_esc1 < m_height) + m_con_y = m_esc1; + } + /* ESC[num1;num2m -- set attributes num1,num2 */ + else if(c == 'm') + { + SetAttrib(m_esc1); + SetAttrib(m_esc2); + } + m_esc = 0; + return; + } + /* ESC[num1;num2;num3 */ + else if(m_esc == 4) + { + if (iswdigit(c)) + { + m_esc3 = m_esc3 * 10 + c - '0'; + return; + } + /* ESC[num1;num2;num3m -- set attributes num1,num2,num3 */ + else if(c == 'm') + { + SetAttrib(m_esc1); + SetAttrib(m_esc2); + SetAttrib(m_esc3); + } + m_esc = 0; + return; + } + + m_esc = 0; + switch (c) + { + case L'\n': + m_con_x = 0; + m_con_y++; + break; + + case L'\r': + m_con_x = 0; + break; + + case L'\t': + m_con_x = (m_con_x + 4) & ~3; + break; + + case L'\b': + if (m_con_x > 0) + m_con_x--; + break; + + case 27: + m_esc = 1; + break; + + default: + Output(m_con_x, m_con_y, c, m_attrib); + m_con_x++; + + if (m_con_x >= m_width) + { + m_con_x = 0; + m_con_y++; + } + } + } + + while (m_con_y >= m_height) + { + m_con_y--; + Scroll(0, -1); + } +} + +void CConsole::SetAttrib(byte att) +{ + static const char ansi_to_vga[] = + { + 0, 4, 2, 6, 1, 5, 3, 7 + }; + unsigned char new_att; + + new_att = m_attrib >> 8; + if(att == 0) + new_att &= ~0x08; /* bold off */ + else if(att == 1) + new_att |= 0x08; /* bold on */ + else if(att >= 30 && att <= 37) + { + att = ansi_to_vga[att - 30]; + new_att = (new_att & ~0x07) | att;/* fg color */ + } + else if(att >= 40 && att <= 47) + { + att = ansi_to_vga[att - 40] << 4; + new_att = (new_att & ~0x70) | att;/* bg color */ + } + + m_attrib = new_att << 8; +} + +/***************************************************************************** + * CConsole::CStream * + *****************************************************************************/ + +CConsole::CStream::CStream(CConsole* con) +{ + m_con = con; + m_con->AddRef(); + m_mode = ioUnicode; + m_refs = 0; +} + +CConsole::CStream::~CStream() +{ + if (m_con) + m_con->Release(); +} + +// IUnknown methods +HRESULT CConsole::CStream::QueryInterface(REFIID iid, void ** ppvObject) +{ + //wprintf(L"QI"); + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IStream)) + { + //wprintf(L"(IDevice)\n"); + AddRef(); + *ppvObject = (IStream*) this; + return S_OK; + } + else if (InlineIsEqualGUID(iid, IID_IDevice)) + { + //wprintf(L"(IStream)\n"); + m_con->AddRef(); + *ppvObject = (IDevice*) m_con; + return S_OK; + } + + //wprintf(L"(fail)\n"); + *ppvObject = NULL; + return E_FAIL; +} + +ULONG CConsole::CStream::AddRef() +{ + return ++m_refs; +} + +ULONG CConsole::CStream::Release() +{ + if (m_refs == 0) + { + delete this; + return 0; + } + else + return --m_refs; +} + +// IStream methods +size_t CConsole::CStream::Read(void* buffer, size_t length) +{ + return 0; +} + +size_t CConsole::CStream::Write(const void* buffer, size_t length) +{ + word* ch; + size_t written = 0; + + for (ch = (word*) buffer; written < length; ) + { + switch (m_mode) + { + case ioRaw: + case ioUnicode: + m_con->WriteCharacter(m_mode, *ch); + ch++; + written += sizeof(wchar_t); + break; + + case ioAnsi: + m_con->WriteCharacter(m_mode, (char) *ch); + ch = (word*) ((char*) ch + 1); + written += sizeof(char); + break; + } + } + + m_con->UpdateCursor(); + return written; +} + +HRESULT CConsole::CStream::SetIoMode(dword mode) +{ + m_mode = mode; + return S_OK; +} + +HRESULT CConsole::CStream::IsReady() +{ + return S_OK; +} + +HRESULT CConsole::CStream::Stat(folderitem_t* buf) +{ + return E_FAIL; +} + +HRESULT CConsole::CStream::Seek(long offset, int origin) +{ + return E_FAIL; +} \ No newline at end of file diff --git a/mobius/src/drivers/textcons/console.h b/mobius/src/drivers/textcons/console.h new file mode 100644 index 0000000..4c728eb --- /dev/null +++ b/mobius/src/drivers/textcons/console.h @@ -0,0 +1,60 @@ +#ifndef __CONSOLE_H +#define __CONSOLE_H + +#include + +class CConsole : public IUnknown, public IDevice +{ +protected: + dword m_refs; + unsigned short m_con_x, m_con_y, m_width, m_height; + byte m_esc, m_esc1, m_esc2, m_esc3; + word m_attrib; + +public: + CConsole(); + + virtual void UpdateCursor() = 0; + virtual void Output(int x, int y, wchar_t c, word attrib) = 0; + void WriteCharacter(dword mode, wchar_t c); + void SetAttrib(byte attrib); + virtual void Clear() = 0; + virtual void Scroll(int dx, int dy) = 0; + + // IUnknown methods + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + STDMETHOD_(ULONG, AddRef)(); + STDMETHOD_(ULONG, Release)(); + + // IDevice method + STDMETHOD(GetInfo)(device_t* buf); + STDMETHOD(DeviceOpen)(); + + class CStream : public IUnknown, public IStream + { + protected: + CConsole *m_con; + dword m_mode, m_refs; + + public: + CStream(CConsole* con); + ~CStream(); + + // IUnknown methods + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + STDMETHOD_(ULONG, AddRef)(); + STDMETHOD_(ULONG, Release)(); + + // IStream methods + STDMETHOD_(size_t, Read)(void* buffer, size_t length); + STDMETHOD_(size_t, Write)(const void* buffer, size_t length); + STDMETHOD(SetIoMode)(dword mode); + STDMETHOD(IsReady)(); + STDMETHOD(Stat)(folderitem_t* buf); + STDMETHOD(Seek)(long offset, int origin); + }; + + friend class CStream; +}; + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/textcons/textcons.cpp b/mobius/src/drivers/textcons/textcons.cpp new file mode 100644 index 0000000..5713658 --- /dev/null +++ b/mobius/src/drivers/textcons/textcons.cpp @@ -0,0 +1,70 @@ +#define INITGUID +#include "textcons.h" +#include +#include +#include + +#define VGA_CRTC_INDEX 0x3D4 +#define VGA_CRTC_DATA 0x3D5 + +#pragma code_seg(".init") + +extern "C" bool STDCALL drvInit() +{ + _cputws_check(L" \n" CHECK_L2 L"Console\r\t"); + sysExtRegisterDevice(L"screen", new CTextConsole); + return true; +} + +/***************************************************************************** + * CTextConsole * + *****************************************************************************/ + +CTextConsole::CTextConsole() +{ + m_buffer = (word*) 0xb8000; + //m_buffer = (dword*) 0xff000000; + m_width = 80; + m_height = 25; + //Clear(); +} + +#pragma code_seg() + +void CTextConsole::UpdateCursor() +{ + unsigned short Off; + + Off = (m_con_y * m_width + m_con_x) * 2; + // extra shift because even/odd text mode uses word clocking + out(VGA_CRTC_INDEX, 14); + out(VGA_CRTC_DATA, Off >> 9); + out(VGA_CRTC_INDEX, 15); + out(VGA_CRTC_DATA, Off >> 1); +} + +void CTextConsole::Output(int x, int y, wchar_t c, word attrib) +{ + char sc[2]; + wcstombs(sc, &c, 1); + m_buffer[y * m_width + x] = (unsigned char) sc[0] | (attrib & 0xff00); +} + +void CTextConsole::Clear() +{ + word w = m_attrib | ' '; + m_con_x = m_con_y = 0; + i386_lmemset32((addr_t) m_buffer, + (dword) w << 16 | w, + m_width * m_height * sizeof(*m_buffer)); +} + +void CTextConsole::Scroll(int dx, int dy) +{ + i386_llmemcpy((addr_t) m_buffer, (addr_t) (m_buffer - dy * m_width), + sizeof(*m_buffer) * m_width * (m_height + dy)); + + i386_lmemset32((addr_t) (m_buffer + m_width * (m_height + dy)), + (dword) (m_attrib | ' ') << 16 | m_attrib | ' ', + sizeof(*m_buffer) * m_width * -dy); +} diff --git a/mobius/src/drivers/textcons/textcons.dsp b/mobius/src/drivers/textcons/textcons.dsp new file mode 100644 index 0000000..20183cb --- /dev/null +++ b/mobius/src/drivers/textcons/textcons.dsp @@ -0,0 +1,117 @@ +# Microsoft Developer Studio Project File - Name="textcons" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=textcons - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "textcons.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "textcons.mak" CFG="textcons - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "textcons - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "textcons - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "textcons - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f textcons.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "textcons.exe" +# PROP BASE Bsc_Name "textcons.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "nmake /f "textcons.mak"" +# PROP Rebuild_Opt "/a" +# PROP Target_File "textcons.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "textcons - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f textcons.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "textcons.exe" +# PROP BASE Bsc_Name "textcons.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "set" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\bin\textcons.dll" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "textcons - Win32 Release" +# Name "textcons - Win32 Debug" + +!IF "$(CFG)" == "textcons - Win32 Release" + +!ELSEIF "$(CFG)" == "textcons - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\console.cpp +# End Source File +# Begin Source File + +SOURCE=.\textcons.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\console.h +# End Source File +# Begin Source File + +SOURCE=.\textcons.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/textcons/textcons.h b/mobius/src/drivers/textcons/textcons.h new file mode 100644 index 0000000..4af6556 --- /dev/null +++ b/mobius/src/drivers/textcons/textcons.h @@ -0,0 +1,20 @@ +#ifndef __TEXTCONS_H +#define __TEXTCONS_H + +#include "console.h" + +class CTextConsole : public CConsole +{ +protected: + word* m_buffer; + + virtual void UpdateCursor(); + virtual void Output(int x, int y, wchar_t c, word attrib); + virtual void Clear(); + virtual void Scroll(int dx, int dy); + +public: + CTextConsole(); +}; + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/textcons/textcons.plg b/mobius/src/drivers/textcons/textcons.plg new file mode 100644 index 0000000..c323147 --- /dev/null +++ b/mobius/src/drivers/textcons/textcons.plg @@ -0,0 +1,26 @@ + + +
+

Build Log

+

+--------------------Configuration: textcons - Win32 Debug-------------------- +

+ +cl /nologo /D__MOBIUS__ /DKERNEL /If:\Projects\mobius\include /c textcons.cpp /Fotextcons.o +textcons.cpp +console.h(7) : error C2504: 'IDevice' : base class undefined +console.h(34) : error C2504: 'IStream' : base class undefined +console.h(53) : error C2061: syntax error : identifier 'folderitem_t' +textcons.cpp(13) : error C2733: second C linkage of overloaded function 'drvInit' not allowed + textcons.cpp(12) : see declaration of 'drvInit' +textcons.cpp(15) : error C2065: 'sysExtRegisterDevice' : undeclared identifier +make: *** [textcons.o] Error 2 +Error executing make. + + + +

Results

+textcons.dll - 6 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/drivers/vgatext/Makefile b/mobius/src/drivers/vgatext/Makefile new file mode 100644 index 0000000..69e4542 --- /dev/null +++ b/mobius/src/drivers/vgatext/Makefile @@ -0,0 +1,7 @@ +TARGET= $(BIN)/vgatext.drv +OBJS= vgatext.o +BASE= vgatext + +include ../make.driver + +include $(OBJS:.o=.d) \ No newline at end of file diff --git a/mobius/src/drivers/vgatext/vgatext.c b/mobius/src/drivers/vgatext/vgatext.c new file mode 100644 index 0000000..f6ba802 --- /dev/null +++ b/mobius/src/drivers/vgatext/vgatext.c @@ -0,0 +1,101 @@ +#include +#include +#include + +/*! + * \ingroup drivers + * \defgroup vgatext CGA text-mode frame buffer + * @{ + */ + +#define _crtc_base_adr 0x3C0 + +/* I/O addresses for VGA registers */ +#define VGA_MISC_READ 0x3CC +#define VGA_GC_INDEX 0x3CE +#define VGA_GC_DATA 0x3CF +#define VGA_CRTC_INDEX 0x14 /* relative to 0x3C0 or 0x3A0 */ +#define VGA_CRTC_DATA 0x15 /* relative to 0x3C0 or 0x3A0 */ + +bool vgatRequest(device_t* dev, request_t* req) +{ + int i; + void* base; + dword* params; + + i = devFindResource(dev->config, dresMemory, 0); + if (i == -1) + base = (void*) 0xb8000; + else + base = (void*) dev->config->resources[i].u.memory.base; + + switch (req->code) + { + case DEV_OPEN: + case DEV_CLOSE: + hndSignal(req->event, true); + return true; + + case DEV_WRITE: + memcpy(base + (dword) req->params.write.pos, + (void*) req->params.write.buffer, + req->params.write.length); + hndSignal(req->event, true); + return true; + + case DEV_READ: + memcpy((void*) req->params.read.buffer, + base + (dword) req->params.read.pos, + req->params.read.length); + hndSignal(req->event, true); + return true; + + case DEV_IOCTL: + params = (dword*) req->params.ioctl.buffer; + switch (req->params.ioctl.code) + { + case 0: + /* extra shift because even/odd text mode uses word clocking */ + + /* set base address */ + out(_crtc_base_adr + VGA_CRTC_INDEX, 12); + out(_crtc_base_adr + VGA_CRTC_DATA, params[0] >> 9); + out(_crtc_base_adr + VGA_CRTC_INDEX, 13); + out(_crtc_base_adr + VGA_CRTC_DATA, params[0] >> 1); + + /* move cursor */ + out(_crtc_base_adr + VGA_CRTC_INDEX, 14); + out(_crtc_base_adr + VGA_CRTC_DATA, params[1] >> 9); + out(_crtc_base_adr + VGA_CRTC_INDEX, 15); + out(_crtc_base_adr + VGA_CRTC_DATA, params[1] >> 1); + + hndSignal(req->event, true); + return true; + } + + break; + } + + req->result = ENOTIMPL; + return false; +} + +device_t* vgatAddDevice(driver_t* drv, const wchar_t* name, device_config_t* cfg) +{ + device_t* dev; + + dev = hndAlloc(sizeof(device_t), NULL); + dev->request = vgatRequest; + dev->driver = drv; + dev->config = cfg; + dev->req_first = dev->req_last = NULL; + return dev; +} + +bool STDCALL INIT_CODE drvInit(driver_t* drv) +{ + drv->add_device = vgatAddDevice; + return true; +} + +//@} \ No newline at end of file diff --git a/mobius/src/drivers/vgatext/vgatext.d b/mobius/src/drivers/vgatext/vgatext.d new file mode 100644 index 0000000..be1f122 --- /dev/null +++ b/mobius/src/drivers/vgatext/vgatext.d @@ -0,0 +1,11 @@ +vgatext.o: vgatext.c f:\Projects\mobius\include\kernel/kernel.h \ + f:\Projects\mobius\include\kernel/i386.h \ + f:\Projects\mobius\include\sys/types.h \ + f:\Projects\mobius\include\wchar.h f:\Projects\mobius\include\os/os.h \ + f:\Projects\mobius\include\kernel/driver.h \ + f:\Projects\mobius\include\kernel/proc.h \ + f:\Projects\mobius\include\kernel/obj.h \ + f:\Projects\mobius\include\os/pe.h \ + f:\Projects\mobius\include\kernel/handle.h \ + f:\Projects\mobius\include\os/devreq.h \ + f:\Projects\mobius\include\errno.h diff --git a/mobius/src/drivers/vgatext/vgatext.dsp b/mobius/src/drivers/vgatext/vgatext.dsp new file mode 100644 index 0000000..5f4c0e7 --- /dev/null +++ b/mobius/src/drivers/vgatext/vgatext.dsp @@ -0,0 +1,105 @@ +# Microsoft Developer Studio Project File - Name="vgatext" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=vgatext - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "vgatext.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "vgatext.mak" CFG="vgatext - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "vgatext - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "vgatext - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "vgatext - Win32 Release" + +# PROP BASE Use_MFC +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f vgatext.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "vgatext.exe" +# PROP BASE Bsc_Name "vgatext.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\vgatext.drv" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "vgatext - Win32 Debug" + +# PROP BASE Use_MFC +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f vgatext.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "vgatext.exe" +# PROP BASE Bsc_Name "vgatext.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "make" +# PROP Rebuild_Opt "rebuild" +# PROP Target_File "..\..\..\bin\vgatext.drv" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "vgatext - Win32 Release" +# Name "vgatext - Win32 Debug" + +!IF "$(CFG)" == "vgatext - Win32 Release" + +!ELSEIF "$(CFG)" == "vgatext - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\vgatext.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Makefile +# End Source File +# End Target +# End Project diff --git a/mobius/src/drivers/vgatext/vgatext.plg b/mobius/src/drivers/vgatext/vgatext.plg new file mode 100644 index 0000000..15481d3 --- /dev/null +++ b/mobius/src/drivers/vgatext/vgatext.plg @@ -0,0 +1,19 @@ + + +
+

Build Log

+

+--------------------Configuration: vgatext - Win32 Debug-------------------- +

+ +'make' is not recognized as an internal or external command, +operable program or batch file. +Error executing i:\winnt\system32\cmd.exe. + + + +

Results

+vgatext.drv - 1 error(s), 0 warning(s) +
+ + diff --git a/mobius/src/drivers/video/Makefile b/mobius/src/drivers/video/Makefile new file mode 100644 index 0000000..6d4dbef --- /dev/null +++ b/mobius/src/drivers/video/Makefile @@ -0,0 +1,7 @@ +TARGET= $(BIN)/video.drv +OBJS= video.o vga4.o cupertino.o +BASE= video + +include ../make.driver + +include $(OBJS:.o=.d) \ No newline at end of file diff --git a/mobius/src/drivers/video/cupertino.c b/mobius/src/drivers/video/cupertino.c new file mode 100644 index 0000000..39441e5 --- /dev/null +++ b/mobius/src/drivers/video/cupertino.c @@ -0,0 +1,125 @@ +unsigned char cupertino[3072] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 48, 48, 48, 48, 48, 48, 0, 48, 48, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 48, 48, 16, 32, 0, + 0, 0, 0, 0, 124, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 48, 48, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 120, 204, 204, 204, 204, 204, 204, 204, 120, 0, 0, 0, + 48, 112, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, + 124, 134, 6, 12, 24, 48, 96, 192, 252, 0, 0, 0, + 252, 8, 16, 56, 12, 12, 12, 140, 120, 0, 0, 0, + 4, 12, 28, 44, 76, 254, 12, 12, 12, 0, 0, 0, + 252, 192, 192, 248, 12, 12, 12, 140, 120, 0, 0, 0, + 56, 96, 192, 248, 204, 204, 204, 204, 120, 0, 0, 0, + 252, 12, 12, 12, 24, 48, 48, 48, 48, 0, 0, 0, + 120, 204, 204, 204, 120, 204, 204, 204, 120, 0, 0, 0, + 120, 204, 204, 204, 204, 124, 12, 24, 112, 0, 0, 0, + 0, 0, 0, 48, 48, 0, 0, 48, 48, 0, 0, 0, + 0, 0, 0, 48, 48, 0, 0, 48, 48, 16, 32, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 120, 140, 12, 24, 48, 48, 0, 48, 48, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 120, 204, 204, 204, 252, 204, 204, 204, 204, 0, 0, 0, + 248, 204, 204, 204, 248, 204, 204, 204, 248, 0, 0, 0, + 120, 196, 192, 192, 192, 192, 192, 196, 120, 0, 0, 0, + 248, 204, 204, 204, 204, 204, 204, 204, 248, 0, 0, 0, + 252, 192, 192, 192, 248, 192, 192, 192, 252, 0, 0, 0, + 252, 192, 192, 192, 248, 192, 192, 192, 192, 0, 0, 0, + 120, 196, 192, 192, 220, 204, 204, 204, 120, 0, 0, 0, + 204, 204, 204, 204, 252, 204, 204, 204, 204, 0, 0, 0, + 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, + 12, 12, 12, 12, 12, 12, 204, 204, 120, 0, 0, 0, + 198, 204, 216, 240, 224, 240, 216, 204, 198, 0, 0, 0, + 192, 192, 192, 192, 192, 192, 192, 192, 252, 0, 0, 0, + 130, 198, 238, 254, 186, 146, 130, 130, 130, 0, 0, 0, + 130, 194, 226, 242, 186, 158, 142, 134, 130, 0, 0, 0, + 120, 204, 204, 204, 204, 204, 204, 204, 120, 0, 0, 0, + 248, 204, 204, 248, 192, 192, 192, 192, 192, 0, 0, 0, + 120, 204, 204, 204, 204, 204, 204, 204, 120, 12, 0, 0, + 248, 204, 204, 248, 204, 204, 204, 204, 204, 0, 0, 0, + 112, 200, 192, 224, 112, 56, 24, 152, 112, 0, 0, 0, + 252, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, + 204, 204, 204, 204, 204, 204, 204, 204, 120, 0, 0, 0, + 204, 204, 204, 204, 204, 204, 204, 200, 240, 0, 0, 0, + 214, 214, 214, 214, 214, 214, 214, 212, 248, 0, 0, 0, + 204, 204, 204, 120, 48, 120, 204, 204, 204, 0, 0, 0, + 204, 204, 204, 120, 48, 48, 48, 48, 48, 0, 0, 0, + 252, 12, 12, 24, 48, 96, 192, 192, 252, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 254, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 120, 140, 124, 204, 204, 204, 124, 0, 0, 0, + 192, 192, 248, 204, 204, 204, 204, 204, 248, 0, 0, 0, + 0, 0, 120, 196, 192, 192, 192, 196, 120, 0, 0, 0, + 12, 12, 124, 204, 204, 204, 204, 204, 124, 0, 0, 0, + 0, 0, 120, 204, 204, 252, 192, 196, 120, 0, 0, 0, + 56, 96, 240, 96, 96, 96, 96, 96, 96, 0, 0, 0, + 0, 0, 124, 204, 204, 204, 204, 204, 124, 12, 140, 120, + 192, 192, 248, 204, 204, 204, 204, 204, 204, 0, 0, 0, + 48, 0, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, + 24, 0, 24, 24, 24, 24, 24, 24, 24, 24, 152, 112, + 192, 192, 204, 216, 240, 224, 240, 216, 204, 0, 0, 0, + 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, + 0, 0, 252, 214, 214, 214, 214, 214, 214, 0, 0, 0, + 0, 0, 248, 204, 204, 204, 204, 204, 204, 0, 0, 0, + 0, 0, 120, 204, 204, 204, 204, 204, 120, 0, 0, 0, + 0, 0, 248, 204, 204, 204, 204, 204, 248, 192, 192, 0, + 0, 0, 124, 204, 204, 204, 204, 204, 124, 12, 12, 0, + 0, 0, 216, 224, 192, 192, 192, 192, 192, 0, 0, 0, + 0, 0, 112, 200, 224, 112, 56, 152, 112, 0, 0, 0, + 96, 96, 240, 96, 96, 96, 96, 96, 48, 0, 0, 0, + 0, 0, 204, 204, 204, 204, 204, 204, 124, 0, 0, 0, + 0, 0, 204, 204, 204, 204, 204, 200, 240, 0, 0, 0, + 0, 0, 214, 214, 214, 214, 214, 212, 248, 0, 0, 0, + 0, 0, 204, 204, 204, 120, 204, 204, 204, 0, 0, 0, + 0, 0, 204, 204, 204, 204, 204, 204, 124, 12, 140, 120, + 0, 0, 252, 12, 24, 48, 96, 192, 252, 0, 0, 0, +}; \ No newline at end of file diff --git a/mobius/src/drivers/video/vga4.c b/mobius/src/drivers/video/vga4.c new file mode 100644 index 0000000..ebeda15 --- /dev/null +++ b/mobius/src/drivers/video/vga4.c @@ -0,0 +1,299 @@ +#include +#include +#include "video.h" + +//! Physical address of the VGA frame buffer +addr_t video_base = 0xa0000; +int maskbit[640], y80[480], xconv[640], startmasks[8], endmasks[8]; + +void vga4Close(video_t *vid) +{ +} + +int vga4EnumModes(video_t *vid, unsigned index, videomode_t *mode) +{ + /* We only support one mode -- BIOS 12h (set by the real-mode loader) */ + if (index == 0) + { + mode->cookie = 0; + mode->width = 640; + mode->height = 480; + mode->bitsPerPixel = 4; + mode->bytesPerLine = (mode->width * mode->bitsPerPixel) / 8; + return VID_ENUM_STOP; + } + else + return VID_ENUM_ERROR; +} + +bool vga4SetMode(video_t *vid, videomode_t *mode) +{ + /* Clear the screen when we "change" modes */ + //vid->vidFillRect(vid, 0, 0, mode->width, mode->height, 0); + return true; +} + +void vga4PreCalc() +{ + unsigned long j; + + startmasks[7] = 255; + startmasks[6] = 127; + startmasks[5] = 63; + startmasks[4] = 31; + startmasks[3] = 15; + startmasks[2] = 7; + startmasks[1] = 3; + startmasks[0] = 1; + + endmasks[0] = 255; + endmasks[1] = 128; + endmasks[2] = 192; + endmasks[3] = 224; + endmasks[4] = 240; + endmasks[5] = 248; + endmasks[6] = 252; + endmasks[7] = 254; + + for (j = 0; j < 80; j++) + { + maskbit[j * 8] = 128; + maskbit[j * 8 + 1] = 64; + maskbit[j * 8 + 2] = 32; + maskbit[j * 8 + 3] = 16; + maskbit[j * 8 + 4] = 8; + maskbit[j * 8 + 5] = 4; + maskbit[j * 8 + 6] = 2; + maskbit[j * 8 + 7] = 1; + } + + for (j = 0; j < 480; j++) + y80[j] = j * 80; + for (j = 0; j < 640; j++) + xconv[j] = j >> 3; +} + +void vga4PutPixel(video_t *vid, int x, int y, pixel_t c) +{ + addr_t offset; + volatile byte a; + + c = (byte) c; + offset = video_base + xconv[x] + y80[y]; + + out16(VGA_GC_INDEX, 0x08 | (maskbit[x] << 8)); + if (c) + { + out16(VGA_SEQ_INDEX, 0x02 | (c << 8)); + a = i386_lpeek8(offset); + i386_lpoke8(offset, 0xff); + } + + if (~c) + { + out16(VGA_SEQ_INDEX, 0x02 | (~c << 8)); + a = i386_lpeek8(offset); + i386_lpoke8(offset, 0); + } +} + +void vga4GetByte(addr_t offset, + byte *b, byte *g, + byte *r, byte *i) +{ + out16(VGA_GC_INDEX, 0x0304); + *i = i386_lpeek8(video_base + offset); + out16(VGA_GC_INDEX, 0x0204); + *r = i386_lpeek8(video_base + offset); + out16(VGA_GC_INDEX, 0x0104); + *g = i386_lpeek8(video_base + offset); + out16(VGA_GC_INDEX, 0x0004); + *b = i386_lpeek8(video_base + offset); +} + +pixel_t vga4GetPixel(video_t *vid, int x, int y) +{ + byte mask, b, g, r, i; + addr_t offset; + + offset = xconv[x] + y80[y]; + vga4GetByte(offset, &b, &g, &r, &i); + + mask = maskbit[x]; + b &= mask; + g &= mask; + r &= mask; + i &= mask; + + mask = 7 - (x % 8); + g >>= mask; + b >>= mask; + r >>= mask; + i >>= mask; + + return b + 2 * g + 4 * r + 8 * i; +} + +void vga4HLine(video_t *vid, int x1, int x2, int y, pixel_t c) +{ + int midx, leftpix, rightx, midpix, rightpix; + byte leftmask, rightmask; + addr_t offset; + volatile byte a; + + c = (byte) c; + offset = xconv[x1] + y80[y]; + offset += video_base; + + /* midx = start of middle region */ + midx = (x1 + 7) & -8; + /* leftpix = number of pixels to left of middle */ + leftpix = midx - x1; + + if (leftpix > 0) + { + /* leftmask = pixels set to left of middle */ + leftmask = 0xff >> (8 - leftpix); + //leftmask = startmasks[leftpix]; + + out16(VGA_GC_INDEX, 0x08 | (leftmask << 8)); + out16(VGA_SEQ_INDEX, 0x02 | (c << 8)); + a = i386_lpeek8(offset); + i386_lpoke8(offset, 0xff); + out16(VGA_SEQ_INDEX, 0x02 | (~c << 8)); + a = i386_lpeek8(offset); + i386_lpoke8(offset, 0); + + offset++; + } + + /* rightx = end of middle region */ + rightx = x2 & -8; + /* midpix = number of pixels in middle */ + midpix = rightx - midx; + + out16(VGA_GC_INDEX, 0xff08); + if (c) + { + out16(VGA_SEQ_INDEX, 0x02 | (c << 8)); + i386_lmemset(offset, 0xff, midpix / 8); + } + + if (~c) + { + out16(VGA_SEQ_INDEX, 0x02 | (~c << 8)); + i386_lmemset(offset, 0, midpix / 8); + } + + offset += midpix / 8; + + /* rightpix = number of pixels to right of middle */ + rightpix = x2 - rightx; + if (rightpix > 0) + { + /* rightmask = pixels set to right of middle */ + rightmask = 0xff << (8 - rightpix); + //rightmask = endmasks[rightpix]; + + out16(VGA_GC_INDEX, 0x08 | (rightmask << 8)); + out16(VGA_SEQ_INDEX, 0x02 | (c << 8)); + a = i386_lpeek8(offset); + i386_lpoke8(offset, 0xff); + out16(VGA_SEQ_INDEX, 0x02 | (~c << 8)); + a = i386_lpeek8(offset); + i386_lpoke8(offset, 0); + } +} + +void vga4TextOut(video_t *vid, + int x, int y, vga_font_t *font, const wchar_t *str, + size_t len, pixel_t afg, pixel_t abg) +{ + int ay; + byte *data, fg, bg; + addr_t offset; + volatile int a; + unsigned char ch[2]; + + fg = (byte) afg; + bg = (byte) abg; + + if (len == -1) + len = wcslen(str); + + for (; len > 0; str++, len--) + { + ch[0] = 0; + wcstombs(ch, str, 1); + if (ch[0] < font->First || ch[0] > font->Last) + ch[0] = '?'; + + data = font->Bitmaps + font->Height * (ch[0] - font->First); + offset = video_base + xconv[x] + y80[y]; + + for (ay = 0; ay < font->Height; ay++) + { + if (afg != (pixel_t) -1) + { + /* draw letter */ + out16(VGA_GC_INDEX, 0x08 | (data[ay] << 8)); + if (fg) + { + out16(VGA_SEQ_INDEX, 0x02 | (fg << 8)); + a = i386_lpeek8(offset); + i386_lpoke8(offset, 0xff); + } + + if (~fg) + { + out16(VGA_SEQ_INDEX, 0x02 | (~fg << 8)); + a = i386_lpeek8(offset); + i386_lpoke8(offset, 0); + } + } + + if (abg != (pixel_t) -1) + { + /* draw background */ + out16(VGA_GC_INDEX, 0x08 | (~data[ay] << 8)); + if (bg) + { + out16(VGA_SEQ_INDEX, 0x02 | (bg << 8)); + a = i386_lpeek8(offset); + i386_lpoke8(offset, 0xff); + } + + if (~bg) + { + out16(VGA_SEQ_INDEX, 0x02 | (~bg << 8)); + a = i386_lpeek8(offset); + i386_lpoke8(offset, 0); + } + } + + offset += 80; + } + + x += 8; + } +} + +video_t vga4 = +{ + vga4Close, + vga4EnumModes, + vga4SetMode, + vga4PutPixel, + vga4GetPixel, + vga4HLine, + NULL, /* vline */ + NULL, /* line */ + NULL, /* fillrect */ + vga4TextOut +}; + +video_t *vga4Init(videomode_t *mode) +{ + vga4PreCalc(); + return &vga4; +} \ No newline at end of file diff --git a/mobius/src/drivers/video/video.c b/mobius/src/drivers/video/video.c new file mode 100644 index 0000000..807eabf --- /dev/null +++ b/mobius/src/drivers/video/video.c @@ -0,0 +1,389 @@ +#include +#include +#include +#include +#include +#include + +#include "video.h" + +void swap_int(int *a, int *b) +{ + int temp = *b; + *b = *a; + *a = temp; +} + +extern byte cupertino[]; +vga_font_t _Cupertino={ 0, 256, 12, cupertino }; + +int *__errno() +{ + static int errno; + return &errno; +} + +typedef struct video_drv_t video_drv_t; +struct video_drv_t +{ + device_t dev; + video_t *vid; +}; + +video_t *vga4Init(); + +struct +{ + const wchar_t *name; + video_t *(*init)(); + video_t *vid; +} drivers[] = +{ + { L"vga4", vga4Init, NULL }, + { NULL, NULL, NULL }, +}; + +typedef struct modemap_t modemap_t; +struct modemap_t +{ + videomode_t mode; + video_t *vid; +}; + +modemap_t *modes; +unsigned numModes; + +void vidHLine(video_t *vid, int x1, int x2, int y, pixel_t c) +{ + for (; x1 < x2; x1++) + vid->vidPutPixel(vid, x1, y, c); +} + +void vidVLine(video_t *vid, int x, int y1, int y2, pixel_t c) +{ + for (; y1 < y2; y1++) + vid->vidPutPixel(vid, x, y1, c); +} + +/* from Allegro gfx.c */ +static void do_line(video_t *vid, int x1, int y1, int x2, int y2, pixel_t d, + void (*proc)(video_t*, int, int, pixel_t)) +{ + int dx = x2-x1; + int dy = y2-y1; + int i1, i2; + int x, y; + int dd; + + /* worker macro */ +#define DO_LINE(pri_sign, pri_c, pri_cond, sec_sign, sec_c, sec_cond) \ + { \ + if (d##pri_c == 0) { \ + proc(vid, x1, y1, d); \ + return; \ + } \ + \ + i1 = 2 * d##sec_c; \ + dd = i1 - (sec_sign (pri_sign d##pri_c)); \ + i2 = dd - (sec_sign (pri_sign d##pri_c)); \ + \ + x = x1; \ + y = y1; \ + \ + while (pri_c pri_cond pri_c##2) { \ + proc(vid, x, y, d); \ + if (dd sec_cond 0) { \ + sec_c sec_sign##= 1; \ + dd += i2; \ + } \ + else \ + dd += i1; \ + \ + pri_c pri_sign##= 1; \ + } \ + } + + if (dx >= 0) { + if (dy >= 0) { + if (dx >= dy) { + /* (x1 <= x2) && (y1 <= y2) && (dx >= dy) */ + DO_LINE(+, x, <=, +, y, >=); + } + else { + /* (x1 <= x2) && (y1 <= y2) && (dx < dy) */ + DO_LINE(+, y, <=, +, x, >=); + } + } + else { + if (dx >= -dy) { + /* (x1 <= x2) && (y1 > y2) && (dx >= dy) */ + DO_LINE(+, x, <=, -, y, <=); + } + else { + /* (x1 <= x2) && (y1 > y2) && (dx < dy) */ + DO_LINE(-, y, >=, +, x, >=); + } + } + } + else { + if (dy >= 0) { + if (-dx >= dy) { + /* (x1 > x2) && (y1 <= y2) && (dx >= dy) */ + DO_LINE(-, x, >=, +, y, >=); + } + else { + /* (x1 > x2) && (y1 <= y2) && (dx < dy) */ + DO_LINE(+, y, <=, -, x, <=); + } + } + else { + if (-dx >= -dy) { + /* (x1 > x2) && (y1 > y2) && (dx >= dy) */ + DO_LINE(-, x, >=, -, y, <=); + } + else { + /* (x1 > x2) && (y1 > y2) && (dx < dy) */ + DO_LINE(-, y, >=, -, x, <=); + } + } + } +} + +void vidLine(video_t *vid, int x1, int y1, int x2, int y2, pixel_t d) +{ + if (x1 == x2) + vid->vidVLine(vid, x1, y1, y2, d); + else if (y1 == y2) + vid->vidHLine(vid, x1, x2, y1, d); + else + do_line(vid, x1, y1, x2, y2, d, vid->vidPutPixel); +} + +void vidFillRect(video_t *vid, int x1, int y1, int x2, int y2, pixel_t c) +{ + for (; y1 < y2; y1++) + vid->vidHLine(vid, x1, x2, y1, c); +} + +int vidMatchMode(videomode_t *a, videomode_t *b) +{ + if ((b->width == 0 || a->width == b->width) && + (b->height == 0 || a->height == b->height) && + (b->bitsPerPixel == 0 || a->bitsPerPixel == b->bitsPerPixel)) + return 0; + else + return INT_MAX; +} + +bool vidSetMode(video_drv_t *video, videomode_t *mode) +{ + int i, best, score, s; + video_t *vid; + + if (video->vid) + { + video->vid->vidClose(video->vid); + video->vid = NULL; + } + + best = -1; + score = INT_MAX; + for (i = 0; i < numModes; i++) + { + s = vidMatchMode(&modes[i].mode, mode); + if (s < score) + { + best = i; + score = s; + } + } + + if (best == -1) + { + errno = ENOTFOUND; + return false; + } + + *mode = modes[best].mode; + vid = modes[best].vid; + assert(vid->vidClose != NULL); + assert(vid->vidEnumModes != NULL); + assert(vid->vidSetMode != NULL); + assert(vid->vidPutPixel != NULL); + + if (vid->vidHLine == NULL) + vid->vidHLine = vidHLine; + if (vid->vidVLine == NULL) + vid->vidVLine = vidVLine; + if (vid->vidFillRect == NULL) + vid->vidFillRect = vidFillRect; + if (vid->vidLine == NULL) + vid->vidLine = vidLine; + + if (!vid->vidSetMode(vid, mode)) + return false; + + video->vid = vid; + wprintf(L"video: using mode %ux%ux%u\n", + mode->width, mode->height, mode->bitsPerPixel); + + return true; +} + +bool vidRequest(device_t* dev, request_t* req) +{ + video_drv_t *video = (video_drv_t*) dev; + + switch (req->code) + { + case DEV_REMOVE: + hndFree(dev); + + case DEV_OPEN: + case DEV_CLOSE: + hndSignal(req->event, true); + return true; + + case VID_SETMODE: + if (!vidSetMode(video, (videomode_t*) &req->params)) + { + req->result = errno; + return false; + } + else + { + hndSignal(req->event, true); + return true; + } + + case VID_FILLRECT: + { + vid_rect_t *p = (vid_rect_t*) &req->params; + video->vid->vidFillRect(video->vid, + p->rect.left, p->rect.top, + p->rect.right, p->rect.bottom, + p->colour); + hndSignal(req->event, true); + return true; + } + + case VID_HLINE: + { + vid_line_t *p = (vid_line_t*) &req->params; + if (p->a.x != p->b.x) + { + if (p->b.x < p->a.x) + swap_int(&p->a.x, &p->b.x); + video->vid->vidHLine(video->vid, + p->a.x, p->b.x, + p->a.y, + p->colour); + } + hndSignal(req->event, true); + return true; + } + + case VID_VLINE: + { + vid_line_t *p = (vid_line_t*) &req->params; + if (p->a.y != p->b.y) + { + if (p->b.y < p->a.y) + swap_int(&p->a.y, &p->b.y); + video->vid->vidVLine(video->vid, + p->a.x, + p->a.y, p->b.y, + p->colour); + } + hndSignal(req->event, true); + return true; + } + + case VID_LINE: + { + vid_line_t *p = (vid_line_t*) &req->params; + if (p->b.x < p->a.x) + swap_int(&p->a.x, &p->b.x); + if (p->b.y < p->a.y) + swap_int(&p->a.y, &p->b.y); + + video->vid->vidLine(video->vid, + p->a.x, p->a.y, + p->b.x, p->b.y, + p->colour); + hndSignal(req->event, true); + return true; + } + + case VID_PUTPIXEL: + { + vid_pixel_t *p = (vid_pixel_t*) &req->params; + video->vid->vidPutPixel(video->vid, + p->point.x, p->point.y, + p->colour); + hndSignal(req->event, true); + return true; + } + + case VID_GETPIXEL: + { + vid_pixel_t *p = (vid_pixel_t*) &req->params; + p->colour = video->vid->vidGetPixel(video->vid, + p->point.x, p->point.y); + hndSignal(req->event, true); + return true; + } + + case VID_TEXTOUT: + { + vid_text_t *p = (vid_text_t*) &req->params; + video->vid->vidTextOut(video->vid, p->x, p->y, &_Cupertino, + (const wchar_t*) p->buffer, p->length / sizeof(wchar_t), + p->foreColour, p->backColour); + hndSignal(req->event, true); + return true; + } + } + + req->result = ENOTIMPL; + return false; +} + +device_t* vidAddDevice(driver_t* drv, const wchar_t* name, device_config_t* cfg) +{ + video_drv_t* dev; + int i, j, code; + videomode_t mode; + video_t *vid; + + for (i = 0; drivers[i].name; i++) + { + vid = drivers[i].vid = drivers[i].init(); + + j = 0; + do + { + code = vid->vidEnumModes(vid, j, &mode); + numModes++; + modes = realloc(modes, sizeof(modemap_t) * numModes); + modes[numModes - 1].vid = vid; + modes[numModes - 1].mode = mode; + j++; + } while (code != VID_ENUM_STOP); + } + + dev = hndAlloc(sizeof(video_drv_t), NULL); + dev->dev.request = vidRequest; + dev->dev.driver = drv; + dev->vid = NULL; + + if (numModes > 0) + vidSetMode(dev, &modes[0].mode); + return &dev->dev; +} + +bool STDCALL INIT_CODE drvInit(driver_t* drv) +{ + drv->add_device = vidAddDevice; + return true; +} \ No newline at end of file diff --git a/mobius/src/drivers/video/video.dsp b/mobius/src/drivers/video/video.dsp new file mode 100644 index 0000000..d7545ac --- /dev/null +++ b/mobius/src/drivers/video/video.dsp @@ -0,0 +1,113 @@ +# Microsoft Developer Studio Project File - Name="video" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=video - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "video.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "video.mak" CFG="video - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "video - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "video - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "video - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f video.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "video.exe" +# PROP BASE Bsc_Name "video.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "nmake /f "video.mak"" +# PROP Rebuild_Opt "/a" +# PROP Target_File "video.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "video - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f video.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "video.exe" +# PROP BASE Bsc_Name "video.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "nmake /f "video.mak"" +# PROP Rebuild_Opt "/a" +# PROP Target_File "video.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "video - Win32 Release" +# Name "video - Win32 Debug" + +!IF "$(CFG)" == "video - Win32 Release" + +!ELSEIF "$(CFG)" == "video - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\video.c +# End Source File +# Begin Source File + +SOURCE=.\video4.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\video.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\include\os\video.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/mobius/src/drivers/video/video.h b/mobius/src/drivers/video/video.h new file mode 100644 index 0000000..116049b --- /dev/null +++ b/mobius/src/drivers/video/video.h @@ -0,0 +1,64 @@ +#ifndef __VGA_H +#define __VGA_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +// I/O addresses for VGA registers +#define VGA_AC_INDEX 0x3C0 +#define VGA_AC_WRITE 0x3C0 +#define VGA_AC_READ 0x3C1 +#define VGA_MISC_WRITE 0x3C2 +#define VGA_SEQ_INDEX 0x3C4 +#define VGA_SEQ_DATA 0x3C5 +#define VGA_DAC_READ_INDEX 0x3C7 +#define VGA_DAC_WRITE_INDEX 0x3C8 +#define VGA_DAC_DATA 0x3C9 +#define VGA_MISC_READ 0x3CC +#define VGA_GC_INDEX 0x3CE +#define VGA_GC_DATA 0x3CF +#define VGA_CRTC_INDEX 0x3D4 +#define VGA_CRTC_DATA 0x3D5 +#define VGA_INSTAT_READ 0x3DA + +// number of registers in each VGA unit +#define NUM_CRTC_REGS 25 +#define NUM_AC_REGS 21 +#define NUM_GC_REGS 9 +#define NUM_SEQ_REGS 5 +#define NUM_OTHER_REGS 1 +#define NUM_REGS (NUM_CRTC_REGS + NUM_AC_REGS + NUM_GC_REGS + \ + + NUM_SEQ_REGS + NUM_OTHER_REGS) + +#define _CRTCBaseAdr 0x3c0 + +typedef struct video_t video_t; +struct video_t +{ + void (*vidClose)(video_t *vid); + int (*vidEnumModes)(video_t *vid, unsigned index, videomode_t *mode); + bool (*vidSetMode)(video_t *vid, videomode_t *mode); + + void (*vidPutPixel)(video_t *vid, int x, int y, pixel_t c); + pixel_t (*vidGetPixel)(video_t *vid, int x, int y); + void (*vidHLine)(video_t *vid, int x1, int x2, int y, pixel_t c); + void (*vidVLine)(video_t *vid, int x, int y1, int y2, pixel_t c); + void (*vidLine)(video_t *vid, int x1, int y1, int x2, int y2, pixel_t d); + void (*vidFillRect)(video_t *vid, int x1, int y1, int x2, int y2, pixel_t c); + void (*vidTextOut)(video_t *vid, int x, int y, vga_font_t *font, + const wchar_t *str, size_t len, pixel_t fg, pixel_t bg); +}; + +#define VID_ENUM_CONTINUE 1 +#define VID_ENUM_ERROR 0 +#define VID_ENUM_STOP -1 + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/ClipSurface.cpp b/mobius/src/drivers/winmgr/ClipSurface.cpp new file mode 100644 index 0000000..6ce4f16 --- /dev/null +++ b/mobius/src/drivers/winmgr/ClipSurface.cpp @@ -0,0 +1,108 @@ +// ClipSurface.cpp: implementation of the CClipSurface class. +// +////////////////////////////////////////////////////////////////////// + +#include "ClipSurface.h" + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CClipSurface::CClipSurface(ISurface* surf, const rectangle_t* rect) +{ + m_surf = surf; + m_rect = *rect; + m_refs = 0; +} + +CClipSurface::~CClipSurface() +{ + m_surf->Release(); +} + +HRESULT CClipSurface::QueryInterface(REFIID iid, void** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_ISurface)) + { + AddRef(); + *ppvObject = (ISurface*) this; + return S_OK; + } + else + return E_FAIL; +} + +HRESULT CClipSurface::SetPalette(int nIndex, int red, int green, int blue) +{ + return m_surf->SetPalette(nIndex, red, green, blue); +} + +HRESULT CClipSurface::Blt(ISurface* pSrc, int x, int y, int nWidth, + int nHeight, int nSrcX, int nSrcY, pixel_t pixTrans) +{ + return m_surf->Blt(pSrc, x + m_rect.left, y + m_rect.top, nWidth, nHeight, nSrcX, nSrcY, pixTrans); +} + +HRESULT CClipSurface::Lock(surface_t* pDesc) +{ + return m_surf->Lock(pDesc); +} + +HRESULT CClipSurface::Unlock() +{ + return m_surf->Unlock(); +} + +HRESULT CClipSurface::GetSurfaceDesc(surface_t* pDesc) +{ + return m_surf->GetSurfaceDesc(pDesc); +} + +pixel_t CClipSurface::ColourMatch(colour_t clr) +{ + return m_surf->ColourMatch(clr); +} + +HRESULT CClipSurface::SetPixel(int x, int y, pixel_t pix) +{ + return m_surf->SetPixel(x + m_rect.left, y + m_rect.top, pix); +} + +pixel_t CClipSurface::GetPixel(int x, int y) +{ + return m_surf->GetPixel(x + m_rect.left, y + m_rect.top); +} + +DrawMode CClipSurface::SetDrawMode(DrawMode mode) +{ + return m_surf->SetDrawMode(mode); +} + +HRESULT CClipSurface::FillRect(const rectangle_t* rect, pixel_t pix) +{ + rectangle_t rc = *rect; + rc.OffsetRect(m_rect.left, m_rect.top); + return m_surf->FillRect(rc, pix); +} + +HRESULT CClipSurface::Rect3d(const rectangle_t* rect, pixel_t pixTop, + pixel_t pixBottom, int nWidth) +{ + rectangle_t rc = *rect; + rc.OffsetRect(m_rect.left, m_rect.top); + return m_surf->Rect3d(rc, pixTop, pixBottom, nWidth); +} + +HRESULT CClipSurface::Rect(const rectangle_t* rect, pixel_t pix, int nWidth) +{ + rectangle_t rc = *rect; + rc.OffsetRect(m_rect.left, m_rect.top); + return m_surf->Rect(rc, pix, nWidth); +} + +HRESULT CClipSurface::GetClipRect(rectangle_t* rect) +{ + *rect = m_rect; + return S_OK; +} \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/ClipSurface.h b/mobius/src/drivers/winmgr/ClipSurface.h new file mode 100644 index 0000000..579eda8 --- /dev/null +++ b/mobius/src/drivers/winmgr/ClipSurface.h @@ -0,0 +1,47 @@ +// ClipSurface.h: interface for the CClipSurface class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_CLIPSURFACE_H__CE89407E_9481_4AC3_BE6A_242345B87028__INCLUDED_) +#define AFX_CLIPSURFACE_H__CE89407E_9481_4AC3_BE6A_242345B87028__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#include + +class CClipSurface : + public IUnknown, + public ISurface +{ +protected: + ISurface* m_surf; + rectangle_t m_rect; + +public: + CClipSurface(ISurface* surf, const rectangle_t* rect); + virtual ~CClipSurface(); + + STDMETHOD(QueryInterface)(REFIID iid, void** ppvObject); + IMPLEMENT_IUNKNOWN(CClipSurface); + + STDMETHOD(SetPalette)(int nIndex, int red, int green, int blue); + STDMETHOD(Blt)(ISurface* pSrc, int x, int y, int nWidth, + int nHeight, int nSrcX, int nSrcY, pixel_t pixTrans); + STDMETHOD(Lock)(surface_t* pDesc); + STDMETHOD(Unlock)(); + STDMETHOD(GetSurfaceDesc)(surface_t* pDesc); + STDMETHOD_(pixel_t, ColourMatch)(colour_t clr); + + STDMETHOD(SetPixel)(int x, int y, pixel_t pix); + STDMETHOD_(pixel_t, GetPixel)(int x, int y); + STDMETHOD_(DrawMode, SetDrawMode)(DrawMode mode); + STDMETHOD(FillRect)(const rectangle_t* rect, pixel_t pix); + STDMETHOD(Rect3d)(const rectangle_t* rect, pixel_t pixTop, + pixel_t pixBottom, int nWidth); + STDMETHOD(Rect)(const rectangle_t* rect, pixel_t pix, int nWidth); + STDMETHOD(GetClipRect)(rectangle_t* rect); +}; + +#endif // !defined(AFX_CLIPSURFACE_H__CE89407E_9481_4AC3_BE6A_242345B87028__INCLUDED_) diff --git a/mobius/src/drivers/winmgr/DesktopWnd.cpp b/mobius/src/drivers/winmgr/DesktopWnd.cpp new file mode 100644 index 0000000..6730bac --- /dev/null +++ b/mobius/src/drivers/winmgr/DesktopWnd.cpp @@ -0,0 +1,14 @@ +// DesktopWnd.cpp: implementation of the CDesktopWnd class. +// +////////////////////////////////////////////////////////////////////// + +#include "DesktopWnd.h" + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +void CDesktopWnd::OnPaint(ISurface* surf, const rectangle_t* rect) +{ + surf->FillRect(rect, surf->ColourMatch(RGB(0, 128, 128))); +} \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/DesktopWnd.h b/mobius/src/drivers/winmgr/DesktopWnd.h new file mode 100644 index 0000000..0bf8f94 --- /dev/null +++ b/mobius/src/drivers/winmgr/DesktopWnd.h @@ -0,0 +1,22 @@ +// DesktopWnd.h: interface for the CDesktopWnd class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_DESKTOPWND_H__4D710E2D_4AB3_406A_8E63_9C4385858341__INCLUDED_) +#define AFX_DESKTOPWND_H__4D710E2D_4AB3_406A_8E63_9C4385858341__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#include "window.h" + +class CDesktopWnd : public CWindow +{ +public: + CDesktopWnd(const windowdef_t* def, IWindowServer* srv) : CWindow(def, srv) { } + + virtual void OnPaint(ISurface* surf, const rectangle_t* rect); +}; + +#endif // !defined(AFX_DESKTOPWND_H__4D710E2D_4AB3_406A_8E63_9C4385858341__INCLUDED_) diff --git a/mobius/src/drivers/winmgr/Makefile b/mobius/src/drivers/winmgr/Makefile new file mode 100644 index 0000000..2b8086e --- /dev/null +++ b/mobius/src/drivers/winmgr/Makefile @@ -0,0 +1,2 @@ +all: + \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/MsgQueue.cpp b/mobius/src/drivers/winmgr/MsgQueue.cpp new file mode 100644 index 0000000..9e22c70 --- /dev/null +++ b/mobius/src/drivers/winmgr/MsgQueue.cpp @@ -0,0 +1,122 @@ +// MsgQueue.cpp: implementation of the CMsgQueue class. +// +////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include "MsgQueue.h" +#include +#include + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CMsgQueue::CMsgQueue() +{ + _cputws(L"CMsgQueue::CMsgQueue\n"); + m_refs = 0; + m_head = m_tail = NULL; +} + +CMsgQueue::~CMsgQueue() +{ + _cputws(L"CMsgQueue::~CMsgQueue\n"); +} + +HRESULT CMsgQueue::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IMsgQueue)) + { + AddRef(); + *ppvObject = (IMsgQueue*) this; + return S_OK; + } + else + return E_FAIL; +} + +HRESULT CMsgQueue::PeekMessage(msg_t* msg, bool remove) +{ + mqent_t* next; + + if (m_head) + { + *msg = m_head->msg; + + if (remove) + { + next = m_head->next; + free(m_head); + m_head = next; + + if (m_head == NULL) + m_tail = NULL; + } + + return msg->message == WM_QUIT ? S_FALSE : S_OK; + } + else + return E_FAIL; +} + +HRESULT CMsgQueue::GetMessage(msg_t* msg) +{ + HRESULT hr; + + //_cputws(L"GetMessage..."); + while ((hr = PeekMessage(msg, true)) == E_FAIL) + ; + + //_cputws(L"done\n"); + return hr; +} + +HRESULT CMsgQueue::DispatchMessage(const msg_t* msg) +{ + void *wndproc; + dword params[3]; + + if (msg->wnd) + { + if (msg->wnd->GetAttrib(ATTR_PROCESS) == (dword) procCurrent()) + { + wndproc = (void*) msg->wnd->GetAttrib(ATTR_WNDPROC); + if (wndproc) + { + //wprintf(L"wndproc = %p\n", wndproc); + params[0] = (dword) msg->wnd; + params[1] = msg->message; + params[2] = msg->params; + thrCall(thrCurrent(), wndproc, params, sizeof(params)); + } + else + msg->wnd->DefWndProc(msg->message, msg->params); + + return S_OK; + } + } + + return E_FAIL; +} + +HRESULT CMsgQueue::PostMessage(IWindow* wnd, dword message, dword params) +{ + mqent_t* ent = (mqent_t*) malloc(sizeof(mqent_t)); + + ent->msg.wnd = wnd; + ent->msg.message = message; + ent->msg.params = params; + ent->next = NULL; + + if (m_tail) + m_tail->next = ent; + m_tail = ent; + if (m_head == NULL) + m_head = ent; + + return S_OK; +} \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/MsgQueue.h b/mobius/src/drivers/winmgr/MsgQueue.h new file mode 100644 index 0000000..a15fcd3 --- /dev/null +++ b/mobius/src/drivers/winmgr/MsgQueue.h @@ -0,0 +1,40 @@ +// MsgQueue.h: interface for the CMsgQueue class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_MSGQUEUE_H__76B07981_7DE1_4513_8FA9_B4269A40986A__INCLUDED_) +#define AFX_MSGQUEUE_H__76B07981_7DE1_4513_8FA9_B4269A40986A__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#include + +struct mqent_t +{ + mqent_t *next, *prev; + msg_t msg; +}; + +class CMsgQueue : + public IUnknown, + public IMsgQueue +{ +public: + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + IMPLEMENT_IUNKNOWN(CMsgQueue); + + STDMETHOD(PeekMessage)(msg_t* msg, bool remove); + STDMETHOD(GetMessage)(msg_t* msg); + STDMETHOD(DispatchMessage)(const msg_t* msg); + STDMETHOD(PostMessage)(IWindow* wnd, dword message, dword params); + +public: + CMsgQueue(); + virtual ~CMsgQueue(); + + mqent_t *m_head, *m_tail; +}; + +#endif // !defined(AFX_MSGQUEUE_H__76B07981_7DE1_4513_8FA9_B4269A40986A__INCLUDED_) diff --git a/mobius/src/drivers/winmgr/ResFont.cpp b/mobius/src/drivers/winmgr/ResFont.cpp new file mode 100644 index 0000000..0d3079e --- /dev/null +++ b/mobius/src/drivers/winmgr/ResFont.cpp @@ -0,0 +1,109 @@ +// ResFont.cpp: implementation of the CResFont class. +// +////////////////////////////////////////////////////////////////////// + +#include "ResFont.h" +#include +#include + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CResFont::CResFont(dword inst, word id) +{ + m_refs = 0; + m_header = (const FontDirEntry*) resFind(inst, RT_FONT, id, 0); + if (!m_header || m_header->Version != 0x200) + { + m_header = NULL; + m_chartable = NULL; + } + else + m_chartable = (const GlyphInfo20*) ((const byte*) m_header + SIZEOF_FONTDIRENTRY20); +} + +CResFont::~CResFont() +{ + +} + +HRESULT CResFont::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IFont)) + { + AddRef(); + *ppvObject = (IFont*) this; + return S_OK; + } + else + return E_FAIL; +} + +HRESULT CResFont::DrawText(ISurface* pSurf, int x, int y, const wchar_t* str, + pixel_t pixColour) +{ + const GlyphInfo20 *gi; + const byte* data; + int cx, cy; + pixel_t pix; + surface_t desc; + byte* buf; + rectangle_t rect; + + if (!m_chartable || !m_header) + return E_FAIL; + + if (SUCCEEDED(pSurf->Lock(&desc))) + { + pSurf->GetClipRect(&rect); + x += rect.left; + y += rect.top; + buf = (byte*) desc.pMemory + y * desc.nPitch; + + for (; *str; str++) + { + gi = m_chartable + ((char) *str - m_header->FirstChar); + data = (const byte*) m_header + gi->GIoffset; + + for (cy = 0; cy < m_header->PixHeight; cy++) + { + for (cx = 0; cx < gi->GIwidth; cx++) + { + pix = data[cy] & (0x80 >> cx); + if (pix) + buf[x + cx + cy * desc.nPitch] = pixColour; + //pSurf->SetPixel(x + cx, y + cy, pixColour); + } + } + + x += gi->GIwidth; + } + + pSurf->Unlock(); + } + + return S_OK; +} + +HRESULT CResFont::GetTextExtent(const wchar_t* str, point_t* size) +{ + const GlyphInfo20 *gi; + + if (!m_chartable || !m_header) + { + size->x = size->y = 0; + return E_FAIL; + } + + size->x = 0; + for (; *str; str++) + { + gi = m_chartable + ((char) *str - m_header->FirstChar); + size->x += gi->GIwidth; + } + + size->y = m_header->PixHeight; + return S_OK; +} \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/ResFont.h b/mobius/src/drivers/winmgr/ResFont.h new file mode 100644 index 0000000..591faad --- /dev/null +++ b/mobius/src/drivers/winmgr/ResFont.h @@ -0,0 +1,85 @@ +// ResFont.h: interface for the CResFont class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_RESFONT_H__58AD83B0_C15E_43C3_9690_8501C38D16BC__INCLUDED_) +#define AFX_RESFONT_H__58AD83B0_C15E_43C3_9690_8501C38D16BC__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#include + +#pragma pack(push, 1) + +/* font file header (Adaptation Guide section 6.4) */ +struct FontDirEntry { + word Version; /* Always 17985 for the Nonce */ + dword Size; /* Size of whole file */ + char Copyright[60]; + word Type; /* Raster Font if Type & 1 == 0 */ + word Points; /* Nominal Point size */ + word VertRes; /* Nominal Vertical resolution */ + word HorizRes; /* Nominal Horizontal resolution */ + word Ascent; /* Height of Ascent */ + word IntLeading; /* Internal (Microsoft) Leading */ + word ExtLeading; /* External (Microsoft) Leading */ + byte Italic; /* Italic font if set */ + byte Underline; /* Etc. */ + byte StrikeOut; /* Etc. */ + word Weight; /* Weight: 200 = regular */ + byte CharSet; /* ANSI=0. other=255 */ + word PixWidth; /* Fixed width. 0 ==> Variable */ + word PixHeight; /* Fixed Height */ + byte Family; /* Pitch and Family */ + word AvgWidth; /* Width of character 'X' */ + word MaxWidth; /* Maximum width */ + byte FirstChar; /* First character defined in font */ + byte LastChar; /* Last character defined in font */ + byte DefaultChar; /* Sub. for out of range chars. */ + byte BreakChar; /* word Break Character */ + word Widthbytes; /* No.bytes/row of Bitmap */ + dword Device; /* Pointer to Device Name string */ + dword Face; /* Pointer to Face Name String */ + dword BitsPointer; /* Pointer to Bit Map */ + dword BitsOffset; /* Offset to Bit Map */ + byte Reserved; + dword Flags; + word Aspace; + word Bspace; + word Cspace; + dword ColourPointer; + byte Reserved1[16]; +}; /* Above pointers all rel. to start of file */ + +struct GlyphInfo20 { + word GIwidth; + word GIoffset; +}; + +#define SIZEOF_FONTDIRENTRY20 (sizeof(FontDirEntry) - 30) + +#pragma pack(pop) + +class CResFont : + public IUnknown, + public IFont +{ +protected: + const FontDirEntry* m_header; + const GlyphInfo20* m_chartable; + +public: + CResFont(dword inst, word id); + virtual ~CResFont(); + + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + IMPLEMENT_IUNKNOWN(CResFont); + + STDMETHOD(DrawText)(ISurface* pSurf, int x, int y, const wchar_t* str, + pixel_t pixColour); + STDMETHOD(GetTextExtent)(const wchar_t* str, point_t* size); +}; + +#endif // !defined(AFX_RESFONT_H__58AD83B0_C15E_43C3_9690_8501C38D16BC__INCLUDED_) diff --git a/mobius/src/drivers/winmgr/S3Graphics.cpp b/mobius/src/drivers/winmgr/S3Graphics.cpp new file mode 100644 index 0000000..8c25d24 --- /dev/null +++ b/mobius/src/drivers/winmgr/S3Graphics.cpp @@ -0,0 +1,2024 @@ +// S3Graphics.cpp: implementation of the CS3Graphics class. +// +////////////////////////////////////////////////////////////////////// + +#include "S3Graphics.h" +#include "driver.h" +#include +#include + +MonitorModeTiming* current_timing; + +#define CRT_C 24 /* 24 CRT Controller Registers */ +#define ATT_C 21 /* 21 Attribute Controller Registers */ +#define GRA_C 9 /* 9 Graphics Controller Registers */ +#define SEQ_C 5 /* 5 Sequencer Registers */ +#define MIS_C 1 /* 1 Misc Output Register */ + +#define VGA_TOTAL_REGS 60 + +#define CRT_IC 0x3D4 /* CRT Controller Index (mono: 0x3B4) */ +#define ATT_IW 0x3C0 /* Attribute Controller Index & Data Write Register */ +#define GRA_I 0x3CE /* Graphics Controller Index */ +#define SEQ_I 0x3C4 /* Sequencer Index */ +#define PEL_IW 0x3C8 /* PEL Write Index */ + +/* VGA registers saving indexes */ +#define CRT 0 /* CRT Controller Registers start */ +#define ATT (CRT+CRT_C) /* Attribute Controller Registers start */ +#define GRA (ATT+ATT_C) /* Graphics Controller Registers start */ +#define SEQ (GRA+GRA_C) /* Sequencer Registers */ +#define MIS (SEQ+SEQ_C) /* General Registers */ +#define EXT (MIS+MIS_C) /* SVGA Extended Registers */ + +#define CRT_D 0x3D5 /* CRT Controller Data Register (mono: 0x3B5) */ +#define ATT_R 0x3C1 /* Attribute Controller Data Read Register */ +#define GRA_D 0x3CF /* Graphics Controller Data Register */ +#define SEQ_D 0x3C5 /* Sequencer Data Register */ +#define MIS_R 0x3CC /* Misc Output Read Register */ +#define MIS_W 0x3C2 /* Misc Output Write Register */ +#define IS1_R 0x3DA /* Input Status Register 1 (mono: 0x3BA) */ +#define PEL_D 0x3C9 /* PEL Data Register */ + +#define VGA_CRTC_OFFSET 0 /* 24 registers */ +#define VGA_ATC_OFFSET 24 /* 21 registers */ +#define VGA_GRAPHICS_OFFSET 45 /* 9 registers. */ +#define VGA_SEQUENCER_OFFSET 54 /* 5 registers. */ +#define VGA_MISCOUTPUT 59 /* (single register) */ +#define VGA_TOTAL_REGS 60 + +#define PaletteMask 0x3C6 // bit mask register +#define PaletteRegisterRead 0x3C7 // read index +#define PaletteRegisterWrite 0x3C8 // write index +#define PaletteData 0x3C9 // send/receive data here + +#define __svgalib_CRT_D CRT_D +#define __svgalib_CRT_I CRT_IC +#define __svgalib_IS1_R IS1_R +#define __svgalib_driver_report 1 + +#define ADVFUNC_CNTL 0x4AE8 /* S3 */ + +int __svgalib_vga_inmisc(void) +{ + return in(MIS_R); +} + +void __svgalib_vga_outmisc(int i) +{ + out(MIS_W,i); +} + +int __svgalib_vga_incrtc(int i) +{ + out(__svgalib_CRT_I,i); + return in(__svgalib_CRT_D); +} + +void __svgalib_vga_outcrtc(int i, int d) +{ + out16(__svgalib_CRT_I,i|(d<<8)); +} + +int __svgalib_vga_inseq(int index) +{ + out(SEQ_I, index); + return in(SEQ_D); +} + +void __svgalib_vga_outseq(int index, int val) +{ + int v; + v = ((int) val << 8) + index; + out16(SEQ_I, v); +} + +/* +* These are simple functions to write a value to a VGA Graphics +* Controller, CRTC Controller or Sequencer register. +* The idea is that drivers call these as a function call, making the +* code smaller and inserting small delays between I/O accesses when +* doing mode switches. +*/ + +void __svgalib_outGR(int index, unsigned char val) +{ + int v; + v = ((int) val << 8) + index; + out16(GRA_I, v); +} + +void __svgalib_outbGR(int index, unsigned char val) +{ + out(GRA_I, index); + out(GRA_D, val); +} + +void __svgalib_outCR(int index, unsigned char val) +{ + int v; + v = ((int) val << 8) + index; + out16(CRT_IC, v); +} + +void __svgalib_outbCR(int index, unsigned char val) +{ + out(CRT_IC, index); + out(__svgalib_CRT_D, val); +} + +void __svgalib_outSR(int index, unsigned char val) +{ + int v; + v = ((int) val << 8) + index; + out16(SEQ_I, v); +} + +void __svgalib_outbSR(int index, unsigned char val) +{ + out(SEQ_I, index); + out(SEQ_D, val); +} + +unsigned char __svgalib_inGR(int index) +{ + out(GRA_I, index); + return in(GRA_D); +} + +unsigned char __svgalib_inCR(int index) +{ + out(CRT_IC, index); + return in(CRT_D); +} + +unsigned char __svgalib_inSR(int index) +{ + out(SEQ_I, index); + return in(SEQ_D); +} + +enum { + S3_911, S3_924, S3_801, S3_805, S3_928, S3_864, S3_964, S3_TRIO32, + S3_TRIO64, S3_866, S3_868, S3_968, S3_765 +}; + +void CS3Graphics::HwLock() +{ + __svgalib_outCR(0x39, 0x00); /* Lock system control regs. */ + __svgalib_outCR(0x38, 0x00); /* Lock special regs. */ +} + +void CS3Graphics::HwLockEnh() +{ + if (s3_chiptype > S3_911) + __svgalib_outCR(0x40, __svgalib_inCR(0x40) & ~0x01); /* Lock enhanced command regs. */ + HwLock(); +} + +/* +* Unlock S3's registers. +* There are more locks, but this should suffice. +*/ +void CS3Graphics::HwUnlock() +{ + __svgalib_outCR(0x38, 0x48); /* Unlock special regs. */ + __svgalib_outCR(0x39, 0xA5); /* Unlock system control regs. */ +} + +void CS3Graphics::HwUnlockEnh() +{ + Unlock(); + if (s3_chiptype > S3_911) + __svgalib_outCR(0x40, __svgalib_inCR(0x40) | 0x01); /* Unlock enhanced command regs. */ +} + +static const wchar_t *s3_chipname[] = +{L"911", L"924", L"801", L"805", L"928", +L"864", L"964", L"Trio32", L"Trio64", L"866", L"868", L"968", L"Trio64V+"}; + +/* flags used by this driver */ +#define S3_LOCALBUS 0x01 +#define S3_CLUT8_8 0x02 +#define S3_OLD_STEPPING 0x04 + +/* Card flags. */ +/* The card has programmable clocks (matchProgrammableClock is valid). */ +#define CLOCK_PROGRAMMABLE 0x1 +/* For interlaced modes, the vertical timing must be divided by two. */ +#define INTERLACE_DIVIDE_VERT 0x2 +/* For modes with vertical timing greater or equal to 1024, vertical */ +/* timing must be divided by two. */ +#define GREATER_1024_DIVIDE_VERT 0x4 +/* The DAC doesn't support 64K colors (5-6-5) at 16bpp, just 5-5-5. */ +#define NO_RGB16_565 0x8 + +int CS3Graphics::Init(int force, int par1, int par2) +{ + int id, rev, config; + + HwUnlock(); + + s3_flags = 0; /* initialize */ + id = __svgalib_inCR(0x30); /* Get chip id. */ + rev = id & 0x0F; + if (id >= 0xE0) { + id |= __svgalib_inCR(0x2E) << 8; + rev |= __svgalib_inCR(0x2F) << 4; + } + if (force) { + s3_chiptype = par1; /* we already know the type */ + s3_memory = par2; + /* ARI: can we really trust the user's specification, or should we ignore + it and probe ourselves ? */ + if (s3_chiptype == S3_801 || s3_chiptype == S3_805) { + if ((rev & 0x0F) < 2) + s3_flags |= S3_OLD_STEPPING; /* can't handle 1152 width */ + } else if (s3_chiptype == S3_928) { + if ((rev & 0x0F) < 4) /* ARI: Stepping D or below */ + s3_flags |= S3_OLD_STEPPING; /* can't handle 1152 width */ + } + } else { + s3_chiptype = -1; + config = __svgalib_inCR(0x36); /* get configuration info */ + switch (id & 0xf0) { + case 0x80: + if (rev == 1) { + s3_chiptype = S3_911; + break; + } + if (rev == 2) { + s3_chiptype = S3_924; + break; + } + break; + case 0xa0: + switch (config & 0x03) { + case 0x00: + case 0x01: + /* EISA or VLB - 805 */ + s3_chiptype = S3_805; + /* ARI: Test stepping: 0:B, 1:unknown, 2,3,4:C, 8:I, >=5:D */ + if ((rev & 0x0F) < 2) + s3_flags |= S3_OLD_STEPPING; /* can't handle 1152 width */ + break; + case 0x03: + /* ISA - 801 */ + s3_chiptype = S3_801; + /* Stepping same as 805, just ISA */ + if ((rev & 0x0F) < 2) + s3_flags |= S3_OLD_STEPPING; /* can't handle 1152 width */ + break; + } + break; + case 0x90: + s3_chiptype = S3_928; + if ((rev & 0x0F) < 4) /* ARI: Stepping D or below */ + s3_flags |= S3_OLD_STEPPING; /* can't handle 1152 width */ + break; + case 0xB0: + /* 928P */ + s3_chiptype = S3_928; + break; + case 0xC0: + s3_chiptype = S3_864; + break; + case 0xD0: + s3_chiptype = S3_964; + break; + case 0xE0: + switch (id & 0xFFF0) { + case 0x10E0: + s3_chiptype = S3_TRIO32; + break; + case 0x3DE0: /* ViRGE/VX ID */ + case 0x31E0: /* ViRGE ID */ + case 0x01E0: /* S3Trio64V2/DX ... any others? */ + case 0x04E0: + case 0x11E0: + if (rev & 0x0400) + s3_chiptype = S3_765; + else + s3_chiptype = S3_TRIO64; + break; + case 0x80E0: + s3_chiptype = S3_866; + break; + case 0x90E0: + s3_chiptype = S3_868; + break; + case 0xF0E0: /* XXXX From data book; XF86 says 0xB0E0? */ + s3_chiptype = S3_968; + break; + } + } + if (s3_chiptype == -1) { + wprintf(L"svgalib: S3: Unknown chip id %02x\n", + id); + return -1; + } + if (s3_chiptype <= S3_924) { + if ((config & 0x20) != 0) + s3_memory = 512; + else + s3_memory = 1024; + } else { + /* look at bits 5, 6 and 7 */ + switch ((config & 0xE0) >> 5) { + case 0: + s3_memory = 4096; + break; + case 2: + s3_memory = 3072; + break; + case 3: + s3_memory = 8192; + break; + case 4: + s3_memory = 2048; + break; + case 5: + s3_memory = 6144; + break; + case 6: + s3_memory = 1024; + break; + case 7: + s3_memory = 512; + break; /* Trio32 */ + } + } + + if ((config & 0x03) < 3) /* XXXX 928P is ignored */ + s3_flags |= S3_LOCALBUS; + } + + if (__svgalib_driver_report) { + wprintf(L"svgalib: Using S3 driver (%s, %dK).\n", s3_chipname[s3_chiptype], + s3_memory); + if (s3_flags & S3_OLD_STEPPING) + wprintf(L"svgalib: Chip revision cannot handle modes with width 1152.\n"); + if (s3_chiptype > S3_TRIO64) { + wprintf(L"svgalib: s3: chipsets newer than S3 Trio64 is not supported well yet.\n"); + } + } + /* begin: Initialize cardspecs. */ + /* If IOPERM is set, assume permissions have already been set by Olaf Titz' */ + /* ioperm(1). */ + + /*if (getenv("IOPERM") == NULL) { + if (0 > iopl(3)) + wprintf(L"svgalib: s3: cannot get I/O permissions for 8514."); + }*/ +#ifdef S3_LINEAR_SUPPORT + if (s3_chiptype > S3_805) { + int found_pciconfig; + unsigned long pci_conf[64]; + + found_pciconfig = __svgalib_pci_find_vendor_vga(0x5333, pci_conf, 0); + if (!found_pciconfig) + s3_linear_base = pci_conf[4] & 0xFF800000; + } + + s3_cr59 = s3_linear_base >> 24; + s3_cr5A = (s3_linear_base >> 16); + if (! (s3_cr59 | s3_cr5A)) { + s3_cr59 = __svgalib_inCR(0x59); + s3_cr5A = __svgalib_inCR(0x5A); + if (!s3_cr59) { + s3_cr59 = 0xF3000000 >> 24; + s3_cr5A = (0xF3000000 >> 16); + } + s3_linear_base = (s3_cr59 << 24) | (s3_cr5A << 16); + } + s3_linear_opt |= 0x10; + switch (s3_memory) { + case 512 : + case 1024 : + s3_linear_opt |= 0x01; + break; + case 2048 : + s3_linear_opt |= 0x02; + break; + case 3072 : + case 4096 : + case 6144 : + case 8192 : + s3_linear_opt |= 0x03; + break; + default : + s3_linear_opt = 0x14; /* like XFree */ + } +#endif + + cardspecs = (CardSpecs*) malloc(sizeof(CardSpecs)); + cardspecs->videoMemory = s3_memory; + cardspecs->nClocks = 0; + /*cardspecs->maxHorizontalCrtc = 2040; SL: kills 800x600x32k and above */ + cardspecs->maxHorizontalCrtc = 4088; + cardspecs->flags = INTERLACE_DIVIDE_VERT; + + /* Process S3-specific config file options. */ + //__svgalib_read_options(s3_config_options, s3_process_option); + +#ifdef INCLUDE_S3_TRIO64_DAC + if ((s3_chiptype == S3_TRIO64 || s3_chiptype == S3_765) && dac_used == NULL) + dac_used = &__svgalib_Trio64_methods; +#endif + + //if (dac_used == NULL) + //dac_used = __svgalib_probeDacs(dacs_to_probe); + //else + //dac_used->initialize(); + + + //if (dac_used == NULL) { + /* Not supported. */ + /*wprintf(L"svgalib: s3: Assuming normal VGA DAC.\n"); + #ifdef INCLUDE_NORMAL_DAC + dac_used = &__svgalib_normal_dac_methods; + dac_used->initialize(); + #else + wprintf(L"svgalib: Alas, normal VGA DAC support is not compiled in, goodbye.\n"); + return 1; + #endif + } + if (clk_used) + clk_used->initialize(cardspecs, dac_used);*/ + + //dac_used->qualifyCardSpecs(cardspecs, dac_speed); + + /* Initialize standard clocks for unknown DAC. */ + if ((!(cardspecs->flags & CLOCK_PROGRAMMABLE)) + && cardspecs->nClocks == 0) { + /* + * Almost all cards have 25 and 28 MHz on VGA clocks 0 and 1, + * so use these for an unknown DAC, yielding 640x480x256. + */ + cardspecs->nClocks = 2; + cardspecs->clocks = (int*) malloc(sizeof(int) * 2); + cardspecs->clocks[0] = 25175; + cardspecs->clocks[1] = 28322; + } + /* Limit pixel clocks according to chip specifications. */ + if (s3_chiptype == S3_864 || s3_chiptype == S3_868) { + /* Limit max clocks according to 95 MHz DCLK spec. */ + /* SL: might just be 95000 for 4/8bpp since no pixmux'ing */ + /*LIMIT(cardspecs->maxPixelClock4bpp, 95000 * 2); + LIMIT(cardspecs->maxPixelClock8bpp, 95000 * 2); + LIMIT(cardspecs->maxPixelClock16bpp, 95000);*/ + /* see explanation below */ + //LIMIT(cardspecs->maxPixelClock24bpp, 36000); + /* + * The official 32bpp limit is 47500, but we allow + * 50 MHz for VESA 800x600 timing (actually the + * S3-864 doesn't have the horizontal timing range + * to run unmodified VESA 800x600 72 Hz timings). + */ + //LIMIT(cardspecs->maxPixelClock32bpp, 50000); + } +#ifndef S3_16_COLORS + //cardspecs->maxPixelClock4bpp = 0; /* 16-color doesn't work. */ +#endif + + /* end: Initialize cardspecs. */ + + /*__svgalib_driverspecs = &__svgalib_s3_driverspecs; + + __svgalib_banked_mem_base=0xa0000; + __svgalib_banked_mem_size=0x10000; + #ifdef S3_LINEAR_SUPPORT + __svgalib_linear_mem_base=s3_linear_base; + __svgalib_linear_mem_size=s3_memory*0x400; +#endif*/ + + return 0; +} + +#define S3_CR(n) (EXT + (0x##n) - 0x30) + +#define S3_CR30 S3_CR(30) +#define S3_CR31 S3_CR(31) +#define S3_CR32 S3_CR(32) +#define S3_CR33 S3_CR(33) +#define S3_CR34 S3_CR(34) +#define S3_CR35 S3_CR(35) +#define S3_CR3A S3_CR(3A) +#define S3_CR3B S3_CR(3B) +#define S3_CR3C S3_CR(3C) +#define S3_CR40 S3_CR(40) +#define S3_CR42 S3_CR(42) +#define S3_CR43 S3_CR(43) +#define S3_CR44 S3_CR(44) +#define S3_CR50 S3_CR(50) /* 801+ */ +#define S3_CR51 S3_CR(51) +#define S3_CR53 S3_CR(53) +#define S3_CR54 S3_CR(54) +#define S3_CR55 S3_CR(55) +#define S3_CR58 S3_CR(58) +#define S3_CR59 S3_CR(59) +#define S3_CR5A S3_CR(5A) +#define S3_CR5D S3_CR(5D) +#define S3_CR5E S3_CR(5E) +#define S3_CR60 S3_CR(60) +#define S3_CR61 S3_CR(61) +#define S3_CR62 S3_CR(62) +#define S3_CR67 S3_CR(67) +#define S3_CR6A S3_CR(6A) +#define S3_CR6D S3_CR(6D) + +/* For debugging, these (non-)registers are read also (but never written). */ + +#define S3_CR36 S3_CR(36) +#define S3_CR37 S3_CR(37) +#define S3_CR38 S3_CR(38) +#define S3_CR39 S3_CR(39) +#define S3_CR3D S3_CR(3D) +#define S3_CR3E S3_CR(3E) +#define S3_CR3F S3_CR(3F) +#define S3_CR45 S3_CR(45) +#define S3_CR46 S3_CR(46) +#define S3_CR47 S3_CR(47) +#define S3_CR48 S3_CR(48) +#define S3_CR49 S3_CR(49) +#define S3_CR4A S3_CR(4A) +#define S3_CR4B S3_CR(4B) +#define S3_CR4C S3_CR(4C) +#define S3_CR4D S3_CR(4D) +#define S3_CR4E S3_CR(4E) +#define S3_CR4F S3_CR(4F) +#define S3_CR52 S3_CR(52) +#define S3_CR56 S3_CR(56) +#define S3_CR57 S3_CR(57) +#define S3_CR5B S3_CR(5B) +#define S3_CR5C S3_CR(5C) +#define S3_CR5F S3_CR(5F) +#define S3_CR63 S3_CR(63) +#define S3_CR64 S3_CR(64) +#define S3_CR65 S3_CR(65) +#define S3_CR66 S3_CR(66) +#define S3_CR6E S3_CR(6E) +#define S3_CR6F S3_CR(6F) + +/* Trio extended SR registers */ + +#define S3_SR(n) (S3_CR6F + 1 + (0x##n) - 0x08) + +#define S3_SR08 S3_SR(08) +#define S3_SR09 S3_SR(09) +#define S3_SR0A S3_SR(0A) +#define S3_SR0D S3_SR(0D) +#define S3_SR10 S3_SR(10) +#define S3_SR11 S3_SR(11) +#define S3_SR12 S3_SR(12) +#define S3_SR13 S3_SR(13) +#define S3_SR15 S3_SR(15) +#define S3_SR18 S3_SR(18) +#define S3_SR1D S3_SR(1D) + +#define S3_8514_OFFSET (S3_SR1D + 1) + +#define S3_8514_COUNT (1) /* number of 2-byte words */ + +#define S3_DAC_OFFSET (S3_8514_OFFSET + (S3_8514_COUNT * 2)) + +#define S3_TOTAL_REGS (S3_DAC_OFFSET /*+ MAX_DAC_STATE*/) + +/* 8514 regs */ +#define S3_ADVFUNC_CNTL 0 + +static unsigned short s3_8514regs[S3_8514_COUNT] = +{ + /* default assuming text mode */ + 0x0000U +}; + +/* +* save S3 registers. Lock registers receive special treatment +* so dumpreg will work under X. +*/ +int CS3Graphics::SaveRegisters(unsigned char regs[]) +{ + unsigned char b, bmax; + unsigned char cr38, cr39, cr40; + + cr38 = __svgalib_inCR(0x38); + __svgalib_outCR(0x38, 0x48); /* unlock S3 VGA regs (CR30-CR3B) */ + + cr39 = __svgalib_inCR(0x39); + __svgalib_outCR(0x39, 0xA5); /* unlock S3 system control (CR40-CR4F) */ + /* and extended regs (CR50-CR6D) */ + + cr40 = __svgalib_inCR(0x40); /* unlock enhanced regs */ + __svgalib_outCR(0x40, cr40 | 0x01); + + /* retrieve values from private copy */ + memcpy(regs + S3_8514_OFFSET, s3_8514regs, S3_8514_COUNT * 2); + + /* get S3 VGA/Ext registers */ + bmax = 0x4F; + if (s3_chiptype >= S3_801) + bmax = 0x66; + if (s3_chiptype >= S3_864) + bmax = 0x6D; + for (b = 0x30; b <= bmax; b++) + regs[EXT + b - 0x30] = __svgalib_inCR(b); + + /* get S3 ext. SR registers */ + /* if (s3_chiptype >= S3_864) { */ + if (s3_chiptype == S3_TRIO32 || s3_chiptype == S3_TRIO64 + || s3_chiptype == S3_765) {/* SL: actually Trio32/64/V+ */ + regs[S3_SR08] = __svgalib_inSR(0x08); + __svgalib_outSR(0x08, 0x06); /* unlock extended seq regs */ + regs[S3_SR09] = __svgalib_inSR(0x09); + regs[S3_SR0A] = __svgalib_inSR(0x0A); + regs[S3_SR0D] = __svgalib_inSR(0x0D); + regs[S3_SR10] = __svgalib_inSR(0x10); + regs[S3_SR11] = __svgalib_inSR(0x11); + regs[S3_SR12] = __svgalib_inSR(0x12); + regs[S3_SR13] = __svgalib_inSR(0x13); + regs[S3_SR15] = __svgalib_inSR(0x15); + regs[S3_SR18] = __svgalib_inSR(0x18); + __svgalib_outSR(0x08, regs[S3_SR08]); + } + + //dac_used->saveState(regs + S3_DAC_OFFSET); + + /* leave the locks the way we found it */ + __svgalib_outCR(0x40, regs[EXT + 0x40 - 0x30] = cr40); + __svgalib_outCR(0x39, regs[EXT + 0x39 - 0x30] = cr39); + __svgalib_outCR(0x38, regs[EXT + 0x38 - 0x30] = cr38); +#if 0 +#include "ramdac/IBMRGB52x.h" + + do { + unsigned char m, n, df; + + printf("pix_fmt = 0x%02X, 8bpp = 0x%02X, 16bpp = 0x%02X, 24bpp = 0x%02X, 32bpp = 0x%02X,\n" + "CR58 = 0x%02X, CR66 = 0x%02X, CR67 = 0x%02X, CR6D = 0x%02X\n", + regs[S3_DAC_OFFSET + IBMRGB_pix_fmt], + regs[S3_DAC_OFFSET + IBMRGB_8bpp], + regs[S3_DAC_OFFSET + IBMRGB_16bpp], + regs[S3_DAC_OFFSET + IBMRGB_24bpp], + regs[S3_DAC_OFFSET + IBMRGB_32bpp], + regs[S3_CR58], + regs[S3_CR66], + regs[S3_CR67], + regs[S3_CR6D]); + + m = regs[S3_DAC_OFFSET + IBMRGB_m0 + 4]; + n = regs[S3_DAC_OFFSET + IBMRGB_n0 + 4]; + df = m >> 6; + m &= ~0xC0; + + printf("m = 0x%02X %d, n = 0x%02X %d, df = 0x%02X %d, freq = %.3f\n", + m, m, n, n, df, df, ((m + 65.0) / n) / (8 >> df) * 16.0); + } while (0); +#endif + return S3_DAC_OFFSET - VGA_TOTAL_REGS ;//+ dac_used->stateSize; +} + +struct +{ + int xdim; + int ydim; + int bytesperpixel; + int colors; + int xbytes; +} __svgalib_infotable[] = +{ + { 640, 480, 1, 256, 640 } +}; + +ModeInfo * +__svgalib_createModeInfoStructureForSvgalibMode(int mode) +{ + ModeInfo *modeinfo; + /* Create the new ModeInfo structure. */ + modeinfo = (ModeInfo*) malloc(sizeof(ModeInfo)); + modeinfo->width = __svgalib_infotable[mode].xdim; + modeinfo->height = __svgalib_infotable[mode].ydim; + modeinfo->bytesPerPixel = __svgalib_infotable[mode].bytesperpixel; + switch (__svgalib_infotable[mode].colors) { + case 16: + modeinfo->colorBits = 4; + break; + case 256: + modeinfo->colorBits = 8; + break; + case 32768: + modeinfo->colorBits = 15; + modeinfo->blueOffset = 0; + modeinfo->greenOffset = 5; + modeinfo->redOffset = 10; + modeinfo->blueWeight = 5; + modeinfo->greenWeight = 5; + modeinfo->redWeight = 5; + break; + case 65536: + modeinfo->colorBits = 16; + modeinfo->blueOffset = 0; + modeinfo->greenOffset = 5; + modeinfo->redOffset = 11; + modeinfo->blueWeight = 5; + modeinfo->greenWeight = 6; + modeinfo->redWeight = 5; + break; + case 256 * 65536: + modeinfo->colorBits = 24; + modeinfo->blueOffset = 0; + modeinfo->greenOffset = 8; + modeinfo->redOffset = 16; + modeinfo->blueWeight = 8; + modeinfo->greenWeight = 8; + modeinfo->redWeight = 8; + break; + } + modeinfo->bitsPerPixel = modeinfo->bytesPerPixel * 8; + if (__svgalib_infotable[mode].colors == 16) + modeinfo->bitsPerPixel = 4; + modeinfo->lineWidth = __svgalib_infotable[mode].xbytes; + return modeinfo; +} + +/* +* Clock allowance in 1/1000ths. 10 (1%) corresponds to a 250 kHz +* deviation at 25 MHz, 1 MHz at 100 MHz +*/ +#define CLOCK_ALLOWANCE 10 + +#define PROGRAMMABLE_CLOCK_MAGIC_NUMBER 0x1234 + +static int findclock(int clock, CardSpecs * cardspecs) +{ + int i; + /* Find a clock that is close enough. */ + for (i = 0; i < cardspecs->nClocks; i++) { + int diff; + diff = cardspecs->clocks[i] - clock; + if (diff < 0) + diff = -diff; + if (diff * 1000 / clock < CLOCK_ALLOWANCE) + return i; + } + /* Try programmable clocks if available. */ + if (cardspecs->flags & CLOCK_PROGRAMMABLE) { + int diff; + diff = cardspecs->matchProgrammableClock(clock) - clock; + if (diff < 0) + diff = -diff; + if (diff * 1000 / clock < CLOCK_ALLOWANCE) + return PROGRAMMABLE_CLOCK_MAGIC_NUMBER; + } + /* No close enough clock found. */ + return -1; +} + +typedef struct { +/* refresh ranges in Hz */ + unsigned min; + unsigned max; +} RefreshRange; + +RefreshRange __svgalib_horizsync = +{31500U, 0U}; /* horz. refresh (Hz) min, max */ +RefreshRange __svgalib_vertrefresh = +{50U, 70U}; /* vert. refresh (Hz) min, max */ + +/* + * SYNC_ALLOWANCE is in percent + * 1% corresponds to a 315 Hz deviation at 31.5 kHz, 1 Hz at 100 Hz + */ +#define SYNC_ALLOWANCE 1 + +#define INRANGE(x,y) \ + ((x) > __svgalib_##y.min * (1.0f - SYNC_ALLOWANCE / 100.0f) && \ + (x) < __svgalib_##y.max * (1.0f + SYNC_ALLOWANCE / 100.0f)) + +/* + * Check monitor spec. + */ +static int timing_within_monitor_spec(MonitorModeTiming * mmtp) +{ + float hsf; /* Horz. sync freq in Hz */ + float vsf; /* Vert. sync freq in Hz */ + + hsf = mmtp->pixelClock * 1000.0f / mmtp->HTotal; + vsf = hsf / mmtp->VTotal; + if ((mmtp->flags & INTERLACED)) + vsf *= 2.0f; + if ((mmtp->flags & DOUBLESCAN)) + vsf /= 2.0f; +#if 1 + wprintf(L"hsf = %f (in:%d), vsf = %f (in:%d)\n", + hsf / 1000, (int) INRANGE(hsf, horizsync), + vsf, (int) INRANGE(vsf, vertrefresh)); +#endif + return INRANGE(hsf, horizsync) && INRANGE(vsf, vertrefresh); +} + +static MonitorModeTiming *search_mode(MonitorModeTiming * timings, + int maxclock, + ModeInfo * modeinfo, + CardSpecs * cardspecs) +{ + int bestclock = 0; + MonitorModeTiming *besttiming = NULL, *t; + + /* + * bestclock is the highest pixel clock found for the resolution + * in the mode timings, within the spec of the card and + * monitor. + * besttiming holds a pointer to timing with this clock. + */ + + /* Search the timings for the best matching mode. */ + for (t = timings; t; t = t->next) + if (t->HDisplay == modeinfo->width + && t->VDisplay == modeinfo->height + && timing_within_monitor_spec(t) + && t->pixelClock <= maxclock + && t->pixelClock > bestclock + && cardspecs->mapHorizontalCrtc(modeinfo->bitsPerPixel, + t->pixelClock, + t->HTotal) + <= cardspecs->maxHorizontalCrtc + /* Find the clock (possibly scaled by mapClock). */ + && findclock(cardspecs->mapClock(modeinfo->bitsPerPixel, + t->pixelClock), cardspecs) != -1 + ) { + bestclock = t->pixelClock; + besttiming = t; + } + return besttiming; +} + +MonitorModeTiming __svgalib_standard_timings[] = +{ +#define S __svgalib_standard_timings +/* 320x200 @ 70 Hz, 31.5 kHz hsync */ + {12588, 320, 336, 384, 400, 200, 204, 206, 225, DOUBLESCAN, S + 1}, +/* 320x200 @ 83 Hz, 37.5 kHz hsync */ + {13333, 320, 336, 384, 400, 200, 204, 206, 225, DOUBLESCAN, S + 2}, +/* 320x240 @ 60 Hz, 31.5 kHz hsync */ + {12588, 320, 336, 384, 400, 240, 245, 247, 263, DOUBLESCAN, S + 3}, +/* 320x240 @ 72Hz, 38.5 kHz hsync */ + {15000, 320, 336, 384, 400, 240, 244, 246, 261, DOUBLESCAN, S + 4}, +/* 320x400 @ 70 Hz, 31.5 kHz hsync */ + {12588, 320, 336, 384, 400, 400, 408, 412, 450, 0, S + 5}, +/* 320x400 @ 83 Hz, 37.5 kHz hsync */ + {13333, 320, 336, 384, 400, 400, 408, 412, 450, 0, S + 6}, +/* 320x480 @ 60 Hz, 31.5 kHz hsync */ + {12588, 320, 336, 384, 400, 480, 490, 494, 526, 0, S + 7}, +/* 320x480 @ 72Hz, 38.5 kHz hsync */ + {15000, 320, 336, 384, 400, 480, 488, 492, 522, 0, S + 8}, +/* 400x300 @ 56 Hz, 35.2 kHz hsync, 4:3 aspect ratio */ + {18000, 400, 416, 448, 512, 300, 301, 302, 312, DOUBLESCAN, S+9}, +/* 400x300 @ 60 Hz, 37.8 kHz hsync */ + {20000, 400, 416, 480, 528, 300, 301, 303, 314, DOUBLESCAN, S+10}, +/* 400x300 @ 72 Hz, 48.0 kHz hsync*/ + {25000, 400, 424, 488, 520, 300, 319, 322, 333, DOUBLESCAN, S+11}, +/* 400x600 @ 56 Hz, 35.2 kHz hsync, 4:3 aspect ratio */ + {18000, 400, 416, 448, 512, 600, 602, 604, 624, 0, S+12}, +/* 400x600 @ 60 Hz, 37.8 kHz hsync */ + {20000, 400, 416, 480, 528, 600, 602, 606, 628, 0, S+13}, +/* 400x600 @ 72 Hz, 48.0 kHz hsync*/ + {25000, 400, 424, 488, 520, 600, 639, 644, 666, 0, S+14}, +/* 512x384 @ 67Hz */ + {19600, 512, 522, 598, 646, 384, 418, 426, 454, 0, S+15 }, +/* 512x384 @ 86Hz */ + {25175, 512, 522, 598, 646, 384, 418, 426, 454,0, S+16}, +/* 512x480 @ 55Hz */ + {19600, 512, 522, 598, 646, 480, 500, 510, 550, 0, S+17}, +/* 512x480 @ 71Hz */ + {25175, 512, 522, 598, 646, 480, 500, 510, 550,0, S+18}, +/* 640x400 at 70 Hz, 31.5 kHz hsync */ + {25175, 640, 664, 760, 800, 400, 409, 411, 450, 0, S + 19}, +/* 640x480 at 60 Hz, 31.5 kHz hsync */ + {25175, 640, 664, 760, 800, 480, 491, 493, 525, 0, S + 20}, +/* 640x480 at 72 Hz, 36.5 kHz hsync */ + {31500, 640, 680, 720, 864, 480, 488, 491, 521, 0, S + 21}, +/* 800x600 at 56 Hz, 35.15 kHz hsync */ + {36000, 800, 824, 896, 1024, 600, 601, 603, 625, 0, S + 22}, +/* 800x600 at 60 Hz, 37.8 kHz hsync */ + {40000, 800, 840, 968, 1056, 600, 601, 605, 628, PHSYNC | PVSYNC, S + 23}, +/* 800x600 at 72 Hz, 48.0 kHz hsync */ + {50000, 800, 856, 976, 1040, 600, 637, 643, 666, PHSYNC | PVSYNC, S + 24}, +/* 960x720 @ 70Hz */ + {66000, 960, 984, 1112, 1248, 720, 723, 729, 756, NHSYNC | NVSYNC, S+25}, +/* 960x720* interlaced, 35.5 kHz hsync */ + {40000, 960, 984, 1192, 1216, 720, 728, 784, 817, INTERLACED, S + 26}, +/* 1024x768 at 87 Hz interlaced, 35.5 kHz hsync */ + {44900, 1024, 1048, 1208, 1264, 768, 776, 784, 817, INTERLACED, S + 27}, +/* 1024x768 at 100 Hz, 40.9 kHz hsync */ + {55000, 1024, 1048, 1208, 1264, 768, 776, 784, 817, INTERLACED, S + 28}, +/* 1024x768 at 60 Hz, 48.4 kHz hsync */ + {65000, 1024, 1032, 1176, 1344, 768, 771, 777, 806, NHSYNC | NVSYNC, S + 29}, +/* 1024x768 at 70 Hz, 56.6 kHz hsync */ + {75000, 1024, 1048, 1184, 1328, 768, 771, 777, 806, NHSYNC | NVSYNC, S + 30}, +/* 1152x864 at 59.3Hz */ + {85000, 1152, 1214, 1326, 1600, 864, 870, 885, 895, 0, S+31}, +/* 1280x1024 at 87 Hz interlaced, 51 kHz hsync */ + {80000, 1280, 1296, 1512, 1568, 1024, 1025, 1037, 1165, INTERLACED, S + 32}, +/* 1024x768 at 76 Hz, 62.5 kHz hsync */ + {85000, 1024, 1032, 1152, 1360, 768, 784, 787, 823, 0, S + 33}, +/* 1280x1024 at 60 Hz, 64.3 kHz hsync */ + {110000, 1280, 1328, 1512, 1712, 1024, 1025, 1028, 1054, 0, S + 34}, +/* 1280x1024 at 74 Hz, 78.9 kHz hsync */ + {135000, 1280, 1312, 1456, 1712, 1024, 1027, 1030, 1064, 0, S + 35}, +/* 1600x1200 at 68Hz */ + {188500, 1600, 1792, 1856, 2208, 1200, 1202, 1205, 1256, 0, S + 36}, +/* 1600x1200 at 75 Hz */ + {198000, 1600, 1616, 1776, 2112, 1200, 1201, 1204, 1250, 0, S + 37}, +/* 720x540 at 56 Hz, 35.15 kHz hsync */ + {32400, 720, 744, 808, 920, 540, 541, 543, 563, 0, S + 38}, +/* 720x540 at 60 Hz, 37.8 kHz hsync */ + {36000, 720, 760, 872, 952, 540, 541, 545, 565, 0, S + 39}, +/* 720x540 at 72 Hz, 48.0 kHz hsync */ + {45000, 720, 768, 880, 936, 540, 552, 558, 599, 0, S + 40}, +/* 1072x600 at 57 Hz interlaced, 35.5 kHz hsync */ + {44900, 1072, 1096, 1208, 1264, 600, 602, 604, 625, 0, S + 41}, +/* 1072x600 at 65 Hz, 40.9 kHz hsync */ + {55000, 1072, 1096, 1208, 1264, 600, 602, 604, 625, 0, S + 42}, +/* 1072x600 at 78 Hz, 48.4 kHz hsync */ + {65000, 1072, 1088, 1184, 1344, 600, 603, 607, 625, NHSYNC | NVSYNC, S + 43}, +/* 1072x600 at 90 Hz, 56.6 kHz hsync */ + {75000, 1072, 1096, 1200, 1328, 768, 603, 607, 625, NHSYNC | NVSYNC, S + 44}, +/* 1072x600 at 100 Hz, 62.5 kHz hsync */ + {85000, 1072, 1088, 1160, 1360, 768, 603, 607, 625, 0, NULL}, +#undef S +}; + +int __svgalib_getmodetiming(ModeTiming * modetiming, ModeInfo * modeinfo, + CardSpecs * cardspecs) +{ + int maxclock, desiredclock; + MonitorModeTiming *besttiming=NULL; + + /*if(force_timing){ + if(timing_within_monitor_spec(force_timing) && + force_timing->HDisplay == modeinfo->width && + force_timing->VDisplay == modeinfo->height) + { + besttiming=force_timing; + }; +};*/ + + /* Get the maximum pixel clock for the depth of the requested mode. */ + if (modeinfo->bitsPerPixel == 4) + maxclock = cardspecs->maxPixelClock4bpp; + else if (modeinfo->bitsPerPixel == 8) + maxclock = cardspecs->maxPixelClock8bpp; + else if (modeinfo->bitsPerPixel == 16) + { + if ((cardspecs->flags & NO_RGB16_565) + && modeinfo->greenWeight == 6) + return 1; /* No 5-6-5 RGB. */ + maxclock = cardspecs->maxPixelClock16bpp; + } + else if (modeinfo->bitsPerPixel == 24) + maxclock = cardspecs->maxPixelClock24bpp; + else if (modeinfo->bitsPerPixel == 32) + maxclock = cardspecs->maxPixelClock32bpp; + else + maxclock = 0; + + /* + * Check user defined timings first. + * If there is no match within these, check the standard timings. + */ + //if(!besttiming) + //besttiming = search_mode(user_timings, maxclock, modeinfo, cardspecs); + besttiming = __svgalib_standard_timings + 20; + if (!besttiming) { + besttiming = search_mode(__svgalib_standard_timings, maxclock, modeinfo, cardspecs); + if (!besttiming) + { + wprintf(L"besttiming == NULL\n"); + return 1; + } + } + /* + * Copy the selected timings into the result, which may + * be adjusted for the chipset. + */ + + modetiming->flags = besttiming->flags; + modetiming->pixelClock = besttiming->pixelClock; /* Formal clock. */ + + /* + * We know a close enough clock is available; the following is the + * exact clock that fits the mode. This is probably different + * from the best matching clock that will be programmed. + */ + desiredclock = cardspecs->mapClock(modeinfo->bitsPerPixel, + besttiming->pixelClock); + + /* Fill in the best-matching clock that will be programmed. */ + modetiming->selectedClockNo = findclock(desiredclock, cardspecs); + if (modetiming->selectedClockNo == PROGRAMMABLE_CLOCK_MAGIC_NUMBER) { + modetiming->programmedClock = + cardspecs->matchProgrammableClock(desiredclock); + modetiming->flags |= USEPROGRCLOCK; + } else + modetiming->programmedClock = cardspecs->clocks[ + modetiming->selectedClockNo]; + modetiming->HDisplay = besttiming->HDisplay; + modetiming->HSyncStart = besttiming->HSyncStart; + modetiming->HSyncEnd = besttiming->HSyncEnd; + modetiming->HTotal = besttiming->HTotal; + if (cardspecs->mapHorizontalCrtc(modeinfo->bitsPerPixel, + modetiming->programmedClock, + besttiming->HTotal) + != besttiming->HTotal) { + /* Horizontal CRTC timings are scaled in some way. */ + modetiming->CrtcHDisplay = + cardspecs->mapHorizontalCrtc(modeinfo->bitsPerPixel, + modetiming->programmedClock, + besttiming->HDisplay); + modetiming->CrtcHSyncStart = + cardspecs->mapHorizontalCrtc(modeinfo->bitsPerPixel, + modetiming->programmedClock, + besttiming->HSyncStart); + modetiming->CrtcHSyncEnd = + cardspecs->mapHorizontalCrtc(modeinfo->bitsPerPixel, + modetiming->programmedClock, + besttiming->HSyncEnd); + modetiming->CrtcHTotal = + cardspecs->mapHorizontalCrtc(modeinfo->bitsPerPixel, + modetiming->programmedClock, + besttiming->HTotal); + modetiming->flags |= HADJUSTED; + } else { + modetiming->CrtcHDisplay = besttiming->HDisplay; + modetiming->CrtcHSyncStart = besttiming->HSyncStart; + modetiming->CrtcHSyncEnd = besttiming->HSyncEnd; + modetiming->CrtcHTotal = besttiming->HTotal; + } + modetiming->VDisplay = besttiming->VDisplay; + modetiming->VSyncStart = besttiming->VSyncStart; + modetiming->VSyncEnd = besttiming->VSyncEnd; + modetiming->VTotal = besttiming->VTotal; + if (modetiming->flags & DOUBLESCAN){ + modetiming->VDisplay <<= 1; + modetiming->VSyncStart <<= 1; + modetiming->VSyncEnd <<= 1; + modetiming->VTotal <<= 1; + } + modetiming->CrtcVDisplay = modetiming->VDisplay; + modetiming->CrtcVSyncStart = modetiming->VSyncStart; + modetiming->CrtcVSyncEnd = modetiming->VSyncEnd; + modetiming->CrtcVTotal = modetiming->VTotal; + if (((modetiming->flags & INTERLACED) + && (cardspecs->flags & INTERLACE_DIVIDE_VERT)) + || (modetiming->VTotal >= 1024 + && (cardspecs->flags & GREATER_1024_DIVIDE_VERT))) { + /* + * Card requires vertical CRTC timing to be halved for + * interlaced modes, or for all modes with vertical + * timing >= 1024. + */ + modetiming->CrtcVDisplay /= 2; + modetiming->CrtcVSyncStart /= 2; + modetiming->CrtcVSyncEnd /= 2; + modetiming->CrtcVTotal /= 2; + modetiming->flags |= VADJUSTED; + } + current_timing=besttiming; + return 0; /* Succesful. */ +} + +/* Return non-zero if mode is available */ + +bool CS3Graphics::ModeAvailable(int mode) +{ + //struct info *info; + ModeInfo *modeinfo; + ModeTiming *modetiming; + + //if (mode < G640x480x256 || mode == G720x348x2) + //return __svgalib_vga_driverspecs.modeavailable(mode); + + /* Enough memory? */ + //info = &__svgalib_infotable[mode]; + //if (s3_memory * 1024 < info->ydim * s3_adjlinewidth(info->xbytes)) + //return 0; + + modeinfo = __svgalib_createModeInfoStructureForSvgalibMode(mode); + + modetiming = (ModeTiming*) malloc(sizeof(ModeTiming)); + if (__svgalib_getmodetiming(modetiming, modeinfo, cardspecs)) + { + wprintf(L"__svgalib_getmodetiming failed\n"); + free(modetiming); + free(modeinfo); + return 0; + } + free(modetiming); + free(modeinfo); + + return true; +} + +/* +* Adjust the display width. This is necessary for the graphics +* engine if acceleration is used. However it will require more +* memory making some modes unavailable. +*/ +int CS3Graphics::AdjustLineWidth(int oldwidth) +{ + if (s3_chiptype < S3_801) + return 1024; +#ifdef S3_USE_GRAPHIC_ENGINE + if (oldwidth <= 640) + return 640; + if (oldwidth <= 800) + return 800; + if (oldwidth <= 1024) + return 1024; + if (!(s3_flags & S3_OLD_STEPPING)) + if (oldwidth <= 1152) + return 1152; + if (oldwidth <= 1280) + return 1280; + if (oldwidth <= 1600 && s3_chiptype >= S3_864) + return 1600; + + return 2048; +#else + return oldwidth; +#endif +} + +#define VGAREG_CR(i) (i) +#define VGAREG_AR(i) (i + VGA_ATC_OFFSET) +#define VGAREG_GR(i) (i + VGA_GRAPHICS_OFFSET) +#define VGAREG_SR(i) (i + VGA_SEQUENCER_OFFSET) + +#define VGA_CR0 VGAREG_CR(0x00) +#define VGA_CR1 VGAREG_CR(0x01) +#define VGA_CR2 VGAREG_CR(0x02) +#define VGA_CR3 VGAREG_CR(0x03) +#define VGA_CR4 VGAREG_CR(0x04) +#define VGA_CR5 VGAREG_CR(0x05) +#define VGA_CR6 VGAREG_CR(0x06) +#define VGA_CR7 VGAREG_CR(0x07) +#define VGA_CR8 VGAREG_CR(0x08) +#define VGA_CR9 VGAREG_CR(0x09) +#define VGA_CRA VGAREG_CR(0x0A) +#define VGA_CRB VGAREG_CR(0x0B) +#define VGA_CRC VGAREG_CR(0x0C) +#define VGA_CRD VGAREG_CR(0x0D) +#define VGA_CRE VGAREG_CR(0x0E) +#define VGA_CRF VGAREG_CR(0x0F) +#define VGA_CR10 VGAREG_CR(0x10) +#define VGA_CR11 VGAREG_CR(0x11) +#define VGA_CR12 VGAREG_CR(0x12) +#define VGA_CR13 VGAREG_CR(0x13) +#define VGA_SCANLINEOFFSET VGAREG_CR(0x13) +#define VGA_CR14 VGAREG_CR(0x14) +#define VGA_CR15 VGAREG_CR(0x15) +#define VGA_CR16 VGAREG_CR(0x16) +#define VGA_CR17 VGAREG_CR(0x17) +#define VGA_CR18 VGAREG_CR(0x18) + +#define VGA_AR0 VGAREG_AR(0x00) +#define VGA_AR10 VGAREG_AR(0x10) +#define VGA_AR11 VGAREG_AR(0x11) +#define VGA_AR12 VGAREG_AR(0x12) +#define VGA_AR13 VGAREG_AR(0x13) +#define VGA_AR14 VGAREG_AR(0x14) + +#define VGA_GR0 VGAREG_GR(0x00) +#define VGA_GR1 VGAREG_GR(0x01) +#define VGA_GR2 VGAREG_GR(0x02) +#define VGA_GR3 VGAREG_GR(0x03) +#define VGA_GR4 VGAREG_GR(0x04) +#define VGA_GR5 VGAREG_GR(0x05) +#define VGA_GR6 VGAREG_GR(0x06) +#define VGA_GR7 VGAREG_GR(0x07) +#define VGA_GR8 VGAREG_GR(0x08) + +#define VGA_SR0 VGAREG_SR(0x00) +#define VGA_SR1 VGAREG_SR(0x01) +#define VGA_SR2 VGAREG_SR(0x02) +#define VGA_SR3 VGAREG_SR(0x03) +#define VGA_SR4 VGAREG_SR(0x04) + +/* +* Setup VGA registers for SVGA mode timing. Adapted from XFree86, +* vga256/vga/vgaHW.c vgaHWInit(). +* +* Note that VGA registers are set up in a way that is common for +* SVGA modes. This is not particularly useful for standard VGA +* modes, since VGA does not have a clean packed-pixel mode. +*/ + +void __svgalib_setup_VGA_registers(unsigned char *moderegs, ModeTiming * modetiming, + ModeInfo * modeinfo) +{ + int i; + /* Sync Polarities */ + if ((modetiming->flags & (PHSYNC | NHSYNC)) && + (modetiming->flags & (PVSYNC | NVSYNC))) { + /* + * If both horizontal and vertical polarity are specified, + * set them as specified. + */ + moderegs[VGA_MISCOUTPUT] = 0x23; + if (modetiming->flags & NHSYNC) + moderegs[VGA_MISCOUTPUT] |= 0x40; + if (modetiming->flags & NVSYNC) + moderegs[VGA_MISCOUTPUT] |= 0x80; + } else { + /* + * Otherwise, calculate the polarities according to + * monitor standards. + */ + if (modetiming->VDisplay < 400) + moderegs[VGA_MISCOUTPUT] = 0xA3; + else if (modetiming->VDisplay < 480) + moderegs[VGA_MISCOUTPUT] = 0x63; + else if (modetiming->VDisplay < 768) + moderegs[VGA_MISCOUTPUT] = 0xE3; + else + moderegs[VGA_MISCOUTPUT] = 0x23; + } + + /* Sequencer */ + moderegs[VGA_SR0] = 0x00; + if (modeinfo->bitsPerPixel == 4) + moderegs[VGA_SR0] = 0x02; + moderegs[VGA_SR1] = 0x01; + moderegs[VGA_SR2] = 0x0F; /* Bitplanes. */ + moderegs[VGA_SR3] = 0x00; + moderegs[VGA_SR4] = 0x0E; + if (modeinfo->bitsPerPixel == 4) + moderegs[VGA_SR4] = 0x06; + + /* CRTC Timing */ + moderegs[VGA_CR0] = (modetiming->CrtcHTotal / 8) - 5; + moderegs[VGA_CR1] = (modetiming->CrtcHDisplay / 8) - 1; + moderegs[VGA_CR2] = (modetiming->CrtcHSyncStart / 8) - 1; + moderegs[VGA_CR3] = ((modetiming->CrtcHSyncEnd / 8) & 0x1F) | 0x80; + moderegs[VGA_CR4] = (modetiming->CrtcHSyncStart / 8); + moderegs[VGA_CR5] = (((modetiming->CrtcHSyncEnd / 8) & 0x20) << 2) + | ((modetiming->CrtcHSyncEnd / 8) & 0x1F); + moderegs[VGA_CR6] = (modetiming->CrtcVTotal - 2) & 0xFF; + moderegs[VGA_CR7] = (((modetiming->CrtcVTotal - 2) & 0x100) >> 8) + | (((modetiming->CrtcVDisplay - 1) & 0x100) >> 7) + | ((modetiming->CrtcVSyncStart & 0x100) >> 6) + | (((modetiming->CrtcVSyncStart) & 0x100) >> 5) + | 0x10 + | (((modetiming->CrtcVTotal - 2) & 0x200) >> 4) + | (((modetiming->CrtcVDisplay - 1) & 0x200) >> 3) + | ((modetiming->CrtcVSyncStart & 0x200) >> 2); + moderegs[VGA_CR8] = 0x00; + moderegs[VGA_CR9] = ((modetiming->CrtcVSyncStart & 0x200) >> 4) | 0x40; + if (modetiming->flags & DOUBLESCAN) + moderegs[VGA_CR9] |= 0x80; + moderegs[VGA_CRA] = 0x00; + moderegs[VGA_CRB] = 0x00; + moderegs[VGA_CRC] = 0x00; + moderegs[VGA_CRD] = 0x00; + moderegs[VGA_CRE] = 0x00; + moderegs[VGA_CRF] = 0x00; + moderegs[VGA_CR10] = modetiming->CrtcVSyncStart & 0xFF; + moderegs[VGA_CR11] = (modetiming->CrtcVSyncEnd & 0x0F) | 0x20; + moderegs[VGA_CR12] = (modetiming->CrtcVDisplay - 1) & 0xFF; + moderegs[VGA_CR13] = modeinfo->lineWidth >> 4; /* Just a guess. */ + moderegs[VGA_CR14] = 0x00; + moderegs[VGA_CR15] = modetiming->CrtcVSyncStart & 0xFF; + moderegs[VGA_CR16] = (modetiming->CrtcVSyncStart + 1) & 0xFF; + moderegs[VGA_CR17] = 0xC3; + if (modeinfo->bitsPerPixel == 4) + moderegs[VGA_CR17] = 0xE3; + moderegs[VGA_CR18] = 0xFF; + + /* Graphics Controller */ + moderegs[VGA_GR0] = 0x00; + moderegs[VGA_GR1] = 0x00; + moderegs[VGA_GR2] = 0x00; + moderegs[VGA_GR3] = 0x00; + moderegs[VGA_GR4] = 0x00; + moderegs[VGA_GR5] = 0x40; + if (modeinfo->bitsPerPixel == 4) + moderegs[VGA_GR5] = 0x02; + moderegs[VGA_GR6] = 0x05; + moderegs[VGA_GR7] = 0x0F; + moderegs[VGA_GR8] = 0xFF; + + /* Attribute Controller */ + for (i = 0; i < 16; i++) + moderegs[VGA_AR0 + i] = i; + moderegs[VGA_AR10] = 0x41; + if (modeinfo->bitsPerPixel == 4) + moderegs[VGA_AR10] = 0x01; /* was 0x81 */ + /* Attribute register 0x11 is the overscan color. */ + moderegs[VGA_AR12] = 0x0F; + moderegs[VGA_AR13] = 0x00; + moderegs[VGA_AR14] = 0x00; +} + +/* Color modes. */ + +#define CLUT8_6 0 +#define CLUT8_8 1 +#define RGB16_555 2 +#define RGB16_565 3 +#define RGB24_888_B 4 /* 3 bytes per pixel, blue byte first. */ +#define RGB32_888_B 5 /* 4 bytes per pixel. */ + +/* +* This function converts a number of significant color bits to a matching +* DAC mode type as defined in the RAMDAC interface. +*/ + +int __svgalib_colorbits_to_colormode(int bpp, int colorbits) +{ + if (colorbits == 8) + return CLUT8_6; + if (colorbits == 15) + return RGB16_555; + if (colorbits == 16) + return RGB16_565; + if (colorbits == 24) { + if (bpp == 24) + return RGB24_888_B; + else + return RGB32_888_B; + } + return CLUT8_6; +} + + +/* +* Initialize register state for a mode. +*/ + +void CS3Graphics::InitializeMode(unsigned char *moderegs, + ModeTiming * modetiming, ModeInfo * modeinfo) +{ + /* Get current values. */ + SaveRegisters(moderegs); + + /* Set up the standard VGA registers for a generic SVGA. */ + __svgalib_setup_VGA_registers(moderegs, modetiming, modeinfo); + + /* Set up the extended register values, including modifications */ + /* of standard VGA registers. */ + + moderegs[VGA_SR0] = 0x03; + moderegs[VGA_CR13] = modeinfo->lineWidth >> 3; + moderegs[VGA_CR17] = 0xE3; + + if (modeinfo->lineWidth / modeinfo->bytesPerPixel == 2048) + moderegs[S3_CR31] = 0x8F; + else + moderegs[S3_CR31] = 0x8D; +#ifdef S3_LINEAR_MODE_BANKING_864 + if (s3_chiptype >= S3_864) { + /* moderegs[S3_ENHANCEDMODE] |= 0x01; */ + /* Enable enhanced memory mode. */ + moderegs[S3_CR31] |= 0x04; + /* Enable banking via CR6A in linear mode. */ + moderegs[S3_CR31] |= 0x01; + } +#endif + moderegs[S3_CR32] = 0; + moderegs[S3_CR33] = 0x20; + moderegs[S3_CR34] = 0x10; /* 1024 */ + moderegs[S3_CR35] = 0; + /* Call cebank() here when setting registers. */ + if (modeinfo->bitsPerPixel >= 8) { + moderegs[S3_CR3A] = 0xB5; + if (s3_chiptype == S3_928) + /* ARI: Turn on CHAIN4 for 928, since __svgalib_setup_VGA_registers + initializes ModeX */ + moderegs[VGA_CR14] = 0x60; + } else { + /* 16 color mode */ + moderegs[VGA_CR13] = modeinfo->lineWidth >> 1; + moderegs[VGA_GR0] = 0x0F; + moderegs[VGA_GR1] = 0x0F; + moderegs[VGA_GR5] = 0x00; /* write mode 0 */ + moderegs[VGA_AR11] = 0x00; + moderegs[S3_CR3A] = 0x85; + } + + moderegs[S3_CR3B] = (moderegs[VGA_CR0] + moderegs[VGA_CR4] + 1) / 2; + moderegs[S3_CR3C] = moderegs[VGA_CR0] / 2; + if (s3_chiptype == S3_911) { + moderegs[S3_CR40] &= 0xF2; + moderegs[S3_CR40] |= 0x09; + } else if (s3_flags & S3_LOCALBUS) { + moderegs[S3_CR40] &= 0xF2; + /* Pegasus wants 0x01 for zero wait states. */ +#ifdef S3_0_WAIT_805_864 + moderegs[S3_CR40] |= 0x09; /* use fifo + 0 wait state */ +#else + moderegs[S3_CR40] |= 0x05; +#endif + } else { + moderegs[S3_CR40] &= 0xF6; + moderegs[S3_CR40] |= 0x01; + } + + if (modeinfo->bitsPerPixel >= 24) { + /* 24/32 bit color */ + if (s3_chiptype == S3_864 || s3_chiptype == S3_964) + moderegs[S3_CR43] = 0x08; + else if (s3_chiptype == S3_928 /*&& dac_used->id == SIERRA_15025*/) + moderegs[S3_CR43] = 0x01; /* ELSA Winner 1000 */ + } else if (modeinfo->bitsPerPixel >= 15) { + /* 15/16 bit color */ + if (s3_chiptype <= S3_864 || s3_chiptype >= S3_866) { /* XXXX Trio? */ + moderegs[S3_CR43] = 0x08; + //if (dac_used->id == IBMRGB52x) + //moderegs[S3_CR43] = 0x10; + //else + if (s3_chiptype == S3_928 /*&& dac_used->id == SIERRA_15025*/) + moderegs[S3_CR43] = 0x01; + if (s3_chiptype <= S3_924 /*&& dac_used->id != NORMAL_DAC*/) + moderegs[S3_CR43] = 0x01; + + } else + /* XXXX some DAC might need this; XF86 source says... */ + moderegs[S3_CR43] = 0x09; + } else { + /* 4/8 bit color */ + moderegs[S3_CR43] = 0x00; + } + + if (s3_chiptype >= S3_924 && s3_chiptype <= S3_928) { /* different for 864+ */ + s3_8514regs[S3_ADVFUNC_CNTL] = 0x0002; + if ((s3_chiptype == S3_928 && modeinfo->bitsPerPixel != 4) || !(s3_flags & S3_OLD_STEPPING)) + s3_8514regs[S3_ADVFUNC_CNTL] |= 0x0001; + if (modeinfo->bitsPerPixel == 4) + s3_8514regs[S3_ADVFUNC_CNTL] |= 0x0004; +#if 0 + /* 864 databook says it is for enhanced 4bpp */ + if (modeinfo->lineWidth > 640) + s3_8514regs[S3_ADVFUNC_CNTL] |= 0x0004; +#endif + } else if (s3_chiptype == S3_968) { + s3_8514regs[S3_ADVFUNC_CNTL] = 0x0002; + if (modeinfo->bitsPerPixel == 4) + s3_8514regs[S3_ADVFUNC_CNTL] |= 0x0004; +#ifdef PIXEL_MULTIPLEXING + else + s3_8514regs[S3_ADVFUNC_CNTL] |= 0x0001; +#endif + } else if (modeinfo->lineWidth / modeinfo->bytesPerPixel == 1024) + s3_8514regs[S3_ADVFUNC_CNTL] = 0x0007; + else + s3_8514regs[S3_ADVFUNC_CNTL] = 0x0003; + + moderegs[S3_CR44] = 0; + /* Skip CR45, 'hi/truecolor cursor color enable'. */ + + if (s3_chiptype >= S3_801) { + int m, n; /* for FIFO balancing */ + + /* XXXX Not all chips support all widths. */ + moderegs[S3_CR50] &= ~0xF1; + switch (modeinfo->bitsPerPixel) { + case 16: + moderegs[S3_CR50] |= 0x10; + break; + case 24: /* XXXX 868/968 only */ + if (s3_chiptype >= S3_868) + moderegs[S3_CR50] |= 0x20; + break; + case 32: + moderegs[S3_CR50] |= 0x30; + break; + } + + switch (modeinfo->lineWidth / modeinfo->bytesPerPixel) { + case 640: + moderegs[S3_CR50] |= 0x40; + break; + case 800: + moderegs[S3_CR50] |= 0x80; + break; + case 1152: + if (!(s3_flags & S3_OLD_STEPPING)) { + moderegs[S3_CR50] |= 0x01; + break; + } /* else fall through */ + case 1280: + moderegs[S3_CR50] |= 0xC0; + break; + case 1600: + moderegs[S3_CR50] |= 0x81; + break; + /* 1024/2048 no change. */ + } + + moderegs[S3_CR51] &= 0xC0; + moderegs[S3_CR51] |= (modeinfo->lineWidth >> 7) & 0x30; + + /* moderegs[S3_CR53] |= 0x10; *//* Enable MMIO. */ + /* moderegs[S3_CR53] |= 0x20; *//* DRAM interleaving for S3_805i with 2MB */ + + n = 0xFF; + if (s3_chiptype >= S3_864 || + s3_chiptype == S3_801 || s3_chiptype == S3_805) { + /* + * CRT FIFO balancing for DRAM cards and 964/968 + * in VGA mode. + */ + int clock, mclk; + if (modeinfo->bitsPerPixel < 8) { + clock = modetiming->pixelClock; + } else { + clock = modetiming->pixelClock * + modeinfo->bytesPerPixel; + } + if (s3_memory < 2048 || s3_chiptype == S3_TRIO32) + clock *= 2; + if (s3Mclk > 0) + mclk = s3Mclk; + else if (s3_chiptype == S3_801 || s3_chiptype == S3_805) + mclk = 50000; /* Assumption. */ + else + mclk = 60000; /* Assumption. */ + m = (int) ((mclk / 1000.0 * .72 + 16.867) * 89.736 / (clock / 1000.0 + 39) - 21.1543); + if (s3_memory < 2048 || s3_chiptype == S3_TRIO32) + m /= 2; + if (m > 31) + m = 31; + else if (m < 0) { + m = 0; + n = 16; + } + } else if (s3_memory == 512 || modetiming->HDisplay > 1200) + m = 0; + else if (s3_memory == 1024) + m = 2; + else + m = 20; + + moderegs[S3_CR54] = m << 3; + moderegs[S3_CR60] = n; + + moderegs[S3_CR55] &= 0x08; + moderegs[S3_CR55] |= 0x40; + +#ifdef S3_LINEAR_MODE_BANKING_864 + if (s3_chiptype >= S3_864) { + if (modeinfo->bitsPerPixel >= 8) { + /* Enable linear addressing. */ + moderegs[S3_CR58] |= 0x10; + /* Set window size to 64K. */ + moderegs[S3_CR58] &= ~0x03; + /* Assume CR59/5A are correctly set up for 0xA0000. */ + /* Set CR6A linear bank to zero. */ + moderegs[S3_CR6A] &= ~0x3F; + /* use alternate __svgalib_setpage() function */ + __svgalib_s3_driverspecs.__svgalib_setpage = s3_setpage864; + } else { + /* doesn't work for 4bpp. */ + __svgalib_s3_driverspecs.__svgalib_setpage = s3_setpage; + } + } +#endif +#ifdef S3_LINEAR_SUPPORT + moderegs[S3_CR59] = s3_cr59; + moderegs[S3_CR5A] = s3_cr5A; +#endif + + /* Extended CRTC timing. */ + moderegs[S3_CR5E] = + (((modetiming->CrtcVTotal - 2) & 0x400) >> 10) | + (((modetiming->CrtcVDisplay - 1) & 0x400) >> 9) | + (((modetiming->CrtcVSyncStart) & 0x400) >> 8) | + (((modetiming->CrtcVSyncStart) & 0x400) >> 6) | 0x40; + + { + int i, j; + i = ((((modetiming->CrtcHTotal >> 3) - 5) & 0x100) >> 8) | + ((((modetiming->CrtcHDisplay >> 3) - 1) & 0x100) >> 7) | + ((((modetiming->CrtcHSyncStart >> 3) - 1) & 0x100) >> 6) | + ((modetiming->CrtcHSyncStart & 0x800) >> 7); + if ((modetiming->CrtcHSyncEnd >> 3) - (modetiming->CrtcHSyncStart >> 3) > 64) + i |= 0x08; + if ((modetiming->CrtcHSyncEnd >> 3) - (modetiming->CrtcHSyncStart >> 3) > 32) + i |= 0x20; + j = ((moderegs[VGA_CR0] + ((i & 0x01) << 8) + + moderegs[VGA_CR4] + ((i & 0x10) << 4) + 1) / 2); + if (j - (moderegs[VGA_CR4] + ((i & 0x10) << 4)) < 4) { + if (moderegs[VGA_CR4] + ((i & 0x10) << 4) + 4 <= moderegs[VGA_CR0] + ((i & 0x01) << 8)) + j = moderegs[VGA_CR4] + ((i & 0x10) << 4) + 4; + else + j = moderegs[VGA_CR0] + ((i & 0x01) << 8) + 1; + } + + moderegs[S3_CR3B] = j & 0xFF; + i |= (j & 0x100) >> 2; + /* Interlace mode frame offset. */ + moderegs[S3_CR3C] = (moderegs[VGA_CR0] + ((i & 0x01) << 8)) / 2; + moderegs[S3_CR5D] = (moderegs[S3_CR5D] & 0x80) | i; + } + + { + int i; + + if (modeinfo->bitsPerPixel < 8) + i = modetiming->HDisplay / 4 + 1; + else + i = modetiming->HDisplay * + modeinfo->bytesPerPixel / 4 + 1; + + moderegs[S3_CR61] = (i >> 8) | 0x80; + moderegs[S3_CR62] = i & 0xFF; + } + } /* 801+ */ + if (modetiming->flags & INTERLACED) + moderegs[S3_CR42] |= 0x20; + + /* + * Clock select works as follows: + * Clocks 0 and 1 (VGA 25 and 28 MHz) can be selected via the + * two VGA MiscOutput clock select bits. + * If 0x3 is written to these bits, the selected clock index + * is taken from the S3 clock select register at CR42. Clock + * indices 0 and 1 should correspond to the VGA ones above, + * and 3 is often 0 MHz, followed by extended clocks for a + * total of mostly 16. + */ + + if (modetiming->flags & USEPROGRCLOCK) + moderegs[VGA_MISCOUTPUT] |= 0x0C; /* External clock select. */ + else if (modetiming->selectedClockNo < 2) { + /* Program clock select bits 0 and 1. */ + moderegs[VGA_MISCOUTPUT] &= ~0x0C; + moderegs[VGA_MISCOUTPUT] |= + (modetiming->selectedClockNo & 3) << 2; + } else if (modetiming->selectedClockNo >= 2) { + moderegs[VGA_MISCOUTPUT] |= 0x0C; + /* Program S3 clock select bits. */ + moderegs[S3_CR42] &= ~0x1F; + moderegs[S3_CR42] |= + modetiming->selectedClockNo; + } + if (s3_chiptype == S3_TRIO64 || s3_chiptype == S3_765) { + moderegs[S3_CR33] &= ~0x08; + if (modeinfo->bitsPerPixel == 16) + moderegs[S3_CR33] |= 0x08; + /* + * The rest of the DAC/clocking is setup by the + * Trio64 code in the RAMDAC interface (ramdac.c). + */ + } + /*if (dac_used->id != NORMAL_DAC) { + int colormode; + colormode = __svgalib_colorbits_to_colormode(modeinfo->bitsPerPixel, + modeinfo->colorBits); + dac_used->initializeState(&moderegs[S3_DAC_OFFSET], + modeinfo->bitsPerPixel, colormode, + modetiming->pixelClock); + + if (dac_used->id == ATT20C490) { + int pixmux, invert_vclk, blank_delay; + pixmux = 0; + invert_vclk = 0; + blank_delay = 2; + if (colormode == CLUT8_6 + && modetiming->pixelClock >= 67500) { + pixmux = 0x00; + invert_vclk = 1; + } else if (colormode == CLUT8_8) + pixmux = 0x02; + else if (colormode == RGB16_555) + pixmux = 0xa0; + else if (colormode == RGB16_565) + pixmux = 0xc0; + else if (colormode == RGB24_888_B) + pixmux = 0xe0; + moderegs[S3_CR67] = pixmux | invert_vclk; + moderegs[S3_CR6D] = blank_delay; + }*/ + /*if (dac_used->id == S3_SDAC) { + int pixmux, invert_vclk, blank_delay; + pixmux = 0; + invert_vclk = 0; + blank_delay = 0; + if (colormode == CLUT8_6 + && modetiming->pixelClock >= 67500) { +#ifdef SDAC_8BPP_PIXMUX*/ + /* x64 8bpp pixel multiplexing? */ + /* pixmux = 0x10; + if (s3_chiptype != S3_866 && s3_chiptype != S3_868) + invert_vclk = 1; + blank_delay = 2; + #endif + } else if (colormode == RGB16_555) { + pixmux = 0x30; + blank_delay = 2; + } else if (colormode == RGB16_565) { + pixmux = 0x50; + blank_delay = 2; + } else if (colormode == RGB24_888_B) { // XXXX 868/968 only + pixmux = 0x90; + blank_delay = 2; + } else if (colormode == RGB32_888_B) { + pixmux = 0x70; + blank_delay = 2; + } + moderegs[S3_CR67] = pixmux | invert_vclk; + moderegs[S3_CR6D] = blank_delay; + // Clock select. + moderegs[S3_CR42] &= ~0x0F; + moderegs[S3_CR42] |= 0x02; + }*/ + /* if (dac_used->id == IBMRGB52x) { + unsigned char pixmux, blank_delay, tmp; + tmp = 0; + pixmux = 0x11; + blank_delay = 0; + if (modeinfo->bitsPerPixel < 8 || colormode == RGB32_888_B) + pixmux = 0x00; + moderegs[S3_CR58] |= 0x40; + moderegs[S3_CR65] = 0; + moderegs[S3_CR66] &= 0xf8; + moderegs[S3_CR66] |= tmp; + #ifdef PIXEL_MULTIPLEXING + moderegs[S3_CR67] = pixmux; + #endif + moderegs[S3_CR6D] = blank_delay; + // Clock select. + moderegs[S3_CR42] &= ~0x0F; + moderegs[S3_CR42] |= 0x02; + } + }*/ +#ifdef S3_LINEAR_SUPPORT + s3_cr58 = moderegs[S3_CR58]; + s3_cr40 = moderegs[S3_CR40]; + s3_cr54 = moderegs[S3_CR54]; +#endif + /*if (clk_used == &__svgalib_I2061A_clockchip_methods && + (modetiming->flags & USEPROGRCLOCK)) { + // Clock select. + moderegs[S3_CR42] &= ~0x0F; + moderegs[S3_CR42] |= 0x02; + }*/ + /* update the 8514 regs */ + memcpy(moderegs + S3_8514_OFFSET, s3_8514regs, S3_8514_COUNT * 2); +} + +int __svgalib_setregs(const unsigned char *regs) +{ + int i; + + //if(__svgalib_novga) return 1; + + //if (__svgalib_chipset == EGA) { + /* Enable graphics register modification */ + //port_out(0x00, GRA_E0); + //port_out(0x01, GRA_E1); + //} + /* update misc output register */ + __svgalib_vga_outmisc(regs[MIS]); + + /* synchronous reset on */ + __svgalib_vga_outseq(0x00,0x01); + + /* write sequencer registers */ + __svgalib_vga_outseq(0x01,regs[SEQ + 1] | 0x20); + out(SEQ_I, 1); + out(SEQ_D, regs[SEQ + 1] | 0x20); + for (i = 2; i < SEQ_C; i++) { + __svgalib_vga_outseq(i,regs[SEQ + i]); + } + + /* synchronous reset off */ + __svgalib_vga_outseq(0x00,0x03); + + /*if (__svgalib_chipset != EGA) { + // deprotect CRT registers 0-7 + __svgalib_outcrtc(0x11,__svgalib_incrtc(0x11)&0x7f); +}*/ + /* write CRT registers */ + for (i = 0; i < CRT_C; i++) { + __svgalib_vga_outcrtc(i,regs[CRT + i]); + } + + /* write graphics controller registers */ + for (i = 0; i < GRA_C; i++) { + out(GRA_I, i); + out(GRA_D, regs[GRA + i]); + } + + /* write attribute controller registers */ + for (i = 0; i < ATT_C; i++) { + in(__svgalib_IS1_R); /* reset flip-flop */ + //__svgalib_delay(); + msleep(1); + out(ATT_IW, i); + //__svgalib_delay(); + msleep(1); + out(ATT_IW, regs[ATT + i]); + //__svgalib_delay(); + msleep(1); + } + + return 0; +} + +/* Set chipset-specific registers */ +void CS3Graphics::SetRegisters(const unsigned char regs[], int mode) +{ + unsigned char b, bmax; + /* + * Right now, anything != 0x00 gets written in s3_setregs. + * May change this into a bitmask later. + */ + static unsigned char s3_regmask[] = + { + 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x00, 0x00, /* CR30-CR37 */ + 0x00, 0x00, 0x3A, 0x3B, 0x3C, 0x00, 0x00, 0x00, /* CR38-CR3F */ + 0x00, 0x00, 0x42, 0x43, 0x44, 0x00, 0x00, 0x00, /* CR40-CR47 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* CR48-CR4F */ + 0x50, 0x51, 0x00, 0x00, 0x54, 0x55, 0x00, 0x00, /* CR50-CR57 */ + 0x58, 0x59, 0x5A, 0x00, 0x00, 0x5D, 0x5E, 0x00, /* CR58-CR5F */ + 0x60, 0x61, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, /* CR60-CR67 */ + 0x00, 0x00, 0x6A, 0x00, 0x00, 0x00 /* CR68-CR6D */ + }; + + HwUnlockEnh(); + + /* save a private copy */ + memcpy(s3_8514regs, regs + S3_8514_OFFSET, S3_8514_COUNT * 2); + /* + * set this first, so if we segfault on this (e.g. we didn't do a iopl(3)) + * we don't get a screwed up display + */ + out16(ADVFUNC_CNTL, s3_8514regs[S3_ADVFUNC_CNTL]); + + /* get S3 VGA/Ext registers */ + bmax = 0x4F; + if (s3_chiptype >= S3_801) + bmax = 0x66; + if (s3_chiptype >= S3_864) + bmax = 0x6D; + for (b = 0x30; b <= bmax; b++) { + if (s3_regmask[b - 0x30]) + __svgalib_outCR(b, regs[EXT + b - 0x30]); + } + + /*if (dac_used->id != NORMAL_DAC) { + unsigned char CR1; + // Blank the screen. + CR1 = __svgalib_inCR(0x01); + __svgalib_outCR(0x01, CR1 | 0x20); + + __svgalib_outbCR(0x55, __svgalib_inCR(0x55) | 1); + __svgalib_outCR(0x66, regs[S3_CR66]); + __svgalib_outCR(0x67, regs[S3_CR67]); // S3 pixmux. + + dac_used->restoreState(regs + S3_DAC_OFFSET); + + __svgalib_outCR(0x6D, regs[S3_CR6D]); + __svgalib_outbCR(0x55, __svgalib_inCR(0x55) & ~1); + + __svgalib_outCR(0x01, CR1); // Unblank screen. +}*/ +#ifdef S3_LINEAR_SUPPORT + if (mode == TEXT && s3_linear_addr) + s3_linear_disable(); /* make sure linear is off */ +#endif + + /* restore CR38/39 (may lock other regs) */ + if (mode == 1) { + /* restore lock registers as well */ + __svgalib_outCR(0x40, regs[S3_CR40]); + __svgalib_outCR(0x39, regs[S3_CR39]); + __svgalib_outCR(0x38, regs[S3_CR38]); + } else + HwLockEnh(); +} + +/* Set a mode */ + +int CS3Graphics::SetMode(int mode, int prv_mode) +{ + ModeInfo *modeinfo; + ModeTiming *modetiming; + unsigned char moderegs[S3_TOTAL_REGS]; + int res; + + /*if (mode < G640x480x256 || mode == G720x348x2) { + // Let the standard VGA driver set standard VGA modes. + res = __svgalib_vga_driverspecs.setmode(mode, prv_mode); + if (res == 0 && s3_chiptype <= S3_928) */ + /* + * ARI: Turn off virtual size of 1024 - this fixes all problems + * with standard modes, including 320x200x256. + * + * SL: Is this for 928 only? Doesn't matter for 805. + */ + /*HwUnlock(); + __svgalib_outCR(0x34, __svgalib_inCR(0x34) & ~0x10); + HwLock(); + } + return res; +}*/ + if (!ModeAvailable(mode)) + { + wprintf(L"Mode %d not available\n", mode); + return 1; + } + + modeinfo = __svgalib_createModeInfoStructureForSvgalibMode(mode); + wprintf(L"Mode: %ux%ux%u\n", modeinfo->width, modeinfo->height, modeinfo->bitsPerPixel); + + modetiming = (ModeTiming*) malloc(sizeof(ModeTiming)); + if (__svgalib_getmodetiming(modetiming, modeinfo, cardspecs)) + { + wprintf(L"Unable to get mode timings\n"); + free(modetiming); + free(modeinfo); + return 1; + } + /* Adjust the display width. */ + modeinfo->lineWidth = AdjustLineWidth(modeinfo->lineWidth); + //CI.xbytes = modeinfo->lineWidth; + + InitializeMode(moderegs, modetiming, modeinfo); + free(modeinfo); + free(modetiming); + + __svgalib_setregs(moderegs); /* Set standard regs. */ + SetRegisters(moderegs, mode); /* Set extended regs. */ + return 0; +} + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CS3Graphics::CS3Graphics() +{ + s3Mclk = 0; + Init(0, 0, 0); + if (SetMode(0, 0)) + wprintf(L"Unable to set mode\n"); +} + +CS3Graphics::~CS3Graphics() +{ + +} + +HRESULT CS3Graphics::SetPalette(int nIndex, int red, int green, int blue) +{ + return E_FAIL; +} + +HRESULT CS3Graphics::Lock(surface_t* pDesc) +{ + return E_FAIL; +} + +HRESULT CS3Graphics::Unlock() +{ + return E_FAIL; +} + +HRESULT CS3Graphics::GetSurfaceDesc(surface_t* pDesc) +{ + return E_FAIL; +} + +pixel_t CS3Graphics::ColourMatch(colour_t clr) +{ + return 0; +} + +HRESULT CS3Graphics::SetPixel(int x, int y, pixel_t pix) +{ + return E_FAIL; +} + +pixel_t CS3Graphics::GetPixel(int x, int y) +{ + return 0; +} + +HRESULT CS3Graphics::Blt(ISurface* pSrc, int x, int y, int nWidth, + int nHeight, int nSrcX, int nSrcY, pixel_t pixTrans) +{ + return E_FAIL; +} + +HRESULT CS3Graphics::FillRect(const rectangle_t* rect, pixel_t pix) +{ + return E_FAIL; +} + +HRESULT CS3Graphics::AttachProcess() +{ + return S_OK; +} \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/S3Graphics.h b/mobius/src/drivers/winmgr/S3Graphics.h new file mode 100644 index 0000000..d31ed36 --- /dev/null +++ b/mobius/src/drivers/winmgr/S3Graphics.h @@ -0,0 +1,165 @@ +// S3Graphics.h: interface for the CS3Graphics class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_S3GRAPHICS_H__17417CB7_9D36_41EF_8FF5_FAF1C201C207__INCLUDED_) +#define AFX_S3GRAPHICS_H__17417CB7_9D36_41EF_8FF5_FAF1C201C207__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#include "surface.h" + +/* This is for the hardware (card)-adjusted mode timing. */ +struct ModeTiming { + int pixelClock; /* Pixel clock in kHz. */ + int HDisplay; /* Horizontal Timing. */ + int HSyncStart; + int HSyncEnd; + int HTotal; + int VDisplay; /* Vertical Timing. */ + int VSyncStart; + int VSyncEnd; + int VTotal; + int flags; +/* The following field are optionally filled in according to card */ +/* specific parameters. */ + int programmedClock; /* Actual clock to be programmed. */ + int selectedClockNo; /* Index number of fixed clock used. */ + int CrtcHDisplay; /* Actual programmed horizontal CRTC timing. */ + int CrtcHSyncStart; + int CrtcHSyncEnd; + int CrtcHTotal; + int CrtcVDisplay; /* Actual programmed vertical CRTC timing. */ + int CrtcVSyncStart; + int CrtcVSyncEnd; + int CrtcVTotal; +}; + +/* Flags in ModeTiming. */ +#define PHSYNC 0x1 /* Positive hsync polarity. */ +#define NHSYNC 0x2 /* Negative hsync polarity. */ +#define PVSYNC 0x4 /* Positive vsync polarity. */ +#define NVSYNC 0x8 /* Negative vsync polarity. */ +#define INTERLACED 0x10 /* Mode has interlaced timing. */ +#define DOUBLESCAN 0x20 /* Mode uses VGA doublescan (see note). */ +#define HADJUSTED 0x40 /* Horizontal CRTC timing adjusted. */ +#define VADJUSTED 0x80 /* Vertical CRTC timing adjusted. */ +#define USEPROGRCLOCK 0x100 /* A programmable clock is used. */ + +/* Mode info. */ +struct ModeInfo { +/* Basic properties. */ + short width; /* Width of the screen in pixels. */ + short height; /* Height of the screen in pixels. */ + char bytesPerPixel; /* Number of bytes per pixel. */ + char bitsPerPixel; /* Number of bits per pixel. */ + char colorBits; /* Number of significant bits in pixel. */ + char __padding1; +/* Truecolor pixel specification. */ + char redWeight; /* Number of significant red bits. */ + char greenWeight; /* Number of significant green bits. */ + char blueWeight; /* Number of significant blue bits. */ + char __padding2; + char redOffset; /* Offset in bits of red value into pixel. */ + char blueOffset; /* Offset of green value. */ + char greenOffset; /* Offset of blue value. */ + char __padding3; + unsigned redMask; /* Pixel mask of read value. */ + unsigned blueMask; /* Pixel mask of green value. */ + unsigned greenMask; /* Pixel mask of blue value. */ +/* Structural properties of the mode. */ + int lineWidth; /* Offset in bytes between scanlines. */ + short realWidth; /* Real on-screen resolution. */ + short realHeight; /* Real on-screen resolution. */ + int flags; +}; + +/* Cards specifications. */ +struct CardSpecs { + int videoMemory; /* Video memory in kilobytes. */ + int maxPixelClock4bpp; /* Maximum pixel clocks in kHz for each depth. */ + int maxPixelClock8bpp; + int maxPixelClock16bpp; + int maxPixelClock24bpp; + int maxPixelClock32bpp; + int flags; /* Flags (e.g. programmable clocks). */ + int nClocks; /* Number of fixed clocks. */ + int *clocks; /* Pointer to array of fixed clock values. */ + int maxHorizontalCrtc; + /* + * The following function maps from a pixel clock and depth to + * the raw clock frequency required. + */ + int (*mapClock) (int bpp, int pixelclock); + /* + * The following function maps from a requested clock value + * to the closest clock that the programmable clock device + * can produce. + */ + int (*matchProgrammableClock) (int desiredclock); + /* + * The following function maps from a pixel clock, depth and + * horizontal CRTC timing parameter to the horizontal timing + * that has to be programmed. + */ + int (*mapHorizontalCrtc) (int bpp, int pixelclock, int htiming); +}; + +struct MonitorModeTiming { + int pixelClock; /* Pixel clock in kHz. */ + int HDisplay; /* Horizontal Timing. */ + int HSyncStart; + int HSyncEnd; + int HTotal; + int VDisplay; /* Vertical Timing. */ + int VSyncStart; + int VSyncEnd; + int VTotal; + int flags; + MonitorModeTiming *next; +}; + +class CS3Graphics : public Surface +{ +public: + CS3Graphics(); + virtual ~CS3Graphics(); + + IMPLEMENT_IUNKNOWN(CS3Graphics); + + STDMETHOD(SetPalette)(int nIndex, int red, int green, int blue); + STDMETHOD(Lock)(surface_t* pDesc); + STDMETHOD(Unlock)(); + STDMETHOD(GetSurfaceDesc)(surface_t* pDesc); + STDMETHOD_(pixel_t, ColourMatch)(colour_t clr); + + STDMETHOD(SetPixel)(int x, int y, pixel_t pix); + STDMETHOD_(pixel_t, GetPixel)(int x, int y); + STDMETHOD(Blt)(ISurface* pSrc, int x, int y, int nWidth, + int nHeight, int nSrcX, int nSrcY, pixel_t pixTrans); + STDMETHOD(FillRect)(const rectangle_t* rect, pixel_t pix); + + STDMETHOD(AttachProcess)(); + +protected: + int s3_flags, s3_chiptype, s3_memory; + CardSpecs* cardspecs; + int s3Mclk; + + void HwLock(); + void HwLockEnh(); + void HwUnlock(); + void HwUnlockEnh(); + int Init(int force, int par1, int par2); + bool ModeAvailable(int mode); + int AdjustLineWidth(int oldwidth); + void InitializeMode(unsigned char *moderegs, + ModeTiming * modetiming, ModeInfo * modeinfo); + int SaveRegisters(unsigned char regs[]); + void SetRegisters(const unsigned char regs[], int mode); + int SetMode(int mode, int prv_mode); +}; + +#endif // !defined(AFX_S3GRAPHICS_H__17417CB7_9D36_41EF_8FF5_FAF1C201C207__INCLUDED_) diff --git a/mobius/src/drivers/winmgr/Window.cpp b/mobius/src/drivers/winmgr/Window.cpp new file mode 100644 index 0000000..2caadce --- /dev/null +++ b/mobius/src/drivers/winmgr/Window.cpp @@ -0,0 +1,232 @@ +// Window.cpp: implementation of the CWindow class. +// +////////////////////////////////////////////////////////////////////// + +#include +#include "Window.h" +#include "ClipSurface.h" +#include +#include +#include +#include +#include + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +//dword thrGetTls(); + +extern CWindow* desktop; + +int new_window_x, new_window_y; + +CWindow::CWindow(const windowdef_t* def, IWindowServer* srv) +{ + surface_t desc; + + m_refs = 0; + m_srv = srv; + m_surf = srv->GetScreen(); + m_font = srv->GetFont(1); + m_first = m_last = m_prev = m_next = m_parent = NULL; + + m_surf->GetSurfaceDesc(&desc); + + if (def->flags & WIN_TITLE) + m_title = wcsdup(def->title); + else + m_title = wcsdup(L""); + + if (def->flags & WIN_X) + left = def->x; + else + { + left = new_window_x; + new_window_x += 20; + if (new_window_x + 100 > desc.nWidth) + new_window_x = 0; + } + + if (def->flags & WIN_Y) + top = def->y; + else + { + top = new_window_y; + new_window_y += 20; + if (new_window_y + 100 > desc.nHeight) + new_window_y = 0; + } + + if (def->flags & WIN_WIDTH) + right = left + def->width; + else + right = left + 100; + + if (def->flags & WIN_HEIGHT) + bottom = top + def->height; + else + bottom = top + 100; + + if (def->flags & WIN_PARENT) + m_parent = (CWindow*) def->parent; + else + m_parent = desktop; + + if (m_parent) + { + m_parent->AddRef(); + + m_prev = m_parent->m_last; + if (m_parent->m_last) + m_parent->m_last->m_next = this; + m_parent->m_last = this; + if (m_parent->m_first == NULL) + m_parent->m_first = this; + } + + if (def->flags & WIN_WNDPROC) + m_attribs[ATTR_WNDPROC] = (dword) def->wndproc; + else + m_attribs[ATTR_WNDPROC] = NULL; + + m_invalid_rect.SetEmpty(); + m_attribs[ATTR_PROCESS] = (dword) procCurrent(); + m_attribs[ATTR_MSGQUEUE] = thrGetInfo()->queue; + InvalidateRect(this); +} + +CWindow::~CWindow() +{ + if (m_prev) + m_prev->m_next = m_next; + if (m_next) + m_next->m_prev = m_prev; + + if (m_parent) + { + m_parent->RemoveChild(this); + m_parent->Release(); + } + + free(m_title); + m_surf->Release(); + + if (m_font) + m_font->Release(); + + m_srv->Release(); +} + +HRESULT CWindow::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IWindow)) + { + AddRef(); + *ppvObject = (IWindow*) this; + return S_OK; + } + else + return E_FAIL; +} + +void CWindow::OnPaint(ISurface* surf, const rectangle_t* rect) +{ +} + +void CWindow::PostMessage(dword message, dword param) +{ + IMsgQueue* queue = (IMsgQueue*) m_attribs[ATTR_MSGQUEUE]; + queue->PostMessage(this, message, param); +} + +void CWindow::RemoveChild(CWindow* child) +{ + if (m_first == child) + m_first = child->m_next; + if (m_last == child) + m_last = child->m_prev; + + InvalidateRect(child); + UpdateWindow(); +} + +dword CWindow::GetAttrib(dword index) +{ + return m_attribs[index]; +} + +ISurface* CWindow::GetSurface() +{ + rectangle_t rect; + m_surf->AddRef(); + rect = *this; + if (m_parent) + m_parent->ClientToScreen(&rect); + return new CClipSurface(m_surf, rect); +} + +HRESULT CWindow::InvalidateRect(const rectangle_t* rect) +{ + CWindow* child; + + m_invalid_rect.UnionRect(rect); + + for (child = m_first; child; child = child->m_next) + child->InvalidateRect(rect); + + PostMessage(WM_PAINT, 0); + return S_OK; +} + +HRESULT CWindow::UpdateWindow() +{ + CWindow* child; + ISurface* surf; + + if (!m_invalid_rect.IsEmpty()) + { + surf = GetSurface(); + OnPaint(surf, m_invalid_rect); + surf->Release(); + m_invalid_rect.SetEmpty(); + } + + for (child = m_first; child; child = child->m_next) + child->UpdateWindow(); + + return S_OK; +} + +HRESULT CWindow::DefWndProc(dword message, dword param) +{ + switch (message) + { + case WM_PAINT: + UpdateWindow(); + break; + } + + return S_OK; +} + +IWindow* CWindow::GetFirstChild() +{ + if (m_first) + { + m_first->AddRef(); + return m_first; + } + else + return NULL; +} + +HRESULT CWindow::ClientToScreen(rectangle_t* rect) +{ + if (m_parent) + m_parent->ClientToScreen(rect); + + rect->OffsetRect(left, top); + return S_OK; +} \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/Window.h b/mobius/src/drivers/winmgr/Window.h new file mode 100644 index 0000000..8ee7c46 --- /dev/null +++ b/mobius/src/drivers/winmgr/Window.h @@ -0,0 +1,48 @@ +// Window.h: interface for the CWindow class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_WINDOW_H__5E636D91_60B2_47BF_BA22_0380D4BAAFA8__INCLUDED_) +#define AFX_WINDOW_H__5E636D91_60B2_47BF_BA22_0380D4BAAFA8__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#include + +class CWindow : + public IUnknown, + public IWindow, + public rectangle_t +{ +public: + CWindow *m_prev, *m_next, *m_first, *m_last, *m_parent; + IWindowServer* m_srv; + ISurface* m_surf; + IFont* m_font; + wchar_t* m_title; + rectangle_t m_invalid_rect; + dword m_attribs[3]; + + CWindow(const windowdef_t* def, IWindowServer* srv); + virtual ~CWindow(); + + virtual void OnPaint(ISurface* surf, const rectangle_t* rect); + virtual void AdjustForFrame(rectangle_t* rect) { } + void PostMessage(dword message, dword param); + virtual void RemoveChild(CWindow* child); + + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + IMPLEMENT_IUNKNOWN(CWindow); + + STDMETHOD_(dword, GetAttrib)(dword index); + STDMETHOD_(ISurface*, GetSurface)(); + STDMETHOD(InvalidateRect)(const rectangle_t* rect); + STDMETHOD(UpdateWindow)(); + STDMETHOD(DefWndProc)(dword message, dword param); + STDMETHOD_(IWindow*, GetFirstChild)(); + STDMETHOD(ClientToScreen)(rectangle_t* rect); +}; + +#endif // !defined(AFX_WINDOW_H__5E636D91_60B2_47BF_BA22_0380D4BAAFA8__INCLUDED_) diff --git a/mobius/src/drivers/winmgr/WindowServer.cpp b/mobius/src/drivers/winmgr/WindowServer.cpp new file mode 100644 index 0000000..47e4b88 --- /dev/null +++ b/mobius/src/drivers/winmgr/WindowServer.cpp @@ -0,0 +1,201 @@ +// WindowServer.cpp: implementation of the CWindowServer class. +// +////////////////////////////////////////////////////////////////////// + +#include +#include +#include + +#include "WindowServer.h" +#include "Window.h" +#include "winframe.h" +#include "MsgQueue.h" +#include "ResFont.h" +#include "DesktopWnd.h" +#include "S3Graphics.h" + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +extern "C" IWindowServer* OpenServer(); + +extern "C" const byte font1[], font2[]; +extern ISurface* CreateGraphics(int nMode); +extern IFont* CreateFont(const byte* pFontData); + +CWindow* desktop; + +void __cdecl idle() +{ +#if 0 + msg_t msg; + IMsgQueue* queue; + HRESULT (*wndproc) (IWindow*, dword, dword); + + queue = (IMsgQueue*) thrGetTls(); + if (queue) + { + while (true) + { + if (SUCCEEDED(queue->GetMessage(&msg))) + { + /* Can't currently use IMsgQueue::DispatchMessage in kernel mode */ + if (msg.wnd) + { + wndproc = (HRESULT (*) (IWindow*, dword, dword)) + msg.wnd->GetAttrib(ATTR_WNDPROC); + + if (wndproc) + wndproc(msg.wnd, msg.message, msg.params); + else + msg.wnd->DefWndProc(msg.message, msg.params); + } + } + } + } +#endif +} + +CWindowServer::CWindowServer() +{ + const word *font_dir, *ord; + const FontDirEntry *header; + windowdef_t def; + int i; + surface_t desc; + + m_refs = 0; + m_gfx = CreateGraphics(0x13); + //m_gfx = new CS3Graphics; + m_gfx->GetSurfaceDesc(&desc); + + memset(m_fonts, 0, sizeof(m_fonts)); + m_fonts[0] = CreateFont(font2); + + font_dir = (const word*) resFind(_info.base, RT_FONTDIR, 0, 0); + if (font_dir) + { + ord = font_dir + 1; + for (i = 0; i < *font_dir; i++) + { + header = (const FontDirEntry*) (ord + 1); + m_fonts[i + 1] = new CResFont(_info.base, *ord); + + if (header->Version == 0x200) + ord = (const word*) ((const byte*) header + SIZEOF_FONTDIRENTRY20); + else + ord = (const word*) ((const byte*) header + sizeof(FontDirEntry)); + } + } + + DeviceOpen(); + + def.size = sizeof(def); + def.flags = WIN_X | WIN_Y | WIN_WIDTH | WIN_HEIGHT | WIN_PARENT; + def.x = def.y = 0; + def.width = desc.nWidth; + def.height = desc.nHeight; + def.parent = NULL; + AddRef(); + desktop = new CDesktopWnd(&def, this); + + desktop->UpdateWindow(); +} + +CWindowServer::~CWindowServer() +{ + int i; + + desktop->Release(); + desktop = NULL; + + for (i = 0; i < countof(m_fonts); i++) + if (m_fonts[i]) + m_fonts[i]->Release(); + + m_gfx->Release(); +} + +HRESULT CWindowServer::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IDevice)) + { + AddRef(); + *ppvObject = (IDevice*) this; + return S_OK; + } + else if (InlineIsEqualGUID(iid, IID_IWindowServer)) + { + AddRef(); + *ppvObject = (IWindowServer*) this; + return S_OK; + } + else + return E_FAIL; +} + +HRESULT CWindowServer::GetInfo(device_t* buf) +{ + if (buf->size < sizeof(device_t)) + return E_FAIL; + + wcscpy(buf->name, L"Window Server"); + return S_OK; +} + +HRESULT CWindowServer::DeviceOpen() +{ + if (thrGetInfo()->queue == NULL) + { + CMsgQueue* queue = new CMsgQueue; + //thrSetTls((dword) (IMsgQueue*) queue); + thrGetInfo()->queue = (dword) (IMsgQueue*) queue; + } + + return S_OK; +} + +IWindow* CWindowServer::CreateWindow(const windowdef_t* def) +{ + CWindowFrame* frame; + CWindow* wnd; + windowdef_t deftemp = *def, def2 = *def; + rectangle_t rect; + + AddRef(); + deftemp.flags &= ~WIN_WNDPROC; + deftemp.wndproc = NULL; + frame = new CWindowFrame(&deftemp, this); + + rect = *frame; + frame->AdjustForFrame(&rect); + def2.flags |= WIN_PARENT | WIN_X | WIN_Y | WIN_WIDTH | WIN_HEIGHT; + def2.parent = frame; + def2.x = rect.left; + def2.y = rect.top; + def2.width = rect.Width(); + def2.height = rect.Height(); + + wnd = new CWindow(&def2, this); + frame->UpdateWindow(); + return wnd; +} + +ISurface* CWindowServer::GetScreen() +{ + m_gfx->AddRef(); + return m_gfx; +} + +IFont* CWindowServer::GetFont(int index) +{ + if (m_fonts[index]) + { + m_fonts[index]->AddRef(); + return m_fonts[index]; + } + else + return NULL; +} \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/WindowServer.h b/mobius/src/drivers/winmgr/WindowServer.h new file mode 100644 index 0000000..05e7799 --- /dev/null +++ b/mobius/src/drivers/winmgr/WindowServer.h @@ -0,0 +1,41 @@ +// WindowServer.h: interface for the CWindowServer class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_WINDOWSERVER_H__1726670A_0953_4E42_BB4B_C09886089C16__INCLUDED_) +#define AFX_WINDOWSERVER_H__1726670A_0953_4E42_BB4B_C09886089C16__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#include +#include +#include +#include + +class CWindowServer : + public IUnknown, + public IWindowServer, + public IDevice +{ +public: + CWindowServer(); + virtual ~CWindowServer(); + + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + IMPLEMENT_IUNKNOWN(CWindowServer); + + STDMETHOD(GetInfo)(device_t* buf); + STDMETHOD(DeviceOpen)(); + + STDMETHOD_(IWindow*, CreateWindow)(const windowdef_t* def); + STDMETHOD_(ISurface*, GetScreen)(); + STDMETHOD_(IFont*, GetFont)(int index); + +protected: + ISurface* m_gfx; + IFont *m_fonts[16]; +}; + +#endif // !defined(AFX_WINDOWSERVER_H__1726670A_0953_4E42_BB4B_C09886089C16__INCLUDED_) diff --git a/mobius/src/drivers/winmgr/common.c b/mobius/src/drivers/winmgr/common.c new file mode 100644 index 0000000..c34d9ba --- /dev/null +++ b/mobius/src/drivers/winmgr/common.c @@ -0,0 +1,2 @@ +#define INITGUID +#include \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/console.cpp b/mobius/src/drivers/winmgr/console.cpp new file mode 100644 index 0000000..9e6a46b --- /dev/null +++ b/mobius/src/drivers/winmgr/console.cpp @@ -0,0 +1,368 @@ +#include "console.h" +#include +#include +#include +#include + +/***************************************************************************** + * CConsole * + *****************************************************************************/ + +CConsole::CConsole() +{ + m_refs = 0; + m_con_x = 0; + m_con_y = 0; + m_width = m_height = 0; + m_attrib = 0x0700; + m_esc = 0; +} + +// IUnknown methods +HRESULT CConsole::QueryInterface(REFIID iid, void ** ppvObject) +{ + //wprintf(L"QI"); + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IDevice)) + { + //wprintf(L"(IDevice)\n"); + AddRef(); + *ppvObject = (IDevice*) this; + return S_OK; + } + else if (InlineIsEqualGUID(iid, IID_IStream)) + { + //wprintf(L"(IStream)\n"); + AddRef(); + *ppvObject = (IStream*) new CStream(this); + return S_OK; + } + + /*wprintf(L"(fail) %p %p {%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x} %p\n", + this, + iid.Data1, iid.Data2, iid.Data3, + iid.Data4[0], + iid.Data4[1], + iid.Data4[2], + iid.Data4[3], + iid.Data4[4], + iid.Data4[5], + iid.Data4[6], + iid.Data4[7], + ppvObject);*/ + *ppvObject = NULL; + return E_FAIL; +} + +ULONG CConsole::AddRef() +{ + return ++m_refs; +} + +ULONG CConsole::Release() +{ + if (m_refs == 0) + { + delete this; + return 0; + } + else + return --m_refs; +} + +// IDevice method +HRESULT CConsole::GetInfo(device_t* buf) +{ + if (buf->size < sizeof(device_t)) + return E_FAIL; + + wcscpy(buf->name, L"Console"); + return S_OK; +} + +HRESULT CConsole::DeviceOpen() +{ + return S_OK; +} + +void CConsole::WriteCharacter(dword mode, wchar_t c) +{ + if (mode == ioRaw) + { + Output(m_con_x, m_con_y, c, 0); + m_con_x++; + + if (m_con_x >= m_width) + { + m_con_x = 0; + m_con_y++; + } + } + else + { + if (m_esc == 1) + { + if (c == L'[') + { + m_esc++; + m_esc1 = 0; + return; + } + } + else if (m_esc == 2) + { + if (iswdigit(c)) + { + m_esc1 = m_esc1 * 10 + c - L'0'; + return; + } + else if (c == ';') + { + m_esc++; + m_esc2 = 0; + return; + } + else if (c == 'J') + { + if (m_esc1 == 2) + Clear(); + } + else if (c == 'm') + SetAttrib(m_esc1); + + m_esc = 0; + return; + } + else if (m_esc == 3) + { + if (iswdigit(c)) + { + m_esc2 = m_esc2 * 10 + c - '0'; + return; + } + else if(c == ';') + { + m_esc++; /* ESC[num1;num2; */ + m_esc3 = 0; + return; + } + /* ESC[num1;num2H -- move cursor to num1,num2 */ + else if(c == 'H') + { + if(m_esc2 < m_width) + m_con_x = m_esc2; + if(m_esc1 < m_height) + m_con_y = m_esc1; + } + /* ESC[num1;num2m -- set attributes num1,num2 */ + else if(c == 'm') + { + SetAttrib(m_esc1); + SetAttrib(m_esc2); + } + m_esc = 0; + return; + } + /* ESC[num1;num2;num3 */ + else if(m_esc == 4) + { + if (iswdigit(c)) + { + m_esc3 = m_esc3 * 10 + c - '0'; + return; + } + /* ESC[num1;num2;num3m -- set attributes num1,num2,num3 */ + else if(c == 'm') + { + SetAttrib(m_esc1); + SetAttrib(m_esc2); + SetAttrib(m_esc3); + } + m_esc = 0; + return; + } + + m_esc = 0; + switch (c) + { + case L'\n': + m_con_x = 0; + m_con_y++; + break; + + case L'\r': + m_con_x = 0; + break; + + case L'\t': + m_con_x = (m_con_x + 4) & ~3; + break; + + case L'\b': + if (m_con_x > 0) + m_con_x--; + break; + + case 27: + m_esc = 1; + break; + + default: + Output(m_con_x, m_con_y, c, m_attrib); + m_con_x++; + + if (m_con_x >= m_width) + { + m_con_x = 0; + m_con_y++; + } + } + } + + while (m_con_y >= m_height) + { + m_con_y--; + Scroll(0, -1); + } +} + +void CConsole::SetAttrib(byte att) +{ + static const char ansi_to_vga[] = + { + 0, 4, 2, 6, 1, 5, 3, 7 + }; + unsigned char new_att; + + new_att = m_attrib >> 8; + if(att == 0) + new_att &= ~0x08; /* bold off */ + else if(att == 1) + new_att |= 0x08; /* bold on */ + else if(att >= 30 && att <= 37) + { + att = ansi_to_vga[att - 30]; + new_att = (new_att & ~0x07) | att;/* fg color */ + } + else if(att >= 40 && att <= 47) + { + att = ansi_to_vga[att - 40] << 4; + new_att = (new_att & ~0x70) | att;/* bg color */ + } + + m_attrib = new_att << 8; +} + +/***************************************************************************** + * CConsole::CStream * + *****************************************************************************/ + +CConsole::CStream::CStream(CConsole* con) +{ + m_con = con; + m_con->AddRef(); + m_mode = ioUnicode; + m_refs = 0; +} + +CConsole::CStream::~CStream() +{ + if (m_con) + m_con->Release(); +} + +// IUnknown methods +HRESULT CConsole::CStream::QueryInterface(REFIID iid, void ** ppvObject) +{ + //wprintf(L"QI"); + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IStream)) + { + //wprintf(L"(IDevice)\n"); + AddRef(); + *ppvObject = (IStream*) this; + return S_OK; + } + else if (InlineIsEqualGUID(iid, IID_IDevice)) + { + //wprintf(L"(IStream)\n"); + m_con->AddRef(); + *ppvObject = (IDevice*) m_con; + return S_OK; + } + + //wprintf(L"(fail)\n"); + *ppvObject = NULL; + return E_FAIL; +} + +ULONG CConsole::CStream::AddRef() +{ + return ++m_refs; +} + +ULONG CConsole::CStream::Release() +{ + if (m_refs == 0) + { + delete this; + return 0; + } + else + return --m_refs; +} + +// IStream methods +size_t CConsole::CStream::Read(void* buffer, size_t length) +{ + return 0; +} + +size_t CConsole::CStream::Write(const void* buffer, size_t length) +{ + word* ch; + size_t written = 0; + + for (ch = (word*) buffer; written < length; ) + { + switch (m_mode) + { + case ioRaw: + case ioUnicode: + m_con->WriteCharacter(m_mode, *ch); + ch++; + written += sizeof(wchar_t); + break; + + case ioAnsi: + m_con->WriteCharacter(m_mode, (char) *ch); + ch = (word*) ((char*) ch + 1); + written += sizeof(char); + break; + } + } + + m_con->UpdateCursor(); + return written; +} + +HRESULT CConsole::CStream::SetIoMode(dword mode) +{ + m_mode = mode; + return S_OK; +} + +HRESULT CConsole::CStream::IsReady() +{ + return S_OK; +} + +HRESULT CConsole::CStream::Stat(folderitem_t* buf) +{ + return E_FAIL; +} + +HRESULT CConsole::CStream::Seek(long offset, int origin) +{ + return E_FAIL; +} \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/console.h b/mobius/src/drivers/winmgr/console.h new file mode 100644 index 0000000..4c728eb --- /dev/null +++ b/mobius/src/drivers/winmgr/console.h @@ -0,0 +1,60 @@ +#ifndef __CONSOLE_H +#define __CONSOLE_H + +#include + +class CConsole : public IUnknown, public IDevice +{ +protected: + dword m_refs; + unsigned short m_con_x, m_con_y, m_width, m_height; + byte m_esc, m_esc1, m_esc2, m_esc3; + word m_attrib; + +public: + CConsole(); + + virtual void UpdateCursor() = 0; + virtual void Output(int x, int y, wchar_t c, word attrib) = 0; + void WriteCharacter(dword mode, wchar_t c); + void SetAttrib(byte attrib); + virtual void Clear() = 0; + virtual void Scroll(int dx, int dy) = 0; + + // IUnknown methods + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + STDMETHOD_(ULONG, AddRef)(); + STDMETHOD_(ULONG, Release)(); + + // IDevice method + STDMETHOD(GetInfo)(device_t* buf); + STDMETHOD(DeviceOpen)(); + + class CStream : public IUnknown, public IStream + { + protected: + CConsole *m_con; + dword m_mode, m_refs; + + public: + CStream(CConsole* con); + ~CStream(); + + // IUnknown methods + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + STDMETHOD_(ULONG, AddRef)(); + STDMETHOD_(ULONG, Release)(); + + // IStream methods + STDMETHOD_(size_t, Read)(void* buffer, size_t length); + STDMETHOD_(size_t, Write)(const void* buffer, size_t length); + STDMETHOD(SetIoMode)(dword mode); + STDMETHOD(IsReady)(); + STDMETHOD(Stat)(folderitem_t* buf); + STDMETHOD(Seek)(long offset, int origin); + }; + + friend class CStream; +}; + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/font.cpp b/mobius/src/drivers/winmgr/font.cpp new file mode 100644 index 0000000..57d0501 --- /dev/null +++ b/mobius/src/drivers/winmgr/font.cpp @@ -0,0 +1,91 @@ +#include +#include + +class VgaFont : public IFont +{ +protected: + const byte* pFontData; + +public: + VgaFont(const byte* buf); + + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + IMPLEMENT_IUNKNOWN(VgaFont); + + STDMETHOD(DrawText)(ISurface* pSurf, int x, int y, const wchar_t* str, + pixel_t pixColour); + STDMETHOD(GetTextExtent)(const wchar_t* str, point_t* size); +}; + +IFont* CreateFont(const byte* pFontData) +{ + return new VgaFont(pFontData); +} + +VgaFont::VgaFont(const byte* buf) +{ + pFontData = buf; + m_refs = 0; +} + +HRESULT VgaFont::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_IFont)) + { + AddRef(); + *ppvObject = (IFont*) this; + return S_OK; + } + else + return E_FAIL; +} + +HRESULT VgaFont::DrawText(ISurface* pSurf, int x, int y, const wchar_t* str, pixel_t pixColour) +{ + const byte *pCharData; + const wchar_t* ch; + byte pix, *buf; + int cx, cy; + surface_t desc; + rectangle_t rect; + + if (SUCCEEDED(pSurf->Lock(&desc))) + { + pSurf->GetClipRect(&rect); + x += rect.left; + y += rect.top; + buf = (byte*) desc.pMemory + y * desc.nPitch; + + for (ch = str; *ch; ch++) + { + pCharData = pFontData + (byte) *ch * 8; + for (cy = 0; cy < 8; cy++) + { + if (pCharData[cy]) + { + for (cx = 0; cx < 8; cx++) + { + pix = pCharData[cy] & (0x80 >> cx); + if (pix) + buf[x + cx + cy * desc.nPitch] = pixColour; + //pSurf->SetPixel(x + cx, y + cy, pixColour); + } + } + } + + x += 8; + } + + pSurf->Unlock(); + } + + return S_OK; +} + +HRESULT VgaFont::GetTextExtent(const wchar_t* str, point_t* size) +{ + size->x = wcslen(str) * 8; + size->y = 8; + return S_OK; +} diff --git a/mobius/src/drivers/winmgr/font1.c b/mobius/src/drivers/winmgr/font1.c new file mode 100644 index 0000000..d708288 --- /dev/null +++ b/mobius/src/drivers/winmgr/font1.c @@ -0,0 +1,131 @@ +unsigned char font1[2048] = +{ + 124,130,186,162,186,130,124,0,126,129,165,129,165,153,129,126, + 126,129,165,129,153,165,129,126,108,246,246,254,124,56,16,0, + 16,56,124,254,124,56,16,0,16,56,84,254,84,16,56,0, + 56,124,254,254,108,16,56,0,16,24,20,20,48,112,96,0, + 254,254,254,238,254,254,254,0,236,138,138,170,170,170,236,0, + 142,136,136,140,136,136,232,0,174,170,170,234,170,170,174,0, + 238,136,136,204,136,136,136,0,238,138,138,142,140,138,234,0, + 62,34,62,34,102,238,204,0,16,84,40,198,40,84,16,0, + 240,248,252,254,252,248,240,0,30,62,126,254,126,62,30,0, + 16,56,124,16,124,56,16,0,238,238,238,238,238,0,238,0, + 254,68,68,68,68,68,68,0,126,128,188,198,122,2,252,0, + 0,0,0,0,255,255,0,0,16,56,124,16,124,56,16,254, + 16,56,124,254,56,56,56,0,56,56,56,254,124,56,16,0, + 16,24,252,254,252,24,16,0,16,48,126,254,126,48,16,0, + 144,72,36,18,36,72,144,0,18,36,72,144,72,36,18,0, + 16,40,68,146,40,68,130,0,130,68,40,146,68,40,16,0, + 0,0,0,0,0,0,0,0,16,16,16,16,16,0,16,0, + 40,40,40,0,0,0,0,0,68,254,68,68,68,254,68,0, + 16,126,144,124,18,252,16,0,66,164,72,16,36,74,132,0, + 56,68,56,112,138,132,122,0,16,16,32,0,0,0,0,0, + 8,16,16,16,16,16,8,0,32,16,16,16,16,16,32,0, + 16,84,56,254,56,84,16,0,16,16,16,254,16,16,16,0, + 0,0,0,0,0,16,16,32,0,0,0,254,0,0,0,0, + 0,0,0,0,0,0,16,0,2,4,8,16,32,64,128,0, + 124,130,130,130,130,130,124,0,240,16,16,16,16,16,254,0, + 252,2,2,124,128,128,254,0,252,2,2,28,2,2,252,0, + 130,130,130,126,2,2,2,0,254,128,252,2,2,2,252,0, + 126,128,252,130,130,130,124,0,252,2,2,2,2,2,2,0, + 124,130,130,124,130,130,124,0,126,130,130,126,2,2,252,0, + 0,0,0,16,0,0,16,0,0,0,0,16,0,0,16,32, + 8,16,32,64,32,16,8,0,0,0,0,254,0,254,0,0, + 64,32,16,8,16,32,64,0,56,68,4,8,16,0,16,0, + 60,66,154,170,156,64,62,0,124,130,130,254,130,130,130,0, + 252,130,130,252,130,130,252,0,124,130,128,128,128,130,124,0, + 252,130,130,130,130,130,252,0,254,128,128,240,128,128,254,0, + 254,128,128,240,128,128,128,0,124,130,128,142,130,130,124,0, + 130,130,130,254,130,130,130,0,254,16,16,16,16,16,254,0, + 62,2,2,2,130,130,124,0,130,132,136,240,136,132,130,0, + 128,128,128,128,128,128,254,0,252,146,146,146,146,146,146,0, + 130,194,162,146,138,134,130,0,124,130,130,130,130,130,124,0, + 252,130,130,252,128,128,128,0,124,130,130,130,138,134,126,0, + 252,130,130,252,130,130,130,0,126,128,128,124,2,2,252,0, + 254,16,16,16,16,16,16,0,130,130,130,130,130,130,124,0, + 130,130,68,68,40,40,16,0,130,130,130,146,146,146,108,0, + 130,68,40,16,40,68,130,0,130,130,130,126,2,2,252,0, + 254,4,8,16,32,64,254,0,56,32,32,32,32,32,56,0, + 128,64,32,16,8,4,2,0,56,8,8,8,8,8,56,0, + 16,40,68,130,0,0,0,0,0,0,0,0,0,0,0,255, + 32,32,16,0,0,0,0,0,0,0,56,68,124,68,68,0, + 0,0,120,68,120,68,120,0,0,0,60,64,64,64,60,0, + 0,0,120,68,68,68,120,0,0,0,124,64,112,64,124,0, + 0,0,124,64,112,64,64,0,0,0,60,64,76,68,60,0, + 0,0,68,68,124,68,68,0,0,0,124,16,16,16,124,0, + 0,0,28,4,4,68,56,0,0,0,68,72,112,72,68,0, + 0,0,64,64,64,64,124,0,0,0,120,84,84,84,84,0, + 0,0,120,68,68,68,68,0,0,0,56,68,68,68,56,0, + 0,0,120,68,120,64,64,0,0,0,56,68,68,76,54,0, + 0,0,120,68,120,68,68,0,0,0,60,64,56,4,120,0, + 0,0,124,16,16,16,16,0,0,0,68,68,68,68,56,0, + 0,0,68,68,40,40,16,0,0,0,68,68,84,108,68,0, + 0,0,68,40,16,40,68,0,0,0,68,68,60,4,120,0, + 0,0,124,8,16,32,124,0,8,16,16,32,16,16,8,0, + 16,16,16,0,16,16,16,0,32,16,16,8,16,16,32,0, + 80,40,0,0,0,0,0,0,0,16,40,68,130,130,254,0, + 254,254,254,254,254,254,254,0,0,0,0,0,0,254,254,0, + 0,0,124,124,124,124,124,0,0,0,0,0,0,0,124,0, + 128,128,128,128,128,128,128,0,0,64,64,64,64,64,64,0, + 16,24,28,30,28,24,16,0,16,48,112,240,112,48,16,0, + 62,30,30,62,114,224,64,0,4,14,156,248,240,240,248,0, + 64,224,114,62,30,30,62,0,248,240,240,248,156,14,4,0, + 56,68,130,130,130,68,56,0,56,124,254,254,254,124,56,0, + 0,124,68,68,68,124,0,0,0,124,124,124,124,124,0,0, + 0,60,110,126,112,126,60,0,0,60,118,126,14,126,60,0, + 0,60,126,106,126,126,106,0,0,60,126,86,126,126,86,0, + 0,0,0,24,24,0,0,0,0,0,24,60,60,24,0,0, + 0,12,52,36,36,108,72,0,0,0,0,0,0,0,0,0, + 60,126,198,231,255,224,126,60,60,126,227,231,255,7,126,60, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,52,118,118,94,126,60,0,0,60,110,126,112,126,60,0, + 0,60,126,122,110,110,44,0,0,60,126,14,126,118,60,0, + 0,0,0,0,0,0,0,0,126,126,126,126,60,0,0,0, + 0,15,31,31,31,31,15,0,126,127,127,127,127,127,63,0, + 0,0,0,60,126,126,126,126,126,126,126,126,126,126,126,126, + 0,63,127,127,127,127,127,126,126,127,127,127,127,127,127,126, + 0,240,248,248,248,248,240,0,126,254,254,254,254,254,252,0, + 0,255,255,255,255,255,255,0,126,255,255,255,255,255,255,0, + 0,252,254,254,254,254,254,126,126,254,254,254,254,254,254,126, + 0,255,255,255,255,255,255,126,126,255,255,255,255,255,255,126, + 0,0,63,63,48,55,52,52,0,0,255,255,0,255,0,0, + 0,0,248,248,24,216,88,88,88,88,88,88,88,88,88,88, + 88,216,24,248,248,0,0,0,0,255,0,255,255,0,0,0, + 52,55,48,63,63,0,0,0,52,52,52,52,52,52,52,52, + 0,0,0,31,24,24,24,24,0,0,0,255,0,0,0,0, + 0,0,0,240,48,48,48,48,48,48,48,48,48,48,48,48, + 48,48,48,240,0,0,0,0,0,0,0,255,0,0,0,0, + 24,24,24,31,0,0,0,0,24,24,24,24,24,24,24,24, + 136,34,136,34,136,34,136,34,85,170,85,170,85,170,85,170, + 68,170,68,170,68,170,68,170,51,102,204,153,51,102,204,153, + 204,102,51,153,204,102,51,153,199,143,31,62,124,248,241,227, + 227,241,248,124,62,31,143,199,174,128,186,2,234,8,171,32, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; diff --git a/mobius/src/drivers/winmgr/font2.c b/mobius/src/drivers/winmgr/font2.c new file mode 100644 index 0000000..5156a30 --- /dev/null +++ b/mobius/src/drivers/winmgr/font2.c @@ -0,0 +1,257 @@ +unsigned char font2[2048]={ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7E, 0x81, 0xA5, 0x81, 0xBD, 0x99, 0x81, 0x7E, + 0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E, + 0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00, + 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00, + 0x38, 0x7C, 0x38, 0xFE, 0xFE, 0x92, 0x10, 0x7C, + 0x00, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C, + 0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00, + 0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF, + 0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00, + 0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF, + 0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78, + 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, + 0x3F, 0x33, 0x3F, 0x30, 0x30, 0x70, 0xF0, 0xE0, + 0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0, + 0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99, + 0x80, 0xE0, 0xF8, 0xFE, 0xF8, 0xE0, 0x80, 0x00, + 0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00, + 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, + 0x7F, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00, + 0x3E, 0x63, 0x38, 0x6C, 0x6C, 0x38, 0x86, 0xFC, + 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00, + 0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF, + 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, + 0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, + 0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00, + 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00, + 0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00, + 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00, + 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00, + 0x18, 0x7E, 0xC0, 0x7C, 0x06, 0xFC, 0x18, 0x00, + 0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00, + 0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00, + 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00, + 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00, + 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, + 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, + 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, + 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, + 0x7C, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0x7C, 0x00, + 0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xFC, 0x00, + 0x78, 0xCC, 0x0C, 0x38, 0x60, 0xCC, 0xFC, 0x00, + 0x78, 0xCC, 0x0C, 0x38, 0x0C, 0xCC, 0x78, 0x00, + 0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00, + 0xFC, 0xC0, 0xF8, 0x0C, 0x0C, 0xCC, 0x78, 0x00, + 0x38, 0x60, 0xC0, 0xF8, 0xCC, 0xCC, 0x78, 0x00, + 0xFC, 0xCC, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00, + 0x78, 0xCC, 0xCC, 0x78, 0xCC, 0xCC, 0x78, 0x00, + 0x78, 0xCC, 0xCC, 0x7C, 0x0C, 0x18, 0x70, 0x00, + 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, + 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30, + 0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x00, + 0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00, + 0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00, + 0x3C, 0x66, 0x0C, 0x18, 0x18, 0x00, 0x18, 0x00, + 0x7C, 0xC6, 0xDE, 0xDE, 0xDC, 0xC0, 0x7C, 0x00, + 0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0x00, + 0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, + 0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00, + 0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, + 0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00, + 0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00, + 0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3A, 0x00, + 0xCC, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0xCC, 0x00, + 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00, + 0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00, + 0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00, + 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00, + 0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00, + 0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00, + 0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, + 0x7C, 0xC6, 0xC6, 0xC6, 0xD6, 0x7C, 0x0E, 0x00, + 0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00, + 0x7C, 0xC6, 0xE0, 0x78, 0x0E, 0xC6, 0x7C, 0x00, + 0xFC, 0xB4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, + 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00, + 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00, + 0xC6, 0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0x6C, 0x00, + 0xC6, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0xC6, 0x00, + 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x30, 0x78, 0x00, + 0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00, + 0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00, + 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00, + 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00, + 0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, + 0xE0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xDC, 0x00, + 0x00, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x00, + 0x1C, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0x76, 0x00, + 0x00, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, + 0x38, 0x6C, 0x64, 0xF0, 0x60, 0x60, 0xF0, 0x00, + 0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, + 0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00, + 0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x0C, 0x00, 0x1C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, + 0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00, + 0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x00, 0x00, 0xCC, 0xFE, 0xFE, 0xD6, 0xD6, 0x00, + 0x00, 0x00, 0xB8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, + 0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00, + 0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0, + 0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E, + 0x00, 0x00, 0xDC, 0x76, 0x62, 0x60, 0xF0, 0x00, + 0x00, 0x00, 0x7C, 0xC0, 0x70, 0x1C, 0xF8, 0x00, + 0x10, 0x30, 0xFC, 0x30, 0x30, 0x34, 0x18, 0x00, + 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, + 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00, + 0x00, 0x00, 0xC6, 0xC6, 0xD6, 0xFE, 0x6C, 0x00, + 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00, + 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, + 0x00, 0x00, 0xFC, 0x98, 0x30, 0x64, 0xFC, 0x00, + 0x1C, 0x30, 0x30, 0xE0, 0x30, 0x30, 0x1C, 0x00, + 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, + 0xE0, 0x30, 0x30, 0x1C, 0x30, 0x30, 0xE0, 0x00, + 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00, + 0x7C, 0xC6, 0xC0, 0xC6, 0x7C, 0x0C, 0x06, 0x7C, + 0x00, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, + 0x1C, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, + 0x7E, 0x81, 0x3C, 0x06, 0x3E, 0x66, 0x3B, 0x00, + 0xCC, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, + 0xE0, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, + 0x30, 0x30, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, + 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0x78, 0x0C, 0x38, + 0x7E, 0x81, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00, + 0xCC, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, + 0xE0, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, + 0xCC, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x7C, 0x82, 0x38, 0x18, 0x18, 0x18, 0x3C, 0x00, + 0xE0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0xC6, 0x10, 0x7C, 0xC6, 0xFE, 0xC6, 0xC6, 0x00, + 0x30, 0x30, 0x00, 0x78, 0xCC, 0xFC, 0xCC, 0x00, + 0x1C, 0x00, 0xFC, 0x60, 0x78, 0x60, 0xFC, 0x00, + 0x00, 0x00, 0x7F, 0x0C, 0x7F, 0xCC, 0x7F, 0x00, + 0x3E, 0x6C, 0xCC, 0xFE, 0xCC, 0xCC, 0xCE, 0x00, + 0x78, 0x84, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, + 0x00, 0xCC, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, + 0x00, 0xE0, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, + 0x78, 0x84, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, + 0x00, 0xE0, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, + 0x00, 0xCC, 0x00, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, + 0xC3, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x00, + 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x00, + 0x18, 0x18, 0x7E, 0xC0, 0xC0, 0x7E, 0x18, 0x18, + 0x38, 0x6C, 0x64, 0xF0, 0x60, 0xE6, 0xFC, 0x00, + 0xCC, 0xCC, 0x78, 0x30, 0xFC, 0x30, 0xFC, 0x30, + 0xF8, 0xCC, 0xCC, 0xFA, 0xC6, 0xCF, 0xC6, 0xC3, + 0x0E, 0x1B, 0x18, 0x3C, 0x18, 0x18, 0xD8, 0x70, + 0x1C, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, + 0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x00, 0x1C, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, + 0x00, 0x1C, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, + 0x00, 0xF8, 0x00, 0xB8, 0xCC, 0xCC, 0xCC, 0x00, + 0xFC, 0x00, 0xCC, 0xEC, 0xFC, 0xDC, 0xCC, 0x00, + 0x3C, 0x6C, 0x6C, 0x3E, 0x00, 0x7E, 0x00, 0x00, + 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x7C, 0x00, 0x00, + 0x18, 0x00, 0x18, 0x18, 0x30, 0x66, 0x3C, 0x00, + 0x00, 0x00, 0x00, 0xFC, 0xC0, 0xC0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFC, 0x0C, 0x0C, 0x00, 0x00, + 0xC6, 0xCC, 0xD8, 0x36, 0x6B, 0xC2, 0x84, 0x0F, + 0xC3, 0xC6, 0xCC, 0xDB, 0x37, 0x6D, 0xCF, 0x03, + 0x18, 0x00, 0x18, 0x18, 0x3C, 0x3C, 0x18, 0x00, + 0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00, + 0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00, + 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, + 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, + 0xDB, 0xF6, 0xDB, 0x6F, 0xDB, 0x7E, 0xD7, 0xED, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, + 0x18, 0x18, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18, + 0x36, 0x36, 0x36, 0x36, 0xF6, 0x36, 0x36, 0x36, + 0x00, 0x00, 0x00, 0x00, 0xFE, 0x36, 0x36, 0x36, + 0x00, 0x00, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18, + 0x36, 0x36, 0xF6, 0x06, 0xF6, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x00, 0x00, 0xFE, 0x06, 0xF6, 0x36, 0x36, 0x36, + 0x36, 0x36, 0xF6, 0x06, 0xFE, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0xFE, 0x00, 0x00, 0x00, + 0x18, 0x18, 0xF8, 0x18, 0xF8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, + 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x37, 0x30, 0x3F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3F, 0x30, 0x37, 0x36, 0x36, 0x36, + 0x36, 0x36, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, + 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, + 0x36, 0x36, 0xF7, 0x00, 0xF7, 0x36, 0x36, 0x36, + 0x18, 0x18, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0xFF, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x3F, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x3F, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0xFF, 0x36, 0x36, 0x36, + 0x18, 0x18, 0xFF, 0x18, 0xFF, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0xF8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, + 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x76, 0xDC, 0xC8, 0xDC, 0x76, 0x00, + 0x00, 0x78, 0xCC, 0xF8, 0xCC, 0xF8, 0xC0, 0xC0, + 0x00, 0xFC, 0xCC, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, + 0x00, 0x00, 0xFE, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, + 0xFC, 0xCC, 0x60, 0x30, 0x60, 0xCC, 0xFC, 0x00, + 0x00, 0x00, 0x7E, 0xD8, 0xD8, 0xD8, 0x70, 0x00, + 0x00, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0xC0, + 0x00, 0x76, 0xDC, 0x18, 0x18, 0x18, 0x18, 0x00, + 0xFC, 0x30, 0x78, 0xCC, 0xCC, 0x78, 0x30, 0xFC, + 0x38, 0x6C, 0xC6, 0xFE, 0xC6, 0x6C, 0x38, 0x00, + 0x38, 0x6C, 0xC6, 0xC6, 0x6C, 0x6C, 0xEE, 0x00, + 0x1C, 0x30, 0x18, 0x7C, 0xCC, 0xCC, 0x78, 0x00, + 0x00, 0x00, 0x7E, 0xDB, 0xDB, 0x7E, 0x00, 0x00, + 0x06, 0x0C, 0x7E, 0xDB, 0xDB, 0x7E, 0x60, 0xC0, + 0x38, 0x60, 0xC0, 0xF8, 0xC0, 0x60, 0x38, 0x00, + 0x78, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, + 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, + 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x7E, 0x00, + 0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0xFC, 0x00, + 0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0xFC, 0x00, + 0x0E, 0x1B, 0x1B, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0x70, + 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00, + 0x00, 0x76, 0xDC, 0x00, 0x76, 0xDC, 0x00, 0x00, + 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x0F, 0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x3C, 0x1C, + 0x58, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, + 0x70, 0x98, 0x30, 0x60, 0xF8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/mobius/src/drivers/winmgr/fontbfd.cpp b/mobius/src/drivers/winmgr/fontbfd.cpp new file mode 100644 index 0000000..0fc8d95 --- /dev/null +++ b/mobius/src/drivers/winmgr/fontbfd.cpp @@ -0,0 +1,352 @@ +/***************************************************************************** +load BDF bitmap font into memory +These fonts used to be used (still are?) by X windows, +and are usually freely available. + +xxx - bdfLoadFont() always allocates space for 256 characters +*****************************************************************************/ +#include /* strlen(), memcmp(), memset() */ +#include /* atoi() */ +/* FILE, printf(), sscanf(), fopen(), fgets(), fclose() */ +#include +#include +#include +#include + +class BfdFont : public IFont +{ +protected: + int Wd, Ht; + int First, Last; + byte *Spacings, *Bitmaps; + + int loadHelp(IStream *Infile, char *Line); + +public: + BfdFont(); + virtual ~BfdFont(); + int load(const wchar_t* FileName); + + STDMETHOD(DrawText)(ISurface* pSurf, int x, int y, const wchar_t* String, + pixel_t pixColour); + STDMETHOD(GetTextExtent)(const wchar_t* String, point_t* size); +}; + +IFont* CreateFontBfd(const wchar_t* lpszFileName) +{ + BfdFont* pFont = new BfdFont; + if (pFont && pFont->load(lpszFileName) == 0) + return pFont; + else + { + delete pFont; + return NULL; + } +} + +#define MAX_LINE_LEN 256 +#define MAX_ENC 2048 +#define MAX_WD 5 +#define MAX_HT 40 +/***************************************************************************** +*****************************************************************************/ +BfdFont::BfdFont() +{ + Wd=0; + Ht=0; + First=0; + Last=0; + Spacings=NULL; + Bitmaps=NULL; +} +/***************************************************************************** +*****************************************************************************/ +BfdFont::~BfdFont(void) +{ + Wd=0; + Ht=0; + First=0; + Last=0; + if (Spacings != NULL) + { + delete[] Spacings; + Spacings=NULL; + } + + if (Bitmaps != NULL) + { + delete[] Bitmaps; + Bitmaps=NULL; + } +} + +char* fgets(char* buf, int max, IStream* strm) +{ + char ch, *start = buf; + + while (true) + { + if (FAILED(IStream_Read(strm, &ch, 1))) + return NULL; + + if (ch != '\n') + *buf++ = ch; + else + break; + } + + return start; +} + +void fclose(IStream* strm) +{ + IUnknown_Release(strm); +} + +IStream *_wfopen(const wchar_t *filename, const wchar_t *mode) +{ + IUnknown* ptr = sysOpen(filename); + IStream* ret; + + if (ptr) + { + ret = NULL; + IUnknown_QueryInterface(ptr, IID_IStream, (void**) &ret); + IUnknown_Release(ptr); + return ret; + } + else + return NULL; +} + +/***************************************************************************** +*****************************************************************************/ +static int _expect(IStream* Infile, char *Line, char *Target, int Quiet) +{ unsigned Len; + + Len = strlen(Target); + do + { + if (fgets(Line, MAX_LINE_LEN, Infile) == NULL) + { + fclose(Infile); + if(!Quiet) + wprintf(L"did not find %s line\n", Target); + return(-1); + } + } while(memcmp(Line, Target, Len) != 0); + + return 0; +} +/***************************************************************************** +*****************************************************************************/ +int Encoding=-1; +int FontYOff; + +int BfdFont::loadHelp(IStream *Infile, char *Line) +{ + int CharWd, CharHt, CharXOff, CharYOff;//, Encoding; + + // Encoding=atoi(Line + 9); + Encoding++; + if(Encoding > MAX_ENC) + { + wprintf(L"bad ENCODING (%u)\n", Encoding); + return(-1); + } + + if(Encoding < First) + First=Encoding; + if(Encoding > Last) + Last=Encoding; +/* look for BBX, which gives the proportional spacing value (char width) */ + if(_expect(Infile, Line, "BBX", 0) != 0) + return(-1); + sscanf(Line + 4, "%d %d %d %d", + &CharWd, &CharHt, &CharXOff, &CharYOff); + Spacings[Encoding]=CharWd; +/* look for BITMAP */ + if(_expect(Infile, Line, "BITMAP", 0) != 0) + return(-1); +/* start reading the actual raster data */ + { + byte CharData[MAX_HT][MAX_WD], *Ptr; + int Row, Col, YPos; + + memset(CharData, 0, sizeof(CharData)); + for(Row=0; Row < MAX_HT; Row++) + { + memset(Line, 0, MAX_LINE_LEN); + if(fgets(Line, MAX_LINE_LEN, Infile) == NULL) + return(-1); +/* exit this loop when ENDCHAR seen */ + if(memcmp(Line, "ENDCHAR", 7) == 0) + break; +/* read char from top to bottom */ + YPos=Ht - CharHt + + FontYOff - CharYOff + Row; + if(YPos < 0 || YPos >= MAX_HT) + { + wprintf(L"warning: top or bottom edge " + L"of char %d might be clipped (YPos " + L"== %d)\n", Encoding, YPos); + continue; + } + + for(Col=0; Col < MAX_WD; Col++) + { + byte Temp; + + if(sscanf(Line + Col * 2, "%2x", &Temp) != 1) + break; + CharData[YPos][Col]=Temp; }} +/* store at Bitmaps */ + Ptr=Bitmaps + Wd * Ht * Encoding; + for(Row=0; Row < Ht; Row++) + { for(Col=0; Col < Wd; Col++) + Ptr[Col]=CharData[Row][Col]; + Ptr += Wd; }} + return(0); +} + +/***************************************************************************** +*****************************************************************************/ +int BfdFont::load(const wchar_t* FileName) +{ + char Line[MAX_LINE_LEN]; + IStream* Infile; +// int FontYOff; + + wprintf(L"bdfLoadFont '%s': ", FileName); +/* open file */ + Infile=_wfopen(FileName, L"r"); + if(Infile == NULL) + { wprintf(L"can't open file\n"); + return(-1); } +/* look for STARTFONT */ + if(_expect(Infile, Line, "STARTFONT", 0) != 0) + { fclose(Infile); + return(-1); } +/* OK, it's a BDF font file: look for FONTBOUNDINGBOX */ + if(_expect(Infile, Line, "FONTBOUNDINGBOX", 0) != 0) + { fclose(Infile); + return(-1); } + + { int FontWd, FontXOff; + + sscanf(Line + 16, "%d %d %d %d", + &FontWd, &Ht, &FontXOff, &FontYOff); +/* use FONTBOUNDINGBOX to set Wd (in range 1-MAX_WD bytes), +Ht (in range 1-MAX_HT rows), and FontYOff */ + Wd=(FontWd + 7) >> 3; + if(Wd < 1 || Wd > MAX_WD) + { wprintf(L"bad Wd (%u)\n", Wd); + fclose(Infile); + return(-1); } + if(Ht < 1 || Ht > MAX_HT) + { wprintf(L"bad Ht (%u)\n", Ht); + fclose(Infile); + return(-1); } + wprintf(L"Wd=%u, Ht=%u, ", + Wd, Ht); + } +/* look for "CHARS ". You need the space, +or it will trip on CHARSET_REGISTRY, etc. */ + if(_expect(Infile, Line, "CHARS ", 0) != 0) + { fclose(Infile); + return(-1); } +/* CHARS sets size of Spacings and Bitmaps arrays */ + { unsigned NumChars; + + NumChars=MAX_ENC + 1;//atoi(Line + 6); xxx + Spacings=(byte *)malloc(NumChars); + if(Spacings == NULL) +ERR_MEM: { wprintf(L"out of memory\n"); + fclose(Infile); + return(-1); } + Bitmaps=(byte *)malloc(NumChars * Ht * Wd); + if(Bitmaps == NULL) + { free(Spacings); + goto ERR_MEM; } + wprintf(L"%u characters, ", NumChars); } +/* got all the info we need, move on to bitmap data */ + First=MAX_ENC;/* xxx */ + Last=0; /* xxx */ +/* look for ENCODING */ + { int Quiet=0, Err=-1; + +Encoding=31; + while(_expect(Infile, Line, "ENCODING", Quiet) == 0) + { Err=loadHelp(Infile, Line); + if(Err != 0) + break; + Quiet=1; } +First=0; /* xxx */ + fclose(Infile); + if(Err != 0) + { free(Spacings); + free(Bitmaps); } + else wprintf(L"OK\n"); + return(Err); }} + +HRESULT BfdFont::DrawText(ISurface* pSurf, int x, int y, const wchar_t* String, pixel_t pixColour) +{ + bmp1 SrcBmp; + rect Clip; + char Char; + + for(Char=*String++; Char != '\0'; Char=*String++) +/* valid Char? */ + { + if(Char < TheFont.First || Char > TheFont.Last) + continue; + Char -= TheFont.First; + if(TheFont.Spacings == NULL) +/* monospaced font: make each char 8 pixels * character cell width */ + Clip.Wd=TheFont.Wd * 8; + else + Clip.Wd=TheFont.Spacings[Char]; +/* clip it */ + Clip.Ht=TheFont.Ht; + Clip.DstX=this->CsrX; + Clip.DstY=this->CsrY; + if(!taliWinClip(&(Clip.SrcX), &(Clip.SrcY), + &(Clip.DstX), &(Clip.DstY), + &(Clip.Wd), &(Clip.Ht), this->Wd, this->Ht)) + continue; +/* create monochrome source bitmap */ + SrcBmp.Wd=TheFont.Wd * 8; + SrcBmp.Ht=Clip.Ht; + SrcBmp.Raster=TheFont.Bitmaps + TheFont.Wd * + TheFont.Ht * Char; +/* blit it */ + this->Bitmap->blit1(Clip, SrcBmp); +/* advance cursor. ONE pixel between chars */ + this->CsrX=this->CsrX + Clip.Wd + 1; + } +/* prevent delete[]/free() by SrcBmp destructor */ + SrcBmp.Raster=NULL; +} + +/***************************************************************************** +*****************************************************************************/ +HRESULT BfdFont::GetTextExtent(const wchar_t *String, point_t* size) +{ + unsigned RetVal; + + /* monospaced font */ + if(Spacings == NULL) + return Point(strlen(String) * Wd * 8, Ht); + + /* proportional-spaced font */ + for(RetVal=0; *String != '\0'; String++) + { + if(*String < First || *String > Last) + continue; /* undefined chars have zero width */ + RetVal += Spacings[*String - First] + 1; + } + + size->x = RetVal; + size->y = Ht; + return S_OK; +} diff --git a/mobius/src/drivers/winmgr/gfxcons.cpp b/mobius/src/drivers/winmgr/gfxcons.cpp new file mode 100644 index 0000000..e1ca46a --- /dev/null +++ b/mobius/src/drivers/winmgr/gfxcons.cpp @@ -0,0 +1,97 @@ +#include "gfxcons.h" +#include +#include +#include + +/***************************************************************************** + * CGfxConsole * + *****************************************************************************/ + +HRESULT ConsoleWndProc(IWindow* wnd, dword message, dword params) +{ + ISurface* surf; + rectangle_t rect; + + switch (message) + { + case WM_PAINT: + surf = wnd->GetSurface(); + surf->GetClipRect(&rect); + surf->FillRect(&rect, surf->ColourMatch(0)); + surf->Release(); + } + + return wnd->DefWndProc(message, params); +} + +CGfxConsole::CGfxConsole() +{ + IWindowServer* srv; + windowdef_t def; + + m_width = 35; + m_height = 22; + + def.size = sizeof(def); + def.flags = WIN_TITLE | WIN_WIDTH | WIN_HEIGHT | WIN_WNDPROC; + def.title = L"Console"; + def.width = 8 * m_width + 8; + def.height = 8 * m_height + 8 + 4 + 12; + def.wndproc = ConsoleWndProc; + + srv = OpenServer(); + if (srv) + { + m_font = srv->GetFont(0); + m_wnd = srv->CreateWindow(&def); + m_surf = m_wnd->GetSurface(); + srv->Release(); + } + + Clear(); +} + +CGfxConsole::~CGfxConsole() +{ + m_wnd->Release(); + m_surf->Release(); + m_font->Release(); +} + +void CGfxConsole::UpdateCursor() +{ + /*IMsgQueue* queue = (IMsgQueue*) thrGetTls(); + msg_t msg; + HRESULT (*wndproc) (IWindow*, dword, dword); + + if (queue && SUCCEEDED(queue->PeekMessage(&msg, true))) + { + wndproc = (HRESULT (*) (IWindow*, dword, dword)) msg.wnd->GetAttrib(ATTR_WNDPROC); + + if (wndproc) + wndproc(msg.wnd, msg.message, msg.params); + else + msg.wnd->DefWndProc(msg.message, msg.params); + }*/ +} + +void CGfxConsole::Output(int x, int y, wchar_t c, word attrib) +{ + wchar_t str[2] = { c, '\0' }; + m_surf->FillRect(rectangle_t(x * 8, y * 8, x * 8 + 8, y * 8 + 8), attrib >> 12); + m_font->DrawText(m_surf, x * 8, y * 8, str, (attrib >> 8) & 0xff); +} + +void CGfxConsole::Clear() +{ + m_surf->FillRect(rectangle_t(0, 0, m_width * 8, m_height * 8), m_attrib >> 12); + m_con_x = m_con_y = 0; + UpdateCursor(); +} + +void CGfxConsole::Scroll(int dx, int dy) +{ + //i386_llmemcpy(0xa0000, 0xa0000 - dy * m_width * 64, 64 * m_width * (m_height + dy)); + //m_surf->FillRect(rectangle_t(0, (m_height - 1) * 8, m_width * 8, m_height * 8), m_attrib >> 12); + Clear(); +} \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/gfxcons.h b/mobius/src/drivers/winmgr/gfxcons.h new file mode 100644 index 0000000..61a7443 --- /dev/null +++ b/mobius/src/drivers/winmgr/gfxcons.h @@ -0,0 +1,24 @@ +#ifndef __GFXCONS_H +#define __GFXCONS_H + +#include "console.h" +#include + +class CGfxConsole : public CConsole +{ +protected: + IFont* m_font; + ISurface* m_surf; + IWindow* m_wnd; + + virtual ~CGfxConsole(); + virtual void UpdateCursor(); + virtual void Output(int x, int y, wchar_t c, word attrib); + virtual void Clear(); + virtual void Scroll(int dx, int dy); + +public: + CGfxConsole(); +}; + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/main.cpp b/mobius/src/drivers/winmgr/main.cpp new file mode 100644 index 0000000..b1fbf02 --- /dev/null +++ b/mobius/src/drivers/winmgr/main.cpp @@ -0,0 +1,14 @@ +#include "WindowServer.h" +#include "gfxcons.h" + +extern "C" bool STDCALL DllMain(dword hDllHandle, dword dwReason, void* lpreserved) +{ + return true; +} + +extern "C" bool __declspec(dllexport) drvInit() +{ + sysExtRegisterDevice(L"aaa", new CWindowServer); + //sysExtRegisterDevice(L"screen", new CGfxConsole); + return true; +} \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/palette.h b/mobius/src/drivers/winmgr/palette.h new file mode 100644 index 0000000..0626b8a --- /dev/null +++ b/mobius/src/drivers/winmgr/palette.h @@ -0,0 +1,259 @@ +static unsigned char palette[256 * 3] = +{ + 0, 0, 0, + 128, 0, 0, + 0, 128, 0, + 128, 128, 0, + 0, 0, 128, + 128, 0, 128, + 0, 128, 128, + 128, 128, 128, + 0, 0, 0, + 51, 0, 0, + 102, 0, 0, + 153, 0, 0, + 204, 0, 0, + 255, 0, 0, + 0, 51, 0, + 51, 51, 0, + 102, 51, 0, + 153, 51, 0, + 204, 51, 0, + 255, 51, 0, + 0, 102, 0, + 51, 102, 0, + 102, 102, 0, + 153, 102, 0, + 204, 102, 0, + 255, 102, 0, + 0, 153, 0, + 51, 153, 0, + 102, 153, 0, + 153, 153, 0, + 204, 153, 0, + 255, 153, 0, + 0, 204, 0, + 51, 204, 0, + 102, 204, 0, + 153, 204, 0, + 204, 204, 0, + 255, 204, 0, + 0, 255, 0, + 51, 255, 0, + 102, 255, 0, + 153, 255, 0, + 204, 255, 0, + 255, 255, 0, + 0, 0, 51, + 51, 0, 51, + 102, 0, 51, + 153, 0, 51, + 204, 0, 51, + 255, 0, 51, + 0, 51, 51, + 51, 51, 51, + 102, 51, 51, + 153, 51, 51, + 204, 51, 51, + 255, 51, 51, + 0, 102, 51, + 51, 102, 51, + 102, 102, 51, + 153, 102, 51, + 204, 102, 51, + 255, 102, 51, + 0, 153, 51, + 51, 153, 51, + 102, 153, 51, + 153, 153, 51, + 204, 153, 51, + 255, 153, 51, + 0, 204, 51, + 51, 204, 51, + 102, 204, 51, + 153, 204, 51, + 204, 204, 51, + 255, 204, 51, + 0, 255, 51, + 51, 255, 51, + 102, 255, 51, + 153, 255, 51, + 204, 255, 51, + 255, 255, 51, + 0, 0, 102, + 51, 0, 102, + 102, 0, 102, + 153, 0, 102, + 204, 0, 102, + 255, 0, 102, + 0, 51, 102, + 51, 51, 102, + 102, 51, 102, + 153, 51, 102, + 204, 51, 102, + 255, 51, 102, + 0, 102, 102, + 51, 102, 102, + 102, 102, 102, + 153, 102, 102, + 204, 102, 102, + 255, 102, 102, + 0, 153, 102, + 51, 153, 102, + 102, 153, 102, + 153, 153, 102, + 204, 153, 102, + 255, 153, 102, + 0, 204, 102, + 51, 204, 102, + 102, 204, 102, + 153, 204, 102, + 204, 204, 102, + 255, 204, 102, + 0, 255, 102, + 51, 255, 102, + 102, 255, 102, + 153, 255, 102, + 204, 255, 102, + 255, 255, 102, + 0, 0, 153, + 51, 0, 153, + 102, 0, 153, + 153, 0, 153, + 204, 0, 153, + 255, 0, 153, + 0, 51, 153, + 51, 51, 153, + 102, 51, 153, + 153, 51, 153, + 204, 51, 153, + 255, 51, 153, + 0, 102, 153, + 51, 102, 153, + 102, 102, 153, + 153, 102, 153, + 204, 102, 153, + 255, 102, 153, + 0, 153, 153, + 51, 153, 153, + 102, 153, 153, + 153, 153, 153, + 204, 153, 153, + 255, 153, 153, + 0, 204, 153, + 51, 204, 153, + 102, 204, 153, + 153, 204, 153, + 204, 204, 153, + 255, 204, 153, + 0, 255, 153, + 51, 255, 153, + 102, 255, 153, + 153, 255, 153, + 204, 255, 153, + 255, 255, 153, + 0, 0, 204, + 51, 0, 204, + 102, 0, 204, + 153, 0, 204, + 204, 0, 204, + 255, 0, 204, + 0, 51, 204, + 51, 51, 204, + 102, 51, 204, + 153, 51, 204, + 204, 51, 204, + 255, 51, 204, + 0, 102, 204, + 51, 102, 204, + 102, 102, 204, + 153, 102, 204, + 204, 102, 204, + 255, 102, 204, + 0, 153, 204, + 51, 153, 204, + 102, 153, 204, + 153, 153, 204, + 204, 153, 204, + 255, 153, 204, + 0, 204, 204, + 51, 204, 204, + 102, 204, 204, + 153, 204, 204, + 204, 204, 204, + 255, 204, 204, + 0, 255, 204, + 51, 255, 204, + 102, 255, 204, + 153, 255, 204, + 204, 255, 204, + 255, 255, 204, + 0, 0, 255, + 51, 0, 255, + 102, 0, 255, + 153, 0, 255, + 204, 0, 255, + 255, 0, 255, + 0, 51, 255, + 51, 51, 255, + 102, 51, 255, + 153, 51, 255, + 204, 51, 255, + 255, 51, 255, + 0, 102, 255, + 51, 102, 255, + 102, 102, 255, + 153, 102, 255, + 204, 102, 255, + 255, 102, 255, + 0, 153, 255, + 51, 153, 255, + 102, 153, 255, + 153, 153, 255, + 204, 153, 255, + 255, 153, 255, + 0, 204, 255, + 51, 204, 255, + 102, 204, 255, + 153, 204, 255, + 204, 204, 255, + 255, 204, 255, + 0, 255, 255, + 51, 255, 255, + 102, 255, 255, + 153, 255, 255, + 204, 255, 255, + 255, 255, 255, + 61, 68, 84, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 192, 192, 192, + 255, 0, 0, + 0, 255, 0, + 255, 255, 0, + 0, 0, 255, + 255, 0, 255, + 0, 255, 255, + 255, 255, 255, +}; diff --git a/mobius/src/drivers/winmgr/res/84.fnt b/mobius/src/drivers/winmgr/res/84.fnt new file mode 100644 index 0000000..19cdc88 --- /dev/null +++ b/mobius/src/drivers/winmgr/res/84.fnt Binary files differ diff --git a/mobius/src/drivers/winmgr/res/85.fnt b/mobius/src/drivers/winmgr/res/85.fnt new file mode 100644 index 0000000..b12a1f6 --- /dev/null +++ b/mobius/src/drivers/winmgr/res/85.fnt Binary files differ diff --git a/mobius/src/drivers/winmgr/res/86.fnt b/mobius/src/drivers/winmgr/res/86.fnt new file mode 100644 index 0000000..28c6401 --- /dev/null +++ b/mobius/src/drivers/winmgr/res/86.fnt Binary files differ diff --git a/mobius/src/drivers/winmgr/res/87.fnt b/mobius/src/drivers/winmgr/res/87.fnt new file mode 100644 index 0000000..a1c802e --- /dev/null +++ b/mobius/src/drivers/winmgr/res/87.fnt Binary files differ diff --git a/mobius/src/drivers/winmgr/res/88.fnt b/mobius/src/drivers/winmgr/res/88.fnt new file mode 100644 index 0000000..b1ea9c3 --- /dev/null +++ b/mobius/src/drivers/winmgr/res/88.fnt Binary files differ diff --git a/mobius/src/drivers/winmgr/res/89.fnt b/mobius/src/drivers/winmgr/res/89.fnt new file mode 100644 index 0000000..f012b0d --- /dev/null +++ b/mobius/src/drivers/winmgr/res/89.fnt Binary files differ diff --git a/mobius/src/drivers/winmgr/resource.h b/mobius/src/drivers/winmgr/resource.h new file mode 100644 index 0000000..288e83f --- /dev/null +++ b/mobius/src/drivers/winmgr/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by winmgr.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/mobius/src/drivers/winmgr/surface.cpp b/mobius/src/drivers/winmgr/surface.cpp new file mode 100644 index 0000000..5048da8 --- /dev/null +++ b/mobius/src/drivers/winmgr/surface.cpp @@ -0,0 +1,92 @@ +#include +#include "surface.h" + +HRESULT Surface::QueryInterface(REFIID iid, void ** ppvObject) +{ + if (InlineIsEqualGUID(iid, IID_IUnknown) || + InlineIsEqualGUID(iid, IID_ISurface)) + { + AddRef(); + *ppvObject = (ISurface*) this; + return S_OK; + } + else + return E_FAIL; +} + +HRESULT Surface::Blt(ISurface* pSrc, int x, int y, int nWidth, + int nHeight, int nSrcX, int nSrcY, pixel_t pixTrans) +{ + /*SurfaceDesc srcDesc; + HRESULT hr; + int line, nBytesPerLine; + + if (FAILED(hr = pSrc->Lock(&srcDesc))) + return hr; + + if (srcDesc.nBpp != fBpp) + { + pSrc->Unlock(); + return E_NOTIMPLEMENTED; + } + + nBytesPerLine = fBpp / 8; + for (line = nSrcY; line < nSrcY + nHeight; line++) + memcpy(pBuf + (nBytesPerLine * (fWidth * (line + y) + x)), + (BYTE*) srcDesc.pMemory + srcDesc.nPitch * line + nSrcX * nBytesPerLine, + nWidth * nBytesPerLine); + + pSrc->Unlock(); + return S_OK;*/ + + int ax, ay; + pixel_t pix; + + for (ax = 0; ax < nWidth; ax++) + for (ay = 0; ay < nHeight; ay++) + if (ax + x < fWidth && + ay + y < fHeight) + { + pix = pSrc->GetPixel(nSrcX + ax, nSrcY + ay); + if (pix != pixTrans) + SetPixel(ax + x, ay + y, pix); + } + + return S_OK; +} + +DrawMode Surface::SetDrawMode(DrawMode mode) +{ + DrawMode oldMode = fDrawMode; + fDrawMode = mode; + return oldMode; +} + +HRESULT Surface::FillRect(const rectangle_t* rect, pixel_t pix) +{ + int x, y; + + for (y = max(0, rect->top); y < min(fHeight, rect->bottom); y++) + for (x = max(0, rect->left); x < min(fWidth, rect->right); x++) + SetPixel(x, y, pix); + + return S_OK; +} + +HRESULT Surface::Rect3d(const rectangle_t* rect, pixel_t pixTop, pixel_t pixBottom, + int nWidth) +{ + FillRect(rectangle_t(rect->left, rect->top, rect->right, rect->top + nWidth), pixTop); + FillRect(rectangle_t(rect->left, rect->top + nWidth, rect->left + nWidth, rect->bottom), pixTop); + FillRect(rectangle_t(rect->right - nWidth, rect->top + nWidth, rect->right, rect->bottom), pixBottom); + FillRect(rectangle_t(rect->left + nWidth, rect->bottom - nWidth, rect->right - nWidth, rect->bottom), pixBottom); + return S_OK; +} + +HRESULT Surface::GetClipRect(rectangle_t* rect) +{ + rect->left = rect->top = 0; + rect->right = fWidth; + rect->bottom = fHeight; + return S_OK; +} \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/surface.h b/mobius/src/drivers/winmgr/surface.h new file mode 100644 index 0000000..adc6026 --- /dev/null +++ b/mobius/src/drivers/winmgr/surface.h @@ -0,0 +1,29 @@ +#ifndef __SURFACE_INT_H +#define __SURFACE_INT_H + +#include + +class Surface : public ISurface +{ +protected: + int fWidth, fHeight, fBpp; + DrawMode fDrawMode; + +public: + STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject); + + STDMETHOD_(DrawMode, SetDrawMode)(DrawMode mode); + STDMETHOD(FillRect)(const rectangle_t* rect, pixel_t pix); + STDMETHOD(Rect3d)(const rectangle_t* rect, pixel_t pixTop, + pixel_t pixBottom, int nWidth); + STDMETHOD(Rect)(const rectangle_t* rect, pixel_t pix, int nWidth) + { return Rect3d(rect, pix, pix, nWidth); } + STDMETHOD(Blt)(ISurface* pSrc, int x, int y, int nWidth, + int nHeight, int nSrcX, int nSrcY, pixel_t pixTrans); + + STDMETHOD(AttachProcess)() + { return S_OK; } + STDMETHOD(GetClipRect)(rectangle_t* rect); +}; + +#endif \ No newline at end of file diff --git a/mobius/src/drivers/winmgr/trio.c b/mobius/src/drivers/winmgr/trio.c new file mode 100644 index 0000000..d7345c6 --- /dev/null +++ b/mobius/src/drivers/winmgr/trio.c @@ -0,0 +1,1863 @@ +/* + * Trio64 driver for x86. Most of this code originates from Amiga Cybervision + * driver, and some from the Amiga S3 driver, but has been modified to work + * in a x86/PCI environment, and after PC BIOS has trashed several registers + * Cybervision apparently doesn't need to touch. Slight code cleanup has + * been done, and a rewrite of the PLL value calculation routine. + * Initially I wanted to do a platform-independent version of the Cybervision + * driver, but the debugging process got too complicated (and I don't have + * an Amiga to test it), so I ended up with a x86-only version. + * + * So far, acceleration works only through programmed i/o, which means no + * memory mapping of acceleration engine registers, which means no support + * for userland graphics acceleration, which actually sucks. As far as my + * documentation tells me, Trio supports mmio in a fixed memory area (from + * 0xA8000 to 0xAFFFF), but apparently (reading from the sources) the + * Cybervision implementation behaves differently. Anyone willing to + * clarify this? + * + * Version: 0.1 (initial release), released 1999-09-17 + * BUGS/TODO: + * - no mmaping of acceleration registers + * - poor support for 16 bpp, no support for 24bpp + * - trio32 support + * - modularization + * - virge support (and rename the driver ;-) ? + * - hwcursor support? + * - more options? + * - where does that white bg come from in the beginning? + * I have a hunch fbcon does something I'm not prepared for... + * + * -- Hannu Mallat + */ + +/*#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include