Beep音とは?
-> 電子機器が通知のために発する音
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h> // for usleep
#include <sys/io.h> // for inb(バイトデータを呼び出し), outb(バイトデータを出力)
static void beep_on(void){
outb(inb(0x61)|3, 0x61); // 0x61はa
}
static void beep_off(void){
outb(inb(0x61)&0xfc, 0x61);
}
int main(int argc, char *argv[]){
uint32_t count; // 32ビットの符号なし整数型
if((ioperm(0x0040, 4, 1)) ||(ioperm(0x0061, 1, 1))){ //iopermはポートの入出力を許可
perror("ioperm");
return 1;
}
count = 1193180 / 1000;
outb(0xb6, 0x43);
outb(count & 0xff, 0x42);
outb((count>>8) & 0xff, 0x42);
beep_on();
usleep(1000000);
beep_off();
return 0;
}
$ ./main
ioperm: Operation not permitted
ん? 何故だ?