Devilzc0de Forum Follow @devilzc0de
  • Home
  • Hacking
  • Networking
  • Programming
  • O.S
  • Server
  • Tweets
  • Search
  • Member List
  • Calendar
Current time: 05-21-2013, 03:36 PM Hello There, Guest! (Login — Register)
Devilzc0de Forum › Information Technology › Programming › C / C++ v
« Previous 1 ... 5 6 7 8 9 ... 15 Next »

[dummie]basic programming kernel modul

Home General Computer Multimedia Business Lounge

Post Reply 
Tweet
Threaded Mode | Linear Mode
[dummie]basic programming kernel modul
02-29-2012, 01:35 AM (This post was last modified: 02-29-2012 01:45 AM by alessandra.)
Post: #1
alessandra Offline
i'm so lonely broken angel
Posts: 196
Joined: Feb 2012
Reputation: 41
[dummie]basic programming kernel modul
PENGANTAR
---------

Kernel module adalah potongan kode yang dapat di load dan unload ke dalam kernel saat ada request dari user
program tersebut akan memperluas fungstionalitas kernel tanpa perlu reboot sistem.
Sebagai contoh,satu jenis modul device buat driver yang memungkinkan kernel untuk mengakses hardware untuk terhubung ke komputer.
tanpa modul,kita harus bisa membuat kernel monolitik agar dapat menambahkan fungsi baru yang terhubung langsung di dalam kernel
selain memiliki memori kernel yang lebih besar,kelemahannya adalah kita akan di minta terus untuk
reboot kernel ketika kita menginginkan fungsi terbaru di dalamnya.

START
-----

Modul kernel seharusnya memiliki setidaknya 2fungsi utama,yaitu :
"start"(initialisasi) untuk pemanggilan fungsi terhadap init_module()
dan pemanggilan fungsi cleanup_module()
fungsi tersebut biasanya di panggil oleh module insmodded ke dalam kernel tadi sesaat sebelum
rmmoded di jalankan,dan menggunakan init_module() dan cleanup_module() untuk memulai dan mengakhiri fungsinya
(untuk lebih jelasnya tentang insmodded dan rmmoded silahkan bergoogling)
biasanya,init_module() di gunakan untuk register handler langsung dengan kernel atau mengganti salah satu
fungsi kernel dengan kode itu sendiri (tetap melakukan pemanggilan fungsi asli)
setiap modul kernel di haruskan menyertakan linux/module.h
guna ekspansi makro yang akan menyempurnakan perintah printk()log level
dan KERN_ALERT

berikut contoh kodingan simple untuk kernel module

#include <linux/module.h>
#include <linux/kernel.h>

