mirror of
https://github.com/drasko/codezero.git
synced 2026-04-28 22:51:31 +02:00
Sanity checking for container memory regions added
This commit is contained in:
6
build.py
6
build.py
@@ -11,6 +11,7 @@ import os, sys, shelve, shutil
|
|||||||
from os.path import join
|
from os.path import join
|
||||||
from config.projpaths import *
|
from config.projpaths import *
|
||||||
from config.configuration import *
|
from config.configuration import *
|
||||||
|
from config.config_check import *
|
||||||
from scripts.conts import containers
|
from scripts.conts import containers
|
||||||
from configure import *
|
from configure import *
|
||||||
|
|
||||||
@@ -21,6 +22,11 @@ def main():
|
|||||||
#
|
#
|
||||||
configure_system(opts, args)
|
configure_system(opts, args)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for sanity of containers
|
||||||
|
#
|
||||||
|
sanity_check_conts()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build userspace libraries
|
# Build userspace libraries
|
||||||
#
|
#
|
||||||
|
|||||||
54
config/config_check.py
Normal file
54
config/config_check.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#! /usr/bin/env python2.6
|
||||||
|
# -*- mode: python; coding: utf-8; -*-
|
||||||
|
import os, sys, re
|
||||||
|
|
||||||
|
from projpaths import *
|
||||||
|
from lib import *
|
||||||
|
|
||||||
|
def get_conts_memory_regions(phys_virt, array_start, array_end):
|
||||||
|
with open(join(PROJROOT, CONFIG_H), 'r')as file:
|
||||||
|
for line in file:
|
||||||
|
begin = line.rfind(" ")
|
||||||
|
end = len(line)
|
||||||
|
if re.search("(" + phys_virt + ")([0-9]){1,4}(_START)", line):
|
||||||
|
array_start.append(int(line[begin : end], 16))
|
||||||
|
elif re.search("(" + phys_virt + ")([0-9]){1,4}(_END)", line):
|
||||||
|
array_end.append(int(line[begin : end], 16))
|
||||||
|
|
||||||
|
def check_memory_overlap(phys_virt, array_start, array_end):
|
||||||
|
length = len(array_start)
|
||||||
|
# Brute force method
|
||||||
|
for index, s1 in enumerate(array_start):
|
||||||
|
e1 = array_end[index]
|
||||||
|
iter = 0
|
||||||
|
while iter < length:
|
||||||
|
if index == iter:
|
||||||
|
iter = iter + 1
|
||||||
|
continue
|
||||||
|
if ((s1 <= array_start[iter]) and \
|
||||||
|
((e1 >= array_end[iter]) or (array_start[iter] < e1 <= array_end[iter]))):
|
||||||
|
print 'Memory overlap between containers!!!'
|
||||||
|
print 'overlapping ranges: '+ \
|
||||||
|
conv_hex(s1) + '-' + conv_hex(e1) + ' and ' + \
|
||||||
|
conv_hex(array_start[iter]) + '-' + conv_hex(array_end[iter])
|
||||||
|
print '\n'
|
||||||
|
sys.exit()
|
||||||
|
else:
|
||||||
|
iter = iter + 1
|
||||||
|
|
||||||
|
def phys_region_sanity_check():
|
||||||
|
phys_start = []
|
||||||
|
phys_end = []
|
||||||
|
get_conts_memory_regions('PHYS', phys_start, phys_end)
|
||||||
|
check_memory_overlap('PHYS', phys_start, phys_end)
|
||||||
|
|
||||||
|
def virt_region_sanity_check():
|
||||||
|
virt_start = []
|
||||||
|
virt_end = []
|
||||||
|
get_conts_memory_regions('VIRT', virt_start, virt_end)
|
||||||
|
check_memory_overlap('VIRT', virt_start, virt_end)
|
||||||
|
|
||||||
|
def sanity_check_conts():
|
||||||
|
phys_region_sanity_check()
|
||||||
|
virt_region_sanity_check()
|
||||||
|
|
||||||
Reference in New Issue
Block a user