Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\kernel\cpu\mtrr\mtrr.c Create Date:2022-07-28 08:05:08
Last Modify:2022-05-18 17:35:08 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:mtrr_add_page - Add a memory type region*@base: Physical base address of region in pages (in units of 4 kB!)*@size: Physical size of region in pages (4 kB)*@type: Type of MTRR desired*@increment: If this is true do usage counting on the region* Memory

Proto:int mtrr_add_page(unsigned long base, unsigned long size, unsigned int type, bool increment)

Type:int

Parameter:

TypeParameterName
unsigned longbase
unsigned longsize
unsigned inttype
boolincrement
308  If Not mtrr_enabled() Then Return -ENXIO
311  error = validate_add_page(base, size, type)
312  If error Then Return error
315  If type >= MTRR_NUM_TYPES Then
316  pr_warn("type: %u invalid\n", type)
317  Return -EINVAL
321  If type == MTRR_TYPE_WRCOMB && Not Returns non-zero if we have the write-combining memory type Then
322  pr_warn("your processor doesn't support write-combining\n")
323  Return -ENOSYS
326  If Not size Then
327  pr_warn("zero sized request\n")
328  Return -EINVAL
331  If (base | base + size - 1 ) >> x86_phys_bits - PAGE_SHIFT determines the page size Then
333  pr_warn("base or size exceeds the MTRR width\n")
334  Return -EINVAL
337  error = -EINVAL
338  replace = -1
341  get_online_cpus()
344  mutex_lock( & mtrr_mutex)
345  When i < num_var_ranges cycle
346  get(i, & lbase, & lsize, & ltype)
347  If Not lsize || base > lbase + lsize - 1 || base + size - 1 < lbase Then Continue
354  If base < lbase || base + size - 1 > lbase + lsize - 1 Then
355  If base <= lbase && base + size - 1 >= lbase + lsize - 1 Then
358  If type == ltype Then
359  replace = If replace == -1 Then i Else -2
360  Continue
361  Else if types_compatible(type, ltype) Then Continue
364  pr_warn("0x%lx000,0x%lx000 overlaps existing 0x%lx000,0x%lx000\n", base, size, lbase, lsize)
366  Go to out
369  If ltype != type Then
370  If types_compatible(type, ltype) Then Continue
372  pr_warn("type mismatch for %lx000,%lx000 old: %s new: %s\n", base, size, mtrr_attrib_to_str(ltype), mtrr_attrib_to_str(type))
375  Go to out
377  If increment Then ++mtrr_usage_table[i]
379  error = i
380  Go to out
383  i = get_free_region(base, size, replace)
384  If i >= 0 Then
385  set_mtrr_cpuslocked(i, base, size, type)
387  mtrr_usage_table[i] = 1
388  Else
390  If increment Then mtrr_usage_table[i]++
397  Else
398  pr_info("no more MTRRs available\n")
400  error = i
401  out :
402  mutex_unlock( & mtrr_mutex)
403  put_online_cpus()
404  Return error
Caller
NameDescribe
mtrr_addmtrr_add - Add a memory type region*@base: Physical base address of region*@size: Physical size of region*@type: Type of MTRR desired*@increment: If this is true do usage counting on the region* Memory type region registers control the caching on newer
mtrr_file_add
mtrr_writeseq_file can seek but we ignore it.* Format of control line:* "base=%Lx size=%Lx type=%s" or "disable=%d"
mtrr_ioctl