Message ID | E1b9xsE-0003sO-FZ@e0050434b2927.dyn.armlinux.org.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 06/06/16 at 05:59pm, Russell King wrote: > diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c > new file mode 100644 > index 0000000..a4952ff > --- /dev/null > +++ b/kexec/mem_regions.c > @@ -0,0 +1,30 @@ > +#include "kexec.h" > +#include "mem_regions.h" > + > +/** > + * mem_regions_add() - add a memory region to a set of ranges > + * @ranges: ranges to add the memory region to > + * @max: maximum number of entries in memory region This need be removed. It should be a remnant of intermediate attempt. > + * @base: base address of memory region > + * @length: length of memory region in bytes > + * @type: type of memory region > + * > + * Add the memory region to the set of ranges, and return %0 if successful, > + * or %-1 if we ran out of space. > + */ > +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base, > + unsigned long long length, int type) > +{ > + struct memory_range *range; > + > + if (ranges->size >= ranges->max_size) > + return -1; > + > + range = ranges->ranges + ranges->size++; > + range->start = base; > + range->end = base + length - 1; > + range->type = type; > + > + return 0; > +} > + > diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h > new file mode 100644 > index 0000000..b9cfba1 > --- /dev/null > +++ b/kexec/mem_regions.h > @@ -0,0 +1,9 @@ > +#ifndef MEM_REGIONS_H > +#define MEM_REGIONS_H > + > +struct memory_ranges; > + > +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base, > + unsigned long long length, int type); > + > +#endif > -- > 1.9.1 >
On Wed, Jun 08, 2016 at 09:13:44AM +0800, Baoquan He wrote: > On 06/06/16 at 05:59pm, Russell King wrote: > > diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c > > new file mode 100644 > > index 0000000..a4952ff > > --- /dev/null > > +++ b/kexec/mem_regions.c > > @@ -0,0 +1,30 @@ > > +#include "kexec.h" > > +#include "mem_regions.h" > > + > > +/** > > + * mem_regions_add() - add a memory region to a set of ranges > > + * @ranges: ranges to add the memory region to > > + * @max: maximum number of entries in memory region > > This need be removed. It should be a remnant of intermediate attempt. Russell, Please fix this as a follow-up patch as I applied the series earlier this morning. > > + * @base: base address of memory region > > + * @length: length of memory region in bytes > > + * @type: type of memory region > > + * > > + * Add the memory region to the set of ranges, and return %0 if successful, > > + * or %-1 if we ran out of space. > > + */ > > +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base, > > + unsigned long long length, int type) > > +{ > > + struct memory_range *range; > > + > > + if (ranges->size >= ranges->max_size) > > + return -1; > > + > > + range = ranges->ranges + ranges->size++; > > + range->start = base; > > + range->end = base + length - 1; > > + range->type = type; > > + > > + return 0; > > +} > > + > > diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h > > new file mode 100644 > > index 0000000..b9cfba1 > > --- /dev/null > > +++ b/kexec/mem_regions.h > > @@ -0,0 +1,9 @@ > > +#ifndef MEM_REGIONS_H > > +#define MEM_REGIONS_H > > + > > +struct memory_ranges; > > + > > +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base, > > + unsigned long long length, int type); > > + > > +#endif > > -- > > 1.9.1 > > > > _______________________________________________ > kexec mailing list > kexec@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec >
diff --git a/kexec/Makefile b/kexec/Makefile index a758b4a..e2aee84 100644 --- a/kexec/Makefile +++ b/kexec/Makefile @@ -69,6 +69,10 @@ dist += kexec/fs2dt.c kexec/fs2dt.h $(ARCH)_FS2DT = KEXEC_SRCS += $($(ARCH)_FS2DT) +dist += kexec/mem_regions.c kexec/mem_regions.h +$(ARCH)_MEM_REGIONS = +KEXEC_SRCS += $($(ARCH)_MEM_REGIONS) + include $(srcdir)/kexec/arch/alpha/Makefile include $(srcdir)/kexec/arch/arm/Makefile include $(srcdir)/kexec/arch/i386/Makefile diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c new file mode 100644 index 0000000..a4952ff --- /dev/null +++ b/kexec/mem_regions.c @@ -0,0 +1,30 @@ +#include "kexec.h" +#include "mem_regions.h" + +/** + * mem_regions_add() - add a memory region to a set of ranges + * @ranges: ranges to add the memory region to + * @max: maximum number of entries in memory region + * @base: base address of memory region + * @length: length of memory region in bytes + * @type: type of memory region + * + * Add the memory region to the set of ranges, and return %0 if successful, + * or %-1 if we ran out of space. + */ +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base, + unsigned long long length, int type) +{ + struct memory_range *range; + + if (ranges->size >= ranges->max_size) + return -1; + + range = ranges->ranges + ranges->size++; + range->start = base; + range->end = base + length - 1; + range->type = type; + + return 0; +} + diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h new file mode 100644 index 0000000..b9cfba1 --- /dev/null +++ b/kexec/mem_regions.h @@ -0,0 +1,9 @@ +#ifndef MEM_REGIONS_H +#define MEM_REGIONS_H + +struct memory_ranges; + +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base, + unsigned long long length, int type); + +#endif