€•}„Œsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ!/translations/zh_CN/arch/x86/mtrr”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ!/translations/zh_TW/arch/x86/mtrr”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ!/translations/it_IT/arch/x86/mtrr”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ!/translations/ja_JP/arch/x86/mtrr”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ!/translations/ko_KR/arch/x86/mtrr”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ!/translations/pt_BR/arch/x86/mtrr”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ!/translations/sp_SP/arch/x86/mtrr”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…””}”hh·sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hµhhh²hh³Œ;/var/lib/git/docbuild/linux/Documentation/arch/x86/mtrr.rst”h´KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ)MTRR (Memory Type Range Register) control”h]”hŒ)MTRR (Memory Type Range Register) control”…””}”(hhÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhhÊh²hh³hÇh´KubhŒ field_list”“”)”}”(hhh]”hŒfield”“”)”}”(hhh]”(hŒ field_name”“”)”}”(hŒAuthors”h]”hŒAuthors”…””}”(hhéh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhhäh³hÇh´KubhŒ field_body”“”)”}”(hŒs- Richard Gooch - 3 Jun 1999 - Luis R. Rodriguez - April 9, 2015 ”h]”hŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒ1Richard Gooch - 3 Jun 1999”h]”hŒ paragraph”“”)”}”(hjh]”(hŒRichard Gooch <”…””}”(hj h²hh³Nh´NubhŒ reference”“”)”}”(hŒrgooch@atnf.csiro.au”h]”hŒrgooch@atnf.csiro.au”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:rgooch@atnf.csiro.au”uh1jhj ubhŒ> - 3 Jun 1999”…””}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Khjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhhÿubj)”}”(hŒ=Luis R. Rodriguez - April 9, 2015 ”h]”j )”}”(hŒ;Luis R. Rodriguez - April 9, 2015”h]”(hŒLuis R. Rodriguez <”…””}”(hj7h²hh³Nh´Nubj)”}”(hŒmcgrof@do-not-panic.com”h]”hŒmcgrof@do-not-panic.com”…””}”(hj?h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:mcgrof@do-not-panic.com”uh1jhj7ubhŒ> - April 9, 2015”…””}”(hj7h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Khj3ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhhÿubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1hýh³hÇh´Khhùubah}”(h]”h ]”h"]”h$]”h&]”uh1h÷hhäubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÇh´Khhßh²hubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhhÊh²hh³hÇh´KubhÉ)”}”(hhh]”(hÎ)”}”(hŒPhasing out MTRR use”h]”hŒPhasing out MTRR use”…””}”(hj|h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjyh²hh³hÇh´K ubj )”}”(hX+MTRR use is replaced on modern x86 hardware with PAT. Direct MTRR use by drivers on Linux is now completely phased out, device drivers should use arch_phys_wc_add() in combination with ioremap_wc() to make MTRR effective on non-PAT systems while a no-op but equally effective on PAT enabled systems.”h]”hX+MTRR use is replaced on modern x86 hardware with PAT. Direct MTRR use by drivers on Linux is now completely phased out, device drivers should use arch_phys_wc_add() in combination with ioremap_wc() to make MTRR effective on non-PAT systems while a no-op but equally effective on PAT enabled systems.”…””}”(hjŠh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Khjyh²hubj )”}”(hXCEven if Linux does not use MTRRs directly, some x86 platform firmware may still set up MTRRs early before booting the OS. They do this as some platform firmware may still have implemented access to MTRRs which would be controlled and handled by the platform firmware directly. An example of platform use of MTRRs is through the use of SMI handlers, one case could be for fan control, the platform code would need uncachable access to some of its fan control registers. Such platform access does not need any Operating System MTRR code in place other than mtrr_type_lookup() to ensure any OS specific mapping requests are aligned with platform MTRR setup. If MTRRs are only set up by the platform firmware code though and the OS does not make any specific MTRR mapping requests mtrr_type_lookup() should always return MTRR_TYPE_INVALID.”h]”hXCEven if Linux does not use MTRRs directly, some x86 platform firmware may still set up MTRRs early before booting the OS. They do this as some platform firmware may still have implemented access to MTRRs which would be controlled and handled by the platform firmware directly. An example of platform use of MTRRs is through the use of SMI handlers, one case could be for fan control, the platform code would need uncachable access to some of its fan control registers. Such platform access does not need any Operating System MTRR code in place other than mtrr_type_lookup() to ensure any OS specific mapping requests are aligned with platform MTRR setup. If MTRRs are only set up by the platform firmware code though and the OS does not make any specific MTRR mapping requests mtrr_type_lookup() should always return MTRR_TYPE_INVALID.”…””}”(hj˜h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Khjyh²hubj )”}”(hŒ4For details refer to Documentation/arch/x86/pat.rst.”h]”hŒ4For details refer to Documentation/arch/x86/pat.rst.”…””}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Khjyh²hubhŒtip”“”)”}”(hX•On Intel P6 family processors (Pentium Pro, Pentium II and later) the Memory Type Range Registers (MTRRs) may be used to control processor access to memory ranges. This is most useful when you have a video (VGA) card on a PCI or AGP bus. Enabling write-combining allows bus write transfers to be combined into a larger transfer before bursting over the PCI/AGP bus. This can increase performance of image write operations 2.5 times or more. The Cyrix 6x86, 6x86MX and M II processors have Address Range Registers (ARRs) which provide a similar functionality to MTRRs. For these, the ARRs are used to emulate the MTRRs. The AMD K6-2 (stepping 8 and above) and K6-3 processors have two MTRRs. These are supported. The AMD Athlon family provide 8 Intel style MTRRs. The Centaur C6 (WinChip) has 8 MCRs, allowing write-combining. These are supported. The VIA Cyrix III and VIA C3 CPUs offer 8 Intel style MTRRs. The CONFIG_MTRR option creates a /proc/mtrr file which may be used to manipulate your MTRRs. Typically the X server should use this. This should have a reasonably generic interface so that similar control registers on other processors can be easily supported.”h]”(j )”}”(hX¸On Intel P6 family processors (Pentium Pro, Pentium II and later) the Memory Type Range Registers (MTRRs) may be used to control processor access to memory ranges. This is most useful when you have a video (VGA) card on a PCI or AGP bus. Enabling write-combining allows bus write transfers to be combined into a larger transfer before bursting over the PCI/AGP bus. This can increase performance of image write operations 2.5 times or more.”h]”hX¸On Intel P6 family processors (Pentium Pro, Pentium II and later) the Memory Type Range Registers (MTRRs) may be used to control processor access to memory ranges. This is most useful when you have a video (VGA) card on a PCI or AGP bus. Enabling write-combining allows bus write transfers to be combined into a larger transfer before bursting over the PCI/AGP bus. This can increase performance of image write operations 2.5 times or more.”…””}”(hjºh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K"hj¶ubj )”}”(hŒ±The Cyrix 6x86, 6x86MX and M II processors have Address Range Registers (ARRs) which provide a similar functionality to MTRRs. For these, the ARRs are used to emulate the MTRRs.”h]”hŒ±The Cyrix 6x86, 6x86MX and M II processors have Address Range Registers (ARRs) which provide a similar functionality to MTRRs. For these, the ARRs are used to emulate the MTRRs.”…””}”(hjÈh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K*hj¶ubj )”}”(hŒThe AMD K6-2 (stepping 8 and above) and K6-3 processors have two MTRRs. These are supported. The AMD Athlon family provide 8 Intel style MTRRs.”h]”hŒThe AMD K6-2 (stepping 8 and above) and K6-3 processors have two MTRRs. These are supported. The AMD Athlon family provide 8 Intel style MTRRs.”…””}”(hjÖh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K.hj¶ubj )”}”(hŒSThe Centaur C6 (WinChip) has 8 MCRs, allowing write-combining. These are supported.”h]”hŒSThe Centaur C6 (WinChip) has 8 MCRs, allowing write-combining. These are supported.”…””}”(hjäh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K2hj¶ubj )”}”(hŒ! /proc/mtrr”h]”hŒI# echo "base=0xf8000000 size=0x400000 type=write-combining" >! /proc/mtrr”…””}”hjYsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j;h³hÇh´KNhj*h²hubj )”}”(hŒor if you use bash::”h]”hŒor if you use bash:”…””}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´KPhj*h²hubj<)”}”(hŒI# echo "base=0xf8000000 size=0x400000 type=write-combining" >| /proc/mtrr”h]”hŒI# echo "base=0xf8000000 size=0x400000 type=write-combining" >| /proc/mtrr”…””}”hjusbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j;h³hÇh´KRhj*h²hubj )”}”(hŒAnd the result thereof::”h]”hŒAnd the result thereof:”…””}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´KThj*h²hubj<)”}”(hŒÛ% cat /proc/mtrr reg00: base=0x00000000 ( 0MB), size= 128MB: write-back, count=1 reg01: base=0x08000000 ( 128MB), size= 64MB: write-back, count=1 reg02: base=0xf8000000 (3968MB), size= 4MB: write-combining, count=1”h]”hŒÛ% cat /proc/mtrr reg00: base=0x00000000 ( 0MB), size= 128MB: write-back, count=1 reg01: base=0x08000000 ( 128MB), size= 64MB: write-back, count=1 reg02: base=0xf8000000 (3968MB), size= 4MB: write-combining, count=1”…””}”hj‘sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j;h³hÇh´KVhj*h²hubj )”}”(hŒôThis is for video RAM at base address 0xf8000000 and size 4 megabytes. To find out your base address, you need to look at the output of your X server, which tells you where the linear framebuffer address is. A typical line that you may get is::”h]”hŒóThis is for video RAM at base address 0xf8000000 and size 4 megabytes. To find out your base address, you need to look at the output of your X server, which tells you where the linear framebuffer address is. A typical line that you may get is:”…””}”(hjŸh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K[hj*h²hubj<)”}”(hŒ/(--) S3: PCI: 968 rev 0, Linear FB @ 0xf8000000”h]”hŒ/(--) S3: PCI: 968 rev 0, Linear FB @ 0xf8000000”…””}”hj­sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j;h³hÇh´K`hj*h²hubj )”}”(hŒ©Note that you should only use the value from the X server, as it may move the framebuffer base address, so the only value you can trust is that reported by the X server.”h]”hŒ©Note that you should only use the value from the X server, as it may move the framebuffer base address, so the only value you can trust is that reported by the X server.”…””}”(hj»h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Kbhj*h²hubj )”}”(hŒmTo find out the size of your framebuffer (what, you don't actually know?), the following line will tell you::”h]”hŒnTo find out the size of your framebuffer (what, you don’t actually know?), the following line will tell you:”…””}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Kfhj*h²hubj<)”}”(hŒ(--) S3: videoram: 4096k”h]”hŒ(--) S3: videoram: 4096k”…””}”hj×sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j;h³hÇh´Kihj*h²hubj )”}”(hXHThat's 4 megabytes, which is 0x400000 bytes (in hexadecimal). A patch is being written for XFree86 which will make this automatic: in other words the X server will manipulate /proc/mtrr using the ioctl() interface, so users won't have to do anything. If you use a commercial X server, lobby your vendor to add support for MTRRs.”h]”hXLThat’s 4 megabytes, which is 0x400000 bytes (in hexadecimal). A patch is being written for XFree86 which will make this automatic: in other words the X server will manipulate /proc/mtrr using the ioctl() interface, so users won’t have to do anything. If you use a commercial X server, lobby your vendor to add support for MTRRs.”…””}”(hjåh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Kkhj*h²hubeh}”(h]”Œreading-mtrrs-from-the-shell”ah ]”h"]”Œreading mtrrs from the shell”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´KEubhÉ)”}”(hhh]”(hÎ)”}”(hŒCreating overlapping MTRRs”h]”hŒCreating overlapping MTRRs”…””}”(hjþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjûh²hh³hÇh´Ksubj<)”}”(hŒ‡%echo "base=0xfb000000 size=0x1000000 type=write-combining" >/proc/mtrr %echo "base=0xfb000000 size=0x1000 type=uncachable" >/proc/mtrr”h]”hŒ‡%echo "base=0xfb000000 size=0x1000000 type=write-combining" >/proc/mtrr %echo "base=0xfb000000 size=0x1000 type=uncachable" >/proc/mtrr”…””}”hj sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j;h³hÇh´Kvhjûh²hubj )”}”(hŒAnd the results::”h]”hŒAnd the results:”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Kyhjûh²hubj<)”}”(hŒÛ% cat /proc/mtrr reg00: base=0x00000000 ( 0MB), size= 64MB: write-back, count=1 reg01: base=0xfb000000 (4016MB), size= 16MB: write-combining, count=1 reg02: base=0xfb000000 (4016MB), size= 4kB: uncachable, count=1”h]”hŒÛ% cat /proc/mtrr reg00: base=0x00000000 ( 0MB), size= 64MB: write-back, count=1 reg01: base=0xfb000000 (4016MB), size= 16MB: write-combining, count=1 reg02: base=0xfb000000 (4016MB), size= 4kB: uncachable, count=1”…””}”hj(sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j;h³hÇh´K{hjûh²hubj )”}”(hŒŽSome cards (especially Voodoo Graphics boards) need this 4 kB area excluded from the beginning of the region because it is used for registers.”h]”hŒŽSome cards (especially Voodoo Graphics boards) need this 4 kB area excluded from the beginning of the region because it is used for registers.”…””}”(hj6h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K€hjûh²hubj )”}”(hŒoNOTE: You can only create type=uncachable region, if the first region that you created is type=write-combining.”h]”hŒoNOTE: You can only create type=uncachable region, if the first region that you created is type=write-combining.”…””}”(hjDh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K„hjûh²hubeh}”(h]”Œcreating-overlapping-mtrrs”ah ]”h"]”Œcreating overlapping mtrrs”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´KsubhÉ)”}”(hhh]”(hÎ)”}”(hŒRemoving MTRRs from the C-shel”h]”hŒRemoving MTRRs from the C-shel”…””}”(hj]h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjZh²hh³hÇh´K‰ubj<)”}”(hŒ % echo "disable=2" >! /proc/mtrr”h]”hŒ % echo "disable=2" >! /proc/mtrr”…””}”hjksbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j;h³hÇh´KŒhjZh²hubj )”}”(hŒor using bash::”h]”hŒor using bash:”…””}”(hjyh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´KŽhjZh²hubj<)”}”(hŒ % echo "disable=2" >| /proc/mtrr”h]”hŒ % echo "disable=2" >| /proc/mtrr”…””}”hj‡sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j;h³hÇh´KhjZh²hubeh}”(h]”Œremoving-mtrrs-from-the-c-shel”ah ]”h"]”Œremoving mtrrs from the c-shel”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K‰ubhÉ)”}”(hhh]”(hÎ)”}”(hŒ.Reading MTRRs from a C program using ioctl()'s”h]”hŒ0Reading MTRRs from a C program using ioctl()’s”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjh²hh³hÇh´K”ubj<)”}”(hXš /* mtrr-show.c Source file for mtrr-show (example program to show MTRRs using ioctl()'s) Copyright (C) 1997-1998 Richard Gooch This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Richard Gooch may be reached by email at rgooch@atnf.csiro.au The postal address is: Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. */ /* This program will use an ioctl() on /proc/mtrr to show the current MTRR settings. This is an alternative to reading /proc/mtrr. Written by Richard Gooch 17-DEC-1997 Last updated by Richard Gooch 2-MAY-1998 */ #include #include #include #include #include #include #include #include #include #define TRUE 1 #define FALSE 0 #define ERRSTRING strerror (errno) static char *mtrr_strings[MTRR_NUM_TYPES] = { "uncachable", /* 0 */ "write-combining", /* 1 */ "?", /* 2 */ "?", /* 3 */ "write-through", /* 4 */ "write-protect", /* 5 */ "write-back", /* 6 */ }; int main () { int fd; struct mtrr_gentry gentry; if ( ( fd = open ("/proc/mtrr", O_RDONLY, 0) ) == -1 ) { if (errno == ENOENT) { fputs ("/proc/mtrr not found: not supported or you don't have a PPro?\n", stderr); exit (1); } fprintf (stderr, "Error opening /proc/mtrr\t%s\n", ERRSTRING); exit (2); } for (gentry.regnum = 0; ioctl (fd, MTRRIOC_GET_ENTRY, &gentry) == 0; ++gentry.regnum) { if (gentry.size < 1) { fprintf (stderr, "Register: %u disabled\n", gentry.regnum); continue; } fprintf (stderr, "Register: %u base: 0x%lx size: 0x%lx type: %s\n", gentry.regnum, gentry.base, gentry.size, mtrr_strings[gentry.type]); } if (errno == EINVAL) exit (0); fprintf (stderr, "Error doing ioctl(2) on /dev/mtrr\t%s\n", ERRSTRING); exit (3); } /* End Function main */”h]”hXš /* mtrr-show.c Source file for mtrr-show (example program to show MTRRs using ioctl()'s) Copyright (C) 1997-1998 Richard Gooch This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Richard Gooch may be reached by email at rgooch@atnf.csiro.au The postal address is: Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. */ /* This program will use an ioctl() on /proc/mtrr to show the current MTRR settings. This is an alternative to reading /proc/mtrr. Written by Richard Gooch 17-DEC-1997 Last updated by Richard Gooch 2-MAY-1998 */ #include #include #include #include #include #include #include #include #include #define TRUE 1 #define FALSE 0 #define ERRSTRING strerror (errno) static char *mtrr_strings[MTRR_NUM_TYPES] = { "uncachable", /* 0 */ "write-combining", /* 1 */ "?", /* 2 */ "?", /* 3 */ "write-through", /* 4 */ "write-protect", /* 5 */ "write-back", /* 6 */ }; int main () { int fd; struct mtrr_gentry gentry; if ( ( fd = open ("/proc/mtrr", O_RDONLY, 0) ) == -1 ) { if (errno == ENOENT) { fputs ("/proc/mtrr not found: not supported or you don't have a PPro?\n", stderr); exit (1); } fprintf (stderr, "Error opening /proc/mtrr\t%s\n", ERRSTRING); exit (2); } for (gentry.regnum = 0; ioctl (fd, MTRRIOC_GET_ENTRY, &gentry) == 0; ++gentry.regnum) { if (gentry.size < 1) { fprintf (stderr, "Register: %u disabled\n", gentry.regnum); continue; } fprintf (stderr, "Register: %u base: 0x%lx size: 0x%lx type: %s\n", gentry.regnum, gentry.base, gentry.size, mtrr_strings[gentry.type]); } if (errno == EINVAL) exit (0); fprintf (stderr, "Error doing ioctl(2) on /dev/mtrr\t%s\n", ERRSTRING); exit (3); } /* End Function main */”…””}”hj®sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j;h³hÇh´K—hjh²hubeh}”(h]”Œ,reading-mtrrs-from-a-c-program-using-ioctl-s”ah ]”h"]”Œ.reading mtrrs from a c program using ioctl()'s”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K”ubhÉ)”}”(hhh]”(hÎ)”}”(hŒ1Creating MTRRs from a C programme using ioctl()'s”h]”hŒ3Creating MTRRs from a C programme using ioctl()’s”…””}”(hjÇh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjÄh²hh³hÇh´K÷ubj<)”}”(hX /* mtrr-add.c Source file for mtrr-add (example programme to add an MTRRs using ioctl()) Copyright (C) 1997-1998 Richard Gooch This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Richard Gooch may be reached by email at rgooch@atnf.csiro.au The postal address is: Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. */ /* This programme will use an ioctl() on /proc/mtrr to add an entry. The first available mtrr is used. This is an alternative to writing /proc/mtrr. Written by Richard Gooch 17-DEC-1997 Last updated by Richard Gooch 2-MAY-1998 */ #include #include #include #include #include #include #include #include #include #include #define TRUE 1 #define FALSE 0 #define ERRSTRING strerror (errno) static char *mtrr_strings[MTRR_NUM_TYPES] = { "uncachable", /* 0 */ "write-combining", /* 1 */ "?", /* 2 */ "?", /* 3 */ "write-through", /* 4 */ "write-protect", /* 5 */ "write-back", /* 6 */ }; int main (int argc, char **argv) { int fd; struct mtrr_sentry sentry; if (argc != 4) { fprintf (stderr, "Usage:\tmtrr-add base size type\n"); exit (1); } sentry.base = strtoul (argv[1], NULL, 0); sentry.size = strtoul (argv[2], NULL, 0); for (sentry.type = 0; sentry.type < MTRR_NUM_TYPES; ++sentry.type) { if (strcmp (argv[3], mtrr_strings[sentry.type]) == 0) break; } if (sentry.type >= MTRR_NUM_TYPES) { fprintf (stderr, "Illegal type: \"%s\"\n", argv[3]); exit (2); } if ( ( fd = open ("/proc/mtrr", O_WRONLY, 0) ) == -1 ) { if (errno == ENOENT) { fputs ("/proc/mtrr not found: not supported or you don't have a PPro?\n", stderr); exit (3); } fprintf (stderr, "Error opening /proc/mtrr\t%s\n", ERRSTRING); exit (4); } if (ioctl (fd, MTRRIOC_ADD_ENTRY, &sentry) == -1) { fprintf (stderr, "Error doing ioctl(2) on /dev/mtrr\t%s\n", ERRSTRING); exit (5); } fprintf (stderr, "Sleeping for 5 seconds so you can see the new entry\n"); sleep (5); close (fd); fputs ("I've just closed /proc/mtrr so now the new entry should be gone\n", stderr); } /* End Function main */”h]”hX /* mtrr-add.c Source file for mtrr-add (example programme to add an MTRRs using ioctl()) Copyright (C) 1997-1998 Richard Gooch This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Richard Gooch may be reached by email at rgooch@atnf.csiro.au The postal address is: Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. */ /* This programme will use an ioctl() on /proc/mtrr to add an entry. The first available mtrr is used. This is an alternative to writing /proc/mtrr. Written by Richard Gooch 17-DEC-1997 Last updated by Richard Gooch 2-MAY-1998 */ #include #include #include #include #include #include #include #include #include #include #define TRUE 1 #define FALSE 0 #define ERRSTRING strerror (errno) static char *mtrr_strings[MTRR_NUM_TYPES] = { "uncachable", /* 0 */ "write-combining", /* 1 */ "?", /* 2 */ "?", /* 3 */ "write-through", /* 4 */ "write-protect", /* 5 */ "write-back", /* 6 */ }; int main (int argc, char **argv) { int fd; struct mtrr_sentry sentry; if (argc != 4) { fprintf (stderr, "Usage:\tmtrr-add base size type\n"); exit (1); } sentry.base = strtoul (argv[1], NULL, 0); sentry.size = strtoul (argv[2], NULL, 0); for (sentry.type = 0; sentry.type < MTRR_NUM_TYPES; ++sentry.type) { if (strcmp (argv[3], mtrr_strings[sentry.type]) == 0) break; } if (sentry.type >= MTRR_NUM_TYPES) { fprintf (stderr, "Illegal type: \"%s\"\n", argv[3]); exit (2); } if ( ( fd = open ("/proc/mtrr", O_WRONLY, 0) ) == -1 ) { if (errno == ENOENT) { fputs ("/proc/mtrr not found: not supported or you don't have a PPro?\n", stderr); exit (3); } fprintf (stderr, "Error opening /proc/mtrr\t%s\n", ERRSTRING); exit (4); } if (ioctl (fd, MTRRIOC_ADD_ENTRY, &sentry) == -1) { fprintf (stderr, "Error doing ioctl(2) on /dev/mtrr\t%s\n", ERRSTRING); exit (5); } fprintf (stderr, "Sleeping for 5 seconds so you can see the new entry\n"); sleep (5); close (fd); fputs ("I've just closed /proc/mtrr so now the new entry should be gone\n", stderr); } /* End Function main */”…””}”hjÕsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j;h³hÇh´KúhjÄh²hubeh}”(h]”Œ/creating-mtrrs-from-a-c-programme-using-ioctl-s”ah ]”h"]”Œ1creating mtrrs from a c programme using ioctl()'s”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K÷ubeh}”(h]”Œ'mtrr-memory-type-range-register-control”ah ]”h"]”Œ)mtrr (memory type range register) control”ah$]”h&]”uh1hÈhhh²hh³hÇh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÇuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hÍNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÇŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jðjíj'j$jøjõjWjTjšj—jÁj¾jèjåuŒ nametypes”}”(jð‰j'‰jø‰jW‰jš‰jÁ‰jè‰uh}”(jíhÊj$jyjõj*jTjûj—jZj¾jjåjÄuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.