€•ƒŒ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Œ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”“”)”}”(hhòh]”(hŒRichard Gooch <”…””}”(hhöhžhhŸNh NubhŒ reference”“”)”}”(hŒrgooch@atnf.csiro.au”h]”hŒrgooch@atnf.csiro.au”…””}”(hhÿhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:rgooch@atnf.csiro.au”uh1hýhhöubhŒ> - 3 Jun 1999”…””}”(hhöhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hôhŸh³h Khhðubah}”(h]”h ]”h"]”h$]”h&]”uh1hîhhëubhï)”}”(hŒ=Luis R. Rodriguez - April 9, 2015 ”h]”hõ)”}”(hŒ;Luis R. Rodriguez - April 9, 2015”h]”(hŒLuis R. Rodriguez <”…””}”(hj#hžhhŸNh Nubhþ)”}”(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”uh1hýhj#ubhŒ> - April 9, 2015”…””}”(hj#hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hôhŸh³h Khjubah}”(h]”h ]”h"]”h$]”h&]”uh1hîhhë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”…””}”(hjhhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hjehžhhŸh³h K ubhõ)”}”(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.”…””}”(hjvhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hôhŸh³h Khjehžhubhõ)”}”(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&]”uh1hôhŸh³h Khjehžhubhõ)”}”(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&]”uh1hôhŸh³h Khjehž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]”(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.”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&]”uh1hôhŸh³h K"hj¢ubhõ)”}”(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&]”uh1hôhŸh³h K*hj¢ubhõ)”}”(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&]”uh1hôhŸh³h K.hj¢ubhõ)”}”(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&]”uh1hôhŸh³h K2hj¢ubhõ)”}”(hŒ! /proc/mtrr”h]”hŒI# echo "base=0xf8000000 size=0x400000 type=write-combining" >! /proc/mtrr”…””}”hjEsbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1j'hŸh³h KNhjhžhubhõ)”}”(hŒor if you use bash::”h]”hŒor if you use bash:”…””}”(hjShžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hôhŸh³h KPhjhž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”…””}”hjasbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1j'hŸh³h KRhjhžhubhõ)”}”(hŒAnd the result thereof::”h]”hŒAnd the result thereof:”…””}”(hjohžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hôhŸh³h KThjhž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 KVhjhžhubhõ)”}”(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&]”uh1hôhŸh³h K[hjhž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`hjhžhubhõ)”}”(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&]”uh1hôhŸh³h Kbhjhžhubhõ)”}”(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&]”uh1hôhŸh³h Kfhjhžhubj()”}”(hŒ(--) S3: videoram: 4096k”h]”hŒ(--) S3: videoram: 4096k”…””}”hjÃsbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1j'hŸh³h Kihjhžhubhõ)”}”(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&]”uh1hôhŸh³h Kkhjhž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žhubhõ)”}”(hŒAnd the results::”h]”hŒAnd the results:”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hôhŸ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”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1j'hŸh³h K{hjçhžhubhõ)”}”(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.”…””}”(hj"hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hôhŸh³h K€hjçhžhubhõ)”}”(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.”…””}”(hj0hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hôhŸ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”…””}”(hjIhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hjFhžhhŸh³h K‰ubj()”}”(hŒ % echo "disable=2" >! /proc/mtrr”h]”hŒ % echo "disable=2" >! /proc/mtrr”…””}”hjWsbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1j'hŸh³h KŒhjFhžhubhõ)”}”(hŒor using bash::”h]”hŒor using bash:”…””}”(hjehžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hôhŸh³h KŽhjFhžhubj()”}”(hŒ % echo "disable=2" >| /proc/mtrr”h]”hŒ % echo "disable=2" >| /proc/mtrr”…””}”hjssbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1j'hŸh³h KhjFhž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¹hj‰hž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—hj‰hž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ÙjjjäjájCj@j†jƒj­jªjÔjÑuŒ nametypes”}”(j܉j‰jä‰jC‰j†‰j­‰jÔ‰uh}”(jÙh¶jjejájj@jçjƒjFjªj‰jÑ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.