int init_module(void)
{
printk(KERN_INFO "hai unyu\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "fufufu\n");
}
coba simpan dengan nama semu.c

cara kompilenya pun sedikit berbeda dari aplikasi userspace biasa
yang disimpan dalam Makefile,walaupun sedikit nampak terorganisir,pengaturan berlebihan yang banyak
terakumulasi dalam sublevel Makefiles yang cukup besar memakan memory userspace.

sekarang mari kita mencoba kompilasi code program dengan perintah :
obj-m += semu.o
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

lalu ketikan perintah :
alessa@nullsoft:~/lkm# make

dan akan menampilkan output,seperti berikut :

make −C /lib/modules/2.6.11/build M=/root/lkm modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.35-22'
CC [M] /root/lkm/semu.c
Building modules, stage 2.
MODPOST

pemanggilan kbuild dan build adalah proses untuk modul loadable eksternal yang
sekarang adalah sepenuhnya terintegrasi dalam kernel standar untuk membangun mekanisme kerjanya
[*next lanjut ya,tutorialnya alessa udah ngantuk nih mau bobo..]


Referensi :
http://en.wikipedia.org/wiki/Loadable_kernel_module
(Loadable kernel module)

http://techpubs.sgi.com/library/tpl/cgi-...ode20.html
(Developer/Lx_KMPG system call )

http://140.120.7.20/LinuxRef/LinuxArticl...mming.html
(introducing linux kernel module)

http://www.stillhq.com/pdfdb/000489/data.pdf
(introducing linux kernel programming with module)

http://www.linuxchix.org/content/courses...ng/lesson8
(your first kernel module)

mohon tambahan ilmunya ngemis untuk saya yang masih newbie
semoga berkenan memberikan tambahan mimisan
salam kenal pulawawa
Find all posts by this user
Quote this message in a reply
 Reputed by :  anko_kum4ru(+1) , ditatompel(+1) , ev1lut10n(+1)
02-29-2012, 01:43 AM
Post: #2
ditatompel Offline
Administrator
*******
Administrators
Posts: 2,168
Joined: Dec 2010
Reputation: 367
RE: [dummie]basic programming kernel modul
:wah.. bikin mimisan nih tutorialnya... mimisan
keren mbak.. mantap
dits ijin pelajari dulu belajar
Find all posts by this user
Quote this message in a reply
02-29-2012, 01:44 AM
Post: #3
badwolves1986 [RJ] Offline
Staf Registrasi DIC
RJ
Posts: 2,881
Joined: Oct 2010
Reputation: 91
RE: [dummie]basic programming kernel modul
widih keren tutorial nya mantap
Find all posts by this user
Quote this message in a reply
02-29-2012, 01:46 AM
Post: #4
alessandra Offline
i'm so lonely broken angel
Posts: 196
Joined: Feb 2012
Reputation: 41
RE: [dummie]basic programming kernel modul
bru belajar mas bro malu
Find all posts by this user
Quote this message in a reply
02-29-2012, 02:10 AM
Post: #5
ev1lut10n Offline
./Devilz Officer
Posts: 239
Joined: Aug 2011
Reputation: 82
RE: [dummie]basic programming kernel modul
mantapmantapmantap keren cewe2 di sini mantapmantap
Find all posts by this user
Quote this message in a reply
03-21-2012, 06:49 AM (This post was last modified: 03-21-2012 06:50 AM by x.intruders.)
Post: #6
x.intruders Offline
paduka kecil
Posts: 527
Joined: Dec 2010
Reputation: 57
RE: [dummie]basic programming kernel modul
(02-29-2012 01:43 AM)ditatompel Wrote:  keren mbak.. mantap

(02-29-2012 02:10 AM)ev1lut10n Wrote:  mantapmantapmantap keren cewe2 di sini mantapmantap

itu cew ato cow sih om dit?? bingung
Visit this user's website Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Topic Tools
Topic Link :
BBCode :
HTML Code :
View a Printable Version Send Thread to a Friend Subscribe to this thread
Submit Google Submit Face book Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Tutor] Nembak Cewek di C Basic [Dari om Nisan] Zeattacker 12 360 12-20-2012 03:45 PM
Last Post: ubuntux
  Some Kernel Coding Style in C (incomplete) cr0security 4 283 07-20-2012 10:03 PM
Last Post: monyett
  Sekilas VFS pada linux kernel 2.4 ev1lut10n 2 505 07-14-2012 09:44 PM
Last Post: cbrnewbie
  [Tutor] Network Programming jackerp 8 563 03-02-2012 10:37 AM
Last Post: jackerp
  [Solved] C Programming d3m3nt012 8 595 01-16-2012 03:20 AM
Last Post: d3m3nt012
  IOCTL Programming Under Linux Kernel 2.6 ev1lut10n 3 670 11-25-2011 01:01 PM
Last Post: ketek
  TCP Socket Programming dengan Bahasa C (Linux) mywisdom 8 1,905 04-20-2011 01:16 AM
Last Post: mywisdom
  Loadable Kernel Module (part 1) mywisdom 1 839 10-01-2010 02:00 PM
Last Post: blu3k1d5

Users Browsing
1 Guest(s)

  • Contact Us
  • devilzc0de
  • Return to Top
  • Mobile Version
  • RSS Syndication
  • Help
Current time: 05-21-2013, 03:36 PM Powered By MyBB, © 2002-2013 MyBB Group. Theme created by Justin S. | Mixed By Chaer.Newbie | Fixed By Aditya

USING THIS SITE INDICATES THAT YOU HAVE READ AND ACCEPT OUR TERMS. IF YOU DO NOT ACCEPT THESE TERMS, YOU ARE NOT AUTHORIZED TO USE THIS SITE