You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In \verb|Makefile|, \verb|$(CURDIR)| can set to the absolute pathname of the current working directory(after all \verb|-C| options are processed, if any).
267
+
In \verb|Makefile|, \verb|$(CURDIR)| can be set to the absolute pathname of the current working directory(after all \verb|-C| options are processed, if any).
268
268
See more about \verb|CURDIR| in \href{https://www.gnu.org/software/make/manual/make.html}{GNU make manual}.
Then, we can use \verb|-p| flag to print out the environment variable values from the Makefile.
295
+
Then, we can use the \verb|-p| flag to print out the environment variable values from the Makefile.
296
296
297
297
\begin{verbatim}
298
298
$ make -p | grep PWD
@@ -806,13 +806,13 @@ \subsection{Name Space}
806
806
\subsection{Code space}
807
807
\label{sec:codespace}
808
808
Memory management is a very complicated subject and the majority of O'Reilly's \href{https://www.oreilly.com/library/view/understanding-the-linux/0596005652/}{Understanding The Linux Kernel} exclusively covers memory management!
809
-
We are not setting out to be experts on memory managements, but we do need to know a couple of facts to even begin worrying about writing real modules.
809
+
We are not setting out to be experts on memory management, but we do need to know a couple of facts to even begin worrying about writing real modules.
810
810
811
811
If you have not thought about what a segfault really means, you may be surprised to hear that pointers do not actually point to memory locations.
812
812
Not real ones, anyway.
813
813
When a process is created, the kernel sets aside a portion of real physical memory and hands it to the process to use for its executing code, variables, stack, heap and other things which a computer scientist would know about.
814
814
This memory begins with 0x00000000 and extends up to whatever it needs to be.
815
-
Since the memory space for any two processes do not overlap, every process that can access a memory address, say 0xbffff978, would be accessing a different location in real physical memory! The processes would be accessing an index named 0xbffff978 which points to some kind of offset into the region of memory set aside for that particular process.
815
+
Since the memory space for any two processes does not overlap, every process that can access a memory address, say 0xbffff978, would be accessing a different location in real physical memory! The processes would be accessing an index named 0xbffff978 which points to some kind of offset into the region of memory set aside for that particular process.
816
816
For the most part, a process like our Hello, World program can't access the space of another process, although there are ways which we will talk about later.
817
817
818
818
The kernel has its own space of memory as well. Since a module is code which can be dynamically inserted and removed in the kernel (as opposed to a semi-autonomous object), it shares the kernel's codespace rather than having its own.
Because we don't get called when the file is opened or closed, there's nowhere for us to put \cpp|try_module_get| and \cpp|module_put| in this module, and if the file is opened and then the module is removed, there's no way to avoid the consequences.
1150
1150
1151
-
Here a simple example showing how to use a \verb|/proc| file.
1151
+
Here is a simple example showing how to use a \verb|/proc| file.
1152
1152
This is the HelloWorld for the \verb|/proc| filesystem.
1153
1153
There are three parts: create the file \verb|/proc/helloworld| in the function \cpp|init_module|, return a value (and a buffer) when the file \verb|/proc/helloworld| is read in the callback function \cpp|procfile_read|, and delete the file \verb|/proc/helloworld| in the function \cpp|cleanup_module|.
1154
1154
@@ -1294,7 +1294,7 @@ \section{sysfs: Interacting with your module}
1294
1294
Attributes can be exported for kobjects in the form of regular files in the filesystem.
1295
1295
Sysfs forwards file I/O operations to methods defined for the attributes, providing a means to read and write kernel attributes.
1296
1296
1297
-
An attribute definition in simply:
1297
+
A simple attribute definition:
1298
1298
1299
1299
\begin{code}
1300
1300
struct attribute {
@@ -1322,7 +1322,7 @@ \section{sysfs: Interacting with your module}
To read or write attributes, \cpp|show()| or \cpp|store()| method must be specified when declaring the attribute.
1325
+
To read or write attributes, the \cpp|show()| or \cpp|store()| method must be specified when declaring the attribute.
1326
1326
For the common cases \src{include/linux/sysfs.h} provides convenience macros (\cpp|__ATTR|, \cpp|__ATTR_RO|, \cpp|__ATTR_WO|, etc.) to make defining attributes easier as well as making code more concise and readable.
1327
1327
1328
1328
An example of a hello world module which includes the creation of a variable accessible via sysfs is given below.
0 commit comments