Merged changes from branch build_system_redesign at revision 14573.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14574 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2005-10-29 16:27:43 +00:00
parent 5412b02d50
commit 338b8dc301
1836 changed files with 114718 additions and 14057 deletions
+55
View File
@@ -0,0 +1,55 @@
#ifndef HAIKU_BUILD_COMPATIBILITY_H
#define HAIKU_BUILD_COMPATIBILITY_H
typedef unsigned long haiku_build_addr_t;
#define addr_t haiku_build_addr_t
#include <Errors.h>
#include <sys/types.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
// Is kernel-only under Linux.
extern size_t strlcpy(char *dest, const char *source, size_t length);
// BeOS only
extern ssize_t read_pos(int fd, off_t pos, void *buffer, size_t count);
extern ssize_t write_pos(int fd, off_t pos, const void *buffer,size_t count);
// There's no O_NOTRAVERSE under Linux, but there's a O_NOFOLLOW, which
// means something different (open() fails when the file is a symlink), but
// we can abuse this flag for our purposes (we filter it in libroot).
#ifndef O_NOTRAVERSE
#ifdef O_NOFOLLOW
#define O_NOTRAVERSE O_NOFOLLOW
#else
#define O_NOTRAVERSE 0
#endif
#endif
#ifndef S_IUMSK
#define S_IUMSK ALLPERMS
#endif
// remap strerror()
extern char *_haiku_build_strerror(int errnum);
#ifndef BUILDING_HAIKU_ERROR_MAPPER
#undef strerror
#define strerror(errnum) _haiku_build_strerror(errnum)
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif // HAIKU_BUILD_COMPATIBILITY_H
+17
View File
@@ -0,0 +1,17 @@
/*
* Master include file for the App Kit.
*
*/
#include <AppDefs.h>
#include <Application.h>
#include <Clipboard.h>
#include <Handler.h>
#include <Invoker.h>
#include <Looper.h>
#include <Message.h>
#include <MessageFilter.h>
#include <MessageQueue.h>
#include <MessageRunner.h>
#include <Messenger.h>
#include <PropertyInfo.h>
#include <Roster.h>
+15
View File
@@ -0,0 +1,15 @@
/*
* All-in-one include file for the entire system.
*
*/
#include <AppKit.h>
#include <DeviceKit.h>
#include <GameKit.h>
#include <InterfaceKit.h>
#include <KernelKit.h>
#include <MediaKit.h>
#include <MidiKit.h>
#include <NetKit.h>
#include <StorageKit.h>
#include <SupportKit.h>
#include <TranslationKit.h>
+387
View File
@@ -0,0 +1,387 @@
/******************************************************************************
/
/ File: BeBuild.h
/
/ Description: Import/export macros
/
/ Copyright 1993-98, Be Incorporated
/
*******************************************************************************/
#ifndef _BE_BUILD_H
#define _BE_BUILD_H
#define B_BEOS_VERSION_4 0x0400
#define B_BEOS_VERSION_4_5 0x0450
#define B_BEOS_VERSION_5 0x0500
#define B_BEOS_VERSION B_BEOS_VERSION_5
#define B_BEOS_VERSION_MAUI B_BEOS_VERSION_5
#if defined(__POWERPC__)
// the PowerPC build is using GCC now (BeOS R5 used to use the Metrowerks
// compiler), so it is not compatible to any BeOS version on that platform
// before. However, that wouldn't rule out source compatibility, which
// we do here (for now).
#define _PR2_COMPATIBLE_ 0
#define _PR3_COMPATIBLE_ 0
#define _R4_COMPATIBLE_ 0
#define _R4_5_COMPATIBLE_ 0
#elif defined(__INTEL__)
#define _PR2_COMPATIBLE_ 0
#define _PR3_COMPATIBLE_ 0
#define _R4_COMPATIBLE_ 1
#define _R4_5_COMPATIBLE_ 1
#else
# error Configure BeBuild.h for your platform
#endif
#if __MWERKS__
# define _UNUSED(x)
# define _PACKED
#endif
#if __GNUC__
# define _UNUSED(x) x
# define _PACKED __attribute__((packed))
#endif
#if defined(__INTEL__) || defined(__POWERPC__)
// This is the standard import/export definitions used for
// the ELF binary format - this should be usable by all flavors
// of OpenBeOS.
# define _EXPORT
# define _IMPORT
# define _IMPEXP_KERNEL
# define _IMPEXP_GL
# define _IMPEXP_ROOT
# define _IMPEXP_NET
# define _IMPEXP_NETDEV
# define _IMPEXP_ATALK
# define _IMPEXP_BE
# define _IMPEXP_TRACKER
# define _IMPEXP_MAIL
# define _IMPEXP_DEVICE
# define _IMPEXP_MEDIA
# define _IMPEXP_MIDI
# define _IMPEXP_MIDI2
# define _IMPEXP_GAME
# define _IMPEXP_GSOUND
# define _IMPEXP_TRANSLATION
# define _IMPEXP_TEXTENCODING
# define _IMPEXP_INPUT
#endif
#ifdef __cplusplus
/* cpp kit */
/* -- <typeinfo> */
class _IMPEXP_ROOT bad_cast;
class _IMPEXP_ROOT bad_typeid;
class _IMPEXP_ROOT type_info;
/* -- <exception> */
class _IMPEXP_ROOT exception;
class _IMPEXP_ROOT bad_exception;
/* -- <new.h> */
class _IMPEXP_ROOT bad_alloc;
/* -- <mexcept.h> */
class _IMPEXP_ROOT logic_error;
class _IMPEXP_ROOT domain_error;
class _IMPEXP_ROOT invalid_argument;
class _IMPEXP_ROOT length_error;
class _IMPEXP_ROOT out_of_range;
class _IMPEXP_ROOT runtime_error;
class _IMPEXP_ROOT range_error;
class _IMPEXP_ROOT overflow_error;
/* support kit */
class _IMPEXP_BE BArchivable;
class _IMPEXP_BE BAutolock;
class _IMPEXP_BE BBlockCache;
class _IMPEXP_BE BBufferIO;
class _IMPEXP_BE BDataIO;
class _IMPEXP_BE BPositionIO;
class _IMPEXP_BE BMallocIO;
class _IMPEXP_BE BMemoryIO;
class _IMPEXP_BE BFlattenable;
class _IMPEXP_BE BList;
class _IMPEXP_BE BLocker;
class _IMPEXP_BE BStopWatch;
class _IMPEXP_BE BString;
class _IMPEXP_BE PointerList;
/*storage kit */
struct _IMPEXP_BE entry_ref;
struct _IMPEXP_BE node_ref;
class _IMPEXP_BE BAppFileInfo;
class _IMPEXP_BE BDirectory;
class _IMPEXP_BE BEntry;
class _IMPEXP_BE BFile;
class _IMPEXP_BE BRefFilter;
class _IMPEXP_BE BMimeType;
class _IMPEXP_BE BNode;
class _IMPEXP_BE BNodeInfo;
class _IMPEXP_BE BPath;
class _IMPEXP_BE BQuery;
class _IMPEXP_BE BResources;
class _IMPEXP_BE BResourceStrings;
class _IMPEXP_BE BStatable;
class _IMPEXP_BE BSymLink;
class _IMPEXP_BE BVolume;
class _IMPEXP_BE BVolumeRoster;
//class _IMPEXP_BE Partition;
//class _IMPEXP_BE Session;
//class _IMPEXP_BE Device;
//class _IMPEXP_BE DeviceList;
//class _IMPEXP_BE TNodeWalker;
//class _IMPEXP_BE TQueryWalker;
//class _IMPEXP_BE TVolWalker;
/*app kit */
struct _IMPEXP_BE app_info;
class _IMPEXP_BE BApplication;
class _IMPEXP_BE BClipboard;
class _IMPEXP_BE BHandler;
class _IMPEXP_BE BInvoker;
class _IMPEXP_BE BLooper;
class _IMPEXP_BE BMessage;
class _IMPEXP_BE BMessageFilter;
class _IMPEXP_BE BMessageQueue;
class _IMPEXP_BE BMessageRunner;
class _IMPEXP_BE BMessenger;
class _IMPEXP_BE BPropertyInfo;
class _IMPEXP_BE BRoster;
class _IMPEXP_BE _BAppServerLink_;
class _IMPEXP_BE _BSession_;
/*interface kit */
class _IMPEXP_BE BAlert;
class _IMPEXP_BE BBitmap;
class _IMPEXP_BE BBox;
class _IMPEXP_BE BButton;
class _IMPEXP_BE BChannelControl;
class _IMPEXP_BE BChannelSlider;
class _IMPEXP_BE BCheckBox;
class _IMPEXP_BE BColorControl;
class _IMPEXP_BE BControl;
class _IMPEXP_BE BDeskbar;
class _IMPEXP_BE BDragger;
class _IMPEXP_BE BFont;
class _IMPEXP_BE BInputDevice;
class _IMPEXP_BE BListItem;
class _IMPEXP_BE BListView;
class _IMPEXP_BE BStringItem;
class _IMPEXP_BE BMenu;
class _IMPEXP_BE BMenuBar;
class _IMPEXP_BE BMenuField;
class _IMPEXP_BE BMenuItem;
class _IMPEXP_BE BOptionControl;
class _IMPEXP_BE BOptionPopUp;
class _IMPEXP_BE BOutlineListView;
class _IMPEXP_BE BPicture;
class _IMPEXP_BE BPictureButton;
class _IMPEXP_BE BPoint;
class _IMPEXP_BE BPolygon;
class _IMPEXP_BE BPopUpMenu;
class _IMPEXP_BE BPrintJob;
class _IMPEXP_BE BRadioButton;
class _IMPEXP_BE BRect;
class _IMPEXP_BE BRegion;
class _IMPEXP_BE BScreen;
class _IMPEXP_BE BScrollBar;
class _IMPEXP_BE BScrollView;
class _IMPEXP_BE BSeparatorItem;
class _IMPEXP_BE BShelf;
class _IMPEXP_BE BShape;
class _IMPEXP_BE BShapeIterator;
class _IMPEXP_BE BSlider;
class _IMPEXP_BE BStatusBar;
class _IMPEXP_BE BStringView;
class _IMPEXP_BE BTab;
class _IMPEXP_BE BTabView;
class _IMPEXP_BE BTextControl;
class _IMPEXP_BE BTextView;
class _IMPEXP_BE BView;
class _IMPEXP_BE BWindow;
class _IMPEXP_BE _BTextInput_;
class _IMPEXP_BE _BMCMenuBar_;
class _IMPEXP_BE _BMCItem_;
class _IMPEXP_BE _BWidthBuffer_;
class _IMPEXP_BE BPrivateScreen;
/* net kit */
class _IMPEXP_NET _Allocator;
class _IMPEXP_NET _Transacter;
class _IMPEXP_NET _FastIPC;
/* netdev kit */
class _IMPEXP_NETDEV BNetPacket;
class _IMPEXP_NETDEV BStandardPacket;
class _IMPEXP_NETDEV BTimeoutHandler;
class _IMPEXP_NETDEV BPacketHandler;
class _IMPEXP_NETDEV BNetProtocol;
class _IMPEXP_NETDEV BNetDevice;
class _IMPEXP_NETDEV BCallBackHandler;
class _IMPEXP_NETDEV BNetConfig;
class _IMPEXP_NETDEV BIpDevice;
class _IMPEXP_NETDEV _NetBufList;
class _IMPEXP_NETDEV _BSem;
/* atalk kit */
class _IMPEXP_ATALK _PrinterNode;
/* tracker kit */
class _IMPEXP_TRACKER BFilePanel;
class _IMPEXP_TRACKER BRecentItemsList;
class _IMPEXP_TRACKER BRecentFilesList;
class _IMPEXP_TRACKER BRecentFoldersList;
class _IMPEXP_TRACKER BRecentAppsList;
/* mail kit */
class _IMPEXP_MAIL BMailMessage;
/* device kit */
class _IMPEXP_DEVICE BA2D;
class _IMPEXP_DEVICE BD2A;
class _IMPEXP_DEVICE BDigitalPort;
class _IMPEXP_DEVICE BJoystick;
class _IMPEXP_DEVICE BSerialPort;
/* media kit */
class _IMPEXP_MEDIA BDACRenderer;
class _IMPEXP_MEDIA BAudioFileStream;
class _IMPEXP_MEDIA BADCStream;
class _IMPEXP_MEDIA BDACStream;
class _IMPEXP_MEDIA BAbstractBufferStream;
class _IMPEXP_MEDIA BBufferStreamManager;
class _IMPEXP_MEDIA BBufferStream;
class _IMPEXP_MEDIA BSoundFile;
class _IMPEXP_MEDIA BSubscriber;
class _IMPEXP_MEDIA BMediaRoster;
class _IMPEXP_MEDIA BMediaNode;
class _IMPEXP_MEDIA BTimeSource;
class _IMPEXP_MEDIA BBufferProducer;
class _IMPEXP_MEDIA BBufferConsumer;
class _IMPEXP_MEDIA BBuffer;
class _IMPEXP_MEDIA BBufferGroup;
class _IMPEXP_MEDIA BControllable;
class _IMPEXP_MEDIA BFileInterface;
class _IMPEXP_MEDIA BEntityInterface;
class _IMPEXP_MEDIA BMediaAddOn;
class _IMPEXP_MEDIA BMediaTheme;
class _IMPEXP_MEDIA BParameterWeb;
class _IMPEXP_MEDIA BParameterGroup;
class _IMPEXP_MEDIA BParameter;
class _IMPEXP_MEDIA BNullParameter;
class _IMPEXP_MEDIA BDiscreteParameter;
class _IMPEXP_MEDIA BContinuousParameter;
class _IMPEXP_MEDIA BMediaFiles;
class _IMPEXP_MEDIA BSound;
class _IMPEXP_MEDIA BSoundCard;
class _IMPEXP_MEDIA BSoundPlayer;
class _IMPEXP_MEDIA BMediaFormats;
class _IMPEXP_MEDIA BTimedEventQueue;
//class _IMPEXP_MEDIA BEventIterator;
class _IMPEXP_MEDIA BMediaEventLooper;
class _IMPEXP_MEDIA BMediaFile;
class _IMPEXP_MEDIA BMediaTrack;
class _IMPEXP_MEDIA media_node;
struct _IMPEXP_MEDIA media_input;
struct _IMPEXP_MEDIA media_output;
struct _IMPEXP_MEDIA live_node_info;
struct _IMPEXP_MEDIA buffer_clone_info;
struct _IMPEXP_MEDIA media_source;
struct _IMPEXP_MEDIA media_destination;
struct _IMPEXP_MEDIA media_raw_audio_format;
struct _IMPEXP_MEDIA media_raw_video_format;
struct _IMPEXP_MEDIA media_video_display_info;
struct _IMPEXP_MEDIA flavor_info;
struct _IMPEXP_MEDIA dormant_node_info;
struct _IMPEXP_MEDIA dormant_flavor_info;
struct _IMPEXP_MEDIA media_source;
struct _IMPEXP_MEDIA media_destination;
struct _IMPEXP_MEDIA _media_format_description;
struct _IMPEXP_MEDIA media_timed_event;
/* midi kit */
class _IMPEXP_MIDI BMidi;
class _IMPEXP_MIDI BMidiPort;
class _IMPEXP_MIDI BMidiStore;
class _IMPEXP_MIDI BMidiSynth;
class _IMPEXP_MIDI BMidiSynthFile;
class _IMPEXP_MIDI BMidiText;
class _IMPEXP_MIDI BSamples;
class _IMPEXP_MIDI BSynth;
class _IMPEXP_MIDI2 BMidiEndpoint;
class _IMPEXP_MIDI2 BMidiProducer;
class _IMPEXP_MIDI2 BMidiConsumer;
class _IMPEXP_MIDI2 BMidiLocalProducer;
class _IMPEXP_MIDI2 BMidiLocalConsumer;
class _IMPEXP_MIDI2 BMidiRoster;
/* game kit */
class _IMPEXP_GAME BWindowScreen;
class _IMPEXP_GAME BDirectWindow;
/* gamesound kit */
class _IMPEXP_GSOUND BGameSound;
class _IMPEXP_GSOUND BSimpleGameSound;
class _IMPEXP_GSOUND BStreamingGameSound;
class _IMPEXP_GSOUND BFileGameSound;
class _IMPEXP_GSOUND BPushGameSound;
/* translation kit */
class _IMPEXP_TRANSLATION BTranslatorRoster;
class _IMPEXP_TRANSLATION BTranslationUtils;
class _IMPEXP_TRANSLATION BBitmapStream;
class _IMPEXP_TRANSLATION BTranslator;
struct _IMPEXP_TRANSLATION translation_format;
struct _IMPEXP_TRANSLATION translator_info;
/* GL */
class _IMPEXP_GL BGLView;
class _IMPEXP_GL BGLScreen;
class _IMPEXP_GL GLUnurbs;
class _IMPEXP_GL GLUquadric;
class _IMPEXP_GL GLUtesselator;
typedef class _IMPEXP_GL GLUnurbs GLUnurbsObj;
typedef class _IMPEXP_GL GLUquadric GLUquadricObj;
typedef class _IMPEXP_GL GLUtesselator GLUtesselatorObj;
typedef class _IMPEXP_GL GLUtesselator GLUtriangulatorObj;
/* input_server */
class _IMPEXP_INPUT BInputServerDevice;
class _IMPEXP_INPUT BInputServerFilter;
class _IMPEXP_INPUT BInputServerMethod;
#else /* __cplusplus */
/*
//typedef struct _IMPEXP_GL GLUnurbs GLUnurbs;
//typedef struct _IMPEXP_GL GLUquadric GLUquadric;
//typedef struct _IMPEXP_GL GLUtesselator GLUtesselator;
//typedef struct _IMPEXP_GL GLUnurbs GLUnurbsObj;
//typedef struct _IMPEXP_GL GLUquadric GLUquadricObj;
//typedef struct _IMPEXP_GL GLUtesselator GLUtesselatorObj;
//typedef struct _IMPEXP_GL GLUtesselator GLUtriangulatorObj;
*/
#endif /* __cplusplus */
#endif /* _BE_BUILD_H */
+15
View File
@@ -0,0 +1,15 @@
/*
* Master include file for the Device Kit.
*
*/
#include <A2D.h>
#include <D2A.h>
#include <DigitalPort.h>
#include <Joystick.h>
#include <SerialPort.h>
#include <graphic_driver.h>
/*
#include <perfmon_cpu.h>
#include <scsi.h>
#include <scsiprobe_driver.h>
*/
+12
View File
@@ -0,0 +1,12 @@
/*
* Master include file for the Game Kit.
*
*/
#include <WindowScreen.h>
#include <DirectWindow.h>
#include <FileGameSound.h>
#include <GameSound.h>
#include <GameSoundDefs.h>
#include <PushGameSound.h>
#include <SimpleGameSound.h>
#include <StreamingGameSound.h>
+46
View File
@@ -0,0 +1,46 @@
/*
* Master include file for the Interface Kit.
*
* <UnicodeBlockObjects.h> is not included on purpose.
*/
#include <Alert.h>
#include <Bitmap.h>
#include <Box.h>
#include <Button.h>
#include <CheckBox.h>
#include <ColorControl.h>
#include <Control.h>
#include <Dragger.h>
#include <Font.h>
#include <GraphicsDefs.h>
#include <Input.h>
#include <InterfaceDefs.h>
#include <ListItem.h>
#include <ListView.h>
#include <Menu.h>
#include <MenuBar.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <OutlineListView.h>
#include <Picture.h>
#include <PictureButton.h>
#include <Point.h>
#include <Polygon.h>
#include <PopUpMenu.h>
#include <PrintJob.h>
#include <RadioButton.h>
#include <Rect.h>
#include <Region.h>
#include <Screen.h>
#include <ScrollBar.h>
#include <ScrollView.h>
#include <Shape.h>
#include <Shelf.h>
#include <Slider.h>
#include <StatusBar.h>
#include <StringView.h>
#include <TabView.h>
#include <TextControl.h>
#include <TextView.h>
#include <View.h>
#include <Window.h>
+12
View File
@@ -0,0 +1,12 @@
/*
* Master include file for the Kernel Kit.
*
*/
#include <OS.h>
#include <debugger.h>
#include <fs_attr.h>
#include <fs_index.h>
#include <fs_info.h>
#include <fs_query.h>
#include <image.h>
#include <scheduler.h>
+5
View File
@@ -0,0 +1,5 @@
/*
* Master include file for the Mail Kit.
*
*/
#include <E-mail.h>
+29
View File
@@ -0,0 +1,29 @@
/*
* Master include file for the Media Kit.
*
*/
#include <Buffer.h>
#include <BufferConsumer.h>
#include <BufferGroup.h>
#include <BufferProducer.h>
#include <Controllable.h>
#include <FileInterface.h>
#include <MediaAddOn.h>
#include <MediaDefs.h>
#include <MediaEventLooper.h>
#include <MediaFile.h>
#include <MediaFiles.h>
#include <MediaFormats.h>
#include <MediaNode.h>
#include <MediaRoster.h>
#include <MediaTheme.h>
#include <MediaTrack.h>
#include <ParameterWeb.h>
#include <PlaySound.h>
#include <RealtimeAlloc.h>
#include <Sound.h>
#include <SoundFile.h>
#include <SoundPlayer.h>
#include <TimeCode.h>
#include <TimeSource.h>
#include <TimedEventQueue.h>
+13
View File
@@ -0,0 +1,13 @@
/*
* Master include file for the Midi Kit.
*
*/
#include <Midi.h>
#include <MidiDefs.h>
#include <MidiPort.h>
#include <MidiStore.h>
#include <MidiSynth.h>
#include <MidiSynthFile.h>
#include <MidiText.h>
#include <Samples.h>
#include <Synth.h>
+8
View File
@@ -0,0 +1,8 @@
/*
* Master include file for the Net Kit.
*
*/
#include <net_settings.h>
#include <netdb.h>
#include <socket.h>
#include <netinet/in.h>
+9
View File
@@ -0,0 +1,9 @@
/*
* Master include file for the Network Kit.
*
*/
#include <socket.h>
#include <NetAddress.h>
#include <NetBuffer.h>
#include <NetEndpoint.h>
#include <NetDebug.h>
+9
View File
@@ -0,0 +1,9 @@
/*
* Master include file for the OpenGL Kit.
*
*/
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <GLView.h>
+25
View File
@@ -0,0 +1,25 @@
/*
* Master include file for the Storage Kit.
*
*/
#include <Alias.h>
#include <AppFileInfo.h>
#include <Directory.h>
#include <Entry.h>
#include <EntryList.h>
#include <File.h>
#include <FilePanel.h>
#include <FindDirectory.h>
#include <Mime.h>
#include <Node.h>
#include <NodeInfo.h>
#include <NodeMonitor.h>
#include <Path.h>
#include <Query.h>
#include <Resources.h>
#include <ResourceStrings.h>
#include <Statable.h>
#include <StorageDefs.h>
#include <SymLink.h>
#include <Volume.h>
#include <VolumeRoster.h>
+23
View File
@@ -0,0 +1,23 @@
/*
* Master include file for the Support Kit.
*
*/
#include <Archivable.h>
#include <Autolock.h>
#include <Beep.h>
#include <BlockCache.h>
#include <BufferIO.h>
#include <ByteOrder.h>
#include <ClassInfo.h>
#include <DataIO.h>
#include <Debug.h>
#include <Errors.h>
#include <Flattenable.h>
#include <List.h>
#include <Locker.h>
#include <StopWatch.h>
#include <String.h>
#include <SupportDefs.h>
#include <TypeConstants.h>
#include <UTF8.h>
#include <syslog.h>
+12
View File
@@ -0,0 +1,12 @@
/*
* Master include file for the Translation Kit.
*
* <TranslatorAddOn.h> not included, as it's only required when building an add-on
*/
#include <BitmapStream.h>
#include <TranslationDefs.h>
#include <TranslationErrors.h>
#include <TranslationUtils.h>
#include <TranslatorFormats.h>
#include <TranslatorRoster.h>
#include <Translator.h>
@@ -0,0 +1,261 @@
/*
Copyright 1999-2001, Be Incorporated. All Rights Reserved.
This file may be used under the terms of the Be Sample Code License.
*/
#ifndef _FSPROTO_H
#define _FSPROTO_H
#include <sys/dirent.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include <iovec.h>
#include <OS.h>
#include <fs_attr.h>
#include <fs_info.h>
#include <BeBuild.h>
#include <Drivers.h>
typedef dev_t nspace_id;
typedef ino_t vnode_id;
/*
* PUBLIC PART OF THE FILE SYSTEM PROTOCOL
*/
#define WSTAT_MODE 0x0001
#define WSTAT_UID 0x0002
#define WSTAT_GID 0x0004
#define WSTAT_SIZE 0x0008
#define WSTAT_ATIME 0x0010
#define WSTAT_MTIME 0x0020
#define WSTAT_CRTIME 0x0040
#define WFSSTAT_NAME 0x0001
#define B_ENTRY_CREATED 1
#define B_ENTRY_REMOVED 2
#define B_ENTRY_MOVED 3
#define B_STAT_CHANGED 4
#define B_ATTR_CHANGED 5
#define B_DEVICE_MOUNTED 6
#define B_DEVICE_UNMOUNTED 7
#define B_STOP_WATCHING 0x0000
#define B_WATCH_NAME 0x0001
#define B_WATCH_STAT 0x0002
#define B_WATCH_ATTR 0x0004
#define B_WATCH_DIRECTORY 0x0008
#define SELECT_READ 1
#define SELECT_WRITE 2
#define SELECT_EXCEPTION 3
#define B_CUR_FS_API_VERSION 2
#define IOCTL_FILE_UNCACHED_IO 10000
#define IOCTL_CREATE_TIME 10002
#define IOCTL_MODIFIED_TIME 10003
struct attr_info;
struct index_info;
typedef int op_read_vnode(void *ns, vnode_id vnid, char r, void **node);
typedef int op_write_vnode(void *ns, void *node, char r);
typedef int op_remove_vnode(void *ns, void *node, char r);
typedef int op_secure_vnode(void *ns, void *node);
typedef int op_wake_vnode(void *ns, void *node);
typedef int op_suspend_vnode(void *ns, void *node);
typedef int op_walk(void *ns, void *base, const char *file, char **newpath,
vnode_id *vnid);
typedef int op_access(void *ns, void *node, int mode);
typedef int op_create(void *ns, void *dir, const char *name,
int omode, int perms, vnode_id *vnid, void **cookie);
typedef int op_mkdir(void *ns, void *dir, const char *name, int perms);
typedef int op_symlink(void *ns, void *dir, const char *name,
const char *path);
typedef int op_link(void *ns, void *dir, const char *name, void *node);
typedef int op_rename(void *ns, void *olddir, const char *oldname,
void *newdir, const char *newname);
typedef int op_unlink(void *ns, void *dir, const char *name);
typedef int op_rmdir(void *ns, void *dir, const char *name);
typedef int op_readlink(void *ns, void *node, char *buf, size_t *bufsize);
typedef int op_opendir(void *ns, void *node, void **cookie);
typedef int op_closedir(void *ns, void *node, void *cookie);
typedef int op_rewinddir(void *ns, void *node, void *cookie);
typedef int op_readdir(void *ns, void *node, void *cookie, long *num,
struct dirent *buf, size_t bufsize);
typedef int op_open(void *ns, void *node, int omode, void **cookie);
typedef int op_close(void *ns, void *node, void *cookie);
typedef int op_free_cookie(void *ns, void *node, void *cookie);
typedef int op_read(void *ns, void *node, void *cookie, off_t pos, void *buf,
size_t *len);
typedef int op_write(void *ns, void *node, void *cookie, off_t pos,
const void *buf, size_t *len);
typedef int op_readv(void *ns, void *node, void *cookie, off_t pos, const iovec *vec,
size_t count, size_t *len);
typedef int op_writev(void *ns, void *node, void *cookie, off_t pos, const iovec *vec,
size_t count, size_t *len);
typedef int op_ioctl(void *ns, void *node, void *cookie, int cmd, void *buf,
size_t len);
typedef int op_setflags(void *ns, void *node, void *cookie, int flags);
typedef int op_rstat(void *ns, void *node, struct stat *);
typedef int op_wstat(void *ns, void *node, struct stat *, long mask);
typedef int op_fsync(void *ns, void *node);
typedef int op_select(void *ns, void *node, void *cookie, uint8 event,
uint32 ref, selectsync *sync);
typedef int op_deselect(void *ns, void *node, void *cookie, uint8 event,
selectsync *sync);
typedef int op_initialize(const char *devname, void *parms, size_t len);
typedef int op_mount(nspace_id nsid, const char *devname, ulong flags,
void *parms, size_t len, void **data, vnode_id *vnid);
typedef int op_unmount(void *ns);
typedef int op_sync(void *ns);
typedef int op_rfsstat(void *ns, struct fs_info *);
typedef int op_wfsstat(void *ns, struct fs_info *, long mask);
typedef int op_open_attrdir(void *ns, void *node, void **cookie);
typedef int op_close_attrdir(void *ns, void *node, void *cookie);
typedef int op_rewind_attrdir(void *ns, void *node, void *cookie);
typedef int op_read_attrdir(void *ns, void *node, void *cookie, long *num,
struct dirent *buf, size_t bufsize);
typedef int op_remove_attr(void *ns, void *node, const char *name);
typedef int op_rename_attr(void *ns, void *node, const char *oldname,
const char *newname);
typedef int op_stat_attr(void *ns, void *node, const char *name,
struct attr_info *buf);
typedef int op_write_attr(void *ns, void *node, const char *name, int type,
const void *buf, size_t *len, off_t pos);
typedef int op_read_attr(void *ns, void *node, const char *name, int type,
void *buf, size_t *len, off_t pos);
typedef int op_open_indexdir(void *ns, void **cookie);
typedef int op_close_indexdir(void *ns, void *cookie);
typedef int op_rewind_indexdir(void *ns, void *cookie);
typedef int op_read_indexdir(void *ns, void *cookie, long *num,
struct dirent *buf, size_t bufsize);
typedef int op_create_index(void *ns, const char *name, int type, int flags);
typedef int op_remove_index(void *ns, const char *name);
typedef int op_rename_index(void *ns, const char *oldname,
const char *newname);
typedef int op_stat_index(void *ns, const char *name, struct index_info *buf);
typedef int op_open_query(void *ns, const char *query, ulong flags,
port_id port, long token, void **cookie);
typedef int op_close_query(void *ns, void *cookie);
typedef int op_read_query(void *ns, void *cookie, long *num,
struct dirent *buf, size_t bufsize);
typedef struct vnode_ops {
op_read_vnode (*read_vnode);
op_write_vnode (*write_vnode);
op_remove_vnode (*remove_vnode);
op_secure_vnode (*secure_vnode);
op_walk (*walk);
op_access (*access);
op_create (*create);
op_mkdir (*mkdir);
op_symlink (*symlink);
op_link (*link);
op_rename (*rename);
op_unlink (*unlink);
op_rmdir (*rmdir);
op_readlink (*readlink);
op_opendir (*opendir);
op_closedir (*closedir);
op_free_cookie (*free_dircookie);
op_rewinddir (*rewinddir);
op_readdir (*readdir);
op_open (*open);
op_close (*close);
op_free_cookie (*free_cookie);
op_read (*read);
op_write (*write);
op_readv (*readv);
op_writev (*writev);
op_ioctl (*ioctl);
op_setflags (*setflags);
op_rstat (*rstat);
op_wstat (*wstat);
op_fsync (*fsync);
op_initialize (*initialize);
op_mount (*mount);
op_unmount (*unmount);
op_sync (*sync);
op_rfsstat (*rfsstat);
op_wfsstat (*wfsstat);
op_select (*select);
op_deselect (*deselect);
op_open_indexdir (*open_indexdir);
op_close_indexdir (*close_indexdir);
op_free_cookie (*free_indexdircookie);
op_rewind_indexdir (*rewind_indexdir);
op_read_indexdir (*read_indexdir);
op_create_index (*create_index);
op_remove_index (*remove_index);
op_rename_index (*rename_index);
op_stat_index (*stat_index);
op_open_attrdir (*open_attrdir);
op_close_attrdir (*close_attrdir);
op_free_cookie (*free_attrdircookie);
op_rewind_attrdir (*rewind_attrdir);
op_read_attrdir (*read_attrdir);
op_write_attr (*write_attr);
op_read_attr (*read_attr);
op_remove_attr (*remove_attr);
op_rename_attr (*rename_attr);
op_stat_attr (*stat_attr);
op_open_query (*open_query);
op_close_query (*close_query);
op_free_cookie (*free_querycookie);
op_read_query (*read_query);
// for Dano compatibility only
op_wake_vnode (*wake_vnode);
op_suspend_vnode (*suspend_vnode);
} vnode_ops;
#ifdef __cplusplus
extern "C" {
#endif
extern _IMPEXP_KERNEL int new_path(const char *path, char **copy);
extern _IMPEXP_KERNEL void free_path(char *p);
extern _IMPEXP_KERNEL int notify_listener(int op, nspace_id nsid,
vnode_id vnida, vnode_id vnidb,
vnode_id vnidc, const char *name);
extern _IMPEXP_KERNEL int send_notification(port_id port, long token,
ulong what, long op, nspace_id nsida,
nspace_id nsidb, vnode_id vnida,
vnode_id vnidb, vnode_id vnidc,
const char *name);
extern _IMPEXP_KERNEL int get_vnode(nspace_id nsid, vnode_id vnid, void **data);
extern _IMPEXP_KERNEL int put_vnode(nspace_id nsid, vnode_id vnid);
extern _IMPEXP_KERNEL int new_vnode(nspace_id nsid, vnode_id vnid, void *data);
extern _IMPEXP_KERNEL int remove_vnode(nspace_id nsid, vnode_id vnid);
extern _IMPEXP_KERNEL int unremove_vnode(nspace_id nsid, vnode_id vnid);
extern _IMPEXP_KERNEL int is_vnode_removed(nspace_id nsid, vnode_id vnid);
#ifdef __cplusplus
}
#endif
extern _EXPORT vnode_ops fs_entry;
extern _EXPORT int32 api_version;
#endif
@@ -0,0 +1,249 @@
#if !defined(_ACCELERANT_H_)
#define _ACCELERANT_H_
#include <BeBuild.h>
#include <SupportDefs.h>
#include <GraphicsDefs.h>
#include <OS.h>
#if defined(__cplusplus)
extern "C" {
#endif
#define B_ACCELERANT_ENTRY_POINT "get_accelerant_hook"
#define B_ACCELERANT_VERSION 1
typedef void * (*GetAccelerantHook)(uint32, void *);
_EXPORT void * get_accelerant_hook(uint32 feature, void *data);
enum {
/* initialization */
B_INIT_ACCELERANT = 0, /* required */
B_ACCELERANT_CLONE_INFO_SIZE, /* required */
B_GET_ACCELERANT_CLONE_INFO, /* required */
B_CLONE_ACCELERANT, /* required */
B_UNINIT_ACCELERANT, /* required */
B_GET_ACCELERANT_DEVICE_INFO, /* required */
B_ACCELERANT_RETRACE_SEMAPHORE, /* optional */
/* mode configuration */
B_ACCELERANT_MODE_COUNT = 0x100, /* required */
B_GET_MODE_LIST, /* required */
B_PROPOSE_DISPLAY_MODE, /* optional */
B_SET_DISPLAY_MODE, /* required */
B_GET_DISPLAY_MODE, /* required */
B_GET_FRAME_BUFFER_CONFIG, /* required */
B_GET_PIXEL_CLOCK_LIMITS, /* required */
B_GET_TIMING_CONSTRAINTS, /* optional */
B_MOVE_DISPLAY, /* optional */
B_SET_INDEXED_COLORS, /* required if driver supports 8bit indexed modes */
B_DPMS_CAPABILITIES, /* required if driver supports DPMS */
B_DPMS_MODE, /* required if driver supports DPMS */
B_SET_DPMS_MODE, /* required if driver supports DPMS */
/* cursor managment */
B_MOVE_CURSOR = 0x200, /* optional */
B_SET_CURSOR_SHAPE, /* optional */
B_SHOW_CURSOR, /* optional */
/* synchronization */
B_ACCELERANT_ENGINE_COUNT = 0x300, /* required */
B_ACQUIRE_ENGINE, /* required */
B_RELEASE_ENGINE, /* required */
B_WAIT_ENGINE_IDLE, /* required */
B_GET_SYNC_TOKEN, /* required */
B_SYNC_TO_TOKEN, /* required */
/* 2D acceleration */
B_SCREEN_TO_SCREEN_BLIT = 0x400, /* optional */
B_FILL_RECTANGLE, /* optional */
B_INVERT_RECTANGLE, /* optional */
B_FILL_SPAN, /* optional */
B_SCREEN_TO_SCREEN_TRANSPARENT_BLIT, /* optional */
B_SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT, /* optional. NOTE: source and dest may NOT overlap */
/* 3D acceleration */
B_ACCELERANT_PRIVATE_START = (int)0x80000000
};
typedef struct {
uint32 version; /* structure version number */
char name[32]; /* a name the user will recognize the device by */
char chipset[32]; /* the chipset used by the device */
char serial_no[32]; /* serial number for the device */
uint32 memory; /* amount of memory on the device, in bytes */
uint32 dac_speed; /* nominal DAC speed, in MHz */
} accelerant_device_info;
typedef struct {
uint32 pixel_clock; /* kHz */
uint16 h_display; /* in pixels (not character clocks) */
uint16 h_sync_start;
uint16 h_sync_end;
uint16 h_total;
uint16 v_display; /* in lines */
uint16 v_sync_start;
uint16 v_sync_end;
uint16 v_total;
uint32 flags; /* sync polarity, etc. */
} display_timing;
typedef struct {
display_timing timing; /* CTRC info */
uint32 space; /* pixel configuration */
uint16 virtual_width; /* in pixels */
uint16 virtual_height; /* in lines */
uint16 h_display_start; /* first displayed pixel in line */
uint16 v_display_start; /* first displayed line */
uint32 flags; /* mode flags */
} display_mode;
typedef struct {
void *frame_buffer; /* pointer to first byte of frame buffer in virtual memory */
void *frame_buffer_dma; /* pointer to first byte of frame buffer in physical memory for DMA */
uint32 bytes_per_row; /* number of bytes in one virtual_width line */
/* not neccesarily the same as virtual_width * byte_per_pixel */
} frame_buffer_config;
typedef struct {
uint16 h_res; /* minimum effective change in horizontal pixels, usually 8 */
uint16 h_sync_min; /* min/max horizontal sync pulse width in pixels, a multiple of h_res */
uint16 h_sync_max;
uint16 h_blank_min; /* min/max horizontal blank pulse width in pixels, a multiple of h_res */
uint16 h_blank_max;
uint16 v_res; /* minimum effective change in vertical lines, usually 1 */
uint16 v_sync_min; /* min/max vertical sync pulse width in lines, a multiple of v_res */
uint16 v_sync_max;
uint16 v_blank_min; /* min/max vertical blank pulse width in linex, a multiple of v_res */
uint16 v_blank_max;
} display_timing_constraints;
enum { /* mode flags */
B_SCROLL = 1 << 0,
B_8_BIT_DAC = 1 << 1,
B_HARDWARE_CURSOR = 1 << 2,
B_PARALLEL_ACCESS = 1 << 3,
B_DPMS = 1 << 4,
B_IO_FB_NA = 1 << 5
};
enum { /* power saver flags */
B_DPMS_ON = 1 << 0,
B_DPMS_STAND_BY = 1 << 1,
B_DPMS_SUSPEND = 1 << 2,
B_DPMS_OFF = 1 << 3
};
enum { /* timing flags */
B_BLANK_PEDESTAL = 1 << 27,
B_TIMING_INTERLACED = 1 << 28,
B_POSITIVE_HSYNC = 1 << 29,
B_POSITIVE_VSYNC = 1 << 30,
B_SYNC_ON_GREEN = 1 << 31
};
typedef struct {
uint16 src_left; /* guaranteed constrained to virtual width and height */
uint16 src_top;
uint16 dest_left;
uint16 dest_top;
uint16 width; /* 0 to N, where zero means one pixel, one means two pixels, etc. */
uint16 height; /* 0 to M, where zero means one line, one means two lines, etc. */
} blit_params;
typedef struct {
uint16 src_left; /* guaranteed constrained to virtual width and height */
uint16 src_top;
uint16 src_width; /* 0 to N, where zero means one pixel, one means two pixels, etc. */
uint16 src_height; /* 0 to M, where zero means one line, one means two lines, etc. */
uint16 dest_left;
uint16 dest_top;
uint16 dest_width; /* 0 to N, where zero means one pixel, one means two pixels, etc. */
uint16 dest_height; /* 0 to M, where zero means one line, one means two lines, etc. */
} scaled_blit_params;
typedef struct {
uint16 left; /* guaranteed constrained to virtual width and height */
uint16 top;
uint16 right;
uint16 bottom;
} fill_rect_params;
typedef struct {
uint32 engine_id; /* 0 == no engine, 1,2,3 etc individual engines */
uint32 capability_mask; /* features this engine supports */
void *opaque; /* optional pointer to engine private storage */
} engine_token;
enum { /* engine capabilities */
B_2D_ACCELERATION = 1 << 0,
B_3D_ACCELERATION = 1 << 1
};
typedef struct {
uint64 counter; /* counts issued primatives */
uint32 engine_id; /* what engine the counter is for */
char opaque[12]; /* 12 bytes of private storage */
} sync_token;
/* Masks for color info */
/* B_CMAP8 - 0x000000ff */
/* B_RGB15/16 - 0x0000ffff */
/* B_RGB24 - 0x00ffffff */
/* B_RGB32 - 0xffffffff */
typedef status_t (*init_accelerant)(int fd);
typedef ssize_t (*accelerant_clone_info_size)(void);
typedef void (*get_accelerant_clone_info)(void *data);
typedef status_t (*clone_accelerant)(void *data);
typedef void (*uninit_accelerant)(void);
typedef status_t (*get_accelerant_device_info)(accelerant_device_info *adi);
typedef uint32 (*accelerant_mode_count)(void);
typedef status_t (*get_mode_list)(display_mode *);
typedef status_t (*propose_display_mode)(display_mode *target, display_mode *low, display_mode *high);
typedef status_t (*set_display_mode)(display_mode *mode_to_set);
typedef status_t (*get_display_mode)(display_mode *current_mode);
typedef status_t (*get_frame_buffer_config)(frame_buffer_config *a_frame_buffer);
typedef status_t (*get_pixel_clock_limits)(display_mode *dm, uint32 *low, uint32 *high);
typedef status_t (*move_display_area)(uint16 h_display_start, uint16 v_display_start);
typedef status_t (*get_timing_constraints)(display_timing_constraints *dtc);
typedef void (*set_indexed_colors)(uint count, uint8 first, uint8 *color_data, uint32 flags);
typedef uint32 (*dpms_capabilities)(void);
typedef uint32 (*dpms_mode)(void);
typedef status_t (*set_dpms_mode)(uint32 dpms_flags);
typedef sem_id (*accelerant_retrace_semaphore)(void);
typedef status_t (*set_cursor_shape)(uint16 width, uint16 height, uint16 hot_x, uint16 hot_y, uint8 *andMask, uint8 *xorMask);
typedef void (*move_cursor)(uint16 x, uint16 y);
typedef void (*show_cursor)(bool is_visible);
typedef uint32 (*accelerant_engine_count)(void);
typedef status_t (*acquire_engine)(uint32 capabilities, uint32 max_wait, sync_token *st, engine_token **et);
typedef status_t (*release_engine)(engine_token *et, sync_token *st);
typedef void (*wait_engine_idle)(void);
typedef status_t (*get_sync_token)(engine_token *et, sync_token *st);
typedef status_t (*sync_to_token)(sync_token *st);
typedef void (*screen_to_screen_blit)(engine_token *et, blit_params *list, uint32 count);
typedef void (*fill_rectangle)(engine_token *et, uint32 color, fill_rect_params *list, uint32 count);
typedef void (*invert_rectangle)(engine_token *et, fill_rect_params *list, uint32 count);
typedef void (*screen_to_screen_transparent_blit)(engine_token *et, uint32 transparent_color, blit_params *list, uint32 count);
typedef void (*screen_to_screen_scaled_filtered_blit)(engine_token *et, scaled_blit_params *list, uint32 count);
typedef void (*fill_span)(engine_token *et, uint32 color, uint16 *list, uint32 count);
/*
The uint16 *list points to a list of tripples:
list[N+0] Y co-ordinate of span
list[N+1] Left x co-ordinate of span
list[N+2] Right x co-ordinate of span
where N is in the range 0 to count-1.
*/
#if defined(__cplusplus)
}
#endif
#endif
@@ -0,0 +1,188 @@
/******************************************************************************
/
/ File: GraphicsCard.h
/
/ Description: App Server interface for graphics card add-ons.
/
/ Copyright 1993-98, Be Incorporated
/
*******************************************************************************/
#ifndef _GRAPHICS_CARD_H
#define _GRAPHICS_CARD_H
#include <BeBuild.h>
#include <GraphicsDefs.h>
#include <SupportDefs.h>
/*-------------------------------------------------------------*/
/*----- Command Constants -------------------------------------*/
enum {
B_OPEN_GRAPHICS_CARD,
B_CLOSE_GRAPHICS_CARD,
B_GET_GRAPHICS_CARD_INFO,
B_GET_GRAPHICS_CARD_HOOKS,
B_SET_INDEXED_COLOR,
B_GET_SCREEN_SPACES,
B_CONFIG_GRAPHICS_CARD,
B_GET_REFRESH_RATES,
B_SET_SCREEN_GAMMA,
B_GET_INFO_FOR_CLONE_SIZE,
B_GET_INFO_FOR_CLONE,
B_SET_CLONED_GRAPHICS_CARD,
B_CLOSE_CLONED_GRAPHICS_CARD,
B_PROPOSE_FRAME_BUFFER,
B_SET_FRAME_BUFFER,
B_SET_DISPLAY_AREA,
B_MOVE_DISPLAY_AREA}
;
/*----- Optional ---------------*/
enum {
B_CRT_CONTROL = 0x0001,
B_GAMMA_CONTROL = 0x0002,
B_FRAME_BUFFER_CONTROL = 0x0004,
B_PARALLEL_BUFFER_ACCESS = 0x0008,
B_LAME_ASS_CARD = 0x0010
};
/*-------------------------------------------------------------*/
/*----- Structures --------------------------------------------*/
typedef struct {
int16 version;
int16 id;
void *frame_buffer;
char rgba_order[4];
int16 flags;
int16 bits_per_pixel;
int16 bytes_per_row;
int16 width;
int16 height;
} graphics_card_info;
typedef struct {
int32 index;
rgb_color color;
} indexed_color;
typedef struct {
uint32 space;
float refresh_rate;
uchar h_position;
uchar v_position;
uchar h_size;
uchar v_size;
} graphics_card_config;
typedef struct {
float min;
float max;
float current;
} refresh_rate_info;
typedef struct {
void *screen_base;
void *io_base;
uint32 vendor_id;
uint32 device_id;
uint32 _reserved1_;
uint32 _reserved2_;
} graphics_card_spec;
typedef struct {
int16 x1;
int16 y1;
int16 x2;
int16 y2;
rgb_color color;
} rgb_color_line;
typedef struct {
int16 x1;
int16 y1;
int16 x2;
int16 y2;
uchar color;
} indexed_color_line;
typedef struct {
int16 bits_per_pixel;
int16 bytes_per_row;
int16 width;
int16 height;
int16 display_width;
int16 display_height;
int16 display_x;
int16 display_y;
} frame_buffer_info;
typedef struct {
uchar red[256];
uchar green[256];
uchar blue[256];
} screen_gamma;
/*-------------------------------------------------------------*/
/*----- Hook Function -----------------------------------------*/
typedef void (*graphics_card_hook) ();
#define B_GRAPHICS_HOOK_COUNT 48
#ifdef __cplusplus
extern "C" {
#endif
_EXPORT int32 control_graphics_card(uint32, void*);
#ifdef __cplusplus
}
#endif
/*-------------------------------------------------------------*/
/*----- Debugging Functions ------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
void dprintf(const char *format, ...);
bool set_dprintf_enabled(bool); /* returns old enable flag */
#ifdef __cplusplus
}
#endif
/*-------------------------------------------------------------*/
/*----- Obsolete ---------------------------------------------*/
#define B_HOOK_COUNT B_GRAPHICS_HOOK_COUNT
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _GRAPHICS_CARD_H */
@@ -0,0 +1,79 @@
/******************************************************************************
/
/ File: InputServerDevice.h
/
/ Description: Add-on class for input_server devices.
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
******************************************************************************/
#ifndef _INPUTSERVERDEVICE_H
#define _INPUTSERVERDEVICE_H
#include <BeBuild.h>
#include <Input.h>
#include <SupportDefs.h>
struct input_device_ref {
char *name;
input_device_type type;
void *cookie;
};
enum {
// B_KEYBOARD_DEVICE notifications
B_KEY_MAP_CHANGED = 1,
B_KEY_LOCKS_CHANGED,
B_KEY_REPEAT_DELAY_CHANGED,
B_KEY_REPEAT_RATE_CHANGED,
// B_POINTING_DEVICE notifications
B_MOUSE_TYPE_CHANGED,
B_MOUSE_MAP_CHANGED,
B_MOUSE_SPEED_CHANGED,
B_CLICK_SPEED_CHANGED,
B_MOUSE_ACCELERATION_CHANGED
};
class _BDeviceAddOn_;
class BInputServerDevice {
public:
BInputServerDevice();
virtual ~BInputServerDevice();
virtual status_t InitCheck();
virtual status_t SystemShuttingDown();
virtual status_t Start(const char *device, void *cookie);
virtual status_t Stop(const char *device, void *cookie);
virtual status_t Control(const char *device,
void *cookie,
uint32 code,
BMessage *message);
status_t RegisterDevices(input_device_ref **devices);
status_t UnregisterDevices(input_device_ref **devices);
status_t EnqueueMessage(BMessage *message);
status_t StartMonitoringDevice(const char *device);
status_t StopMonitoringDevice(const char *device);
private:
_BDeviceAddOn_* fOwner;
virtual void _ReservedInputServerDevice1();
virtual void _ReservedInputServerDevice2();
virtual void _ReservedInputServerDevice3();
virtual void _ReservedInputServerDevice4();
uint32 _reserved[4];
};
#endif
@@ -0,0 +1,39 @@
/******************************************************************************
/
/ File: InputServerFilter.h
/
/ Description: Add-on class for input_server filters.
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _INPUTSERVERFILTER_H
#define _INPUTSERVERFILTER_H
#include <BeBuild.h>
#include <MessageFilter.h>
#include <SupportDefs.h>
class BInputServerFilter {
public:
BInputServerFilter();
virtual ~BInputServerFilter();
virtual status_t InitCheck();
virtual filter_result Filter(BMessage *message, BList *outList);
status_t GetScreenRegion(BRegion *region) const;
private:
virtual void _ReservedInputServerFilter1();
virtual void _ReservedInputServerFilter2();
virtual void _ReservedInputServerFilter3();
virtual void _ReservedInputServerFilter4();
uint32 _reserved[4];
};
#endif
@@ -0,0 +1,51 @@
/******************************************************************************
/
/ File: InputServerMethod.h
/
/ Description: Add-on class for input_server methods.
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
******************************************************************************/
#ifndef _INPUTSERVERMETHOD_H
#define _INPUTSERVERMETHOD_H
#include <BeBuild.h>
#include <InputServerFilter.h>
#include <SupportDefs.h>
class _BMethodAddOn_;
class AddOnManager;
class InputServer;
class BInputServerMethod : public BInputServerFilter {
public:
BInputServerMethod(const char *name,
const uchar *icon);
virtual ~BInputServerMethod();
virtual status_t MethodActivated(bool active);
status_t EnqueueMessage(BMessage *message);
status_t SetName(const char *name);
status_t SetIcon(const uchar *icon);
status_t SetMenu(const BMenu *menu, const BMessenger target);
private:
_BMethodAddOn_* fOwner;
friend class AddOnManager;
friend class InputServer;
virtual void _ReservedInputServerMethod1();
virtual void _ReservedInputServerMethod2();
virtual void _ReservedInputServerMethod3();
virtual void _ReservedInputServerMethod4();
uint32 _reserved[4];
};
#endif
@@ -0,0 +1,98 @@
#ifndef ZOIDBERG_MAIL_CHAIN_RUNNER_H
#define ZOIDBERG_MAIL_CHAIN_RUNNER_H
/* ChainRunner - runs the mail inbound and outbound chains
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
#include <MailAddon.h>
#include <MailSettings.h>
#include <Looper.h>
class BStringList;
class BMailStatusWindow;
class BMailStatusView;
class BMailChain;
class BMailChainCallback {
public:
virtual void Callback(status_t result) = 0;
// Called by the callback routines in ChainRunner
// result is the message that ended the chain
// (MD_HANDLED, MD_DISCARD, MD_NO_MORE_MESSAGES)
// Obviously, for process callbacks, result is
// gauranteed to be MD_NO_MORE_MESSAGES.
};
class BMailChainRunner : public BLooper {
public:
BMailChainRunner(BMailChain *chain, BMailStatusWindow *status,
bool self_destruct_when_done = true, bool save_chain_when_done = false,
bool destruct_chain_when_done = false);
~BMailChainRunner();
//----Callback functions. Callback objects will be deleted for you.
void RegisterMessageCallback(BMailChainCallback *callback);
// Your callback->Callback() function will be called when
// the current message is done being processed.
void RegisterProcessCallback(BMailChainCallback *callback);
// Your callback->Callback() function will be called when
// a filter returns MD_PASS_COMPLETE and before we go back
// to waiting for new messages, or when the fetch list
// runs out.
void RegisterChainCallback(BMailChainCallback *callback);
// Your callback->Callback() function will be called when
// a filter returns MD_ALL_PASSES_DONE and before everything
// is unloaded and sent home.
void Stop(bool immediately = false);
void ReportProgress(int bytes, int messages, const char *message = NULL);
void ResetProgress(const char *message = NULL);
void GetMessages(BStringList *list, int32 bytes);
void GetSingleMessage(const char *uid, int32 length, BPath *into);
// The bytes or length field is the total size, used for updating the
// progress bar. Use -1 for unknown maximum size.
bool QuitRequested();
void ShowError(const char *error);
void ShowMessage(const char *message);
BMailChain *Chain();
//----The big, bad asynchronous RunChain() function. Pretty harmless looking, huh?
status_t RunChain(bool asynchronous = true);
void MessageReceived (BMessage *msg);
private:
void CallCallbacksFor(BList &list, status_t code);
void get_messages(BStringList *list);
status_t Init();
#if USE_NASTY_SYNC_THREAD_HACK
static int32 thread_sync_func(void *arg);
status_t init_addons();
#endif
BMailChain *_chain;
BList message_cb, process_cb, chain_cb;
bool destroy_self, destroy_chain, save_chain;
BMailStatusWindow *_status;
BMailStatusView *_statview;
BList addons;
bool suicide;
uint8 _other_reserved[3];
uint32 _reserved[4];
};
BMailChainRunner *GetMailChainRunner(int32 chain_id, BMailStatusWindow *status, bool selfDestruct = true);
#endif /* ZOIDBERG_MAIL_CHAIN_RUNNER_H */
@@ -0,0 +1,151 @@
#ifndef ZOIDBERG_MAIL_ADDON_H
#define ZOIDBERG_MAIL_ADDON_H
/* Filter - the base class for all mail filters
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
class BMessage;
class BView;
class BPositionIO;
class BEntry;
class BPath;
class BView;
class BString;
class BPositionIO;
class BEntry;
enum {
B_MAIL_DISCARD = B_MAIL_ERROR_BASE + 8,
//--- This terminates the chain and removes the message being processed
// both from disk and from the server.
B_MAIL_END_FETCH,
//--- Terminates the current operation
B_MAIL_END_CHAIN
//--- This is for yikes errors, like an unreachable server.
};
class BMailStatusView;
class BMailChainRunner;
class BMailFilter
{
public:
BMailFilter(BMessage* settings);
// How to support queueing messages until a time of the
// day/week/month/year? The settings will contain a
// persistent ChainID field, the same for all Filters
// on the same "chain".
virtual ~BMailFilter();
// This will be called when the settings for this Filter
// are changed, or there are no new messages to consume
// after settings->FindInt32("timeout") seconds.
virtual status_t InitCheck(BString* out_message = NULL) = 0;
// Returns B_OK if the Filter was constructed success-
// fully. Otherwise it returns an error code. If it is
// passed a valid BString*, it may add an error message
// to the end of that BString iff it returns an error.
// If it returns an error code then the MailFilter will
// probably be deleted and the error shown to the user.
virtual status_t ProcessMailMessage
(
BPositionIO** io_message, BEntry* io_entry,
BMessage* io_headers, BPath* io_folder, const char *io_uid
) = 0;
// Filters a message. On input and output, the arguments
// are expected to be as below; however it is allowed for
// the MailFilter to alter any of these values as nece-
// ssary, so long as the constraints are as described when
// the function returns:
//
// * io_message - a PositionIO that contains the message
// data, pointing to the first byte of the message's
// header. This can be swapped if, eg, the message
// is copied across volume boundries. When the chain
// begins this is a file in /tmp.
// * io_entry - The entry for the PositionIO above.
// * io_headers - a list of attributes that will be added
// to the message file.
// * io_folder - The message's "folder"---may be com-
// pletely unrelated to its on-disk Entry.
// * io_uid - The unique ID provided by the message's
// Protocol
//
// At most one Filter::ProcessMailMessage() for a given
// chain (and thus ChainID) will be called at a time.
private:
virtual void _ReservedFilter1();
virtual void _ReservedFilter2();
virtual void _ReservedFilter3();
virtual void _ReservedFilter4();
};
//
// The addon interface: export instantiate_mailfilter()
// and instantiate_mailconfig() to create a Filter addon
//
extern "C" _EXPORT BView* instantiate_config_panel(BMessage *settings,BMessage *metadata);
// return a view that configures the MailProtocol or MailFilter
// returned by the functions below. BView::Archive(foo,true)
// produces this addon's settings, which are passed to the in-
// stantiate_* functions and stored persistently. This function
// should gracefully handle empty and NULL settings.
// A note on the metadata argument: The metadata pointer is
// guaranteed to remain valid as long as this view exists. As it is
// a pointer to the chain's metadata, your view can save any
// chain-global settings to it in its Archive() function. Note that
// you must cache this pointer yourself! You will never get it again.
// Also note that it is possible for it to be NULL.
extern "C" _EXPORT BMailFilter* instantiate_mailfilter(BMessage *settings,
BMailChainRunner *runner);
// Return a MailProtocol or MailFilter ready to do its thing,
// based on settings produced by archiving your config panel.
// Note that a Mail::Protocol is a Mail::Filter, so use
// instantiate_mailfilter to start things up.
extern "C" _EXPORT status_t descriptive_name(BMessage *msg, char *buffer);
// the config panel will show this name in the chains filter
// list if this function returns B_OK.
// The buffer is as big as B_FILE_NAME_LENGTH.
// standard Filters:
//
// * Parser - does ParseRFC2822(io_message,io_headers)
// * Folder - stores the message in the specified folder,
// optionally under io_folder, returns MD_HANDLED
// * HeaderFilter(regex,Yes_fiters,No_filters) -
// Applies Nes_filters to messages that have a header
// matching regex; applies No_filters otherwise.
// * CompatabilityFilter - Invokes the standard mail_dae-
// mon filter ~/config/settings/add-ons/MailDaemon/Filter
// on the message's Entry.
// * Producer - Reads outbound messages from disk and inserts
// them into the queue.
// * SMTPSender - Sends the message, via the specified
// SMTP server, to the people in header field
// "MAIL:recipients", changes the the Entry's
// "MAIL:flags" field to no longer pending, changes the
// "MAIL:status" header field to "Sent", and adds a header
// field "MAIL:when" with the time it was sent.
// * Dumper - returns MD_DISCARD
//
//
// Standard chain types:
//
// Incoming Mail: Protocol - Parser - Notifier - Folder
// Outgoing Mail: Producer - SMTPSender
//
// "chains" are lists of addons that appear in, or can be
// added to, the "Accounts" list in the config panel, a tree-
// view ordered by the chain type and the chain's AccountName().
// Their config views should be shown, one after the other,
// in the config panel.
#endif /* ZOIDBERG_MAIL_ADDON_H */
@@ -0,0 +1,107 @@
#ifndef ZOIDBERG_MAIL_PROTOCOL_H
#define ZOIDBERG_MAIL_PROTOCOL_H
/* Protocol - the base class for protocol filters
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
#include <OS.h>
#include <MailAddon.h>
class BHandler;
class BStringList;
class BMailChainRunner;
class BMailProtocol : public BMailFilter
{
public:
BMailProtocol(BMessage* settings, BMailChainRunner *runner);
// Open a connection based on 'settings'. 'settings' will
// contain a persistent uint32 ChainID field. At most one
// Protocol per ChainID will exist at a given time.
// The constructor of Mail::Protocol initializes manifest.
// It is your responsibility to fill in unique_ids, *and
// to keep it updated* in the course of whatever nefarious
// things your protocol does.
virtual ~BMailProtocol();
// Close the connection and clean up. This will be cal-
// led after FetchMessage() or FetchNewMessage() returns
// B_TIMED_OUT or B_ERROR, or when the settings for this
// Protocol are changed.
virtual status_t GetMessage(
const char* uid,
BPositionIO** out_file, BMessage* out_headers,
BPath* out_folder_location
)=0;
// Downloads the message with id uid, writing the message's
// RFC2822 contents to *out_file and storing any headers it
// wants to add other than those from the message itself into
// out_headers. It may store a path (if this type of account
// supports folders) in *out_folder_location.
//
// Returns B_OK if the message is now available in out_file,
// B_NAME_NOT_FOUND if there is no message with id 'uid' on
// the server, or another error if the connection failed.
//
// B_OK will cause the message to be stored and processed.
// B_NAME_NOT_FOUND will cause appropriate recovery to be
// taken (if such exists) but not cause the connection to
// be terminated. Any other error will cause anything writen
// to be discarded and and the connection closed.
// OBS:
// The Protocol may replace *out_file with a custom (read-
// only) BPositionIO-derived object that preserves the il-
// lusion that the message is writen to *out_file, but in
// fact only reads from the server and writes to *out_file
// on demand. This BPositionIO must guarantee that any
// data returned by Read() has also been writen to *out_-
// file. It must return a read error if reading from the
// network or writing to *out_file fails.
//
// The mail_daemon will delete *out_file before invoking
// FetchMessage() or FetchNewMessage() again.
virtual status_t DeleteMessage(const char* uid)=0;
// Removes the message from the server. After this, it's
// assumed (but not required) that GetMessage(uid,...)
// et al will fail with B_NAME_NOT_FOUND.
void CheckForDeletedMessages();
// You can call this to trigger a sweep for deleted messages.
// Automatically called at the beginning of the chain.
//------MailFilter calls
virtual status_t ProcessMailMessage
(
BPositionIO** io_message, BEntry* io_entry,
BMessage* io_headers, BPath* io_folder, const char* io_uid
);
protected:
BStringList *manifest, *unique_ids;
BMessage *settings;
BMailChainRunner *runner;
private:
inline void error_alert(const char *process, status_t error);
virtual void _ReservedProtocol1();
virtual void _ReservedProtocol2();
virtual void _ReservedProtocol3();
virtual void _ReservedProtocol4();
virtual void _ReservedProtocol5();
friend class DeletePass;
BHandler *trash_monitor;
BStringList *uids_on_disk;
uint32 _reserved[3];
};
#endif // ZOIDBERG_MAIL_PROTOCOL_H
@@ -0,0 +1,38 @@
#ifndef ZOIDBERG_PROTOCOL_CONFIG_VIEW_H
#define ZOIDBERG_PROTOCOL_CONFIG_VIEW_H
/* ProtocolConfigView - the standard config view for all protocols
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
#include <View.h>
typedef enum {
B_MAIL_PROTOCOL_HAS_AUTH_METHODS = 1,
B_MAIL_PROTOCOL_HAS_FLAVORS = 2,
B_MAIL_PROTOCOL_HAS_USERNAME = 4,
B_MAIL_PROTOCOL_HAS_PASSWORD = 8,
B_MAIL_PROTOCOL_HAS_HOSTNAME = 16,
B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER = 32
} b_mail_protocol_config_options;
class BMailProtocolConfigView : public BView {
public:
BMailProtocolConfigView(uint32 options_mask = B_MAIL_PROTOCOL_HAS_FLAVORS | B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_PASSWORD | B_MAIL_PROTOCOL_HAS_HOSTNAME);
virtual ~BMailProtocolConfigView();
void SetTo(BMessage *archive);
void AddFlavor(const char *label);
void AddAuthMethod(const char *label,bool needUserPassword = true);
virtual status_t Archive(BMessage *into, bool deep = true) const;
virtual void GetPreferredSize(float *width, float *height);
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage *msg);
private:
uint32 _reserved[5];
};
#endif /* ZOIDBERG_PROTOCOL_CONFIG_VIEW_H */
@@ -0,0 +1,41 @@
#ifndef ZOIDBERG_MAIL_REMOTESTORAGEPROTOCOL_H
#define ZOIDBERG_MAIL_REMOTESTORAGEPROTOCOL_H
/* RemoteStorageProtocol - the base class for protocol filters
**
** Copyright 2003 Dr. Zoidberg Enterprises. All rights reserved.
*/
#include <MailProtocol.h>
#include <StringList.h>
class BRemoteMailStorageProtocol : public BMailProtocol {
public:
BRemoteMailStorageProtocol(BMessage *settings, BMailChainRunner *runner);
virtual ~BRemoteMailStorageProtocol();
virtual status_t GetMessage(const char *mailbox, const char *message, BPositionIO **, BMessage *headers) = 0;
virtual status_t AddMessage(const char *mailbox, BPositionIO *data, BString *id) = 0;
virtual status_t DeleteMessage(const char *mailbox, const char *message) = 0;
virtual status_t CopyMessage(const char *mailbox, const char *to_mailbox, BString *message) = 0;
virtual status_t CreateMailbox(const char *mailbox) = 0;
virtual status_t DeleteMailbox(const char *mailbox) = 0;
void SyncMailbox(const char *mailbox);
//----Mail::Protocol stuff
virtual status_t GetMessage(
const char* uid,
BPositionIO** out_file, BMessage* out_headers,
BPath* out_folder_location);
virtual status_t DeleteMessage(const char* uid);
//---Data members
BStringList mailboxes;
private:
BHandler *handler;
};
#endif // ZOIDBERG_MAIL_REMOTESTORAGEPROTOCOL_H
@@ -0,0 +1,73 @@
#ifndef ZOIDBERG_STRING_LIST_H
#define ZOIDBERG_STRING_LIST_H
/* StringList - a string list implementation
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
#include <Flattenable.h>
class BList;
class BStringList : public BFlattenable {
public:
BStringList();
BStringList(const BStringList&);
~BStringList(void);
BStringList &operator=(const BStringList &from);
/* Flattenable stuff */
virtual bool IsFixedSize() const; //--false for obvious reasons
virtual type_code TypeCode() const;
virtual ssize_t FlattenedSize() const;
virtual status_t Flatten(void *buffer, ssize_t size) const;
virtual bool AllowsTypeCode(type_code code) const;
virtual status_t Unflatten(type_code c, const void *buf, ssize_t size);
/* Adding and removing items. */
void AddItem(const char *item);
void AddList(const BStringList *newItems);
bool RemoveItem(const char *item);
void MakeEmpty();
/* Retrieving items. */
const char *ItemAt(int32) const;
int32 IndexOf(const char *) const;
/* Querying the list. */
bool HasItem(const char *item) const;
int32 CountItems() const;
bool IsEmpty() const;
/* Determining differences between lists */
void NotHere(BStringList &other_list, BStringList *results);
void NotThere(BStringList &other_list, BStringList *results);
/* Useful list logic operators */
BStringList &operator += (const char *item);
BStringList &operator += (BStringList &list);
BStringList &operator -= (const char *item);
BStringList &operator -= (BStringList &list);
BStringList operator | (BStringList &list);
BStringList &operator |= (BStringList &list);
BStringList operator ^ (BStringList &list);
BStringList &operator ^= (BStringList &list);
bool operator == (BStringList &list);
const char *operator [] (int32 index);
private:
void *_buckets[256];
int32 _items;
BList *_indexed;
uint32 _reserved[5];
};
#endif /* ZOIDBERG_STRING_LIST_H */
@@ -0,0 +1,82 @@
#if ! defined _SCREENSAVER_H
#define _SCREENSAVER_H
#include <BeBuild.h>
#include <DirectWindow.h> // for direct_buffer_info
#include <image.h>
#include <Message.h>
class BView;
class BScreenSaver
{
public:
BScreenSaver(BMessage *archive, image_id);
virtual ~BScreenSaver();
// Return an error if something goes wrong or if you don't
// like the running environment (lack of 3D acceleration,
// lack of sound, ...).
virtual status_t InitCheck();
// Animation start and stop. The view is not yet visible when
// StartSaver is called.
virtual status_t StartSaver(BView *view, bool preview);
virtual void StopSaver();
// This hook is called periodically, you should
// override it to do the drawing. Notice that you
// should clear the screen when frame == 0 if you
// don't want to paint over the desktop.
virtual void Draw(BView *view, int32 frame);
// These hooks are for direct screen access, the first is
// called every time the settings change, the second is
// the equivalent of Draw to be called to access the screen
// directly. Draw and DirectDraw can be used at the same time.
virtual void DirectConnected(direct_buffer_info *info);
virtual void DirectDraw(int32 frame);
// configuration dialog methods
virtual void StartConfig(BView *configView);
virtual void StopConfig();
// Module should fill this in with metadata
// example: randomizable = true
virtual void SupplyInfo(BMessage *info) const;
// Send all the metadata info to the module
virtual void ModulesChanged(const BMessage *info);
// BArchivable like parameter saver method
virtual status_t SaveState(BMessage *into) const;
// These methods can be used to control drawing frequency.
void SetTickSize(bigtime_t ts);
bigtime_t TickSize() const;
// These methods can be used to control animation loop cycles
void SetLoop(int32 on_count, int32 off_count);
int32 LoopOnCount() const;
int32 LoopOffCount() const;
private:
virtual void _ReservedScreenSaver1();
virtual void _ReservedScreenSaver2();
virtual void _ReservedScreenSaver3();
virtual void _ReservedScreenSaver4();
virtual void _ReservedScreenSaver5();
virtual void _ReservedScreenSaver6();
virtual void _ReservedScreenSaver7();
virtual void _ReservedScreenSaver8();
bigtime_t ticksize;
int32 looponcount;
int32 loopoffcount;
uint32 _reservedScreenSaver[6];
};
extern "C" _EXPORT BScreenSaver *instantiate_screen_saver(BMessage *msg, image_id id);
#endif
@@ -0,0 +1,44 @@
/*******************************************************************************
/
/ File: Background.h
/
/ Description: Defines constants for setting Tracker background images
/
/ Copyright 1998-1999, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#ifndef _TRACKER_BACKGROUND_H
#define _TRACKER_BACKGROUND_H
/*----------------------------------------------------------------*/
/*----- Tracker background attribute name ----------------------*/
#define B_BACKGROUND_INFO "be:bgndimginfo"
/*----------------------------------------------------------------*/
/*----- Tracker background BMessage entries --------------------*/
#define B_BACKGROUND_IMAGE "be:bgndimginfopath" // string path
#define B_BACKGROUND_MODE "be:bgndimginfomode" // int32, the enum below
#define B_BACKGROUND_ORIGIN "be:bgndimginfooffset" // BPoint
#define B_BACKGROUND_ERASE_TEXT "be:bgndimginfoerasetext" // bool
#define B_BACKGROUND_WORKSPACES "be:bgndimginfoworkspaces" // uint32
/*----------------------------------------------------------------*/
/*----- Background mode values ---------------------------------*/
enum {
B_BACKGROUND_MODE_USE_ORIGIN,
B_BACKGROUND_MODE_CENTERED, // only works on Desktop
B_BACKGROUND_MODE_SCALED, // only works on Desktop
B_BACKGROUND_MODE_TILED
};
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
const int32 B_RESTORE_BACKGROUND_IMAGE = 'Tbgr'; // force a Tracker window to
// use a new background image
#endif /* _TRACKER_BACKGROUND_H */
@@ -0,0 +1,27 @@
/******************************************************************************
/
/ File: TrackerAddOn.h
/
/ Description: Protocol for the process_refs() hook function.
/
/ Copyright 1995-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _TRACKER_ADDON_H
#define _TRACKER_ADDON_H
#include <BeBuild.h>
struct entry_ref;
class BMessage;
/*-------------------------------------------------------------*/
/*------- This is why you're here: ----------------------------*/
extern "C" _EXPORT void process_refs(entry_ref dir_ref, BMessage* msg, void*);
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _TRACKER_ADDON_H */
+170
View File
@@ -0,0 +1,170 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: AppDefs.h
// Author: Erik Jaesler ([email protected])
// Description: Message codes and the global cursors.
//------------------------------------------------------------------------------
#ifndef _APP_DEFS_H
#define _APP_DEFS_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// Global Cursors --------------------------------------------------------------
// Old-style cursors
extern const unsigned char B_HAND_CURSOR[];
extern const unsigned char B_I_BEAM_CURSOR[];
// New-style cursors
#ifdef __cplusplus
class BCursor;
extern const BCursor *B_CURSOR_SYSTEM_DEFAULT;
extern const BCursor *B_CURSOR_I_BEAM;
#endif
// System Message Codes --------------------------------------------------------
enum {
B_ABOUT_REQUESTED = '_ABR',
B_WINDOW_ACTIVATED = '_ACT',
B_APP_ACTIVATED = '_ACT', // Same as B_WINDOW_ACTIVATED
B_ARGV_RECEIVED = '_ARG',
B_QUIT_REQUESTED = '_QRQ',
B_CLOSE_REQUESTED = '_QRQ', // Obsolete; use B_QUIT_REQUESTED
B_CANCEL = '_CNC',
B_KEY_DOWN = '_KYD',
B_KEY_UP = '_KYU',
B_UNMAPPED_KEY_DOWN = '_UKD',
B_UNMAPPED_KEY_UP = '_UKU',
B_MODIFIERS_CHANGED = '_MCH',
B_MINIMIZE = '_WMN',
B_MOUSE_DOWN = '_MDN',
B_MOUSE_MOVED = '_MMV',
B_MOUSE_ENTER_EXIT = '_MEX',
B_MOUSE_UP = '_MUP',
B_MOUSE_WHEEL_CHANGED = '_MWC',
B_OPEN_IN_WORKSPACE = '_OWS',
B_PRINTER_CHANGED = '_PCH',
B_PULSE = '_PUL',
B_READY_TO_RUN = '_RTR',
B_REFS_RECEIVED = '_RRC',
B_RELEASE_OVERLAY_LOCK = '_ROV',
B_ACQUIRE_OVERLAY_LOCK = '_AOV',
B_SCREEN_CHANGED = '_SCH',
B_VALUE_CHANGED = '_VCH',
B_VIEW_MOVED = '_VMV',
B_VIEW_RESIZED = '_VRS',
B_WINDOW_MOVED = '_WMV',
B_WINDOW_RESIZED = '_WRS',
B_WORKSPACES_CHANGED = '_WCG',
B_WORKSPACE_ACTIVATED = '_WAC',
B_ZOOM = '_WZM',
_COLORS_UPDATED = '_CLU', // Currently internal-use only. Later, public as B_COLORS_UPDATED
_FONTS_UPDATED = '_FNU', // Currently internal-use only. Later, public as B_FONTS_UPDATED
_APP_MENU_ = '_AMN',
_BROWSER_MENUS_ = '_BRM',
_MENU_EVENT_ = '_MEV',
_PING_ = '_PBL',
_QUIT_ = '_QIT',
_VOLUME_MOUNTED_ = '_NVL',
_VOLUME_UNMOUNTED_ = '_VRM',
_MESSAGE_DROPPED_ = '_MDP',
_DISPOSE_DRAG_ = '_DPD',
_MENUS_DONE_ = '_MND',
_SHOW_DRAG_HANDLES_ = '_SDH',
_EVENTS_PENDING_ = '_EVP',
_UPDATE_ = '_UPD',
_UPDATE_IF_NEEDED_ = '_UPN',
_PRINTER_INFO_ = '_PIN',
_SETUP_PRINTER_ = '_SUP',
_SELECT_PRINTER_ = '_PSL'
// Media Kit reserves all reserved codes starting in '_TR'
};
// Other Commands --------------------------------------------------------------
enum {
B_SET_PROPERTY = 'PSET',
B_GET_PROPERTY = 'PGET',
B_CREATE_PROPERTY = 'PCRT',
B_DELETE_PROPERTY = 'PDEL',
B_COUNT_PROPERTIES = 'PCNT',
B_EXECUTE_PROPERTY = 'PEXE',
B_GET_SUPPORTED_SUITES = 'SUIT',
B_UNDO = 'UNDO',
B_REDO = 'REDO',
B_CUT = 'CCUT',
B_COPY = 'COPY',
B_PASTE = 'PSTE',
B_SELECT_ALL = 'SALL',
B_SAVE_REQUESTED = 'SAVE',
B_MESSAGE_NOT_UNDERSTOOD = 'MNOT',
B_NO_REPLY = 'NONE',
B_REPLY = 'RPLY',
B_SIMPLE_DATA = 'DATA',
B_MIME_DATA = 'MIME',
B_ARCHIVED_OBJECT = 'ARCV',
B_UPDATE_STATUS_BAR = 'SBUP',
B_RESET_STATUS_BAR = 'SBRS',
B_NODE_MONITOR = 'NDMN',
B_QUERY_UPDATE = 'QUPD',
B_ENDORSABLE = 'ENDO',
B_COPY_TARGET = 'DDCP',
B_MOVE_TARGET = 'DDMV',
B_TRASH_TARGET = 'DDRM',
B_LINK_TARGET = 'DDLN',
B_INPUT_DEVICES_CHANGED = 'IDCH',
B_INPUT_METHOD_EVENT = 'IMEV',
B_WINDOW_MOVE_TO = 'WDMT',
B_WINDOW_MOVE_BY = 'WDMB',
B_SILENT_RELAUNCH = 'AREL',
B_OBSERVER_NOTICE_CHANGE = 'NTCH',
B_CONTROL_INVOKED = 'CIVK',
B_CONTROL_MODIFIED = 'CMOD'
// Media Kit reserves all reserved codes starting in 'TRI'
};
//------------------------------------------------------------------------------
#endif // _APP_DEFS_H
/*
* $Log $
*
* $Id $
*
*/
+179
View File
@@ -0,0 +1,179 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Erik Jaesler ([email protected])
*/
#ifndef _APPLICATION_H
#define _APPLICATION_H
#include <BeBuild.h>
#include <AppDefs.h> // For convenience
#include <InterfaceDefs.h>
#include <Looper.h>
#include <Messenger.h>
#include <Point.h>
#include <Rect.h>
class BCursor;
class BList;
class BWindow;
class _BSession_;
class BResources;
class BMessageRunner;
class BServer;
struct _server_heap_;
struct _drag_data_;
namespace BPrivate {
class PortLink;
}
class BApplication : public BLooper {
public:
BApplication(const char* signature);
BApplication(const char* signature,
status_t* error);
virtual ~BApplication();
// Archiving
BApplication(BMessage* data);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
status_t InitCheck() const;
// App control and System Message handling
virtual thread_id Run();
virtual void Quit();
virtual bool QuitRequested();
virtual void Pulse();
virtual void ReadyToRun();
virtual void MessageReceived(BMessage* msg);
virtual void ArgvReceived(int32 argc, char** argv);
virtual void AppActivated(bool active);
virtual void RefsReceived(BMessage* message);
virtual void AboutRequested();
// Scripting
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
// Cursor control, window/looper list, and app info
void ShowCursor();
void HideCursor();
void ObscureCursor();
bool IsCursorHidden() const;
void SetCursor(const void* cursor);
void SetCursor(const BCursor* cursor, bool sync = true);
int32 CountWindows() const;
BWindow* WindowAt(int32 index) const;
int32 CountLoopers() const;
BLooper* LooperAt(int32 index) const;
bool IsLaunching() const;
status_t GetAppInfo(app_info* info) const;
static BResources* AppResources();
virtual void DispatchMessage(BMessage* message,
BHandler* handler);
void SetPulseRate(bigtime_t rate);
// More scripting
virtual status_t GetSupportedSuites(BMessage* data);
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
class Private;
private:
typedef BLooper _inherited;
friend class Private;
friend class BServer;
BApplication(const char* signature, bool initGUI,
status_t* error);
BApplication(uint32 signature);
BApplication(const BApplication&);
BApplication& operator=(const BApplication&);
virtual void _ReservedApplication1();
virtual void _ReservedApplication2();
virtual void _ReservedApplication3();
virtual void _ReservedApplication4();
virtual void _ReservedApplication5();
virtual void _ReservedApplication6();
virtual void _ReservedApplication7();
virtual void _ReservedApplication8();
virtual bool ScriptReceived(BMessage* msg, int32 index,
BMessage* specifier, int32 form,
const char* property);
void run_task();
void InitData(const char* signature, bool initGUI,
status_t* error);
void BeginRectTracking(BRect r, bool trackWhole);
void EndRectTracking();
status_t setup_server_heaps();
void* rw_offs_to_ptr(uint32 offset);
void* ro_offs_to_ptr(uint32 offset);
void* global_ro_offs_to_ptr(uint32 offset);
status_t _InitGUIContext();
status_t connect_to_app_server();
void send_drag( BMessage* msg,
int32 vs_token,
BPoint offset,
BRect drag_rect,
BHandler* reply_to);
void send_drag( BMessage* msg,
int32 vs_token,
BPoint offset,
int32 bitmap_token,
drawing_mode dragMode,
BHandler* reply_to);
void write_drag(_BSession_* session, BMessage* a_message);
bool quit_all_windows(bool force);
bool window_quit_loop(bool, bool);
void do_argv(BMessage* msg);
void SetAppCursor();
uint32 InitialWorkspace();
int32 count_windows(bool incl_menus) const;
BWindow* window_at(uint32 index, bool incl_menus) const;
status_t get_window_list(BList* list, bool incl_menus) const;
static int32 async_quit_entry(void*);
static BResources* _app_resources;
static BLocker _app_resources_lock;
const char* fAppName;
BPrivate::PortLink* fServerLink;
uint32 _unused0;
void* fCursorData;
_server_heap_* fServerHeap;
bigtime_t fPulseRate;
uint32 fInitialWorkspace;
_drag_data_* fDraggedMessage;
BMessageRunner* fPulseRunner;
status_t fInitError;
uint32 _reserved[11];
bool fReadyToRunCalled;
};
// Global Objects
extern _IMPEXP_BE BApplication* be_app;
extern _IMPEXP_BE BMessenger be_app_messenger;
#endif // _APPLICATION_H
+105
View File
@@ -0,0 +1,105 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Clipboard.h
// Author: Gabe Yoder ([email protected])
// Description: BClipboard provides an interface to a system-wide clipboard
// storage area.
//------------------------------------------------------------------------------
#ifndef _CLIPBOARD_H
#define _CLIPBOARD_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Messenger.h>
#include <Locker.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BMessage;
enum {
B_CLIPBOARD_CHANGED = 'CLCH'
};
// BClipboard class ---------------------------------------------------------------
class BClipboard {
public:
BClipboard(const char *name, bool transient = false);
virtual ~BClipboard();
const char *Name() const;
uint32 LocalCount() const;
uint32 SystemCount() const;
status_t StartWatching(BMessenger target);
status_t StopWatching(BMessenger target);
bool Lock();
void Unlock();
bool IsLocked() const;
status_t Clear();
status_t Commit();
status_t Revert();
BMessenger DataSource() const;
BMessage *Data() const;
/*----- Private or reserved -----------------------------------------*/
private:
BClipboard(const BClipboard &);
BClipboard &operator=(const BClipboard &);
virtual void _ReservedClipboard1();
virtual void _ReservedClipboard2();
virtual void _ReservedClipboard3();
bool AssertLocked() const;
status_t DownloadFromSystem(bool force = false);
status_t UploadToSystem();
uint32 _reserved0;
BMessage *fData;
BLocker fLock;
BMessenger fClipHandler;
BMessenger fDataSource;
uint32 fCount;
char *fName;
uint32 _reserved[4];
};
//----- Global Clipboard -------------------------------------------------------
extern _IMPEXP_BE BClipboard *be_clipboard;
//------------------------------------------------------------------------------
#endif // _CLIPBOARD_H
+82
View File
@@ -0,0 +1,82 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Cursor.h
// Author: Frans van Nispen ([email protected])
// Description: BCursor describes a view-wide or application-wide cursor.
//------------------------------------------------------------------------------
#ifndef _CURSOR_H
#define _CURSOR_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <Archivable.h>
#include <BeBuild.h>
#include <InterfaceDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// BCursor class ---------------------------------------------------------------
class BCursor : BArchivable {
public:
BCursor(const void* cursorData);
BCursor(BMessage* data);
virtual ~BCursor();
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* data);
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
private:
virtual void _ReservedCursor1();
virtual void _ReservedCursor2();
virtual void _ReservedCursor3();
virtual void _ReservedCursor4();
friend class BApplication;
friend class BView;
int32 m_serverToken;
int32 m_needToFree;
uint32 _reserved[6];
};
//------------------------------------------------------------------------------
#endif // _CURSOR_H
/*
* $Log $
*
* $Id $
*
*/
+148
View File
@@ -0,0 +1,148 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Handler.cpp
// Author: Erik Jaesler ([email protected])
// Description: BHandler defines the message-handling protocol.
// MessageReceived() is its lynchpin.
//------------------------------------------------------------------------------
#ifndef _HANDLER_H
#define _HANDLER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Archivable.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BLooper;
class BMessageFilter;
class BMessage;
class BList;
class _ObserverList;
#define B_OBSERVE_WHAT_CHANGE "be:observe_change_what"
#define B_OBSERVE_ORIGINAL_WHAT "be:observe_orig_what"
const uint32 B_OBSERVER_OBSERVE_ALL = 0xffffffff;
// BHandler class --------------------------------------------------------------
class BHandler : public BArchivable {
public:
BHandler(const char* name = NULL);
virtual ~BHandler();
// Archiving
BHandler(BMessage* data);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
// BHandler guts.
virtual void MessageReceived(BMessage* message);
BLooper* Looper() const;
void SetName(const char* name);
const char* Name() const;
virtual void SetNextHandler(BHandler* handler);
BHandler* NextHandler() const;
// Message filtering
virtual void AddFilter(BMessageFilter* filter);
virtual bool RemoveFilter(BMessageFilter* filter);
virtual void SetFilterList(BList* filters);
BList* FilterList();
bool LockLooper();
status_t LockLooperWithTimeout(bigtime_t timeout);
void UnlockLooper();
// Scripting
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
// Observer calls, inter-looper and inter-team
status_t StartWatching(BMessenger, uint32 what);
status_t StartWatchingAll(BMessenger);
status_t StopWatching(BMessenger, uint32 what);
status_t StopWatchingAll(BMessenger);
// Observer calls for observing targets in the same BLooper
status_t StartWatching(BHandler* , uint32 what);
status_t StartWatchingAll(BHandler* );
status_t StopWatching(BHandler* , uint32 what);
status_t StopWatchingAll(BHandler* );
// Reserved
virtual status_t Perform(perform_code d, void* arg);
// Notifier calls
virtual void SendNotices(uint32 what, const BMessage* = 0);
bool IsWatched() const;
//----- Private or reserved -----------------------------------------
private:
typedef BArchivable _inherited;
friend inline int32 _get_object_token_(const BHandler* );
friend class BLooper;
friend class BMessageFilter;
virtual void _ReservedHandler2();
virtual void _ReservedHandler3();
virtual void _ReservedHandler4();
void InitData(const char* name);
BHandler(const BHandler&);
BHandler& operator=(const BHandler&);
void SetLooper(BLooper* loop);
int32 fToken;
char* fName;
BLooper* fLooper;
BHandler* fNextHandler;
BList* fFilters;
_ObserverList* fObserverList;
uint32 _reserved[3];
};
//------------------------------------------------------------------------------
#endif // _HANDLER_H
/*
* $Log $
*
* $Id $
*
*/
+128
View File
@@ -0,0 +1,128 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Invoker.h
// Author: Frans van Nispen ([email protected])
// Description: BInvoker class defines a protocol for objects that
// post messages to a "target".
//------------------------------------------------------------------------------
#ifndef _INVOKER_H
#define _INVOKER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Messenger.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BHandler;
class BLooper;
class BMessage;
// BInvoker class --------------------------------------------------------------
class BInvoker {
public:
BInvoker();
BInvoker(BMessage *message,
const BHandler *handler,
const BLooper *looper = NULL);
BInvoker(BMessage *message, BMessenger target);
virtual ~BInvoker();
virtual status_t SetMessage(BMessage *message);
BMessage *Message() const;
uint32 Command() const;
virtual status_t SetTarget(const BHandler *h, const BLooper *loop = NULL);
virtual status_t SetTarget(BMessenger messenger);
bool IsTargetLocal() const;
BHandler *Target(BLooper **looper = NULL) const;
BMessenger Messenger() const;
virtual status_t SetHandlerForReply(BHandler *handler);
BHandler *HandlerForReply() const;
virtual status_t Invoke(BMessage *msg = NULL);
// Invoke with BHandler notification. Use this to perform an
// Invoke() with some other kind of notification change code.
// (A raw invoke should always notify as B_CONTROL_INVOKED.)
// Unlike a raw Invoke(), there is no standard message that is
// sent. If 'msg' is NULL, then nothing will be sent to this
// invoker's target... however, a notification message will
// still be sent to any watchers of the invoker's handler.
// Note that the BInvoker class does not actually implement
// any of this behavior -- it is up to subclasses to override
// Invoke() and call Notify() with the appropriate change code.
status_t InvokeNotify(BMessage *msg, uint32 kind = B_CONTROL_INVOKED);
status_t SetTimeout(bigtime_t timeout);
bigtime_t Timeout() const;
protected:
// Return the change code for a notification. This is either
// B_CONTROL_INVOKED for raw Invoke() calls, or the kind
// supplied to InvokeNotify(). In addition, 'notify' will be
// set to true if this was an InvokeNotify() call, else false.
uint32 InvokeKind(bool* notify = NULL);
// Start and end an InvokeNotify context around an Invoke() call.
// These are only needed for writing custom methods that
// emulate the standard InvokeNotify() call.
void BeginInvokeNotify(uint32 kind = B_CONTROL_INVOKED);
void EndInvokeNotify();
// Private or reserved ---------------------------------------------------------
private:
// to be able to keep binary compatibility
virtual void _ReservedInvoker1();
virtual void _ReservedInvoker2();
virtual void _ReservedInvoker3();
BInvoker(const BInvoker&);
BInvoker &operator=(const BInvoker&);
BMessage *fMessage;
BMessenger fMessenger;
BHandler *fReplyTo;
bigtime_t fTimeout;
uint32 fNotifyKind;
uint32 _reserved[1]; // to be able to keep binary compatibility
};
//------------------------------------------------------------------------------
#endif // _INVOKER_H
/*
* $Log $
*
* $Id $
*
*/
+238
View File
@@ -0,0 +1,238 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Looper.h
// Author(s): Erik Jaesler ([email protected])
// DarkWyrm ([email protected])
// Description: BLooper class spawns a thread that runs a message loop.
//------------------------------------------------------------------------------
#ifndef _LOOPER_H
#define _LOOPER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Handler.h>
#include <List.h>
#include <OS.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BMessage;
class BMessageQueue;
namespace BPrivate {
class BLooperList;
}
struct _loop_data_;
// Port (Message Queue) Capacity -----------------------------------------------
#define B_LOOPER_PORT_DEFAULT_CAPACITY 100
// BLooper class ---------------------------------------------------------------
class BLooper : public BHandler {
public:
BLooper(const char* name = NULL,
int32 priority = B_NORMAL_PRIORITY,
int32 port_capacity = B_LOOPER_PORT_DEFAULT_CAPACITY);
virtual ~BLooper();
// Archiving
BLooper(BMessage* data);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
// Message transmission
status_t PostMessage(uint32 command);
status_t PostMessage(BMessage* message);
status_t PostMessage(uint32 command,
BHandler* handler,
BHandler* reply_to = NULL);
status_t PostMessage(BMessage* message,
BHandler* handler,
BHandler* reply_to = NULL);
virtual void DispatchMessage(BMessage* message, BHandler* handler);
virtual void MessageReceived(BMessage* msg);
BMessage* CurrentMessage() const;
BMessage* DetachCurrentMessage();
BMessageQueue* MessageQueue() const;
bool IsMessageWaiting() const;
// Message handlers
void AddHandler(BHandler* handler);
bool RemoveHandler(BHandler* handler);
int32 CountHandlers() const;
BHandler* HandlerAt(int32 index) const;
int32 IndexOf(BHandler* handler) const;
BHandler* PreferredHandler() const;
void SetPreferredHandler(BHandler* handler);
// Loop control
virtual thread_id Run();
virtual void Quit();
virtual bool QuitRequested();
bool Lock();
void Unlock();
bool IsLocked() const;
status_t LockWithTimeout(bigtime_t timeout);
thread_id Thread() const;
team_id Team() const;
static BLooper* LooperForThread(thread_id tid);
// Loop debugging
thread_id LockingThread() const;
int32 CountLocks() const;
int32 CountLockRequests() const;
sem_id Sem() const;
// Scripting
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
// Message filters (also see BHandler).
virtual void AddCommonFilter(BMessageFilter* filter);
virtual bool RemoveCommonFilter(BMessageFilter* filter);
virtual void SetCommonFilterList(BList* filters);
BList* CommonFilterList() const;
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
protected:
// called from overridden task_looper
BMessage* MessageFromPort(bigtime_t = B_INFINITE_TIMEOUT);
private:
typedef BHandler _inherited;
friend class BWindow;
friend class BApplication;
friend class BMessenger;
friend class BView;
friend class BHandler;
friend class BPrivate::BLooperList;
friend port_id _get_looper_port_(const BLooper* );
friend status_t _safe_get_server_token_(const BLooper* , int32* );
friend team_id _find_cur_team_id_();
virtual void _ReservedLooper1();
virtual void _ReservedLooper2();
virtual void _ReservedLooper3();
virtual void _ReservedLooper4();
virtual void _ReservedLooper5();
virtual void _ReservedLooper6();
BLooper(const BLooper&);
BLooper& operator=(const BLooper&);
BLooper(int32 priority, port_id port, const char* name);
status_t _PostMessage(BMessage* msg,
BHandler* handler,
BHandler* reply_to);
static status_t _Lock(BLooper* loop,
port_id port,
bigtime_t timeout);
static status_t _LockComplete(BLooper* loop,
int32 old,
thread_id this_tid,
sem_id sem,
bigtime_t timeout);
void InitData();
void InitData(const char* name, int32 prio, int32 capacity);
void AddMessage(BMessage* msg);
void _AddMessagePriv(BMessage* msg);
static status_t _task0_(void* arg);
void* ReadRawFromPort(int32* code,
bigtime_t tout = B_INFINITE_TIMEOUT);
BMessage* ReadMessageFromPort(bigtime_t tout = B_INFINITE_TIMEOUT);
virtual BMessage* ConvertToMessage(void* raw, int32 code);
virtual void task_looper();
void do_quit_requested(BMessage* msg);
bool AssertLocked() const;
BHandler* top_level_filter(BMessage* msg, BHandler* t);
BHandler* handler_only_filter(BMessage* msg, BHandler* t);
BHandler* apply_filters( BList* list,
BMessage* msg,
BHandler* target);
void check_lock();
BHandler* resolve_specifier(BHandler* target, BMessage* msg);
void UnlockFully();
static uint32 sLooperID;
static team_id sTeamID;
// DEPRECATED
static void AddLooper(BLooper* l);
static bool IsLooperValid(const BLooper* l);
static void RemoveLooper(BLooper* l);
static void GetLooperList(BList* list);
static BLooper* LooperForName(const char* name);
static BLooper* LooperForPort(port_id port);
uint32 fLooperID;
BMessageQueue* fQueue;
BMessage* fLastMessage;
port_id fMsgPort;
long fAtomicCount;
sem_id fLockSem;
long fOwnerCount;
thread_id fOwner;
thread_id fTaskID;
uint32 _unused1;
int32 fInitPriority;
BHandler* fPreferred;
BList fHandlers;
BList* fCommonFilters;
bool fTerminating;
bool fRunCalled;
thread_id fCachedPid;
size_t fCachedStack;
void* fMsgBuffer;
size_t fMsgBufferSize;
uint32 _reserved[6];
};
//------------------------------------------------------------------------------
#endif // _LOOPER_H
/*
* $Log $
*
* $Id $
*
*/
+439
View File
@@ -0,0 +1,439 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Message.h
// Author(s): Erik Jaesler ([email protected])
// DarkWyrm <[email protected]>
// Description: BMessage class creates objects that store data and that
// can be processed in a message loop. BMessage objects
// are also used as data containers by the archiving and
// the scripting mechanisms.
//------------------------------------------------------------------------------
#ifndef _MESSAGE_H
#define _MESSAGE_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <OS.h>
#include <Rect.h>
#include <DataIO.h>
#include <Flattenable.h>
#include <AppDefs.h> /* For convenience */
#include <TypeConstants.h> /* For convenience */
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BBlockCache;
class BMessenger;
class BHandler;
class BString;
// Private or reserved ---------------------------------------------------------
extern "C" void _msg_cache_cleanup_();
extern "C" int _init_message_();
extern "C" int _delete_message_();
//------------------------------------------------------------------------------
// Name lengths and Scripting specifiers ---------------------------------------
#define B_FIELD_NAME_LENGTH 255
#define B_PROPERTY_NAME_LENGTH 255
enum
{
B_NO_SPECIFIER = 0,
B_DIRECT_SPECIFIER = 1,
B_INDEX_SPECIFIER,
B_REVERSE_INDEX_SPECIFIER,
B_RANGE_SPECIFIER,
B_REVERSE_RANGE_SPECIFIER,
B_NAME_SPECIFIER,
B_ID_SPECIFIER,
B_SPECIFIERS_END = 128
// app-defined specifiers start at B_SPECIFIERS_END+1
};
namespace BPrivate {
class BMessageBody;
}
// BMessage class --------------------------------------------------------------
class BMessage
{
public:
uint32 what;
BMessage();
BMessage(uint32 what);
BMessage(const BMessage &a_message);
virtual ~BMessage();
BMessage &operator=(const BMessage &msg);
// Statistics and misc info
status_t GetInfo(type_code typeRequested, int32 which, char **name,
type_code *typeReturned, int32 *count = NULL) const;
status_t GetInfo(const char *name, type_code *type, int32 *c = 0) const;
status_t GetInfo(const char *name, type_code *type, bool *fixed_size) const;
int32 CountNames(type_code type) const;
bool IsEmpty() const;
bool IsSystem() const;
bool IsReply() const;
void PrintToStream() const;
status_t Rename(const char *old_entry, const char *new_entry);
// Delivery info
bool WasDelivered() const;
bool IsSourceWaiting() const;
BMessenger ReturnAddress() const;
const BMessage *Previous() const;
bool WasDropped() const;
BPoint DropPoint(BPoint *offset = NULL) const;
// Flattening data
ssize_t FlattenedSize() const;
status_t Flatten(char *buffer, ssize_t size) const;
status_t Flatten(BDataIO *stream, ssize_t *size = NULL) const;
status_t Unflatten(const char *flat_buffer);
status_t Unflatten(BDataIO *stream);
// Specifiers (scripting)
status_t AddSpecifier(const char *property);
status_t AddSpecifier(const char *property, int32 index);
status_t AddSpecifier(const char *property, int32 index, int32 range);
status_t AddSpecifier(const char *property, const char *name);
status_t AddSpecifier(const BMessage *specifier);
status_t SetCurrentSpecifier(int32 index);
status_t GetCurrentSpecifier(int32 *index, BMessage *specifier = NULL,
int32 *form = NULL, const char **property = NULL) const;
bool HasSpecifiers() const;
status_t PopSpecifier();
// Adding data
status_t AddRect(const char *name, BRect a_rect);
status_t AddPoint(const char *name, BPoint a_point);
status_t AddString(const char *name, const char *a_string);
status_t AddString(const char *name, const BString& a_string);
status_t AddInt8(const char *name, int8 val);
status_t AddInt16(const char *name, int16 val);
status_t AddInt32(const char *name, int32 val);
status_t AddInt64(const char *name, int64 val);
status_t AddBool(const char *name, bool a_boolean);
status_t AddFloat(const char *name, float a_float);
status_t AddDouble(const char *name, double a_double);
status_t AddPointer(const char *name, const void *ptr);
status_t AddMessenger(const char *name, BMessenger messenger);
status_t AddRef(const char *name, const entry_ref *ref);
status_t AddMessage(const char *name, const BMessage *msg);
status_t AddFlat(const char *name, BFlattenable *obj, int32 count = 1);
status_t AddData(const char *name, type_code type, const void *data,
ssize_t numBytes, bool is_fixed_size = true, int32 count = 1);
// Removing data
status_t RemoveData(const char *name, int32 index = 0);
status_t RemoveName(const char *name);
status_t MakeEmpty();
// Finding data
status_t FindRect(const char *name, BRect *rect) const;
status_t FindRect(const char *name, int32 index, BRect *rect) const;
status_t FindPoint(const char *name, BPoint *pt) const;
status_t FindPoint(const char *name, int32 index, BPoint *pt) const;
status_t FindString(const char *name, const char **str) const;
status_t FindString(const char *name, int32 index, const char **str) const;
status_t FindString(const char *name, BString *str) const;
status_t FindString(const char *name, int32 index, BString *str) const;
status_t FindInt8(const char *name, int8 *value) const;
status_t FindInt8(const char *name, int32 index, int8 *val) const;
status_t FindInt16(const char *name, int16 *value) const;
status_t FindInt16(const char *name, int32 index, int16 *val) const;
status_t FindInt32(const char *name, int32 *value) const;
status_t FindInt32(const char *name, int32 index, int32 *val) const;
status_t FindInt64(const char *name, int64 *value) const;
status_t FindInt64(const char *name, int32 index, int64 *val) const;
status_t FindBool(const char *name, bool *value) const;
status_t FindBool(const char *name, int32 index, bool *value) const;
status_t FindFloat(const char *name, float *f) const;
status_t FindFloat(const char *name, int32 index, float *f) const;
status_t FindDouble(const char *name, double *d) const;
status_t FindDouble(const char *name, int32 index, double *d) const;
status_t FindPointer(const char *name, void **ptr) const;
status_t FindPointer(const char *name, int32 index, void **ptr) const;
status_t FindMessenger(const char *name, BMessenger *m) const;
status_t FindMessenger(const char *name, int32 index, BMessenger *m) const;
status_t FindRef(const char *name, entry_ref *ref) const;
status_t FindRef(const char *name, int32 index, entry_ref *ref) const;
status_t FindMessage(const char *name, BMessage *msg) const;
status_t FindMessage(const char *name, int32 index, BMessage *msg) const;
status_t FindFlat(const char *name, BFlattenable *obj) const;
status_t FindFlat(const char *name, int32 index, BFlattenable *obj) const;
status_t FindData(const char *name, type_code type,
const void **data, ssize_t *numBytes) const;
status_t FindData(const char *name, type_code type, int32 index,
const void **data, ssize_t *numBytes) const;
// Replacing data
status_t ReplaceRect(const char *name, BRect a_rect);
status_t ReplaceRect(const char *name, int32 index, BRect a_rect);
status_t ReplacePoint(const char *name, BPoint a_point);
status_t ReplacePoint(const char *name, int32 index, BPoint a_point);
status_t ReplaceString(const char *name, const char *string);
status_t ReplaceString(const char *name, int32 index, const char *string);
status_t ReplaceString(const char *name, const BString& string);
status_t ReplaceString(const char *name, int32 index, const BString& string);
status_t ReplaceInt8(const char *name, int8 val);
status_t ReplaceInt8(const char *name, int32 index, int8 val);
status_t ReplaceInt16(const char *name, int16 val);
status_t ReplaceInt16(const char *name, int32 index, int16 val);
status_t ReplaceInt32(const char *name, int32 val);
status_t ReplaceInt32(const char *name, int32 index, int32 val);
status_t ReplaceInt64(const char *name, int64 val);
status_t ReplaceInt64(const char *name, int32 index, int64 val);
status_t ReplaceBool(const char *name, bool a_bool);
status_t ReplaceBool(const char *name, int32 index, bool a_bool);
status_t ReplaceFloat(const char *name, float a_float);
status_t ReplaceFloat(const char *name, int32 index, float a_float);
status_t ReplaceDouble(const char *name, double a_double);
status_t ReplaceDouble(const char *name, int32 index, double a_double);
status_t ReplacePointer(const char *name, const void *ptr);
status_t ReplacePointer(const char *name,int32 index,const void *ptr);
status_t ReplaceMessenger(const char *name, BMessenger messenger);
status_t ReplaceMessenger(const char *name, int32 index, BMessenger msngr);
status_t ReplaceRef( const char *name,const entry_ref *ref);
status_t ReplaceRef( const char *name, int32 index, const entry_ref *ref);
status_t ReplaceMessage(const char *name, const BMessage *msg);
status_t ReplaceMessage(const char *name, int32 index, const BMessage *msg);
status_t ReplaceFlat(const char *name, BFlattenable *obj);
status_t ReplaceFlat(const char *name, int32 index, BFlattenable *obj);
status_t ReplaceData(const char *name, type_code type,
const void *data, ssize_t data_size);
status_t ReplaceData(const char *name, type_code type, int32 index,
const void *data, ssize_t data_size);
void *operator new(size_t size);
void *operator new(size_t, void* p);
void operator delete(void *ptr, size_t size);
// Private, reserved, or obsolete ----------------------------------------------
bool HasRect(const char *, int32 n = 0) const;
bool HasPoint(const char *, int32 n = 0) const;
bool HasString(const char *, int32 n = 0) const;
bool HasInt8(const char *, int32 n = 0) const;
bool HasInt16(const char *, int32 n = 0) const;
bool HasInt32(const char *, int32 n = 0) const;
bool HasInt64(const char *, int32 n = 0) const;
bool HasBool(const char *, int32 n = 0) const;
bool HasFloat(const char *, int32 n = 0) const;
bool HasDouble(const char *, int32 n = 0) const;
bool HasPointer(const char *, int32 n = 0) const;
bool HasMessenger(const char *, int32 n = 0) const;
bool HasRef(const char *, int32 n = 0) const;
bool HasMessage(const char *, int32 n = 0) const;
bool HasFlat(const char *, const BFlattenable *) const;
bool HasFlat(const char *,int32 ,const BFlattenable *) const;
bool HasData(const char *, type_code , int32 n = 0) const;
BRect FindRect(const char *, int32 n = 0) const;
BPoint FindPoint(const char *, int32 n = 0) const;
const char *FindString(const char *, int32 n = 0) const;
int8 FindInt8(const char *, int32 n = 0) const;
int16 FindInt16(const char *, int32 n = 0) const;
int32 FindInt32(const char *, int32 n = 0) const;
int64 FindInt64(const char *, int32 n = 0) const;
bool FindBool(const char *, int32 n = 0) const;
float FindFloat(const char *, int32 n = 0) const;
double FindDouble(const char *, int32 n = 0) const;
class Private;
private:
class Header;
friend class BMessageQueue;
friend class BMessenger;
friend class BApplication;
friend class Header;
friend class Private;
friend inline void _set_message_target_(BMessage *, int32, bool);
friend inline void _set_message_reply_(BMessage *, BMessenger);
friend inline int32 _get_message_target_(BMessage *);
friend inline bool _use_preferred_target_(BMessage *);
// deprecated
BMessage(BMessage *a_message);
virtual void _ReservedMessage1();
virtual void _ReservedMessage2();
virtual void _ReservedMessage3();
void init_data();
status_t flatten_target_info(BDataIO *stream,
ssize_t size,
uchar flags) const;
status_t real_flatten(char *result,
ssize_t size) const;
status_t real_flatten(BDataIO *stream) const;
char *stack_flatten(char *stack_ptr,
ssize_t stack_size,
bool incl_reply,
ssize_t *size = NULL) const;
ssize_t calc_size(uchar flags) const;
ssize_t calc_hdr_size(uchar flags) const;
status_t nfind_data( const char *name,
type_code type,
int32 index,
const void **data,
ssize_t *data_size) const;
status_t copy_data( const char *name,
type_code type,
int32 index,
void *data,
ssize_t data_size) const;
static void _StaticInit();
static void _StaticCleanup();
static void _StaticCacheCleanup();
static BBlockCache *sMsgCache;
struct dyn_array {
int32 fLogicalBytes;
int32 fPhysicalBytes;
int32 fChunkSize;
int32 fCount;
int32 fEntryHdrSize;
};
struct entry_hdr : public dyn_array {
entry_hdr *fNext;
uint32 fType;
uchar fNameLength;
char fName[1];
};
struct var_chunk {
int32 fDataSize;
char fData[1];
};
entry_hdr *entry_find(const char *name, uint32 type,status_t *result=NULL) const;
void entry_remove(entry_hdr *entry);
void *da_create(int32 header_size, int32 chunk_size,
bool fixed, int32 nchunks);
status_t da_add_data(dyn_array **da, const void *data, int32 size);
void *da_find_data(dyn_array *da, int32 index,
int32 *size = NULL) const;
status_t da_delete_data(dyn_array **pda, int32 index);
status_t da_replace_data(dyn_array **pda, int32 index,
const void *data, int32 dsize);
int32 da_calc_size(int32 hdr_size, int32 chunksize,
bool is_fixed, int32 nchunks) const;
void *da_grow(dyn_array **pda, int32 increase);
void da_dump(dyn_array *da);
int32 da_chunk_hdr_size() const
{ return sizeof(int32); }
int32 da_chunk_size(var_chunk *v) const
{ return (v->fDataSize + da_chunk_hdr_size() + 7) & ~7; }
var_chunk *da_first_chunk(dyn_array *da) const
{ return (var_chunk *) da_start_of_data(da); }
var_chunk *da_next_chunk(var_chunk *v) const
{ return (var_chunk *) (((char*) v) + da_chunk_size(v)); }
var_chunk *da_chunk_ptr(void *data) const
{ return (var_chunk*) (((char *) data) - da_chunk_hdr_size()); }
int32 da_pad_8(int32 val) const
{ return (val + 7) & ~7; }
int32 da_total_size(dyn_array *da) const
{ return (int32)sizeof(dyn_array) + da->fEntryHdrSize +
da->fPhysicalBytes; }
int32 da_total_logical_size(dyn_array *da) const
{ return (int32)sizeof(dyn_array) + da->fEntryHdrSize +
da->fLogicalBytes; }
char *da_start_of_data(dyn_array *da) const
{ return ((char *) da) + (sizeof(dyn_array) +
da->fEntryHdrSize); }
bool da_is_mini_data(dyn_array *da) const
{ return ((da->fLogicalBytes <= (int32) UCHAR_MAX) &&
(da->fCount <= (int32) UCHAR_MAX));}
void da_swap_var_sized(dyn_array *da);
void da_swap_fixed_sized(dyn_array *da);
BMessage *link;
int32 fTarget;
BMessage *fOriginal;
uint32 fChangeCount;
int32 fCurSpecifier;
uint32 fPtrOffset;
// ejaesler: Stealing one for my whacky BMessageBody l33tness
uint32 _reserved[2];
BPrivate::BMessageBody* fBody;
BMessage::entry_hdr *fEntries;
struct reply_to_info {
port_id port;
int32 target;
team_id team;
bool preferred;
} fReplyTo;
bool fPreferred;
bool fReplyRequired;
bool fReplyDone;
bool fIsReply;
bool fWasDelivered;
bool fReadOnly;
bool fHasSpecifiers;
};
//------------------------------------------------------------------------------
#endif // _MESSAGE_H
/*
* $Log $
*
* $Id $
*
*/
+126
View File
@@ -0,0 +1,126 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: MessageFilter.h
// Author: Erik Jaesler ([email protected])
// Description: BMessageFilter class creates objects that filter
// in-coming BMessages.
//------------------------------------------------------------------------------
#ifndef _MESSAGE_FILTER_H
#define _MESSAGE_FILTER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Handler.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BMessage;
// filter_hook Return Codes and Protocol ---------------------------------------
enum filter_result {
B_SKIP_MESSAGE,
B_DISPATCH_MESSAGE
};
typedef filter_result (*filter_hook)
(BMessage* message, BHandler** target, BMessageFilter* filter);
// BMessageFilter invocation criteria ------------------------------------------
enum message_delivery {
B_ANY_DELIVERY,
B_DROPPED_DELIVERY,
B_PROGRAMMED_DELIVERY
};
enum message_source {
B_ANY_SOURCE,
B_REMOTE_SOURCE,
B_LOCAL_SOURCE
};
// BMessageFilter Class --------------------------------------------------------
class BMessageFilter {
public:
BMessageFilter( uint32 what,
filter_hook func = NULL);
BMessageFilter( message_delivery delivery,
message_source source,
filter_hook func = NULL);
BMessageFilter( message_delivery delivery,
message_source source,
uint32 what,
filter_hook func = NULL);
BMessageFilter(const BMessageFilter& filter);
BMessageFilter(const BMessageFilter* filter);
virtual ~BMessageFilter();
BMessageFilter &operator=(const BMessageFilter& from);
// Hook function; ignored if filter_hook is non-NULL
virtual filter_result Filter(BMessage* message, BHandler** target);
message_delivery MessageDelivery() const;
message_source MessageSource() const;
uint32 Command() const;
bool FiltersAnyCommand() const;
BLooper *Looper() const;
// Private or reserved ---------------------------------------------------------
private:
friend class BLooper;
friend class BHandler;
virtual void _ReservedMessageFilter1();
virtual void _ReservedMessageFilter2();
void SetLooper(BLooper* owner);
filter_hook FilterFunction() const;
bool fFiltersAny;
uint32 what;
message_delivery fDelivery;
message_source fSource;
BLooper *fLooper;
filter_hook fFilterFunction;
uint32 _reserved[3];
};
//------------------------------------------------------------------------------
#endif // _MESSAGE_FILTER_H
/*
* $Log $
*
* $Id $
*
*/
+65
View File
@@ -0,0 +1,65 @@
//
// $Id: MessageQueue.h 1686 2002-10-26 18:59:16Z beveloper $
//
// This is the BMessageQueue interface for OpenBeOS. It has been created
// to be source and binary compatible with the BeOS version of
// BMessageQueue.
//
#ifndef _OPENBEOS_MESSAGEQUEUE_H
#define _OPENBEOS_MESSAGEQUEUE_H
#include <Locker.h>
#include <Message.h> /* For convenience */
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BMessageQueue {
public:
BMessageQueue();
virtual ~BMessageQueue();
void AddMessage(BMessage *message);
void RemoveMessage(BMessage *message);
int32 CountMessages(void) const;
bool IsEmpty(void) const;
BMessage *FindMessage(int32 index) const;
BMessage *FindMessage(uint32 what, int32 index=0) const;
bool Lock(void);
void Unlock(void);
bool IsLocked(void);
BMessage *NextMessage(void);
private:
// Reserved space in the vtable for future changes to BMessageQueue
virtual void _ReservedMessageQueue1(void);
virtual void _ReservedMessageQueue2(void);
virtual void _ReservedMessageQueue3(void);
BMessageQueue(const BMessageQueue &);
BMessageQueue &operator=(const BMessageQueue &);
BMessage *fTheQueue;
BMessage *fQueueTail;
int32 fMessageCount;
BLocker fLocker;
// Reserved space for future changes to BMessageQueue
uint32 fReservedSpace[3];
};
#ifdef USE_OPENBEOS_NAMESPACE
}
#endif
#endif // _OPENBEOS_MESSAGEQUEUE_H
+67
View File
@@ -0,0 +1,67 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: MessageRunner.h
// Author: Ingo Weinhold ([email protected])
// Description: A BMessageRunner periodically sends a message to a
// specified target.
//------------------------------------------------------------------------------
#ifndef _MESSAGE_RUNNER_H
#define _MESSAGE_RUNNER_H
#include <Messenger.h>
class BMessageRunner {
public:
BMessageRunner(BMessenger target, const BMessage *message,
bigtime_t interval, int32 count = -1);
BMessageRunner(BMessenger target, const BMessage *message,
bigtime_t interval, int32 count, BMessenger replyTo);
virtual ~BMessageRunner();
status_t InitCheck() const;
status_t SetInterval(bigtime_t interval);
status_t SetCount(int32 count);
status_t GetInfo(bigtime_t *interval, int32 *count) const;
private:
BMessageRunner(const BMessageRunner &);
BMessageRunner &operator=(const BMessageRunner &);
void InitData(BMessenger target, const BMessage *message,
bigtime_t interval, int32 count, BMessenger replyTo);
status_t SetParams(bool resetInterval, bigtime_t interval, bool resetCount,
int32 count);
virtual void _ReservedMessageRunner1();
virtual void _ReservedMessageRunner2();
virtual void _ReservedMessageRunner3();
virtual void _ReservedMessageRunner4();
virtual void _ReservedMessageRunner5();
virtual void _ReservedMessageRunner6();
int32 fToken;
uint32 _reserved[6];
};
#endif // _MESSAGE_RUNNER_H
+88
View File
@@ -0,0 +1,88 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Messenger.h
// Author: Ingo Weinhold ([email protected])
// Description: BMessenger delivers messages to local or remote targets.
//------------------------------------------------------------------------------
#ifndef _MESSENGER_H
#define _MESSENGER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <OS.h>
#include <ByteOrder.h>
#include <Message.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BHandler;
class BLooper;
// BMessenger class ------------------------------------------------------------
class BMessenger {
public:
BMessenger();
BMessenger(const BMessenger &from);
~BMessenger();
// Operators and misc
BMessenger &operator=(const BMessenger &from);
bool operator==(const BMessenger &other) const;
bool IsValid() const;
team_id Team() const;
//----- Private or reserved -----------------------------------------
class Private;
private:
friend class Private;
void SetTo(team_id team, port_id port, int32 token, bool preferred);
private:
port_id fPort;
int32 fHandlerToken;
team_id fTeam;
int32 extra0;
int32 extra1;
bool fPreferredTarget;
bool extra2;
bool extra3;
bool extra4;
};
_IMPEXP_BE bool operator<(const BMessenger &a, const BMessenger &b);
_IMPEXP_BE bool operator!=(const BMessenger &a, const BMessenger &b);
#endif // _MESSENGER_H
+152
View File
@@ -0,0 +1,152 @@
/*******************************************************************************
/
/ File: PropertyInfo.h
/
/ Description: Utility class for maintain scripting information
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/ Modified for use with OpenBeOS.
/
*******************************************************************************/
#ifndef _PROPERTY_INFO_H
#define _PROPERTY_INFO_H
#include <BeBuild.h>
#include <SupportDefs.h>
#include <Flattenable.h>
#include <TypeConstants.h> /* For convenience */
/*
* The following define is used to turn off a number of member functions
* and member variables in BPropertyInfo which are only there to faciliate
* BeOS R3 compatibility. Be changed the property_info structure between
* R3 and R4 and these functions ensure that BPropertyInfo is backward
* compatible. However, between R3 and R4, Be changed the Intel executable
* format so R4 was not backward compatible with R3.
*
* Because OpenBeOS is only targetting Intel platform compatibility at this
* time, there is no need for R3 compatibility in OpenBeOS. By default
* these members will be turned off with the R3_COMPATIBLE define.
*/
#undef R3_COMPATIBLE
#ifdef R3_COMPATIBLE
struct _oproperty_info_;
#endif
/*----------------------------------------------------------------*/
/*----- the property_info structure ------------------------------*/
struct compound_type {
struct field_pair {
char *name; // name of entry in message
type_code type; // type_code of entry in message
};
field_pair pairs[5];
};
struct property_info {
char *name;
uint32 commands[10];
uint32 specifiers[10];
char *usage;
uint32 extra_data;
uint32 types[10];
compound_type ctypes[3];
uint32 _reserved[10];
};
enum value_kind {
B_COMMAND_KIND = 0,
B_TYPE_CODE_KIND = 1
};
struct value_info {
char *name;
uint32 value;
value_kind kind;
char *usage;
uint32 extra_data;
uint32 _reserved[10];
};
#define B_PROPERTY_INFO_TYPE 'SCTD'
/*----------------------------------------------------------------*/
/*----- BPropertyInfo class --------------------------------------*/
class BPropertyInfo : public BFlattenable {
public:
BPropertyInfo(property_info *p = NULL,
value_info *ci = NULL,
bool free_on_delete = false);
virtual ~BPropertyInfo();
virtual int32 FindMatch(BMessage *msg,
int32 index,
BMessage *spec,
int32 form,
const char *prop,
void *data = NULL) const;
virtual bool IsFixedSize() const;
virtual type_code TypeCode() const;
virtual ssize_t FlattenedSize() const;
virtual status_t Flatten(void *buffer, ssize_t size) const;
virtual bool AllowsTypeCode(type_code code) const;
virtual status_t Unflatten(type_code c,
const void *buf,
ssize_t s);
const property_info *Properties() const;
const value_info *Values() const;
int32 CountProperties() const;
int32 CountValues() const;
void PrintToStream() const;
/*----- Private or reserved -----------------------------------------*/
protected:
static bool FindCommand(uint32, int32, property_info *);
static bool FindSpecifier(uint32, property_info *);
private:
virtual void _ReservedPropertyInfo1();
virtual void _ReservedPropertyInfo2();
virtual void _ReservedPropertyInfo3();
virtual void _ReservedPropertyInfo4();
BPropertyInfo(const BPropertyInfo &);
BPropertyInfo &operator=(const BPropertyInfo &);
void FreeMem();
property_info *fPropInfo;
value_info *fValueInfo;
int32 fPropCount;
bool fInHeap;
uint16 fValueCount;
#ifndef R3_COMPATIBLE
uint32 _reserved[4];
#else
_oproperty_info_ *fOldPropInfo;
bool fOldInHeap;
uint32 _reserved[2]; /* was 4 */
/* Deprecated */
private:
static property_info *ConvertToNew(const _oproperty_info_ *p);
static _oproperty_info_ *ConvertFromNew(const property_info *p);
const property_info *PropertyInfo() const;
BPropertyInfo(property_info *p,
bool free_on_delete);
static bool MatchCommand(uint32, int32, property_info *);
static bool MatchSpecifier(uint32, property_info *);
#endif
};
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _PROPERTY_INFO_H */
+198
View File
@@ -0,0 +1,198 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Roster.h
// Author: Ingo Weinhold ([email protected])
// Description: BRoster class lets you launch apps and keeps
// track of apps that are running.
// Global be_roster represents the default BRoster.
// app_info structure provides info for a running app.
//------------------------------------------------------------------------------
#ifndef _ROSTER_H
#define _ROSTER_H
#include <Entry.h>
#include <Messenger.h>
#include <OS.h>
// app_info
struct app_info {
app_info();
~app_info();
thread_id thread;
team_id team;
port_id port;
uint32 flags;
entry_ref ref;
char signature[B_MIME_TYPE_LENGTH];
};
// app flags
#define B_SINGLE_LAUNCH (0x0)
#define B_MULTIPLE_LAUNCH (0x1)
#define B_EXCLUSIVE_LAUNCH (0x2)
#define B_LAUNCH_MASK (0x3)
#define B_BACKGROUND_APP (0x4)
#define B_ARGV_ONLY (0x8)
#define _B_APP_INFO_RESERVED1_ (0x10000000)
// watching request flags
enum {
B_REQUEST_LAUNCHED = 0x00000001,
B_REQUEST_QUIT = 0x00000002,
B_REQUEST_ACTIVATED = 0x00000004,
};
// notification message "what"
enum {
B_SOME_APP_LAUNCHED = 'BRAS',
B_SOME_APP_QUIT = 'BRAQ',
B_SOME_APP_ACTIVATED = 'BRAW',
};
class BList;
// BRoster
class BRoster {
public:
BRoster();
~BRoster();
// running apps
bool IsRunning(const char *mimeSig) const;
bool IsRunning(entry_ref *ref) const;
team_id TeamFor(const char *mimeSig) const;
team_id TeamFor(entry_ref *ref) const;
void GetAppList(BList *teamIDList) const;
void GetAppList(const char *sig, BList *teamIDList) const;
// app infos
status_t GetAppInfo(const char *sig, app_info *info) const;
status_t GetAppInfo(entry_ref *ref, app_info *info) const;
status_t GetRunningAppInfo(team_id team, app_info *info) const;
status_t GetActiveAppInfo(app_info *info) const;
// find app
status_t FindApp(const char *mimeType, entry_ref *app) const;
status_t FindApp(entry_ref *ref, entry_ref *app) const;
// broadcast
status_t Broadcast(BMessage *message) const;
status_t Broadcast(BMessage *message, BMessenger replyTo) const;
// watching
status_t StartWatching(BMessenger target,
uint32 eventMask = B_REQUEST_LAUNCHED
| B_REQUEST_QUIT) const;
status_t StopWatching(BMessenger target) const;
status_t ActivateApp(team_id team) const;
// launch app
status_t Launch(const char *mimeType, BMessage *initialMessage = 0,
team_id *appTeam = 0) const;
status_t Launch(const char *mimeType, BList *messageList,
team_id *appTeam = 0) const;
status_t Launch(const char *mimeType, int argc, char **args,
team_id *appTeam = 0) const;
status_t Launch(const entry_ref *ref, const BMessage *initialMessage = 0,
team_id *appTeam = 0) const;
status_t Launch(const entry_ref *ref, const BList *messageList,
team_id *appTeam = 0) const;
status_t Launch(const entry_ref *ref, int argc, const char * const *args,
team_id *appTeam = 0) const;
// recent documents, folders, apps
void GetRecentDocuments(BMessage *refList, int32 maxCount,
const char *fileType = 0,
const char *appSig = 0) const;
void GetRecentDocuments(BMessage *refList, int32 maxCount,
const char *fileTypes[], int32 fileTypesCount,
const char *appSig = 0) const;
void GetRecentFolders(BMessage *refList, int32 maxCount,
const char *appSig = 0) const;
void GetRecentApps(BMessage *refList, int32 maxCount) const;
void AddToRecentDocuments(const entry_ref *doc,
const char *appSig = 0) const;
void AddToRecentFolders(const entry_ref *folder,
const char *appSig = 0) const;
// private/reserved stuff starts here
class Private;
private:
class ArgVector;
friend class Private;
status_t ShutDown(bool reboot, bool confirm, bool synchronous);
status_t AddApplication(const char *mimeSig, const entry_ref *ref,
uint32 flags, team_id team, thread_id thread,
port_id port, bool fullReg, uint32 *pToken,
team_id *otherTeam) const;
status_t SetSignature(team_id team, const char *mimeSig) const;
void SetThread(team_id team, thread_id thread) const;
status_t SetThreadAndTeam(uint32 entryToken, thread_id thread,
team_id team) const;
status_t CompleteRegistration(team_id team, thread_id thread,
port_id port) const;
bool IsAppPreRegistered(const entry_ref *ref, team_id team,
app_info *info) const;
status_t RemovePreRegApp(uint32 entryToken) const;
status_t RemoveApp(team_id team) const;
status_t xLaunchAppPrivate(const char *mimeType, const entry_ref *ref,
const BList *messageList, int argc,
const char *const *args,
team_id *appTeam) const;
bool UpdateActiveApp(team_id team) const;
void SetAppFlags(team_id team, uint32 flags) const;
void DumpRoster() const;
status_t resolve_app(const char *inType, entry_ref *ref, entry_ref *appRef,
char *appSig, uint32 *appFlags,
bool *wasDocument) const;
status_t translate_ref(entry_ref *ref, BMimeType *appMeta,
entry_ref *appRef, BFile *appFile,
bool *wasDocument) const;
status_t translate_type(const char *mimeType, BMimeType *appMeta,
entry_ref *appRef, BFile *appFile) const;
status_t sniff_file(const entry_ref *file, BNodeInfo *nodeInfo,
char *mimeType) const;
status_t send_to_running(team_id team, int argc, const char *const *args,
const BList *messageList, const entry_ref *ref,
bool readyToRun) const;
void InitMessengers();
void AddToRecentApps(const char *appSig) const;
void ClearRecentDocuments() const;
void ClearRecentFolders() const;
void ClearRecentApps() const;
void LoadRecentLists(const char *filename) const;
void SaveRecentLists(const char *filename) const;
BMessenger fMess;
BMessenger fMimeMess;
uint32 _reserved[3];
};
// global BRoster instance
extern const BRoster *be_roster;
#endif // _ROSTER_H
+12
View File
@@ -0,0 +1,12 @@
/*
* Copyright 2005, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _ARCH_PPC_DEBUGGER_H
#define _ARCH_PPC_DEBUGGER_H
struct debug_cpu_state {
uint32 dummy;
} __attribute__((aligned(8)));
#endif // _ARCH_PPC_DEBUGGER_H
+32
View File
@@ -0,0 +1,32 @@
/*
* Copyright 2005, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _ARCH_X86_DEBUGGER_H
#define _ARCH_X86_DEBUGGER_H
struct debug_cpu_state {
uint8 extended_regs[512];
uint32 gs;
uint32 fs;
uint32 es;
uint32 ds;
uint32 edi;
uint32 esi;
uint32 ebp;
uint32 esp;
uint32 ebx;
uint32 edx;
uint32 ecx;
uint32 eax;
uint32 vector;
uint32 error_code;
uint32 eip;
uint32 cs;
uint32 eflags;
uint32 user_esp;
uint32 user_ss;
} __attribute__((aligned(8)));
#endif // _ARCH_X86_DEBUGGER_H
@@ -0,0 +1,6 @@
#ifndef _DESKBAR_H
// I don't know why this file exists in addition to the one we include
// below, but who cares... (originally, in R5, both files exist and are
// identical).
# include <interface/Deskbar.h>
#endif
@@ -0,0 +1,51 @@
/*******************************************************************************
/
/ File: NetPositive.h
/
/ Description: Defines all public APIs for communicating with NetPositive
/
/ Copyright 1998-1999, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#ifndef _NETPOSITIVE_H
#define _NETPOSITIVE_H
/*----------------------------------------------------------------*/
/*----- message command constants -------------------------------*/
enum {
/* Can be sent to the NetPositive application, a window, or a replicant */
/* view. Put the URL in a String field named be:url */
B_NETPOSITIVE_OPEN_URL = 'NPOP',
/* Can be sent to a window or replicant view */
B_NETPOSITIVE_BACK = 'NPBK',
B_NETPOSITIVE_FORWARD = 'NPFW',
B_NETPOSITIVE_HOME = 'NPHM',
B_NETPOSITIVE_RELOAD = 'NPRL',
B_NETPOSITIVE_STOP = 'NPST',
B_NETPOSITIVE_DOWN = 'NPDN',
B_NETPOSITIVE_UP = 'NPUP'
};
/*----------------------------------------------------------------*/
/*----- NetPositive-related MIME types --------------------------*/
/* The MIME types for the NetPositive application and its bookmark files */
#define B_NETPOSITIVE_APP_SIGNATURE "application/x-vnd.Be-NPOS"
#define B_NETPOSITIVE_BOOKMARK_SIGNATURE "application/x-vnd.Be-bookmark"
/* To set up your application to receive notification when the user */
/* clicks on a specific type of URL (telnet URL's, for example), see the */
/* details in TypeConstants.h. NetPositive will use external handlers */
/* for all URL types except for http, https, file, netpositive, and */
/* javascript, which it always handles internally. To maintain */
/* compatibility with its previous behavior, if NetPositive does not */
/* find a handler for mailto URL's, it will instead launch the handler */
/* for "text/x-email". */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
#endif /* _NETPOSITIVE_H */
@@ -0,0 +1,68 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _TRACKER_BACKGROUND_H
#define _TRACKER_BACKGROUND_H
/*----------------------------------------------------------------*/
/*----- Tracker background attribute name ----------------------*/
#define B_BACKGROUND_INFO "be:bgndimginfo"
/*----------------------------------------------------------------*/
/*----- Tracker background BMessage entries --------------------*/
#define B_BACKGROUND_IMAGE "be:bgndimginfopath" // string path
#define B_BACKGROUND_MODE "be:bgndimginfomode" // int32, the enum below
#define B_BACKGROUND_ORIGIN "be:bgndimginfooffset" // BPoint
#define B_BACKGROUND_ERASE_TEXT "be:bgndimginfoerasetext" // bool
#define B_BACKGROUND_WORKSPACES "be:bgndimginfoworkspaces" // uint32
/*----------------------------------------------------------------*/
/*----- Background mode values ---------------------------------*/
enum {
B_BACKGROUND_MODE_USE_ORIGIN,
B_BACKGROUND_MODE_CENTERED, // only works on Desktop
B_BACKGROUND_MODE_SCALED, // only works on Desktop
B_BACKGROUND_MODE_TILED
};
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
const int32 B_RESTORE_BACKGROUND_IMAGE = 'Tbgr'; // force a Tracker window to
// use a new background image
#endif /* _TRACKER_BACKGROUND_H */
@@ -0,0 +1,207 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __RECENT_ITEMS_LIST__
#define __RECENT_ITEMS_LIST__
#include <Entry.h>
#include <Message.h>
#include <String.h>
/* BRecentItemsList classes allow creating an entire menu with
* recent files, folders, apps. If the user wishes to add items to
* their own menu, they can instead use the GetNextMenuItem call to
* get one menu at a time to add it to their app.
*/
class BMenuItem;
class BMenu;
class BRecentItemsList {
public:
BRecentItemsList(int32 maxItems, bool navMenuFolders);
/* if <navMenuFolders> passed, folder items get NavMenu-style
* subdirectories attached to them
*/
virtual ~BRecentItemsList() {}
virtual void Rewind();
/* resets the iteration */
virtual BMenuItem *GetNextMenuItem(const BMessage *fileOpenMessage = NULL,
const BMessage *containerOpenMessage = NULL,
BHandler *target = NULL, entry_ref *currentItemRef = NULL);
/* if <fileOpenMessage> specified, the item for a file gets a copy with
* the item ref attached as "refs", otherwise a default B_REFS_RECEIVED
* message message gets attached
* if <containerOpenMessage> specified, the item for a folder, volume or query
* gets a copy with the item ref attached as "refs", otherwise a default
* B_REFS_RECEIVED message message gets attached
* if <currentItemRef> gets passed, the caller gets to look at the
* entry_ref corresponding to the item
*/
virtual status_t GetNextRef(entry_ref *);
protected:
BMessage fItems;
int32 fIndex;
int32 fMaxItems;
bool fNavMenuFolders;
private:
virtual void _r1();
virtual void _r2();
virtual void _r3();
virtual void _r4();
virtual void _r5();
virtual void _r6();
virtual void _r7();
virtual void _r8();
virtual void _r9();
virtual void _r10();
uint32 _reserved[20];
};
class BRecentFilesList : public BRecentItemsList {
public:
/* use one of the two constructors to set up next item iteration */
BRecentFilesList(int32 maxItems = 10, bool navMenuFolders = false,
const char *ofType = NULL, const char *openedByAppSig = NULL);
BRecentFilesList(int32 maxItems, bool navMenuFolders, const char *ofTypeList[],
int32 ofTypeListCount, const char *openedByAppSig = NULL);
virtual ~BRecentFilesList();
/* use one of the two NewFileListMenu calls to get an entire menu */
static BMenu *NewFileListMenu(const char *title,
BMessage *openFileMessage = NULL, BMessage *openFolderMessage = NULL,
BHandler *target = NULL,
int32 maxItems = 10, bool navMenuFolders = false,
const char *ofType = NULL, const char *openedByAppSig = NULL);
static BMenu *NewFileListMenu(const char *title,
BMessage *openFileMessage, BMessage *openFolderMessage,
BHandler *target,
int32 maxItems, bool navMenuFolders,
const char *ofTypeList[], int32 ofTypeListCount,
const char *openedByAppSig);
virtual status_t GetNextRef(entry_ref *);
protected:
BString fType;
char **fTypes;
int32 fTypeCount;
BString fAppSig;
private:
virtual void _r11();
virtual void _r12();
virtual void _r13();
virtual void _r14();
virtual void _r15();
virtual void _r16();
virtual void _r17();
virtual void _r18();
virtual void _r19();
virtual void _r110();
uint32 _reserved[20];
};
class BRecentFoldersList : public BRecentItemsList {
public:
/* use the constructor to set up next item iteration */
BRecentFoldersList(int32 maxItems, bool navMenuFolders = false,
const char *openedByAppSig = NULL);
/* use NewFolderListMenu to get an entire menu */
static BMenu *NewFolderListMenu(const char *title,
BMessage *openMessage = NULL, BHandler *target = NULL,
int32 maxItems = 10, bool navMenuFolders = false,
const char *openedByAppSig = NULL);
virtual status_t GetNextRef(entry_ref *);
protected:
BString fAppSig;
private:
virtual void _r21();
virtual void _r22();
virtual void _r23();
virtual void _r24();
virtual void _r25();
virtual void _r26();
virtual void _r27();
virtual void _r28();
virtual void _r29();
virtual void _r210();
uint32 _reserved[20];
};
class BRecentAppsList : public BRecentItemsList {
public:
/* use the constructor to set up next item iteration */
BRecentAppsList(int32 maxItems);
/* use NewFolderListMenu to get an entire menu */
static BMenu *NewAppListMenu(const char *title,
BMessage *openMessage = NULL, BHandler *target = NULL,
int32 maxItems = 10);
virtual status_t GetNextRef(entry_ref *);
private:
virtual void _r31();
virtual void _r32();
virtual void _r33();
virtual void _r34();
virtual void _r35();
virtual void _r36();
virtual void _r37();
virtual void _r38();
virtual void _r39();
virtual void _r310();
uint32 _reserved[20];
};
#endif
+43
View File
@@ -0,0 +1,43 @@
/********************************************************************************
/
/ File: A2D.h
/
/ Description: Analog-to-Digital converter class header.
/
/ Copyright 1996-98, Be Incorporated, All Rights Reserved.
/
********************************************************************************/
#ifndef _A2D_H
#define _A2D_H
#include <BeBuild.h>
#include <stddef.h>
#include <SupportDefs.h>
/* -----------------------------------------------------------------------*/
class BA2D {
public:
BA2D();
virtual ~BA2D();
status_t Open(const char *portName);
void Close(void);
bool IsOpen(void);
ssize_t Read(ushort *buf);
/* -----------------------------------------------------------------------*/
private:
virtual void _ReservedA2D1();
virtual void _ReservedA2D2();
virtual void _ReservedA2D3();
int ffd;
uint32 _fReserved[3];
};
#endif
+711
View File
@@ -0,0 +1,711 @@
/* ++++++++++
CAM.h
Copyright (c) 1996-98 by Be Incorporated. All Rights Reserved.
Definitions for the SCSI Common Access Method as implemented in the Be OS.
See also "Draft Proposed American National Standard, SCSI-2 Common
Access Method Transport and SCSI Interface Module", Revision 12,
ANSI refernce number X3.232-199x.
This file consists of the definitions for the fictional "UNIVOS"
operating system described in the standard. The file is mostly
the same text as the standard, with Be-provided additions as needed.
+++++ */
#ifndef _CAM_H
#define _CAM_H
#include <bus_manager.h>
/* ---
Be-provided additions to the standard include file.
--- */
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef U32
typedef unsigned long U32;
#endif
#ifndef I32
typedef long I32;
#endif
#ifndef U16
typedef unsigned short U16;
#endif
typedef struct {
uint32 serial; /* operation serial number */
uint32 micros; /* operation time in microseconds (4294s max) */
uint32 bytes; /* number of bytes to transfer */
uchar path; /* target SIM ID */
uchar target; /* target device ID */
uchar sgcount; /* # of sg segments (0 if non-sg operation) */
uchar scsi_op; /* scsi operation byte */
} cam_iostat;
/* -----
The rest of this file contains the definitions and data structures for
the CAM Subsystem interface. The contents of this file should match the
data structures and constants that are specified in the CAM document
----- */
/* Defines for the XPT function codes, Table 8-2 in the CAM spec. */
/* Common function commands, 0x00 - 0x0F */
#define XPT_NOOP 0x00 /* Execute Nothing */
#define XPT_SCSI_IO 0x01 /* Execute the requested SCSI IO */
#define XPT_GDEV_TYPE 0x02 /* Get the device type information */
#define XPT_PATH_INQ 0x03 /* Path Inquiry */
#define XPT_REL_SIMQ 0x04 /* Release the SIM queue that is frozen */
#define XPT_SASYNC_CB 0x05 /* Set Async callback parameters */
#define XPT_SDEV_TYPE 0x06 /* Set the device type information */
#define XPT_SCAN_BUS 0x07 /* Scan the Scsi Bus */
/* XPT SCSI control functions, 0x10 - 0x1F */
#define XPT_ABORT 0x10 /* Abort the selected CCB */
#define XPT_RESET_BUS 0x11 /* Reset the SCSI bus */
#define XPT_RESET_DEV 0x12 /* Reset the SCSI device, BDR */
#define XPT_TERM_IO 0x13 /* Terminate the I/O process */
/* HBA engine commands, 0x20 - 0x2F */
#define XPT_ENG_INQ 0x20 /* HBA engine inquiry */
#define XPT_ENG_EXEC 0x21 /* HBA execute engine request */
/* Target mode commands, 0x30 - 0x3F */
#define XPT_EN_LUN 0x30 /* Enable LUN, Target mode support */
#define XPT_TARGET_IO 0x31 /* Execute the target IO request */
#define XPT_ACCEPT_TARG 0x32 /* Accept Host Target Mode CDB */
#define XPT_CONT_TARG 0x33 /* Cont. Host Target I/O Connection */
#define XPT_IMMED_NOTIFY 0x34 /* Notify Host Target driver of event*/
#define XPT_NOTIFY_ACK 0x35 /* Acknowledgement of event */
#define XPT_FUNC 0x7F /* TEMPLATE */
#define XPT_VUNIQUE 0x80 /* All the rest are vendor unique commands */
/* ---------------------------------------------------------------------- */
/* General allocation length defines for the CCB structures. */
#define IOCDBLEN 12 /* Space for the CDB bytes/pointer */
#define VUHBA 14 /* Vendor Unique HBA length */
#define SIM_ID 16 /* ASCII string len for SIM ID */
#define HBA_ID 16 /* ASCII string len for HBA ID */
#define BE_SIM_CCB_SIZE 1536 /* we want to allocate 1.5k chunks */
#define BE_SIM_SCSIIO_SIZE 88 /* sizeof(CAM_CCB_SCSIIO) - SIM_PRIV */
#define SIM_PRIV (BE_SIM_CCB_SIZE - BE_SIM_SCSIIO_SIZE) /* Length of SIM private data area */
/* SIM_PRIV (sim private data area) Terms and Conditions:
- the size of SIM_PRIV shall be such that sizeof(CCB_SIZE_UNION) = 1.5k
- all CCB's shall be allocated from locked, contiguous memory
- CCB's shall be aligned on 512 byte boundaries
- SIM_PRIV will be >= 1408 bytes
- this provides 128 8byte sg entries (512mb worth of pages, worstcase fragmentation)
- and 256 bytes for sense data and 128 bytes for whatever else the SIM needs
- These conditions are NULL and (void) where prohibited by law.
- All sales are final.
- Do not use near open flame.
*/
/* Structure definitions for the CAM control blocks, CCB's for the
subsystem. */
/* Common CCB header definition. */
typedef struct ccb_header
{
uint32 phys_addr; /* physical address of this CCB */
uint16 cam_ccb_len; /* Length of the entire CCB */
uchar cam_func_code; /* XPT function code */
uchar cam_status; /* Returned CAM subsystem status */
uchar cam_hrsvd0; /* Reserved field, for alignment */
uchar cam_path_id; /* Path ID for the request */
uchar cam_target_id; /* Target device ID */
uchar cam_target_lun; /* Target LUN number */
uint32 cam_flags; /* Flags for operation of the subsystem */
} CCB_HEADER;
/* Common SCSI functions. */
/* Union definition for the CDB space in the SCSI I/O request CCB */
typedef union cdb_un
{
uchar *cam_cdb_ptr; /* Pointer to the CDB bytes to send */
uchar cam_cdb_bytes[ IOCDBLEN ]; /* Area for the CDB to send */
} CDB_UN;
/* Get device type CCB */
typedef struct ccb_getdev
{
CCB_HEADER cam_ch; /* Header information fields */
char *cam_inq_data; /* Ptr to the inquiry data space */
uchar cam_pd_type; /* Periph device type from the TLUN */
} CCB_GETDEV;
/* Path inquiry CCB */
typedef struct ccb_pathinq
{
CCB_HEADER cam_ch; /* Header information fields */
uchar cam_version_num; /* Version number for the SIM/HBA */
uchar cam_hba_inquiry; /* Mimic of INQ byte 7 for the HBA */
uchar cam_target_sprt; /* Flags for target mode support */
uchar cam_hba_misc; /* Misc HBA feature flags */
uint16 cam_hba_eng_cnt; /* HBA engine count */
uchar cam_vuhba_flags[ VUHBA ]; /* Vendor unique capabilities */
uint32 cam_sim_priv; /* Size of SIM private data area */
uint32 cam_async_flags; /* Event cap. for Async Callback */
uchar cam_hpath_id; /* Highest path ID in the subsystem */
uchar cam_initiator_id; /* ID of the HBA on the SCSI bus */
uchar cam_prsvd0; /* Reserved field, for alignment */
uchar cam_prsvd1; /* Reserved field, for alignment */
char cam_sim_vid[ SIM_ID ]; /* Vendor ID of the SIM */
char cam_hba_vid[ HBA_ID ]; /* Vendor ID of the HBA */
uchar *cam_osd_usage; /* Ptr for the OSD specific area */
} CCB_PATHINQ;
/* Release SIM Queue CCB */
typedef struct ccb_relsim
{
CCB_HEADER cam_ch; /* Header information fields */
} CCB_RELSIM;
/* SCSI I/O Request CCB */
typedef struct ccb_scsiio
{
CCB_HEADER cam_ch; /* Header information fields */
uchar *cam_pdrv_ptr; /* Ptr used by the Peripheral driver */
CCB_HEADER *cam_next_ccb; /* Ptr to the next CCB for action */
uchar *cam_req_map; /* Ptr for mapping info on the Req. */
void (*cam_cbfcnp)(struct ccb_scsiio *);
/* Callback on completion function */
uchar *cam_data_ptr; /* Pointer to the data buf/SG list */
uint32 cam_dxfer_len; /* Data xfer length */
uchar *cam_sense_ptr; /* Pointer to the sense data buffer */
uchar cam_sense_len; /* Num of bytes in the Autosense buf */
uchar cam_cdb_len; /* Number of bytes for the CDB */
uint16 cam_sglist_cnt; /* Num of scatter gather list entries */
uint32 cam_sort; /* Value used by SIM to sort on */
uchar cam_scsi_status; /* Returned scsi device status */
uchar cam_sense_resid; /* Autosense resid length: 2's comp */
uchar cam_osd_rsvd1[2]; /* OSD Reserved field, for alignment */
int32 cam_resid; /* Transfer residual length: 2's comp */
CDB_UN cam_cdb_io; /* Union for CDB bytes/pointer */
uint32 cam_timeout; /* Timeout value */
uchar *cam_msg_ptr; /* Pointer to the message buffer */
uint16 cam_msgb_len; /* Num of bytes in the message buf */
uint16 cam_vu_flags; /* Vendor unique flags */
uchar cam_tag_action; /* What to do for tag queuing */
uchar cam_iorsvd0[3]; /* Reserved field, for alignment */
uchar cam_sim_priv[ SIM_PRIV ]; /* SIM private data area */
} CCB_SCSIIO;
/* Set Async Callback CCB */
typedef struct ccb_setasync
{
CCB_HEADER cam_ch; /* Header information fields */
uint32 cam_async_flags; /* Event enables for Callback resp */
void (*cam_async_func)(); /* Async Callback function address */
uchar *pdrv_buf; /* Buffer set aside by the Per. drv */
uchar pdrv_buf_len; /* The size of the buffer */
} CCB_SETASYNC;
/* Set device type CCB */
typedef struct ccb_setdev
{
CCB_HEADER cam_ch; /* Header information fields */
uchar cam_dev_type; /* Val for the dev type field in EDT */
} CCB_SETDEV;
/* SCSI Control Functions. */
/* Abort XPT Request CCB */
typedef struct ccb_abort
{
CCB_HEADER cam_ch; /* Header information fields */
CCB_HEADER *cam_abort_ch; /* Pointer to the CCB to abort */
} CCB_ABORT;
/* Reset SCSI Bus CCB */
typedef struct ccb_resetbus
{
CCB_HEADER cam_ch; /* Header information fields */
} CCB_RESETBUS;
/* Reset SCSI Device CCB */
typedef struct ccb_resetdev
{
CCB_HEADER cam_ch; /* Header information fields */
} CCB_RESETDEV;
/* Terminate I/O Process Request CCB */
typedef struct ccb_termio
{
CCB_HEADER cam_ch; /* Header information fields */
CCB_HEADER *cam_termio_ch; /* Pointer to the CCB to terminate */
} CCB_TERMIO;
/* Target mode structures. */
/* Host Target Mode Version 1 Enable LUN CCB */
typedef struct ccb_en_lun
{
CCB_HEADER cam_ch; /* Header information fields */
uint16 cam_grp6_len; /* Group 6 VU CDB length */
uint16 cam_grp7_len; /* Group 7 VU CDB length */
uchar *cam_ccb_listptr; /* Pointer to the target CCB list */
uint16 cam_ccb_listcnt; /* Count of Target CCBs in the list */
} CCB_EN_LUN;
/* Enable LUN CCB (HTM V2) */
typedef struct ccb_enable_lun
{
CCB_HEADER cam_ch; /* Header information fields */
uint16 cam_grp6_length; /* Group 6 Vendor Unique CDB Lengths */
uint16 cam_grp7_length; /* Group 7 Vendor Unique CDB Lengths */
uchar *cam_immed_notify_list; /* Ptr to Immediate Notify CCB list */
uint32 cam_immed_notify_cnt; /* Number of Immediate Notify CCBs */
uchar *cam_accept_targ_list; /* Ptr to Accept Target I/O CCB list */
uint32 cam_accept_targ_cnt; /* Number of Accept Target I/O CCBs */
uchar cam_sim_priv[ SIM_PRIV ]; /* SIM private data area */
} CCB_ENABLE_LUN;
/* Immediate Notify CCB */
typedef struct ccb_immed_notify
{
CCB_HEADER cam_ch; /* Header information fields */
uchar *cam_pdrv_ptr; /* Ptr used by the Peripheral driver */
void (*cam_cbfnot)(); /* Callback on notification function */
uchar *cam_sense_ptr; /* Pointer to the sense data buffer */
uchar cam_sense_len; /* Num of bytes in the Autosense buf */
uchar cam_init_id; /* ID of Initiator that selected */
uint16 cam_seq_id; /* Sequence Identifier */
uchar cam_msg_code; /* Message Code */
uchar cam_msg_args[7]; /* Message Arguments */
} CCB_IMMED_NOTIFY;
/* Notify Acknowledge CCB */
typedef struct ccb_notify_ack
{
CCB_HEADER cam_ch; /* Header information fields */
uint16 cam_seq_id; /* Sequence Identifier */
uchar cam_event; /* Event */
uchar cam_rsvd;
} CCB_NOTIFY_ACK;
/* Accept Target I/O CCB */
typedef struct ccb_accept_targ
{
CCB_HEADER cam_ch; /* Header information fields */
uchar *cam_pdrv_ptr; /* Ptr used by the Peripheral driver */
CCB_HEADER *cam_next_ccb; /* Ptr to the next CCB for action */
uchar *cam_req_map; /* Ptr for mapping info on the Req. */
void (*cam_cbfcnot)(); /* Callback on completion function */
uchar *cam_data_ptr; /* Pointer to the data buf/SG list */
uint32 cam_dxfer_len; /* Data xfer length */
uchar *cam_sense_ptr; /* Pointer to the sense data buffer */
uchar cam_sense_len; /* Num of bytes in the Autosense buf */
uchar cam_cdb_len; /* Number of bytes for the CDB */
uint16 cam_sglist_cnt; /* Num of scatter gather list entries */
uint32 cam_sort; /* Value used by SIM to sort on */
uchar cam_scsi_status; /* Returned scsi device status */
uchar cam_sense_resid; /* Autosense resid length: 2's comp */
uchar cam_osd_rsvd1[2]; /* OSD Reserved field, for alignment */
int32 cam_resid; /* Transfer residual length: 2's comp */
CDB_UN cam_cdb_io; /* Union for CDB bytes/pointer */
uint32 cam_timeout; /* Timeout value */
uchar *cam_msg_ptr; /* Pointer to the message buffer */
uint16 cam_msgb_len; /* Num of bytes in the message buf */
uint16 cam_vu_flags; /* Vendor unique flags */
uchar cam_tag_action; /* What to do for tag queuing */
uchar cam_tag_id; /* Tag ID */
uchar cam_initiator_id; /* Initiator ID */
uchar cam_iorsvd0[1]; /* Reserved field, for alignment */
uchar cam_sim_priv[ SIM_PRIV ]; /* SIM private data area */
} CCB_ACCEPT_TARG;
/* Continue Target I/O CCB */
typedef CCB_ACCEPT_TARG CCB_CONT_TARG;
/* HBA engine structures. */
typedef struct ccb_eng_inq
{
CCB_HEADER cam_ch; /* Header information fields */
uint16 cam_eng_num; /* The number for this inquiry */
uchar cam_eng_type; /* Returned engine type */
uchar cam_eng_algo; /* Returned algorithm type */
uint32 cam_eng_memory; /* Returned engine memory size */
} CCB_ENG_INQ;
typedef struct ccb_eng_exec /* NOTE: must match SCSIIO size */
{
CCB_HEADER cam_ch; /* Header information fields */
uchar *cam_pdrv_ptr; /* Ptr used by the Peripheral driver */
uint32 cam_engrsvd0; /* Reserved field, for alignment */
uchar *cam_req_map; /* Ptr for mapping info on the Req. */
void (*cam_cbfcnp)(); /* Callback on completion function */
uchar *cam_data_ptr; /* Pointer to the data buf/SG list */
uint32 cam_dxfer_len; /* Data xfer length */
uchar *cam_engdata_ptr; /* Pointer to the engine buffer data */
uchar cam_engrsvd1; /* Reserved field, for alignment */
uchar cam_engrsvd2; /* Reserved field, for alignment */
uint16 cam_sglist_cnt; /* Num of scatter gather list entries */
uint32 cam_dmax_len; /* Destination data maximum length */
uint32 cam_dest_len; /* Destination data length */
int32 cam_src_resid; /* Source residual length: 2's comp */
uchar cam_engrsvd3[12]; /* Reserved field, for alignment */
uint32 cam_timeout; /* Timeout value */
uint32 cam_engrsvd4; /* Reserved field, for alignment */
uint16 cam_eng_num; /* Engine number for this request */
uint16 cam_vu_flags; /* Vendor unique flags */
uchar cam_engrsvd5; /* Reserved field, for alignment */
uchar cam_engrsvd6[3]; /* Reserved field, for alignment */
uchar cam_sim_priv[ SIM_PRIV ]; /* SIM private data area */
} CCB_ENG_EXEC;
/* The sim_module_info definition is used to define the entry points for
the SIMs contained in the SCSI CAM subsystem. Each SIM file will
contain a declaration for it's entry. The address for this entry will
be stored in the cam_conftbl[] array along will all the other SIM
entries. */
typedef struct sim_module_info sim_module_info;
struct sim_module_info {
module_info minfo;
};
typedef struct CAM_SIM_ENTRY CAM_SIM_ENTRY;
struct CAM_SIM_ENTRY {
status_t (*sim_init)();
int32 (*sim_action)();
};
/* ---------------------------------------------------------------------- */
/* Defines for the CAM status field in the CCB header. */
#define CAM_REQ_INPROG 0x00 /* CCB request is in progress */
#define CAM_REQ_CMP 0x01 /* CCB request completed w/out error */
#define CAM_REQ_ABORTED 0x02 /* CCB request aborted by the host */
#define CAM_UA_ABORT 0x03 /* Unable to Abort CCB request */
#define CAM_REQ_CMP_ERR 0x04 /* CCB request completed with an err */
#define CAM_BUSY 0x05 /* CAM subsystem is busy */
#define CAM_REQ_INVALID 0x06 /* CCB request is invalid */
#define CAM_PATH_INVALID 0x07 /* Path ID supplied is invalid */
#define CAM_DEV_NOT_THERE 0x08 /* SCSI device not installed/there */
#define CAM_UA_TERMIO 0x09 /* Unable to Terminate I/O CCB req */
#define CAM_SEL_TIMEOUT 0x0A /* Target selection timeout */
#define CAM_CMD_TIMEOUT 0x0B /* Command timeout */
#define CAM_MSG_REJECT_REC 0x0D /* Message reject received */
#define CAM_SCSI_BUS_RESET 0x0E /* SCSI bus reset sent/received */
#define CAM_UNCOR_PARITY 0x0F /* Uncorrectable parity err occurred */
#define CAM_AUTOSENSE_FAIL 0x10 /* Autosense: Request sense cmd fail */
#define CAM_NO_HBA 0x11 /* No HBA detected Error */
#define CAM_DATA_RUN_ERR 0x12 /* Data overrun/underrun error */
#define CAM_UNEXP_BUSFREE 0x13 /* Unexpected BUS free */
#define CAM_SEQUENCE_FAIL 0x14 /* Target bus phase sequence failure */
#define CAM_CCB_LEN_ERR 0x15 /* CCB length supplied is inadequate */
#define CAM_PROVIDE_FAIL 0x16 /* Unable to provide requ. capability */
#define CAM_BDR_SENT 0x17 /* A SCSI BDR msg was sent to target */
#define CAM_REQ_TERMIO 0x18 /* CCB request terminated by the host */
#define CAM_HBA_ERR 0x19 /* Unrecoverable host bus adaptor err*/
#define CAM_BUS_RESET_DENIED 0x1A /* SCSI bus reset denied */
#define CAM_IDE 0x33 /* Initiator Detected Error Received */
#define CAM_RESRC_UNAVAIL 0x34 /* Resource unavailable */
#define CAM_UNACKED_EVENT 0x35 /* Unacknowledged event by host */
#define CAM_MESSAGE_RECV 0x36 /* Msg received in Host Target Mode */
#define CAM_INVALID_CDB 0x37 /* Invalid CDB recvd in HT Mode */
#define CAM_LUN_INVALID 0x38 /* LUN supplied is invalid */
#define CAM_TID_INVALID 0x39 /* Target ID supplied is invalid */
#define CAM_FUNC_NOTAVAIL 0x3A /* The requ. func is not available */
#define CAM_NO_NEXUS 0x3B /* Nexus is not established */
#define CAM_IID_INVALID 0x3C /* The initiator ID is invalid */
#define CAM_CDB_RECVD 0x3D /* The SCSI CDB has been received */
#define CAM_LUN_ALLREADY_ENAB 0x3E /* LUN already enabled */
#define CAM_SCSI_BUSY 0x3F /* SCSI bus busy */
#define CAM_SIM_QFRZN 0x40 /* The SIM queue is frozen w/this err */
#define CAM_AUTOSNS_VALID 0x80 /* Autosense data valid for target */
#define CAM_STATUS_MASK 0x3F /* Mask bits for just the status # */
/* ---------------------------------------------------------------------- */
/* Defines for the CAM flags field in the CCB header. */
#define CAM_DIR_RESV 0x00000000 /* Data direction (00: reserved) */
#define CAM_DIR_IN 0x00000040 /* Data direction (01: DATA IN) */
#define CAM_DIR_OUT 0x00000080 /* Data direction (10: DATA OUT) */
#define CAM_DIR_NONE 0x000000C0 /* Data direction (11: no data) */
#define CAM_DIS_AUTOSENSE 0x00000020 /* Disable autosense feature */
#define CAM_SCATTER_VALID 0x00000010 /* Scatter/gather list is valid */
#define CAM_DIS_CALLBACK 0x00000008 /* Disable callback feature */
#define CAM_CDB_LINKED 0x00000004 /* The CCB contains a linked CDB */
#define CAM_QUEUE_ENABLE 0x00000002 /* SIM queue actions are enabled */
#define CAM_CDB_POINTER 0x00000001 /* The CDB field contains a pointer */
#define CAM_DIS_DISCONNECT 0x00008000 /* Disable disconnect */
#define CAM_INITIATE_SYNC 0x00004000 /* Attempt Sync data xfer, and SDTR */
#define CAM_DIS_SYNC 0x00002000 /* Disable sync, go to async */
#define CAM_SIM_QHEAD 0x00001000 /* Place CCB at the head of SIM Q */
#define CAM_SIM_QFREEZE 0x00000800 /* Return the SIM Q to frozen state */
#define CAM_SIM_QFRZDIS 0x00000400 /* Disable the SIM Q frozen state */
#define CAM_ENG_SYNC 0x00000200 /* Flush resid bytes before cmplt */
#define CAM_ENG_SGLIST 0x00800000 /* The SG list is for the HBA engine */
#define CAM_CDB_PHYS 0x00400000 /* CDB pointer is physical */
#define CAM_DATA_PHYS 0x00200000 /* SG/Buffer data ptrs are physical */
#define CAM_SNS_BUF_PHYS 0x00100000 /* Autosense data ptr is physical */
#define CAM_MSG_BUF_PHYS 0x00080000 /* Message buffer ptr is physical */
#define CAM_NXT_CCB_PHYS 0x00040000 /* Next CCB pointer is physical */
#define CAM_CALLBCK_PHYS 0x00020000 /* Callback func ptr is physical */
#define CAM_SEND_STATUS 0x80000000 /* Send status after date phase */
#define CAM_DISCONNECT 0x40000000 /* Disc. mandatory after cdb recv */
#define CAM_TERM_IO 0x20000000 /* Terminate I/O Message supported */
#define CAM_DATAB_VALID 0x80000000 /* Data buffer valid */
#define CAM_STATUS_VALID 0x40000000 /* Status buffer valid */
#define CAM_MSGB_VALID 0x20000000 /* Message buffer valid */
#define CAM_TGT_PHASE_MODE 0x08000000 /* The SIM will run in phase mode */
#define CAM_TGT_CCB_AVAIL 0x04000000 /* Target CCB available */
#define CAM_DIS_AUTODISC 0x02000000 /* Disable autodisconnect */
#define CAM_DIS_AUTOSRP 0x01000000 /* Disable autosave/restore ptrs */
/* ---------------------------------------------------------------------- */
/* Defines for the SIM/HBA queue actions. These value are used in the
SCSI I/O CCB, for the queue action field. [These values should match the
defines from some other include file for the SCSI message phases. We may
not need these definitions here. ] */
#define CAM_SIMPLE_QTAG 0x20 /* Tag for a simple queue */
#define CAM_HEAD_QTAG 0x21 /* Tag for head of queue */
#define CAM_ORDERED_QTAG 0x22 /* Tag for ordered queue */
/* ---------------------------------------------------------------------- */
/* Defines for the timeout field in the SCSI I/O CCB. At this time a value
of 0xF-F indicates a infinite timeout. A value of 0x0-0 indicates that the
SIM's default timeout can take effect. */
#define CAM_TIME_DEFAULT 0x00000000 /* Use SIM default value */
#define CAM_TIME_INFINITY 0xFFFFFFFF /* Infinite timeout for I/O */
/* ---------------------------------------------------------------------- */
/* Defines for the Path Inquiry CCB fields. */
#define CAM_VERSION 0x25 /* Binary value for the current ver */
#define PI_MDP_ABLE 0x80 /* Supports MDP message */
#define PI_WIDE_32 0x40 /* Supports 32 bit wide SCSI */
#define PI_WIDE_16 0x20 /* Supports 16 bit wide SCSI */
#define PI_SDTR_ABLE 0x10 /* Supports SDTR message */
#define PI_LINKED_CDB 0x08 /* Supports linked CDBs */
#define PI_TAG_ABLE 0x02 /* Supports tag queue message */
#define PI_SOFT_RST 0x01 /* Supports soft reset */
#define PIT_PROCESSOR 0x80 /* Target mode processor mode */
#define PIT_PHASE 0x40 /* Target mode phase cog. mode */
#define PIM_SCANHILO 0x80 /* Bus scans from ID 7 to ID 0 */
#define PIM_NOREMOVE 0x40 /* Removable dev not included in scan */
#define PIM_NOINQUIRY 0x20 /* Inquiry data not kept by XPT */
/* ---------------------------------------------------------------------- */
/* Defines for Asynchronous Callback CCB fields. */
#define AC_FOUND_DEVICES 0x80 /* During a rescan new device found */
#define AC_SIM_DEREGISTER 0x40 /* A loaded SIM has de-registered */
#define AC_SIM_REGISTER 0x20 /* A loaded SIM has registered */
#define AC_SENT_BDR 0x10 /* A BDR message was sent to target */
#define AC_SCSI_AEN 0x08 /* A SCSI AEN has been received */
#define AC_UNSOL_RESEL 0x02 /* A unsolicited reselection occurred */
#define AC_BUS_RESET 0x01 /* A SCSI bus RESET occurred */
/* ---------------------------------------------------------------------- */
/* Typedef for a scatter/gather list element. */
typedef struct sg_elem
{
uchar *cam_sg_address; /* Scatter/Gather address */
uint32 cam_sg_count; /* Scatter/Gather count */
} SG_ELEM;
/* ---------------------------------------------------------------------- */
/* Defines for the "event" field in the CCB_NOTIFY_ACK */
#define CAM_RESET_CLEARED 0x80 /* Reset Cleared */
/* ---------------------------------------------------------------------- */
/* Defines for the HBA engine inquiry CCB fields. */
#define EIT_BUFFER 0x00 /* Engine type: Buffer memory */
#define EIT_LOSSLESS 0x01 /* Engine type: Lossless compression */
#define EIT_LOSSLY 0x02 /* Engine type: Lossly compression */
#define EIT_ENCRYPT 0x03 /* Engine type: Encryption */
#define EAD_VUNIQUE 0x00 /* Eng algorithm ID: vendor unique */
#define EAD_LZ1V1 0x00 /* Eng algorithm ID: LZ1 var. 1*/
#define EAD_LZ2V1 0x00 /* Eng algorithm ID: LZ2 var. 1*/
#define EAD_LZ2V2 0x00 /* Eng algorithm ID: LZ2 var. 2*/
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* Unix OSD defines and data structures. */
#define INQLEN 36 /* Inquiry string length to store. */
#define CAM_SUCCESS 0 /* For signaling general success */
#define CAM_FAILURE 1 /* For signaling general failure */
#define CAM_FALSE 0 /* General purpose flag value */
#define CAM_TRUE 1 /* General purpose flag value */
#define XPT_CCB_INVALID -1 /* for signaling a bad CCB to free */
/* The typedef for the Async callback information. This structure is used to
store the supplied info from the Set Async Callback CCB, in the EDT table
in a linked list structure. */
typedef struct async_info
{
struct async_info *cam_async_next; /* pointer to the next structure */
uint32 cam_event_enable; /* Event enables for Callback resp */
void (*cam_async_func)(); /* Async Callback function address */
uint32 cam_async_blen; /* Length of "information" buffer */
uchar *cam_async_ptr; /* Address for the "information */
} ASYNC_INFO;
/* The CAM EDT table contains the device information for all the
devices, SCSI ID and LUN, for all the SCSI busses in the system. The
table contains a CAM_EDT_ENTRY structure for each device on the bus.
*/
typedef struct cam_edt_entry
{
int32 cam_tlun_found; /* Flag for the existence of the target/LUN */
ASYNC_INFO *cam_ainfo; /* Async callback list info for this B/T/L */
uint32 cam_owner_tag; /* Tag for the peripheral driver's ownership */
char cam_inq_data[ INQLEN ]; /* storage for the inquiry data */
} CAM_EDT_ENTRY;
/* ============================================================================== */
/* ----------------------------- VENDOR UNIQUE DATA ----------------------------- */
/* ============================================================================== */
/* ---
Vendor unique XPT function codes
--- */
#define XPT_EXTENDED_PATH_INQ (XPT_VUNIQUE + 1) /* Extended Path Inquiry */
/* Extended path inquiry CCB */
#define FAM_ID 16 /* ASCII string len for FAMILY ID */
#define TYPE_ID 16 /* ASCII string len for TYPE ID */
#define VERS 8 /* ASCII string len for SIM & HBA vers */
typedef struct ccb_extended_pathinq
{
CCB_PATHINQ cam_path; /* Default path inquiry */
char cam_sim_version [ VERS ]; /* SIM version number */
char cam_hba_version [ VERS ]; /* HBA version number */
char cam_controller_family [ FAM_ID ]; /* Controller family */
char cam_controller_type [ TYPE_ID ]; /* Controller type */
} CCB_EXTENDED_PATHINQ;
/* ---
Vendor unique flags supported by Be OS (cam_vu_flags)
--- */
enum {
VU_RESERVED_0 = 0x0001,
VU_RESERVED_1 = 0x0002,
VU_DISABLE_SEL_W_ATN = 0x0004,
VU_RESERVED_4 = 0x0008
};
/* ---
XPT interface used by SCSI drivers
--- */
typedef struct cam_for_driver_module_info cam_for_driver_module_info;
struct cam_for_driver_module_info {
bus_manager_info minfo;
CCB_HEADER * (*xpt_ccb_alloc)(void);
void (*xpt_ccb_free)(void *ccb);
long (*xpt_action)(CCB_HEADER *ccbh);
};
#define B_CAM_FOR_DRIVER_MODULE_NAME "bus_managers/scsi/driver/v1"
/* ---
XPT interface used by SCSI SIMs
--- */
typedef struct cam_for_sim_module_info cam_for_sim_module_info;
struct cam_for_sim_module_info {
bus_manager_info minfo;
long (*xpt_bus_register) (CAM_SIM_ENTRY *sim);
long (*xpt_bus_deregister) (long path);
};
#define B_CAM_FOR_SIM_MODULE_NAME "bus_managers/scsi/sim/v1"
/* General Union for Kernel Space allocation. Contains all the possible CCB
structures. This union should never be used for manipulating CCB's its only
use is for the allocation and deallocation of raw CCB space. */
typedef union ccb_size_union
{
CCB_SCSIIO csio; /* Please keep this first, for debug/print */
CCB_GETDEV cgd;
CCB_PATHINQ cpi;
CCB_RELSIM crs;
CCB_SETASYNC csa;
CCB_SETDEV csd;
CCB_ABORT cab;
CCB_RESETBUS crb;
CCB_RESETDEV crd;
CCB_TERMIO ctio;
CCB_EN_LUN cel;
CCB_ENABLE_LUN cel2;
CCB_IMMED_NOTIFY cin;
CCB_NOTIFY_ACK cna;
CCB_ACCEPT_TARG cat;
CCB_ENG_INQ cei;
CCB_ENG_EXEC cee;
CCB_EXTENDED_PATHINQ cdpi;
} CCB_SIZE_UNION;
#ifdef __cplusplus
}
#endif
#endif
+45
View File
@@ -0,0 +1,45 @@
/********************************************************************************
/
/ File: D2A.h
/
/ Description: Digital-To-Analog converter class header.
/
/ Copyright 1996-98, Be Incorporated, All Rights Reserved.
/
********************************************************************************/
#ifndef _D2A_H
#define _D2A_H
#include <BeBuild.h>
#include <stddef.h>
#include <SupportDefs.h>
/* -----------------------------------------------------------------------*/
class BD2A {
public:
BD2A();
virtual ~BD2A();
status_t Open(const char *portName);
void Close(void);
bool IsOpen(void);
ssize_t Read(uint8 *buf);
ssize_t Write(uint8 value);
/* -----------------------------------------------------------------------*/
private:
virtual void _ReservedD2A1();
virtual void _ReservedD2A2();
virtual void _ReservedD2A3();
int ffd;
uint32 _fReserved[3];
};
#endif
+54
View File
@@ -0,0 +1,54 @@
/********************************************************************************
/
/ File: DigitalPort.h
/
/ Description: Digital Port class header.
/
/ Copyright 1996-98, Be Incorporated, All Rights Reserved.
/
********************************************************************************/
#ifndef _DIGITAL_PORT_H
#define _DIGITAL_PORT_H
#include <BeBuild.h>
#include <stddef.h>
#include <SupportDefs.h>
/* -----------------------------------------------------------------------*/
class BDigitalPort {
public:
BDigitalPort();
virtual ~BDigitalPort();
status_t Open(const char *portName);
void Close(void);
bool IsOpen(void);
ssize_t Read(uint8 *buf);
ssize_t Write(uint8 value);
status_t SetAsOutput (void);
bool IsOutput (void);
status_t SetAsInput (void);
bool IsInput (void);
/* -----------------------------------------------------------------------*/
private:
virtual void _ReservedDigitalPort1();
virtual void _ReservedDigitalPort2();
virtual void _ReservedDigitalPort3();
int ffd;
bool fIsInput;
uint32 _fReserved[3];
};
#endif
+118
View File
@@ -0,0 +1,118 @@
/********************************************************************************
/
/ File: Joystick.h
/
/ Description: Joystick port class header.
/
/ Copyright 1996-98, Be Incorporated, All Rights Reserved.
/
********************************************************************************/
#ifndef _JOYSTICK_H
#define _JOYSTICK_H
#include <BeBuild.h>
#include <SupportDefs.h>
#include <OS.h>
class BList;
struct _extended_joystick;
class _IMPEXP_DEVICE _BJoystickTweaker;
/* -----------------------------------------------------------------------*/
class BJoystick {
public:
BJoystick();
virtual ~BJoystick();
status_t Open(const char *portName); /* always goes for enhanced mode */
status_t Open(const char *portName, bool enter_enhanced);
void Close(void);
status_t Update(void);
status_t SetMaxLatency(
bigtime_t max_latency);
bigtime_t timestamp;
int16 horizontal;
int16 vertical;
bool button1; /* NOTE: true == off */
bool button2;
int32 CountDevices();
status_t GetDeviceName(int32 n, char * name,
size_t bufSize = B_OS_NAME_LENGTH);
/* if you care about more than just the first two axes/buttons, here's where you go */
bool EnterEnhancedMode(
const entry_ref * ref = NULL);
int32 CountSticks();
int32 CountAxes();
int32 CountHats();
int32 CountButtons();
status_t GetAxisValues(
int16 * out_values,
int32 for_stick = 0); /* CountAxes() elements */
status_t GetHatValues(
uint8 * out_hats,
int32 for_stick = 0);
uint32 ButtonValues(
int32 for_stick = 0); /* NOTE: Buttons() are 1 == on */
status_t GetAxisNameAt(
int32 index,
BString * out_name);
status_t GetHatNameAt(
int32 index,
BString * out_name);
status_t GetButtonNameAt(
int32 index,
BString * out_name);
status_t GetControllerModule(
BString * out_name);
status_t GetControllerName(
BString * out_name);
bool IsCalibrationEnabled();
status_t EnableCalibration(
bool calibrates = true);
/* -----------------------------------------------------------------------*/
protected:
virtual void Calibrate(
struct _extended_joystick * reading);
private:
friend class _BJoystickTweaker;
struct _joystick_info;
void ScanDevices(
bool use_disabled = false);
status_t gather_enhanced_info(
const entry_ref * ref = NULL);
status_t save_config(
const entry_ref * ref = NULL);
void _ReservedJoystick1();
virtual void _ReservedJoystick2();
virtual void _ReservedJoystick3();
bool _mBeBoxMode;
bool _mReservedBool;
int ffd;
BList * _fDevices;
_joystick_info * m_info;
char * m_dev_name;
#if !_PR3_COMPATIBLE_
virtual status_t _Reserved_Joystick_4(void *, ...);
virtual status_t _Reserved_Joystick_5(void *, ...);
virtual status_t _Reserved_Joystick_6(void *, ...);
uint32 _reserved_Joystick_[10];
#endif
};
#endif
+109
View File
@@ -0,0 +1,109 @@
/********************************************************************************
/
/ File: SerialPort.h
/
/ Description: Serial Port class header.
/
/ Copyright 1995-98, Be Incorporated, All Rights Reserved.
/
********************************************************************************/
#ifndef _SERIAL_PORT_H
#define _SERIAL_PORT_H
#include <BeBuild.h>
#include <stddef.h>
#include <OS.h>
#include <SupportDefs.h>
class BList;
enum data_rate { B_0_BPS = 0, B_50_BPS, B_75_BPS, B_110_BPS, B_134_BPS,
B_150_BPS, B_200_BPS, B_300_BPS, B_600_BPS, B_1200_BPS,
B_1800_BPS, B_2400_BPS, B_4800_BPS, B_9600_BPS, B_19200_BPS,
B_38400_BPS, B_57600_BPS, B_115200_BPS,
B_230400_BPS, B_31250_BPS };
enum data_bits { B_DATA_BITS_7, B_DATA_BITS_8 };
enum stop_bits { B_STOP_BITS_1, B_STOP_BITS_2 };
#define B_STOP_BIT_1 B_STOP_BITS_1
enum parity_mode { B_NO_PARITY, B_ODD_PARITY, B_EVEN_PARITY };
enum { B_NOFLOW_CONTROL = 0, B_HARDWARE_CONTROL = 0x00000001,
B_SOFTWARE_CONTROL = 0x00000002 };
/* -----------------------------------------------------------------------*/
class BSerialPort {
public:
BSerialPort();
virtual ~BSerialPort();
status_t Open(const char *portName);
void Close(void);
ssize_t Read(void *buf, size_t count);
ssize_t Write(const void *buf, size_t count);
void SetBlocking(bool Blocking);
status_t SetTimeout(bigtime_t microSeconds);
status_t SetDataRate(data_rate bitsPerSecond);
data_rate DataRate(void);
void SetDataBits(data_bits numBits);
data_bits DataBits(void);
void SetStopBits(stop_bits numBits);
stop_bits StopBits(void);
void SetParityMode(parity_mode which);
parity_mode ParityMode(void);
void ClearInput(void);
void ClearOutput(void);
void SetFlowControl(uint32 method);
uint32 FlowControl(void);
status_t SetDTR(bool asserted);
status_t SetRTS(bool asserted);
status_t NumCharsAvailable(int32 *wait_until_this_many);
bool IsCTS(void);
bool IsDSR(void);
bool IsRI(void);
bool IsDCD(void);
ssize_t WaitForInput(void);
/* -----------------------------------------------------------------------*/
int32 CountDevices();
status_t GetDeviceName(int32 n, char * name,
size_t bufSize = B_OS_NAME_LENGTH);
private:
void ScanDevices();
virtual void _ReservedSerialPort1();
virtual void _ReservedSerialPort2();
virtual void _ReservedSerialPort3();
virtual void _ReservedSerialPort4();
int ffd;
data_rate fBaudRate;
data_bits fDataBits;
stop_bits fStopBits;
parity_mode fParityMode;
uint32 fFlow;
bigtime_t fTimeout;
bool fBlocking;
int DriverControl();
BList * _fDevices;
uint32 _fReserved[3];
};
#endif
+20
View File
@@ -0,0 +1,20 @@
#if !defined(_GRAPHIC_DRIVER_H_)
#define _GRAPHIC_DRIVER_H_
#include <Drivers.h>
/* The API for driver access is C, not C++ */
#ifdef __cplusplus
extern "C" {
#endif
enum {
B_GET_ACCELERANT_SIGNATURE = B_GRAPHIC_DRIVER_BASE
};
#ifdef __cplusplus
}
#endif
#endif
+178
View File
@@ -0,0 +1,178 @@
/******************************************************************************
/
/ File: scsi.h
/
/ Description: Data structures and control calls for using the scsi driver.
/
/ Copyright 1992-98, Be Incorporated
/
*******************************************************************************/
#ifndef _SCSI_H
#define _SCSI_H
#include <SupportDefs.h>
#include <OS.h>
#include <Drivers.h>
/* scsi device types */
/*------------------------*/
#define B_SCSI_DISK 0x00
#define B_SCSI_TAPE 0x01
#define B_SCSI_PRINTER 0x02
#define B_SCSI_CPU 0x03
#define B_SCSI_WORM 0x04
#define B_SCSI_CD 0x05
#define B_SCSI_SCANNER 0x06
#define B_SCSI_OPTICAL 0x07
#define B_SCSI_JUKEBOX 0x08
#define B_SCSI_NETWORK 0x09
/* scsi device masks */
/*----------------------------------*/
#define B_SCSI_ALL_DEVICES_MASK 0xffffffff
#define B_SCSI_DISK_MASK (1 << (B_SCSI_DISK))
#define B_SCSI_TAPE_MASK (1 << (B_SCSI_TAPE))
#define B_SCSI_PRINTER_MASK (1 << (B_SCSI_PRINTER))
#define B_SCSI_CPU_MASK (1 << (B_SCSI_CPU))
#define B_SCSI_WORM_MASK (1 << (B_SCSI_WORM))
#define B_SCSI_CD_MASK (1 << (B_SCSI_CD))
#define B_SCSI_SCANNER_MASK (1 << (B_SCSI_SCANNER))
#define B_SCSI_OPTICAL_MASK (1 << (B_SCSI_OPTICAL))
#define B_SCSI_JUKEBOX_MASK (1 << (B_SCSI_JUKEBOX))
#define B_SCSI_NETWORK_MASK (1 << (B_SCSI_NETWORK))
/* control call codes for rescan scsi driver (/dev/scsi/rescan) */
/*-----------------------------------------------------*/
enum {
B_SCSI_SCAN_FOR_DEVICES = B_DEVICE_OP_CODES_END + 1,
B_SCSI_ENABLE_PROFILING
};
/* control calls for all individual scsi device drivers */
/*------------------------------------------------------*/
enum {
B_SCSI_INQUIRY = B_DEVICE_OP_CODES_END + 100,
B_SCSI_EJECT,
B_SCSI_PREVENT_ALLOW,
B_RAW_DEVICE_COMMAND
};
typedef struct {
uchar inquiry_data[36]; /* inquiry data (see SCSI standard) */
} scsi_inquiry;
/* control calls for scsi cd-rom driver */
/*--------------------------------------*/
enum {
B_SCSI_GET_TOC = B_DEVICE_OP_CODES_END + 200,
B_SCSI_PLAY_TRACK,
B_SCSI_PLAY_POSITION,
B_SCSI_STOP_AUDIO,
B_SCSI_PAUSE_AUDIO,
B_SCSI_RESUME_AUDIO,
B_SCSI_GET_POSITION,
B_SCSI_SET_VOLUME,
B_SCSI_GET_VOLUME,
B_SCSI_READ_CD,
B_SCSI_SCAN,
B_SCSI_DATA_MODE
};
typedef struct {
uchar toc_data[804]; /* table of contents data (see SCSI standard) */
} scsi_toc;
typedef struct {
uchar start_track; /* starting track */
uchar start_index; /* starting index */
uchar end_track; /* ending track */
uchar end_index; /* ending index */
} scsi_play_track;
typedef struct {
uchar start_m; /* starting minute */
uchar start_s; /* starting second */
uchar start_f; /* starting frame */
uchar end_m; /* ending minute */
uchar end_s; /* ending second */
uchar end_f; /* ending frame */
} scsi_play_position;
typedef struct {
uchar position[16]; /* position data (see SCSI standard) */
} scsi_position;
typedef struct {
uchar flags; /* A 1 in any position means change that field */
/* with port0_channel as bit 0 and port3_volume */
/* as bit 7. */
uchar port0_channel;
uchar port0_volume;
uchar port1_channel;
uchar port1_volume;
uchar port2_channel;
uchar port2_volume;
uchar port3_channel;
uchar port3_volume;
} scsi_volume;
#define B_SCSI_PORT0_CHANNEL 0x01
#define B_SCSI_PORT0_VOLUME 0x02
#define B_SCSI_PORT1_CHANNEL 0x04
#define B_SCSI_PORT1_VOLUME 0x08
#define B_SCSI_PORT2_CHANNEL 0x10
#define B_SCSI_PORT2_VOLUME 0x20
#define B_SCSI_PORT3_CHANNEL 0x40
#define B_SCSI_PORT3_VOLUME 0x80
typedef struct {
uchar start_m; /* starting minute */
uchar start_s; /* starting second */
uchar start_f; /* starting frame */
uchar length_m; /* transfer length minute */
uchar length_s; /* transfer length second */
uchar length_f; /* transfer length frame */
long buffer_length; /* size of read buffer */
char* buffer; /* buffer to hold requested data */
bool play; /* FALSE = don't play, TRUE = play */
} scsi_read_cd;
typedef struct {
char speed; /* 0 = slow - 5x, 1 = fast - 12x */
char direction; /* 1 = forward, 0 = stop scan, -1 = backward */
} scsi_scan;
typedef struct {
off_t block;
int32 mode;
} scsi_data_mode;
/* raw device commands */
typedef struct {
uint8 command[16];
uint8 command_length;
uint8 flags;
uint8 scsi_status; /* SCSI Status Byte */
/* (0 = success, 2 = check cond, ... */
uint8 cam_status; /* CAM_* status conditions from CAM.h */
void *data;
size_t data_length;
void *sense_data; /* buffer to return mode sense data in */
size_t sense_data_length; /* size of optional buffer for mode sense */
bigtime_t timeout;
} raw_device_command;
enum {
B_RAW_DEVICE_DATA_IN = 0x01,
B_RAW_DEVICE_REPORT_RESIDUAL = 0x02,
B_RAW_DEVICE_SHORT_READ_VALID = 0x04
};
#endif
@@ -0,0 +1,29 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
Part of Open SCSI bus manager
Devfs entry for raw bus access.
This interface will go away. It's used by scsi_probe as
long as we have no proper pnpfs where all the info can
be retrieved from.
*/
#ifndef _SCSI_BUS_RAW_DRIVER_H
#define _SCSI_BUS_RAW_DRIVER_H
#include <Drivers.h>
// we start with +300 to not collide with any other SCSI opcode defined
// in scsiprobe_driver.h or scsi.h;
// all ioctl calls return the subsystem status (see SCSI.h)
enum {
B_SCSI_BUS_RAW_RESET = B_DEVICE_OP_CODES_END + 300,
B_SCSI_BUS_RAW_PATH_INQUIRY
};
#endif
+122
View File
@@ -0,0 +1,122 @@
/* ACPI Bus Manger Interface
* Copyright 2005, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License
*/
#ifndef _ACPI_H
#define _ACPI_H
#include <bus_manager.h>
#include <KernelExport.h>
typedef struct acpi_module_info acpi_module_info;
typedef struct acpi_object_type acpi_object_type;
struct acpi_module_info {
bus_manager_info binfo;
/* Fixed Event Management */
void (*enable_fixed_event) (uint32 event);
void (*disable_fixed_event) (uint32 event);
uint32 (*fixed_event_status) (uint32 event);
/* Returns 1 if event set, 0 otherwise */
void (*reset_fixed_event) (uint32 event);
status_t (*install_fixed_event_handler) (uint32 event, interrupt_handler *handler, void *data);
status_t (*remove_fixed_event_handler) (uint32 event, interrupt_handler *handler);
/* Namespace Access */
status_t (*get_next_entry) (uint32 object_type, const char *base, char *result, size_t len, void **counter);
status_t (*get_device) (const char *hid, uint32 index, char *result);
status_t (*get_device_hid) (const char *path, char *hid);
uint32 (*get_object_type) (const char *path);
/* Control method execution and data acquisition */
status_t (*evaluate_object) (const char *object, acpi_object_type *return_value, size_t buf_len);
status_t (*evaluate_method) (const char *object, const char *method, acpi_object_type *return_value, size_t buf_len, acpi_object_type *args, int num_args);
/* Power state setting */
status_t (*enter_sleep_state) (uint8 state);
/* Sleep state values:
0: On (Working)
1: Sleep
2: Software Off
3: Mechanical Off
4: Hibernate
5: Software Off */
};
#ifndef __ACTYPES_H__
/* ACPI fixed event types */
enum {
ACPI_EVENT_PMTIMER = 0,
ACPI_EVENT_GLOBAL,
ACPI_EVENT_POWER_BUTTON,
ACPI_EVENT_SLEEP_BUTTON,
ACPI_EVENT_RTC
};
/* ACPI Object Types */
enum {
ACPI_TYPE_ANY = 0,
ACPI_TYPE_INTEGER,
ACPI_TYPE_STRING,
ACPI_TYPE_BUFFER,
ACPI_TYPE_PACKAGE,
ACPI_TYPE_FIELD_UNIT,
ACPI_TYPE_DEVICE,
ACPI_TYPE_EVENT,
ACPI_TYPE_METHOD,
ACPI_TYPE_MUTEX,
ACPI_TYPE_REGION,
ACPI_TYPE_POWER,
ACPI_TYPE_PROCESSOR,
ACPI_TYPE_THERMAL,
ACPI_TYPE_BUFFER_FIELD
};
/* ACPI control method arg type */
struct acpi_object_type {
uint32 object_type;
union {
uint32 integer;
struct {
uint32 len;
char *string; /* You have to allocate string space yourself */
} string;
struct {
size_t length;
void *buffer;
} buffer;
struct {
uint32 count;
acpi_object_type *objects;
} package;
struct {
uint32 cpu_id;
int pblk_address;
size_t pblk_length;
} processor;
struct {
uint32 min_power_state;
uint32 resource_order;
} power_resource;
} data;
};
#endif
#define B_ACPI_MODULE_NAME "bus_managers/acpi/v1"
#endif /* _ACPI_H */
+213
View File
@@ -0,0 +1,213 @@
#ifndef _DRIVERS_DRIVERS_H
#define _DRIVERS_DRIVERS_H
#include <BeBuild.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <SupportDefs.h>
#include <Select.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ---
these hooks are how the kernel accesses the device
--- */
typedef status_t (*device_open_hook) (const char *name, uint32 flags, void **cookie);
typedef status_t (*device_close_hook) (void *cookie);
typedef status_t (*device_free_hook) (void *cookie);
typedef status_t (*device_control_hook) (void *cookie, uint32 op, void *data,
size_t len);
typedef status_t (*device_read_hook) (void *cookie, off_t position, void *data,
size_t *numBytes);
typedef status_t (*device_write_hook) (void *cookie, off_t position,
const void *data, size_t *numBytes);
typedef status_t (*device_select_hook) (void *cookie, uint8 event, uint32 ref,
selectsync *sync);
typedef status_t (*device_deselect_hook) (void *cookie, uint8 event,
selectsync *sync);
typedef status_t (*device_read_pages_hook)(void *cookie, off_t position, const iovec *vec,
size_t count, size_t *_numBytes);
typedef status_t (*device_write_pages_hook) (void *cookie, off_t position, const iovec *vec,
size_t count, size_t *_numBytes);
#define B_CUR_DRIVER_API_VERSION 2
/* ---
the device_hooks structure is a descriptor for the device, giving its
entry points.
--- */
typedef struct {
device_open_hook open; /* called to open the device */
device_close_hook close; /* called to close the device */
device_free_hook free; /* called to free the cookie */
device_control_hook control; /* called to control the device */
device_read_hook read; /* reads from the device */
device_write_hook write; /* writes to the device */
device_select_hook select; /* start select */
device_deselect_hook deselect; /* stop select */
device_read_pages_hook read_pages; /* scatter-gather physical read from the device */
device_write_pages_hook write_pages; /* scatter-gather physical write to the device */
} device_hooks;
status_t init_hardware(void);
const char **publish_devices(void);
device_hooks *find_device(const char *name);
status_t init_driver(void);
void uninit_driver(void);
extern int32 api_version;
enum {
B_GET_DEVICE_SIZE = 1, /* get # bytes */
/* returns size_t in *data */
B_SET_DEVICE_SIZE, /* set # bytes */
/* passed size_t in *data */
B_SET_NONBLOCKING_IO, /* set to non-blocking i/o */
B_SET_BLOCKING_IO, /* set to blocking i/o */
B_GET_READ_STATUS, /* check if can read w/o blocking */
/* returns bool in *data */
B_GET_WRITE_STATUS, /* check if can write w/o blocking */
/* returns bool in *data */
B_GET_GEOMETRY, /* get info about device geometry */
/* returns struct geometry in *data */
B_GET_DRIVER_FOR_DEVICE, /* get the path of the executable serving that device */
B_GET_PARTITION_INFO, /* get info about a device partition */
/* returns struct partition_info in *data */
B_SET_PARTITION, /* create a user-defined partition */
B_FORMAT_DEVICE, /* low-level device format */
B_EJECT_DEVICE, /* eject the media if supported */
B_GET_ICON, /* return device icon (see struct below) */
B_GET_BIOS_GEOMETRY, /* get info about device geometry */
/* as reported by the bios */
/* returns struct geometry in *data */
B_GET_MEDIA_STATUS, /* get status of media. */
/* return status_t in *data: */
/* B_NO_ERROR: media ready */
/* B_DEV_NO_MEDIA: no media */
/* B_DEV_NOT_READY: device not ready */
/* B_DEV_MEDIA_CHANGED: media changed */
/* since open or last B_GET_MEDIA_STATUS */
/* B_DEV_MEDIA_CHANGE_REQUESTED: user */
/* pressed button on drive */
/* B_DEV_DOOR_OPEN: door open */
B_LOAD_MEDIA, /* load the media if supported */
B_GET_BIOS_DRIVE_ID, /* get bios id for this device */
B_SET_UNINTERRUPTABLE_IO, /* prevent cntl-C from interrupting i/o */
B_SET_INTERRUPTABLE_IO, /* allow cntl-C to interrupt i/o */
B_FLUSH_DRIVE_CACHE, /* flush drive cache */
B_GET_NEXT_OPEN_DEVICE = 1000, /* iterate through open devices */
B_ADD_FIXED_DRIVER, /* private */
B_REMOVE_FIXED_DRIVER, /* private */
B_AUDIO_DRIVER_BASE = 8000, /* base for codes in audio_driver.h */
B_MIDI_DRIVER_BASE = 8100, /* base for codes in midi_driver.h */
B_JOYSTICK_DRIVER_BASE = 8200, /* base for codes in joystick.h */
B_GRAPHIC_DRIVER_BASE = 8300, /* base for codes in graphic_driver.h */
B_DEVICE_OP_CODES_END = 9999 /* end of Be-defined contol id's */
};
/* ---
geometry structure for the B_GET_GEOMETRY opcode
--- */
typedef struct {
uint32 bytes_per_sector; /* sector size in bytes */
uint32 sectors_per_track; /* # sectors per track */
uint32 cylinder_count; /* # cylinders */
uint32 head_count; /* # heads */
uchar device_type; /* type */
bool removable; /* non-zero if removable */
bool read_only; /* non-zero if read only */
bool write_once; /* non-zero if write-once */
} device_geometry;
/* ---
Be-defined device types returned by B_GET_GEOMETRY. Use these if it makes
sense for your device.
--- */
enum {
B_DISK = 0, /* Hard disks, floppy disks, etc. */
B_TAPE, /* Tape drives */
B_PRINTER, /* Printers */
B_CPU, /* CPU devices */
B_WORM, /* Write-once, read-many devices */
B_CD, /* CD ROMS */
B_SCANNER, /* Scanners */
B_OPTICAL, /* Optical devices */
B_JUKEBOX, /* Jukeboxes */
B_NETWORK /* Network devices */
};
/* ---
partition_info structure used by B_GET_PARTITION_INFO and B_SET_PARTITION
--- */
typedef struct {
off_t offset; /* offset (in bytes) */
off_t size; /* size (in bytes) */
int32 logical_block_size; /* logical block size of partition */
int32 session; /* id of session */
int32 partition; /* id of partition */
char device[256]; /* path to the physical device */
} partition_info;
/* ---
driver_path structure returned by the B_GET_DRIVER_FOR_DEVICE
--- */
typedef char driver_path[256];
/* ---
open_device_iterator structure used by the B_GET_NEXT_OPEN_DEVICE opcode
--- */
typedef struct {
uint32 cookie; /* must be set to 0 before iterating */
char device[256]; /* device path */
} open_device_iterator;
/* ---
icon structure for the B_GET_ICON opcode
--- */
typedef struct {
int32 icon_size; /* icon size requested */
void *icon_data; /* where to put 'em (usually BBitmap->Bits()) */
} device_icon;
#ifdef __cplusplus
}
#endif
#endif /* _DRIVERS_DRIVERS_H */
+84
View File
@@ -0,0 +1,84 @@
/*******************************************************************************
/
/ File: ISA.h
/
/ Description: Interface to ISA module
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _ISA_H
#define _ISA_H
//#include <SupportDefs.h>
#include <bus_manager.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ---
ISA scatter/gather dma support.
--- */
typedef struct {
ulong address; /* memory address (little endian!) 4 bytes */
ushort transfer_count; /* # transfers minus one (little endian!) 2 bytes*/
uchar reserved; /* filler, 1byte*/
uchar flag; /* end of link flag, 1byte */
} isa_dma_entry;
#define B_LAST_ISA_DMA_ENTRY 0x80 /* sets end of link flag in isa_dma_entry */
enum {
B_8_BIT_TRANSFER,
B_16_BIT_TRANSFER
};
#define B_MAX_ISA_DMA_COUNT 0x10000
typedef struct isa_module_info isa_module_info;
struct isa_module_info {
bus_manager_info binfo;
uint8 (*read_io_8) (int mapped_io_addr);
void (*write_io_8) (int mapped_io_addr, uint8 value);
uint16 (*read_io_16) (int mapped_io_addr);
void (*write_io_16) (int mapped_io_addr, uint16 value);
uint32 (*read_io_32) (int mapped_io_addr);
void (*write_io_32) (int mapped_io_addr, uint32 value);
void * (*ram_address) (const void *physical_address_in_system_memory);
long (*make_isa_dma_table) (
const void *buffer, /* buffer to make a table for */
long buffer_size, /* buffer size */
ulong num_bits, /* dma transfer size that will be used */
isa_dma_entry *table, /* -> caller-supplied scatter/gather table */
long num_entries /* max # entries in table */
);
long (*start_isa_dma) (
long channel, /* dma channel to use */
void *buf, /* buffer to transfer */
long transfer_count, /* # transfers */
uchar mode, /* mode flags */
uchar e_mode /* extended mode flags */
);
long (*start_scattered_isa_dma) (
long channel, /* channel # to use */
const isa_dma_entry *table, /* physical address of scatter/gather table */
uchar mode, /* mode flags */
uchar emode /* extended mode flags */
);
long (*lock_isa_dma_channel) (long channel);
long (*unlock_isa_dma_channel) (long channel);
};
#define B_ISA_MODULE_NAME "bus_managers/isa/v1"
#ifdef __cplusplus
}
#endif
#endif /* _ISA_H */
+222
View File
@@ -0,0 +1,222 @@
/* Kernel only exports for kernel add-ons
*
* Copyright 2005, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_EXPORT_H
#define _KERNEL_EXPORT_H
#include <SupportDefs.h>
#include <OS.h>
#ifdef __cplusplus
extern "C" {
#endif
/*-------------------------------------------------------------*/
/* interrupts and spinlocks */
/* disable/restore interrupts on the current CPU */
typedef ulong cpu_status;
extern cpu_status disable_interrupts(void);
extern void restore_interrupts(cpu_status status);
/* spinlocks. Note that acquire/release should be called with
* interrupts disabled.
*/
typedef vint32 spinlock;
extern void acquire_spinlock(spinlock *lock);
extern void release_spinlock(spinlock *lock);
/* interrupt handling support for device drivers */
typedef int32 (*interrupt_handler)(void *data);
/* Values returned by interrupt handlers */
#define B_UNHANDLED_INTERRUPT 0 /* pass to next handler */
#define B_HANDLED_INTERRUPT 1 /* don't pass on */
#define B_INVOKE_SCHEDULER 2 /* don't pass on; invoke the scheduler */
/* Flags that can be passed to install_io_interrupt_handler() */
#define B_NO_ENABLE_COUNTER 1
extern status_t install_io_interrupt_handler(long interrupt_number,
interrupt_handler handler, void *data, ulong flags);
extern status_t remove_io_interrupt_handler(long interrupt_number,
interrupt_handler handler, void *data);
/*-------------------------------------------------------------*/
/* timer interrupts services */
/* The BeOS qent structure is probably part of a general double linked list
* interface used all over the kernel; a struct is required to have a qent
* entry struct as first element, so it can be linked to other elements
* easily. The key field is probably just an id, eventually used to order
* the list.
* Since we don't use this kind of interface, but we have to provide it
* to keep compatibility, we can use the qent struct for other purposes...
*
* ToDo: don't do this! Drop source compatibility, but don't overdefine those values!
*/
typedef struct qent {
int64 key; /* We use this as the sched time */
struct qent *next; /* This is used as a pointer to next timer */
struct qent *prev; /* This can be used for callback args */
} qent;
typedef struct timer timer;
typedef int32 (*timer_hook)(timer *);
struct timer {
qent entry;
uint16 flags;
uint16 cpu;
timer_hook hook;
bigtime_t period;
};
#define B_ONE_SHOT_ABSOLUTE_TIMER 1
#define B_ONE_SHOT_RELATIVE_TIMER 2
#define B_PERIODIC_TIMER 3
extern status_t add_timer(timer *t, timer_hook hook, bigtime_t period, int32 flags);
extern bool cancel_timer(timer *t);
/*-------------------------------------------------------------*/
/* kernel threads */
extern thread_id spawn_kernel_thread(thread_func function, const char *threadName,
int32 priority, void *arg);
/*-------------------------------------------------------------*/
/* signal functions */
extern int send_signal_etc(pid_t thread, uint sig, uint32 flags);
/*-------------------------------------------------------------*/
/* virtual memory buffer functions */
#define B_DMA_IO 0x00000001
#define B_READ_DEVICE 0x00000002
typedef struct {
void *address; /* address in physical memory */
ulong size; /* size of block */
} physical_entry;
extern long lock_memory(void *buffer, ulong numBytes, ulong flags);
extern long unlock_memory(void *buffer, ulong numBytes, ulong flags);
extern long get_memory_map(const void *buffer, ulong size,
physical_entry *table, long numEntries);
/* address specifications for mapping physical memory */
#define B_ANY_KERNEL_BLOCK_ADDRESS (B_ANY_KERNEL_ADDRESS + 1)
/* area protection flags for the kernel */
#define B_KERNEL_READ_AREA 16
#define B_KERNEL_WRITE_AREA 32
#define B_USER_CLONEABLE_AREA 256
/* call to map physical memory - typically used for memory-mapped i/o */
extern area_id map_physical_memory(const char *areaName, void *physicalAddress,
size_t size, uint32 flags, uint32 protection, void **mappedAddress);
/* MTR attributes for mapping physical memory (Intel Architecture only) */
// ToDo: what have those to do here?
#define B_MTR_UC 0x10000000
#define B_MTR_WC 0x20000000
#define B_MTR_WT 0x30000000
#define B_MTR_WP 0x40000000
#define B_MTR_WB 0x50000000
#define B_MTR_MASK 0xf0000000
/*-------------------------------------------------------------*/
/* hardware inquiry */
/* platform_type return value is defined in OS.h */
extern platform_type platform();
#if __POWERPC__
extern long motherboard_version(void);
extern long io_card_version(void);
#endif
/*-------------------------------------------------------------*/
/* primitive kernel debugging facilities */
/* Standard debug output is on...
* mac: modem port
* pc: com1
* ...at 19.2 kbaud, no parity, 8 bit, 1 stop bit.
*
* Note: the kernel settings file can override these defaults
*/
#if __GNUC__
extern void dprintf(const char *format, ...) /* just like printf */
__attribute__ ((format (__printf__, 1, 2)));
extern void kprintf(const char *fmt, ...) /* only for debugger cmds */
__attribute__ ((format (__printf__, 1, 2)));
#else
extern void dprintf(const char *format, ...); /* just like printf */
extern void kprintf(const char *fmt, ...); /* only for debugger cmds */
#endif
extern bool set_dprintf_enabled(bool new_state); /* returns old state */
extern void panic(const char *format, ...);
extern void kernel_debugger(const char *message); /* enter kernel debugger */
extern uint32 parse_expression(const char *string); /* utility for debugger cmds */
/* special return codes for kernel debugger */
#define B_KDEBUG_CONT 2
#define B_KDEBUG_QUIT 3
typedef int (*debugger_command_hook)(int argc, char **argv);
extern int add_debugger_command(char *name, debugger_command_hook hook, char *help);
extern int remove_debugger_command(char *name, debugger_command_hook hook);
extern status_t load_driver_symbols(const char *driverName);
/*-------------------------------------------------------------*/
/* misc */
extern void spin(bigtime_t microseconds);
/* does a busy delay loop for at least "microseconds" */
typedef void (*daemon_hook)(void *arg, int iteration);
extern status_t register_kernel_daemon(daemon_hook hook, void *arg, int frequency);
extern status_t unregister_kernel_daemon(daemon_hook hook, void *arg);
extern void call_all_cpus(void (*f)(void *, int), void *cookie);
/* safe methods to access user memory without having to lock it */
extern status_t user_memcpy(void *to, const void *from, size_t size);
extern ssize_t user_strlcpy(char *to, const char *from, size_t size);
extern status_t user_memset(void *start, char c, size_t count);
#ifdef __cplusplus
}
#endif
#endif /* _KERNEL_EXPORT_H */
+604
View File
@@ -0,0 +1,604 @@
/*******************************************************************************
/
/ File: PCI.h
/
/ Description: Interface to the PCI bus.
/ For more information, see "PCI Local Bus Specification, Revision 2.1",
/ PCI Special Interest Group, 1995.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _PCI_H
#define _PCI_H
//#include <BeBuild.h>
//#include <SupportDefs.h>
#include <bus_manager.h>
#ifdef __cplusplus
extern "C" {
#endif
/* -----
pci device info
----- */
typedef struct pci_info {
ushort vendor_id; /* vendor id */
ushort device_id; /* device id */
uchar bus; /* bus number */
uchar device; /* device number on bus */
uchar function; /* function number in device */
uchar revision; /* revision id */
uchar class_api; /* specific register interface type */
uchar class_sub; /* specific device function */
uchar class_base; /* device type (display vs network, etc) */
uchar line_size; /* cache line size in 32 bit words */
uchar latency; /* latency timer */
uchar header_type; /* header type */
uchar bist; /* built-in self-test */
uchar reserved; /* filler, for alignment */
union {
struct {
ulong cardbus_cis; /* CardBus CIS pointer */
ushort subsystem_id; /* subsystem (add-in card) id */
ushort subsystem_vendor_id; /* subsystem (add-in card) vendor id */
ulong rom_base; /* rom base address, viewed from host */
ulong rom_base_pci; /* rom base addr, viewed from pci */
ulong rom_size; /* rom size */
ulong base_registers[6]; /* base registers, viewed from host */
ulong base_registers_pci[6]; /* base registers, viewed from pci */
ulong base_register_sizes[6]; /* size of what base regs point to */
uchar base_register_flags[6]; /* flags from base address fields */
uchar interrupt_line; /* interrupt line */
uchar interrupt_pin; /* interrupt pin */
uchar min_grant; /* burst period @ 33 Mhz */
uchar max_latency; /* how often PCI access needed */
} h0;
struct {
ulong base_registers[2]; /* base registers, viewed from host */
ulong base_registers_pci[2]; /* base registers, viewed from pci */
ulong base_register_sizes[2]; /* size of what base regs point to */
uchar base_register_flags[2]; /* flags from base address fields */
uchar primary_bus;
uchar secondary_bus;
uchar subordinate_bus;
uchar secondary_latency;
uchar io_base;
uchar io_limit;
ushort secondary_status;
ushort memory_base;
ushort memory_limit;
ushort prefetchable_memory_base;
ushort prefetchable_memory_limit;
ulong prefetchable_memory_base_upper32;
ulong prefetchable_memory_limit_upper32;
ushort io_base_upper16;
ushort io_limit_upper16;
ulong rom_base; /* rom base address, viewed from host */
ulong rom_base_pci; /* rom base addr, viewed from pci */
uchar interrupt_line; /* interrupt line */
uchar interrupt_pin; /* interrupt pin */
ushort bridge_control;
ushort subsystem_id; /* subsystem (add-in card) id */
ushort subsystem_vendor_id; /* subsystem (add-in card) vendor id */
} h1;
struct {
ushort subsystem_id; /* subsystem (add-in card) id */
ushort subsystem_vendor_id; /* subsystem (add-in card) vendor id */
} h2;
} u;
} pci_info;
typedef struct pci_module_info pci_module_info;
struct pci_module_info {
bus_manager_info binfo;
uint8 (*read_io_8) (int mapped_io_addr);
void (*write_io_8) (int mapped_io_addr, uint8 value);
uint16 (*read_io_16) (int mapped_io_addr);
void (*write_io_16) (int mapped_io_addr, uint16 value);
uint32 (*read_io_32) (int mapped_io_addr);
void (*write_io_32) (int mapped_io_addr, uint32 value);
long (*get_nth_pci_info) (
long index, /* index into pci device table */
pci_info *info /* caller-supplied buffer for info */
);
uint32 (*read_pci_config) (
uchar bus, /* bus number */
uchar device, /* device # on bus */
uchar function, /* function # in device */
uchar offset, /* offset in configuration space */
uchar size /* # bytes to read (1, 2 or 4) */
);
void (*write_pci_config) (
uchar bus, /* bus number */
uchar device, /* device # on bus */
uchar function, /* function # in device */
uchar offset, /* offset in configuration space */
uchar size, /* # bytes to write (1, 2 or 4) */
uint32 value /* value to write */
);
void * (*ram_address) (const void *physical_address_in_system_memory);
};
#define B_PCI_MODULE_NAME "bus_managers/pci/v1"
/* ---
offsets in PCI configuration space to the elements of the predefined
header common to all header types
--- */
#define PCI_vendor_id 0x00 /* (2 byte) vendor id */
#define PCI_device_id 0x02 /* (2 byte) device id */
#define PCI_command 0x04 /* (2 byte) command */
#define PCI_status 0x06 /* (2 byte) status */
#define PCI_revision 0x08 /* (1 byte) revision id */
#define PCI_class_api 0x09 /* (1 byte) specific register interface type */
#define PCI_class_sub 0x0a /* (1 byte) specific device function */
#define PCI_class_base 0x0b /* (1 byte) device type (display vs network, etc) */
#define PCI_line_size 0x0c /* (1 byte) cache line size in 32 bit words */
#define PCI_latency 0x0d /* (1 byte) latency timer */
#define PCI_header_type 0x0e /* (1 byte) header type */
#define PCI_bist 0x0f /* (1 byte) built-in self-test */
/* ---
offsets in PCI configuration space to the elements of the predefined
header common to header types 0x00 and 0x01
--- */
#define PCI_base_registers 0x10 /* base registers (size varies) */
#define PCI_interrupt_line 0x3c /* (1 byte) interrupt line */
#define PCI_interrupt_pin 0x3d /* (1 byte) interrupt pin */
/* ---
offsets in PCI configuration space to the elements of header type 0x00
--- */
#define PCI_cardbus_cis 0x28 /* (4 bytes) CardBus CIS (Card Information Structure) pointer (see PCMCIA v2.10 Spec) */
#define PCI_subsystem_vendor_id 0x2c /* (2 bytes) subsystem (add-in card) vendor id */
#define PCI_subsystem_id 0x2e /* (2 bytes) subsystem (add-in card) id */
#define PCI_rom_base 0x30 /* (4 bytes) expansion rom base address */
#define PCI_capabilities_ptr 0x34 /* (1 byte) pointer to the start of the capabilities list */
#define PCI_min_grant 0x3e /* (1 byte) burst period @ 33 Mhz */
#define PCI_max_latency 0x3f /* (1 byte) how often PCI access needed */
/* ---
offsets in PCI configuration space to the elements of header type 0x01 (PCI-to-PCI bridge)
--- */
#define PCI_primary_bus 0x18 /* (1 byte) */
#define PCI_secondary_bus 0x19 /* (1 byte) */
#define PCI_subordinate_bus 0x1A /* (1 byte) */
#define PCI_secondary_latency 0x1B /* (1 byte) latency of secondary bus */
#define PCI_io_base 0x1C /* (1 byte) io base address register for 2ndry bus*/
#define PCI_io_limit 0x1D /* (1 byte) */
#define PCI_secondary_status 0x1E /* (2 bytes) */
#define PCI_memory_base 0x20 /* (2 bytes) */
#define PCI_memory_limit 0x22 /* (2 bytes) */
#define PCI_prefetchable_memory_base 0x24 /* (2 bytes) */
#define PCI_prefetchable_memory_limit 0x26 /* (2 bytes) */
#define PCI_prefetchable_memory_base_upper32 0x28
#define PCI_prefetchable_memory_limit_upper32 0x2C
#define PCI_io_base_upper16 0x30 /* (2 bytes) */
#define PCI_io_limit_upper16 0x32 /* (2 bytes) */
#define PCI_sub_vendor_id_1 0x34 /* (2 bytes) */
#define PCI_sub_device_id_1 0x36 /* (2 bytes) */
#define PCI_bridge_rom_base 0x38
#define PCI_bridge_control 0x3E /* (1 byte) */
/* PCI type 2 header offsets */
#define PCI_capabilities_ptr_2 0x14 /* (1 byte) */
#define PCI_secondary_status_2 0x16 /* (2 bytes) */
#define PCI_primary_bus_2 0x18 /* (1 byte) */
#define PCI_secondary_bus_2 0x19 /* (1 byte) */
#define PCI_subordinate_bus_2 0x1A /* (1 byte) */
#define PCI_secondary_latency_2 0x1B /* (1 byte) latency of secondary bus */
#define PCI_memory_base0_2 0x1C /* (4 bytes) */
#define PCI_memory_limit0_2 0x20 /* (4 bytes) */
#define PCI_memory_base1_2 0x24 /* (4 bytes) */
#define PCI_memory_limit1_2 0x28 /* (4 bytes) */
#define PCI_io_base0_2 0x2c /* (4 bytes) */
#define PCI_io_limit0_2 0x30 /* (4 bytes) */
#define PCI_io_base1_2 0x34 /* (4 bytes) */
#define PCI_io_limit1_2 0x38 /* (4 bytes) */
#define PCI_bridge_control_2 0x3E /* (1 byte) */
#define PCI_sub_vendor_id_2 0x40 /* (2 bytes) */
#define PCI_sub_device_id_2 0x42 /* (2 bytes) */
#define PCI_card_interface_2 0x44 /* ?? */
/* ---
values for the class_base field in the common header
--- */
#define PCI_early 0x00 /* built before class codes defined */
#define PCI_mass_storage 0x01 /* mass storage_controller */
#define PCI_network 0x02 /* network controller */
#define PCI_display 0x03 /* display controller */
#define PCI_multimedia 0x04 /* multimedia device */
#define PCI_memory 0x05 /* memory controller */
#define PCI_bridge 0x06 /* bridge controller */
#define PCI_simple_communications 0x07 /* simple communications controller */
#define PCI_base_peripheral 0x08 /* base system peripherals */
#define PCI_input 0x09 /* input devices */
#define PCI_docking_station 0x0a /* docking stations */
#define PCI_processor 0x0b /* processors */
#define PCI_serial_bus 0x0c /* serial_bus_controller */
#define PCI_wireless 0x0d
#define PCI_intelligent_io 0x0e
#define PCI_satellite_communications 0x0f
#define PCI_encryption_decryption 0x10
#define PCI_data_acquisition 0x11
#define PCI_undefined 0xFF /* not in any defined class */
/* ---
values for the class_sub field for class_base = 0x00 (built before
class codes were defined)
--- */
#define PCI_early_not_vga 0x00 /* all except vga */
#define PCI_early_vga 0x01 /* vga devices */
/* ---
values for the class_sub field for class_base = 0x01 (mass storage)
--- */
#define PCI_scsi 0x00 /* SCSI controller */
#define PCI_ide 0x01 /* IDE controller */
#define PCI_floppy 0x02 /* floppy disk controller */
#define PCI_ipi 0x03 /* IPI bus controller */
#define PCI_raid 0x04 /* RAID controller */
#define PCI_mass_storage_other 0x80 /* other mass storage controller */
/* ---
values for the class_sub field for class_base = 0x02 (network)
--- */
#define PCI_ethernet 0x00 /* Ethernet controller */
#define PCI_token_ring 0x01 /* Token Ring controller */
#define PCI_fddi 0x02 /* FDDI controller */
#define PCI_atm 0x03 /* ATM controller */
#define PCI_isdn 0x04 /* ISDN controller */
#define PCI_network_other 0x80 /* other network controller */
/* ---
values for the class_sub field for class_base = 0x03 (display)
--- */
#define PCI_vga 0x00 /* VGA controller */
#define PCI_xga 0x01 /* XGA controller */
#define PCI_3d 0x02 /* £d controller */
#define PCI_display_other 0x80 /* other display controller */
/* ---
values for the class_sub field for class_base = 0x04 (multimedia device)
--- */
#define PCI_video 0x00 /* video */
#define PCI_audio 0x01 /* audio */
#define PCI_telephony 0x02 /* computer telephony device */
#define PCI_multimedia_other 0x80 /* other multimedia device */
/* ---
values for the class_sub field for class_base = 0x05 (memory)
--- */
#define PCI_ram 0x00 /* RAM */
#define PCI_flash 0x01 /* flash */
#define PCI_memory_other 0x80 /* other memory controller */
/* ---
values for the class_sub field for class_base = 0x06 (bridge)
--- */
#define PCI_host 0x00 /* host bridge */
#define PCI_isa 0x01 /* ISA bridge */
#define PCI_eisa 0x02 /* EISA bridge */
#define PCI_microchannel 0x03 /* MicroChannel bridge */
#define PCI_pci 0x04 /* PCI-to-PCI bridge */
#define PCI_pcmcia 0x05 /* PCMCIA bridge */
#define PCI_nubus 0x06 /* NuBus bridge */
#define PCI_cardbus 0x07 /* CardBus bridge */
#define PCI_raceway 0x08 /* RACEway bridge */
#define PCI_bridge_other 0x80 /* other bridge device */
/* ---
values for the class_sub field for class_base = 0x07 (simple
communications controllers)
--- */
#define PCI_serial 0x00 /* serial port controller */
#define PCI_parallel 0x01 /* parallel port */
#define PCI_multiport_serial 0x02 /* multiport serial controller */
#define PCI_modem 0x03 /* modem */
#define PCI_simple_communications_other 0x80 /* other communications device */
/* ---
values of the class_api field for
class_base = 0x07 (simple communications), and
class_sub = 0x00 (serial port controller)
--- */
#define PCI_serial_xt 0x00 /* XT-compatible serial controller */
#define PCI_serial_16450 0x01 /* 16450-compatible serial controller */
#define PCI_serial_16550 0x02 /* 16550-compatible serial controller */
/* ---
values of the class_api field for
class_base = 0x07 (simple communications), and
class_sub = 0x01 (parallel port)
--- */
#define PCI_parallel_simple 0x00 /* simple (output-only) parallel port */
#define PCI_parallel_bidirectional 0x01 /* bidirectional parallel port */
#define PCI_parallel_ecp 0x02 /* ECP 1.x compliant parallel port */
/* ---
values for the class_sub field for class_base = 0x08 (generic
system peripherals)
--- */
#define PCI_pic 0x00 /* periperal interrupt controller */
#define PCI_dma 0x01 /* dma controller */
#define PCI_timer 0x02 /* timers */
#define PCI_rtc 0x03 /* real time clock */
#define PCI_generic_hot_plug 0x04 /* generic PCI hot-plug controller */
#define PCI_system_peripheral_other 0x80 /* other generic system peripheral */
/* ---
values of the class_api field for
class_base = 0x08 (generic system peripherals)
class_sub = 0x00 (peripheral interrupt controller)
--- */
#define PCI_pic_8259 0x00 /* generic 8259 */
#define PCI_pic_isa 0x01 /* ISA pic */
#define PCI_pic_eisa 0x02 /* EISA pic */
/* ---
values of the class_api field for
class_base = 0x08 (generic system peripherals)
class_sub = 0x01 (dma controller)
--- */
#define PCI_dma_8237 0x00 /* generic 8237 */
#define PCI_dma_isa 0x01 /* ISA dma */
#define PCI_dma_eisa 0x02 /* EISA dma */
/* ---
values of the class_api field for
class_base = 0x08 (generic system peripherals)
class_sub = 0x02 (timer)
--- */
#define PCI_timer_8254 0x00 /* generic 8254 */
#define PCI_timer_isa 0x01 /* ISA timer */
#define PCI_timer_eisa 0x02 /* EISA timers (2 timers) */
/* ---
values of the class_api field for
class_base = 0x08 (generic system peripherals)
class_sub = 0x03 (real time clock
--- */
#define PCI_rtc_generic 0x00 /* generic real time clock */
#define PCI_rtc_isa 0x01 /* ISA real time clock */
/* ---
values for the class_sub field for class_base = 0x09 (input devices)
--- */
#define PCI_keyboard 0x00 /* keyboard controller */
#define PCI_pen 0x01 /* pen */
#define PCI_mouse 0x02 /* mouse controller */
#define PCI_scanner 0x03 /* scanner controller */
#define PCI_gameport 0x04 /* gameport controller */
#define PCI_input_other 0x80 /* other input controller */
/* ---
values for the class_sub field for class_base = 0x0a (docking stations)
--- */
#define PCI_docking_generic 0x00 /* generic docking station */
/* ---
values for the class_sub field for class_base = 0x0b (processor)
--- */
#define PCI_386 0x00 /* 386 */
#define PCI_486 0x01 /* 486 */
#define PCI_pentium 0x02 /* Pentium */
#define PCI_alpha 0x10 /* Alpha */
#define PCI_PowerPC 0x20 /* PowerPC */
#define PCI_mips 0x30 /* MIPS */
#define PCI_coprocessor 0x40 /* co-processor */
/* ---
values for the class_sub field for class_base = 0x0c (serial bus
controller)
--- */
#define PCI_firewire 0x00 /* FireWire (IEEE 1394) */
#define PCI_access 0x01 /* ACCESS bus */
#define PCI_ssa 0x02 /* SSA */
#define PCI_usb 0x03 /* Universal Serial Bus */
#define PCI_fibre_channel 0x04 /* Fibre channel */
/* ---
values of the class_api field for
class_base = 0x0c ( serial bus controller )
class_sub = 0x03 ( Universal Serial Bus )
--- */
#define PCI_usb_uhci 0x00 /* Universal Host Controller Interface */
#define PCI_usb_ohci 0x10 /* Open Host Controller Interface */
/* ---
masks for command register bits
--- */
#define PCI_command_io 0x001 /* 1/0 i/o space en/disabled */
#define PCI_command_memory 0x002 /* 1/0 memory space en/disabled */
#define PCI_command_master 0x004 /* 1/0 pci master en/disabled */
#define PCI_command_special 0x008 /* 1/0 pci special cycles en/disabled */
#define PCI_command_mwi 0x010 /* 1/0 memory write & invalidate en/disabled */
#define PCI_command_vga_snoop 0x020 /* 1/0 vga pallette snoop en/disabled */
#define PCI_command_parity 0x040 /* 1/0 parity check en/disabled */
#define PCI_command_address_step 0x080 /* 1/0 address stepping en/disabled */
#define PCI_command_serr 0x100 /* 1/0 SERR# en/disabled */
#define PCI_command_fastback 0x200 /* 1/0 fast back-to-back en/disabled */
/* ---
masks for status register bits
--- */
#define PCI_status_capabilities 0x0010 /* capabilities list */
#define PCI_status_66_MHz_capable 0x0020 /* 66 Mhz capable */
#define PCI_status_udf_supported 0x0040 /* user-definable-features (udf) supported */
#define PCI_status_fastback 0x0080 /* fast back-to-back capable */
#define PCI_status_parity_signalled 0x0100 /* parity error signalled */
#define PCI_status_devsel 0x0600 /* devsel timing (see below) */
#define PCI_status_target_abort_signalled 0x0800 /* signaled a target abort */
#define PCI_status_target_abort_received 0x1000 /* received a target abort */
#define PCI_status_master_abort_received 0x2000 /* received a master abort */
#define PCI_status_serr_signalled 0x4000 /* signalled SERR# */
#define PCI_status_parity_error_detected 0x8000 /* parity error detected */
/* ---
masks for devsel field in status register
--- */
#define PCI_status_devsel_fast 0x0000 /* fast */
#define PCI_status_devsel_medium 0x0200 /* medium */
#define PCI_status_devsel_slow 0x0400 /* slow */
/* ---
masks for header type register
--- */
#define PCI_header_type_mask 0x7F /* header type field */
#define PCI_multifunction 0x80 /* multifunction device flag */
/** types of PCI header */
#define PCI_header_type_generic 0x00
#define PCI_header_type_PCI_to_PCI_bridge 0x01
#define PCI_header_type_cardbus 0x02
/* ---
masks for built in self test (bist) register bits
--- */
#define PCI_bist_code 0x0F /* self-test completion code, 0 = success */
#define PCI_bist_start 0x40 /* 1 = start self-test */
#define PCI_bist_capable 0x80 /* 1 = self-test capable */
/** masks for flags in the various base address registers */
#define PCI_address_space 0x01 /* 0 = memory space, 1 = i/o space */
#define PCI_register_start 0x10
#define PCI_register_end 0x24
#define PCI_register_ppb_end 0x18
#define PCI_register_pcb_end 0x14
/** masks for flags in memory space base address registers */
#define PCI_address_type_32 0x00 /* locate anywhere in 32 bit space */
#define PCI_address_type_32_low 0x02 /* locate below 1 Meg */
#define PCI_address_type_64 0x04 /* locate anywhere in 64 bit space */
#define PCI_address_type 0x06 /* type (see below) */
#define PCI_address_prefetchable 0x08 /* 1 if prefetchable (see PCI spec) */
#define PCI_address_memory_32_mask 0xFFFFFFF0 /* mask to get 32bit memory space base address */
/* ---
masks for flags in i/o space base address registers
--- */
#define PCI_address_io_mask 0xFFFFFFFC /* mask to get i/o space base address */
/* ---
masks for flags in expansion rom base address registers
--- */
#define PCI_rom_enable 0x00000001 /* 1 = expansion rom decode enabled */
#define PCI_rom_address_mask 0xFFFFF800 /* mask to get expansion rom addr */
/** PCI interrupt pin values */
#define PCI_pin_mask 0x07
#define PCI_pin_none 0x00
#define PCI_pin_a 0x01
#define PCI_pin_b 0x02
#define PCI_pin_c 0x03
#define PCI_pin_d 0x04
#define PCI_pin_max 0x04
/** PCI Capability Codes */
#define PCI_cap_id_reserved 0x00
#define PCI_cap_id_pm 0x01 /* Power management */
#define PCI_cap_id_agp 0x02 /* AGP */
#define PCI_cap_id_vpd 0x03 /* Vital product data */
#define PCI_cap_id_slotid 0x04 /* Slot ID */
#define PCI_cap_id_msi 0x05 /* Message signalled interrupt ??? */
#define PCI_cap_id_chswp 0x06 /* Compact PCI HotSwap */
#define PCI_cap_id_pcix 0x07
#define PCI_cap_id_ldt 0x08
#define PCI_cap_id_vendspec 0x09
#define PCI_cap_id_debugport 0x0a
#define PCI_cap_id_cpci_rsrcctl 0x0b
#define PCI_cap_id_hotplug 0x0c
/** Power Management Control Status Register settings */
#define PCI_pm_mask 0x03
#define PCI_pm_ctrl 0x02
#define PCI_pm_d1supp 0x0200
#define PCI_pm_d2supp 0x0400
#define PCI_pm_status 0x04
#define PCI_pm_state_d0 0x00
#define PCI_pm_state_d1 0x01
#define PCI_pm_state_d2 0x02
#define PCI_pm_state_d3 0x03
#ifdef __cplusplus
}
#endif
#endif /* _PCI_H */
+44
View File
@@ -0,0 +1,44 @@
/* File System and Drivers select support
**
** Distributed under the terms of the Haiku License.
*/
#ifndef _DRIVERS_SELECT_H
#define _DRIVERS_SELECT_H
#include <SupportDefs.h>
struct selectsync;
typedef struct selectsync selectsync;
enum select_events {
B_SELECT_READ = 1, // standard select() support
B_SELECT_WRITE,
B_SELECT_ERROR,
B_SELECT_PRI_READ, // additional poll() support
B_SELECT_PRI_WRITE,
B_SELECT_HIGH_PRI_READ,
B_SELECT_HIGH_PRI_WRITE,
B_SELECT_DISCONNECTED
};
#ifdef __cplusplus
extern "C" {
#endif
#ifdef COMPILE_FOR_R5
extern void notify_select_event(struct selectsync *sync, uint32 ref);
#else
extern status_t notify_select_event(struct selectsync *sync, uint32 ref, uint8 event);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _DRIVERS_SELECT_H */
+189
View File
@@ -0,0 +1,189 @@
/*
** USB.h - Version 2 USB Device Driver API
**
** Copyright 1999, Be Incorporated. All Rights Reserved.
**
*/
#ifndef _USB_H
#define _USB_H
#include <KernelExport.h>
#include <bus_manager.h>
#include <USB_spec.h>
#include <USB_rle.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct usb_module_info usb_module_info;
/* these are opaque handles to internal stack objects */
typedef struct usb_device usb_device;
typedef struct usb_interface usb_interface;
typedef struct usb_pipe usb_pipe;
typedef struct usb_endpoint_info usb_endpoint_info;
typedef struct usb_interface_info usb_interface_info;
typedef struct usb_interface_list usb_interface_list;
typedef struct usb_configuration_info usb_configuration_info;
typedef struct usb_notify_hooks {
status_t (*device_added)(const usb_device *device, void **cookie);
status_t (*device_removed)(void *cookie);
} usb_notify_hooks;
typedef struct usb_support_descriptor {
uint8 dev_class;
uint8 dev_subclass;
uint8 dev_protocol;
uint16 vendor;
uint16 product;
} usb_support_descriptor;
/* ie, I support any hub device:
** usb_support_descriptor hub_devs = { 9, 0, 0, 0, 0 };
*/
struct usb_endpoint_info {
usb_endpoint_descriptor *descr; /* descriptor and handle */
usb_pipe *handle; /* of this endpoint/pipe */
};
struct usb_interface_info {
usb_interface_descriptor *descr; /* descriptor and handle */
usb_interface *handle; /* of this interface */
size_t endpoint_count; /* count and list of endpoints */
usb_endpoint_info *endpoint; /* in this interface */
size_t generic_count; /* unparsed descriptors in this */
usb_descriptor **generic; /* interface */
};
struct usb_interface_list {
size_t alt_count; /* count and list of alternate */
usb_interface_info *alt; /* interfaces available */
usb_interface_info *active; /* currently active alternate */
};
struct usb_configuration_info {
usb_configuration_descriptor *descr; /* descriptor of this config */
size_t interface_count; /* interfaces in this config */
usb_interface_list *interface;
};
typedef void (*usb_callback_func)(void *cookie, uint32 status,
void *data, uint32 actual_len);
struct usb_module_info {
bus_manager_info binfo;
/* inform the bus manager of our intent to support a set of devices */
status_t (*register_driver)(const char *driver_name,
const usb_support_descriptor *descriptors,
size_t count,
const char *optional_republish_driver_name);
/* request notification from the bus manager for add/remove of devices we
support */
status_t (*install_notify)(const char *driver_name,
const usb_notify_hooks *hooks);
status_t (*uninstall_notify)(const char *driver_name);
/* get the device descriptor */
const usb_device_descriptor *(*get_device_descriptor)(const usb_device *dev);
/* get the nth supported configuration */
const usb_configuration_info *(*get_nth_configuration)(const usb_device *dev, uint index);
/* get the active configuration */
const usb_configuration_info *(*get_configuration)(const usb_device *dev);
/* set the active configuration */
status_t (*set_configuration)(const usb_device *dev,
const usb_configuration_info *configuration);
status_t (*set_alt_interface)(const usb_device *dev,
const usb_interface_info *ifc);
/* standard device requests -- convenience functions */
/* obj may be a usb_device*, usb_pipe*, or usb_interface* */
status_t (*set_feature)(const void *object, uint16 selector);
status_t (*clear_feature)(const void *object, uint16 selector);
status_t (*get_status)(const void *object, uint16 *status);
status_t (*get_descriptor)(const usb_device *d,
uint8 type, uint8 index, uint16 lang,
void *data, size_t len, size_t *actual_len);
/* generic device request function */
status_t (*send_request)(const usb_device *d,
uint8 request_type, uint8 request,
uint16 value, uint16 index, uint16 length,
void *data, size_t data_len, size_t *actual_len);
/* async request queueing */
status_t (*queue_interrupt)(const usb_pipe *handle,
void *data, size_t len,
usb_callback_func notify, void *cookie);
status_t (*queue_bulk)(const usb_pipe *handle,
void *data, size_t len,
usb_callback_func notify, void *cookie);
status_t (*queue_isochronous)(const usb_pipe *handle,
void *data, size_t len,
rlea* rle_array, uint16 buffer_duration_ms,
usb_callback_func notify, void *cookie);
status_t (*queue_request)(const usb_device *d,
uint8 request_type, uint8 request,
uint16 value, uint16 index, uint16 length,
void *data, size_t data_len,
usb_callback_func notify, void *cookie);
status_t (*set_pipe_policy)(const usb_pipe *handle, uint8 max_num_queued_packets,
uint16 max_buffer_duration_ms, uint16 sample_size);
/* cancel pending async requests to an endpoint */
status_t (*cancel_queued_transfers)(const usb_pipe *handle);
/* tuning, timeouts, etc */
status_t (*usb_ioctl)(uint32 opcode, void* buf, size_t buf_size);
};
/* status code for usb callback functions */
#define B_USB_STATUS_SUCCESS 0x0000
#define B_USB_STATUS_DEVICE_CRC_ERROR 0x0002
#define B_USB_STATUS_DEVICE_TIMEOUT 0x0004
#define B_USB_STATUS_DEVICE_STALLED 0x0008
#define B_USB_STATUS_IRP_CANCELLED_BY_REQUEST 0x0010
#define B_USB_STATUS_DRIVER_INTERNAL_ERROR 0x0020
#define B_USB_STATUS_ADAPTER_HARDWARE_ERROR 0x0040
#define B_USB_STATUS_ISOCH_IRP_ABORTED 0x0080
/* result codes for usb bus manager functions */
#define B_USBD_SUCCESS 0
#define B_USBD_BAD_HANDLE 1
#define B_USBD_BAD_ARGS 2
#define B_USBD_NO_DATA 3
#define B_USBD_DEVICE_FAILURE 4
#define B_USBD_COMMAND_FAILED 5
#define B_USBD_PIPE_NOT_CONFIGURED 6
#define B_USBD_DEVICE_ERROR 7
#define B_USBD_PIPE_ERROR 8
#define B_USBD_NO_MEMORY 9
#define B_USB_MODULE_NAME "bus_managers/usb/v2"
#ifdef __cplusplus
}
#endif
#endif
+36
View File
@@ -0,0 +1,36 @@
/*
** USB_printer.h
**
** Copyright 1999, Be Incorporated. All Rights Reserved.
**
*/
#ifndef _USB_PRINTER_H
#define _USB_PRINTER_H
#include <Drivers.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ioctl() opcodes for usb_printer driver */
enum
{
USB_PRINTER_GET_DEVICE_ID = B_DEVICE_OP_CODES_END+1
};
/* Maximum length of the DEVICE_ID. User MUST allocate this size
when calling USB_PRINTER_GET_DEVICE_ID ioctl() */
#define USB_PRINTER_DEVICE_ID_LENGTH 256
#ifdef __cplusplus
}
#endif
#endif
+91
View File
@@ -0,0 +1,91 @@
/*
** USB_rle.h
**
** Copyright 1999, Be Incorporated. All Rights Reserved.
**
*/
#ifndef _USB_RLE_H
#define _USB_RLE_H
#ifdef __cplusplus
extern "C" {
#endif
struct _usbd_param_hdr;
/*
Run Length encoding records for isochronous IN transfers.
Run Length encoding records are used to identify which samples in
the buffer are good which are bad and which are missing.
Bad bytes are not extracted from the buffer, but are padded to next
nearest sample boundary. The ultimate consumer of the buffer
should also receive the RLE array.
RLE records are constructed based on the following rules:
1. an RLE record contains a sample count and a status
(good, bad, missing or unknown). A buffer has
associated with it an array of rle records. The number of
rle records available is specified in the RLE header. The
number used is also in the RLE header.
2. Within the scope of a buffer, successive packets with the
same completion status are represented with (1) rle record.
For example, after three transactions which have completion
status of success, the byte count in the rle record for this
position in the data stream represents the bytes received in
all three packets.
3. New rle records are initialized each time the status for a
given packet differs from that of the previous packet.
*/
#define RLE_GOOD 1
#define RLE_BAD 2
#define RLE_MISSING 3
#define RLE_UNKNOWN 4
/*
Name: rle
Purpose: used to represent the state of a portion of a data buffer
Fields:
rle_status will contain only the values: RLE_GOOD, RLE_BAD, RLE_MISSING
sample_count the number of usb samples in the buffer associated with this rle
record.
Notes:
If the buffer length field in queue_buffer_single structure changes to an
uint32 from uin16, then the sample_count data type must
track this change.
*/
typedef struct rle {
uint16 rle_status;
uint16 sample_count;
} rle;
/*
Name: rlea
Purpose: used as the primary rle information data structure between the
USB driver stack and a consuming client.
Fields:
length the number of rle records available in this structure.
num_valid filled in by the USB driver. indicates the number of valid
records filled.
rles[] unconstrained array of rle records.
*/
typedef struct rlea {
uint16 length;
uint16 num_valid;
rle rles[1];
} rlea;
#ifdef __cplusplus
}
#endif
#endif
+144
View File
@@ -0,0 +1,144 @@
/*
** USB_spec.h
**
** Copyright 1999, Be Incorporated. All Rights Reserved.
**
** This file contains structures and constants based on the USB Specification 1.1
**
*/
#ifndef _USB_SPEC_H
#define _USB_SPEC_H
#ifdef __cplusplus
extern "C" {
#endif
/* request types (target & direction) for send_request() */
/* cf USB Spec Rev 1.1, table 9-2, p 183 */
#define USB_REQTYPE_DEVICE_IN 0x80
#define USB_REQTYPE_DEVICE_OUT 0x00
#define USB_REQTYPE_INTERFACE_IN 0x81
#define USB_REQTYPE_INTERFACE_OUT 0x01
#define USB_REQTYPE_ENDPOINT_IN 0x82
#define USB_REQTYPE_ENDPOINT_OUT 0x02
#define USB_REQTYPE_OTHER_OUT 0x03
#define USB_REQTYPE_OTHER_IN 0x83
/* request types for send_request() */
/* cf USB Spec Rev 1.1, table 9-2, p 183 */
#define USB_REQTYPE_STANDARD 0x00
#define USB_REQTYPE_CLASS 0x20
#define USB_REQTYPE_VENDOR 0x40
#define USB_REQTYPE_RESERVED 0x60
#define USB_REQTYPE_MASK 0x9F
/* standard request values for send_request() */
/* cf USB Spec Rev 1.1, table 9-4, p 187 */
#define USB_REQUEST_GET_STATUS 0
#define USB_REQUEST_CLEAR_FEATURE 1
#define USB_REQUEST_SET_FEATURE 3
#define USB_REQUEST_SET_ADDRESS 5
#define USB_REQUEST_GET_DESCRIPTOR 6
#define USB_REQUEST_SET_DESCRIPTOR 7
#define USB_REQUEST_GET_CONFIGURATION 8
#define USB_REQUEST_SET_CONFIGURATION 9
#define USB_REQUEST_GET_INTERFACE 10
#define USB_REQUEST_SET_INTERFACE 11
#define USB_REQUEST_SYNCH_FRAME 12
/* used by {set,get}_descriptor() */
/* cf USB Spec Rev 1.1, table 9-5, p 187 */
#define USB_DESCRIPTOR_DEVICE 1
#define USB_DESCRIPTOR_CONFIGURATION 2
#define USB_DESCRIPTOR_STRING 3
#define USB_DESCRIPTOR_INTERFACE 4
#define USB_DESCRIPTOR_ENDPOINT 5
/* used by {set,clear}_feature() */
/* cf USB Spec Rev 1.1, table 9-6, p 188 */
#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1
#define USB_FEATURE_ENDPOINT_HALT 0
typedef struct {
/* cf USB Spec Rev 1.1, table 9-7, p 197 */
uint8 length;
uint8 descriptor_type; /* USB_DESCRIPTOR_DEVICE */
uint16 usb_version; /* USB_DESCRIPTOR_DEVICE_LENGTH */
uint8 device_class;
uint8 device_subclass;
uint8 device_protocol;
uint8 max_packet_size_0;
uint16 vendor_id;
uint16 product_id;
uint16 device_version;
uint8 manufacturer;
uint8 product;
uint8 serial_number;
uint8 num_configurations;
} _PACKED usb_device_descriptor;
typedef struct {
/* cf USB Spec Rev 1.1, table 9-8, p 199 */
uint8 length;
uint8 descriptor_type; /* USB_DESCRIPTOR_CONFIGURATION */
uint16 total_length; /* USB_DESCRIPTOR_CONFIGURATION_LENGTH */
uint8 number_interfaces;
uint8 configuration_value;
uint8 configuration;
uint8 attributes;
uint8 max_power;
} _PACKED usb_configuration_descriptor;
typedef struct {
/* cf USB Spec Rev 1.1, table 9-9, p 202 */
uint8 length;
uint8 descriptor_type; /* USB_DESCRIPTOR_INTERFACE */
uint8 interface_number; /* USB_DESCRIPTOR_INTERFACE_LENGTH */
uint8 alternate_setting;
uint8 num_endpoints;
uint8 interface_class;
uint8 interface_subclass;
uint8 interface_protocol;
uint8 interface;
} _PACKED usb_interface_descriptor;
typedef struct {
/* cf USB Spec Rev 1.1, table 9-10, p 203 */
uint8 length;
uint8 descriptor_type; /* USB_DESCRIPTOR_ENDPOINT */
uint8 endpoint_address; /* USB_DESCRIPTOR_ENDPOINT_LENGTH */
uint8 attributes;
uint16 max_packet_size;
uint8 interval;
} _PACKED usb_endpoint_descriptor;
typedef struct {
/* cf USB Spec Rev 1.1, table 9-12, p 205 */
uint8 length; /* USB_DESCRIPTOR_STRING */
uint8 descriptor_type;
uchar string[1];
} _PACKED usb_string_descriptor;
typedef struct {
uint8 length;
uint8 descriptor_type;
uint8 data[1];
} _PACKED usb_generic_descriptor;
typedef union {
usb_generic_descriptor generic;
usb_device_descriptor device;
usb_interface_descriptor interface;
usb_endpoint_descriptor endpoint;
usb_configuration_descriptor configuration;
usb_string_descriptor string;
} usb_descriptor;
#ifdef __cplusplus
}
#endif
#endif
+97
View File
@@ -0,0 +1,97 @@
/*******************************************************************************
/
/ File: atomizer.h
/
/ Description: Kernel atomizer module API
/
/ Copyright 1999, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _ATOMIZER_MODULE_H_
#define _ATOMIZER_MODULE_H_
#include <module.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
An atomizer is a software device that returns a unique token for a
null-terminated UTF8 string.
Each atomizer comprises a separate token space. The same string interned
in two different atomizers will generate two distinct tokens.
Atomizers and the tokens they generate are only guaranteed valid between
matched calls to get_module/put_module.
void * find_or_make_atomizer(const char *string)
Returns a token that identifies the named atomizer, creating a new
atomizer if the named atomizer does not exist. Pass null, a zero
length string, or the value B_SYSTEM_ATOMIZER_NAME for string will
return a pointer to the system atomizer. Returns (void *)(0)
if the atomizer could not be created (for whatever reason). A return
value of (void *)(-1) refers to the system atomizer.
status_t delete_atomizer(void *atomizer)
Delete the atomizer specified. Returns B_OK if successfull, B_ERROR
otherwise. An error return usually means that a race condition was
detected while destroying the atomizer.
void * atomize(void *atomizer, const char *string, int create)
Return the unique token for the specified string, creating a new token
if the string was not previously atomized and create is non-zero. If
atomizer is (void *)(-1), use the system atomizer (saving the step of
looking it up with find_or_make_atomizer(). Returns (const char *)(0)
if there were any errors detected: insufficient memory or a race
condition with someone deleting the atomizer.
const char * string_for_token(void *atomizer, void *atom)
Return a pointer to the string described by atom in the provided atomizer.
Returns (const char *)(0) if either the atomizer or the atom were invalid.
status_t get_next_atomizer_info(void **cookie, atomizer_info *info)
Returns info about the next atomizer in the list of atomizers by modifying
the contents of info. The pointer specified by *cookie should be set to
(void *)(0) to retrieve the first atomizer, and should not be modified
thereafter. Returns B_ERROR when there are no more atomizers.
Adding or deleting atomizers between calls to get_next_atomizer() results
in a safe but undefined behavior.
void * get_next_atom(void *atomizer, uint32 *cookie)
Returns the next atom interned in specified atomizer, *cookie
should be set to (uint32)(0) to get the first atom. Returns
(void *)(0) when there are no more atoms. Adding atoms between
calls to get_next_atom() may cause atoms to be skipped.
Atomizers are SMP-safe. Check return codes for errors!
*/
#define B_ATOMIZER_MODULE_NAME "generic/atomizer/v1"
#define B_SYSTEM_ATOMIZER_NAME "BeOS System Atomizer"
typedef struct {
void *atomizer; /* An opaque token representing the atomizer. */
char name[B_OS_NAME_LENGTH]; /* The first B_OS_NAME_LENGTH bytes of the atomizer name, null terminated. */
uint32 atom_count; /* The number of atoms currently interned in this atomizer. */
} atomizer_info;
typedef struct {
module_info minfo;
const void * (*find_or_make_atomizer)(const char *string);
status_t (*delete_atomizer)(const void *atomizer);
const void * (*atomize)(const void *atomizer, const char *string, int create);
const char * (*string_for_token)(const void * atomizer, const void *atom);
status_t (*get_next_atomizer_info)(void **cookie, atomizer_info *info);
const void * (*get_next_atom)(const void *atomizer, uint32 *cookie);
} atomizer_module_info;
#ifdef __cplusplus
}
#endif
#endif
+100
View File
@@ -0,0 +1,100 @@
/*
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef __BLOCK_IO_H__
#define __BLOCK_IO_H__
/*
Part of Open block device manager
Block devices can be easily written by providing the interface
specified hereinafter. The block device manager takes care of
DMA and other restrictions imposed by underlying controller or
protocol and transparently handles transmission of partial blocks
by using a buffer (performance will suffer, though).
*/
#include <KernelExport.h>
#include <device_manager.h>
// cookies issued by block_io
typedef struct block_io_device_info *block_io_device;
typedef struct block_io_handle_info *block_io_handle;
// cookies issued by device driver
typedef struct block_device_device_cookie *block_device_device_cookie;
typedef struct block_device_handle_cookie *block_device_handle_cookie;
// two reason why to use array of size 1:
// 1. zero-sized arrays aren't standard C
// 2. it's handy if you need a temporary global variable with num=1
typedef struct phys_vecs {
size_t num;
size_t total_len;
physical_entry vec[1];
} phys_vecs;
#define PHYS_VECS(name, size) \
uint8 name[sizeof(phys_vecs) + (size - 1)*sizeof(phys_vec)]; \
phys_vecs *name = (phys_vecs *)name
// Block Device Node
// attributes:
// if true, this device may be a BIOS drive (uint8, optional, default: false)
#define B_BLOCK_DEVICE_IS_BIOS_DRIVE "block_device/is_bios_drive"
// address bits that must be 0 - must be 2^i-1 for some i (uint32, optional, default: 0)
#define B_BLOCK_DEVICE_DMA_ALIGNMENT "block_device/dma_alignment"
// maximum number of blocks per transfer (uint32, optional, default: unlimited)
#define B_BLOCK_DEVICE_MAX_BLOCKS_ITEM "block_device/max_blocks"
// mask of bits that can change in one sg block (uint32, optional, default: ~0)
#define B_BLOCK_DEVICE_DMA_BOUNDARY "block_device/dma_boundary"
// maximum size of one block in scatter/gather list (uint32, optional, default: ~0)
#define B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE "block_device/max_sg_block_size"
// maximum number of scatter/gather blocks (uint32, optional, default: unlimited)
#define B_BLOCK_DEVICE_MAX_SG_BLOCKS "block_device/max_sg_blocks"
// interface to be provided by device driver
typedef struct block_device_interface {
driver_module_info info;
// iovecs are physical address here
// pos and num_blocks are in blocks; bytes_transferred in bytes
// vecs are guaranteed to describe enough data for given block count
status_t (*open)(block_device_device_cookie device, block_device_handle_cookie *handle);
status_t (*close)(block_device_handle_cookie handle);
status_t (*free)(block_device_handle_cookie handle);
status_t (*read)(block_device_handle_cookie handle, const phys_vecs *vecs, off_t pos,
size_t num_blocks, uint32 block_size, size_t *bytes_transferred);
status_t (*write)(block_device_handle_cookie handle, const phys_vecs *vecs, off_t pos,
size_t num_blocks, uint32 block_size, size_t *bytes_transferred);
status_t (*ioctl)(block_device_handle_cookie handle, int op, void *buf, size_t len);
} block_device_interface;
#define B_BLOCK_IO_MODULE_NAME "generic/block_io/v1"
// Interface for Drivers
// blkman interface used for callbacks done by driver
typedef struct block_io_for_driver_interface {
module_info info;
// block_size - block size in bytes
// ld_block_size - log2( block_size) (set to zero if block_size is not power of two)
// capacity - capacity in blocks
void (*set_media_params)(block_io_device device, uint32 block_size, uint32 ld_block_size,
uint64 capacity);
} block_io_for_driver_interface;
#define B_BLOCK_IO_FOR_DRIVER_MODULE_NAME "generic/block_io/driver/v1"
#endif /* __BLOCK_IO_H__ */
+363
View File
@@ -0,0 +1,363 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
Part of Open IDE bus manager
IDE bus manager interface
*/
#ifndef __IDE_H__
#define __IDE_H__
#include <bus_manager.h>
#include <iovec.h>
#include <lendian_bitfield.h>
#include <device_manager.h>
#include <KernelExport.h>
// IDE task file.
// contains the command block interpreted under different conditions with
// first byte being first command register, second byte second command register
// etc.; for lba48, registers must be written twice, therefore there
// are twice as many bytes as registers - the first eight bytes are those
// that must be written first, the second eight bytes are those that
// must be written second.
typedef union {
struct {
uint8 features;
uint8 sector_count;
uint8 sector_number;
uint8 cylinder_0_7;
uint8 cylinder_8_15;
LBITFIELD8_3(
head : 4,
device : 1,
mode : 3
);
uint8 command;
} chs;
struct {
uint8 features;
uint8 sector_count;
uint8 lba_0_7;
uint8 lba_8_15;
uint8 lba_16_23;
LBITFIELD8_3(
lba_24_27 : 4,
device : 1,
mode : 3
);
uint8 command;
} lba;
struct {
LBITFIELD8_3(
dma : 1,
ovl : 1,
_0_res2 : 6
);
LBITFIELD8_2(
_1_res0 : 3,
tag : 5
);
uint8 _2_res;
uint8 byte_count_0_7;
uint8 byte_count_8_15;
LBITFIELD8_6(
lun : 3,
_5_res3 : 1,
device : 1,
_5_one5 : 1,
_5_res6 : 1,
_5_one7 : 1
);
uint8 command;
} packet;
struct {
LBITFIELD8_5(
ili : 1,
eom : 1,
abrt : 1,
_0_res3 : 1,
sense_key : 4
);
LBITFIELD8_4(
cmd_or_data : 1, // 1 - cmd, 0 - data
input_or_output : 1, // 0 - input (to device), 1 - output
release : 1,
tag : 5
);
uint8 _2_res;
uint8 byte_count_0_7;
uint8 byte_count_8_15;
LBITFIELD8_5(
_4_res0 : 4,
device : 1,
_4_obs5 : 1,
_4_res6 : 1,
_4_obs7 : 1
);
LBITFIELD8_7(
chk : 1,
_7_res1 : 2,
drq : 1,
serv : 1,
dmrd : 1,
drdy : 1,
bsy : 1
);
} packet_res;
struct {
uint8 sector_count;
LBITFIELD8_4( // only <tag> is defined for write
cmd_or_data : 1, // 1 - cmd, 0 - data
input_or_output : 1, // 0 - input (to device), 1 - output
release : 1,
tag : 5
);
uint8 lba_0_7;
uint8 lba_8_15;
uint8 lba_16_23;
LBITFIELD8_3(
lba_24_27 : 4,
device : 1,
mode : 3
);
uint8 command;
} queued;
struct {
// low order bytes
uint8 features;
uint8 sector_count_0_7;
uint8 lba_0_7;
uint8 lba_8_15;
uint8 lba_16_23;
LBITFIELD8_3(
_5low_res0 : 4,
device : 1,
mode : 3
);
uint8 command;
// high order bytes
uint8 _0high_res;
uint8 sector_count_8_15;
uint8 lba_24_31;
uint8 lba_32_39;
uint8 lba_40_47;
} lba48;
struct {
// low order bytes
uint8 sector_count_0_7;
LBITFIELD8_4(
cmd_or_data : 1, // 1 - cmd, 0 - data
input_or_output : 1, // 0 - input (to device), 1 - output
release : 1,
tag : 5
);
uint8 lba_0_7;
uint8 lba_8_15;
uint8 lba_16_23;
LBITFIELD8_3(
_5low_res0 : 4,
device : 1,
mode : 3
);
uint8 command;
// high order bytes
uint8 sector_count_8_15;
uint8 _1high_res;
uint8 lba_24_31;
uint8 lba_32_39;
uint8 lba_40_47;
} queued48;
struct {
uint8 _0_res[3];
uint8 ver; // RMSN version
LBITFIELD8_3(
pena : 1, // previously enabled
lock : 1, // capable of locking
pej : 1 // can physically eject
);
} set_MSN_res;
struct {
uint8 r[7+5];
} raw;
struct {
uint8 features;
uint8 sector_count;
uint8 sector_number;
uint8 cylinder_low;
uint8 cylinder_high;
uint8 device_head;
uint8 command;
} write;
struct {
uint8 error;
uint8 sector_count;
uint8 sector_number;
uint8 cylinder_low;
uint8 cylinder_high;
uint8 device_head;
uint8 status;
} read;
} ide_task_file;
// content of "mode" field
enum {
ide_mode_chs = 5,
ide_mode_lba = 7
};
// mask for ide_task_file fields to be written
typedef enum {
ide_mask_features = 0x01,
ide_mask_sector_count = 0x02,
// CHS
ide_mask_sector_number = 0x04,
ide_mask_cylinder_low = 0x08,
ide_mask_cylinder_high = 0x10,
// LBA
ide_mask_LBA_low = 0x04,
ide_mask_LBA_mid = 0x08,
ide_mask_LBA_high = 0x10,
// packet
ide_mask_byte_count = 0x18,
// packet and dma queued result
ide_mask_error = 0x01,
ide_mask_ireason = 0x02,
ide_mask_device_head = 0x20,
ide_mask_command = 0x40,
ide_mask_status = 0x40,
// for 48 bits, the following flags tell which registers to load twice
ide_mask_features_48 = 0x80 | ide_mask_features,
ide_mask_sector_count_48 = 0x80 | ide_mask_sector_count,
ide_mask_LBA_low_48 = 0x100 | ide_mask_LBA_low,
ide_mask_LBA_mid_48 = 0x200 | ide_mask_LBA_mid,
ide_mask_LBA_high_48 = 0x400 | ide_mask_LBA_high,
ide_mask_HOB = 0x780
//ide_mask_all = 0x7f
} ide_reg_mask;
// status register
enum {
ide_status_err = 0x01, // error
ide_status_index = 0x02, // obsolete
ide_status_corr = 0x04, // obsolete
ide_status_drq = 0x08, // data request
ide_status_dsc = 0x10, // reserved
ide_status_service = 0x10, // ready to service device
ide_status_dwf = 0x20, // reserved
ide_status_dma = 0x20, // reserved
ide_status_dmrd = 0x20, // packet: DMA ready
ide_status_df = 0x20, // packet: disk failure
ide_status_drdy = 0x40, // device ready
ide_status_bsy = 0x80 // busy
} ide_status_mask;
// device control register
enum {
// bit 0 must be zero
ide_devctrl_nien = 0x02, // disable INTRQ
ide_devctrl_srst = 0x04, // software device reset
ide_devctrl_bit3 = 0x08, // don't know, but must be set
// bits inbetween are reserved
ide_devctrl_hob = 0x80 // read high order byte (for 48-bit lba)
} ide_devcntrl_mask;
// error register - most bits are command specific
enum {
// always used
ide_error_abrt = 0x04, // command aborted
// used for Ultra DMA modes
ide_error_icrc = 0x80, // interface CRC error
// used by reading data transfers
ide_error_unc = 0x40, // uncorrectable data error
// used by writing data transfers
ide_error_wp = 0x40, // media write protect
// used by all data transfer commands
ide_error_mc = 0x20, // medium changed
ide_error_idnf = 0x10, // CHS translation not init./ invalid CHS address
ide_error_mcr = 0x08, // media change requested
ide_error_nm = 0x02, // no media (for removable media devices)
} ide_error_mask;
typedef struct ide_channel_info *ide_channel_cookie;
// Controller Driver Node
// attributes:
// node type
#define IDE_BUS_TYPE_NAME "bus/ide/v1"
// maximum number of devices connected to controller (uint8, optional, default:2)
#define IDE_CONTROLLER_MAX_DEVICES_ITEM "ide/max_devices"
// set to not-0 if DMA is supported (uint8, optional, default:0)
// (if so, publish necessary blkdev restriction too)
#define IDE_CONTROLLER_CAN_DMA_ITEM "ide/can_DMA"
// set to not-0 if CQ is supported (uint8, optional, default:1)
#define IDE_CONTROLLER_CAN_CQ_ITEM "ide/can_CQ"
// name of controller (string, required)
#define IDE_CONTROLLER_CONTROLLER_NAME_ITEM "ide/controller_name"
// interface of controller driver
typedef struct {
driver_module_info info;
status_t (*write_command_block_regs)
(ide_channel_cookie channel, ide_task_file *tf, ide_reg_mask mask);
status_t (*read_command_block_regs)
(ide_channel_cookie channel, ide_task_file *tf, ide_reg_mask mask);
uint8 (*get_altstatus) (ide_channel_cookie channel);
status_t (*write_device_control) (ide_channel_cookie channel, uint8 val);
status_t (*write_pio) (ide_channel_cookie channel, uint16 *data, int count, bool force_16bit );
status_t (*read_pio) (ide_channel_cookie channel, uint16 *data, int count, bool force_16bit );
status_t (*prepare_dma)(ide_channel_cookie channel,
const physical_entry *sg_list, size_t sg_list_count,
bool write);
status_t (*start_dma)(ide_channel_cookie channel);
status_t (*finish_dma)(ide_channel_cookie channel);
} ide_controller_interface;
// channel cookie, issued by ide bus manager
typedef struct ide_bus_info *ide_channel;
// Interface for Controller Driver
// interface of bus manager as seen from controller driver
// use this interface as the fixed consumer of your controller driver
typedef struct {
driver_module_info info;
// status - status read from controller (_not_ alt_status, as reading
// normal status acknowledges IRQ request of device)
status_t (*irq_handler)( ide_channel channel, uint8 status );
} ide_for_controller_interface;
#define IDE_FOR_CONTROLLER_MODULE_NAME "bus_managers/ide/controller/v1"
#endif /* __IDE_H__ */
+67
View File
@@ -0,0 +1,67 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
ISA bus manager
This is an improper name - this bus manager uses the PnP manager to
load device drivers, but calling it ISA PnP manager would be wrong as
ISA PnP information isn't used at all.
All ISA drivers must be Universal driver (see pnp_manager.h), as they
are all direct children of the ISA bus node. Having an ISA PnP bus manager
(which we don't), one node would be created per ISA device and thus you
could write Specific drivers, but under normal ISA we don't even know
how many devices are there, therefore the Universal driver trick.
Apart from the loading, the main change is the resource manager. In
a driver, you must allocate the resources before registering the node and
deallocate it when your node is removed and if the driver isn't loaded at
this time. If it is, you must delay deallocation until the driver gets
unloaded to make sure no new driver touches the same resources like you
meanwhile.
*/
#ifndef _ISA2_H
#define _ISA2_H
#include <device_manager.h>
#include <ISA.h>
// maximum size of one dma transfer
// (in bytes for 8 bit transfer, in words for 16 bit transfer)
#define B_MAX_ISA_DMA_COUNT 0x10000
typedef struct isa2_module_info {
bus_module_info info;
uint8 (*read_io_8)( int mapped_io_addr );
void (*write_io_8)( int mapped_io_addr, uint8 value );
uint16 (*read_io_16)( int mapped_io_addr );
void (*write_io_16)( int mapped_io_addr, uint16 value );
uint32 (*read_io_32)( int mapped_io_addr );
void (*write_io_32)( int mapped_io_addr, uint32 value );
// don't know what it's for, remains for compatibility
void *(*ram_address)( const void *physical_address_in_system_memory );
// start dma transfer (scattered DMA is not supported as it's EISA specific)
status_t (*start_isa_dma)(
long channel, // dma channel to use
void *buf, // buffer to transfer
long transfer_count, // # transfers
uchar mode, // mode flags
uchar e_mode // extended mode flags
);
} isa2_module_info;
// type of isa device
#define ISA_DEVICE_TYPE_NAME "isa/device/v1"
// directory of ISA drivers
// (there is only one device node, so put all drivers under "universal")
#define ISA_DRIVERS_DIR "isa"
#endif
+158
View File
@@ -0,0 +1,158 @@
/*
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
PCI bus manager
*/
#ifndef _PCI2_H
#define _PCI2_H
#include <device_manager.h>
#include <PCI.h>
// currently, this structure is disabled to avoid collision with R5 header
#if 0
typedef struct pci_info {
ushort vendor_id; /* vendor id */
ushort device_id; /* device id */
uchar bus; /* bus number */
uchar device; /* device number on bus */
uchar function; /* function number in device */
uchar revision; /* revision id */
uchar class_api; /* specific register interface type */
uchar class_sub; /* specific device function */
uchar class_base; /* device type (display vs network, etc) */
uchar line_size; /* cache line size in 32 bit words */
uchar latency; /* latency timer */
uchar header_type; /* header type */
uchar bist; /* built-in self-test */
uchar reserved; /* filler, for alignment */
union {
struct {
ulong cardbus_cis; /* CardBus CIS pointer */
ushort subsystem_id; /* subsystem (add-in card) id */
ushort subsystem_vendor_id; /* subsystem (add-in card) vendor id */
ulong rom_base; /* rom base address, viewed from host */
ulong rom_base_pci; /* rom base addr, viewed from pci */
ulong rom_size; /* rom size */
ulong base_registers[6]; /* base registers, viewed from host */
ulong base_registers_pci[6]; /* base registers, viewed from pci */
ulong base_register_sizes[6]; /* size of what base regs point to */
uchar base_register_flags[6]; /* flags from base address fields */
uchar interrupt_line; /* interrupt line */
uchar interrupt_pin; /* interrupt pin */
uchar min_grant; /* burst period @ 33 Mhz */
uchar max_latency; /* how often PCI access needed */
} h0;
struct {
ulong base_registers[2]; /* base registers, viewed from host */
ulong base_registers_pci[2]; /* base registers, viewed from pci */
ulong base_register_sizes[2]; /* size of what base regs point to */
uchar base_register_flags[2]; /* flags from base address fields */
uchar primary_bus;
uchar secondary_bus;
uchar subordinate_bus;
uchar secondary_latency;
uchar io_base;
uchar io_limit;
ushort secondary_status;
ushort memory_base;
ushort memory_limit;
ushort prefetchable_memory_base;
ushort prefetchable_memory_limit;
ulong prefetchable_memory_base_upper32;
ulong prefetchable_memory_limit_upper32;
ushort io_base_upper16;
ushort io_limit_upper16;
ulong rom_base; /* rom base address, viewed from host */
ulong rom_base_pci; /* rom base addr, viewed from pci */
uchar interrupt_line; /* interrupt line */
uchar interrupt_pin; /* interrupt pin */
ushort bridge_control;
} h1;
} u;
} pci_info;
#endif
typedef struct pci_device_info *pci_device;
// Interface to one PCI device.
// Actually, this is a _function_ of a device only, but
// pci_function_module_info would be a bit non-intuitive
typedef struct pci_device_module_info {
driver_module_info info;
uint8 (*read_io_8)(pci_device device, int mapped_io_addr);
void (*write_io_8)(pci_device device, int mapped_io_addr, uint8 value);
uint16 (*read_io_16)(pci_device device, int mapped_io_addr);
void (*write_io_16)(pci_device device, int mapped_io_addr, uint16 value);
uint32 (*read_io_32)(pci_device device, int mapped_io_addr);
void (*write_io_32)(pci_device device, int mapped_io_addr, uint32 value);
uint32 (*read_pci_config)(pci_device device,
uchar offset, /* offset in configuration space */
uchar size); /* # bytes to read (1, 2 or 4) */
void (*write_pci_config)(pci_device device,
uchar offset, /* offset in configuration space */
uchar size, /* # bytes to write (1, 2 or 4) */
uint32 value); /* value to write */
void *(*ram_address)(pci_device device, const void *physical_address_in_system_memory);
/* status_t (*allocate_iomem)( void *base, size_t len, const char *name );
status_t (*release_iomem)( void *base, size_t len );
status_t (*allocate_ioports)( uint16 ioport_base, size_t len, const char *name );
status_t (*release_ioports)( uint16 ioport_base, size_t len );*/
} pci_device_module_info;
// directory of PCI drivers
#define PCI_DRIVERS_DIR "pci"
// attributes of PCI device nodes
// bus idx (uint8)
#define PCI_DEVICE_BUS_ITEM "pci/bus"
// device idx (uint8)
#define PCI_DEVICE_DEVICE_ITEM "pci/device"
// function idx (uint8)
#define PCI_DEVICE_FUNCTION_ITEM "pci/function"
// vendor id (uint16)
#define PCI_DEVICE_VENDOR_ID_ITEM "pci/vendor_id"
// device id (uint16)
#define PCI_DEVICE_DEVICE_ID_ITEM "pci/device_id"
// subsystem id (uint16)
#define PCI_DEVICE_SUBSYSTEM_ID_ITEM "pci/subsystem_id"
// subvendor id (uint16)
#define PCI_DEVICE_SUBVENDOR_ID_ITEM "pci/subvendor_id"
// device base class (uint16)
#define PCI_DEVICE_BASE_CLASS_ID_ITEM "pci/class/base_id"
// device subclass (uint16)
#define PCI_DEVICE_SUB_CLASS_ID_ITEM "pci/class/sub_id"
// device api (uint16)
#define PCI_DEVICE_API_ID_ITEM "pci/class/api_id"
// dynamic consumer patterns for PCI devices
#define PCI_DEVICE_DYNAMIC_CONSUMER_0 \
PCI_DRIVERS_DIR "/" \
"vendor %" PCI_DEVICE_VENDOR_ID_ITEM "%|" \
", device %" PCI_DEVICE_DEVICE_ID_ITEM "%|" \
", subsystem %" PCI_DEVICE_SUBSYSTEM_ID_ITEM "%|" \
", subvendor %" PCI_DEVICE_SUBVENDOR_ID_ITEM "%"
#define PCI_DEVICE_DYNAMIC_CONSUMER_1 \
PCI_DRIVERS_DIR "/" \
"base_class %" PCI_DEVICE_BASE_CLASS_ID_ITEM "%|" \
", sub_class %" PCI_DEVICE_SUB_CLASS_ID_ITEM "%|" \
", api %" PCI_DEVICE_API_ID_ITEM "%"
#endif
+456
View File
@@ -0,0 +1,456 @@
/*
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef __SCSI_BUSMANAGER_H__
#define __SCSI_BUSMANAGER_H__
/*
Part of Open SCSI bus manager
SCSI bus manager interface
The bus manager interface is _based_ on CAM, but I've modified it because :-
- HBA engine, target mode and queue freezing (and probably other features)
aren't supported (at least the first two aren't supported by linux too ;)
- Asynchronous events aren't supported (no OS/driver I know uses them)
- P/T/L was defined by number not by handle, requiring many redundant tests
and thus making adding/removing of devices/busses very hard, especially if
PnP is to be supported
- single entry system as proposed by CAM involves extra tests and overhead
because of generalized data structure
For peripheral driver writers:
Something about requests involving data transfer: you can either specify
the virtual address in <data> of CCB (in which case it must be continuous),
or store a pointer to a S/G list that contains physical addresses in
<sg_list>/<sg_cnt>. If <sg_list> is non-Null, <data> is ignored.
The S/G list must be in kernel space because the request can be executed
in a different thread context. This is also the reason why the S/G list has
to contain physical addresses. For obvious reason, the data buffer specified
by <sg_list> must be locked, but <data> doesn't need to be.
You can either execute the request synchronously ("sync_io") or
asynchronously ("async_io"; you have to acquire <completion_sem> to find
out when the request is finished). In the first case you can use either
<data> or <sg_list>, in the latter <sg_list> only.
The SCSI bus manager takes care that the controller can access the data
via DMA by copying it into a buffer if necessary. For the paging path,
this can lead to problems (if the system writes a page to disk and the SCSI
bus manager has to allocate a buffer during execution you are in trouble),
therefore the blk_man takes care that is not necessary for reads/writes.
To safe some microseconds, you should set the SCSI_DMA_SAFE flag for these
requests, so the SCSI bus manager ommittes the test.
Effectively, using synchronous execution and specifying the address via
<data> is a safe bet.
For SIM writers:
Requests sent by peripheral drivers are forwarded to the <scsi_io> entry
of the SIM. You should return as soon as some waiting is required.
Usually, the controller raises an IRQ when a request can be continued
or is finished. As interrupt handlers must be as fast as possible, you
can schedule a DPC in the handler (<schedule_dpc>) which executed by a
high priority service thread that is spawned by the SCSI bus manager
for each bus. This service thread also takes care to submit waiting
requests.
You can specify a maximum number of concurrent requests per bus via
path_inquiry (<hba_queue_size>) for the bus. The device limit is
determined via INQUIRY. If you need a lower/dynamic limit, you can refuse
a request by <requeue>. If <bus_overflow> is true, no further requests
to the bus will be sent, if <bus_overflow> is false, no further requests
to the device will be sent. To terminate the overflow condition, call
<cont_send_device>/<cont_send_bus>. It also terminated when a request
for the bus/device is finished via <finished> or <resubmit>.
Because of the asynchronous nature, requests may still arrive after the
overflow condition being signalled, so you should add a safety test to
<scsi_io>.
If a problem occurs during execution, you can ask for a restart via
<resubmit>. The request in question will be submitted as soon as possible.
If you want to be not disturbed, you can block further requests via
<block_bus>/<block_device>. As said above, you must have a safety test
at <scsi_io> though.
If the SIM uses a non-SCSI protocol, it can ask the SCSI bus manager
to emulate unsupported SCSI commands by translating them other (supported)
commands. The bus manager calls <get_restriction> during detection for
each device, setting <is_atapi> on return makes the bus manager translate
READ6/WRITE6 commands to READ10/WRITE10 commands, MODE REQUEST6/SENSE6
to MODE REQUEST10/SENSE10 and fix the version fields of INQUIRY results,
so ATAPI devices can be used like standard SCSI devices. Further, the
SCSI bus manager can emulate auto-sense by executing a REQUEST SENSE
if <subsys_status> is SCSI_REQ_CMP_ERR and <device_status> is
SCSI_DEVICE_CHECK_CONDITION when a request is finished. This emulation
may be enhanced/generalized in the future.
*/
#include <KernelExport.h>
#include <device_manager.h>
#define SCSI_MAX_CDB_SIZE 16 // max size of cdb
#define SCSI_MAX_SENSE_SIZE 64 // max size of sense data
#define SCSI_SIM_PRIV 1536 // SIM private data; this may be a bit much but
// we currently need that for the compatibility layer
// bus/device handle
typedef struct scsi_bus_info *scsi_bus;
typedef struct scsi_device_info *scsi_device;
// structure of one scsi i/o CCB (command control block)
typedef struct scsi_ccb
{
struct scsi_ccb *next, *prev; // internal
uchar subsys_status; // Returned subsystem status
uchar device_status; // Returned scsi device status
uchar path_id; // Path ID for the request
uchar target_id; // Target device ID
uchar target_lun; // Target LUN number
uint32 flags; // Flags for operation of the subsystem
// released once after asynchronous execution of request;
// initialised by alloc_ccb, can be replaced for action but
// must be restored before returning via free_ccb
sem_id completion_sem;
uint8 cdb[SCSI_MAX_CDB_SIZE]; // command data block
uchar cdb_len; // length of command in bytes
int64 sort; // value of command to sort on (<0 means n/a)
bigtime_t timeout; // timeout - 0 = use default
uchar *data; // pointer to data
const physical_entry *sg_list; // SG list
uint16 sg_cnt; // number of SG entries
uint32 data_len; // length of data
int32 data_resid; // data transfer residual length: 2's comp
uchar sense[SCSI_MAX_SENSE_SIZE]; // autosense data
uchar sense_resid; // autosense resid length: 2's comp
// private
bool ordered : 1; // request cannot overtake/be overtaken by others
bool buffered : 1; // data is buffered to make it DMA safe
bool emulated : 1; // command is executed as part of emulation
scsi_bus bus; // associated bus
scsi_device device; // associated device
struct dma_buffer *dma_buffer; // used dma buffer, or NULL
uchar state; // bus manager state
// original data before command emulation was applied
uint8 orig_cdb[SCSI_MAX_CDB_SIZE];
uchar orig_cdb_len;
const physical_entry *orig_sg_list;
uint16 orig_sg_cnt;
uint32 orig_data_len;
// private SIM data
uchar sim_state; // set to zero when request is submitted first time
uchar sim_priv[SCSI_SIM_PRIV]; /* SIM private data area */
} scsi_ccb;
// Defines for the subsystem status field
#define SCSI_REQ_INPROG 0x00 /* request is in progress */
#define SCSI_REQ_CMP 0x01 /* request completed w/out error */
#define SCSI_REQ_ABORTED 0x02 /* request aborted by the host */
#define SCSI_UA_ABORT 0x03 /* Unable to Abort request */
#define SCSI_REQ_CMP_ERR 0x04 /* request completed with an err */
#define SCSI_BUSY 0x05 /* subsystem is busy */
#define SCSI_REQ_INVALID 0x06 /* request is invalid */
#define SCSI_PATH_INVALID 0x07 /* Path ID supplied is invalid */
#define SCSI_DEV_NOT_THERE 0x08 /* SCSI device not installed/there */
#define SCSI_UA_TERMIO 0x09 /* Unable to Terminate I/O req */
#define SCSI_SEL_TIMEOUT 0x0A /* Target selection timeout */
#define SCSI_CMD_TIMEOUT 0x0B /* Command timeout */
#define SCSI_MSG_REJECT_REC 0x0D /* Message reject received */
#define SCSI_SCSI_BUS_RESET 0x0E /* SCSI bus reset sent/received */
#define SCSI_UNCOR_PARITY 0x0F /* Uncorrectable parity err occurred */
#define SCSI_AUTOSENSE_FAIL 0x10 /* Autosense: Request sense cmd fail */
#define SCSI_NO_HBA 0x11 /* No HBA detected Error */
#define SCSI_DATA_RUN_ERR 0x12 /* Data overrun/underrun error */
#define SCSI_UNEXP_BUSFREE 0x13 /* Unexpected BUS free */
#define SCSI_SEQUENCE_FAIL 0x14 /* Target bus phase sequence failure */
#define SCSI_PROVIDE_FAIL 0x16 /* Unable to provide requ. capability */
#define SCSI_BDR_SENT 0x17 /* A SCSI BDR msg was sent to target */
#define SCSI_REQ_TERMIO 0x18 /* request terminated by the host */
#define SCSI_HBA_ERR 0x19 /* Unrecoverable host bus adaptor err*/
#define SCSI_BUS_RESET_DENIED 0x1A /* SCSI bus reset denied */
#define SCSI_IDE 0x33 /* Initiator Detected Error Received */
#define SCSI_RESRC_UNAVAIL 0x34 /* Resource unavailable */
#define SCSI_UNACKED_EVENT 0x35 /* Unacknowledged event by host */
#define SCSI_LUN_INVALID 0x38 /* LUN supplied is invalid */
#define SCSI_TID_INVALID 0x39 /* Target ID supplied is invalid */
#define SCSI_FUNC_NOTAVAIL 0x3A /* The requ. func is not available */
#define SCSI_NO_NEXUS 0x3B /* Nexus is not established */
#define SCSI_IID_INVALID 0x3C /* The initiator ID is invalid */
#define SCSI_CDB_RECVD 0x3D /* The SCSI CDB has been received */
#define SCSI_LUN_ALLREADY_ENAB 0x3E /* LUN already enabled */
#define SCSI_SCSI_BUSY 0x3F /* SCSI bus busy */
#define SCSI_AUTOSNS_VALID 0x80 /* Autosense data valid for target */
#define SCSI_SUBSYS_STATUS_MASK 0x3F /* Mask bits for just the status # */
// Defines for the flags field
#define SCSI_DIR_RESV 0x00000000 /* Data direction (00: reserved) */
#define SCSI_DIR_IN 0x00000040 /* Data direction (01: DATA IN) */
#define SCSI_DIR_OUT 0x00000080 /* Data direction (10: DATA OUT) */
#define SCSI_DIR_NONE 0x000000C0 /* Data direction (11: no data) */
#define SCSI_DIR_MASK 0x000000C0
#define SCSI_DIS_AUTOSENSE 0x00000020 /* Disable autosense feature */
#define SCSI_ORDERED_QTAG 0x00000010 // ordered queue (cannot overtake/be overtaken)
#define SCSI_DMA_SAFE 0x00000008 // set if data buffer is DMA approved
#define SCSI_DIS_DISCONNECT 0x00008000 /* Disable disconnect */
#define SCSI_INITIATE_SYNC 0x00004000 /* Attempt Sync data xfer, and SDTR */
#define SCSI_DIS_SYNC 0x00002000 /* Disable sync, go to async */
#define SCSI_ENG_SYNC 0x00000200 /* Flush resid bytes before cmplt */
// Defines for the Path Inquiry CCB fields
// flags in hba_inquiry
#define SCSI_PI_MDP_ABLE 0x80 /* Supports MDP message */
#define SCSI_PI_WIDE_32 0x40 /* Supports 32 bit wide SCSI */
#define SCSI_PI_WIDE_16 0x20 /* Supports 16 bit wide SCSI */
#define SCSI_PI_SDTR_ABLE 0x10 /* Supports SDTR message */
#define SCSI_PI_TAG_ABLE 0x02 /* Supports tag queue message */
#define SCSI_PI_SOFT_RST 0x01 /* Supports soft reset */
// flags in hba_misc
#define SCSI_PIM_SCANHILO 0x80 /* Bus scans from ID 7 to ID 0 */
#define SCSI_PIM_NOREMOVE 0x40 /* Removable dev not included in scan */
// sizes of inquiry fields
#define SCSI_VUHBA 14 /* Vendor Unique HBA length */
#define SCSI_SIM_ID 16 /* ASCII string len for SIM ID */
#define SCSI_HBA_ID 16 /* ASCII string len for HBA ID */
#define SCSI_FAM_ID 16 /* ASCII string len for FAMILY ID */
#define SCSI_TYPE_ID 16 /* ASCII string len for TYPE ID */
#define SCSI_VERS 8 /* ASCII string len for SIM & HBA vers */
// Path inquiry, extended by BeOS XPT_EXTENDED_PATH_INQ parameters
typedef struct
{
uchar version_num; /* Version number for the SIM/HBA */
uchar hba_inquiry; /* Mimic of INQ byte 7 for the HBA */
uchar hba_misc; /* Misc HBA feature flags */
uint32 sim_priv; /* Size of SIM private data area */
uchar vuhba_flags[SCSI_VUHBA];/* Vendor unique capabilities */
uchar initiator_id; /* ID of the HBA on the SCSI bus */
uint32 hba_queue_size; // size of adapaters command queue
char sim_vid[SCSI_SIM_ID]; /* Vendor ID of the SIM */
char hba_vid[SCSI_HBA_ID]; /* Vendor ID of the HBA */
char sim_version[SCSI_VERS]; /* SIM version number */
char hba_version[SCSI_VERS]; /* HBA version number */
char controller_family[SCSI_FAM_ID]; /* Controller family */
char controller_type[SCSI_TYPE_ID]; /* Controller type */
} scsi_path_inquiry;
// Device node
// target (uint8)
#define SCSI_DEVICE_TARGET_ID_ITEM "scsi/target_id"
// lun (uint8)
#define SCSI_DEVICE_TARGET_LUN_ITEM "scsi/target_lun"
// node type
#define SCSI_DEVICE_TYPE_NAME "scsi/device/v1"
// device inquiry data (raw scsi_res_inquiry)
#define SCSI_DEVICE_INQUIRY_ITEM "scsi/device_inquiry"
// device type (uint8)
#define SCSI_DEVICE_TYPE_ITEM "scsi/type"
// vendor name (string)
#define SCSI_DEVICE_VENDOR_ITEM "scsi/vendor"
// product name (string)
#define SCSI_DEVICE_PRODUCT_ITEM "scsi/product"
// revision (string)
#define SCSI_DEVICE_REVISION_ITEM "scsi/revision"
// directory containing links to peripheral drivers
#define SCSI_PERIPHERAL_DRIVERS_DIR "scsi"
// bus manager device interface for peripheral driver
typedef struct scsi_device_interface {
driver_module_info info;
// get CCB
// warning: if pool of CCBs is exhausted, this call is delayed until a
// CCB is freed, so don't try to allocate more then one CCB at once!
scsi_ccb *(*alloc_ccb)(scsi_device device);
// free CCB
void (*free_ccb)(scsi_ccb *ccb);
// execute command asynchronously
// when it's finished, the semaphore of the ccb is released
// you must provide a S/G list if data_len != 0
void (*async_io)(scsi_ccb *ccb);
// execute command synchronously
// you don't need to provide a S/G list nor have to lock data
void (*sync_io)(scsi_ccb *ccb);
// abort request
uchar (*abort)(scsi_ccb *ccb_to_abort);
// reset device
uchar (*reset_device)(scsi_device device);
// terminate request
uchar (*term_io)(scsi_ccb *ccb_to_terminate);
} scsi_device_interface;
#define SCSI_DEVICE_MODULE_NAME "bus_managers/scsi/driver/v1"
// Bus node
// attributes:
// path (uint8)
#define SCSI_BUS_PATH_ID_ITEM "scsi/path_id"
// node type
#define SCSI_BUS_TYPE_NAME "scsi/bus"
// SCSI bus node driver.
// This interface can be used by peripheral drivers to access the
// bus directly.
typedef struct scsi_bus_interface {
bus_module_info info;
// get information about host controller
uchar (*path_inquiry)(scsi_bus bus, scsi_path_inquiry *inquiry_data);
// reset SCSI bus
uchar (*reset_bus)(scsi_bus bus);
} scsi_bus_interface;
// name of SCSI bus node driver
#define SCSI_BUS_MODULE_NAME "bus_managers/scsi/bus/v1"
// Interface for SIM
// cookie for dpc
typedef struct scsi_dpc_info *scsi_dpc_cookie;
// Bus manager interface used by SCSI controller drivers.
// SCSI controller drivers get this interface passed via their init_device
// method. Further, they must specify this driver as their fixed consumer.
typedef struct scsi_for_sim_interface {
driver_module_info info;
// put request into wait queue because of overflow
// bus_overflow: true - too many bus requests
// false - too many device requests
// bus/device won't receive requests until cont_sent_bus/cont_send_device
// is called or a request is finished via finished();
// to avoid race conditions (reporting a full and a available bus at once)
// the SIM should synchronize calls to requeue, resubmit and finished
void (*requeue)(scsi_ccb *ccb, bool bus_overflow);
// resubmit request ASAP
// to be used if execution of request went wrong and must be retried
void (*resubmit)(scsi_ccb *ccb);
// mark request as being finished
// num_requests: number of requests that were handled by device
// when the request was sent (read: how full was the device
// queue); needed to find out how large the device queue is;
// e.g. if three were already running plus this request makes
// num_requests=4
void (*finished)(scsi_ccb *ccb, uint num_requests);
// following functions return error on invalid arguments only
status_t (*alloc_dpc)(scsi_dpc_cookie *dpc);
status_t (*free_dpc)(scsi_dpc_cookie dpc);
status_t (*schedule_dpc)(scsi_bus cookie, scsi_dpc_cookie dpc, /*int flags,*/
void (*func)( void * ), void *arg);
// block entire bus (can be nested)
// no more request will be submitted to this bus
void (*block_bus)(scsi_bus bus);
// unblock entire bus
// requests will be submitted to bus ASAP
void (*unblock_bus)(scsi_bus bus);
// block one device
// no more requests will be submitted to this device
void (*block_device)(scsi_device device);
// unblock device
// requests for this device will be submitted ASAP
void (*unblock_device)(scsi_device device);
// terminate bus overflow condition (see "requeue")
void (*cont_send_bus)(scsi_bus bus);
// terminate device overflow condition (see "requeue")
void (*cont_send_device)(scsi_device device);
} scsi_for_sim_interface;
#define SCSI_FOR_SIM_MODULE_NAME "bus_managers/scsi/sim/v1"
// SIM Node
// attributes:
// node type
#define SCSI_SIM_TYPE_NAME "bus/scsi/v1"
// controller name (required, string)
#define SCSI_DESCRIPTION_CONTROLLER_NAME "controller_name"
typedef struct scsi_sim_cookie *scsi_sim_cookie;
// SIM interface
// SCSI controller drivers must provide this interface
typedef struct scsi_sim_interface {
driver_module_info info;
// execute request
void (*scsi_io)( scsi_sim_cookie cookie, scsi_ccb *ccb );
// abort request
uchar (*abort)( scsi_sim_cookie cookie, scsi_ccb *ccb_to_abort );
// reset device
uchar (*reset_device)( scsi_sim_cookie cookie, uchar target_id, uchar target_lun );
// terminate request
uchar (*term_io)( scsi_sim_cookie cookie, scsi_ccb *ccb_to_terminate );
// get information about bus
uchar (*path_inquiry)( scsi_sim_cookie cookie, scsi_path_inquiry *inquiry_data );
// scan bus
// this is called immediately before the SCSI bus manager scans the bus
uchar (*scan_bus)( scsi_sim_cookie cookie );
// reset bus
uchar (*reset_bus)( scsi_sim_cookie cookie );
// get restrictions of one device
// (used for non-SCSI transport protocols and bug fixes)
void (*get_restrictions)(
scsi_sim_cookie cookie,
uchar target_id, // target id
bool *is_atapi, // set to true if this is an ATAPI device that
// needs some commands emulated
bool *no_autosense, // set to true if there is no autosense;
// the SCSI bus manager will request sense on
// SCSI_REQ_CMP_ERR/SCSI_DEVICE_CHECK_CONDITION
uint32 *max_blocks ); // maximum number of blocks per transfer if > 0;
// used for buggy devices that cannot handle
// large transfers (read: ATAPI ZIP drives)
} scsi_sim_interface;
#endif /* __SCSI_BUSMANAGER_H__ */
@@ -0,0 +1,220 @@
/*
* Copyright 2005, Axel Dörfler, [email protected]. All rights reserved.
* Copyright 2002-04, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
#ifndef _IDE_PCI_H
#define _IDE_PCI_H
/*
IDE adapter library
Module to simplify writing an IDE adapter driver.
The interface is not very abstract, i.e. the actual driver is
free to access any controller or channel data of this library.
*/
#include <bus/PCI.h>
#include <bus/IDE.h>
#include <device_manager.h>
// one Physical Region Descriptor (PRD)
// (one region must not cross 64K boundary;
// the PRD table must not cross a 64K boundary)
typedef struct prd_entry {
uint32 address; // physical address of block (must be even)
uint16 count; // size of block, 0 stands for 65536 (must be even)
uint8 res6;
LBITFIELD8_2(
res7_0 : 7,
EOT : 1 // 1 for last entry
);
} prd_entry;
// command register
typedef struct ide_bm_command {
LBITFIELD8_4(
start_stop : 1, // start BM by changing from 0 to 1;
// stop BM by changing from 1 to 0
res0_1 : 2,
from_device : 1, // true - read from device, false - write to device
res0_4 : 4
);
} ide_bm_command;
// status register
typedef struct ide_bm_status {
LBITFIELD8_7(
active : 1, // 1, if BM is active
error : 1, // 1, if error occured; write 1 to reset
interrupt : 1, // 1, if INTRQ was raised, write 1 to reset
res0_3 : 2,
device0_dma : 1, // 1, if BIOS/driver has setup DMA for device 0
device1_dma : 1, // 1, if BIOS/driver has setup DMA for device 1
simplex : 1 // 1, if only one channel can use DMA at a time
);
} ide_bm_status;
// offset of bus master registers
enum {
ide_bm_command_reg = 0, // see ide_bm_command
ide_bm_status_reg = 2, // see ide_bm_status
ide_bm_prdt_address = 4 // offset of PRDT register; content must be dword-aligned
};
// bit mask in class_api of PCI configuration
// (for adapters that can run in compatability mode)
enum {
ide_api_primary_native = 1, // primary channel is in native mode
ide_api_primary_fixed = 2, // primary channel can be switched to native mode
ide_api_secondary_native = 4, // secondary channel is in native mode
ide_api_secondary_fixed = 8 // secondary channel can be switched to native mode
};
// (maximum) size of S/G table
// there are so many restrictions that we want to keep it inside one page
// to be sure that we fulfill them all
#define IDE_ADAPTER_MAX_SG_COUNT (B_PAGE_SIZE / sizeof( prd_entry ))
// channel node items
// io address of command block (uint16)
#define IDE_ADAPTER_COMMAND_BLOCK_BASE "ide_adapter/command_block_base"
// io address of control block (uint16)
#define IDE_ADAPTER_CONTROL_BLOCK_BASE "ide_adapter/control_block_base"
// interrupt number (uint8)
// can also be defined in controller node if both channels use same IRQ!
#define IDE_ADAPTER_INTNUM "ide_adapter/irq"
// non-zero if primary channel, else secondary channel (uint8)
#define IDE_ADAPTER_IS_PRIMARY "ide_adapter/is_primary"
// controller node items
// io address of bus master registers (uint16)
#define IDE_ADAPTER_BUS_MASTER_BASE "ide_adapter/bus_master_base"
// info about one channel
typedef struct ide_adapter_channel_info {
pci_device_module_info *pci;
pci_device device;
uint16 command_block_base; // io address command block
uint16 control_block_base; // io address control block
uint16 bus_master_base;
int intnum; // interrupt number
uint32 lost; // != 0 if device got removed, i.e. if it must not
// be accessed anymore
ide_channel ide_channel;
device_node_handle node;
int32 (*inthand)( void *arg );
area_id prd_area;
prd_entry *prdt;
uint32 prdt_phys;
uint32 dmaing;
} ide_adapter_channel_info;
// info about controller
typedef struct ide_adapter_controller_info {
pci_device_module_info *pci;
pci_device device;
uint16 bus_master_base;
uint32 lost; // != 0 if device got removed, i.e. if it must not
// be accessed anymore
device_node_handle node;
} ide_adapter_controller_info;
// interface of IDE adapter library
typedef struct {
module_info info;
// function calls that can be forwarded from actual driver
status_t (*write_command_block_regs)(ide_adapter_channel_info *channel,
ide_task_file *tf, ide_reg_mask mask);
status_t (*read_command_block_regs)(ide_adapter_channel_info *channel,
ide_task_file *tf, ide_reg_mask mask);
uint8 (*get_altstatus) (ide_adapter_channel_info *channel);
status_t (*write_device_control) (ide_adapter_channel_info *channel, uint8 val);
status_t (*write_pio)(ide_adapter_channel_info *channel, uint16 *data, int count, bool force_16bit);
status_t (*read_pio)(ide_adapter_channel_info *channel, uint16 *data, int count, bool force_16bit);
status_t (*prepare_dma)(ide_adapter_channel_info *channel, const physical_entry *sg_list,
size_t sg_list_count, bool to_device);
status_t (*start_dma)(ide_adapter_channel_info *channel);
status_t (*finish_dma)(ide_adapter_channel_info *channel);
// default functions that should be replaced by a more specific version
// (copy them from source code of this library and modify them at will)
int32 (*inthand)(void *arg);
// functions that must be called by init/uninit etc. of channel driver
status_t (*init_channel)(device_node_handle node, ide_channel ide_channel,
ide_adapter_channel_info **cookie, size_t total_data_size,
int32 (*inthand)(void *arg));
status_t (*uninit_channel)(ide_adapter_channel_info *channel);
void (*channel_removed)(device_node_handle node, ide_adapter_channel_info *channel);
// publish channel node
status_t (*publish_channel)(device_node_handle controller_node,
const char *channel_module_name, uint16 command_block_base,
uint16 control_block_base, uint8 intnum, bool can_dma,
bool is_primary, const char *name,
io_resource_handle *resources, device_node_handle *node);
// verify channel configuration and publish node on success
status_t (*detect_channel)(pci_device_module_info *pci, pci_device pci_device,
device_node_handle controller_node, const char *channel_module_name,
bool controller_can_dma, uint16 command_block_base,
uint16 control_block_base, uint16 bus_master_base,
uint8 intnum, bool is_primary, const char *name,
device_node_handle *node, bool supports_compatibility_mode);
// functions that must be called by init/uninit etc. of controller driver
status_t (*init_controller)(device_node_handle node, void *user_cookie,
ide_adapter_controller_info **cookie, size_t total_data_size);
status_t (*uninit_controller)(ide_adapter_controller_info *controller);
void (*controller_removed)(device_node_handle node, ide_adapter_controller_info *controller);
// publish controller node
status_t (*publish_controller)(device_node_handle parent, uint16 bus_master_base,
io_resource_handle *resources, const char *controller_driver,
const char *controller_driver_type, const char *controller_name,
bool can_dma, bool can_cq, uint32 dma_alignment, uint32 dma_boundary,
uint32 max_sg_block_size, device_node_handle *node);
// verify controller configuration and publish node on success
status_t (*detect_controller)(pci_device_module_info *pci, pci_device pci_device,
device_node_handle parent, uint16 bus_master_base,
const char *controller_driver, const char *controller_driver_type,
const char *controller_name, bool can_dma, bool can_cq,
uint32 dma_alignment, uint32 dma_boundary, uint32 max_sg_block_size,
device_node_handle *node);
// standard master probe for controller that registers controller and channel nodes
status_t (*probe_controller)(device_node_handle parent, const char *controller_driver,
const char *controller_driver_type, const char *controller_name,
const char *channel_module_name, bool can_dma, bool can_cq,
uint32 dma_alignment, uint32 dma_boundary, uint32 max_sg_block_size,
bool supports_compatibility_mode);
} ide_adapter_interface;
#define IDE_ADAPTER_MODULE_NAME "generic/ide_adapter/v1"
#endif /* _IDE_PCI_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,162 @@
/*
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open SCSI Peripheral Driver
Use this module to minimize work required to write a SCSI
peripheral driver.
It takes care of:
- error handling
- medium changes (including restarting the medium)
- detection of medium capacity
*/
#ifndef __SCSI_PERIPH_H__
#define __SCSI_PERIPH_H__
#include <bus/SCSI.h>
#include <block_io.h>
#include <bus/scsi/scsi_cmds.h>
#include <Drivers.h>
// cookie issued by module per device
typedef struct scsi_periph_device_info *scsi_periph_device;
// cookie issued by module per file handle
typedef struct scsi_periph_handle_info *scsi_periph_handle;
// "standardized" error code to simplify handling of scsi errors
typedef enum {
err_act_ok, // executed successfully
err_act_retry, // failed, retry 3 times
err_act_fail, // failed, don't retry
err_act_many_retries, // failed, retry multiple times (currently 10 times)
err_act_start, // devices requires a "start" command
err_act_invalid_req // request is invalid
} err_act;
// packed scsi command result
typedef struct err_res {
status_t error_code : 32; // Be error code
uint32 action : 8; // err_act code
} err_res;
#define MK_ERROR( aaction, code ) ({ \
err_res res = {error_code: (code), action: (aaction) }; \
res; \
})
// device icon type
typedef enum {
icon_type_disk,
icon_type_removal,
icon_type_floppy,
icon_type_cd
} icon_type;
// cookie issued by driver to identify itself
//typedef struct periph_info *periph_cookie;
// cookie issued by driver per device
typedef struct periph_device_info *periph_device_cookie;
// cookie issued by driver per file handle
typedef struct periph_handle_info *periph_handle_cookie;
// callbacks to be provided by peripheral driver
typedef struct scsi_periph_callbacks {
// *** block devices ***
// informs of new size of medium
// (set to NULL if not a block device)
void (*set_capacity)( periph_device_cookie periph_device, uint64 capacity,
uint32 block_size );
// *** removable devices
// called when media got changed (can be NULL if medium is not changable)
// (you don't need to call periph->media_changed, but it's doesn't if you do)
// ccb - request at your disposal
void (*media_changed)( periph_device_cookie periph_device,
scsi_ccb *request );
} scsi_periph_callbacks;
// functions provided by this module
typedef struct scsi_periph_interface {
module_info info;
// *** init/cleanup ***
status_t (*register_device)(
periph_device_cookie periph_device,
scsi_periph_callbacks *callbacks,
scsi_device scsi_device,
scsi_device_interface *scsi,
device_node_handle node,
bool removable,
scsi_periph_device *driver );
status_t (*unregister_device)( scsi_periph_device driver );
// *** basic command execution ***
// exec command, retrying on problems
status_t (*safe_exec)(
scsi_periph_device periph_device,
scsi_ccb *request );
// exec simple command
status_t (*simple_exec)( scsi_periph_device device,
void *cdb, uchar cdb_len, void *data, size_t data_len,
int ccb_flags );
// *** file handling ***
// to be called when a new file is opened
status_t (*handle_open)( scsi_periph_device device,
periph_handle_cookie periph_handle, scsi_periph_handle *res_handle );
// to be called when a file is closed
status_t (*handle_close)( scsi_periph_handle handle );
// to be called when a file is freed
status_t (*handle_free)( scsi_periph_handle handle );
// *** default implementation for block devices ***
// block read
// preferred_ccb_size - preferred command size; if zero, the shortest is used
status_t (*read)( scsi_periph_handle handle, const phys_vecs *vecs,
off_t pos, size_t num_blocks, uint32 block_size, size_t *bytes_transferred,
int preferred_ccb_size );
// block write
// (see block_read)
status_t (*write)( scsi_periph_handle handle, const phys_vecs *vecs,
off_t pos, size_t num_blocks, uint32 block_size, size_t *bytes_transferred,
int preferred_ccb_size );
// block ioctls
status_t (*ioctl)( scsi_periph_handle handle, int op, void *buf, size_t len );
// check medium capacity (calls set_capacity callback on success)
// request - ccb for this device; is used to talk to device
status_t (*check_capacity)( scsi_periph_device device, scsi_ccb *request );
// *** removable media ***
// to be called when a medium change is detected to block subsequent commands
void (*media_changed)( scsi_periph_device device );
// convert result of *request to err_res
err_res (*check_error)( scsi_periph_device device, scsi_ccb *request );
// send start or stop command to device
// with_LoEj = true - include loading/ejecting,
// false - only do allow/deny
err_res (*send_start_stop)( scsi_periph_device device, scsi_ccb *request,
bool start, bool with_LoEj );
// checks media status and waits for device to become ready
// returns: B_OK, B_DEV_MEDIA_CHANGE_REQUESTED, B_NO_MEMORY or
// pending error reported by handle_get_error
status_t (*get_media_status)( scsi_periph_handle handle );
// compose device name consisting of prefix and path/target/LUN
// (result must be freed by caller)
char *(*compose_device_name)(device_node_handle device_node, const char *prefix);
// fill data with icon (for B_GET_ICON ioctl)
status_t (*get_icon)( icon_type type, device_icon *data );
} scsi_periph_interface;
#define SCSI_PERIPH_MODULE_NAME "generic/scsi_periph/v1"
#endif
+31
View File
@@ -0,0 +1,31 @@
/*******************************************************************************
/
/ File: bus_managers.h
/
/ Description: bus manager API
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _BUS_MANAGER_H
#define _BUS_MANAGER_H
#include <module.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct bus_manager_info bus_manager_info;
struct bus_manager_info {
module_info minfo;
status_t (*rescan)();
};
#ifdef __cplusplus
}
#endif
#endif /* _BUS_MANAGER_H */
+115
View File
@@ -0,0 +1,115 @@
#ifndef _CONFIG_MANAGER_H
#define _CONFIG_MANAGER_H
#include <module.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
B_ISA_BUS,
B_PCI_BUS,
B_PCMCIA_BUS,
B_UNKNOWN_BUS = 0x80
} bus_type;
typedef struct {
uchar base;
uchar subtype;
uchar interface;
} device_type;
typedef struct {
uint32 mask;
uint32 flags;
uint32 cookie;
} resource_mask_descriptor;
typedef struct {
uint32 minbase;
uint32 maxbase;
uint32 basealign;
uint32 len;
uint32 flags;
uint32 cookie;
} resource_range_descriptor;
typedef enum {
B_IRQ_RESOURCE,
B_DMA_RESOURCE,
B_IO_PORT_RESOURCE,
B_MEMORY_RESOURCE
} resource_type;
typedef struct {
resource_type type;
union {
resource_mask_descriptor m;
resource_range_descriptor r;
uint32 for_padding[7];
} d;
} resource_descriptor;
struct device_configuration {
uint32 flags;
uint32 num_resources;
resource_descriptor resources[0];
};
struct possible_device_configurations {
uint32 flags;
uint32 num_possible;
struct device_configuration possible[0];
};
struct device_info {
uint32 size;
uint32 bus_dependent_info_offset;
bus_type bus;
device_type devtype;
uint32 id[4]; /* unique (per-bus) normally-persistent id for device */
uint32 flags;
status_t config_status;
/* bus-dependent data goes here... */
};
#define B_DEVICE_INFO_ENABLED 1
#define B_DEVICE_INFO_CONFIGURED 2
#define B_DEVICE_INFO_CAN_BE_DISABLED 4
typedef struct config_manager_for_driver_module_info {
module_info minfo;
status_t (*get_next_device_info)(bus_type bus, uint64 *cookie,
struct device_info *info, uint32 len);
status_t (*get_device_info_for)(uint64 device,
struct device_info *info, uint32 len);
status_t (*get_size_of_current_configuration_for)(uint64 device);
status_t (*get_current_configuration_for)(uint64 device,
struct device_configuration *config, uint32 len);
status_t (*get_size_of_possible_configurations_for)(uint64 device);
status_t (*get_possible_configurations_for)(uint64 device,
struct possible_device_configurations *possible,
uint32 len);
/* helper routines for drivers */
status_t (*count_resource_descriptors_of_type)(
const struct device_configuration *config,
resource_type type);
status_t (*get_nth_resource_descriptor_of_type)(
const struct device_configuration *config, uint32 n,
resource_type type, resource_descriptor *descriptor,
uint32 len);
} config_manager_for_driver_module_info;
#define B_CONFIG_MANAGER_FOR_DRIVER_MODULE_NAME "bus_managers/config_manager/driver/v1"
#ifdef __cplusplus
}
#endif
#endif /* _CONFIG_MANAGER_H */
+197
View File
@@ -0,0 +1,197 @@
/*
* Copyright 2004-2005, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT license.
*/
#ifndef _DEVICE_MANAGER_H
#define _DEVICE_MANAGER_H
#include <TypeConstants.h>
#include <Drivers.h>
#include <module.h>
// type of I/O resource
enum {
IO_MEM = 1,
IO_PORT = 2,
ISA_DMA_CHANNEL = 3
};
// I/O resource description
typedef struct {
uint32 type;
// type of I/O resource
uint32 base;
// I/O memory: first physical address (32 bit)
// I/O port: first port address (16 bit)
// ISA DMA channel: channel number (0-7)
uint32 length;
// I/O memory: size of address range (32 bit)
// I/O port: size of port range (16 bit)
// ISA DMA channel: must be 1
} io_resource;
// attribute of a device node
typedef struct {
const char *name;
type_code type; // for supported types, see value
union {
uint8 ui8; // B_UINT8_TYPE
uint16 ui16; // B_UINT16_TYPE
uint32 ui32; // B_UINT32_TYPE
uint64 ui64; // B_UINT64_TYPE
const char *string; // B_STRING_TYPE
struct { // B_RAW_TYPE
void *data;
size_t length;
} raw;
} value;
} device_attr;
typedef struct device_node_info *device_node_handle;
typedef struct io_resource_info *io_resource_handle;
typedef struct device_attr_info *device_attr_handle;
typedef struct driver_module_info driver_module_info;
// interface of the device manager
typedef struct device_manager_info {
module_info info;
status_t (*init_driver)(device_node_handle node, void *userCookie,
driver_module_info **interface, void **cookie);
status_t (*uninit_driver)(device_node_handle node);
status_t (*rescan)(device_node_handle node);
status_t (*register_device)(device_node_handle parent,
const device_attr *attrs,
const io_resource_handle *io_resources,
device_node_handle *node);
status_t (*unregister_device)(device_node_handle node);
status_t (*get_next_child_device)(device_node_handle parent,
device_node_handle *_node, const device_attr *attrs);
device_node_handle (*get_parent)(device_node_handle node);
void (*put_device_node)(device_node_handle node);
status_t (*acquire_io_resources)(io_resource *resources,
io_resource_handle *handles);
status_t (*release_io_resources)(const io_resource_handle *handles);
int32 (*create_id)(const char *generator);
status_t (*free_id)(const char *generator, uint32 id);
status_t (*get_attr_uint8)(device_node_handle node,
const char *name, uint8 *value, bool recursive);
status_t (*get_attr_uint16)(device_node_handle node,
const char *name, uint16 *value, bool recursive);
status_t (*get_attr_uint32)(device_node_handle node,
const char *name, uint32 *value, bool recursive);
status_t (*get_attr_uint64)(device_node_handle node,
const char *name, uint64 *value, bool recursive);
status_t (*get_attr_string)(device_node_handle node,
const char *name, char **value, bool recursive);
status_t (*get_attr_raw)(device_node_handle node,
const char *name, void **data, size_t *_size,
bool recursive);
status_t (*get_next_attr)(device_node_handle node,
device_attr_handle *attrHandle);
status_t (*release_attr)(device_node_handle node,
device_attr_handle attr_handle);
status_t (*retrieve_attr)(device_attr_handle attr_handle,
const device_attr **attr);
status_t (*write_attr)(device_node_handle node,
const device_attr *attr);
status_t (*remove_attr)(device_node_handle node, const char *name);
} device_manager_info;
#define B_DEVICE_MANAGER_MODULE_NAME "system/device_manager/v1"
// interface of device driver
struct driver_module_info {
module_info info;
float (*supports_device)(device_node_handle parent, bool *_noConnection);
status_t (*register_device)(device_node_handle parent);
status_t (*init_driver)(device_node_handle node, void *user_cookie, void **_cookie);
status_t (*uninit_driver)(void *cookie);
void (*device_removed)(device_node_handle node, void *cookie);
void (*device_cleanup)(device_node_handle node);
void (*get_supported_paths)(const char ***_busses, const char ***_devices);
};
// standard device node attributes
#define PNP_MANAGER_ID_GENERATOR "id_generator"
// if you are using an id generator (see create_id), you can let the
// manager automatically free the id when the node is deleted by setting
// the following attributes:
// name of generator (string)
#define PNP_MANAGER_AUTO_ID "auto_id"
// generated id (uint32)
#define B_DRIVER_MODULE "driver/module"
#define B_DRIVER_PRETTY_NAME "driver/pretty name"
#define B_DRIVER_FIXED_CHILD "driver/fixed child"
#define B_DRIVER_MAPPING "driver/mapping"
#define B_DRIVER_BUS "driver/bus"
#define B_DRIVER_FIND_DEVICES_ON_DEMAND "driver/on demand"
#define B_DRIVER_EXPLORE_LAST "driver/explore last"
#define B_DRIVER_UNIQUE_DEVICE_ID "unique id"
#define B_DRIVER_DEVICE_TYPE "device type"
#define B_AUDIO_DRIVER_TYPE "audio"
#define B_BUS_DRIVER_TYPE "bus"
#define B_DISK_DRIVER_TYPE "disk"
#define B_GRAPHICS_DRIVER_TYPE "graphics"
#define B_INPUT_DRIVER_TYPE "input"
#define B_MISC_DRIVER_TYPE "misc"
#define B_NETWORK_DRIVER_TYPE "net"
#define B_VIDEO_DRIVER_TYPE "video"
#define PNP_DRIVER_CONNECTION "connection"
// connection of parent the device is attached to (optional, string)
// there can be only one device per connection
// interface of a bus device driver
typedef struct bus_module_info {
driver_module_info info;
// scan the bus and register all devices.
status_t (*register_child_devices)(void *cookie);
// user initiated rescan of the bus - only propagate changes
// you only need to implement this, if you cannot detect device changes yourself
// driver is always loaded during this call, but other hooks may
// be called concurrently
status_t (*rescan_bus)(void *cookie);
} bus_module_info;
// standard attributes
// PnP bus identification (required, uint8)
// define this to let the PnP manager know that this is a PnP bus
// the actual content is ignored
#define PNP_BUS_IS_BUS "bus/is_bus"
#endif /* _DEVICE_MANAGER_H */
@@ -0,0 +1,126 @@
// disk_device_manager.h
//
// C API exported by the disk device manager.
// Currently only functions of interest for partition modules/FS add-ons
// are considered.
#ifndef _DISK_DEVICE_MANAGER_H
#define _DISK_DEVICE_MANAGER_H
#include <Drivers.h>
#include <storage/DiskDeviceDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
// C API partition representation
// Fields marked [sys] are set by the system and are not to be changed by
// the disk system modules.
typedef struct partition_data {
partition_id id; // [sys]
off_t offset;
off_t size;
off_t content_size;
uint32 block_size;
int32 child_count;
int32 index; // [sys]
uint32 status;
uint32 flags;
dev_t volume; // [sys]
void *mount_cookie; // [sys]
char *name; // max: B_OS_NAME_LENGTH
char *content_name; //
char *type; //
const char *content_type; // [sys]
char *parameters;
char *content_parameters;
void *cookie;
void *content_cookie;
} partition_data;
// C API disk device representation
typedef struct disk_device_data {
partition_id id; // equal to that of the root partition
uint32 flags;
char *path;
device_geometry geometry;
} disk_device_data;
// C API partitionable space representation
typedef struct partitionable_space_data {
off_t offset;
off_t size;
} partitionable_space_data;
// operations on partitions
enum {
B_PARTITION_DEFRAGMENT,
B_PARTITION_REPAIR,
B_PARTITION_RESIZE,
B_PARTITION_RESIZE_CHILD,
B_PARTITION_MOVE,
B_PARTITION_MOVE_CHILD,
B_PARTITION_SET_NAME,
B_PARTITION_SET_CONTENT_NAME,
B_PARTITION_SET_TYPE,
B_PARTITION_SET_PARAMETERS,
B_PARTITION_SET_CONTENT_PARAMETERS,
B_PARTITION_INITIALIZE,
B_PARTITION_CREATE_CHILD,
B_PARTITION_DELETE_CHILD,
};
// disk device job cancel status
enum {
B_DISK_DEVICE_JOB_CONTINUE,
B_DISK_DEVICE_JOB_CANCEL,
B_DISK_DEVICE_JOB_REVERSE,
};
// disk device locking
disk_device_data *write_lock_disk_device(partition_id partitionID);
void write_unlock_disk_device(partition_id partitionID);
disk_device_data *read_lock_disk_device(partition_id partitionID);
void read_unlock_disk_device(partition_id partitionID);
// parameter is the ID of any partition on the device
// getting disk devices/partitions by path
// (no locking required)
int32 find_disk_device(const char *path);
int32 find_partition(const char *path);
// disk device/partition read access
// (read lock required)
disk_device_data *get_disk_device(partition_id partitionID);
partition_data *get_partition(partition_id partitionID);
partition_data *get_parent_partition(partition_id partitionID);
partition_data *get_child_partition(partition_id partitionID, int32 index);
// partition write access
// (write lock required)
partition_data *create_child_partition(partition_id partitionID, int32 index,
partition_id childID);
// childID is an optional input parameter -- -1 to be ignored
bool delete_partition(partition_id partitionID);
void partition_modified(partition_id partitionID);
// tells the disk device manager, that the parition has been modified
// disk systems
disk_system_id find_disk_system(const char *name);
// jobs
bool update_disk_device_job_progress(disk_job_id jobID, float progress);
bool update_disk_device_job_extra_progress(disk_job_id jobID,
const char *info);
bool set_disk_device_job_error_message(disk_job_id jobID, const char *message);
uint32 update_disk_device_job_interrupt_properties(disk_job_id jobID,
uint32 interruptProperties);
// returns one of B_DISK_DEVICE_JOB_{CONTINUE,CANCEL,REVERSE}
#ifdef __cplusplus
}
#endif
#endif // _DISK_DEVICE_MANAGER_H
@@ -0,0 +1,52 @@
#ifndef _DRIVER_SETTINGS_H
#define _DRIVER_SETTINGS_H
#include <OS.h>
typedef struct driver_parameter {
char *name;
int value_count;
char **values;
int parameter_count;
struct driver_parameter *parameters;
} driver_parameter;
typedef struct driver_settings {
int parameter_count;
struct driver_parameter *parameters;
} driver_settings;
#ifdef __cplusplus
extern "C" {
#endif
extern void *load_driver_settings(const char *driverName);
extern status_t unload_driver_settings(void *handle);
extern void *parse_driver_settings_string(const char *settingsString);
extern status_t get_driver_settings_string(void *_handle, char *buffer,
size_t *_bufferSize, bool flat);
extern status_t delete_driver_settings(void *handle);
extern const char *get_driver_parameter(void *handle, const char *key,
const char *unknownValue, /* key not present */
const char *noargValue); /* key has no value */
extern bool get_driver_boolean_parameter(void *handle, const char *key,
bool unknownValue, bool noargValue);
extern const driver_settings *get_driver_settings(void *handle);
/* Pass this in as drivername to access safe mode settings */
#define B_SAFEMODE_DRIVER_SETTINGS "/safemode/"
/* Pass this as the key value to check if safe mode is enabled */
#define B_SAFEMODE_SAFE_MODE "safemode"
#ifdef __cplusplus
}
#endif
#endif /* _DRIVER_SETTINGS_H */
+80
View File
@@ -0,0 +1,80 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
Fast logging facilities.
This logging is much faster then dprintf and is saver
against buffer overflow conditions.
Clients have to define events by creating an array of
fast_log_type entries, each consisting of a code and the
associated human-readable description. During logging,
only the code is stored to save space and time. Also,
all arguments are stored binary (currently, they must
be of type uint32). Conversion to human-readable text is
post-poned until the logging data is read or a client
connection is closed (as this invalidates the event-
description binding).
The reader interface is /dev/FAST_LOG_DEVFS_NAME. This
device can only be read from (no seeking or further
functionality) and does not block if there is no data.
This is because if you want to store the log into a
file, the file access may lead to further logging data,
so doing a sleep between reads saves logging entries.
*/
#ifndef FAST_LOG_H
#define FAST_LOG_H
#include <module.h>
// one event type as defined by client
typedef struct fast_log_event_type {
// code of event (zero means end-of-list)
int16 event;
// human-readable description
const char *description;
} fast_log_event_type;
// handle of client connection
typedef struct fast_log_connection *fast_log_handle;
// client interface
typedef struct fast_log_info {
module_info minfo;
// open client connection
// prefix - prefix to print in log before each event
// types - array of event types; last entry must have event=0
fast_log_handle (*start_log)(const char *prefix, fast_log_event_type types[]);
// close client connection
void (*stop_log)(fast_log_handle handle);
// log an entry without arguments
void (*log_0)(fast_log_handle handle, int event);
// log an entry with one argument
void (*log_1)(fast_log_handle handle, int event, uint32 param1);
// log an entry with two arguments
void (*log_2)(fast_log_handle handle, int event, uint32 param1, uint32 param2);
// log an entry with three arguments
void (*log_3)(fast_log_handle handle, int event, uint32 param1, uint32 param2, uint32 param3);
// log an entry with four arguments
void (*log_4)(fast_log_handle handle, int event, uint32 param1, uint32 param2, uint32 param3, uint32 param4);
// log an entry with n arguments
// don't cheat on num_params!
void (*log_n)(fast_log_handle handle, int event, int num_params, ...);
} fast_log_info;
// name of client interface module
#define FAST_LOG_MODULE_NAME "generic/fast_log/v1"
// name of device to read logging data from
#define FAST_LOG_DEVFS_NAME "fast_log"
#endif
+63
View File
@@ -0,0 +1,63 @@
/* File System File and Block Caches
*
* Copyright 2004-2005, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FS_CACHE_H
#define _FS_CACHE_H
#include <fs_interface.h>
typedef void (*transaction_notification_hook)(int32 id, void *data);
#ifdef __cplusplus
extern "C" {
#endif
/* transactions */
extern int32 cache_start_transaction(void *_cache);
extern status_t cache_sync_transaction(void *_cache, int32 id);
extern status_t cache_end_transaction(void *_cache, int32 id, transaction_notification_hook hook, void *data);
extern status_t cache_abort_transaction(void *_cache, int32 id);
extern int32 cache_detach_sub_transaction(void *_cache, int32 id);
extern status_t cache_abort_sub_transaction(void *_cache, int32 id);
extern status_t cache_start_sub_transaction(void *_cache, int32 id);
extern status_t cache_next_block_in_transaction(void *_cache, int32 id, uint32 *_cookie,
off_t *_blockNumber, void **_data, void **_unchangedData);
/* block cache */
extern void block_cache_delete(void *_cache, bool allowWrites);
extern void *block_cache_create(int fd, off_t numBlocks, size_t blockSize);
extern status_t block_cache_sync(void *_cache);
extern status_t block_cache_make_writable(void *_cache, off_t blockNumber, int32 transaction);
extern void *block_cache_get_writable_etc(void *_cache, off_t blockNumber, off_t base,
off_t length, int32 transaction);
extern void *block_cache_get_writable(void *_cache, off_t blockNumber, int32 transaction);
extern void *block_cache_get_empty(void *_cache, off_t blockNumber, int32 transaction);
extern const void *block_cache_get_etc(void *_cache, off_t blockNumber, off_t base, off_t length);
extern const void *block_cache_get(void *_cache, off_t blockNumber);
extern status_t block_cache_set_dirty(void *_cache, off_t blockNumber, bool isDirty, int32 transaction);
extern void block_cache_put(void *_cache, off_t blockNumber);
/* file cache */
extern void *file_cache_create(mount_id mountID, vnode_id vnodeID, off_t size, int fd);
extern void file_cache_delete(void *_cacheRef);
extern status_t file_cache_set_size(void *_cacheRef, off_t size);
extern status_t file_cache_sync(void *_cache);
extern status_t file_cache_invalidate_file_map(void *_cacheRef, off_t offset, off_t size);
extern status_t file_cache_read_pages(void *_cacheRef, off_t offset,
const iovec *vecs, size_t count, size_t *_numBytes);
extern status_t file_cache_write_pages(void *_cacheRef, off_t offset,
const iovec *vecs, size_t count, size_t *_numBytes);
extern status_t file_cache_read(void *_cacheRef, off_t offset, void *bufferBase, size_t *_size);
extern status_t file_cache_write(void *_cacheRef, off_t offset, const void *buffer, size_t *_size);
#ifdef __cplusplus
}
#endif
#endif /* _FS_CACHE_H */
+258
View File
@@ -0,0 +1,258 @@
/* File System Interface Layer Definition
*
* Copyright 2004-2005, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FS_INTERFACE_H
#define _FS_INTERFACE_H
#include <OS.h>
#include <Select.h>
#include <module.h>
#include <disk_device_manager.h>
#include <sys/uio.h>
struct dirent;
struct stat;
struct fs_info;
struct select_sync;
typedef dev_t mount_id;
typedef ino_t vnode_id;
/* the file system's private data structures */
typedef void *fs_volume;
typedef void *fs_cookie;
typedef void *fs_vnode;
/* passed to write_stat() */
enum write_stat_mask {
FS_WRITE_STAT_MODE = 0x0001,
FS_WRITE_STAT_UID = 0x0002,
FS_WRITE_STAT_GID = 0x0004,
FS_WRITE_STAT_SIZE = 0x0008,
FS_WRITE_STAT_ATIME = 0x0010,
FS_WRITE_STAT_MTIME = 0x0020,
FS_WRITE_STAT_CRTIME = 0x0040
// NOTE: Changing these constants will break
// src/kits/storage/LibBeAdapter.cpp:_kern_write_stat().
};
/* passed to write_fs_info() */
#define FS_WRITE_FSINFO_NAME 0x0001
struct file_io_vec {
off_t offset;
off_t length;
};
#define B_CURRENT_FS_API_VERSION "/v1"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct file_system_module_info {
struct module_info info;
const char *pretty_name;
/* scanning (the device is write locked) */
float (*identify_partition)(int fd, partition_data *partition,
void **cookie);
status_t (*scan_partition)(int fd, partition_data *partition,
void *cookie);
void (*free_identify_partition_cookie)(partition_data *partition,
void *cookie);
void (*free_partition_content_cookie)(partition_data *partition);
/* general operations */
status_t (*mount)(mount_id id, const char *device, uint32 flags,
const char *args, fs_volume *_fs, vnode_id *_rootVnodeID);
status_t (*unmount)(fs_volume fs);
status_t (*read_fs_info)(fs_volume fs, struct fs_info *info);
status_t (*write_fs_info)(fs_volume fs, const struct fs_info *info, uint32 mask);
status_t (*sync)(fs_volume fs);
/* vnode operations */
status_t (*lookup)(fs_volume fs, fs_vnode dir, const char *name, vnode_id *_id, int *_type);
status_t (*get_vnode_name)(fs_volume fs, fs_vnode vnode, char *buffer, size_t bufferSize);
status_t (*get_vnode)(fs_volume fs, vnode_id id, fs_vnode *_vnode, bool reenter);
status_t (*put_vnode)(fs_volume fs, fs_vnode vnode, bool reenter);
status_t (*remove_vnode)(fs_volume fs, fs_vnode vnode, bool reenter);
/* VM file access */
bool (*can_page)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
status_t (*read_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes);
status_t (*write_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes);
/* cache file access */
status_t (*get_file_map)(fs_volume fs, fs_vnode vnode, off_t offset, size_t size, struct file_io_vec *vecs, size_t *_count);
/* common operations */
status_t (*ioctl)(fs_volume fs, fs_vnode v, fs_cookie cookie, ulong op, void *buffer, size_t length);
status_t (*set_flags)(fs_volume fs, fs_vnode v, fs_cookie cookie, int flags);
status_t (*select)(fs_volume fs, fs_vnode v, fs_cookie cookie, uint8 event,
uint32 ref, selectsync *sync);
status_t (*deselect)(fs_volume fs, fs_vnode v, fs_cookie cookie,
uint8 event, selectsync *sync);
status_t (*fsync)(fs_volume fs, fs_vnode v);
status_t (*read_link)(fs_volume fs, fs_vnode link, char *buffer, size_t *_bufferSize);
status_t (*write_link)(fs_volume fs, fs_vnode link, char *toPath);
status_t (*create_symlink)(fs_volume fs, fs_vnode dir, const char *name, const char *path, int mode);
status_t (*link)(fs_volume fs, fs_vnode dir, const char *name, fs_vnode vnode);
status_t (*unlink)(fs_volume fs, fs_vnode dir, const char *name);
status_t (*rename)(fs_volume fs, fs_vnode fromDir, const char *fromName, fs_vnode toDir, const char *toName);
status_t (*access)(fs_volume fs, fs_vnode vnode, int mode);
status_t (*read_stat)(fs_volume fs, fs_vnode vnode, struct stat *stat);
status_t (*write_stat)(fs_volume fs, fs_vnode vnode, const struct stat *stat, uint32 statMask);
/* file operations */
status_t (*create)(fs_volume fs, fs_vnode dir, const char *name, int openMode, int perms, fs_cookie *_cookie, vnode_id *_newVnodeID);
status_t (*open)(fs_volume fs, fs_vnode v, int openMode, fs_cookie *_cookie);
status_t (*close)(fs_volume fs, fs_vnode v, fs_cookie cookie);
status_t (*free_cookie)(fs_volume fs, fs_vnode v, fs_cookie cookie);
status_t (*read)(fs_volume fs, fs_vnode v, fs_cookie cookie, off_t pos, void *buffer, size_t *length);
status_t (*write)(fs_volume fs, fs_vnode v, fs_cookie cookie, off_t pos, const void *buffer, size_t *length);
/* directory operations */
status_t (*create_dir)(fs_volume fs, fs_vnode parent, const char *name, int perms, vnode_id *_newVnodeID);
status_t (*remove_dir)(fs_volume fs, fs_vnode parent, const char *name);
status_t (*open_dir)(fs_volume fs, fs_vnode vnode, fs_cookie *_cookie);
status_t (*close_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
status_t (*free_dir_cookie)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
status_t (*read_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num);
status_t (*rewind_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
/* attribute directory operations */
status_t (*open_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie *_cookie);
status_t (*close_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
status_t (*free_attr_dir_cookie)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
status_t (*read_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num);
status_t (*rewind_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
/* attribute operations */
status_t (*create_attr)(fs_volume fs, fs_vnode file, const char *name, uint32 type, int openMode, fs_cookie *_cookie);
status_t (*open_attr)(fs_volume fs, fs_vnode file, const char *name, int openMode, fs_cookie *_cookie);
status_t (*close_attr)(fs_volume fs, fs_vnode file, fs_cookie cookie);
status_t (*free_attr_cookie)(fs_volume fs, fs_vnode file, fs_cookie cookie);
status_t (*read_attr)(fs_volume fs, fs_vnode file, fs_cookie cookie, off_t pos, void *buffer, size_t *length);
status_t (*write_attr)(fs_volume fs, fs_vnode file, fs_cookie cookie, off_t pos, const void *buffer, size_t *length);
status_t (*read_attr_stat)(fs_volume fs, fs_vnode file, fs_cookie cookie, struct stat *stat);
status_t (*write_attr_stat)(fs_volume fs, fs_vnode file, fs_cookie cookie, const struct stat *stat, int statMask);
status_t (*rename_attr)(fs_volume fs, fs_vnode fromFile, const char *fromName, fs_vnode toFile, const char *toName);
status_t (*remove_attr)(fs_volume fs, fs_vnode file, const char *name);
/* index directory & index operations */
status_t (*open_index_dir)(fs_volume fs, fs_cookie *cookie);
status_t (*close_index_dir)(fs_volume fs, fs_cookie cookie);
status_t (*free_index_dir_cookie)(fs_volume fs, fs_cookie cookie);
status_t (*read_index_dir)(fs_volume fs, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num);
status_t (*rewind_index_dir)(fs_volume fs, fs_cookie cookie);
status_t (*create_index)(fs_volume fs, const char *name, uint32 type, uint32 flags);
status_t (*remove_index)(fs_volume fs, const char *name);
status_t (*read_index_stat)(fs_volume fs, const char *name, struct stat *stat);
/* query operations */
status_t (*open_query)(fs_volume fs, const char *query, uint32 flags, port_id port, uint32 token, fs_cookie *_cookie);
status_t (*close_query)(fs_volume fs, fs_cookie cookie);
status_t (*free_query_cookie)(fs_volume fs, fs_cookie cookie);
status_t (*read_query)(fs_volume fs, fs_cookie cookie,
struct dirent *buffer, size_t bufferSize, uint32 *_num);
status_t (*rewind_query)(fs_volume fs, fs_cookie cookie);
/* capability querying (the device is read locked) */
// ToDo: this will probably be combined to a single call
bool (*supports_defragmenting)(partition_data *partition,
bool *whileMounted);
bool (*supports_repairing)(partition_data *partition,
bool checkOnly, bool *whileMounted);
bool (*supports_resizing)(partition_data *partition,
bool *whileMounted);
bool (*supports_moving)(partition_data *partition, bool *isNoOp);
bool (*supports_setting_content_name)(partition_data *partition,
bool *whileMounted);
bool (*supports_setting_content_parameters)(partition_data *partition,
bool *whileMounted);
bool (*supports_initializing)(partition_data *partition);
bool (*validate_resize)(partition_data *partition, off_t *size);
bool (*validate_move)(partition_data *partition, off_t *start);
bool (*validate_set_content_name)(partition_data *partition,
char *name);
bool (*validate_set_content_parameters)(partition_data *partition,
const char *parameters);
bool (*validate_initialize)(partition_data *partition, char *name,
const char *parameters);
/* shadow partition modification (device is write locked) */
status_t (*shadow_changed)(partition_data *partition,
uint32 operation);
/* writing (the device is NOT locked) */
status_t (*defragment)(int fd, partition_id partition,
disk_job_id job);
status_t (*repair)(int fd, partition_id partition, bool checkOnly,
disk_job_id job);
status_t (*resize)(int fd, partition_id partition, off_t size,
disk_job_id job);
status_t (*move)(int fd, partition_id partition, off_t offset,
disk_job_id job);
status_t (*set_content_name)(int fd, partition_id partition,
const char *name, disk_job_id job);
status_t (*set_content_parameters)(int fd, partition_id partition,
const char *parameters, disk_job_id job);
status_t (*initialize)(const char *partition, const char *name,
const char *parameters, disk_job_id job);
// This is pretty close to how the hook in R5 looked. Save the job ID, of
// course and that the parameters were given as (void*, size_t) pair.
} file_system_module_info;
/* file system add-ons only prototypes */
extern status_t new_vnode(mount_id mountID, vnode_id vnodeID, fs_vnode privateNode);
extern status_t publish_vnode(mount_id mountID, vnode_id vnodeID, fs_vnode privateNode);
extern status_t get_vnode(mount_id mountID, vnode_id vnodeID, fs_vnode *_privateNode);
extern status_t put_vnode(mount_id mountID, vnode_id vnodeID);
extern status_t remove_vnode(mount_id mountID, vnode_id vnodeID);
extern status_t unremove_vnode(mount_id mountID, vnode_id vnodeID);
extern status_t notify_listener(int op, mount_id device, vnode_id parentNode,
vnode_id toParentNode, vnode_id node, const char *name);
extern status_t send_notification(port_id port, long token, ulong what, long op,
mount_id device, mount_id toDevice, vnode_id parentNode,
vnode_id toParentNode, vnode_id node, const char *name);
extern status_t notify_entry_created(mount_id device, vnode_id directory,
const char *name, vnode_id node);
extern status_t notify_entry_removed(mount_id device, vnode_id directory,
const char *name, vnode_id node);
extern status_t notify_entry_moved(mount_id device, vnode_id fromDirectory,
const char *fromName, vnode_id toDirectory,
const char *toName, vnode_id node);
extern status_t notify_stat_changed(mount_id device, vnode_id node,
uint32 statFields);
extern status_t notify_attribute_changed(mount_id device, vnode_id node,
const char *attribute, int32 cause);
extern status_t notify_query_entry_created(port_id port, int32 token,
mount_id device, vnode_id directory, const char *name,
vnode_id node);
extern status_t notify_query_entry_removed(port_id port, int32 token,
mount_id device, vnode_id directory, const char *name,
vnode_id node);
#ifdef __cplusplus
}
#endif
#endif /* _FS_INTERFACE_H */
+68
View File
@@ -0,0 +1,68 @@
#ifndef _ISA_CONFIG_H
#define _ISA_CONFIG_H
#include <config_manager.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef union {
uint32 id;
uchar b[4];
} EISA_PRODUCT_ID;
/* uint32 MAKE_EISA_PRODUCT_ID(EISA_PRODUCT_ID* ptr, char ch0, char ch1, char ch2, uint12 prod_num, uint4 rev) */
/* example: MAKE_EISA_PRODUCT_ID(&foo_id, 'F','O','O', 0xdb1, 3); */
/* makes correct little-endian format */
#define MAKE_EISA_PRODUCT_ID(ptr, ch0, ch1, ch2, prod_num, rev) \
do { \
(ptr)->b[0] = (uint8)(((((ch0) - 'A' + 1) & 0x1f) << 2) | ((((ch1) - 'A' + 1) & 0x18) >> 3)); \
(ptr)->b[1] = (uint8)(((((ch1) - 'A' + 1) & 0x07) << 5) | ((((ch2) - 'A' + 1) & 0x1f) )); \
(ptr)->b[2] = (uint8)((((prod_num) & 0xff0) >> 4)); \
(ptr)->b[3] = (uint8)((((prod_num) & 0x00f) << 4) | ((rev) & 0xf) ); \
} while(0)
/* Compare IDs without revision */
/* bool EQUAL_EISA_PRODUCT_ID(EISA_PRODUCT_ID id1, EISA_PRODUCT_ID id2); */
#define EQUAL_EISA_PRODUCT_ID(id1, id2) \
(((id1).b[0] == (id2).b[0]) && ((id1).b[1] == (id2).b[1]) && ((id1).b[2] == (id2).b[2]) && (((id1).b[3] & 0xf0) == ((id2).b[3] & 0xf0)))
#define B_MAX_COMPATIBLE_IDS 8
/* This structure is deprecated and will be going away in the next release */
struct isa_device_info {
struct device_info info;
uchar csn;
uchar ldn;
uint32 vendor_id;
uint32 card_id; /* a.k.a. serial number */
uint32 logical_device_id;
uint32 num_compatible_ids;
uint32 compatible_ids[B_MAX_COMPATIBLE_IDS];
char card_name[B_OS_NAME_LENGTH];
char logical_device_name[B_OS_NAME_LENGTH];
};
/* So use this instead */
struct isa_info {
uchar csn;
uchar ldn;
uint32 vendor_id;
uint32 card_id; /* a.k.a. serial number */
uint32 logical_device_id;
uint32 num_compatible_ids;
uint32 compatible_ids[B_MAX_COMPATIBLE_IDS];
char card_name[B_OS_NAME_LENGTH];
char logical_device_name[B_OS_NAME_LENGTH];
};
/* for the mem_descriptor cookie */
#define B_ISA_MEMORY_32_BIT 0x100
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,68 @@
/*
** Copyright 2002, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef LENDIAN_BITFIELD_H
#define LENDIAN_BITFIELD_H
#include <ByteOrder.h>
#define B_HOST_IS_LENDIAN 1
#if B_HOST_IS_BENDIAN
#define LBITFIELD8_2(b1,b2) uint8 b2,b1
#define LBITFIELD8_3(b1,b2,b3) uint8 b3,b2,b1
#define LBITFIELD8_4(b1,b2,b3,b4) uint8 b4,b3,b2,b1
#define LBITFIELD8_5(b1,b2,b3,b4,b5) uint8 b5,b4,b3,b2,b1
#define LBITFIELD8_6(b1,b2,b3,b4,b5,b6) uint8 b6,b5,b4,b3,b2,b1
#define LBITFIELD8_7(b1,b2,b3,b4,b5,b6,b7) uint8 b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD8_8(b1,b2,b3,b4,b5,b6,b7,b8) uint8 b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD2(b1,b2) uint16 b2,b1
#define LBITFIELD3(b1,b2,b3) uint16 b3,b2,b1
#define LBITFIELD4(b1,b2,b3,b4) uint16 b4,b3,b2,b1
#define LBITFIELD5(b1,b2,b3,b4,b5) uint16 b5,b4,b3,b2,b1
#define LBITFIELD6(b1,b2,b3,b4,b5,b6) uint16 b6,b5,b4,b3,b2,b1
#define LBITFIELD7(b1,b2,b3,b4,b5,b6,b7) uint16 b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD8(b1,b2,b3,b4,b5,b6,b7,b8) uint16 b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD9(b1,b2,b3,b4,b5,b6,b7,b8,b9) uint16 b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD10(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10) uint16 b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD11(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11) uint16 b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD12(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12) uint16 b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD13(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13) uint16 b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD14(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14) uint16 b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD15(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15) uint16 b15,b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD16(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16) uint16 b16,b15,b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#elif B_HOST_IS_LENDIAN
#define LBITFIELD8_2(b1,b2) uint8 b1,b2
#define LBITFIELD8_3(b1,b2,b3) uint8 b1,b2,b3
#define LBITFIELD8_4(b1,b2,b3,b4) uint8 b1,b2,b3,b4
#define LBITFIELD8_5(b1,b2,b3,b4,b5) uint8 b1,b2,b3,b4,b5
#define LBITFIELD8_6(b1,b2,b3,b4,b5,b6) uint8 b1,b2,b3,b4,b5,b6
#define LBITFIELD8_7(b1,b2,b3,b4,b5,b6,b7) uint8 b1,b2,b3,b4,b5,b6,b7
#define LBITFIELD8_8(b1,b2,b3,b4,b5,b6,b7,b8) uint8 b1,b2,b3,b4,b5,b6,b7,b8
#define LBITFIELD2(b1,b2) uint16 b1,b2
#define LBITFIELD3(b1,b2,b3) uint16 b1,b2,b3
#define LBITFIELD4(b1,b2,b3,b4) uint16 b1,b2,b3,b4
#define LBITFIELD5(b1,b2,b3,b4,b5) uint16 b1,b2,b3,b4,b5
#define LBITFIELD6(b1,b2,b3,b4,b5,b6) uint16 b1,b2,b3,b4,b5,b6
#define LBITFIELD7(b1,b2,b3,b4,b5,b6,b7) uint16 b1,b2,b3,b4,b5,b6,b7
#define LBITFIELD8(b1,b2,b3,b4,b5,b6,b7,b8) uint16 b1,b2,b3,b4,b5,b6,b7,b8
#define LBITFIELD9(b1,b2,b3,b4,b5,b6,b7,b8,b9) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9
#define LBITFIELD10(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10
#define LBITFIELD11(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11
#define LBITFIELD12(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12
#define LBITFIELD13(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13
#define LBITFIELD14(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14
#define LBITFIELD15(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15
#define LBITFIELD16(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16
#else
#error "Unknown host endianness"
#endif
#endif /* LENDIAN_BITFIELD_H */
+70
View File
@@ -0,0 +1,70 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
Paging-safe allocation of locked memory.
Library for managing temporary, locked memory with the condition of
not calling any function during allocation that can lead to paging.
Such memory is needed by drivers that are used to access the page file
but still need locked memory to execute requests.
Basically, a background thread manages a memory pool where blocks
are allocated from. If the pool is empty, allocation is delayed until
either a blocks is freed or the pool is enlarged by the background
thread.
All memory blocks must have same size and can be pre-initialized when
added to memory pool (and cleaned-up when removed from pool). The
free list is stored within free memory blocks, so you have to specify
a block offset where the manager can store the list pointers without
interfering with pre-initialization.
You can also specify an alignment, e.g. if the blocks are used for
DMA access, a minimum pool size (in blocks), a maximum pool size
(in blocks) and the size of memory chunks to be added if the entire
pool is allocated.
*/
#ifndef __LOCKED_POOL_H__
#define __LOCKED_POOL_H__
#include <device_manager.h>
typedef struct locked_pool *locked_pool_cookie;
typedef status_t (*locked_pool_add_hook)(void *block, void *arg);
typedef void (*locked_pool_remove_hook)(void *block, void *arg);
typedef struct {
module_info minfo;
// allocate block
void *(*alloc)(locked_pool_cookie pool);
// free block
void (*free)(locked_pool_cookie pool, void *block);
// create new pool
// block_size - size of one memory block
// alignment - set address bits here that must be zero for block addresses
// next_ofs - offset in block where internal next-pointer can be stored
// chunk_size - how much system memory is to be allocated at once
// max_blocks - maximum number of blocks
// min_free_block - minimum number of free blocks
// name - name of pool
// lock_flags - flags to be passed to lock_memory()
// alloc_hook - hook to be called when new block is added to pool (can be NULL )
// free_hook - hook to be called when block is removed from pool (can be NULL )
// hook_arg - value to be passed to hooks as arg
locked_pool_cookie (*create)(int block_size, int alignment, int next_ofs,
int chunk_size, int max_blocks, int min_free_blocks, const char *name,
uint32 lock_flags, locked_pool_add_hook add_hook,
locked_pool_remove_hook remove_hook, void *hook_arg);
void (*destroy)(locked_pool_cookie pool);
} locked_pool_interface;
#define LOCKED_POOL_MODULE_NAME "generic/locked_pool/v1"
#endif
+118
View File
@@ -0,0 +1,118 @@
/* ++++++++++
FILE: midi_driver.h
REVS: $Revision: 1.1 $
NAME: herold
DATE: Tue Jun 4 15:23:29 PDT 1996
Interface to /dev/midi, the midi driver
+++++ */
/*
Copyright 1999, Be Incorporated. All Rights Reserved.
This file may be used under the terms of the Be Sample Code License.
*/
#ifndef _MIDI_DRIVER_H
#define _MIDI_DRIVER_H
#include <Drivers.h>
#include <module.h>
/* -----
ioctl codes
----- */
/* the old opcodes are deprecated, and may or may not work
in newer drivers */
enum {
B_MIDI_GET_READ_TIMEOUT = B_MIDI_DRIVER_BASE,
B_MIDI_SET_READ_TIMEOUT,
B_MIDI_TIMED_READ,
B_MIDI_TIMED_WRITE,
B_MIDI_WRITE_SYNC,
B_MIDI_WRITE_CLEAR,
B_MIDI_GET_READ_TIMEOUT_OLD = B_DEVICE_OP_CODES_END + 1,
B_MIDI_SET_READ_TIMEOUT_OLD
};
/* the default timeout when you open a midi driver */
#define B_MIDI_DEFAULT_TIMEOUT 1000000000000000LL
/* Usage:
To read, set "data" to a pointer to your buffer, and "size" to the
maximum size of this buffer. On return, "when" will contain the time
at which the data was received (first byte) and "size" will contain
the actual amount of data read.
Call ioctl(fd, B_MIDI_TIMED_READ, &midi_timed_data, sizeof(midi_timed_data));
To write, set "when" to when you want the first byte to go out the
wire, set "data" to point to your data, and set "size" to the size
of your data.
Call ioctl(fd, B_MIDI_TIMED_WRITE, &midi_timed_data, sizeof(midi_timed_data));
*/
typedef struct {
bigtime_t when;
size_t size;
unsigned char * data;
} midi_timed_data;
/* The MIDI parser returns the number of bytes that a message contains, given the */
/* initial byte. For some messages, this is not known until the second byte is seen. */
/* For such messages, a state > 0 is returned as well as some count > 0. When state */
/* is > 0, you should call (*parse) for the next byte as well, which might modify */
/* the returned message size. Message size will always be returned with the current */
/* byte being counted as byte 1. A return of 0 means that the byte initiates a new */
/* message. SysX is handled by returning max_size until the end or next initial message */
/* is seen. So your loop looks something like: */
/*
uint32 state = 0; // Only set this to 0 the first time you call the parser.
// preserve the 'state' between invocations of your read() hook.
int todo = 0;
unsigned char * end = in_buf+buf_size
unsigned char * out_buf = in_buf;
while (true) {
uchar byte = read_midi();
if (!todo || state) {
todo = (*parser->parse)(&state, byte, end-out_buf);
}
if (todo < 1) {
unput_midi(byte);
} else {
*(out_buf++) = byte;
todo--;
}
if (todo < 1 || out_buf >= end) {
received_midi_message(in_buf, out_buf-in_buf);
todo = 0;
}
}
*/
#define B_MIDI_PARSER_MODULE_NAME "media/midiparser/v1"
typedef struct _midi_parser_module_info {
module_info minfo;
int (*parse)(uint32 * state, uchar byte, size_t max_size);
int _reserved_;
} midi_parser_module_info;
#define B_MPU_401_MODULE_NAME "generic/mpu401/v1"
enum {
B_MPU_401_ENABLE_CARD_INT = 1,
B_MPU_401_DISABLE_CARD_INT
};
typedef struct _generic_mpu401_module {
module_info minfo;
status_t (*create_device)(int port, void ** out_storage, uint32 workarounds, void (*interrupt_op)(int32 op, void * card), void * card);
status_t (*delete_device)(void * storage);
status_t (*open_hook)(void * storage, uint32 flags, void ** out_cookie);
status_t (*close_hook)(void * cookie);
status_t (*free_hook)(void * cookie);
status_t (*control_hook)(void * cookie, uint32 op, void * data, size_t len);
status_t (*read_hook)(void * cookie, off_t pos, void * data, size_t * len);
status_t (*write_hook)(void * cookie, off_t pos, const void * data, size_t * len);
bool (*interrupt_hook)(void * cookie);
int _reserved_;
} generic_mpu401_module;
#endif
+56
View File
@@ -0,0 +1,56 @@
/*******************************************************************************
/
/ File: mime_table.h
/
/ Description: Kernel mime table and matcher module API
/
/ Copyright 2005, François Revol.
/
*******************************************************************************/
#ifndef _MIME_TABLE_MODULE_H_
#define _MIME_TABLE_MODULE_H_
#include <module.h>
struct ext_mime {
char *extension;
char *mime;
};
#ifdef __cplusplus
extern "C" {
#endif
/*
status_t get_table(struct ext_mime **table)
Returns the current kernel mime table.
You must call free_table() when finished with it.
void free_table(struct ext_mime *table)
Frees the given mime table;
const char * mime_for_ext(const char *ext)
Returns the known mime type for the given extension.
const char * ext_for_mime(const char *mime)
Returns the known extension for the given mime type.
*/
#define B_MIME_TABLE_MODULE_NAME "generic/mime_table/v1"
typedef struct {
module_info minfo;
status_t (*get_table)(struct ext_mime **table);
void (*free_table)(struct ext_mime *table);
const char * (*mime_for_ext)(const char *ext);
const char * (*ext_for_mime)(const char *mime);
} mime_table_module_info;
#ifdef __cplusplus
}
#endif
#endif
+58
View File
@@ -0,0 +1,58 @@
/* Modules Definitions
**
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef _MODULE_H
#define _MODULE_H
#include <OS.h>
/* Every module exports a list of module_info structures.
* It defines the interface of the module and the name
* that is used to access the interface.
*/
typedef struct module_info {
const char *name;
uint32 flags;
status_t (*std_ops)(int32, ...);
} module_info;
/* module standard operations */
#define B_MODULE_INIT 1
#define B_MODULE_UNINIT 2
/* module flags */
#define B_KEEP_LOADED 0x00000001
/* Use the module_dependency structure to let the
* kernel automatically load modules yet depend on
* before B_MODULE_INIT is called.
*/
typedef struct module_dependency {
const char *name;
module_info **info;
} module_dependency;
#ifdef __cplusplus
extern "C" {
#endif
extern status_t get_module(const char *path, module_info **_info);
extern status_t put_module(const char *path);
extern status_t get_next_loaded_module_name(uint32 *cookie, char *buffer, size_t *_bufferSize);
extern void *open_module_list(const char *prefix);
extern status_t close_module_list(void *cookie);
extern status_t read_next_module_name(void *cookie, char *buffer, size_t *_bufferSize);
#ifdef __cplusplus
}
#endif
#endif /* _MODULE_H */
+22
View File
@@ -0,0 +1,22 @@
/* Node monitor calls for kernel add-ons
**
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef _DRIVERS_NODE_MONITOR_H
#define _DRIVERS_NODE_MONITOR_H
#include <OS.h>
#include <storage/NodeMonitor.h>
extern status_t stop_notifying(port_id port, uint32 token);
extern status_t start_watching(dev_t device, ino_t node, uint32 flags,
port_id port, uint32 token);
extern status_t stop_watching(dev_t device, ino_t node, uint32 flags,
port_id port, uint32 token);
// ToDo: add simple message parsing convenience functionality
#endif /* _DRIVERS_NODE_MONITOR_H */
+55
View File
@@ -0,0 +1,55 @@
/*
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
PnP devfs driver interface.
The interface follows the normal pnp driver rules, i.e.
your driver creates a node for it and chooses PNP_DEVFS_MODULE_NAME
as the consumer, the type must be PNP_DEVFS_TYPE_NAME. The file
name is set via a PNP_DEVFS_FILENAME item.
Loading and unloading of your driver is done via the pnp manager.
Hooks are similar to the original devfs interface, but the open
hook gets the driver cookie (as returned by init_device of the
driver) instead of a filename.
*/
#ifndef _PNP_DEVFS_H
#define _PNP_DEVFS_H
#include <Drivers.h>
#include <device_manager.h>
// changed open hook - gets cookie returned by init_device instead of name
typedef status_t (*pnp_device_open_hook)(void *device_cookie, uint32 flags,
void **handle_cookie);
// new interface to devfs
typedef struct pnp_devfs_driver_info {
driver_module_info info;
pnp_device_open_hook open; // called to open the device
device_close_hook close; // called to close the device
device_free_hook free; // called to free the cookie
device_control_hook control; // called to control the device
device_read_hook read; // reads from the device
device_write_hook write; // writes to the device
device_select_hook select; // start select (can be NULL)
device_deselect_hook deselect; // stop select (can be NULL)
device_read_pages_hook read_pages; // scatter-gather read from the device (can be NULL)
device_write_pages_hook write_pages; // scatter-gather write to the device (can be NULL)
} pnp_devfs_driver_info;
// items:
// name under which the device should be published under /dev (required, string)
#define PNP_DEVFS_FILENAME "devfs/filename"
#define PNP_DEVFS_MODULE_NAME "system/devfs/device_v1"
#endif
+144
View File
@@ -0,0 +1,144 @@
#ifndef USB_AUDIO_H
#define USB_AUDIO_H
// (Partial) USB Class Definitions for Audio Devices, version 1.0
// Reference: http://www.usb.org/developers/devclass_docs/audio10.pdf
#include <BeBuild.h> // for _PACKED definition
#define USB_AUDIO_DEVICE_CLASS 0x01
#define USB_AUDIO_CLASS_VERSION 0x0100
enum {
USB_AUDIO_INTERFACE_AUDIO_CLASS = 0x01
};
enum { // Audio Interface Subclasses
USB_AUDIO_INTERFACE_AUDIOCONTROL_SUBCLASS = 0x01, //
USB_AUDIO_INTERFACE_AUDIOSTREAMING_SUBCLASS, //
USB_AUDIO_INTERFACE_MIDISTREAMING_SUBCLASS //
};
enum { // Audio Class-Specific AudioControl Interface descriptor subtypes
USB_AUDIO_AC_HEADER = 0x01,
USB_AUDIO_AC_INPUT_TERMINAL,
USB_AUDIO_AC_OUTPUT_TERMINAL,
USB_AUDIO_AC_MIXER_UNIT,
USB_AUDIO_AC_SELECTOR_UNIT,
USB_AUDIO_AC_FEATURE_UNIT,
USB_AUDIO_AC_PROCESSING_UNIT,
USB_AUDIO_AC_EXTENSION_UNIT
};
enum { // Audio Class-Specific AudioStreaming Interface descriptor subtypes
USB_AUDIO_AS_GENERAL = 0x01,
USB_AUDIO_AS_FORMAT_TYPE,
USB_AUDIO_AS_FORMAT_SPECIFIC
};
enum { // Processing Unit Process Types (for USB_AUDIO_AC_PROCESSING_UNIT)
USB_AUDIO_UPDOWNMIX_PROCESS = 0x01,
USB_AUDIO_DOLBY_PROLOGIC_PROCESS,
USB_AUDIO_3D_STEREO_EXTENDER_PROCESS,
USB_AUDIO_REVERBERATION_PROCESS,
USB_AUDIO_CHORUS_PROCESS,
USB_AUDIO_DYN_RANGE_COMP_PROCESS
};
// AudioControl request codes
#define USB_AUDIO_SET_CURRENT 0x01
#define USB_AUDIO_GET_CURRENT 0x81
#define USB_AUDIO_SET_MIN 0x02
#define USB_AUDIO_GET_MIN 0x82
#define USB_AUDIO_SET_MAX 0x03
#define USB_AUDIO_GET_MAX 0x83
#define USB_AUDIO_SET_RES 0x04
#define USB_AUDIO_GET_RES 0x84
#define USB_AUDIO_SET_MEM 0x05
#define USB_AUDIO_GET_MEM 0x85
#define USB_AUDIO_GET_STATUS 0xFF
enum { // Terminal Control Selectors
USB_AUDIO_COPY_PROTECT_CONTROL = 0x01
};
/* A.10.2 Feature Unit Control Selectors */
#define AC_FU_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_MUTE_CONTROL 0x01
#define USB_AUDIO_VOLUME_CONTROL 0x02
#define USB_AUDIO_BASS_CONTROL 0x03
#define USB_AUDIO_MID_CONTROL 0x04
#define USB_AUDIO_TREBLE_CONTROL 0x05
#define USB_AUDIO_GRAPHIC_EQUALIZER_CONTROL 0x06
#define USB_AUDIO_AUTOMATIC_GAIN_CONTROL 0x07
#define USB_AUDIO_DELAY_CONTROL 0x08
#define USB_AUDIO_BASS_BOOST_CONTROL 0x09
#define USB_AUDIO_LOUDNESS_CONTROL 0x0A
/* A.10.3.1 Up/Down-mix Processing Unit Control Selectors */
#define USB_AUDIO_UD_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_UD_ENABLED_CONTROL 0x01
#define USB_AUDIO_UD_MODE_SELECT_CONTROL 0x02
/* A.10.3.2 Dolby Prologic(tm) Processing Unit Control Selectors */
#define USB_AUDIO_DP_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_DP_ENABLE_CONTROL 0x01
#define USB_AUDIO_DP_MODE_SELECT_CONTROL 0x02
/* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
#define USB_AUDIO_3D_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_3D_ENABLED_CONTROL 0x01
#define USB_AUDIO_3D_SPACIOUSNESS_CONTROL 0x03
/* A.10.3.4 Reverberation Processing Unit Control Selectors */
#define USB_AUDIO_RV_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_RV_ENABLE_CONTROL 0x01
#define USB_AUDIO_RV_REVERB_LEVEL_CONTROL 0x02
#define USB_AUDIO_RV_REVERB_TIME_CONTROL 0x03
#define USB_AUDIO_RV_REVERB_FEEDBACK_CONTROL 0x04
/* A.10.3.5 Chorus Processing Unit Control Selectors */
#define USB_AUDIO_CH_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_CH_ENABLE_CONTROL 0x01
#define USB_AUDIO_CHORUS_LEVEL_CONTROL 0x02
#define USB_AUDIO_CHORUS_RATE_CONTROL 0x03
#define USB_AUDIO_CHORUS_DETH_CONTROL 0x04
/* A.10.3.6 Dynamic Range Compressor Processing Unit Control Selectors */
#define USB_AUDIO_DR_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_DR_ENABLE_CONTROL 0x01
#define USB_AUDIO_COMPRESSION_RATE_CONTROL 0x02
#define USB_AUDIO_MAXAMPL_CONTROL 0x03
#define USB_AUDIO_THRESHOLD_CONTROL 0x04
#define USB_AUDIO_ATTACK_TIME 0x05
#define USB_AUDIO_RELEASE_TIME 0x06
/* A.10.4 Extension Unit Control Selectors */
#define USB_AUDIO_XU_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_XU_ENABLE_CONTROL 0x01
/* A.10.5 Endpoint Control Selectors */
#define USB_AUDIO_EP_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_SAMPLING_FREQ_CONTROL 0x01
#define USB_AUDIO_PITCH_CONTROL 0x02
typedef struct {
uint8 length;
uint8 type;
uint8 subtype;
uint8 format_type;
uint8 num_channels;
uint8 subframe_size;
uint8 bit_resolution;
uint8 sample_freq_type;
uint8 sample_freq[3]; // [0] + [1] << 8 + [2] << 16
// if sample_freq_type != 1,
// (sample_freq_type - 1) x uint8 sample_freq[3] follows...
} _PACKED usb_audio_format_type_descriptor;
#define USB_AUDIO_FORMAT_TYPE_UNDEFINED 0x00
#define USB_AUDIO_FORMAT_TYPE_I 0x01
#define USB_AUDIO_FORMAT_TYPE_II 0x02
#define USB_AUDIO_FORMAT_TYPE_III 0x03
#endif // USB_AUDIO_H
+136
View File
@@ -0,0 +1,136 @@
#ifndef USB_CDC_H
#define USB_CDC_H
// (Partial) USB Class Definitions for Communication Devices (CDC), version 1.1
// Reference: http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
#define USB_COMMUNICATION_DEVICE_CLASS 0x02
#define USB_CDC_COMMUNICATION_INTERFACE_CLASS 0x02
#define USB_CDC_CLASS_VERSION 0x0101
enum { // Communication Interface Subclasses
USB_CDC_COMMUNICATION_INTERFACE_DLCM_SUBCLASS = 0x01, // Direct Line Control Model
USB_CDC_COMMUNICATION_INTERFACE_ACM_SUBCLASS, // Abstract Control Model
USB_CDC_COMMUNICATION_INTERFACE_TCM_SUBCLASS, // Telephone Control Model
USB_CDC_COMMUNICATION_INTERFACE_MCCM_SUBCLASS, // Multi-Channel Control Model
USB_CDC_COMMUNICATION_INTERFACE_CAPICM_SUBCLASS, // CAPI Control Model
USB_CDC_COMMUNICATION_INTERFACE_ENCM_SUBCLASS, // Ethernet Networking Control Model
USB_CDC_COMMUNICATION_INTERFACE_ATMNCM_SUBCLASS // ATM Networking Control Model
};
enum { // Communication Interface Class Control Protocols
USB_CDC_COMMUNICATION_INTERFACE_NONE_PROTOCOL = 0x00, // No class specific protocol required
USB_CDC_COMMUNICATION_INTERFACE_V25TER_PROTOCOL = 0x01, // Common AT commands (also knowns as "Hayes compatible")
USB_CDC_COMMUNICATION_INTERFACE_SPECIFIC_PROTOCOL = 0xff // Vendor-specific protocol
};
#define USB_CDC_DATA_INTERFACE_CLASS 0x0a
enum { // Management Element Requests (p62)
USB_CDC_SEND_ENCAPSULATED_COMMAND = 0x00,
USB_CDC_GET_ENCAPSULATED_RESPONSE,
USB_CDC_SET_COMM_FEATURE,
USB_CDC_GET_COMM_FEATURE,
USB_CDC_CLEAR_COMM_FEATURE,
// 0x05 -> 0x0F: reserved for future use
USB_CDC_SET_AUX_LINE_STATE = 0x10,
USB_CDC_SET_HOOK_STATE,
USB_CDC_PULSE_SETUP,
USB_CDC_SEND_PULSE,
USB_CDC_SET_PULSE_TIME,
USB_CDC_RING_AUX_JACK,
// 0x16 -> 0x1F: reserved for future use
USB_CDC_SET_LINE_CODING = 0x20,
USB_CDC_GET_LINE_CODING,
USB_CDC_SET_CONTROL_LINE_STATE,
USB_CDC_SEND_BREAK,
// 0x24 -> 0x2F: reserved for future use
USB_CDC_SET_RINGER_PARMS = 0x30,
USB_CDC_GET_RINGER_PARMS,
USB_CDC_SET_OPERATION_PARMS,
USB_CDC_GET_OPERATION_PARMS,
USB_CDC_SET_LINE_PARMS,
USB_CDC_GET_LINE_PARMS,
USB_CDC_DIAL_DIGITS,
USB_CDC_SET_UNIT_PARAMETER,
USB_CDC_GET_UNIT_PARAMETER,
USB_CDC_CLEAR_UNIT_PARAMETER,
USB_CDC_GET_PROFILE,
// 0x3B -> 0x3F: reserved for future use
USB_CDC_SET_ETHERNET_MULTICAST_FILTERS = 0x40,
USB_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER,
USB_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER,
USB_CDC_SET_ETHERNET_PACKET_FILTER,
USB_CDC_GET_ETHERNET_STATISTIC,
// 0x45 -> 0x4F: reserved for future use
USB_CDC_SET_ATM_DATA_FORMAT = 0x50,
USB_CDC_GET_ATM_DEVICE_STATISTICS,
USB_CDC_SET_ATM_DEFAULT_VC,
USB_CDC_GET_ATM_VC_STATISTICS
// 0x54 -> 0xFF: reserved for future use
};
enum { // Feature Selector (for USB_CDC_SET/GET/CLEAR_COMM_FEATURE (p65-66))
USB_CDC_ABSTRACT_STATE = 0x01,
USB_CDC_COUNTRY_SETTING = 0x02
};
enum { // ABSTRACT_STATE bitmap (for USB_CDC_ABSTRAT_STATE Feature Selector (p66))
USB_CDC_ABSTRACT_STATE_IDLE = 0x01,
USB_CDC_ABSTRACT_STATE_DATA_MULTIPLEXED = 0x02
};
typedef struct { // Line Coding Structure (for USB_CDC_SET/GET_LINE_CODING (p69))
uint32 speed;
uint8 stopbits;
uint8 parity;
uint8 databits;
} _PACKED usb_cdc_line_coding;
enum { // CDC stopbits values (for Line Coding Structure stopbits field)
USB_CDC_1_STOPBIT = 0,
USB_CDC_1_5_STOPBITS,
USB_CDC_2_STOPBITS
};
enum { // CDC parity values (for Line Coding Structure parity field)
USB_CDC_NO_PARITY = 0,
USB_CDC_ODD_PARITY,
USB_CDC_EVEN_PARITY,
USB_CDC_MARK_PARITY,
USB_CDC_SPACE_PARITY
};
enum { // CDC Control Signal bitmap (for CDC_SET_CONTROL_LINE_STATE request)
USB_CDC_CONTROL_SIGNAL_STATE_DTR = 0x01,
USB_CDC_CONTROL_SIGNAL_STATE_RTS = 0x02
};
enum { // Notification Elements notifications (p84)
USB_CDC_NETWORK_CONNECTION = 0x00,
USB_CDC_RESPONSE_AVAILABLE,
// 0x02 -> 0x07: reserved for future use
USB_CDC_AUX_JACK_HOOK_STATE = 0x08,
USB_CDC_RING_DETECT,
// 0x0a -> 0x1f: reserved for future use
USB_CDC_SERIAL_STATE = 0x20,
// 0x21 -> 0x27: reserved for future use
USB_CDC_CALL_STATE_CHANGE = 0x28,
USB_CDC_LINE_STATE_CHANGE,
USB_CDC_CONNECTION_SPEED_CHANGE
// 0x2b -> 0xff: reserved for future use
};
enum { // CDC UART State bitmap (for USB_CDC_SERIAL_STATE notification)
USB_CDC_UART_STATE_DCD = 0x01,
USB_CDC_UART_STATE_DSR = 0x02,
USB_CDC_UART_STATE_BREAK = 0x04,
USB_CDC_UART_STATE_RING = 0x08,
USB_CDC_UART_STATE_FRAMING_ERROR = 0x10,
USB_CDC_UART_STATE_PARITY_ERROR = 0x20,
USB_CDC_UART_STATE_OVERRUN_ERROR = 0x40
};
#endif // USB_CDC_H
+116
View File
@@ -0,0 +1,116 @@
#ifndef USB_HID_H
#define USB_HID_H
// (Partial) USB Class Definitions for HID Devices, version 1.11
// Reference: http://www.usb.org/developers/devclass_docs/hid1_11.pdf
#define USB_HID_DEVICE_CLASS 0x03
#define USB_HID_CLASS_VERSION 0x0100
enum { // HID Interface Subclasses
USB_HID_INTERFACE_NO_SUBCLASS = 0x00, // No Subclass
USB_HID_INTERFACE_BOOT_SUBCLASS // Boot Interface Subclass
};
enum { // HID Class-Specific descriptor subtypes
USB_HID_DESCRIPTOR_HID = 0x21,
USB_HID_DESCRIPTOR_REPORT,
USB_HID_DESCRIPTOR_PHYSICAL
};
enum { // HID Class-specific requests
USB_REQUEST_HID_GET_REPORT = 0x01,
USB_REQUEST_HID_GET_IDLE,
USB_REQUEST_HID_GET_PROTOCOL,
USB_REQUEST_HID_SET_REPORT = 0x09,
USB_REQUEST_HID_SET_IDLE,
USB_REQUEST_HID_SET_PROTOCOL
};
typedef struct
{
uint8 length;
uint8 descriptor_type;
uint16 hid_version;
uint8 country_code;
uint8 num_descriptors;
struct
{
uint8 descriptor_type;
uint16 descriptor_length;
} _PACKED descriptor_info [1];
} _PACKED usb_hid_descriptor;
/*
Usage Pages/IDs
*/
enum
{
USAGE_PAGE_GENERIC_DESKTOP = 0x1,
USAGE_PAGE_SIMULATION,
USAGE_PAGE_VR,
USAGE_PAGE_SPORT,
USAGE_PAGE_GAME,
USAGE_PAGE_GENERIC,
USAGE_PAGE_KEYBOARD,
USAGE_PAGE_LED,
USAGE_PAGE_BUTTON,
USAGE_PAGE_ORDINAL,
USAGE_PAGE_TELEPHONY,
USAGE_PAGE_CONSUMER,
USAGE_PAGE_DIGITIZER,
USAGE_PAGE_PID = 0xf,
USAGE_PAGE_UNICODE,
USAGE_PAGE_ALPHANUM_DISPLAY = 0x14,
USAGE_PAGE_MEDICAL = 0x40
};
/* Page 1: Generic Desktop */
enum
{
USAGE_ID_POINTER = 0x1,
USAGE_ID_MOUSE,
USAGE_ID_JOYSTICK = 0x4,
USAGE_ID_GAMEPAD,
USAGE_ID_KEYBOARD,
USAGE_ID_KEYPAD,
USAGE_ID_MULTIAXIS = 0x8,
USAGE_ID_X = 0x30,
USAGE_ID_Y,
USAGE_ID_Z,
USAGE_ID_RX,
USAGE_ID_RY,
USAGE_ID_RZ,
USAGE_ID_SLIDER,
USAGE_ID_DIAL,
USAGE_ID_WHEEL,
USAGE_ID_HAT_SWITCH,
USAGE_ID_COUNTED_BUFFER,
USAGE_ID_BYTE_COUNT,
USAGE_ID_MOTION_WAKEUP,
USAGE_ID_START,
USAGE_ID_SELECT,
USAGE_ID_VX = 0x40,
USAGE_ID_VY,
USAGE_ID_VZ,
USAGE_ID_VBRX,
USAGE_ID_VBRY,
USAGE_ID_VBRZ,
USAGE_ID_VNO,
USAGE_ID_FEATURE_NOTIFICATION
};
/* Page 2: Simulation */
enum
{
USAGE_ID_RUDDER = 0xBA,
USAGE_ID_THROTTLE = 0xBB,
};
#endif // USB_HID_H
+173
View File
@@ -0,0 +1,173 @@
#ifndef USB_LANGIDS_H
#define USB_LANGIDS_H
// USB Language Identifiers, 3/29/2000, version 1.0
// Reference: http://www.usb.org/developers/docs/USB_LANGIDs.pdf
#define USB_LANGIDS_VERSION 0x0100 // version 1.0
// descriptor string index 0 = supported LANGIDs array
#define USB_LANGIDS_STRING_INDEX (0)
#define USB_PRIMARY_LANGID_MASK (0x003F) // 9 to 0 bits
#define USB_SUB_LANGID_MASK (0xFC00) // 15 to 10 bits
#define USB_PRIMARY_LANGID(id) (id & USB_PRIMARY_LANGID_MASK)
#define USB_SUB_LANGID(id) ((id & USB_SUB_LANGID_MASK) >> 10)
enum {
USB_LANGID_AFRIKAANS = 0x0436, // Afrikaans
USB_LANGID_ALBANIAN = 0x041c, // Albanian
USB_LANGID_ARABIC_SAUDI_ARABIA = 0x0401, // Arabic (Saudi Arabia)
USB_LANGID_ARABIC_IRAK = 0x0801, // Arabic (Irak)
USB_LANGID_ARABIC_EGYPT = 0x0c01, // Arabic (Egypt)
USB_LANGID_ARABIC_LYBYA = 0x1001, // Arabic (Libya)
USB_LANGID_ARABIC_ALGERIA = 0x1401, // Arabic (Algeria)
USB_LANGID_ARABIC_MOROCCO = 0x1801, // Arabic (Morocco)
USB_LANGID_ARABIC_TUNISIA = 0x1c01, // Arabic (Tunisia)
USB_LANGID_ARABIC_OMAN = 0x2001, // Arabic (Oman)
USB_LANGID_ARABIC_YEMEN = 0x2401, // Arabic (Yemen)
USB_LANGID_ARABIC_SYRIA = 0x2801, // Arabic (Syria)
USB_LANGID_ARABIC_JORDAN = 0x2c01, // Arabic (Jordan)
USB_LANGID_ARABIC_LEBANON = 0x3001, // Arabic (Lebanon)
USB_LANGID_ARABIC_KUWAIT = 0x3401, // Arabic (Kuwait)
USB_LANGID_ARABIC_UAE = 0x3801, // Arabic (U.A.E.)
USB_LANGID_ARABIC_BAHRAIN = 0x3c01, // Arabic (Bahrain)
USB_LANGID_ARABIC_QATAR = 0x4001, // Arabic (Qatar)
USB_LANGID_ARMENIAN = 0x042b, // Armenian
USB_LANGID_ASSAMESE = 0x044d, // Assamese
USB_LANGID_AZERI_LATIN = 0x042c, // Azeri (Latin)
USB_LANGID_AZERI_CYRILLIC = 0x082c, // Azeri (Cyrillic)
USB_LANGID_BASQUE = 0x042d, // Basque
USB_LANGID_BELARUSSIAN = 0x0423, // Belarussian
USB_LANGID_BENGALI = 0x0445, // Bengali
USB_LANGID_BULGARIAN = 0x0402, // Bulgarian
USB_LANGID_BURMESE = 0x0455, // Burmese
USB_LANGID_CATALAN = 0x0403, // Catalan
USB_LANGID_CHINESE_TAIWAN = 0x0404, // Chinese (Taiwan)
USB_LANGID_CHINESE_PRC = 0x0804, // Chinese (PRC = People Republic of Chinese)
USB_LANGID_CHINESE_HONG_KONG = 0x0c04, // Chinese (Hong Kong)
USB_LANGID_CHINESE_SINGAPORE = 0x1004, // Chinese (Singapore)
USB_LANGID_CHINESE_MACAU_SAR = 0x1404, // Chinese (Macau SAR)
USB_LANGID_CROATIAN = 0x041a, // Croatian
USB_LANGID_CZECH = 0x0405, // Czech
USB_LANGID_DANISH = 0x0406, // Danish
USB_LANGID_DUTCH_NETHERLANDS = 0x0413, // Dutch (Netherlands)
USB_LANGID_DUTCH_BELGIUM = 0x0813, // Dutch (Belgium)
USB_LANGID_ENGLISH_UNITED_STATES = 0x0409, // English (United States)
USB_LANGID_ENGLISH_UNITED_KINGDOM = 0x0809, // English (United Kingdom)
USB_LANGID_ENGLISH_AUSTRALIAN = 0x0c09, // English (Australian)
USB_LANGID_ENGLISH_CANADIAN = 0x1009, // English (Canadian)
USB_LANGID_ENGLISH_NEW_ZEALAND = 0x1409, // English (New Zealand)
USB_LANGID_ENGLISH_IRELAND = 0x1809, // English (Ireland)
USB_LANGID_ENGLISH_SOUTH_AFRICA = 0x1c09, // English (South Africa)
USB_LANGID_ENGLISH_JAMAICA = 0x2009, // English (Jamaica)
USB_LANGID_ENGLISH_CARIBBEAN = 0x2409, // English (Caribbean)
USB_LANGID_ENGLISH_BELIZE = 0x2809, // English (Belize)
USB_LANGID_ENGLISH_TRINIDAD = 0x2c09, // English (Trinidad)
USB_LANGID_ENGLISH_ZIMBABWE = 0x3009, // English (Zimbabwe)
USB_LANGID_ENGLISH_PHLIPPINES = 0x3409, // English (Philippines)
USB_LANGID_ESTONIAN = 0x0425, // Estonian
USB_LANGID_FAEROESE = 0x0438, // Faeroese
USB_LANGID_FARSI = 0x0429, // Farsi
USB_LANGID_FINNISH = 0x040b, // Finnish
USB_LANGID_FRENCH_STANDARD = 0x040c, // French (Standard)
USB_LANGID_FRENCH_BELGIAN = 0x080c, // French (Belgian)
USB_LANGID_FRENCH_CANADIAN = 0x0c0c, // French (Canadian)
USB_LANGID_FRENCH_SWITZERLAND = 0x100c, // French (Switzerland)
USB_LANGID_FRENCH_LUXEMBOURG = 0x140c, // French (Luxembourg)
USB_LANGID_FRENCH_MONACO = 0x180c, // French (Monaco)
USB_LANGID_GEORGIAN = 0x0437, // Georgian
USB_LANGID_GERMAN_STANDARD = 0x0407, // German (Standard)
USB_LANGID_GERMAN_SWITZERLAND = 0x0807, // German (Switzerland)
USB_LANGID_GERMAN_AUSTRIA = 0x0c07, // German (Austria)
USB_LANGID_GERMAN_LUXEMBOURG = 0x1007, // German (Luxembourg)
USB_LANGID_GERMAN_LIECHTENSTEIN = 0x1407, // German (Liechtenstein)
USB_LANGID_GREEK = 0x0408, // Greek
USB_LANGID_GUJARATI = 0x0447, // Gujarati
USB_LANGID_HEBREW = 0x040d, // Hebrew
USB_LANGID_HINDI = 0x0439, // Hindi
USB_LANGID_HUNGARIAN = 0x040e, // Hungarian
USB_LANGID_ICELANDIC = 0x040f, // Icelandic
USB_LANGID_INDONESIAN = 0x0421, // Indonesian
USB_LANGID_ITALIAN_STANDARD = 0x0410, // Italian (Standard)
USB_LANGID_ITALIAN_SWITZERLAND = 0x0810, // Italian (Switzerland)
USB_LANGID_JAPANESE = 0x0411, // Japanese
USB_LANGID_KANNADA = 0x044b, // Kannada
USB_LANGID_KASHMIRI_INDIA = 0x0860, // Kashmiri (India)
USB_LANGID_KAZAKH = 0x043f, // Kazakh
USB_LANGID_KONKANI = 0x0457, // Konkani
USB_LANGID_KOREAN_JOHAB = 0x0412, // Korean (Johab)
USB_LANGID_LATVIAN = 0x0426, // Latvian
USB_LANGID_LITHUANIAN = 0x0427, // Lithuanian
USB_LANGID_LITHUANIAN_CLASSIC = 0x0827, // Lithuanian (Classic)
USB_LANGID_MACEDONIAN = 0x042f, // Macedonian
USB_LANGID_MALAY_MALAYSIAN = 0x043e, // Malay (Malaysian)
USB_LANGID_MALAY_BRUNEI_DARUSSALAM = 0x083e, // Malay (Brunei Darussalam)
USB_LANGID_MALAYALAM = 0x044c, // Malayalam
USB_LANGID_MANIPURI = 0x0458, // Manipuri
USB_LANGID_MARATHI = 0x044e, // Marathi
USB_LANGID_NEPALI_INDIA = 0x0861, // Nepali (India)
USB_LANGID_NORWEGIAN_BOKMAL = 0x0414, // Norwegian (Bokmal)
USB_LANGID_NORWEGIAN_NYNORSK = 0x0814, // Norwegian (Nynorsk)
USB_LANGID_ORIYA = 0x0448, // Oriya
USB_LANGID_POLISH = 0x0415, // Polish
USB_LANGID_PORTUGUESE_BRAZIL = 0x0416, // Portuguese (Brazil)
USB_LANGID_PORTUGUESE_STANDARD = 0x0816, // Portuguese (Standard)
USB_LANGID_PUNJABI = 0x0446, // Punjabi
USB_LANGID_ROMANIAN = 0x0418, // Romanian
USB_LANGID_RUSSIAN = 0x0419, // Russian
USB_LANGID_SANSKRIT = 0x044f, // Sanskrit
USB_LANGID_SERBIAN_CYRILLIC = 0x0c1a, // Serbian (Cyrillic)
USB_LANGID_SERBIAN_LATIN = 0x081a, // Serbian (Latin)
USB_LANGID_SINDHI = 0x0459, // Sindhi
USB_LANGID_SLOVAK = 0x041b, // Slovak
USB_LANGID_SLOVENIAN = 0x0424, // Slovenian
USB_LANGID_SPANNISH_TRADITIONAL_SORT= 0x040a, // Spannish (Traditional Sort)
USB_LANGID_SPANNISH_MEXICAN = 0x080a, // Spannish (Mexican)
USB_LANGID_SPANNISH_MODERN_SORT = 0x0c0a, // Spannish (Modern Sort)
USB_LANGID_SPANNISH_GUATEMALA = 0x100a, // Spannish (Guatemala)
USB_LANGID_SPANNISH_COSTA_RICA = 0x140a, // Spannish (Costa Rica)
USB_LANGID_SPANNISH_PANAMA = 0x180a, // Spannish (Panama)
USB_LANGID_SPANNISH_DOMINICAN_REPUBLIC = 0x1c0a, // Spannish (Dominican Republic)
USB_LANGID_SPANNISH_VENEZUELA = 0x200a, // Spannish (Venezuela)
USB_LANGID_SPANNISH_COLOMBIA = 0x240a, // Spannish (Colombia)
USB_LANGID_SPANNISH_PERU = 0x280a, // Spannish (Peru)
USB_LANGID_SPANNISH_ARGENTINA = 0x2c0a, // Spannish (Argentina)
USB_LANGID_SPANNISH_ECUADOR = 0x300a, // Spannish (Ecuador)
USB_LANGID_SPANNISH_CHILE = 0x340a, // Spannish (Chile)
USB_LANGID_SPANNISH_URUGUAY = 0x380a, // Spannish (Uruguay)
USB_LANGID_SPANNISH_PARAGUAY = 0x3c0a, // Spannish (Paraguay)
USB_LANGID_SPANNISH_BOLIVIA = 0x400a, // Spannish (Bolivia)
USB_LANGID_SPANNISH_EL_SALVADOR = 0x440a, // Spannish (El Salvador)
USB_LANGID_SPANNISH_HONDURAS = 0x480a, // Spannish (Honduras)
USB_LANGID_SPANNISH_NICARAGUA = 0x4c0a, // Spannish (Nicaragua)
USB_LANGID_SPANNISH_PUERTO_RICO = 0x500a, // Spannish (Puerto Rico)
USB_LANGID_SUTU = 0x0430, // Sutu
USB_LANGID_SWAHILI_KENYA = 0x0441, // Swahili (Kenya)
USB_LANGID_SWEDISH = 0x041d, // Swedish
USB_LANGID_SWEDISH_FINLAND = 0x081d, // Swedish (Finland)
USB_LANGID_TAMIL = 0x0449, // Tamil
USB_LANGID_TATAR_TATARSTAN = 0x0444, // Tatar (Tatarstan)
USB_LANGID_TELUGU = 0x044a, // Telugu
USB_LANGID_THAI = 0x041e, // Thai
USB_LANGID_TURKISH = 0x041f, // Turkish
USB_LANGID_UKRAINIAN = 0x0422, // Ukrainian
USB_LANGID_URDU_PAKISTAN = 0x0420, // Urdu (Pakistan)
USB_LANGID_URDU_INDIA = 0x0820, // Urdu (India)
USB_LANGID_UZBEK_LATIN = 0x0443, // Uzbek (Latin)
USB_LANGID_UZBEK_CYRILLIC = 0x0843, // Uzbek (Cyrillic)
USB_LANGID_VIETNAMESE = 0x042a, // Vietnamese
USB_LANGID_HID_UDD = 0x04ff, // HID (Usage Data Descriptor)
USB_LANGID_HID1 = 0xf0ff, // HID (Vendor Defined 1)
USB_LANGID_HID2 = 0xf4ff, // HID (Vendor Defined 2)
USB_LANGID_HID3 = 0xf8ff, // HID (Vendor Defined 3)
USB_LANGID_HID4 = 0xfcff, // HID (Vendor Defined 4)
USB_LANGID_INVALID = 0x0000 // Invalid LANG ID
};
#endif // USB_LANGIDS_H

Some files were not shown because too many files have changed in this diff Show More