Samsung WCUBE User Document
Samsung WCUBE User Document
CUBE
(Small-C)
User Document
Blank Page
Table of Content
1. INTRODUCTION 7
2. PURPOSE 7
3. SCOPE 8
6. REQUIREMENT 8
6.1. UDMA: 9
7. SETUP 11
8.4. Function 24
8.4.1. Pre-Defined Function 24
8.4.2. User Defined Function 24
9. WCUBE 25
9.1. Overview 25
9.2. Features 26
9.10. Flags 42
9.11. Macros 43
10.3.5. Help 55
10.3.6. Console: Basic I/O Functions 56
10.3.7. Console: Display Functions 58
10.3.8. Run-time Control Flag Switch 58
10.3.9. Trace/Debug functions 60
10.3.10. Buffer functions 60
10.3.10.1. Bedit 63
10.3.11. Power Control Functions 67
10.3.11.1. ATX Power Control Via Parallel Port (PWR_CONTROL = 1) 68
10.3.12. PCI functions 69
10.3.13. Memory Mapped IO 70
10.3.14. Other & Date/ Time 71
10.3.15. Legacy Command Tag-Queue 72
10.3.16. Native Command Queuing 73
10.3.17. Drive Commands 75
10.3.18. Drive Commands (Samsung VU Commands) 81
10.3.19. MISC commands (Math,Test….) 85
10.3.20. Command compatibility between Gemini and Cube 87
11. VTOOL 96
11.1. Overview 96
REVISION HISTORY
1. INTRODUCTION
This documentation lays out the “Small-C” language definition.
Small-C is developed to serve as a generic test language for Samsung. Small-C has three
major parts:
Of these three, Lexical Analyzer and Parser is a generic Small-C compiler components. The
Code Generator in other hand is micro-processor specific. At the time of this write-up, the
code we are generating is based on CUBE virtual – for Cube related topics, please refer to
section 7.
Reserved words
Language feature and syntax
Small-C usage (inputs and outputs)
2. PURPOSE
This document serves as a reference for those who require to write Small-C codes (script),
the syntax and the grammar.
3. SCOPE
This document is intended for the programmers developing Small-C based test codes. For
those who are doing a Small-C programming can skip the first few sections and move right
into the language syntax section.
6. REQUIREMENT
- Hardware:
PC (Pentium with 8meg or more memory)
Storage device (Floppy or resident HDD) – to store the program
HDD Controller
On-board PCI chipset (IDE/SATA controller) supported
All onboard PCI chipset should work in Compatible mode (some
may also work Native mode)
Tested PCI Chipsets
o VIA
o SiS
o NVidia
o Intel (ICH4 / ICH5) – also can run in native mode
Promise PATA controller:
U33 (not tested)
U66 (not tested)
U100 - TESTED
U133 - TESTED
Optional:
Power control
Samsung ISA Power control board
ATX power supply with Parallel port connection
6.1. UDMA:
To interpret the "Ultra DMA[88]" line, you need to understand that the
displayed value is two bytes, any leading zeros are not displayed. So in the
above case, the value we ought to see it as is 0x007F. The left byte (0x00)
represents the udma mode that is set, and the right byte (0x7F) is what the
drive supports.
To understand these values, we must convert the number into binary. To see
what udma mode the drive supports we convert the right byte. Converting
0x7F to binary we get 01111111b. Label the bits right to left from zero (0) to
seven (7). For each bit set represents that that udma mode is supported. So the
right most bit at position zero (0) means udma mode 0 is support, one bit to
the left at position one (1) means udma mode 1 is supported, and so on a so
forth.
Similarly we do the same for the left byte to see what udma mode is currently
set. Converting 0x00 to binary we get 00000000b, so we see that no udma
mode is set.
We convert the right byte to binary, 0x3F = 00111111b. This means that all
only udma modes 5 to 0 are supported. And if we conver the left byte to
binary, 0x04 = 00000100b, we see that the drive is currently operating in
udma mode 2.
To set udma mode, you use the set features command (setf). setf takes a two
byte argument. It is simplest to input the argument as a hexadecimal number
as you will see why.
The left byte (0x4?) represents that you wish to set udma mode and which
mode; the right byte (0x03) represents that you wish to set the transfer mode.
So the left four-? (0x4?) represents udma setting udma with the question mark
signifying which mode. The right zero-three (0x03) represents setting the
transfer mode.
For more information regarding the set features command, refer to the ATA
command spec.
Limitations:
For (at least) Promise cards, if a drive is ever disconnected and reconnected, it
is imperative that you set dma mode using the setf() command before issuing
a dma command. Failure to do so may lead to system hang/freeze.
Additionally, for Promise cards, UDMA mode 5 and 6 are supported, with
restrictions. To get the modes to work, you must have the drive plugged in
while the system is booting. If no drive is connected at boot up and you try to
set udma mode 5 or 6, you may recieve CRC errors. Once the system has
booted, you may disconnect and reconnect a different drive if you wish,
provided you set the udma mode again.
- Software:
Latest CUBE.EXE
Driver file (*.drv)
INT_ICH.DRV for ICH 4 or 5 (Native or Compat mode – BIOS
controlled)
PRO_IDE.DRV for Promise U33/66/100/133 (Native mode)
Other on-board chipset (Compat mode)
TNT runtime library
OS (Dos)
Optional: Text Editor
7. Setup
Following are the key and reserved words for Small-C language.
These words can not be used as a variable name in script files.
break
case
char
continue
default
do
else
float
for
goto
if
int
return
switch
void
while"
Variables and constants are manipulated by operators to form expressions. These are the
most basic elements of Small-C language. This section will closely examine each.
In Small-C, the names that are used to reference variables and labels are known as identifiers.
The length of an identifier in Small-C can vary from one to several characters. In all cases the
first character must be a letter, and subsequent characters must be either letters, numbers, or
underscore. Here are some examples of correct and incorrect identifier names.
Correct Incorrect
num 23num
myid23 myid?23
my_ident my_ident?
my_float my_float@
my_str my_str#
There are two types of identifiers, user defined and reserved (Machine dependent/specific).
Reserved identifiers are the variable names that are predefined for a machine that can be
accessed by script file.
example:
void main(void)
{
int total; // declare a variable of int
total = 1;
return;
}
In Small-C, there are three data types that are supported, and they are as follows:
8.2.4. Declaration
All variables must be declared before use. A declaration specifies a type, and is followed by a
list of one or more variables of that type.
Example:
Global declaration
When variable or other identifiers are declare as global, these identifiers will be in symbol
table throughout the execution of the program.
Program example:
void foo(void)
{
int myLocalVar; // declare a local variable
myLocalVar = 1; // initialize local variable
void main(void)
{
foo( ); // Declare a local variable
return; // When we leave, gMyGlobalVar will be
// lost, too
}
Local declaration
Unlike Global declaration, variables declared as local will be removed from the symbol
table once the routine that declared the variable(s) exits.
Program example:
void foo(void)
{
int myLocalVar; // declare a local variable
myLocalVar = 1; // initialize local variable
void main(void)
{
foo( ); // Declare a local variable
return; // When we leave, gMyGlobalVar will be
// lost, too
}
Program example:
void main(void)
{
int age; // declare a variable
age = 17; // Initialize age to value 17
return;
}
8.2.6. Operators
An operator is a symbol that tells the compiler that you want to perform specific
mathematical or logical manipulations. Small-C, just like C, has three general classes of
operators: arithmetic, relational and logical, and bitwise.
Arithmetic Operators
Table 6-1 lists the binary arithmetic operators allowed in Small-C. The operators -, +, *, and /
work the same way in Small-C as they do in most other computer languages.
Operator Action
Example:
x = 3 / 2;
Example:
x = 5 % 3;
Modulus operator can only be applied to integers; cannot be applied to floating number.
In the term relational operator the word relation refers to the relationships that values can
have with one another. In the term logical operator the word logical refers to the ways these
relationships can be connected together. Because the relational and logical operators often
work together, they will be discussed together here. The key to the concepts that underlie
relational and logical operators are the ideas true and false.
Relational Operators
Operator Action
Logical operators
Operator Action
&& and
|| or
! not --- not working yet
~ not --- nor working yet
Bitwise Operators
The term bitwise operation refers to the shifting of the actual bits. Table 12-3 lists the
operators that apply to bitwise operators.
Operator Action
& and
| or
^ exclusive or --- not working yet
~ not
>> shift right
<< shift left
Table 7-3 The Bitwise Operators
Assignment statements
variable_name = expression;
The table below lists the rules for precedence and associatively of all operators that are
supported by Small-C.
Operator Associativity
() [] left to right
! ~ ++ -- right to left
* / % left to right
+ - left to right
<< >> left to right
< <= > >== left to right
== != left to right
& | left to right
^ left to right
&& || left to right
= right to left
A statement specifies an action to be carried out by the computer (simple statements must
end with a semicolon)
This section discusses the various program control statements. These includes the conditional
statements
if
switch
, the looping construct
while
do-while
for
, and the statements
break
continue
goto
8.3.1. IF Statement
8.3.1.1. IF
Syntax:
if (expression)
statement;
Example:
if (age < 5)
put(“Baby”);
Syntax:
if (expression)
statement;
else
statement
Example:
if (age < 18)
printf(“you are still a kid₩n”);
else
printf(“you are on your own₩n”);
Syntax:
if ( condition )
statement
else if (condition)
statement
else
statement
Syntax:
switch (expression)
{
case constant: statement(s);
case constant: statement(s);
default: statement(s);
}
Example:
char selection;
selection = 2;
switch (selection)
{
case 0: printf(”Num is ZERO”); break;
case 1: printf(”Num is ONE”); break;
case 2: printf(“Num is TWO”); break;
default: printf(“Bad data”);
Syntax: A re w e d o ne?
while (expression) (exp ressio n)
Statement
No
OR
D o S tuff
while (expression) Y es
{
Statement(s);
} C o ntinue w ith
o ther thing s
D o ne
No
D o S tuff
Syntax:
do
{
statement(s);
} while(expression) A re w e d o ne?
Y es
C o ntinue w ith
o ther thing s
D o ne
Syntax:
for (exp1; exp2; exp3)
statement;
OR
8.4. Function
1. Predefined functions
To write and use user defined function(s), the programmer must do the following
1. Declare
2. Implement
3. Use
Declare
Syntax:
Implementation
Syntax:
Example:
8.5.2. #define
Syntax: #define MAX_NUM_OF_READS 1000
9. WCUBE
9.1. Overview
This application is designed to provide a user interface to CUBE in a Windows environment.
Since this tool is designed to manipulate scripts for execution on the drive, it only makes sense to
emulate a user interface similar to other integrated compilers such as Visual C++. As a result the
application contains a text editor with additional components, specific to CUBE functionality.
9.2. Features
All windows aside from the text editor can be free floating or docked. All windows can be
docked on any side to the main window or other docked windows. This allows for the flexibility
of user preference in the appearance of the application. Each window, including the main
window, remembers its position and visibility when the application is closed. So each time the
application is reopened, the same interface will be seen.
Note: Since windows can be docked on any side, there may be difficulties in docking windows in certain
positions as they may have a tendency to snap to the undesired edges. Watch the outline of the window
when dragging to dock.
The Buffer Editor, Disk Status, and Command History are all free floating while the Command
Line is still docked:
Additionally, the windows maybe closed/hidden so there is more room for other windows. There
are three ways to toggle the visibility of the various window. You can use the individual close
button on the window, use the toggle buttons on the top, or use the file menu.
As you can see, the file menu allows you to hide more windows than the toggle bar. If you really
need the space, then they can be closed. However, they are not normally closed since they take
minimal space and provide quicker access to various parts of the application. Once a window is
hidden, reselect from the toggle bar or the file menu to make it reappear.
All toolbar icons and file menu selections have captions assigned to them. If confused about
what a particular command may do, hold the mouse over the item and the status bar will display
a more detailed explanation about its function.
A list of the devices detected on your system will be displayed. Selecting one of the devices will
load the appropriate drivers and register the device for usage on with executable commands.
Additionally, there are the options to configure and reduce Windows overhead.
Note: Windows requires an inf installed for each device on the system before you may interact with it. If, in the
Device Manager, there is an exclamation point next to a device you wish you use in WCUBE, it will not show
up until an inf has been installed and the exclamation point is gone.
The configure option will display a new dialog box which will allow you to hide or show devices
on your system.
You will see a similar listing of devices in this window, however each device has a check box
next to it. By unchecking the box, the device will not appear in the menu. Additionally, you will
be unable to select that device from the command line either. This helps to remove devices you
do not wish to test to prevent accidental data loss or damage, such as the OS’s resident hard drive.
Since Windows requires more resources, there is inherent overhead using Windows versus DOS.
Checking the “Reduce Windows Overhead” will attempt to minimize this overhead. This will not
reduce drive execution time, just the time between each command. Of course, as more system
resources are dedicated to WCUBE, other applications may feel more sluggish with this on than
without. This option will not affect system performance when no scripts/commands are running.
Note: This option may not work on some systems, particularly Windows 98 machines. If you notice command
execution times taking longer than they should with this option, please disable it.
When selecting a device, the name of the window will change. When having multiple WCUBE
windows open, you can more easily distinguish which WCUBE belongs to which host adapter.
Remember, you can only one WCUBE can select each host adapter.
All of these settings are saved when the application is closed so reselecting and configuring of
devices is unnecessary between application restarts.
Both provide methods for creating new, opening, and saving files as well as undoing, redoing,
cutting, copying and pasting text for each script. Additionally, in the toolbar, there is support for
flagging of lines. At the bottom, there is a status bar which provides various information such as
the current cursor position, text mode, and key status (num lock, caps lock, etc).
The tabs also provide some repeated functionality. By right clicking on the tab, you can access
the same functionality found in the file menu and toolbar for that particular script (right). Right
clicking on the bar will produce a different list of options (left).
In addition to basic text entry, the editor supports syntax highlighting, automatic indenting, and
flagging/bookmarking of lines.
Syntax highlighting - Most basic C commands are recognized by the editor and will
automatically change colors. Such syntax includes: compiler commands (#), quotations (“),
numbers (0-9), comments (both // and /**/) and keywords (int, main, char, etc).
Automatic indenting – Like other programming orientated text editors, this editor will
automatically indent on a carriage return if the previous line was indented.
Note: the editor will *only* indent if the previous line has been indented (first indent is
manually put)
Flagging lines -And finally, one can flag various lines for quick access. This can be done by
selecting the flag button in the toolbar or pressing ctrl+<#> where <#> is a number between 0
and 9. This will create a little bubble in the left margin. By selecting “next flag” or “previous
flag” in the toolbar, you can jump to the next or previous flag set based upon your current
cursor location. If the flag was set by ctrl+<#> you can also press alt+<#> to jump to that
specific flag.
The above image shows the command line window. At the bottom is the command line itself.
This is the main interface to the CUBE compiler and virtual machine. Any commands which are
understood by the CUBE compiler can be entered at the prompt.
There are two types of commands, built-in commands, and CUBE commands. Although the
built-in commands have very similar, if not exact, counterparts in the DOS CUBE, the
underlying structure is different such that they need to be specially written for WCUBE. All
commands which do not fall into the built-in commands are assumed to be CUBE commands
and automatically compiled.
Built-in Commands:
Command Description
new The application will open a new, empty script file for editing.
No file will be created until explicitly told to save
load The application will open the standard Windows load dialog
for you to select a file to open in the text editor
load <filename> The application will attempt to open the file with the
specified filename in the text editor
loadm <filename> Load the file as a macro
listm Lists all the macros detected
save The application will save the currently selected text editor
window
run The application will run the contents of the currently selected
editor window
exit Exit the application. Will prompt to save any scripts that have
been modified.
cls Clear all text from the command line
* Whatever cannot be understood will be assumed to be a
small-c script and sent to the compiler/virtual machine.
Note: the code will be automatically wrapped in “void main()
{}”
Since a press of the enter key will start the execution of a command, the command line only
accepts single line commands. For multi-lined commands, use the script editor. Please note for
CUBE commands, there is no need to add “void main() {}”, the text will be automatically
encapsulated so they can be properly executed.
Like a DOS shell, whenever a command is entered, it is displayed along with any output that
may have occurred as a result of the command. Typically an “ok” will display in the window to
indicate the completion of the command. Additionally, the prompt along with a blinking cursor
will appear so another command may be entered.
The command line also support command history. Any command typed during the current
session can be recalled using the down and up arrow keys. The up key will cycle through earlier
commands while the down key will cycle through later commands. Once you reach your desired
command, you may edit it, or keep as is, for execution again.
While a command is processing, the input will disappear. This will prevent multiple commands
being executed on a drive at the same time. Any other part of the application may be used while
a command is processing. That is the beauty of Windows and multithreaded applications. To
cancel a command, press “ESC” which will attempt to halt any commands currently being
executed.
At the top is the CWin (console window). By default it is not shown an the command line
encompasses the entire window. It is another place for output to be displayed per the user
requests. The display window is attached to the command line window and cannot be detached.
Additionally it cannot be resized except through the commands defined by CUBE. The All
supported command, including creating and resizing the window, are described in the CUBE
documentation.
The address field will display the range of addresses, in hexadecimal, viewed in the other two
fields. Also, the address field provides quick access to a particular address. Just type in the
address in hexadecimal and press enter, the buffer will jump to the specified address, if it is valid.
Press escape or click to cancel out. While manipulating the data in the other fields, the address
field will highlight the address of the data being selected.
The hex field displays the contents of the buffer in hexadecimal and likewise the ASCII field
displays it in ASCII. By default the editor is in overwrite mode. Any thing that is typed in will
overwrite the existing values. To switch to insert mode, press insert. This will shift all data after
cursor to the right and inserting the new value. Additionally, the delete be available, which will
shift all data after the cursor to the right
Note: When inserting, the last byte will be “pushed out”. Also, when deleting, the last byte will be shifted
in with value 0x00.
At the top, there is toolbar to provide additional functionality other than insert and overwrite.
The eight buttons are (left to right) Search, Fill, Commit, Revert/Refresh, Clear, Compare, Copy,
and Configure.
Search button – displays a dialog enter either a hex or an ASCII value. This value will be
searched for within the entire buffer.
Fill button – display a similar dialog as the search button. This will to fill the entire buffer with
the specified pattern.
Note: When entering hex, the input must be byte aligned, that is, your searches must be multiples of 8 bits
wide (i.e. “000A” and “0A” is ok, but “00A” or “A” is not).
Commit button – copies all modifications to the actual buffer. No actual modifications are made
to the buffer until the commit button is pushed.
Revert/Refresh button – undoes any changes since last commit and reload the current buffer
values into the window. This is useful if any undesirable modifications were made. Also this
button can be used to get the current state of the buffer.
Clear – This will clear the buffer of all values, replacing everything with zeros. At the bottom,
the status bar displays, from left to right, the mode (insert or overwrite) and the cursor
position in both decimal and hexadecimal values.
Compare – This toggles the compare between read and write buffers, highlighting the differences
in the buffer you are currently in.
Copy – This will pop up a new window to copy various selections from one destination to the
other. The copy range will automatically be filled with the whatever you are selecting.
Warning: Copying large amounts of data from the buffer is not recommended as the process is slow. If you
need to dump the entire read/write buffer, use rdump/ wdump, or rsave/wsave commands.
Configure – This will open a window to allow you to customize the appearance of the buffer.
The scrollbar range is for making the scroll bar not scroll for the entire buffer. This is useful
when you only want to look at 10 blocks of data, and you don’t need the scroll bar to be
sensitive for the entire 4000 blocks.
9.10. Flags
This window shows the built in flags in WCUBE. The names are similar to what you would type
in at the command line. If the flag is enabled, there will be a check by it, otherwise it will be
unchecked. The flag will update in “real-time”; whenever the a flag changes, in a script,
command line or mouse click, it will be reflected immediately. All flags can be modified at
anytime, even while a script is running with the exception of logfile. To turn on and off the
logfile, you must type it in at the commandline or within a script.
9.11. Macros
This window lists all the macros in a file whenever a macro file is loaded either through the file
menu or “loadm”. This is the same list displayed at load time or when the “listm” command is
issued. To run any of the macros, double click on it and the macro will run, as if you had typed
“run <macro name>”
If you are using second channel on the board, if you find you are unable to talk to the drive or a
[?] appears instead of [0] in the title bar of WCUBE you need to type DRIVE = 1 (defaulted to
DRIVE = 0) then try selecting the host adapter again. This will cause WCUBE to use the second
port rather than the first. WCUBE does not remember what port you are using from session to
session. It will always default to DRIVE = 0. To remedy this, write a cube.ini which sets DRIVE
= 1 then setha <host adapter number>.
Now for installation. You do not need to install the WCUBE drivers to use the motherboard
controllers. Instead you need to disable the device in device manager. Go to your Device
Manager and find the channel you wish you use:
Right click on the channel and click Disable. Windows may or may not give you a warning
message that this will make the device no longer function. Click yes and the device should
appear with a red ‘X’ now. You can now use compatibility/onboard in WCUBE.
To disable the DRQ polling, and rely only on interrupts, disable the flag “drqpolling” (drqpolling
0).
Cube, when loaded, will first look for CUBE.INI. This is CUBE initialization file which
Cube will execute. If the file does not exist, cube will still load but no initialization will take
place. Meaning, the user must set things up manually before drive can be tested.
CUBE.INI file content syntax follows Small-C grammar. The kinds of thing one would do
inside the CUBE.INI will be such a setting as setting up the power controller type, PATA or
SATA controller to load. Below is a sample CUBE.INI for your reference:
//-------------------------------------------
//- By: Daniel
//- Date: 08/08/2003
//-
//- This is the CUBE Initialization file
//-
//- Here, we will scan for controller and
//- set/load driver for the first controller found
//-------------------------------------------
void main(void)
{
scanallpci;
setha(0);
PWR_CONTROL=1;
return;
}
Macros will not take in any call parameters. All parameter, argument, passing must be done
using the predefined global variables (ex: R0-R19). Also, macros must not return any return
types. Therefore, all macro definitions must follow the following syntax:
//-------------------------------------------
//- By: Daniel
//- Date: 07/19/2004
//- FileName MyMacro.MAC
//-
//- Macro file demonstration
//-
//-------------------------------------------
void mytest(void)
{
id 0;
sk( 1,1);
rdmae(1,1);
}
void msg1(void)
{
put(“This is message”); newline;
put(“This is a message”);
}
Above simple example has two macros define, mytest & msg1.
Identifier Description
R0 – R19 Reserved Variable for the users
VU Vendor Unique mode flag (0 == no, 1 == yes)
DRIVE Drive selector (0 == Primary, 1 == secondary)
SLAVE Drive selector (0 == Master, 1 == slave)
ECC ECC byte count (set when Identify command is issued)
RETRY Retry count
DEVICE_TYPE DUT device type (set when Identify command is issued)
0 == Unknown
1 == PATA
2 == SATA
4 == SDIO
CMD_TIMEOUT Command Timeout value in milliseconds. The default is 10,000. The
value can be modified using cmdtimeout(exp) function.
ex: cmdtimeout(123); // timeout value changed to 123milliseconds
acc Accumulator (was added to support Gemini like parameter passing on
some VU commands)
MAX_C Max cylinder (set when Identify command is issued)
MAX_H Max head (set when Identify command is issued)
MAX_S Max sector (set when Identify command is issued)
MAX_LBA Max lba (set when Identify command is issued)
MAX_Z Max zone (set when “init” command is issued to drive)
MAX_PC Max Physical Cylinder (set when “init” or “inith” is issued to the drive)
MAX_PH Max Physical Head (set when “init” or “inith” is issued to the drive)
MAX_PS Max Physical Sector (set when “init” or “inith” is issued to the drive)
MAX_PBA Max Physical Block Address (set when “init” or “inith” is issued to the
drive)
MIN_PC Minimum Physical Cylinder accessible (set when “init” or “inith” is
issued). Any VU command accessing below this cylinder will be
rejected.
Key Description
F1 Toggle Status window
F2 Toggle Console screen mode (size: 25 lines vs 40 lines)
F3 Show command execution trace buffer (this assumes “trace 1” was issued before)
F4
F5
F6
F7
F8
F9 Show symbol table
F10
ESC Stop script execution
10.3.4. Edit
This is a very simple edit that work a barebones of an editor. If large file is used, it is recommended
to use editor outside of Cube.
10.3.5. Help
Help is for those who needs instant help without going to the cube.doc. The contents of the help file
is same as the cube.doc.
On the console:
‘?’ will print help on help.
‘??’ will invoke the help screen where the help file will be displayed.
example:
getd(“Give me data: “, R0);
getf(prompt, var) Get a float number from the user and store it into
var
gets(prompt, var) Get a string from the user and store it into var Not Supported At This Time
Color Attributes:
ex:
void main(void)
{
cwin(5); // create a user console window of size 5 (max of 5 lines)
cputs(1,1,”Hello!”, 0x35); // Display “Hello” at xy coordinate with attribute of 0x35)
return;
}
ex:
void main(void)
{
When “erhlt 1” is issued and we get an error, the system will halt with option of either to STOP
or to CONTINUE. If Continue is selected, Cube will read and dump TF contents and dump the
trace buffer – if tracing is enabled.
From the console window, you can also use F3 key to displace trace buffer
ex:
void main(void)
{
trace 1; // Enable tracing
id(1); // Issue identify command
sk(1,1); // Seek to cyl=1, head=1
trace_show(10); // Display upto 10 last cmds issued
return;
}
When “erhlt 1” is issued and we get an error, the system will halt with option of either to
STOP or to CONTINUE. If Continue is selected, Cube will read and dump TF contents
and dump the trace buffer – if tracing is enabled.
The user can map read/write buffer to one of the predefined buffer.
ex:
setrbuf(1); // sets read buffer to buf1
setwbuf(2); // sets write buffer to buf2
By default, when Cube is loaded, read buffer is set to buf1 and write buffer is set to buf2
Example:
To tag and fill write buffer:
tag 1;
wfill(0xffffffff);
FFEEDDCC
3: ID pattern
using c/h/s/b writes in in
BCD,hex, and inverse of
c/h/s/b
4: IQ pattern
fills in sector with the
current
LBA and subsequently
increments the value.
5: Random pattern
beginning
count : byte count # to copy
10.3.10.1. Bedit
When the user type Bedit with parameter ‘1’ or ‘2’, a buffer editor will popup.
Buffer size is limited to 8192 blocks = 4194304 bytes.
2.
3.
1. Shows the offset of the data at the cursor, value is the current data value of where the
cursor is.(see Figure 4 Buffer Editor)
2. Shows the data as ascii format.(See Figure 4 Buffer Editor)
3. This is the menu for the buffer editor. (See Figure 4 Buffer Editor)
F1: will toggle the cursor between ASCII area anf HEX area
F2: Put the cursor at a data and press F2 will fill that line with the same data as where the
cursor is. (See Figure 5 Fill Line :F2)
F3. Search the buffer the data
F4. Swaps buffer between Write Buffer, and Read Buffer
F5. Saves the buffer
F6. Sets all the data back to zero
F7. Compares Data between Write Buffer and Read buffer. The mis compared data will
be in purple(See Figure 7 Comparing the buffer F7).
F8. Clears the buffer
F9. Put the cursor at a data and press F9 will fill the whole buffer with the same data as
where the cursor is. (See Figure 6 Fill Whole Buffer :F3)
ESC: Quits the buffer and go back to the cube command prompt
PgDn: Goes to next 512 bytes of data when full screen. If pass the limit, it will go back
to offset zero.
PgUp: Goes to previous 512 bytes of data when full screen. If pass zero, it will go the
1ff00.
Home: Goes to the beginning of the offset for that screen.
End : Goes to the end of the offset for that screen .
Insert key: Toggles insert/overwrite.
User can attach a power control board to a test system to turn power on or off.
13
25
12
10 20 24
11
9 19 23
G ND 10
8 18 22
9
P C P arallel P o rt
7 17 21
8
6 A TX P o w er 16 20
G ND 7
5 C o nnecto r 15 19
6
4 14 P C _O N 18
5
3 13 17
4
2 12 16
3
1 11 15
D A TA 0
2
14
1
[no te]
P in 14 P in 2
P in 15 P in 23
Before CUBE can communicate with the drive under test, the user must detect and load
appropriate driver (PATA/SATA). This can be done by using PCI functions
If you are working with a new hardware where writing and reading of data to the HW is done
via the memory mapped IO, you must use the following predefined functions to operate on it.
Memory mapped IO operations are done in conjunction with PCI function (see PCI functions
section for more info)
*** It is important to note that when mapping a physical memory space, it must be mapped in
blocks of 0x1000. ie. you must mask the hardware address with 0xFFFFF000 prior to calling
the map_phys(..) function.
ex: if your HW memory address is 0x1FC13204, and want to read offset 0x10 from it, you must
do the following:
hw_addr = 0x1FC13204;
hw_addr = hw_addr & 0xFFFFFFF0; // must always mask of last 4 bits
new_hw_addr = hw_addr & 0xfffff000;
difference = hw_addr – new_hw_addr;
//==========================================================
//= By: Daniel
//=
//= Memory mapped io example using CUBE
//=
//= - we will flash the LED of Si3124 card (Silicon Image SATA-II card)
//=
//==========================================================
void main()
{
int BAR1; // PCI config space BAR1 register
int mappedAddress; // Will hold mapped io space addr
int difference;
int offset;
R0 = mappedAddress + difference;
newline;
putd(" mapped io address: R0 = %X", R0); newline;newline;
offset = 0;
free_phys(mappedAddress);
}
example:
void main()
{
int sTime;
int eTime;
gettime(sTime);
gettime(eTime);
example:
//=================================================
//= By: Daniel
//=
//= Tag Cmd Queue example using CUBE
//=
//=================================================
void main(void)
{
int tagId, lba;
In order to use Serial ATA Native Command Queuing commands over a particular Serial ATA
port, three requirements must be met:
The host controller NCQ feature (must support the DMA Setup FIS and the Set Device Bits
FIS in order to enable First Party DMA transfers and efficient command completion)
The software driver must support the Read FPDMA Queued and Write FPDMA Queued
commands.
The drive must support Serial ATA Native Command Queuing.
More to be done….
Before any drive command is issued, the user must make sure the controller is selected and the
driver is loaded by issuing following two PCI functions
1 – scanpci or scanallpci
2 – setha(HA#)
For DMA functions/commands, the user must make sure the following are true:
- Controller supports DMA and/or UDMA
- Transfer mode is set by issuing setf(m) function
For Extended command, you must make sure your controller supports extended mode
[note] any drive command having CHS or LBA mode addressing option, to issue command in
LBA mode, the user must issue “slba 1” prior to issuing the drive command. Or, if user wants
to use CHS mode, you’ll are required to issue “slba 0” prior to issuing the drive command
The command execution timeout is based on the CMD_TIMEOUT global variable; the value is
in milliseconds. User can modify the timeout value using cmdtimeout(exp) function.
[note]
“bs” & “xb” has no meaning if “dir” is set to ZERO
void main()
{
int CMD_UNLOCK;
int PASS_FE;
int LOCK;
CMD_UNLOCK = 0xC0;
PASS_FE = 0x22;
LOCK = 0;
cmd(CMD_UNLOCK,PASS_FE,LOCK, 0,0,0,0xA1,0,0,0);
}
To set the
By function name
function syntax OP parameter/description requirement
cfa_es(lba, s) 0xC0 CFA Erase sector
lba:
s: sector
dcfg(f) 0xB1 Device Configuration
f: Feature
0xC0 – Restore
0xC1 – Freeze lock
0xC2 – Identify
0xC3 – Set
ckpw 0xE5 Check Power Mode
diag 0x90 Diagnostic
dreset 0x08 NA
dw fn 0x92 Download Micro Code (Diskware)
fn: filename
example: dw “palo.dn2”;
idle t 0xE3 Idle
t: timer period value
0 // Timeout disabled
1-240 // (t * 5) seconds
241-251 // ((t-240)*30) minutes
252 // 21 minutes
253 // between 8 and 12 hours
254 // Reserved
255 // 21 min 15 seconds
flush 0xE7 Flush Cache
flushe 0xEA Flush Cache Extended
id m 0xEC Device Identify
m: display mode
0 == Do not display data
1 == Display data
idlei 0xE1 Idle Immediate
nop 0x00 NA
nvcache(fea,lba,sc) 0xB6 Send Non-Volatile CACHE command to For Hybrid-HDD
drive. Features register controls what
type of NVCACHE command.
0x00 : Set NV Cache Power Mode
0x01 : RETURN From NV Cache Power Mode
0x10 : Add LBA(s) to NV Cache Pinned
0x11 : Remove LBA(s) From NV Cache
Pinned Set
0x12 : Query NV Cache Pinned Set
0x13 : Query NV Cache Misses
0x14 : Flush NV Cache
rbuf 0xE4 Read Buffer
reset NA reset device – issue soft reset to
controller/drive
rd(c_lba, h, s, b) 0x20 Read sector - PIO
example: rw “palo.dn2”;
scdp 0xF6 Security – Disable password
scep 0xF3 Security - Erase Prepare
sceu 0xF4 Security – Erase Unit
scfl 0xF5 Security – Freeze Lock
sgry opt FAh Scan Grey Code: The 13 bit gray code
at DSP memory address 0205h is read
and displayed. The ACC is set equal
to the 16 bit contents of DSP address
0205h.
[0-255]
TRK_TRK 0x01
TWO_TRK 0x02
ONE_THIRD 0x04
FULL_TRACK 0x08
AVG_SEEK 0x10
WEIGHTED_AVG_SEEK 0x20
All test 0xff
3. “acc” should be set up as repeat
count when we test WEIGHTED_AVG_SEEK.
showdefect(“filenam Displays the defect list to the Must use after burin
e”) file :filename in
createfile(handle, The createfile function creates or
name) opens a file, directory, physical
disk, volume, console buffer, tape
drive, communications resource,
mailslot, or pipe.
- parameter / description
@ handle: Variable to contain an
open handle to the specified file.
@ name: Pointer to a null-terminated
string that specifies the name of the
object to create or open.
- warning : This function can damage
your hard disk drive if you use it
for a wrong purpose.
closehandle(handle) The closehandle function closes an
open object handle.
- parameter / description
@ handle: Handle to an open object.
- warning : This function can damage
your hard disk drive if you use it
for a wrong purpose.
readfile(handle, The readfile function reads data from
lba, count) a file, starting at the position
indicated by the lba.
- parameter / description
@ handle: Handle to the file to be
read.
@ lba : File LBA position to be
read.
@ count : Number of sectors to be
read from the file.
- warning : This function can damage
your hard disk drive if you use it
for a wrong purpose.
writefile(handle, writefile function writes data to a
lba, count) file.
- parameter / description
@ handle: Handle to the file to be
written.
@ lba : File LBA position to be
written.
@ count : Number of sectors to be
written from the file.
- warning : This function can damage
your hard disk drive if you use it
for a wrong purpose.
fig 8-1
(Cube console window)
Assuming Hardware & Software requirement is met, start the CUBE and you will see a screen
similar to fig 8-1.
By default, at the CUBE load time, it will load Compat.DRV. Default driver loaded will run on
on-board interface connector.
Before the users of CUBE can exercise the drive, you must setup the controller first. To do this,
please follow the following steps (if default driver is not desired):
fig 8-2
(scanning for Controller)
fig 8-3
(Selecting Controller)
Once the controller is selected and appropriate driver is loaded, the user can now issue
commands to drive.
Commands can be issued from the command-line, or you can load pre-written Small-C script
and run. To load and run, do the following
void DoSequantialSeek();
void main(void)
{
int counter;
void DoSequantialSeek()
{
int c, h;
int totalTime;
//----------------------------------------------
//- Do Sequential seek (all cyl, then heads)
//----------------------------------------------
for(h=0; h<2;h++) // Head loop
{
totalTime=0; // Initialize totalTime
for(c=0; c< 1000; c++) // We will seek from C=0 to 1000
{
sk(c, h); // Seek
totalTime = totalTime+CMD_TIME; // Accumulate test time
}
cputd(30,h,"SingleTrackSeek: %d microsec", totalTime/c, 0x60);
}
return;
}
void main(void)
{
int counter;
randomize; // Randomize
cmdtime 1; // Enable the clock(microsecond clock
slba 1;
for(i=0;i<loopCount;i++)
{
cputd(5,4,"%ld",i, 0x35); // Show loop count
rand(R0, 0, MAX_LBA); // Generate random LBA
sk(R0, 1); // Seek
totalTime=totalTime+CMD_TIME; // Accumulate the total time
}
cputd(30,4,"RandomSeekTime: %d usec", totalTime/loopCount, 0x60);
return;
}
void main()
{
int lba;
int startLBA;
id(1); // Identify
time;newline;date;newline;
for(lba=startLBA; lba < MAX_LBA; lba=lba+255)
{
rdma(lba, 0, 0, 255); // Do UDMA Read – do buffer compare
// since we enabled bcmp 1
}
time;newline;date;newline;
return;
}
11. VTOOL
11.1. Overview
This is overview of VTOOL Windows version. This document doesn’t explain the whole of
VTOOL usage. This just explains how we can run VTOOL inside W-Cube and how we can run
each menu.
W-Cube includes Windows version of VTOOL. It’s almost similar to Dos version of VTOOL.
When we click “VTOOL” button, VTOOL menu tree will appear inside W-Cube as follows.
Before we click “VTOOL” button, we should connect a drive. If not, we can see some kind of
error message.
Now we can click “DEFECT” menu, and then we can watch Defect Statistical Chart as follows.
If we want to save this data, just hit F9 key and enter appropriate file name.
[NOTE] We can open multiple lists in Windows 2000, XP at the same time.
But we cannot open multiple lists in Windows 98, ME at the same time.
[NOTE] Now, W-Cube supports jpg, gif, bmp file format. To decide which file format we save a
screen as, we just enter appropriate file extension.
11.2. Configuration
Windows VTOOL has some kinds of configuration option. To change them, we can use
configuration dialog box. We can find it in a sub-menu of W-Cube.
Here we can change “MC Access Mode”, some kinds of operation option, identify the drive
under testing, send reset to it.
[NOTE] Windows VTOOL supports MCF file and MCF mode. It’s similar to Dos version MCR
file but the file format is different.
11.3.1. Functions
11.3.2. Examples
4. SPAT
void main()
{
R0 = 100; // Cylinder
R1 = 0; // Head
R2 = 0; // Offtrack
R3 = 1000; // Iteration
R4 = 200; // Src Cyl
R5 = 0; // Src Head
R6 = 10; // Interval
R7 = 10; // # of Cyl
R8 = 0; // Type : Following(0), Random(1), Indicate(2), Rand Indicate(3), Seq
Following(4)
R9 = 1; // Mode : Read(2), Write(1), Real Write(5)
R10 = 0; // TraceData : PERR(0), PRAW(1), USER(2)
R11 = 1; // Srv RCC : OFF(0), ON(1)
R12 = 0; // FFT Avg : TIME(0), FREQ(1)
R13 = 0; // FFT Axis : Lin(0), dB(1)
R14 = 0; // Reserved
R15 = 0; // Reserved
R16 = 0; // Reserved
R17 = 0; // Reserved
R18 = 0; // Reserved
R19 = 0; // Reserved
vtoolgetdata("RUN_SPAT", "", "SPAT.GIF");
return;
}
5. TET
void main()
{
R0 = 100; // Cylinder
R1 = 0; // Head
R2 = 1; // Sector
R3 = 1; // Step
R4 = 0; // User Retry
R5 = 0; // HR Retry
R6 = 5; // Read #
R7 = 40; // Max offt
R8 = 130; // Cell #
R9 = 0; // ECC
R10 = 0; // Adjacent Track
R11 = 1; // DataPtn
R12 = 0; // Reserved
R13 = 0; // Reserved
R14 = 0; // Reserved
R15 = 0; // Reserved
R16 = 0; // Reserved
R17 = 0; // Reserved
R18 = 0; // Reserved
R19 = 0; // Reserved
vtoolgetdata("RUN_TET", "", "TET.GIF");
return;
}
void main()
{
vtoolstepmask(2, 0); // select all step.
vtoolgetdata("GET_ELOG_MAP", "", "ELOG.GIF");
vtoolgetdata("GET_VLIST_MAP", "", "VLIST.GIF");
vtoolgetdata("GET_DLIST_MAP", "", "DLIST.GIF");
void main()
{
vtoolgetdata("", ".", ""); // delete existing output file.
vtoolgetdata("ANALYSIS₩DEFECT", ".", "");
vtoolgetdata("ANALYSIS₩BURN-IN RESULT", ".", "");
vtoolgetdata("ANALYSIS₩WEAK HEAD TEST RESULT", ".", "");
vtoolgetdata("ANALYSIS₩BURN-IN STEP TIME", ".", "");
vtoolgetdata("ANALYSIS₩BURN-IN STEP", ".", "");
vtoolgetdata("ANALYSIS₩SMART RESULT", ".", "");
---------------------------------end of file--------------------------------------