Table of Contents
BE ENGINEERING INSIGHTS: Mastering Your Own BeOS Demo CD By Ming Low ming@be.com
A few months ago, Be released the BeOS Demo CD as an inexpensive and uncomplicated way for people to try the BeOS without having to paritition/initialize their disk or purchase the full version. The BeOS Demo CD is a bootable CD. It boots into a version of BeOS Release 3.2 which is fully functional except for the ability to partition or initialize a BFS partition, preventing the user from saving their work. Although some features' performance is affected, everything works, and you can even save preferences onto a floppy, preserving settings across rebooting. The BeOS Demo CD has since been used by people to try systems at computer stores to see if they are BeOS compatible, for Be enthusiasts to give friends a quick demo of the BeOS on their system, and even to show off what the BeOS can do at their local computer stores. Internally we have a variation of the Demo CD that turns our Window 98 systems into a gaming station: booting from the CD directly into a game such as Quake, Doom, or ATetris, just by turning on the machine with the CD in the drive. The usefulness of the BeOS Demo CD has stirred interest from third-party developers who want to see demo versions of their products on the Demo CD. We're working on making that happen -- the next Demo CD (with R4) will include third-party demonstration apps. Other developers have wondered about the possibility of making their own demo CDs, which boot the BeOS but only include demonstrations of their own products. Marketing says, "Interesting idea!" The purpose of this article is to explain how we made the BeOS Demo CD, because it was an interesting technical challenge. Before you use this as a recipe for your own demo CDs, though, if you are planning to distribute a CD that includes the BeOS, you need to obtain a license to distribute it. Contact our guy in charge of licensing, Bart Adao, at <bart@be.com> for details. Making the CD Bootable into BeOS To make the CD bootable, you need to create an ISO track on it by following the PC El Torito Specification for creating a bootable CD. This ISO track or partition must contain a special zbeos boot image and a boot catalog file plus some boot information for the CD's Boot Volume Descriptor. The special zbeos image essentially mimics a BeOS Intel boot floppy. The BeOS needs to boot off the CD from a 2.88 MB boot image. Some commercial software will create a bootable CD but only from a 1.44 MB floppy. One commercial CD-burning package that supports creating a 2.88 MB boot image is Ahead Software's Nero <http://www.ahead.de/>. If your toasting software can't create a bootable CD from a 2.88 MB image, you can still do it manually using your existing software. Good step-by-step documentation that walks you through creating the bootable ISO track manually is available on the web, at <http://www.nikko.simplenet.com/goldentime/bootcd1b.htm>. I tested the manual process for creating a bootable BeOS CD and it works, mostly. You need to change the setting from 02 (1.44 MB bootable floppy disk image) to 03 (2.88 MB bootable floppy disk image) on the section that describes the bootable media type. If you want additional information on the El Torito Bootable CD Specification, a copy is available for download from Phoenix Technology LTD at <http://www.ptltd.com/products/specs.html>. Creating the 2.88 MB BeOS Boot Image Here's how to create the 2.88 MB BeOS boot image. You start by creating a 2.88 MB file that contains all zeros. You can do this with the dd command: Then merge the Finally, chop off any excess bytes over 2.88 MB. You use the dd command again to do this: The Creating the BFS Partition To create the BeOS track for the bootable CD, first make a
partition on your hard disk that's big enough to contain the
" After you select your partition size, initialize the partition with a block size of 2048 bytes or greater (remember, the BeOS defaults to creating partitions with a block size of 1024 bytes). You need to do this because the BeOS won't recognize volumes with a block size smaller than the device's minimum block size, which on a CD-ROM is 2048 bytes. If you forget to do this you end up with a nice coaster or something to use for a microwave light show (yes, we do that here at Be). If you want to have your demo CD boot into the Tracker on
startup (like the BeOS Demo CD), you need to copy the
following files from your Desktop_settings Key_map Keymap Keymap_Data MIMEPrefs_settings Tracker beos_mime fonts_list fonts_status You may also want to copy over the Below is a sample Bootscript you can use for your CD
partition. This script doesn't do everything the standard
Bootscript does; i.e., it does not load the variables in the
# ------------------------------------------------------- # This is a special CD Bootscript for demo CDs. # It manages starting up all the necessary servers # and ensuring a sane system state. # # ++++++++++ # function: launch exectuable_path [ thread_to_wait_for ] # ++++++++++ launch () { if [ -f "/fd/$1" ] then echo Launching "/fd/$1" "/fd/$1" & [ "$2" != "" ] && waitfor "$2" return 1 else if [ -f "/boot/$1" ] then echo Launching "/boot/$1" "/boot/$1" & [ "$2" != "" ] && waitfor "$2" return 1 else echo There is no "$1" fi fi return 0 } # ++++++++++ # function: launchscript script_path # ++++++++++ launchscript() { if [ -f "/fd/$1" ] then echo Executing "/fd/$1" . "/fd/$1" else if [ -f "/boot/$1" ] then echo Executing "/boot/$1" . "/boot/$1" fi fi } # # First we set up a bunch environment variables that # we'll need later. # export PATH=:/bin:/boot/beos/apps:/boot/beos/preferences export HOME=/boot/home export SHELL=/bin/sh export USER=demo export GROUP=group SCRIPTS=beos/system/boot SERVERS=beos/system/servers # # Start the Boot of servers # launch $SERVERS/app_server picasso # launch app_server launch $SERVERS/registrar _roster_thread_ # launch registrar launch $SERVERS/debug_server # we hate crashing launch beos/system/Tracker # start the Tracker launch beos/system/Deskbar # launch DeskBar launch $SERVERS/audio_server # we like it noisy launch $SERVERS/print_server # we own paper stocks sleep 2 # let things settle down a bit and then # continue launchscript $SCRIPTS/Netscript # start up networking # ------------------------------------------------------- To create a BeOS CD that boots straight into an application such as Quake for the BeOS, you can simplify the above Bootscript by removing the following lines: launch $SERVERS/debug_server # we hate crashing launch beos/system/Tracker # start the Tracker launch beos/system/Deskbar # launch DeskBar launch $SERVERS/print_server # we own paper stocks ## Remove these two lines if you don't need networking sleep 2 # let things settle down a bit and then continue launchscript $SCRIPTS/Netscript # start up networking If you have a Matrox Video card, you may want to increase
the performance by installing the fast_video driver from the
BeOS R3.1 CD,
## This assuming the fastvid was installed ## into /boot/home/config/bin. /boot/home/config/bin/fastvid set # Speed up for # Matrox video card /boot/quake/Quake # Launch Quake shutdown -r -d 4 & # Reboot the machine when # the user quits the game Creating a Floppy for Saving Settings The BeOS Demo CD lets you save preference settings files to
a floppy. You do this is by renaming the actual config
directory on the CD from ## Add the following lines before the app_server is launched ## to determine if it should use the cd or the fd config ## directory ## mkdir /fd # create the fd mount point mount /dev/disk/floppy/raw /fd # try and mount floppy if [ $? -eq 0 ] # check to see if the floppy # was mounted successfully then ln -s /fd/home/config /config # point the link from the # floppy to the cd launchscript Bootscript.fd # if you need it, # launch Bootsript.fd else ln -s /boot/home/config2 /config # create the cd link fi By using this technique, you can save high scores from your Bootable Game CD or give all your kids a personal settings floppy so they won't change yours....
BE ENGINEERING INSIGHTS: SCSI From UserLand By Brian Swetlandswetland@be.com
BeOS R4 adds a new driver (scsi_raw) which allows programs to send arbitrary commands over the SCSI bus from userspace, without having to write a device driver for every little thing. What's this good for, you might ask? Not every SCSI device has a simple interface easily wrapped with a device using the POSIX-style open/close/read/write model of IO. This works great for disks, CD-ROMs, and other "simple" devices, but sometimes it's nice to be able to send the SCSI commands you need without having a special driver for that device -- maybe for a utility program or a CD-R authoring tool. Or maybe just to muck about with the raw bus to find out what makes it go. That's where the This naming scheme is used for all SCSI devices in R4 -- what was /dev/disk/scsi/000/raw is now /dev/disk/scsi/0/0/0/raw, and so on. We suggest that tape devices be named in a similar fashion as well. The major reason for this renaming is to allow wide SCSI to work without confusion -- wide device IDs can be greater than 9, which would cause problems in the old scheme. /dev/disk/scsi/1120/raw is more likely cause confusion than /dev/disk/scsi/1/12/0/raw where you can clearly see the division between path, target, and lun. Raw SCSI devices can be opened or closed, but not read from or written to. The only operation that can be done on a raw SCSI device is an ioctl call of the form ioctl(fd, B_RAW_DEVICE_COMMAND, &rawdevcmd, sizeof(raw_device_command)) This ioctl is also supported by ATAPI drives on the IDE chain (since ATAPI devices speak SCSI commands over the IDE bus). The raw device command data structure appears here and is explained below: /* raw device commands - from be/devices/scsi.h */ 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 }; * * * B_RAW_DEVICE_DATA_IN -- after the command is issued, data
is read from the bus to the buffer provided. If this flag
is not set, data is written to the bus instead.
* * * * * * * A Word Of Caution Be aware that the Example: SCSIProbe for the command line The following simple program walks the /* inquiry.cpp - SCSIProbe for the command line, more or less ** ** PPC: cc -o inquiry inquiry.cpp ** Intel: gcc -o inquiry inquiry.cpp -lbe */ #include <stdio.h> #include <string.h> #include <unistd.h> #include <Directory.h> #include <Entry.h> #include <Path.h> #include <scsi.h> #include <CAM.h> /* table with textual descriptions of the inquiry data's ** device type */ char *devtype[] = { "Disk ", "Tape ", "Printer", "CPU ", "WORM ", "CD-ROM ", "Scanner", "Optical", "Changer", "Comm ", "Unknown" }; /* open a raw device, issue an inquiry command, print the ** results (and a header if it's the first time). */ void inquiry(const char *dev) { static int header = 1; int fd,e; int path,targ,lun,type; raw_device_command rdc; uchar data[36], sense[16]; if(!strncmp("/dev/bus/scsi/",dev,14)){ sscanf(dev,"/dev/bus/scsi/%d/%d/%d/raw", &path,&targ,&lun); } else { path = targ = lun = 0; } /* fill out our raw device command data */ rdc.data = data; rdc.data_length = 36; rdc.sense_data = sense; rdc.sense_data_length = 0; rdc.timeout = 1000000; rdc.flags = B_RAW_DEVICE_DATA_IN; rdc.command_length = 6; rdc.command[0] = 0x12; rdc.command[1] = 0x00; rdc.command[2] = 0x00; rdc.command[3] = 0x00; rdc.command[4] = 36; rdc.command[5] = 0x00; if((fd = open(dev,0)) < 0) return; e = ioctl(fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc)); close(fd); if((e != 0) || (rdc.cam_status != CAM_REQ_CMP)) return; if(header){ printf("Bus ID LUN Type Vendor Device Rev \n" "--- --- --- ------- -------- ---------------- ----\n"); header = 0; } type = data[0] & 0x1F; if(type > 9) type = 10; printf("%3d %3d %3d %7s %8.8s %16.16s %4.4s\n", path, targ, lun, devtype[type], data + 8, data + 16, data + 32); } /* recursively wander down from a path, looking for "raw" ** devices to call inquiry on. */ void walkpath(const char *path) { BDirectory dir(path); if(dir.InitCheck() == B_OK){ BEntry entry; while(dir.GetNextEntry(&entry) >= 0) { BPath name; entry.GetPath(&name); if(entry.IsDirectory()) { walkpath(name.Path()); } else if(!strcmp(name.Leaf(),"raw")){ inquiry(name.Path()); } } } } /* handle a command line arg or just walk the directory ** tree looking for devices */ int main(int argc, char *argv[]) { if(argc != 2) { walkpath("/dev/bus/scsi"); } else { inquiry(argv[1]); } return 0; }
DEVELOPERS' WORKSHOP: Getting a Grip on BJoystick By Eric Shepherd sheppy@be.com "Developers' Workshop" is a weekly feature that provides
answers to our developers' questions, or topic requests.
To submit a question, visit
http://www.be.com/developers/suggestion_box.html.
The These sticks often have a half-dozen buttons or more, thumb
hats (those little direction knobs on top of the main
stick), and additional axes, such as rotational controls or
throttles. Game players want to use these controls to their
maximum potential, and the new The old This article is based on the sample project StickIt. StickIt
lets you pick a joystick (previously configured using the
new Joysticks preference application), then presents a
window showing all the buttons, hats, and axes provided by
that joystick, providing instant feedback as the joystick is
manipulated. Only key portions of the code will be shown
here; you can download the complete source code at
<ftp://ftp.be.com/pub/samples/device_kit/stickit.tgz>.
On R4 Intel, you can use the following command in a Terminal
window to compile and link the program:
On R4 PowerPC, this command compiles and links the program:
Note that I use the term "joystick," but I mean "any
BeOS-compatible game controller." There are supported game
pads as well.
Let's begin by looking at how to figure out what joysticks
are available, and how to open them. Take a look at the
It begins by calling Otherwise, a loop prints out the names of the joysticks the
user has configured for each game port:
This begins by obtaining the device name of the joystick
that's configured for the port (calling Once the device is open, StickIt's Let's just skim on to the At the top of the window, in a nice large font, the
joystick's name is displayed:
We've seen how In the loop, each button's name is retrieved by calling
A similar procedure is done to create the labels for the
hats, which are displayed in the same column as the buttons.
The right-hand column is dedicated to displays for the axes.
The topmost display is a two-dimensional display for the X
and Y axes, and a "Stick:" label is displayed there, under
the assumption that all joysticks have an X/Y axis pair.
Below this are created labels for any other axes, such as
throttles, twist controls, and the like. This is done just
like the button labels (except that Finally, the view and window are resized so the height of
the view and window is just a bit higher than needed to
display the taller of the two columns. This makes the window
look nice, without a lot of wasted space on the screen.
The The The axes and hats arrays will be used when we call
Then, We begin by drawing the state of the buttons. Each button is
represented by a box next to the corresponding label. If the
button is pressed, a solid black box is drawn. If the button
isn't pressed, a hollow box is drawn. This is done in a
loop, as follows:
The This code loops through, once for each button, and looks to
see whether that button is pressed or not. If it's pressed,
the rectangle is filled solid with the high color;
otherwise, the interior of the rectangle is cleared to the
low color and the frame is refreshed in the high color.
The states of the hats are obtained by calling
These nine values represent nine different positions, which
can be nicely displayed in a three-by-three grid of squares.
I won't go into the specifics of how the code that draws
this grid works (this article is getting long already), but
we fill in the appropriate square given the value of each
hat, and make sure the others are all cleared.
We read the axes by calling Next, the X and Y axes (which we're treating as a
two-dimensional field) are drawn. This code isn't very
smart, but it does the job. It simply scales the X and Y
values into the range needed to draw the dot, and draws a
red, filled circle to represent the stick's position.
The rest of the axes are drawn as a horizontal slider-type
display, with a black box and a red oblong indicating the
value of the axis.
Download StickIt and have a look at the code. When you get
R4, give it a try. The new
I'm in Europe -- actually, in Paris, France. In the old
days, the idea of Europe was just that, an idea cherished by
citizens with memories of the bad old days and hopes for a
better future. In those times, one could not freely move
one's person or belongings or profession from one country to
another.
Half a century later, preparing for landing at the Charles
de Gaulle airport, the airline attendant mentions the
"Schengen Space," the set of countries we can all move
freely between, citizens of the European Union or not. And
talk freely between -- your GSM cell phone works everywhere.
Not the same frequency of GSM as the one timidly offered in
the US, but multistandard phones are becoming available and,
voilà , a world-wide cell phone (almost, no GSM in Japan, if
memory serves).
So, slowly, with all the difficulties involved in mediating
cultural differences, with the danger lurking in an
additional layer of civil servants, the occasionally reviled
eurocrats, the shining idea of a united Europe is becoming a
dented reality.
This seems to generate many opportunities for the PC
industry. PC sales are growing everywhere, even in the midst
of economic uncertainty. On a country by country basis,
growth rates range from 18% in the UK to more than 21% in
France. Compaq still leads and Dell registers the strongest
growth, almost doubling unit sales last quarter (possibly a
response to its sending a seed team of elite troops to one
country after another to firmly implant its methods, in
reaction to its problematic first efforts). On the surface,
with the possible exception of Siemens, major European
brands don't have much market presence any more.
In a world of standard products based on Windows and Intel
Architecture processors, in theory, there is little
technological advantage available to any one player. What
follows, still in theory, is that European companies have a
more level playing field than with IBM proprietary mainframe
architectures. Instead, they are leveled not by technology
but by strong corporate cultures, although this is only
partly true. In the US, a good 25% of all PCs are no-name
systems assembled to order by aggressive local retailers who
manage to "out price" and "out service" the big guys. In
Europe, each sizeable city enjoys such an active core of
small companies who, according to a local study, serve an
even higher percentage of the market than in the US.
Conversations here put less emphasis on the Y2K problem,
rightly or wrongly, than on opening markets to competition
in fields such as telecommunications. Local monopolies no
longer control the field and, what do you know, the just
opened market consumes so much more of the newly competitive
services that the old monopolies prosper more than ever,
along with their new competitors. This, in turn, has removed
obstacles that used to stand in the way of Internet
development. What was seen as yet another invasion of
American culture is now embraced by both the new blood who
see the future on the Net, and the old guard who know they
must follow or die.
For the software industry, the emerging new Europe offers an
interesting mix of opposing trends. On one hand, we have the
obvious: the easier circulation of goods, services, people,
and even professions (your professional degree is now
recognized in more places) all make it easier to sell more
product in more places. On the other, but not opposed, hand,
Europeans are used to different, fragmented cultures. This
makes it easy for us to promote what in other places is
sometimes perceived as a "fragmenting" product.
In other less politically correct words, Microsoft is a
lesser god in Europe than in the US. Where the common US
view is "there is no other Microsoft but Microsoft," Europe
is not so monotheistic. As a result, BeOS enjoys
proportionally higher acceptance with software developers
and distribution channels, as well as with the general and
professional media. This is in line with what happened with
the VCR and audio CDs, or even the Macintosh -- they all
first gained traction in Europe.
In conclusion, and in contradiction with some of the above,
if the story is that the US favors standardization and
Europe accepts more diversity, how do I explain five or six
incompatible cellular telephone systems in the US vs.
Europe-wide (and beyond) GSM?
1997 Be Newsletters | 1995 & 1996 Be Newsletters Copyright ©1998 Be, Inc. Be is a registered trademark, and BeOS, BeBox, BeWare, GeekPort, the Be logo and the BeOS logo are trademarks of Be, Inc. All other trademarks mentioned are the property of their respective owners. Comments about this site? Please write us at webmaster@be.com. |