Monday, October 28, 2013
Wednesday, August 28, 2013
Make Beep on x86 machines
http://hi.baidu.com/sfmewmddznjorye/item/afd09b5b867a9aadacc85757
http://jianggmulab.blogspot.com/search?q=beep
/*
* IP port: 0x43
Bits Usage
6 and 7 Select channel :
0 0 = Channel 0
0 1 = Channel 1
1 0 = Channel 2
1 1 = Read-back command (8254 only)
4 and 5 Access mode :
0 0 = Latch count value command
0 1 = Access mode: lobyte only
1 0 = Access mode: hibyte only
1 1 = Access mode: lobyte/hibyte
1 to 3 Operating mode :
0 0 0 = Mode 0 (interrupt on terminal count)
0 0 1 = Mode 1 (hardware re-triggerable one-shot)
0 1 0 = Mode 2 (rate generator)
0 1 1 = Mode 3 (square wave generator)
1 0 0 = Mode 4 (software triggered strobe)
1 0 1 = Mode 5 (hardware triggered strobe)
1 1 0 = Mode 2 (rate generator, same as 010b)
1 1 1 = Mode 3 (square wave generator, same as 011b)
0 BCD/Binary mode: 0 = 16-bit binary, 1 = four-digit BCD
*
*/
static void Beep(void)
{
__asm__ volatile(
// configure Speaker IO controller
// set bit 0, 1 to 1
// IO port: 0x61
"in $0x61, %al\n"
"or $0x3, %al\n"
"out %al, $0x61\n"
// set 8254 timer contol register
// IO port: 0x43
// 0xb6: 1011 0110
// channel2, access mode lo and hi, square wave
"movb $0xb6, %al\n"
"out %al, $0x43\n"
// set the high 8 bits of time2 counter
// IO port: 0x42
"movb $0x0, %al\n"
"out %al, $0x42\n"
// set the low 8 bits of timer2 counter
// IO port: 0x42
// use value $0x0f to firmware attack, high frequency
// use value $0xff to the configuration attack
"movb $0x0f, %al\n"
"out %al, $0x42\n"
);
}
static void UnBeep(void)
{
__asm__ volatile(
// configure speaker IO contorller
// set bit 0 and 1 to 0;
// IO port: 0x61
"in $0x61, %al\n"
"and $0xFC, %al\n"
"out %al, $0x61\n"
);
}
http://jianggmulab.blogspot.com/search?q=beep
/*
* IP port: 0x43
Bits Usage
6 and 7 Select channel :
0 0 = Channel 0
0 1 = Channel 1
1 0 = Channel 2
1 1 = Read-back command (8254 only)
4 and 5 Access mode :
0 0 = Latch count value command
0 1 = Access mode: lobyte only
1 0 = Access mode: hibyte only
1 1 = Access mode: lobyte/hibyte
1 to 3 Operating mode :
0 0 0 = Mode 0 (interrupt on terminal count)
0 0 1 = Mode 1 (hardware re-triggerable one-shot)
0 1 0 = Mode 2 (rate generator)
0 1 1 = Mode 3 (square wave generator)
1 0 0 = Mode 4 (software triggered strobe)
1 0 1 = Mode 5 (hardware triggered strobe)
1 1 0 = Mode 2 (rate generator, same as 010b)
1 1 1 = Mode 3 (square wave generator, same as 011b)
0 BCD/Binary mode: 0 = 16-bit binary, 1 = four-digit BCD
*
*/
static void Beep(void)
{
__asm__ volatile(
// configure Speaker IO controller
// set bit 0, 1 to 1
// IO port: 0x61
"in $0x61, %al\n"
"or $0x3, %al\n"
"out %al, $0x61\n"
// set 8254 timer contol register
// IO port: 0x43
// 0xb6: 1011 0110
// channel2, access mode lo and hi, square wave
"movb $0xb6, %al\n"
"out %al, $0x43\n"
// set the high 8 bits of time2 counter
// IO port: 0x42
"movb $0x0, %al\n"
"out %al, $0x42\n"
// set the low 8 bits of timer2 counter
// IO port: 0x42
// use value $0x0f to firmware attack, high frequency
// use value $0xff to the configuration attack
"movb $0x0f, %al\n"
"out %al, $0x42\n"
);
}
static void UnBeep(void)
{
__asm__ volatile(
// configure speaker IO contorller
// set bit 0 and 1 to 0;
// IO port: 0x61
"in $0x61, %al\n"
"and $0xFC, %al\n"
"out %al, $0x61\n"
);
}
the above code works on any x86 machines. It uses a timer counter existing on all x86 platforms. they all has Programmable interval timer Intel 8253
We use the channal 2
http://wiki.osdev.org/Programmable_Interval_Timer
We use the channal 2
http://wiki.osdev.org/Programmable_Interval_Timer
Thursday, August 22, 2013
redirect stdout and stderr to a file
program [arguments...] 2>&1 | tee -a outfile &
2>&1: directs stderr to stdout
tee receives the content from stdout and write them to a file. -a means append
see man tee for more info.
E.g.,
I want to append the openvz migration log message to a file. This shell script migrates 100 openvz containers in parallel, and wait all of them to finish. It outputs the time at the end.
#!/bin/sh
echo "*********************************************************" | tee -a migrationResult.txt
date | tee -a migrationResult.txt
for i in {1..100}
do
vzmigrate --live -t sr1s1 $i 2>&1 | tee -a migrationResult.txt &
done
wait // wait all of the processes to finish
date | tee -a migrationResult.txt
Tuesday, August 20, 2013
time command
root@server102:/etc/init.d# time ./apache2 start
* Starting web server apache2 [ OK ]
real 0m0.034s
user 0m0.006s
sys 0m0.016s
* Starting web server apache2 [ OK ]
real 0m0.034s
user 0m0.006s
sys 0m0.016s
http://zch051383471952.blogspot.com/2010/01/different-of-real-user-sys-time.html
Real refers to actual elapsed time; User and Sys refer to CPU time used only by the process.
- Real is wall clock time - time from start to finish of the call. This is all elapsed time including time slices used by other processes and time the process spends blocked (for example if it is waiting for I/O to complete).
- User is the amount of CPU time spent in user-mode code (outside the kernel) within the process. This is only actual CPU time used in executing the process. Other processes and time the process spends blocked do not count towards this figure.
- Sys is the amount of CPU time spent in the kernel within the process. This means executing CPU time spent in system calls within the kernel, as opposed to library code, which is still running in user-space. Like 'user', this is only CPU time used by the process.
Monday, August 19, 2013
Access PCI configuration space
Two dedicated I/O ports (to be accessed via IN/OUT instructions):
0xCF8 – selects the address (Bus, Node, Function, Offset)
0xCFC – data port
I/O mapped memory:
PCI configuration space, power management registers, ACPI PM base
Memory mapped:
LAPIC, IOAPIC
More in this presentation:
http://72.3.219.184/conference/2007/papers/rutkowska-joanna-slides.pdf
0xCF8 – selects the address (Bus, Node, Function, Offset)
0xCFC – data port
I/O mapped memory:
PCI configuration space, power management registers, ACPI PM base
Memory mapped:
LAPIC, IOAPIC
More in this presentation:
http://72.3.219.184/conference/2007/papers/rutkowska-joanna-slides.pdf
Tuesday, August 6, 2013
Install httperf on Untuntu
sudo apt-get install httperf
if you get error:
E: Unable to locate package httperf
You need to update your soruce.list
1. generate source list from website:
2. Copy paste source list to /etc/apt/source.list
3. run apt-get update
4. install httperf
More info:
http://forums.debian.net/viewtopic.php?f=10&t=64694
Tuesday, July 30, 2013
Install license for parallel cloud server
parallel cloud server user guide:
http://www.parallels.com/fileadmin/parallels/documents/hosting-cloud-enablement/pcs/Production_Documents/Update_2/Parallels_Cloud_Server_User_s_Guide_03262013.pdf
nstalling the License
Depending on the way you have obtained your Parallels Cloud Server license, the process of
installing the license slightly differs:
• If you have obtained the license in the form of a product key, you can install it on the server
using the -p option of the vzlicload command. For example, you can execute the following
command to install the XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX product key:
# vzlicload -p XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX
Note: You can also use the vzlicload utility to upgrade the license. For example, this may be
necessary if your current license does not support using Parallels Virtual Automation for managing
Parallels servers.
• If you have obtained the license in the form of an activation code, you can install it on the server
using the -a option of the vzlicupdate command. For example:
# vzlicupdate -a XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX
where XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX is your activation code. When executed,
vzlicupdate connects to the Parallels Key Authentication (KA) licensing server and transmits
the specified activation code there. The licensing server, in turn, generates a license file, sends it
back to the server from where the activation code has been dispatched, and automatically
installs it on this server. So, before executing the aforementioned command, make sure that
your Parallels server is connected to the Internet.
If you are activating your installation by means of an activation key, you must have an active Internet
connection to successfully complete the license installation. Otherwise, you will be presented with
the corresponding warning message informing you of the steps you have to take to activate your
license. As a rule, these steps are the following:
1 Visiting the http://www.parallels.com/en/support/virtuozzo/activate web page and activating the
license manually.
2 Providing the following information on this web page:
• In the Product Code field, specify your license activation code.
• In the HWID field, provide the ID of your server.
• In the Enter following digits field, type the digits displayed next to this field.
3 Clicking the ACTIVATE LICENSE button.
If you have entered the correct information on the Virtuozzo License Activation page, you will be
provided with a link to a license file that you should download to and install on the server. For
example, you can run this command to install the obtained license file
# vzlicload -f /etc/vzlicense
This command will install the license file with the name of vzlicense on your server.
http://www.parallels.com/fileadmin/parallels/documents/hosting-cloud-enablement/pcs/Production_Documents/Update_2/Parallels_Cloud_Server_User_s_Guide_03262013.pdf
nstalling the License
Depending on the way you have obtained your Parallels Cloud Server license, the process of
installing the license slightly differs:
• If you have obtained the license in the form of a product key, you can install it on the server
using the -p option of the vzlicload command. For example, you can execute the following
command to install the XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX product key:
# vzlicload -p XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX
Note: You can also use the vzlicload utility to upgrade the license. For example, this may be
necessary if your current license does not support using Parallels Virtual Automation for managing
Parallels servers.
• If you have obtained the license in the form of an activation code, you can install it on the server
using the -a option of the vzlicupdate command. For example:
# vzlicupdate -a XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX
where XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX is your activation code. When executed,
vzlicupdate connects to the Parallels Key Authentication (KA) licensing server and transmits
the specified activation code there. The licensing server, in turn, generates a license file, sends it
back to the server from where the activation code has been dispatched, and automatically
installs it on this server. So, before executing the aforementioned command, make sure that
your Parallels server is connected to the Internet.
If you are activating your installation by means of an activation key, you must have an active Internet
connection to successfully complete the license installation. Otherwise, you will be presented with
the corresponding warning message informing you of the steps you have to take to activate your
license. As a rule, these steps are the following:
1 Visiting the http://www.parallels.com/en/support/virtuozzo/activate web page and activating the
license manually.
2 Providing the following information on this web page:
• In the Product Code field, specify your license activation code.
• In the HWID field, provide the ID of your server.
• In the Enter following digits field, type the digits displayed next to this field.
3 Clicking the ACTIVATE LICENSE button.
If you have entered the correct information on the Virtuozzo License Activation page, you will be
provided with a link to a license file that you should download to and install on the server. For
example, you can run this command to install the obtained license file
# vzlicload -f /etc/vzlicense
This command will install the license file with the name of vzlicense on your server.
Subscribe to:
Posts (Atom)